Merge branch 'tizen_3.0' into tizen 48/118048/1 accepted/tizen/common/20170309.175328 accepted/tizen/ivi/20170308.121817 accepted/tizen/mobile/20170308.121752 accepted/tizen/tv/20170308.121802 accepted/tizen/unified/20170310.075645 accepted/tizen/wearable/20170308.121807 submit/tizen/20170308.110622 submit/tizen_unified/20170310.011401
authorPiotr Kosko <p.kosko@samsung.com>
Wed, 8 Mar 2017 10:43:28 +0000 (11:43 +0100)
committerPiotr Kosko <p.kosko@samsung.com>
Wed, 8 Mar 2017 11:04:29 +0000 (12:04 +0100)
Change-Id: Ib4da480084b40a068293bab2dd12163cf8cb909c

19 files changed:
packaging/webapi-plugins.spec
src/alarm/alarm.gyp
src/application/application.gyp
src/bluetooth/bluetooth.gyp
src/common/common.gyp
src/convergence/convergence_instance.cc
src/convergence/convergence_remote_app_control_service.cc
src/convergence/convergence_utils.cc
src/nfc/nfc.gyp
src/notification/notification.gyp
src/notification/notification_api.js
src/notification/notification_instance.cc
src/notification/notification_instance.h
src/notification/notification_manager.cc
src/notification/notification_manager.h
src/notification/status_notification.cc
src/notification/status_notification.h
src/preference/preference.gyp
src/push/push.gyp

index 456b61c..99cd65b 100644 (file)
@@ -401,7 +401,7 @@ BuildRequires: pkgconfig(capi-network-bluetooth)
 BuildRequires: pkgconfig(capi-network-wifi-manager)
 BuildRequires: pkgconfig(tapi)
 BuildRequires: pkgconfig(libpcrecpp)
-BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(capi-appfw-app-common)
 BuildRequires: pkgconfig(capi-appfw-app-manager)
 BuildRequires: pkgconfig(capi-appfw-package-manager)
 BuildRequires: pkgconfig(capi-content-media-content)
@@ -432,10 +432,21 @@ BuildRequires: pkgconfig(accounts-svc)
 %endif
 
 %if 0%{?tizen_feature_alarm_support}
+BuildRequires: pkgconfig(capi-appfw-app-control)
+BuildRequires: pkgconfig(capi-appfw-application)
 BuildRequires: pkgconfig(capi-appfw-alarm)
 BuildRequires: pkgconfig(alarm-service)
 %endif
 
+%if 0%{?tizen_feature_application_support}
+BuildRequires: pkgconfig(capi-appfw-app-control)
+BuildRequires: pkgconfig(capi-appfw-event)
+%endif
+
+%if 0%{?tizen_feature_bluetooth_support}
+BuildRequires: pkgconfig(capi-appfw-app-control)
+%endif
+
 %if 0%{?tizen_feature_bookmark_support}
 BuildRequires: pkgconfig(capi-web-bookmark)
 BuildRequires: pkgconfig(bookmark-adaptor)
@@ -474,6 +485,7 @@ BuildRequires: pkgconfig(capi-appfw-application)
 
 %if 0%{?tizen_feature_push_support}
 BuildRequires: pkgconfig(push)
+BuildRequires: pkgconfig(capi-appfw-app-control)
 %endif
 
 %if 0%{?tizen_feature_key_manager_support}
@@ -513,6 +525,7 @@ BuildRequires:  pkgconfig(libexif)
 
 %if 0%{?tizen_feature_nfc_support}
 BuildRequires:  pkgconfig(capi-network-nfc)
+BuildRequires:  pkgconfig(capi-appfw-app-control)
 %endif
 
 %if 0%{?tizen_feature_fm_radio_support}
@@ -533,6 +546,11 @@ BuildRequires: pkgconfig(capi-message-port)
 
 %if 0%{?tizen_feature_notification_support}
 BuildRequires: pkgconfig(notification)
+BuildRequires: pkgconfig(capi-appfw-app-control)
+%endif
+
+%if 0%{?tizen_feature_preference_support}
+BuildRequires: pkgconfig(capi-appfw-preference)
 %endif
 
 %if 0%{?tizen_feature_sound_support}
index dc1135a..66eb77b 100644 (file)
@@ -25,6 +25,8 @@
           'variables': {
             'packages': [
               'capi-appfw-alarm',
+              'capi-appfw-app-control',
+              'capi-appfw-application',
             ]
           },
         }],
index 40b614f..7a222ba 100644 (file)
@@ -33,7 +33,8 @@
             'packages': [
               'aul',
               'capi-appfw-app-manager',
-              'capi-appfw-application',
+              'capi-appfw-app-control',
+              'capi-appfw-event',
               'capi-appfw-package-manager',
               'pkgmgr',
               'pkgmgr-info',
index 72eb206..8981306 100644 (file)
@@ -50,6 +50,7 @@
          'variables': {
             'packages': [
               'capi-network-bluetooth',
+              'capi-appfw-app-control',
               'capi-system-info',
               'libpcrecpp',
             ]
index 7f4e78e..64404f8 100644 (file)
@@ -68,7 +68,7 @@
           'variables': {
             'packages': [
               'capi-appfw-app-manager',
-              'capi-appfw-application',
+              'capi-appfw-app-common',
               'capi-appfw-package-manager',
               'storage',
               'security-privilege-manager',
index 4ad3807..c00109b 100644 (file)
@@ -412,7 +412,11 @@ common::TizenResult ConvergenceInstance::RemoteAppControlServiceLaunchAppControl
                                          static_cast<int>(ConvergenceUtils::GetArg(args, kJSCurrentListenerId).get<double>()));
     }
 
-    this->Post(token, result);
+    //only in case of failure call callback
+    //other cases are handled by conv_service_listener_cb()
+    if (!result) {
+      this->Post(token, result);
+    }
   };
 
   std::thread(launch_app_control, token).detach();
index cdd1716..23bb6b6 100644 (file)
@@ -128,6 +128,7 @@ TizenResult ConvergenceRemoteAppControlService::Disconnect() {
   }
 
   int error = conv_service_disconnect(service);
+
   if (CONV_ERROR_NONE != error) {
     return LogAndCreateTizenError(AbortError, "conv_service_disconnect [Fail]");
   } else {
index bbe9a7c..f14cac2 100644 (file)
@@ -97,6 +97,7 @@ common::TizenResult ConvergenceUtils::ConvertConvergenceError(int error) {
   }
 
   return common::TizenSuccess();
+
 }
 
 } // namespace convergence
index 25b02f9..79597cd 100644 (file)
@@ -34,7 +34,7 @@
             'packages': [
                 'capi-system-info',
                 'capi-network-nfc',
-                'capi-appfw-application'
+                'capi-appfw-app-control',
             ]
           },
         }],
index 9c219a8..35fc135 100755 (executable)
@@ -26,6 +26,7 @@
             'packages': [
               'notification',
               'capi-system-device',
+              'capi-appfw-app-control',
             ]
           },
         }],
index 21bcadf..5c7ce37 100644 (file)
@@ -242,6 +242,42 @@ NotificationManager.prototype.stopLEDCustomEffect = function() {
   }
 };
 
+NotificationManager.prototype.saveNotificationAsTemplate = function(name, notification) {
+  var args = validator_.validateArgs(arguments, [
+    {name: 'name', type: types_.STRING},
+    {name: 'notification', type: types_.PLATFORM_OBJECT, values: StatusNotification}
+  ]);
+
+  var result = native_.callSync('NotificationManager_saveNotificationAsTemplate', args);
+
+  if (native_.isFailure(result)) {
+    throw native_.getErrorObject(result);
+  }
+};
+
+NotificationManager.prototype.createNotificationFromTemplate = function(name) {
+  var args = validator_.validateArgs(arguments, [
+    {name: 'name', type: types_.STRING}
+  ]);
+
+  if (!arguments.length) {
+    throw new WebAPIException(WebAPIException.NOT_FOUND_ERR);
+  }
+
+  var result = native_.callSync('NotificationManager_createNotificationFromTemplate', args);
+
+  if (native_.isFailure(result)) {
+    throw native_.getErrorObject(result);
+  }
+  var n = native_.getResultObject(result);
+
+  _edit.allow();
+  var returnObject = new StatusNotification(n.statusType, n.title, n);
+  _edit.disallow();
+
+  return returnObject;
+};
+
 
 function NotificationInitDict(data) {
   var _iconPath = null;
index ec92eb5..d4f06da 100644 (file)
@@ -52,6 +52,8 @@ NotificationInstance::NotificationInstance() {
       NotificationManagerPlayLEDCustomEffect);
   REGISTER_SYNC("NotificationManager_stopLEDCustomEffect",
       NotificationManagerStopLEDCustomEffect);
+  REGISTER_SYNC("NotificationManager_saveNotificationAsTemplate", NotificationManagerSaveTemplate);
+  REGISTER_SYNC("NotificationManager_createNotificationFromTemplate", NotificationManagerCreateFromTemplate);
 #undef REGISTER_SYNC
 
   manager_ = NotificationManager::GetInstance();
@@ -188,6 +190,37 @@ void NotificationInstance::NotificationManagerStopLEDCustomEffect(
   }
 }
 
+void NotificationInstance::NotificationManagerSaveTemplate(const picojson::value& args,
+                                                           picojson::object& out) {
+  LoggerD("Enter");
+  CHECK_PRIVILEGE_ACCESS(kPrivilegeNotification, &out);
+
+  PlatformResult status = manager_->SaveTemplate(args.get<picojson::object>());
+
+  if (status.IsSuccess()) {
+    ReportSuccess(out);
+  } else {
+    LogAndReportError(status, &out);
+  }
+}
+
+
+void NotificationInstance::NotificationManagerCreateFromTemplate(const picojson::value& args,
+                                                                 picojson::object& out) {
+  LoggerD("Enter");
+  CHECK_PRIVILEGE_ACCESS(kPrivilegeNotification, &out);
+  picojson::value val{picojson::object{}};
+
+  PlatformResult status =
+      manager_->CreateFromTemplate(args.get<picojson::object>(), val.get<picojson::object>());
+
+  if (status.IsSuccess()) {
+    ReportSuccess(val, out);
+  } else {
+    LogAndReportError(status, &out);
+  }
+}
+
 #undef CHECK_EXIST
 
 }  // namespace notification
index 3a1e2e7..4eef4f8 100644 (file)
@@ -48,6 +48,10 @@ class NotificationInstance : public common::ParsedInstance {
                                               picojson::object& out);
   void NotificationManagerStopLEDCustomEffect(const picojson::value& args,
                                               picojson::object& out);
+  void NotificationManagerSaveTemplate(const picojson::value& args,
+                                       picojson::object& out);
+  void NotificationManagerCreateFromTemplate(const picojson::value& args,
+                                             picojson::object& out);
 };
 
 }  // namespace notification
index 93f0c09..afaae6e 100644 (file)
@@ -244,5 +244,64 @@ PlatformResult NotificationManager::StopLEDCustomEffect() {
   return PlatformResult(ErrorCode::NO_ERROR);
 }
 
+common::PlatformResult NotificationManager::SaveTemplate(const picojson::object& args) {
+  LoggerD("Enter");
+  std::string name = FromJson<std::string>(args, "name");
+  notification_h noti_handle = nullptr;
+  int ret;
+  SCOPE_EXIT {
+    notification_free(noti_handle);
+  };
+
+  PlatformResult status = StatusNotification::GetNotiHandleFromJson(args, false, &noti_handle);
+
+  if (status.IsError()){
+    return status;
+  }
+
+  ret = notification_save_as_template(noti_handle, name.c_str());
+  if (ret != NOTIFICATION_ERROR_NONE) {
+    LoggerD("Error: %d (%s)", ret, get_error_message(ret));
+    if (ret == NOTIFICATION_ERROR_MAX_EXCEEDED) {
+      return LogAndCreateResult(ErrorCode::QUOTA_EXCEEDED_ERR,
+                                "Maximum number of templates exceeded",
+                                ("Maximum number of templates exceeded, error: %d", ret));
+    } else {
+      return LogAndCreateResult(ErrorCode::ABORT_ERR,
+                                "Saving template failed",
+                                ("Saving template failed, error: %d", ret));
+    }
+  }
+
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+
+common::PlatformResult NotificationManager::CreateFromTemplate(const picojson::object& args,
+                                                               picojson::object& out) {
+  LoggerD("Enter");
+  std::string name = FromJson<std::string>(args, "name");
+
+  notification_h noti_handle = nullptr;
+  noti_handle = notification_create_from_template(name.c_str());
+  if (!noti_handle) {
+    return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR,
+                              "The template with given name not found",
+                              ("The template with given name not found, handle is NULL"));
+  }
+
+  SCOPE_EXIT {
+    notification_free(noti_handle);
+  };
+
+  PlatformResult status = StatusNotification::ToJson(0, noti_handle, nullptr, &out);
+  if (status.IsError())
+  {
+    LoggerE("Failed: ToJson");
+    return status;
+  }
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
 }  // namespace notification
 }  // namespace extension
index eaeac9f..85cd85f 100644 (file)
@@ -41,6 +41,10 @@ class NotificationManager {
   common::PlatformResult PlayLEDCustomEffect(const picojson::object& args);
   common::PlatformResult StopLEDCustomEffect();
 
+  common::PlatformResult SaveTemplate(const picojson::object& args);
+  common::PlatformResult CreateFromTemplate(const picojson::object& args,
+                                            picojson::object& out);
+
  private:
   NotificationManager();
   virtual ~NotificationManager();
index 1b55a50..279182c 100644 (file)
@@ -1088,19 +1088,21 @@ PlatformResult StatusNotification::ToJson(int id,
     return status;
   out["vibration"] = picojson::value(vibration);
 
-  picojson::object app_control = picojson::object();
-  status = GetApplicationControl(app_handle, &app_control);
-  if (status.IsError())
-    return status;
-  if (app_control.size()) {
-    out["appControl"] = picojson::value(app_control);
-  }
+  if (app_handle) {
+    picojson::object app_control = picojson::object();
+    status = GetApplicationControl(app_handle, &app_control);
+    if (status.IsError())
+      return status;
+    if (app_control.size()) {
+      out["appControl"] = picojson::value(app_control);
+    }
 
-  status = GetApplicationId(app_handle, &value_str);
-  if (status.IsError())
-    return status;
-  if (value_str.length()) {
-    out["appId"] = picojson::value(value_str);
+    status = GetApplicationId(app_handle, &value_str);
+    if (status.IsError())
+      return status;
+    if (value_str.length()) {
+      out["appId"] = picojson::value(value_str);
+    }
   }
 
   std::string progress_type;
@@ -1144,9 +1146,9 @@ PlatformResult StatusNotification::ToJson(int id,
   return PlatformResult(ErrorCode::NO_ERROR);
 }
 
-PlatformResult StatusNotification::FromJson(const picojson::object& args,
-                                            bool is_update,
-                                            picojson::object* out_ptr) {
+PlatformResult StatusNotification::GetNotiHandleFromJson(const picojson::object& args,
+                                       bool is_update,
+                                       notification_h *noti_handle){
   LoggerD("Enter");
   picojson::object noti_obj =
       common::FromJson<picojson::object>(args, "notification");
@@ -1160,32 +1162,29 @@ PlatformResult StatusNotification::FromJson(const picojson::object& args,
     return status;
 
   int id = NOTIFICATION_PRIV_ID_NONE;
-  int ret;
 
-  notification_h noti_handle = nullptr;
-  app_control_h app_control = NULL;
+  app_control_h app_control = nullptr;
 
   SCOPE_EXIT {
     if (app_control) {
       app_control_destroy(app_control);
     }
-    notification_free(noti_handle);
   };
 
   if (is_update) {
     id = std::stoi(common::FromJson<std::string>(noti_obj, "id"));
 
-    PlatformResult status = GetNotiHandle(id, &noti_handle);
+    PlatformResult status = GetNotiHandle(id, noti_handle);
     if (status.IsError())
       return status;
 
   } else {
-    status = Create(noti_type, &noti_handle);
+    status = Create(noti_type, noti_handle);
     if (status.IsError())
       return status;
   }
 
-  status = SetLayout(noti_handle, status_type);
+  status = SetLayout(*noti_handle, status_type);
   if (status.IsError()) {
     return status;
   }
@@ -1195,7 +1194,7 @@ PlatformResult StatusNotification::FromJson(const picojson::object& args,
     const std::string& value_str = common::FromJson<std::string>(noti_obj, "iconPath");
     std::string real_path = common::FilesystemProvider::Create().GetRealPath(value_str);
 
-    status = SetImage(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON, real_path);
+    status = SetImage(*noti_handle, NOTIFICATION_IMAGE_TYPE_ICON, real_path);
     if (status.IsError()) {
       return status;
     }
@@ -1206,7 +1205,7 @@ PlatformResult StatusNotification::FromJson(const picojson::object& args,
         common::FromJson<std::string>(noti_obj, "subIconPath");
     std::string real_path = common::FilesystemProvider::Create().GetRealPath(value_str);
 
-    status = SetImage(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON_SUB, real_path);
+    status = SetImage(*noti_handle, NOTIFICATION_IMAGE_TYPE_ICON_SUB, real_path);
     if (status.IsError()) {
       return status;
     }
@@ -1214,7 +1213,7 @@ PlatformResult StatusNotification::FromJson(const picojson::object& args,
 
   if (val.contains("number") && !IsNull(noti_obj, "number")) {
     long number = (long)common::FromJson<double>(noti_obj, "number");
-    status = SetText(noti_handle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, std::to_string(number));
+    status = SetText(*noti_handle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, std::to_string(number));
     if (status.IsError()) {
       return status;
     }
@@ -1222,28 +1221,28 @@ PlatformResult StatusNotification::FromJson(const picojson::object& args,
 
   if (val.contains("detailInfo") && !IsNull(noti_obj, "detailInfo")) {
     status = SetDetailInfos(
-        noti_handle, common::FromJson<picojson::array>(noti_obj, "detailInfo"));
+        *noti_handle, common::FromJson<picojson::array>(noti_obj, "detailInfo"));
     if (status.IsError()) {
       return status;
     }
   }
 
   if (val.contains("ledColor") && !IsNull(noti_obj, "ledColor")) {
-    status = SetLedColor(noti_handle,
+    status = SetLedColor(*noti_handle,
                          common::FromJson<std::string>(noti_obj, "ledColor"));
     if (status.IsError()) {
       return status;
     }
   }
 
-  status = SetLedOnPeriod(noti_handle,
+  status = SetLedOnPeriod(*noti_handle,
                           static_cast<unsigned long>(common::FromJson<double>(
                               noti_obj, "ledOnPeriod")));
   if (status.IsError()) {
     return status;
   }
 
-  status = SetLedOffPeriod(noti_handle,
+  status = SetLedOffPeriod(*noti_handle,
                            static_cast<unsigned long>(common::FromJson<double>(
                                noti_obj, "ledOffPeriod")));
   if (status.IsError()) {
@@ -1255,7 +1254,7 @@ PlatformResult StatusNotification::FromJson(const picojson::object& args,
     const std::string& value_str = common::FromJson<std::string>(noti_obj, "backgroundImagePath");
     std::string real_path = common::FilesystemProvider::Create().GetRealPath(value_str);
 
-    status = SetImage(noti_handle, NOTIFICATION_IMAGE_TYPE_BACKGROUND, real_path);
+    status = SetImage(*noti_handle, NOTIFICATION_IMAGE_TYPE_BACKGROUND, real_path);
     if (status.IsError()) {
       return status;
     }
@@ -1263,7 +1262,7 @@ PlatformResult StatusNotification::FromJson(const picojson::object& args,
 
   if (val.contains("thumbnails") && !IsNull(noti_obj, "thumbnails")) {
     status = SetThumbnails(
-        noti_handle, common::FromJson<picojson::array>(noti_obj, "thumbnails"));
+        *noti_handle, common::FromJson<picojson::array>(noti_obj, "thumbnails"));
     if (status.IsError()) {
       return status;
     }
@@ -1273,14 +1272,14 @@ PlatformResult StatusNotification::FromJson(const picojson::object& args,
     const std::string& value_str = common::FromJson<std::string>(noti_obj, "soundPath");
     std::string real_path = common::FilesystemProvider::Create().GetRealPath(value_str);
 
-    status = SetSoundPath(noti_handle, real_path);
+    status = SetSoundPath(*noti_handle, real_path);
     if (status.IsError()) {
       return status;
     }
   }
 
   status =
-      SetVibration(noti_handle, common::FromJson<bool>(noti_obj, "vibration"));
+      SetVibration(*noti_handle, common::FromJson<bool>(noti_obj, "vibration"));
   if (status.IsError()) {
     return status;
   }
@@ -1309,7 +1308,7 @@ PlatformResult StatusNotification::FromJson(const picojson::object& args,
 
   const std::string& progress_type =
       common::FromJson<std::string>(noti_obj, "progressType");
-  status = SetImage(noti_handle, NOTIFICATION_IMAGE_TYPE_LIST_5, progress_type);
+  status = SetImage(*noti_handle, NOTIFICATION_IMAGE_TYPE_LIST_5, progress_type);
   if (status.IsError()) {
     return status;
   }
@@ -1322,14 +1321,14 @@ PlatformResult StatusNotification::FromJson(const picojson::object& args,
     progressValue = -1;
   }
 
-  status = SetProgressValue(noti_handle, progress_type, progressValue,
+  status = SetProgressValue(*noti_handle, progress_type, progressValue,
       is_update);
 
   if (status.IsError()) {
     return status;
   }
 
-  status = SetText(noti_handle,
+  status = SetText(*noti_handle,
                    NOTIFICATION_TEXT_TYPE_TITLE,
                    common::FromJson<std::string>(noti_obj, "title"));
   if (status.IsError()) {
@@ -1337,7 +1336,7 @@ PlatformResult StatusNotification::FromJson(const picojson::object& args,
   }
 
   if (val.contains("content") && !IsNull(noti_obj, "content")) {
-    status = SetText(noti_handle,
+    status = SetText(*noti_handle,
                      NOTIFICATION_TEXT_TYPE_CONTENT,
                      common::FromJson<std::string>(noti_obj, "content"));
     if (status.IsError()) {
@@ -1345,11 +1344,31 @@ PlatformResult StatusNotification::FromJson(const picojson::object& args,
     }
   }
 
-  status = SetAppControl(noti_handle, app_control);
+  status = SetAppControl(*noti_handle, app_control);
+
+  return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult StatusNotification::FromJson(const picojson::object& args,
+                                            bool is_update,
+                                            picojson::object* out_ptr) {
+  LoggerD("Enter");
+  notification_h noti_handle = nullptr;
+  int ret;
+  int id = NOTIFICATION_PRIV_ID_NONE;
+
+  SCOPE_EXIT {
+    notification_free(noti_handle);
+  };
+
+  PlatformResult status = GetNotiHandleFromJson(args, is_update, &noti_handle);
+
+  if (status.IsError()){
+    return status;
+  }
 
   if (is_update) {
     ret = notification_update(noti_handle);
-
   } else {
     ret = notification_insert(noti_handle, &id);
     if (NOTIFICATION_ERROR_NONE != ret) {
index ae50e8d..51aab91 100644 (file)
@@ -35,6 +35,9 @@ class StatusNotification {
                                        notification_h noti_handle,
                                        app_control_h app_handle,
                                        picojson::object* out_ptr);
+  static common::PlatformResult GetNotiHandleFromJson(const picojson::object& args,
+                                         bool is_update,
+                                         notification_h *noti_handle);
   static common::PlatformResult FromJson(const picojson::object& args,
                                          bool is_update,
                                          picojson::object* out_ptr);
index 0b5161b..eedd0f4 100644 (file)
@@ -22,7 +22,7 @@
         ['tizen == 1', {
           'variables': {
             'packages': [
-              'capi-appfw-application',
+              'capi-appfw-preference',
             ]
           },
         }],
index 5cdb2ad..6028465 100644 (file)
@@ -28,7 +28,7 @@
           'variables': {
             'packages': [
               'push',
-              'capi-appfw-application',
+              'capi-appfw-app-control',
               'libpcrecpp',
             ]
           },