Completely switch to the Log class.
authorDean
Wed, 07 Sep 2016 22:31:02 +0200
changeset 124900cc05656f71
parent 1248 d6aa0fcdbaa3
child 1250 e219136cec9d
Completely switch to the Log class.
CryptableMailItem.cs
Globals.cs
Log.cs
MsgProcessor.cs
PEPAttachment.cs
PEPIdentity.cs
PEPMessage.cs
PEPSettings.cs
ThisAddIn.cs
UI/FormControlOptions.xaml.cs
UI/FormControlPrivacyStatus.xaml.cs
UI/FormReaderSplash.cs
UI/FormRegionPreviewUnencrypted.cs
UI/FormRegionPrivacyStatus.cs
UI/RibbonCustomizations.cs
     1.1 --- a/CryptableMailItem.cs	Wed Sep 07 18:23:04 2016 +0200
     1.2 +++ b/CryptableMailItem.cs	Wed Sep 07 22:31:02 2016 +0200
     1.3 @@ -857,7 +857,7 @@
     1.4          {
     1.5              _pEp_color result = _pEp_color.pEp_rating_undefined;
     1.6  
     1.7 -            Globals.LogVerbose("ProcessAndGetRating: Started.");
     1.8 +            Log.Verbose("ProcessAndGetRating: Started.");
     1.9  
    1.10              lock (mutexMailItem)
    1.11              {
    1.12 @@ -916,8 +916,8 @@
    1.13                              {
    1.14                                  decryptionList.Add(entryID, "");
    1.15                                  entryIDWasAdded = true;
    1.16 -                                Globals.LogVerbose("ProcessAndGetRating: Added EntryID to decryption list. " + entryID);
    1.17 -                                Globals.LogVerbose("ProcessAndGetRating: Active decryption count = " + decryptionList.Count.ToString());
    1.18 +                                Log.Verbose("ProcessAndGetRating: Added EntryID to decryption list. " + entryID);
    1.19 +                                Log.Verbose("ProcessAndGetRating: Active decryption count = " + decryptionList.Count.ToString());
    1.20                                  break;
    1.21                              }
    1.22                          }
    1.23 @@ -925,7 +925,7 @@
    1.24                          // Wait for the other thread to finish
    1.25                          if (isAlreadyBeingDecrypted)
    1.26                          {
    1.27 -                            Globals.LogVerbose("ProcessAndGetRating: Waiting for other decryption thread to finish. " + entryID);
    1.28 +                            Log.Verbose("ProcessAndGetRating: Waiting for other decryption thread to finish. " + entryID);
    1.29                              Thread.Sleep(sleepTime);
    1.30                              curWaitTime += sleepTime;
    1.31                          }
    1.32 @@ -937,11 +937,11 @@
    1.33                      // Log the issue unless the MailItem is an unsaved draft message
    1.34                      if (isDraft == false)
    1.35                      {
    1.36 -                        Globals.Log("ProcessAndGetRating: EntryID does not exist, unable to lock during decryption.");
    1.37 +                        Log.Warning("ProcessAndGetRating: EntryID does not exist, unable to lock during decryption.");
    1.38                      }
    1.39                      else
    1.40                      {
    1.41 -                        Globals.LogVerbose("ProcessAndGetRating: Could not add EntryID to decryption list lock because message is an unsaved draft.");
    1.42 +                        Log.Verbose("ProcessAndGetRating: Could not add EntryID to decryption list lock because message is an unsaved draft.");
    1.43                      }
    1.44                  }
    1.45  
    1.46 @@ -949,7 +949,7 @@
    1.47                  if ((isAlreadyBeingDecrypted) ||
    1.48                      (curWaitTime >= maxWaitTime))
    1.49                  {
    1.50 -                    Globals.Log("ProcessAndGetRating: Exited by timeout. " + (string.IsNullOrEmpty(entryID) ? "<no ID>" : entryID));
    1.51 +                    Log.Error("ProcessAndGetRating: Exited by timeout. " + (string.IsNullOrEmpty(entryID) ? "<no ID>" : entryID));
    1.52                      return (_pEp_color.pEp_rating_cannot_decrypt);
    1.53                  }
    1.54  
    1.55 @@ -966,7 +966,7 @@
    1.56                          // If the value was undefined, don't use it. Recalculation is needed.
    1.57                          if (result != _pEp_color.pEp_rating_undefined)
    1.58                          {
    1.59 -                            Globals.LogVerbose("ProcessAndGetRating: Mirror detected, using stored rating.");
    1.60 +                            Log.Verbose("ProcessAndGetRating: Mirror detected, using stored rating.");
    1.61                              specialCaseFound = true;
    1.62                          }
    1.63                      }
    1.64 @@ -980,7 +980,7 @@
    1.65                  if ((specialCaseFound == false) &&
    1.66                      (isDraft))
    1.67                  {
    1.68 -                    Globals.LogVerbose("ProcessAndGetRating: Draft detected, using outgoing rating.");
    1.69 +                    Log.Verbose("ProcessAndGetRating: Draft detected, using outgoing rating.");
    1.70  
    1.71                      result = this.OutgoingRating;
    1.72                      specialCaseFound = true;
    1.73 @@ -996,18 +996,18 @@
    1.74                      if (CryptableMailItem.GetIsInSecureStore(this.internalMailItem) ||
    1.75                          CryptableMailItem.GetIsNeverUnsecure(this.internalMailItem))
    1.76                      {
    1.77 -                        Globals.LogVerbose("ProcessAndGetRating: In encrypted store or marked never unsecure.");
    1.78 +                        Log.Verbose("ProcessAndGetRating: In encrypted store or marked never unsecure.");
    1.79  
    1.80                          // Sent Folder
    1.81                          if (CryptableMailItem.GetIsInSentFolder(this.internalMailItem))
    1.82                          {
    1.83 -                            Globals.LogVerbose("ProcessAndGetRating: In sent folder.");
    1.84 +                            Log.Verbose("ProcessAndGetRating: In sent folder.");
    1.85  
    1.86                              // Encrypted mail in an encrypted (untrusted store) or marked never unsecure
    1.87                              // This will use a mirror
    1.88                              if (PEPMessage.GetIsEncrypted(this.internalMailItem))
    1.89                              {
    1.90 -                                Globals.LogVerbose("ProcessAndGetRating: Is encrypted.");
    1.91 +                                Log.Verbose("ProcessAndGetRating: Is encrypted.");
    1.92  
    1.93                                  mirror = CryptableMailItem.FindMirrorOMI(this.internalMailItem);
    1.94  
    1.95 @@ -1015,7 +1015,7 @@
    1.96                                  {
    1.97                                      if (sts == Globals.ReturnStatus.Success)
    1.98                                      {
    1.99 -                                        Globals.LogVerbose("ProcessAndGetRating: Mirror not found, creating and decrypting.");
   1.100 +                                        Log.Verbose("ProcessAndGetRating: Mirror not found, creating and decrypting.");
   1.101  
   1.102                                          tRating = msgProcessor.Decrypt(internalMessage, out newMessage, out decryptionKeylist);
   1.103                                          tRating2 = this.OutgoingRating;
   1.104 @@ -1027,7 +1027,7 @@
   1.105                                          {
   1.106                                              // Do nothing, decryption failed
   1.107                                              this._LastProcessingStatus = Globals.ReturnStatus.Failure;
   1.108 -                                            Globals.Log("ProcessAndGetRating: Decryption failed, " + tRating.ToString());
   1.109 +                                            Log.Error("ProcessAndGetRating: Decryption failed, " + tRating.ToString());
   1.110                                          }
   1.111                                          else
   1.112                                          {
   1.113 @@ -1053,7 +1053,7 @@
   1.114                                  {
   1.115                                      if (sts == Globals.ReturnStatus.Success)
   1.116                                      {
   1.117 -                                        Globals.LogVerbose("ProcessAndGetRating: Mirror found.");
   1.118 +                                        Log.Verbose("ProcessAndGetRating: Mirror found.");
   1.119  
   1.120                                          tRating = CryptableMailItem.GetStoredRating(mirror);
   1.121  
   1.122 @@ -1084,20 +1084,20 @@
   1.123                              // This does not have a mirror
   1.124                              else
   1.125                              {
   1.126 -                                Globals.LogVerbose("ProcessAndGetRating: Is unencrypted.");
   1.127 +                                Log.Verbose("ProcessAndGetRating: Is unencrypted.");
   1.128                                  result = _pEp_color.pEp_rating_unencrypted;
   1.129                              }
   1.130                          }
   1.131                          // Incoming
   1.132                          else if (CryptableMailItem.GetIsIncoming(this.internalMailItem))
   1.133                          {
   1.134 -                            Globals.LogVerbose("ProcessAndGetRating: Is incoming.");
   1.135 +                            Log.Verbose("ProcessAndGetRating: Is incoming.");
   1.136  
   1.137                              // Encrypted mail in an encrypted (untrusted store) or marked never unsecure
   1.138                              // This will use a mirror
   1.139                              if (PEPMessage.GetIsEncrypted(this.internalMailItem))
   1.140                              {
   1.141 -                                Globals.LogVerbose("ProcessAndGetRating: Is encrypted.");
   1.142 +                                Log.Verbose("ProcessAndGetRating: Is encrypted.");
   1.143  
   1.144                                  mirror = CryptableMailItem.FindMirrorOMI(this.internalMailItem);
   1.145  
   1.146 @@ -1105,7 +1105,7 @@
   1.147                                  {
   1.148                                      if (sts == Globals.ReturnStatus.Success)
   1.149                                      {
   1.150 -                                        Globals.LogVerbose("ProcessAndGetRating: Mirror not found, creating and decrypting.");
   1.151 +                                        Log.Verbose("ProcessAndGetRating: Mirror not found, creating and decrypting.");
   1.152  
   1.153                                          tRating = msgProcessor.Decrypt(internalMessage, out newMessage, out decryptionKeylist);
   1.154  
   1.155 @@ -1116,7 +1116,7 @@
   1.156                                          {
   1.157                                              // Do nothing, decryption failed
   1.158                                              this._LastProcessingStatus = Globals.ReturnStatus.Failure;
   1.159 -                                            Globals.Log("ProcessAndGetRating: Decryption failed, " + tRating.ToString());
   1.160 +                                            Log.Error("ProcessAndGetRating: Decryption failed, " + tRating.ToString());
   1.161                                          }
   1.162                                          else
   1.163                                          {
   1.164 @@ -1142,7 +1142,7 @@
   1.165                                  {
   1.166                                      if (sts == Globals.ReturnStatus.Success)
   1.167                                      {
   1.168 -                                        Globals.LogVerbose("ProcessAndGetRating: Mirror found, decrypting to verify rating.");
   1.169 +                                        Log.Verbose("ProcessAndGetRating: Mirror found, decrypting to verify rating.");
   1.170  
   1.171                                          tRating = msgProcessor.Decrypt(internalMessage, out newMessage, out decryptionKeylist);
   1.172                                          tRating2 = CryptableMailItem.GetStoredRating(mirror);
   1.173 @@ -1174,7 +1174,7 @@
   1.174                              // This does not have a mirror
   1.175                              else
   1.176                              {
   1.177 -                                Globals.LogVerbose("ProcessAndGetRating: Is unencrypted.");
   1.178 +                                Log.Verbose("ProcessAndGetRating: Is unencrypted.");
   1.179                                  result = _pEp_color.pEp_rating_unencrypted;
   1.180  
   1.181                                  if (sts == Globals.ReturnStatus.Success)
   1.182 @@ -1189,19 +1189,19 @@
   1.183                          {
   1.184                              if (isDraft)
   1.185                              {
   1.186 -                                Globals.LogVerbose("ProcessAndGetRating: Is outgoing draft.");
   1.187 +                                Log.Verbose("ProcessAndGetRating: Is outgoing draft.");
   1.188                                  result = this.OutgoingRating;
   1.189                              }
   1.190                              // Sent but no longer in sent folder
   1.191                              else
   1.192                              {
   1.193 -                                Globals.LogVerbose("ProcessAndGetRating: Is outgoing (assumed previously sent).");
   1.194 +                                Log.Verbose("ProcessAndGetRating: Is outgoing (assumed previously sent).");
   1.195  
   1.196                                  // Encrypted mail in an encrypted (untrusted store) or marked never unsecure
   1.197                                  // This will use a mirror
   1.198                                  if (PEPMessage.GetIsEncrypted(this.internalMailItem))
   1.199                                  {
   1.200 -                                    Globals.LogVerbose("ProcessAndGetRating: Is encrypted.");
   1.201 +                                    Log.Verbose("ProcessAndGetRating: Is encrypted.");
   1.202  
   1.203                                      mirror = CryptableMailItem.FindMirrorOMI(this.internalMailItem);
   1.204  
   1.205 @@ -1209,7 +1209,7 @@
   1.206                                      {
   1.207                                          if (sts == Globals.ReturnStatus.Success)
   1.208                                          {
   1.209 -                                            Globals.LogVerbose("ProcessAndGetRating: Mirror not found, creating and decrypting.");
   1.210 +                                            Log.Verbose("ProcessAndGetRating: Mirror not found, creating and decrypting.");
   1.211  
   1.212                                              tRating = msgProcessor.Decrypt(internalMessage, out newMessage, out decryptionKeylist);
   1.213                                              tRating2 = this.OutgoingRating;
   1.214 @@ -1221,7 +1221,7 @@
   1.215                                              {
   1.216                                                  // Do nothing, decryption failed
   1.217                                                  this._LastProcessingStatus = Globals.ReturnStatus.Failure;
   1.218 -                                                Globals.Log("ProcessAndGetRating: Decryption failed, " + tRating.ToString());
   1.219 +                                                Log.Error("ProcessAndGetRating: Decryption failed, " + tRating.ToString());
   1.220                                              }
   1.221                                              else
   1.222                                              {
   1.223 @@ -1247,7 +1247,7 @@
   1.224                                      {
   1.225                                          if (sts == Globals.ReturnStatus.Success)
   1.226                                          {
   1.227 -                                            Globals.LogVerbose("ProcessAndGetRating: Mirror found.");
   1.228 +                                            Log.Verbose("ProcessAndGetRating: Mirror found.");
   1.229  
   1.230                                              tRating = CryptableMailItem.GetStoredRating(mirror);
   1.231  
   1.232 @@ -1278,7 +1278,7 @@
   1.233                                  // This does not have a mirror
   1.234                                  else
   1.235                                  {
   1.236 -                                    Globals.LogVerbose("ProcessAndGetRating: Is unencrypted.");
   1.237 +                                    Log.Verbose("ProcessAndGetRating: Is unencrypted.");
   1.238                                      result = _pEp_color.pEp_rating_unencrypted;
   1.239                                  }
   1.240                              }
   1.241 @@ -1287,17 +1287,17 @@
   1.242                      // Unencrypted (trusted) store
   1.243                      else
   1.244                      {
   1.245 -                        Globals.LogVerbose("ProcessAndGetRating: In unencrypted store.");
   1.246 +                        Log.Verbose("ProcessAndGetRating: In unencrypted store.");
   1.247  
   1.248                          // Sent Folder
   1.249                          if (CryptableMailItem.GetIsInSentFolder(this.internalMailItem))
   1.250                          {
   1.251 -                            Globals.LogVerbose("ProcessAndGetRating: In sent folder.");
   1.252 +                            Log.Verbose("ProcessAndGetRating: In sent folder.");
   1.253  
   1.254                              // Encrypted mail in an unencrypted (trusted store)
   1.255                              if (PEPMessage.GetIsEncrypted(this.internalMailItem))
   1.256                              {
   1.257 -                                Globals.LogVerbose("ProcessAndGetRating: Is encrypted.");
   1.258 +                                Log.Verbose("ProcessAndGetRating: Is encrypted.");
   1.259  
   1.260                                  if (sts == Globals.ReturnStatus.Success)
   1.261                                  {
   1.262 @@ -1311,7 +1311,7 @@
   1.263                                      {
   1.264                                          // Do nothing, decryption failed
   1.265                                          this._LastProcessingStatus = Globals.ReturnStatus.Failure;
   1.266 -                                        Globals.Log("ProcessAndGetRating: Decryption failed, " + tRating.ToString());
   1.267 +                                        Log.Error("ProcessAndGetRating: Decryption failed, " + tRating.ToString());
   1.268                                      }
   1.269                                      else
   1.270                                      {
   1.271 @@ -1335,7 +1335,7 @@
   1.272                              // Unencrypted mail in an unencrypted (trusted store)
   1.273                              else
   1.274                              {
   1.275 -                                Globals.LogVerbose("ProcessAndGetRating: Is unencrypted.");
   1.276 +                                Log.Verbose("ProcessAndGetRating: Is unencrypted.");
   1.277  
   1.278                                  tRating = CryptableMailItem.GetStoredRating(this.internalMailItem);
   1.279  
   1.280 @@ -1354,12 +1354,12 @@
   1.281                          // Incoming
   1.282                          else if (CryptableMailItem.GetIsIncoming(this.internalMailItem))
   1.283                          {
   1.284 -                            Globals.LogVerbose("ProcessAndGetRating: Is incoming.");
   1.285 +                            Log.Verbose("ProcessAndGetRating: Is incoming.");
   1.286  
   1.287                              // Encrypted mail in an unencrypted (trusted store)
   1.288                              if (PEPMessage.GetIsEncrypted(this.internalMailItem))
   1.289                              {
   1.290 -                                Globals.LogVerbose("ProcessAndGetRating: Is encrypted.");
   1.291 +                                Log.Verbose("ProcessAndGetRating: Is encrypted.");
   1.292  
   1.293                                  if (sts == Globals.ReturnStatus.Success)
   1.294                                  {
   1.295 @@ -1372,7 +1372,7 @@
   1.296                                      {
   1.297                                          // Do nothing, decryption failed
   1.298                                          this._LastProcessingStatus = Globals.ReturnStatus.Failure;
   1.299 -                                        Globals.Log("ProcessAndGetRating: Decryption failed, " + tRating.ToString());
   1.300 +                                        Log.Error("ProcessAndGetRating: Decryption failed, " + tRating.ToString());
   1.301                                      }
   1.302                                      else
   1.303                                      {
   1.304 @@ -1396,7 +1396,7 @@
   1.305                              // Unencrypted mail in an unencrypted (trusted store)
   1.306                              else
   1.307                              {
   1.308 -                                Globals.LogVerbose("ProcessAndGetRating: Is unencrypted.");
   1.309 +                                Log.Verbose("ProcessAndGetRating: Is unencrypted.");
   1.310  
   1.311                                  result = CryptableMailItem.GetStoredRating(this.internalMailItem);
   1.312  
   1.313 @@ -1418,18 +1418,18 @@
   1.314                          {
   1.315                              if (isDraft)
   1.316                              {
   1.317 -                                Globals.LogVerbose("ProcessAndGetRating: Is outgoing draft.");
   1.318 +                                Log.Verbose("ProcessAndGetRating: Is outgoing draft.");
   1.319                                  result = this.OutgoingRating;
   1.320                              }
   1.321                              // Sent but no longer in sent folder
   1.322                              else
   1.323                              {
   1.324 -                                Globals.LogVerbose("ProcessAndGetRating: Is outgoing (assumed previously sent).");
   1.325 +                                Log.Verbose("ProcessAndGetRating: Is outgoing (assumed previously sent).");
   1.326  
   1.327                                  // Encrypted mail in an unencrypted (trusted store)
   1.328                                  if (PEPMessage.GetIsEncrypted(this.internalMailItem))
   1.329                                  {
   1.330 -                                    Globals.LogVerbose("ProcessAndGetRating: Is encrypted.");
   1.331 +                                    Log.Verbose("ProcessAndGetRating: Is encrypted.");
   1.332  
   1.333                                      if (sts == Globals.ReturnStatus.Success)
   1.334                                      {
   1.335 @@ -1443,7 +1443,7 @@
   1.336                                          {
   1.337                                              // Do nothing, decryption failed
   1.338                                              this._LastProcessingStatus = Globals.ReturnStatus.Failure;
   1.339 -                                            Globals.Log("ProcessAndGetRating: Decryption failed, " + tRating.ToString());
   1.340 +                                            Log.Error("ProcessAndGetRating: Decryption failed, " + tRating.ToString());
   1.341                                          }
   1.342                                          else
   1.343                                          {
   1.344 @@ -1467,7 +1467,7 @@
   1.345                                  // Unencrypted mail in an unencrypted (trusted store)
   1.346                                  else
   1.347                                  {
   1.348 -                                    Globals.LogVerbose("ProcessAndGetRating: Is unencrypted.");
   1.349 +                                    Log.Verbose("ProcessAndGetRating: Is unencrypted.");
   1.350  
   1.351                                      tRating = CryptableMailItem.GetStoredRating(this.internalMailItem);
   1.352  
   1.353 @@ -1508,20 +1508,20 @@
   1.354                          try
   1.355                          {
   1.356                              decryptionList.Remove(entryID);
   1.357 -                            Globals.LogVerbose("ProcessAndGetRating: Removed EntryID from decryption list. " +
   1.358 +                            Log.Verbose("ProcessAndGetRating: Removed EntryID from decryption list. " +
   1.359                                                 (string.IsNullOrEmpty(entryID) ? "<no ID>" : entryID));
   1.360                          }
   1.361                          catch
   1.362                          {
   1.363 -                            Globals.Log("ProcessAndGetRating: Error removing EntryID from decryption list.");
   1.364 +                            Log.Error("ProcessAndGetRating: Error removing EntryID from decryption list.");
   1.365                          }
   1.366                      }
   1.367  
   1.368 -                    Globals.LogVerbose("ProcessAndGetRating: Active decryption count = " + decryptionList.Count.ToString());
   1.369 +                    Log.Verbose("ProcessAndGetRating: Active decryption count = " + decryptionList.Count.ToString());
   1.370                  }
   1.371              }
   1.372  
   1.373 -            Globals.LogVerbose("ProcessAndGetRating: Completed.");
   1.374 +            Log.Verbose("ProcessAndGetRating: Completed.");
   1.375  
   1.376              return (result);
   1.377          }
   1.378 @@ -1625,7 +1625,7 @@
   1.379              }
   1.380              catch (Exception ex)
   1.381              {
   1.382 -                Globals.Log("MirrorLocator_DoWork: Failed to find mirror OMI, " + ex.ToString());
   1.383 +                Log.Error("MirrorLocator_DoWork: Failed to find mirror OMI, " + ex.ToString());
   1.384              }
   1.385              finally
   1.386              {
   1.387 @@ -1725,7 +1725,7 @@
   1.388                  }
   1.389                  catch (Exception ex)
   1.390                  {
   1.391 -                    Globals.Log("ResolveAllRecipients: exception " + ex.ToString());
   1.392 +                    Log.Error("ResolveAllRecipients: exception " + ex.ToString());
   1.393                  }
   1.394              }
   1.395  
   1.396 @@ -1795,12 +1795,12 @@
   1.397  
   1.398                  if (itemAdded == false)
   1.399                  {
   1.400 -                    Globals.Log("AddToEncryptedConversationCache: Cannot add item.");
   1.401 +                    Log.Warning("AddToEncryptedConversationCache: Cannot add item.");
   1.402                  }
   1.403              }
   1.404              else
   1.405              {
   1.406 -                Globals.Log("AddToEncryptedConversationCache: Cannot add null item.");
   1.407 +                Log.Error("AddToEncryptedConversationCache: Cannot add null item.");
   1.408              }
   1.409  
   1.410              return;
   1.411 @@ -1867,7 +1867,7 @@
   1.412              }
   1.413              else
   1.414              {
   1.415 -                Globals.Log("SetIsOriginallyEncryptedByCache: Cannot set for null item.");
   1.416 +                Log.Error("SetIsOriginallyEncryptedByCache: Cannot set for null item.");
   1.417              }
   1.418  
   1.419              return (isEncrypted);
   1.420 @@ -1891,7 +1891,7 @@
   1.421              {
   1.422                  try
   1.423                  {
   1.424 -                    Globals.LogVerbose("CreateMirrorOMI: Creating by copy.");
   1.425 +                    Log.Verbose("CreateMirrorOMI: Creating by copy.");
   1.426  
   1.427                      /* Attempt to first create the mirror by copying
   1.428                       * Depending on account types, anything after Office 2010 can have the following error:
   1.429 @@ -1954,7 +1954,7 @@
   1.430                  }
   1.431                  catch
   1.432                  {
   1.433 -                    Globals.LogVerbose("CreateMirrorOMI: Creating by copy failed.");
   1.434 +                    Log.Verbose("CreateMirrorOMI: Creating by copy failed.");
   1.435                  }
   1.436              }
   1.437  
   1.438 @@ -1962,7 +1962,7 @@
   1.439              {
   1.440                  try
   1.441                  {
   1.442 -                    Globals.LogVerbose("CreateMirrorOMI: Creating by new mail item.");
   1.443 +                    Log.Verbose("CreateMirrorOMI: Creating by new mail item.");
   1.444  
   1.445                      // Release any partially created omi from a failed copy
   1.446                      if (omi != null)
   1.447 @@ -2087,7 +2087,7 @@
   1.448                  }
   1.449                  catch
   1.450                  {
   1.451 -                    Globals.LogVerbose("CreateMirrorOMI: Creating by new mail item failed.");
   1.452 +                    Log.Verbose("CreateMirrorOMI: Creating by new mail item failed.");
   1.453                  }
   1.454              }
   1.455  
   1.456 @@ -2381,7 +2381,7 @@
   1.457              }
   1.458              catch
   1.459              {
   1.460 -                Globals.Log("GetIsInSecureStore: failure occured, returning default.");
   1.461 +                Log.Error("GetIsInSecureStore: failure occured, returning default.");
   1.462              }
   1.463              finally
   1.464              {
   1.465 @@ -2421,7 +2421,7 @@
   1.466              }
   1.467              catch
   1.468              {
   1.469 -                Globals.Log("GetIsInPEPEnabledStore: failure occured, returning default.");
   1.470 +                Log.Error("GetIsInPEPEnabledStore: failure occured, returning default.");
   1.471              }
   1.472              finally
   1.473              {
   1.474 @@ -2558,7 +2558,7 @@
   1.475              }
   1.476              catch
   1.477              {
   1.478 -                Globals.Log("GetIsInIMAPStore: failure occured, returning default false.");
   1.479 +                Log.Error("GetIsInIMAPStore: failure occured, returning default false.");
   1.480              }
   1.481              finally
   1.482              {
   1.483 @@ -2619,7 +2619,7 @@
   1.484              }
   1.485              else
   1.486              {
   1.487 -                Globals.Log("GetIsIncoming: Attempted to get for a null MailItem.");
   1.488 +                Log.Error("GetIsIncoming: Attempted to get for a null MailItem.");
   1.489              }
   1.490  
   1.491              return (result);
   1.492 @@ -2718,12 +2718,12 @@
   1.493              try
   1.494              {
   1.495                  folder = (Outlook.Folder)folders[username];
   1.496 -                Globals.LogVerbose("GetUnencryptedFolder: Using existing folder.");
   1.497 +                Log.Verbose("GetUnencryptedFolder: Using existing folder.");
   1.498              }
   1.499              catch
   1.500              {
   1.501                  folder = (Outlook.Folder)folders.Add(username);
   1.502 -                Globals.LogVerbose("GetUnencryptedFolder: Creating new folder.");
   1.503 +                Log.Verbose("GetUnencryptedFolder: Creating new folder.");
   1.504              }
   1.505  
   1.506              // Release objects
   1.507 @@ -3101,13 +3101,13 @@
   1.508                  }
   1.509                  else
   1.510                  {
   1.511 -                    Globals.Log("GetInterpretedProperty: Can't set for null MailItem or propertyName.");
   1.512 +                    Log.Error("GetInterpretedProperty: Can't set for null MailItem or propertyName.");
   1.513                  }
   1.514              }
   1.515              catch (Exception ex)
   1.516              {
   1.517                  success = false;
   1.518 -                Globals.Log("GetInterpretedProperty: An error occured: " + ex.ToString());
   1.519 +                Log.Error("GetInterpretedProperty: An error occured with " + (propertyName ?? "null") + ", " + ex.ToString());
   1.520              }
   1.521  
   1.522              value = outValue;
   1.523 @@ -3212,13 +3212,13 @@
   1.524                  }
   1.525                  else
   1.526                  {
   1.527 -                    Globals.Log("SetInterpretedProperty: Can't set for null MailItem or propertyName.");
   1.528 +                    Log.Error("SetInterpretedProperty: Can't set for null MailItem or propertyName.");
   1.529                  }
   1.530              }
   1.531              catch (Exception ex)
   1.532              {
   1.533                  success = false;
   1.534 -                Globals.Log("SetInterpretedProperty: An error occured: " + ex.ToString());
   1.535 +                Log.Error("SetInterpretedProperty: An error occured with " + (propertyName ?? "null") + ", " + ex.ToString());
   1.536              }
   1.537  
   1.538              return (success);
     2.1 --- a/Globals.cs	Wed Sep 07 18:23:04 2016 +0200
     2.2 +++ b/Globals.cs	Wed Sep 07 22:31:02 2016 +0200
     2.3 @@ -20,9 +20,6 @@
     2.4      internal sealed partial class Globals
     2.5      {
     2.6          public const string CUSTOM_SENT_FOLDER_NAME    = "Sent";
     2.7 -        public const string LOG_FILE_NAME              = "log.txt";
     2.8 -        public const int    LOG_LINES_TO_REPLACE       = 50;                              // The number of lines to replace when the log file gets cleaned up
     2.9 -        public const int    LOG_MAX_LINES              = 1000;                            // The maximum lines a log file can reach before the first lines get replaced (FIFO)
    2.10          public const string PEP_COPYRIGHT              = "Copyright © 2014-2016 p≡p Security SA, Luxembourg";
    2.11          public const string PEP_DATA_FILE_NAME         = "pEp";                           // The file name of the pEp data store. This does NOT include extension (.pst)
    2.12          public const string PEP_DISPLAY_NAME           = "p≡p for Outlook";               // Display name to the user
    2.13 @@ -76,9 +73,6 @@
    2.14          }
    2.15  
    2.16          private static bool               eventsAreConnected = false;
    2.17 -        private static int                logLineCount       = 0;
    2.18 -        private static StreamWriter       logWriter          = null;
    2.19 -        private static object             mutexLogFile       = new object();
    2.20          private static ResourceDictionary _ResourceDict      = null;
    2.21  
    2.22          /**************************************************************
    2.23 @@ -149,7 +143,7 @@
    2.24                  // Get log
    2.25                  try
    2.26                  {
    2.27 -                    log = string.Join(Environment.NewLine, Globals.ReadLogFile());
    2.28 +                    log = string.Join(Environment.NewLine, Log.Read());
    2.29                  }
    2.30                  catch
    2.31                  {
    2.32 @@ -251,7 +245,7 @@
    2.33              }
    2.34  
    2.35              // Stop logging
    2.36 -            Globals.CloseLogFile();
    2.37 +            Log.Close();
    2.38  
    2.39              // Locate the Outlook add-in
    2.40              comAddIns = Globals.ThisAddIn.Application.COMAddIns;
    2.41 @@ -301,25 +295,6 @@
    2.42          }
    2.43  
    2.44          /// <summary>
    2.45 -        /// Adds the given text to the pEp for Outlook log.
    2.46 -        /// </summary>
    2.47 -        /// <param name="text">The text to add to the log.</param>
    2.48 -        public static void Log(string text)
    2.49 -        {
    2.50 -            pEp.Log.Info(text);
    2.51 -        }
    2.52 -
    2.53 -        /// <summary>
    2.54 -        /// Adds the given verbose text to the pEp for Outlook log only
    2.55 -        /// when verbose logging is enabled.
    2.56 -        /// </summary>
    2.57 -        /// <param name="text">The verbose text to add to the lob.</param>
    2.58 -        public static void LogVerbose(string text)
    2.59 -        {
    2.60 -            pEp.Log.Verbose(text);
    2.61 -        }
    2.62 -
    2.63 -        /// <summary>
    2.64          /// Gets the current system information string.
    2.65          /// </summary>
    2.66          /// <returns>The system information as a string.</returns>
    2.67 @@ -402,41 +377,6 @@
    2.68          }
    2.69  
    2.70          /// <summary>
    2.71 -        /// Reads all lines of text from the log file.
    2.72 -        /// This will never return null.
    2.73 -        /// </summary>
    2.74 -        /// <returns>The lines of text in the log file.</returns>
    2.75 -        public static string ReadLogFile()
    2.76 -        {
    2.77 -            return pEp.Log.Read();
    2.78 -        }
    2.79 -
    2.80 -        /// <summary>
    2.81 -        /// Closes and releases any open log file writer.
    2.82 -        /// </summary>
    2.83 -        public static void CloseLogFile()
    2.84 -        {
    2.85 -            pEp.Log.Close();
    2.86 -        }
    2.87 -
    2.88 -        /// <summary>
    2.89 -        /// Clears all logged text by deleting the file.
    2.90 -        /// </summary>
    2.91 -        public static void ClearLogFile()
    2.92 -        {
    2.93 -            pEp.Log.Clear();
    2.94 -        }
    2.95 -
    2.96 -        /// <summary>
    2.97 -        /// Gets the path of the log file.
    2.98 -        /// </summary>
    2.99 -        /// <returns>The path of the log file.</returns>
   2.100 -        private static string GetLogFilePath()
   2.101 -        {
   2.102 -            return (Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "pEp", LOG_FILE_NAME));
   2.103 -        }
   2.104 -
   2.105 -        /// <summary>
   2.106          /// Gets the path of the GPA .exe using the install directory from the registry.
   2.107          /// WARNING: this method can return a null path.
   2.108          /// </summary>
   2.109 @@ -459,7 +399,7 @@
   2.110              {
   2.111                  // As I do not expext any exceptions to actually appear at this level,
   2.112                  // we log them (even in non-verbose level).
   2.113 -                Globals.Log("GetGpaPath: " + ex.Message);
   2.114 +                Log.Error("GetGpaPath: " + ex.Message);
   2.115              }
   2.116  
   2.117              return null;
   2.118 @@ -488,12 +428,12 @@
   2.119  
   2.120              // Use backup hardcoded directory locations as fallbacks. However, we log this issue
   2.121              // as it is not expected (broken installation?)
   2.122 -            Globals.Log("TryToGuessGpgPathes: Not found in registry, trying backup hard-coded directory pathes.");
   2.123 +            Log.Warning("TryToGuessGpgPathes: Not found in registry, trying backup hard-coded directory pathes.");
   2.124  
   2.125 -            yield return System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
   2.126 +            yield return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
   2.127                  "GNU", "GnuPG");
   2.128  
   2.129 -            yield return System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
   2.130 +            yield return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
   2.131                  "GNU", "GnuPG");
   2.132          }
   2.133  
   2.134 @@ -512,7 +452,7 @@
   2.135              {
   2.136                  // Exceptions here are expected (the key does not exist in the view we currently 
   2.137                  // tried), thus we only long them in verbose mode.
   2.138 -                Globals.LogVerbose("TryToReadGpgPathFromRegistry: " + ex.Message);
   2.139 +                Log.Verbose("TryToReadGpgPathFromRegistry: " + ex.Message);
   2.140                  return null;
   2.141              }
   2.142          }
     3.1 --- a/Log.cs	Wed Sep 07 18:23:04 2016 +0200
     3.2 +++ b/Log.cs	Wed Sep 07 22:31:02 2016 +0200
     3.3 @@ -8,13 +8,13 @@
     3.4      /// </summary>
     3.5      internal class Log
     3.6      {
     3.7 -        public const string LOG_FILE_NAME              = "log.txt";
     3.8 -        public const int    LOG_LINES_TO_REPLACE       = 50;                              // The number of lines to replace when the log file gets cleaned up
     3.9 -        public const int    LOG_MAX_LINES              = 1000;                            // The maximum lines a log file can reach before the first lines get replaced (FIFO)
    3.10 +        public const string LOG_FILE_NAME        = "log.txt";
    3.11 +        public const int    LOG_LINES_TO_REPLACE = 50;        // The number of lines to replace when the log file gets cleaned up
    3.12 +        public const int    LOG_MAX_LINES        = 1000;      // The maximum lines a log file can reach before the first lines get replaced (FIFO)
    3.13  
    3.14 -        private static int                logLineCount       = 0;
    3.15 -        private static StreamWriter       logWriter          = null;
    3.16 -        private static object             mutexLogFile       = new object();
    3.17 +        private static int          logLineCount = 0;
    3.18 +        private static StreamWriter logWriter    = null;
    3.19 +        private static object       mutexLogFile = new object();
    3.20  
    3.21          /**************************************************************
    3.22           * 
    3.23 @@ -39,7 +39,7 @@
    3.24          {
    3.25              if (text != null)
    3.26              {
    3.27 -                Log.Write(System.DateTime.Now.ToString("HH:mm:ss.fff") + " | " + text);
    3.28 +                Log.Write(DateTime.Now.ToString("HH:mm:ss.fff") + " | " + text);
    3.29              }
    3.30              return;
    3.31          }
    3.32 @@ -52,7 +52,7 @@
    3.33          {
    3.34              if (text != null)
    3.35              {
    3.36 -                Log.Write(System.DateTime.Now.ToString("HH:mm:ss.fff") + " |E| " + text);
    3.37 +                Log.Write(DateTime.Now.ToString("HH:mm:ss.fff") + " |E| " + text);
    3.38              }
    3.39              return;
    3.40          }
    3.41 @@ -65,7 +65,7 @@
    3.42          {
    3.43              if (text != null)
    3.44              {
    3.45 -                Log.Write(System.DateTime.Now.ToString("HH:mm:ss.fff") + " |W| " + text);
    3.46 +                Log.Write(DateTime.Now.ToString("HH:mm:ss.fff") + " |W| " + text);
    3.47              }
    3.48              return;
    3.49          }
    3.50 @@ -81,7 +81,7 @@
    3.51                  (Globals.ThisAddIn != null) &&
    3.52                  (Globals.ThisAddIn.Settings.IsVerboseLoggingEnabled))
    3.53              {
    3.54 -                Log.Write(System.DateTime.Now.ToString("HH:mm:ss.fff") + " |V| " + text);
    3.55 +                Log.Write(DateTime.Now.ToString("HH:mm:ss.fff") + " |V| " + text);
    3.56              }
    3.57              return;
    3.58          }
     4.1 --- a/MsgProcessor.cs	Wed Sep 07 18:23:04 2016 +0200
     4.2 +++ b/MsgProcessor.cs	Wed Sep 07 22:31:02 2016 +0200
     4.3 @@ -100,7 +100,7 @@
     4.4              List<PEPMessage> bccMessages = new List<PEPMessage>();
     4.5              Globals.ReturnStatus status = Globals.ReturnStatus.Success;
     4.6  
     4.7 -            Globals.LogVerbose("ProcessSentMessage: Started");
     4.8 +            Log.Verbose("ProcessSentMessage: Started");
     4.9  
    4.10              // Force the working message to outgoing direction.
    4.11              // This protects mostly for outgoing rating calculation which requires it.
    4.12 @@ -108,7 +108,7 @@
    4.13              if (workingMessage.Direction == _pEp_msg_direction.pEp_dir_incoming)
    4.14              {
    4.15                  workingMessage.Direction = _pEp_msg_direction.pEp_dir_outgoing;
    4.16 -                Globals.Log("ProcessSentMessage: Message direction set to outgoing (was incorrectly incoming).");
    4.17 +                Log.Warning("ProcessSentMessage: Message direction set to outgoing (was incorrectly incoming).");
    4.18              }
    4.19  
    4.20              // Set stored sent message rating to outgoing rating
    4.21 @@ -120,7 +120,7 @@
    4.22              //  This updates workingMessage
    4.23              ///////////////////////////////////////////////////////////
    4.24  
    4.25 -            Globals.LogVerbose("ProcessSentMessage: Processing CIDs and flattening recipients.");
    4.26 +            Log.Verbose("ProcessSentMessage: Processing CIDs and flattening recipients.");
    4.27  
    4.28              workingMessage.NormalizeContentIDs();
    4.29              workingMessage.FlattenAllRecipientIdentities();
    4.30 @@ -130,7 +130,7 @@
    4.31              //  This uses the encrypted/unencrypted messages
    4.32              ///////////////////////////////////////////////////////////
    4.33  
    4.34 -            Globals.LogVerbose("ProcessSentMessage: Processing send unencrypted by identity.");
    4.35 +            Log.Verbose("ProcessSentMessage: Processing send unencrypted by identity.");
    4.36  
    4.37              // BCC
    4.38              for (int i = 0; i < workingMessage.BCC.Count; i++)
    4.39 @@ -234,7 +234,7 @@
    4.40              //  This uses the encrypted messages
    4.41              ///////////////////////////////////////////////////////////
    4.42  
    4.43 -            Globals.LogVerbose("ProcessSentMessage: Processing BCC");
    4.44 +            Log.Verbose("ProcessSentMessage: Processing BCC");
    4.45  
    4.46              // Remove any encrypted messages with BCC for special processing
    4.47              for (int i = 0; i < encryptedMessages.Count; i++)
    4.48 @@ -326,7 +326,7 @@
    4.49              // Encrypt
    4.50              ///////////////////////////////////////////////////////////
    4.51  
    4.52 -            Globals.LogVerbose("ProcessSentMessage: Encrypting messages, count=" + encryptedMessages.Count.ToString());
    4.53 +            Log.Verbose("ProcessSentMessage: Encrypting messages, count=" + encryptedMessages.Count.ToString());
    4.54  
    4.55              for (int i = 0; i < encryptedMessages.Count; i++)
    4.56              {
    4.57 @@ -351,13 +351,13 @@
    4.58                           (newMessage.IsEncrypted == false)))
    4.59                      {
    4.60                          status = Globals.ReturnStatus.Failure;
    4.61 -                        Globals.Log("ProcessSentMessage: Message encryption failed or doesn't match outgoing rating.");
    4.62 +                        Log.Error("ProcessSentMessage: Message encryption failed or doesn't match outgoing rating.");
    4.63                      }
    4.64                  }
    4.65                  catch (Exception ex)
    4.66                  {
    4.67                      status = Globals.ReturnStatus.Failure;
    4.68 -                    Globals.Log("ProcessSentMessage: Message encryption failed, " + ex.ToString());
    4.69 +                    Log.Error("ProcessSentMessage: Message encryption failed, " + ex.ToString());
    4.70                  }
    4.71              }
    4.72  
    4.73 @@ -365,7 +365,7 @@
    4.74              // Create the saved sent message
    4.75              ///////////////////////////////////////////////////////////
    4.76  
    4.77 -            Globals.LogVerbose("ProcessSentMessage: Creating saved sent message.");
    4.78 +            Log.Verbose("ProcessSentMessage: Creating saved sent message.");
    4.79  
    4.80              if (isInEncryptedStore)
    4.81              {
    4.82 @@ -388,7 +388,7 @@
    4.83                      if (result == false)
    4.84                      {
    4.85                          status = Globals.ReturnStatus.Failure;
    4.86 -                        Globals.Log("ProcessSentMessage: Encryption of saved sent message failed.");
    4.87 +                        Log.Error("ProcessSentMessage: Encryption of saved sent message failed.");
    4.88                      }
    4.89                  }
    4.90              }
    4.91 @@ -402,11 +402,11 @@
    4.92              outSavedSentMessage = savedSentMessage;
    4.93              outSavedSentMessageStoredRating = savedSentMessageStoredRating;
    4.94  
    4.95 -            Globals.LogVerbose("ProcessSentMessage: Encrypted Count=" + outEncryptedMessages.Length.ToString() +
    4.96 +            Log.Verbose("ProcessSentMessage: Encrypted Count=" + outEncryptedMessages.Length.ToString() +
    4.97                                 " Unencrypted Count=" + outUnencryptedMessages.Length.ToString());
    4.98 -            Globals.LogVerbose("ProcessSentMessage: Completed.");
    4.99 +            Log.Verbose("ProcessSentMessage: Completed.");
   4.100  
   4.101 -            Globals.LogVerbose("ProcessSentMessage: ReturnStatus=" + status.ToString());
   4.102 +            Log.Verbose("ProcessSentMessage: ReturnStatus=" + status.ToString());
   4.103              return (status);
   4.104          }
   4.105  
   4.106 @@ -424,7 +424,7 @@
   4.107              _pEp_color contactRating = _pEp_color.pEp_rating_undefined;
   4.108              _pEp_color engineRating = _pEp_color.pEp_rating_undefined;
   4.109  
   4.110 -            Globals.LogVerbose("GetOutgoingRating: Started.");
   4.111 +            Log.Verbose("GetOutgoingRating: Started.");
   4.112  
   4.113              if (message != null)
   4.114              {
   4.115 @@ -443,12 +443,12 @@
   4.116                      catch (COMException ex)
   4.117                      {
   4.118                          engineRating = _pEp_color.pEp_rating_undefined;
   4.119 -                        Globals.Log("GetOutgoingRating: engine rating undefined due to error, " + ex.ToString());
   4.120 +                        Log.Error("GetOutgoingRating: engine rating undefined due to error, " + ex.ToString());
   4.121                      }
   4.122                      catch (Exception ex)
   4.123                      {
   4.124                          engineRating = _pEp_color.pEp_rating_undefined;
   4.125 -                        Globals.Log("GetOutgoingRating: engine rating undefined due to error, " + ex.ToString());
   4.126 +                        Log.Error("GetOutgoingRating: engine rating undefined due to error, " + ex.ToString());
   4.127                      }
   4.128                  }
   4.129  
   4.130 @@ -475,7 +475,7 @@
   4.131                  }
   4.132              }
   4.133  
   4.134 -            Globals.LogVerbose("GetOutgoingRating: Completed.");
   4.135 +            Log.Verbose("GetOutgoingRating: Completed.");
   4.136  
   4.137              return (rating);
   4.138          }
   4.139 @@ -557,7 +557,7 @@
   4.140              _pEp_color rating = _pEp_color.pEp_rating_cannot_decrypt;
   4.141              Globals.ReturnStatus sts;
   4.142  
   4.143 -            Globals.LogVerbose("Decrypt: Started.");
   4.144 +            Log.Verbose("Decrypt: Started.");
   4.145  
   4.146              if (sourceMessage != null)
   4.147              {
   4.148 @@ -570,15 +570,15 @@
   4.149                  }
   4.150                  catch (COMException ex)
   4.151                  {
   4.152 -                    Globals.Log("Decrypt: exception " + ex.ToString());
   4.153                      rating = _pEp_color.pEp_rating_cannot_decrypt;
   4.154                      success = false;
   4.155 +                    Log.Error("Decrypt: exception " + ex.ToString());
   4.156                  }
   4.157                  catch (Exception ex)
   4.158                  {
   4.159 -                    Globals.Log("Decrypt: exception " + ex.ToString());
   4.160                      rating = _pEp_color.pEp_rating_cannot_decrypt;
   4.161                      success = false;
   4.162 +                    Log.Error("Decrypt: exception " + ex.ToString());
   4.163                  }
   4.164              }
   4.165  
   4.166 @@ -598,7 +598,7 @@
   4.167                  decryptionKeyList = new string[0];
   4.168              }
   4.169  
   4.170 -            Globals.LogVerbose("Decrypt: Complete.");
   4.171 +            Log.Verbose("Decrypt: Complete.");
   4.172  
   4.173              return rating;
   4.174          }
   4.175 @@ -619,7 +619,7 @@
   4.176              text_message dst = new text_message();
   4.177              Globals.ReturnStatus sts;
   4.178  
   4.179 -            Globals.LogVerbose("Encrypt: Started.");
   4.180 +            Log.Verbose("Encrypt: Started.");
   4.181  
   4.182              if (sourceMessage != null)
   4.183              {
   4.184 @@ -632,12 +632,12 @@
   4.185                  }
   4.186                  catch (COMException ex)
   4.187                  {
   4.188 -                    Globals.Log("Encrypt: exception " + ex.ToString());
   4.189 +                    Log.Error("Encrypt: exception " + ex.ToString());
   4.190                      success = false;
   4.191                  }
   4.192                  catch (Exception ex)
   4.193                  {
   4.194 -                    Globals.Log("Encrypt: exception " + ex.ToString());
   4.195 +                    Log.Error("Encrypt: exception " + ex.ToString());
   4.196                      success = false;
   4.197                  }
   4.198              }
   4.199 @@ -656,7 +656,7 @@
   4.200                  destMessage = null;
   4.201              }
   4.202  
   4.203 -            Globals.LogVerbose("Encrypt: Complete.");
   4.204 +            Log.Verbose("Encrypt: Complete.");
   4.205  
   4.206              return (success);
   4.207          }
     5.1 --- a/PEPAttachment.cs	Wed Sep 07 18:23:04 2016 +0200
     5.2 +++ b/PEPAttachment.cs	Wed Sep 07 22:31:02 2016 +0200
     5.3 @@ -460,7 +460,7 @@
     5.4              }
     5.5              catch (Exception ex)
     5.6              {
     5.7 -                Globals.Log("Open: PEPAttachment failed, " + ex.ToString());
     5.8 +                Log.Error("Open: PEPAttachment failed, " + ex.ToString());
     5.9                  success = false;
    5.10              }
    5.11  
    5.12 @@ -496,7 +496,7 @@
    5.13              }
    5.14              catch (Exception ex)
    5.15              {
    5.16 -                Globals.Log("SaveAs: PEPAttachment failed, " + ex.ToString());
    5.17 +                Log.Error("SaveAs: PEPAttachment failed, " + ex.ToString());
    5.18                  success = false;
    5.19              }
    5.20  
    5.21 @@ -609,7 +609,7 @@
    5.22              {
    5.23                  case Outlook.OlAttachmentType.olByReference:
    5.24                      {
    5.25 -                        Globals.Log("PEPAttachment.GetData: olByReference attachment type is unsupported.");
    5.26 +                        Log.Error("PEPAttachment.GetData: olByReference attachment type is unsupported.");
    5.27                          break;
    5.28                      }
    5.29                  case Outlook.OlAttachmentType.olByValue:
    5.30 @@ -624,7 +624,7 @@
    5.31                           */
    5.32                          if (data == null)
    5.33                          {
    5.34 -                            Globals.LogVerbose("PEPAttachment.GetData: olByValue, PidTagAttachDataBinary returned null so trying backup method.");
    5.35 +                            Log.Verbose("PEPAttachment.GetData: olByValue, PidTagAttachDataBinary returned null so trying backup method.");
    5.36  
    5.37                              try
    5.38                              {
    5.39 @@ -635,7 +635,7 @@
    5.40                              catch (Exception ex)
    5.41                              {
    5.42                                  data = null;
    5.43 -                                Globals.Log("PEPAttachment.GetData: olByValue, backup method failed. " + ex.ToString());
    5.44 +                                Log.Error("PEPAttachment.GetData: olByValue, backup method failed. " + ex.ToString());
    5.45                              }
    5.46                              finally
    5.47                              {
    5.48 @@ -657,19 +657,19 @@
    5.49                      }
    5.50                  case Outlook.OlAttachmentType.olOLE:
    5.51                      {
    5.52 -                        Globals.Log("PEPAttachment.GetData: olOLE attachment type is unsupported.");
    5.53 +                        Log.Error("PEPAttachment.GetData: olOLE attachment type is unsupported.");
    5.54                          break;
    5.55                      }
    5.56                  default:
    5.57                      {
    5.58 -                        Globals.Log("PEPAttachment.GetData: Attachment type is unsupported.");
    5.59 +                        Log.Error("PEPAttachment.GetData: Attachment type is unsupported.");
    5.60                          break;
    5.61                      }
    5.62              }
    5.63  
    5.64              if (data == null)
    5.65              {
    5.66 -                Globals.Log("PEPAttachment.GetData: Null data detected.");
    5.67 +                Log.Error("PEPAttachment.GetData: Null data detected.");
    5.68              }
    5.69  
    5.70              return (data);
     6.1 --- a/PEPIdentity.cs	Wed Sep 07 18:23:04 2016 +0200
     6.2 +++ b/PEPIdentity.cs	Wed Sep 07 22:31:02 2016 +0200
     6.3 @@ -777,7 +777,7 @@
     6.4              catch (Exception ex)
     6.5              {
     6.6                  status = Globals.ReturnStatus.Failure;
     6.7 -                Globals.Log("GetOwnIdentity: Failure occured, " + ex.ToString());
     6.8 +                Log.Error("GetOwnIdentity: Failure occured, " + ex.ToString());
     6.9              }
    6.10              finally
    6.11              {
    6.12 @@ -886,7 +886,7 @@
    6.13              }
    6.14              catch (Exception ex)
    6.15              {
    6.16 -                Globals.Log("GetOwnAccount: Failure occured, " + ex.ToString());
    6.17 +                Log.Error("GetOwnAccount: Failure occured, " + ex.ToString());
    6.18              }
    6.19              finally
    6.20              {
    6.21 @@ -1043,7 +1043,7 @@
    6.22              catch (Exception ex)
    6.23              {
    6.24                  status = Globals.ReturnStatus.Failure;
    6.25 -                Globals.Log("GetOwnIdentity: Failure occured, " + ex.ToString());
    6.26 +                Log.Error("GetOwnIdentity: Failure occured, " + ex.ToString());
    6.27              }
    6.28              finally
    6.29              {
    6.30 @@ -1153,7 +1153,7 @@
    6.31              catch (Exception ex)
    6.32              {
    6.33                  status = Globals.ReturnStatus.Failure;
    6.34 -                Globals.Log("GetFromUsername: Failure occured, " + ex.ToString());
    6.35 +                Log.Error("GetFromUsername: Failure occured, " + ex.ToString());
    6.36              }
    6.37              finally
    6.38              {
    6.39 @@ -1324,7 +1324,7 @@
    6.40              catch (Exception ex)
    6.41              {
    6.42                  status = Globals.ReturnStatus.Failure;
    6.43 -                Globals.Log("GetFromIdentity: Failure occured, " + ex.ToString());
    6.44 +                Log.Error("GetFromIdentity: Failure occured, " + ex.ToString());
    6.45              }
    6.46              finally
    6.47              {
    6.48 @@ -1384,7 +1384,7 @@
    6.49              catch (Exception ex)
    6.50              {
    6.51                  status = Globals.ReturnStatus.Failure;
    6.52 -                Globals.Log("GetDefaultFromIdentity: Failure occured, " + ex.ToString());
    6.53 +                Log.Error("GetDefaultFromIdentity: Failure occured, " + ex.ToString());
    6.54              }
    6.55              finally
    6.56              {
     7.1 --- a/PEPMessage.cs	Wed Sep 07 18:23:04 2016 +0200
     7.2 +++ b/PEPMessage.cs	Wed Sep 07 22:31:02 2016 +0200
     7.3 @@ -1121,7 +1121,7 @@
     7.4                      }
     7.5                      catch
     7.6                      {
     7.7 -                        Globals.Log("PEPMessage.ApplyTo: Failed to set the Sender.");
     7.8 +                        Log.Warning("PEPMessage.ApplyTo: Failed to set the Sender.");
     7.9                      }
    7.10  
    7.11                      //Remove the From recipient from the Recipients collection by searching for a match by EntryID
    7.12 @@ -1141,7 +1141,7 @@
    7.13                                  }
    7.14                                  catch
    7.15                                  {
    7.16 -                                    Globals.Log("PEPMessage.ApplyTo: Error removing 'From' recipient from Recipients collection.");
    7.17 +                                    Log.Warning("PEPMessage.ApplyTo: Error removing 'From' recipient from Recipients collection.");
    7.18                                  }
    7.19                                  break;
    7.20                              }
    7.21 @@ -1157,11 +1157,11 @@
    7.22                          try
    7.23                          {
    7.24                              recipients.Remove(recipients.Count);
    7.25 -                            Globals.Log("PEPMessage.ApplyTo: No EntryID match for 'From' recipient in Recipients collection. Removed using fallback solution.");
    7.26 +                            Log.Warning("PEPMessage.ApplyTo: No EntryID match for 'From' recipient in Recipients collection. Removed using fallback solution.");
    7.27                          }
    7.28                          catch
    7.29                          {
    7.30 -                            Globals.Log("PEPMessage.ApplyTo: No EntryID match for 'From' recipient in Recipients collection. Fallback solution also failed.");
    7.31 +                            Log.Error("PEPMessage.ApplyTo: No EntryID match for 'From' recipient in Recipients collection. Fallback solution also failed.");
    7.32                          }
    7.33                      }
    7.34  
    7.35 @@ -1173,7 +1173,7 @@
    7.36                      }
    7.37                      catch (Exception ex)
    7.38                      {
    7.39 -                        Globals.Log("PEPMessage.ApplyTo: Unable to set sender's name or email address via MAPIProperty. " + ex.Message);
    7.40 +                        Log.Warning("PEPMessage.ApplyTo: Unable to set sender's name or email address via MAPIProperty. " + ex.Message);
    7.41                      }
    7.42  
    7.43                      Marshal.ReleaseComObject(fromRecipient);
    7.44 @@ -1196,7 +1196,7 @@
    7.45                  }
    7.46                  catch
    7.47                  {
    7.48 -                    Globals.Log("PEPMessage.ApplyTo: Failed to set UTF-8 encoding.");
    7.49 +                    Log.Warning("PEPMessage.ApplyTo: Failed to set UTF-8 encoding.");
    7.50                  }
    7.51  
    7.52                  // Set the subject
    7.53 @@ -1286,7 +1286,7 @@
    7.54                  }
    7.55                  catch (Exception ex1)
    7.56                  {
    7.57 -                    Globals.Log("PEPMessage.ApplyTo: Failure setting conversation information. " + ex1.ToString());
    7.58 +                    Log.Warning("PEPMessage.ApplyTo: Failure setting conversation information. " + ex1.ToString());
    7.59                  }
    7.60  
    7.61                  /* Add internal properties
    7.62 @@ -1319,7 +1319,7 @@
    7.63              catch (Exception ex)
    7.64              {
    7.65                  status = Globals.ReturnStatus.Failure;
    7.66 -                Globals.Log("PEPMessage.ApplyTo: Failure occured, " + ex.ToString());
    7.67 +                Log.Error("PEPMessage.ApplyTo: Failure occured, " + ex.ToString());
    7.68              }
    7.69              finally
    7.70              {
    7.71 @@ -1567,7 +1567,7 @@
    7.72                      }
    7.73                      catch
    7.74                      {
    7.75 -                        Globals.Log("NormalizeContentIDs: Incorrect index detected when calculating CID position, skipping current img.");
    7.76 +                        Log.Warning("NormalizeContentIDs: Incorrect index detected when calculating CID position, skipping current img.");
    7.77  
    7.78                          // Likely System.ArgumentOutOfRangeException from incorrect index
    7.79                          // Just invalidate all locations and will not change this <img>
    7.80 @@ -1590,7 +1590,7 @@
    7.81                          }
    7.82                          catch
    7.83                          {
    7.84 -                            Globals.Log("NormalizeContentIDs: Error splitting HTML at CID, skipping current img.");
    7.85 +                            Log.Warning("NormalizeContentIDs: Error splitting HTML at CID, skipping current img.");
    7.86  
    7.87                              beginning = null;
    7.88                              ending = null;
    7.89 @@ -1627,7 +1627,7 @@
    7.90                      }
    7.91                      catch
    7.92                      {
    7.93 -                        Globals.Log("NormalizeContentIDs: Incorrect index detected, stopping calculation.");
    7.94 +                        Log.Warning("NormalizeContentIDs: Incorrect index detected, stopping calculation.");
    7.95  
    7.96                          // Likely System.ArgumentOutOfRangeException from incorrect index
    7.97                          // Stop processing the HTML and use whatever is processed up to this point
    7.98 @@ -1808,7 +1808,7 @@
    7.99              catch (Exception ex)
   7.100              {
   7.101                  status = Globals.ReturnStatus.Failure;
   7.102 -                Globals.Log("PEPMessage.Create: Failure occured, " + ex.ToString());
   7.103 +                Log.Error("PEPMessage.Create: Failure occured, " + ex.ToString());
   7.104              }
   7.105  
   7.106              createdMessage = newMessage;
   7.107 @@ -1851,7 +1851,7 @@
   7.108  
   7.109              try
   7.110              {
   7.111 -                Globals.LogVerbose("PEPMessage.Create: Creating new PEPMessage from OMI started, calculating recipients.");
   7.112 +                Log.Verbose("PEPMessage.Create: Creating new PEPMessage from OMI started, calculating recipients.");
   7.113  
   7.114                  /* Note: Skip the following properties which are not supported in the MailItem
   7.115                   *   • Direction
   7.116 @@ -1883,7 +1883,7 @@
   7.117                                          status = sts;
   7.118                                      }
   7.119  
   7.120 -                                    Globals.Log("PEPMessage.Create: Failure creating 'BCC' identity.");
   7.121 +                                    Log.Error("PEPMessage.Create: Failure creating 'BCC' identity.");
   7.122                                  }
   7.123  
   7.124                                  break;
   7.125 @@ -1903,7 +1903,7 @@
   7.126                                          status = sts;
   7.127                                      }
   7.128  
   7.129 -                                    Globals.Log("PEPMessage.Create: Failure creating 'CC' identity.");
   7.130 +                                    Log.Error("PEPMessage.Create: Failure creating 'CC' identity.");
   7.131                                  }
   7.132  
   7.133                                  break;
   7.134 @@ -1923,7 +1923,7 @@
   7.135                                          status = sts;
   7.136                                      }
   7.137  
   7.138 -                                    Globals.Log("PEPMessage.Create: Failure creating 'To' identity.");
   7.139 +                                    Log.Error("PEPMessage.Create: Failure creating 'To' identity.");
   7.140                                  }
   7.141  
   7.142                                  break;
   7.143 @@ -1934,7 +1934,7 @@
   7.144                      currRecipient = null;
   7.145                  }
   7.146  
   7.147 -                Globals.LogVerbose("PEPMessage.Create: Recipients calculated, calculating main properties.");
   7.148 +                Log.Verbose("PEPMessage.Create: Recipients calculated, calculating main properties.");
   7.149  
   7.150                  newMessage.Direction = CryptableMailItem.GetIsIncoming(omi) ? _pEp_msg_direction.pEp_dir_incoming : _pEp_msg_direction.pEp_dir_outgoing;
   7.151  
   7.152 @@ -1952,7 +1952,7 @@
   7.153                          status = sts;
   7.154                      }
   7.155  
   7.156 -                    Globals.Log("PEPMessage.Create: Failure creating 'From' identity.");
   7.157 +                    Log.Error("PEPMessage.Create: Failure creating 'From' identity.");
   7.158                  }
   7.159  
   7.160                  newMessage.ID = (string)MAPIHelper.GetProperty(omi, MAPIProperty.PidTagInternetMessageId, "");
   7.161 @@ -2017,7 +2017,7 @@
   7.162                                                           out propValue);
   7.163                  newMessage.PEPProtocolVersion = (string)propValue;
   7.164  
   7.165 -                Globals.LogVerbose("PEPMessage.Create: Main properties calculated, calculating body and attachments.");
   7.166 +                Log.Verbose("PEPMessage.Create: Main properties calculated, calculating body and attachments.");
   7.167  
   7.168                  // Calculate text body and attachments
   7.169                  if (createWithoutContent == false)
   7.170 @@ -2031,11 +2031,16 @@
   7.171                          try
   7.172                          {
   7.173                              rtfBody = omi.RTFBody;
   7.174 -                            newMessage.LongMsgFormattedRTF = Encoding.ASCII.GetString(rtfBody, 0, rtfBody.Length);
   7.175 +
   7.176 +                            if ((rtfBody != null) &&
   7.177 +                                (rtfBody.Length > 0))
   7.178 +                            {
   7.179 +                                newMessage.LongMsgFormattedRTF = Encoding.ASCII.GetString(rtfBody, 0, rtfBody.Length);
   7.180 +                            }
   7.181                          }
   7.182                          catch
   7.183                          {
   7.184 -                            Globals.Log("PEPMessage.Create: Unable to read RTF body in MailItem.");
   7.185 +                            Log.Warning("PEPMessage.Create: Unable to read RTF body in MailItem.");
   7.186                          }
   7.187  
   7.188                          // Force any rich text into HTML
   7.189 @@ -2090,17 +2095,17 @@
   7.190                          catch
   7.191                          {
   7.192                              newMessage.Keywords.Clear();
   7.193 -                            Globals.Log("PEPMessage.Create: Unable to set keywords.");
   7.194 +                            Log.Warning("PEPMessage.Create: Unable to set keywords.");
   7.195                          }
   7.196                      }
   7.197                  }
   7.198  
   7.199 -                Globals.LogVerbose("PEPMessage.Create: New PEPMessage created from OMI.");
   7.200 +                Log.Verbose("PEPMessage.Create: New PEPMessage created from OMI.");
   7.201              }
   7.202              catch (Exception ex)
   7.203              {
   7.204                  status = Globals.ReturnStatus.Failure;
   7.205 -                Globals.Log("PEPMessage.Create: failure occured, " + ex.ToString());
   7.206 +                Log.Error("PEPMessage.Create: failure occured, " + ex.ToString());
   7.207              }
   7.208              finally
   7.209              {
   7.210 @@ -2132,7 +2137,7 @@
   7.211  
   7.212              createdMessage = newMessage;
   7.213  
   7.214 -            Globals.LogVerbose("PEPMessage.Create: ReturnStatus=" + status.ToString());
   7.215 +            Log.Verbose("PEPMessage.Create: ReturnStatus=" + status.ToString());
   7.216              return (status);
   7.217          }
   7.218  
     8.1 --- a/PEPSettings.cs	Wed Sep 07 18:23:04 2016 +0200
     8.2 +++ b/PEPSettings.cs	Wed Sep 07 22:31:02 2016 +0200
     8.3 @@ -492,7 +492,7 @@
     8.4              }
     8.5              catch (Exception ex)
     8.6              {
     8.7 -                Globals.Log("SaveUpdaterConfigToRegistry: Failure occured, " + ex.ToString());
     8.8 +                Log.Error("SaveUpdaterConfigToRegistry: Failure occured, " + ex.ToString());
     8.9              }
    8.10  
    8.11              return;
    8.12 @@ -577,7 +577,7 @@
    8.13              }
    8.14              catch (Exception ex)
    8.15              {
    8.16 -                Globals.Log("SaveToRegistry: Failure occured, " + ex.ToString());
    8.17 +                Log.Error("SaveToRegistry: Failure occured, " + ex.ToString());
    8.18              }
    8.19  
    8.20              return;
    8.21 @@ -647,7 +647,7 @@
    8.22              }
    8.23              catch
    8.24              {
    8.25 -                Globals.Log("LoadFromRegistry: Failure occured reading TNEF disabled status");
    8.26 +                Log.Warning("LoadFromRegistry: Failure occured reading TNEF disabled status");
    8.27              }
    8.28              finally
    8.29              {
    8.30 @@ -751,7 +751,7 @@
    8.31                              }
    8.32                              catch
    8.33                              {
    8.34 -                                Globals.Log("LoadFromRegistry: Unable to fully read AccountSettingsList");
    8.35 +                                Log.Warning("LoadFromRegistry: Unable to fully read AccountSettingsList");
    8.36                              }
    8.37                              finally
    8.38                              {
    8.39 @@ -843,7 +843,7 @@
    8.40                              }
    8.41                              catch
    8.42                              {
    8.43 -                                Globals.Log("LoadFromRegistry: Unable to read AccountWhitelist");
    8.44 +                                Log.Warning("LoadFromRegistry: Unable to read AccountWhitelist");
    8.45                              }
    8.46                              finally
    8.47                              {
    8.48 @@ -873,7 +873,7 @@
    8.49                              }
    8.50                              catch
    8.51                              {
    8.52 -                                Globals.Log("LoadFromRegistry: Unable to read CrashReportSendAddress");
    8.53 +                                Log.Warning("LoadFromRegistry: Unable to read CrashReportSendAddress");
    8.54                              }
    8.55                              finally
    8.56                              {
    8.57 @@ -898,7 +898,7 @@
    8.58                              }
    8.59                              catch
    8.60                              {
    8.61 -                                Globals.Log("LoadFromRegistry: Unable to read ExtraKeys");
    8.62 +                                Log.Warning("LoadFromRegistry: Unable to read ExtraKeys");
    8.63                              }
    8.64                              finally
    8.65                              {
    8.66 @@ -925,7 +925,7 @@
    8.67                              }
    8.68                              catch
    8.69                              {
    8.70 -                                Globals.Log("LoadFromRegistry: Unable to read IsAutoUpdateEnabled");
    8.71 +                                Log.Warning("LoadFromRegistry: Unable to read IsAutoUpdateEnabled");
    8.72                              }
    8.73                              finally
    8.74                              {
    8.75 @@ -952,7 +952,7 @@
    8.76                              }
    8.77                              catch
    8.78                              {
    8.79 -                                Globals.Log("LoadFromRegistry: Unable to read IsCrashReportVisible");
    8.80 +                                Log.Warning("LoadFromRegistry: Unable to read IsCrashReportVisible");
    8.81                              }
    8.82                              finally
    8.83                              {
    8.84 @@ -979,7 +979,7 @@
    8.85                              }
    8.86                              catch
    8.87                              {
    8.88 -                                Globals.Log("LoadFromRegistry: Unable to read IsDeveloperModeEnabled");
    8.89 +                                Log.Warning("LoadFromRegistry: Unable to read IsDeveloperModeEnabled");
    8.90                              }
    8.91                              finally
    8.92                              {
    8.93 @@ -1006,7 +1006,7 @@
    8.94                              }
    8.95                              catch
    8.96                              {
    8.97 -                                Globals.Log("LoadFromRegistry: Unable to read IsDisableProtectionForContactsEnabled");
    8.98 +                                Log.Warning("LoadFromRegistry: Unable to read IsDisableProtectionForContactsEnabled");
    8.99                              }
   8.100                              finally
   8.101                              {
   8.102 @@ -1033,7 +1033,7 @@
   8.103                              }
   8.104                              catch
   8.105                              {
   8.106 -                                Globals.Log("LoadFromRegistry: Unable to read IsEncryptAllAccountsEnabled");
   8.107 +                                Log.Warning("LoadFromRegistry: Unable to read IsEncryptAllAccountsEnabled");
   8.108                              }
   8.109                              finally
   8.110                              {
   8.111 @@ -1060,7 +1060,7 @@
   8.112                              }
   8.113                              catch
   8.114                              {
   8.115 -                                Globals.Log("LoadFromRegistry: Unable to read IsKeyServerUsed");
   8.116 +                                Log.Warning("LoadFromRegistry: Unable to read IsKeyServerUsed");
   8.117                              }
   8.118                              finally
   8.119                              {
   8.120 @@ -1087,7 +1087,7 @@
   8.121                              }
   8.122                              catch
   8.123                              {
   8.124 -                                Globals.Log("LoadFromRegistry: Unable to read IsPassiveModeEnabled");
   8.125 +                                Log.Warning("LoadFromRegistry: Unable to read IsPassiveModeEnabled");
   8.126                              }
   8.127                              finally
   8.128                              {
   8.129 @@ -1114,7 +1114,7 @@
   8.130                              }
   8.131                              catch
   8.132                              {
   8.133 -                                Globals.Log("LoadFromRegistry: Unable to read IsPEPFolderVisible");
   8.134 +                                Log.Warning("LoadFromRegistry: Unable to read IsPEPFolderVisible");
   8.135                              }
   8.136                              finally
   8.137                              {
   8.138 @@ -1141,7 +1141,7 @@
   8.139                              }
   8.140                              catch
   8.141                              {
   8.142 -                                Globals.Log("LoadFromRegistry: Unable to read IsReaderSplashEnabled");
   8.143 +                                Log.Warning("LoadFromRegistry: Unable to read IsReaderSplashEnabled");
   8.144                              }
   8.145                              finally
   8.146                              {
   8.147 @@ -1168,7 +1168,7 @@
   8.148                              }
   8.149                              catch
   8.150                              {
   8.151 -                                Globals.Log("LoadFromRegistry: Unable to read IsSecurityLossWarningEnabled");
   8.152 +                                Log.Warning("LoadFromRegistry: Unable to read IsSecurityLossWarningEnabled");
   8.153                              }
   8.154                              finally
   8.155                              {
   8.156 @@ -1195,7 +1195,7 @@
   8.157                              }
   8.158                              catch
   8.159                              {
   8.160 -                                Globals.Log("LoadFromRegistry: Unable to read IsUnencryptedSubjectEnabled");
   8.161 +                                Log.Warning("LoadFromRegistry: Unable to read IsUnencryptedSubjectEnabled");
   8.162                              }
   8.163                              finally
   8.164                              {
   8.165 @@ -1222,7 +1222,7 @@
   8.166                              }
   8.167                              catch
   8.168                              {
   8.169 -                                Globals.Log("LoadFromRegistry: Unable to read IsVerboseLoggingEnabled");
   8.170 +                                Log.Warning("LoadFromRegistry: Unable to read IsVerboseLoggingEnabled");
   8.171                              }
   8.172                              finally
   8.173                              {
   8.174 @@ -1248,7 +1248,7 @@
   8.175                              }
   8.176                              catch
   8.177                              {
   8.178 -                                Globals.Log("LoadFromRegistry: Unable to read TrustwordsCulture");
   8.179 +                                Log.Warning("LoadFromRegistry: Unable to read TrustwordsCulture");
   8.180                              }
   8.181                              finally
   8.182                              {
   8.183 @@ -1265,7 +1265,7 @@
   8.184              }
   8.185              catch (Exception ex)
   8.186              {
   8.187 -                Globals.Log("LoadFromRegistry: Failure occured, " + ex.ToString());
   8.188 +                Log.Error("LoadFromRegistry: Failure occured, " + ex.ToString());
   8.189              }
   8.190  
   8.191              return;
     9.1 --- a/ThisAddIn.cs	Wed Sep 07 18:23:04 2016 +0200
     9.2 +++ b/ThisAddIn.cs	Wed Sep 07 22:31:02 2016 +0200
     9.3 @@ -74,7 +74,7 @@
     9.4                      catch
     9.5                      {
     9.6                          engineList = "";
     9.7 -                        Globals.Log("LanguageList: Failed to get list from engine.");
     9.8 +                        Log.Error("LanguageList: Failed to get list from engine.");
     9.9                      }
    9.10  
    9.11                      languages = engineList.Split('\n');
    9.12 @@ -212,7 +212,7 @@
    9.13                          }
    9.14                          else
    9.15                          {
    9.16 -                            Globals.Log("SyncWithSettings: Invalid SMTP address detected, skipping account.");
    9.17 +                            Log.Warning("SyncWithSettings: Invalid SMTP address detected, skipping account.");
    9.18                          }
    9.19  
    9.20                          Marshal.ReleaseComObject(acct);
    9.21 @@ -308,14 +308,14 @@
    9.22                          {
    9.23                              // Reset to default
    9.24                              this._Settings.TrustwordsCulture = new CultureInfo(PEPSettings.CULTURE_CODE_DEFAULT);
    9.25 -                            Globals.Log("SyncWithSettings: Invalid TrustwordsCulture detected, setting to default.");
    9.26 +                            Log.Warning("SyncWithSettings: Invalid TrustwordsCulture detected, setting to default.");
    9.27                          }
    9.28                      }
    9.29                      else
    9.30                      {
    9.31                          // Reset to default
    9.32                          this._Settings.TrustwordsCulture = new CultureInfo(PEPSettings.CULTURE_CODE_DEFAULT);
    9.33 -                        Globals.Log("SyncWithSettings: Invalid TrustwordsCulture detected, setting to default.");
    9.34 +                        Log.Warning("SyncWithSettings: Invalid TrustwordsCulture detected, setting to default.");
    9.35                      }
    9.36                  }
    9.37              }
    9.38 @@ -363,13 +363,13 @@
    9.39                          addin.Connect = false;
    9.40                          wasDisabled = true;
    9.41  
    9.42 -                        Globals.Log("DisableGpgOL: GpgOL was detected and disabled.");
    9.43 +                        Log.Info("DisableGpgOL: GpgOL was detected and disabled.");
    9.44                      }
    9.45                  }
    9.46              }
    9.47              catch (Exception ex)
    9.48              {
    9.49 -                Globals.Log("DisableGpgOL: Error trying to disable GpgOL, " + ex.ToString());
    9.50 +                Log.Error("DisableGpgOL: Error trying to disable GpgOL, " + ex.ToString());
    9.51              }
    9.52              finally
    9.53              {
    9.54 @@ -408,12 +408,12 @@
    9.55                  // Log information if invalid
    9.56                  if (string.IsNullOrWhiteSpace(me.address))
    9.57                  {
    9.58 -                    Globals.Log("RegisterMyself: Myself[" + i.ToString() + "] doesn't have an address.");
    9.59 +                    Log.Warning("RegisterMyself: Myself[" + i.ToString() + "] doesn't have an address.");
    9.60                  }
    9.61  
    9.62                  if (string.IsNullOrWhiteSpace(me.username))
    9.63                  {
    9.64 -                    Globals.Log("RegisterMyself: Myself[" + i.ToString() + "] doesn't have a username.");
    9.65 +                    Log.Warning("RegisterMyself: Myself[" + i.ToString() + "] doesn't have a username.");
    9.66                  }
    9.67  
    9.68                  // Call engine
    9.69 @@ -601,7 +601,7 @@
    9.70                          }
    9.71                          catch
    9.72                          {
    9.73 -                            Globals.Log("GetUserID: Attempted to use contact but failed.");
    9.74 +                            Log.Error("GetUserID: Attempted to use contact but failed.");
    9.75                          }
    9.76                      }
    9.77  
    9.78 @@ -691,7 +691,7 @@
    9.79                                         PEPMessage sentMessage,
    9.80                                         _pEp_color storedRating = _pEp_color.pEp_rating_undefined)
    9.81          {
    9.82 -            System.Int32 messageFlags;
    9.83 +            Int32 messageFlags;
    9.84              Outlook.MailItem sentMailItem = null;
    9.85              Outlook.Folder sentFolder = null;
    9.86              Outlook.NameSpace ns = Application.Session;
    9.87 @@ -833,7 +833,7 @@
    9.88                                  sentFolder = null;
    9.89                              }
    9.90  
    9.91 -                            Globals.Log("CreateNewSentMail: No Sent folder found and no new Sent folder could be created because of the following error: " + ex.ToString());
    9.92 +                            Log.Error("CreateNewSentMail: No Sent folder found and no new Sent folder could be created because of the following error: " + ex.ToString());
    9.93                          }
    9.94                      }
    9.95  
    9.96 @@ -877,7 +877,7 @@
    9.97              }
    9.98              catch (Exception ex)
    9.99              {
   9.100 -                Globals.Log("CreateNewSentMail: Error occured, " + ex.ToString());
   9.101 +                Log.Error("CreateNewSentMail: Error occured, " + ex.ToString());
   9.102                  throw;
   9.103              }
   9.104              finally
   9.105 @@ -978,7 +978,7 @@
   9.106                      }
   9.107                      catch (Exception ex)
   9.108                      {
   9.109 -                        Globals.Log("PermanentlyDelete: unable to locate parent store, " + ex.ToString());
   9.110 +                        Log.Error("PermanentlyDelete: unable to locate parent store, " + ex.ToString());
   9.111                      }
   9.112                      finally
   9.113                      {
   9.114 @@ -1079,7 +1079,7 @@
   9.115              }
   9.116              catch (Exception ex)
   9.117              {
   9.118 -                Globals.Log("PermanentlyDelete: Failed, " + ex.ToString());
   9.119 +                Log.Error("PermanentlyDelete: Failed, " + ex.ToString());
   9.120              }
   9.121              finally
   9.122              {
   9.123 @@ -1192,7 +1192,7 @@
   9.124              }
   9.125              catch (Exception ex)
   9.126              {
   9.127 -                Globals.Log("SetOutlookRegistryOptions: Failed to set options, " + ex.ToString());
   9.128 +                Log.Error("SetOutlookRegistryOptions: Failed to set options, " + ex.ToString());
   9.129              }
   9.130  
   9.131              return;
   9.132 @@ -1270,7 +1270,7 @@
   9.133                      }
   9.134                      else
   9.135                      {
   9.136 -                        Globals.LogVerbose("SetOptionsState: Existing account settings not found.");
   9.137 +                        Log.Verbose("SetOptionsState: Existing account settings not found.");
   9.138                      }
   9.139                  }
   9.140  
   9.141 @@ -1336,7 +1336,7 @@
   9.142              catch (COMException ex)
   9.143              {
   9.144                  blacklist = new string[0];
   9.145 -                Globals.Log("GetOptionsState: Error getting blacklist from engine. " + ex.ToString());
   9.146 +                Log.Error("GetOptionsState: Error getting blacklist from engine. " + ex.ToString());
   9.147              }
   9.148  
   9.149              // TODO: remove this when adapter is updated, blacklist is non-functional right now
   9.150 @@ -1502,7 +1502,7 @@
   9.151                      }
   9.152                      catch (Exception ex1)
   9.153                      {
   9.154 -                        Globals.Log("OpenPEPStoreRootFolder: Failed to get store, " + ex1.ToString());
   9.155 +                        Log.Warning("OpenPEPStoreRootFolder: Failed to get store, " + ex1.ToString());
   9.156                      }
   9.157  
   9.158                      if (curStore != null)
   9.159 @@ -1792,15 +1792,15 @@
   9.160                              ns.RemoveStore(this._PEPStoreRootFolder);
   9.161                          }
   9.162                      }
   9.163 -                    catch
   9.164 +                    catch (Exception e)
   9.165                      {
   9.166 -                        Globals.Log("SetPEPStoreRootFolderVisibility: Failed to add/remove pEp store.");
   9.167 +                        Log.Warning("SetPEPStoreRootFolderVisibility: Failed to add/remove pEp store. " + e.ToString());
   9.168                      }
   9.169                  }
   9.170              }
   9.171              catch (Exception ex)
   9.172              {
   9.173 -                Globals.Log("SetPEPStoreRootFolderVisibility: Failed, " + ex.ToString());
   9.174 +                Log.Error("SetPEPStoreRootFolderVisibility: Failed, " + ex.ToString());
   9.175              }
   9.176              finally
   9.177              {
   9.178 @@ -1868,7 +1868,7 @@
   9.179                          catch
   9.180                          {
   9.181                              deliveryStore = null;
   9.182 -                            Globals.Log("GetIsSecureStorageEnabled: Failure getting DeliveryStore.");
   9.183 +                            Log.Warning("GetIsSecureStorageEnabled: Failure getting DeliveryStore.");
   9.184                          }
   9.185  
   9.186                          if ((deliveryStore != null) &&
   9.187 @@ -1904,13 +1904,13 @@
   9.188                  else
   9.189                  {
   9.190                      result = defaultResult;
   9.191 -                    Globals.Log("GetIsSecureStorageEnabled: null store, returning default.");
   9.192 +                    Log.Warning("GetIsSecureStorageEnabled: null store, returning default.");
   9.193                  }
   9.194              }
   9.195              catch (Exception ex)
   9.196              {
   9.197                  result = defaultResult;
   9.198 -                Globals.Log("GetIsSecureStorageEnabled: Failure occured, returning default. " + ex.ToString());
   9.199 +                Log.Error("GetIsSecureStorageEnabled: Failure occured, returning default. " + ex.ToString());
   9.200              }
   9.201              finally
   9.202              {
   9.203 @@ -1979,7 +1979,7 @@
   9.204                          catch
   9.205                          {
   9.206                              deliveryStore = null;
   9.207 -                            Globals.Log("GetIsPEPEnabled: Failure getting DeliveryStore.");
   9.208 +                            Log.Warning("GetIsPEPEnabled: Failure getting DeliveryStore.");
   9.209                          }
   9.210  
   9.211                          if ((deliveryStore != null) &&
   9.212 @@ -2015,13 +2015,13 @@
   9.213                  else
   9.214                  {
   9.215                      result = defaultResult;
   9.216 -                    Globals.Log("GetIsEncrypted: null store, returning default.");
   9.217 +                    Log.Warning("GetIsEncrypted: null store, returning default.");
   9.218                  }
   9.219              }
   9.220              catch (Exception ex)
   9.221              {
   9.222                  result = defaultResult;
   9.223 -                Globals.Log("GetIsEncrypted: Failure occured, returning default. " + ex.ToString());
   9.224 +                Log.Error("GetIsEncrypted: Failure occured, returning default. " + ex.ToString());
   9.225              }
   9.226              finally
   9.227              {
   9.228 @@ -2089,7 +2089,7 @@
   9.229                          catch
   9.230                          {
   9.231                              deliveryStore = null;
   9.232 -                            Globals.Log("GetIsActiveSync: Failure getting DeliveryStore.");
   9.233 +                            Log.Warning("GetIsActiveSync: Failure getting DeliveryStore.");
   9.234                          }
   9.235  
   9.236                          if ((deliveryStore != null) &&
   9.237 @@ -2116,13 +2116,13 @@
   9.238                  else
   9.239                  {
   9.240                      result = defaultResult;
   9.241 -                    Globals.Log("GetIsActiveSync: null store, returning default.");
   9.242 +                    Log.Warning("GetIsActiveSync: null store, returning default.");
   9.243                  }
   9.244              }
   9.245              catch (Exception ex)
   9.246              {
   9.247                  result = defaultResult;
   9.248 -                Globals.Log("GetIsActiveSync: Failure occured, returning default. " + ex.ToString());
   9.249 +                Log.Error("GetIsActiveSync: Failure occured, returning default. " + ex.ToString());
   9.250              }
   9.251              finally
   9.252              {
   9.253 @@ -2196,7 +2196,7 @@
   9.254                                  catch
   9.255                                  {
   9.256                                      deliveryStore = null;
   9.257 -                                    Globals.Log("GetIsIMAP: Failure getting DeliveryStore.");
   9.258 +                                    Log.Warning("GetIsIMAP: Failure getting DeliveryStore.");
   9.259                                  }
   9.260  
   9.261                                  if ((deliveryStore != null) &&
   9.262 @@ -2225,13 +2225,13 @@
   9.263                  else
   9.264                  {
   9.265                      result = defaultResult;
   9.266 -                    Globals.Log("GetIsIMAP: null store, returning default.");
   9.267 +                    Log.Warning("GetIsIMAP: null store, returning default.");
   9.268                  }
   9.269              }
   9.270              catch (Exception ex)
   9.271              {
   9.272                  result = defaultResult;
   9.273 -                Globals.Log("GetIsIMAP: Failure occured, returning default. " + ex.ToString());
   9.274 +                Log.Error("GetIsIMAP: Failure occured, returning default. " + ex.ToString());
   9.275              }
   9.276              finally
   9.277              {
   9.278 @@ -2385,14 +2385,14 @@
   9.279                  {
   9.280                      trustwordsShort = "";
   9.281                      trustwordsFull = "";
   9.282 -                    Globals.Log("CalcTrustwords: myself or myself.Fingerprint is null/empty.");
   9.283 +                    Log.Error("CalcTrustwords: myself or myself.Fingerprint is null/empty.");
   9.284                  }
   9.285                  else if ((partner == null) ||
   9.286                           (string.IsNullOrEmpty(partner.Fingerprint)))
   9.287                  {
   9.288                      trustwordsShort = "";
   9.289                      trustwordsFull = "";
   9.290 -                    Globals.Log("CalcTrustwords: partner or partner.Fingerprint is null/empty.");
   9.291 +                    Log.Error("CalcTrustwords: partner or partner.Fingerprint is null/empty.");
   9.292                  }
   9.293                  else
   9.294                  {
   9.295 @@ -2424,13 +2424,13 @@
   9.296              {
   9.297                  trustwordsShort = "";
   9.298                  trustwordsFull = "";
   9.299 -                Globals.Log("CalcTrustwords: Failure occured, " + ex.ToString());
   9.300 +                Log.Error("CalcTrustwords: Failure occured, " + ex.ToString());
   9.301              }
   9.302              catch (Exception ex)
   9.303              {
   9.304                  trustwordsShort = "";
   9.305                  trustwordsFull = "";
   9.306 -                Globals.Log("CalcTrustwords: Failure occured, " + ex.ToString());
   9.307 +                Log.Error("CalcTrustwords: Failure occured, " + ex.ToString());
   9.308              }
   9.309  
   9.310              return;
   9.311 @@ -2450,7 +2450,7 @@
   9.312          private void ThisAddIn_Startup(object sender, System.EventArgs e)
   9.313          {
   9.314              // Reset the log
   9.315 -            Globals.ClearLogFile();
   9.316 +            Log.Clear();
   9.317  
   9.318              // Disable GPGOL
   9.319              this.DisableGpgOL();
   9.320 @@ -2483,49 +2483,49 @@
   9.321                          this._Settings.ActiveCulture = new CultureInfo("ca");
   9.322                          Thread.CurrentThread.CurrentCulture = new CultureInfo("ca");
   9.323                          Thread.CurrentThread.CurrentUICulture = new CultureInfo("ca");
   9.324 -                        Globals.Log("ThisAddIn_Startup: 'ca' language detected.");
   9.325 +                        Log.Info("ThisAddIn_Startup: 'ca' language detected.");
   9.326                          break;
   9.327                      case Office.MsoLanguageID.msoLanguageIDGerman:
   9.328                          this._Settings.ActiveCulture = new CultureInfo("de");
   9.329                          Thread.CurrentThread.CurrentCulture = new CultureInfo("de");
   9.330                          Thread.CurrentThread.CurrentUICulture = new CultureInfo("de");
   9.331 -                        Globals.Log("ThisAddIn_Startup: 'de' language detected.");
   9.332 +                        Log.Info("ThisAddIn_Startup: 'de' language detected.");
   9.333                          break;
   9.334                      case Office.MsoLanguageID.msoLanguageIDSpanish:
   9.335                          this._Settings.ActiveCulture = new CultureInfo("es");
   9.336                          Thread.CurrentThread.CurrentCulture = new CultureInfo("es");
   9.337                          Thread.CurrentThread.CurrentUICulture = new CultureInfo("es");
   9.338 -                        Globals.Log("ThisAddIn_Startup: 'es' language detected.");
   9.339 +                        Log.Info("ThisAddIn_Startup: 'es' language detected.");
   9.340                          break;
   9.341                      case Office.MsoLanguageID.msoLanguageIDSpanishModernSort:
   9.342                          this._Settings.ActiveCulture = new CultureInfo("es");
   9.343                          Thread.CurrentThread.CurrentCulture = new CultureInfo("es");
   9.344                          Thread.CurrentThread.CurrentUICulture = new CultureInfo("es");
   9.345 -                        Globals.Log("ThisAddIn_Startup: 'es' language detected.");
   9.346 +                        Log.Info("ThisAddIn_Startup: 'es' language detected.");
   9.347                          break;
   9.348                      case Office.MsoLanguageID.msoLanguageIDFrench:
   9.349                          this._Settings.ActiveCulture = new CultureInfo("fr");
   9.350                          Thread.CurrentThread.CurrentCulture = new CultureInfo("fr");
   9.351                          Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr");
   9.352 -                        Globals.Log("ThisAddIn_Startup: 'fr' language detected.");
   9.353 +                        Log.Info("ThisAddIn_Startup: 'fr' language detected.");
   9.354                          break;
   9.355                      case Office.MsoLanguageID.msoLanguageIDItalian:
   9.356                          this._Settings.ActiveCulture = new CultureInfo("it");
   9.357                          Thread.CurrentThread.CurrentCulture = new CultureInfo("it");
   9.358                          Thread.CurrentThread.CurrentUICulture = new CultureInfo("it");
   9.359 -                        Globals.Log("ThisAddIn_Startup: 'it' language detected.");
   9.360 +                        Log.Info("ThisAddIn_Startup: 'it' language detected.");
   9.361                          break;
   9.362                      case Office.MsoLanguageID.msoLanguageIDTurkish:
   9.363                          this._Settings.ActiveCulture = new CultureInfo("tr");
   9.364                          Thread.CurrentThread.CurrentCulture = new CultureInfo("tr");
   9.365                          Thread.CurrentThread.CurrentUICulture = new CultureInfo("tr");
   9.366 -                        Globals.Log("ThisAddIn_Startup: 'tr' language detected.");
   9.367 +                        Log.Info("ThisAddIn_Startup: 'tr' language detected.");
   9.368                          break;
   9.369                      default:
   9.370                          this._Settings.ActiveCulture = new CultureInfo("en");
   9.371                          Thread.CurrentThread.CurrentCulture = new CultureInfo("en");
   9.372                          Thread.CurrentThread.CurrentUICulture = new CultureInfo("en");
   9.373 -                        Globals.Log("ThisAddIn_Startup: default 'en' language detected.");
   9.374 +                        Log.Info("ThisAddIn_Startup: default 'en' language detected.");
   9.375                          break;
   9.376                  }
   9.377              }
   9.378 @@ -2554,7 +2554,7 @@
   9.379                      ((Outlook.ApplicationEvents_11_Event)this.Application).ItemSend += Application_ItemSend;
   9.380  
   9.381                      // Initialization complete
   9.382 -                    Globals.Log("ThisAddIn_Startup: Main program started.");
   9.383 +                    Log.Info("ThisAddIn_Startup: Main program started.");
   9.384                      this.initialized = true;
   9.385                  }
   9.386              }
   9.387 @@ -2628,7 +2628,7 @@
   9.388                  ThisAddIn._PEPEngine = null;
   9.389              }
   9.390  
   9.391 -            Globals.CloseLogFile();
   9.392 +            Log.Close();
   9.393  
   9.394              return;
   9.395          }
   9.396 @@ -2703,14 +2703,14 @@
   9.397                              {
   9.398                                  // Reset to default
   9.399                                  this._Settings.TrustwordsCulture = new CultureInfo(PEPSettings.CULTURE_CODE_DEFAULT);
   9.400 -                                Globals.Log("Settings_PropertyChanged: Invalid TrustwordsCulture detected, setting to default.");
   9.401 +                                Log.Warning("Settings_PropertyChanged: Invalid TrustwordsCulture detected, setting to default.");
   9.402                              }
   9.403                          }
   9.404                          else
   9.405                          {
   9.406                              // Reset to default
   9.407                              this._Settings.TrustwordsCulture = new CultureInfo(PEPSettings.CULTURE_CODE_DEFAULT);
   9.408 -                            Globals.Log("Settings_PropertyChanged: Invalid TrustwordsCulture detected, setting to default.");
   9.409 +                            Log.Warning("Settings_PropertyChanged: Invalid TrustwordsCulture detected, setting to default.");
   9.410                          }
   9.411                          break;
   9.412                      }
   9.413 @@ -2731,7 +2731,7 @@
   9.414              Outlook.MailItem omi = null;
   9.415              CryptableMailItem cmi;
   9.416  
   9.417 -            Globals.LogVerbose("Application_NewMailEx: Started processing new items.");
   9.418 +            Log.Verbose("Application_NewMailEx: Started processing new items.");
   9.419  
   9.420              foreach (string eid in EntryIDCollection.Split(','))
   9.421              {
   9.422 @@ -2752,7 +2752,7 @@
   9.423                      }
   9.424                      else
   9.425                      {
   9.426 -                        Globals.LogVerbose("Application_NewMailEx: Item skipped because pEp is disabled.");
   9.427 +                        Log.Verbose("Application_NewMailEx: Item skipped because pEp is disabled.");
   9.428                      }
   9.429                  }
   9.430                  catch { }
   9.431 @@ -2764,7 +2764,7 @@
   9.432                  ns = null;
   9.433              }
   9.434  
   9.435 -            Globals.LogVerbose("Application_NewMailEx: Complete (decryption likely ongoing in background threads).");
   9.436 +            Log.Verbose("Application_NewMailEx: Complete (decryption likely ongoing in background threads).");
   9.437  
   9.438              return;
   9.439          }
   9.440 @@ -2781,7 +2781,7 @@
   9.441              Outlook.MailItem omi;
   9.442              CryptableMailItem cmi;
   9.443  
   9.444 -            Globals.LogVerbose("Application_ItemSend: Send started");
   9.445 +            Log.Verbose("Application_ItemSend: Send started");
   9.446  
   9.447              if ((item != null) &&
   9.448                  (item is Outlook.MailItem))
   9.449 @@ -2805,7 +2805,7 @@
   9.450                      PEPAttachment ownKey;
   9.451                      pEp_identity_s from;
   9.452  
   9.453 -                    Globals.LogVerbose("Application_ItemSend: Attaching own public key.");
   9.454 +                    Log.Verbose("Application_ItemSend: Attaching own public key.");
   9.455  
   9.456                      try
   9.457                      {
   9.458 @@ -2860,7 +2860,7 @@
   9.459                          // Encrypt unless the send unencrypted property is true
   9.460                          if (forceUnencryptedProperty == false)
   9.461                          {
   9.462 -                            Globals.LogVerbose("Application_ItemSend: Starting encryption and message processing.");
   9.463 +                            Log.Verbose("Application_ItemSend: Starting encryption and message processing.");
   9.464  
   9.465                              createSts = PEPMessage.Create(omi, out sentMessage);
   9.466  
   9.467 @@ -2881,7 +2881,7 @@
   9.468                                  }
   9.469  
   9.470                                  // Create and send individual processed messages
   9.471 -                                Globals.LogVerbose("Application_ItemSend: Sending message(s).");
   9.472 +                                Log.Verbose("Application_ItemSend: Sending message(s).");
   9.473                                  for (int i = 0; i < messages.Length; i++)
   9.474                                  {
   9.475                                      // Note: exceptions will be caught in the main try/catch to inform the user of an error
   9.476 @@ -2889,7 +2889,7 @@
   9.477                                  }
   9.478  
   9.479                                  // Save the sent message
   9.480 -                                Globals.LogVerbose("Application_ItemSend: Saving sent message.");
   9.481 +                                Log.Verbose("Application_ItemSend: Saving sent message.");
   9.482                                  try
   9.483                                  {
   9.484                                      sendingAccount = omi.SendUsingAccount;
   9.485 @@ -2908,7 +2908,7 @@
   9.486                                          catch
   9.487                                          {
   9.488                                              sendingStore = null;
   9.489 -                                            Globals.Log("Application_ItemSend: Failure getting DeliveryStore to save sent message.");
   9.490 +                                            Log.Warning("Application_ItemSend: Failure getting DeliveryStore to save sent message.");
   9.491                                          }
   9.492  
   9.493                                          //Get sending account settings
   9.494 @@ -2951,7 +2951,7 @@
   9.495                                  }
   9.496                                  catch (Exception ex)
   9.497                                  {
   9.498 -                                    Globals.Log("Application_ItemSend: Failed to create sent mail item, " + ex.ToString());
   9.499 +                                    Log.Error("Application_ItemSend: Failed to create sent mail item, " + ex.ToString());
   9.500                                  }
   9.501                                  finally
   9.502                                  {
   9.503 @@ -2973,7 +2973,7 @@
   9.504                                  cancel = true;
   9.505  
   9.506                                  // Close inspector/window
   9.507 -                                Globals.LogVerbose("Application_ItemSend: Closing inspector and deleting original message.");
   9.508 +                                Log.Verbose("Application_ItemSend: Closing inspector and deleting original message.");
   9.509                                  insp = Application.ActiveInspector();
   9.510                                  if (insp != null)
   9.511                                  {
   9.512 @@ -3041,7 +3041,7 @@
   9.513                                  catch
   9.514                                  {
   9.515                                      sendingStore = null;
   9.516 -                                    Globals.Log("Application_ItemSend: Failure getting DeliveryStore to delete composed message.");
   9.517 +                                    Log.Warning("Application_ItemSend: Failure getting DeliveryStore to delete composed message.");
   9.518                                  }
   9.519  
   9.520                                  this.PermanentlyDelete(omi, sendingStore);
   9.521 @@ -3076,7 +3076,8 @@
   9.522                          }
   9.523                          else
   9.524                          {
   9.525 -                            Globals.Log("Application_ItemSend: Sending forcefully unencrypted");
   9.526 +                            // Always log (not as only in verbose) to show when user sent unencrypted
   9.527 +                            Log.Info("Application_ItemSend: Sending forcefully unencrypted");
   9.528  
   9.529                              // Remove any user properties to avoid 'winmail.dat'
   9.530                              CryptableMailItem.DeleteUserProperty(omi, CryptableMailItem.USER_PROPERTY_KEY_FORCE_UNENCRYPTED);
   9.531 @@ -3087,7 +3088,7 @@
   9.532                      }
   9.533                      catch (Exception ex)
   9.534                      {
   9.535 -                        Globals.Log("Application_ItemSend: Send failure, " + ex.ToString());
   9.536 +                        Log.Error("Application_ItemSend: Send failure, " + ex.ToString());
   9.537  
   9.538                          // Ask the user to continue?
   9.539                          result = MessageBox.Show(Properties.Resources.Message_SendError + Environment.NewLine + Environment.NewLine +
   9.540 @@ -3100,23 +3101,23 @@
   9.541                          {
   9.542                              // Send original message without processing
   9.543                              cancel = false;
   9.544 -                            Globals.Log("Application_ItemSend: After send failure, user selected to send original unencrypted message.");
   9.545 +                            Log.Info("Application_ItemSend: After send failure, user selected to send original unencrypted message.");
   9.546                          }
   9.547                          else
   9.548                          {
   9.549                              // Don't send the original message
   9.550                              cancel = true;
   9.551 -                            Globals.Log("Application_ItemSend: After send failure, user cancelled send.");
   9.552 +                            Log.Info("Application_ItemSend: After send failure, user cancelled send.");
   9.553                          }
   9.554                      }
   9.555  #endif
   9.556                  }
   9.557  
   9.558 -                Globals.LogVerbose("Application_ItemSend: Completed. cancel=" + cancel.ToString());
   9.559 +                Log.Verbose("Application_ItemSend: Completed. cancel=" + cancel.ToString());
   9.560              }
   9.561              else
   9.562              {
   9.563 -                Globals.LogVerbose("Application_ItemSend: Item skipped because pEp is disabled.");
   9.564 +                Log.Verbose("Application_ItemSend: Item skipped because pEp is disabled.");
   9.565              }
   9.566  
   9.567              return;
    10.1 --- a/UI/FormControlOptions.xaml.cs	Wed Sep 07 18:23:04 2016 +0200
    10.2 +++ b/UI/FormControlOptions.xaml.cs	Wed Sep 07 22:31:02 2016 +0200
    10.3 @@ -136,7 +136,7 @@
    10.4              }
    10.5              catch (Exception ex)
    10.6              {
    10.7 -                Globals.Log("ButtonOpenKeyManager_Click: Unable to open GPA, " + ex.ToString());
    10.8 +                Log.Error("ButtonOpenKeyManager_Click: Unable to open GPA, " + ex.ToString());
    10.9              }
   10.10  
   10.11              return;
   10.12 @@ -161,7 +161,7 @@
   10.13              // pEp for Outlook
   10.14              try
   10.15              {
   10.16 -                this.displayState.LogOutlook = Globals.ReadLogFile();
   10.17 +                this.displayState.LogOutlook = Log.Read();
   10.18              }
   10.19              catch (Exception ex)
   10.20              {
   10.21 @@ -241,7 +241,7 @@
   10.22              }
   10.23              catch (Exception ex)
   10.24              {
   10.25 -                Globals.Log("HyperlinkPEP_Click: Unable to open website link, " + ex.ToString());
   10.26 +                Log.Error("HyperlinkPEP_Click: Unable to open website link, " + ex.ToString());
   10.27              }
   10.28  
   10.29              return;
    11.1 --- a/UI/FormControlPrivacyStatus.xaml.cs	Wed Sep 07 18:23:04 2016 +0200
    11.2 +++ b/UI/FormControlPrivacyStatus.xaml.cs	Wed Sep 07 22:31:02 2016 +0200
    11.3 @@ -83,7 +83,7 @@
    11.4              }
    11.5              catch (Exception ex)
    11.6              {
    11.7 -                Globals.Log("LinkLabelUpgrade_LinkClicked: Unable to open website link, " + ex.ToString());
    11.8 +                Log.Error("LinkLabelUpgrade_LinkClicked: Unable to open website link, " + ex.ToString());
    11.9              }
   11.10  
   11.11              return;
    12.1 --- a/UI/FormReaderSplash.cs	Wed Sep 07 18:23:04 2016 +0200
    12.2 +++ b/UI/FormReaderSplash.cs	Wed Sep 07 22:31:02 2016 +0200
    12.3 @@ -76,7 +76,7 @@
    12.4              }
    12.5              catch (Exception ex)
    12.6              {
    12.7 -                Globals.Log("ButtonUpgradePEP_Click: Unable to open website link, " + ex.ToString());
    12.8 +                Log.Error("ButtonUpgradePEP_Click: Unable to open website link, " + ex.ToString());
    12.9              }
   12.10              finally
   12.11              {
    13.1 --- a/UI/FormRegionPreviewUnencrypted.cs	Wed Sep 07 18:23:04 2016 +0200
    13.2 +++ b/UI/FormRegionPreviewUnencrypted.cs	Wed Sep 07 22:31:02 2016 +0200
    13.3 @@ -591,7 +591,7 @@
    13.4              }
    13.5              catch (Exception ex)
    13.6              {
    13.7 -                Globals.Log("MailItem_Forward: Failure occured, " + ex.ToString());
    13.8 +                Log.Error("MailItem_Forward: Failure occured, " + ex.ToString());
    13.9              }
   13.10              finally
   13.11              {
   13.12 @@ -635,7 +635,7 @@
   13.13              }
   13.14              catch (Exception ex)
   13.15              {
   13.16 -                Globals.Log("MailItem_ReplyAll: Failure occured, " + ex.ToString());
   13.17 +                Log.Error("MailItem_ReplyAll: Failure occured, " + ex.ToString());
   13.18              }
   13.19              finally
   13.20              {
   13.21 @@ -679,7 +679,7 @@
   13.22              }
   13.23              catch (Exception ex)
   13.24              {
   13.25 -                Globals.Log("MailItem_Reply: Failure occured, " + ex.ToString());
   13.26 +                Log.Error("MailItem_Reply: Failure occured, " + ex.ToString());
   13.27              }
   13.28              finally
   13.29              {
    14.1 --- a/UI/FormRegionPrivacyStatus.cs	Wed Sep 07 18:23:04 2016 +0200
    14.2 +++ b/UI/FormRegionPrivacyStatus.cs	Wed Sep 07 22:31:02 2016 +0200
    14.3 @@ -247,7 +247,7 @@
    14.4              DialogResult result;
    14.5              FormHandshake handshakeDialog;
    14.6  
    14.7 -            Globals.LogVerbose("DoHandshake: Handshake started.");
    14.8 +            Log.Verbose("DoHandshake: Handshake started.");
    14.9  
   14.10              // Create and show handshake dialog
   14.11              handshakeDialog = new FormHandshake();
   14.12 @@ -300,7 +300,7 @@
   14.13                      }
   14.14              }
   14.15  
   14.16 -            Globals.LogVerbose("ProcessDoHandshakeResult: Handshake complete.");
   14.17 +            Log.Verbose("ProcessDoHandshakeResult: Handshake complete.");
   14.18  
   14.19              return;
   14.20          }
   14.21 @@ -414,7 +414,7 @@
   14.22                      catch (COMException ex)
   14.23                      {
   14.24                          identityPartnerRating = _pEp_color.pEp_rating_undefined;
   14.25 -                        Globals.Log("GetManagerState: Failed to get identity rating, " + ex.ToString());
   14.26 +                        Log.Warning("GetManagerState: Failed to get identity rating, " + ex.ToString());
   14.27                      }
   14.28  
   14.29                      isMyself = PEPIdentity.GetIsOwnIdentity(partnerIdentity.Address);
   14.30 @@ -619,7 +619,7 @@
   14.31          /// </summary>
   14.32          private void ImmediateRatingAndUIUpdate()
   14.33          {
   14.34 -            Globals.LogVerbose("ImmediateRatingAndUIUpdate: Started.");
   14.35 +            Log.Verbose("ImmediateRatingAndUIUpdate: Started.");
   14.36  
   14.37              if (this.associatedMailItem != null)
   14.38              {
   14.39 @@ -628,11 +628,11 @@
   14.40                      // Force unencrypted
   14.41                      this.FormControlPrivacyStatusChild.DisplayState.Rating = _pEp_color.pEp_rating_unencrypted;
   14.42  
   14.43 -                    Globals.LogVerbose("ImmediateRatingAndUIUpdate: Force unencrypted detected.");
   14.44 +                    Log.Verbose("ImmediateRatingAndUIUpdate: Force unencrypted detected.");
   14.45                  }
   14.46                  else
   14.47                  {
   14.48 -                    Globals.LogVerbose("ImmediateRatingAndUIUpdate: Starting decryption.");
   14.49 +                    Log.Verbose("ImmediateRatingAndUIUpdate: Starting decryption.");
   14.50  
   14.51                      // Start the rating calculation/decryption process
   14.52                      this.associatedMailItem.StartProcessing();
   14.53 @@ -902,7 +902,7 @@
   14.54                      }
   14.55                      catch (Exception ex)
   14.56                      {
   14.57 -                        Globals.Log("TimerRefresh_Tick: Get DownloadState failed, " + ex.ToString());
   14.58 +                        Log.Warning("TimerRefresh_Tick: Get DownloadState failed, " + ex.ToString());
   14.59  
   14.60                          // Assume everything is downloaded, but try to download again as well
   14.61                          dlState = Outlook.OlDownloadState.olFullItem;
   14.62 @@ -928,7 +928,7 @@
   14.63                          }
   14.64                          catch (Exception ex)
   14.65                          {
   14.66 -                            Globals.Log("TimerRefresh_Tick: MarkForDownload failed, " + ex.ToString());
   14.67 +                            Log.Warning("TimerRefresh_Tick: MarkForDownload failed, " + ex.ToString());
   14.68                          }
   14.69                      }
   14.70                  }
   14.71 @@ -952,7 +952,7 @@
   14.72          /// </summary>
   14.73          private void MailItem_ProcessingCompleted(object sender, CryptableMailItem.ProcessingCompletedEventArgs e)
   14.74          {
   14.75 -            Globals.LogVerbose("MailItem_ProcessingComplete: Decryption completed.");
   14.76 +            Log.Verbose("MailItem_ProcessingComplete: Decryption completed.");
   14.77  
   14.78              try
   14.79              {
   14.80 @@ -972,7 +972,7 @@
   14.81                          {
   14.82                              if (this.associatedMailItem.IsStoredEncrypted)
   14.83                              {
   14.84 -                                Globals.LogVerbose("MailItem_ProcessingComplete: Starting mirror location.");
   14.85 +                                Log.Verbose("MailItem_ProcessingComplete: Starting mirror location.");
   14.86                                  this.associatedMailItem.StartGetMirror();
   14.87                              }
   14.88                              else
   14.89 @@ -984,13 +984,13 @@
   14.90                          {
   14.91                              // Error is possible in some situations where the mail item was deleted or moved while decryption was ongoing.
   14.92                              // While rare, just log the issue and stop the process
   14.93 -                            Globals.Log("MailItem_ProcessingComplete: Failed to start mirror location, " + ex.ToString());
   14.94 +                            Log.Warning("MailItem_ProcessingComplete: Failed to start mirror location, " + ex.ToString());
   14.95                          }
   14.96                      }));
   14.97              }
   14.98              catch (Exception ex)
   14.99              {
  14.100 -                Globals.Log("MailItem_ProcessingComplete: Error setting UI state, " + ex.ToString());
  14.101 +                Log.Error("MailItem_ProcessingComplete: Error setting UI state, " + ex.ToString());
  14.102              }
  14.103  
  14.104              return;
  14.105 @@ -1013,13 +1013,13 @@
  14.106                              (this.associatedMailItem.LastProcessingStatus == Globals.ReturnStatus.Failure))
  14.107                          {
  14.108                              this.ClearPreview(Properties.Resources.Message_OpenError);
  14.109 -                            Globals.LogVerbose("MailItem_GetMirrorComplete: Cannot display mirror, failure during decryption.");
  14.110 +                            Log.Verbose("MailItem_GetMirrorComplete: Cannot display mirror, failure during decryption.");
  14.111                          }
  14.112                          else if ((e.Mirror == null) &&
  14.113                                   (this.associatedMailItem.LastProcessingStatus == Globals.ReturnStatus.FailureNoConnection))
  14.114                          {
  14.115                              this.ClearPreview(Properties.Resources.Message_DecryptionNoConnection);
  14.116 -                            Globals.LogVerbose("MailItem_GetMirrorComplete: Cannot display mirror, connection failure during decryption.");
  14.117 +                            Log.Verbose("MailItem_GetMirrorComplete: Cannot display mirror, connection failure during decryption.");
  14.118                          }
  14.119                          else
  14.120                          {
  14.121 @@ -1028,7 +1028,7 @@
  14.122                                  (formRegions.FormRegionPreviewUnencrypted.Visible))
  14.123                              {
  14.124                                  formRegions.FormRegionPreviewUnencrypted.SetMessage(e.Mirror);
  14.125 -                                Globals.LogVerbose("MailItem_GetMirrorComplete: Mirror found and displayed.");
  14.126 +                                Log.Verbose("MailItem_GetMirrorComplete: Mirror found and displayed.");
  14.127                              }
  14.128                          }
  14.129  
  14.130 @@ -1043,7 +1043,7 @@
  14.131              }
  14.132              catch (Exception ex)
  14.133              {
  14.134 -                Globals.Log("MailItem_GetMirrorComplete: Error displaying preview, " + ex.ToString());
  14.135 +                Log.Error("MailItem_GetMirrorComplete: Error displaying preview, " + ex.ToString());
  14.136              }
  14.137  
  14.138              return;
  14.139 @@ -1182,7 +1182,7 @@
  14.140              }
  14.141              catch (Exception ex)
  14.142              {
  14.143 -                Globals.Log("LinkLabelUpgrade_LinkClicked: Unable to open website link, " + ex.ToString());
  14.144 +                Log.Error("LinkLabelUpgrade_LinkClicked: Unable to open website link, " + ex.ToString());
  14.145              }
  14.146  
  14.147              return;
    15.1 --- a/UI/RibbonCustomizations.cs	Wed Sep 07 18:23:04 2016 +0200
    15.2 +++ b/UI/RibbonCustomizations.cs	Wed Sep 07 22:31:02 2016 +0200
    15.3 @@ -857,7 +857,7 @@
    15.4              }
    15.5              catch (Exception ex)
    15.6              {
    15.7 -                Globals.Log("ButtonUpgradePEP_Click: Unable to open website link, " + ex.ToString());
    15.8 +                Log.Error("ButtonUpgradePEP_Click: Unable to open website link, " + ex.ToString());
    15.9              }
   15.10  
   15.11              return;