Index: include/AdblockPlus/Notification.h |
diff --git a/include/AdblockPlus/Notification.h b/include/AdblockPlus/Notification.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e8b7078adba2b1e830cf16e8b2acca633b0149c2 |
--- /dev/null |
+++ b/include/AdblockPlus/Notification.h |
@@ -0,0 +1,67 @@ |
+/* |
+ * This file is part of Adblock Plus <https://adblockplus.org/>, |
+ * Copyright (C) 2006-2015 Eyeo GmbH |
+ * |
+ * Adblock Plus is free software: you can redistribute it and/or modify |
+ * it under the terms of the GNU General Public License version 3 as |
+ * published by the Free Software Foundation. |
+ * |
+ * Adblock Plus is distributed in the hope that it will be useful, |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+ * GNU General Public License for more details. |
+ * |
+ * You should have received a copy of the GNU General Public License |
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
+ */ |
+ |
+#ifndef ADBLOCK_PLUS_NOTIFICATION_H |
+#define ADBLOCK_PLUS_NOTIFICATION_H |
+ |
+#include <string> |
+#include <vector> |
+#include <memory> |
+ |
+namespace AdblockPlus |
+{ |
+ class FilterEngine; |
+ enum NotificationType |
+ { |
+ NOTIFICATION_TYPE_INFORMATION = 0, |
Felix Dahlke
2015/01/22 10:25:25
Why explicitly assign the values here? We typicall
sergei
2015/01/22 14:08:15
fixed
|
+ NOTIFICATION_TYPE_QUESTION = 1, |
Felix Dahlke
2015/01/22 10:25:25
No column aligning please :D
|
+ NOTIFICATION_TYPE_CRITICAL = 2 |
+ }; |
+ |
+ struct NotificationTexts |
Felix Dahlke
2015/01/22 10:25:25
It's a single one, so "NotificationText"?
sergei
2015/01/22 14:08:15
Actually there were two fields and the plural form
Felix Dahlke
2015/01/22 14:36:31
Argh you're right, of course it's two. Should real
|
+ { |
+ std::string title; |
+ std::string message; |
+ }; |
+ |
+ class Notification : public JsValue, public std::tr1::enable_shared_from_this<Notification> |
+ { |
+ friend class FilterEngine; |
+ protected: |
+ struct PrivateCtrArg{}; |
Felix Dahlke
2015/01/22 10:25:25
I still find this pattern highly obscure. We've go
sergei
2015/01/22 14:08:15
JIC, if the constructor is not public then std::ma
|
+ static std::tr1::shared_ptr<Notification> JsValueToNotification(const JsValuePtr& jsValue); |
+ /// @param jsText is javascript object returned by getLocalizedTexts. |
+ static NotificationTexts JsTextsToNotificationTexts(const JsValue& jsText); |
+ public: |
+ Notification(NotificationType type, const std::string& id, const JsValuePtr& jsValue, PrivateCtrArg); |
+ Notification(const JsValuePtr& value, PrivateCtrArg); |
+ std::string GetId() const; |
Wladimir Palant
2015/01/22 10:47:20
I think this method should be removed. The ID is a
sergei
2015/01/22 14:08:15
removed
|
+ NotificationType GetType() const; |
+ /** |
+ * Localizes the texts of the supplied notification. |
+ * @return the translated texts. |
+ */ |
+ NotificationTexts GetTexts(); |
Wladimir Palant
2015/01/22 10:47:20
An explicit method here shouldn't be necessary. Th
sergei
2015/01/22 14:08:15
fixed
Felix Dahlke
2015/01/23 21:27:50
Missed this discussion before. I actually disagree
|
+ void SetTitle(const std::string& value); |
+ void SetMessage(const std::string& value); |
+ std::vector<std::string> GetUrlFilters() const; |
+ void AddUrlFilter(const std::string& value); |
Wladimir Palant
2015/01/22 10:47:20
The four methods above should be removed - as disc
sergei
2015/01/22 14:08:15
fixed
|
+ void MarkAsShown(); |
+ }; |
+} |
+ |
+#endif |