[Notification] Return UserNotification object from template 90/143090/2
authorTomasz Marciniak <t.marciniak@samsung.com>
Mon, 7 Aug 2017 12:58:54 +0000 (14:58 +0200)
committerTomasz Marciniak <t.marciniak@samsung.com>
Tue, 8 Aug 2017 12:52:11 +0000 (14:52 +0200)
[Verification] Code compiles.

Change-Id: Id5c1ac3ad87e12790707c24298f77724f9f3eaa7
Signed-off-by: Tomasz Marciniak <t.marciniak@samsung.com>
src/notification/notification_api.js
src/notification/notification_instance.cc
src/notification/notification_manager.cc

index af65a3e209a0d4059f4c4fe5902c99e321bde384..b4cd723cf0c65c3b6d1b4dca12629c057efbc7b6 100644 (file)
@@ -338,8 +338,7 @@ NotificationManager.prototype.createNotificationFromTemplate = function(name) {
   var n = native_.getResultObject(result);
 
   _edit.allow();
-  //TODO create UserNotification here
-  var returnObject = new StatusNotification(n.statusType, n.title, n);
+  var returnObject = new UserNotification(n.userType, n.title, n);
   _edit.disallow();
 
   return returnObject;
@@ -1058,21 +1057,20 @@ function LedsInitDict(data) {
   }
 }
 
-function UserNotification(userType, title, notificationGropedInitDict) {
+function UserNotification(userType, title, notificationGroupedInitDict) {
   validator_.isConstructorCall(this, UserNotification);
-  type_.isObject(notificationGropedInitDict) ?
-      notificationGropedInitDict.title = title :
-        notificationGropedInitDict = {title: title};
-  UserNotificationInitDict.call(this, notificationGropedInitDict);
-  Notification.call(this, notificationGropedInitDict);
-
-  // validation of each member - setting default values instead of incorrect ones
-  TextContentsInitDict.call(this.textContents, notificationGropedInitDict.textContents);
-  ImagesInitDict.call(this.images, notificationGropedInitDict.images);
-  ThumbnailsInitDict.call(this.thumbnails, notificationGropedInitDict.thumbnails);
-  ActionsInitDict.call(this.actions, notificationGropedInitDict.actions);
-  LedsInitDict.call(this.leds, notificationGropedInitDict.leds);
-  GroupContentsInitDict.call(this.groupContents, notificationGropedInitDict.groupContents);
+  type_.isObject(notificationGroupedInitDict) ?
+      notificationGroupedInitDict.title = title :
+        notificationGroupedInitDict = {title: title};
+  UserNotificationInitDict.call(this, notificationGroupedInitDict);
+  Notification.call(this, notificationGroupedInitDict);
+
+  this.textContents = new TextContentsInitDict(notificationGroupedInitDict.textContents);
+  this.images = new ImagesInitDict(notificationGroupedInitDict.images);
+  this.thumbnails = new ThumbnailsInitDict(notificationGroupedInitDict.thumbnails);
+  this.actions = new ActionsInitDict(notificationGroupedInitDict.actions);
+  this.leds = new LedsInitDict(notificationGroupedInitDict.leds);
+  this.groupContents = new GroupContentsInitDict(notificationGroupedInitDict.groupContents);
 
   var _userType = (Object.keys(UserNotificationType)).indexOf(userType) >= 0
       ? userType : StatusNotificationType.SIMPLE;
index 5447733ac0cdadbbcc8866833c3e712d94703556..9c334d6746d9024a093908f3dbd0652f7e500a13 100644 (file)
@@ -232,7 +232,6 @@ void NotificationInstance::NotificationManagerCreateFromTemplate(const picojson:
   CHECK_PRIVILEGE_ACCESS(kPrivilegeNotification, &out);
   picojson::value val{picojson::object{}};
 
-  //TODO return UserNotification here
   PlatformResult status =
       manager_->CreateFromTemplate(args.get<picojson::object>(), val.get<picojson::object>());
 
index b3cc6ee7756d612cb10cbc4a8cdbf07c66709325..2476484d7960339492a1eeae27ef5d2149d5a82d 100644 (file)
@@ -278,8 +278,13 @@ common::PlatformResult NotificationManager::SaveTemplate(const picojson::object&
     notification_free(noti_handle);
   };
 
-  // TODO use UserNotification method
-  PlatformResult status = StatusNotification::GetNotiHandleFromJson(args, false, &noti_handle);
+  PlatformResult status = PlatformResult(ErrorCode::NO_ERROR);
+  const auto& new_impl_it = args.find("newImpl");
+  if (args.end() != new_impl_it && new_impl_it->second.get<bool>()) {
+    status = UserNotification::GetNotiHandleFromJson(args, false, &noti_handle);
+  } else {
+    status = StatusNotification::GetNotiHandleFromJson(args, false, &noti_handle);
+  }
 
   if (status.IsError()) {
     return status;
@@ -320,8 +325,8 @@ common::PlatformResult NotificationManager::CreateFromTemplate(const picojson::o
     notification_free(noti_handle);
   };
 
-  // TODO use UserNotification method
-  PlatformResult status = StatusNotification::ToJson(0, noti_handle, nullptr, &out);
+  //This method is designed to return only UserNotification objects
+  PlatformResult status = UserNotification::ToJson(0, noti_handle, nullptr, &out);
   if (status.IsError())
   {
     LoggerE("Failed: ToJson");