EncryptionStatusPanel.cs
author Dean Looyengoed
Tue, 29 Dec 2015 21:33:55 +0100
changeset 172 60c6af7c94e5
parent 171 897440376f2d
child 173 cf2c9c426576
permissions -rw-r--r--
Add state method framework (non-functional right now)
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
        private struct EncStatusData
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    42
        {
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    43
            public string title;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    44
            public string explanation;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    45
            public string suggestion;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    46
            public Color background;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    47
            public Color foreground;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    48
            public string button_text;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    49
            public ContextMenuStrip strip;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    50
        };
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    51
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    52
        /* Notes:
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    53
         * 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
    54
         * Use this.OutlookFormRegion to get a reference to the form region.
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    55
         */
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    56
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    57
        private CryptableMailItem _mailItem = null;
163
c5784c6a3059 Rename local in_reset variable to resetOngoing
Dean Looyengoed
parents: 162
diff changeset
    58
        private bool resetOngoing = false;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    59
        private EncStatusData enc_status_data;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    60
        private _pEp_color _enc_status;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    61
170
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    62
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    63
        private bool eventsAreConnected = false;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    64
        private CryptableMailItem associatedMailItem = null;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    65
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    66
        // UI data or controls not stored in the UI
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    67
        private ContextMenuStrip buttonContextMenuStrip;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
    68
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    69
        /**************************************************************
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    70
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    71
         * Property Accessors
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    72
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    73
         *************************************************************/
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    74
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    75
        CryptableMailItem mailItem
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    76
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    77
            get
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    78
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    79
                try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    80
                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    81
                    if (this.OutlookItem == null)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    82
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    83
                        _mailItem = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    84
                        return null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    85
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    86
                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    87
                catch (COMException)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    88
                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    89
                    return null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    90
                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    91
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    92
                Outlook.MailItem omi = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    93
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    94
                try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    95
                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    96
                    omi = (Outlook.MailItem)this.OutlookItem;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    97
                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    98
                catch
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    99
                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   100
                    _mailItem = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   101
                    return null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   102
                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   103
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   104
                Outlook.MAPIFolder folder = omi.Parent;
136
34e41293d3b0 fun with b0rken IMAP
Volker Birk <vb@pep-project.org>
parents: 133
diff changeset
   105
                Outlook.MAPIFolder deleted = folder.Store.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems);
34e41293d3b0 fun with b0rken IMAP
Volker Birk <vb@pep-project.org>
parents: 133
diff changeset
   106
                if (deleted != null && folder.EntryID == deleted.EntryID)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   107
                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   108
                    _mailItem = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   109
                    return null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   110
                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   111
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   112
                if (_mailItem == null) {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   113
                    _mailItem = new CryptableMailItem(omi);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   114
                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   115
                else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   116
                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   117
                    if (_mailItem.EntryID != omi.EntryID)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   118
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   119
                        _mailItem = new CryptableMailItem(omi);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   120
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   121
                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   122
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   123
                return _mailItem;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   124
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   125
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   126
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   127
        public _pEp_color enc_status {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   128
            get
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   129
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   130
                return _enc_status;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   131
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   132
            set
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   133
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   134
                if (value != _enc_status)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   135
                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   136
                    _enc_status = value;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   137
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   138
                    switch (value)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   139
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   140
                        case _pEp_color.pEp_rating_trusted:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   141
                        case _pEp_color.pEp_rating_trusted_and_anonymized:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   142
                            enc_status_data.explanation = pEp.Properties.Resources.RatingTrustedExplanation;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   143
                            enc_status_data.suggestion = pEp.Properties.Resources.RatingTrustedSuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   144
                            enc_status_data.title = pEp.Properties.Resources.RatingTrustedTitle;
162
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   145
                            enc_status_data.background = COLOR_GREEN;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   146
                            enc_status_data.foreground = TEXT_COLOR_WHITE;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   147
                            enc_status_data.button_text = pEp.Properties.Resources.RatingTrustedButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   148
                            enc_status_data.strip = new ContextMenuStrip();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   149
                            enc_status_data.strip.Items.Add("");
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   150
                            enc_status_data.strip.Opening += secure_strip_Opening;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   151
                            break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   152
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   153
                        case _pEp_color.pEp_rating_reliable:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   154
                            enc_status_data.explanation = pEp.Properties.Resources.RatingReliableExplaination;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   155
                            enc_status_data.suggestion = pEp.Properties.Resources.RatingReliableSuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   156
                            enc_status_data.title = pEp.Properties.Resources.RatingReliableTitle;
162
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   157
                            enc_status_data.background = COLOR_YELLOW;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   158
                            enc_status_data.foreground = TEXT_COLOR_BLACK;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   159
                            enc_status_data.button_text = pEp.Properties.Resources.RatingReliableButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   160
                            enc_status_data.strip = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   161
                            break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   162
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   163
                        case _pEp_color.pEp_rating_unreliable:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   164
                            enc_status_data.explanation = pEp.Properties.Resources.RatingUnreliableExplanation;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   165
                            enc_status_data.suggestion = pEp.Properties.Resources.RatingUnreliableSuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   166
                            enc_status_data.title = pEp.Properties.Resources.RatingUnreliableTitle;
162
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   167
                            enc_status_data.background = COLOR_GREY;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   168
                            enc_status_data.foreground = TEXT_COLOR_BLACK;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   169
                            enc_status_data.button_text = pEp.Properties.Resources.RatingUnreliableButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   170
                            enc_status_data.strip = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   171
                            break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   172
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   173
                        case _pEp_color.pEp_rating_unencrypted:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   174
                            enc_status_data.explanation = pEp.Properties.Resources.RatingUnencryptedExplanation;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   175
                            enc_status_data.suggestion = pEp.Properties.Resources.RatingUnencryptedSuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   176
                            enc_status_data.title = pEp.Properties.Resources.RatingUnencryptedTitle;
162
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   177
                            enc_status_data.background = COLOR_GREY;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   178
                            enc_status_data.foreground = TEXT_COLOR_BLACK;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   179
                            enc_status_data.button_text = pEp.Properties.Resources.RatingUnencryptedButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   180
                            enc_status_data.strip = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   181
                            break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   182
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   183
                        case _pEp_color.pEp_rating_under_attack:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   184
                            enc_status_data.explanation = pEp.Properties.Resources.RatingUnderattackExplanation;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   185
                            enc_status_data.suggestion = pEp.Properties.Resources.RatingUnderattackSuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   186
                            enc_status_data.title = pEp.Properties.Resources.RatingUnderattackTitle;
162
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   187
                            enc_status_data.background = COLOR_RED;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   188
                            enc_status_data.foreground = TEXT_COLOR_WHITE;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   189
                            enc_status_data.button_text = pEp.Properties.Resources.RatingUnderattackButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   190
                            enc_status_data.strip = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   191
                            break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   192
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   193
                        case _pEp_color.pEp_rating_undefined:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   194
                            // will not happen
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   195
                            enc_status_data.explanation = pEp.Properties.Resources.RatingUndefinedExplanation;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   196
                            enc_status_data.suggestion = pEp.Properties.Resources.RatingUndefinedSuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   197
                            enc_status_data.title = pEp.Properties.Resources.RatingUndefinedTitle;
162
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   198
                            enc_status_data.background = COLOR_GREY;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   199
                            enc_status_data.foreground = TEXT_COLOR_BLACK;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   200
                            enc_status_data.button_text = pEp.Properties.Resources.RatingUndefinedButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   201
                            enc_status_data.strip = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   202
                            break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   203
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   204
                        case _pEp_color.pEp_rating_cannot_decrypt:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   205
                        case _pEp_color.pEp_rating_have_no_key:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   206
                            enc_status_data.explanation = pEp.Properties.Resources.RatingHavenokeyExplanation;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   207
                            enc_status_data.suggestion = pEp.Properties.Resources.RatingHavenokeySuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   208
                            enc_status_data.title = pEp.Properties.Resources.RatingHavenokeyTitle;
162
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   209
                            enc_status_data.background = COLOR_GREY;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   210
                            enc_status_data.foreground = TEXT_COLOR_BLACK;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   211
                            enc_status_data.button_text = pEp.Properties.Resources.RatingHavenokeyButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   212
                            enc_status_data.strip = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   213
                            break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   214
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   215
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   216
                    linkExplanation.Text = enc_status_data.title;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   217
                    EncryptionStatus.BackColor = enc_status_data.background;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   218
                    EncryptionStatus.ForeColor = enc_status_data.foreground;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   219
                    EncryptionStatus.Text = enc_status_data.button_text;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   220
                    EncryptionStatus.ContextMenuStrip = enc_status_data.strip;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   221
                }
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
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   224
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   225
        /**************************************************************
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   226
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   227
         * Methods
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   228
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   229
         *************************************************************/
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   230
171
897440376f2d Comment the StopHere method
Dean Looyengoed
parents: 170
diff changeset
   231
        /// <summary>
897440376f2d Comment the StopHere method
Dean Looyengoed
parents: 170
diff changeset
   232
        /// Method used to show/report an error based on build mode.
897440376f2d Comment the StopHere method
Dean Looyengoed
parents: 170
diff changeset
   233
        /// </summary>
897440376f2d Comment the StopHere method
Dean Looyengoed
parents: 170
diff changeset
   234
        /// <param name="reason">The reason/explanation to stop.</param>
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   235
        static void StopHere(string reason)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   236
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   237
#if DEBUG
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   238
            MessageBox.Show(reason);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   239
#else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   240
            try
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   241
            {
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   242
                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
   243
            }
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   244
            catch (COMException) { }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   245
            catch (Exception) { }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   246
#endif
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   247
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   248
170
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   249
        /// <summary>
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   250
        /// 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
   251
        /// 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
   252
        /// </summary>
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   253
        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
   254
        {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   255
            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
   256
            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
   257
            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
   258
            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
   259
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   260
            // Null check
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   261
            if (!errorOccurred)
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   262
            {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   263
                try
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   264
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   265
                    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
   266
                    {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   267
                        errorOccurred = true;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   268
                    }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   269
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   270
                catch (COMException)
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   271
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   272
                    errorOccurred = true;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   273
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   274
            }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   275
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   276
            // 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
   277
            if (!errorOccurred)
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   278
            {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   279
                try
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   280
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   281
                    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
   282
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   283
                catch
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   284
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   285
                    errorOccurred = true;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   286
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   287
            }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   288
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   289
            // 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
   290
            if (!errorOccurred)
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   291
            {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   292
                try
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   293
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   294
                    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
   295
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   296
                    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
   297
                    {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   298
                        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
   299
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   300
                        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
   301
                            (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
   302
                        {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   303
                            errorOccurred = true;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   304
                        }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   305
                    }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   306
                    else
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   307
                    {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   308
                        errorOccurred = true;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   309
                    }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   310
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   311
                catch
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   312
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   313
                    errorOccurred = true;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   314
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   315
            }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   316
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   317
            // 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
   318
            if ((errorOccurred) ||
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   319
                (omi == null))
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   320
            {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   321
                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
   322
            }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   323
            else
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   324
            {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   325
                // 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
   326
                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
   327
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   328
                    // 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
   329
                    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
   330
                    {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   331
                        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
   332
                    }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   333
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   334
                else
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   335
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   336
                    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
   337
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   338
            }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   339
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   340
            return;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   341
        }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   342
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   343
        private void doHandshake(pEp_identity_s identityPartner)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   344
        {
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   345
            string ownShort;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   346
            string ownLong;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   347
            string ownFpr;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   348
            string partnerShort;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   349
            string partnerLong;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   350
            string partnerFpr;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   351
            string[] lines;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   352
            pEp_identity_s me;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   353
            FormHandshake handshakeDialog;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   354
            FormHandshake.State state = new FormHandshake.State();
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   355
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   356
            Debug.Assert(mailItem.ColorRating == _pEp_color.pEp_rating_yellow);
132
f0c74e2c6dfb review of mailItem handling
Volker Birk <vb@pep-project.org>
parents: 131
diff changeset
   357
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   358
            ThisAddIn.verbose("doHandshake");
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   359
            ThisAddIn.verbose(identityPartner.address);
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   360
132
f0c74e2c6dfb review of mailItem handling
Volker Birk <vb@pep-project.org>
parents: 131
diff changeset
   361
            if (identityPartner.username == "")
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   362
                identityPartner.username = identityPartner.address;
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   363
            ThisAddIn.verbose(identityPartner.username);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   364
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   365
            identityPartner.user_id = CryptableMailItem.GetUserIDFromAddress(identityPartner.address, identityPartner.username);
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   366
            ThisAddIn.verbose(identityPartner.user_id);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   367
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   368
            if (mailItem.IsIncoming)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   369
            {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   370
                string entryID = mailItem.ReceivedByEntryID;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   371
                string address = "";
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   372
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   373
                foreach (Outlook.Account a in ThisAddIn.addIn.Application.Session.Accounts){
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   374
                    if (a.CurrentUser.EntryID == entryID) {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   375
                        address = a.SmtpAddress;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   376
                        break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   377
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   378
                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   379
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   380
                if (address == "")
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   381
                    address = ThisAddIn.addIn.Application.Session.Accounts[1].SmtpAddress;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   382
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   383
                me = ThisAddIn.addIn.mySelf(address);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   384
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   385
            else // outgoing
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   386
            {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   387
                ThisAddIn.verbose("mailItem.from_address: " + mailItem.FromAddress);
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   388
                me = ThisAddIn.addIn.mySelf(mailItem.FromAddress);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   389
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   390
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   391
            ThisAddIn.verbose(me.fpr);
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   392
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   393
            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
   394
            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
   395
            ownFpr   = this.ToQuadruple(me.fpr);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   396
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   397
            ThisAddIn.verbose(identityPartner.fpr);
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   398
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   399
            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
   400
            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
   401
            partnerFpr   = this.ToQuadruple(identityPartner.fpr);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   402
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   403
            if (ownFpr.CompareTo(partnerFpr) > 0)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   404
            {
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   405
                state.TrustwordsShort = partnerShort + ownShort;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   406
                state.TrustwordsFull  = partnerLong  + ownLong;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   407
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   408
                lines = new string[3];
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   409
                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
   410
                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
   411
                state.Fingerprint = lines;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   412
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   413
            else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   414
            {
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   415
                state.TrustwordsShort = ownShort + " " + partnerShort;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   416
                state.TrustwordsFull  = ownLong  + " " + partnerLong;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   417
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   418
                lines = new string[3];
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   419
                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
   420
                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
   421
                state.Fingerprint = lines;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   422
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   423
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   424
            ThisAddIn.verbose("try to show dialog");
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   425
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   426
            // 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
   427
            handshakeDialog = new FormHandshake(state);
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   428
132
f0c74e2c6dfb review of mailItem handling
Volker Birk <vb@pep-project.org>
parents: 131
diff changeset
   429
            DialogResult result = handshakeDialog.ShowDialog(this);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   430
            ThisAddIn.verbose("handshakeDialog.ShowDialog(this) => " + result.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   431
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   432
            switch (result)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   433
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   434
                case DialogResult.Yes:
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   435
                    mailItem.ColorRating = _pEp_color.pEp_rating_trusted;
132
f0c74e2c6dfb review of mailItem handling
Volker Birk <vb@pep-project.org>
parents: 131
diff changeset
   436
                    identityPartner = ThisAddIn.pEp.trust_personal_key(identityPartner);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   437
                    reset_enc_status(); 
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   438
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   439
                case DialogResult.No:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   440
                    ThisAddIn.pEp.key_compromized(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   441
                    identityPartner.comm_type = _pEp_comm_type.pEp_ct_compromized;
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   442
                    mailItem.ColorRating = _pEp_color.pEp_rating_red;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   443
                    reset_enc_status(); 
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   444
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   445
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   446
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   447
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   448
        private void undoHandshake(pEp_identity_s identityPartner)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   449
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   450
            ThisAddIn.pEp.update_identity(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   451
//            Debug.Assert((identityPartner.comm_type & _pEp_comm_type.pEp_ct_confirmed) != _pEp_comm_type.pEp_ct_unknown);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   452
            identityPartner.comm_type ^= _pEp_comm_type.pEp_ct_confirmed;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   453
            ThisAddIn.pEp.update_identity(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   454
            reset_enc_status();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   455
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   456
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   457
        /// <summary>
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   458
        /// 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
   459
        /// 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
   460
        /// </summary>
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   461
        /// <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
   462
        /// <returns>The re-formatted string.</returns>
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   463
        private string ToQuadruple(string text)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   464
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   465
            List<string> result = new List<string>();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   466
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   467
            if (text != null)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   468
            {
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   469
                for (int i = 0; i < text.Length; i += 4)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   470
                {
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   471
                    try
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   472
                    {
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   473
                        result.Add(text.Substring(i, 4));
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   474
                    }
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   475
                    catch (ArgumentOutOfRangeException)
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   476
                    {
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   477
                        result.Add(text.Substring(i));
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   478
                        break;
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   479
                    }
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   480
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   481
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   482
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   483
            return String.Join(" ", result);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   484
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   485
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   486
        protected void makePreview()
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   487
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   488
            WindowFormRegionCollection formRegions;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   489
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   490
            if (Globals.ThisAddIn.Application.ActiveInspector() != null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   491
                return;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   492
            else if (Globals.ThisAddIn.Application.ActiveExplorer() != null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   493
                formRegions = Globals.FormRegions[Globals.ThisAddIn.Application.ActiveExplorer()];
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   494
            else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   495
                return;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   496
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   497
            try
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   498
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   499
                if (formRegions.PreviewUnencrypted.Visible)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   500
                {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   501
                    byte[] rtf = mailItem.MirrorGetRTFBody();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   502
                    formRegions.PreviewUnencrypted.textPreview.Rtf = System.Text.Encoding.ASCII.GetString(rtf, 0, rtf.Length);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   503
                    formRegions.PreviewUnencrypted.textSubject.Text = mailItem.MirrorGetSubject();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   504
                    formRegions.PreviewUnencrypted.textFrom.Text = mailItem.FromUsername + " <" + mailItem.FromAddress + ">";
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   505
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   506
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   507
            catch { }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   508
        }
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
        protected void reset_enc_status()
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   511
        {
163
c5784c6a3059 Rename local in_reset variable to resetOngoing
Dean Looyengoed
parents: 162
diff changeset
   512
            if (resetOngoing)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   513
                return;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   514
163
c5784c6a3059 Rename local in_reset variable to resetOngoing
Dean Looyengoed
parents: 162
diff changeset
   515
            this.resetOngoing = true;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   516
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   517
            if (mailItem != null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   518
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   519
                if (_mailItem.DownloadState == Outlook.OlDownloadState.olFullItem)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   520
                {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   521
                    if (_mailItem.SendUnencrypted == CheckState.Checked)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   522
                    {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   523
                        enc_status = _pEp_color.pEp_rating_unencrypted;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   524
                    }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   525
                    else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   526
                    {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   527
                        ThisAddIn.verbose("get_color in reset_enc_status");
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   528
                        enc_status = _mailItem.ColorRating;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   529
                    }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   530
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   531
                else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   532
                {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   533
                    _mailItem.MarkForDownload = Outlook.OlRemoteStatus.olMarkedForDownload;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   534
                    timerRefresh.Interval = 500;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   535
                    timerRefresh.Enabled = true;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   536
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   537
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   538
163
c5784c6a3059 Rename local in_reset variable to resetOngoing
Dean Looyengoed
parents: 162
diff changeset
   539
            this.resetOngoing = false;
159
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
172
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   542
        #region StateMethods
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   543
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   544
        /// <summary>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   545
        /// Connects or disconnects all control events from the UI.
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   546
        /// </summary>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   547
        /// <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
   548
        private void ConnectEvents(bool connect)
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   549
        {
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   550
            // Connect events only if not already connected
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   551
            if ((connect == true) && 
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   552
                (this.eventsAreConnected == false))
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   553
            {
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   554
                
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   555
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   556
                this.eventsAreConnected = true;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   557
            }
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   558
            // Always attempt to disconnect
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   559
            else if (connect == false)
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   560
            {
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   561
                
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   562
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   563
                this.eventsAreConnected = false;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   564
            }
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   565
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   566
            return;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   567
        }
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   568
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   569
        /// <summary>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   570
        /// Refreshes the UI by reloading the state.
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   571
        /// </summary>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   572
        private void RefreshUI()
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   573
        {
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   574
            this.CopyStateToUI(this.CopyUIToState());
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   575
            return;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   576
        }
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   577
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   578
        /// <summary>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   579
        /// Copies the given state to the UI.
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   580
        /// Events are turned off until the process is complete.
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   581
        /// </summary>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   582
        /// <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
   583
        private void CopyStateToUI(State state)
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   584
        {
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   585
            this.ConnectEvents(false);
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   586
            
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   587
            ///////////////////////////////////////////////////////////
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   588
            // Set UI data
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   589
            ///////////////////////////////////////////////////////////
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   590
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   591
            this.LinkLabelExplanation.Text        = state.Title;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   592
            this.ButtonEncryptionStatus.BackColor = state.ButtonBackground;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   593
            this.ButtonEncryptionStatus.ForeColor = state.ButtonForeground;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   594
            this.ButtonEncryptionStatus.Text      = state.ButtonText;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   595
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   596
            ///////////////////////////////////////////////////////////
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   597
            // Set UI selections
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   598
            ///////////////////////////////////////////////////////////
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   599
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   600
            
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   601
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   602
            ///////////////////////////////////////////////////////////
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   603
            // Set UI control visibility
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   604
            ///////////////////////////////////////////////////////////
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   605
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   606
            this.ConnectEvents(true);
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   607
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   608
            return;
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   609
        }
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   610
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   611
        /// <summary>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   612
        /// Copies the UI to a new state.
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   613
        /// </summary>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   614
        /// <returns>The state of the UI.</returns>
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   615
        private State CopyUIToState()
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   616
        {
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   617
            State state = new State();
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   618
            
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   619
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   620
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   621
            return (state);
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   622
        }
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   623
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   624
        #endregion
60c6af7c94e5 Add state method framework (non-functional right now)
Dean Looyengoed
parents: 171
diff changeset
   625
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   626
        /**************************************************************
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   627
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   628
         * Event Handling
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   629
         * 
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
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   632
        /// <summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   633
        /// 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
   634
        /// </summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   635
        private void FormRegion1_FormRegionShowing(object sender, System.EventArgs e)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   636
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   637
            if (this.OutlookItem == null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   638
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   639
                enc_status = _pEp_color.pEp_rating_undefined;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   640
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   641
            else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   642
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   643
                Outlook.MailItem omi = (Outlook.MailItem)this.OutlookItem;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   644
                try
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   645
                {
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   646
                    omi.PropertyChange += MailItem_PropertyChange;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   647
                    if (CryptableMailItem.IsEncryptedStore(omi))
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   648
                    {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   649
                        if (PreviewUnencrypted.isPGPEncrypted(omi) && omi.Sender != null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   650
                        {
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   651
                            omi.Open += MailItem_Open;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   652
                        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   653
                    }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   654
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   655
                catch { }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   656
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   657
                if (ThisAddIn.addIn.enabled)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   658
                {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   659
                    reset_enc_status();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   660
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   661
                else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   662
                {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   663
                    timerRefresh.Enabled = true;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   664
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   665
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   666
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   667
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   668
        /// <summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   669
        /// Event handler for when the form region is closed.
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   670
        /// </summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   671
        private void FormRegion1_FormRegionClosed(object sender, System.EventArgs e)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   672
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   673
            return;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   674
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   675
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   676
        /// <summary>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   677
        /// 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
   678
        /// </summary>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   679
        /// <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
   680
        /// 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
   681
        /// and the inspector is not displayed.</param>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   682
        private void MailItem_Open(ref bool cancel)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   683
        {
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   684
            // Cancel opening the if the mirror is displayed instead
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   685
            if (mailItem != null && _mailItem.MirrorDisplay())
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   686
            {
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   687
                cancel = true;
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   688
            }
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   689
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   690
            return;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   691
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   692
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   693
        /// <summary>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   694
        /// Event handler for when a mail item property is changed.
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   695
        /// See: https://msdn.microsoft.com/en-us/library/office/ff866739.aspx
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   696
        /// </summary>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   697
        /// <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
   698
        private void MailItem_PropertyChange(string propertyName)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   699
        {
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   700
            switch (propertyName)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   701
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   702
                case "To":
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   703
                    timerRefresh.Enabled = true;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   704
                    break;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   705
                // 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
   706
                //case "CC":
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   707
                //    reset_enc_status();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   708
                //    break;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   709
            }
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   710
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   711
            return;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   712
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   713
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   714
        private void secure_strip_Opening(object sender, System.ComponentModel.CancelEventArgs e)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   715
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   716
            enc_status_data.strip.Items.Clear();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   717
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   718
            if (mailItem.IsIncoming)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   719
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   720
                pEp_identity_s ident = new pEp_identity_s();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   721
                ident.address = mailItem.FromAddress;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   722
                ident.username = mailItem.FromUsername;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   723
                ident.user_id = CryptableMailItem.GetUserIDFromAddress(ident.address, ident.username);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   724
                ident = ThisAddIn.pEp.update_identity(ident);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   725
                string text = pEp.Properties.Resources.IdentityTrustText + ident.username + " <" + ident.address + ">";
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   726
                enc_status_data.strip.Items.Add(text, null, (x, y) => { undoHandshake(ident); });
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   727
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   728
            else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   729
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   730
                foreach (pEp_identity_s ident in mailItem.Addresses)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   731
                {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   732
                    pEp_identity_s identityPartner = ThisAddIn.pEp.update_identity(ident);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   733
                    if (identityPartner.comm_type >= _pEp_comm_type.pEp_ct_confirmed_encryption)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   734
                    {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   735
                        string text = pEp.Properties.Resources.IdentityTrustText + ident.username + " <" + ident.address + ">";
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   736
                        enc_status_data.strip.Items.Add(text, null, (x, y) => { undoHandshake(ident); });
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   737
                    }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   738
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   739
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   740
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   741
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   742
        private void EncryptionStatus_Click(object sender, EventArgs e)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   743
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   744
            switch (enc_status)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   745
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   746
                case _pEp_color.pEp_rating_green:
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
                    {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   749
                        string[] key_list = mailItem.Keylist;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   750
                        if (key_list.Length > 0)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   751
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   752
                            string msg;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   753
                            if (key_list.Length > 1)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   754
                                msg = String.Format(pEp.Properties.Resources.EncryptionStatusClickMessageMultiple + " {0}.", String.Join(", ", key_list));
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   755
                            else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   756
                                msg = String.Format(pEp.Properties.Resources.EncryptionStatusClickMessageSingle + " {0}.", key_list[0]);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   757
                            MessageBox.Show(msg, pEp.Properties.Resources.EncryptionStatusClickMessageBox, MessageBoxButtons.OK, MessageBoxIcon.Information);
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
                    catch (Exception ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   761
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   762
                        StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   763
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   764
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   765
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   766
                case _pEp_color.pEp_rating_yellow:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   767
                    try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   768
                    {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   769
                        if (mailItem.IsIncoming)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   770
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   771
                            pEp_identity_s identityPartner = new pEp_identity_s();
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   772
                            identityPartner.address = mailItem.FromAddress;
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   773
                            identityPartner.username = mailItem.FromUsername;
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   774
                            identityPartner.user_id = CryptableMailItem.GetUserIDFromAddress(identityPartner.address, identityPartner.username);
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   775
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   776
                            try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   777
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   778
                                identityPartner = ThisAddIn.pEp.update_identity(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   779
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   780
                            catch
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   781
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   782
                                enc_status = _pEp_color.pEp_rating_undefined;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   783
                                return;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   784
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   785
                            doHandshake(identityPartner);
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
                        else // outgoing
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   788
                        {
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   789
                            ThisAddIn.verbose("yellow, handshake initiated");
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   790
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   791
                            List<pEp_identity_s> partnersToCheck = new List<pEp_identity_s>();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   792
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   793
                            foreach (pEp_identity_s identity in mailItem.Addresses)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   794
                            {
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   795
                                ThisAddIn.verbose("adding " + identity.username + " <" + identity.address + ">");
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   796
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   797
                                try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   798
                                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   799
                                    pEp_identity_s identityPartner = ThisAddIn.pEp.update_identity(identity);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   800
                                    if (identityPartner.comm_type >= _pEp_comm_type.pEp_ct_unconfirmed_encryption
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   801
                                        && identityPartner.comm_type < _pEp_comm_type.pEp_ct_confirmed_encryption)
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
                                        partnersToCheck.Add(identityPartner);
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
                                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   806
                                catch
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   807
                                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   808
                                }
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
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   811
                            if (partnersToCheck.Count == 0)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   812
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   813
                                enc_status = _pEp_color.pEp_rating_undefined;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   814
                                return;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   815
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   816
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   817
                            pEp_identity_s[] addresses = mailItem.Addresses;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   818
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   819
                            if (addresses.Length == 1)
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
                                doHandshake(partnersToCheck[0]);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   822
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   823
                            else if (addresses.Length > 1)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   824
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   825
                                contextMenuHandshake.Items.Clear();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   826
                                foreach (pEp_identity_s identity in partnersToCheck) {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   827
                                    string text = identity.username + " <" + identity.address + ">";
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   828
                                    contextMenuHandshake.Items.Add(text, null, (x, y) => { doHandshake(identity); });
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   829
                                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   830
                                contextMenuHandshake.Show(EncryptionStatus, 10, 10);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   831
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   832
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   833
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   834
                    catch (COMException ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   835
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   836
                        StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   837
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   838
                    catch (Exception ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   839
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   840
                        StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   841
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   842
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   843
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   844
                case _pEp_color.pEp_rating_unencrypted:
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   845
                    if (mailItem.IsIncoming)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   846
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   847
                        MessageBox.Show(pEp.Properties.Resources.RatingUnencryptedMessageboxReasonBody, pEp.Properties.Resources.RatingUnencryptedMessageboxReasonTitle);
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
                    else
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
                        try
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
                            string reason = "";
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   854
                            foreach (pEp_identity_s identity in mailItem.Addresses)
133
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
                                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
   857
                                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   858
                                    if (reason != "")
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   859
                                        reason += "\n";
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   860
                                    // BUG: reason string in English language only and trivial
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   861
                                    string ct = identity.comm_type.ToString();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   862
                                    ct = new string(ct.Skip(7).ToArray());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   863
                                    ct = ct.Replace("_", " ");
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   864
                                    reason += identity.username + " <" + identity.address + ">: " + ct;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   865
                                }
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
                            if (reason != "")
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   868
                                MessageBox.Show(reason, pEp.Properties.Resources.RatingUnencryptedMessageboxReasonTitle);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   869
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   870
                        catch (COMException ex)
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
                            StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   873
                        }
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
                    break;
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
                case _pEp_color.pEp_rating_cannot_decrypt:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   878
                case _pEp_color.pEp_rating_have_no_key:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   879
                    try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   880
                    {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   881
                        string[] keys = mailItem.Keylist;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   882
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   883
                        if (keys.Length > 1)
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
                            string reason;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   886
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   887
                            if (keys.Length == 2)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   888
                                reason = pEp.Properties.Resources.RatingHavenokeyMessageboxReasonBodyNokey;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   889
                            else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   890
                                reason = string.Format(pEp.Properties.Resources.RatingHavenokeyMessageboxReasonBodySomekey, keys.Length - 1);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   891
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   892
                            string keyinfo = "";
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   893
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   894
                            foreach (string key in keys)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   895
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   896
                                if (key.Length >= 8)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   897
                                    keyinfo += "\n" + key;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   898
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   899
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   900
                            reason += keyinfo;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   901
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   902
                            MessageBox.Show(reason, pEp.Properties.Resources.RatingHavenokeyTitle);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   903
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   904
                        else if (keys.Length == 1)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   905
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   906
                            MessageBox.Show(pEp.Properties.Resources.RatingHavenokeyMessageboxReasonError + keys[0], pEp.Properties.Resources.RatingHavenokeyTitle);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   907
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   908
                        else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   909
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   910
                            MessageBox.Show(pEp.Properties.Resources.RatingHavenokeyMessageboxReasonUnknownformat, pEp.Properties.Resources.RatingHavenokeyTitle);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   911
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   912
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   913
                    catch (COMException ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   914
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   915
                        StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   916
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   917
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   918
                    
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   919
                case _pEp_color.pEp_rating_undefined:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   920
                    if (mailItem != null)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   921
                    {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   922
                        enc_status = mailItem.ColorRating;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   923
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   924
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   925
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   926
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   927
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   928
        private void linkExplanation_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   929
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   930
            if (enc_status == _pEp_color.pEp_rating_undefined)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   931
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   932
                enc_status_data.explanation = pEp.Properties.Resources.RatingUndefinedExplanation;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   933
                enc_status_data.suggestion = pEp.Properties.Resources.RatingUndefinedSuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   934
                enc_status_data.title = pEp.Properties.Resources.RatingUndefinedTitle;
162
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   935
                enc_status_data.background = COLOR_GREY;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   936
                enc_status_data.foreground = TEXT_COLOR_BLACK;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   937
                enc_status_data.button_text = pEp.Properties.Resources.RatingUndefinedButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   938
                enc_status_data.strip = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   939
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   940
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   941
            var result = MessageBox.Show(
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   942
                            enc_status_data.explanation + "\n\n" + enc_status_data.suggestion,
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   943
                            enc_status_data.title,
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   944
                            MessageBoxButtons.OK,
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   945
                            enc_status == _pEp_color.pEp_rating_under_attack
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   946
                                ? MessageBoxIcon.Stop
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   947
                                : MessageBoxIcon.Information
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   948
                        );
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   949
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   950
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   951
        private void timerRefresh_Tick(object sender, EventArgs e)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   952
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   953
            timerRefresh.Interval = 100;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   954
            timerRefresh.Enabled = false; // only once
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   955
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   956
            if (!ThisAddIn.addIn.enabled)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   957
                ThisAddIn.addIn.enable();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   958
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   959
            makePreview();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   960
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   961
            reset_enc_status();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   962
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   963
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   964
        private void EncryptionStatus_MouseUp(object sender, MouseEventArgs e)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   965
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   966
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   967
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   968
                CryptableMailItem cmi = mailItem;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   969
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   970
                if (cmi != null && !cmi.IsIncoming && !cmi.IsInSentFolder && cmi.OutgoingColor > _pEp_color.pEp_rating_unencrypted)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   971
                {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   972
                    if (cmi.SendUnencrypted == CheckState.Indeterminate)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   973
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   974
                        sendUnencryptedToolStripMenuItem.CheckState = CheckState.Unchecked;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   975
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   976
                    else {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   977
                        sendUnencryptedToolStripMenuItem.CheckState = cmi.SendUnencrypted;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   978
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   979
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   980
                    Control _sender = (Control)sender;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   981
                    contextMenuEdit.Show(_sender.PointToScreen(e.Location));
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   982
                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   983
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   984
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   985
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   986
        private void sendUnencryptedToolStripMenuItem_Click(object sender, EventArgs e)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   987
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   988
            sendUnencryptedToolStripMenuItem.Checked = !sendUnencryptedToolStripMenuItem.Checked;
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   989
            mailItem.SendUnencrypted = sendUnencryptedToolStripMenuItem.CheckState;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   990
            timerRefresh.Enabled = true;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   991
        }
151
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   992
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   993
        /// <summary>
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   994
        /// 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
   995
        /// 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
   996
        /// </summary>
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   997
        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
   998
        {
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   999
            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
  1000
            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
  1001
            frm.StartPosition = FormStartPosition.CenterScreen;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
  1002
            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
  1003
154
8b05adf8a371 Complete refactoring and add state to options form. Also make registry save/load much more robust.
Dean Looyengoed
parents: 152
diff changeset
  1004
            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
  1005
                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
  1006
            else
8b05adf8a371 Complete refactoring and add state to options form. Also make registry save/load much more robust.
Dean Looyengoed
parents: 152
diff changeset
  1007
                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
  1008
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1009
            return;
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
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1012
        /// <summary>
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1013
        /// 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
  1014
        /// 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
  1015
        /// </summary>
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1016
        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
  1017
        {
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1018
            ToolTip toolTip = new ToolTip();
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1019
            toolTip.SetToolTip(this.PictureBoxOptions, "Click to open options");
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1020
            return;
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
  1021
        }
166
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1022
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1023
        /**************************************************************
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1024
         * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1025
         * Sub-classes
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1026
         * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1027
         *************************************************************/
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1028
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1029
        /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1030
        /// 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
  1031
        /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1032
        public class State
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1033
        {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1034
            private _pEp_color _EncryptionStatus;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1035
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1036
            private string _Title;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1037
            private string _Explanation;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1038
            private string _Suggestion;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1039
            private Color  _ButtonBackground;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1040
            private Color  _ButtonForeground;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1041
            private string _ButtonText;
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
            /**************************************************************
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
             * Constructors
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
             *************************************************************/
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1048
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
            /// Default constructor.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1051
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1052
            public State()
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1053
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1054
                this.Reset();
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1055
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1056
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1057
            /**************************************************************
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1058
             * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1059
             * Property Accessors
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1060
             * 
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
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1064
            /// 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
  1065
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1066
            public _pEp_color EncryptionStatus
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
                get { return (this._EncryptionStatus); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1069
                set 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1070
                { 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1071
                    this._EncryptionStatus = value;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1072
                    this.UpdateProperties();
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1073
                }
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
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1077
            /// Gets the title of the encryption status.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1078
            /// 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
  1079
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1080
            public string Title
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
                get { return (this._Title); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1083
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1084
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1085
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1086
            /// Gets the explanation for the encryption status.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1087
            /// 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
  1088
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1089
            public string Explanation
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1090
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1091
                get { return (this._Explanation); }
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
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1095
            /// Gets the suggestion to improve the encryption status.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1096
            /// 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
  1097
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1098
            public string Suggestion
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1099
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1100
                get { return (this._Suggestion); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1101
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1102
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1103
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1104
            /// Gets the background color of the encryption button.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1105
            /// 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
  1106
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1107
            public Color ButtonBackground
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1108
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1109
                get { return (this._ButtonBackground); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1110
            }
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
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1113
            /// Gets the foreground color of the encryption button.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1114
            /// 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
  1115
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1116
            public Color ButtonForeground
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1117
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1118
                get { return (this._ButtonForeground); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1119
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1120
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1121
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1122
            /// Gets the text of the encryption button.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1123
            /// 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
  1124
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1125
            public string ButtonText
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1126
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1127
                get { return (this._ButtonText); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1128
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1129
e830996006c2 Add initial state class to the encryption status panel
Dean Looyeng&