Globals.cs
author Dean Looyengoed
Fri, 14 Oct 2016 17:42:21 +0200
branchRelease_1_0_Series
changeset 1365 5aef818d8240
parent 1364 326b6e026fe5
permissions -rw-r--r--
OUT-130: Make GetPEPVersion() method to be used in ribbon also.
Dean@660
     1
using System;
Dean@660
     2
using System.Collections.Generic;
Dean@660
     3
using System.Drawing;
Dean@607
     4
using System.Globalization;
Dean@911
     5
using System.IO;
Dean@660
     6
using System.Reflection;
Dean@660
     7
using System.Runtime.InteropServices;
Dean@660
     8
using System.Text;
Dean@660
     9
using System.Threading;
Dean@660
    10
using System.Windows.Forms;
Dean@660
    11
using Office = Microsoft.Office.Core;
Dean@606
    12
Dean@606
    13
namespace pEp
Dean@606
    14
{
Dean@606
    15
    /// <summary>
Dean@660
    16
    /// Class to store all global/shared data and methods.
Dean@860
    17
    /// This class is a shared partial class with the internally generated code.
Dean@606
    18
    /// </summary>
Dean@860
    19
    internal sealed partial class Globals
Dean@606
    20
    {
Dean@854
    21
        public const string                CRASH_REPORT_SEND_ADDRESS_DEFAULT                  = "crashreport@prettyeasyprivacy.com";
Dean@854
    22
        public const string                CULTURE_CODE_DEFAULT                               = "en";
Dean@854
    23
        public static readonly CultureInfo CULTURE_DEFAULT                                    = new CultureInfo(CULTURE_CODE_DEFAULT);
Dean@854
    24
        public const bool                  ENCRYPT_ACCOUNTS_BY_DEFAULT                        = false;
Dean@1024
    25
        public const bool                  IS_AUTO_UPDATE_ENABLED_DEFAULT                     = true;
Dean@854
    26
        public const bool                  IS_CRASH_REPORT_VISIBLE_DEFAULT                    = true;
Dean@854
    27
        public const bool                  IS_DEVELOPER_MODE_ENABLED_DEFAULT                  = false;
Dean@854
    28
        public const bool                  IS_DISABLE_PROTECTION_FOR_CONTACTS_ENABLED_DEFAULT = false;
Dean@854
    29
        public const bool                  IS_ENCRYPT_ALL_ACCOUNTS_ENABLED_DEFAULT            = false;
Dean@854
    30
        public const bool                  IS_KEY_SERVER_USED_DEFAULT                         = false;
Dean@854
    31
        public const bool                  IS_PASSIVE_MODE_ENABLED_DEFAULT                    = false;
Dean@854
    32
        public const bool                  IS_PEP_FOLDER_VISIBLE_DEFAULT                      = false;
Dean@854
    33
        public const bool                  IS_TNEF_DISABLED_DEFAULT                           = false;
Dean@854
    34
        public const bool                  IS_UNENCRYPTED_SUBJECT_ENABLED_DEFAULT             = false;
Dean@854
    35
        public const bool                  IS_VERBOSE_LOGGING_ENABLED_DEFAULT                 = false;
Dean@911
    36
        public const string                LOG_FILE_NAME                                      = "log.txt";
Dean@606
    37
Dean@1023
    38
        public const string PEP_COPYRIGHT              = "Copyright 2014-2016 p≡p Security SA, Luxembourg";
Dean@1023
    39
        public const string PEP_NAME                   = "p≡p for Outlook";               // Display name to the user
Dean@1023
    40
#if DEBUG
Dean@1023
    41
        public const string PEP_NAME_ADDIN_DESC        = "pEp";                           // Description of the add-in within Outlook itself (shared with reader)
Dean@1023
    42
#else
Dean@1023
    43
        public const string PEP_NAME_ADDIN_DESC        = "pEp for Outlook";               // Description of the add-in within Outlook itself (shared with reader)
Dean@1023
    44
#endif
Dean@1023
    45
        public const string PEP_NAME_INSTALL           = "pEp for Outlook";               // Name for Windows installer, must sync with installation code (shared with reader)
Dean@1023
    46
        public const string PEP_READER_NAME            = "p≡p for Outlook Reader";        // Display name to the user
Dean@1023
    47
        public const string PEP_WEBSITE_LINK           = "https://prettyeasyprivacy.com";
Dean@1023
    48
        public const string PEP_WEBSITE_UPGRADE_LINK   = "https://prettyeasyprivacy.com";
Dean@859
    49
Dean@859
    50
#if READER_RELEASE_MODE
Dean@859
    51
        public const ReleaseMode RELEASE_MODE = ReleaseMode.Reader;
Dean@859
    52
#else
Dean@859
    53
        public const ReleaseMode RELEASE_MODE = ReleaseMode.Standard;
Dean@859
    54
#endif
Dean@859
    55
Dean@689
    56
        public static readonly Color COLOR_SELECTED   = Color.FromArgb(175, 212, 239);
Dean@606
    57
        public static readonly Color COLOR_UNSELECTED = Color.FromArgb(255, 255, 255);
Dean@689
    58
        public static readonly Color COLOR_MOUSE_OVER = Color.FromArgb(204, 230, 248);
Dean@607
    59
Dean@882
    60
        // Engine translations
Dean@882
    61
        public const int PHRASE_ID_TRUSTWORDS_LANGUAGE = 1000;
Dean@882
    62
Dean@607
    63
        /// <summary>
Dean@859
    64
        /// Enumeration to define the supported release modes.
Dean@859
    65
        /// </summary>
Dean@859
    66
        public enum ReleaseMode
Dean@859
    67
        {
Dean@859
    68
            Standard,
Dean@859
    69
            Reader
Dean@859
    70
        }
Dean@859
    71
Dean@859
    72
        /// <summary>
Dean@910
    73
        /// Enumeration to define the return status of methods.
Dean@910
    74
        /// </summary>
Dean@910
    75
        public enum ReturnStatus
Dean@910
    76
        {
Dean@910
    77
            /// <summary>
Dean@910
    78
            /// An unspecified failure occured.
Dean@910
    79
            /// </summary>
Dean@910
    80
            Failure,
Dean@910
    81
Dean@910
    82
            /// <summary>
Dean@910
    83
            /// A failure occured because there is no internet or Exchange connection.
Dean@910
    84
            /// </summary>
Dean@910
    85
            FailureNoConnection,
Dean@910
    86
Dean@910
    87
            /// <summary>
Dean@910
    88
            /// Successfully completed with no unexpected failures.
Dean@910
    89
            /// </summary>
Dean@910
    90
            Success
Dean@910
    91
        }
Dean@910
    92
Dean@910
    93
        /// <summary>
Dean@649
    94
        /// Hardcoded list of all accounts that should be whitelisted (trusted by default).
Dean@649
    95
        /// </summary>
Dean@649
    96
        public static readonly string[] HARDCODED_ACCOUNT_WHITELIST = new string[] { };
Dean@649
    97
Dean@660
    98
        private static bool         eventsAreConnected = false;
Dean@911
    99
        private static StreamWriter logWriter          = null;
Dean@923
   100
        private static object       mutexLogFile       = new object();
Dean@660
   101
Dean@660
   102
        /**************************************************************
Dean@660
   103
         * 
Dean@660
   104
         * Methods
Dean@660
   105
         * 
Dean@660
   106
         *************************************************************/
Dean@660
   107
Dean@660
   108
        /// <summary>
Dean@660
   109
        /// Builds a crash report and displays it to the user before sending. 
Dean@660
   110
        /// </summary>
Dean@660
   111
        /// <param name="exception">The exception to build the report with.</param>
Dean@660
   112
        /// <param name="summaryMessage">The message summarizing where the error occured or what it is.</param>
Dean@660
   113
        /// <param name="allowRestart">True to allow the add-in to attempt to restart itself.</param>
Dean@660
   114
        /// <param name="isEngineCrash">True if the engine generated the error. This will not attempt to get
Dean@660
   115
        /// an engine log as the engine itself is not working (avoids infinite loop).</param>
Dean@660
   116
        public static void StopAndSendCrashReport(Exception exception = null,
Dean@660
   117
                                                  string summaryMessage = null,
Dean@660
   118
                                                  bool allowRestart = true,
Dean@660
   119
                                                  bool isEngineCrash = false)
Dean@660
   120
        {
Dean@660
   121
            bool continueSend = true;
Dean@660
   122
            string engineLog = "";
Dean@960
   123
            string log = "";
Dean@660
   124
            FormCrashReport form;
Dean@660
   125
            FormCrashReport.State stateIn = null;
Dean@660
   126
            FormCrashReport.State stateOut;
Dean@660
   127
            DialogResult result;
Dean@660
   128
            Office.COMAddIns comAddIns = null;
Dean@660
   129
            Office.COMAddIn addIn = null;
Dean@660
   130
            PEPMessage newMessage;
Dean@660
   131
            PEPAttachment attachment = null;
Dean@660
   132
Dean@660
   133
            // Show the report before sending
Dean@660
   134
            if (continueSend)
Dean@660
   135
            {
Dean@660
   136
                stateIn = new FormCrashReport.State();
Dean@660
   137
                stateIn.AddressTo = Globals.ThisAddIn.CrashReportSendAddress;
Dean@660
   138
                stateIn.AddressFrom = null; // A message can be sent without a "from" address
Dean@660
   139
Dean@960
   140
                // Get log
Dean@960
   141
                try
Dean@960
   142
                {
Dean@960
   143
                    log = string.Join(Environment.NewLine, Globals.ReadLogFile());
Dean@960
   144
                }
Dean@960
   145
                catch
Dean@960
   146
                {
Dean@960
   147
                    log = "";
Dean@960
   148
                }
Dean@960
   149
Dean@660
   150
                // Get engine log
Dean@660
   151
                if (isEngineCrash == false)
Dean@660
   152
                {
Dean@660
   153
                    try
Dean@660
   154
                    {
Dean@660
   155
                        engineLog = ThisAddIn.pEp.get_crashdump_log();
Dean@660
   156
                    }
Dean@660
   157
                    catch (COMException ex)
Dean@660
   158
                    {
Dean@660
   159
                        engineLog = ex.ToString();
Dean@660
   160
                    }
Dean@660
   161
                    catch (Exception ex)
Dean@660
   162
                    {
Dean@660
   163
                        engineLog = ex.ToString();
Dean@660
   164
                    }
Dean@660
   165
                }
Dean@660
   166
Dean@960
   167
                // Double check for null log files
Dean@960
   168
                if (log == null) { log = ""; }
Dean@960
   169
                if (engineLog == null) { engineLog = ""; }
Dean@960
   170
Dean@660
   171
                // Build report header
Dean@660
   172
                stateIn.ReportText = string.Join(Environment.NewLine, new string[]
Dean@660
   173
                    {
Dean@660
   174
                        "Summary---------------------------------------------------",
Dean@660
   175
                        "",
Dean@660
   176
                        "Date: " + System.DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss K"),
Dean@860
   177
                        Globals.GetSystemInfo(),
Dean@660
   178
                        "",
Dean@660
   179
                        (string.IsNullOrWhiteSpace(summaryMessage) ? "no message" : summaryMessage),
Dean@660
   180
                        "",
Dean@660
   181
                        "Exception Details-----------------------------------------",
Dean@660
   182
                        "",
Dean@660
   183
                        (exception == null ? "no exception" : exception.ToString()),
Dean@660
   184
                        "",
Dean@660
   185
                        "p≡p for Outlook Log---------------------------------------",
Dean@660
   186
                        "",
Dean@960
   187
                        log,
Dean@660
   188
                        "",
Dean@660
   189
                        "p≡p Engine Log--------------------------------------------",
Dean@660
   190
                        "",
Dean@660
   191
                        engineLog,
Dean@660
   192
                        "",
Dean@660
   193
                        "END OF REPORT"
Dean@660
   194
                    });
Dean@660
   195
Dean@660
   196
                if (Globals.ThisAddIn.IsCrashReportVisible)
Dean@660
   197
                {
Dean@660
   198
                    form = new FormCrashReport();
Dean@660
   199
                    result = form.ShowDialog(null, stateIn, out stateOut);
Dean@660
   200
Dean@660
   201
                    if (result != DialogResult.OK)
Dean@660
   202
                    {
Dean@660
   203
                        continueSend = false;
Dean@660
   204
                    }
Dean@660
   205
                }
Dean@660
   206
            }
Dean@660
   207
Dean@660
   208
            // Build and send message
Dean@660
   209
            if (continueSend)
Dean@660
   210
            {
Dean@660
   211
                newMessage = new PEPMessage();
Dean@660
   212
                newMessage.ShortMsg = "Crash Report";
Dean@660
   213
                newMessage.To.Add(new PEPIdentity(stateIn.AddressTo));
Dean@660
   214
                newMessage.LongMsg = stateIn.ReportText;
Dean@660
   215
                newMessage.Direction = pEpCOMServerAdapterLib._pEp_msg_direction.pEp_dir_outgoing;
Dean@660
   216
Dean@960
   217
                // Add logs as attachments
Dean@960
   218
                if (string.IsNullOrEmpty(log) == false)
Dean@660
   219
                {
Dean@960
   220
                    attachment = new PEPAttachment();
Dean@960
   221
                    attachment.Data = Encoding.UTF8.GetBytes(log);
Dean@960
   222
                    attachment.FileName = "pEp Log.txt";
Dean@960
   223
                    newMessage.Attachments.Add(attachment);
Dean@960
   224
                }
Dean@960
   225
Dean@960
   226
                if (string.IsNullOrEmpty(engineLog) == false)
Dean@960
   227
                {
Dean@960
   228
                    attachment = new PEPAttachment();
Dean@960
   229
                    attachment.Data = Encoding.UTF8.GetBytes(engineLog);
Dean@960
   230
                    attachment.FileName = "pEp Engine Log.txt";
Dean@660
   231
                    newMessage.Attachments.Add(attachment);
Dean@660
   232
                }
Dean@660
   233
Dean@660
   234
                Globals.ThisAddIn.SendWithoutProcessing(newMessage, true);
Dean@660
   235
            }
Dean@660
   236
Dean@1053
   237
            // Stop logging
Dean@1053
   238
            Globals.CloseLogFile();
Dean@1053
   239
Dean@660
   240
            // Locate the Outlook add-in
Dean@660
   241
            comAddIns = Globals.ThisAddIn.Application.COMAddIns;
Dean@660
   242
            foreach (Office.COMAddIn addin in comAddIns)
Dean@660
   243
            {
Dean@1023
   244
                if (string.Equals(addin.Description, Globals.PEP_NAME_ADDIN_DESC, StringComparison.OrdinalIgnoreCase))
Dean@660
   245
                {
Dean@660
   246
                    addIn = addin;
Dean@660
   247
                    break;
Dean@660
   248
                }
Dean@660
   249
            }
Dean@660
   250
Dean@660
   251
            // Shutdown add-in
Dean@660
   252
            if (addIn != null)
Dean@660
   253
            {
Dean@660
   254
                addIn.Connect = false;
Dean@660
   255
            }
Dean@660
   256
Dean@660
   257
            return;
Dean@660
   258
        }
Dean@660
   259
Dean@660
   260
        /// <summary>
Dean@660
   261
        /// Connects or disconnects all global error handling events.
Dean@660
   262
        /// </summary>
Dean@660
   263
        /// <param name="connect">True to connect events, false to disconnect.</param>
Dean@660
   264
        public static void ConnectEvents(bool connect)
Dean@660
   265
        {
Dean@660
   266
            // Connect events only if not already connected
Dean@660
   267
            if ((connect == true) &&
Dean@660
   268
                (eventsAreConnected == false))
Dean@660
   269
            {
Dean@660
   270
                Application.ThreadException += Application_UnhandledException;
Dean@660
   271
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Dean@660
   272
Dean@660
   273
                eventsAreConnected = true;
Dean@660
   274
            }
Dean@660
   275
            // Always attempt to disconnect
Dean@660
   276
            else if (connect == false)
Dean@660
   277
            {
Dean@660
   278
                Application.ThreadException -= Application_UnhandledException;
Dean@660
   279
                AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
Dean@660
   280
Dean@660
   281
                eventsAreConnected = false;
Dean@660
   282
            }
Dean@660
   283
Dean@660
   284
            return;
Dean@660
   285
        }
Dean@660
   286
Dean@660
   287
        /// <summary>
Dean@660
   288
        /// Adds the given text to the pEp for Outlook log.
Dean@660
   289
        /// </summary>
Dean@660
   290
        /// <param name="text">The text to add to the log.</param>
Dean@759
   291
        public static void Log(string text)
Dean@660
   292
        {
Dean@911
   293
            Globals.WriteToLogFile(text);
Dean@732
   294
            return;
Dean@732
   295
        }
Dean@732
   296
Dean@732
   297
        /// <summary>
Dean@732
   298
        /// Adds the given verbose text to the pEp for Outlook log only
Dean@732
   299
        /// when verbose logging is enabled.
Dean@732
   300
        /// </summary>
Dean@732
   301
        /// <param name="text">The verbose text to add to the lob.</param>
Dean@759
   302
        public static void LogVerbose(string text)
Dean@732
   303
        {
Dean@911
   304
            if (Globals.ThisAddIn.IsVerboseLoggingEnabled)
Dean@732
   305
            {
Dean@911
   306
                Globals.WriteToLogFile(System.DateTime.Now.ToString("HH:mm:ss.fff") + " | " + text);
Dean@660
   307
            }
Dean@660
   308
            return;
Dean@660
   309
        }
Dean@660
   310
Dean@660
   311
        /// <summary>
Dean@1365
   312
        /// Gets the pEp for Outlook version.
Dean@1365
   313
        /// This will never be null.
Dean@660
   314
        /// </summary>
Dean@1365
   315
        /// <returns>The version string.</returns>
Dean@1365
   316
        public static string GetPEPVersion()
Dean@660
   317
        {
Dean@1364
   318
            string version;
Dean@1364
   319
            string updateLevel;
Dean@1364
   320
Dean@1364
   321
            // Build the version string
Dean@1364
   322
            updateLevel = Properties.Settings.Default.UpdateLevel;
Dean@1364
   323
            version = string.Empty;
Dean@1364
   324
            version += Assembly.GetExecutingAssembly().GetName().Version.Major.ToString();
Dean@1364
   325
            version += "." + Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString();
Dean@1364
   326
Dean@1364
   327
            if (string.IsNullOrWhiteSpace(updateLevel) == false)
Dean@1364
   328
            {
Dean@1364
   329
                version += " Update " + updateLevel;
Dean@1364
   330
            }
Dean@660
   331
Dean@1365
   332
            return (version);
Dean@1365
   333
        }
Dean@1365
   334
Dean@1365
   335
        /// <summary>
Dean@1365
   336
        /// Gets the current system information string.
Dean@1365
   337
        /// </summary>
Dean@1365
   338
        /// <returns>The system information as a string.</returns>
Dean@1365
   339
        public static string GetSystemInfo()
Dean@1365
   340
        {
Dean@1365
   341
            string systemInfo = "";
Dean@1365
   342
            string version = GetPEPVersion();
Dean@1365
   343
Dean@660
   344
            try
Dean@660
   345
            {
Dean@660
   346
                systemInfo = string.Join(Environment.NewLine, new string[]
Dean@660
   347
                {
Dean@860
   348
                    "Serial: " + (Globals.RELEASE_MODE == Globals.ReleaseMode.Reader ? "Reader" : Properties.Settings.Default.Serial),
Dean@1364
   349
                    "p≡p Version: " + (version != null ? version : "-"),
Dean@660
   350
                    "Outlook Version: " + Globals.ThisAddIn.Application.Version,
Dean@660
   351
                    "OS Version: " + Environment.OSVersion.VersionString,
Dean@660
   352
                    "Language Install: " + ((Office.MsoLanguageID)Globals.ThisAddIn.Application.LanguageSettings.LanguageID[Office.MsoAppLanguageID.msoLanguageIDInstall]).ToString(),
Dean@660
   353
                    "Language UI: " + ((Office.MsoLanguageID)Globals.ThisAddIn.Application.LanguageSettings.LanguageID[Office.MsoAppLanguageID.msoLanguageIDUI]).ToString(),
Dean@660
   354
                });
Dean@660
   355
            }
Dean@660
   356
            catch { }
Dean@660
   357
Dean@660
   358
            return (systemInfo);
Dean@660
   359
        }
Dean@660
   360
Dean@660
   361
        /// <summary>
Dean@911
   362
        /// Writes the given text to the log file.
Dean@660
   363
        /// </summary>
Dean@911
   364
        /// <param name="text">The text to write to the log file.</param>
Dean@911
   365
        private static void WriteToLogFile(string text)
Dean@660
   366
        {
Dean@911
   367
            try
Dean@911
   368
            {
Dean@911
   369
                if (text != null)
Dean@911
   370
                {
Dean@923
   371
                    lock (mutexLogFile)
Dean@911
   372
                    {
Dean@923
   373
                        if (Globals.logWriter == null)
Dean@923
   374
                        {
Dean@923
   375
                            // Open the file
Dean@926
   376
                            Globals.logWriter = File.AppendText(Globals.GetLogFilePath());
Dean@923
   377
                        }
Dean@923
   378
Dean@923
   379
                        Globals.logWriter.WriteLine(text);
Dean@911
   380
                    }
Dean@911
   381
                }
Dean@911
   382
            }
Dean@911
   383
            catch { }
Dean@911
   384
Dean@911
   385
            return;
Dean@911
   386
        }
Dean@911
   387
Dean@911
   388
        /// <summary>
Dean@911
   389
        /// Reads all lines of text from the log file.
Dean@911
   390
        /// This will never return null.
Dean@911
   391
        /// </summary>
Dean@911
   392
        /// <returns>The lines of text in the log file.</returns>
Dean@911
   393
        public static string ReadLogFile()
Dean@911
   394
        {
Dean@911
   395
            string log = "";
Dean@911
   396
            string path;
Dean@911
   397
            StreamReader logReader;
Dean@911
   398
Dean@911
   399
            try
Dean@660
   400
            {
Dean@911
   401
                Globals.CloseLogFile();
Dean@911
   402
Dean@923
   403
                lock (mutexLogFile)
Dean@911
   404
                {
Dean@926
   405
                    path = Globals.GetLogFilePath();
Dean@923
   406
                    if (File.Exists(path))
Dean@923
   407
                    {
Dean@923
   408
                        logReader = new StreamReader(path);
Dean@923
   409
                        log = logReader.ReadToEnd();
Dean@911
   410
Dean@923
   411
                        logReader.Close();
Dean@923
   412
                        logReader.Dispose();
Dean@923
   413
                    }
Dean@911
   414
                }
Dean@911
   415
Dean@911
   416
                // Never allow null
Dean@911
   417
                if (log == null)
Dean@911
   418
                {
Dean@911
   419
                    log = "";
Dean@911
   420
                }
Dean@660
   421
            }
Dean@911
   422
            catch { }
Dean@660
   423
Dean@911
   424
            return (log);
Dean@911
   425
        }
Dean@911
   426
Dean@911
   427
        /// <summary>
Dean@911
   428
        /// Closes and releases any open log file writer.
Dean@911
   429
        /// </summary>
Dean@911
   430
        public static void CloseLogFile()
Dean@911
   431
        {
Dean@911
   432
            try
Dean@911
   433
            {
Dean@923
   434
                lock (mutexLogFile)
Dean@911
   435
                {
Dean@923
   436
                    if (Globals.logWriter != null)
Dean@923
   437
                    {
Dean@923
   438
                        Globals.logWriter.Flush();
Dean@923
   439
                        Globals.logWriter.Close();
Dean@923
   440
                        Globals.logWriter.Dispose();
Dean@923
   441
                        Globals.logWriter = null;
Dean@923
   442
                    }
Dean@911
   443
                }
Dean@911
   444
            }
Dean@911
   445
            catch { }
Dean@911
   446
Dean@911
   447
            return;
Dean@911
   448
        }
Dean@911
   449
Dean@911
   450
        /// <summary>
Dean@911
   451
        /// Clears all logged text by deleting the file.
Dean@911
   452
        /// </summary>
Dean@911
   453
        public static void ClearLogFile()
Dean@911
   454
        {
Dean@911
   455
            string path;
Dean@911
   456
Dean@911
   457
            try
Dean@911
   458
            {
Dean@911
   459
                Globals.CloseLogFile();
Dean@911
   460
Dean@923
   461
                lock (mutexLogFile)
Dean@911
   462
                {
Dean@926
   463
                    path = Globals.GetLogFilePath();
Dean@923
   464
                    if (File.Exists(path))
Dean@923
   465
                    {
Dean@923
   466
                        File.Delete(path);
Dean@923
   467
                    }
Dean@911
   468
                }
Dean@911
   469
            }
Dean@911
   470
            catch { }
Dean@911
   471
Dean@911
   472
            return;
Dean@660
   473
        }
Dean@660
   474
Dean@926
   475
        /// <summary>
Dean@926
   476
        /// Gets the path of the log file.
Dean@926
   477
        /// </summary>
Dean@926
   478
        /// <returns>The path of the log file.</returns>
Dean@926
   479
        private static string GetLogFilePath()
Dean@926
   480
        {
Dean@926
   481
            return (Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "pEp", LOG_FILE_NAME));
Dean@926
   482
        }
Dean@926
   483
Dean@660
   484
        /**************************************************************
Dean@660
   485
         * 
Dean@660
   486
         * Event Handling
Dean@660
   487
         * 
Dean@660
   488
         *************************************************************/
Dean@660
   489
Dean@660
   490
        /// <summary>
Dean@660
   491
        /// Event handler for when an unhandled error occurs within the current application.
Dean@660
   492
        /// </summary>
Dean@660
   493
        private static void Application_UnhandledException(object sender, ThreadExceptionEventArgs e)
Dean@660
   494
        {
Dean@860
   495
            Globals.StopAndSendCrashReport(e.Exception);
Dean@660
   496
            return;
Dean@660
   497
        }
Dean@660
   498
Dean@660
   499
        /// <summary>
Dean@660
   500
        /// Event handler for when an unhandled error occurs within the current domain.
Dean@660
   501
        /// </summary>
Dean@660
   502
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
Dean@660
   503
        {
Dean@860
   504
            Globals.StopAndSendCrashReport();
Dean@660
   505
            return;
Dean@660
   506
        }
Dean@660
   507
Dean@606
   508
    }
Dean@606
   509
}