LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 #pragma once | 18 #pragma once |
19 | 19 |
20 #include <type_traits> | 20 #include <type_traits> |
21 #include <vector> | 21 #include <vector> |
22 | 22 |
23 #include <emscripten.h> | |
24 | |
25 #include "../filter/Filter.h" | 23 #include "../filter/Filter.h" |
26 #include "../String.h" | 24 #include "../String.h" |
27 #include "../FilterNotifier.h" | 25 #include "../FilterNotifier.h" |
28 #include "../intrusive_ptr.h" | 26 #include "../intrusive_ptr.h" |
29 #include "../debug.h" | 27 #include "../debug.h" |
| 28 #include "../bindings/runtime.h" |
30 | 29 |
31 #define SUBSCRIPTION_PROPERTY_INTERNAL(field_type, param_type, name, topic, gett
er, setter) \ | 30 #define SUBSCRIPTION_PROPERTY_INTERNAL(field_type, param_type, name, topic, gett
er, setter) \ |
32 private:\ | 31 private:\ |
33 field_type name;\ | 32 field_type name;\ |
34 public:\ | 33 public:\ |
35 param_type EMSCRIPTEN_KEEPALIVE getter() const\ | 34 param_type BINDINGS_EXPORTED getter() const\ |
36 {\ | 35 {\ |
37 return name;\ | 36 return name;\ |
38 }\ | 37 }\ |
39 void EMSCRIPTEN_KEEPALIVE setter(param_type value)\ | 38 void BINDINGS_EXPORTED setter(param_type value)\ |
40 {\ | 39 {\ |
41 if (name != value)\ | 40 if (name != value)\ |
42 {\ | 41 {\ |
43 name = value;\ | 42 name = value;\ |
44 if (FilterNotifier::Topic::topic != FilterNotifier::Topic::NONE)\ | 43 if (FilterNotifier::Topic::topic != FilterNotifier::Topic::NONE)\ |
45 {\ | 44 {\ |
46 FilterNotifier::SubscriptionChange(FilterNotifier::Topic::topic,\ | 45 FilterNotifier::SubscriptionChange(FilterNotifier::Topic::topic,\ |
47 this);\ | 46 this);\ |
48 }\ | 47 }\ |
49 }\ | 48 }\ |
(...skipping 18 matching lines...) Expand all Loading... |
68 UNKNOWN = 0, | 67 UNKNOWN = 0, |
69 DOWNLOADABLE = 1, | 68 DOWNLOADABLE = 1, |
70 USERDEFINED = 2 | 69 USERDEFINED = 2 |
71 }; | 70 }; |
72 | 71 |
73 explicit Subscription(Type type, const String& id); | 72 explicit Subscription(Type type, const String& id); |
74 ~Subscription(); | 73 ~Subscription(); |
75 | 74 |
76 Type mType; | 75 Type mType; |
77 | 76 |
78 EMSCRIPTEN_KEEPALIVE const String& GetID() const | 77 BINDINGS_EXPORTED const String& GetID() const |
79 { | 78 { |
80 return mID; | 79 return mID; |
81 } | 80 } |
82 | 81 |
83 SUBSCRIPTION_STRING_PROPERTY(mTitle, SUBSCRIPTION_TITLE, GetTitle, SetTitle); | 82 SUBSCRIPTION_STRING_PROPERTY(mTitle, SUBSCRIPTION_TITLE, GetTitle, SetTitle); |
84 SUBSCRIPTION_PROPERTY(bool, mDisabled, SUBSCRIPTION_DISABLED, | 83 SUBSCRIPTION_PROPERTY(bool, mDisabled, SUBSCRIPTION_DISABLED, |
85 GetDisabled, SetDisabled); | 84 GetDisabled, SetDisabled); |
86 | 85 |
87 EMSCRIPTEN_KEEPALIVE unsigned GetFilterCount() const | 86 BINDINGS_EXPORTED unsigned GetFilterCount() const |
88 { | 87 { |
89 return mFilters.size(); | 88 return mFilters.size(); |
90 } | 89 } |
91 | 90 |
92 EMSCRIPTEN_KEEPALIVE Filter* FilterAt(unsigned index); | 91 BINDINGS_EXPORTED Filter* FilterAt(unsigned index); |
93 EMSCRIPTEN_KEEPALIVE int IndexOfFilter(Filter* filter); | 92 BINDINGS_EXPORTED int IndexOfFilter(Filter* filter); |
94 EMSCRIPTEN_KEEPALIVE OwnedString Serialize() const; | 93 BINDINGS_EXPORTED OwnedString Serialize() const; |
95 EMSCRIPTEN_KEEPALIVE OwnedString SerializeFilters() const; | 94 BINDINGS_EXPORTED OwnedString SerializeFilters() const; |
96 | 95 |
97 static EMSCRIPTEN_KEEPALIVE Subscription* FromID(const String& id); | 96 static BINDINGS_EXPORTED Subscription* FromID(const String& id); |
98 }; | 97 }; |
99 | 98 |
100 typedef intrusive_ptr<Subscription> SubscriptionPtr; | 99 typedef intrusive_ptr<Subscription> SubscriptionPtr; |
LEFT | RIGHT |