EncryptionStatusPanel.cs
author Dean Looyengoed
Tue, 29 Dec 2015 21:26:17 +0100
changeset 170 07911d16b012
parent 169 c7d9b7ad0639
child 171 897440376f2d
permissions -rw-r--r--
Add method to determine then set the associated mail item for the encryption status panel.
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
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   231
        static void StopHere(string reason)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   232
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   233
#if DEBUG
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   234
            MessageBox.Show(reason);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   235
#else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   236
            try
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   237
            {
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   238
                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
   239
            }
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   240
            catch (COMException) { }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   241
            catch (Exception) { }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   242
#endif
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   243
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   244
170
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   245
        /// <summary>
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   246
        /// 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
   247
        /// 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
   248
        /// </summary>
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   249
        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
   250
        {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   251
            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
   252
            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
   253
            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
   254
            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
   255
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   256
            // Null check
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   257
            if (!errorOccurred)
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   258
            {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   259
                try
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   260
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   261
                    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
   262
                    {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   263
                        errorOccurred = true;
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
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   266
                catch (COMException)
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   267
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   268
                    errorOccurred = true;
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
            }
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
            // 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
   273
            if (!errorOccurred)
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
                try
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   276
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   277
                    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
   278
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   279
                catch
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
                    errorOccurred = true;
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
            }
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
            // 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
   286
            if (!errorOccurred)
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
                try
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   289
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   290
                    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
   291
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   292
                    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
   293
                    {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   294
                        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
   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 ((deletedFolder != null) && 
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   297
                            (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
   298
                        {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   299
                            errorOccurred = true;
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   300
                        }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   301
                    }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   302
                    else
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   303
                    {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   304
                        errorOccurred = true;
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
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   307
                catch
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   308
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   309
                    errorOccurred = true;
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
            }
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
            // 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
   314
            if ((errorOccurred) ||
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   315
                (omi == null))
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
                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
   318
            }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   319
            else
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
                // 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
   322
                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
   323
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   324
                    // 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
   325
                    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
   326
                    {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   327
                        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
   328
                    }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   329
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   330
                else
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   331
                {
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   332
                    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
   333
                }
07911d16b012 Add method to determine then set the associated mail item for the encryption status panel.
Dean Looyengoed
parents: 169
diff changeset
   334
            }
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
            return;
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
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   339
        private void doHandshake(pEp_identity_s identityPartner)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   340
        {
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   341
            string ownShort;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   342
            string ownLong;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   343
            string ownFpr;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   344
            string partnerShort;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   345
            string partnerLong;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   346
            string partnerFpr;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   347
            string[] lines;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   348
            pEp_identity_s me;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   349
            FormHandshake handshakeDialog;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   350
            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
   351
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   352
            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
   353
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   354
            ThisAddIn.verbose("doHandshake");
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   355
            ThisAddIn.verbose(identityPartner.address);
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   356
132
f0c74e2c6dfb review of mailItem handling
Volker Birk <vb@pep-project.org>
parents: 131
diff changeset
   357
            if (identityPartner.username == "")
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   358
                identityPartner.username = identityPartner.address;
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   359
            ThisAddIn.verbose(identityPartner.username);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   360
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   361
            identityPartner.user_id = CryptableMailItem.GetUserIDFromAddress(identityPartner.address, identityPartner.username);
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   362
            ThisAddIn.verbose(identityPartner.user_id);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   363
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   364
            if (mailItem.IsIncoming)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   365
            {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   366
                string entryID = mailItem.ReceivedByEntryID;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   367
                string address = "";
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   368
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   369
                foreach (Outlook.Account a in ThisAddIn.addIn.Application.Session.Accounts){
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   370
                    if (a.CurrentUser.EntryID == entryID) {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   371
                        address = a.SmtpAddress;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   372
                        break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   373
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   374
                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   375
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   376
                if (address == "")
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   377
                    address = ThisAddIn.addIn.Application.Session.Accounts[1].SmtpAddress;
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
                me = ThisAddIn.addIn.mySelf(address);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   380
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   381
            else // outgoing
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   382
            {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   383
                ThisAddIn.verbose("mailItem.from_address: " + mailItem.FromAddress);
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   384
                me = ThisAddIn.addIn.mySelf(mailItem.FromAddress);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   385
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   386
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   387
            ThisAddIn.verbose(me.fpr);
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   388
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   389
            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
   390
            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
   391
            ownFpr   = this.ToQuadruple(me.fpr);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   392
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   393
            ThisAddIn.verbose(identityPartner.fpr);
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   394
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   395
            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
   396
            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
   397
            partnerFpr   = this.ToQuadruple(identityPartner.fpr);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
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
            if (ownFpr.CompareTo(partnerFpr) > 0)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   400
            {
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   401
                state.TrustwordsShort = partnerShort + ownShort;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   402
                state.TrustwordsFull  = partnerLong  + ownLong;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   403
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   404
                lines = new string[3];
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   405
                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
   406
                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
   407
                state.Fingerprint = lines;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   408
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   409
            else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   410
            {
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   411
                state.TrustwordsShort = ownShort + " " + partnerShort;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   412
                state.TrustwordsFull  = ownLong  + " " + partnerLong;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   413
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   414
                lines = new string[3];
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   415
                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
   416
                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
   417
                state.Fingerprint = lines;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   418
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   419
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   420
            ThisAddIn.verbose("try to show dialog");
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   421
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   422
            // 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
   423
            handshakeDialog = new FormHandshake(state);
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   424
132
f0c74e2c6dfb review of mailItem handling
Volker Birk <vb@pep-project.org>
parents: 131
diff changeset
   425
            DialogResult result = handshakeDialog.ShowDialog(this);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   426
            ThisAddIn.verbose("handshakeDialog.ShowDialog(this) => " + result.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   427
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   428
            switch (result)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   429
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   430
                case DialogResult.Yes:
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   431
                    mailItem.ColorRating = _pEp_color.pEp_rating_trusted;
132
f0c74e2c6dfb review of mailItem handling
Volker Birk <vb@pep-project.org>
parents: 131
diff changeset
   432
                    identityPartner = ThisAddIn.pEp.trust_personal_key(identityPartner);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   433
                    reset_enc_status(); 
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   434
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   435
                case DialogResult.No:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   436
                    ThisAddIn.pEp.key_compromized(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   437
                    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
   438
                    mailItem.ColorRating = _pEp_color.pEp_rating_red;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   439
                    reset_enc_status(); 
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   440
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   441
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   442
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   443
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   444
        private void undoHandshake(pEp_identity_s identityPartner)
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
            ThisAddIn.pEp.update_identity(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   447
//            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
   448
            identityPartner.comm_type ^= _pEp_comm_type.pEp_ct_confirmed;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   449
            ThisAddIn.pEp.update_identity(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   450
            reset_enc_status();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   451
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   452
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   453
        /// <summary>
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   454
        /// 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
   455
        /// 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
   456
        /// </summary>
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   457
        /// <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
   458
        /// <returns>The re-formatted string.</returns>
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   459
        private string ToQuadruple(string text)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   460
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   461
            List<string> result = new List<string>();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   462
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   463
            if (text != null)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   464
            {
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   465
                for (int i = 0; i < text.Length; i += 4)
159
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
                    try
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   468
                    {
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   469
                        result.Add(text.Substring(i, 4));
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   470
                    }
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   471
                    catch (ArgumentOutOfRangeException)
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));
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   474
                        break;
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   475
                    }
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   476
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   477
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   478
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   479
            return String.Join(" ", result);
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
        protected void makePreview()
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   483
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   484
            WindowFormRegionCollection formRegions;
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
            if (Globals.ThisAddIn.Application.ActiveInspector() != null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   487
                return;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   488
            else if (Globals.ThisAddIn.Application.ActiveExplorer() != null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   489
                formRegions = Globals.FormRegions[Globals.ThisAddIn.Application.ActiveExplorer()];
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   490
            else
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
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   493
            try
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   494
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   495
                if (formRegions.PreviewUnencrypted.Visible)
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
                    byte[] rtf = mailItem.MirrorGetRTFBody();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   498
                    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
   499
                    formRegions.PreviewUnencrypted.textSubject.Text = mailItem.MirrorGetSubject();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   500
                    formRegions.PreviewUnencrypted.textFrom.Text = mailItem.FromUsername + " <" + mailItem.FromAddress + ">";
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   501
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   502
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   503
            catch { }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   504
        }
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
        protected void reset_enc_status()
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   507
        {
163
c5784c6a3059 Rename local in_reset variable to resetOngoing
Dean Looyengoed
parents: 162
diff changeset
   508
            if (resetOngoing)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   509
                return;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   510
163
c5784c6a3059 Rename local in_reset variable to resetOngoing
Dean Looyengoed
parents: 162
diff changeset
   511
            this.resetOngoing = true;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   512
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   513
            if (mailItem != null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   514
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   515
                if (_mailItem.DownloadState == Outlook.OlDownloadState.olFullItem)
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.SendUnencrypted == CheckState.Checked)
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
                        enc_status = _pEp_color.pEp_rating_unencrypted;
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
                    else
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
                        ThisAddIn.verbose("get_color in reset_enc_status");
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   524
                        enc_status = _mailItem.ColorRating;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   525
                    }
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
                else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   528
                {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   529
                    _mailItem.MarkForDownload = Outlook.OlRemoteStatus.olMarkedForDownload;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   530
                    timerRefresh.Interval = 500;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   531
                    timerRefresh.Enabled = true;
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
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   534
163
c5784c6a3059 Rename local in_reset variable to resetOngoing
Dean Looyengoed
parents: 162
diff changeset
   535
            this.resetOngoing = false;
159
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
        /**************************************************************
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   539
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   540
         * Event Handling
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   541
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   542
         *************************************************************/
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   543
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   544
        /// <summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   545
        /// 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
   546
        /// </summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   547
        private void FormRegion1_FormRegionShowing(object sender, System.EventArgs e)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   548
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   549
            if (this.OutlookItem == null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   550
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   551
                enc_status = _pEp_color.pEp_rating_undefined;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   552
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   553
            else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   554
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   555
                Outlook.MailItem omi = (Outlook.MailItem)this.OutlookItem;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   556
                try
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   557
                {
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   558
                    omi.PropertyChange += MailItem_PropertyChange;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   559
                    if (CryptableMailItem.IsEncryptedStore(omi))
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   560
                    {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   561
                        if (PreviewUnencrypted.isPGPEncrypted(omi) && omi.Sender != null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   562
                        {
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   563
                            omi.Open += MailItem_Open;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   564
                        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   565
                    }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   566
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   567
                catch { }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   568
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   569
                if (ThisAddIn.addIn.enabled)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   570
                {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   571
                    reset_enc_status();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   572
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   573
                else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   574
                {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   575
                    timerRefresh.Enabled = true;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   576
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   577
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   578
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   579
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   580
        /// <summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   581
        /// Event handler for when the form region is closed.
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   582
        /// </summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   583
        private void FormRegion1_FormRegionClosed(object sender, System.EventArgs e)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   584
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   585
            return;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   586
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   587
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   588
        /// <summary>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   589
        /// 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
   590
        /// </summary>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   591
        /// <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
   592
        /// 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
   593
        /// and the inspector is not displayed.</param>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   594
        private void MailItem_Open(ref bool cancel)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   595
        {
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   596
            // Cancel opening the if the mirror is displayed instead
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   597
            if (mailItem != null && _mailItem.MirrorDisplay())
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   598
            {
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   599
                cancel = true;
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   600
            }
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   601
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   602
            return;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   603
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   604
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   605
        /// <summary>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   606
        /// Event handler for when a mail item property is changed.
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   607
        /// See: https://msdn.microsoft.com/en-us/library/office/ff866739.aspx
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   608
        /// </summary>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   609
        /// <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
   610
        private void MailItem_PropertyChange(string propertyName)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   611
        {
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   612
            switch (propertyName)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   613
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   614
                case "To":
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   615
                    timerRefresh.Enabled = true;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   616
                    break;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   617
                // 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
   618
                //case "CC":
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   619
                //    reset_enc_status();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   620
                //    break;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   621
            }
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   622
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   623
            return;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   624
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   625
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   626
        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
   627
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   628
            enc_status_data.strip.Items.Clear();
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
            if (mailItem.IsIncoming)
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
                pEp_identity_s ident = new pEp_identity_s();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   633
                ident.address = mailItem.FromAddress;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   634
                ident.username = mailItem.FromUsername;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   635
                ident.user_id = CryptableMailItem.GetUserIDFromAddress(ident.address, ident.username);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   636
                ident = ThisAddIn.pEp.update_identity(ident);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   637
                string text = pEp.Properties.Resources.IdentityTrustText + ident.username + " <" + ident.address + ">";
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   638
                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
   639
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   640
            else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   641
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   642
                foreach (pEp_identity_s ident in mailItem.Addresses)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   643
                {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   644
                    pEp_identity_s identityPartner = ThisAddIn.pEp.update_identity(ident);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   645
                    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
   646
                    {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   647
                        string text = pEp.Properties.Resources.IdentityTrustText + ident.username + " <" + ident.address + ">";
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   648
                        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
   649
                    }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   650
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   651
            }
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
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   654
        private void EncryptionStatus_Click(object sender, EventArgs e)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   655
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   656
            switch (enc_status)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   657
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   658
                case _pEp_color.pEp_rating_green:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   659
                    try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   660
                    {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   661
                        string[] key_list = mailItem.Keylist;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   662
                        if (key_list.Length > 0)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   663
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   664
                            string msg;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   665
                            if (key_list.Length > 1)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   666
                                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
   667
                            else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   668
                                msg = String.Format(pEp.Properties.Resources.EncryptionStatusClickMessageSingle + " {0}.", key_list[0]);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   669
                            MessageBox.Show(msg, pEp.Properties.Resources.EncryptionStatusClickMessageBox, MessageBoxButtons.OK, MessageBoxIcon.Information);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   670
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   671
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   672
                    catch (Exception ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   673
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   674
                        StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   675
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   676
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   677
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   678
                case _pEp_color.pEp_rating_yellow:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   679
                    try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   680
                    {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   681
                        if (mailItem.IsIncoming)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   682
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   683
                            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
   684
                            identityPartner.address = mailItem.FromAddress;
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   685
                            identityPartner.username = mailItem.FromUsername;
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   686
                            identityPartner.user_id = CryptableMailItem.GetUserIDFromAddress(identityPartner.address, identityPartner.username);
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   687
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   688
                            try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   689
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   690
                                identityPartner = ThisAddIn.pEp.update_identity(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   691
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   692
                            catch
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   693
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   694
                                enc_status = _pEp_color.pEp_rating_undefined;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   695
                                return;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   696
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   697
                            doHandshake(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   698
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   699
                        else // outgoing
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   700
                        {
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   701
                            ThisAddIn.verbose("yellow, handshake initiated");
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   702
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   703
                            List<pEp_identity_s> partnersToCheck = new List<pEp_identity_s>();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   704
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   705
                            foreach (pEp_identity_s identity in mailItem.Addresses)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   706
                            {
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   707
                                ThisAddIn.verbose("adding " + identity.username + " <" + identity.address + ">");
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   708
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   709
                                try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   710
                                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   711
                                    pEp_identity_s identityPartner = ThisAddIn.pEp.update_identity(identity);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   712
                                    if (identityPartner.comm_type >= _pEp_comm_type.pEp_ct_unconfirmed_encryption
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   713
                                        && identityPartner.comm_type < _pEp_comm_type.pEp_ct_confirmed_encryption)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   714
                                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   715
                                        partnersToCheck.Add(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   716
                                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   717
                                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   718
                                catch
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   719
                                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   720
                                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   721
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   722
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   723
                            if (partnersToCheck.Count == 0)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   724
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   725
                                enc_status = _pEp_color.pEp_rating_undefined;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   726
                                return;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   727
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   728
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   729
                            pEp_identity_s[] addresses = mailItem.Addresses;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   730
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   731
                            if (addresses.Length == 1)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   732
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   733
                                doHandshake(partnersToCheck[0]);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   734
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   735
                            else if (addresses.Length > 1)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   736
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   737
                                contextMenuHandshake.Items.Clear();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   738
                                foreach (pEp_identity_s identity in partnersToCheck) {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   739
                                    string text = identity.username + " <" + identity.address + ">";
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   740
                                    contextMenuHandshake.Items.Add(text, null, (x, y) => { doHandshake(identity); });
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   741
                                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   742
                                contextMenuHandshake.Show(EncryptionStatus, 10, 10);
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
                        }
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
                    catch (COMException ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   747
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   748
                        StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   749
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   750
                    catch (Exception ex)
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
                        StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   753
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   754
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   755
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   756
                case _pEp_color.pEp_rating_unencrypted:
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   757
                    if (mailItem.IsIncoming)
133
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
                        MessageBox.Show(pEp.Properties.Resources.RatingUnencryptedMessageboxReasonBody, pEp.Properties.Resources.RatingUnencryptedMessageboxReasonTitle);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   760
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   761
                    else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   762
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   763
                        try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   764
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   765
                            string reason = "";
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   766
                            foreach (pEp_identity_s identity in mailItem.Addresses)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   767
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   768
                                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
   769
                                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   770
                                    if (reason != "")
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   771
                                        reason += "\n";
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   772
                                    // BUG: reason string in English language only and trivial
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   773
                                    string ct = identity.comm_type.ToString();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   774
                                    ct = new string(ct.Skip(7).ToArray());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   775
                                    ct = ct.Replace("_", " ");
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   776
                                    reason += identity.username + " <" + identity.address + ">: " + ct;
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
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   779
                            if (reason != "")
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   780
                                MessageBox.Show(reason, pEp.Properties.Resources.RatingUnencryptedMessageboxReasonTitle);
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
                        catch (COMException ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   783
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   784
                            StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   785
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   786
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   787
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   788
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   789
                case _pEp_color.pEp_rating_cannot_decrypt:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   790
                case _pEp_color.pEp_rating_have_no_key:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   791
                    try
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
                        string[] keys = mailItem.Keylist;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   794
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   795
                        if (keys.Length > 1)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   796
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   797
                            string reason;
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
                            if (keys.Length == 2)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   800
                                reason = pEp.Properties.Resources.RatingHavenokeyMessageboxReasonBodyNokey;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   801
                            else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   802
                                reason = string.Format(pEp.Properties.Resources.RatingHavenokeyMessageboxReasonBodySomekey, keys.Length - 1);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   803
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   804
                            string keyinfo = "";
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
                            foreach (string key in keys)
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
                                if (key.Length >= 8)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   809
                                    keyinfo += "\n" + key;
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
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   812
                            reason += keyinfo;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   813
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   814
                            MessageBox.Show(reason, pEp.Properties.Resources.RatingHavenokeyTitle);
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
                        else if (keys.Length == 1)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   817
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   818
                            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
   819
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   820
                        else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   821
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   822
                            MessageBox.Show(pEp.Properties.Resources.RatingHavenokeyMessageboxReasonUnknownformat, pEp.Properties.Resources.RatingHavenokeyTitle);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   823
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   824
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   825
                    catch (COMException ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   826
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   827
                        StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   828
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   829
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   830
                    
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   831
                case _pEp_color.pEp_rating_undefined:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   832
                    if (mailItem != null)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   833
                    {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   834
                        enc_status = mailItem.ColorRating;
133
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
                    break;
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
        }
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
        private void linkExplanation_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
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
            if (enc_status == _pEp_color.pEp_rating_undefined)
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
                enc_status_data.explanation = pEp.Properties.Resources.RatingUndefinedExplanation;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   845
                enc_status_data.suggestion = pEp.Properties.Resources.RatingUndefinedSuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   846
                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
   847
                enc_status_data.background = COLOR_GREY;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   848
                enc_status_data.foreground = TEXT_COLOR_BLACK;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   849
                enc_status_data.button_text = pEp.Properties.Resources.RatingUndefinedButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   850
                enc_status_data.strip = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   851
            }
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
            var result = MessageBox.Show(
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   854
                            enc_status_data.explanation + "\n\n" + enc_status_data.suggestion,
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   855
                            enc_status_data.title,
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   856
                            MessageBoxButtons.OK,
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   857
                            enc_status == _pEp_color.pEp_rating_under_attack
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   858
                                ? MessageBoxIcon.Stop
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   859
                                : MessageBoxIcon.Information
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   860
                        );
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   861
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   862
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   863
        private void timerRefresh_Tick(object sender, EventArgs e)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   864
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   865
            timerRefresh.Interval = 100;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   866
            timerRefresh.Enabled = false; // only once
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   867
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   868
            if (!ThisAddIn.addIn.enabled)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   869
                ThisAddIn.addIn.enable();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   870
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   871
            makePreview();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   872
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   873
            reset_enc_status();
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
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   876
        private void EncryptionStatus_MouseUp(object sender, MouseEventArgs e)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   877
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   878
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   879
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   880
                CryptableMailItem cmi = mailItem;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   881
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   882
                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
   883
                {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   884
                    if (cmi.SendUnencrypted == CheckState.Indeterminate)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   885
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   886
                        sendUnencryptedToolStripMenuItem.CheckState = CheckState.Unchecked;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   887
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   888
                    else {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   889
                        sendUnencryptedToolStripMenuItem.CheckState = cmi.SendUnencrypted;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   890
                    }
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
                    Control _sender = (Control)sender;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   893
                    contextMenuEdit.Show(_sender.PointToScreen(e.Location));
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   894
                }
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
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   897
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   898
        private void sendUnencryptedToolStripMenuItem_Click(object sender, EventArgs e)
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
            sendUnencryptedToolStripMenuItem.Checked = !sendUnencryptedToolStripMenuItem.Checked;
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   901
            mailItem.SendUnencrypted = sendUnencryptedToolStripMenuItem.CheckState;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   902
            timerRefresh.Enabled = true;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   903
        }
151
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   904
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   905
        /// <summary>
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   906
        /// 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
   907
        /// 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
   908
        /// </summary>
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   909
        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
   910
        {
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   911
            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
   912
            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
   913
            frm.StartPosition = FormStartPosition.CenterScreen;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   914
            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
   915
154
8b05adf8a371 Complete refactoring and add state to options form. Also make registry save/load much more robust.
Dean Looyengoed
parents: 152
diff changeset
   916
            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
   917
                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
   918
            else
8b05adf8a371 Complete refactoring and add state to options form. Also make registry save/load much more robust.
Dean Looyengoed
parents: 152
diff changeset
   919
                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
   920
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   921
            return;
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   922
        }
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   923
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   924
        /// <summary>
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   925
        /// 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
   926
        /// 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
   927
        /// </summary>
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   928
        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
   929
        {
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   930
            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
   931
            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
   932
            return;
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   933
        }
166
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   934
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   935
        /**************************************************************
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   936
         * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   937
         * Sub-classes
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   938
         * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   939
         *************************************************************/
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   940
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   941
        /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   942
        /// 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
   943
        /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   944
        public class State
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   945
        {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   946
            private _pEp_color _EncryptionStatus;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   947
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   948
            private string _Title;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   949
            private string _Explanation;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   950
            private string _Suggestion;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   951
            private Color  _ButtonBackground;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   952
            private Color  _ButtonForeground;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   953
            private string _ButtonText;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   954
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   955
            /**************************************************************
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   956
             * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   957
             * Constructors
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   958
             * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   959
             *************************************************************/
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   960
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   961
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   962
            /// Default constructor.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   963
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   964
            public State()
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   965
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   966
                this.Reset();
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   967
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   968
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   969
            /**************************************************************
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   970
             * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   971
             * Property Accessors
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   972
             * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   973
             *************************************************************/
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   974
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   975
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   976
            /// 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
   977
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   978
            public _pEp_color EncryptionStatus
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   979
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   980
                get { return (this._EncryptionStatus); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   981
                set 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   982
                { 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   983
                    this._EncryptionStatus = value;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   984
                    this.UpdateProperties();
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   985
                }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   986
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   987
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   988
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   989
            /// Gets the title of the encryption status.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   990
            /// 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
   991
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   992
            public string Title
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   993
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   994
                get { return (this._Title); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   995
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   996
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   997
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   998
            /// Gets the explanation for the encryption status.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   999
            /// 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
  1000
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1001
            public string Explanation
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1002
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1003
                get { return (this._Explanation); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1004
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1005
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1006
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1007
            /// Gets the suggestion to improve the encryption status.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1008
            /// 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
  1009
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1010
            public string Suggestion
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1011
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1012
                get { return (this._Suggestion); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1013
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1014
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1015
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1016
            /// Gets the background color of the encryption button.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1017
            /// 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
  1018
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1019
            public Color ButtonBackground
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1020
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1021
                get { return (this._ButtonBackground); }
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
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1025
            /// Gets the foreground color of the encryption button.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1026
            /// 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
  1027
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1028
            public Color ButtonForeground
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1029
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1030
                get { return (this._ButtonForeground); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1031
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1032
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1033
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1034
            /// Gets the text of the encryption button.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1035
            /// 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
  1036
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1037
            public string ButtonText
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1038
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1039
                get { return (this._ButtonText); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1040
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1041
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1042
            /**************************************************************
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1043
             * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1044
             * Methods
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1045
             * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1046
             *************************************************************/
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1047
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1048
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1049
            /// Resets the object to it's default values.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1050
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1051
            public void Reset()
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1052
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1053
                this._EncryptionStatus = _pEp_color.pEp_rating_undefined;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1054
                this.UpdateProperties();
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
                return;
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
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1060
            /// Updates any properties dependent on the encryption status.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1061
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1062
            private void UpdateProperties()
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1063
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1064
                switch (this._EncryptionStatus)
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1065
                {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1066
                    case _pEp_color.pEp_rating_trusted:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1067
                    case _pEp_color.pEp_rating_trusted_and_anonymized:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1068
                        this._Title       = pEp.Properties.Resources.RatingTrustedTitle;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1069
                        this._Explanation = pEp.Properties.Resources.RatingTrustedExplanation;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1070
                        this._Suggestion  = pEp.Properties.Resources.RatingTrustedSuggestion;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1071
                        
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1072
                        this._ButtonBackground = COLOR_GREEN;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1073
                        this._ButtonForeground = TEXT_COLOR_WHITE;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1074
                        this._ButtonText       = pEp.Properties.Resources.RatingTrustedButtontext;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1075
                        break;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1076
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1077
                    case _pEp_color.pEp_rating_reliable:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1078
                        this._Title       = pEp.Properties.Resources.RatingReliableTitle;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1079
                        this._Explanation = pEp.Properties.Resources.RatingReliableExplaination;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1080
                        this._Suggestion  = pEp.Properties.Resources.RatingReliableSuggestion;
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
                        this._ButtonBackground = COLOR_YELLOW;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1083
                        this._ButtonForeground = TEXT_COLOR_BLACK;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1084
                        this._ButtonText       = pEp.Properties.Resources.RatingReliableButtontext;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1085
                        break;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1086
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1087
                    case _pEp_color.pEp_rating_unreliable:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1088
                        this._Title       = pEp.Properties.Resources.RatingUnreliableTitle;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1089
                        this._Explanation = pEp.Properties.Resources.RatingUnreliableExplanation;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1090
                        this._Suggestion  = pEp.Properties.Resources.RatingUnreliableSuggestion;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1091
                        
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1092
                        this._ButtonBackground = COLOR_GREY;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1093
                        this._ButtonForeground = TEXT_COLOR_BLACK;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1094
                        this._ButtonText       = pEp.Properties.Resources.RatingUnreliableButtontext;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1095
                        break;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1096
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1097
                    case _pEp_color.pEp_rating_unencrypted:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1098
                        this._Title       = pEp.Properties.Resources.RatingUnencryptedTitle;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1099
                        this._Explanation = pEp.Properties.Resources.RatingUnencryptedExplanation;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1100
                        this._Suggestion  = pEp.Properties.Resources.RatingUnencryptedSuggestion;
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
                        this._ButtonBackground = COLOR_GREY;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1103
                        this._ButtonForeground = TEXT_COLOR_BLACK;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1104
                        this._ButtonText       = pEp.Properties.Resources.RatingUnencryptedButtontext;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1105
                        break;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1106
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1107
                    case _pEp_color.pEp_rating_under_attack:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1108
                        this._Title       = pEp.Properties.Resources.RatingUnderattackTitle;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1109
                        this._Explanation = pEp.Properties.Resources.RatingUnderattackExplanation;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1110
                        this._Suggestion  = pEp.Properties.Resources.RatingUnderattackSuggestion;
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
                        this._ButtonBackground = COLOR_RED;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1113
                        this._ButtonForeground = TEXT_COLOR_WHITE;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1114
                        this._ButtonText       = pEp.Properties.Resources.RatingUnderattackButtontext;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1115
                        break;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1116
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1117
                    case _pEp_color.pEp_rating_undefined:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1118
                        this._Title       = pEp.Properties.Resources.RatingUndefinedTitle;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1119
                        this._Explanation = pEp.Properties.Resources.RatingUndefinedExplanation;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1120
                        this._Suggestion  = pEp.Properties.Resources.RatingUndefinedSuggestion;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1121
                        
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1122
                        this._ButtonBackground = COLOR_GREY;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1123
                        this._ButtonForeground = TEXT_COLOR_BLACK;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1124
                        this._ButtonText       = pEp.Properties.Resources.RatingUndefinedButtontext;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1125
                        break;
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
                    case _pEp_color.pEp_rating_cannot_decrypt: