{2, NOTIFICATION_IMAGE_TYPE_LIST_3},
{3, NOTIFICATION_IMAGE_TYPE_LIST_4}};
+const InformationEnumMap CommonNotification::buttons_texts_map_ = {
+ {0, NOTIFICATION_TEXT_TYPE_BUTTON_1},
+ {1, NOTIFICATION_TEXT_TYPE_BUTTON_2},
+ {2, NOTIFICATION_TEXT_TYPE_BUTTON_3},
+ {2, NOTIFICATION_TEXT_TYPE_BUTTON_4},
+ {2, NOTIFICATION_TEXT_TYPE_BUTTON_5},
+ {2, NOTIFICATION_TEXT_TYPE_BUTTON_6}};
+
+const ImageEnumMap CommonNotification::buttons_icon_paths_map_ = {
+ {0, NOTIFICATION_IMAGE_TYPE_BUTTON_1},
+ {1, NOTIFICATION_IMAGE_TYPE_BUTTON_2},
+ {2, NOTIFICATION_IMAGE_TYPE_BUTTON_3},
+ {3, NOTIFICATION_IMAGE_TYPE_BUTTON_4},
+ {3, NOTIFICATION_IMAGE_TYPE_BUTTON_5},
+ {3, NOTIFICATION_IMAGE_TYPE_BUTTON_6}};
+
+
CommonNotification::CommonNotification() {
}
LoggerD("Enter");
std::string text;
PlatformResult status = GetText(noti_handle, text_type, &text);
- if (status.IsError())
- return status;
+ CHECK_ERROR(status);
if (text.length())
*number = std::stol(text);
return PlatformResult(ErrorCode::NO_ERROR);
}
-PlatformResult CommonNotification::GetDetailInfos(notification_h noti_handle,
- picojson::array* out) {
- LoggerD("Enter");
- if (info_map_.size() != info_sub_map_.size()) {
- return LogAndCreateResult(
- ErrorCode::VALIDATION_ERR,
- "Different notification information types element size");
- }
-
- picojson::value detail_info = picojson::value(picojson::object());
- picojson::object& detail_info_obj = detail_info.get<picojson::object>();
-
- std::string text;
- size_t info_map_size = info_map_.size();
- for (size_t idx = 0; idx < info_map_size; ++idx) {
- PlatformResult status = GetText(noti_handle, info_map_.at(idx), &text);
- if (status.IsError())
- return status;
-
- if (!text.length())
- break;
-
- detail_info_obj["mainText"] = picojson::value(text);
-
- status = GetText(noti_handle, info_sub_map_.at(idx), &text);
- if (status.IsError())
- return status;
-
- if (text.length()) {
- detail_info_obj["subText"] = picojson::value(text);
- }
-
- out->push_back(detail_info);
- }
-
- return PlatformResult(ErrorCode::NO_ERROR);
-}
-
PlatformResult CommonNotification::SetDetailInfos(
notification_h noti_handle,
const picojson::array& value) {
return PlatformResult(ErrorCode::NO_ERROR);
}
-PlatformResult CommonNotification::GetThumbnails(notification_h noti_handle,
- picojson::array* out) {
- LoggerD("Enter");
- std::string text;
- size_t thumbnails_map_size = thumbnails_map_.size();
- for (size_t idx = 0; idx < thumbnails_map_size; ++idx) {
- PlatformResult status =
- GetImage(noti_handle, thumbnails_map_.at(idx), &text);
- if (status.IsError())
- return status;
-
- if (!text.length())
- break;
-
- //CHECK GetVirtualPath ??
- out->push_back(picojson::value(common::FilesystemProvider::Create().GetVirtualPath(text)));
- }
-
- return PlatformResult(ErrorCode::NO_ERROR);
-}
-
PlatformResult CommonNotification::SetThumbnails(notification_h noti_handle,
const picojson::array& value) {
LoggerD("Enter");
return PlatformResult(ErrorCode::NO_ERROR);
}
+PlatformResult CommonNotification::AddProgressTypeAndValueToJson(notification_h noti_handle,
+ const std::string& noti_type_str,
+ picojson::object* out_ptr) {
+ LoggerD("Enter");
+
+ picojson::object& out = *out_ptr;
+ std::string progress_type;
+ // native code does not support progress_type value, we are using NOTIFICATION_IMAGE_TYPE_LIST_5
+ // to store this field on native level
+ PlatformResult status = GetImage(noti_handle, NOTIFICATION_IMAGE_TYPE_LIST_5, &progress_type);
+ CHECK_ERROR(status)
+
+ // notification service daemon doesn't set progress type - NOTIFICATION_IMAGE_TYPE_LIST_5 is used
+ // as workaround, so use default if notification type is different from "PROGRESS"
+ if ("PROGRESS" != noti_type_str) {
+ progress_type = progress_type == kProgressTypeByte ? progress_type : kProgressTypePercentage;
+ }
+ out["progressType"] = picojson::value(progress_type);
+
+ double progress_value;
+ status = GetProgressValue(noti_handle, progress_type, &progress_value);
+ CHECK_ERROR(status);
+ out["progressValue"] = picojson::value(progress_value);
+
+ return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult CommonNotification::AddEventsNumberToJson(notification_h noti_handle, const std::string& key,
+ picojson::object* out_ptr) {
+ LoggerD("Enter");
+ picojson::object& out = *out_ptr;
+
+ long number = 0;
+ PlatformResult status = GetNumber(noti_handle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &number);
+ CHECK_ERROR(status);
+ if (number >= 0) {
+ out[key] = picojson::value(static_cast<double>(number));
+ }
+ return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult CommonNotification::AddDetailInfosToJson(notification_h noti_handle,
+ picojson::object* out_ptr) {
+ LoggerD("Enter");
+ picojson::object& out = *out_ptr;
+
+ picojson::value result_json = picojson::value(picojson::array());
+ picojson::array& detail_info_array = result_json.get<picojson::array>();
+
+ if (info_map_.size() != info_sub_map_.size()) {
+ return LogAndCreateResult(
+ ErrorCode::VALIDATION_ERR,
+ "Different notification information types element size");
+ }
+
+ picojson::value detail_info = picojson::value(picojson::object());
+ picojson::object& detail_info_obj = detail_info.get<picojson::object>();
+
+ std::string text;
+ size_t info_map_size = info_map_.size();
+ for (size_t idx = 0; idx < info_map_size; ++idx) {
+ PlatformResult status = GetText(noti_handle, info_map_.at(idx), &text);
+ CHECK_ERROR(status);
+
+ if (text.length()) {
+ detail_info_obj["mainText"] = picojson::value(text);
+
+ status = AddTextToJson(noti_handle, info_sub_map_.at(idx),
+ "subText", &detail_info_obj);
+ CHECK_ERROR(status);
+ detail_info_array.push_back(detail_info);
+ }
+
+ }
+ out["detailInfo"] = result_json;
+
+ return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult CommonNotification::AddPathToJson(notification_h noti_handle,
+ notification_image_type_e type,
+ const std::string& key,
+ picojson::object* out_ptr) {
+ picojson::object& out = *out_ptr;
+
+ std::string value_str;
+ PlatformResult status = GetImage(noti_handle, type, &value_str);
+ CHECK_ERROR(status);
+ if (value_str.length()) {
+ out[key] = picojson::value(common::FilesystemProvider::Create().GetVirtualPath(value_str));
+ }
+ return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult CommonNotification::AddTextToJson(notification_h noti_handle,
+ notification_text_type_e type,
+ const std::string& key,
+ picojson::object* out_ptr) {
+ picojson::object& out = *out_ptr;
+
+ std::string value_str;
+ PlatformResult ret = GetText(noti_handle, type, &value_str);
+ CHECK_ERROR(ret);
+ if (value_str.length()) {
+ out[key] = picojson::value(value_str);
+ }
+ return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult CommonNotification::AddLedOnOffPeriodToJson(notification_h noti_handle,
+ picojson::object* out_ptr) {
+ LoggerD("Enter");
+ picojson::object& out = *out_ptr;
+
+ unsigned long on_period = 0;
+ unsigned long off_period = 0;
+ PlatformResult status = GetLedPeriod(noti_handle, &on_period, &off_period);
+ CHECK_ERROR(status);
+
+ out["ledOnPeriod"] = picojson::value(static_cast<double>(on_period));
+ out["ledOffPeriod"] = picojson::value(static_cast<double>(off_period));
+ return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult CommonNotification::AddPathsArrayToJson(notification_h noti_handle,
+ ImageEnumMap map,
+ const std::string& key,
+ picojson::object* out_ptr) {
+ LoggerD("Enter");
+ picojson::object& out = *out_ptr;
+
+ picojson::value result_json = picojson::value(picojson::array());
+ picojson::array& result_array = result_json.get<picojson::array>();
+
+ std::string path;
+ size_t map_size = map.size();
+ for (size_t idx = 0; idx < map_size; ++idx) {
+ PlatformResult status = GetImage(noti_handle, map.at(idx), &path);
+ CHECK_ERROR(status);
+
+ if (path.length()) {
+ result_array.push_back(
+ picojson::value(common::FilesystemProvider::Create().GetVirtualPath(path)));
+ }
+ }
+
+ out[key] = result_json;
+
+ return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult CommonNotification::AddTextsArrayToJson(notification_h noti_handle,
+ InformationEnumMap map,
+ const std::string& key,
+ picojson::object* out_ptr) {
+ LoggerD("Enter");
+ picojson::object& out = *out_ptr;
+
+ picojson::value result_json = picojson::value(picojson::array());
+ picojson::array& result_array = result_json.get<picojson::array>();
+
+ std::string text;
+ size_t map_size = map.size();
+ for (size_t idx = 0; idx < map_size; ++idx) {
+ PlatformResult status = GetText(noti_handle, map.at(idx), &text);
+
+ CHECK_ERROR(status);
+ if (text.length()) {
+ result_array.push_back(picojson::value(text));
+ }
+ }
+
+ out[key] = result_json;
+
+ return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult CommonNotification::AddLedColorToJson(notification_h noti_handle,
+ picojson::object* out_ptr) {
+ LoggerD("Enter");
+ picojson::object& out = *out_ptr;
+
+ std::string color;
+ PlatformResult status = GetLedColor(noti_handle, &color);
+ CHECK_ERROR(status);
+ if (color.length()) {
+ out["ledColor"] = picojson::value(color);
+ }
+
+ return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult CommonNotification::AddSoundPathToJson(notification_h noti_handle,
+ picojson::object* out_ptr) {
+ LoggerD("Enter");
+ picojson::object& out = *out_ptr;
+
+ std::string sound_path;
+ PlatformResult status = GetSoundPath(noti_handle, &sound_path);
+ CHECK_ERROR(status);
+ if (sound_path.length()) {
+ out["soundPath"] = picojson::value(common::FilesystemProvider::Create().GetVirtualPath(sound_path));
+ }
+
+ return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult CommonNotification::AddVibrationToJson(notification_h noti_handle,
+ picojson::object* out_ptr) {
+ LoggerD("Enter");
+ picojson::object& out = *out_ptr;
+
+ bool vibration;
+ PlatformResult status = GetVibration(noti_handle, &vibration);
+ CHECK_ERROR(status);
+ out["vibration"] = picojson::value(vibration);
+
+ return PlatformResult(ErrorCode::NO_ERROR);
+}
+
+PlatformResult CommonNotification::AddAppControlInfoToJson(notification_h noti_handle,
+ app_control_h app_handle,
+ picojson::object* out_ptr) {
+ LoggerD("Enter");
+ picojson::object& out = *out_ptr;
+
+ if (app_handle) {
+ picojson::object app_control = picojson::object();
+ PlatformResult status = GetApplicationControl(app_handle, &app_control);
+ CHECK_ERROR(status);
+ if (app_control.size()) {
+ out["appControl"] = picojson::value(app_control);
+ }
+
+ std::string app_id;
+ status = GetApplicationId(app_handle, &app_id);
+ CHECK_ERROR(status);
+ if (app_id.length()) {
+ out["appId"] = picojson::value(app_id);
+ }
+ }
+ return PlatformResult(ErrorCode::NO_ERROR);
+}
+
PlatformResult CommonNotification::InitNotiFromJson(const picojson::object& noti_obj,
bool is_update,
notification_h* noti_handle) {
static const InformationEnumMap info_map_;
static const InformationEnumMap info_sub_map_;
static const ImageEnumMap thumbnails_map_;
+ static const InformationEnumMap buttons_texts_map_;
+ static const ImageEnumMap buttons_icon_paths_map_;
static common::PlatformResult StatusTypeFromPlatform(
notification_type_e noti_type,
static common::PlatformResult GetNumber(notification_h noti_handle,
notification_text_type_e text_type,
long* number);
- static common::PlatformResult GetDetailInfos(notification_h noti_handle,
- picojson::array* out);
static common::PlatformResult SetDetailInfos(notification_h noti_handle,
const picojson::array& value);
static common::PlatformResult GetLedColor(notification_h noti_handle,
unsigned long on_period);
static common::PlatformResult SetLedOffPeriod(notification_h noti_handle,
unsigned long off_period);
- static common::PlatformResult GetThumbnails(notification_h noti_handle,
- picojson::array* out);
static common::PlatformResult SetThumbnails(notification_h noti_handle,
const picojson::array& value);
static common::PlatformResult GetSoundPath(notification_h noti_handle,
picojson::object* out_ptr);
static common::PlatformResult AddTypeToJson(notification_h noti_handle, const std::string& key,
picojson::object* out_ptr, std::string* noti_type_str);
+ static common::PlatformResult AddProgressTypeAndValueToJson(notification_h noti_handle,
+ const std::string& noti_type_str,
+ picojson::object* out_ptr);
+ static common::PlatformResult AddEventsNumberToJson(notification_h noti_handle, const std::string& key,
+ picojson::object* out_ptr);
+ static common::PlatformResult AddDetailInfosToJson(notification_h noti_handle,
+ picojson::object* out_ptr);
+ static common::PlatformResult AddPathToJson(notification_h noti_handle, notification_image_type_e type,
+ const std::string& key, picojson::object* out_ptr);
+ static common::PlatformResult AddTextToJson(notification_h noti_handle, notification_text_type_e type,
+ const std::string& key, picojson::object* out_ptr);
+ static common::PlatformResult AddIconPathToJson(notification_h noti_handle,
+ picojson::object* out_ptr);
+ static common::PlatformResult AddSubIconPathToJson(notification_h noti_handle,
+ picojson::object* out_ptr);
+ static common::PlatformResult AddBackgroundImagePathToJson(notification_h noti_handle,
+ picojson::object* out_ptr);
+ static common::PlatformResult AddLedOnOffPeriodToJson(notification_h noti_handle,
+ picojson::object* out_ptr);
+ static common::PlatformResult AddLedColorToJson(notification_h noti_handle,
+ picojson::object* out_ptr);
+ static common::PlatformResult AddSoundPathToJson(notification_h noti_handle,
+ picojson::object* out_ptr);
+ static common::PlatformResult AddVibrationToJson(notification_h noti_handle,
+ picojson::object* out_ptr);
+ static common::PlatformResult AddAppControlInfoToJson(notification_h noti_handle,
+ app_control_h app_handle,
+ picojson::object* out_ptr);
+ static common::PlatformResult AddPathsArrayToJson(notification_h noti_handle,
+ ImageEnumMap map,
+ const std::string& key,
+ picojson::object* out_ptr);
+ static common::PlatformResult AddTextsArrayToJson(notification_h noti_handle,
+ InformationEnumMap map,
+ const std::string& key,
+ picojson::object* out_ptr);
// FromJson section
static common::PlatformResult InitNotiFromJson(const picojson::object& args, bool is_update,
ret = notification_save_as_template(noti_handle, name.c_str());
if (NOTIFICATION_ERROR_NONE != ret) {
LoggerD("Error: %d (%s)", ret, get_error_message(ret));
- if (ret == NOTIFICATION_ERROR_MAX_EXCEEDED) {
+ if (NOTIFICATION_ERROR_MAX_EXCEEDED == ret) {
return LogAndCreateResult(ErrorCode::QUOTA_EXCEEDED_ERR,
"Maximum number of templates exceeded",
("Maximum number of templates exceeded, error: %d", ret));
LoggerD("Enter");
picojson::object& out = *out_ptr;
- CHECK_ERROR(AddCommonMembersToJson(id, noti_handle, out_ptr));
+ PlatformResult status = AddCommonMembersToJson(id, noti_handle, out_ptr);
+ CHECK_ERROR(status);
std::string noti_type_str;
- CHECK_ERROR(AddTypeToJson(noti_handle, "statusType", out_ptr, ¬i_type_str));
-
- std::string value_str;
- PlatformResult status = GetImage(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON, &value_str);
- if (status.IsError())
- return status;
- if (value_str.length()) {
- out["iconPath"] = picojson::value(common::FilesystemProvider::Create().GetVirtualPath(value_str));
- }
-
- status = GetImage(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON_SUB, &value_str);
- if (status.IsError())
- return status;
- if (value_str.length()) {
- out["subIconPath"] = picojson::value(common::FilesystemProvider::Create().GetVirtualPath(value_str));
- }
-
- long number;
- status = GetNumber(noti_handle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &number);
- if (status.IsError())
- return status;
- if (number >= 0) {
- out["number"] = picojson::value(static_cast<double>(number));
- }
+ status = AddTypeToJson(noti_handle, "statusType", out_ptr, ¬i_type_str);
+ CHECK_ERROR(status);
- picojson::array detail_infos = picojson::array();
- status = GetDetailInfos(noti_handle, &detail_infos);
- if (status.IsError())
- return status;
- if (detail_infos.size()) {
- out["detailInfo"] = picojson::value(detail_infos);
- }
+ // iconPath
+ status = AddPathToJson(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON,
+ "iconPath", out_ptr);
+ CHECK_ERROR(status);
- status = GetLedColor(noti_handle, &value_str);
- if (status.IsError())
- return status;
- if (value_str.length()) {
- out["ledColor"] = picojson::value(value_str);
- }
+ // subIconPath
+ status = AddPathToJson(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON_SUB,
+ "subIconPath", out_ptr);
+ CHECK_ERROR(status);
- unsigned long on_period;
- unsigned long off_period;
- status = GetLedPeriod(noti_handle, &on_period, &off_period);
- if (status.IsError())
- return status;
- out["ledOnPeriod"] = picojson::value(static_cast<double>(on_period));
- out["ledOffPeriod"] = picojson::value(static_cast<double>(off_period));
+ // eventsNumber
+ status = AddEventsNumberToJson(noti_handle, "number", &out);
+ CHECK_ERROR(status);
- status =
- GetImage(noti_handle, NOTIFICATION_IMAGE_TYPE_BACKGROUND, &value_str);
- if (status.IsError())
- return status;
- if (value_str.length()) {
- out["backgroundImagePath"] =
- picojson::value(common::FilesystemProvider::Create().GetVirtualPath(value_str));
- }
+ // detailInfo
+ status = AddDetailInfosToJson(noti_handle, &out);
+ CHECK_ERROR(status);
- picojson::array thumbnails = picojson::array();
- status = GetThumbnails(noti_handle, &thumbnails);
- if (status.IsError())
- return status;
- if (thumbnails.size()) {
- out["thumbnails"] = picojson::value(thumbnails);
- }
+ // ledColor
+ status = AddLedColorToJson(noti_handle, &out);
+ CHECK_ERROR(status);
- status = GetSoundPath(noti_handle, &value_str);
- if (status.IsError())
- return status;
- if (value_str.length()) {
- out["soundPath"] = picojson::value(common::FilesystemProvider::Create().GetVirtualPath(value_str));
- }
+ // ledOnPeriod, ledOffPeriod
+ status = AddLedOnOffPeriodToJson(noti_handle, &out);
+ CHECK_ERROR(status);
- bool vibration;
- status = GetVibration(noti_handle, &vibration);
- if (status.IsError())
- return status;
- out["vibration"] = picojson::value(vibration);
+ // backgroundImagePath
+ status = AddPathToJson(noti_handle, NOTIFICATION_IMAGE_TYPE_BACKGROUND,
+ "backgroundImagePath", out_ptr);
+ CHECK_ERROR(status);
- 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);
- }
+ // thumbnails
+ status = AddPathsArrayToJson(noti_handle, thumbnails_map_, "thumbnails", out_ptr);
+ CHECK_ERROR(status);
- status = GetApplicationId(app_handle, &value_str);
- if (status.IsError())
- return status;
- if (value_str.length()) {
- out["appId"] = picojson::value(value_str);
- }
- }
+ // soundPath
+ status = AddSoundPathToJson(noti_handle, &out);
+ CHECK_ERROR(status);
- std::string progress_type;
- status =
- GetImage(noti_handle, NOTIFICATION_IMAGE_TYPE_LIST_5, &progress_type);
- if (status.IsError())
- return status;
+ // vibration
+ status = AddVibrationToJson(noti_handle, &out);
+ CHECK_ERROR(status);
- //push service daemon doesn't set progress type
- //so use default if notification type is different from "PROGRESS"
- if ("PROGRESS" != noti_type_str) {
- progress_type = progress_type == kProgressTypeByte ? progress_type : kProgressTypePercentage;
- }
- out["progressType"] = picojson::value(progress_type);
+ // appControl, appId
+ status = AddAppControlInfoToJson(noti_handle, app_handle, &out);
+ CHECK_ERROR(status);
- double progress_value;
- status = GetProgressValue(noti_handle, progress_type, &progress_value);
- if (status.IsError())
- return status;
- out["progressValue"] = picojson::value(progress_value);
+ // progressType, progressValue
+ status = AddProgressTypeAndValueToJson(noti_handle, noti_type_str, &out);
+ CHECK_ERROR(status);
return PlatformResult(ErrorCode::NO_ERROR);
}
};
notification_h tmp_noti = nullptr;
+ // statusType, id
PlatformResult status = InitNotiFromJson(noti_obj, is_update, &tmp_noti);
CHECK_ERROR(status);
std::unique_ptr<std::remove_pointer<notification_h>::type, int(*)(notification_h)>
tmp_noti_ptr(tmp_noti, ¬ification_free); // automatically release the memory
+ // title, content
status = SetCommonMembersFromJson(noti_val, tmp_noti);
CHECK_ERROR(status);
ret = AddTypeToJson(noti_handle, "userType", out_ptr, ¬i_type_str);
CHECK_ERROR(ret);
- ret = AddTextContentsToJson(noti_handle, out_ptr);
+ ret = AddTextContentsToJson(noti_handle, noti_type_str, out_ptr);
CHECK_ERROR(ret);
ret = AddImagesToJson(noti_handle, out_ptr);
ret = AddThumbnailsToJson(noti_handle, out_ptr);
CHECK_ERROR(ret);
- ret = AddActionsToJson(noti_handle, out_ptr);
+ ret = AddActionsToJson(noti_handle, app_handle, out_ptr);
CHECK_ERROR(ret);
ret = AddGroupContentsToJson(noti_handle, out_ptr);
}
PlatformResult UserNotification::AddTextContentsToJson(notification_h noti_handle,
+ std::string noti_type_str,
picojson::object* out_ptr) {
LoggerD("Enter");
- picojson::object& out = *out_ptr;
picojson::value text_contents = picojson::value(picojson::object());
picojson::object& text_contents_obj = text_contents.get<picojson::object>();
- out["textContents"] = text_contents;
+ // progressType, progressValue
+ PlatformResult status = AddProgressTypeAndValueToJson(noti_handle, noti_type_str, &text_contents_obj);
+ CHECK_ERROR(status);
+
+ // eventsNumber
+ status = AddEventsNumberToJson(noti_handle, "eventsNumber", &text_contents_obj);
+ CHECK_ERROR(status);
+
+ // detailInfo
+ status = AddDetailInfosToJson(noti_handle, &text_contents_obj);
+ CHECK_ERROR(status);
+
+ // buttonsTexts
+ status = AddTextsArrayToJson(noti_handle, buttons_texts_map_, "buttonsTexts", out_ptr);
+ CHECK_ERROR(status);
+
+ // contentForOff
+ status = AddTextToJson(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF,
+ "contentForOff", out_ptr);
+ CHECK_ERROR(status);
+
+ (*out_ptr)["textContents"] = text_contents;
return PlatformResult(ErrorCode::NO_ERROR);
}
PlatformResult UserNotification::AddImagesToJson(notification_h noti_handle,
picojson::object* out_ptr) {
LoggerD("Enter");
- picojson::object& out = *out_ptr;
- picojson::value text_contents = picojson::value(picojson::object());
- picojson::object& text_contents_obj = text_contents.get<picojson::object>();
+ picojson::value images_contents = picojson::value(picojson::object());
+ picojson::object& images_contents_obj = images_contents.get<picojson::object>();
+
+ // iconPath
+ PlatformResult status = AddPathToJson(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON,
+ "iconPath", &images_contents_obj);
+ CHECK_ERROR(status);
- out["images"] = text_contents;
+ // subIconPath
+ status = AddPathToJson(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON_SUB,
+ "subIconPath", &images_contents_obj);
+ CHECK_ERROR(status);
+
+ // indicatorIconPath
+ status = AddPathToJson(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR,
+ "indicatorIconPath", &images_contents_obj);
+ CHECK_ERROR(status);
+
+ // lockScreenIconPath
+ status = AddPathToJson(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK,
+ "lockScreenIconPath", &images_contents_obj);
+ CHECK_ERROR(status);
+
+ // buttonIconPaths
+ status = AddPathsArrayToJson(noti_handle, buttons_icon_paths_map_, "buttonIconPaths", out_ptr);
+ CHECK_ERROR(status);
+
+ // backgroundImagePath
+ status = AddPathToJson(noti_handle, NOTIFICATION_IMAGE_TYPE_BACKGROUND,
+ "backgroundImagePath", &images_contents_obj);
+ CHECK_ERROR(status);
+
+ (*out_ptr)["images"] = images_contents;
return PlatformResult(ErrorCode::NO_ERROR);
}
PlatformResult UserNotification::AddThumbnailsToJson(notification_h noti_handle,
picojson::object* out_ptr) {
LoggerD("Enter");
- picojson::object& out = *out_ptr;
- picojson::value text_contents = picojson::value(picojson::object());
- picojson::object& text_contents_obj = text_contents.get<picojson::object>();
+ picojson::value thumbnails_contents = picojson::value(picojson::object());
+ picojson::object& thumbnails_contents_obj = thumbnails_contents.get<picojson::object>();
+
+ // lockScreenThumbnailIconPath
+ PlatformResult status = AddPathToJson(noti_handle, NOTIFICATION_IMAGE_TYPE_THUMBNAIL_FOR_LOCK,
+ "lockScreenThumbnailIconPath", out_ptr);
+ CHECK_ERROR(status);
+
+ // thumbnailIconPath
+ status = AddPathToJson(noti_handle, NOTIFICATION_IMAGE_TYPE_THUMBNAIL,
+ "thumbnailIconPath", out_ptr);
+ CHECK_ERROR(status);
- out["thumbnails"] = text_contents;
+ // thumbnails
+ status = AddPathsArrayToJson(noti_handle, thumbnails_map_, "thumbnails", out_ptr);
+ CHECK_ERROR(status);
+
+ (*out_ptr)["thumbnails"] = thumbnails_contents;
return PlatformResult(ErrorCode::NO_ERROR);
}
PlatformResult UserNotification::AddActionsToJson(notification_h noti_handle,
+ app_control_h app_handle,
picojson::object* out_ptr) {
LoggerD("Enter");
- picojson::object& out = *out_ptr;
- picojson::value text_contents = picojson::value(picojson::object());
- picojson::object& text_contents_obj = text_contents.get<picojson::object>();
+ picojson::value actions_contents = picojson::value(picojson::object());
+ picojson::object& actions_contents_obj = actions_contents.get<picojson::object>();
- out["actions"] = text_contents;
+ // soundPath
+ PlatformResult status = AddSoundPathToJson(noti_handle, &actions_contents_obj);
+ CHECK_ERROR(status);
+
+ //vibration
+ status = AddVibrationToJson(noti_handle, &actions_contents_obj);
+ CHECK_ERROR(status);
+
+ //appControl, appId
+ status = AddAppControlInfoToJson(noti_handle, app_handle, &actions_contents_obj);
+ CHECK_ERROR(status);
+
+ (*out_ptr)["actions"] = actions_contents;
return PlatformResult(ErrorCode::NO_ERROR);
}
PlatformResult UserNotification::AddGroupContentsToJson(notification_h noti_handle,
picojson::object* out_ptr) {
LoggerD("Enter");
- picojson::object& out = *out_ptr;
- picojson::value text_contents = picojson::value(picojson::object());
- picojson::object& text_contents_obj = text_contents.get<picojson::object>();
+ picojson::value group_contents = picojson::value(picojson::object());
+ picojson::object& group_contents_obj = group_contents.get<picojson::object>();
+
+ // groupTitle
+ PlatformResult status = AddTextToJson(noti_handle, NOTIFICATION_TEXT_TYPE_GROUP_TITLE,
+ "groupTitle", &group_contents_obj);
+ CHECK_ERROR(status);
+
+ // groupContent
+ status = AddTextToJson(noti_handle, NOTIFICATION_TEXT_TYPE_GROUP_CONTENT,
+ "groupContent", &group_contents_obj);
+ CHECK_ERROR(status);
+
+ // groupContentForOff
+ status = AddTextToJson(noti_handle, NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF,
+ "groupContentForOff", &group_contents_obj);
+ CHECK_ERROR(status);
- out["groupContents"] = text_contents;
+ (*out_ptr)["groupContents"] = group_contents;
return PlatformResult(ErrorCode::NO_ERROR);
}
PlatformResult UserNotification::AddLedsToJson(notification_h noti_handle,
picojson::object* out_ptr) {
LoggerD("Enter");
- picojson::object& out = *out_ptr;
- picojson::value text_contents = picojson::value(picojson::object());
- picojson::object& text_contents_obj = text_contents.get<picojson::object>();
+ picojson::value leds_contents = picojson::value(picojson::object());
+ picojson::object& leds_contents_obj = leds_contents.get<picojson::object>();
+
+ // ledColor
+ PlatformResult status = AddLedColorToJson(noti_handle, &leds_contents_obj);
+ CHECK_ERROR(status);
+
+ // ledOnPeriod, ledOffPeriod
+ status = AddLedOnOffPeriodToJson(noti_handle, &leds_contents_obj);
+ CHECK_ERROR(status);
- out["leds"] = text_contents;
+ (*out_ptr)["leds"] = leds_contents;
return PlatformResult(ErrorCode::NO_ERROR);
}
picojson::object* out_ptr);
static common::PlatformResult AddTextContentsToJson(notification_h noti_handle,
+ std::string noti_type_str,
picojson::object* out_ptr);
static common::PlatformResult AddImagesToJson(notification_h noti_handle,
picojson::object* out_ptr);
static common::PlatformResult AddThumbnailsToJson(notification_h noti_handle,
picojson::object* out_ptr);
static common::PlatformResult AddActionsToJson(notification_h noti_handle,
+ app_control_h app_handle,
picojson::object* out_ptr);
static common::PlatformResult AddGroupContentsToJson(notification_h noti_handle,
picojson::object* out_ptr);