author | Thomas |
Tue, 22 Nov 2016 15:45:44 +0100 | |
changeset 1485 | 022959f1542b |
parent 1467 | 622a86775584 |
child 1487 | cd258d88fcc3 |
permissions | -rw-r--r-- |
155
cda43d18bcd3
Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents:
144
diff
changeset
|
1 |
using Microsoft.Win32; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
2 |
using pEp.UI; |
155
cda43d18bcd3
Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents:
144
diff
changeset
|
3 |
using pEpCOMServerAdapterLib; |
cda43d18bcd3
Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents:
144
diff
changeset
|
4 |
using System; |
0 | 5 |
using System.Collections.Generic; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
6 |
using System.ComponentModel; |
155
cda43d18bcd3
Add state to handshake form and decouple it from the encryption status panel
Dean Looyengoed
parents:
144
diff
changeset
|
7 |
using System.Globalization; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
8 |
using System.IO; |
0 | 9 |
using System.Runtime.InteropServices; |
10 |
using System.Threading; |
|
47 | 11 |
using System.Windows.Forms; |
714
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
12 |
using Office = Microsoft.Office.Core; |
0 | 13 |
using Outlook = Microsoft.Office.Interop.Outlook; |
14 |
||
15 |
namespace pEp |
|
16 |
{ |
|
17 |
public partial class ThisAddIn |
|
18 |
{ |
|
190
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
19 |
#region VSTO generated code |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
20 |
|
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
21 |
/// <summary> |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
22 |
/// Required method for Designer support - do not modify |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
23 |
/// the contents of this method with the code editor. |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
24 |
/// </summary> |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
25 |
private void InternalStartup() |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
26 |
{ |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
27 |
this.Startup += new System.EventHandler(ThisAddIn_Startup); |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
28 |
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
29 |
} |
201
9e0548fa3942
Code reformatting.
Markus Schaber <markus@pep-security.net>
parents:
191
diff
changeset
|
30 |
|
190
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
31 |
#endregion |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
32 |
|
1441
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
33 |
internal delegate void NewAccountEventHandler(object sender, NewAccountEventArgs e); |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
34 |
|
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
35 |
/// <summary> |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
36 |
/// Custom event for when the add-in is starting for the first time. |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
37 |
/// </summary> |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
38 |
internal event EventHandler FirstStartup; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
39 |
|
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
40 |
/// <summary> |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
41 |
/// Custom event for when a new account is detected by the add-in. |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
42 |
/// </summary> |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
43 |
internal event NewAccountEventHandler NewAccount; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
44 |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
45 |
private List<KeyValuePair<CultureInfo, string>> _LanguageList = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
46 |
private static pEpEngine _PEPEngine = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
47 |
private Outlook.Folder _PEPStoreRootFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
48 |
private PEPSettings _Settings = null; |
64
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
49 |
|
1405 | 50 |
#if !READER_RELEASE_MODE |
51 |
private AdapterCallbacks adapterCallbacks = null; |
|
52 |
#endif |
|
53 |
||
1394
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
54 |
private bool initialized = false; |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
55 |
private bool isItemSendHandlerEnabled = true; |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
56 |
private FormControlOptions.State lastOptionsState = null; |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
57 |
private Dictionary<string, string> userIdCache = new Dictionary<string, string>(); |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
58 |
private List<WatchedSentFolder> watchedSentFolders = new List<WatchedSentFolder>(); |
1398
c603ea77d615
Add a WatchedMailItem class and use it to track loaded MailItems.
Dean
parents:
1394
diff
changeset
|
59 |
private List<WatchedMailItem> watchedMailItems = new List<WatchedMailItem>(); |
190
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
60 |
|
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
61 |
/************************************************************** |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
62 |
* |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
63 |
* Property Accessors |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
64 |
* |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
65 |
*************************************************************/ |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
66 |
|
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
67 |
/// <summary> |
854
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
68 |
/// Gets the list of languages supported in the pEp engine. |
935
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
69 |
/// The list of language includes a key-value pair of the culture as well as a |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
70 |
/// display phrase in the native language for the trustwords. |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
71 |
/// (phrase example: "I want to display the trustwords in English language") |
854
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
72 |
/// </summary> |
935
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
73 |
internal List<KeyValuePair<CultureInfo, string>> LanguageList |
854
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
74 |
{ |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
75 |
get |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
76 |
{ |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
77 |
string code; |
935
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
78 |
string phrase; |
854
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
79 |
string engineList; |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
80 |
string[] languages; |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
81 |
string[] language; |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
82 |
|
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
83 |
if (this._LanguageList == null) |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
84 |
{ |
935
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
85 |
this._LanguageList = new List<KeyValuePair<CultureInfo, string>>(); |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
86 |
|
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
87 |
try |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
88 |
{ |
1343
1520e906a692
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1340
diff
changeset
|
89 |
engineList = ThisAddIn.PEPEngine.GetLanguageList(); |
935
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
90 |
} |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
91 |
catch |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
92 |
{ |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
93 |
engineList = ""; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
94 |
Log.Error("LanguageList: Failed to get list from engine."); |
935
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
95 |
} |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
96 |
|
854
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
97 |
languages = engineList.Split('\n'); |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
98 |
|
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
99 |
// Go through each language group |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
100 |
for (int i = 0; i < languages.Length; i++) |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
101 |
{ |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
102 |
language = languages[i].Split(','); |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
103 |
|
935
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
104 |
if (language.Length == 3) |
854
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
105 |
{ |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
106 |
code = language[0].Trim(); |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
107 |
code = code.Replace("\"", ""); |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
108 |
|
935
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
109 |
phrase = language[2].Trim(); |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
110 |
phrase = phrase.Replace("\"", ""); |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
111 |
|
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
112 |
this._LanguageList.Add(new KeyValuePair<CultureInfo, string>(new CultureInfo(code), |
5308aa8494f0
Update language list and trustwords language selection to use latest engine format.
Dean Looyengoed
parents:
933
diff
changeset
|
113 |
phrase)); |
854
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
114 |
} |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
115 |
} |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
116 |
} |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
117 |
|
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
118 |
return (this._LanguageList); |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
119 |
} |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
120 |
} |
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
121 |
|
f47d5c915d54
Support changing trustwords language during advanced handshake.
Dean Looyengoed
parents:
853
diff
changeset
|
122 |
/// <summary> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
123 |
/// Gets the static pEp engine reference. |
190
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
124 |
/// </summary> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
125 |
internal static pEpEngine PEPEngine |
64
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
126 |
{ |
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
127 |
get |
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
128 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
129 |
if (ThisAddIn._PEPEngine == null) |
64
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
130 |
{ |
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
131 |
try |
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
132 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
133 |
ThisAddIn._PEPEngine = new pEpEngine(); |
64
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
134 |
} |
467
aeb05f7b2704
Finish initial implementation of global exception handler and sending crash report.
Dean Looyengoed
parents:
465
diff
changeset
|
135 |
catch (Exception ex) |
64
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
136 |
{ |
467
aeb05f7b2704
Finish initial implementation of global exception handler and sending crash report.
Dean Looyengoed
parents:
465
diff
changeset
|
137 |
string summaryMessage = Properties.Resources.Message_InitError + " " + |
aeb05f7b2704
Finish initial implementation of global exception handler and sending crash report.
Dean Looyengoed
parents:
465
diff
changeset
|
138 |
Properties.Resources.Message_Reinstall; |
860 | 139 |
Globals.StopAndSendCrashReport(ex, summaryMessage, false, true); |
460
690f8853d7ae
Start to implement the global exception handler in ThisAddIn.
Dean Looyengoed
parents:
455
diff
changeset
|
140 |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
141 |
return (null); |
64
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
142 |
} |
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
143 |
} |
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
144 |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
145 |
return (ThisAddIn._PEPEngine); |
64
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
146 |
} |
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
147 |
} |
5111a11eed7f
replacing TextMessage object with struct
Volker Birk <vb@pep-project.org>
parents:
61
diff
changeset
|
148 |
|
611 | 149 |
/// <summary> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
150 |
/// Gets the root folder of the pEp data store. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
151 |
/// This is primarily used to save unencrypted outlook mail items (mirrors). |
1115
f152a1ffe405
Rename 'pEp' to 'PEPEngine' and 'TempFolder' to 'PEPStoreRootFolder' in ThisAddIn.
Dean
parents:
1114
diff
changeset
|
152 |
/// </summary> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
153 |
internal Outlook.Folder PEPStoreRootFolder |
1115
f152a1ffe405
Rename 'pEp' to 'PEPEngine' and 'TempFolder' to 'PEPStoreRootFolder' in ThisAddIn.
Dean
parents:
1114
diff
changeset
|
154 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
155 |
get { return (this._PEPStoreRootFolder); } |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
156 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
157 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
158 |
/// <summary> |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
159 |
/// Gets the current pEp settings for the add-in. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
160 |
/// </summary> |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
161 |
internal PEPSettings Settings |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
162 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
163 |
get { return (this._Settings); } |
1090
6234a0b9c6a8
Add PEPSettings class and move all add-in configuration into it.
Dean
parents:
1082
diff
changeset
|
164 |
} |
6234a0b9c6a8
Add PEPSettings class and move all add-in configuration into it.
Dean
parents:
1082
diff
changeset
|
165 |
|
190
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
166 |
/************************************************************** |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
167 |
* |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
168 |
* Methods |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
169 |
* |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
170 |
*************************************************************/ |
335 | 171 |
|
361
bbe04f85ac03
Updates to the get my identity methods adding the ability to get my identity from a mail item.
Dean Looyengoed
parents:
342
diff
changeset
|
172 |
/// <summary> |
bbe04f85ac03
Updates to the get my identity methods adding the ability to get my identity from a mail item.
Dean Looyengoed
parents:
342
diff
changeset
|
173 |
/// Required override to add ribbon extensions. |
bbe04f85ac03
Updates to the get my identity methods adding the ability to get my identity from a mail item.
Dean Looyengoed
parents:
342
diff
changeset
|
174 |
/// </summary> |
326
2acfe22efee4
Remove pEp ribbon tab and add ribbon for backstage options (disabled for now).
Dean Looyengoed
parents:
307
diff
changeset
|
175 |
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject() |
2acfe22efee4
Remove pEp ribbon tab and add ribbon for backstage options (disabled for now).
Dean Looyengoed
parents:
307
diff
changeset
|
176 |
{ |
340
ded73ac01f51
Implement the send unencrypted option in the ribbon.
Dean Looyengoed
parents:
335
diff
changeset
|
177 |
return new RibbonCustomizations(); |
335 | 178 |
} |
0 | 179 |
|
361
bbe04f85ac03
Updates to the get my identity methods adding the ability to get my identity from a mail item.
Dean Looyengoed
parents:
342
diff
changeset
|
180 |
/// <summary> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
181 |
/// Syncronizes the current settings class with the pEp for Outlook instance and the pEp engine. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
182 |
/// This code should be similar to the Settings_PropertyChanged event. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
183 |
/// </summary> |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
184 |
private void SyncWithSettings() |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
185 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
186 |
bool exists; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
187 |
Outlook.NameSpace ns = Application.Session; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
188 |
Outlook.Account acct = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
189 |
Outlook.Accounts accounts = ns.Accounts; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
190 |
List<KeyValuePair<CultureInfo, string>> languages; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
191 |
List<PEPSettings.PEPAccountSettings> legacyAcctSettings = new List<PEPSettings.PEPAccountSettings>(); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
192 |
PEPSettings.PEPAccountSettings newAcctSettings; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
193 |
PEPSettings.PEPAccountSettings existingAcctSettings; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
194 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
195 |
try |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
196 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
197 |
if (this._Settings != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
198 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
199 |
// Extract any legacy account settings which don't have a Type but do have an SMTP address |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
200 |
for (int i = (this._Settings.AccountSettingsList.Count - 1); i >= 0; i--) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
201 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
202 |
existingAcctSettings = this._Settings.AccountSettingsList[i]; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
203 |
|
1348
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
204 |
if ((string.IsNullOrEmpty(existingAcctSettings.SmtpAddress) == false) && |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
205 |
(string.IsNullOrEmpty(existingAcctSettings.Type) == true)) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
206 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
207 |
legacyAcctSettings.Add(existingAcctSettings); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
208 |
this._Settings.AccountSettingsList.RemoveAt(i); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
209 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
210 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
211 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
212 |
// Add any new Outlook accounts to the account settings list |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
213 |
for (int i = 1; i <= accounts.Count; i++) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
214 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
215 |
acct = accounts[i]; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
216 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
217 |
if (string.IsNullOrWhiteSpace(acct.SmtpAddress) == false) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
218 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
219 |
newAcctSettings = new PEPSettings.PEPAccountSettings(); |
1348
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
220 |
newAcctSettings.SmtpAddress = acct.SmtpAddress; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
221 |
newAcctSettings.Type = acct.AccountType.ToString(); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
222 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
223 |
// Check if it already exists in the list |
1348
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
224 |
existingAcctSettings = this._Settings.GetAccountSettings(newAcctSettings.SmtpAddress, newAcctSettings.Type); |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
225 |
if (existingAcctSettings == null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
226 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
227 |
this._Settings.AccountSettingsList.Add(newAcctSettings); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
228 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
229 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
230 |
else |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
231 |
{ |
1350
8fdce6140e29
Change more places to .net standard capitalization rules.
Dean
parents:
1349
diff
changeset
|
232 |
Log.Warning("SyncWithSettings: Invalid Smtp address detected, skipping account."); |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
233 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
234 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
235 |
Marshal.ReleaseComObject(acct); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
236 |
acct = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
237 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
238 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
239 |
// Remove any entries of the account settings list not in Outlook |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
240 |
// This is needed to skip any entries in the registry that may be invalid and user created |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
241 |
for (int i = (this._Settings.AccountSettingsList.Count - 1); i >= 0; i--) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
242 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
243 |
existingAcctSettings = this._Settings.AccountSettingsList[i]; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
244 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
245 |
// Check if it exists in Outlook |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
246 |
exists = false; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
247 |
for (int j = 1; j <= accounts.Count; j++) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
248 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
249 |
acct = accounts[j]; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
250 |
newAcctSettings = new PEPSettings.PEPAccountSettings(); |
1348
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
251 |
newAcctSettings.SmtpAddress = acct.SmtpAddress; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
252 |
newAcctSettings.Type = acct.AccountType.ToString(); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
253 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
254 |
if (existingAcctSettings.EqualsByAddressAndType(newAcctSettings)) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
255 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
256 |
exists = true; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
257 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
258 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
259 |
Marshal.ReleaseComObject(acct); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
260 |
acct = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
261 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
262 |
if (exists) { break; } |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
263 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
264 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
265 |
// Delete if necessary |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
266 |
if (exists == false) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
267 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
268 |
this._Settings.AccountSettingsList.RemoveAt(i); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
269 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
270 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
271 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
272 |
// Add and legacy settings back to the validated account settings list |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
273 |
for (int i = 0; i < legacyAcctSettings.Count; i++) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
274 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
275 |
for (int j = 0; j < this._Settings.AccountSettingsList.Count; j++) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
276 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
277 |
existingAcctSettings = this._Settings.AccountSettingsList[j]; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
278 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
279 |
if (legacyAcctSettings[i].EqualsByAddress(existingAcctSettings)) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
280 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
281 |
// Set the store securely setting only |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
282 |
existingAcctSettings.IsSecureStorageEnabled = legacyAcctSettings[i].IsSecureStorageEnabled; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
283 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
284 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
285 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
286 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
287 |
// Sync IsKeyServerUsed with engine |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
288 |
if (this._Settings.IsKeyServerUsed) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
289 |
{ |
1337
6b93b1a3b751
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1328
diff
changeset
|
290 |
ThisAddIn.PEPEngine.StartKeyserverLookup(); |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
291 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
292 |
else |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
293 |
{ |
1337
6b93b1a3b751
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1328
diff
changeset
|
294 |
ThisAddIn.PEPEngine.StopKeyserverLookup(); |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
295 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
296 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
297 |
// Sync IsPassiveModeEnabled with engine |
1337
6b93b1a3b751
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1328
diff
changeset
|
298 |
ThisAddIn.PEPEngine.PassiveMode(this._Settings.IsPassiveModeEnabled); |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
299 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
300 |
// Sync IsPEPFolderVisible with Outlook |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
301 |
this.SetPEPStoreRootFolderVisibility(this._Settings.IsPEPFolderVisible); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
302 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
303 |
// Sync IsUnencryptedSubjectEnabled with engine |
1337
6b93b1a3b751
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1328
diff
changeset
|
304 |
ThisAddIn.PEPEngine.UnencryptedSubject(this._Settings.IsUnencryptedSubjectEnabled); |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
305 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
306 |
// Sync IsVerboseLoggingEnabled with engine |
1337
6b93b1a3b751
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1328
diff
changeset
|
307 |
ThisAddIn.PEPEngine.VerboseLogging(this._Settings.IsVerboseLoggingEnabled); |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
308 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
309 |
// Sync TrustwordsCulture with engine |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
310 |
if (this._Settings.TrustwordsCulture != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
311 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
312 |
// Validate it exists in the engine list |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
313 |
exists = false; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
314 |
languages = this.LanguageList; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
315 |
foreach (KeyValuePair<CultureInfo, string> entry in languages) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
316 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
317 |
if (entry.Key.LCID == this._Settings.TrustwordsCulture.LCID) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
318 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
319 |
exists = true; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
320 |
break; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
321 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
322 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
323 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
324 |
if (exists == false) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
325 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
326 |
// Reset to default |
1351
80e7cec5b7cc
Select the default trustwords language as the UI language.
Dean
parents:
1350
diff
changeset
|
327 |
this._Settings.TrustwordsCulture = this.GetActiveUICulture(); |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
328 |
Log.Warning("SyncWithSettings: Invalid TrustwordsCulture detected, setting to default."); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
329 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
330 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
331 |
else |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
332 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
333 |
// Reset to default |
1351
80e7cec5b7cc
Select the default trustwords language as the UI language.
Dean
parents:
1350
diff
changeset
|
334 |
this._Settings.TrustwordsCulture = this.GetActiveUICulture(); |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
335 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
336 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
337 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
338 |
catch { } |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
339 |
finally |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
340 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
341 |
if (ns != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
342 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
343 |
Marshal.ReleaseComObject(ns); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
344 |
ns = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
345 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
346 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
347 |
if (acct != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
348 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
349 |
Marshal.ReleaseComObject(acct); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
350 |
acct = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
351 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
352 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
353 |
if (accounts != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
354 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
355 |
Marshal.ReleaseComObject(accounts); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
356 |
accounts = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
357 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
358 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
359 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
360 |
return; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
361 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
362 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
363 |
/// <summary> |
1441
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
364 |
/// Compares the given settings with the current state of Outlook and detects any changes. |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
365 |
/// This is primarily used to find new accounts or identify first startup. |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
366 |
/// </summary> |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
367 |
/// <param name="lastSettings">The last settings to compare with. |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
368 |
/// This should be the settings just loaded from the registry at startup (last saved settings).</param> |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
369 |
private void DetectChangesFromLastSettings(PEPSettings lastSettings) |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
370 |
{ |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
371 |
Outlook.Account account = null; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
372 |
Outlook.Accounts accounts = null; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
373 |
Outlook.NameSpace ns = null; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
374 |
PEPSettings.PEPAccountSettings acctSettings; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
375 |
NewAccountEventArgs args; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
376 |
|
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
377 |
// Detect first startup |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
378 |
if (lastSettings.IsFirstStartupComplete == false) |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
379 |
{ |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
380 |
this.FirstStartup?.Invoke(this, new EventArgs()); |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
381 |
} |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
382 |
|
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
383 |
// Detect new accounts |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
384 |
try |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
385 |
{ |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
386 |
ns = this.Application.Session; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
387 |
accounts = ns.Accounts; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
388 |
|
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
389 |
for (int i = 1; i <= accounts.Count; i++) |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
390 |
{ |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
391 |
account = accounts[i]; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
392 |
|
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
393 |
if (account != null) |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
394 |
{ |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
395 |
// Locate any existing account settings |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
396 |
acctSettings = Globals.ThisAddIn.Settings.GetAccountSettings(account.SmtpAddress, |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
397 |
account.AccountType.ToString()); |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
398 |
if (acctSettings == null) |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
399 |
{ |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
400 |
// Raise the event |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
401 |
args = new NewAccountEventArgs(); |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
402 |
args.AccountType = account.AccountType; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
403 |
args.DisplayName = account.DisplayName; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
404 |
args.SmtpAddress = account.SmtpAddress; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
405 |
args.UserName = account.UserName; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
406 |
|
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
407 |
this.NewAccount?.Invoke(this, args); |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
408 |
} |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
409 |
|
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
410 |
Marshal.ReleaseComObject(account); |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
411 |
account = null; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
412 |
} |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
413 |
} |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
414 |
} |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
415 |
catch (Exception ex) |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
416 |
{ |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
417 |
Log.Error("DetectChangesFromLastSettings: Failure detecting new accounts, " + ex.ToString()); |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
418 |
} |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
419 |
finally |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
420 |
{ |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
421 |
if (account != null) |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
422 |
{ |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
423 |
Marshal.ReleaseComObject(account); |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
424 |
account = null; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
425 |
} |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
426 |
|
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
427 |
if (accounts != null) |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
428 |
{ |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
429 |
Marshal.ReleaseComObject(accounts); |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
430 |
accounts = null; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
431 |
} |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
432 |
|
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
433 |
if (ns != null) |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
434 |
{ |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
435 |
Marshal.ReleaseComObject(ns); |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
436 |
ns = null; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
437 |
} |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
438 |
} |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
439 |
|
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
440 |
return; |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
441 |
} |
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
442 |
|
5d86ae076016
Add custom FirstStartup and NewAccount events to ThisAddIn.
Dean
parents:
1438
diff
changeset
|
443 |
/// <summary> |
626 | 444 |
/// Detects and disables GPG for Windows GpgOL Outlook add-in. |
445 |
/// </summary> |
|
446 |
/// <returns>True if the GpgOL add-in was disabled.</returns> |
|
447 |
private bool DisableGpgOL() |
|
448 |
{ |
|
449 |
bool wasDisabled = false; |
|
830
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
450 |
Office.COMAddIns comAddIns = null; |
626 | 451 |
|
830
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
452 |
try |
626 | 453 |
{ |
830
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
454 |
comAddIns = Globals.ThisAddIn.Application.COMAddIns; |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
455 |
foreach (Office.COMAddIn addin in comAddIns) |
626 | 456 |
{ |
830
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
457 |
if (string.Equals(addin.Description, "GpgOL - The GnuPG Outlook Plugin", StringComparison.OrdinalIgnoreCase)) |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
458 |
{ |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
459 |
addin.Connect = false; |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
460 |
wasDisabled = true; |
626 | 461 |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
462 |
Log.Info("DisableGpgOL: GpgOL was detected and disabled."); |
830
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
463 |
} |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
464 |
} |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
465 |
} |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
466 |
catch (Exception ex) |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
467 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
468 |
Log.Error("DisableGpgOL: Error trying to disable GpgOL, " + ex.ToString()); |
830
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
469 |
} |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
470 |
finally |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
471 |
{ |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
472 |
if (comAddIns != null) |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
473 |
{ |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
474 |
Marshal.ReleaseComObject(comAddIns); |
592efb9cf41d
Handle and log errors in DisableGpgOL method.
Dean Looyengoed
parents:
820
diff
changeset
|
475 |
comAddIns = null; |
626 | 476 |
} |
477 |
} |
|
478 |
||
479 |
return (wasDisabled); |
|
480 |
} |
|
481 |
||
482 |
/// <summary> |
|
384
a0aa034cb7f3
Create and implement new classes for PEPAttachment, PEPIdentity and PEPMessage.
Dean Looyengoed
parents:
378
diff
changeset
|
483 |
/// Registers each personal identity in the pEp engine. |
a0aa034cb7f3
Create and implement new classes for PEPAttachment, PEPIdentity and PEPMessage.
Dean Looyengoed
parents:
378
diff
changeset
|
484 |
/// An identity is determined by each account in Outlook. |
361
bbe04f85ac03
Updates to the get my identity methods adding the ability to get my identity from a mail item.
Dean Looyengoed
parents:
342
diff
changeset
|
485 |
/// </summary> |
910
9bd60ca2c6ac
Add offline support (mostly for Exchange accounts).
Dean Looyengoed
parents:
902
diff
changeset
|
486 |
internal void RegisterMyself() |
0 | 487 |
{ |
919
252172b0fbec
Standardize calls to the Session in ThisAddIn.
Dean Looyengoed
parents:
918
diff
changeset
|
488 |
Outlook.NameSpace ns = this.Application.Session; |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
489 |
Outlook.Account acct = null; |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
490 |
Outlook.Accounts accounts = ns.Accounts; |
576
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
491 |
Outlook.Recipient currUser = null; |
1337
6b93b1a3b751
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1328
diff
changeset
|
492 |
pEpIdentity me; |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
493 |
|
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
494 |
for (int i = 1; i <= accounts.Count; i++) |
0 | 495 |
{ |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
496 |
acct = accounts[i]; |
576
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
497 |
currUser = acct.CurrentUser; |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
498 |
|
1337
6b93b1a3b751
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1328
diff
changeset
|
499 |
me = new pEpIdentity(); |
1347
b374b67e6dd2
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1344
diff
changeset
|
500 |
me.Address = acct.SmtpAddress; |
b374b67e6dd2
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1344
diff
changeset
|
501 |
me.UserName = (currUser != null ? currUser.Name : null); |
1348
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
502 |
me.UserId = Globals.ThisAddIn.GetUserId(me.Address, null); |
12 | 503 |
|
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
504 |
// Log information if invalid |
1347
b374b67e6dd2
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1344
diff
changeset
|
505 |
if (string.IsNullOrWhiteSpace(me.Address)) |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
506 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
507 |
Log.Warning("RegisterMyself: Myself[" + i.ToString() + "] doesn't have an address."); |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
508 |
} |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
509 |
|
1347
b374b67e6dd2
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1344
diff
changeset
|
510 |
if (string.IsNullOrWhiteSpace(me.UserName)) |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
511 |
{ |
1348
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
512 |
Log.Warning("RegisterMyself: Myself[" + i.ToString() + "] doesn't have a user name."); |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
513 |
} |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
514 |
|
1367
1aa823105f05
OUT-128: Only log exceptions during Myself calls which can fail during key generation.
Dean
parents:
1359
diff
changeset
|
515 |
/* Call engine to register myself (doesn't matter if already done in a past instance) |
1aa823105f05
OUT-128: Only log exceptions during Myself calls which can fail during key generation.
Dean
parents:
1359
diff
changeset
|
516 |
* Note that key generation can take place during the call to Myself if it's a new installation |
1aa823105f05
OUT-128: Only log exceptions during Myself calls which can fail during key generation.
Dean
parents:
1359
diff
changeset
|
517 |
* and the engine is unable to elect a key. In this situation key generation can take some time. |
1aa823105f05
OUT-128: Only log exceptions during Myself calls which can fail during key generation.
Dean
parents:
1359
diff
changeset
|
518 |
* It takes long-enough for the call to the adapter to timeout here and throw an exception. |
1aa823105f05
OUT-128: Only log exceptions during Myself calls which can fail during key generation.
Dean
parents:
1359
diff
changeset
|
519 |
* However, since the fingerprint of the own identity is not actually needed here, the assumption is |
1aa823105f05
OUT-128: Only log exceptions during Myself calls which can fail during key generation.
Dean
parents:
1359
diff
changeset
|
520 |
* made that the engine will be OK and continue processing. |
1aa823105f05
OUT-128: Only log exceptions during Myself calls which can fail during key generation.
Dean
parents:
1359
diff
changeset
|
521 |
* The exception is simply ignored and we go to the next identity. |
1aa823105f05
OUT-128: Only log exceptions during Myself calls which can fail during key generation.
Dean
parents:
1359
diff
changeset
|
522 |
*/ |
12 | 523 |
try |
524 |
{ |
|
1337
6b93b1a3b751
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1328
diff
changeset
|
525 |
ThisAddIn.PEPEngine.Myself(me); |
12 | 526 |
} |
527 |
catch (COMException ex) |
|
528 |
{ |
|
1367
1aa823105f05
OUT-128: Only log exceptions during Myself calls which can fail during key generation.
Dean
parents:
1359
diff
changeset
|
529 |
Log.Warning("RegisterMyself: Engine returned exception, " + ex.ToString()); |
12 | 530 |
} |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
531 |
|
576
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
532 |
// Release objects |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
533 |
if (acct != null) |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
534 |
{ |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
535 |
Marshal.ReleaseComObject(acct); |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
536 |
acct = null; |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
537 |
} |
576
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
538 |
|
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
539 |
if (currUser != null) |
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
540 |
{ |
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
541 |
Marshal.ReleaseComObject(currUser); |
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
542 |
currUser = null; |
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
543 |
} |
575
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
544 |
} |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
545 |
|
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
546 |
// Release objects |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
547 |
if (ns != null) |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
548 |
{ |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
549 |
Marshal.ReleaseComObject(ns); |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
550 |
ns = null; |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
551 |
} |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
552 |
|
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
553 |
if (acct != null) |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
554 |
{ |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
555 |
Marshal.ReleaseComObject(acct); |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
556 |
acct = null; |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
557 |
} |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
558 |
|
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
559 |
if (accounts != null) |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
560 |
{ |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
561 |
Marshal.ReleaseComObject(accounts); |
27512d0d41cf
Rewrite RegisterMyself method to release objects and log issues.
Dean Looyengoed
parents:
571
diff
changeset
|
562 |
accounts = null; |
0 | 563 |
} |
588
2d12fb5ee4fc
Add developer mode to config and options state.
Dean Looyengoed
parents:
587
diff
changeset
|
564 |
|
576
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
565 |
if (currUser != null) |
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
566 |
{ |
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
567 |
Marshal.ReleaseComObject(currUser); |
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
568 |
currUser = null; |
e0190df007de
Check if current user is null in RegisterMyself method.
Dean Looyengoed
parents:
575
diff
changeset
|
569 |
} |
0 | 570 |
|
384
a0aa034cb7f3
Create and implement new classes for PEPAttachment, PEPIdentity and PEPMessage.
Dean Looyengoed
parents:
378
diff
changeset
|
571 |
return; |
190
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
572 |
} |
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
573 |
|
a685c30e07d2
Refactor/comment/partial rewrite of the ThisAddIn class.
Dean Looyengoed
parents:
168
diff
changeset
|
574 |
/// <summary> |
776
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
575 |
/// Gets the pEp user ID for the given address and contact. |
362
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
576 |
/// </summary> |
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
577 |
/// <param name="address">The address to get the user ID for.</param> |
776
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
578 |
/// <param name="contact">The contact associated with the address (if any). |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
579 |
/// This value can be null and is not required for 'myself' user IDs.</param> |
362
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
580 |
/// <returns>The user ID (Outlook EntryID) for the given address</returns> |
1348
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
581 |
internal string GetUserId(string address, |
910
9bd60ca2c6ac
Add offline support (mostly for Exchange accounts).
Dean Looyengoed
parents:
902
diff
changeset
|
582 |
Outlook.ContactItem contact) |
362
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
583 |
{ |
511
4a970a30be20
Get rid of unnecessary null/empty check as the structure of the method has changed.
Dean Looyengoed
parents:
510
diff
changeset
|
584 |
string id = null; |
776
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
585 |
Outlook.Folder contactFolder = null; |
507
d0b1586c5235
Add fallback to GetUserID that searches address book entry-by-entry.
Dean Looyengoed
parents:
502
diff
changeset
|
586 |
|
474
a27dbbb2dd88
Add try/catch and error handling around several ThisAddIn methods.
Dean Looyengoed
parents:
473
diff
changeset
|
587 |
try |
362
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
588 |
{ |
608
38ba4b8308f2
Update GetUserID method to cache IDs, skip Exchange servers and create new contacts if necessary.
Dean Looyengoed
parents:
607
diff
changeset
|
589 |
if (string.IsNullOrEmpty(address) == false) |
569 | 590 |
{ |
608
38ba4b8308f2
Update GetUserID method to cache IDs, skip Exchange servers and create new contacts if necessary.
Dean Looyengoed
parents:
607
diff
changeset
|
591 |
// Search cache |
38ba4b8308f2
Update GetUserID method to cache IDs, skip Exchange servers and create new contacts if necessary.
Dean Looyengoed
parents:
607
diff
changeset
|
592 |
if (id == null) |
511
4a970a30be20
Get rid of unnecessary null/empty check as the structure of the method has changed.
Dean Looyengoed
parents:
510
diff
changeset
|
593 |
{ |
569 | 594 |
try |
474
a27dbbb2dd88
Add try/catch and error handling around several ThisAddIn methods.
Dean Looyengoed
parents:
473
diff
changeset
|
595 |
{ |
1348
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
596 |
id = this.userIdCache[address]; |
569 | 597 |
} |
598 |
catch |
|
599 |
{ |
|
608
38ba4b8308f2
Update GetUserID method to cache IDs, skip Exchange servers and create new contacts if necessary.
Dean Looyengoed
parents:
607
diff
changeset
|
600 |
id = null; |
510
500cb064737d
Remove try/catch around GetUserID that could hide errors.
Dean Looyengoed
parents:
508
diff
changeset
|
601 |
} |
511
4a970a30be20
Get rid of unnecessary null/empty check as the structure of the method has changed.
Dean Looyengoed
parents:
510
diff
changeset
|
602 |
} |
477 | 603 |
|
714
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
604 |
// Handle myself user ID calculation |
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
605 |
if (id == null) |
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
606 |
{ |
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
607 |
// Check if the address is myself |
910
9bd60ca2c6ac
Add offline support (mostly for Exchange accounts).
Dean Looyengoed
parents:
902
diff
changeset
|
608 |
if (PEPIdentity.GetIsOwnIdentity(address)) |
714
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
609 |
{ |
932 | 610 |
id = "pEp_own_userId"; // Alternatively, null or empty could be used |
1348
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
611 |
this.userIdCache[address] = id; |
714
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
612 |
} |
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
613 |
} |
761f853c4c0f
For all Myself identities, calculate user ID using a hash of the windows Environment.UserName;
Dean Looyengoed
parents:
686
diff
changeset
|
614 |
|
776
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
615 |
// Use a contact EntryID if available |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
616 |
if ((id == null) && |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
617 |
(contact != null)) |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
618 |
{ |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
619 |
try |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
620 |
{ |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
621 |
contactFolder = (Outlook.Folder)contact.Parent; |
1349 | 622 |
id = contactFolder.StoreID.ToUpperInvariant() + "_" + contact.EntryID.ToUpperInvariant(); |
1348
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
623 |
this.userIdCache[address] = id; |
776
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
624 |
} |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
625 |
catch |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
626 |
{ |
1348
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
627 |
Log.Error("GetUserId: Attempted to use contact but failed."); |
776
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
628 |
} |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
629 |
} |
725
41bac55ab436
Comment out user_id calculation using address books.
Dean Looyengoed
parents:
714
diff
changeset
|
630 |
|
858
c0e7c8cd7227
Support virtual users in UserID calculation (return null if not myself and no contact).
Dean Looyengoed
parents:
854
diff
changeset
|
631 |
/* If no user ID is found at this point, return null. |
c0e7c8cd7227
Support virtual users in UserID calculation (return null if not myself and no contact).
Dean Looyengoed
parents:
854
diff
changeset
|
632 |
* The engine supports 'virtual users' that are only uniquely identified by address. |
c0e7c8cd7227
Support virtual users in UserID calculation (return null if not myself and no contact).
Dean Looyengoed
parents:
854
diff
changeset
|
633 |
* Virtual users will be automatically upgraded if a contact is ever created for the email address. |
c0e7c8cd7227
Support virtual users in UserID calculation (return null if not myself and no contact).
Dean Looyengoed
parents:
854
diff
changeset
|
634 |
*/ |
362
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
635 |
} |
474
a27dbbb2dd88
Add try/catch and error handling around several ThisAddIn methods.
Dean Looyengoed
parents:
473
diff
changeset
|
636 |
} |
a27dbbb2dd88
Add try/catch and error handling around several ThisAddIn methods.
Dean Looyengoed
parents:
473
diff
changeset
|
637 |
catch (Exception ex) |
a27dbbb2dd88
Add try/catch and error handling around several ThisAddIn methods.
Dean Looyengoed
parents:
473
diff
changeset
|
638 |
{ |
860 | 639 |
Globals.StopAndSendCrashReport(ex); |
362
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
640 |
} |
776
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
641 |
finally |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
642 |
{ |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
643 |
if (contactFolder != null) |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
644 |
{ |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
645 |
Marshal.FinalReleaseComObject(contactFolder); |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
646 |
contactFolder = null; |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
647 |
} |
451e3831822b
Support passing a contact in the GetUserID method.
Dean Looyengoed
parents:
773
diff
changeset
|
648 |
} |
362
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
649 |
|
511
4a970a30be20
Get rid of unnecessary null/empty check as the structure of the method has changed.
Dean Looyengoed
parents:
510
diff
changeset
|
650 |
return (id); |
362
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
651 |
} |
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
652 |
|
867beb89ee19
Move GetUserIDFromAddress from the CryptableMailItem to ThisAddIn.
Dean Looyengoed
parents:
361
diff
changeset
|
653 |
/// <summary> |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
654 |
/// Create a new Outlook MailItem from the given PEPMessage and send it. |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
655 |
/// The sent message will not be processed by the 'Application_ItemSend' event. |
744
278a6ecd7639
Document and implement special handling for Exchange ActiveSync issues during send.
Dean Looyengoed
parents:
743
diff
changeset
|
656 |
/// WARNING: Exchange ActiveSync accounts ignore the deleteAfterSend parameter (always false). |
455
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
657 |
/// </summary> |
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
658 |
/// <param name="message">The message to send.</param> |
475
7a23ec4d8b28
Add deleteAfterSend parameter in SendWithoutProcessing method.
Dean Looyengoed
parents:
474
diff
changeset
|
659 |
/// <param name="deleteAfterSend">Whether the message is deleted after sending (true) or a copy is saved (false).</param> |
1455
8df403ec31ee
OUT-167: Detect anytime From/SendingAccount != To recipient in keysync.
Dean
parents:
1454
diff
changeset
|
660 |
/// <param name="validateSendingAccount">Validates that the SendingAccount matches the From identity of the given message. |
8df403ec31ee
OUT-167: Detect anytime From/SendingAccount != To recipient in keysync.
Dean
parents:
1454
diff
changeset
|
661 |
/// This can catch situations (and throw exceptions) where the default account would be used instead.</param> |
910
9bd60ca2c6ac
Add offline support (mostly for Exchange accounts).
Dean Looyengoed
parents:
902
diff
changeset
|
662 |
internal void SendWithoutProcessing(PEPMessage message, |
1455
8df403ec31ee
OUT-167: Detect anytime From/SendingAccount != To recipient in keysync.
Dean
parents:
1454
diff
changeset
|
663 |
bool deleteAfterSend, |
8df403ec31ee
OUT-167: Detect anytime From/SendingAccount != To recipient in keysync.
Dean
parents:
1454
diff
changeset
|
664 |
bool validateSendingAccount) |
455
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
665 |
{ |
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
666 |
Outlook.MailItem newItem; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
667 |
Globals.ReturnStatus sts; |
455
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
668 |
|
1394
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
669 |
this.isItemSendHandlerEnabled = false; |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
670 |
|
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
671 |
try |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
672 |
{ |
1394
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
673 |
newItem = Application.CreateItem(Outlook.OlItemType.olMailItem); |
1467
622a86775584
OUT-167: Make sure to set SendUsingAccount during SendWithoutProcessing.
Thomas
parents:
1465
diff
changeset
|
674 |
|
622a86775584
OUT-167: Make sure to set SendUsingAccount during SendWithoutProcessing.
Thomas
parents:
1465
diff
changeset
|
675 |
/* Notes: |
622a86775584
OUT-167: Make sure to set SendUsingAccount during SendWithoutProcessing.
Thomas
parents:
1465
diff
changeset
|
676 |
* Do NOT include internal Header Fields (MAPI properties) on outgoing messages! |
622a86775584
OUT-167: Make sure to set SendUsingAccount during SendWithoutProcessing.
Thomas
parents:
1465
diff
changeset
|
677 |
* The sender must be set from the from identity (setSender=true) |
622a86775584
OUT-167: Make sure to set SendUsingAccount during SendWithoutProcessing.
Thomas
parents:
1465
diff
changeset
|
678 |
*/ |
622a86775584
OUT-167: Make sure to set SendUsingAccount during SendWithoutProcessing.
Thomas
parents:
1465
diff
changeset
|
679 |
sts = message.ApplyTo(newItem, false, true); |
1394
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
680 |
|
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
681 |
if (sts == Globals.ReturnStatus.Success) |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
682 |
{ |
1455
8df403ec31ee
OUT-167: Detect anytime From/SendingAccount != To recipient in keysync.
Dean
parents:
1454
diff
changeset
|
683 |
// Check that the sending account is the From identity |
8df403ec31ee
OUT-167: Detect anytime From/SendingAccount != To recipient in keysync.
Dean
parents:
1454
diff
changeset
|
684 |
if ((validateSendingAccount) && |
8df403ec31ee
OUT-167: Detect anytime From/SendingAccount != To recipient in keysync.
Dean
parents:
1454
diff
changeset
|
685 |
(message.From != null)) |
8df403ec31ee
OUT-167: Detect anytime From/SendingAccount != To recipient in keysync.
Dean
parents:
1454
diff
changeset
|
686 |
{ |
8df403ec31ee
OUT-167: Detect anytime From/SendingAccount != To recipient in keysync.
Dean
parents:
1454
diff
changeset
|
687 |
if (message.From.EqualsByAddress(newItem.GetSendUsingAccountIdentity()) == false) |
8df403ec31ee
OUT-167: Detect anytime From/SendingAccount != To recipient in keysync.
Dean
parents:
1454
diff
changeset
|
688 |
{ |
8df403ec31ee
OUT-167: Detect anytime From/SendingAccount != To recipient in keysync.
Dean
parents:
1454
diff
changeset
|
689 |
throw new Exception("Sending account does not match from identity"); |
8df403ec31ee
OUT-167: Detect anytime From/SendingAccount != To recipient in keysync.
Dean
parents:
1454
diff
changeset
|
690 |
} |
8df403ec31ee
OUT-167: Detect anytime From/SendingAccount != To recipient in keysync.
Dean
parents:
1454
diff
changeset
|
691 |
} |
8df403ec31ee
OUT-167: Detect anytime From/SendingAccount != To recipient in keysync.
Dean
parents:
1454
diff
changeset
|
692 |
|
1394
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
693 |
// Do not allow TNEF/RTF format with 'winmail.dat' attachment |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
694 |
MapiHelper.SetProperty(newItem, MapiProperty.PidLidUseTnef, false); |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
695 |
|
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
696 |
/* Send |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
697 |
* |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
698 |
* Note: For ActiveSync accounts, the DeleteAfterSubmit property is ignored. |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
699 |
* This means the message will always appear in the sent folder by default. |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
700 |
* The reason for this is unknown. |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
701 |
* |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
702 |
* It's possible this is related to the ActiveSync specification version |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
703 |
* and therefore may behave differently depending on Outlook version. |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
704 |
* More research is needed here. |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
705 |
*/ |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
706 |
newItem.DeleteAfterSubmit = deleteAfterSend; |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
707 |
((Outlook._MailItem)newItem).Send(); |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
708 |
|
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
709 |
Marshal.ReleaseComObject(newItem); |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
710 |
newItem = null; |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
711 |
} |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
712 |
else |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
713 |
{ |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
714 |
newItem.PermanentlyDelete(); |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
715 |
Marshal.ReleaseComObject(newItem); |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
716 |
newItem = null; |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
717 |
|
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
718 |
throw new Exception("Failed to create MailItem to send"); |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
719 |
} |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
720 |
} |
1394
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
721 |
catch |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
722 |
{ |
1394
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
723 |
throw; |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
724 |
} |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
725 |
finally |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
726 |
{ |
1fb7ea1e40ba
OUT-17: Disable Application_ItemSend when within the SendWithoutProcessing method.
Dean
parents:
1390
diff
changeset
|
727 |
this.isItemSendHandlerEnabled = true; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
728 |
} |
455
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
729 |
|
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
730 |
return; |
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
731 |
} |
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
732 |
|
a4158ad1f4b7
Add method to create a new Outlook MailItem and send it without processing.
Dean Looyengoed
parents:
453
diff
changeset
|
733 |
/// <summary> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
734 |
/// Create a new 'sent' Outlook MailItem and place it in the given store. |
744
278a6ecd7639
Document and implement special handling for Exchange ActiveSync issues during send.
Dean Looyengoed
parents:
743
diff
changeset
|
735 |
/// WARNING: Exchange ActiveSync accounts are not supported by this method. The sent |
278a6ecd7639
Document and implement special handling for Exchange ActiveSync issues during send.
Dean Looyengoed
parents:
743
diff
changeset
|
736 |
/// message will always appear in the drafts folder. |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
737 |
/// </summary> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
738 |
/// <param name="sendingStore">The store to save the sent message to.</param> |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
739 |
/// <param name="acctSettings">The sending account settings.</param> |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
740 |
/// <param name="sentMessage">The message that is sent.</param> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
741 |
/// <param name="storedRating">The rating to store to the sent message mail item. |
970
d676bc7cbad6
Store the outgoing color rating for sent messages where possible.
Dean Looyengoed
parents:
935
diff
changeset
|
742 |
/// Will only be set if not undefined (default). Warning: Only use this on trusted servers.</param> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
743 |
private void CreateNewSentMail(Outlook.Store sendingStore, |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
744 |
PEPSettings.PEPAccountSettings acctSettings, |
970
d676bc7cbad6
Store the outgoing color rating for sent messages where possible.
Dean Looyengoed
parents:
935
diff
changeset
|
745 |
PEPMessage sentMessage, |
1337
6b93b1a3b751
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1328
diff
changeset
|
746 |
pEpRating storedRating = pEpRating.pEpRatingUndefined) |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
747 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
748 |
Int32 messageFlags; |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
749 |
Outlook.MailItem sentMailItem = null; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
750 |
Outlook.Folder sentFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
751 |
Outlook.NameSpace ns = Application.Session; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
752 |
Outlook.MAPIFolder rootFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
753 |
Outlook.Folders folders = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
754 |
Outlook.Folder folder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
755 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
756 |
/* The process is: |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
757 |
* 1. Use the Store.GetDefaultFolder(olFolderSentMail) to try to get the default Sent folder. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
758 |
* However, this can fail for a number of reasons, depending on server and folder configuration. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
759 |
* 2. As a fallback, search for the Sent folder by matching the Sent folder Entry ID |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
760 |
* However, this can also fail if no Sent folder Entry ID has been recorded. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
761 |
* 3. As another fallback, search by Folder name ("SENT") for an existing Sent folder |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
762 |
* If found, record the folder's Entry ID. If not, goto point 4. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
763 |
* 4. If everything of the above fails, create a new Sent folder and record the Entry ID. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
764 |
*/ |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
765 |
|
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
766 |
try |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
767 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
768 |
if ((sendingStore != null) && |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
769 |
(acctSettings != null) && |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
770 |
(sentMessage != null)) |
1108 | 771 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
772 |
rootFolder = sendingStore.GetRootFolder(); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
773 |
if (rootFolder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
774 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
775 |
folders = rootFolder.Folders; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
776 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
777 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
778 |
// Step 1 |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
779 |
try |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
780 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
781 |
sentFolder = (Outlook.Folder)sendingStore.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
782 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
783 |
catch |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
784 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
785 |
if (sentFolder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
786 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
787 |
Marshal.ReleaseComObject(sentFolder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
788 |
sentFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
789 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
790 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
791 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
792 |
// Step 2 |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
793 |
if (sentFolder == null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
794 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
795 |
try |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
796 |
{ |
1348
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
797 |
/* Search for folder by entry ID |
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
798 |
* Normally, the way to go would be the following line: |
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
799 |
* sentFolder = (Outlook.Folder)ns.GetItemFromID(acctSettings.SentFolderEntryId, sendingStore.StoreID); |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
800 |
* However, for some reason, this can come up with the following error: "Could not open the item. Try again." |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
801 |
* Therefore, the below solution is used: |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
802 |
*/ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
803 |
if (folders != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
804 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
805 |
for (int i = 1; i <= folders.Count; i++) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
806 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
807 |
folder = (Outlook.Folder)folders[i]; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
808 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
809 |
if (folder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
810 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
811 |
if ((string.IsNullOrEmpty(folder.EntryID) == false) && |
1348
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
812 |
(string.Equals(folder.EntryID, acctSettings.SentFolderEntryId))) |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
813 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
814 |
sentFolder = folder; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
815 |
break; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
816 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
817 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
818 |
Marshal.ReleaseComObject(folder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
819 |
folder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
820 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
821 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
822 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
823 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
824 |
catch |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
825 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
826 |
if (sentFolder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
827 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
828 |
Marshal.ReleaseComObject(sentFolder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
829 |
sentFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
830 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
831 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
832 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
833 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
834 |
// Step 3 |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
835 |
if (sentFolder == null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
836 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
837 |
try |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
838 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
839 |
//Search for folder by name |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
840 |
if (folders != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
841 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
842 |
for (int i = 1; i <= folders.Count; i++) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
843 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
844 |
folder = (Outlook.Folder)folders[i]; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
845 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
846 |
if (folder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
847 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
848 |
if ((string.IsNullOrEmpty(folder.Name) == false) && |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
849 |
(folder.Name.Trim().StartsWith(Globals.CUSTOM_SENT_FOLDER_NAME, StringComparison.OrdinalIgnoreCase))) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
850 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
851 |
sentFolder = folder; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
852 |
break; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
853 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
854 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
855 |
Marshal.ReleaseComObject(folder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
856 |
folder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
857 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
858 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
859 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
860 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
861 |
catch |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
862 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
863 |
if (sentFolder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
864 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
865 |
Marshal.ReleaseComObject(sentFolder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
866 |
sentFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
867 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
868 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
869 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
870 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
871 |
// Step 4 |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
872 |
if (sentFolder == null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
873 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
874 |
try |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
875 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
876 |
// Create folder |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
877 |
if (folders != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
878 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
879 |
sentFolder = (Outlook.Folder)folders.Add(Globals.CUSTOM_SENT_FOLDER_NAME); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
880 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
881 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
882 |
catch (Exception ex) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
883 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
884 |
if (sentFolder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
885 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
886 |
Marshal.ReleaseComObject(sentFolder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
887 |
sentFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
888 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
889 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
890 |
Log.Error("CreateNewSentMail: No Sent folder found and no new Sent folder could be created because of the following error: " + ex.ToString()); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
891 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
892 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
893 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
894 |
if (sentFolder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
895 |
{ |
1348
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
896 |
acctSettings.SentFolderEntryId = sentFolder.EntryID; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
897 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
898 |
// Create the basic sent mail item |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
899 |
sentMailItem = (Outlook.MailItem)sentFolder.Items.Add(Outlook.OlItemType.olMailItem); |
1299
523bb6ad5ccc
Add setSender parameter to ApplyTo() method and only use it in CreateNewSentMail()
Thomas
parents:
1287
diff
changeset
|
900 |
sentMessage.ApplyTo(sentMailItem, false, true); // Do NOT include internal Header Fields (MAPI properties)! |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
901 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
902 |
// Set the date and time the mail item was sent |
1275
2a69f2f93ca3
OUT-83: Catch more MAPIProperty.SetProperty errors when creating a new sent message.
Dean
parents:
1271
diff
changeset
|
903 |
try |
2a69f2f93ca3
OUT-83: Catch more MAPIProperty.SetProperty errors when creating a new sent message.
Dean
parents:
1271
diff
changeset
|
904 |
{ |
1350
8fdce6140e29
Change more places to .net standard capitalization rules.
Dean
parents:
1349
diff
changeset
|
905 |
MapiHelper.SetProperty(sentMailItem, MapiProperty.PidTagClientSubmitTime, DateTime.Now.ToUniversalTime()); |
1275
2a69f2f93ca3
OUT-83: Catch more MAPIProperty.SetProperty errors when creating a new sent message.
Dean
parents:
1271
diff
changeset
|
906 |
} |
2a69f2f93ca3
OUT-83: Catch more MAPIProperty.SetProperty errors when creating a new sent message.
Dean
parents:
1271
diff
changeset
|
907 |
catch { } |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
908 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
909 |
// Set flags |
1275
2a69f2f93ca3
OUT-83: Catch more MAPIProperty.SetProperty errors when creating a new sent message.
Dean
parents:
1271
diff
changeset
|
910 |
try |
2a69f2f93ca3
OUT-83: Catch more MAPIProperty.SetProperty errors when creating a new sent message.
Dean
parents:
1271
diff
changeset
|
911 |
{ |
1350
8fdce6140e29
Change more places to .net standard capitalization rules.
Dean
parents:
1349
diff
changeset
|
912 |
messageFlags = (System.Int32)MapiHelper.GetProperty(sentMailItem, MapiProperty.PidTagMessageFlags); |
8fdce6140e29
Change more places to .net standard capitalization rules.
Dean
parents:
1349
diff
changeset
|
913 |
messageFlags &= ~((System.Int32)MapiPropertyValue.EnumPidTagMessageFlags.mfUnsent); // Clear UNSENT flag -- must be done before save |
8fdce6140e29
Change more places to .net standard capitalization rules.
Dean
parents:
1349
diff
changeset
|
914 |
messageFlags |= ((System.Int32)MapiPropertyValue.EnumPidTagMessageFlags.mfRead); // Mark as read |
8fdce6140e29
Change more places to .net standard capitalization rules.
Dean
parents:
1349
diff
changeset
|
915 |
MapiHelper.SetProperty(sentMailItem, MapiProperty.PidTagMessageFlags, messageFlags); |
1275
2a69f2f93ca3
OUT-83: Catch more MAPIProperty.SetProperty errors when creating a new sent message.
Dean
parents:
1271
diff
changeset
|
916 |
} |
2a69f2f93ca3
OUT-83: Catch more MAPIProperty.SetProperty errors when creating a new sent message.
Dean
parents:
1271
diff
changeset
|
917 |
catch { } |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
918 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
919 |
// Save pEp rating |
1275
2a69f2f93ca3
OUT-83: Catch more MAPIProperty.SetProperty errors when creating a new sent message.
Dean
parents:
1271
diff
changeset
|
920 |
try |
2a69f2f93ca3
OUT-83: Catch more MAPIProperty.SetProperty errors when creating a new sent message.
Dean
parents:
1271
diff
changeset
|
921 |
{ |
1303
5b20f1bee571
Add and implement class for MailItem extension methods.
Dean
parents:
1299
diff
changeset
|
922 |
sentMailItem.SetPEPProperty(MailItemExtensions.PEPProperty.Rating, storedRating); |
1275
2a69f2f93ca3
OUT-83: Catch more MAPIProperty.SetProperty errors when creating a new sent message.
Dean
parents:
1271
diff
changeset
|
923 |
} |
2a69f2f93ca3
OUT-83: Catch more MAPIProperty.SetProperty errors when creating a new sent message.
Dean
parents:
1271
diff
changeset
|
924 |
catch { } |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
925 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
926 |
// Save changes to the mail item (must be done last for some properties) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
927 |
sentMailItem.Save(); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
928 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
929 |
/* Attempt to move to the sent folder. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
930 |
* For ActiveSync accounts, this will fail with the error: |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
931 |
* 'Sorry, Exchange ActiveSync doesn't support what you're trying to do.' |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
932 |
* This is because the .Items.Add(folder) will ignore the specified folder and create in local Drafts. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
933 |
* Then "Exchange ActiveSync doesn’t support the Drafts folder" so it can't be moved out. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
934 |
* Even in the Outlook UI a draft cannot be 'dragged' out of the drafts folder. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
935 |
*/ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
936 |
try |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
937 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
938 |
sentMailItem.Move(sentFolder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
939 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
940 |
catch { } |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
941 |
} |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
942 |
} |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
943 |
} |
743
5bad37bca12f
Do not include optional properties when calling .ApplyTo for a sent mail item.
Dean Looyengoed
parents:
738
diff
changeset
|
944 |
catch (Exception ex) |
5bad37bca12f
Do not include optional properties when calling .ApplyTo for a sent mail item.
Dean Looyengoed
parents:
738
diff
changeset
|
945 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
946 |
Log.Error("CreateNewSentMail: Error occured, " + ex.ToString()); |
886 | 947 |
throw; |
743
5bad37bca12f
Do not include optional properties when calling .ApplyTo for a sent mail item.
Dean Looyengoed
parents:
738
diff
changeset
|
948 |
} |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
949 |
finally |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
950 |
{ |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
951 |
if (sentMailItem != null) |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
952 |
{ |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
953 |
Marshal.ReleaseComObject(sentMailItem); |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
954 |
sentMailItem = null; |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
955 |
} |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
956 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
957 |
if (ns != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
958 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
959 |
Marshal.ReleaseComObject(ns); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
960 |
ns = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
961 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
962 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
963 |
if (sentFolder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
964 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
965 |
Marshal.ReleaseComObject(sentFolder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
966 |
sentFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
967 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
968 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
969 |
if (rootFolder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
970 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
971 |
Marshal.ReleaseComObject(rootFolder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
972 |
rootFolder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
973 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
974 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
975 |
if (folders != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
976 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
977 |
Marshal.ReleaseComObject(folders); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
978 |
folders = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
979 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
980 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
981 |
if (folder != null) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
982 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
983 |
Marshal.ReleaseComObject(folder); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
984 |
folder = null; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
985 |
} |
738
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
986 |
} |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
987 |
|
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
988 |
return; |
ac649e82fd98
Create and save the sent mail item exactly the same as how it was composed.
Dean Looyengoed
parents:
726
diff
changeset
|
989 |
} |
1340 | 990 |
|
745
832f49345e6f
Add PermanentlyDelete method to remove any drafts or original mail item after send.
Dean Looyengoed
parents:
744
diff
changeset
|
991 |
/// <summary> |
671
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
992 |
/// Gets whether the given account is trusted (on the account whitelist). |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
993 |
/// Character case and whitespace is ignored during comparison. |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
994 |
/// </summary> |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
995 |
/// <param name="address">The address of the account.</param> |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
996 |
/// <returns>True if the account with the given address is trusted by default (on the whitelist), otherwise false.</returns> |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
997 |
private bool GetIsAccountTrusted(string address) |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
998 |
{ |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
999 |
bool isTrusted = false; |
1349 | 1000 |
string searchAddress = address.ToUpperInvariant().Trim(); |
671
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1001 |
string searchDomain = searchAddress.Contains("@") ? searchAddress.Substring(searchAddress.LastIndexOf("@")) : null; |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1002 |
string whitelistAccount; |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1003 |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1004 |
for (int i = 0; i < this._Settings.AccountWhitelist.Length; i++) |
671
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1005 |
{ |
1349 | 1006 |
whitelistAccount = this._Settings.AccountWhitelist[i].ToUpperInvariant().Trim(); |
671
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1007 |
|
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1008 |
// Check for exact match |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1009 |
if (searchAddress == whitelistAccount) |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1010 |
{ |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1011 |
isTrusted = true; |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1012 |
break; |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1013 |
} |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1014 |
|
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1015 |
// Check for domain match |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1016 |
if ((searchDomain != null) && |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1017 |
whitelistAccount.StartsWith("@") && |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1018 |
(searchDomain == whitelistAccount)) |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1019 |
{ |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1020 |
isTrusted = true; |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1021 |
break; |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1022 |
} |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1023 |
} |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1024 |
|
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1025 |
return (isTrusted); |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1026 |
} |
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1027 |
|
57fdc1b20a02
Add method to get account trust by searching the whitelist.
Dean Looyengoed
parents:
667
diff
changeset
|
1028 |
/// <summary> |
820
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1029 |
/// Writes the pEp required Outlook options to the registry. |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1030 |
/// </summary> |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1031 |
private void SetOutlookRegistryOptions() |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1032 |
{ |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1033 |
try |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1034 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1035 |
using (RegistryKey key1 = Registry.CurrentUser.OpenSubKey(PEPSettings.REG_KEY_SOFTWARE)) |
820
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1036 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1037 |
using (RegistryKey keyOffice = key1.OpenSubKey(PEPSettings.REG_KEY_MICROSOFT_OFFICE)) |
820
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1038 |
{ |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1039 |
/* Outlook versions |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1040 |
* "12" Outlook 2007 |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1041 |
* "14" Outlook 2010 |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1042 |
* "15" Outlook 2013 |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1043 |
* "16" Outlook 2016 |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1044 |
*/ |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1045 |
using (RegistryKey keyInternationalOptions = keyOffice.OpenSubKey(Application.Version.Substring(0, 2) + ".0\\Outlook\\Options\\MSHTML\\International", true)) |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1046 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1047 |
keyInternationalOptions.SetValue(PEPSettings.REG_NAME_DEFAULT_CODEPAGE_OUT, (Int32)65001); // UTF-8 |
820
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1048 |
} |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1049 |
} |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1050 |
} |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1051 |
} |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1052 |
catch (Exception ex) |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1053 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1054 |
Log.Error("SetOutlookRegistryOptions: Failed to set options, " + ex.ToString()); |
820
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1055 |
} |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1056 |
|
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1057 |
return; |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1058 |
} |
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1059 |
|
6a08ad3137da
Add SetOutlookRegistryOptions() method and use it to set default out codepage to UTF-8.
Dean Looyengoed
parents:
818
diff
changeset
|
1060 |
/// <summary> |
203
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1061 |
/// Copies any necessary data from the given options form state back into this add-ins current state. |
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1062 |
/// The registry is also updated by this method. |
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1063 |
/// </summary> |
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1064 |
/// <param name="state">The state to copy data from.</param> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1065 |
internal void SetOptionsState(FormControlOptions.State state) |
203
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1066 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1067 |
bool isBlacklisted; |
839 | 1068 |
string fpr1; |
1069 |
string fpr2; |
|
1070 |
string[] blacklist; |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1071 |
PEPSettings.PEPAccountSettings acctSettings; |
839 | 1072 |
|
203
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1073 |
if (state != null) |
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1074 |
{ |
1382
f37576e7edbb
OUT-87: Support adding new fingerprints to the blacklist.
Dean
parents:
1379
diff
changeset
|
1075 |
// Get the blacklist |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1076 |
try |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1077 |
{ |
1379 | 1078 |
blacklist = ThisAddIn.PEPEngine.BlacklistRetrieve(); |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1079 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1080 |
catch (COMException ex) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1081 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1082 |
blacklist = new string[0]; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1083 |
Log.Error("SetOptionsState: Error getting blacklist from engine. " + ex.ToString()); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1084 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1085 |
|
1382
f37576e7edbb
OUT-87: Support adding new fingerprints to the blacklist.
Dean
parents:
1379
diff
changeset
|
1086 |
// Remove any fingerprints no longer in the engine blacklist |
839 | 1087 |
if (blacklist != null) |
1088 |
{ |
|
1089 |
for (int i = (blacklist.Length - 1); i >= 0; i--) |
|
1090 |
{ |
|
1091 |
fpr1 = this.RemoveFprFormatting(blacklist[i]); |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1092 |
isBlacklisted = false; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1093 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1094 |
if (string.IsNullOrEmpty(fpr1) == false) |
839 | 1095 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1096 |
// Check if fingerprint is still blacklisted |
1382
f37576e7edbb
OUT-87: Support adding new fingerprints to the blacklist.
Dean
parents:
1379
diff
changeset
|
1097 |
foreach (KVPair<PEPIdentity, bool> entry in state.Blacklist) |
839 | 1098 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1099 |
fpr2 = this.RemoveFprFormatting(entry.Key.Fingerprint); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1100 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1101 |
// Value is true if the entry is blacklisted |
1382
f37576e7edbb
OUT-87: Support adding new fingerprints to the blacklist.
Dean
parents:
1379
diff
changeset
|
1102 |
if ((string.Equals(fpr1, fpr2, StringComparison.OrdinalIgnoreCase)) && |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1103 |
(entry.Value)) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1104 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1105 |
isBlacklisted = true; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1106 |
break; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1107 |
} |
839 | 1108 |
} |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1109 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1110 |
if (isBlacklisted == false) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1111 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1112 |
try |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1113 |
{ |
1337
6b93b1a3b751
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1328
diff
changeset
|
1114 |
ThisAddIn.PEPEngine.BlacklistDelete(fpr1); |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1115 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1116 |
catch (COMException ex) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1117 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1118 |
Log.Error("SetOptionsState: Failed to delete blacklist entry, " + ex.ToString()); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1119 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1120 |
} |
839 | 1121 |
} |
1122 |
} |
|
1123 |
} |
|
1124 |
||
1382
f37576e7edbb
OUT-87: Support adding new fingerprints to the blacklist.
Dean
parents:
1379
diff
changeset
|
1125 |
// Add any new fingerprints to the engine blacklist |
f37576e7edbb
OUT-87: Support adding new fingerprints to the blacklist.
Dean
parents:
1379
diff
changeset
|
1126 |
foreach (KVPair<PEPIdentity, bool> entry in state.Blacklist) |
839 | 1127 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1128 |
fpr1 = this.RemoveFprFormatting(entry.Key.Fingerprint); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1129 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1130 |
// Value is true if the entry is blacklisted |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1131 |
if ((entry.Value) && |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1132 |
(string.IsNullOrEmpty(fpr1) == false)) |
839 | 1133 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1134 |
try |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1135 |
{ |
1337
6b93b1a3b751
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1328
diff
changeset
|
1136 |
if (ThisAddIn.PEPEngine.BlacklistIsListed(fpr1) == false) |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1137 |
{ |
1337
6b93b1a3b751
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1328
diff
changeset
|
1138 |
ThisAddIn.PEPEngine.BlacklistAdd(fpr1); |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1139 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1140 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1141 |
catch (COMException ex) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1142 |
{ |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1143 |
Log.Error("SetOptionsState: Failed to add new blacklist entry, " + ex.ToString()); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1144 |
} |
839 | 1145 |
} |
1146 |
} |
|
1250 | 1147 |
|
1460
0b65f50c102e
OUT-162: OUT-164: OUT-176: Allow managing a separate display state for account options.
Dean
parents:
1455
diff
changeset
|
1148 |
foreach (FormControlOptions.AccountState entry in state.AccountSettingsList) |
203
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1149 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1150 |
/* pEp internally uses account types as defined by microsoft. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1151 |
* This means they have 'ol' before the type (Example: 'olImap'). |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1152 |
* This isn't always user friendly so for the options UI the 'ol' is removed. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1153 |
* However, when comparing again with the settings list, this 'ol' must be added back. |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1154 |
*/ |
1348
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
1155 |
acctSettings = this._Settings.GetAccountSettings(entry.SmtpAddress, ("ol" + entry.Type)); |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1156 |
|
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1157 |
if (acctSettings != null) |
203
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1158 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1159 |
// Modify existing value |
1348
c394606d6f6c
Change to .net standard capitalization rules in several places.
Dean
parents:
1347
diff
changeset
|
1160 |
// The following are skipped: SentFolderEntryId, SmtpAddress & Type |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1161 |
acctSettings.IsPEPEnabled = entry.IsPEPEnabled; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1162 |
acctSettings.IsSecureStorageEnabled = entry.IsSecureStorageEnabled; |
203
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1163 |
} |
1166
5f600ac7b163
Remove 'ol' from account type when displayed in the options UI.
Dean
parents:
1155
diff
changeset
|
1164 |
else |
5f600ac7b163
Remove 'ol' from account type when displayed in the options UI.
Dean
parents:
1155
diff
changeset
|
1165 |
{ |
1460
0b65f50c102e
OUT-162: OUT-164: OUT-176: Allow managing a separate display state for account options.
Dean
parents:
1455
diff
changeset
|
1166 |
Log.Warning("SetOptionsState: Existing account settings not found."); |
1166
5f600ac7b163
Remove 'ol' from account type when displayed in the options UI.
Dean
parents:
1155
diff
changeset
|
1167 |
} |
203
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1168 |
} |
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1169 |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1170 |
this._Settings.IsAutoUpdateEnabled = state.IsAutoUpdateEnabled; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1171 |
this._Settings.IsEncryptAllAccountsEnabled = state.IsEncryptAllAccountsEnabled; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1172 |
this._Settings.IsKeyServerUsed = state.IsKeyServerUsed; |
1314
4b4f0b1943fb
OUT-109: Implement option to show/hide the Store Protected button.
Dean
parents:
1304
diff
changeset
|
1173 |
this._Settings.IsNeverUnsecureOptionVisible = state.IsNeverUnsecureOptionVisible; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1174 |
this._Settings.IsPEPFolderVisible = state.IsPEPFolderVisible; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1175 |
this._Settings.IsSecurityLossWarningEnabled = state.IsSecurityLossWarningEnabled; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1176 |
this._Settings.IsUnencryptedSubjectEnabled = state.IsUnencryptedSubjectEnabled; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1177 |
this._Settings.IsVerboseLoggingEnabled = state.IsVerboseLoggingEnabled; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1178 |
this._Settings.TrustwordsCulture = ((state.TrustwordsCulture != null) ? new CultureInfo(state.TrustwordsCulture.LCID) : null); |
659
a1712cc16fdb
Report system information in about page of options.
Dean Looyengoed
parents:
652
diff
changeset
|
1179 |
|
219
ee11aec8fa86
Save and restore the complete options state between instances of the options form.
Dean Looyengoed
parents:
209
diff
changeset
|
1180 |
// Save last state for next options opening |
ee11aec8fa86
Save and restore the complete options state between instances of the options form.
Dean Looyengoed
parents:
209
diff
changeset
|
1181 |
this.lastOptionsState = state.Copy(); |
ee11aec8fa86
Save and restore the complete options state between instances of the options form.
Dean Looyengoed
parents:
209
diff
changeset
|
1182 |
|
203
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1183 |
// Update registry (in case of unforseen app shutdown) |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1184 |
this._Settings.SaveToRegistry(); |
203
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1185 |
} |
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1186 |
|
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1187 |
return; |
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1188 |
} |
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1189 |
|
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1190 |
/// <summary> |
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1191 |
/// Builds a new options form state using this add-ins current state. |
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1192 |
/// </summary> |
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1193 |
/// <returns>A new options form state.</returns> |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1194 |
internal FormControlOptions.State GetOptionsState() |
203
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1195 |
{ |
818
27197ae4d497
Add detection if the pEp store is the default and don't allow it to be hidden.
Dean Looyengoed
parents:
816
diff
changeset
|
1196 |
bool isDefaultStore = false; |
1382
f37576e7edbb
OUT-87: Support adding new fingerprints to the blacklist.
Dean
parents:
1379
diff
changeset
|
1197 |
bool exists; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1198 |
string fpr1; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1199 |
string fpr2; |
839 | 1200 |
string[] blacklist; |
1337
6b93b1a3b751
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1328
diff
changeset
|
1201 |
StringPair[] keylist; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1202 |
PEPIdentity newIdent; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1203 |
PEPSettings.PEPAccountSettings newAcctSettings; |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1204 |
FormControlOptions.State state; |
919
252172b0fbec
Standardize calls to the Session in ThisAddIn.
Dean Looyengoed
parents:
918
diff
changeset
|
1205 |
Outlook.NameSpace ns = this.Application.Session; |
818
27197ae4d497
Add detection if the pEp store is the default and don't allow it to be hidden.
Dean Looyengoed
parents:
816
diff
changeset
|
1206 |
Outlook.Store defaultStore = null; |
27197ae4d497
Add detection if the pEp store is the default and don't allow it to be hidden.
Dean Looyengoed
parents:
816
diff
changeset
|
1207 |
|
27197ae4d497
Add detection if the pEp store is the default and don't allow it to be hidden.
Dean Looyengoed
parents:
816
diff
changeset
|
1208 |
// Check if pEp is the default store |
27197ae4d497
Add detection if the pEp store is the default and don't allow it to be hidden.
Dean Looyengoed
parents:
816
diff
changeset
|
1209 |
try |
27197ae4d497
Add detection if the pEp store is the default and don't allow it to be hidden.
Dean Looyengoed
parents:
816
diff
changeset
|
1210 |
{ |
27197ae4d497
Add detection if the pEp store is the default and don't allow it to be hidden.
Dean Looyengoed
parents:
816
diff
changeset
|
1211 |
defaultStore = ns.DefaultStore; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1212 |
isDefaultStore = (defaultStore.StoreID == this._PEPStoreRootFolder.StoreID); |
818
27197ae4d497
Add detection if the pEp store is the default and don't allow it to be hidden.
Dean Looyengoed
parents:
816
diff
changeset
|
1213 |
} |
27197ae4d497
Add detection if the pEp store is the default and don't allow it to be hidden.
Dean Looyengoed
parents:
816
diff
changeset
|
1214 |
catch |
27197ae4d497
Add detection if the pEp store is the default and don't allow it to be hidden.
Dean Looyengoed
parents:
816
diff
changeset
|
1215 |
{ |
27197ae4d497
Add detection if the pEp store is the default and don't allow it to be hidden.
Dean Looyengoed
parents:
816
diff
changeset
|
1216 |
isDefaultStore = false; |
27197ae4d497
Add detection if the pEp store is the default and don't allow it to be hidden.
Dean Looyengoed
parents:
816
diff
changeset
|
1217 |
} |
219
ee11aec8fa86
Save and restore the complete options state between instances of the options form.
Dean Looyengoed
parents:
209
diff
changeset
|
1218 |
|
ee11aec8fa86
Save and restore the complete options state between instances of the options form.
Dean Looyengoed
parents:
209
diff
changeset
|
1219 |
// Load from last state if possible |
ee11aec8fa86
Save and restore the complete options state between instances of the options form.
Dean Looyengoed
parents:
209
diff
changeset
|
1220 |
if (this.lastOptionsState != null) |
ee11aec8fa86
Save and restore the complete options state between instances of the options form.
Dean Looyengoed
parents:
209
diff
changeset
|
1221 |
{ |
ee11aec8fa86
Save and restore the complete options state between instances of the options form.
Dean Looyengoed
parents:
209
diff
changeset
|
1222 |
state = this.lastOptionsState.Copy(); |
ee11aec8fa86
Save and restore the complete options state between instances of the options form.
Dean Looyengoed
parents:
209
diff
changeset
|
1223 |
} |
ee11aec8fa86
Save and restore the complete options state between instances of the options form.
Dean Looyengoed
parents:
209
diff
changeset
|
1224 |
else |
ee11aec8fa86
Save and restore the complete options state between instances of the options form.
Dean Looyengoed
parents:
209
diff
changeset
|
1225 |
{ |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1226 |
state = new FormControlOptions.State(); |
219
ee11aec8fa86
Save and restore the complete options state between instances of the options form.
Dean Looyengoed
parents:
209
diff
changeset
|
1227 |
} |
203
44dac4bb337a
Complete the state management in both the options form and this add-in.
Dean Looyengoed
parents:
201
diff
changeset
|
1228 |
|
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1229 |
// Get complete OpenPGP key list |
1250 | 1230 |
try |
1231 |
{ |
|
1343
1520e906a692
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1340
diff
changeset
|
1232 |
keylist = ThisAddIn.PEPEngine.OpenPGPListKeyinfo(null); |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1233 |
} |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1234 |
catch (COMException ex) |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1235 |
{ |
1337
6b93b1a3b751
OUT-117: Catching up rename-refactorings from COM-24, COM-29, COM-30, COM-31
Markus Schaber <markus@pep-security.net>
parents:
1328
diff
changeset
|
1236 |
keylist = new StringPair[0]; |
1262
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1237 |
Log.Error("GetOptionsState: Error getting OpenPGP keylist from engine. " + ex.ToString()); |
92840238d7af
Manual merge of ThisAddIn with latest default branch code.
Dean
parents:
1261
diff
changeset
|
1238 |
} |