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");
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, ¬i_handle);
+ PlatformResult status = GetNotiHandle(id, noti_handle);
if (status.IsError())
return status;
} else {
- status = Create(noti_type, ¬i_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;
}
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;
}
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;
}
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;
}
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()) {
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;
}
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;
}
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;
}
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;
}
if (val.contains("progressValue") && !IsNull(noti_obj, "progressValue")) {
double progressValue = common::FromJson<double>(noti_obj, "progressValue");
- status = SetProgressValue(noti_handle, progress_type, progressValue,
+ status = SetProgressValue(*noti_handle, progress_type, progressValue,
is_update);
if (status.IsError()) {
}
}
- status = SetText(noti_handle,
+ status = SetText(*noti_handle,
NOTIFICATION_TEXT_TYPE_TITLE,
common::FromJson<std::string>(noti_obj, "title"));
if (status.IsError()) {
}
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()) {
}
}
- 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, ¬i_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) {