Index: compiled/subscription/UserDefinedSubscription.cpp |
diff --git a/compiled/subscription/UserDefinedSubscription.cpp b/compiled/subscription/UserDefinedSubscription.cpp |
index 5e3972e09d80281d08e5f9c192b7ae129a2c6ce2..749e86f5033ee306b5703c260c2d3f20b42493ce 100644 |
--- a/compiled/subscription/UserDefinedSubscription.cpp |
+++ b/compiled/subscription/UserDefinedSubscription.cpp |
@@ -45,9 +45,10 @@ namespace |
} |
} |
-UserDefinedSubscription::UserDefinedSubscription(const String& id) |
- : Subscription(classType, id), mDefaults(0) |
+UserDefinedSubscription::UserDefinedSubscription(const String& id, const KeyValues& properties) |
+ : Subscription(classType, id, properties), mDefaults(0) |
{ |
+ parseDefaultsProperty(properties, mDefaults); |
} |
bool UserDefinedSubscription::IsDefaultFor(const Filter& filter) const |
@@ -88,9 +89,9 @@ bool UserDefinedSubscription::RemoveFilterAt(unsigned pos) |
return true; |
} |
-OwnedString UserDefinedSubscription::Serialize() const |
+OwnedString UserDefinedSubscription::SerializeProperties() const |
{ |
- OwnedString result(Subscription::Serialize()); |
+ OwnedString result(Subscription::DoSerializeProperties()); |
if (!IsGeneric()) |
{ |
result.append(u"defaults="_str); |
@@ -104,3 +105,23 @@ OwnedString UserDefinedSubscription::Serialize() const |
} |
return result; |
} |
+ |
+void UserDefinedSubscription::parseDefaultsProperty(const KeyValues& properties, int& defaults) |
+{ |
+ auto stringDefaultFor = findPropertyValue(properties, u"defaults"_str); |
+ if (stringDefaultFor == nullptr) |
+ return; |
+ String::size_type prevSpacePos = 0; |
+ while (prevSpacePos != String::npos) |
+ { |
+ String::size_type spacePos = stringDefaultFor->find(u' ', prevSpacePos + 1); |
+ auto values = SplitString(DependentString(*stringDefaultFor, prevSpacePos), spacePos); |
+ if (values.first == u"blocking"_str) |
+ defaults |= FilterCategory::BLOCKING; |
+ else if (values.first == u"whitelist"_str) |
+ defaults |= FilterCategory::WHITELIST; |
+ else if (values.first == u"elemhide"_str) |
+ defaults |= FilterCategory::ELEMHIDE; |
+ prevSpacePos = spacePos; |
+ } |
+} |