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: rebase Created Nov. 4, 2015, 9:22 a.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 d7514889f260caab664503cdf176d111532e896a..25cd425f6acc84c2665716901cec5e78fbcac2f0 100644
--- a/src/Notification.cpp
+++ b/src/Notification.cpp
@@ -64,17 +64,26 @@ 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;
+ JsValueList 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())
+ {
+ notificationTexts.title = jsTitle->AsString();
+ }
+ JsValuePtr jsMessage = jsTexts->GetProperty("message");
+ if (jsMessage->IsString())
+ {
+ notificationTexts.message = jsMessage->AsString();
+ }
+ return notificationTexts;
}
std::vector<std::string> Notification::GetLinks() const
@@ -99,32 +108,4 @@ 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);
- JsValuePtr jsTitle = jsTexts->GetProperty("title");
- if (jsTitle->IsString())
- {
- notification->title = jsTitle->AsString();
- }
- JsValuePtr jsMessage = jsTexts->GetProperty("message");
- if (jsMessage->IsString())
- {
- notification->message = jsMessage->AsString();
- }
- return notification;
}
« 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