From d6cdeba42f3e09abccbe6fdb6980908736875823 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Wed, 2 Aug 2017 17:14:43 +0900 Subject: [PATCH 01/16] Release version 1.4.19 Changes: - Reduce log string and format Signed-off-by: Seungha Son Change-Id: Ifa5fb85d1c494211543a7186c0f953e361dc8b13 --- packaging/data-provider-master.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/data-provider-master.spec b/packaging/data-provider-master.spec index 41e9c60..2f4e4f6 100755 --- a/packaging/data-provider-master.spec +++ b/packaging/data-provider-master.spec @@ -2,7 +2,7 @@ Name: data-provider-master Summary: Master service provider for badge, shortcut, notification -Version: 1.4.18 +Version: 1.4.19 Release: 1 Group: Applications/Core Applications License: Apache-2.0 -- 2.7.4 From da02a21c7cc38cc3b560317da80e1e8c32bb0147 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Fri, 11 Aug 2017 17:09:59 +0900 Subject: [PATCH 02/16] Add logic that check package privilege - When application request setting_h by app_id, it is needs to check privilege whether this app_id has notification privilege or not. Signed-off-by: Seungha Son Change-Id: I7ca7909aa701c58693d575479f93267c819a8900 --- src/notification_service.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/src/notification_service.c b/src/notification_service.c index a777474..86be057 100755 --- a/src/notification_service.c +++ b/src/notification_service.c @@ -1005,6 +1005,71 @@ out: return ret; } +#define NOTIFICATION_PRIVILEGE "http://tizen.org/privilege/notification" +static int privilege_cb(const char *privilege_name, void *is_checked) +{ + if (!g_strcmp0(privilege_name, NOTIFICATION_PRIVILEGE)) + { + *(int *)is_checked = 1; + return -1; + } + return 0; +} + +static int __check_app_has_privilege(const char *app_id, uid_t uid) +{ + int ret = NOTIFICATION_ERROR_NONE; + int err; + int is_checked = 0; + char *pkgname = NULL; + pkgmgrinfo_appinfo_h app_handle = NULL; + pkgmgrinfo_pkginfo_h pkg_handle = NULL; + + err = pkgmgrinfo_appinfo_get_usr_appinfo(app_id, uid, &app_handle); + if (err != PMINFO_R_OK) { + ERR("failed to get app info [%s][%d]", app_id, uid); + ret = NOTIFICATION_ERROR_IO_ERROR; + goto out; + } + + err = pkgmgrinfo_appinfo_get_pkgname(app_handle, &pkgname); + if (err != PMINFO_R_OK) { + ERR("failed to get pkgname [%s][%d]", app_id); + ret = NOTIFICATION_ERROR_IO_ERROR; + goto out; + } + + err = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgname, uid, &pkg_handle); + if (err != PMINFO_R_OK) { + ERR("failed to get pkg info [%s][%d]", pkgname, uid); + ret = NOTIFICATION_ERROR_IO_ERROR; + goto out; + } + + err = pkgmgrinfo_pkginfo_foreach_privilege(pkg_handle, privilege_cb, &is_checked); + if (err != PMINFO_R_OK) { + ERR("failed to foreach privilege_cb", pkgname, uid); + ret = NOTIFICATION_ERROR_IO_ERROR; + goto out; + } + + DBG("[%s] %s notification privilege", app_id, + is_checked == 1 ? "has" : "hasn't"); + + if (is_checked == 1) + ret = NOTIFICATION_ERROR_NONE; + else + ret = NOTIFICATION_ERROR_NOT_EXIST_ID; + +out: + if (app_handle) + pkgmgrinfo_appinfo_destroy_appinfo(app_handle); + if (pkg_handle) + pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle); + + return ret; +} + /* get_setting_by_app_id */ int notification_get_setting_by_app_id(GVariant *parameters, GVariant **reply_body, uid_t uid) { @@ -1020,6 +1085,12 @@ int notification_get_setting_by_app_id(GVariant *parameters, GVariant **reply_bo if (ret != NOTIFICATION_ERROR_NONE) return ret; + ret = __check_app_has_privilege(app_id, param_uid); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("app id[%s] err[%d]", app_id, ret); + return ret; + } + ret = noti_setting_service_get_setting_by_app_id(app_id, &setting, param_uid); if (ret == NOTIFICATION_ERROR_NOT_EXIST_ID) { err = __init_setting_handle_by_app_id(app_id, &setting, param_uid); -- 2.7.4 From ca4bdbb448ca6e82f93a228af5b8e5292fdef932 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Fri, 18 Aug 2017 12:41:44 +0900 Subject: [PATCH 03/16] Add app_fw group to dbus service file Signed-off-by: Seungha Son Change-Id: I19166a04230f3f6f609fef36ddb7fd978eb12368 --- org.tizen.data-provider-master.service.in | 1 + 1 file changed, 1 insertion(+) diff --git a/org.tizen.data-provider-master.service.in b/org.tizen.data-provider-master.service.in index 5d60061..d95dab5 100644 --- a/org.tizen.data-provider-master.service.in +++ b/org.tizen.data-provider-master.service.in @@ -3,3 +3,4 @@ Name=org.tizen.data_provider_service Exec=/bin/false SystemdService=data-provider-master.service User=app_fw +Group=app_fw -- 2.7.4 From afd321382d847720d9c551e1fbaf42b44a3e0dff Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Fri, 18 Aug 2017 16:35:51 +0900 Subject: [PATCH 04/16] Release version 1.4.20 Changes: - Add logic that check package privilege - Add app_fw group to dbus service file Signed-off-by: Seungha Son Change-Id: I346fc5ad42b2d29e3eedd4014bab9fe4e6f66a46 --- packaging/data-provider-master.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/data-provider-master.spec b/packaging/data-provider-master.spec index 2f4e4f6..6abaa33 100755 --- a/packaging/data-provider-master.spec +++ b/packaging/data-provider-master.spec @@ -2,7 +2,7 @@ Name: data-provider-master Summary: Master service provider for badge, shortcut, notification -Version: 1.4.19 +Version: 1.4.20 Release: 1 Group: Applications/Core Applications License: Apache-2.0 -- 2.7.4 From 47ff5c4ca2cd514778c26c0c1bef2ec5a76f6588 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Thu, 24 Aug 2017 15:07:06 +0900 Subject: [PATCH 05/16] Fix wrong log argument format Signed-off-by: Seungha Son Change-Id: Ia54aaa5e09e8818d2c143e60c775bcc62b404d88 --- src/badge_service.c | 2 +- src/service_common.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/badge_service.c b/src/badge_service.c index 62656d6..55f18e7 100755 --- a/src/badge_service.c +++ b/src/badge_service.c @@ -764,7 +764,7 @@ int badge_get_setting_by_appid(GVariant *parameters, GVariant **reply_body, uid_ return BADGE_ERROR_OUT_OF_MEMORY; } - INFO("Success, appid[%d]", appid); + INFO("Success, appid[%s]", appid); return ret; } diff --git a/src/service_common.c b/src/service_common.c index e8866e7..cc92dcf 100755 --- a/src/service_common.c +++ b/src/service_common.c @@ -299,7 +299,7 @@ int service_register(GVariant *parameters, GVariant **reply_body, const gchar *s m_info, NULL); if (m_info->watcher_id == 0) { - ERR("Fail to watch name [%d]", bus_name); + ERR("Fail to watch name [%s]", bus_name); free(m_info->bus_name); free(m_info); return SERVICE_COMMON_ERROR_IO_ERROR; -- 2.7.4 From 960ddce860b39f947dbe192a46ec5ec943258b53 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Thu, 24 Aug 2017 15:32:14 +0900 Subject: [PATCH 06/16] Release version 1.4.21 Changes: - Fix wrong log argument format Signed-off-by: Seungha Son Change-Id: I1ad51f0b33668d28802f6debe9e5df93d4401f36 --- packaging/data-provider-master.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/data-provider-master.spec b/packaging/data-provider-master.spec index 6abaa33..08a0923 100755 --- a/packaging/data-provider-master.spec +++ b/packaging/data-provider-master.spec @@ -2,7 +2,7 @@ Name: data-provider-master Summary: Master service provider for badge, shortcut, notification -Version: 1.4.20 +Version: 1.4.21 Release: 1 Group: Applications/Core Applications License: Apache-2.0 -- 2.7.4 From 11a76903e0283f5f0e5ed08776e3768193e9cf85 Mon Sep 17 00:00:00 2001 From: Myungki Lee Date: Fri, 25 Aug 2017 20:00:45 +0900 Subject: [PATCH 07/16] Add parameter for notification_launch_default_viewer - add uid Change-Id: Ic5fa574d5857fd10934d8c43eb4417da6a430c58 Signed-off-by: Myungki Lee --- src/notification_service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notification_service.c b/src/notification_service.c index 86be057..cb5ff3a 100755 --- a/src/notification_service.c +++ b/src/notification_service.c @@ -465,7 +465,7 @@ static int _add_noti(GVariant **reply_body, notification_h noti, uid_t uid) } if (default_viewer != NULL) { - ret = notification_launch_default_viewer(default_viewer, priv_id); + ret = notification_launch_default_viewer(default_viewer, priv_id, uid); if (ret != NOTIFICATION_ERROR_NONE) { ERR("Failed to launch default viewer [%d]", ret); return NOTIFICATION_ERROR_IO_ERROR; @@ -733,7 +733,7 @@ static int _update_noti(GVariant **reply_body, notification_h noti, uid_t uid) } if (default_viewer != NULL) { - ret = notification_launch_default_viewer(default_viewer, priv_id); + ret = notification_launch_default_viewer(default_viewer, priv_id, uid); if (ret != NOTIFICATION_ERROR_NONE) { ERR("Failed to launch (app_control error : %d)", ret); return NOTIFICATION_ERROR_IO_ERROR; -- 2.7.4 From ebc36ec8d358881e5e70eaf6119ffeb962ca2eae Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Thu, 17 Aug 2017 10:15:49 +0900 Subject: [PATCH 08/16] Refactor logic to check privilege Signed-off-by: Seungha Son Change-Id: I991c7f2120a8edf461d578a69afbfd058f14af90 --- src/notification_service.c | 146 +++++++++++++++++++++++---------------------- 1 file changed, 76 insertions(+), 70 deletions(-) diff --git a/src/notification_service.c b/src/notification_service.c index cb5ff3a..9ab23f7 100755 --- a/src/notification_service.c +++ b/src/notification_service.c @@ -957,115 +957,129 @@ int notification_get_setting_array(GVariant *parameters, GVariant **reply_body, return ret; } -static bool __init_setting_handle_by_app_id(const char *app_id, notification_setting_h *setting, uid_t uid) +static pkgmgrinfo_pkginfo_h __create_pkginfo_by_app_id(const char *app_id, uid_t uid) { - bool ret = false; int ret_pkgmgr; char *pkgname = NULL; - notification_setting_h ret_setting = NULL; - pkgmgrinfo_appinfo_h handle = NULL; + pkgmgrinfo_appinfo_h app_handle = NULL; + pkgmgrinfo_pkginfo_h pkg_handle = NULL; - if (app_id == NULL || setting == NULL) - return false; + if (app_id == NULL) + return NULL; - ret_pkgmgr = pkgmgrinfo_appinfo_get_appinfo(app_id, &handle); + ret_pkgmgr = pkgmgrinfo_appinfo_get_usr_appinfo(app_id, uid, &app_handle); if (ret_pkgmgr != PMINFO_R_OK) { - ERR("Failed to pkgmgrinfo_appinfo_get_appinfo [%s][%d]", app_id, ret); + ERR("Failed to pkgmgrinfo_appinfo_get_appinfo [%s][%d]", + app_id, ret_pkgmgr); goto out; } - ret_pkgmgr = pkgmgrinfo_appinfo_get_pkgname(handle, &pkgname); + ret_pkgmgr = pkgmgrinfo_appinfo_get_pkgname(app_handle, &pkgname); if (ret_pkgmgr != PMINFO_R_OK) { - ERR("Failed to pkgmgrinfo_appinfo_get_pkgname [%s][%d]", app_id, ret); + ERR("Failed to pkgmgrinfo_appinfo_get_pkgname [%s][%d]", + app_id, ret_pkgmgr); goto out; } - ret_setting = (struct notification_setting *)malloc(sizeof(struct notification_setting)); - if (ret_setting == NULL) { - ERR("Failed to alloc memory"); + ret_pkgmgr = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgname, uid, &pkg_handle); + if (ret_pkgmgr != PMINFO_R_OK) { + ERR("Failed to pkgmgrinfo_appinfo_get_pkginfo [%s][%d]", + app_id, ret_pkgmgr); goto out; } - ret_setting->package_name = strdup(pkgname); - ret_setting->app_id = strdup(app_id); - ret_setting->allow_to_notify = 1; - ret_setting->do_not_disturb_except = 0; - ret_setting->visibility_class = 0; - ret_setting->pop_up_notification = 1; - ret_setting->lock_screen_content_level = 0; - ret_setting->app_disabled = 0; - - *setting = ret_setting; - ret = true; - out: - if (handle) - pkgmgrinfo_appinfo_destroy_appinfo(handle); + if (app_handle) + pkgmgrinfo_appinfo_destroy_appinfo(app_handle); - return ret; + return pkg_handle; } #define NOTIFICATION_PRIVILEGE "http://tizen.org/privilege/notification" -static int privilege_cb(const char *privilege_name, void *is_checked) +static int __check_privilege_cb(const char *privilege_name, void *is_existed) { if (!g_strcmp0(privilege_name, NOTIFICATION_PRIVILEGE)) { - *(int *)is_checked = 1; + *(int *)is_existed = 1; return -1; } return 0; } -static int __check_app_has_privilege(const char *app_id, uid_t uid) +static int __has_notification_privilege(pkgmgrinfo_pkginfo_h handle) +{ + int ret_pkgmgr; + int is_existed = 0; + + ret_pkgmgr = pkgmgrinfo_pkginfo_foreach_privilege(handle, __check_privilege_cb, &is_existed); + if (ret_pkgmgr != PMINFO_R_OK) { + ERR("Failed to pkgmgrinfo_foreach_privilege [%d]", + ret_pkgmgr); + return NOTIFICATION_ERROR_IO_ERROR; + } + + if (is_existed == 0) + return NOTIFICATION_ERROR_NOT_EXIST_ID; + + return NOTIFICATION_ERROR_NONE; +} + +static int __init_setting_handle_by_app_id(const char *app_id, + notification_setting_h *setting, uid_t uid) { int ret = NOTIFICATION_ERROR_NONE; - int err; - int is_checked = 0; + int ret_pkgmgr; char *pkgname = NULL; - pkgmgrinfo_appinfo_h app_handle = NULL; - pkgmgrinfo_pkginfo_h pkg_handle = NULL; + notification_setting_h ret_setting = NULL; + pkgmgrinfo_pkginfo_h handle = NULL; - err = pkgmgrinfo_appinfo_get_usr_appinfo(app_id, uid, &app_handle); - if (err != PMINFO_R_OK) { - ERR("failed to get app info [%s][%d]", app_id, uid); + if (app_id == NULL || setting == NULL) + return NOTIFICATION_ERROR_INVALID_PARAMETER; + + handle = __create_pkginfo_by_app_id(app_id, uid); + if (handle == NULL) { + ERR("Failed to create pkginfo by app_id [%s]", app_id); ret = NOTIFICATION_ERROR_IO_ERROR; goto out; } - err = pkgmgrinfo_appinfo_get_pkgname(app_handle, &pkgname); - if (err != PMINFO_R_OK) { - ERR("failed to get pkgname [%s][%d]", app_id); - ret = NOTIFICATION_ERROR_IO_ERROR; + ret = __has_notification_privilege(handle); + if (ret != NOTIFICATION_ERROR_NONE) { + if (ret == NOTIFICATION_ERROR_NOT_EXIST_ID) + DBG("No notification privilege [%s]", app_id); + else + ERR("Failed to check privilege [%d]", ret); goto out; } - err = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgname, uid, &pkg_handle); - if (err != PMINFO_R_OK) { - ERR("failed to get pkg info [%s][%d]", pkgname, uid); + ret_pkgmgr = pkgmgrinfo_pkginfo_get_pkgname(handle, &pkgname); + if (ret_pkgmgr != PMINFO_R_OK) { + ERR("Failed to get pkgname from pkginfo [%d]", ret_pkgmgr); ret = NOTIFICATION_ERROR_IO_ERROR; goto out; } - err = pkgmgrinfo_pkginfo_foreach_privilege(pkg_handle, privilege_cb, &is_checked); - if (err != PMINFO_R_OK) { - ERR("failed to foreach privilege_cb", pkgname, uid); - ret = NOTIFICATION_ERROR_IO_ERROR; + ret_setting = (struct notification_setting *)malloc(sizeof(struct notification_setting)); + if (ret_setting == NULL) { + ERR("Failed to alloc memory"); + ret = NOTIFICATION_ERROR_OUT_OF_MEMORY; goto out; } - DBG("[%s] %s notification privilege", app_id, - is_checked == 1 ? "has" : "hasn't"); + ret_setting->package_name = strdup(pkgname); + ret_setting->app_id = strdup(app_id); + ret_setting->allow_to_notify = 1; + ret_setting->do_not_disturb_except = 0; + ret_setting->visibility_class = 0; + ret_setting->pop_up_notification = 1; + ret_setting->lock_screen_content_level = 0; + ret_setting->app_disabled = 0; - if (is_checked == 1) - ret = NOTIFICATION_ERROR_NONE; - else - ret = NOTIFICATION_ERROR_NOT_EXIST_ID; + *setting = ret_setting; out: - if (app_handle) - pkgmgrinfo_appinfo_destroy_appinfo(app_handle); - if (pkg_handle) - pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle); + if (handle) + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); return ret; } @@ -1073,7 +1087,6 @@ out: /* get_setting_by_app_id */ int notification_get_setting_by_app_id(GVariant *parameters, GVariant **reply_body, uid_t uid) { - bool err; int ret; GVariant *body; char *app_id = NULL; @@ -1085,18 +1098,11 @@ int notification_get_setting_by_app_id(GVariant *parameters, GVariant **reply_bo if (ret != NOTIFICATION_ERROR_NONE) return ret; - ret = __check_app_has_privilege(app_id, param_uid); - if (ret != NOTIFICATION_ERROR_NONE) { - ERR("app id[%s] err[%d]", app_id, ret); - return ret; - } - ret = noti_setting_service_get_setting_by_app_id(app_id, &setting, param_uid); if (ret == NOTIFICATION_ERROR_NOT_EXIST_ID) { - err = __init_setting_handle_by_app_id(app_id, &setting, param_uid); - if (err == false) - return NOTIFICATION_ERROR_IO_ERROR; - ret = NOTIFICATION_ERROR_NONE; + ret = __init_setting_handle_by_app_id(app_id, &setting, param_uid); + if (ret != NOTIFICATION_ERROR_NONE) + return ret; } else if (ret != NOTIFICATION_ERROR_NONE) { return ret; } -- 2.7.4 From 6c7d0530dfc51db39e05753c5a24e4cce3a9b5a6 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Tue, 29 Aug 2017 13:50:58 +0900 Subject: [PATCH 09/16] Release version 1.4.22 Changes: - Add parameter for notification_launch_default_viewer - Refactor logic to check privilege Signed-off-by: Seungha Son Change-Id: I4c7205ac71a734d52d762fee025ab62e39f1927f --- packaging/data-provider-master.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/data-provider-master.spec b/packaging/data-provider-master.spec index 08a0923..c8cef2a 100755 --- a/packaging/data-provider-master.spec +++ b/packaging/data-provider-master.spec @@ -2,7 +2,7 @@ Name: data-provider-master Summary: Master service provider for badge, shortcut, notification -Version: 1.4.21 +Version: 1.4.22 Release: 1 Group: Applications/Core Applications License: Apache-2.0 -- 2.7.4 From be55ff5970c942d520ec1682d4e9b00bbd330b5b Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Wed, 30 Aug 2017 22:32:40 +0900 Subject: [PATCH 10/16] Adjust coding rule Signed-off-by: Seungha Son Change-Id: Ib279e779319b5b55d5660743228a7e9cdcf68ddd --- src/shortcut_service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shortcut_service.c b/src/shortcut_service.c index d94c9b3..904a3b3 100755 --- a/src/shortcut_service.c +++ b/src/shortcut_service.c @@ -267,7 +267,7 @@ static void _remove_invocation(char *request_id) } /* add_shortcut */ -void shortcut_add(GVariant *parameters, GDBusMethodInvocation *invocation, uid_t uid) +void shortcut_add(GVariant *parameters, GDBusMethodInvocation *invocation, uid_t uid) { int ret = SERVICE_COMMON_ERROR_NONE; char *request_id = NULL; -- 2.7.4 From afa8beb25a13deb4dbbeb068c4a77f4a84cbfd85 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Wed, 30 Aug 2017 22:31:16 +0900 Subject: [PATCH 11/16] Remove unnecessary variable Signed-off-by: Seungha Son Change-Id: I3ef5c3e24f713198baad473a00c0a14b0af10358 --- src/badge_service.c | 4 +--- src/notification_service.c | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/badge_service.c b/src/badge_service.c index 55f18e7..f6ff37c 100755 --- a/src/badge_service.c +++ b/src/badge_service.c @@ -203,8 +203,6 @@ int badge_register_dbus_interface() static int _validate_and_set_param_uid_with_uid(uid_t uid, uid_t *param_uid) { - int ret = BADGE_ERROR_NONE; - if (uid > NORMAL_UID_BASE && uid != *param_uid) { ERR("Invalid sender uid[%d] param_uid[%d]", uid, *param_uid); return BADGE_ERROR_INVALID_PARAMETER; @@ -215,7 +213,7 @@ static int _validate_and_set_param_uid_with_uid(uid_t uid, uid_t *param_uid) *param_uid = tzplatform_getuid(TZ_SYS_DEFAULT_USER); } } - return ret; + return BADGE_ERROR_NONE; } static void _release_badge_info(gpointer data) diff --git a/src/notification_service.c b/src/notification_service.c index 9ab23f7..57dca7a 100755 --- a/src/notification_service.c +++ b/src/notification_service.c @@ -519,7 +519,6 @@ static int _validate_and_set_noti_with_uid(uid_t uid, notification_h noti, uid_t static int _validate_and_set_param_uid_with_uid(uid_t uid, uid_t *param_uid) { - int ret = NOTIFICATION_ERROR_NONE; if (uid > NORMAL_UID_BASE && uid != *param_uid) { ERR("invalid seder uid[%d], param_uid[%d]", uid, *param_uid); return NOTIFICATION_ERROR_INVALID_PARAMETER; @@ -534,7 +533,7 @@ static int _validate_and_set_param_uid_with_uid(uid_t uid, uid_t *param_uid) *param_uid = tzplatform_getuid(TZ_SYS_DEFAULT_USER); } } - return ret; + return NOTIFICATION_ERROR_NONE; } static void __sender_name_appeared_cb(GDBusConnection *connection, -- 2.7.4 From 20d9f757c5e6812004d48f08edcc27446e9472af Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Fri, 1 Sep 2017 11:20:10 +0900 Subject: [PATCH 12/16] Add logic to create shortcut db Related changes: shortcut : https://review.tizen.org/gerrit/#/c/147092/ Signed-off-by: Seungha Son Change-Id: I8484569ce5c8519ddd43c5ceb77fdd3255e767db --- src/shortcut_service.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/shortcut_service.c b/src/shortcut_service.c index 904a3b3..e74ae5b 100755 --- a/src/shortcut_service.c +++ b/src/shortcut_service.c @@ -362,6 +362,12 @@ HAPI int shortcut_service_init(void) _monitoring_hash = g_hash_table_new(g_direct_hash, g_direct_equal); _invocation_hash = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL); + result = shortcut_db_init(); + if (result != SHORTCUT_ERROR_NONE) { + ERR("Failed to init DB[%d]", result); + return result; + } + result = shortcut_register_dbus_interface(); if (result != SERVICE_COMMON_ERROR_NONE) { ERR("Failed to register dbus interface [%d]", result); -- 2.7.4 From 3da9baf780d4b40a699e5638721c9a62cbc8dffa Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Tue, 5 Sep 2017 10:31:19 +0900 Subject: [PATCH 13/16] Release version 1.4.23 Changes: - Adjust coding rule - Remove unnecessary variable - Add logic to create shortcut db Signed-off-by: Seungha Son Change-Id: I118bfd04cff54447eba1e50804e5cec7cc44cff6 --- packaging/data-provider-master.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/data-provider-master.spec b/packaging/data-provider-master.spec index c8cef2a..4bef68e 100755 --- a/packaging/data-provider-master.spec +++ b/packaging/data-provider-master.spec @@ -2,7 +2,7 @@ Name: data-provider-master Summary: Master service provider for badge, shortcut, notification -Version: 1.4.22 +Version: 1.4.23 Release: 1 Group: Applications/Core Applications License: Apache-2.0 -- 2.7.4 From 5fafb28e3a7cb051b2e9ffce8748fd7a7f7b77ae Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Fri, 22 Sep 2017 13:42:25 +0900 Subject: [PATCH 14/16] Fix coding rule else should follow close brace '}' Signed-off-by: Seungha Son Change-Id: Id37d55f0c460c9bc9366a90caf234e4decef7a44 --- src/badge_service.c | 3 +- src/notification_service.c | 78 ++++++++++++++++------------------------------ 2 files changed, 27 insertions(+), 54 deletions(-) diff --git a/src/badge_service.c b/src/badge_service.c index f6ff37c..59f0798 100755 --- a/src/badge_service.c +++ b/src/badge_service.c @@ -613,8 +613,7 @@ int badge_get_display_option(GVariant *parameters, GVariant **reply_body, const if (pkgname != NULL) { ret = badge_db_get_display_option(pkgname, &is_display, param_uid); - } - else { + } else { ERR("Invalid pkgname"); return BADGE_ERROR_INVALID_PARAMETER; } diff --git a/src/notification_service.c b/src/notification_service.c index 57dca7a..ebbb076 100755 --- a/src/notification_service.c +++ b/src/notification_service.c @@ -124,82 +124,57 @@ static void _noti_dbus_method_call_handler(GDBusConnection *conn, _on_name_appeared, _on_name_vanished, &_monitoring_hash, uid); if (ret == NOTIFICATION_ERROR_NONE) notification_add_private_sharing_target_id(pid, sender, uid); - } - else if (g_strcmp0(method_name, "update_noti") == 0) { + } else if (g_strcmp0(method_name, "update_noti") == 0) { ret = notification_update_noti(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "add_noti") == 0) { + } else if (g_strcmp0(method_name, "add_noti") == 0) { ret = notification_add_noti(parameters, &reply_body, sender, uid); - } - else if (g_strcmp0(method_name, "refresh_noti") == 0) { + } else if (g_strcmp0(method_name, "refresh_noti") == 0) { ret = notification_refresh_noti(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "del_noti_single") == 0) { + } else if (g_strcmp0(method_name, "del_noti_single") == 0) { ret = notification_del_noti_single(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "del_noti_multiple") == 0) { + } else if (g_strcmp0(method_name, "del_noti_multiple") == 0) { ret = notification_del_noti_multiple(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "get_noti_count") == 0) { + } else if (g_strcmp0(method_name, "get_noti_count") == 0) { ret = notification_get_noti_count(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "update_noti_setting") == 0) { + } else if (g_strcmp0(method_name, "update_noti_setting") == 0) { ret = notification_update_noti_setting(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "update_noti_sys_setting") == 0) { + } else if (g_strcmp0(method_name, "update_noti_sys_setting") == 0) { ret = notification_update_noti_sys_setting(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "load_noti_by_tag") == 0) { + } else if (g_strcmp0(method_name, "load_noti_by_tag") == 0) { ret = notification_load_noti_by_tag(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "load_noti_by_priv_id") == 0) { + } else if (g_strcmp0(method_name, "load_noti_by_priv_id") == 0) { ret = notification_load_noti_by_priv_id(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "load_noti_grouping_list") == 0) { + } else if (g_strcmp0(method_name, "load_noti_grouping_list") == 0) { notification_add_private_sharing_target_id(pid, sender, uid); ret = notification_load_grouping_list(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "load_noti_detail_list") == 0) { + } else if (g_strcmp0(method_name, "load_noti_detail_list") == 0) { notification_add_private_sharing_target_id(pid, sender, uid); ret = notification_load_detail_list(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "get_setting_array") == 0) { + } else if (g_strcmp0(method_name, "get_setting_array") == 0) { ret = notification_get_setting_array(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "get_setting_by_app_id") == 0) { + } else if (g_strcmp0(method_name, "get_setting_by_app_id") == 0) { ret = notification_get_setting_by_app_id(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "load_system_setting") == 0) { + } else if (g_strcmp0(method_name, "load_system_setting") == 0) { ret = notification_load_system_setting(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "save_as_template") == 0) { + } else if (g_strcmp0(method_name, "save_as_template") == 0) { ret = notification_add_noti_template(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "create_from_template") == 0) { + } else if (g_strcmp0(method_name, "create_from_template") == 0) { ret = notification_get_noti_template(parameters, &reply_body, pid, uid); - } - else if (g_strcmp0(method_name, "create_from_package_template") == 0) { + } else if (g_strcmp0(method_name, "create_from_package_template") == 0) { ret = notification_get_noti_package_template(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "get_noti_block_state") == 0) { + } else if (g_strcmp0(method_name, "get_noti_block_state") == 0) { ret = notification_get_block_state(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "load_dnd_allow_exception") == 0) { + } else if (g_strcmp0(method_name, "load_dnd_allow_exception") == 0) { ret = notification_load_dnd_allow_exception(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "update_dnd_allow_exception") == 0) { + } else if (g_strcmp0(method_name, "update_dnd_allow_exception") == 0) { ret = notification_update_dnd_allow_exception(parameters, &reply_body, uid); - } - else if (g_strcmp0(method_name, "send_noti_event") == 0) { + } else if (g_strcmp0(method_name, "send_noti_event") == 0) { ret = notification_send_noti_event(parameters, &reply_body); - } - else if (g_strcmp0(method_name, "send_noti_event_by_priv_id") == 0) { + } else if (g_strcmp0(method_name, "send_noti_event_by_priv_id") == 0) { ret = notification_send_noti_event_by_priv_id(parameters, &reply_body); - } - else if (g_strcmp0(method_name, "check_event_receiver") == 0) { + } else if (g_strcmp0(method_name, "check_event_receiver") == 0) { ret = notification_check_event_receiver(parameters, &reply_body); - } - else if (g_strcmp0(method_name, "reset_event_handler") == 0) { + } else if (g_strcmp0(method_name, "reset_event_handler") == 0) { ret = notification_reset_event_receiver(parameters, &reply_body, sender); } @@ -997,8 +972,7 @@ out: #define NOTIFICATION_PRIVILEGE "http://tizen.org/privilege/notification" static int __check_privilege_cb(const char *privilege_name, void *is_existed) { - if (!g_strcmp0(privilege_name, NOTIFICATION_PRIVILEGE)) - { + if (!g_strcmp0(privilege_name, NOTIFICATION_PRIVILEGE)) { *(int *)is_existed = 1; return -1; } -- 2.7.4 From 6114ebdb4f82f2e0e5c4f4e20aeb81d9e0ad3e17 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Fri, 22 Sep 2017 13:33:09 +0900 Subject: [PATCH 15/16] Change setting db initailization point Signed-off-by: Seungha Son Change-Id: Id6a3a010e70a265bc77f507c92c4a012a143d7a6 --- src/badge_service.c | 47 ++++++++++++++-------------------------------- src/notification_service.c | 27 +++++++++----------------- src/service_common.c | 9 ++++----- 3 files changed, 27 insertions(+), 56 deletions(-) diff --git a/src/badge_service.c b/src/badge_service.c index 59f0798..a4e6287 100755 --- a/src/badge_service.c +++ b/src/badge_service.c @@ -32,8 +32,6 @@ #define PROVIDER_BADGE_INTERFACE_NAME "org.tizen.data_provider_badge_service" static GHashTable *_monitoring_hash = NULL; -int need_to_reload_pkginfo_for_badge = 1; - static void _on_name_appeared(GDBusConnection *connection, const gchar *name, const gchar *name_owner, @@ -240,15 +238,10 @@ int badge_get_badge_existing(GVariant *parameters, GVariant **reply_body, uid_t if (ret != BADGE_ERROR_NONE) return ret; - if (pkgname != NULL) { - if (need_to_reload_pkginfo_for_badge) { - badge_setting_refresh_setting_table(tzplatform_getuid(TZ_SYS_DEFAULT_USER)); - need_to_reload_pkginfo_for_badge = 0; - } + if (pkgname != NULL) ret = badge_db_is_existing(pkgname, &existing, param_uid); - } else { + else return BADGE_ERROR_INVALID_PARAMETER; - } if (ret != BADGE_ERROR_NONE) { ERR("Failed to get badge existing :%d", ret); @@ -328,15 +321,10 @@ int badge_insert(GVariant *parameters, GVariant **reply_body, uid_t uid) if (ret != BADGE_ERROR_NONE) return ret; - if (pkgname != NULL && writable_pkg != NULL && caller != NULL) { - if (need_to_reload_pkginfo_for_badge) { - badge_setting_refresh_setting_table(tzplatform_getuid(TZ_SYS_DEFAULT_USER)); - need_to_reload_pkginfo_for_badge = 0; - } + if (pkgname != NULL && writable_pkg != NULL && caller != NULL) ret = badge_db_insert(pkgname, writable_pkg, caller, param_uid); - } else { + else return BADGE_ERROR_INVALID_PARAMETER; - } if (ret != BADGE_ERROR_NONE) { ERR("Failed to insert badge [%d]", ret); @@ -443,15 +431,10 @@ int badge_set_badge_count(GVariant *parameters, GVariant **reply_body, uid_t uid if (ret != BADGE_ERROR_NONE) return ret; - if (pkgname != NULL && caller != NULL) { - if (need_to_reload_pkginfo_for_badge) { - badge_setting_refresh_setting_table(tzplatform_getuid(TZ_SYS_DEFAULT_USER)); - need_to_reload_pkginfo_for_badge = 0; - } + if (pkgname != NULL && caller != NULL) ret = badge_db_set_count(pkgname, caller, count, param_uid, pid); - } else { + else return BADGE_ERROR_INVALID_PARAMETER; - } if (ret != BADGE_ERROR_NONE) { ERR("Failed to set badge [%d]", ret); @@ -677,11 +660,6 @@ int badge_update_badge_setting(GVariant *parameters, GVariant **reply_body, uid_ char *pkgname = NULL; char *appid = NULL; - if (need_to_reload_pkginfo_for_badge) { - badge_setting_refresh_setting_table(tzplatform_getuid(TZ_SYS_DEFAULT_USER)); - need_to_reload_pkginfo_for_badge = 0; - } - g_variant_get(parameters, "(&s&sii)", &pkgname, &appid, &allow_to_display, ¶m_uid); ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid); @@ -730,11 +708,6 @@ int badge_get_setting_by_appid(GVariant *parameters, GVariant **reply_body, uid_ badge_setting_h setting = NULL; uid_t param_uid; - if (need_to_reload_pkginfo_for_badge) { - badge_setting_refresh_setting_table(tzplatform_getuid(TZ_SYS_DEFAULT_USER)); - need_to_reload_pkginfo_for_badge = 0; - } - g_variant_get(parameters, "(&si)", &appid, ¶m_uid); if (appid == NULL) return BADGE_ERROR_INVALID_PARAMETER; @@ -829,6 +802,13 @@ int badge_init_display(GVariant *parameters, GVariant **reply_body, uid_t uid) return ret; } +static gboolean __refresh_setting_table(gpointer data) +{ + badge_setting_refresh_setting_table( + tzplatform_getuid(TZ_SYS_DEFAULT_USER)); + return G_SOURCE_REMOVE; +} + /*! * MAIN THREAD * Do not try to do anyother operation in these functions @@ -850,6 +830,7 @@ HAPI int badge_service_init(void) return BADGE_ERROR_IO_ERROR; } + g_idle_add(__refresh_setting_table, NULL); return BADGE_ERROR_NONE; } diff --git a/src/notification_service.c b/src/notification_service.c index ebbb076..b901d92 100755 --- a/src/notification_service.c +++ b/src/notification_service.c @@ -20,7 +20,6 @@ #include #include #include - #include #include #include @@ -67,8 +66,6 @@ typedef struct _event_sender_info { guint watcher_id; } event_sender_info_s; -int need_to_reload_pkginfo_for_notification = 1; - /*! * SERVICE HANDLER */ @@ -890,11 +887,6 @@ int notification_get_setting_array(GVariant *parameters, GVariant **reply_body, notification_setting_h temp; uid_t param_uid; - if (need_to_reload_pkginfo_for_notification) { - notification_setting_refresh_setting_table(tzplatform_getuid(TZ_SYS_DEFAULT_USER)); - need_to_reload_pkginfo_for_notification = 0; - } - g_variant_get(parameters, "(i)", ¶m_uid); ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid); if (ret != NOTIFICATION_ERROR_NONE) @@ -1405,11 +1397,6 @@ int notification_update_noti_setting(GVariant *parameters, GVariant **reply_body int lock_screen_content_level = 0; uid_t param_uid; - if (need_to_reload_pkginfo_for_notification) { - notification_setting_refresh_setting_table(tzplatform_getuid(TZ_SYS_DEFAULT_USER)); - need_to_reload_pkginfo_for_notification = 0; - } - g_variant_get(parameters, "(&s&siiiiii)", &pkgname, &app_id, @@ -1919,11 +1906,6 @@ int notification_get_block_state(GVariant *parameters, GVariant **reply_body, ui return NOTIFICATION_ERROR_IO_ERROR; } - if (need_to_reload_pkginfo_for_notification) { - notification_setting_refresh_setting_table(tzplatform_getuid(TZ_SYS_DEFAULT_USER)); - need_to_reload_pkginfo_for_notification = 0; - } - ret = notification_get_dnd_and_allow_to_notify(app_id, &dnd, &dnd_except, &allow_to_notify, param_uid); INFO("app_id[%s] dnd[%d] dnd_except[%d] allow_to_notify[%d]", app_id, dnd, dnd_except, allow_to_notify); @@ -2358,6 +2340,13 @@ out: return ret; } +static gboolean __refresh_setting_table(gpointer data) +{ + notification_setting_refresh_setting_table( + tzplatform_getuid(TZ_SYS_DEFAULT_USER)); + return G_SOURCE_REMOVE; +} + /*! * MAIN THREAD * Do not try to do any other operation in these functions @@ -2396,6 +2385,8 @@ HAPI int notification_service_init(void) if (uids) free(uids); + g_idle_add(__refresh_setting_table, NULL); + DBG("Successfully initialized"); return NOTIFICATION_ERROR_NONE; } diff --git a/src/service_common.c b/src/service_common.c index cc92dcf..4edc640 100755 --- a/src/service_common.c +++ b/src/service_common.c @@ -44,9 +44,6 @@ static GDBusConnection *_gdbus_conn = NULL; -extern int need_to_reload_pkginfo_for_notification; -extern int need_to_reload_pkginfo_for_badge; - void print_noti(notification_h noti) { char *pkgname = NULL; @@ -441,8 +438,10 @@ out: static int _package_install_cb(uid_t uid, const char *pkgname, enum pkgmgr_status status, double value, void *data) { if (status == PKGMGR_STATUS_END) { - need_to_reload_pkginfo_for_notification = 1; - need_to_reload_pkginfo_for_badge = 1; + if (uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)) + uid = tzplatform_getuid(TZ_SYS_DEFAULT_USER); + notification_setting_insert_package_for_uid(pkgname, uid); + badge_setting_insert_package_for_uid(pkgname, uid); } return 0; -- 2.7.4 From 86af720661ce996e20a8415c1a431e8f5aec7754 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Fri, 22 Sep 2017 17:12:59 +0900 Subject: [PATCH 16/16] Release version 1.4.24 Changes: - Fix coding rule - Change setting db initailization point Signed-off-by: Seungha Son Change-Id: I05311231f2211144d2303771cdea687174b44820 --- packaging/data-provider-master.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/data-provider-master.spec b/packaging/data-provider-master.spec index 4bef68e..6b84f1a 100755 --- a/packaging/data-provider-master.spec +++ b/packaging/data-provider-master.spec @@ -2,7 +2,7 @@ Name: data-provider-master Summary: Master service provider for badge, shortcut, notification -Version: 1.4.23 +Version: 1.4.24 Release: 1 Group: Applications/Core Applications License: Apache-2.0 -- 2.7.4