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()) |
+ { |
+ // Report no success |
+ response << false; |
+ break; |
+ } |
+ |
+ |
+ if (valuePtr->IsBool()) |
+ { |
+ response << true; |
+ response << valuePtr->AsBool(); |
+ } |
+ else if (valuePtr->IsNumber()) |
+ { |
+ response << true; |
+ response << valuePtr->AsInt(); |
+ } |
+ else if (valuePtr->IsString()) |
+ { |
+ response << true; |
+ response << valuePtr->AsString(); |
+ } |
+ else |
+ { |
+ // Report failure |
+ response << false; |
+ } |
+ break; |
+ } |
+ |
} |
return response; |
} |