#define NOTI_TEXT_RESULT_LEN 2048
#define NOTI_PKGNAME_LEN 512
+#define REGULAR_UID_MIN 5000
+
char *notification_get_pkgname_by_pid(void)
{
char pkgname[NOTI_PKGNAME_LEN + 1] = { 0, };
}
if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
- || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
+ || event_type >= NOTIFICATION_EVENT_TYPE_MAX) {
NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
err = NOTIFICATION_ERROR_INVALID_PARAMETER;
goto out;
}
if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
- || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
+ || event_type >= NOTIFICATION_EVENT_TYPE_MAX) {
NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
err = NOTIFICATION_ERROR_INVALID_PARAMETER;
goto out;
return err;
}
-
-
-
-
EXPORT_API int notification_set_property(notification_h noti,
int flags)
{
return NULL;
}
- noti = (notification_h) calloc(1, sizeof(struct _notification));
+ noti = (notification_h)calloc(1, sizeof(struct _notification));
if (noti == NULL) {
NOTIFICATION_ERR("NO MEMORY : noti == NULL");
set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
else if (type == NOTIFICATION_TYPE_ONGOING)
noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
- noti->caller_pkgname = notification_get_pkgname_by_pid();
noti->group_id = NOTIFICATION_GROUP_ID_NONE;
noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
noti->display_applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_INDICATOR;
noti->auto_remove = true;
noti->ongoing_flag = false;
+ noti->default_button_index = 0;
+ noti->type = NOTIFICATION_ONGOING_VALUE_TYPE_PERCENT;
+ noti->timeout = 0;
+
+ if (getuid() >= REGULAR_UID_MIN) {
+ noti->caller_pkgname = notification_get_pkgname_by_pid();
+
+ err_app_manager = app_manager_get_app_id(getpid(), &app_id);
+ if (err_app_manager != APP_MANAGER_ERROR_NONE || app_id == NULL) {
+ NOTIFICATION_WARN("app_manager_get_app_id failed err[%d] app_id[%p]",
+ err_app_manager, app_id);
+ goto out;
+ }
- err_app_manager = app_manager_get_app_id(getpid(), &app_id);
- if (err_app_manager != APP_MANAGER_ERROR_NONE || app_id == NULL) {
- NOTIFICATION_WARN("app_manager_get_app_id failed err[%d] app_id[%p]", err_app_manager, app_id);
- goto out;
- }
-
- /* app name is used as domain name */
- /* domain_name is allocated by app_get_package_app_name */
- err_app_manager = app_get_package_app_name(app_id, &domain_name);
+ /* app name is used as domain name */
+ /* domain_name is allocated by app_get_package_app_name */
+ err_app_manager = app_get_package_app_name(app_id, &domain_name);
- if (err_app_manager != APP_ERROR_NONE || domain_name == NULL) {
- NOTIFICATION_WARN("app_get_package_app_name failed err[%d] domain_name[%p]", err_app_manager, domain_name);
- goto out;
- }
+ if (err_app_manager != APP_ERROR_NONE || domain_name == NULL) {
+ NOTIFICATION_WARN("app_get_package_app_name failed err[%d] domain_name[%p]",
+ err_app_manager, domain_name);
+ goto out;
+ }
- err_app_manager = package_info_create(noti->caller_pkgname, &package_info);
+ err_app_manager = package_info_create(noti->caller_pkgname, &package_info);
- if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || package_info == NULL) {
- NOTIFICATION_WARN("package_info_create failed err[%d] package_info[%p] caller_pkgname[%s]",
- err_app_manager, package_info, noti->caller_pkgname);
- goto out;
- }
+ if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || package_info == NULL) {
+ NOTIFICATION_WARN("package_info_create failed err[%d] package_info[%p] caller_pkgname[%s]",
+ err_app_manager, package_info, noti->caller_pkgname);
+ goto out;
+ }
- err_app_manager = package_info_get_root_path(package_info, &app_root_path);
+ err_app_manager = package_info_get_root_path(package_info, &app_root_path);
- if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || app_root_path == NULL) {
- NOTIFICATION_WARN("package_info_get_root_path failed err[%d] app_root_path[%p]", err_app_manager, app_root_path);
- goto out;
- }
+ if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || app_root_path == NULL) {
+ NOTIFICATION_WARN("package_info_get_root_path failed err[%d] app_root_path[%p]",
+ err_app_manager, app_root_path);
+ goto out;
+ }
- snprintf(locale_directory, PATH_MAX, "%s/res/locale", app_root_path);
+ snprintf(locale_directory, PATH_MAX, "%s/res/locale", app_root_path);
- noti->domain = strdup(domain_name);
- noti->dir = strdup(locale_directory);
+ noti->domain = strdup(domain_name);
+ noti->dir = strdup(locale_directory);
+ }
out:
if (domain_name)
return _notification_create(type);
}
-EXPORT_API notification_h notification_load_by_tag(const char *tag)
+EXPORT_API notification_h notification_load_by_tag(const char *tag)
{
return notification_load_by_tag_for_uid(tag, getuid());
}
new_noti->progress_percentage = noti->progress_percentage;
new_noti->ongoing_flag = noti->ongoing_flag;
+ new_noti->ongoing_value_type = noti->ongoing_value_type;
+ new_noti->ongoing_current = noti->ongoing_current;
+ new_noti->ongoing_duration = noti->ongoing_duration;
new_noti->auto_remove = noti->auto_remove;
+ new_noti->default_button_index = noti->default_button_index;
+ new_noti->timeout = noti->timeout;
+ new_noti->text_input_max_length = noti->text_input_max_length;
new_noti->uid = noti->uid;
new_noti->app_icon_path = NULL;
return NOTIFICATION_ERROR_NONE;
}
+EXPORT_API int notification_save_as_template(notification_h noti, const char *template_name)
+{
+ if (noti == NULL || template_name == NULL) {
+ NOTIFICATION_ERR("Invalid parameter");
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ return notification_ipc_request_save_as_template(noti, template_name);
+}
+
+EXPORT_API notification_h notification_create_from_template(const char *template_name)
+{
+ int ret = 0;
+ notification_h noti = NULL;
+
+ if (template_name == NULL) {
+ NOTIFICATION_ERR("Invalid parameter");
+ set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ noti = (notification_h)calloc(1, sizeof(struct _notification));
+ if (noti == NULL) {
+ NOTIFICATION_ERR("Failed to alloc a new notification");
+ set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ ret = notification_ipc_request_create_from_template(noti, template_name);
+
+ set_last_result(ret);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ notification_free(noti);
+ return NULL;
+ }
+
+ return noti;
+}
+
+EXPORT_API int notification_get_noti_block_state(notification_block_state_e *state)
+{
+ int ret;
+ char *pkgname;
+ int do_not_disturb;
+ int do_not_disturb_except;
+ int allow_to_notify;
+
+ if (state == NULL)
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ pkgname = notification_get_pkgname_by_pid();
+
+ ret = notification_ipc_get_noti_block_state(pkgname, &do_not_disturb, &do_not_disturb_except, &allow_to_notify, getuid());
+
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ if (pkgname)
+ free(pkgname);
+ return ret;
+ }
+
+ if (allow_to_notify) {
+ *state = NOTIFICATION_BLOCK_STATE_ALLOWED;
+ if (do_not_disturb && !do_not_disturb_except)
+ *state = NOTIFICATION_BLOCK_STATE_DO_NOT_DISTURB;
+ } else {
+ *state = NOTIFICATION_BLOCK_STATE_BLOCKED;
+ }
+
+ if (pkgname)
+ free(pkgname);
+
+ return ret;
+}
+
+EXPORT_API int notification_set_text_input(notification_h noti, int text_input_max_length)
+{
+ if (noti == NULL)
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ noti->text_input_max_length = text_input_max_length;
+
+ return NOTIFICATION_ERROR_NONE;
+}