OLD | NEW |
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 | 2 |
3 #include <Wbemidl.h> | 3 #include <Wbemidl.h> |
4 #include <time.h> | 4 #include <time.h> |
5 #include "PluginSettings.h" | 5 #include "PluginSettings.h" |
6 #include "PluginClient.h" | 6 #include "PluginClient.h" |
7 #include "PluginSystem.h" | 7 #include "PluginSystem.h" |
8 #ifdef SUPPORT_FILTER | |
9 #include "PluginFilter.h" | 8 #include "PluginFilter.h" |
10 #endif | |
11 #include "PluginMutex.h" | 9 #include "PluginMutex.h" |
12 #include "../shared/Utils.h" | 10 #include "../shared/Utils.h" |
13 #include <memory> | 11 #include <memory> |
14 | 12 |
15 | 13 |
16 // IE functions | 14 // IE functions |
17 #pragma comment(lib, "iepmapi.lib") | 15 #pragma comment(lib, "iepmapi.lib") |
18 | 16 |
19 #include <knownfolders.h> | 17 #include <knownfolders.h> |
20 | 18 |
21 namespace | 19 namespace |
22 { | 20 { |
23 std::wstring CreateDomainWhitelistingFilter(const CString domain) | 21 std::wstring CreateDomainWhitelistingFilter(const CString domain) |
24 { | 22 { |
25 return std::wstring(L"@@||") + domain.GetString() + std::wstring(L"^$documen
t"); | 23 return std::wstring(L"@@||") + domain.GetString() + std::wstring(L"^$documen
t"); |
26 } | 24 } |
27 } | 25 } |
28 | 26 |
29 class TSettings | 27 class TSettings |
30 { | 28 { |
31 DWORD processorId; | 29 DWORD processorId; |
32 | 30 |
33 char sPluginId[44]; | 31 char sPluginId[44]; |
34 }; | 32 }; |
35 | 33 |
36 #ifdef SUPPORT_WHITELIST | |
37 | |
38 class CPluginSettingsWhitelistLock : public CPluginMutex | 34 class CPluginSettingsWhitelistLock : public CPluginMutex |
39 { | 35 { |
40 public: | 36 public: |
41 CPluginSettingsWhitelistLock() : CPluginMutex(L"SettingsFileWhitelist", PLUGIN
_ERROR_MUTEX_SETTINGS_FILE_WHITELIST) {} | 37 CPluginSettingsWhitelistLock() : CPluginMutex(L"SettingsFileWhitelist", PLUGIN
_ERROR_MUTEX_SETTINGS_FILE_WHITELIST) {} |
42 ~CPluginSettingsWhitelistLock() {} | 38 ~CPluginSettingsWhitelistLock() {} |
43 }; | 39 }; |
44 | 40 |
45 #endif | |
46 | |
47 CPluginSettings* CPluginSettings::s_instance = NULL; | 41 CPluginSettings* CPluginSettings::s_instance = NULL; |
48 | |
49 CComAutoCriticalSection CPluginSettings::s_criticalSectionLocal; | 42 CComAutoCriticalSection CPluginSettings::s_criticalSectionLocal; |
50 | 43 |
51 | |
52 CPluginSettings::CPluginSettings() : m_dwWorkingThreadId(0) | 44 CPluginSettings::CPluginSettings() : m_dwWorkingThreadId(0) |
53 { | 45 { |
54 s_instance = NULL; | 46 s_instance = NULL; |
55 | |
56 m_WindowsBuildNumber = 0; | 47 m_WindowsBuildNumber = 0; |
57 | |
58 #ifdef SUPPORT_WHITELIST | |
59 ClearWhitelist(); | 48 ClearWhitelist(); |
60 #endif | |
61 } | 49 } |
62 | 50 |
63 | |
64 CPluginSettings::~CPluginSettings() | 51 CPluginSettings::~CPluginSettings() |
65 { | 52 { |
66 s_instance = NULL; | 53 s_instance = NULL; |
67 } | 54 } |
68 | 55 |
69 | |
70 CPluginSettings* CPluginSettings::GetInstance() | 56 CPluginSettings* CPluginSettings::GetInstance() |
71 { | 57 { |
72 CPluginSettings* instance = NULL; | 58 CPluginSettings* instance = NULL; |
73 | 59 |
74 s_criticalSectionLocal.Lock(); | 60 s_criticalSectionLocal.Lock(); |
75 { | 61 { |
76 if (!s_instance) | 62 if (!s_instance) |
77 { | 63 { |
78 s_instance = new CPluginSettings(); | 64 s_instance = new CPluginSettings(); |
79 } | 65 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 void CPluginSettings::AddError(const CString& error, const CString& errorCode) | 140 void CPluginSettings::AddError(const CString& error, const CString& errorCode) |
155 { | 141 { |
156 DEBUG_SETTINGS(L"SettingsTab::AddError error:" + error + " code:" + errorCode) | 142 DEBUG_SETTINGS(L"SettingsTab::AddError error:" + error + " code:" + errorCode) |
157 } | 143 } |
158 | 144 |
159 | 145 |
160 // ============================================================================ | 146 // ============================================================================ |
161 // Whitelist settings | 147 // Whitelist settings |
162 // ============================================================================ | 148 // ============================================================================ |
163 | 149 |
164 #ifdef SUPPORT_WHITELIST | |
165 | |
166 void CPluginSettings::ClearWhitelist() | 150 void CPluginSettings::ClearWhitelist() |
167 { | 151 { |
168 s_criticalSectionLocal.Lock(); | 152 s_criticalSectionLocal.Lock(); |
169 { | 153 { |
170 m_whitelistedDomains.clear(); | 154 m_whitelistedDomains.clear(); |
171 } | 155 } |
172 s_criticalSectionLocal.Unlock(); | 156 s_criticalSectionLocal.Unlock(); |
173 } | 157 } |
174 | 158 |
175 | |
176 bool CPluginSettings::ReadWhitelist(bool isDebug) | 159 bool CPluginSettings::ReadWhitelist(bool isDebug) |
177 { | 160 { |
178 bool isRead = true; | 161 bool isRead = true; |
179 | 162 |
180 DEBUG_SETTINGS("SettingsWhitelist::Read") | 163 DEBUG_SETTINGS("SettingsWhitelist::Read") |
181 | 164 |
182 if (isDebug) | 165 if (isDebug) |
183 { | 166 { |
184 DEBUG_GENERAL("*** Loading whitelist settings"); | 167 DEBUG_GENERAL("*** Loading whitelist settings"); |
185 } | 168 } |
186 | 169 |
187 CPluginSettingsWhitelistLock lock; | 170 CPluginSettingsWhitelistLock lock; |
188 if (lock.IsLocked()) | 171 if (lock.IsLocked()) |
189 { | 172 { |
190 ClearWhitelist(); | 173 ClearWhitelist(); |
191 | 174 |
192 s_criticalSectionLocal.Lock(); | 175 s_criticalSectionLocal.Lock(); |
193 m_whitelistedDomains = CPluginClient::GetInstance()->GetExceptionDomains()
; | 176 m_whitelistedDomains = CPluginClient::GetInstance()->GetExceptionDomains()
; |
194 s_criticalSectionLocal.Unlock(); | 177 s_criticalSectionLocal.Unlock(); |
195 } | 178 } |
196 else | 179 else |
197 { | 180 { |
198 isRead = false; | 181 isRead = false; |
199 } | 182 } |
200 | 183 |
201 return isRead; | 184 return isRead; |
202 } | 185 } |
203 | 186 |
204 | |
205 void CPluginSettings::AddWhiteListedDomain(const CString& domain) | 187 void CPluginSettings::AddWhiteListedDomain(const CString& domain) |
206 { | 188 { |
207 DEBUG_SETTINGS("SettingsWhitelist::AddWhiteListedDomain domain:" + domain) | 189 DEBUG_SETTINGS("SettingsWhitelist::AddWhiteListedDomain domain:" + domain) |
208 CPluginClient::GetInstance()->AddFilter(CreateDomainWhitelistingFilter(domain)
); | 190 CPluginClient::GetInstance()->AddFilter(CreateDomainWhitelistingFilter(domain)
); |
209 } | 191 } |
210 | 192 |
211 void CPluginSettings::RemoveWhiteListedDomain(const CString& domain) | 193 void CPluginSettings::RemoveWhiteListedDomain(const CString& domain) |
212 { | 194 { |
213 DEBUG_SETTINGS("SettingsWhitelist::RemoveWhiteListedDomain domain:" + domain) | 195 DEBUG_SETTINGS("SettingsWhitelist::RemoveWhiteListedDomain domain:" + domain) |
214 CPluginClient::GetInstance()->RemoveFilter(CreateDomainWhitelistingFilter(doma
in)); | 196 CPluginClient::GetInstance()->RemoveFilter(CreateDomainWhitelistingFilter(doma
in)); |
215 } | 197 } |
216 | 198 |
217 int CPluginSettings::GetWhiteListedDomainCount() const | 199 int CPluginSettings::GetWhiteListedDomainCount() const |
218 { | 200 { |
219 int count = 0; | 201 int count = 0; |
220 | 202 |
221 s_criticalSectionLocal.Lock(); | 203 s_criticalSectionLocal.Lock(); |
222 { | 204 { |
223 count = (int)m_whitelistedDomains.size(); | 205 count = (int)m_whitelistedDomains.size(); |
224 } | 206 } |
225 s_criticalSectionLocal.Unlock(); | 207 s_criticalSectionLocal.Unlock(); |
226 | 208 |
227 return count; | 209 return count; |
228 } | 210 } |
229 | 211 |
230 | |
231 std::vector<std::wstring> CPluginSettings::GetWhiteListedDomainList() | 212 std::vector<std::wstring> CPluginSettings::GetWhiteListedDomainList() |
232 { | 213 { |
233 bool r = ReadWhitelist(false); | 214 bool r = ReadWhitelist(false); |
234 return m_whitelistedDomains; | 215 return m_whitelistedDomains; |
235 } | 216 } |
236 | 217 |
237 | 218 |
238 bool CPluginSettings::RefreshWhitelist() | 219 bool CPluginSettings::RefreshWhitelist() |
239 { | 220 { |
240 CPluginSettingsWhitelistLock lock; | 221 CPluginSettingsWhitelistLock lock; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 | 270 |
290 CString CPluginSettings::GetAppLocale() | 271 CString CPluginSettings::GetAppLocale() |
291 { | 272 { |
292 return to_CString(GetBrowserLanguage()); | 273 return to_CString(GetBrowserLanguage()); |
293 } | 274 } |
294 | 275 |
295 CString CPluginSettings::GetDocumentationLink() | 276 CString CPluginSettings::GetDocumentationLink() |
296 { | 277 { |
297 return CString(CPluginClient::GetInstance()->GetDocumentationLink().c_str()); | 278 return CString(CPluginClient::GetInstance()->GetDocumentationLink().c_str()); |
298 } | 279 } |
299 | |
300 | |
301 | |
302 #endif // SUPPORT_WHITELIST | |
OLD | NEW |