Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/Notification.cpp

Issue 4904655779790848: Issue 1107.update1 - read Notification properties (title, message and type) on the fly (Closed)
Patch Set: fix style Created Jan. 27, 2015, 1:18 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/FilterEngine.cpp ('k') | test/Notification.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/Notification.cpp
diff --git a/src/Notification.cpp b/src/Notification.cpp
index 0791f3db86d0464c162812bce203f6fb9a03f0ca..c490e688846ad90d1d3aba8cefc8d17bc8318109 100644
--- a/src/Notification.cpp
+++ b/src/Notification.cpp
@@ -64,50 +64,31 @@ Notification::Notification(const JsValuePtr& jsValue)
NotificationType Notification::GetType() const
{
- return type;
+ return StringToNotificationType(GetProperty("type")->AsString());
}
-const std::string& Notification::GetTitle() const
+NotificationTexts Notification::GetTexts()
{
- return title;
-}
-
-const std::string& Notification::GetMessageString() const
-{
- return message;
-}
-
-void Notification::MarkAsShown()
-{
- JsValueList params;
- params.push_back(GetProperty("id"));
- jsEngine->Evaluate("API.markNotificationAsShown")->Call(params);
-}
-
-NotificationPtr Notification::JsValueToNotification(const JsValuePtr& jsValue)
-{
- if (!jsValue || !jsValue->IsObject())
- {
- return NotificationPtr();
- }
-
- NotificationPtr notification(new Notification(jsValue));
- JsValuePtr jsType = notification->GetProperty("type");
- notification->type = StringToNotificationType(jsType ? jsType->AsString() : "");
-
JsValueList params;
- params.push_back(notification);
- JsValuePtr func = notification->jsEngine->Evaluate("API.getNotificationTexts");
- JsValuePtr jsTexts = func->Call(params);
+ params.push_back(shared_from_this());
+ JsValuePtr jsTexts = jsEngine->Evaluate("API.getNotificationTexts")->Call(params);
+ NotificationTexts notificationTexts;
JsValuePtr jsTitle = jsTexts->GetProperty("title");
if (jsTitle->IsString())
{
- notification->title = jsTitle->AsString();
+ notificationTexts.title = jsTitle->AsString();
}
JsValuePtr jsMessage = jsTexts->GetProperty("message");
if (jsMessage->IsString())
{
- notification->message = jsMessage->AsString();
+ notificationTexts.message = jsMessage->AsString();
}
- return notification;
+ return notificationTexts;
+}
+
+void Notification::MarkAsShown()
+{
+ JsValueList params;
+ params.push_back(GetProperty("id"));
+ jsEngine->Evaluate("API.markNotificationAsShown")->Call(params);
}
« no previous file with comments | « src/FilterEngine.cpp ('k') | test/Notification.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld