OLD | NEW |
(Empty) | |
| 1 #include "UserDefinedSubscription.h" |
| 2 |
| 3 int UserDefinedSubscription::filterTypeToDefaults[] = { |
| 4 UserDefinedSubscription::Defaults::BLOCKING, // UNKNOWN |
| 5 UserDefinedSubscription::Defaults::BLOCKING, // INVALID |
| 6 UserDefinedSubscription::Defaults::BLOCKING, // COMMENT |
| 7 UserDefinedSubscription::Defaults::BLOCKING, // BLOCKING |
| 8 UserDefinedSubscription::Defaults::WHITELIST, // WHITELIST |
| 9 UserDefinedSubscription::Defaults::ELEMHIDE, // ELEMHIDE |
| 10 UserDefinedSubscription::Defaults::ELEMHIDE, // ELEMHIDEEXCEPTION |
| 11 UserDefinedSubscription::Defaults::ELEMHIDE, // ELEMHIDEEMULATION |
| 12 }; |
| 13 |
| 14 UserDefinedSubscription::UserDefinedSubscription(const String& id) |
| 15 : Subscription(Type::USERDEFINED, id), mDefaults(0) |
| 16 { |
| 17 } |
| 18 |
| 19 bool UserDefinedSubscription::isDefaultFor(const Filter* filter) const |
| 20 { |
| 21 return mDefaults & filterTypeToDefaults[filter->mType]; |
| 22 } |
| 23 |
| 24 void UserDefinedSubscription::makeDefaultFor(const Filter* filter) |
| 25 { |
| 26 mDefaults |= filterTypeToDefaults[filter->mType]; |
| 27 } |
| 28 |
| 29 OwnedString UserDefinedSubscription::Serialize() const |
| 30 { |
| 31 OwnedString result(Subscription::Serialize()); |
| 32 if (mDefaults) |
| 33 { |
| 34 result.append(u"defaults="_str); |
| 35 if (mDefaults & Defaults::BLOCKING) |
| 36 result.append(u" blocking"_str); |
| 37 if (mDefaults & Defaults::WHITELIST) |
| 38 result.append(u" whitelist"_str); |
| 39 if (mDefaults & Defaults::ELEMHIDE) |
| 40 result.append(u" elemhide"_str); |
| 41 result.append(u'\n'); |
| 42 } |
| 43 return result; |
| 44 } |
OLD | NEW |