EncryptionStatusPanel.cs
author Dean Looyengoed
Wed, 30 Dec 2015 04:29:34 +0100
changeset 179 ff5101f87d35
parent 178 a2358eedefef
child 180 1602b0e8fdd6
permissions -rw-r--r--
Finish almost completely rewriting the encryption status panel... yes, it was very necessary. The preview unencrypted functionality is currently disabled to be added back later. This fixes a lot of issues and most functionality should work a lot better now. However, needs further testing and some TODO's remain.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
     1
´╗┐using pEpCOMServerAdapterLib;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
     2
using System;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
     3
using System.Collections.Generic;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
     4
using System.Diagnostics;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
     5
using System.Linq;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
     6
using System.Runtime.InteropServices;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
     7
using System.Windows.Forms;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
     8
using Color = System.Drawing.Color;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
     9
using Outlook = Microsoft.Office.Interop.Outlook;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    10
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    11
namespace pEp
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    12
{
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    13
    /// <summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    14
    /// Partial class for the encryption status panel that is displayed below every outlook message.
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    15
    /// </summary>
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    16
    partial class EncryptionStatusPanel
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    17
    {
164
e87296c335ee Defined colors need to be readonly not const due to type
Dean Looyengoed
parents: 163
diff changeset
    18
        private static readonly Color COLOR_RED        = Color.Red;
e87296c335ee Defined colors need to be readonly not const due to type
Dean Looyengoed
parents: 163
diff changeset
    19
        private static readonly Color COLOR_YELLOW     = Color.Gold;
e87296c335ee Defined colors need to be readonly not const due to type
Dean Looyengoed
parents: 163
diff changeset
    20
        private static readonly Color COLOR_GREEN      = Color.Green;
e87296c335ee Defined colors need to be readonly not const due to type
Dean Looyengoed
parents: 163
diff changeset
    21
        private static readonly Color COLOR_GREY       = Color.Gainsboro;
e87296c335ee Defined colors need to be readonly not const due to type
Dean Looyengoed
parents: 163
diff changeset
    22
        private static readonly Color TEXT_COLOR_BLACK = Color.Black;
e87296c335ee Defined colors need to be readonly not const due to type
Dean Looyengoed
parents: 163
diff changeset
    23
        private static readonly Color TEXT_COLOR_WHITE = Color.White;
162
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
    24
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    25
        #region Form Region Factory
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    26
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    27
        [Microsoft.Office.Tools.Outlook.FormRegionMessageClass(Microsoft.Office.Tools.Outlook.FormRegionMessageClassAttribute.Note)]
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    28
        [Microsoft.Office.Tools.Outlook.FormRegionName("pEp.FormRegion1")]
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    29
        public partial class FormRegion1Factory
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    30
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    31
            // Occurs before the form region is initialized.
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    32
            // To prevent the form region from appearing, set e.Cancel to true.
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    33
            // Use e.OutlookItem to get a reference to the current Outlook item.
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    34
            private void FormRegion1Factory_FormRegionInitializing(object sender, Microsoft.Office.Tools.Outlook.FormRegionInitializingEventArgs e)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    35
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    36
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    37
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    38
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    39
        #endregion
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    40
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    41
        /* Notes:
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
    42
         * 
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    43
         * Use this.OutlookItem to get a reference to the current Outlook item.
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    44
         * Use this.OutlookFormRegion to get a reference to the form region.
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
    45
         * 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
    46
         * UI State Managment:
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
    47
         * 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
    48
         * The UI state is almost entirely set from the associated mail item data.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
    49
         * However, a separate state class is maintained to represent the UI as some separation is needed.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
    50
         * This logical separation MUST be maintained throughout the code.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
    51
         * Specific cases are noted where possible.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
    52
         * 
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    53
         */
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    54
170
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    55
        private CryptableMailItem associatedMailItem = null;
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
    56
        private bool              refreshOngoing     = false;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
    57
        private bool              eventsAreConnected = false;
170
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    58
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    59
        // UI data or controls not stored in the UI
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
    60
        private _pEp_color stateUIColorRating; // WARNING: Do NOT use this directly
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    61
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    62
        /**************************************************************
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    63
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    64
         * Methods
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    65
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    66
         *************************************************************/
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    67
171
897440376f2d Comment the StopHere method
Dean Looyengoed
parents: 170
diff changeset
    68
        /// <summary>
897440376f2d Comment the StopHere method
Dean Looyengoed
parents: 170
diff changeset
    69
        /// Method used to show/report an error based on build mode.
897440376f2d Comment the StopHere method
Dean Looyengoed
parents: 170
diff changeset
    70
        /// </summary>
897440376f2d Comment the StopHere method
Dean Looyengoed
parents: 170
diff changeset
    71
        /// <param name="reason">The reason/explanation to stop.</param>
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    72
        static void StopHere(string reason)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    73
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    74
#if DEBUG
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    75
            MessageBox.Show(reason);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    76
#else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    77
            try
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    78
            {
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    79
                ThisAddIn.pEp.log("internal error", "pEp for Outlook", reason, "in EncryptionStatusPanel.cs");
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    80
            }
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    81
            catch (COMException) { }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    82
            catch (Exception) { }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    83
#endif
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    84
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    85
170
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    86
        /// <summary>
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    87
        /// Sets the cryptable mail item associated with this encryption status panel.
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    88
        /// The associated mail item can then be accessed through its local variable.
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    89
        /// </summary>
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    90
        private void SetAssociatedMailItem()
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    91
        {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    92
            bool errorOccurred = false;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    93
            Outlook.MailItem omi = null;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    94
            Outlook.MAPIFolder omiFolder;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    95
            Outlook.MAPIFolder deletedFolder;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    96
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    97
            // Null check
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    98
            if (!errorOccurred)
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    99
            {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   100
                try
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   101
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   102
                    if (this.OutlookItem == null)
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   103
                    {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   104
                        errorOccurred = true;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   105
                    }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   106
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   107
                catch (COMException)
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   108
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   109
                    errorOccurred = true;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   110
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   111
            }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   112
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   113
            // Attempt to get and cast the outlook mail item
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   114
            if (!errorOccurred)
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   115
            {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   116
                try
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   117
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   118
                    omi = (Outlook.MailItem)this.OutlookItem;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   119
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   120
                catch
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   121
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   122
                    errorOccurred = true;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   123
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   124
            }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   125
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   126
            // Ensure the mail item is not in the deleted folder
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   127
            if (!errorOccurred)
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   128
            {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   129
                try
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   130
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   131
                    omiFolder = omi.Parent;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   132
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   133
                    if (omiFolder != null)
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   134
                    {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   135
                        deletedFolder = omiFolder.Store.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems);
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   136
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   137
                        if ((deletedFolder != null) && 
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   138
                            (omiFolder.EntryID == deletedFolder.EntryID))
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   139
                        {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   140
                            errorOccurred = true;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   141
                        }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   142
                    }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   143
                    else
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   144
                    {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   145
                        errorOccurred = true;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   146
                    }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   147
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   148
                catch
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   149
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   150
                    errorOccurred = true;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   151
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   152
            }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   153
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   154
            // Finally set the associated mail item
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   155
            if ((errorOccurred) ||
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   156
                (omi == null))
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   157
            {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   158
                this.associatedMailItem = null;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   159
            }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   160
            else
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   161
            {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   162
                // Check if the associated mail item has already been set
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   163
                if (this.associatedMailItem != null)
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   164
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   165
                    // Only re-set the mail item if the EntryID has changed
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   166
                    if (this.associatedMailItem.EntryID != omi.EntryID)
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   167
                    {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   168
                        this.associatedMailItem = new CryptableMailItem(omi);
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   169
                    }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   170
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   171
                else
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   172
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   173
                    this.associatedMailItem = new CryptableMailItem(omi);
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   174
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   175
            }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   176
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   177
            return;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   178
        }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   179
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   180
        /// <summary>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   181
        /// Starts the handshake process where the identity of a partner can be confirmed.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   182
        /// </summary>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   183
        /// <param name="identityPartner">The identity of the partner to complete the handshake with.</param>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   184
        private void DoHandshake(pEp_identity_s identityPartner)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   185
        {
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   186
            string ownShort;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   187
            string ownLong;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   188
            string ownFpr;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   189
            string partnerShort;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   190
            string partnerLong;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   191
            string partnerFpr;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   192
            string[] lines;
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   193
            DialogResult result;
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   194
            pEp_identity_s me;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   195
            FormHandshake handshakeDialog;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   196
            FormHandshake.State state = new FormHandshake.State();
176
881c0669425b Remove not-very-useful Debug.Assert
Dean Looyengoed
parents: 175
diff changeset
   197
            
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   198
            ThisAddIn.verbose("doHandshake");
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   199
            ThisAddIn.verbose(identityPartner.address);
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   200
132
f0c74e2c6dfb review of mailItem handling
Volker Birk <vb@pep-project.org>
parents: 131
diff changeset
   201
            if (identityPartner.username == "")
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   202
                identityPartner.username = identityPartner.address;
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   203
            ThisAddIn.verbose(identityPartner.username);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   204
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   205
            identityPartner.user_id = CryptableMailItem.GetUserIDFromAddress(identityPartner.address, identityPartner.username);
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   206
            ThisAddIn.verbose(identityPartner.user_id);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   207
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   208
            if (this.associatedMailItem.IsIncoming)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   209
            {
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   210
                string entryID = this.associatedMailItem.ReceivedByEntryID;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   211
                string address = "";
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   212
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   213
                foreach (Outlook.Account a in ThisAddIn.addIn.Application.Session.Accounts){
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   214
                    if (a.CurrentUser.EntryID == entryID) {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   215
                        address = a.SmtpAddress;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   216
                        break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   217
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   218
                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   219
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   220
                if (address == "")
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   221
                    address = ThisAddIn.addIn.Application.Session.Accounts[1].SmtpAddress;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   222
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   223
                me = ThisAddIn.addIn.mySelf(address);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   224
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   225
            else // outgoing
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   226
            {
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   227
                ThisAddIn.verbose("mailItem.from_address: " + this.associatedMailItem.FromAddress);
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   228
                me = ThisAddIn.addIn.mySelf(this.associatedMailItem.FromAddress);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   229
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   230
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   231
            ThisAddIn.verbose(me.fpr);
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   232
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   233
            ownShort = ThisAddIn.pEp.trustwords(me.fpr, max_words: 5).ToLower();
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   234
            ownLong  = ThisAddIn.pEp.trustwords(me.fpr).ToLower();
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   235
            ownFpr   = this.ToQuadruple(me.fpr);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   236
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   237
            ThisAddIn.verbose(identityPartner.fpr);
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   238
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   239
            partnerShort = ThisAddIn.pEp.trustwords(identityPartner.fpr, max_words: 5).ToLower();
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   240
            partnerLong  = ThisAddIn.pEp.trustwords(identityPartner.fpr).ToLower();
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   241
            partnerFpr   = this.ToQuadruple(identityPartner.fpr);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   242
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   243
            if (ownFpr.CompareTo(partnerFpr) > 0)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   244
            {
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   245
                state.TrustwordsShort = partnerShort + ownShort;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   246
                state.TrustwordsFull  = partnerLong  + ownLong;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   247
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   248
                lines = new string[3];
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   249
                lines[0] = pEp.Properties.Resources.TrustwordsPartnershortPartner + partnerFpr;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   250
                lines[2] = pEp.Properties.Resources.TrustwordsPartnershortMyself + ownFpr;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   251
                state.Fingerprint = lines;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   252
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   253
            else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   254
            {
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   255
                state.TrustwordsShort = ownShort + " " + partnerShort;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   256
                state.TrustwordsFull  = ownLong  + " " + partnerLong;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   257
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   258
                lines = new string[3];
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   259
                lines[0] = pEp.Properties.Resources.TrustwordsOwnshortMyself + ownFpr;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   260
                lines[2] = pEp.Properties.Resources.TrustwordsOwnshortPartner + partnerFpr;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   261
                state.Fingerprint = lines;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   262
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   263
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   264
            ThisAddIn.verbose("try to show dialog");
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   265
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   266
            // Create and show handshake dialog
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   267
            handshakeDialog = new FormHandshake(state);
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   268
            handshakeDialog.StartPosition = FormStartPosition.CenterScreen;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   269
            result = handshakeDialog.ShowDialog(this);
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   270
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   271
            ThisAddIn.verbose("handshakeDialog.ShowDialog(this) => " + result.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   272
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   273
            switch (result)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   274
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   275
                case DialogResult.Yes:
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   276
                    this.associatedMailItem.ColorRating = _pEp_color.pEp_rating_trusted;
132
f0c74e2c6dfb review of mailItem handling
Volker Birk <vb@pep-project.org>
parents: 131
diff changeset
   277
                    identityPartner = ThisAddIn.pEp.trust_personal_key(identityPartner);
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   278
                    this.UpdateUIFromMailItem();
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   279
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   280
                case DialogResult.No:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   281
                    ThisAddIn.pEp.key_compromized(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   282
                    identityPartner.comm_type = _pEp_comm_type.pEp_ct_compromized;
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   283
                    this.associatedMailItem.ColorRating = _pEp_color.pEp_rating_red;
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   284
                    this.UpdateUIFromMailItem();
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   285
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   286
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   287
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   288
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   289
        /// <summary>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   290
        /// Reverses any past handshake confirmation by unconfirming the given identity partner.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   291
        /// </summary>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   292
        /// <param name="identityPartner">The identity of the partner to unconfirm.</param>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   293
        private void UndoHandshake(pEp_identity_s identityPartner)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   294
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   295
            ThisAddIn.pEp.update_identity(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   296
            identityPartner.comm_type ^= _pEp_comm_type.pEp_ct_confirmed;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   297
            ThisAddIn.pEp.update_identity(identityPartner);
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   298
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   299
            // TODO: review this code, the pEp engine should drive the rating change...
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   300
            this.associatedMailItem.ColorRating = _pEp_color.pEp_rating_reliable;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   301
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   302
            this.UpdateUIFromMailItem();
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   303
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   304
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   305
        /// <summary>
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   306
        /// Formats the given text string as separated 4-character groups.
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   307
        /// Example: 49422235FC99585B891C --> 4942 2235 FC99 585B 891C
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   308
        /// </summary>
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   309
        /// <param name="text">The text to format in 4-character groups.</param>
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   310
        /// <returns>The re-formatted string.</returns>
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   311
        private string ToQuadruple(string text)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   312
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   313
            List<string> result = new List<string>();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   314
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   315
            if (text != null)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   316
            {
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   317
                for (int i = 0; i < text.Length; i += 4)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   318
                {
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   319
                    try
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   320
                    {
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   321
                        result.Add(text.Substring(i, 4));
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   322
                    }
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   323
                    catch (ArgumentOutOfRangeException)
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   324
                    {
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   325
                        result.Add(text.Substring(i));
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   326
                        break;
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   327
                    }
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   328
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   329
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   330
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   331
            return String.Join(" ", result);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   332
        }
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   333
        /* TODO: add this back later
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   334
        protected void makePreview()
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   335
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   336
            WindowFormRegionCollection formRegions;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   337
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   338
            if (Globals.ThisAddIn.Application.ActiveInspector() != null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   339
                return;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   340
            else if (Globals.ThisAddIn.Application.ActiveExplorer() != null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   341
                formRegions = Globals.FormRegions[Globals.ThisAddIn.Application.ActiveExplorer()];
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   342
            else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   343
                return;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   344
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   345
            try
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   346
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   347
                if (formRegions.PreviewUnencrypted.Visible)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   348
                {
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   349
                    byte[] rtf = this.associatedMailItem.MirrorGetRTFBody();
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   350
                    formRegions.PreviewUnencrypted.textPreview.Rtf = System.Text.Encoding.ASCII.GetString(rtf, 0, rtf.Length);
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   351
                    formRegions.PreviewUnencrypted.textSubject.Text = this.associatedMailItem.MirrorGetSubject();
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   352
                    formRegions.PreviewUnencrypted.textFrom.Text = this.associatedMailItem.FromUsername + " <" + this.associatedMailItem.FromAddress + ">";
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   353
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   354
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   355
            catch { }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   356
        }
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   357
        */
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   358
        /// <summary>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   359
        /// Updates the status of the UI state based on the associated mail item.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   360
        /// Any previous state changes in the UI are preserved.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   361
        /// </summary>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   362
        private void UpdateUIFromMailItem()
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   363
        {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   364
            State state;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   365
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   366
            if (this.associatedMailItem != null)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   367
            {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   368
                state = this.CopyUIToState();
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   369
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   370
                // Set encryption status
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   371
                if (this.associatedMailItem.SendUnencrypted == CheckState.Checked)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   372
                {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   373
                    // Always set to unencrypted
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   374
                    state.EncryptionStatus = _pEp_color.pEp_rating_unencrypted;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   375
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   376
                else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   377
                {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   378
                    state.EncryptionStatus = this.associatedMailItem.ColorRating;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   379
                }
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   380
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   381
                // Set send unencrypted state
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   382
                state.SendUnencryptedCheckState = this.associatedMailItem.SendUnencrypted;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   383
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   384
                this.CopyStateToUI(state);
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   385
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   386
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   387
            return;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   388
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   389
172
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   390
        #region StateMethods
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   391
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   392
        /// <summary>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   393
        /// Connects or disconnects all control events from the UI.
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   394
        /// </summary>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   395
        /// <param name="connect">True to connect events, false to disconnect.</param>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   396
        private void ConnectEvents(bool connect)
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   397
        {
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   398
            // Connect events only if not already connected
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   399
            if ((connect == true) && 
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   400
                (this.eventsAreConnected == false))
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   401
            {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   402
                this.ButtonEncryptionStatus.Click     += this.ButtonEncryptionStatus_Click;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   403
                this.ButtonEncryptionStatus.MouseUp   += this.ButtonEncryptionStatus_MouseUp;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   404
                this.LinkLabelExplanation.LinkClicked += this.LinkLabelExplanation_LinkClicked;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   405
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   406
                this.PictureBoxOptions.Click      += this.PictureBoxOptions_Click;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   407
                this.PictureBoxOptions.MouseHover += this.PictureBoxOptions_MouseHover;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   408
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   409
                this.ToolStripMenuItemSendUnencrypted.Click += this.ToolStripMenuItemSendUnencrypted_Click;
172
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   410
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   411
                this.eventsAreConnected = true;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   412
            }
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   413
            // Always attempt to disconnect
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   414
            else if (connect == false)
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   415
            {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   416
                this.ButtonEncryptionStatus.Click     -= this.ButtonEncryptionStatus_Click;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   417
                this.ButtonEncryptionStatus.MouseUp   -= this.ButtonEncryptionStatus_MouseUp;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   418
                this.LinkLabelExplanation.LinkClicked -= this.LinkLabelExplanation_LinkClicked;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   419
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   420
                this.PictureBoxOptions.Click      -= this.PictureBoxOptions_Click;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   421
                this.PictureBoxOptions.MouseHover -= this.PictureBoxOptions_MouseHover;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   422
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   423
                this.ToolStripMenuItemSendUnencrypted.Click -= this.ToolStripMenuItemSendUnencrypted_Click;
172
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   424
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   425
                this.eventsAreConnected = false;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   426
            }
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   427
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   428
            return;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   429
        }
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   430
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   431
        /// <summary>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   432
        /// Refreshes the UI by reloading the state.
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   433
        /// </summary>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   434
        private void RefreshUI()
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   435
        {
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   436
            this.CopyStateToUI(this.CopyUIToState());
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   437
            return;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   438
        }
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   439
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   440
        /// <summary>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   441
        /// Copies the given state to the UI.
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   442
        /// Events are turned off until the process is complete.
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   443
        /// </summary>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   444
        /// <param name="state">The state to set to the UI.</param>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   445
        private void CopyStateToUI(State state)
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   446
        {
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   447
            this.ConnectEvents(false);
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   448
            
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   449
            ///////////////////////////////////////////////////////////
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   450
            // Set UI data
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   451
            ///////////////////////////////////////////////////////////
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   452
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   453
            // Save UI state maintained outside of controls
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   454
            this.stateUIColorRating = state.EncryptionStatus;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   455
172
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   456
            this.LinkLabelExplanation.Text        = state.Title;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   457
            this.ButtonEncryptionStatus.BackColor = state.ButtonBackground;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   458
            this.ButtonEncryptionStatus.ForeColor = state.ButtonForeground;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   459
            this.ButtonEncryptionStatus.Text      = state.ButtonText;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   460
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   461
            ///////////////////////////////////////////////////////////
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   462
            // Set UI selections
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   463
            ///////////////////////////////////////////////////////////
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   464
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   465
            /* Note: When displaying the send unencrypted checked state,
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   466
             * convert any indeterminate state to unchecked.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   467
             * This is necessary for the end user.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   468
             * As a result of this change during display, the UI state will 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   469
             * carry this change as soon as a refresh occurs.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   470
             * This is not a problem because the mail item itself is not updated
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   471
             * until the user clicks the send unencrypted checkbox themselves.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   472
             * This is a case where the UI state and mail item are different.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   473
             */
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   474
            if (state.SendUnencryptedCheckState == CheckState.Checked)
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   475
            {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   476
                this.ToolStripMenuItemSendUnencrypted.CheckState = CheckState.Checked;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   477
            }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   478
            else
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   479
            {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   480
                // Both indeterminate and unchecked shown as unchecked
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   481
                this.ToolStripMenuItemSendUnencrypted.CheckState = CheckState.Unchecked;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   482
            }
172
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   483
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   484
            ///////////////////////////////////////////////////////////
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   485
            // Set UI control visibility
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   486
            ///////////////////////////////////////////////////////////
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   487
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   488
            this.ConnectEvents(true);
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   489
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   490
            return;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   491
        }
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   492
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   493
        /// <summary>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   494
        /// Copies the UI to a new state.
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   495
        /// </summary>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   496
        /// <returns>The state of the UI.</returns>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   497
        private State CopyUIToState()
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   498
        {
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   499
            State state = new State();
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   500
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   501
            state.EncryptionStatus          = this.stateUIColorRating;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   502
            state.SendUnencryptedCheckState = this.ToolStripMenuItemSendUnencrypted.CheckState;
172
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   503
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   504
            return (state);
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   505
        }
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   506
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   507
        #endregion
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   508
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   509
        /**************************************************************
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   510
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   511
         * Event Handling
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   512
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   513
         *************************************************************/
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   514
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   515
        /// <summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   516
        /// Event handler that is called before the form region is displayed.
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   517
        /// </summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   518
        private void FormRegion1_FormRegionShowing(object sender, System.EventArgs e)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   519
        {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   520
            Outlook.MailItem omi = null;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   521
            State state;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   522
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   523
            this.SetAssociatedMailItem();
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   524
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   525
            // TODO: This should be done long before here and only once
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   526
            if (!ThisAddIn.addIn.enabled)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   527
            {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   528
                ThisAddIn.addIn.enable();
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   529
            }
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   530
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   531
            // Connect events for the associated outlook mail item directly
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   532
            if (this.OutlookItem != null)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   533
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   534
                try
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   535
                {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   536
                    omi = (Outlook.MailItem)this.OutlookItem;
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   537
                    omi.PropertyChange += MailItem_PropertyChange;
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   538
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   539
                    if (CryptableMailItem.IsEncryptedStore(omi))
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   540
                    {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   541
                        if (PreviewUnencrypted.isPGPEncrypted(omi) && omi.Sender != null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   542
                        {
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   543
                            omi.Open += MailItem_Open;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   544
                        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   545
                    }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   546
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   547
                catch { }
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   548
            }
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   549
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   550
            // Set the default UI state
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   551
            state = new State();
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   552
            state.EncryptionStatus = _pEp_color.pEp_rating_undefined;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   553
            this.CopyStateToUI(state);
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   554
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   555
            // Check if the mailitem has been dowloaded yet
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   556
            if (this.associatedMailItem != null)
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   557
            {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   558
                if (this.associatedMailItem.DownloadState == Outlook.OlDownloadState.olFullItem)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   559
                {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   560
                    this.UpdateUIFromMailItem();
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   561
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   562
                else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   563
                {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   564
                    this.associatedMailItem.MarkForDownload = Outlook.OlRemoteStatus.olMarkedForDownload;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   565
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   566
                    //this.makePreview(); // TODO: add this back?
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   567
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   568
                    // Start the refresh timer
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   569
                    this.TimerRefresh.Interval = 50;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   570
                    this.TimerRefresh.Enabled = true;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   571
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   572
            }
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   573
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   574
            return;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   575
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   576
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   577
        /// <summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   578
        /// Event handler for when the form region is closed.
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   579
        /// </summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   580
        private void FormRegion1_FormRegionClosed(object sender, System.EventArgs e)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   581
        {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   582
            Outlook.MailItem omi;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   583
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   584
            // Disconnect any events for the associated outlook mail item directly
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   585
            if (this.OutlookItem != null)
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   586
            {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   587
                try
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   588
                {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   589
                    omi = (Outlook.MailItem)this.OutlookItem;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   590
                    omi.PropertyChange -= MailItem_PropertyChange;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   591
                    omi.Open           -= MailItem_Open;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   592
                }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   593
                catch { }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   594
            }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   595
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   596
            return;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   597
        }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   598
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   599
        /// <summary>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   600
        /// Event handler called after the refresh timer has elapsed.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   601
        /// </summary>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   602
        private void TimerRefresh_Tick(object sender, EventArgs e)
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   603
        {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   604
            this.TimerRefresh.Enabled = false; // Only once
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   605
            
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   606
            // Ensure the tick method is not called more than once
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   607
            if (refreshOngoing == false)
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   608
            {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   609
                this.refreshOngoing = true;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   610
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   611
                if (this.associatedMailItem != null)
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   612
                {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   613
                    if (this.associatedMailItem.DownloadState == Outlook.OlDownloadState.olFullItem)
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   614
                    {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   615
                        this.UpdateUIFromMailItem();
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   616
                    }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   617
                    else
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   618
                    {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   619
                        // Set the timer to refresh again later automatically
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   620
                        this.associatedMailItem.MarkForDownload = Outlook.OlRemoteStatus.olMarkedForDownload;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   621
                        this.TimerRefresh.Interval = 100;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   622
                        this.TimerRefresh.Enabled = true;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   623
                    }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   624
                }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   625
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   626
                this.refreshOngoing = false;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   627
            }
175
48628e74ace0 Add a comment to remove event handlers
Dean Looyengoed
parents: 174
diff changeset
   628
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   629
            return;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   630
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   631
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   632
        /// <summary>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   633
        /// Event handler for when a mail item is being opened in an inspector.
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   634
        /// </summary>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   635
        /// <param name="cancel">Whether to cancel the event: Value is False when the event occurs. 
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   636
        /// If the event procedure sets this argument to True, the open operation is not completed 
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   637
        /// and the inspector is not displayed.</param>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   638
        private void MailItem_Open(ref bool cancel)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   639
        {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   640
            // Cancel opening if the mirror is displayed instead
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   641
            if (this.associatedMailItem != null && this.associatedMailItem.MirrorDisplay())
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   642
            {
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   643
                cancel = true;
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   644
            }
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   645
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   646
            return;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   647
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   648
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   649
        /// <summary>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   650
        /// Event handler for when a mail item property is changed.
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   651
        /// See: https://msdn.microsoft.com/en-us/library/office/ff866739.aspx
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   652
        /// </summary>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   653
        /// <param name="propertyName">The name of the property that was changed.</param>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   654
        private void MailItem_PropertyChange(string propertyName)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   655
        {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   656
            switch (propertyName.ToUpper())
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   657
            {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   658
                case "TO":
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   659
                    // Start the refresh timer
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   660
                    this.TimerRefresh.Enabled = true;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   661
                    break;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   662
                // Outlook bug: there are always both events, so one is enough
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   663
                //case "CC":
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   664
                //    // Start the refresh timer
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   665
                //    this.TimerRefresh.Enabled = true;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   666
                //    break;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   667
            }
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   668
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   669
            return;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   670
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   671
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   672
        /// <summary>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   673
        /// Event handler for when the encryption status button is clicked.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   674
        /// </summary>
178
a2358eedefef Rename controls
Dean Looyengoed
parents: 176
diff changeset
   675
        private void ButtonEncryptionStatus_Click(object sender, EventArgs e)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   676
        {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   677
            string text;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   678
            string reason;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   679
            string[] keys;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   680
            State state = this.CopyUIToState();
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   681
            
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   682
            switch (state.EncryptionStatus)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   683
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   684
                case _pEp_color.pEp_rating_green:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   685
                    try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   686
                    {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   687
                        keys = this.associatedMailItem.Keylist;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   688
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   689
                        if (keys.Length > 0)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   690
                        {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   691
                            if (keys.Length > 1)
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   692
                            {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   693
                                text = String.Format(pEp.Properties.Resources.EncryptionStatusClickMessageMultiple + " {0}.",
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   694
                                                     String.Join(", ", keys));
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   695
                            }
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   696
                            else
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   697
                            {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   698
                                text = String.Format(pEp.Properties.Resources.EncryptionStatusClickMessageSingle + " {0}.", 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   699
                                                     keys[0]);
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   700
                            }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   701
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   702
                            // Display all keys the message is encrypted with
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   703
                            MessageBox.Show(text, 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   704
                                            pEp.Properties.Resources.EncryptionStatusClickMessageBox, 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   705
                                            MessageBoxButtons.OK, 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   706
                                            MessageBoxIcon.Information);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   707
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   708
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   709
                    catch (Exception ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   710
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   711
                        StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   712
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   713
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   714
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   715
                case _pEp_color.pEp_rating_yellow:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   716
                    try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   717
                    {
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   718
                        if (this.associatedMailItem.IsIncoming)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   719
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   720
                            pEp_identity_s identityPartner = new pEp_identity_s();
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   721
                            identityPartner.address = this.associatedMailItem.FromAddress;
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   722
                            identityPartner.username = this.associatedMailItem.FromUsername;
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   723
                            identityPartner.user_id = CryptableMailItem.GetUserIDFromAddress(identityPartner.address, identityPartner.username);
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   724
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   725
                            try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   726
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   727
                                identityPartner = ThisAddIn.pEp.update_identity(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   728
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   729
                            catch
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   730
                            {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   731
                                state.EncryptionStatus = _pEp_color.pEp_rating_undefined;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   732
                                this.CopyStateToUI(state);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   733
                                return;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   734
                            }
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   735
                            this.DoHandshake(identityPartner);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   736
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   737
                        else // outgoing
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   738
                        {
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   739
                            ThisAddIn.verbose("yellow, handshake initiated");
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   740
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   741
                            List<pEp_identity_s> partnersToCheck = new List<pEp_identity_s>();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   742
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   743
                            foreach (pEp_identity_s identity in this.associatedMailItem.Addresses)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   744
                            {
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   745
                                ThisAddIn.verbose("adding " + identity.username + " <" + identity.address + ">");
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   746
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   747
                                try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   748
                                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   749
                                    pEp_identity_s identityPartner = ThisAddIn.pEp.update_identity(identity);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   750
                                    if (identityPartner.comm_type >= _pEp_comm_type.pEp_ct_unconfirmed_encryption
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   751
                                        && identityPartner.comm_type < _pEp_comm_type.pEp_ct_confirmed_encryption)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   752
                                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   753
                                        partnersToCheck.Add(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   754
                                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   755
                                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   756
                                catch
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   757
                                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   758
                                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   759
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   760
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   761
                            if (partnersToCheck.Count == 0)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   762
                            {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   763
                                state.EncryptionStatus = _pEp_color.pEp_rating_undefined;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   764
                                this.CopyStateToUI(state);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   765
                                return;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   766
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   767
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   768
                            pEp_identity_s[] addresses = this.associatedMailItem.Addresses;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   769
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   770
                            if (addresses.Length == 1)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   771
                            {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   772
                                this.DoHandshake(partnersToCheck[0]);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   773
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   774
                            else if (addresses.Length > 1)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   775
                            {
178
a2358eedefef Rename controls
Dean Looyengoed
parents: 176
diff changeset
   776
                                ContextMenuHandshake.Items.Clear();
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   777
                                foreach (pEp_identity_s identity in partnersToCheck) 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   778
                                {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   779
                                    text = identity.username + " <" + identity.address + ">";
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   780
                                    ContextMenuHandshake.Items.Add(text, 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   781
                                                                   null, 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   782
                                                                   (x, y) => { this.DoHandshake(identity); });
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   783
                                }
178
a2358eedefef Rename controls
Dean Looyengoed
parents: 176
diff changeset
   784
                                ContextMenuHandshake.Show(ButtonEncryptionStatus, 10, 10);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   785
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   786
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   787
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   788
                    catch (COMException ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   789
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   790
                        StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   791
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   792
                    catch (Exception ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   793
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   794
                        StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   795
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   796
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   797
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   798
                case _pEp_color.pEp_rating_unencrypted:
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   799
                    if (this.associatedMailItem.IsIncoming)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   800
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   801
                        MessageBox.Show(pEp.Properties.Resources.RatingUnencryptedMessageboxReasonBody, pEp.Properties.Resources.RatingUnencryptedMessageboxReasonTitle);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   802
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   803
                    else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   804
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   805
                        try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   806
                        {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   807
                            reason = "";
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   808
                            foreach (pEp_identity_s identity in this.associatedMailItem.Addresses)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   809
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   810
                                if (identity.comm_type < _pEp_comm_type.pEp_ct_security_by_obscurity)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   811
                                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   812
                                    if (reason != "")
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   813
                                        reason += "\n";
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   814
                                    // BUG: reason string in English language only and trivial
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   815
                                    string ct = identity.comm_type.ToString();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   816
                                    ct = new string(ct.Skip(7).ToArray());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   817
                                    ct = ct.Replace("_", " ");
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   818
                                    reason += identity.username + " <" + identity.address + ">: " + ct;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   819
                                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   820
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   821
                            if (reason != "")
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   822
                                MessageBox.Show(reason, pEp.Properties.Resources.RatingUnencryptedMessageboxReasonTitle);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   823
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   824
                        catch (COMException ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   825
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   826
                            StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   827
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   828
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   829
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   830
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   831
                case _pEp_color.pEp_rating_cannot_decrypt:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   832
                case _pEp_color.pEp_rating_have_no_key:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   833
                    try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   834
                    {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   835
                        keys = this.associatedMailItem.Keylist;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   836
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   837
                        if (keys.Length > 1)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   838
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   839
                            if (keys.Length == 2)
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   840
                            {
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   841
                                reason = pEp.Properties.Resources.RatingHavenokeyMessageboxReasonBodyNokey;
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   842
                            }
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   843
                            else
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   844
                            {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   845
                                reason = string.Format(pEp.Properties.Resources.RatingHavenokeyMessageboxReasonBodySomekey, 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   846
                                                       keys.Length - 1);
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   847
                            }
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   848
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   849
                            string keyinfo = "";
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   850
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   851
                            foreach (string key in keys)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   852
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   853
                                if (key.Length >= 8)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   854
                                    keyinfo += "\n" + key;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   855
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   856
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   857
                            reason += keyinfo;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   858
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   859
                            MessageBox.Show(reason, 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   860
                                            pEp.Properties.Resources.RatingHavenokeyTitle);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   861
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   862
                        else if (keys.Length == 1)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   863
                        {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   864
                            MessageBox.Show(pEp.Properties.Resources.RatingHavenokeyMessageboxReasonError + keys[0], 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   865
                                            pEp.Properties.Resources.RatingHavenokeyTitle);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   866
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   867
                        else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   868
                        {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   869
                            MessageBox.Show(pEp.Properties.Resources.RatingHavenokeyMessageboxReasonUnknownformat, 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   870
                                            pEp.Properties.Resources.RatingHavenokeyTitle);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   871
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   872
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   873
                    catch (COMException ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   874
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   875
                        StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   876
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   877
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   878
                    
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   879
                case _pEp_color.pEp_rating_undefined:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   880
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   881
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   882
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   883
            return;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   884
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   885
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   886
        /// <summary>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   887
        /// Event handler for when a mouse button is released over the encryption status button.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   888
        /// This will show the context menu.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   889
        /// </summary>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   890
        private void ButtonEncryptionStatus_MouseUp(object sender, MouseEventArgs e)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   891
        {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   892
            bool showContextMenu = false;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   893
            string text;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   894
            Button button;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   895
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   896
            if ((sender != null) &&
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   897
                (e.Button == System.Windows.Forms.MouseButtons.Right))
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   898
            { 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   899
                button = (Button)sender;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   900
                
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   901
                // Remove all tool strip menu items except the first, which should be send unencrypted
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   902
                while (this.ContextMenuEncryptionStatus.Items.Count > 1)
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   903
                {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   904
                    this.ContextMenuEncryptionStatus.Items.RemoveAt(1);
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   905
                }
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   906
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   907
                // Enable the send unencrypted menu item
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   908
                if (this.associatedMailItem != null && 
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   909
                    !this.associatedMailItem.IsIncoming && 
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   910
                    !this.associatedMailItem.IsInSentFolder && 
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   911
                    this.associatedMailItem.OutgoingColor > _pEp_color.pEp_rating_unencrypted)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   912
                {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   913
                    this.ToolStripMenuItemSendUnencrypted.Visible = true;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   914
                    showContextMenu = true;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   915
                }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   916
                else
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   917
                {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   918
                    this.ToolStripMenuItemSendUnencrypted.Visible = false;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   919
                }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   920
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   921
                // Build and enable any options to untrust identities
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   922
                if (this.associatedMailItem != null)
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   923
                {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   924
                    if (this.associatedMailItem.IsIncoming)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   925
                    {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   926
                        // Create and update identity of the sender
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   927
                        pEp_identity_s ident;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   928
                        ident          = new pEp_identity_s();
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   929
                        ident.address  = this.associatedMailItem.FromAddress;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   930
                        ident.username = this.associatedMailItem.FromUsername;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   931
                        ident.user_id  = CryptableMailItem.GetUserIDFromAddress(ident.address, ident.username);
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   932
                        ident = ThisAddIn.pEp.update_identity(ident);
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   933
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   934
                        text = pEp.Properties.Resources.IdentityTrustText + 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   935
                               ident.username + " <" + ident.address + ">";
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   936
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   937
                        this.ContextMenuEncryptionStatus.Items.Add(text, 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   938
                                                                   null, 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   939
                                                                   (x, y) => { this.UndoHandshake(ident); });
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   940
                    }
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   941
                    else
173
cf2c9c426576 Remove the mailItem property and replace with single associatedMailItem variable.
Dean Looyengoed
parents: 172
diff changeset
   942
                    {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   943
                        foreach (pEp_identity_s ident in this.associatedMailItem.Addresses)
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   944
                        {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   945
                            pEp_identity_s identityPartner = ThisAddIn.pEp.update_identity(ident);
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   946
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   947
                            if (identityPartner.comm_type >= _pEp_comm_type.pEp_ct_confirmed_encryption)
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   948
                            {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   949
                                text = pEp.Properties.Resources.IdentityTrustText + 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   950
                                       ident.username + " <" + ident.address + ">";
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   951
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   952
                                this.ContextMenuEncryptionStatus.Items.Add(text, 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   953
                                                                           null, 
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   954
                                                                           (x, y) => { this.UndoHandshake(ident); });
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   955
                            }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   956
                        }
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   957
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   958
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   959
                    showContextMenu = true;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   960
                }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   961
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   962
                // Show the context menu
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   963
                if (showContextMenu)
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   964
                {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   965
                    this.ContextMenuEncryptionStatus.Show(button.PointToScreen(e.Location));
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   966
                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   967
            }
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   968
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   969
            return;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   970
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   971
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   972
        /// <summary>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   973
        /// Event handler for when the send unencrypted tool strip menu is clicked.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   974
        /// This will update whether the email is sent unencrypted or not.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   975
        /// </summary>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   976
        private void ToolStripMenuItemSendUnencrypted_Click(object sender, EventArgs e)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   977
        {
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   978
            // Toggle the checked state
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   979
            this.ToolStripMenuItemSendUnencrypted.Checked = !this.ToolStripMenuItemSendUnencrypted.Checked;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   980
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   981
            // Change the mail item based on UI state, also refresh
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   982
            State state = this.CopyUIToState();
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   983
            this.associatedMailItem.SendUnencrypted = state.SendUnencryptedCheckState;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   984
            this.CopyStateToUI(state);
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   985
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   986
            this.UpdateUIFromMailItem();
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   987
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   988
            return;
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   989
        }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   990
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   991
        /// <summary>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   992
        /// Event handler for when the explanation link label is clicked.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   993
        /// This will show detailed information for the current encryption state.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   994
        /// </summary>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   995
        private void LinkLabelExplanation_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   996
        {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   997
            State state = this.CopyUIToState();
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   998
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
   999
            var result = MessageBox.Show(
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1000
                            state.Explanation + "\n\n" + state.Suggestion,
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1001
                            state.Title,
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1002
                            MessageBoxButtons.OK,
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1003
                            state.EncryptionStatus == _pEp_color.pEp_rating_under_attack
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1004
                                ? MessageBoxIcon.Stop
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1005
                                : MessageBoxIcon.Information
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1006
                        );
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1007
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1008
            return;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
  1009
        }
151
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1010
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1011
        /// <summary>
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1012
        /// Event handler for when the options picture box is clicked.
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1013
        /// This will open the options form for user editing.
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1014
        /// </summary>
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1015
        private void PictureBoxOptions_Click(object sender, EventArgs e)
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1016
        {
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
  1017
            DialogResult result;
152
3028c2790e3d First step at integrated options form. This allows removal of ribbon UI and sets stage for next changes.
Dean Looyengoed
parents: 151
diff changeset
  1018
            FormOptions frm = new FormOptions();
154
8b05adf8a371 Complete refactoring and add state to options form. Also make registry save/load much more robust.
Dean Looyengoed
parents: 152
diff changeset
  1019
            frm.StartPosition = FormStartPosition.CenterScreen;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
  1020
            result = frm.ShowDialog(this.ParentForm); // Must show as dialog to block code
151
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1021
154
8b05adf8a371 Complete refactoring and add state to options form. Also make registry save/load much more robust.
Dean Looyengoed
parents: 152
diff changeset
  1022
            if (ThisAddIn.addIn.use_keyserver)
8b05adf8a371 Complete refactoring and add state to options form. Also make registry save/load much more robust.
Dean Looyengoed
parents: 152
diff changeset
  1023
                ThisAddIn.pEp.start_keyserver_lookup();
8b05adf8a371 Complete refactoring and add state to options form. Also make registry save/load much more robust.
Dean Looyengoed
parents: 152
diff changeset
  1024
            else
8b05adf8a371 Complete refactoring and add state to options form. Also make registry save/load much more robust.
Dean Looyengoed
parents: 152
diff changeset
  1025
                ThisAddIn.pEp.stop_keyserver_lookup();
151
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1026
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1027
            return;
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1028
        }
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1029
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1030
        /// <summary>
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1031
        /// Event handler for when the mouse hovers over the options picture box.
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1032
        /// This is a work-around to show a tool tip.
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1033
        /// </summary>
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1034
        private void PictureBoxOptions_MouseHover(object sender, EventArgs e)
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1035
        {
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1036
            ToolTip toolTip = new ToolTip();
174
b7eae6216fe1 Add a comment reminding to translate in the future
Dean Looyengoed
parents: 173
diff changeset
  1037
            toolTip.SetToolTip(this.PictureBoxOptions, "Click to open options"); // TODO: translate me
151
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1038
            return;
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1039
        }
166
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1040
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1041
        /**************************************************************
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1042
         * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1043
         * Sub-classes
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1044
         * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1045
         *************************************************************/
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1046
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1047
        /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1048
        /// Class used to store the state of the encryption status panel.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1049
        /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1050
        public class State
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1051
        {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1052
            private _pEp_color _EncryptionStatus;
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1053
            private CheckState _SendUnencryptedCheckState;
166
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1054
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1055
            private string _Title;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1056
            private string _Explanation;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1057
            private string _Suggestion;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1058
            private Color  _ButtonBackground;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1059
            private Color  _ButtonForeground;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1060
            private string _ButtonText;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1061
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1062
            /**************************************************************
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1063
             * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1064
             * Constructors
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1065
             * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1066
             *************************************************************/
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1067
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1068
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1069
            /// Default constructor.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1070
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1071
            public State()
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1072
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1073
                this.Reset();
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1074
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1075
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1076
            /**************************************************************
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1077
             * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1078
             * Property Accessors
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1079
             * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1080
             *************************************************************/
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1081
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1082
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1083
            /// Gets or sets the encryption status as a pEp color rating.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1084
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1085
            public _pEp_color EncryptionStatus
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1086
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1087
                get { return (this._EncryptionStatus); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1088
                set 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1089
                { 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1090
                    this._EncryptionStatus = value;
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1091
                    this.UpdateDependentProperties();
166
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1092
                }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1093
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1094
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1095
            /// <summary>
179
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1096
            /// Gets or sets whether the send unencrypted checkbox is checked by the user.
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1097
            /// </summary>
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1098
            public CheckState SendUnencryptedCheckState
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1099
            {
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1100
                get { return (this._SendUnencryptedCheckState); }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1101
                set { this._SendUnencryptedCheckState = value; }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1102
            }
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1103
ff5101f87d35 Finish almost completely rewriting the encryption status panel... yes, it was very necessary.
Dean Looyengoed
parents: 178
diff changeset
  1104
            /// <summary>
166
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1105
            /// Gets the title of the encryption status.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1106
            /// This is dependent on EncryptionStatus and therefore automatically set.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1107
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1108
            public string Title
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1109
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1110
                get { return (this._Title); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1111
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1112
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1113
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1114
            /// Gets the explanation for the encryption status.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1115
            /// This is dependent on EncryptionStatus and therefore automatically set.