From: Myungki Lee Date: Mon, 29 May 2017 09:29:22 +0000 (+0900) Subject: Adds pkg_id field in notification_h X-Git-Tag: submit/tizen/20170529.093825~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a55a637fca12bcd30cfbea75636b9e76756b4496;p=platform%2Fcore%2Fapi%2Fnotification.git Adds pkg_id field in notification_h When any package is uninstalled, If there are any data related to the package, these should be deleted in database. Add a field in notification_h to remove the data by package name. Change-Id: I142f7c845f9d7396801b22087e523f4620cc03ff Signed-off-by: Seungha Son Signed-off-by: Semun Lee --- diff --git a/include/notification_private.h b/include/notification_private.h index c8747b53..d17d8782 100644 --- a/include/notification_private.h +++ b/include/notification_private.h @@ -44,6 +44,7 @@ struct _notification { int internal_group_id; /* Internal Group ID */ int priv_id; /* Private ID */ + char *pkg_id; char *caller_pkgname; /* Caller App package name */ char *launch_pkgname; /* Launch App package name. It will be from appsvc_set_pkgname */ bundle *args; /* Will be removed. */ @@ -110,6 +111,7 @@ typedef enum notification_data_type { NOTIFICATION_DATA_TYPE_GROUP_ID, NOTIFICATION_DATA_TYPE_INTERNAL_GROUP_ID, NOTIFICATION_DATA_TYPE_PRIV_ID, + NOTIFICATION_DATA_TYPE_PKG_ID, NOTIFICATION_DATA_TYPE_CALLER_PKGNAME, NOTIFICATION_DATA_TYPE_LAUNCH_PKGNAME, NOTIFICATION_DATA_TYPE_ARGS, diff --git a/src/notification.c b/src/notification.c index a581e056..de35c6f7 100755 --- a/src/notification.c +++ b/src/notification.c @@ -1462,12 +1462,15 @@ static notification_h _notification_create(notification_type_e type) goto out; } - if (getuid() >= REGULAR_UID_MIN) { + if (getuid() < REGULAR_UID_MIN) { + noti->pkg_id = strdup(noti->caller_pkgname); + } else { err = aul_app_get_pkgid_bypid(getpid(), pkgid, sizeof(pkgid)); if (err != AUL_R_OK) { NOTIFICATION_ERR("get_pkgid_bypid is failed err[%d]", err); goto out; } + noti->pkg_id = strdup(pkgid); err = _notification_get_app_name(pkgid, &domain_name); if (err != 0 || domain_name == NULL) { @@ -1547,6 +1550,9 @@ EXPORT_API int notification_clone(notification_h noti, notification_h *clone) new_noti->internal_group_id = noti->internal_group_id; new_noti->priv_id = noti->priv_id; + if (noti->pkg_id != NULL) + new_noti->pkg_id = strdup(noti->pkg_id); + if (noti->caller_pkgname != NULL) new_noti->caller_pkgname = strdup(noti->caller_pkgname); else @@ -1688,6 +1694,9 @@ EXPORT_API int notification_free(notification_h noti) if (noti == NULL) return NOTIFICATION_ERROR_INVALID_PARAMETER; + if (noti->pkg_id) + free(noti->pkg_id); + if (noti->caller_pkgname) free(noti->caller_pkgname); diff --git a/src/notification_db.c b/src/notification_db.c index a2e7c10a..d5bee4dd 100755 --- a/src/notification_db.c +++ b/src/notification_db.c @@ -35,6 +35,7 @@ PRAGMA synchronous = FULL; \ create table if not exists noti_list ( \ type INTEGER NOT NULL, \ layout INTEGER NOT NULL default 0, \ + pkg_id TEXT NOT NULL, \ caller_pkgname TEXT NOT NULL, \ launch_pkgname TEXT, \ image_path TEXT, \ @@ -162,6 +163,7 @@ create table if not exists noti_list ( \ CREATE TABLE IF NOT EXISTS noti_template ( \ type INTEGER NOT NULL, \ layout INTEGER NOT NULL default 0, \ + pkg_id TEXT NOT NULL, \ caller_pkgname TEXT NOT NULL, \ launch_pkgname TEXT, \ image_path TEXT, \ diff --git a/src/notification_ipc.c b/src/notification_ipc.c index 1629c974..353f779e 100755 --- a/src/notification_ipc.c +++ b/src/notification_ipc.c @@ -1743,6 +1743,7 @@ EXPORT_API GVariant *notification_ipc_make_gvariant_from_noti(notification_h not g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_GROUP_ID, g_variant_new_int32(noti->group_id)); g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_INTERNAL_GROUP_ID, g_variant_new_int32(noti->internal_group_id)); g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_PRIV_ID, g_variant_new_int32(noti->priv_id)); + g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_PKG_ID, g_variant_new_string((const gchar *)noti->pkg_id)); g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_CALLER_PKGNAME, g_variant_new_string((const gchar *)noti->caller_pkgname)); g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_DISPLAY_APPLIST, g_variant_new_int32(noti->display_applist)); @@ -1977,6 +1978,7 @@ EXPORT_API int notification_ipc_make_noti_from_gvariant(notification_h noti, GHashTable *dict; int i; + char *pkg_id = NULL; char *caller_pkgname = NULL; char *launch_pkgname = NULL; bundle_raw *args = NULL; @@ -2018,6 +2020,7 @@ EXPORT_API int notification_ipc_make_noti_from_gvariant(notification_h noti, _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_GROUP_ID, "i", ¬i->group_id); _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_INTERNAL_GROUP_ID, "i", ¬i->internal_group_id); _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_PRIV_ID, "i", ¬i->priv_id); + _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_PKG_ID, "&s", &pkg_id); _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_CALLER_PKGNAME, "&s", &caller_pkgname); _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_LAUNCH_PKGNAME, "&s", &launch_pkgname); _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_ARGS, "&s", &args); @@ -2075,6 +2078,7 @@ EXPORT_API int notification_ipc_make_noti_from_gvariant(notification_h noti, _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_EXTENSION_IMAGE_SIZE, "i", ¬i->extension_image_size); _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_UID, "i", ¬i->uid); + noti->pkg_id = _dup_string(pkg_id); noti->caller_pkgname = _dup_string(caller_pkgname); noti->launch_pkgname = _dup_string(launch_pkgname); noti->args = _create_bundle_from_bundle_raw(args); diff --git a/src/notification_noti.c b/src/notification_noti.c index f0655653..449de3c6 100755 --- a/src/notification_noti.c +++ b/src/notification_noti.c @@ -248,7 +248,7 @@ static int _insertion_query_create(notification_h noti, char **query) *query = sqlite3_mprintf("INSERT INTO noti_list (" "type, " "layout, " - "caller_pkgname, launch_pkgname, " + "pkg_id, caller_pkgname, launch_pkgname, " "image_path, " "group_id, internal_group_id," "title_key, " @@ -269,7 +269,7 @@ static int _insertion_query_create(notification_h noti, char **query) "text_input_max_length, event_flag, extension_image_size, uid) values (" "%d, " "%d, " - "'%s', '%s', " + "'%s', '%s', '%s', " "'%s', " "%d, %d," "$title_key, " @@ -289,6 +289,7 @@ static int _insertion_query_create(notification_h noti, char **query) "%d, %d, %d, %d, %d, %d, %d)", noti->type, noti->layout, + NOTIFICATION_CHECK_STR(noti->pkg_id), NOTIFICATION_CHECK_STR(noti->caller_pkgname), NOTIFICATION_CHECK_STR(noti->launch_pkgname), NOTIFICATION_CHECK_STR(b_image_path), noti->group_id, @@ -566,6 +567,7 @@ static void _notification_noti_populate_from_stmt(sqlite3_stmt *stmt, notificati noti->type = sqlite3_column_int(stmt, col++); noti->layout = sqlite3_column_int(stmt, col++); + __free_and_set((void **)&(noti->pkg_id), notification_db_column_text(stmt, col++)); __free_and_set((void **)&(noti->caller_pkgname), notification_db_column_text(stmt, col++)); __free_and_set((void **)&(noti->launch_pkgname), notification_db_column_text(stmt, col++)); noti->b_image_path = notification_db_column_bundle(stmt, col++); @@ -596,7 +598,6 @@ static void _notification_noti_populate_from_stmt(sqlite3_stmt *stmt, notificati for (i = 0; i <= NOTIFICATION_EVENT_TYPE_MAX; i++) noti->b_event_handler[i] = notification_db_column_bundle(stmt, col++); - noti->sound_type = sqlite3_column_int(stmt, col++); __free_and_set((void **)&(noti->sound_path), notification_db_column_text(stmt, col++)); noti->vibration_type = sqlite3_column_int(stmt, col++); @@ -1035,7 +1036,7 @@ EXPORT_API int notification_noti_get_by_priv_id(notification_h noti, int priv_id return get_last_result(); char *base_query = "select " - "type, layout, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, " + "type, layout, pkg_id, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, " "tag, b_text, b_key, 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, " @@ -1103,7 +1104,7 @@ EXPORT_API int notification_noti_get_by_tag(notification_h noti, char *pkgname, if (pkgname != NULL && strlen(pkgname) != 0) { ret = sqlite3_prepare_v2(db, "select " - "type, layout, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, " + "type, layout, pkg_id, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, " "tag, b_text, b_key, 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, " @@ -1141,7 +1142,7 @@ EXPORT_API int notification_noti_get_by_tag(notification_h noti, char *pkgname, } else { ret = sqlite3_prepare_v2(db, "select " - "type, layout, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, " + "type, layout, pkg_id, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, " "tag, b_text, b_key, 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, " @@ -1603,7 +1604,7 @@ EXPORT_API int notification_noti_get_grouping_list(notification_type_e type, ret = vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT, &status); snprintf(query_base, sizeof(query_base), "select " - "type, layout, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, " + "type, layout, pkg_id, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, " "tag, b_text, b_key, 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, " @@ -1705,7 +1706,7 @@ EXPORT_API int notification_noti_get_detail_list(const char *pkgname, ret = vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT, &status); snprintf(query_base, sizeof(query_base), "select " - "type, layout, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, " + "type, layout, pkg_id, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, " "tag, b_text, b_key, 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, " @@ -1962,7 +1963,7 @@ static int _template_query_create(notification_h noti, char *template_name, char *query = sqlite3_mprintf("INSERT OR REPLACE INTO noti_template (" "type, " "layout, " - "caller_pkgname, launch_pkgname, " + "pkg_id, caller_pkgname, launch_pkgname, " "image_path, " "group_id, internal_group_id," "title_key, " @@ -1982,7 +1983,7 @@ static int _template_query_create(notification_h noti, char *template_name, char "event_flag, extension_image_size, uid, template_name) values (" "%d, " "%d, " - "'%s', '%s', " + "'%s', '%s', '%s', " "'%s', " "%d, %d," "$title_key, " @@ -2002,6 +2003,7 @@ static int _template_query_create(notification_h noti, char *template_name, char "%d, %d, %d, '%s')", noti->type, noti->layout, + NOTIFICATION_CHECK_STR(noti->pkg_id), NOTIFICATION_CHECK_STR(noti->caller_pkgname), NOTIFICATION_CHECK_STR(noti->launch_pkgname), NOTIFICATION_CHECK_STR(b_image_path), noti->group_id, @@ -2199,7 +2201,7 @@ EXPORT_API int notification_noti_get_package_template(notification_h noti, char return get_last_result(); ret = sqlite3_prepare_v2(db, "select " - "type, layout, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, " + "type, layout, pkg_id, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, " "tag, b_text, b_key, 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, " @@ -2262,7 +2264,7 @@ EXPORT_API int notification_noti_delete_template(const char *pkgname) return get_last_result(); snprintf(query, sizeof(query), "delete from noti_template " - "where caller_pkgname = '%s'", pkgname); + "where pkg_id = '%s'", pkgname); ret = notification_db_exec(db, query, NULL);