OLD | NEW |
1 #include <AdblockPlus.h> | 1 #include <AdblockPlus.h> |
2 #include <functional> | 2 #include <functional> |
3 #include <vector> | 3 #include <vector> |
4 #include <Windows.h> | 4 #include <Windows.h> |
5 | 5 |
6 #include "../shared/AutoHandle.h" | 6 #include "../shared/AutoHandle.h" |
7 #include "../shared/Communication.h" | 7 #include "../shared/Communication.h" |
8 #include "../shared/Dictionary.h" | 8 #include "../shared/Dictionary.h" |
9 #include "../shared/Utils.h" | 9 #include "../shared/Utils.h" |
10 #include "../shared/Version.h" | 10 #include "../shared/Version.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 filterEngine->GetFilter(text)->AddToList(); | 136 filterEngine->GetFilter(text)->AddToList(); |
137 break; | 137 break; |
138 } | 138 } |
139 case Communication::PROC_REMOVE_FILTER: | 139 case Communication::PROC_REMOVE_FILTER: |
140 { | 140 { |
141 std::string text; | 141 std::string text; |
142 request >> text; | 142 request >> text; |
143 filterEngine->GetFilter(text)->RemoveFromList(); | 143 filterEngine->GetFilter(text)->RemoveFromList(); |
144 break; | 144 break; |
145 } | 145 } |
| 146 case Communication::PROC_SET_PREF: |
| 147 { |
| 148 std::string prefName; |
| 149 request >> prefName; |
| 150 |
| 151 Communication::ValueType valueType = request.GetType(); |
| 152 switch (valueType) |
| 153 { |
| 154 case Communication::TYPE_STRING: |
| 155 { |
| 156 std::string prefValue; |
| 157 request >> prefValue; |
| 158 filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValu
e(prefValue)); |
| 159 break; |
| 160 } |
| 161 case Communication::TYPE_INT64: |
| 162 { |
| 163 int64_t prefValue; |
| 164 request >> prefValue; |
| 165 filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValu
e(prefValue)); |
| 166 break; |
| 167 } |
| 168 case Communication::TYPE_INT32: |
| 169 { |
| 170 int prefValue; |
| 171 request >> prefValue; |
| 172 filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValu
e(prefValue)); |
| 173 break; |
| 174 } |
| 175 case Communication::TYPE_BOOL: |
| 176 { |
| 177 bool prefValue; |
| 178 request >> prefValue; |
| 179 filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValu
e(prefValue)); |
| 180 break; |
| 181 } |
| 182 default: |
| 183 break; |
| 184 } |
| 185 break; |
| 186 } |
| 187 case Communication::PROC_GET_PREF: |
| 188 { |
| 189 std::string name; |
| 190 request >> name; |
| 191 |
| 192 AdblockPlus::JsValuePtr valuePtr = filterEngine->GetPref(name); |
| 193 if (valuePtr->IsNull() || valuePtr->IsUndefined()) |
| 194 { |
| 195 // Report no success |
| 196 response << false; |
| 197 break; |
| 198 } |
| 199 |
| 200 // Report success |
| 201 response << true; |
| 202 |
| 203 if (valuePtr->IsBool()) |
| 204 { |
| 205 response << valuePtr->AsBool(); |
| 206 } |
| 207 else if (valuePtr->IsNumber()) |
| 208 { |
| 209 response << valuePtr->AsInt(); |
| 210 } |
| 211 else if (valuePtr->IsString()) |
| 212 { |
| 213 response << valuePtr->AsString(); |
| 214 } |
| 215 break; |
| 216 } |
| 217 |
146 } | 218 } |
147 return response; | 219 return response; |
148 } | 220 } |
149 | 221 |
150 DWORD WINAPI ClientThread(LPVOID param) | 222 DWORD WINAPI ClientThread(LPVOID param) |
151 { | 223 { |
152 std::auto_ptr<Communication::Pipe> pipe(static_cast<Communication::Pipe*>(pa
ram)); | 224 std::auto_ptr<Communication::Pipe> pipe(static_cast<Communication::Pipe*>(pa
ram)); |
153 | 225 |
154 try | 226 try |
155 { | 227 { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 } | 319 } |
248 catch (std::runtime_error e) | 320 catch (std::runtime_error e) |
249 { | 321 { |
250 DebugException(e); | 322 DebugException(e); |
251 return 1; | 323 return 1; |
252 } | 324 } |
253 } | 325 } |
254 | 326 |
255 return 0; | 327 return 0; |
256 } | 328 } |
OLD | NEW |