OLD | NEW |
1 /** | 1 /** |
2 * This class contains all client functionality of the IE plugin | 2 * This class contains all client functionality of the IE plugin |
3 * | 3 * |
4 * Exception errors are tested by calls to ExceptionsTest from: Main ... | 4 * Exception errors are tested by calls to ExceptionsTest from: Main ... |
5 */ | 5 */ |
6 | 6 |
7 #ifndef _PLUGIN_SETTINGS_H_ | 7 #ifndef _PLUGIN_SETTINGS_H_ |
8 #define _PLUGIN_SETTINGS_H_ | 8 #define _PLUGIN_SETTINGS_H_ |
9 | 9 |
10 | |
11 #include "PluginTypedef.h" | 10 #include "PluginTypedef.h" |
12 #include "AdblockPlusClient.h" | 11 #include "AdblockPlusClient.h" |
13 | 12 |
14 // Main settings | 13 // Main settings |
15 | 14 |
16 #define SETTING_PLUGIN_INFO_PANEL L"plugininfopanel" | 15 #define SETTING_PLUGIN_INFO_PANEL L"plugininfopanel" |
17 #define SETTING_PLUGIN_VERSION L"pluginversion" | 16 #define SETTING_PLUGIN_VERSION L"pluginversion" |
18 #define SETTING_PLUGIN_UPDATE_VERSION L"pluginupdateversion" | 17 #define SETTING_PLUGIN_UPDATE_VERSION L"pluginupdateversion" |
19 #define SETTING_PLUGIN_SELFTEST L"pluginselftest" | 18 #define SETTING_PLUGIN_SELFTEST L"pluginselftest" |
20 #define SETTING_LANGUAGE L"language" | 19 #define SETTING_LANGUAGE L"language" |
21 | |
22 #ifdef SUPPORT_CONFIG | |
23 #define SETTING_CONFIG_VERSION L"configversion" | |
24 #endif | |
25 #define SETTING_DICTIONARY_VERSION L"dictionaryversion" | 20 #define SETTING_DICTIONARY_VERSION L"dictionaryversion" |
26 | 21 |
27 // Tab settings | 22 // Tab settings |
28 | 23 |
29 #define SETTING_TAB_PLUGIN_ENABLED L"pluginenabled" | 24 #define SETTING_TAB_PLUGIN_ENABLED L"pluginenabled" |
30 #define SETTING_TAB_COUNT L"tabcount" | 25 #define SETTING_TAB_COUNT L"tabcount" |
31 #define SETTING_TAB_START_TIME L"tabstart" | 26 #define SETTING_TAB_START_TIME L"tabstart" |
32 #define SETTING_TAB_UPDATE_ON_START L"updateonstart" | 27 #define SETTING_TAB_UPDATE_ON_START L"updateonstart" |
33 #define SETTING_TAB_UPDATE_ON_START_REMOVE L"updateonstartremove" | 28 #define SETTING_TAB_UPDATE_ON_START_REMOVE L"updateonstartremove" |
34 #define SETTING_TAB_DICTIONARY_VERSION L"dictionaryversion" | 29 #define SETTING_TAB_DICTIONARY_VERSION L"dictionaryversion" |
35 #define SETTING_TAB_SETTINGS_VERSION L"settingsversion" | 30 #define SETTING_TAB_SETTINGS_VERSION L"settingsversion" |
36 #ifdef SUPPORT_FILTER | |
37 #define SETTING_TAB_FILTER_VERSION L"filterversion" | 31 #define SETTING_TAB_FILTER_VERSION L"filterversion" |
38 #endif | |
39 | |
40 #ifdef SUPPORT_WHITELIST | |
41 #define SETTING_TAB_WHITELIST_VERSION L"whitelistversion" | 32 #define SETTING_TAB_WHITELIST_VERSION L"whitelistversion" |
42 #endif | |
43 #ifdef SUPPORT_CONFIG | |
44 #define SETTING_TAB_CONFIG_VERSION L"configversion" | |
45 #endif | |
46 | |
47 | 33 |
48 class CPluginIniFileW; | 34 class CPluginIniFileW; |
49 | 35 |
50 | |
51 class CPluginSettings | 36 class CPluginSettings |
52 { | 37 { |
53 | |
54 private: | 38 private: |
55 | |
56 DWORD m_dwWorkingThreadId; | 39 DWORD m_dwWorkingThreadId; |
57 | 40 |
58 static CComAutoCriticalSection s_criticalSectionLocal; | 41 static CComAutoCriticalSection s_criticalSectionLocal; |
59 | 42 |
60 void Clear(); | 43 void Clear(); |
61 | 44 |
62 // Private constructor used by the singleton pattern | 45 // Private constructor used by the singleton pattern |
63 CPluginSettings(); | 46 CPluginSettings(); |
| 47 |
64 public: | 48 public: |
65 | |
66 ~CPluginSettings(); | 49 ~CPluginSettings(); |
67 | 50 |
68 static CPluginSettings* s_instance; | 51 static CPluginSettings* s_instance; |
69 | 52 |
70 static bool HasInstance(); | 53 static bool HasInstance(); |
71 static CPluginSettings* GetInstance(); | 54 static CPluginSettings* GetInstance(); |
72 | 55 |
73 bool IsPluginEnabled() const; | 56 bool IsPluginEnabled() const; |
74 | 57 |
75 std::map<CString, CString> GetFilterLanguageTitleList() const; | 58 std::map<CString, CString> GetFilterLanguageTitleList() const; |
76 | 59 |
77 void SetWorkingThreadId(); | 60 void SetWorkingThreadId(); |
78 void SetWorkingThreadId(DWORD id); | 61 void SetWorkingThreadId(DWORD id); |
79 bool IsWorkingThread(DWORD dwThread=0) const; | 62 bool IsWorkingThread(DWORD dwThread=0) const; |
80 | 63 |
81 DWORD m_WindowsBuildNumber; | 64 DWORD m_WindowsBuildNumber; |
82 | 65 |
83 public: | 66 public: |
84 | 67 |
85 void TogglePluginEnabled(); | 68 void TogglePluginEnabled(); |
86 bool GetPluginEnabled() const; | 69 bool GetPluginEnabled() const; |
87 | 70 |
88 void AddError(const CString& error, const CString& errorCode); | 71 void AddError(const CString& error, const CString& errorCode); |
89 | 72 |
90 // Settings whitelist | 73 // Settings whitelist |
91 #ifdef SUPPORT_WHITELIST | |
92 | |
93 private: | 74 private: |
94 std::vector<std::wstring> m_whitelistedDomains; | 75 std::vector<std::wstring> m_whitelistedDomains; |
95 | |
96 void ClearWhitelist(); | 76 void ClearWhitelist(); |
97 bool ReadWhitelist(bool bDebug=true); | 77 bool ReadWhitelist(bool bDebug=true); |
98 | 78 |
99 public: | 79 public: |
100 void AddWhiteListedDomain(const CString& domain); | 80 void AddWhiteListedDomain(const CString& domain); |
101 void RemoveWhiteListedDomain(const CString& domain); | 81 void RemoveWhiteListedDomain(const CString& domain); |
102 int GetWhiteListedDomainCount() const; | 82 int GetWhiteListedDomainCount() const; |
103 std::vector<std::wstring> GetWhiteListedDomainList(); | 83 std::vector<std::wstring> GetWhiteListedDomainList(); |
104 #endif //SUPPORT_WHITELIST | |
105 | 84 |
106 bool RefreshWhitelist(); | 85 bool RefreshWhitelist(); |
107 DWORD GetWindowsBuildNumber(); | 86 DWORD GetWindowsBuildNumber(); |
108 | 87 |
109 void SetSubscription(const std::wstring& url); | 88 void SetSubscription(const std::wstring& url); |
110 void SetDefaultSubscription(); | 89 void SetDefaultSubscription(); |
111 CString GetSubscription(); | 90 CString GetSubscription(); |
112 CString GetAppLocale(); | 91 CString GetAppLocale(); |
113 CString GetDocumentationLink(); | 92 CString GetDocumentationLink(); |
114 }; | 93 }; |
115 | 94 |
116 std::wstring GetDataPath(const std::wstring& filename=L""); | 95 std::wstring GetDataPath(const std::wstring& filename=L""); |
117 | 96 |
118 #endif // _PLUGIN_SETTINGS_H_ | 97 #endif // _PLUGIN_SETTINGS_H_ |
OLD | NEW |