Index: src/engine/main.cpp |
=================================================================== |
--- a/src/engine/main.cpp |
+++ b/src/engine/main.cpp |
@@ -143,6 +143,84 @@ |
filterEngine->GetFilter(text)->RemoveFromList(); |
break; |
} |
+ case Communication::PROC_SET_PREF: |
+ { |
+ std::string prefName; |
+ request >> prefName; |
+ |
+ Communication::ValueType valueType = request.GetType(); |
+ switch (valueType) |
+ { |
+ case Communication::TYPE_STRING: |
+ { |
+ std::string prefValue; |
+ request >> prefValue; |
+ filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValue(prefValue)); |
+ break; |
+ } |
+ case Communication::TYPE_INT64: |
+ { |
+ int64_t prefValue; |
+ request >> prefValue; |
+ filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValue(prefValue)); |
+ break; |
+ } |
+ case Communication::TYPE_INT32: |
+ { |
+ int prefValue; |
+ request >> prefValue; |
+ filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValue(prefValue)); |
+ break; |
+ } |
+ case Communication::TYPE_BOOL: |
+ { |
+ bool prefValue; |
+ request >> prefValue; |
+ filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValue(prefValue)); |
+ break; |
+ } |
+ default: |
+ break; |
+ } |
+ break; |
+ } |
+ case Communication::PROC_GET_PREF: |
+ { |
+ std::string name; |
+ request >> name; |
+ |
+ AdblockPlus::JsValuePtr valuePtr = filterEngine->GetPref(name); |
+ if (valuePtr->IsNull() || valuePtr->IsUndefined()) |
Wladimir Palant
2013/07/26 16:45:37
valuePtr->IsNull() will be true for undefined as w
Oleksandr
2013/08/05 23:11:01
This was addressed in:
https://hg.adblockplus.org/
|
+ { |
+ // Report no success |
+ response << false; |
+ break; |
+ } |
+ |
+ |
+ if (valuePtr->IsBool()) |
+ { |
+ response << valuePtr->AsBool(); |
+ response << true; |
Wladimir Palant
2013/07/26 16:45:37
I don't get this, shouldn't you first write succes
|
+ } |
+ else if (valuePtr->IsNumber()) |
+ { |
+ response << valuePtr->AsInt(); |
+ response << true; |
+ } |
+ else if (valuePtr->IsString()) |
+ { |
+ response << valuePtr->AsString(); |
+ response << true; |
+ } |
+ else |
+ { |
+ // Report failure |
+ response << false; |
+ } |
+ break; |
+ } |
+ |
} |
return response; |
} |