Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/plugin/PluginSettings.cpp

Issue 5187613258416128: Issue #1234 - Rewrite internals of debug facility (Closed)
Patch Set: rebase only Created Nov. 26, 2015, 1:02 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 23 matching lines...) Expand all
34 class CPluginSettingsWhitelistLock : public CPluginMutex 34 class CPluginSettingsWhitelistLock : public CPluginMutex
35 { 35 {
36 public: 36 public:
37 CPluginSettingsWhitelistLock() : CPluginMutex(L"SettingsFileWhitelist", PLUGIN _ERROR_MUTEX_SETTINGS_FILE_WHITELIST) {} 37 CPluginSettingsWhitelistLock() : CPluginMutex(L"SettingsFileWhitelist", PLUGIN _ERROR_MUTEX_SETTINGS_FILE_WHITELIST) {}
38 ~CPluginSettingsWhitelistLock() {} 38 ~CPluginSettingsWhitelistLock() {}
39 }; 39 };
40 40
41 CPluginSettings* CPluginSettings::s_instance = NULL; 41 CPluginSettings* CPluginSettings::s_instance = NULL;
42 CComAutoCriticalSection CPluginSettings::s_criticalSectionLocal; 42 CComAutoCriticalSection CPluginSettings::s_criticalSectionLocal;
43 43
44 CPluginSettings::CPluginSettings() : m_dwWorkingThreadId(0) 44 CPluginSettings::CPluginSettings()
45 { 45 {
46 s_instance = NULL; 46 s_instance = NULL;
47 ClearWhitelist(); 47 ClearWhitelist();
48 } 48 }
49 49
50 CPluginSettings::~CPluginSettings() 50 CPluginSettings::~CPluginSettings()
51 { 51 {
52 s_instance = NULL; 52 s_instance = NULL;
53 } 53 }
54 54
(...skipping 22 matching lines...) Expand all
77 77
78 s_criticalSectionLocal.Lock(); 78 s_criticalSectionLocal.Lock();
79 { 79 {
80 hasInstance = s_instance != NULL; 80 hasInstance = s_instance != NULL;
81 } 81 }
82 s_criticalSectionLocal.Unlock(); 82 s_criticalSectionLocal.Unlock();
83 83
84 return hasInstance; 84 return hasInstance;
85 } 85 }
86 86
87 std::wstring GetDataPath(const std::wstring& filename)
88 {
89 return GetAppDataPath() + L"\\" + filename;
90 }
91
92 bool CPluginSettings::IsPluginEnabled() const 87 bool CPluginSettings::IsPluginEnabled() const
93 { 88 {
94 return GetPluginEnabled(); 89 return GetPluginEnabled();
95 } 90 }
96 91
97 std::map<std::wstring, std::wstring> CPluginSettings::GetFilterLanguageTitleList () const 92 std::map<std::wstring, std::wstring> CPluginSettings::GetFilterLanguageTitleList () const
98 { 93 {
99 auto subscriptions = CPluginClient::GetInstance()->FetchAvailableSubscriptions (); 94 auto subscriptions = CPluginClient::GetInstance()->FetchAvailableSubscriptions ();
100 95
101 std::map<std::wstring, std::wstring> filterList; 96 std::map<std::wstring, std::wstring> filterList;
102 for (size_t i = 0; i < subscriptions.size(); i ++) 97 for (size_t i = 0; i < subscriptions.size(); i ++)
103 { 98 {
104 auto it = subscriptions[i]; 99 auto it = subscriptions[i];
105 filterList.insert(std::make_pair(it.url, it.title)); 100 filterList.insert(std::make_pair(it.url, it.title));
106 } 101 }
107 return filterList; 102 return filterList;
108 } 103 }
109 104
110 bool CPluginSettings::IsWorkingThread(DWORD dwThreadId) const
111 {
112 if (dwThreadId == 0)
113 {
114 dwThreadId = ::GetCurrentThreadId();
115 }
116 return m_dwWorkingThreadId == dwThreadId;
117 }
118
119 void CPluginSettings::SetWorkingThreadId()
120 {
121 m_dwWorkingThreadId = ::GetCurrentThreadId();
122 }
123
124 void CPluginSettings::SetWorkingThreadId(DWORD id)
125 {
126 m_dwWorkingThreadId = id;
127 }
128
129 void CPluginSettings::TogglePluginEnabled() 105 void CPluginSettings::TogglePluginEnabled()
130 { 106 {
131 CPluginClient::GetInstance()->TogglePluginEnabled(); 107 CPluginClient::GetInstance()->TogglePluginEnabled();
132 } 108 }
133 bool CPluginSettings::GetPluginEnabled() const 109 bool CPluginSettings::GetPluginEnabled() const
134 { 110 {
135 return CPluginClient::GetInstance()->GetPref(L"enabled", true); 111 return CPluginClient::GetInstance()->GetPref(L"enabled", true);
136 } 112 }
137 113
138 void CPluginSettings::AddError(const CString& error, const CString& errorCode) 114 void CPluginSettings::AddError(const CString& error, const CString& errorCode)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 213
238 for (auto subscription = subscriptions.begin(); subscription != subscriptions. end(); subscription++) 214 for (auto subscription = subscriptions.begin(); subscription != subscriptions. end(); subscription++)
239 { 215 {
240 if (subscription->url != aaUrl) 216 if (subscription->url != aaUrl)
241 { 217 {
242 return subscription->url; 218 return subscription->url;
243 } 219 }
244 } 220 }
245 return std::wstring(); 221 return std::wstring();
246 } 222 }
OLDNEW

Powered by Google App Engine
This is Rietveld