UI/FormRegionPrivacyStatus.cs
author Dean Looyengoed
Wed, 09 Mar 2016 20:50:46 +0100
changeset 638 5d99a596d5b5
parent 633 c65f81929528
child 641 58d9dbf575bb
permissions -rw-r--r--
Check for null From in CryptableMailItem before use.
Dean@159
     1
´╗┐using pEpCOMServerAdapterLib;
Dean@159
     2
using System;
vb@133
     3
using System.Collections.Generic;
Dean@445
     4
using System.ComponentModel;
Dean@438
     5
using System.Drawing;
Dean@159
     6
using System.Runtime.InteropServices;
vb@133
     7
using System.Windows.Forms;
Dean@159
     8
using Color = System.Drawing.Color;
vb@133
     9
using Outlook = Microsoft.Office.Interop.Outlook;
vb@133
    10
vb@133
    11
namespace pEp
vb@133
    12
{
Dean@159
    13
    /// <summary>
Dean@312
    14
    /// Partial class for the privacy status form region that is displayed below every outlook message.
Dean@159
    15
    /// </summary>
Dean@312
    16
    partial class FormRegionPrivacyStatus
vb@133
    17
    {
vb@133
    18
        #region Form Region Factory
vb@133
    19
vb@133
    20
        [Microsoft.Office.Tools.Outlook.FormRegionMessageClass(Microsoft.Office.Tools.Outlook.FormRegionMessageClassAttribute.Note)]
Dean@312
    21
        [Microsoft.Office.Tools.Outlook.FormRegionName("pEp.FormRegionPrivacyStatus")]
Dean@312
    22
        public partial class FormRegionPrivacyStatusFactory
vb@133
    23
        {
vb@133
    24
            // Occurs before the form region is initialized.
vb@133
    25
            // To prevent the form region from appearing, set e.Cancel to true.
vb@133
    26
            // Use e.OutlookItem to get a reference to the current Outlook item.
Dean@312
    27
            private void FormRegionPrivacyStatus_FormRegionInitializing(object sender, Microsoft.Office.Tools.Outlook.FormRegionInitializingEventArgs e)
vb@133
    28
            {
Dean@327
    29
                WindowFormRegionCollection formRegions;
Dean@327
    30
Dean@327
    31
                /* There is a Microsoft bug at least in Outlook 2013 and Windows 8.1
Dean@327
    32
                 * This bug causes multiple PrivacyStatus form regions to appear stacked on top of each other.
Dean@327
    33
                 * To trigger this bug, on an unencrypted server, click reply to compose an in-line response.
Dean@327
    34
                 * Then click to another tab such as People or Tasks. Then click back on the mail tab to view 
Dean@327
    35
                 * the original email again. Two form regions will be visible: 
Dean@327
    36
                 * (1) for the status during the in-line reply and 
Dean@327
    37
                 * (2) for the status of only the received message.
Dean@327
    38
                 * 
Dean@327
    39
                 * To fix this bug, any existing form regions are found and closed when initializing a new privacy status
Dean@327
    40
                 * form region.
Dean@327
    41
                 */
Dean@327
    42
Dean@327
    43
                try
Dean@327
    44
                {
Dean@327
    45
                    formRegions = Globals.FormRegions[Globals.ThisAddIn.Application.ActiveExplorer()];
Dean@327
    46
                    if (formRegions.FormRegionPrivacyStatus != null)
Dean@327
    47
                    {
Dean@327
    48
                        /* Note: there seems to be no way to actually close the form region.
Dean@327
    49
                         * Therefore, this is as close as possible to actually closing it.
Dean@327
    50
                         * The actual form regions will be cleaned up as soon as another email is selected.
Dean@327
    51
                         */
Dean@327
    52
                        formRegions.FormRegionPrivacyStatus.OutlookFormRegion.Visible = false;
Dean@327
    53
                    }
Dean@327
    54
                }
Dean@327
    55
                catch { }
Dean@327
    56
Dean@327
    57
                return;
vb@133
    58
            }
vb@133
    59
        }
vb@133
    60
vb@133
    61
        #endregion
vb@133
    62
Dean@159
    63
        /* Notes:
Dean@179
    64
         * 
Dean@159
    65
         * Use this.OutlookItem to get a reference to the current Outlook item.
Dean@159
    66
         * Use this.OutlookFormRegion to get a reference to the form region.
Dean@179
    67
         * 
Dean@179
    68
         * UI State Managment:
Dean@179
    69
         * 
Dean@179
    70
         * The UI state is almost entirely set from the associated mail item data.
Dean@179
    71
         * However, a separate state class is maintained to represent the UI as some separation is needed.
Dean@179
    72
         * This logical separation MUST be maintained throughout the code.
Dean@179
    73
         * Specific cases are noted where possible.
Dean@179
    74
         * 
Dean@356
    75
         * The separate privacy status manager form state is also managed here.
Dean@259
    76
         * 
Dean@159
    77
         */
Dean@159
    78
Dean@170
    79
        private CryptableMailItem associatedMailItem = null;
Dean@179
    80
        private bool              refreshOngoing     = false;
Dean@179
    81
        private bool              eventsAreConnected = false;
Dean@170
    82
Dean@313
    83
        private FormManagePrivacyStatus managerForm = null;
Dean@259
    84
Dean@250
    85
        // Data or controls not stored in the UI
Dean@179
    86
        private _pEp_color stateUIColorRating; // WARNING: Do NOT use this directly
vb@133
    87
Dean@159
    88
        /**************************************************************
Dean@159
    89
         * 
Dean@159
    90
         * Methods
Dean@159
    91
         * 
Dean@159
    92
         *************************************************************/
Dean@159
    93
Dean@171
    94
        /// <summary>
Dean@438
    95
        /// Determines if this form region is running in an inspector window.
Dean@438
    96
        /// If not true, it is assumed to be within an explorer window.
Dean@438
    97
        /// </summary>
Dean@438
    98
        /// <returns>True if an inspector window, false if within an explorer.</returns>
Dean@438
    99
        private bool IsWithinInspector()
Dean@438
   100
        {
Dean@438
   101
            bool isWithinInspector = false;
Dean@438
   102
            Outlook.Explorer temp = null;
Dean@438
   103
Dean@438
   104
            try
Dean@438
   105
            {
Dean@438
   106
                // Just try to cast to an explorer class
Dean@438
   107
                temp = (Outlook.Explorer)this.OutlookFormRegion.Parent;
Dean@438
   108
                isWithinInspector = false;
Dean@438
   109
            }
Dean@438
   110
            catch
Dean@438
   111
            {
Dean@438
   112
                isWithinInspector = true;
Dean@438
   113
            }
Dean@438
   114
            finally
Dean@438
   115
            {
Dean@438
   116
                if (temp != null)
Dean@438
   117
                {
Dean@438
   118
                    Marshal.ReleaseComObject(temp);
Dean@438
   119
                    temp = null;
Dean@438
   120
                }
Dean@438
   121
            }
Dean@438
   122
Dean@438
   123
            return (isWithinInspector);
Dean@438
   124
        }
Dean@438
   125
Dean@438
   126
        /// <summary>
Dean@170
   127
        /// Sets the cryptable mail item associated with this encryption status panel.
Dean@170
   128
        /// The associated mail item can then be accessed through its local variable.
Dean@170
   129
        /// </summary>
Dean@170
   130
        private void SetAssociatedMailItem()
Dean@170
   131
        {
Dean@170
   132
            bool errorOccurred = false;
Dean@170
   133
            Outlook.MailItem omi = null;
Dean@170
   134
Dean@170
   135
            // Null check
Dean@170
   136
            if (!errorOccurred)
Dean@170
   137
            {
Dean@170
   138
                try
Dean@170
   139
                {
Dean@170
   140
                    if (this.OutlookItem == null)
Dean@170
   141
                    {
Dean@170
   142
                        errorOccurred = true;
Dean@170
   143
                    }
Dean@170
   144
                }
Dean@170
   145
                catch (COMException)
Dean@170
   146
                {
Dean@170
   147
                    errorOccurred = true;
Dean@170
   148
                }
Dean@170
   149
            }
Dean@170
   150
Dean@170
   151
            // Attempt to get and cast the outlook mail item
Dean@170
   152
            if (!errorOccurred)
Dean@170
   153
            {
Dean@170
   154
                try
Dean@170
   155
                {
Dean@170
   156
                    omi = (Outlook.MailItem)this.OutlookItem;
Dean@170
   157
                }
Dean@170
   158
                catch
Dean@170
   159
                {
Dean@170
   160
                    errorOccurred = true;
Dean@170
   161
                }
Dean@170
   162
            }
Dean@170
   163
Dean@170
   164
            // Finally set the associated mail item
Dean@170
   165
            if ((errorOccurred) ||
Dean@170
   166
                (omi == null))
Dean@170
   167
            {
Dean@170
   168
                this.associatedMailItem = null;
Dean@170
   169
            }
Dean@170
   170
            else
Dean@170
   171
            {
Dean@170
   172
                // Check if the associated mail item has already been set
Dean@170
   173
                if (this.associatedMailItem != null)
Dean@170
   174
                {
Dean@170
   175
                    // Only re-set the mail item if the EntryID has changed
Dean@170
   176
                    if (this.associatedMailItem.EntryID != omi.EntryID)
Dean@170
   177
                    {
Dean@170
   178
                        this.associatedMailItem = new CryptableMailItem(omi);
Dean@170
   179
                    }
Dean@170
   180
                }
Dean@170
   181
                else
Dean@170
   182
                {
Dean@170
   183
                    this.associatedMailItem = new CryptableMailItem(omi);
Dean@170
   184
                }
Dean@170
   185
            }
Dean@170
   186
Dean@170
   187
            return;
Dean@170
   188
        }
Dean@170
   189
Dean@179
   190
        /// <summary>
Dean@290
   191
        /// Completes the handshake process when the identity of a partner was previously marked as compromised.
Dean@281
   192
        /// </summary>
Dean@281
   193
        /// <param name="identityPartner">The identity of the partner to complete the handshake with.</param>
Dean@384
   194
        private void DoHandshakeForCompromisedKey(PEPIdentity identityPartner)
Dean@281
   195
        {
Dean@281
   196
            DialogResult result;
Dean@281
   197
Dean@281
   198
            result = MessageBox.Show(this.ParentForm,
Dean@378
   199
                                     pEp.Properties.Resources.Message_WarningCompromisedKey,
Dean@378
   200
                                     pEp.Properties.Resources.Message_TitleConfirmOperation,
Dean@423
   201
                                     MessageBoxButtons.YesNo);
Dean@281
   202
Dean@423
   203
            if (result == DialogResult.Yes)
Dean@281
   204
            {
Dean@281
   205
                this.DoHandshake(identityPartner);
Dean@281
   206
            }
Dean@281
   207
Dean@281
   208
            return;
Dean@281
   209
        }
Dean@281
   210
Dean@281
   211
        /// <summary>
Dean@281
   212
        /// Completes the handshake process where the identity of a partner is confirmed.
Dean@179
   213
        /// </summary>
Dean@179
   214
        /// <param name="identityPartner">The identity of the partner to complete the handshake with.</param>
Dean@384
   215
        private void DoHandshake(PEPIdentity identityPartner)
vb@133
   216
        {
Dean@155
   217
            string ownFpr;
Dean@155
   218
            string partnerFpr;
Dean@363
   219
            string trustwordsShort;
Dean@363
   220
            string trustwordsFull;
Dean@155
   221
            string[] lines;
Dean@179
   222
            DialogResult result;
Dean@633
   223
            PEPIdentity myIdentity;
Dean@155
   224
            FormHandshake handshakeDialog;
Dean@155
   225
            FormHandshake.State state = new FormHandshake.State();
markus@201
   226
Dean@190
   227
            Globals.ThisAddIn.LogVerbose("doHandshake");
Dean@384
   228
            Globals.ThisAddIn.LogVerbose(identityPartner.Address);
vb@139
   229
Dean@363
   230
            // Process identities
Dean@384
   231
            if (identityPartner.Username == "")
Dean@363
   232
            {
Dean@384
   233
                identityPartner.Username = identityPartner.Address;
vb@133
   234
            }
vb@133
   235
Dean@501
   236
            identityPartner.UserID = Globals.ThisAddIn.GetUserID(identityPartner.Address);
vb@139
   237
Dean@633
   238
            myIdentity = this.associatedMailItem.Myself;
Dean@363
   239
Dean@363
   240
            // Calculate and add trustwords
Dean@633
   241
            this.CalcTrustwords(myIdentity, identityPartner, out trustwordsShort, out trustwordsFull);
Dean@633
   242
            state.Myself = myIdentity.Copy();
Dean@600
   243
            state.Partner = identityPartner.Copy();
Dean@363
   244
            state.TrustwordsShort = trustwordsShort;
Dean@363
   245
            state.TrustwordsFull = trustwordsFull;
Dean@363
   246
Dean@363
   247
            // Calculate and add fingerprint
Dean@633
   248
            ownFpr = this.ToQuadruple(myIdentity.Fingerprint);
Dean@384
   249
            partnerFpr = this.ToQuadruple(identityPartner.Fingerprint);
vb@133
   250
Dean@633
   251
            if (myIdentity.Fingerprint.CompareTo(identityPartner.Fingerprint) > 0)
vb@133
   252
            {
Dean@155
   253
                lines = new string[3];
Dean@378
   254
                lines[0] = pEp.Properties.Resources.PrivacyStatus_TrustwordsPartnerShortPartner + partnerFpr;
Dean@378
   255
                lines[2] = pEp.Properties.Resources.PrivacyStatus_TrustwordsPartnerShortMyself + ownFpr;
Dean@155
   256
                state.Fingerprint = lines;
vb@133
   257
            }
vb@133
   258
            else
vb@133
   259
            {
Dean@155
   260
                lines = new string[3];
Dean@378
   261
                lines[0] = pEp.Properties.Resources.PrivacyStatus_TrustwordsOwnShortMyself + ownFpr;
Dean@378
   262
                lines[2] = pEp.Properties.Resources.PrivacyStatus_TrustwordsOwnShortPartner + partnerFpr;
Dean@155
   263
                state.Fingerprint = lines;
vb@133
   264
            }
vb@133
   265
Dean@155
   266
            // Create and show handshake dialog
Dean@155
   267
            handshakeDialog = new FormHandshake(state);
Dean@179
   268
            handshakeDialog.StartPosition = FormStartPosition.CenterScreen;
Dean@179
   269
            result = handshakeDialog.ShowDialog(this);
Dean@155
   270
Dean@356
   271
            this.ProcessDoHandshakeResult(result, identityPartner);
Dean@356
   272
Dean@356
   273
            return;
Dean@356
   274
        }
Dean@356
   275
Dean@356
   276
        /// <summary>
Dean@356
   277
        /// Processes the result of the do handshake dialog after a user makes a selection.
Dean@356
   278
        /// </summary>
Dean@356
   279
        /// <param name="result">The result of the handshake dialog selection.</param>
Dean@356
   280
        /// <param name="partner">The identity of the partner to handshake with.</param>
Dean@356
   281
        private void ProcessDoHandshakeResult(DialogResult result,
Dean@384
   282
                                              PEPIdentity partner)
Dean@356
   283
        {
Dean@384
   284
            pEp_identity_s identityPartner = ThisAddIn.pEp.update_identity(partner.ToCOMType());
vb@133
   285
vb@133
   286
            switch (result)
vb@133
   287
            {
vb@133
   288
                case DialogResult.Yes:
Dean@279
   289
                    {
Dean@290
   290
                        // Check if key was previously compromised -- warning for this must be displayed earlier
Dean@281
   291
                        if (identityPartner.comm_type == _pEp_comm_type.pEp_ct_compromized)
Dean@281
   292
                        {
Dean@281
   293
                            ThisAddIn.pEp.key_reset_trust(ref identityPartner);
Dean@281
   294
                        }
Dean@281
   295
Dean@279
   296
                        identityPartner = ThisAddIn.pEp.trust_personal_key(ref identityPartner);
Dean@293
   297
                        this.associatedMailItem.ColorRating = _pEp_color.pEp_rating_trusted;
Dean@279
   298
Dean@279
   299
                        this.UpdateUIFromMailItem();
Dean@279
   300
Dean@279
   301
                        // Update the manager form state
Dean@279
   302
                        if (this.managerForm != null)
Dean@279
   303
                        {
Dean@279
   304
                            this.managerForm.CopyStateToUI(this.GetManagerState());
Dean@279
   305
                        }
Dean@279
   306
Dean@279
   307
                        break;
Dean@279
   308
                    }
vb@133
   309
                case DialogResult.No:
Dean@279
   310
                    {
Dean@279
   311
                        ThisAddIn.pEp.key_compromized(ref identityPartner);
Dean@279
   312
                        identityPartner.comm_type = _pEp_comm_type.pEp_ct_compromized;
Dean@279
   313
                        identityPartner = ThisAddIn.pEp.update_identity(identityPartner);
Dean@293
   314
                        this.associatedMailItem.ColorRating = _pEp_color.pEp_rating_red;
Dean@279
   315
Dean@279
   316
                        this.UpdateUIFromMailItem();
Dean@279
   317
Dean@279
   318
                        // Update the manager form state
Dean@279
   319
                        if (this.managerForm != null)
Dean@279
   320
                        {
Dean@279
   321
                            this.managerForm.CopyStateToUI(this.GetManagerState());
Dean@279
   322
                        }
Dean@279
   323
Dean@279
   324
                        break;
Dean@279
   325
                    }
vb@133
   326
            }
Dean@279
   327
Dean@279
   328
            return;
vb@133
   329
        }
vb@133
   330
Dean@179
   331
        /// <summary>
Dean@179
   332
        /// Reverses any past handshake confirmation by unconfirming the given identity partner.
Dean@179
   333
        /// </summary>
Dean@384
   334
        /// <param name="partner">The identity of the partner to unconfirm.</param>
Dean@384
   335
        private void UndoHandshake(PEPIdentity partner)
vb@133
   336
        {
Dean@384
   337
            pEp_identity_s identityPartner = ThisAddIn.pEp.update_identity(partner.ToCOMType());
Dean@280
   338
            ThisAddIn.pEp.key_reset_trust(ref identityPartner);
Dean@279
   339
Dean@179
   340
            this.UpdateUIFromMailItem();
Dean@279
   341
Dean@279
   342
            // Update the manager form state
Dean@279
   343
            if (this.managerForm != null)
Dean@279
   344
            {
Dean@279
   345
                this.managerForm.CopyStateToUI(this.GetManagerState());
Dean@279
   346
            }
Dean@279
   347
Dean@279
   348
            return;
vb@133
   349
        }
vb@133
   350
Dean@161
   351
        /// <summary>
Dean@363
   352
        /// Calculates both the short and full trustwords between the given personal identity and the identity partner.
Dean@363
   353
        /// </summary>
Dean@363
   354
        /// <param name="myIdentity">The personal identity.</param>
Dean@363
   355
        /// <param name="partnerIdentity">The identity of the partner.</param>
Dean@363
   356
        /// <param name="trustwordsShort">The short version of trustwords.</param>
Dean@363
   357
        /// <param name="trustwordsFull">The full/long version of trustwords.</param>
Dean@384
   358
        private void CalcTrustwords(PEPIdentity myIdentity,
Dean@384
   359
                                    PEPIdentity partnerIdentity,
Dean@363
   360
                                    out string trustwordsShort,
Dean@363
   361
                                    out string trustwordsFull)
Dean@363
   362
        {
Dean@363
   363
            string myShort;
Dean@363
   364
            string myLong;
Dean@363
   365
            string partnerShort;
Dean@363
   366
            string partnerLong;
Dean@363
   367
Dean@384
   368
            myShort = ThisAddIn.pEp.trustwords(myIdentity.Fingerprint, max_words: 5).ToLower();
Dean@384
   369
            myLong = ThisAddIn.pEp.trustwords(myIdentity.Fingerprint).ToLower();
Dean@384
   370
            partnerShort = ThisAddIn.pEp.trustwords(partnerIdentity.Fingerprint, max_words: 5).ToLower();
Dean@384
   371
            partnerLong = ThisAddIn.pEp.trustwords(partnerIdentity.Fingerprint).ToLower();
Dean@363
   372
Dean@384
   373
            if (myIdentity.Fingerprint.CompareTo(partnerIdentity.Fingerprint) > 0)
Dean@363
   374
            {
Dean@363
   375
                trustwordsShort = partnerShort + myShort;
Dean@363
   376
                trustwordsFull = partnerLong + myLong;
Dean@363
   377
            }
Dean@363
   378
            else
Dean@363
   379
            {
Dean@363
   380
                trustwordsShort = myShort + " " + partnerShort;
Dean@363
   381
                trustwordsFull = myLong + " " + partnerLong;
Dean@363
   382
            }
Dean@363
   383
Dean@363
   384
            return;
Dean@363
   385
        }
Dean@363
   386
Dean@363
   387
        /// <summary>
Dean@161
   388
        /// Formats the given text string as separated 4-character groups.
Dean@161
   389
        /// Example: 49422235FC99585B891C --> 4942 2235 FC99 585B 891C
Dean@161
   390
        /// </summary>
Dean@161
   391
        /// <param name="text">The text to format in 4-character groups.</param>
Dean@161
   392
        /// <returns>The re-formatted string.</returns>
Dean@161
   393
        private string ToQuadruple(string text)
Dean@159
   394
        {
Dean@159
   395
            List<string> result = new List<string>();
Dean@159
   396
Dean@161
   397
            if (text != null)
Dean@159
   398
            {
Dean@161
   399
                for (int i = 0; i < text.Length; i += 4)
Dean@159
   400
                {
Dean@161
   401
                    try
Dean@161
   402
                    {
Dean@161
   403
                        result.Add(text.Substring(i, 4));
Dean@161
   404
                    }
Dean@161
   405
                    catch (ArgumentOutOfRangeException)
Dean@161
   406
                    {
Dean@161
   407
                        result.Add(text.Substring(i));
Dean@161
   408
                        break;
Dean@161
   409
                    }
Dean@159
   410
                }
Dean@159
   411
            }
Dean@159
   412
Dean@159
   413
            return String.Join(" ", result);
Dean@159
   414
        }
markus@201
   415
Dean@196
   416
        /// <summary>
Dean@196
   417
        /// Makes the unencrypted preview form.
Dean@196
   418
        /// This gets the active form region then fills it's content.
Dean@196
   419
        /// </summary>
Dean@198
   420
        /// <returns>True if successful, otherwise false.</returns>
Dean@198
   421
        private bool MakePreview()
Dean@159
   422
        {
Dean@620
   423
            bool success = false;
Dean@198
   424
            bool isSuccessful;
Dean@198
   425
            byte[] rtfBody;
Dean@159
   426
            WindowFormRegionCollection formRegions;
Dean@620
   427
            PEPMessage mirror;
Dean@198
   428
            formRegions = Globals.FormRegions[Globals.ThisAddIn.Application.ActiveExplorer()];
Dean@159
   429
Dean@198
   430
            if ((formRegions != null) &&
Dean@198
   431
                (formRegions.FormRegionPreviewUnencrypted != null) &&
Dean@620
   432
                (formRegions.FormRegionPreviewUnencrypted.Visible))
Dean@198
   433
            {
Dean@620
   434
                formRegions.FormRegionPreviewUnencrypted.ClearMessage();
Dean@620
   435
                mirror = this.associatedMailItem.MirrorGet();
Dean@620
   436
Dean@620
   437
                if (mirror != null)
Dean@198
   438
                {
Dean@620
   439
                    // Attempt to the the RTF body
Dean@620
   440
                    isSuccessful = this.associatedMailItem.MirrorTryGetRTFBody(out rtfBody);
Dean@620
   441
                    if (isSuccessful == false)
Dean@620
   442
                    {
Dean@620
   443
                        return (false);
Dean@620
   444
                    }
Dean@620
   445
Dean@620
   446
                    formRegions.FormRegionPreviewUnencrypted.SetMessage(mirror);
Dean@620
   447
                    formRegions.FormRegionPreviewUnencrypted.SetRTFBody(System.Text.Encoding.ASCII.GetString(rtfBody, 0, rtfBody.Length));
Dean@620
   448
                    success = true;
Dean@198
   449
                }
Dean@198
   450
            }
Dean@198
   451
Dean@198
   452
            return (success);
Dean@159
   453
        }
markus@201
   454
Dean@179
   455
        /// <summary>
Dean@279
   456
        /// Builds a new manager form state using this encryption state/mail item current state.
Dean@279
   457
        /// </summary>
Dean@279
   458
        /// <returns>A new manager form state.</returns>
Dean@313
   459
        private FormManagePrivacyStatus.State GetManagerState()
Dean@279
   460
        {
Dean@527
   461
            bool isMyself;
Dean@364
   462
            string trustwordsShort;
Dean@364
   463
            string trustwordsFull;
Dean@384
   464
            List<PEPIdentity> identities;
Dean@384
   465
            PEPIdentity myIdentity;
Dean@384
   466
            PEPIdentity incomingIdent;
Dean@527
   467
            PEPIdentity[] myIdentities;
Dean@259
   468
            _pEp_color identityPartnerColor;
Dean@259
   469
            SelectionItem item;
Dean@312
   470
            PrivacyState state = this.CopyUIToState();
Dean@313
   471
            FormManagePrivacyStatus.State managerState = new FormManagePrivacyStatus.State();
Dean@259
   472
Dean@332
   473
            // Resolve all recipients -- this ensures the identities list is correctly populated
Dean@332
   474
            this.associatedMailItem.ResolveAllRecipients();
Dean@332
   475
Dean@279
   476
            managerState.VisualState = state.Copy();
Dean@279
   477
            managerState.IsIncoming = this.associatedMailItem.IsIncoming;
Dean@259
   478
Dean@259
   479
            if (this.associatedMailItem.IsIncoming)
Dean@259
   480
            {
Dean@384
   481
                identities = new List<PEPIdentity>();
Dean@259
   482
Dean@259
   483
                // Add only one identity
Dean@638
   484
                if (this.associatedMailItem.From != null)
Dean@638
   485
                {
Dean@638
   486
                    incomingIdent = new PEPIdentity();
Dean@638
   487
                    incomingIdent.Address = this.associatedMailItem.From.Address;
Dean@638
   488
                    incomingIdent.Username = this.associatedMailItem.From.Username;
Dean@638
   489
                    incomingIdent.UserID = Globals.ThisAddIn.GetUserID(incomingIdent.Address);
Dean@259
   490
Dean@638
   491
                    identities.Add(incomingIdent);
Dean@638
   492
                }
Dean@259
   493
            }
Dean@259
   494
            else
Dean@259
   495
            {
Dean@395
   496
                identities = this.associatedMailItem.Recipients;
Dean@259
   497
            }
Dean@259
   498
Dean@366
   499
            // Get my identity
Dean@633
   500
            myIdentity = this.associatedMailItem.Myself;
Dean@527
   501
            myIdentities = PEPIdentity.GetMyIdentities();
Dean@366
   502
Dean@279
   503
            // Add identities
Dean@394
   504
            identities = PEPIdentity.ToFlatList(identities);
Dean@279
   505
            managerState.Identities.Clear();
Dean@384
   506
            foreach (PEPIdentity ident in identities)
Dean@259
   507
            {
Dean@485
   508
                if (ident.IsValid())
Dean@485
   509
                {
Dean@485
   510
                    pEp_identity_s partnerIdentity_s = ThisAddIn.pEp.update_identity(ident.ToCOMType());
Dean@485
   511
                    PEPIdentity partnerIdentity = new PEPIdentity(partnerIdentity_s);
Dean@485
   512
                    identityPartnerColor = ThisAddIn.pEp.identity_color(partnerIdentity_s);
Dean@259
   513
Dean@527
   514
                    // Check if identity is myself
Dean@527
   515
                    isMyself = false;
Dean@527
   516
                    foreach (PEPIdentity me in myIdentities)
Dean@527
   517
                    {
Dean@527
   518
                        if (partnerIdentity.EqualsByAddress(me))
Dean@527
   519
                        {
Dean@527
   520
                            isMyself = true;
Dean@527
   521
                            break;
Dean@527
   522
                        }
Dean@527
   523
                    }
Dean@527
   524
Dean@485
   525
                    item = new SelectionItem();
Dean@485
   526
                    item.TextLine1 = partnerIdentity.Username;
Dean@485
   527
                    item.TextLine2 = partnerIdentity.Address;
Dean@259
   528
Dean@485
   529
                    // Don't show both the user name and address if they are the same
Dean@485
   530
                    if ((item.TextLine1 != null) &&
Dean@485
   531
                        (item.TextLine2 != null) &&
Dean@485
   532
                        (item.TextLine1 == item.TextLine2))
Dean@485
   533
                    {
Dean@485
   534
                        item.IsTwoTextLinesVisible = false;
Dean@485
   535
                    }
Dean@332
   536
Dean@527
   537
                    // Calculate trustwords
Dean@527
   538
                    this.CalcTrustwords(myIdentity,
Dean@527
   539
                                        partnerIdentity,
Dean@527
   540
                                        out trustwordsShort,
Dean@527
   541
                                        out trustwordsFull);
Dean@527
   542
Dean@485
   543
                    // Set image
Dean@485
   544
                    switch (PrivacyState.ConvertRatingToPrivacyColor(identityPartnerColor))
Dean@485
   545
                    {
Dean@485
   546
                        case PrivacyState.PrivacyColor.Green:
Dean@485
   547
                            item.ItemImage = pEp.Properties.Resources.ImagePrivacyStatusGreen;
Dean@485
   548
                            break;
Dean@485
   549
                        case PrivacyState.PrivacyColor.Yellow:
Dean@485
   550
                            item.ItemImage = pEp.Properties.Resources.ImagePrivacyStatusYellow;
Dean@485
   551
                            break;
Dean@485
   552
                        case PrivacyState.PrivacyColor.Red:
Dean@485
   553
                            item.ItemImage = pEp.Properties.Resources.ImagePrivacyStatusRed;
Dean@485
   554
                            break;
Dean@485
   555
                        case PrivacyState.PrivacyColor.NoColor:
Dean@485
   556
                            item.ItemImage = pEp.Properties.Resources.ImagePrivacyStatusNoColor;
Dean@485
   557
                            break;
Dean@485
   558
                        default:
Dean@485
   559
                            item.ItemImage = null;
Dean@485
   560
                            break;
Dean@485
   561
                    }
Dean@259
   562
Dean@485
   563
                    // Set button
Dean@527
   564
                    if (isMyself == false)
Dean@366
   565
                    {
Dean@485
   566
                        if (partnerIdentity.CommunicationType >= _pEp_comm_type.pEp_ct_confirmed_encryption)
Dean@485
   567
                        {
Dean@485
   568
                            // Undo handshake
Dean@485
   569
                            item.TextButton = pEp.Properties.Resources.PrivacyStatus_StopTrusting;
Dean@485
   570
                            item.IsButtonVisible = true;
Dean@485
   571
                            item.ButtonOnClick = (x, y) => { this.UndoHandshake(partnerIdentity); };
Dean@356
   572
Dean@485
   573
                            item.IsExpandable = false;
Dean@485
   574
                        }
Dean@485
   575
                        else if (partnerIdentity.CommunicationType >= _pEp_comm_type.pEp_ct_unconfirmed_encryption &&
Dean@485
   576
                                 partnerIdentity.CommunicationType < _pEp_comm_type.pEp_ct_confirmed_encryption)
Dean@485
   577
                        {
Dean@485
   578
                            // Do handshake
Dean@485
   579
                            item.TextButton = pEp.Properties.Resources.PrivacyStatus_HandshakeAdvanced;
Dean@485
   580
                            item.IsButtonVisible = true;
Dean@485
   581
                            item.ButtonOnClick = (x, y) => { this.DoHandshake(partnerIdentity); };
Dean@356
   582
Dean@485
   583
                            item.IsExpandable = true;
Dean@485
   584
                            item.ExpandedText = Properties.Resources.PrivacyStatus_TrustwordDesc + "\n\n" +
Dean@485
   585
                                                trustwordsShort;
Dean@447
   586
Dean@485
   587
                            item.ExpandedButton1Text = Properties.Resources.PrivacyStatus_SelectTrust;
Dean@485
   588
                            item.ExpandedButton1OnClick = (x, y) => { this.ProcessDoHandshakeResult(DialogResult.Yes, partnerIdentity); };
Dean@485
   589
                            item.ExpandedButton1BackColor = PrivacyState.COLOR_GREEN;
Dean@485
   590
                            item.ExpandedButton1ForeColor = Color.White;
Dean@447
   591
Dean@485
   592
                            item.ExpandedButton2Text = Properties.Resources.PrivacyStatus_SelectMistrust;
Dean@485
   593
                            item.ExpandedButton2OnClick = (x, y) => { this.ProcessDoHandshakeResult(DialogResult.No, partnerIdentity); };
Dean@485
   594
                            item.ExpandedButton2BackColor = PrivacyState.COLOR_RED;
Dean@485
   595
                            item.ExpandedButton2ForeColor = Color.White;
Dean@485
   596
                        }
Dean@485
   597
                        else if (partnerIdentity.CommunicationType == _pEp_comm_type.pEp_ct_compromized)
Dean@485
   598
                        {
Dean@485
   599
                            // Redo handshake with confirmation
Dean@485
   600
                            item.TextButton = pEp.Properties.Resources.PrivacyStatus_Handshake;
Dean@485
   601
                            item.IsButtonVisible = true;
Dean@485
   602
                            item.ButtonOnClick = (x, y) => { this.DoHandshakeForCompromisedKey(partnerIdentity); };
Dean@485
   603
                        }
Dean@485
   604
                        else
Dean@485
   605
                        {
Dean@485
   606
                            item.IsButtonVisible = false;
Dean@485
   607
                        }
Dean@366
   608
                    }
Dean@366
   609
                    else
Dean@366
   610
                    {
Dean@366
   611
                        item.IsButtonVisible = false;
Dean@366
   612
                    }
Dean@281
   613
                }
Dean@485
   614
                else // Invalid identity
Dean@259
   615
                {
Dean@485
   616
                    item = new SelectionItem();
Dean@485
   617
                    item.TextLine1 = ident.Username;
Dean@485
   618
                    item.TextLine2 = ident.Address;
Dean@485
   619
                    item.ItemImage = null;
Dean@485
   620
                    item.IsTwoTextLinesVisible = true;
Dean@259
   621
                    item.IsButtonVisible = false;
Dean@259
   622
                }
Dean@259
   623
Dean@279
   624
                managerState.Identities.Add(item);
Dean@259
   625
            }
Dean@259
   626
Dean@375
   627
            // Attempt to select the first identity requiring a handshake
Dean@375
   628
            for (int i = 0; i < managerState.Identities.Count; i++)
Dean@375
   629
            {
Dean@375
   630
                // Determine if it's a handshake identity by simply seeing if it's expandable
Dean@375
   631
                if (managerState.Identities[i].IsExpandable)
Dean@375
   632
                {
Dean@375
   633
                    managerState.SelectedIdentityIndex = i;
Dean@375
   634
                    break;
Dean@375
   635
                }
Dean@375
   636
            }
Dean@375
   637
Dean@279
   638
            return (managerState);
Dean@279
   639
        }
Dean@279
   640
Dean@279
   641
        /// <summary>
Dean@279
   642
        /// Builds the latest state of the encryption status manager then shows the UI.
Dean@279
   643
        /// </summary>
Dean@279
   644
        private void BuildAndShowManager()
Dean@279
   645
        {
Dean@279
   646
            DialogResult result;
Dean@313
   647
            FormManagePrivacyStatus form;
Dean@313
   648
            FormManagePrivacyStatus.State stateOut;
Dean@279
   649
Dean@483
   650
            try
Dean@483
   651
            {
Dean@483
   652
                // Show the form
Dean@483
   653
                form = new FormManagePrivacyStatus();
Dean@483
   654
                form.StartPosition = FormStartPosition.CenterScreen;
Dean@259
   655
Dean@483
   656
                this.managerForm = form;
Dean@483
   657
                result = form.ShowDialog(this.ParentForm, this.GetManagerState(), out stateOut); // Must show as dialog to block code
Dean@483
   658
            }
Dean@483
   659
            catch (Exception ex)
Dean@483
   660
            {
Dean@483
   661
                GlobalExceptionHandler.StopAndSendCrashReport(ex);
Dean@483
   662
            }
Dean@259
   663
Dean@259
   664
            return;
Dean@259
   665
        }
Dean@259
   666
Dean@259
   667
        /// <summary>
Dean@179
   668
        /// Updates the status of the UI state based on the associated mail item.
Dean@179
   669
        /// Any previous state changes in the UI are preserved.
Dean@179
   670
        /// </summary>
Dean@622
   671
        public void UpdateUIFromMailItem()
Dean@159
   672
        {
Dean@312
   673
            PrivacyState state;
Dean@342
   674
            bool? sendUnencryptedProperty;
Dean@159
   675
Dean@173
   676
            if (this.associatedMailItem != null)
Dean@159
   677
            {
Dean@342
   678
                sendUnencryptedProperty = this.associatedMailItem.SendUnencrypted;
Dean@342
   679
Dean@342
   680
                if ((sendUnencryptedProperty != null) &&
Dean@342
   681
                    ((bool)sendUnencryptedProperty == true))
Dean@159
   682
                {
Dean@342
   683
                    // Force unencrypted
Dean@312
   684
                    state = new PrivacyState(_pEp_color.pEp_rating_unencrypted);
Dean@159
   685
                }
Dean@159
   686
                else
Dean@159
   687
                {
Dean@312
   688
                    state = new PrivacyState(this.associatedMailItem.ColorRating);
Dean@159
   689
                }
Dean@179
   690
Dean@179
   691
                this.CopyStateToUI(state);
Dean@159
   692
            }
Dean@159
   693
Dean@179
   694
            return;
Dean@159
   695
        }
Dean@159
   696
Dean@172
   697
        #region StateMethods
Dean@172
   698
Dean@172
   699
        /// <summary>
Dean@172
   700
        /// Connects or disconnects all control events from the UI.
Dean@172
   701
        /// </summary>
Dean@172
   702
        /// <param name="connect">True to connect events, false to disconnect.</param>
Dean@172
   703
        private void ConnectEvents(bool connect)
Dean@172
   704
        {
Dean@172
   705
            // Connect events only if not already connected
markus@201
   706
            if ((connect == true) &&
Dean@172
   707
                (this.eventsAreConnected == false))
Dean@172
   708
            {
Dean@312
   709
                this.ButtonPrivacyStatus.Click += this.ButtonPrivacyStatus_Click;
Dean@312
   710
                this.ButtonPrivacyStatus.MouseUp += this.ButtonPrivacyStatus_MouseUp;
Dean@179
   711
Dean@172
   712
                this.eventsAreConnected = true;
Dean@172
   713
            }
Dean@172
   714
            // Always attempt to disconnect
Dean@172
   715
            else if (connect == false)
Dean@172
   716
            {
Dean@312
   717
                this.ButtonPrivacyStatus.Click -= this.ButtonPrivacyStatus_Click;
Dean@312
   718
                this.ButtonPrivacyStatus.MouseUp -= this.ButtonPrivacyStatus_MouseUp;
Dean@179
   719
Dean@172
   720
                this.eventsAreConnected = false;
Dean@172
   721
            }
Dean@172
   722
Dean@172
   723
            return;
Dean@172
   724
        }
Dean@172
   725
Dean@172
   726
        /// <summary>
Dean@172
   727
        /// Refreshes the UI by reloading the state.
Dean@172
   728
        /// </summary>
Dean@172
   729
        private void RefreshUI()
Dean@172
   730
        {
Dean@172
   731
            this.CopyStateToUI(this.CopyUIToState());
Dean@172
   732
            return;
Dean@172
   733
        }
Dean@172
   734
Dean@172
   735
        /// <summary>
Dean@172
   736
        /// Copies the given state to the UI.
Dean@172
   737
        /// Events are turned off until the process is complete.
Dean@172
   738
        /// </summary>
Dean@172
   739
        /// <param name="state">The state to set to the UI.</param>
Dean@312
   740
        private void CopyStateToUI(PrivacyState state)
Dean@172
   741
        {
Dean@172
   742
            this.ConnectEvents(false);
markus@201
   743
Dean@172
   744
            ///////////////////////////////////////////////////////////
Dean@172
   745
            // Set UI data
Dean@172
   746
            ///////////////////////////////////////////////////////////
Dean@172
   747
Dean@179
   748
            // Save UI state maintained outside of controls
Dean@312
   749
            this.stateUIColorRating = state.PrivacyStatus;
Dean@179
   750
Dean@312
   751
            this.ButtonPrivacyStatus.BackColor = state.BackgroundColor;
Dean@312
   752
            this.ButtonPrivacyStatus.ForeColor = state.ForegroundColor;
Dean@312
   753
            this.ButtonPrivacyStatus.Text = state.ShortText;
Dean@172
   754
Dean@172
   755
            this.ConnectEvents(true);
Dean@172
   756
Dean@172
   757
            return;
Dean@172
   758
        }
Dean@172
   759
Dean@172
   760
        /// <summary>
Dean@172
   761
        /// Copies the UI to a new state.
Dean@172
   762
        /// </summary>
Dean@172
   763
        /// <returns>The state of the UI.</returns>
Dean@312
   764
        private PrivacyState CopyUIToState()
Dean@172
   765
        {
Dean@312
   766
            return (new PrivacyState(this.stateUIColorRating));
Dean@172
   767
        }
Dean@172
   768
Dean@172
   769
        #endregion
Dean@172
   770
Dean@159
   771
        /**************************************************************
Dean@159
   772
         * 
Dean@159
   773
         * Event Handling
Dean@159
   774
         * 
Dean@159
   775
         *************************************************************/
Dean@159
   776
Dean@159
   777
        /// <summary>
Dean@159
   778
        /// Event handler that is called before the form region is displayed.
Dean@159
   779
        /// </summary>
Dean@312
   780
        private void FormRegionPrivacyStatus_FormRegionShowing(object sender, System.EventArgs e)
Dean@159
   781
        {
Dean@173
   782
            this.SetAssociatedMailItem();
Dean@173
   783
Dean@631
   784
            // Set background color for Office 2013
Dean@631
   785
            try
Dean@631
   786
            {
Dean@631
   787
                if (Globals.ThisAddIn.Application.Version.Substring(0, 2) == "15")
Dean@631
   788
                {
Dean@631
   789
                    if (this.IsWithinInspector())
Dean@631
   790
                    {
Dean@631
   791
                        this.BackColor = SystemColors.ButtonFace;
Dean@631
   792
                    }
Dean@631
   793
                    else
Dean@631
   794
                    {
Dean@631
   795
                        this.BackColor = SystemColors.Window;
Dean@631
   796
                    }
Dean@631
   797
                }
Dean@631
   798
            }
Dean@631
   799
            catch { }
Dean@631
   800
Dean@199
   801
            // Connect cryptable mail item events
Dean@189
   802
            if (this.associatedMailItem != null)
Dean@159
   803
            {
Dean@159
   804
                try
Dean@159
   805
                {
Dean@445
   806
                    this.associatedMailItem.PropertyChanged += MailItem_PropertyChanged;
Dean@179
   807
Dean@189
   808
                    if (this.associatedMailItem.IsInEncryptedStore &&
Dean@198
   809
                        this.associatedMailItem.IsPGPEncrypted)
Dean@159
   810
                    {
Dean@189
   811
                        this.associatedMailItem.Open += MailItem_Open;
Dean@159
   812
                    }
Dean@159
   813
                }
Dean@159
   814
                catch { }
Dean@179
   815
            }
Dean@159
   816
Dean@179
   817
            // Set the default UI state
Dean@312
   818
            this.CopyStateToUI(new PrivacyState());
Dean@179
   819
Dean@199
   820
            // Call the timer tick method manually to refresh data
Dean@199
   821
            this.TimerRefresh_Tick(null, new EventArgs());
Dean@179
   822
Dean@179
   823
            return;
Dean@159
   824
        }
Dean@159
   825
Dean@159
   826
        /// <summary>
Dean@159
   827
        /// Event handler for when the form region is closed.
Dean@159
   828
        /// </summary>
Dean@312
   829
        private void FormRegionPrivacyStatus_FormRegionClosed(object sender, System.EventArgs e)
Dean@159
   830
        {
Dean@199
   831
            // Disconnect cryptable mail item events
Dean@190
   832
            if (this.associatedMailItem != null)
Dean@179
   833
            {
Dean@179
   834
                try
Dean@179
   835
                {
Dean@445
   836
                    this.associatedMailItem.PropertyChanged -= MailItem_PropertyChanged;
markus@201
   837
                    this.associatedMailItem.Open -= MailItem_Open;
Dean@179
   838
                }
Dean@179
   839
                catch { }
Dean@179
   840
            }
Dean@179
   841
Dean@179
   842
            return;
Dean@179
   843
        }
Dean@179
   844
Dean@179
   845
        /// <summary>
Dean@179
   846
        /// Event handler called after the refresh timer has elapsed.
Dean@179
   847
        /// </summary>
Dean@179
   848
        private void TimerRefresh_Tick(object sender, EventArgs e)
Dean@179
   849
        {
Dean@199
   850
            bool tryAgain = false;
Dean@199
   851
            bool isSuccessful;
Dean@179
   852
            this.TimerRefresh.Enabled = false; // Only once
markus@201
   853
Dean@179
   854
            // Ensure the tick method is not called more than once
Dean@179
   855
            if (refreshOngoing == false)
Dean@179
   856
            {
Dean@179
   857
                this.refreshOngoing = true;
Dean@179
   858
Dean@179
   859
                if (this.associatedMailItem != null)
Dean@179
   860
                {
Dean@179
   861
                    if (this.associatedMailItem.DownloadState == Outlook.OlDownloadState.olFullItem)
Dean@179
   862
                    {
Dean@179
   863
                        this.UpdateUIFromMailItem();
Dean@199
   864
Dean@199
   865
                        /* Create the unencrypted preview if the mail item is encrypted and
Dean@199
   866
                         * it is in an encrypted (untrusted) store
Dean@199
   867
                         * 
Dean@312
   868
                         * This is done here because FormRegionPrivacyStatus has the cryptable mail item and
Dean@199
   869
                         * it also is initialized after FormRegionPreviewUnencrypted.
Dean@199
   870
                         */
Dean@199
   871
                        if (this.associatedMailItem.IsInEncryptedStore &&
Dean@199
   872
                            this.associatedMailItem.IsPGPEncrypted)
Dean@199
   873
                        {
Dean@199
   874
                            isSuccessful = this.MakePreview();
Dean@199
   875
Dean@534
   876
                            // Disable try again as it never seems to recover in real-world testing
Dean@534
   877
                            /*if (isSuccessful == false)
Dean@199
   878
                            {
Dean@199
   879
                                tryAgain = true;
Dean@534
   880
                            }*/
Dean@199
   881
                        }
Dean@179
   882
                    }
Dean@179
   883
                    else
Dean@179
   884
                    {
Dean@179
   885
                        this.associatedMailItem.MarkForDownload = Outlook.OlRemoteStatus.olMarkedForDownload;
Dean@199
   886
                        tryAgain = true;
Dean@179
   887
                    }
Dean@179
   888
                }
Dean@179
   889
Dean@199
   890
                // Set the timer to refresh again later automatically
Dean@199
   891
                if (tryAgain)
Dean@199
   892
                {
Dean@199
   893
                    this.TimerRefresh.Interval = 100;
Dean@199
   894
                    this.TimerRefresh.Enabled = true;
Dean@199
   895
                }
Dean@199
   896
Dean@179
   897
                this.refreshOngoing = false;
Dean@179
   898
            }
Dean@175
   899
Dean@159
   900
            return;
Dean@159
   901
        }
Dean@159
   902
Dean@169
   903
        /// <summary>
Dean@169
   904
        /// Event handler for when a mail item is being opened in an inspector.
Dean@180
   905
        /// See: https://msdn.microsoft.com/en-us/library/office/ff865989.aspx
Dean@169
   906
        /// </summary>
Dean@169
   907
        /// <param name="cancel">Whether to cancel the event: Value is False when the event occurs. 
Dean@169
   908
        /// If the event procedure sets this argument to True, the open operation is not completed 
Dean@169
   909
        /// and the inspector is not displayed.</param>
Dean@169
   910
        private void MailItem_Open(ref bool cancel)
Dean@159
   911
        {
Dean@173
   912
            if (this.associatedMailItem != null && this.associatedMailItem.MirrorDisplay())
Dean@169
   913
            {
Dean@169
   914
                cancel = true;
Dean@169
   915
            }
Dean@169
   916
Dean@169
   917
            return;
Dean@159
   918
        }
Dean@159
   919
Dean@169
   920
        /// <summary>
Dean@169
   921
        /// Event handler for when a mail item property is changed.
Dean@169
   922
        /// See: https://msdn.microsoft.com/en-us/library/office/ff866739.aspx
Dean@169
   923
        /// </summary>
Dean@169
   924
        /// <param name="propertyName">The name of the property that was changed.</param>
Dean@445
   925
        private void MailItem_PropertyChanged(object sender, PropertyChangedEventArgs e)
Dean@159
   926
        {
Dean@445
   927
            switch (e.PropertyName.ToUpper())
Dean@159
   928
            {
Dean@179
   929
                case "TO":
Dean@179
   930
                    // Start the refresh timer
Dean@179
   931
                    this.TimerRefresh.Enabled = true;
Dean@159
   932
                    break;
Dean@159
   933
                // Outlook bug: there are always both events, so one is enough
Dean@159
   934
                //case "CC":
Dean@179
   935
                //    // Start the refresh timer
Dean@179
   936
                //    this.TimerRefresh.Enabled = true;
Dean@159
   937
                //    break;
Dean@159
   938
            }
Dean@169
   939
Dean@169
   940
            return;
Dean@159
   941
        }
Dean@159
   942
Dean@179
   943
        /// <summary>
Dean@312
   944
        /// Event handler for when the privacy status button is clicked.
Dean@179
   945
        /// </summary>
Dean@312
   946
        private void ButtonPrivacyStatus_Click(object sender, EventArgs e)
vb@133
   947
        {
Dean@310
   948
            this.BuildAndShowManager();
Dean@179
   949
            return;
vb@133
   950
        }
vb@133
   951
Dean@179
   952
        /// <summary>
Dean@312
   953
        /// Event handler for when a mouse button is released over the privacy status button.
Dean@179
   954
        /// </summary>
Dean@312
   955
        private void ButtonPrivacyStatus_MouseUp(object sender, MouseEventArgs e)
vb@133
   956
        {
Dean@179
   957
            return;
vb@133
   958
        }
vb@133
   959
    }
vb@133
   960
}