Exemple #1
0
        static ChannelConfiguration BuildLocalChannel(ChannelConfig channel)
        {
            var configuration = AvailableChannels.First(c => c.DisplayName == channel.DisplayName).Clone();

            configuration.DisplayEnabled = true;
            configuration.ChannelId      = channel.ChannelConfigId.Value;
            configuration.IsDefault      = channel.IsDefault;

            if (configuration.DisplayStyle == DisplayStyle.Other ||
                channel.IsManuallyCustomized)
            {
                configuration.IsCustomized = channel.IsManuallyCustomized;

                ChannelBuilder.SetChannelAuthentication(channel.Username, channel.Password,
                                                        configuration.InputChannel,
                                                        configuration.ContactsChannel,
                                                        configuration.CalendarChannel,
                                                        configuration.StatusUpdatesChannel);

                configuration.InputChannel.Hostname      = channel.Hostname;
                configuration.InputChannel.TypeSurrogate = channel.Type;
                configuration.InputChannel.Port          = channel.Port ?? 0;
                configuration.InputChannel.IsSecured     = channel.SSL;

                ChannelBuilder.SetChannelAuthentication(
                    channel.OutgoingUsername, channel.OutgoingPassword, configuration.OutputChannel);

                configuration.OutputChannel.Hostname  = channel.OutgoingHostname;
                configuration.OutputChannel.Port      = channel.OutgoingPort ?? 0;
                configuration.OutputChannel.IsSecured = channel.OutgoingSSL;
            }
            else if (configuration.DisplayStyle == DisplayStyle.Advanced)
            {
                ChannelBuilder.SetChannelHostname(channel.Hostname, configuration.InputChannel,
                                                  configuration.OutputChannel, configuration.ContactsChannel,
                                                  configuration.CalendarChannel, configuration.StatusUpdatesChannel);

                ChannelBuilder.SetChannelAuthentication(channel.Username, channel.Password,
                                                        configuration.InputChannel,
                                                        configuration.OutputChannel, configuration.ContactsChannel,
                                                        configuration.CalendarChannel,
                                                        configuration.StatusUpdatesChannel);
            }
            else
            {
                ChannelBuilder.SetChannelAuthentication(channel.Username, channel.Password,
                                                        configuration.InputChannel,
                                                        configuration.OutputChannel, configuration.ContactsChannel,
                                                        configuration.CalendarChannel,
                                                        configuration.StatusUpdatesChannel);
            }

            return(configuration);
        }
        /// <summary>
        /// Validates the credentials.
        /// </summary>
        void ValidateCredentials()
        {
            if (!IsInEditModus)
            {
                CheckCanvas.Visibility = Visibility.Collapsed;
            }

            LoaderCanvas.Visibility = Visibility.Visible;
            IsChecking = true;

            #region Set channel authentication

            if (ChannelConfiguration.DisplayStyle == DisplayStyle.Other ||
                ChannelConfiguration.Charasteristics.CanCustomize && IsManuallyCustomized)
            {
                // Incoming Settings
                ChannelConfiguration.InputChannel.Authentication.Username = ManualEntryIncomingUsername;
                ChannelConfiguration.InputChannel.Authentication.Password = ManualEntryIncomingPassword;
                ChannelConfiguration.InputChannel.Hostname  = ManualEntryIncomingServer;
                ChannelConfiguration.InputChannel.Port      = ManualEntryIncomingPort;
                ChannelConfiguration.InputChannel.IsSecured = ManualEntryIncomingSsl;
                ChannelConfiguration.InputChannel.Type      = AccountTypeImapRadioButton.IsChecked == true
                                                                                                                        ? typeof(Imap2ClientChannel)
                                                                                                                        : typeof(Pop3ClientChannel);

                // Outgoing Settings
                ChannelConfiguration.OutputChannel.Authentication.Username = ManualEntryOutgoingUsername;
                ChannelConfiguration.OutputChannel.Authentication.Password = ManualEntryOutgoingPassword;
                ChannelConfiguration.OutputChannel.Hostname  = ManualEntryOutgoingServer;
                ChannelConfiguration.OutputChannel.Port      = ManualEntryOutgoingPort;
                ChannelConfiguration.OutputChannel.IsSecured = ManualEntryOutgoingSsl;

                ChannelBuilder.SetChannelAuthentication(
                    ManualEntryIncomingUsername,
                    ManualEntryIncomingPassword,
                    ChannelConfiguration.InputChannel,
                    ChannelConfiguration.OutputChannel);
            }
            else
            {
                if (ChannelConfiguration.DisplayStyle == DisplayStyle.Advanced)
                {
                    ChannelBuilder.SetChannelHostname(
                        HostnameTextBox.Text,
                        ChannelConfiguration.InputChannel,
                        ChannelConfiguration.OutputChannel,
                        ChannelConfiguration.ContactsChannel,
                        ChannelConfiguration.CalendarChannel,
                        ChannelConfiguration.StatusUpdatesChannel);
                }

                ChannelBuilder.SetChannelAuthentication(
                    Username,
                    Password,
                    ChannelConfiguration.InputChannel,
                    ChannelConfiguration.OutputChannel,
                    ChannelConfiguration.ContactsChannel,
                    ChannelConfiguration.CalendarChannel,
                    ChannelConfiguration.StatusUpdatesChannel);
            }

            #endregion

            // Start loader animation
            ((Storyboard)FindResource("RunLoaderStoryboard")).Begin();

            ValidateLocalCredentials();
        }