app_control_h *event_handler);
/**
+ * @internal
+ * @brief Sets the label of caller application.
+ * @details It recommends for daemons. For an Application, the label is set when notification create.
+ * @since tizen 5.0
+ * @param[in] noti Notification handle
+ * @param[in] label Label of Caller application
+ * @return NOTIFICATION_ERROR_NONE on success, other value on failure
+ * @retval NOTIFICATION_ERROR_NONE Success
+ * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
+ * @par Sample code:
+ * @code
+#include <notification.h>
+...
+{
+ notification_h noti = NULL;
+ int noti_err = NOTIFICATION_ERROR_NONE;
+
+ noti = notification_create(NOTIFICATION_TYPE_NOTI);
+ if (noti == NULL) {
+ return;
+ }
+
+ noti_err = notification_set_app_label(noti, "message");
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ notification_free(noti);
+ return;
+ }
+}
+ * @endcode
+ */
+int notification_set_app_label(notification_h noti, char *label);
+
+/**
+ * @internal
+ * @brief Gets the label of caller application
+ * @details Label may be null if it was not set.
+ * Do not free @a label. It will be freed when notification_free() is called.
+ * @since tizen 5.0
+ * @param[in] noti Notification handle
+ * @param[out] label Label of Caller application
+ * @return NOTIFICATION_ERROR_NONE on success, other value on failure
+ * @retval NOTIFICATION_ERROR_NONE Success
+ * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
+ * @par Sample code:
+ * @code
+#include <notification.h>
+...
+{
+ int noti_err = NOTIFICATION_ERROR_NONE;
+ char *label = NULL;
+
+ noti_err = notification_get_app_label(noti, &label);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ return;
+ }
+}
+ * @endcode
+ */
+int notification_get_app_label(notification_h noti, char **label);
+
+/**
* @}
*/
#ifdef __cplusplus
double progress_percentage; /* percentage of progress */
char *app_icon_path; /* Temporary stored app icon path from AIL */
- char *app_name; /* Temporary stored app name from AIL */
+ char *app_label;
char *temp_title;
char *temp_content;
char *tag;
NOTIFICATION_DATA_TYPE_PROGRESS_SIZE,
NOTIFICATION_DATA_TYPE_PROGRESS_PERCENTAGE,
NOTIFICATION_DATA_TYPE_APP_ICON_PATH,
- NOTIFICATION_DATA_TYPE_APP_NAME,
+ NOTIFICATION_DATA_TYPE_APP_LABEL,
NOTIFICATION_DATA_TYPE_TEMP_TITLE,
NOTIFICATION_DATA_TYPE_TEMP_CONTENT,
NOTIFICATION_DATA_TYPE_TAG,
pkg_id TEXT NOT NULL,
caller_app_id TEXT NOT NULL,
launch_app_id TEXT,
+ app_label TEXT,
image_path TEXT,
priv_image_path TEXT,
group_id INTEGER default 0,
pkg_id TEXT NOT NULL,
caller_app_id TEXT NOT NULL,
launch_app_id TEXT,
+ app_label TEXT,
image_path TEXT,
priv_image_path TEXT,
group_id INTEGER default 0,
#include <package_manager.h>
#include <aul.h>
#include <tizen.h>
+#include <pkgmgr-info.h>
+#include <pkgmgrinfo_type.h>
#include <notification.h>
#include <notification_list.h>
return notification_delete_for_uid(noti, getuid());
}
-static int _notification_get_app_name(const char *app_id, char **name)
+static int _notification_get_domain_name(const char *app_id, char **name)
{
char *name_token = NULL;
#define NOTI_PKG_ID_LEN 512
notification_h noti = NULL;
package_info_h package_info = NULL;
+ pkgmgrinfo_appinfo_h appinfo = NULL;
char *domain_name = NULL;
char *app_root_path = NULL;
+ char *label = NULL;
char locale_directory[PATH_MAX] = { 0, }; /* PATH_MAX 4096 */
char pkg_id[NOTI_PKG_ID_LEN + 1] = { 0, };
int err = 0;
goto out;
}
- err = _notification_get_app_name(pkg_id, &domain_name);
+ err = _notification_get_domain_name(pkg_id, &domain_name);
if (err != 0 || domain_name == NULL) {
NOTIFICATION_WARN("Failed to get domain_name");
err = 0;
goto out;
}
+ noti->domain = strdup(domain_name);
+
err = package_info_create(pkg_id, &package_info);
if (err != PACKAGE_MANAGER_ERROR_NONE || package_info == NULL) {
/* LCOV_EXCL_START */
}
snprintf(locale_directory, PATH_MAX, "%s/res/locale", app_root_path);
-
- noti->domain = strdup(domain_name);
noti->dir = strdup(locale_directory);
+
+ err = pkgmgrinfo_appinfo_get_usr_appinfo(noti->caller_app_id,
+ getuid(), &appinfo);
+ if (err != PMINFO_R_OK || appinfo == NULL) {
+ NOTIFICATION_WARN("Failed to get appinfo err[%d]",
+ err, noti->caller_app_id);
+ err = 0;
+ goto out;
+ }
+
+ err = pkgmgrinfo_appinfo_get_label(appinfo, &label);
+ if (err != PMINFO_R_OK || label == NULL) {
+ NOTIFICATION_WARN("Failed to get app_label err[%d]", err);
+ err = 0;
+ goto out;
+ }
+
+ noti->app_label = strdup(label);
}
out:
if (package_info)
package_info_destroy(package_info);
+ if (appinfo)
+ pkgmgrinfo_appinfo_destroy_appinfo(appinfo);
+
if (err != 0) {
notification_free(noti);
noti = NULL;
new_noti->event_flag = noti->event_flag;
new_noti->is_translation = noti->is_translation;
new_noti->extension_image_size = noti->extension_image_size;
+
+ if (noti->app_label != NULL)
+ new_noti->app_label = strdup(noti->app_label);
+
new_noti->uid = noti->uid;
*clone = new_noti;
if (noti->app_icon_path)
free(noti->app_icon_path);
- if (noti->app_name)
- free(noti->app_name);
+ if (noti->app_label)
+ free(noti->app_label);
if (noti->temp_title)
free(noti->temp_title);
" pkg_id TEXT NOT NULL,\n" \
" caller_app_id TEXT NOT NULL,\n" \
" launch_app_id TEXT,\n" \
+ " app_label TEXT,\n" \
" image_path TEXT,\n" \
" priv_image_path TEXT,\n" \
" group_id INTEGER DEFAULT 0,\n" \
" pkg_id TEXT NOT NULL,\n" \
" caller_app_id TEXT NOT NULL,\n" \
" launch_app_id TEXT,\n" \
+ " app_label TEXT,\n" \
" image_path TEXT,\n" \
" priv_image_path TEXT,\n" \
" group_id INTEGER DEFAULT 0,\n" \
" UNIQUE (caller_app_id, template_name));\n"
#define NOTI_LIST_DB_ATTRIBUTES_SELECT \
- "type, layout, pkg_id, caller_app_id, launch_app_id, image_path, " \
- "priv_image_path, group_id, priv_id, b_text, b_key, " \
+ "type, layout, pkg_id, caller_app_id, launch_app_id, app_label, "\
+ "image_path, priv_image_path, group_id, priv_id, b_text, b_key, " \
"tag, b_format_args, num_format_args, text_domain, text_dir, " \
"time, insert_time, args, group_args, b_execute_option, " \
"b_service_responding, b_service_single_launch, b_service_multi_launch, " \
"extension_image_size, uid"
#define NOTI_LIST_DB_ATTRIBUTES_INSERT \
- "type, layout, pkg_id, caller_app_id, launch_app_id, image_path, " \
- "priv_image_path, group_id, internal_group_id, title_key, b_text, b_key, " \
- "tag, b_format_args, num_format_args, text_domain, text_dir, " \
- "time, insert_time, args, group_args, b_execute_option, " \
+ "type, layout, pkg_id, caller_app_id, launch_app_id, app_label, " \
+ "image_path, priv_image_path, group_id, internal_group_id, title_key, " \
+ "b_text, b_key, tag, b_format_args, num_format_args, text_domain, " \
+ "text_dir, time, insert_time, args, group_args, b_execute_option, " \
"b_service_responding, b_service_single_launch, b_service_multi_launch, " \
"b_event_handler_click_on_button_1, b_event_handler_click_on_button_2, " \
"b_event_handler_click_on_button_3, b_event_handler_click_on_button_4, " \
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " \
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " \
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " \
- "? "
+ "?, ? "
#define NOTI_LIST_DB_ATTRIBUTES_UPDATE \
- "type = ?, layout = ?, launch_app_id = ?, image_path = ?, " \
- "priv_image_path = ?, b_text = ?, b_key = ?, tag = ?, " \
+ "type = ?, layout = ?, launch_app_id = ?, app_label = ?, " \
+ "image_path = ?, priv_image_path = ?, b_text = ?, b_key = ?, tag = ?, " \
"b_format_args = ?, num_format_args = ?, text_domain = ?, text_dir = ?, " \
"time = ?, insert_time = ?, args = ?, group_args = ?, " \
"b_execute_option = ?, b_service_responding = ?, " \
"ongoing_current = ?, ongoing_duration = ?, " \
"auto_remove = ?, default_button_index = ?, " \
"hide_timeout = ?, delete_timeout = ?, " \
- "text_input_max_length = ?, event_flag = ?, extension_image_size = ?"
+ "text_input_max_length = ?, event_flag = ?, extension_image_size = ? "
#define NOTIFICATION_SETTING_DB_ATTRIBUTES \
"package_name, app_id, allow_to_notify, do_not_disturb_except, "\
return notification_get_all_count_for_uid(type, count, getuid());
}
+EXPORT_API int notification_set_app_label(notification_h noti, char *label)
+{
+ if (noti == NULL || label == NULL)
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ if (noti->app_label)
+ free(noti->app_label);
+
+ noti->app_label = strdup(label);
+
+ return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_get_app_label(notification_h noti, char **label)
+{
+ if (noti == NULL || label == NULL)
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+ if (noti->app_label)
+ *label = noti->app_label;
+
+ return NOTIFICATION_ERROR_NONE;
+}
if (noti->app_icon_path != NULL)
g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_APP_ICON_PATH, g_variant_new_string((const gchar *)noti->app_icon_path));
- if (noti->app_name != NULL)
- g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_APP_NAME, g_variant_new_string((const gchar *)noti->app_name));
+ if (noti->app_label != NULL)
+ g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_APP_LABEL, g_variant_new_string((const gchar *)noti->app_label));
if (noti->temp_title != NULL)
g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_TEMP_TITLE, g_variant_new_string((const gchar *)noti->temp_title));
if (noti->temp_content != NULL)
char *vibration_path = NULL;
char *priv_vibration_path = NULL;
char *app_icon_path = NULL;
- char *app_name = NULL;
+ char *app_label = NULL;
char *temp_title = NULL;
char *temp_content = NULL;
char *tag = NULL;
_variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_PROGRESS_SIZE, "d", ¬i->progress_size);
_variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_PROGRESS_PERCENTAGE, "d", ¬i->progress_percentage);
_variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_APP_ICON_PATH, "&s", &app_icon_path);
- _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_APP_NAME, "&s", &app_name);
+ _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_APP_LABEL, "&s", &app_label);
_variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_TEMP_TITLE, "&s", &temp_title);
_variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_TEMP_CONTENT, "&s", &temp_content);
_variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_TAG, "&s", &tag);
noti->vibration_path = _dup_string(vibration_path);
noti->priv_vibration_path = _dup_string(priv_vibration_path);
noti->app_icon_path = _dup_string(app_icon_path);
- noti->app_name = _dup_string(app_name);
+ noti->app_label = _dup_string(app_label);
noti->temp_title = _dup_string(temp_title);
noti->temp_content = _dup_string(temp_content);
noti->tag = _dup_string(tag);
__free_and_set((void **)&(noti->pkg_id), notification_db_column_text(stmt, col++));
__free_and_set((void **)&(noti->caller_app_id), notification_db_column_text(stmt, col++));
__free_and_set((void **)&(noti->launch_app_id), notification_db_column_text(stmt, col++));
+ __free_and_set((void **)&(noti->app_label), notification_db_column_text(stmt, col++));
noti->b_image_path = notification_db_column_bundle(stmt, col++);
noti->b_priv_image_path = notification_db_column_bundle(stmt, col++);
noti->group_id = sqlite3_column_int(stmt, col++);
noti->uid = sqlite3_column_int(stmt, col++);
noti->app_icon_path = NULL;
- noti->app_name = NULL;
noti->temp_title = NULL;
noti->temp_content = NULL;
}
__BIND_TEXT(db, stmt, idx++, NOTIFICATION_CHECK_STR(noti->pkg_id), ret, out);
__BIND_TEXT(db, stmt, idx++, NOTIFICATION_CHECK_STR(noti->caller_app_id), ret, out);
__BIND_TEXT(db, stmt, idx++, NOTIFICATION_CHECK_STR(noti->launch_app_id), ret, out);
+ __BIND_TEXT(db, stmt, idx++, NOTIFICATION_CHECK_STR(noti->app_label), ret, out);
__BIND_TEXT(db, stmt, idx++, NOTIFICATION_CHECK_STR(b_image_path), ret, out);
__BIND_TEXT(db, stmt, idx++, NOTIFICATION_CHECK_STR(b_priv_image_path), ret, out);
__BIND_INT(db, stmt, idx++, noti->group_id, ret, out);
__BIND_INT(db, stmt, idx++, noti->type, ret, out);
__BIND_INT(db, stmt, idx++, noti->layout, ret, out);
__BIND_TEXT(db, stmt, idx++, NOTIFICATION_CHECK_STR(noti->launch_app_id), ret, out);
+ __BIND_TEXT(db, stmt, idx++, NOTIFICATION_CHECK_STR(noti->app_label), ret, out);
__BIND_TEXT(db, stmt, idx++, NOTIFICATION_CHECK_STR(b_image_path), ret, out);
__BIND_TEXT(db, stmt, idx++, NOTIFICATION_CHECK_STR(b_priv_image_path), ret, out);
__BIND_TEXT(db, stmt, idx++, NOTIFICATION_CHECK_STR(b_text), ret, out);