From: Tomasz Marciniak Date: Mon, 7 Aug 2017 12:58:54 +0000 (+0200) Subject: [Notification] Return UserNotification object from template X-Git-Tag: submit/tizen/20170821.110349~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c7b198ade674c9aa8fd18aee14fd819ad40d440f;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Notification] Return UserNotification object from template [Verification] Code compiles. Change-Id: Id5c1ac3ad87e12790707c24298f77724f9f3eaa7 Signed-off-by: Tomasz Marciniak --- diff --git a/src/notification/notification_api.js b/src/notification/notification_api.js index af65a3e2..b4cd723c 100644 --- a/src/notification/notification_api.js +++ b/src/notification/notification_api.js @@ -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; diff --git a/src/notification/notification_instance.cc b/src/notification/notification_instance.cc index 5447733a..9c334d67 100644 --- a/src/notification/notification_instance.cc +++ b/src/notification/notification_instance.cc @@ -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(), val.get()); diff --git a/src/notification/notification_manager.cc b/src/notification/notification_manager.cc index b3cc6ee7..2476484d 100644 --- a/src/notification/notification_manager.cc +++ b/src/notification/notification_manager.cc @@ -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, ¬i_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()) { + status = UserNotification::GetNotiHandleFromJson(args, false, ¬i_handle); + } else { + status = StatusNotification::GetNotiHandleFromJson(args, false, ¬i_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");