Пример #1
0
 void ResetLayout_Click(object sender, RoutedEventArgs e)
 {
     if (Inbox2MessageBox.Show(Strings.ThisWillResetLayout, Inbox2MessageBoxButton.YesNo).Result == Inbox2MessageBoxResult.Yes)
     {
         resetLayout = true;
     }
 }
Пример #2
0
 void ResetDialogs_Click(object sender, RoutedEventArgs e)
 {
     if (Inbox2MessageBox.Show(Strings.ThisWillResetDialogs, Inbox2MessageBoxButton.YesNo).Result == Inbox2MessageBoxResult.Yes)
     {
         ClientState.Current.Context.DeleteSetting("/Settings/Dialogs/DeleteConversation");
     }
 }
Пример #3
0
		void CheckDefaultMailClientState()
		{
			var settings = SettingsManager.ClientSettings.AppConfiguration;

			if (!settings.IsJustRegistered && settings.IsDefaultMailClientCheckEnabled)
			{
				// Check if Inbox2 is the default mail client
				var handler = new DefaultMailClientHandler();

				if (!handler.IsDefaultMailClient())
				{
					var result = Inbox2MessageBox.Show(Strings.NotYourDefaultMailClient, Inbox2MessageBoxButton.YesNo,
													   Strings.AlwaysPerformThisCheckDuringStartup, true);

					settings.IsDefaultMailClientCheckEnabled = result.DoNotAskAgainResult;
					SettingsManager.Save();

					if (result.Result == Inbox2MessageBoxResult.Yes)
					{
						var executable = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "Inbox2DefaultMailClient.exe");

						try
						{
							// Start set default mail client process as administrator if needed
							new Process { StartInfo = new ProcessStartInfo(executable) { UseShellExecute = true, Verb = "runas" } }.Start();
						}
						catch (Exception ex)
						{
							Logger.Error("An error has occured while trying to start process. Exception = {0}", LogSource.UI, ex);
						}
					}
				}
			}
		}
Пример #4
0
        bool CanChannelReply()
        {
            var channel = SelectedMessage.SourceChannel;

            if (channel != null)
            {
                if (!channel.Charasteristics.CanReply)
                {
                    var sb  = new StringBuilder();
                    var url = channel.ProfileInfoBuilder.InboxUrl;

                    sb.AppendFormat(Strings.ChannelDoesNotSupportReply, channel.DisplayName);

                    if (!String.IsNullOrEmpty(url))
                    {
                        sb.AppendFormat(" " + Strings.ClickOkToReplyOn, channel.DisplayName);

                        if (Inbox2MessageBox.Show(sb.ToString(), Inbox2MessageBoxButton.OKCancel).Result == Inbox2MessageBoxResult.OK)
                        {
                            new Process {
                                StartInfo = new ProcessStartInfo(url)
                            }.Start();
                        }
                    }
                    else
                    {
                        Inbox2MessageBox.Show(sb.ToString(), Inbox2MessageBoxButton.OK);
                    }

                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        /// Handles the Click event of the ChannelSetupFinishButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        void ChannelSetupFinishButton_Click(object sender, RoutedEventArgs e)
        {
            bool isValid = true;

            if (String.IsNullOrEmpty(DisplayNameTextBox.Text.Trim()))
            {
                isValid = false;
                Inbox2MessageBox.Show("Please enter your full name", Inbox2MessageBoxButton.OK);
            }

            if (HasConfiguredChannels && isValid)
            {
                // Save Default Channel
                var defaultChannel = DefaultEmailAddressComboBox.SelectedItem as ChannelConfiguration;
                defaultChannel.IsDefault = true;
                ClientState.Current.DataService.ExecuteNonQuery(
                    String.Format("update ChannelConfigs set IsDefault='{0}' where ChannelConfigId={1}",
                                  defaultChannel.IsDefault, defaultChannel.ChannelId));

                // Do nothing if none of the channels has been validated
                SettingsManager.ClientSettings.AppConfiguration.Fullname = DisplayNameTextBox.Text;
                SettingsManager.ClientSettings.AppConfiguration.IsChannelSetupFinished = true;
                SettingsManager.Save();

                // Start receiving data on our newly initialized channels
                EventBroker.Publish(AppEvents.RequestReceive);
                EventBroker.Publish(AppEvents.RequestSync);

                // Run startup logic again
                ((ViewController)ClientState.Current.ViewController).Startup();
            }
        }
Пример #6
0
        /// <summary>
        /// User clicks on the load all messages button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void LoadAllMessages_Click(object sender, RoutedEventArgs e)
        {
            ClientStats.LogEvent("Load all messages in overview");

            if (Inbox2MessageBox.Show(Strings.ThisCouldTakeALongTime, Inbox2MessageBoxButton.YesNo).Result == Inbox2MessageBoxResult.Yes)
            {
                // todo mwa
                //if (((TaskQueue)ClientState.Current.TaskQueue).ProcessingPool.HasRunning<ReceiveTask>())
                //{
                //    // Let current send/receive finish
                //    IEventReg subscription = null;

                //    subscription = EventBroker.Subscribe(AppEvents.ReceiveFinished, delegate
                //        {
                //            EventBroker.Unregister(subscription);

                //            RunReceive();
                //        });
                //}

                RunReceive();

                EventBroker.Publish(AppEvents.RequestReceive, Int32.MaxValue);
                EventBroker.Subscribe(AppEvents.ReceiveFinished, () => Thread.CurrentThread.ExecuteOnUIThread(ReceiveFinished));

                SettingsManager.ClientSettings.AppConfiguration.IsJustRegistered     = false;
                SettingsManager.ClientSettings.AppConfiguration.IsLoadingAllMessages = true;
                SettingsManager.Save();

                LoadAllMesagesBorder.Visibility    = Visibility.Collapsed;
                LoadingAllMesagesBorder.Visibility = Visibility.Visible;
            }
        }
Пример #7
0
        public bool TrySave()
        {
            bool failure = false;

            foreach (var config in channelsToDelete)
            {
                var task = new RemoveChannelTask(config);

                task.FinishedFailure += delegate { failure = true; };
                task.Finished        += delegate { Thread.CurrentThread.ExecuteOnUIThread(() => ClientState.Current.ViewController.HidePopup()); };
                task.ExecuteAsync();

                ClientState.Current.ViewController.ShowPopup(new ModalWaitControl {
                    Message = String.Format(Strings.RemovingAccount, config.InputChannel.Authentication.Username)
                });

                if (failure)
                {
                    Inbox2MessageBox.Show(
                        String.Format(Strings.AnErrorHasOccuredWhileDeletingAccount, config.InputChannel.Authentication.Username),
                        Inbox2MessageBoxButton.OK);

                    return(false);
                }
            }

            OnPropertyChanged("ChannelConfigurations");

            return(true);
        }
Пример #8
0
        /// <summary>
        /// Handles the Click event of the ChannelDeleteButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        void ChannelDeleteButton_Click(object sender, RoutedEventArgs e)
        {
            var configuration =
                (e.OriginalSource as DependencyObject).FindListViewItem <ChannelConfiguration>(
                    ChannelConfigurationsListView.ItemContainerGenerator);

            Inbox2MessageBoxResultWrapper result;

            if (configuration.IsConnected)
            {
                // Cloud
                result = Inbox2MessageBox.Show(String.Concat(Strings.AreYouSureYouWantToRemoveThisAccount, Strings.AccountWillAlsoBeRemovedFromCloud), Inbox2MessageBoxButton.YesNo);
            }
            else
            {
                // Local
                result = Inbox2MessageBox.Show(Strings.AreYouSureYouWantToRemoveThisAccount, Inbox2MessageBoxButton.YesNo);
            }

            if (result.Result == Inbox2MessageBoxResult.Yes)
            {
                channelsToDelete.Add(configuration);

                var configurations = ChannelConfigurationsListView.ItemsSource as IEnumerable <ChannelConfiguration>;
                configurations = configurations.Where(c => c.ChannelId != configuration.ChannelId);
                ChannelConfigurationsListView.ItemsSource = configurations;

                OnPropertyChanged("AllChannelConfigurations");
                OnPropertyChanged("ChannelConfiguration");
            }
        }
Пример #9
0
        void CheckNow_Click(object sender, RoutedEventArgs e)
        {
            // Check if Inbox2 is the default mail client
            var handler = new DefaultMailClientHandler();

            if (!handler.IsDefaultMailClient())
            {
                var result = Inbox2MessageBox.Show(Strings.NotYourDefaultMailClient, Inbox2MessageBoxButton.YesNo);

                if (result.Result == Inbox2MessageBoxResult.Yes)
                {
                    var executable = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "Inbox2DefaultMailClient.exe");

                    try
                    {
                        // Start set default mail client process as administrator if needed
                        new Process {
                            StartInfo = new ProcessStartInfo(executable)
                            {
                                UseShellExecute = true, Verb = "runas"
                            }
                        }.Start();
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("An error has occured while trying to start process. Exception = {0}", LogSource.UI, ex);
                    }
                }
            }
            else
            {
                Inbox2MessageBox.Show(Strings.AlreadyDefaultMailClient, Inbox2MessageBoxButton.OK);
            }
        }
Пример #10
0
        /// <summary>
        /// User clicks on the load all messages button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void LoadAllMessages_Click(object sender, RoutedEventArgs e)
        {
            if (Inbox2MessageBox.Show(Strings.ThisCouldTakeALongTime, Inbox2MessageBoxButton.YesNo).Result == Inbox2MessageBoxResult.Yes)
            {
                // todo mwa
                // Cancel any running receive tasks
                //if (((TaskQueue)ClientState.Current.TaskQueue).ProcessingPool.HasRunning<ReceiveTask>())
                //{
                //    // Let current send/receive finish
                //    IEventReg subscription = null;

                //    subscription = EventBroker.Subscribe(AppEvents.ReceiveFinished, delegate
                //        {
                //            EventBroker.Unregister(subscription);

                //            RunReceive();
                //        });
                //}

                RunReceive();

                SettingsManager.ClientSettings.AppConfiguration.IsLoadingAllMessages = true;
                SettingsManager.Save();

                LoadAllMessagesButton.IsEnabled = false;
            }
        }
Пример #11
0
        public bool TrySave()
        {
            bool isValid = true;

            // Save Fullname
            if (!String.IsNullOrEmpty(DisplayNameTextBox.Text.Trim()))
            {
                SettingsManager.ClientSettings.AppConfiguration.Fullname = DisplayNameTextBox.Text;
            }
            else
            {
                Inbox2MessageBox.Show("Please enter a display name", Inbox2MessageBoxButton.OK);

                isValid = false;
            }

            // Save Signature
            if (isValid)
            {
                SettingsManager.ClientSettings.AppConfiguration.Signature       = SignatureTextBox.Text;
                SettingsManager.ClientSettings.AppConfiguration.IsStatsDisabled = IsStatsDisabledCheckBox.IsChecked ?? false;
                SettingsManager.ClientSettings.AppConfiguration.IsDefaultMailClientCheckEnabled = IsDefaultEmailClientCheckBox.IsChecked ?? false;
            }

            if (isValid)
            {
                if (HasMailChannelConfigured && DefaultEmailAddressComboBox.HasItems)
                {
                    // If no default e-mail address has been selected, select the first one
                    if (DefaultEmailAddressComboBox.SelectedItem == null)
                    {
                        DefaultEmailAddressComboBox.SelectedIndex = 0;
                    }

                    // Get the selected default e-mail address
                    var defaultChannel = (ChannelConfiguration)DefaultEmailAddressComboBox.SelectedItem;

                    // First set all channels to false status
                    ChannelsManager.Channels.Select(c => c.Configuration).ForEach(c => c.IsDefault = false);

                    // Set the channel to default
                    defaultChannel.IsDefault = true;

                    // Update database
                    ClientState.Current.DataService.ExecuteNonQuery(String.Format("update ChannelConfigs set IsDefault='{0}'", false));
                    ClientState.Current.DataService.ExecuteNonQuery(
                        String.Format("update ChannelConfigs set IsDefault='{0}' where ChannelConfigId={1}",
                                      defaultChannel.IsDefault, defaultChannel.ChannelId));
                }
            }

            return(isValid);
        }
Пример #12
0
        internal void DeleteStreamSelection()
        {
            using (new ListViewIndexFix(StreamListView))
            {
                // Outlook style
                if (!SettingsManager.ClientSettings.AppConfiguration.RollUpConversations)
                {
                    State.Delete();

                    return;
                }

                // Single line view
                if (!viewFilter.Filter.IsActivityViewVisible)
                {
                    State.Delete(true);

                    return;
                }

                if (State.SelectedMessages.Any(m => m.Conversation.Messages.Count > 1))
                {
                    Inbox2MessageBoxResult result = SettingsManager.SettingOrDefault("/Settings/Dialogs/DeleteConversation", Inbox2MessageBoxResult.None);

                    if (result == Inbox2MessageBoxResult.None)
                    {
                        var wrapper = Inbox2MessageBox.Show(Strings.AlsoDeleteConversations, Inbox2MessageBoxButton.Conversation, Strings.DoNotAskAgain);

                        if (wrapper.Result == Inbox2MessageBoxResult.Cancel)
                        {
                            return;
                        }

                        // Save setting
                        if (wrapper.DoNotAskAgainResult)
                        {
                            ClientState.Current.Context.SaveSetting("/Settings/Dialogs/DeleteConversation", wrapper.Result);
                        }

                        result = wrapper.Result;
                    }

                    if (result == Inbox2MessageBoxResult.Conversation)
                    {
                        State.Delete(true);
                        return;
                    }
                }

                // No need to ask or just delete single message
                State.Delete();
            }
        }
        void Task_FinishedFailure(object sender, EventArgs e)
        {
            var task = (BackgroundTask)sender;

            Thread.CurrentThread.ExecuteOnUIThread(delegate
            {
                ClientStats.LogEvent("Check credentials failure - general error (setup)");

                Inbox2MessageBox.Show(String.Concat(
                                          String.Format(Strings.AddingAccountFailed, ChannelConfiguration.DisplayName),
                                          ", ", task.LastException.Message), Inbox2MessageBoxButton.OK);

                FailureCount++;
            });
        }
Пример #14
0
        public void Remove(string keyword)
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                Inbox2MessageBox.Show(Strings.OperationCouldNotBeCompletedDueToConnection, Inbox2MessageBoxButton.OK);
                return;
            }

            BuildKeywordsCache();

            lock (synclock)
            {
                cached.Remove(keyword.ToLower());

                ClientState.Current.Context.SaveSetting("/Settings/MailBox/SearchKeyword", cached);
            }
        }
Пример #15
0
        void Window_Closing(object sender, CancelEventArgs e)
        {
            var controller = (ViewController)ClientState.Current.ViewController;

            if (!controller.CanShutdown())
            {
                if (Inbox2MessageBox.Show(Strings.AreYouSureYouWantToExit, Inbox2MessageBoxButton.YesNo).Result == Inbox2MessageBoxResult.No)
                {
                    e.Cancel = true;

                    return;
                }
            }

            ApplicationHostControl.Shutdown();

            Application.Current.Shutdown();
        }
        void Close_Click(object sender, RoutedEventArgs e)
        {
            ClientStats.LogEvent("Close realtime streams overview column");

            if (ChannelsManager.GetStatusChannels().Count() > 0)
            {
                if (Inbox2MessageBox.Show(Strings.AreYouSureYouWantToCloseColumn, Inbox2MessageBoxButton.YesNo).Result == Inbox2MessageBoxResult.No)
                {
                    return;
                }

                EventBroker.Publish(AppEvents.RebuildToolbar);
            }

            SettingsManager.ClientSettings.AppConfiguration.ShowStreamColumn = false;

            EventBroker.Publish(AppEvents.RebuildOverview);
        }
Пример #17
0
        void EmptyTrash_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            ClientStats.LogEvent("Empty trash");

            if (Inbox2MessageBox.Show(Strings.SureYouWantToEmptyTrash, Inbox2MessageBoxButton.YesNo).Result == Inbox2MessageBoxResult.Yes)
            {
                List <Message> trashed;

                using (mailbox.Messages.ReaderLock)
                    trashed = mailbox.Messages.Where(m => m.IsTrash).ToList();

                trashed.ForEach(m => m.Purge());

                viewFilter.RebuildCurrentViewAsync();

                EventBroker.Publish(AppEvents.RequestReceive);
            }
        }
Пример #18
0
        void ValidateCredentials()
        {
            if (channel.CredentialsProvider.CanValidateCredentials)
            {
                // Use credentialsprovider if it is capable
                channel.CredentialsProvider.ValidateCredentials();
            }
            else
            {
                var result = channel.Connect();

                channel.Disconnect();

                if (result != ConnectResult.Success)
                {
                    Inbox2MessageBox.Show(ExceptionHelper.BuildChannelError(channel, result, false), Inbox2MessageBoxButton.OK);

                    throw new ChannelAuthenticationException();
                }
            }
        }
        void Task_FinishedSuccess(object sender, EventArgs e)
        {
            var task = (IContextTask)sender;

            Thread.CurrentThread.ExecuteOnUIThread(delegate
            {
                // Make sure this channel has not allready been configured (if not in edit mode)
                string username = (ChannelConfiguration.Charasteristics.CanCustomize && IsManuallyCustomized) ? ManualEntryIncomingUsername : Username;
                if (!IsInEditModus && ChannelsManager.Channels.Any(
                        c => c.Configuration.DisplayName == ChannelConfiguration.DisplayName && c.Configuration.InputChannel.Authentication.Username == username))
                {
                    ClientStats.LogEvent("Check credentials failure - duplicate account (setup)");

                    Inbox2MessageBox.Show(Strings.AccountAlreadyAdded, Inbox2MessageBoxButton.OK);
                }
                else
                {
                    ClientStats.LogEvent("Check credentials success (setup)");

                    IsValidated            = true;
                    CheckCanvas.Visibility = Visibility.Visible;

                    if (IsInEditModus)
                    {
                        UpdateChannel();
                    }
                    else
                    {
                        SaveChannel(task.Values);
                    }

                    if (OnValidationFinished != null)
                    {
                        OnValidationFinished(this, EventArgs.Empty);
                    }
                }
            });
        }
        public void TryCancel()
        {
            if (IsDraft)
            {
                if (Inbox2MessageBox.Show("Cancel and move draft to trash folder?", Inbox2MessageBoxButton.YesNo).Result == Inbox2MessageBoxResult.No)
                {
                    return;
                }
                else
                {
                    CancelDraft();
                }
            }
            else if (HasMessageContent(true))
            {
                if (Inbox2MessageBox.Show("Cancel and lose all changes?", Inbox2MessageBoxButton.YesNo).Result == Inbox2MessageBoxResult.No)
                {
                    return;
                }
            }

            CloseEditor();
        }
        /// <summary>
        /// Creates the redirect.
        /// </summary>
        void CreateRedirect()
        {
            // Create an instance of the InputChannel and check the provided credentials
            var window = new ChannelSetupRedirectWindow(ChannelConfiguration, false);

            window.ShowDialog();

            if (window.Success.HasValue)
            {
                if (window.Success ?? false)
                {
                    token       = window.Token;
                    tokenSecret = window.TokenSecret;

                    // Control is hidden anyway so doesn't matter that we use it for temporarily storing results.
                    // Value of this field if picked up again in the ValidateCredentials method.
                    PincodeTextBox.Text = window.LastUri.ToString();

                    ValidateCredentials();
                }
                else
                {
                    Inbox2MessageBox.Show(String.Format(Strings.AddingAccountFailed, ChannelConfiguration.DisplayName), Inbox2MessageBoxButton.OK);

                    FailureCount++;
                }
            }
            else
            {
                // Close setup control if we didn't get a result (user closed popup window)
                if (OnCancel != null)
                {
                    OnCancel(this, EventArgs.Empty);
                }
            }
        }
        /// <summary>
        /// Checks the user input.
        /// </summary>
        void CheckUserInput()
        {
            ClientStats.LogEventWithSegment("Check user credentials (setup)", ChannelConfiguration.DisplayName);

            bool isValid = true;

            if (IsValidated && !IsInEditModus)
            {
                return;
            }

            if (IsChecking)
            {
                Inbox2MessageBox.Show("Credentials are being validated.", Inbox2MessageBoxButton.OK);
                return;
            }

            if (ChannelConfiguration == null)
            {
                Inbox2MessageBox.Show("No credentials configured.", Inbox2MessageBoxButton.OK);
                return;
            }

            if (ChannelConfiguration.DisplayStyle == DisplayStyle.Other ||
                (ChannelConfiguration.Charasteristics.CanCustomize && IsManuallyCustomized))
            {
                isValid =
                    !(String.IsNullOrEmpty(ManualEntryIncomingUsernameTextBox.Text) ||
                      String.IsNullOrEmpty(ManualEntryIncomingPasswordTextBox.Password) ||
                      String.IsNullOrEmpty(ManualEntryIncomingServerTextBox.Text) ||
                      String.IsNullOrEmpty(ManualEntryIncomingPortTextBox.Text) ||
                      String.IsNullOrEmpty(ManualEntryOutgoingUsernameTextBox.Text) ||
                      String.IsNullOrEmpty(ManualEntryOutgoingPasswordTextBox.Password) ||
                      String.IsNullOrEmpty(ManualEntryOutgoingServerTextBox.Text) ||
                      String.IsNullOrEmpty(ManualEntryOutgoingPortTextBox.Text));
            }
            else if (ChannelConfiguration.DisplayStyle == DisplayStyle.Advanced)
            {
                isValid =
                    !(String.IsNullOrEmpty(UsernameTextBox.Text) ||
                      String.IsNullOrEmpty(PasswordTextBox.Password) ||
                      String.IsNullOrEmpty(HostnameTextBox.Text));
            }
            else if (ChannelConfiguration.DisplayStyle == DisplayStyle.Simple)
            {
                isValid =
                    !(String.IsNullOrEmpty(UsernameTextBox.Text) ||
                      String.IsNullOrEmpty(PasswordTextBox.Password));
            }
            else if (ChannelConfiguration.DisplayStyle == DisplayStyle.RedirectWithPin)
            {
                isValid =
                    (PinGrid.Visibility == Visibility.Visible) ?
                    !String.IsNullOrEmpty(PincodeTextBox.Text) :
                    true;
            }

            if (!isValid)
            {
                Inbox2MessageBox.Show(Strings.PleaseFillConfigurationCorrectly, Inbox2MessageBoxButton.OK);
            }
            else
            {
                ValidateChannel();
            }
        }