OUT-641: Remove PGP and pEp key import wizards sync
authorThomas
Mon, 18 Nov 2019 20:04:48 +0100
branchsync
changeset 2866dcd94db0899f
parent 2863 8d5bd5db108d
child 2867 67f0cdd1b684
OUT-641: Remove PGP and pEp key import wizards
CryptableMailItem.cs
MsgProcessor.cs
UI/KeySyncWizard.xaml
UI/KeySyncWizard.xaml.cs
UI/RibbonCustomizations.cs
UI/RibbonCustomizationsExplorer.xml
UI/RibbonCustomizationsExplorer2010.xml
UI/ValueConverters.cs
pEpForOutlook.csproj
     1.1 --- a/CryptableMailItem.cs	Mon Nov 18 08:27:05 2019 +0100
     1.2 +++ b/CryptableMailItem.cs	Mon Nov 18 20:04:48 2019 +0100
     1.3 @@ -1205,15 +1205,6 @@
     1.4                      // Process mail item
     1.5                      sts1 = PEPMessage.Create(this.internalMailItem, out message);
     1.6  
     1.7 -                    // If Key Import Wizard is open, add mail to list to process later
     1.8 -                    if ((KeySyncWizard.Wizard?.IsVisible == true) &&
     1.9 -                        (message.Direction == pEpMsgDirection.pEpDirIncoming) &&
    1.10 -                        (message.To?.Count == 1) &&
    1.11 -                        (message.From?.EqualsByAddress(message.To[0]) == true))
    1.12 -                    {
    1.13 -                        KeySyncWizard.Wizard?.AddToReceivedSyncMessages(message);
    1.14 -                    }
    1.15 -
    1.16                      // Define decryption flags
    1.17                      decryptionFlags = isSecurelyStored ? pEpDecryptFlags.pEpDecryptFlagUntrustedServer : pEpDecryptFlags.pEpDecryptFlagsNone;
    1.18  
     2.1 --- a/MsgProcessor.cs	Mon Nov 18 08:27:05 2019 +0100
     2.2 +++ b/MsgProcessor.cs	Mon Nov 18 20:04:48 2019 +0100
     2.3 @@ -24,96 +24,6 @@
     2.4           *************************************************************/
     2.5  
     2.6          /// <summary>
     2.7 -        /// Checks if the key sync wizard is open or the message is a sync message.
     2.8 -        /// If this is true, the message will get processed further, either raising
     2.9 -        /// the respective event or opening the wizard.
    2.10 -        /// </summary>
    2.11 -        /// <param name="message">The message to check.</param>
    2.12 -        /// <param name="flags">The decrypt flags.</param>
    2.13 -        private void CheckForSyncMessage(PEPMessage message, ref pEpDecryptFlags flags)
    2.14 -        {
    2.15 -            try
    2.16 -            {
    2.17 -                /* To determine whether the processed message is a sync message:
    2.18 -                 * 1. Is incoming (do not process sent messages)
    2.19 -                 * 2. Has the KeyImport header (in case of pEp sync) and the header is not
    2.20 -                 *    the own fingerprint.
    2.21 -                 * - or -
    2.22 -                 * 3. a. The WizardType is PGP
    2.23 -                 *    b. The message has one To recipient that is also the From recipient
    2.24 -                 *    c. The From recipient is an own identity (seems actually unnecessary)
    2.25 -                 */
    2.26 -                if ((KeySyncWizard.Wizard?.Type == KeySyncWizard.WizardType.PGP) ||
    2.27 -                    (message?.KeyImport?.Equals(KeySyncWizard.Wizard?.Myself?.Fingerprint) == false))
    2.28 -                {
    2.29 -                    if ((message?.To?.Count == 1) &&
    2.30 -                        (message.To[0].EqualsByAddress(message.From)) &&
    2.31 -                        (PEPIdentity.GetIsOwnIdentity(message.From.Address)))
    2.32 -                    {
    2.33 -                        Log.Verbose("CheckForSyncMessage: Potential sync message found. KeyImport Fpr: " + message?.KeyImport ?? "<null>");
    2.34 -
    2.35 -                        if ((KeySyncWizard.Wizard?.Type != KeySyncWizard.WizardType.PGP) &&
    2.36 -                            (KeySyncWizard.Wizard?.IsVisible == false))
    2.37 -                        {
    2.38 -                            Log.Verbose("CheckForSyncMessage: Wizard not open yet.");
    2.39 -
    2.40 -                            // Get own identity
    2.41 -                            PEPIdentity myself = null;
    2.42 -                            try
    2.43 -                            {
    2.44 -                                pEpIdentity _myself = message.To[0].ToCOMType();
    2.45 -                                myself = new PEPIdentity(ThisAddIn.PEPEngine.Myself(_myself));
    2.46 -                            }
    2.47 -                            catch (Exception ex)
    2.48 -                            {
    2.49 -                                myself = null;
    2.50 -                                Log.Verbose("CheckForSyncMessage: Error getting own identity. " + ex.ToString());
    2.51 -                            }
    2.52 -
    2.53 -                            // Only open if not sent to myself. Check again if not open
    2.54 -                            if ((myself?.Fingerprint?.Equals(message?.KeyImport) == false) &&
    2.55 -                                (KeySyncWizard.Wizard?.IsVisible == false))
    2.56 -                            {
    2.57 -                                // Marshall to main thread and create new wizard
    2.58 -                                KeySyncWizard.Wizard?.Dispatcher?.Invoke(new Action(() =>
    2.59 -                                {
    2.60 -                                    KeySyncWizard.Wizard = new KeySyncWizard(KeySyncWizard.WizardType.pEp, false, message.To[0], message.KeyImport);
    2.61 -                                    KeySyncWizard.Wizard.Show();
    2.62 -                                    Log.Verbose("CheckForSyncMessage: Wizard opened.");
    2.63 -                                }));
    2.64 -                            }
    2.65 -                            else
    2.66 -                            {
    2.67 -                                Log.Verbose("CheckForSyncMessage: Wizard not opened. Wizard was {0} open. Own fpr is {1}", ((KeySyncWizard.Wizard?.IsVisible == true) ? "already" : "not"), (myself?.Fingerprint ?? "<null>"));
    2.68 -                            }
    2.69 -                        }
    2.70 -                        else
    2.71 -                        {
    2.72 -                            Log.Verbose("CheckForSyncMessage: Wizard already open or message rating is trusted. Invoking sync message received event.");
    2.73 -                            MsgProcessor.SyncMessageReceived?.Invoke(this, new SyncMessageEventArgs(message, flags));
    2.74 -                        }
    2.75 -
    2.76 -                        // Delete message if necessary
    2.77 -                        if ((KeySyncWizard.Wizard?.Type == KeySyncWizard.WizardType.pEp) &&
    2.78 -                            (string.IsNullOrEmpty(message?.KeyImport) == false) &&
    2.79 -                            (KeySyncWizard.Wizard?.Myself?.Fingerprint?.Equals(message?.KeyImport) == false))
    2.80 -                        {
    2.81 -                            flags |= pEpDecryptFlags.pEpDecryptFlagConsume;
    2.82 -                        }
    2.83 -                    }
    2.84 -                    else
    2.85 -                    {
    2.86 -                        Log.Warning("CheckForSyncMessage: PGP Wizard open or message with KeyImport header, but message doesn't meet formal criteria.");
    2.87 -                    }
    2.88 -                }
    2.89 -            }
    2.90 -            catch (Exception ex)
    2.91 -            {
    2.92 -                Log.Error("CheckForSyncMessage: Error detecting if sync message. " + ex.ToString());
    2.93 -            }
    2.94 -        }
    2.95 -
    2.96 -        /// <summary>
    2.97          /// Processes the given message including any decryption where necessary.
    2.98          /// This will then return the latest pEp rating for the message.
    2.99          /// If rating is ever undefined: it can be assumed an error occured.
   2.100 @@ -643,9 +553,6 @@
   2.101                  keyList = new string[0];
   2.102              }
   2.103  
   2.104 -            // Check for sync message
   2.105 -            this.CheckForSyncMessage((rating == pEpRating.pEpRatingUnencrypted) ? sourceMessage : destMessage, ref flags);
   2.106 -
   2.107              Log.SensitiveData("Decrypt: Complete. " + sourceMessage?.Id);
   2.108  
   2.109              return rating;
     3.1 --- a/UI/KeySyncWizard.xaml	Mon Nov 18 08:27:05 2019 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,124 +0,0 @@
     3.4 -´╗┐<Window x:Class="pEp.UI.KeySyncWizard"
     3.5 -        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     3.6 -        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     3.7 -        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     3.8 -        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     3.9 -        xmlns:core="clr-namespace:System;assembly=mscorlib"
    3.10 -        xmlns:p="clr-namespace:pEp.Properties"
    3.11 -        xmlns:local="clr-namespace:pEp.UI"
    3.12 -        mc:Ignorable="d"
    3.13 -        MinHeight="5"
    3.14 -        Height="Auto"
    3.15 -        Width="Auto"
    3.16 -        x:ClassModifier="internal"
    3.17 -        ResizeMode="NoResize"
    3.18 -        SizeToContent="WidthAndHeight"
    3.19 -        Topmost="True"
    3.20 -        Background="{x:Static SystemColors.MenuBarBrush}"
    3.21 -        Title="{x:Static p:Resources.KeySyncWizard_WindowTitle}"
    3.22 -        Closed="Window_Closed"
    3.23 -        Icon="pack://application:,,,/pEp;component/Resources/ImageLogoIcon.png"
    3.24 -        WindowStartupLocation="CenterScreen">
    3.25 -    <Window.Resources>
    3.26 -        <ResourceDictionary>
    3.27 -            <!-- Converters -->
    3.28 -            <BooleanToVisibilityConverter x:Key="BoolToVisibility" />
    3.29 -            <local:ValueConverterGroup x:Key="InvertBoolToVisibility">
    3.30 -                <local:InvertBoolConverter />
    3.31 -                <BooleanToVisibilityConverter />
    3.32 -            </local:ValueConverterGroup>
    3.33 -            <local:MultiBooleanToVisibilityConverter x:Key="MultiBooleanToVisibility" />
    3.34 -            <local:ValueConverterGroup x:Key="IsStringNotNullOrEmptyToVisibility">
    3.35 -                <local:IsStringEmptyConverter />
    3.36 -                <local:InvertBoolConverter />
    3.37 -                <BooleanToVisibilityConverter />
    3.38 -            </local:ValueConverterGroup>
    3.39 -            <local:WizardTypeToBooleanConverter x:Key="IsWizardType" />
    3.40 -
    3.41 -            <!--Dictionary-->
    3.42 -            <ResourceDictionary.MergedDictionaries>
    3.43 -                <ResourceDictionary Source="pack://application:,,,/pEp;component/Resources/Dictionary.xaml" />
    3.44 -            </ResourceDictionary.MergedDictionaries>
    3.45 -        </ResourceDictionary>
    3.46 -    </Window.Resources>
    3.47 -
    3.48 -    <StackPanel Margin="10"
    3.49 -                Width="470">
    3.50 -
    3.51 -        <!--Information section-->
    3.52 -        <TextBlock Text="{Binding Path=CurrentState.TitleText}"
    3.53 -                   TextWrapping="Wrap"
    3.54 -                   Margin="5,5,5,15" />
    3.55 -
    3.56 -        <!--User name section-->
    3.57 -        <TextBlock Text="{Binding Path=CurrentState.UserText}"
    3.58 -                   Padding="10"
    3.59 -                   MinHeight="80"
    3.60 -                   Background="White"
    3.61 -                   FontWeight="DemiBold"
    3.62 -                   Visibility="{Binding Path=CurrentState.AreTrustwordsVisible, Converter={StaticResource InvertBoolToVisibility}}" />
    3.63 -
    3.64 -        <!--Identities section-->
    3.65 -        <StackPanel Visibility="{Binding Path=CurrentState.AreTrustwordsVisible, Converter={StaticResource BoolToVisibility}}">
    3.66 -            <!--<local:HandshakeItemsControl ItemsSource="{Binding Path=Items}" />-->
    3.67 -            <StackPanel Orientation="Horizontal"
    3.68 -                        Margin="5,10,5,0">
    3.69 -                <StackPanel.Visibility>
    3.70 -                    <MultiBinding Converter="{StaticResource MultiBooleanToVisibility}">
    3.71 -                        <Binding Path="IsInitiator" />
    3.72 -                        <Binding Path="Type"
    3.73 -                                 Converter="{StaticResource IsWizardType}"
    3.74 -                                 ConverterParameter="PGP" />
    3.75 -                    </MultiBinding>
    3.76 -                </StackPanel.Visibility>
    3.77 -                <CheckBox VerticalAlignment="Center"
    3.78 -                          IsChecked="{Binding Path=SetImportedKeyAsDefault}" />
    3.79 -                <Label Content="{x:Static p:Resources.KeySyncWizard_SetImportedKeyAsDefault}"
    3.80 -                       MouseUp="LabelSetImportedKeyAsDefault_MouseUp" />
    3.81 -            </StackPanel>
    3.82 -        </StackPanel>
    3.83 -
    3.84 -        <!--Subtitle section-->
    3.85 -        <TextBlock Text="{Binding Path=CurrentState.SubtitleText}"
    3.86 -                   TextWrapping="Wrap"
    3.87 -                   Margin="5,15"
    3.88 -                   Visibility="{Binding Path=CurrentState.SubtitleText, Converter={StaticResource IsStringNotNullOrEmptyToVisibility}}" />
    3.89 -        
    3.90 -        <!--Progress bar-->
    3.91 -        <ProgressBar IsIndeterminate="True"
    3.92 -                     Minimum="0"
    3.93 -                     Maximum="100"
    3.94 -                     Height="15"
    3.95 -                     Visibility="{Binding Path=CurrentState.IsProgressBarVisible, Converter={StaticResource BoolToVisibility}}" />
    3.96 -
    3.97 -        <!--Buttons section-->
    3.98 -        <StackPanel Margin="0,10"
    3.99 -                    Orientation="Horizontal"
   3.100 -                    HorizontalAlignment="Right">
   3.101 -            <Button x:Name="BackButton"
   3.102 -                    MinHeight="28"
   3.103 -                    MinWidth="150"
   3.104 -                    Margin="0,5,5,5"
   3.105 -                    Click="BackButton_Click"
   3.106 -                    Content="{x:Static p:Resources.KeySyncWizard_BackButtonText}"
   3.107 -                    Visibility="{Binding Path=CurrentState.IsBackButtonVisible, Converter={StaticResource BoolToVisibility}}" />
   3.108 -            <Button x:Name="AcceptButton"
   3.109 -                    MinHeight="28"
   3.110 -                    MinWidth="150"
   3.111 -                    Style="{Binding Path=CurrentState.AcceptButtonStyle}"
   3.112 -                    Margin="5"
   3.113 -                    Click="AcceptButton_Click"
   3.114 -                    Content="{Binding Path=CurrentState.AcceptButtonText}"
   3.115 -                    Visibility="{Binding Path=CurrentState.IsAcceptButtonVisible, Converter={StaticResource BoolToVisibility}}" />
   3.116 -            <Button x:Name="CancelButton"
   3.117 -                    Margin="5,5,0,5"
   3.118 -                    MinHeight="28"
   3.119 -                    MinWidth="150"
   3.120 -                    Style="{Binding Path=CurrentState.CancelButtonStyle}"
   3.121 -                    Click="CancelButton_Click"
   3.122 -                    Content="{Binding Path=CurrentState.CancelButtonText}"
   3.123 -                    Visibility="{Binding Path=CurrentState.IsCancelButtonVisible, Converter={StaticResource BoolToVisibility}}" />
   3.124 -        </StackPanel>
   3.125 -    </StackPanel>
   3.126 -</Window>
   3.127 -
     4.1 --- a/UI/KeySyncWizard.xaml.cs	Mon Nov 18 08:27:05 2019 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,1836 +0,0 @@
     4.4 -´╗┐using pEp.UI.Models;
     4.5 -using pEpCOMServerAdapterLib;
     4.6 -using System;
     4.7 -using System.Collections.Generic;
     4.8 -using System.Collections.ObjectModel;
     4.9 -using System.ComponentModel;
    4.10 -using System.Threading.Tasks;
    4.11 -using System.Windows;
    4.12 -using System.Windows.Input;
    4.13 -using System.Windows.Threading;
    4.14 -using Outlook = Microsoft.Office.Interop.Outlook;
    4.15 -
    4.16 -namespace pEp.UI
    4.17 -{
    4.18 -    /// <summary>
    4.19 -    /// Interaction logic for KeySyncWizard.xaml
    4.20 -    /// </summary>
    4.21 -    internal partial class KeySyncWizard : Window,
    4.22 -                                           INotifyPropertyChanged,
    4.23 -                                           Interfaces.IReset
    4.24 -    {
    4.25 -        /// <summary>
    4.26 -        /// Defines the step this wizard is currently in.
    4.27 -        /// </summary>
    4.28 -        public enum Steps
    4.29 -        {
    4.30 -            Undefined,
    4.31 -            Success,
    4.32 -            Error,
    4.33 -            Step1,
    4.34 -            Step2,
    4.35 -            Step3,
    4.36 -            Step4,
    4.37 -            Step5,
    4.38 -            Step6,
    4.39 -            Step7,
    4.40 -            Step8
    4.41 -        }
    4.42 -
    4.43 -        /// <summary>
    4.44 -        /// The message types for sync messages.
    4.45 -        /// </summary>
    4.46 -        public enum MessageTypes
    4.47 -        {
    4.48 -            Undefined,
    4.49 -            InitialMessage,
    4.50 -            PublicKeyMessage,
    4.51 -            PrivateKeyMessage
    4.52 -        }
    4.53 -
    4.54 -        /// <summary>
    4.55 -        /// Defines the wizard type.
    4.56 -        /// </summary>
    4.57 -        public enum WizardType
    4.58 -        {
    4.59 -            Undefined,
    4.60 -            PGP,
    4.61 -            pEp
    4.62 -        }
    4.63 -
    4.64 -        /// <summary>
    4.65 -        /// Event raised when a property is changed on a component.
    4.66 -        /// </summary>
    4.67 -        public event PropertyChangedEventHandler        PropertyChanged;
    4.68 -
    4.69 -        private WizardState                             _CurrentState;
    4.70 -        private bool                                    _IsInitiator;
    4.71 -        private ObservableCollection<Handshake>     _Items;
    4.72 -        private PEPIdentity                             _Myself;
    4.73 -        private PEPIdentity                             _Partner;
    4.74 -        private bool                                    _PartnerIdentityReset;
    4.75 -        private Steps                                   _Step;
    4.76 -        private bool                                    _SetImportedKeyAsDefault;
    4.77 -        private WizardType                              _Type;
    4.78 -
    4.79 -        private bool                                    privateKeyImported          = false;
    4.80 -        private List<MessageTypes>                      sentMessages                = new List<MessageTypes>();
    4.81 -        private List<PEPMessage>                        receivedSyncMessages        = new List<PEPMessage>();
    4.82 -        private List<WizardState>                       states                      = new List<WizardState>();
    4.83 -        private object                                  mutexReceivedSyncMessages   = new object();
    4.84 -
    4.85 -        public static KeySyncWizard                     Wizard                      = null;
    4.86 -
    4.87 -        // Fast polling timer
    4.88 -        private static  System.Windows.Forms.Timer      timer                       = null;
    4.89 -        private const   int                             FAST_POLLING_INTERVAL       = 1000;    // 1 second in ms
    4.90 -        private const   int                             MAX_POLLING_COUNT           = 600;     // 600 times each second => max. 10 minutes
    4.91 -
    4.92 -        // Button styles
    4.93 -        private static Style                            greenButtonStyle            = new Style(typeof(System.Windows.Controls.Button));
    4.94 -        private static Style                            greyButtonStyle             = new Style(typeof(System.Windows.Controls.Button));
    4.95 -        private static Style                            redButtonStyle              = new Style(typeof(System.Windows.Controls.Button));
    4.96 -
    4.97 -        /// <summary>
    4.98 -        /// Default constructor
    4.99 -        /// </summary>
   4.100 -        public KeySyncWizard()
   4.101 -        { }
   4.102 -
   4.103 -        /// <summary>
   4.104 -        /// Constructor to create a new key sync wizard.
   4.105 -        /// </summary>
   4.106 -        /// <param name="type">The type of this wizard.</param>
   4.107 -        /// <param name="myself">The myself identity.</param>
   4.108 -        /// <param name="partnerFpr">The partner fingerprint.</param>
   4.109 -        public KeySyncWizard(WizardType type,
   4.110 -                             bool isInitiator = false,
   4.111 -                             PEPIdentity myself = null,
   4.112 -                             string partnerFpr = null)
   4.113 -        {
   4.114 -            // Only allow one wizard at a time
   4.115 -            if (KeySyncWizard.Wizard?.IsVisible == true)
   4.116 -            {
   4.117 -                KeySyncWizard.Wizard.Close();
   4.118 -            }
   4.119 -
   4.120 -            Log.Verbose("KeySyncWizard: Starting {0} key import process.", Enum.GetName(typeof(WizardType), type));
   4.121 -
   4.122 -            // Reset all values
   4.123 -            this.Reset();
   4.124 -
   4.125 -            // Initialize the window
   4.126 -            InitializeComponent();
   4.127 -
   4.128 -            // Set current wizard
   4.129 -            KeySyncWizard.Wizard = this;
   4.130 -
   4.131 -            // Initialize the wizard
   4.132 -            this.InitializeWizard(isInitiator, type, myself, partnerFpr);
   4.133 -
   4.134 -            // Attach event handler for new sync messages
   4.135 -            MsgProcessor.SyncMessageReceived += KeySyncWizard_SyncMessageReceived;
   4.136 -
   4.137 -            // Send initial message if necessary
   4.138 -            if (this.IsInitiator)
   4.139 -            {
   4.140 -                this.SendSyncMessage(MessageTypes.InitialMessage);
   4.141 -            }
   4.142 -
   4.143 -            // Enable fast polling and inbox cleaning in pEp mode
   4.144 -            if (this.Type == WizardType.pEp)
   4.145 -            {
   4.146 -                this.ToggleFastPolling(true);
   4.147 -                Globals.ThisAddIn.ToggleInboxCleaning(true);
   4.148 -            }
   4.149 -        }
   4.150 -
   4.151 -        #region Property Accessors
   4.152 -        /**************************************************************
   4.153 -         * 
   4.154 -         * Property Accessors
   4.155 -         * 
   4.156 -         *************************************************************/
   4.157 -
   4.158 -        /// <summary>
   4.159 -        /// Gets or sets the Items collection.
   4.160 -        /// </summary>
   4.161 -        public WizardState CurrentState
   4.162 -        {
   4.163 -            get { return this._CurrentState; }
   4.164 -            set
   4.165 -            {
   4.166 -                this._CurrentState = value;
   4.167 -                this.RaisePropertyChangedEvent(nameof(this.CurrentState));
   4.168 -            }
   4.169 -        }
   4.170 -
   4.171 -        /// <summary>
   4.172 -        /// Gets or sets whether this wizard is the one that
   4.173 -        /// initiated the Key Import process.
   4.174 -        /// </summary>
   4.175 -        public bool IsInitiator
   4.176 -        {
   4.177 -            get { return this._IsInitiator; }
   4.178 -            set
   4.179 -            {
   4.180 -                this._IsInitiator = value;
   4.181 -                this.RaisePropertyChangedEvent(nameof(this.IsInitiator));
   4.182 -            }
   4.183 -        }
   4.184 -
   4.185 -        /// <summary>
   4.186 -        /// Gets or sets the Items collection.
   4.187 -        /// </summary>
   4.188 -        public ObservableCollection<Handshake> Items
   4.189 -        {
   4.190 -            get { return this._Items; }
   4.191 -            set
   4.192 -            {
   4.193 -                this._Items = value;
   4.194 -                this.RaisePropertyChangedEvent(nameof(this.Items));
   4.195 -            }
   4.196 -        }
   4.197 -
   4.198 -        /// <summary>
   4.199 -        /// Gets or sets the own identity.
   4.200 -        /// </summary>
   4.201 -        public PEPIdentity Myself
   4.202 -        {
   4.203 -            get { return this._Myself; }
   4.204 -            set
   4.205 -            {
   4.206 -                this._Myself = value;
   4.207 -                this.RaisePropertyChangedEvent(nameof(this.Myself));
   4.208 -            }
   4.209 -        }
   4.210 -
   4.211 -        /// <summary>
   4.212 -        /// Gets or sets the sync partner.
   4.213 -        /// </summary>
   4.214 -        public PEPIdentity Partner
   4.215 -        {
   4.216 -            get { return this._Partner; }
   4.217 -            set
   4.218 -            {
   4.219 -                this._Partner = value;
   4.220 -                this.RaisePropertyChangedEvent(nameof(this.Partner));
   4.221 -            }
   4.222 -        }
   4.223 -
   4.224 -        /// <summary>
   4.225 -        /// Gets or sets whether the partner identity has been reset.
   4.226 -        /// </summary>
   4.227 -        public bool PartnerIdentityReset
   4.228 -        {
   4.229 -            get { return this._PartnerIdentityReset; }
   4.230 -            set
   4.231 -            {
   4.232 -                this._PartnerIdentityReset = value;
   4.233 -                this.RaisePropertyChangedEvent(nameof(this.PartnerIdentityReset));
   4.234 -            }
   4.235 -        }
   4.236 -
   4.237 -        /// <summary>
   4.238 -        /// Gets or sets the current wizard step.
   4.239 -        /// </summary>
   4.240 -        public Steps Step
   4.241 -        {
   4.242 -            get { return this._Step; }
   4.243 -            set
   4.244 -            {
   4.245 -                this._Step = value;
   4.246 -                this.RaisePropertyChangedEvent(nameof(this.Step));
   4.247 -            }
   4.248 -        }
   4.249 -
   4.250 -        /// <summary>
   4.251 -        /// Gets or sets whether to use the imported key as default key.
   4.252 -        /// </summary>
   4.253 -        public bool SetImportedKeyAsDefault
   4.254 -        {
   4.255 -            get { return this._SetImportedKeyAsDefault; }
   4.256 -            set
   4.257 -            {
   4.258 -                this._SetImportedKeyAsDefault = value;
   4.259 -                this.RaisePropertyChangedEvent(nameof(this.SetImportedKeyAsDefault));
   4.260 -            }
   4.261 -        }
   4.262 -
   4.263 -        /// <summary>
   4.264 -        /// Gets or sets the wizard type.
   4.265 -        /// </summary>
   4.266 -        public WizardType Type
   4.267 -        {
   4.268 -            get { return this._Type; }
   4.269 -            set
   4.270 -            {
   4.271 -                this._Type = value;
   4.272 -                this.RaisePropertyChangedEvent(nameof(this.Type));
   4.273 -            }
   4.274 -        }
   4.275 -
   4.276 -        /// <summary>
   4.277 -        /// Gets the user name to display in the dialog.
   4.278 -        /// </summary>
   4.279 -        public string UserName
   4.280 -        {
   4.281 -            get
   4.282 -            {
   4.283 -                string userName = string.Empty;
   4.284 -
   4.285 -                // Try to get user name in format "name (address)"
   4.286 -                if (string.IsNullOrEmpty(this.Myself?.UserName) == false)
   4.287 -                {
   4.288 -                    userName = this.Myself.UserName;
   4.289 -
   4.290 -                    if (string.IsNullOrEmpty(this.Myself?.Address) == false)
   4.291 -                    {
   4.292 -                        userName += " (" + this.Myself.Address + ")";
   4.293 -                    }
   4.294 -                }
   4.295 -                // If we have no user name, just display address
   4.296 -                else if (string.IsNullOrEmpty(this.Myself?.Address) == false)
   4.297 -                {
   4.298 -                    userName = this.Myself.Address;
   4.299 -                }
   4.300 -
   4.301 -                return userName;
   4.302 -            }
   4.303 -        }
   4.304 -
   4.305 -        #endregion
   4.306 -
   4.307 -        #region Event handlers
   4.308 -        /**************************************************************
   4.309 -         * 
   4.310 -         * Event handlers
   4.311 -         * 
   4.312 -         *************************************************************/
   4.313 -
   4.314 -        /// <summary>
   4.315 -        /// Event handler for when the OK/Next button is clicked.
   4.316 -        /// </summary>
   4.317 -        private void AcceptButton_Click(object sender, RoutedEventArgs e)
   4.318 -        {
   4.319 -            this.CurrentState.AcceptButtonClick();
   4.320 -        }
   4.321 -
   4.322 -        /// <summary>
   4.323 -        /// Event handler for when the Back button is clicked.
   4.324 -        /// </summary>
   4.325 -        private void BackButton_Click(object sender, RoutedEventArgs e)
   4.326 -        {
   4.327 -            this.CurrentState.BackButtonClick();
   4.328 -        }
   4.329 -
   4.330 -        /// <summary>
   4.331 -        /// Event handler for when the Cancel button is clicked.
   4.332 -        /// </summary>
   4.333 -        private void CancelButton_Click(object sender, RoutedEventArgs e)
   4.334 -        {
   4.335 -            this.CurrentState.CancelButtonClick();
   4.336 -        }
   4.337 -
   4.338 -        /// <summary>
   4.339 -        /// Event handler for when a sync message arrives while the wizard is open and in progress.
   4.340 -        /// </summary>
   4.341 -        private void KeySyncWizard_SyncMessageReceived(object sender, MsgProcessor.SyncMessageEventArgs e)
   4.342 -        {
   4.343 -            // Ignore outgoing messages
   4.344 -            if (e.Message?.Direction == pEpMsgDirection.pEpDirIncoming)
   4.345 -            {
   4.346 -                try
   4.347 -                {
   4.348 -                    // Waiting for message with public key from other device
   4.349 -                    if (((this.Type == WizardType.pEp) && (this.Step == Steps.Step1)) ||
   4.350 -                        ((this.Type == WizardType.PGP) && (this.Step == Steps.Step4)))
   4.351 -                    {
   4.352 -                        string partnerFpr = null;
   4.353 -
   4.354 -                        // Make sure the channel is not already trusted (either attack or re-processing)
   4.355 -                        if ((e.Message?.Rating >= pEpRating.pEpRatingTrusted) &&
   4.356 -                            (this.PartnerIdentityReset))
   4.357 -                        {
   4.358 -                            Log.Warning("KeySyncWizard_SyncMessageReceived: Sync message for already trusted channel received.");
   4.359 -                            return;
   4.360 -                        }
   4.361 -
   4.362 -                        // In case of pEp sync, use header
   4.363 -                        if (this.Type == WizardType.pEp)
   4.364 -                        {
   4.365 -                            // Public key message received. Show trustwords.
   4.366 -                            partnerFpr = e.Message?.KeyImport;
   4.367 -
   4.368 -                            Log.Verbose("KeySyncWizard_SyncMessageReceived: pEp import, partner fingerprint is " + partnerFpr);
   4.369 -
   4.370 -                            // Doublecheck that it's not the own key
   4.371 -                            if (this.Myself?.Fingerprint?.Equals(partnerFpr) == true)
   4.372 -                            {
   4.373 -                                Log.Verbose("KeySyncWizard_SyncMessageReceived: Partner fingerprint equals own fingerprint. Setting fpr to null.");
   4.374 -                                partnerFpr = null;
   4.375 -                            }
   4.376 -                        }
   4.377 -                        else if (this.Type == WizardType.PGP)
   4.378 -                        {
   4.379 -                            // In case of PGP import, use key list
   4.380 -                            string[] keys = e.Message?.KeyList?.Split(',');
   4.381 -                            for (int i = 0; i < keys?.Length; i++)
   4.382 -                            {
   4.383 -                                if (keys[i]?.Equals(this.Myself?.Fingerprint) == false)
   4.384 -                                {
   4.385 -                                    partnerFpr = keys[i];
   4.386 -                                    Log.Verbose("KeySyncWizard_SyncMessageReceived: PGP import, partner fingerprint is " + partnerFpr ?? "null");
   4.387 -                                    break;
   4.388 -                                }
   4.389 -                            }
   4.390 -                        }
   4.391 -                        else
   4.392 -                        {
   4.393 -                            Log.Error("KeySyncWizard_SyncMessageReceived: WizardType unknown.");
   4.394 -                        }
   4.395 -
   4.396 -                        // If we are the initiator and have a valid fingerprint, show Trustwords
   4.397 -                        if ((this.IsInitiator) &&
   4.398 -                            (string.IsNullOrEmpty(partnerFpr) == false))
   4.399 -                        {
   4.400 -                            // Set the partner's fingerprint
   4.401 -                            this.Partner.Fingerprint = partnerFpr;
   4.402 -
   4.403 -                            // Reset the partner identity
   4.404 -                            try
   4.405 -                            {
   4.406 -                                pEpIdentity partner = this.Partner.ToCOMType();
   4.407 -                                ThisAddIn.PEPEngine.KeyResetTrust(partner);
   4.408 -                                this._PartnerIdentityReset = true;
   4.409 -                            }
   4.410 -                            catch (Exception ex)
   4.411 -                            {
   4.412 -                                Log.Error("KeySyncWizard_SyncMessageReceived: Error resetting partner trust. " + ex.ToString());
   4.413 -                            }
   4.414 -
   4.415 -                            // Marshall to main thread
   4.416 -                            this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
   4.417 -                            {
   4.418 -                                // Create the handshake item 
   4.419 -                                if (this.CreateHandshakeItem())
   4.420 -                                {
   4.421 -                                    this.GoToNextStep();
   4.422 -                                }
   4.423 -                                else
   4.424 -                                {
   4.425 -                                    Log.Error("KeySyncWizard_SyncMessageReceived: Error creating handshake item.");
   4.426 -                                    this.GoToLastStep(false);
   4.427 -                                }
   4.428 -                            }));
   4.429 -                        }
   4.430 -                        else
   4.431 -                        {
   4.432 -                            Log.Error("KeySyncWizard_SyncMessageReceived: We are not initiator or the Partner fingerprint is null.");
   4.433 -                        }
   4.434 -                    }
   4.435 -                    // Waiting for private key message
   4.436 -                    else if (((this.Type == WizardType.pEp) && (this.Step == Steps.Step3)) ||
   4.437 -                             ((this.Type == WizardType.PGP) && (this.Step == Steps.Step8)))
   4.438 -                    {
   4.439 -                        /* Finish the process under the following conditions:
   4.440 -                         *  1. PGP key import + own private key flag + no key import header
   4.441 -                         *  2. pEp key import +
   4.442 -                         *      a. initiator wizard + own private key flag + partner fpr in key import header
   4.443 -                         *      b. not initiator wizard + trusted message + partner fpr in key import header
   4.444 -                         */
   4.445 -                        bool hasDecryptFlagOwnPrivateKey = e.Flags.HasFlag(pEpDecryptFlags.pEpDecryptFlagOwnPrivateKey);
   4.446 -                        if (((this.Type == WizardType.PGP) && (hasDecryptFlagOwnPrivateKey) && (string.IsNullOrEmpty(e.Message.KeyImport))) ||
   4.447 -                            ((this.IsInitiator) && (e.Message.KeyImport?.Equals(this.Partner?.Fingerprint) == true) && (hasDecryptFlagOwnPrivateKey)) ||
   4.448 -                            ((this.IsInitiator == false) && (e.Message.KeyImport?.Equals(this.Partner?.Fingerprint) == true) && (e.Message.Rating >= pEpRating.pEpRatingTrusted)))
   4.449 -                        {
   4.450 -                            // Set flag
   4.451 -                            this.privateKeyImported = hasDecryptFlagOwnPrivateKey;
   4.452 -
   4.453 -                            // Marshall to main thread
   4.454 -                            this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
   4.455 -                            {
   4.456 -                                // Set private key as default if needed
   4.457 -                                bool success = false;
   4.458 -                                if ((this.IsInitiator) &&
   4.459 -                                    (this.SetImportedKeyAsDefault))
   4.460 -                                {
   4.461 -                                    try
   4.462 -                                    {
   4.463 -                                        pEpIdentity partner = this.Partner.ToCOMType();
   4.464 -                                        ThisAddIn.PEPEngine.SetOwnKey(partner, partner.fpr);
   4.465 -                                        success = true;
   4.466 -                                    }
   4.467 -                                    catch (Exception ex)
   4.468 -                                    {
   4.469 -                                        success = false;
   4.470 -                                        Log.Error("AcceptButtonClick: Error setting own key. " + ex.ToString());
   4.471 -                                    }
   4.472 -                                }
   4.473 -                                else
   4.474 -                                {
   4.475 -                                    success = true;
   4.476 -                                }
   4.477 -
   4.478 -                                this.GoToLastStep(success);
   4.479 -
   4.480 -                            }));
   4.481 -                        }
   4.482 -                        else
   4.483 -                        {
   4.484 -                            Log.Verbose("KeySyncWizard_SyncMessageReceived: Message not processed. Current step: " + Enum.GetName(typeof(KeySyncWizard.Steps), this.Step) + ". Own private key flag is " +
   4.485 -                                        e.Flags.HasFlag(pEpDecryptFlags.pEpDecryptFlagOwnPrivateKey).ToString() + ". Rating is " +
   4.486 -                                        Enum.GetName(typeof(pEpRating), e.Message?.Rating ?? pEpRating.pEpRatingUndefined) + ". KeyImport is " +
   4.487 -                                        e.Message?.KeyImport ?? "null");
   4.488 -                        }
   4.489 -                    }
   4.490 -                }
   4.491 -                catch (Exception ex)
   4.492 -                {
   4.493 -                    Log.Error("KeySyncWizard_SyncMessageReceived: Error processing sync message. " + ex.ToString());
   4.494 -                }
   4.495 -            }
   4.496 -        }
   4.497 -
   4.498 -        /// <summary>
   4.499 -        /// Event handler for when the label next to the Set Imported Key As Default checkbox
   4.500 -        /// is clicked.
   4.501 -        /// </summary>
   4.502 -        private void LabelSetImportedKeyAsDefault_MouseUp(object sender, MouseButtonEventArgs e)
   4.503 -        {
   4.504 -            this.SetImportedKeyAsDefault = (this.SetImportedKeyAsDefault == false);
   4.505 -        }
   4.506 -
   4.507 -        /// <summary>
   4.508 -        /// Raises the property changed event, if possible, with the given arguments.
   4.509 -        /// </summary>
   4.510 -        /// <param name="propertyName">The name of the property that changed.</param>
   4.511 -        private void RaisePropertyChangedEvent(string propertyName)
   4.512 -        {
   4.513 -            this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
   4.514 -            return;
   4.515 -        }
   4.516 -
   4.517 -        /// <summary>
   4.518 -        /// Shows the handshake window
   4.519 -        /// </summary>
   4.520 -        private bool ShowHandshake()
   4.521 -        {
   4.522 -            bool success = false;
   4.523 -
   4.524 -            try
   4.525 -            {
   4.526 -                // Update own identity if necessary
   4.527 -                if (string.IsNullOrEmpty(this.Myself?.Fingerprint))
   4.528 -                {
   4.529 -                    this.Myself = new PEPIdentity(ThisAddIn.PEPEngine.Myself(this.Myself.ToCOMType()));
   4.530 -                }
   4.531 -
   4.532 -                // Reset partner identity
   4.533 -                try
   4.534 -                {
   4.535 -                    pEpIdentity partner = this.Partner.ToCOMType();
   4.536 -                    ThisAddIn.PEPEngine.KeyResetTrust(partner);
   4.537 -                    this.PartnerIdentityReset = true;
   4.538 -                }
   4.539 -                catch (Exception ex)
   4.540 -                {
   4.541 -                    Log.Error("InitializeWizard: Error resetting partner trust. " + ex.ToString());
   4.542 -                }
   4.543 -
   4.544 -                // Create handshake item
   4.545 -                if (this.CreateHandshakeItem())
   4.546 -                {
   4.547 -                    // Set success flag
   4.548 -                    success = true;
   4.549 -
   4.550 -                    // Send answer message with pub key
   4.551 -                    this.SendSyncMessage(MessageTypes.PublicKeyMessage);
   4.552 -                }
   4.553 -                else
   4.554 -                {
   4.555 -                    Log.Error("KeySyncWizard: Error creating handshake item.");
   4.556 -                }
   4.557 -            }
   4.558 -            catch (Exception ex)
   4.559 -            {
   4.560 -                Log.Error("KeySyncWizard: Error updating Myself. " + ex.ToString());
   4.561 -            }
   4.562 -
   4.563 -            return success;
   4.564 -        }
   4.565 -
   4.566 -        /// <summary>
   4.567 -        /// Event handler for when the window is closed.
   4.568 -        /// </summary>
   4.569 -        private void Window_Closed(object sender, EventArgs e)
   4.570 -        {
   4.571 -            // Remove event handler
   4.572 -            MsgProcessor.SyncMessageReceived += KeySyncWizard_SyncMessageReceived;
   4.573 -
   4.574 -            // Cancel fast polling
   4.575 -            this.ToggleFastPolling(false);
   4.576 -
   4.577 -            // Reset static references
   4.578 -            KeySyncWizard.Wizard = new KeySyncWizard();
   4.579 -        }
   4.580 -
   4.581 -        #endregion
   4.582 -
   4.583 -        #region Methods
   4.584 -        /**************************************************************
   4.585 -         * 
   4.586 -         * Methods
   4.587 -         * 
   4.588 -         *************************************************************/
   4.589 -
   4.590 -        /// <summary>
   4.591 -        /// Adds the given PEPMessage to the list of received sync messages.
   4.592 -        /// </summary>
   4.593 -        /// <param name="message">The PEPMessage to add to the list.</param>
   4.594 -        public void AddToReceivedSyncMessages(PEPMessage message)
   4.595 -        {
   4.596 -            /* Add message to list if:
   4.597 -             *  1.  a. WizardType is PGP and message is secure
   4.598 -             *      b. WizardType is pEp, the current step is Step 2 and the
   4.599 -             *         message hasn't been sent from myself
   4.600 -             *  2. Message is not in the list yet
   4.601 -             *  3. List has max 5 items
   4.602 -             */
   4.603 -            lock (mutexReceivedSyncMessages)
   4.604 -            {
   4.605 -                if (((this.Type == WizardType.PGP) &&
   4.606 -                     (message.IsSecure) ||
   4.607 -                     ((this.Type == WizardType.pEp) &&
   4.608 -                      (this.Step == Steps.Step2) &&
   4.609 -                      (message?.KeyImport?.Equals(this.Myself?.Fingerprint) == false))) &&
   4.610 -                    (this.receivedSyncMessages?.Find(a => (a.Id?.Equals(message.Id) == true)) == null) &&
   4.611 -                    (this.receivedSyncMessages?.Count <= 5))
   4.612 -                {
   4.613 -                    this.receivedSyncMessages?.Add(message);
   4.614 -                }
   4.615 -            }
   4.616 -        }
   4.617 -
   4.618 -        /// <summary>
   4.619 -        /// Closes the wizard and resets the partner identity in the management.db.
   4.620 -        /// </summary>
   4.621 -        private void CancelWizard()
   4.622 -        {
   4.623 -            pEpIdentity? partner = this.Partner?.Copy()?.ToCOMType();
   4.624 -
   4.625 -            if (string.IsNullOrEmpty(partner?.fpr) == false)
   4.626 -            {
   4.627 -                Task.Factory.StartNew(new Action(() =>
   4.628 -                {
   4.629 -                    try
   4.630 -                    {
   4.631 -                        ThisAddIn.PEPEngine.KeyResetTrust((pEpIdentity)partner);
   4.632 -                    }
   4.633 -                    catch (Exception ex)
   4.634 -                    {
   4.635 -                        Log.Error("CancelWizard: Error resetting identity. " + ex.ToString());
   4.636 -                    }
   4.637 -                }), TaskCreationOptions.LongRunning);
   4.638 -            }
   4.639 -
   4.640 -            this.Close();
   4.641 -        }
   4.642 -
   4.643 -        /// <summary>
   4.644 -        /// Completes the process and moves wizard to last step.
   4.645 -        /// Sets the imported private key as own key, if needed.
   4.646 -        /// </summary>
   4.647 -        private void CompleteWizard()
   4.648 -        {
   4.649 -            // Marshall to main thread
   4.650 -            this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
   4.651 -            {
   4.652 -                bool success = false;
   4.653 -
   4.654 -                // Private key message received. Set key as default if needed.
   4.655 -                if (this.IsInitiator)
   4.656 -                {
   4.657 -                    try
   4.658 -                    {
   4.659 -                        ThisAddIn.PEPEngine.SetOwnKey(this._Partner.ToCOMType(), this.Partner.Fingerprint);
   4.660 -                        success = true;
   4.661 -                        Log.Verbose("CompleteWizard: Key import process finished. Key with fingerprint " + this.Partner.Fingerprint + " set as new default key.");
   4.662 -                    }
   4.663 -                    catch (Exception ex)
   4.664 -                    {
   4.665 -                        success = false;
   4.666 -                        Log.Error("CompleteWizard: Error trusting partner key. " + ex.ToString());
   4.667 -                    }
   4.668 -                }
   4.669 -                else
   4.670 -                {
   4.671 -                    success = true;
   4.672 -                    Log.Verbose("CompleteWizard: Private key imported. Won't be used as default.");
   4.673 -                }
   4.674 -
   4.675 -                this.GoToLastStep(success);
   4.676 -            }));
   4.677 -        }
   4.678 -
   4.679 -        /// <summary>
   4.680 -        /// Creates the only handshake item for this wizard and adds it to the
   4.681 -        /// Items collection if successful.
   4.682 -        /// </summary>
   4.683 -        /// <returns>True if the item was created successfully, otherwise false.</returns>
   4.684 -        private bool CreateHandshakeItem()
   4.685 -        {
   4.686 -            bool success = false;
   4.687 -
   4.688 -            //if (HandshakeItem.Create(this.Myself, this.Partner, false, out HandshakeItem item) == Globals.ReturnStatus.Success)
   4.689 -            //{
   4.690 -            //    item.AreTabControlsVisible = false;
   4.691 -            //    item.ActiveTab = (this.Type == WizardType.pEp) ? HandshakeItem.Tabs.Trustwords : HandshakeItem.Tabs.Fingerprint;
   4.692 -            //    item.AreHandshakeButtonsVisible = false;
   4.693 -            //    item.Mode = HandshakeItem.HandshakeMode.Sync;
   4.694 -            //    item.IsLanguageSelectorVisible = (this.Type == WizardType.pEp);
   4.695 -            //    this.Items.Add(item);
   4.696 -
   4.697 -            //    success = true;
   4.698 -            //    Log.Verbose("CreateHandshakeItem: Handshake item successfully created.");
   4.699 -            //}
   4.700 -
   4.701 -            return success;
   4.702 -        }
   4.703 -
   4.704 -        /// <summary>
   4.705 -        /// Creates a list of wizard states that serve as model for the wizard.
   4.706 -        /// The pEp Key Import process consists of the following steps:
   4.707 -        ///     Step 1:
   4.708 -        ///         a. Is initiator(user opened wizard): Info message that sync message has been sent.
   4.709 -        ///            Waiting for answer message from other device.
   4.710 -        ///         b. Is not initiator (wizard opened through sync message): Info message that key import has been started.
   4.711 -        ///            Waiting for user decision to continue or abort.
   4.712 -        ///     Step 2:
   4.713 -        ///         - Show trustwords. User interaction: confirm or cancel.
   4.714 -        ///     Step 3: 
   4.715 -        ///         - Private keys have been sent. Waiting for answer message from other device.
   4.716 -        ///     Step 4: 
   4.717 -        ///         - Only on initiator side: Ask user if they want to set imported key as default. Next or Cancel.
   4.718 -        ///     Success:
   4.719 -        ///         - Key Import successfully finished.
   4.720 -        ///     Error:
   4.721 -        ///         - An error occured during the Key Import process.
   4.722 -        /// </summary>
   4.723 -        /// <returns>The list of wizard states.</returns>
   4.724 -        private List<WizardState> CreatePEPWizardStates()
   4.725 -        {
   4.726 -            List<WizardState> states = new List<WizardState>();
   4.727 -
   4.728 -            try
   4.729 -            {
   4.730 -                // Step 1
   4.731 -                states.Add(new WizardState
   4.732 -                {
   4.733 -                    // Step
   4.734 -                    Step = Steps.Step1,
   4.735 -
   4.736 -                    // Title text
   4.737 -                    TitleText = this.IsInitiator ? Properties.Resources.KeySyncWizard_PEPStep1ExplanationText : Properties.Resources.KeySyncWizard_PEPStep1NonInitiatorExplanationText,
   4.738 -
   4.739 -                    // Central area
   4.740 -                    AreTrustwordsVisible = false,
   4.741 -                    UserText = this.UserName,
   4.742 -
   4.743 -                    // Back button
   4.744 -                    IsBackButtonVisible = false,
   4.745 -
   4.746 -                    // Accept button
   4.747 -                    AcceptButtonText = Properties.Resources.KeySyncWizard_Start,
   4.748 -                    IsAcceptButtonVisible = (this.IsInitiator == false),
   4.749 -                    AcceptButtonClick = new Action(() =>
   4.750 -                    {
   4.751 -                        if (this.ShowHandshake())
   4.752 -                        {
   4.753 -                            this.GoToNextStep();
   4.754 -                        }
   4.755 -                        else
   4.756 -                        {
   4.757 -                            this.GoToLastStep(false);
   4.758 -                        }
   4.759 -                    }),
   4.760 -
   4.761 -                    // Cancel button
   4.762 -                    CancelButtonText = Properties.Resources.Options_CancelText,
   4.763 -                    IsCancelButtonVisible = true,
   4.764 -                    CancelButtonClick = new Action(() =>
   4.765 -                    {
   4.766 -                        this.CancelWizard();
   4.767 -                    }),
   4.768 -
   4.769 -                    // Progress bar
   4.770 -                    IsProgressBarVisible = this.IsInitiator,
   4.771 -
   4.772 -                    // Subtitle area
   4.773 -                    SubtitleText = this.IsInitiator ? Properties.Resources.KeySyncWizard_WaitingForResponseText : null
   4.774 -                });
   4.775 -
   4.776 -                // Step 2
   4.777 -                states.Add(new WizardState
   4.778 -                {
   4.779 -                    // Step
   4.780 -                    Step = Steps.Step2,
   4.781 -
   4.782 -                    // Title text
   4.783 -                    TitleText = Properties.Resources.KeySyncWizard_PEPStep2ExplanationText,
   4.784 -
   4.785 -                    // Central area
   4.786 -                    AreTrustwordsVisible = true,
   4.787 -
   4.788 -                    // Back button
   4.789 -                    IsBackButtonVisible = false,
   4.790 -
   4.791 -                    // Accept button
   4.792 -                    AcceptButtonText = Properties.Resources.Handshake_ConfirmTrustwords,
   4.793 -                    AcceptButtonStyle = KeySyncWizard.greenButtonStyle,
   4.794 -                    IsAcceptButtonVisible = true,
   4.795 -                    AcceptButtonClick = new Action(() =>
   4.796 -                    {
   4.797 -                        this.GoToNextStep();
   4.798 -                        this.TrustKey();
   4.799 -                    }),
   4.800 -
   4.801 -                    // Cancel button
   4.802 -                    CancelButtonText = Properties.Resources.Handshake_WrongTrustwords,
   4.803 -                    CancelButtonStyle = KeySyncWizard.redButtonStyle,
   4.804 -                    IsCancelButtonVisible = true,
   4.805 -                    CancelButtonClick = new Action(() =>
   4.806 -                    {
   4.807 -                        this.CancelWizard();
   4.808 -                    }),
   4.809 -
   4.810 -                    // Subtitle area
   4.811 -                    SubtitleText = null
   4.812 -                });
   4.813 -
   4.814 -                // Step 3
   4.815 -                states.Add(new WizardState
   4.816 -                {
   4.817 -                    // Step
   4.818 -                    Step = Steps.Step3,
   4.819 -
   4.820 -                    // Title text
   4.821 -                    TitleText = Properties.Resources.KeySyncWizard_PEPStep3ExplanationText,
   4.822 -
   4.823 -                    // Central area
   4.824 -                    AreTrustwordsVisible = false,
   4.825 -                    UserText = this.UserName,
   4.826 -
   4.827 -                    // Back button
   4.828 -                    IsBackButtonVisible = false,
   4.829 -
   4.830 -                    // Accept button
   4.831 -                    IsAcceptButtonVisible = false,
   4.832 -
   4.833 -                    // Cancel button
   4.834 -                    CancelButtonText = Properties.Resources.Options_CancelText,
   4.835 -                    IsCancelButtonVisible = true,
   4.836 -                    CancelButtonClick = new Action(() =>
   4.837 -                    {
   4.838 -                        this.CancelWizard();
   4.839 -                    }),
   4.840 -
   4.841 -                    // Progress bar
   4.842 -                    IsProgressBarVisible = true,
   4.843 -
   4.844 -                    // Subtitle area
   4.845 -                    SubtitleText = Properties.Resources.KeySyncWizard_WaitingForResponseText
   4.846 -                });
   4.847 -
   4.848 -                // Success
   4.849 -                states.Add(new WizardState
   4.850 -                {
   4.851 -                    // Step
   4.852 -                    Step = Steps.Success,
   4.853 -
   4.854 -                    // Title text
   4.855 -                    TitleText = null,
   4.856 -
   4.857 -                    // Central area
   4.858 -                    AreTrustwordsVisible = false,
   4.859 -                    UserText = this.UserName,
   4.860 -
   4.861 -                    // Back button
   4.862 -                    IsBackButtonVisible = false,
   4.863 -
   4.864 -                    // Accept button
   4.865 -                    AcceptButtonText = Properties.Resources.KeySyncWizard_Finish,
   4.866 -                    IsAcceptButtonVisible = true,
   4.867 -                    AcceptButtonClick = new Action(() =>
   4.868 -                    {
   4.869 -                        this.Close();
   4.870 -                    }),
   4.871 -
   4.872 -                    // Cancel button
   4.873 -                    IsCancelButtonVisible = false,
   4.874 -
   4.875 -                    // Subtitle area
   4.876 -                    SubtitleText = null
   4.877 -                });
   4.878 -
   4.879 -                // Error
   4.880 -                states.Add(new WizardState
   4.881 -                {
   4.882 -                    // Step
   4.883 -                    Step = Steps.Error,
   4.884 -
   4.885 -                    // Title text
   4.886 -                    TitleText = Properties.Resources.KeySyncWizard_ErrorExplanationText,
   4.887 -
   4.888 -                    // Central area
   4.889 -                    AreTrustwordsVisible = false,
   4.890 -                    UserText = this.UserName,
   4.891 -
   4.892 -                    // Back button
   4.893 -                    IsBackButtonVisible = false,
   4.894 -
   4.895 -                    // Accept button
   4.896 -                    AcceptButtonText = Properties.Resources.KeySyncWizard_Finish,
   4.897 -                    IsAcceptButtonVisible = true,
   4.898 -                    AcceptButtonClick = new Action(() =>
   4.899 -                    {
   4.900 -                        this.CancelWizard();
   4.901 -                    }),
   4.902 -
   4.903 -                    // Cancel button
   4.904 -                    IsCancelButtonVisible = false,
   4.905 -
   4.906 -                    // Subtitle area
   4.907 -                    SubtitleText = null
   4.908 -                });
   4.909 -            }
   4.910 -            catch (Exception ex)
   4.911 -            {
   4.912 -                states = null;
   4.913 -                Log.Error("CreateWizardStates: Error creating wizard states. " + ex.ToString());
   4.914 -            }
   4.915 -
   4.916 -            return states;
   4.917 -        }
   4.918 -
   4.919 -        /// <summary>
   4.920 -        /// Creates a list of wizard states that serve as model for the wizard.
   4.921 -        /// The PGP Key Import process consists of the following steps:
   4.922 -        ///     Steps 1-3:
   4.923 -        ///         - Instructions on how to prepare the answer message with pub key.
   4.924 -        ///     Step 4: 
   4.925 -        ///         - Waiting for answer message from other device.
   4.926 -        ///     Step 5: 
   4.927 -        ///         - Show fingerprints. Confirm or deny them.        
   4.928 -        ///     Step 6 - 7: 
   4.929 -        ///         - Instructions on how to prepare the answer message with private key.
   4.930 -        ///     Success:
   4.931 -        ///         - Key Import successfully finished.
   4.932 -        ///     Error:
   4.933 -        ///         - An error occured during the Key Import process.
   4.934 -        /// </summary>
   4.935 -        /// <returns>The list of wizard states.</returns>
   4.936 -        private List<WizardState> CreatePGPWizardStates()
   4.937 -        {
   4.938 -            List<WizardState> states = new List<WizardState>();
   4.939 -
   4.940 -            try
   4.941 -            {
   4.942 -                // Step 1
   4.943 -                states.Add(new WizardState
   4.944 -                {
   4.945 -                    // Step
   4.946 -                    Step = Steps.Step1,
   4.947 -
   4.948 -                    // Title text
   4.949 -                    TitleText = Properties.Resources.KeySyncWizard_PGPStep1ExplanationText,
   4.950 -
   4.951 -                    // Central area
   4.952 -                    AreTrustwordsVisible = false,
   4.953 -                    UserText = this.UserName,
   4.954 -
   4.955 -                    // Back button
   4.956 -                    IsBackButtonVisible = false,
   4.957 -
   4.958 -                    // Accept button
   4.959 -                    AcceptButtonText = Properties.Resources.KeySyncWizard_Next,
   4.960 -                    IsAcceptButtonVisible = true,
   4.961 -                    AcceptButtonClick = new Action(() =>
   4.962 -                    {
   4.963 -                        this.GoToNextStep();
   4.964 -                    }),
   4.965 -
   4.966 -                    // Cancel button
   4.967 -                    CancelButtonText = Properties.Resources.Options_CancelText,
   4.968 -                    IsCancelButtonVisible = true,
   4.969 -                    CancelButtonClick = new Action(() =>
   4.970 -                    {
   4.971 -                        this.CancelWizard();
   4.972 -                    }),
   4.973 -
   4.974 -                    // Subtitle area
   4.975 -                    SubtitleText = null
   4.976 -                });
   4.977 -
   4.978 -                // Step 2
   4.979 -                states.Add(new WizardState
   4.980 -                {
   4.981 -                    // Step
   4.982 -                    Step = Steps.Step2,
   4.983 -
   4.984 -                    // Title text
   4.985 -                    TitleText = Properties.Resources.KeySyncWizard_PGPStep2ExplanationText,
   4.986 -
   4.987 -                    // Central area
   4.988 -                    AreTrustwordsVisible = false,
   4.989 -                    UserText = this.UserName,
   4.990 -
   4.991 -                    // Back button
   4.992 -                    IsBackButtonVisible = true,
   4.993 -                    BackButtonClick = new Action(() =>
   4.994 -                    {
   4.995 -                        this.GoToPreviousStep();
   4.996 -                    }),
   4.997 -
   4.998 -                    // Accept button
   4.999 -                    AcceptButtonText = Properties.Resources.KeySyncWizard_Next,
  4.1000 -                    IsAcceptButtonVisible = true,
  4.1001 -                    AcceptButtonClick = new Action(() =>
  4.1002 -                    {
  4.1003 -                        this.GoToNextStep();
  4.1004 -                    }),
  4.1005 -
  4.1006 -                    // Cancel button
  4.1007 -                    CancelButtonText = Properties.Resources.Options_CancelText,
  4.1008 -                    IsCancelButtonVisible = true,
  4.1009 -                    CancelButtonClick = new Action(() =>
  4.1010 -                    {
  4.1011 -                        this.CancelWizard();
  4.1012 -                    }),
  4.1013 -
  4.1014 -                    // Subtitle area
  4.1015 -                    SubtitleText = null
  4.1016 -                });
  4.1017 -
  4.1018 -                // Step 3
  4.1019 -                states.Add(new WizardState
  4.1020 -                {
  4.1021 -                    // Step
  4.1022 -                    Step = Steps.Step3,
  4.1023 -
  4.1024 -                    // Title text
  4.1025 -                    TitleText = Properties.Resources.KeySyncWizard_PGPStep3ExplanationText,
  4.1026 -
  4.1027 -                    // Central area
  4.1028 -                    AreTrustwordsVisible = false,
  4.1029 -                    UserText = this.UserName,
  4.1030 -
  4.1031 -                    // Back button
  4.1032 -                    IsBackButtonVisible = true,
  4.1033 -                    BackButtonClick = new Action(() =>
  4.1034 -                    {
  4.1035 -                        this.GoToPreviousStep();
  4.1036 -                    }),
  4.1037 -
  4.1038 -                    // Accept button
  4.1039 -                    AcceptButtonText = Properties.Resources.KeySyncWizard_Next,
  4.1040 -                    IsAcceptButtonVisible = true,
  4.1041 -                    AcceptButtonClick = new Action(() =>
  4.1042 -                    {
  4.1043 -                        this.GoToNextStep();
  4.1044 -                        this.ProcessReceivedSyncMessages();
  4.1045 -                    }),
  4.1046 -
  4.1047 -                    // Cancel button
  4.1048 -                    CancelButtonText = Properties.Resources.Options_CancelText,
  4.1049 -                    IsCancelButtonVisible = true,
  4.1050 -                    CancelButtonClick = new Action(() =>
  4.1051 -                    {
  4.1052 -                        this.CancelWizard();
  4.1053 -                    }),
  4.1054 -
  4.1055 -                    // Subtitle area
  4.1056 -                    SubtitleText = null
  4.1057 -                });
  4.1058 -
  4.1059 -                // Step 4
  4.1060 -                states.Add(new WizardState
  4.1061 -                {
  4.1062 -                    // Step
  4.1063 -                    Step = Steps.Step4,
  4.1064 -
  4.1065 -                    // Title text
  4.1066 -                    TitleText = Properties.Resources.KeySyncWizard_WaitingForResponseText,
  4.1067 -
  4.1068 -                    // Central area
  4.1069 -                    AreTrustwordsVisible = false,
  4.1070 -                    UserText = this.UserName,
  4.1071 -
  4.1072 -                    // Back button
  4.1073 -                    IsBackButtonVisible = true,
  4.1074 -                    BackButtonClick = new Action(() =>
  4.1075 -                    {
  4.1076 -                        this.GoToPreviousStep();
  4.1077 -                    }),
  4.1078 -
  4.1079 -                    // Accept button
  4.1080 -                    IsAcceptButtonVisible = false,
  4.1081 -
  4.1082 -                    // Cancel button
  4.1083 -                    CancelButtonText = Properties.Resources.Options_CancelText,
  4.1084 -                    IsCancelButtonVisible = true,
  4.1085 -                    CancelButtonClick = new Action(() =>
  4.1086 -                    {
  4.1087 -                        this.CancelWizard();
  4.1088 -                    }),
  4.1089 -
  4.1090 -                    // Subtitle area
  4.1091 -                    SubtitleText = null
  4.1092 -                });
  4.1093 -
  4.1094 -                // Step 5
  4.1095 -                states.Add(new WizardState
  4.1096 -                {
  4.1097 -                    // Step
  4.1098 -                    Step = Steps.Step5,
  4.1099 -
  4.1100 -                    // Title text
  4.1101 -                    TitleText = Properties.Resources.KeySyncWizard_PGPStep5ExplanationText,
  4.1102 -
  4.1103 -                    // Central area
  4.1104 -                    AreTrustwordsVisible = true,
  4.1105 -
  4.1106 -                    // Back button
  4.1107 -                    IsBackButtonVisible = false,
  4.1108 -
  4.1109 -                    // Accept button
  4.1110 -                    AcceptButtonText = Properties.Resources.Handshake_ConfirmFingerprint,
  4.1111 -                    AcceptButtonStyle = KeySyncWizard.greenButtonStyle,
  4.1112 -                    IsAcceptButtonVisible = true,
  4.1113 -                    AcceptButtonClick = new Action(() =>
  4.1114 -                    {
  4.1115 -                        this.GoToNextStep();
  4.1116 -                        this.TrustKey();
  4.1117 -                    }),
  4.1118 -
  4.1119 -                    // Cancel button
  4.1120 -                    CancelButtonText = Properties.Resources.Handshake_WrongFingerprint,
  4.1121 -                    CancelButtonStyle = KeySyncWizard.redButtonStyle,
  4.1122 -                    IsCancelButtonVisible = true,
  4.1123 -                    CancelButtonClick = new Action(() =>
  4.1124 -                    {
  4.1125 -                        this.CancelWizard();
  4.1126 -                    }),
  4.1127 -
  4.1128 -                    // Subtitle area
  4.1129 -                    SubtitleText = null
  4.1130 -                });
  4.1131 -
  4.1132 -                // Step 6
  4.1133 -                states.Add(new WizardState
  4.1134 -                {
  4.1135 -                    // Step
  4.1136 -                    Step = Steps.Step6,
  4.1137 -
  4.1138 -                    // Title text
  4.1139 -                    TitleText = Properties.Resources.KeySyncWizard_PGPStep6ExplanationText,
  4.1140 -
  4.1141 -                    // Central area
  4.1142 -                    AreTrustwordsVisible = false,
  4.1143 -                    UserText = this.UserName,
  4.1144 -
  4.1145 -                    // Back button
  4.1146 -                    IsBackButtonVisible = false,
  4.1147 -
  4.1148 -                    // Accept button
  4.1149 -                    AcceptButtonText = Properties.Resources.KeySyncWizard_Next,
  4.1150 -                    IsAcceptButtonVisible = true,
  4.1151 -                    AcceptButtonClick = new Action(() =>
  4.1152 -                    {
  4.1153 -                        this.GoToNextStep();
  4.1154 -                    }),
  4.1155 -
  4.1156 -                    // Cancel button
  4.1157 -                    CancelButtonText = Properties.Resources.Options_CancelText,
  4.1158 -                    IsCancelButtonVisible = true,
  4.1159 -                    CancelButtonClick = new Action(() =>
  4.1160 -                    {
  4.1161 -                        this.CancelWizard();
  4.1162 -                    }),
  4.1163 -
  4.1164 -                    // Subtitle area
  4.1165 -                    SubtitleText = null
  4.1166 -                });
  4.1167 -
  4.1168 -                // Step 7
  4.1169 -                states.Add(new WizardState
  4.1170 -                {
  4.1171 -                    // Step
  4.1172 -                    Step = Steps.Step7,
  4.1173 -
  4.1174 -                    // Title text
  4.1175 -                    TitleText = Properties.Resources.KeySyncWizard_PGPStep7ExplanationText,
  4.1176 -
  4.1177 -                    // Central area
  4.1178 -                    AreTrustwordsVisible = false,
  4.1179 -                    UserText = this.UserName,
  4.1180 -
  4.1181 -                    // Back button
  4.1182 -                    IsBackButtonVisible = true,
  4.1183 -                    BackButtonClick = new Action(() =>
  4.1184 -                    {
  4.1185 -                        this.GoToPreviousStep();
  4.1186 -                    }),
  4.1187 -
  4.1188 -                    // Accept button
  4.1189 -                    AcceptButtonText = Properties.Resources.KeySyncWizard_Next,
  4.1190 -                    IsAcceptButtonVisible = true,
  4.1191 -                    AcceptButtonClick = new Action(() =>
  4.1192 -                    {
  4.1193 -                        this.GoToNextStep();
  4.1194 -                        this.ProcessReceivedSyncMessages();
  4.1195 -                    }),
  4.1196 -
  4.1197 -                    // Cancel button
  4.1198 -                    CancelButtonText = Properties.Resources.Options_CancelText,
  4.1199 -                    IsCancelButtonVisible = true,
  4.1200 -                    CancelButtonClick = new Action(() =>
  4.1201 -                    {
  4.1202 -                        this.CancelWizard();
  4.1203 -                    }),
  4.1204 -
  4.1205 -                    // Subtitle area
  4.1206 -                    SubtitleText = null
  4.1207 -                });
  4.1208 -
  4.1209 -                // Step 8
  4.1210 -                states.Add(new WizardState
  4.1211 -                {
  4.1212 -                    // Step
  4.1213 -                    Step = Steps.Step8,
  4.1214 -
  4.1215 -                    // Title text
  4.1216 -                    TitleText = Properties.Resources.KeySyncWizard_WaitingForResponseText,
  4.1217 -
  4.1218 -                    // Central area
  4.1219 -                    AreTrustwordsVisible = false,
  4.1220 -                    UserText = this.UserName,
  4.1221 -
  4.1222 -                    // Back button
  4.1223 -                    IsBackButtonVisible = true,
  4.1224 -                    BackButtonClick = new Action(() =>
  4.1225 -                    {
  4.1226 -                        this.GoToPreviousStep();
  4.1227 -                    }),
  4.1228 -
  4.1229 -                    // Accept button
  4.1230 -                    IsAcceptButtonVisible = false,
  4.1231 -
  4.1232 -                    // Cancel button
  4.1233 -                    CancelButtonText = Properties.Resources.Options_CancelText,
  4.1234 -                    IsCancelButtonVisible = true,
  4.1235 -                    CancelButtonClick = new Action(() =>
  4.1236 -                    {
  4.1237 -                        this.CancelWizard();
  4.1238 -                    }),
  4.1239 -
  4.1240 -                    // Subtitle area
  4.1241 -                    SubtitleText = null
  4.1242 -                });
  4.1243 -
  4.1244 -                // Success
  4.1245 -                states.Add(new WizardState
  4.1246 -                {
  4.1247 -                    // Step
  4.1248 -                    Step = Steps.Success,
  4.1249 -
  4.1250 -                    // Title text
  4.1251 -                    TitleText = Properties.Resources.KeySyncWizard_PGPSuccessExplanationText,
  4.1252 -
  4.1253 -                    // Central area
  4.1254 -                    AreTrustwordsVisible = false,
  4.1255 -                    UserText = this.UserName,
  4.1256 -
  4.1257 -                    // Back button
  4.1258 -                    IsBackButtonVisible = false,
  4.1259 -
  4.1260 -                    // Accept button
  4.1261 -                    AcceptButtonText = Properties.Resources.KeySyncWizard_Finish,
  4.1262 -                    IsAcceptButtonVisible = true,
  4.1263 -                    AcceptButtonClick = new Action(() =>
  4.1264 -                    {
  4.1265 -                        this.Close();
  4.1266 -                    }),
  4.1267 -
  4.1268 -                    // Cancel button
  4.1269 -                    IsCancelButtonVisible = false,
  4.1270 -
  4.1271 -                    // Subtitle area
  4.1272 -                    SubtitleText = null
  4.1273 -                });
  4.1274 -
  4.1275 -                // Error
  4.1276 -                states.Add(new WizardState
  4.1277 -                {
  4.1278 -                    // Step
  4.1279 -                    Step = Steps.Error,
  4.1280 -
  4.1281 -                    // Title text
  4.1282 -                    TitleText = Properties.Resources.KeySyncWizard_ErrorExplanationText,
  4.1283 -
  4.1284 -                    // Central area
  4.1285 -                    AreTrustwordsVisible = false,
  4.1286 -                    UserText = this.UserName,
  4.1287 -
  4.1288 -                    // Back button
  4.1289 -                    IsBackButtonVisible = false,
  4.1290 -
  4.1291 -                    // Accept button
  4.1292 -                    AcceptButtonText = Properties.Resources.KeySyncWizard_Finish,
  4.1293 -                    IsAcceptButtonVisible = true,
  4.1294 -                    AcceptButtonClick = new Action(() =>
  4.1295 -                    {
  4.1296 -                        this.CancelWizard();
  4.1297 -                    }),
  4.1298 -
  4.1299 -                    // Cancel button
  4.1300 -                    IsCancelButtonVisible = false,
  4.1301 -
  4.1302 -                    // Subtitle area
  4.1303 -                    SubtitleText = null
  4.1304 -                });
  4.1305 -            }
  4.1306 -            catch (Exception ex)
  4.1307 -            {
  4.1308 -                states = null;
  4.1309 -                Log.Error("CreateWizardStates: Error creating wizard states. " + ex.ToString());
  4.1310 -            }
  4.1311 -
  4.1312 -            return states;
  4.1313 -        }
  4.1314 -
  4.1315 -        /// <summary>
  4.1316 -        /// Navigates to the last step of the wizard.
  4.1317 -        /// </summary>
  4.1318 -        /// <param name="success">Whether or not the wizard has been completed successfully.</param>
  4.1319 -        private void GoToLastStep(bool success)
  4.1320 -        {
  4.1321 -            // Go to last step
  4.1322 -            this.Step = success ? Steps.Success : Steps.Error;
  4.1323 -
  4.1324 -            // Update wording and state
  4.1325 -            var lastState = this.states.Find(a => a.Step == this.Step);
  4.1326 -
  4.1327 -            if (success)
  4.1328 -            {
  4.1329 -                if (this.IsInitiator)
  4.1330 -                {
  4.1331 -                    if (this.SetImportedKeyAsDefault)
  4.1332 -                    {
  4.1333 -                        lastState.TitleText = Properties.Resources.KeySyncWizard_PEPSuccessImport + "\n\n" + Properties.Resources.KeySyncWizard_PEPSuccessOtherKeyUsedAsDefault;
  4.1334 -                    }
  4.1335 -                    else
  4.1336 -                    {
  4.1337 -                        lastState.TitleText = Properties.Resources.KeySyncWizard_PEPSuccessImport + "\n\n" + Properties.Resources.KeySyncWizard_PEPSuccessOtherKeyUsed;
  4.1338 -                    }
  4.1339 -                }
  4.1340 -                else
  4.1341 -                {
  4.1342 -                    if (this.privateKeyImported)
  4.1343 -                    {
  4.1344 -                        lastState.TitleText = Properties.Resources.KeySyncWizard_PEPSuccessExport + "\n\n" + Properties.Resources.KeySyncWizard_PEPSuccessOtherKeyUsed;
  4.1345 -                    }
  4.1346 -                    else
  4.1347 -                    {
  4.1348 -                        lastState.TitleText = Properties.Resources.KeySyncWizard_PEPSuccessExport;
  4.1349 -                    }
  4.1350 -                }
  4.1351 -            }
  4.1352 -
  4.1353 -            // Apply state
  4.1354 -            this.CurrentState = lastState;
  4.1355 -
  4.1356 -            // Disable Fast Polling
  4.1357 -            this.ToggleFastPolling(false);
  4.1358 -
  4.1359 -            Log.Verbose("GoToLastStep: Process finished. Success is " + success.ToString());
  4.1360 -        }
  4.1361 -
  4.1362 -        /// <summary>
  4.1363 -        /// Navigates to the next step of the wizard.
  4.1364 -        /// </summary>
  4.1365 -        private void GoToNextStep()
  4.1366 -        {
  4.1367 -            // Go to next step
  4.1368 -            this.Step++;
  4.1369 -
  4.1370 -            // Set current state
  4.1371 -            this.CurrentState = states.Find(a => a.Step == this.Step);
  4.1372 -
  4.1373 -            Log.Verbose("GoToNextStep: New state: " + Enum.GetName(typeof(Steps), this.Step));
  4.1374 -        }
  4.1375 -
  4.1376 -        /// <summary>
  4.1377 -        /// Navigates to the previous state of the wizard.
  4.1378 -        /// </summary>
  4.1379 -        private void GoToPreviousStep()
  4.1380 -        {
  4.1381 -            // Go to next step
  4.1382 -            this.Step--;
  4.1383 -
  4.1384 -            // Set current state
  4.1385 -            this.CurrentState = states.Find(a => a.Step == this.Step);
  4.1386 -
  4.1387 -            Log.Verbose("GoToPreviousStep: New state: " + Enum.GetName(typeof(Steps), this.Step));
  4.1388 -        }
  4.1389 -
  4.1390 -        /// <summary>
  4.1391 -        /// Initializes the wizard.
  4.1392 -        /// </summary>
  4.1393 -        private void InitializeWizard(bool isInitiator,
  4.1394 -                                      WizardType type,
  4.1395 -                                      PEPIdentity myself,
  4.1396 -                                      string partnerFpr)
  4.1397 -        {
  4.1398 -            // Set initial state
  4.1399 -            this.DataContext = this;
  4.1400 -            this.Myself = myself;
  4.1401 -            this.Step = Steps.Step1;
  4.1402 -            this.Type = type;
  4.1403 -            this.IsInitiator = isInitiator;
  4.1404 -
  4.1405 -            // Set button styles
  4.1406 -            try
  4.1407 -            {
  4.1408 -                ResourceDictionary dictionary = Application.LoadComponent(new Uri("/pEp;component/Resources/Dictionary.xaml", UriKind.Relative)) as ResourceDictionary;
  4.1409 -                KeySyncWizard.greenButtonStyle = dictionary["StyleButtonConfirm"] as Style;
  4.1410 -                KeySyncWizard.redButtonStyle = dictionary["StyleButtonWrong"] as Style;
  4.1411 -            }
  4.1412 -            catch (Exception ex)
  4.1413 -            {
  4.1414 -                Log.Error("InitializeWizard: Error setting button styles. " + ex.ToString());
  4.1415 -            }
  4.1416 -
  4.1417 -            // If own identity is null, get default account
  4.1418 -            if (this.Myself == null)
  4.1419 -            {
  4.1420 -                PEPIdentity ownIdentity = null;
  4.1421 -                Outlook.Account account = null;
  4.1422 -                Outlook.Accounts accounts = null;
  4.1423 -                Outlook.Store deliveryStore = null;
  4.1424 -                Outlook.Explorer explorer = null;
  4.1425 -                Outlook.Folder folder = null;
  4.1426 -                Outlook.NameSpace ns = null;
  4.1427 -
  4.1428 -                // Try to get own identity for current account
  4.1429 -                try
  4.1430 -                {
  4.1431 -                    Log.Verbose("InitializeWizard: Myself is null. Trying to get default account.");
  4.1432 -
  4.1433 -                    explorer = Globals.ThisAddIn.Application.ActiveExplorer();
  4.1434 -                    folder = explorer?.CurrentFolder as Outlook.Folder;
  4.1435 -
  4.1436 -                    ns = Globals.ThisAddIn.Application.Session;
  4.1437 -                    accounts = ns.Accounts;
  4.1438 -
  4.1439 -                    // Note: Index starts at 1
  4.1440 -                    for (int i = 1; i <= accounts.Count; i++)
  4.1441 -                    {
  4.1442 -                        account = accounts[i];
  4.1443 -
  4.1444 -                        // Getting delivery store can fail for new accounts when Outlook is not restarted
  4.1445 -                        try
  4.1446 -                        {
  4.1447 -                            deliveryStore = account.DeliveryStore;
  4.1448 -                        }
  4.1449 -                        catch (Exception ex)
  4.1450 -                        {
  4.1451 -                            deliveryStore = null;
  4.1452 -                            Log.Error("InitializeWizard: Error getting delivery store. " + ex.ToString());
  4.1453 -                        }
  4.1454 -
  4.1455 -                        if (deliveryStore?.StoreID?.Equals(folder?.StoreID) == true)
  4.1456 -                        {
  4.1457 -                            if (PEPIdentity.GetOwnIdentity(account, out ownIdentity) != Globals.ReturnStatus.Success)
  4.1458 -                            {
  4.1459 -                                ownIdentity = null;
  4.1460 -                                Log.Error("InitializeWizard: Error getting own identity. ReturnStatus != Success.");
  4.1461 -                            }
  4.1462 -                            else
  4.1463 -                            {
  4.1464 -                                ownIdentity = new PEPIdentity(ThisAddIn.PEPEngine.Myself(ownIdentity.ToCOMType()));
  4.1465 -                            }
  4.1466 -                            break;
  4.1467 -                        }
  4.1468 -
  4.1469 -                        account = null;
  4.1470 -                        deliveryStore = null;
  4.1471 -                    }
  4.1472 -
  4.1473 -                    this.Myself = ownIdentity;
  4.1474 -
  4.1475 -                    Log.Verbose("InitializeWizard: Using default account " + ownIdentity.Address);
  4.1476 -                }
  4.1477 -                catch (Exception ex)
  4.1478 -                {
  4.1479 -                    ownIdentity = null;
  4.1480 -                    Log.Error("InitializeWizard: Error getting default account. " + ex.ToString());
  4.1481 -                }
  4.1482 -                finally
  4.1483 -                {
  4.1484 -                    account = null;
  4.1485 -                    accounts = null;
  4.1486 -                    deliveryStore = null;
  4.1487 -                    explorer = null;
  4.1488 -                    folder = null;
  4.1489 -                    ns = null;
  4.1490 -                }
  4.1491 -            }
  4.1492 -
  4.1493 -            // Make sure the myself identity is up-to-date
  4.1494 -            if (this.Myself?.Fingerprint == null)
  4.1495 -            {
  4.1496 -                this.Myself = new PEPIdentity(ThisAddIn.PEPEngine.Myself(this.Myself.ToCOMType()));
  4.1497 -                Log.Verbose("InitializeWizard: Fingerprint for myself retrieved.");
  4.1498 -            }
  4.1499 -
  4.1500 -            // If we have a partner fpr, set and reset identity
  4.1501 -            if ((this.Myself != null) &&
  4.1502 -                (partnerFpr != null))
  4.1503 -            {
  4.1504 -                this.Partner = this.Myself.Copy();
  4.1505 -                this.Partner.Fingerprint = partnerFpr;
  4.1506 -            }
  4.1507 -
  4.1508 -            // Define states
  4.1509 -            this.states = (this.Type == WizardType.pEp) ? this.CreatePEPWizardStates() : this.CreatePGPWizardStates();
  4.1510 -
  4.1511 -            // Set current state
  4.1512 -            this.CurrentState = states?.Find(a => a.Step == Steps.Step1);
  4.1513 -        }
  4.1514 -
  4.1515 -        /// <summary>
  4.1516 -        /// Runs through all received sync messages.
  4.1517 -        /// </summary>
  4.1518 -        private void ProcessReceivedSyncMessages()
  4.1519 -        {
  4.1520 -            lock (mutexReceivedSyncMessages)
  4.1521 -            {
  4.1522 -                if (this.receivedSyncMessages != null)
  4.1523 -                {
  4.1524 -                    foreach (var message in this.receivedSyncMessages)
  4.1525 -                    {
  4.1526 -                        try
  4.1527 -                        {
  4.1528 -                            Task.Factory.StartNew(new Action(() =>
  4.1529 -                            {
  4.1530 -                                MsgProcessor msgProcessor = new MsgProcessor();
  4.1531 -                                msgProcessor.Decrypt(message);
  4.1532 -                            }));
  4.1533 -                        }
  4.1534 -                        catch (Exception ex)
  4.1535 -                        {
  4.1536 -                            Log.Error("ProcessReceivedSyncMessages: Error processing sync message. " + ex.ToString());
  4.1537 -                        }
  4.1538 -                    }
  4.1539 -                }
  4.1540 -            }
  4.1541 -        }
  4.1542 -
  4.1543 -        /// <summary>
  4.1544 -        /// Sends the next sync message.
  4.1545 -        /// </summary>
  4.1546 -        private void SendSyncMessage(MessageTypes messageType)
  4.1547 -        {
  4.1548 -            // If we have an own identity, send message
  4.1549 -            if ((this.Myself != null) &&
  4.1550 -                (this.sentMessages?.Contains(messageType) == false))
  4.1551 -            {
  4.1552 -                try
  4.1553 -                {
  4.1554 -                    // Start sending in background
  4.1555 -                    Task.Factory.StartNew(new Action(() =>
  4.1556 -                    {
  4.1557 -                        // If we have no partner at this point, use a copy of myself
  4.1558 -                        if (this.Partner == null)
  4.1559 -                        {
  4.1560 -                            this.Partner = this.Myself.Copy();
  4.1561 -                            this.Partner.Fingerprint = null;
  4.1562 -                            Log.Verbose("SendSyncMessage: Partner was null. Using copy of myself.");
  4.1563 -                        }
  4.1564 -
  4.1565 -                        // Create basic message
  4.1566 -                        PEPMessage message = new PEPMessage
  4.1567 -                        {
  4.1568 -                            From = this.Myself,
  4.1569 -                            ShortMsg = (this.Type == WizardType.PGP) ? Properties.Resources.KeySyncWizard_PGPInitialMessageSubject : PEPMessage.PEP_HIDDEN_SYNC_MESSAGE_SUBJECT,
  4.1570 -                            LongMsg = ((messageType == MessageTypes.InitialMessage) && (this.Type == WizardType.PGP)) ? Properties.Resources.KeySyncWizard_PGPInitialMessageBody : PEPMessage.PEP_HIDDEN_SYNC_MESSAGE_BODY,
  4.1571 -                            AutoConsume = (this.Type == WizardType.pEp) ? "yes" : null,
  4.1572 -                            Direction = pEpMsgDirection.pEpDirOutgoing,
  4.1573 -                            ForceUnencrypted = (messageType == MessageTypes.InitialMessage)  ? true : false,
  4.1574 -                            KeyImport = ((this.Type == WizardType.pEp) || ((this.Type == WizardType.PGP) && (messageType == MessageTypes.PrivateKeyMessage))) ? this.Myself.Fingerprint : null
  4.1575 -                        };
  4.1576 -                        message.To.Add(this.Partner);
  4.1577 -
  4.1578 -                        // Tunnel the fingerprint also through the Reply-To field in the following format: <fingerprint>@peptunnel.com
  4.1579 -                        string keyImportAddress = string.Concat(message.KeyImport, PEPMessage.PEPTUNNEL_MAIL_ADDRESS);
  4.1580 -                        message.ReplyTo.Add(new PEPIdentity(keyImportAddress));
  4.1581 -
  4.1582 -                        Log.Verbose("SendSyncMessage: Basic message successfully created.");
  4.1583 -
  4.1584 -                        // If message type isn't InitialMessage, encrypt it accordingly
  4.1585 -                        PEPMessage msg;
  4.1586 -                        MsgProcessor msgProcessor = new MsgProcessor();
  4.1587 -                        switch (messageType)
  4.1588 -                        {
  4.1589 -                            case MessageTypes.InitialMessage:
  4.1590 -                                {
  4.1591 -                                    if (msgProcessor.Encrypt(message, out msg, null, pEpEncryptFlags.pEpEncryptFlagDefault, pEpEncFormat.pEpEncNone))
  4.1592 -                                    {
  4.1593 -                                        Log.Verbose("SendSyncMessage: Initial message successfully created.");
  4.1594 -                                        message = msg;
  4.1595 -                                    }
  4.1596 -                                    else
  4.1597 -                                    {
  4.1598 -                                        Log.Error("SendSyncMessage: Error creating initial message.");
  4.1599 -                                        message = null;
  4.1600 -                                    }
  4.1601 -                                }
  4.1602 -                                break;
  4.1603 -                            case MessageTypes.PublicKeyMessage:
  4.1604 -                                {
  4.1605 -                                    // Encrypt using partner fpr as extra key
  4.1606 -                                    if (msgProcessor.Encrypt(message, out msg, new string[] { this.Partner.Fingerprint }))
  4.1607 -                                    {
  4.1608 -                                        Log.Verbose("SendSyncMessage: Public key message successfully created.");
  4.1609 -                                        message = msg;
  4.1610 -                                    }
  4.1611 -                                    else
  4.1612 -                                    {
  4.1613 -                                        Log.Error("SendSyncMessage: Error encrypting public key message.");
  4.1614 -                                        message = null;
  4.1615 -                                    }
  4.1616 -                                }
  4.1617 -                                break;
  4.1618 -                            case MessageTypes.PrivateKeyMessage:
  4.1619 -                                {
  4.1620 -                                    // Encrypt and add private key
  4.1621 -                                    if (msgProcessor.EncryptAndAddPrivateKey(message, out msg, this.Partner.Fingerprint))
  4.1622 -                                    {
  4.1623 -                                        Log.Verbose("SendSyncMessage: Private key message successfully created.");
  4.1624 -                                        message = msg;
  4.1625 -                                    }
  4.1626 -                                    else
  4.1627 -                                    {
  4.1628 -                                        Log.Error("SendSyncMessage: Error encrypting private key message.");
  4.1629 -                                        message = null;
  4.1630 -                                    }
  4.1631 -                                }
  4.1632 -                                break;
  4.1633 -                            case MessageTypes.Undefined:
  4.1634 -                            default:
  4.1635 -                                {
  4.1636 -                                    Log.Error("SendSyncMessage: Error determining message type.");
  4.1637 -                                }
  4.1638 -                                break;
  4.1639 -                        }
  4.1640 -
  4.1641 -                        // If we have a message, send it
  4.1642 -                        if (message != null)
  4.1643 -                        {
  4.1644 -                            Log.Verbose("SendSyncMessage: Sending message...");
  4.1645 -
  4.1646 -                            // Disable passive mode if needed
  4.1647 -                            bool reenablePassiveMode = false;
  4.1648 -                            if ((messageType == MessageTypes.InitialMessage) &&
  4.1649 -                                (Globals.ThisAddIn.Settings.IsPassiveModeEnabled))
  4.1650 -                            {
  4.1651 -                                try
  4.1652 -                                {
  4.1653 -                                    ThisAddIn.PEPEngine.PassiveMode(false);
  4.1654 -                                    reenablePassiveMode = true;
  4.1655 -                                    Log.Verbose("SendSyncMessage: Passive mode temporarily disabled.");
  4.1656 -                                }
  4.1657 -                                catch (Exception ex)
  4.1658 -                                {
  4.1659 -                                    Log.Error("SendSyncMessage: Error disabling passive mode. " + ex.ToString());
  4.1660 -                                }
  4.1661 -                            }
  4.1662 -
  4.1663 -                            // Send message (do not process as it's already processed at this point)
  4.1664 -                            Globals.ThisAddIn.CreateAndSendMessage(message, true, true, false);
  4.1665 -
  4.1666 -                            // Log that message has been sent
  4.1667 -                            this.sentMessages?.Add(messageType);
  4.1668 -
  4.1669 -                            // Reenable passive mode if needed
  4.1670 -                            if (reenablePassiveMode)
  4.1671 -                            {
  4.1672 -                                try
  4.1673 -                                {
  4.1674 -                                    ThisAddIn.PEPEngine.PassiveMode(Globals.ThisAddIn.Settings.IsPassiveModeEnabled);
  4.1675 -                                    Log.Verbose("SendSyncMessage: Passive mode reenabled.");
  4.1676 -                                }
  4.1677 -                                catch (Exception ex)
  4.1678 -                                {
  4.1679 -                                    Log.Error("SendSyncMessage: Error reenabling passive mode. " + ex.ToString());
  4.1680 -                                }
  4.1681 -                            }
  4.1682 -                        }
  4.1683 -                        else
  4.1684 -                        {
  4.1685 -                            Log.Error("SendSyncMessage: Myself identity is null.");
  4.1686 -                        }
  4.1687 -                    }), TaskCreationOptions.LongRunning);
  4.1688 -                }
  4.1689 -                catch (Exception ex)
  4.1690 -                {
  4.1691 -                    Log.Error("SendSyncMessage: Error sending sync message. " + ex.ToString());
  4.1692 -                }
  4.1693 -            }
  4.1694 -        }
  4.1695 -
  4.1696 -        /// <summary>
  4.1697 -        /// Enables or disables continuous Send and Receive calls.
  4.1698 -        /// </summary>
  4.1699 -        /// <param name="enable">Whether to enable or disable fast polling.</param>
  4.1700 -        private void ToggleFastPolling(bool enable)
  4.1701 -        {
  4.1702 -            Outlook.NameSpace ns = null;
  4.1703 -
  4.1704 -            if (enable)
  4.1705 -            {
  4.1706 -                Log.Verbose("ToggleFastPolling: Enabling fast polling.");
  4.1707 -
  4.1708 -                try
  4.1709 -                {
  4.1710 -                    int counter = 0;
  4.1711 -                    ns = Globals.ThisAddIn.Application.Session;
  4.1712 -                    timer = new System.Windows.Forms.Timer
  4.1713 -                    {
  4.1714 -                        Interval = FAST_POLLING_INTERVAL
  4.1715 -                    };
  4.1716 -                    timer.Tick += (s, e) =>
  4.1717 -                    {
  4.1718 -                        if (counter++ < MAX_POLLING_COUNT)
  4.1719 -                        {
  4.1720 -                            ns?.SendAndReceive(false);
  4.1721 -                            Log.Verbose("ToggleFastPolling: Calling Send and Receive.");
  4.1722 -                        }
  4.1723 -                        else
  4.1724 -                        {
  4.1725 -                            Log.Verbose("ToggleFastPolling: Timeout. Shutting down.");
  4.1726 -                            timer?.Stop();
  4.1727 -                            timer?.Dispose();
  4.1728 -                            timer = null;
  4.1729 -                            ns = null;
  4.1730 -                        }
  4.1731 -                    };
  4.1732 -                    timer.Start();
  4.1733 -                }
  4.1734 -                catch (Exception ex)
  4.1735 -                {
  4.1736 -                    Log.Verbose("ToggleFastPolling: Error occured. " + ex.ToString());
  4.1737 -                    timer?.Stop();
  4.1738 -                    timer?.Dispose();
  4.1739 -                    timer = null;
  4.1740 -                    ns = null;
  4.1741 -                }
  4.1742 -            }
  4.1743 -            else
  4.1744 -            {
  4.1745 -                Log.Verbose("ToggleFastPolling: Disabling fast polling.");
  4.1746 -                timer?.Stop();
  4.1747 -                timer?.Dispose();
  4.1748 -                timer = null;
  4.1749 -                ns = null;
  4.1750 -            }
  4.1751 -        }
  4.1752 -
  4.1753 -        /// <summary>
  4.1754 -        /// Trusts the communication partner key (makes the channel green).
  4.1755 -        /// </summary>
  4.1756 -        private void TrustKey()
  4.1757 -        {
  4.1758 -            if (this.Items?.Count == 1)
  4.1759 -            {
  4.1760 -                try
  4.1761 -                {
  4.1762 -                    // Run in background
  4.1763 -                    Task.Factory.StartNew(new Action(() =>
  4.1764 -                    {
  4.1765 -                        Log.Verbose("TrustKey: Trusting partner key...");
  4.1766 -
  4.1767 -                        // Trust the partner's key
  4.1768 -                        this._Partner = this.Items[0].Partner;
  4.1769 -                        pEpIdentity partner = this._Partner.ToCOMType();
  4.1770 -                        ThisAddIn.PEPEngine.TrustOwnKey(partner);
  4.1771 -
  4.1772 -                        // Process messages that might have been received
  4.1773 -                        this.ProcessReceivedSyncMessages();
  4.1774 -
  4.1775 -                    }), TaskCreationOptions.LongRunning).ContinueWith(new Action<Task>((result) =>
  4.1776 -                    {
  4.1777 -                        // If needed, send private key message to partner
  4.1778 -                        if (this.Type == WizardType.pEp)
  4.1779 -                        {
  4.1780 -                            Log.Verbose("TrustKey: Sending private key to partner.");
  4.1781 -                            this.SendSyncMessage(MessageTypes.PrivateKeyMessage);
  4.1782 -                        }
  4.1783 -                    }));
  4.1784 -                }
  4.1785 -                catch (Exception ex)
  4.1786 -                {
  4.1787 -                    this.GoToLastStep(false);
  4.1788 -                    Log.Error("TrustKey: Error trusting partner key. " + ex.ToString());
  4.1789 -                }
  4.1790 -            }
  4.1791 -            else
  4.1792 -            {
  4.1793 -                this.GoToLastStep(false);
  4.1794 -                Log.Error("TrustKey: Error trusting partner key. Items.Count = " + this.Items?.Count);
  4.1795 -            }
  4.1796 -        }
  4.1797 -
  4.1798 -        /// <summary>
  4.1799 -        /// Resets the object to its defaults.
  4.1800 -        /// </summary>
  4.1801 -        public void Reset()
  4.1802 -        {
  4.1803 -            this._CurrentState = new WizardState();
  4.1804 -            this._IsInitiator = false;
  4.1805 -            this._Items = new ObservableCollection<Handshake>();
  4.1806 -            this._Myself = null;
  4.1807 -            this._Partner = null;
  4.1808 -            this._PartnerIdentityReset = false;
  4.1809 -            this._Step = Steps.Undefined;
  4.1810 -            this._SetImportedKeyAsDefault = true;
  4.1811 -            this._Type = WizardType.Undefined;
  4.1812 -        }
  4.1813 -
  4.1814 -        #endregion
  4.1815 -
  4.1816 -        /// <summary>
  4.1817 -        /// Container to define a wizard state.
  4.1818 -        /// </summary>
  4.1819 -        public class WizardState
  4.1820 -        {
  4.1821 -            public Action                   AcceptButtonClick           { get; set; }   =   null;
  4.1822 -            public Style                    AcceptButtonStyle           { get; set; }   =   KeySyncWizard.greyButtonStyle;
  4.1823 -            public string                   AcceptButtonText            { get; set; }   =   null;
  4.1824 -            public bool                     AreTrustwordsVisible        { get; set; }   =   false;
  4.1825 -            public Action                   BackButtonClick             { get; set; }   =   null;
  4.1826 -            public Action                   CancelButtonClick           { get; set; }   =   null;
  4.1827 -            public Style                    CancelButtonStyle           { get; set; }   =   KeySyncWizard.greyButtonStyle;
  4.1828 -            public string                   CancelButtonText            { get; set; }   =   null;
  4.1829 -            public bool                     IsAcceptButtonVisible       { get; set; }   =   true;
  4.1830 -            public bool                     IsBackButtonVisible         { get; set; }   =   false;
  4.1831 -            public bool                     IsCancelButtonVisible       { get; set; }   =   true;
  4.1832 -            public bool                     IsProgressBarVisible        { get; set; }   =   false;
  4.1833 -            public KeySyncWizard.Steps      Step                        { get; set; }   =   Steps.Undefined;
  4.1834 -            public string                   SubtitleText                { get; set; }   =   null;
  4.1835 -            public string                   TitleText                   { get; set; }   =   null;
  4.1836 -            public string                   UserText                    { get; set; }   =   null;
  4.1837 -        }
  4.1838 -    }
  4.1839 -}
     5.1 --- a/UI/RibbonCustomizations.cs	Mon Nov 18 08:27:05 2019 +0100
     5.2 +++ b/UI/RibbonCustomizations.cs	Mon Nov 18 20:04:48 2019 +0100
     5.3 @@ -6,7 +6,6 @@
     5.4  using System.Reflection;
     5.5  using System.Runtime.InteropServices;
     5.6  using System.Windows.Forms;
     5.7 -using System.Windows.Input;
     5.8  using System.Xml;
     5.9  using Office = Microsoft.Office.Core;
    5.10  using Outlook = Microsoft.Office.Interop.Outlook;
    5.11 @@ -804,81 +803,6 @@
    5.12           *************************************************************/
    5.13  
    5.14          ///////////////////////////////////////////////////////////
    5.15 -        // ContextMenuKeyImport
    5.16 -        ///////////////////////////////////////////////////////////
    5.17 -
    5.18 -        /// <summary>
    5.19 -        /// Callback to get the store context menu key import button text.
    5.20 -        /// </summary>
    5.21 -        public string ContextMenuKeyImport_GetLabel(Office.IRibbonControl control)
    5.22 -        {
    5.23 -            return Properties.Resources.StoreContextMenu_KeyImportText;
    5.24 -        }
    5.25 -
    5.26 -        /// <summary>
    5.27 -        /// Callback to get the visibility of the store context menu key import button.
    5.28 -        /// </summary>
    5.29 -        public bool ContextMenuKeyImport_GetVisible(Office.IRibbonControl control)
    5.30 -        {
    5.31 -            bool visible = false;
    5.32 -            Outlook.Account account = null;
    5.33 -            Outlook.Store store = null;
    5.34 -
    5.35 -            try
    5.36 -            {
    5.37 -                // If this store has an associated account, show button
    5.38 -                store = control.Context as Outlook.Store;
    5.39 -                account = store?.GetAccount();
    5.40 -
    5.41 -                visible = (account != null);
    5.42 -            }
    5.43 -            catch (Exception ex)
    5.44 -            {
    5.45 -                visible = false;
    5.46 -                Log.Error("ContextMenuKeyImport_GetVisible: Error determining visibility. " + ex.ToString());
    5.47 -            }
    5.48 -            finally
    5.49 -            {
    5.50 -                account = null;
    5.51 -                store = null;
    5.52 -            }
    5.53 -
    5.54 -            return visible;
    5.55 -        }
    5.56 -
    5.57 -        /// <summary>
    5.58 -        /// Callback to get the store context menu key import button image.
    5.59 -        /// </summary>
    5.60 -        public System.Drawing.Bitmap ContextMenuKeyImport_GetImage(Office.IRibbonControl control)
    5.61 -        {
    5.62 -            return Properties.Resources.ImageLogoIcon;
    5.63 -        }
    5.64 -
    5.65 -        ///////////////////////////////////////////////////////////
    5.66 -        // ContextMenuKeyImportButtonPEP
    5.67 -        ///////////////////////////////////////////////////////////   
    5.68 -
    5.69 -        /// <summary>
    5.70 -        /// Callback to get the store context menu key import button text.
    5.71 -        /// </summary>
    5.72 -        public string ContextMenuKeyImportButtonPEP_GetLabel(Office.IRibbonControl control)
    5.73 -        {
    5.74 -            return Properties.Resources.StoreContextMenu_OpenPEPKeyImportWizard;
    5.75 -        }
    5.76 -
    5.77 -        ///////////////////////////////////////////////////////////
    5.78 -        // ContextMenuKeyImportButtonPGP
    5.79 -        ///////////////////////////////////////////////////////////   
    5.80 -
    5.81 -        /// <summary>
    5.82 -        /// Callback to get the store context menu key import button text.
    5.83 -        /// </summary>
    5.84 -        public string ContextMenuKeyImportButtonPGP_GetLabel(Office.IRibbonControl control)
    5.85 -        {
    5.86 -            return Properties.Resources.StoreContextMenu_OpenPGPKeyImportWizard;
    5.87 -        }
    5.88 -
    5.89 -        ///////////////////////////////////////////////////////////
    5.90          // ButtonContextMenuContactResetTrust
    5.91          ///////////////////////////////////////////////////////////
    5.92  
    5.93 @@ -1634,43 +1558,6 @@
    5.94           *************************************************************/
    5.95  
    5.96          /// <summary>
    5.97 -        /// Event handler for when the key import context menu button is clicked.
    5.98 -        /// </summary>
    5.99 -        public void ContextMenuKeyImportButton_Click(Office.IRibbonControl control)
   5.100 -        {
   5.101 -            Outlook.Store store = null;
   5.102 -            PEPIdentity ownIdentity = null;
   5.103 -
   5.104 -            try
   5.105 -            {
   5.106 -                // Get own pEp identity of this store
   5.107 -                store = control.Context as Outlook.Store;
   5.108 -                ownIdentity = store.GetPEPIdentity(true);
   5.109 -
   5.110 -                // Open wizard if identity has been successfully retrieved.
   5.111 -                if (ownIdentity != null)
   5.112 -                {
   5.113 -                    // Get wizard type (event can be raised from different buttons)
   5.114 -                    var wizardType = (control?.Id.Equals("ContextMenuKeyImportButtonPGP") == true) ? KeySyncWizard.WizardType.PGP : KeySyncWizard.WizardType.pEp;
   5.115 -                    KeySyncWizard.Wizard = new KeySyncWizard(wizardType, true, ownIdentity);
   5.116 -                    KeySyncWizard.Wizard?.Show();
   5.117 -                }
   5.118 -                else
   5.119 -                {
   5.120 -                    Log.Error("ContextMenuKeyImport_Click: Error getting own identity.");
   5.121 -                }
   5.122 -            }
   5.123 -            catch (Exception ex)
   5.124 -            {
   5.125 -                Log.Error("ContextMenuKeyImport_Click: Error opening wizard. " + ex.ToString());
   5.126 -            }
   5.127 -            finally
   5.128 -            {
   5.129 -                store = null;
   5.130 -            }
   5.131 -        }
   5.132 -
   5.133 -        /// <summary>
   5.134          /// Event handler for when the reset contact context menu button is clicked.
   5.135          /// </summary>
   5.136          public void ButtonContextMenuContactResetTrust_Click(Office.IRibbonControl control)
     6.1 --- a/UI/RibbonCustomizationsExplorer.xml	Mon Nov 18 08:27:05 2019 +0100
     6.2 +++ b/UI/RibbonCustomizationsExplorer.xml	Mon Nov 18 20:04:48 2019 +0100
     6.3 @@ -154,23 +154,6 @@
     6.4    </backstage>
     6.5    <contextMenus>
     6.6      
     6.7 -    <!--The manual Key Import context menu entry-->
     6.8 -    <contextMenu idMso="ContextMenuStore">
     6.9 -      <menu id="ContextMenuKeyImport"
    6.10 -            getImage="ContextMenuKeyImport_GetImage"
    6.11 -            getVisible="ContextMenuKeyImport_GetVisible"
    6.12 -            getLabel="ContextMenuKeyImport_GetLabel">
    6.13 -        <button id="ContextMenuKeyImportButtonPEP"
    6.14 -                getLabel="ContextMenuKeyImportButtonPEP_GetLabel"
    6.15 -                imageMso="AdpPrimaryKey"
    6.16 -                onAction="ContextMenuKeyImportButton_Click"/>
    6.17 -        <button id="ContextMenuKeyImportButtonPGP"
    6.18 -                getLabel="ContextMenuKeyImportButtonPGP_GetLabel"
    6.19 -                imageMso="AdpPrimaryKey"
    6.20 -                onAction="ContextMenuKeyImportButton_Click"/>
    6.21 -      </menu>
    6.22 -    </contextMenu>
    6.23 -    
    6.24      <!--The Contact context menu to reset trust-->
    6.25      <contextMenu idMso="ContextMenuContactItem">
    6.26        <button id="ButtonContextMenuResetContactTrust"
     7.1 --- a/UI/RibbonCustomizationsExplorer2010.xml	Mon Nov 18 08:27:05 2019 +0100
     7.2 +++ b/UI/RibbonCustomizationsExplorer2010.xml	Mon Nov 18 20:04:48 2019 +0100
     7.3 @@ -94,22 +94,5 @@
     7.4        </secondColumn>
     7.5      </tab>
     7.6    </backstage>
     7.7 -  <contextMenus>
     7.8 -    <contextMenu idMso="ContextMenuStore">
     7.9 -      <menu id="ContextMenuKeyImport"
    7.10 -            getImage="ContextMenuKeyImport_GetImage"
    7.11 -            getVisible="ContextMenuKeyImport_GetVisible"
    7.12 -            getLabel="ContextMenuKeyImport_GetLabel">
    7.13 -        <button id="ContextMenuKeyImportButtonPEP"
    7.14 -                getLabel="ContextMenuKeyImportButtonPEP_GetLabel"
    7.15 -                imageMso="AdpPrimaryKey"
    7.16 -                onAction="ContextMenuKeyImportButton_Click"/>
    7.17 -        <button id="ContextMenuKeyImportButtonPGP"
    7.18 -                getLabel="ContextMenuKeyImportButtonPGP_GetLabel"
    7.19 -                imageMso="AdpPrimaryKey"
    7.20 -                onAction="ContextMenuKeyImportButton_Click"/>
    7.21 -      </menu>
    7.22 -    </contextMenu>
    7.23 -  </contextMenus>
    7.24  </customUI>
    7.25  
     8.1 --- a/UI/ValueConverters.cs	Mon Nov 18 08:27:05 2019 +0100
     8.2 +++ b/UI/ValueConverters.cs	Mon Nov 18 20:04:48 2019 +0100
     8.3 @@ -475,31 +475,4 @@
     8.4              return (curValue);
     8.5          }
     8.6      }
     8.7 -
     8.8 -    /// <summary>
     8.9 -    /// Returns true if the Wizard is of the given type.
    8.10 -    /// </summary>
    8.11 -    public class WizardTypeToBooleanConverter : IValueConverter
    8.12 -    {
    8.13 -        public object Convert(object value,
    8.14 -                              Type targetType,
    8.15 -                              object parameter,
    8.16 -                              CultureInfo culture)
    8.17 -        {
    8.18 -            if ((value is KeySyncWizard.WizardType val) &&
    8.19 -                Enum.TryParse(parameter as string, out KeySyncWizard.WizardType param))
    8.20 -            {
    8.21 -                return (val == param);
    8.22 -            }
    8.23 -            else
    8.24 -            {
    8.25 -                throw new ArgumentException();
    8.26 -            }
    8.27 -        }
    8.28 -
    8.29 -        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    8.30 -        {
    8.31 -            throw new NotImplementedException();
    8.32 -        }
    8.33 -    }
    8.34  }
     9.1 --- a/pEpForOutlook.csproj	Mon Nov 18 08:27:05 2019 +0100
     9.2 +++ b/pEpForOutlook.csproj	Mon Nov 18 20:04:48 2019 +0100
     9.3 @@ -457,9 +457,6 @@
     9.4      <Compile Include="UI\Views\DialogWindow.xaml.cs">
     9.5        <DependentUpon>DialogWindow.xaml</DependentUpon>
     9.6      </Compile>
     9.7 -    <Compile Include="UI\KeySyncWizard.xaml.cs">
     9.8 -      <DependentUpon>KeySyncWizard.xaml</DependentUpon>
     9.9 -    </Compile>
    9.10      <Compile Include="UI\Notification.xaml.cs">
    9.11        <DependentUpon>Notification.xaml</DependentUpon>
    9.12      </Compile>
    9.13 @@ -722,10 +719,6 @@
    9.14        <SubType>Designer</SubType>
    9.15        <Generator>MSBuild:Compile</Generator>
    9.16      </Page>
    9.17 -    <Page Include="UI\KeySyncWizard.xaml">
    9.18 -      <SubType>Designer</SubType>
    9.19 -      <Generator>MSBuild:Compile</Generator>
    9.20 -    </Page>
    9.21      <Page Include="UI\SelectionBox.xaml">
    9.22        <SubType>Designer</SubType>
    9.23        <Generator>MSBuild:Compile</Generator>