Index: src/engine/main.cpp |
=================================================================== |
--- a/src/engine/main.cpp |
+++ b/src/engine/main.cpp |
@@ -145,11 +145,43 @@ |
} |
case Communication::PROC_SET_PREF: |
{ |
- std::string prefName = ""; |
- std::string prefValue = ""; |
+ std::string prefName; |
request >> prefName; |
- request >> prefValue; |
- filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValue(prefValue)); |
+ |
+ 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: |
@@ -158,11 +190,26 @@ |
request >> name; |
AdblockPlus::JsValuePtr valuePtr = filterEngine->GetPref(name); |
- if ((valuePtr->IsNull()) || (!valuePtr->IsString())) |
- response << 0; |
- else |
+ if (valuePtr->IsNull() || valuePtr->IsUndefined()) |
{ |
- response << 1; |
+ // Report no success |
+ response << false; |
+ break; |
+ } |
+ |
+ // Report success |
+ response << true; |
+ |
+ if (valuePtr->IsBool()) |
+ { |
+ response << valuePtr->AsBool(); |
+ } |
+ else if (valuePtr->IsNumber()) |
+ { |
+ response << valuePtr->AsInt(); |
+ } |
+ else if (valuePtr->IsString()) |
+ { |
response << valuePtr->AsString(); |
} |
break; |