EncryptionStatusPanel.cs
author Dean Looyengoed
Tue, 29 Dec 2015 21:24:53 +0100
changeset 169 c7d9b7ad0639
parent 166 e830996006c2
child 170 07911d16b012
permissions -rw-r--r--
Comment and refactor MailItem event handlers
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
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    62
        /**************************************************************
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    63
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    64
         * Property Accessors
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    65
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
    66
         *************************************************************/
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    67
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    68
        CryptableMailItem mailItem
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    69
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    70
            get
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    71
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    72
                try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    73
                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    74
                    if (this.OutlookItem == null)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    75
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    76
                        _mailItem = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    77
                        return null;
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
                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    80
                catch (COMException)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    81
                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    82
                    return null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    83
                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    84
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    85
                Outlook.MailItem omi = null;
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
                try
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
                    omi = (Outlook.MailItem)this.OutlookItem;
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
                catch
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    92
                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    93
                    _mailItem = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    94
                    return null;
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
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
    97
                Outlook.MAPIFolder folder = omi.Parent;
136
34e41293d3b0 fun with b0rken IMAP
Volker Birk <vb@pep-project.org>
parents: 133
diff changeset
    98
                Outlook.MAPIFolder deleted = folder.Store.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems);
34e41293d3b0 fun with b0rken IMAP
Volker Birk <vb@pep-project.org>
parents: 133
diff changeset
    99
                if (deleted != null && folder.EntryID == deleted.EntryID)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   100
                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   101
                    _mailItem = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   102
                    return null;
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
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   105
                if (_mailItem == null) {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   106
                    _mailItem = new CryptableMailItem(omi);
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
                else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   109
                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   110
                    if (_mailItem.EntryID != omi.EntryID)
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
                        _mailItem = new CryptableMailItem(omi);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   113
                    }
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
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   116
                return _mailItem;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   117
            }
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
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   120
        public _pEp_color enc_status {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   121
            get
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 _enc_status;
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
            set
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
                if (value != _enc_status)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   128
                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   129
                    _enc_status = value;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   130
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   131
                    switch (value)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   132
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   133
                        case _pEp_color.pEp_rating_trusted:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   134
                        case _pEp_color.pEp_rating_trusted_and_anonymized:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   135
                            enc_status_data.explanation = pEp.Properties.Resources.RatingTrustedExplanation;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   136
                            enc_status_data.suggestion = pEp.Properties.Resources.RatingTrustedSuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   137
                            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
   138
                            enc_status_data.background = COLOR_GREEN;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   139
                            enc_status_data.foreground = TEXT_COLOR_WHITE;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   140
                            enc_status_data.button_text = pEp.Properties.Resources.RatingTrustedButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   141
                            enc_status_data.strip = new ContextMenuStrip();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   142
                            enc_status_data.strip.Items.Add("");
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   143
                            enc_status_data.strip.Opening += secure_strip_Opening;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   144
                            break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   145
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   146
                        case _pEp_color.pEp_rating_reliable:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   147
                            enc_status_data.explanation = pEp.Properties.Resources.RatingReliableExplaination;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   148
                            enc_status_data.suggestion = pEp.Properties.Resources.RatingReliableSuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   149
                            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
   150
                            enc_status_data.background = COLOR_YELLOW;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   151
                            enc_status_data.foreground = TEXT_COLOR_BLACK;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   152
                            enc_status_data.button_text = pEp.Properties.Resources.RatingReliableButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   153
                            enc_status_data.strip = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   154
                            break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   155
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   156
                        case _pEp_color.pEp_rating_unreliable:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   157
                            enc_status_data.explanation = pEp.Properties.Resources.RatingUnreliableExplanation;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   158
                            enc_status_data.suggestion = pEp.Properties.Resources.RatingUnreliableSuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   159
                            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
   160
                            enc_status_data.background = COLOR_GREY;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   161
                            enc_status_data.foreground = TEXT_COLOR_BLACK;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   162
                            enc_status_data.button_text = pEp.Properties.Resources.RatingUnreliableButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   163
                            enc_status_data.strip = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   164
                            break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   165
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   166
                        case _pEp_color.pEp_rating_unencrypted:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   167
                            enc_status_data.explanation = pEp.Properties.Resources.RatingUnencryptedExplanation;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   168
                            enc_status_data.suggestion = pEp.Properties.Resources.RatingUnencryptedSuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   169
                            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
   170
                            enc_status_data.background = COLOR_GREY;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   171
                            enc_status_data.foreground = TEXT_COLOR_BLACK;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   172
                            enc_status_data.button_text = pEp.Properties.Resources.RatingUnencryptedButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   173
                            enc_status_data.strip = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   174
                            break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   175
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   176
                        case _pEp_color.pEp_rating_under_attack:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   177
                            enc_status_data.explanation = pEp.Properties.Resources.RatingUnderattackExplanation;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   178
                            enc_status_data.suggestion = pEp.Properties.Resources.RatingUnderattackSuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   179
                            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
   180
                            enc_status_data.background = COLOR_RED;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   181
                            enc_status_data.foreground = TEXT_COLOR_WHITE;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   182
                            enc_status_data.button_text = pEp.Properties.Resources.RatingUnderattackButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   183
                            enc_status_data.strip = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   184
                            break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   185
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   186
                        case _pEp_color.pEp_rating_undefined:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   187
                            // will not happen
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   188
                            enc_status_data.explanation = pEp.Properties.Resources.RatingUndefinedExplanation;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   189
                            enc_status_data.suggestion = pEp.Properties.Resources.RatingUndefinedSuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   190
                            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
   191
                            enc_status_data.background = COLOR_GREY;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   192
                            enc_status_data.foreground = TEXT_COLOR_BLACK;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   193
                            enc_status_data.button_text = pEp.Properties.Resources.RatingUndefinedButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   194
                            enc_status_data.strip = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   195
                            break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   196
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   197
                        case _pEp_color.pEp_rating_cannot_decrypt:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   198
                        case _pEp_color.pEp_rating_have_no_key:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   199
                            enc_status_data.explanation = pEp.Properties.Resources.RatingHavenokeyExplanation;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   200
                            enc_status_data.suggestion = pEp.Properties.Resources.RatingHavenokeySuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   201
                            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
   202
                            enc_status_data.background = COLOR_GREY;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   203
                            enc_status_data.foreground = TEXT_COLOR_BLACK;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   204
                            enc_status_data.button_text = pEp.Properties.Resources.RatingHavenokeyButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   205
                            enc_status_data.strip = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   206
                            break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   207
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   208
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   209
                    linkExplanation.Text = enc_status_data.title;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   210
                    EncryptionStatus.BackColor = enc_status_data.background;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   211
                    EncryptionStatus.ForeColor = enc_status_data.foreground;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   212
                    EncryptionStatus.Text = enc_status_data.button_text;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   213
                    EncryptionStatus.ContextMenuStrip = enc_status_data.strip;
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
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   217
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   218
        /**************************************************************
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   219
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   220
         * Methods
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   221
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   222
         *************************************************************/
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   223
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   224
        static void StopHere(string reason)
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
#if DEBUG
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   227
            MessageBox.Show(reason);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   228
#else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   229
            try
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
                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
   232
            }
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   233
            catch (COMException) { }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   234
            catch (Exception) { }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   235
#endif
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   236
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   237
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   238
        private void doHandshake(pEp_identity_s identityPartner)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   239
        {
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   240
            string ownShort;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   241
            string ownLong;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   242
            string ownFpr;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   243
            string partnerShort;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   244
            string partnerLong;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   245
            string partnerFpr;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   246
            string[] lines;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   247
            pEp_identity_s me;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   248
            FormHandshake handshakeDialog;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   249
            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
   250
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   251
            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
   252
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   253
            ThisAddIn.verbose("doHandshake");
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   254
            ThisAddIn.verbose(identityPartner.address);
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   255
132
f0c74e2c6dfb review of mailItem handling
Volker Birk <vb@pep-project.org>
parents: 131
diff changeset
   256
            if (identityPartner.username == "")
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   257
                identityPartner.username = identityPartner.address;
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   258
            ThisAddIn.verbose(identityPartner.username);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   259
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   260
            identityPartner.user_id = CryptableMailItem.GetUserIDFromAddress(identityPartner.address, identityPartner.username);
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   261
            ThisAddIn.verbose(identityPartner.user_id);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   262
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   263
            if (mailItem.IsIncoming)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   264
            {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   265
                string entryID = mailItem.ReceivedByEntryID;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   266
                string address = "";
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   267
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   268
                foreach (Outlook.Account a in ThisAddIn.addIn.Application.Session.Accounts){
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   269
                    if (a.CurrentUser.EntryID == entryID) {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   270
                        address = a.SmtpAddress;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   271
                        break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   272
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   273
                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   274
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   275
                if (address == "")
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   276
                    address = ThisAddIn.addIn.Application.Session.Accounts[1].SmtpAddress;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   277
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   278
                me = ThisAddIn.addIn.mySelf(address);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   279
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   280
            else // outgoing
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   281
            {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   282
                ThisAddIn.verbose("mailItem.from_address: " + mailItem.FromAddress);
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   283
                me = ThisAddIn.addIn.mySelf(mailItem.FromAddress);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   284
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   285
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   286
            ThisAddIn.verbose(me.fpr);
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   287
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   288
            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
   289
            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
   290
            ownFpr   = this.ToQuadruple(me.fpr);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   291
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   292
            ThisAddIn.verbose(identityPartner.fpr);
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   293
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   294
            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
   295
            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
   296
            partnerFpr   = this.ToQuadruple(identityPartner.fpr);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   297
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   298
            if (ownFpr.CompareTo(partnerFpr) > 0)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   299
            {
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   300
                state.TrustwordsShort = partnerShort + ownShort;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   301
                state.TrustwordsFull  = partnerLong  + ownLong;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   302
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   303
                lines = new string[3];
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   304
                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
   305
                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
   306
                state.Fingerprint = lines;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   307
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   308
            else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   309
            {
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   310
                state.TrustwordsShort = ownShort + " " + partnerShort;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   311
                state.TrustwordsFull  = ownLong  + " " + partnerLong;
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   312
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   313
                lines = new string[3];
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   314
                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
   315
                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
   316
                state.Fingerprint = lines;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   317
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   318
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   319
            ThisAddIn.verbose("try to show dialog");
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   320
155
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   321
            // 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
   322
            handshakeDialog = new FormHandshake(state);
cda43d18bcd3 Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents: 154
diff changeset
   323
132
f0c74e2c6dfb review of mailItem handling
Volker Birk <vb@pep-project.org>
parents: 131
diff changeset
   324
            DialogResult result = handshakeDialog.ShowDialog(this);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   325
            ThisAddIn.verbose("handshakeDialog.ShowDialog(this) => " + result.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   326
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   327
            switch (result)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   328
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   329
                case DialogResult.Yes:
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   330
                    mailItem.ColorRating = _pEp_color.pEp_rating_trusted;
132
f0c74e2c6dfb review of mailItem handling
Volker Birk <vb@pep-project.org>
parents: 131
diff changeset
   331
                    identityPartner = ThisAddIn.pEp.trust_personal_key(identityPartner);
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   332
                    reset_enc_status(); 
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   333
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   334
                case DialogResult.No:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   335
                    ThisAddIn.pEp.key_compromized(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   336
                    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
   337
                    mailItem.ColorRating = _pEp_color.pEp_rating_red;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   338
                    reset_enc_status(); 
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   339
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   340
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   341
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   342
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   343
        private void undoHandshake(pEp_identity_s identityPartner)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   344
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   345
            ThisAddIn.pEp.update_identity(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   346
//            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
   347
            identityPartner.comm_type ^= _pEp_comm_type.pEp_ct_confirmed;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   348
            ThisAddIn.pEp.update_identity(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   349
            reset_enc_status();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   350
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   351
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   352
        /// <summary>
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   353
        /// 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
   354
        /// 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
   355
        /// </summary>
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   356
        /// <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
   357
        /// <returns>The re-formatted string.</returns>
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   358
        private string ToQuadruple(string text)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   359
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   360
            List<string> result = new List<string>();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   361
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   362
            if (text != null)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   363
            {
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   364
                for (int i = 0; i < text.Length; i += 4)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   365
                {
161
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   366
                    try
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   367
                    {
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   368
                        result.Add(text.Substring(i, 4));
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   369
                    }
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   370
                    catch (ArgumentOutOfRangeException)
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   371
                    {
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   372
                        result.Add(text.Substring(i));
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   373
                        break;
2b6b485152c5 Comment and rename quadruple method. Add null check just in case.
Dean Looyengoed
parents: 159
diff changeset
   374
                    }
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   375
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   376
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   377
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   378
            return String.Join(" ", result);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   379
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   380
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   381
        protected void makePreview()
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   382
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   383
            WindowFormRegionCollection formRegions;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   384
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   385
            if (Globals.ThisAddIn.Application.ActiveInspector() != null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   386
                return;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   387
            else if (Globals.ThisAddIn.Application.ActiveExplorer() != null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   388
                formRegions = Globals.FormRegions[Globals.ThisAddIn.Application.ActiveExplorer()];
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   389
            else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   390
                return;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   391
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   392
            try
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   393
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   394
                if (formRegions.PreviewUnencrypted.Visible)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   395
                {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   396
                    byte[] rtf = mailItem.MirrorGetRTFBody();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   397
                    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
   398
                    formRegions.PreviewUnencrypted.textSubject.Text = mailItem.MirrorGetSubject();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   399
                    formRegions.PreviewUnencrypted.textFrom.Text = mailItem.FromUsername + " <" + mailItem.FromAddress + ">";
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   400
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   401
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   402
            catch { }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   403
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   404
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   405
        protected void reset_enc_status()
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   406
        {
163
c5784c6a3059 Rename local in_reset variable to resetOngoing
Dean Looyengoed
parents: 162
diff changeset
   407
            if (resetOngoing)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   408
                return;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   409
163
c5784c6a3059 Rename local in_reset variable to resetOngoing
Dean Looyengoed
parents: 162
diff changeset
   410
            this.resetOngoing = true;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   411
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   412
            if (mailItem != null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   413
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   414
                if (_mailItem.DownloadState == Outlook.OlDownloadState.olFullItem)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   415
                {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   416
                    if (_mailItem.SendUnencrypted == CheckState.Checked)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   417
                    {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   418
                        enc_status = _pEp_color.pEp_rating_unencrypted;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   419
                    }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   420
                    else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   421
                    {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   422
                        ThisAddIn.verbose("get_color in reset_enc_status");
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   423
                        enc_status = _mailItem.ColorRating;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   424
                    }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   425
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   426
                else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   427
                {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   428
                    _mailItem.MarkForDownload = Outlook.OlRemoteStatus.olMarkedForDownload;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   429
                    timerRefresh.Interval = 500;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   430
                    timerRefresh.Enabled = true;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   431
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   432
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   433
163
c5784c6a3059 Rename local in_reset variable to resetOngoing
Dean Looyengoed
parents: 162
diff changeset
   434
            this.resetOngoing = false;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   435
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   436
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   437
        /**************************************************************
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   438
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   439
         * Event Handling
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   440
         * 
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   441
         *************************************************************/
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   442
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   443
        /// <summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   444
        /// 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
   445
        /// </summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   446
        private void FormRegion1_FormRegionShowing(object sender, System.EventArgs e)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   447
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   448
            if (this.OutlookItem == null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   449
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   450
                enc_status = _pEp_color.pEp_rating_undefined;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   451
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   452
            else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   453
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   454
                Outlook.MailItem omi = (Outlook.MailItem)this.OutlookItem;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   455
                try
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   456
                {
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   457
                    omi.PropertyChange += MailItem_PropertyChange;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   458
                    if (CryptableMailItem.IsEncryptedStore(omi))
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   459
                    {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   460
                        if (PreviewUnencrypted.isPGPEncrypted(omi) && omi.Sender != null)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   461
                        {
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   462
                            omi.Open += MailItem_Open;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   463
                        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   464
                    }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   465
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   466
                catch { }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   467
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   468
                if (ThisAddIn.addIn.enabled)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   469
                {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   470
                    reset_enc_status();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   471
                }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   472
                else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   473
                {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   474
                    timerRefresh.Enabled = true;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   475
                }
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
        /// <summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   480
        /// Event handler for when the form region is closed.
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   481
        /// </summary>
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   482
        private void FormRegion1_FormRegionClosed(object sender, System.EventArgs e)
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
            return;
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
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   487
        /// <summary>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   488
        /// 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
   489
        /// </summary>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   490
        /// <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
   491
        /// 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
   492
        /// and the inspector is not displayed.</param>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   493
        private void MailItem_Open(ref bool cancel)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   494
        {
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   495
            // Cancel opening the if the mirror is displayed instead
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   496
            if (mailItem != null && _mailItem.MirrorDisplay())
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   497
            {
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   498
                cancel = true;
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   499
            }
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   500
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   501
            return;
159
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
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   504
        /// <summary>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   505
        /// Event handler for when a mail item property is changed.
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   506
        /// See: https://msdn.microsoft.com/en-us/library/office/ff866739.aspx
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   507
        /// </summary>
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   508
        /// <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
   509
        private void MailItem_PropertyChange(string propertyName)
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   510
        {
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   511
            switch (propertyName)
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
                case "To":
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   514
                    timerRefresh.Enabled = true;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   515
                    break;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   516
                // 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
   517
                //case "CC":
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   518
                //    reset_enc_status();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   519
                //    break;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   520
            }
169
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   521
c7d9b7ad0639 Comment and refactor MailItem event handlers
Dean Looyengoed
parents: 166
diff changeset
   522
            return;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   523
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   524
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   525
        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
   526
        {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   527
            enc_status_data.strip.Items.Clear();
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
            if (mailItem.IsIncoming)
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   530
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   531
                pEp_identity_s ident = new pEp_identity_s();
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   532
                ident.address = mailItem.FromAddress;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   533
                ident.username = mailItem.FromUsername;
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   534
                ident.user_id = CryptableMailItem.GetUserIDFromAddress(ident.address, ident.username);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   535
                ident = ThisAddIn.pEp.update_identity(ident);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   536
                string text = pEp.Properties.Resources.IdentityTrustText + ident.username + " <" + ident.address + ">";
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   537
                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
   538
            }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   539
            else
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   540
            {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   541
                foreach (pEp_identity_s ident in mailItem.Addresses)
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
                    pEp_identity_s identityPartner = ThisAddIn.pEp.update_identity(ident);
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   544
                    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
   545
                    {
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   546
                        string text = pEp.Properties.Resources.IdentityTrustText + ident.username + " <" + ident.address + ">";
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   547
                        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
   548
                    }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   549
                }
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
        }
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   552
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   553
        private void EncryptionStatus_Click(object sender, EventArgs e)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   554
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   555
            switch (enc_status)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   556
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   557
                case _pEp_color.pEp_rating_green:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   558
                    try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   559
                    {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   560
                        string[] key_list = mailItem.Keylist;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   561
                        if (key_list.Length > 0)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   562
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   563
                            string msg;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   564
                            if (key_list.Length > 1)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   565
                                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
   566
                            else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   567
                                msg = String.Format(pEp.Properties.Resources.EncryptionStatusClickMessageSingle + " {0}.", key_list[0]);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   568
                            MessageBox.Show(msg, pEp.Properties.Resources.EncryptionStatusClickMessageBox, MessageBoxButtons.OK, MessageBoxIcon.Information);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   569
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   570
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   571
                    catch (Exception ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   572
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   573
                        StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   574
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   575
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   576
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   577
                case _pEp_color.pEp_rating_yellow:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   578
                    try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   579
                    {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   580
                        if (mailItem.IsIncoming)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   581
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   582
                            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
   583
                            identityPartner.address = mailItem.FromAddress;
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   584
                            identityPartner.username = mailItem.FromUsername;
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   585
                            identityPartner.user_id = CryptableMailItem.GetUserIDFromAddress(identityPartner.address, identityPartner.username);
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   586
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   587
                            try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   588
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   589
                                identityPartner = ThisAddIn.pEp.update_identity(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   590
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   591
                            catch
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   592
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   593
                                enc_status = _pEp_color.pEp_rating_undefined;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   594
                                return;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   595
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   596
                            doHandshake(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   597
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   598
                        else // outgoing
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   599
                        {
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   600
                            ThisAddIn.verbose("yellow, handshake initiated");
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   601
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   602
                            List<pEp_identity_s> partnersToCheck = new List<pEp_identity_s>();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   603
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   604
                            foreach (pEp_identity_s identity in mailItem.Addresses)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   605
                            {
139
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   606
                                ThisAddIn.verbose("adding " + identity.username + " <" + identity.address + ">");
5fba0600b7a2 user_id everywhere
Volker Birk <vb@pep-project.org>
parents: 137
diff changeset
   607
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   608
                                try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   609
                                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   610
                                    pEp_identity_s identityPartner = ThisAddIn.pEp.update_identity(identity);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   611
                                    if (identityPartner.comm_type >= _pEp_comm_type.pEp_ct_unconfirmed_encryption
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   612
                                        && identityPartner.comm_type < _pEp_comm_type.pEp_ct_confirmed_encryption)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   613
                                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   614
                                        partnersToCheck.Add(identityPartner);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   615
                                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   616
                                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   617
                                catch
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   618
                                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   619
                                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   620
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   621
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   622
                            if (partnersToCheck.Count == 0)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   623
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   624
                                enc_status = _pEp_color.pEp_rating_undefined;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   625
                                return;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   626
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   627
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   628
                            pEp_identity_s[] addresses = mailItem.Addresses;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   629
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   630
                            if (addresses.Length == 1)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   631
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   632
                                doHandshake(partnersToCheck[0]);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   633
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   634
                            else if (addresses.Length > 1)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   635
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   636
                                contextMenuHandshake.Items.Clear();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   637
                                foreach (pEp_identity_s identity in partnersToCheck) {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   638
                                    string text = identity.username + " <" + identity.address + ">";
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   639
                                    contextMenuHandshake.Items.Add(text, null, (x, y) => { doHandshake(identity); });
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   640
                                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   641
                                contextMenuHandshake.Show(EncryptionStatus, 10, 10);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   642
                            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   643
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   644
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   645
                    catch (COMException ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   646
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   647
                        StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   648
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   649
                    catch (Exception ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   650
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   651
                        StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   652
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   653
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   654
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   655
                case _pEp_color.pEp_rating_unencrypted:
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   656
                    if (mailItem.IsIncoming)
133
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
                        MessageBox.Show(pEp.Properties.Resources.RatingUnencryptedMessageboxReasonBody, pEp.Properties.Resources.RatingUnencryptedMessageboxReasonTitle);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   659
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   660
                    else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   661
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   662
                        try
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 reason = "";
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   665
                            foreach (pEp_identity_s identity in mailItem.Addresses)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   666
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   667
                                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
   668
                                {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   669
                                    if (reason != "")
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   670
                                        reason += "\n";
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   671
                                    // BUG: reason string in English language only and trivial
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   672
                                    string ct = identity.comm_type.ToString();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   673
                                    ct = new string(ct.Skip(7).ToArray());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   674
                                    ct = ct.Replace("_", " ");
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   675
                                    reason += identity.username + " <" + identity.address + ">: " + ct;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   676
                                }
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
                            if (reason != "")
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   679
                                MessageBox.Show(reason, pEp.Properties.Resources.RatingUnencryptedMessageboxReasonTitle);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   680
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   681
                        catch (COMException ex)
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
                            StopHere(ex.ToString());
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   684
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   685
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   686
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   687
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   688
                case _pEp_color.pEp_rating_cannot_decrypt:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   689
                case _pEp_color.pEp_rating_have_no_key:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   690
                    try
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   691
                    {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   692
                        string[] keys = mailItem.Keylist;
133
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
                        if (keys.Length > 1)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   695
                        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   696
                            string reason;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   697
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   698
                            if (keys.Length == 2)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   699
                                reason = pEp.Properties.Resources.RatingHavenokeyMessageboxReasonBodyNokey;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   700
                            else
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   701
                                reason = string.Format(pEp.Properties.Resources.RatingHavenokeyMessageboxReasonBodySomekey, keys.Length - 1);
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   702
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   703
                            string keyinfo = "";
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   704
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   705
                            foreach (string key in keys)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   706
                            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   707
                                if (key.Length >= 8)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   708
                                    keyinfo += "\n" + key;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   709
                            }
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
                            reason += keyinfo;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   712
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   713
                            MessageBox.Show(reason, pEp.Properties.Resources.RatingHavenokeyTitle);
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
                        else if (keys.Length == 1)
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
                            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
   718
                        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   719
                        else
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
                            MessageBox.Show(pEp.Properties.Resources.RatingHavenokeyMessageboxReasonUnknownformat, pEp.Properties.Resources.RatingHavenokeyTitle);
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
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   724
                    catch (COMException ex)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   725
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   726
                        StopHere(ex.ToString());
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
                    break;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   729
                    
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   730
                case _pEp_color.pEp_rating_undefined:
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   731
                    if (mailItem != null)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   732
                    {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   733
                        enc_status = mailItem.ColorRating;
133
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
                    break;
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
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   738
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   739
        private void linkExplanation_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   740
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   741
            if (enc_status == _pEp_color.pEp_rating_undefined)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   742
            {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   743
                enc_status_data.explanation = pEp.Properties.Resources.RatingUndefinedExplanation;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   744
                enc_status_data.suggestion = pEp.Properties.Resources.RatingUndefinedSuggestion;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   745
                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
   746
                enc_status_data.background = COLOR_GREY;
5defdeba0056 Define colors as constants to make future styling/changes easier
Dean Looyengoed
parents: 161
diff changeset
   747
                enc_status_data.foreground = TEXT_COLOR_BLACK;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   748
                enc_status_data.button_text = pEp.Properties.Resources.RatingUndefinedButtontext;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   749
                enc_status_data.strip = null;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   750
            }
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
            var result = MessageBox.Show(
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   753
                            enc_status_data.explanation + "\n\n" + enc_status_data.suggestion,
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   754
                            enc_status_data.title,
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   755
                            MessageBoxButtons.OK,
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   756
                            enc_status == _pEp_color.pEp_rating_under_attack
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   757
                                ? MessageBoxIcon.Stop
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   758
                                : MessageBoxIcon.Information
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   759
                        );
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   760
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   761
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   762
        private void timerRefresh_Tick(object sender, EventArgs e)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   763
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   764
            timerRefresh.Interval = 100;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   765
            timerRefresh.Enabled = false; // only once
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   766
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   767
            if (!ThisAddIn.addIn.enabled)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   768
                ThisAddIn.addIn.enable();
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
            makePreview();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   771
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   772
            reset_enc_status();
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   773
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   774
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   775
        private void EncryptionStatus_MouseUp(object sender, MouseEventArgs e)
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   776
        {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   777
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
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
                CryptableMailItem cmi = mailItem;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   780
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   781
                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
   782
                {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   783
                    if (cmi.SendUnencrypted == CheckState.Indeterminate)
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   784
                    {
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   785
                        sendUnencryptedToolStripMenuItem.CheckState = CheckState.Unchecked;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   786
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   787
                    else {
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   788
                        sendUnencryptedToolStripMenuItem.CheckState = cmi.SendUnencrypted;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   789
                    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   790
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   791
                    Control _sender = (Control)sender;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   792
                    contextMenuEdit.Show(_sender.PointToScreen(e.Location));
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   793
                }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   794
            }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   795
        }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   796
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   797
        private void sendUnencryptedToolStripMenuItem_Click(object sender, EventArgs e)
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
            sendUnencryptedToolStripMenuItem.Checked = !sendUnencryptedToolStripMenuItem.Checked;
144
146c2602df72 Refactor, organize and comment CryptableMailItem
Dean Looyengoed <dean@pep-project.org>
parents: 143
diff changeset
   800
            mailItem.SendUnencrypted = sendUnencryptedToolStripMenuItem.CheckState;
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   801
            timerRefresh.Enabled = true;
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
   802
        }
151
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   803
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   804
        /// <summary>
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   805
        /// 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
   806
        /// 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
   807
        /// </summary>
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   808
        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
   809
        {
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   810
            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
   811
            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
   812
            frm.StartPosition = FormStartPosition.CenterScreen;
159
15d0050bc11a Initial refactoring of the encryption status panel
Dean Looyengoed
parents: 156
diff changeset
   813
            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
   814
154
8b05adf8a371 Complete refactoring and add state to options form. Also make registry save/load much more robust.
Dean Looyengoed
parents: 152
diff changeset
   815
            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
   816
                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
   817
            else
8b05adf8a371 Complete refactoring and add state to options form. Also make registry save/load much more robust.
Dean Looyengoed
parents: 152
diff changeset
   818
                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
   819
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   820
            return;
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   821
        }
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   822
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   823
        /// <summary>
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   824
        /// 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
   825
        /// 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
   826
        /// </summary>
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   827
        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
   828
        {
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   829
            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
   830
            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
   831
            return;
8b0b69c6f71b Create initial gear icon for options and add the options button to the encryption status panel
Dean Looyengoed
parents: 144
diff changeset
   832
        }
166
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   833
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   834
        /**************************************************************
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   835
         * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   836
         * Sub-classes
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   837
         * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   838
         *************************************************************/
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   839
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   840
        /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   841
        /// 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
   842
        /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   843
        public class State
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   844
        {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   845
            private _pEp_color _EncryptionStatus;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   846
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   847
            private string _Title;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   848
            private string _Explanation;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   849
            private string _Suggestion;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   850
            private Color  _ButtonBackground;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   851
            private Color  _ButtonForeground;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   852
            private string _ButtonText;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   853
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   854
            /**************************************************************
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   855
             * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   856
             * Constructors
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   857
             * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   858
             *************************************************************/
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   859
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   860
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   861
            /// Default constructor.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   862
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   863
            public State()
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   864
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   865
                this.Reset();
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   866
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   867
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   868
            /**************************************************************
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   869
             * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   870
             * Property Accessors
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   871
             * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   872
             *************************************************************/
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   873
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   874
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   875
            /// 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
   876
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   877
            public _pEp_color EncryptionStatus
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   878
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   879
                get { return (this._EncryptionStatus); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   880
                set 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   881
                { 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   882
                    this._EncryptionStatus = value;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   883
                    this.UpdateProperties();
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   884
                }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   885
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   886
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   887
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   888
            /// Gets the title of the encryption status.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   889
            /// 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
   890
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   891
            public string Title
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   892
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   893
                get { return (this._Title); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   894
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   895
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   896
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   897
            /// Gets the explanation for the encryption status.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   898
            /// 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
   899
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   900
            public string Explanation
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   901
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   902
                get { return (this._Explanation); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   903
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   904
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   905
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   906
            /// Gets the suggestion to improve the encryption status.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   907
            /// 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
   908
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   909
            public string Suggestion
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   910
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   911
                get { return (this._Suggestion); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   912
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   913
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   914
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   915
            /// Gets the background color of the encryption button.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   916
            /// 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
   917
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   918
            public Color ButtonBackground
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   919
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   920
                get { return (this._ButtonBackground); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   921
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   922
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   923
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   924
            /// Gets the foreground color of the encryption button.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   925
            /// 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
   926
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   927
            public Color ButtonForeground
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   928
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   929
                get { return (this._ButtonForeground); }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   930
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   931
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   932
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   933
            /// Gets the text of the encryption button.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   934
            /// 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
   935
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   936
            public string ButtonText
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   937
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   938
                get { return (this._ButtonText); }
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
            /**************************************************************
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   942
             * 
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   943
             * Methods
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   944
             * 
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
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   947
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   948
            /// Resets the object to it's default values.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   949
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   950
            public void Reset()
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   951
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   952
                this._EncryptionStatus = _pEp_color.pEp_rating_undefined;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   953
                this.UpdateProperties();
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
                return;
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
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   958
            /// <summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   959
            /// Updates any properties dependent on the encryption status.
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   960
            /// </summary>
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   961
            private void UpdateProperties()
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   962
            {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   963
                switch (this._EncryptionStatus)
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   964
                {
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   965
                    case _pEp_color.pEp_rating_trusted:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   966
                    case _pEp_color.pEp_rating_trusted_and_anonymized:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   967
                        this._Title       = pEp.Properties.Resources.RatingTrustedTitle;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   968
                        this._Explanation = pEp.Properties.Resources.RatingTrustedExplanation;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   969
                        this._Suggestion  = pEp.Properties.Resources.RatingTrustedSuggestion;
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
                        this._ButtonBackground = COLOR_GREEN;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   972
                        this._ButtonForeground = TEXT_COLOR_WHITE;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   973
                        this._ButtonText       = pEp.Properties.Resources.RatingTrustedButtontext;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   974
                        break;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   975
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   976
                    case _pEp_color.pEp_rating_reliable:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   977
                        this._Title       = pEp.Properties.Resources.RatingReliableTitle;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   978
                        this._Explanation = pEp.Properties.Resources.RatingReliableExplaination;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   979
                        this._Suggestion  = pEp.Properties.Resources.RatingReliableSuggestion;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   980
                        
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   981
                        this._ButtonBackground = COLOR_YELLOW;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   982
                        this._ButtonForeground = TEXT_COLOR_BLACK;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   983
                        this._ButtonText       = pEp.Properties.Resources.RatingReliableButtontext;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   984
                        break;
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
                    case _pEp_color.pEp_rating_unreliable:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   987
                        this._Title       = pEp.Properties.Resources.RatingUnreliableTitle;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   988
                        this._Explanation = pEp.Properties.Resources.RatingUnreliableExplanation;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   989
                        this._Suggestion  = pEp.Properties.Resources.RatingUnreliableSuggestion;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   990
                        
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   991
                        this._ButtonBackground = COLOR_GREY;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   992
                        this._ButtonForeground = TEXT_COLOR_BLACK;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   993
                        this._ButtonText       = pEp.Properties.Resources.RatingUnreliableButtontext;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   994
                        break;
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
                    case _pEp_color.pEp_rating_unencrypted:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   997
                        this._Title       = pEp.Properties.Resources.RatingUnencryptedTitle;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   998
                        this._Explanation = pEp.Properties.Resources.RatingUnencryptedExplanation;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
   999
                        this._Suggestion  = pEp.Properties.Resources.RatingUnencryptedSuggestion;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1000
                        
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1001
                        this._ButtonBackground = COLOR_GREY;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1002
                        this._ButtonForeground = TEXT_COLOR_BLACK;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1003
                        this._ButtonText       = pEp.Properties.Resources.RatingUnencryptedButtontext;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1004
                        break;
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
                    case _pEp_color.pEp_rating_under_attack:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1007
                        this._Title       = pEp.Properties.Resources.RatingUnderattackTitle;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1008
                        this._Explanation = pEp.Properties.Resources.RatingUnderattackExplanation;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1009
                        this._Suggestion  = pEp.Properties.Resources.RatingUnderattackSuggestion;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1010
                        
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1011
                        this._ButtonBackground = COLOR_RED;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1012
                        this._ButtonForeground = TEXT_COLOR_WHITE;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1013
                        this._ButtonText       = pEp.Properties.Resources.RatingUnderattackButtontext;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1014
                        break;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1015
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1016
                    case _pEp_color.pEp_rating_undefined:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1017
                        this._Title       = pEp.Properties.Resources.RatingUndefinedTitle;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1018
                        this._Explanation = pEp.Properties.Resources.RatingUndefinedExplanation;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1019
                        this._Suggestion  = pEp.Properties.Resources.RatingUndefinedSuggestion;
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
                        this._ButtonBackground = COLOR_GREY;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1022
                        this._ButtonForeground = TEXT_COLOR_BLACK;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1023
                        this._ButtonText       = pEp.Properties.Resources.RatingUndefinedButtontext;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1024
                        break;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1025
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1026
                    case _pEp_color.pEp_rating_cannot_decrypt:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1027
                    case _pEp_color.pEp_rating_have_no_key:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1028
                        this._Title       = pEp.Properties.Resources.RatingHavenokeyTitle;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1029
                        this._Explanation = pEp.Properties.Resources.RatingHavenokeyExplanation;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1030
                        this._Suggestion  = pEp.Properties.Resources.RatingHavenokeySuggestion;
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
                        this._ButtonBackground = COLOR_GREY;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1033
                        this._ButtonForeground = TEXT_COLOR_BLACK;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1034
                        this._ButtonText       = pEp.Properties.Resources.RatingHavenokeyButtontext;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1035
                        break;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1036
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1037
                    default:
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1038
                        this._Title       = "";
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1039
                        this._Explanation = "";
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1040
                        this._Suggestion  = "";
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
                        this._ButtonBackground = COLOR_GREY;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1043
                        this._ButtonForeground = TEXT_COLOR_BLACK;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1044
                        this._ButtonText       = "";
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1045
                        break;
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
                return;
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1049
            }
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1050
e830996006c2 Add initial state class to the encryption status panel
Dean Looyengoed
parents: 164
diff changeset
  1051
        }
133
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
  1052
    }
214f4dc9e2c8 coloring new
Volker Birk <vb@pep-project.org>
parents: 132
diff changeset
  1053
}