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 |
| 201 if (valuePtr->IsBool()) |
| 202 { |
| 203 response << true; |
| 204 response << valuePtr->AsBool(); |
| 205 } |
| 206 else if (valuePtr->IsNumber()) |
| 207 { |
| 208 response << true; |
| 209 response << valuePtr->AsInt(); |
| 210 } |
| 211 else if (valuePtr->IsString()) |
| 212 { |
| 213 response << true; |
| 214 response << valuePtr->AsString(); |
| 215 } |
| 216 else |
| 217 { |
| 218 // Report failure |
| 219 response << false; |
| 220 } |
| 221 break; |
| 222 } |
| 223 |
146 } | 224 } |
147 return response; | 225 return response; |
148 } | 226 } |
149 | 227 |
150 DWORD WINAPI ClientThread(LPVOID param) | 228 DWORD WINAPI ClientThread(LPVOID param) |
151 { | 229 { |
152 std::auto_ptr<Communication::Pipe> pipe(static_cast<Communication::Pipe*>(pa
ram)); | 230 std::auto_ptr<Communication::Pipe> pipe(static_cast<Communication::Pipe*>(pa
ram)); |
153 | 231 |
154 try | 232 try |
155 { | 233 { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 } | 325 } |
248 catch (std::runtime_error e) | 326 catch (std::runtime_error e) |
249 { | 327 { |
250 DebugException(e); | 328 DebugException(e); |
251 return 1; | 329 return 1; |
252 } | 330 } |
253 } | 331 } |
254 | 332 |
255 return 0; | 333 return 0; |
256 } | 334 } |
OLD | NEW |