From eb5390d462a99c6be12d77134827b1ebe1a53982 Mon Sep 17 00:00:00 2001 From: "seungha.son" Date: Mon, 20 Mar 2017 15:42:57 +0900 Subject: [PATCH 01/16] Release version 1.4.5 - Defer setting db refresh for notification,badge Signed-off-by: seungha.son Change-Id: I2bb4127594f73c28206e2e59e607423085fbd2fb --- 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 0f8f453..694b574 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.4 +Version: 1.4.5 Release: 1 Group: Applications/Core Applications License: Apache-2.0 -- 2.7.4 From e1dd22153c9feca2fb3a04115b0839e57d391762 Mon Sep 17 00:00:00 2001 From: "seungha.son" Date: Tue, 21 Mar 2017 10:41:13 +0900 Subject: [PATCH 02/16] Add logic to send event by priv id Signed-off-by: seungha.son Change-Id: Icdf38b62c582b543a65eb0d72562bbdaa8a02523 --- include/notification_service.h | 1 + src/notification_service.c | 76 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/include/notification_service.h b/include/notification_service.h index d7bb89b..d2cd57f 100755 --- a/include/notification_service.h +++ b/include/notification_service.h @@ -43,6 +43,7 @@ int notification_get_block_state(GVariant *parameters, GVariant **reply_body, ui int notification_load_dnd_allow_exception(GVariant *parameters, GVariant **reply_body, uid_t uid); int notification_update_dnd_allow_exception(GVariant *parameters, GVariant **reply_body, uid_t uid); int notification_send_noti_event(GVariant *parameters, GVariant **reply_body); +int notification_send_noti_event_by_priv_id(GVariant *parameters, GVariant **reply_body); int notification_check_event_receiver(GVariant *parameters, GVariant **reply_body); int notification_reset_event_receiver(GVariant *parameters, GVariant **reply_body, const char *sender); int notification_register_dbus_interface(); diff --git a/src/notification_service.c b/src/notification_service.c index 68f9267..eff5676 100755 --- a/src/notification_service.c +++ b/src/notification_service.c @@ -161,6 +161,8 @@ static void _noti_dbus_method_call_handler(GDBusConnection *conn, ret = notification_update_dnd_allow_exception(parameters, &reply_body, uid); 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) + ret = notification_send_noti_event_by_priv_id(parameters, &reply_body); 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) @@ -342,6 +344,11 @@ int notification_register_dbus_interface() " " " " + " " + " " + " " + " " + " " " " " " @@ -752,7 +759,7 @@ int notification_load_noti_by_priv_id(GVariant *parameters, GVariant **reply_bod return ret; DbgPrint("load_noti_by_priv_id pkgname : %s, priv_id : %d ", pkgname, priv_id); - ret = notification_noti_get_by_priv_id(noti, pkgname, priv_id, param_uid); + ret = notification_noti_get_by_priv_id(noti, priv_id); DbgPrint("notification_noti_get_by_priv_id ret : %d", ret); print_noti(noti); @@ -1911,6 +1918,73 @@ int notification_send_noti_event(GVariant *parameters, GVariant **reply_body) return ret; } +int notification_send_noti_event_by_priv_id(GVariant *parameters, GVariant **reply_body) +{ + int ret; + int event_type; + int priv_id; + bool event_flag = false; + notification_h noti; + GVariant *body = NULL; + event_sender_info_s *info; + + noti = notification_create(NOTIFICATION_TYPE_NOTI); + if (noti != NULL) { + g_variant_get(parameters, "(ii)", &priv_id, &event_type); + + ret = notification_noti_get_by_priv_id(noti, priv_id); + if (ret != NOTIFICATION_ERROR_NONE) { + ErrPrint("failed to get notification by priv id [%d]", ret); + notification_free(noti); + return ret; + } + + ret = notification_get_event_flag(noti, &event_flag); + if (ret != NOTIFICATION_ERROR_NONE || event_flag == false) { + notification_free(noti); + return NOTIFICATION_ERROR_INVALID_PARAMETER; + } + + info = __find_sender_info_by_priv_id(priv_id); + if (info == NULL || info->busname == NULL) { + notification_free(noti); + return NOTIFICATION_ERROR_INVALID_PARAMETER; + } + + if (!info->watcher_id) { + if (!is_existed_busname(info->busname)) { + __event_list = g_list_remove(g_list_first(__event_list), info); + __free_event_info(info); + notification_free(noti); + return NOTIFICATION_ERROR_IO_ERROR; + } else { + info->watcher_id = __insert_sender_watcher_id(info); + } + } + + body = notification_ipc_make_gvariant_from_noti(noti, false); + if (body == NULL) { + ErrPrint("Can't make gvariant to noti"); + notification_free(noti); + return NOTIFICATION_ERROR_OUT_OF_MEMORY; + } + + ret = send_event_notify_by_busname(g_variant_new("(vi)", body, event_type), "send_event", info->busname, PROVIDER_NOTI_EVENT_INTERFACE_NAME); + notification_free(noti); + } else { + return NOTIFICATION_ERROR_OUT_OF_MEMORY; + } + + *reply_body = g_variant_new("()"); + if (*reply_body == NULL) { + ErrPrint("cannot make reply body"); + return NOTIFICATION_ERROR_OUT_OF_MEMORY; + } + + DbgPrint("notification_send_noti_event_by_priv_id done !! %d", ret); + return ret; +} + int notification_check_event_receiver(GVariant *parameters, GVariant **reply_body) { int priv_id; -- 2.7.4 From 263334a92dab57102677b599aebff27760fcd757 Mon Sep 17 00:00:00 2001 From: "seungha.son" Date: Wed, 22 Mar 2017 18:05:06 +0900 Subject: [PATCH 03/16] Release version 1.4.6 - Add logic to send event by priv id Signed-off-by: seungha.son Change-Id: Ida65dc8b9b6ac5759735e228b560133a1ea63811 --- 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 694b574..7f8a06b 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.5 +Version: 1.4.6 Release: 1 Group: Applications/Core Applications License: Apache-2.0 -- 2.7.4 From f3da5105105d6ffbc489b431a50d12780ddc2e32 Mon Sep 17 00:00:00 2001 From: "seungha.son" Date: Thu, 23 Mar 2017 10:41:30 +0900 Subject: [PATCH 04/16] Use license macro Signed-off-by: seungha.son Change-Id: Iab3097e7710c78ab1217e9e80927eececfd4f095 --- packaging/data-provider-master.spec | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packaging/data-provider-master.spec b/packaging/data-provider-master.spec index 7f8a06b..66c3146 100755 --- a/packaging/data-provider-master.spec +++ b/packaging/data-provider-master.spec @@ -59,7 +59,6 @@ CFLAGS="${CFLAGS} -Wall -Winline -Werror" LDFLAGS="${LDFLAGS}" make %{?jobs:-j%j %install rm -rf %{buildroot} %make_install -mkdir -p %{buildroot}/%{_datarootdir}/license mkdir -p %{buildroot}%{_prefix}/lib/systemd/system/multi-user.target.wants install -m 0644 %SOURCE1 %{buildroot}%{_unitdir}/data-provider-master.service ln -sf ../%{name}.service %{buildroot}%{_prefix}/lib/systemd/system/multi-user.target.wants/%{name}.service @@ -67,7 +66,7 @@ ln -sf ../%{name}.service %{buildroot}%{_prefix}/lib/systemd/system/multi-user.t %files %manifest %{name}.manifest %defattr(-,root,root,-) - +%license LICENSE %attr(0755,root,root) %{_bindir}/data-provider-master %attr(0644,root,root) %{_unitdir}/data-provider-master.service %{_unitdir}/multi-user.target.wants/data-provider-master.service -- 2.7.4 From b9d5cd86cca000712ed2282a827fa08924e8b0f2 Mon Sep 17 00:00:00 2001 From: "seungha.son" Date: Thu, 23 Mar 2017 15:04:47 +0900 Subject: [PATCH 05/16] Release version 1.4.7 - Use license macro Signed-off-by: seungha.son Change-Id: I973cfaea310565eaa8ffc5518d2f72d3bd021314 --- 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 66c3146..9acf38b 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.6 +Version: 1.4.7 Release: 1 Group: Applications/Core Applications License: Apache-2.0 -- 2.7.4 From 4a293817324407ad4d652860b3ca9a6147652f9c Mon Sep 17 00:00:00 2001 From: "seungha.son" Date: Tue, 4 Apr 2017 13:42:56 +0900 Subject: [PATCH 06/16] Add function call for remove badge data when package is unintalled Signed-off-by: seungha.son Change-Id: Id0322ba4a5563de6dc44a7a1723626ae0153b081 --- src/badge_service.c | 32 ++++++++++++++++++++++---------- src/service_common.c | 2 ++ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/badge_service.c b/src/badge_service.c index 8296fb5..24d01c1 100755 --- a/src/badge_service.c +++ b/src/badge_service.c @@ -241,10 +241,15 @@ int badge_get_badge_existing(GVariant *parameters, GVariant **reply_body, uid_t if (ret != BADGE_ERROR_NONE) return ret; - if (pkgname != NULL) + 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; + } ret = badge_db_is_existing(pkgname, &existing, param_uid); - else + } else { return BADGE_ERROR_INVALID_PARAMETER; + } if (ret != BADGE_ERROR_NONE) { ErrPrint("failed to get badge existing :%d\n", ret); @@ -321,20 +326,22 @@ 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 (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; + } ret = badge_db_insert(pkgname, writable_pkg, caller, param_uid); - else + } else { return BADGE_ERROR_INVALID_PARAMETER; + } if (ret != BADGE_ERROR_NONE) { ErrPrint("failed to insert badge :%d\n", ret); return ret; } - 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; - } + ret = badge_db_get_allow_to_display_by_appid(pkgname, &allow_to_display, param_uid); if (ret != BADGE_ERROR_NONE) { @@ -437,10 +444,15 @@ 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 (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; + } ret = badge_db_set_count(pkgname, caller, count, param_uid); - else + } else { return BADGE_ERROR_INVALID_PARAMETER; + } if (ret != BADGE_ERROR_NONE) { ErrPrint("failed to set badge :%d\n", ret); diff --git a/src/service_common.c b/src/service_common.c index ff7efe5..e57e89a 100755 --- a/src/service_common.c +++ b/src/service_common.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -462,6 +463,7 @@ static int _package_uninstall_cb(uid_t uid, const char *pkgname, enum pkgmgr_sta if (uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)) uid = tzplatform_getuid(TZ_SYS_DEFAULT_USER); notification_setting_delete_package_for_uid(pkgname, uid); + badge_db_delete_by_pkgname(pkgname, uid); badge_setting_delete_package_for_uid(pkgname, uid); notification_noti_delete_template(pkgname); } -- 2.7.4 From 6b0cbd96fd22fdc8da7ed2bd8703c36dc5ccb774 Mon Sep 17 00:00:00 2001 From: "seungha.son" Date: Wed, 5 Apr 2017 10:54:56 +0900 Subject: [PATCH 07/16] Release version 1.4.8 - Add function call for remove badge data when package is unintalled Signed-off-by: seungha.son Change-Id: I025ba81b09d1ed9c61519f09673ed1c640e4f0be --- 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 9acf38b..71812ba 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.7 +Version: 1.4.8 Release: 1 Group: Applications/Core Applications License: Apache-2.0 -- 2.7.4 From 873e8105418ee28a31a4c36e3a57e91ae0f390c0 Mon Sep 17 00:00:00 2001 From: Myungki Lee Date: Tue, 11 Apr 2017 15:16:40 +0900 Subject: [PATCH 08/16] Use license macro Change-Id: Ieb7c670783c9f3f13af63d2cd7db7e10c1294b84 Signed-off-by: Myungki Lee --- CMakeLists.txt | 1 - packaging/data-provider-master.spec | 1 - 2 files changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a2e5130..b8e3278 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,6 @@ ADD_EXECUTABLE(${PROJECT_NAME} ${BUILD_SOURCE}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkg_LDFLAGS} "-ldl -lrt -pie") -INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME "${PROJECT_NAME}") INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) CONFIGURE_FILE(data-provider-master.conf.in data-provider-master.conf @ONLY) diff --git a/packaging/data-provider-master.spec b/packaging/data-provider-master.spec index 71812ba..7d3d711 100755 --- a/packaging/data-provider-master.spec +++ b/packaging/data-provider-master.spec @@ -73,7 +73,6 @@ ln -sf ../%{name}.service %{buildroot}%{_prefix}/lib/systemd/system/multi-user.t %attr(0644,root,root) %{_datadir}/dbus-1/system-services/org.tizen.data-provider-master.service %config %{_sysconfdir}/dbus-1/system.d/data-provider-master.conf %{_prefix}/bin/%{name} -%{_datarootdir}/license/* #%defattr(-,owner,users,-) # End of a file -- 2.7.4 From 5511c1678655b10153caf040dfd9de1a023e1b2f Mon Sep 17 00:00:00 2001 From: Myungki Lee Date: Tue, 11 Apr 2017 15:33:18 +0900 Subject: [PATCH 09/16] Release version 1.4.9 - Use license macro Change-Id: Ie3979362e9792b27b091c67698e1b6122f651a87 Signed-off-by: Myungki Lee --- 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 7d3d711..4bff4cf 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.8 +Version: 1.4.9 Release: 1 Group: Applications/Core Applications License: Apache-2.0 -- 2.7.4 From 083d0fe48a05492a251ad3eb2f4d7baff2750602 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Tue, 18 Apr 2017 09:54:18 +0900 Subject: [PATCH 10/16] Fix memory leak Signed-off-by: Seungha Son Change-Id: I43af1f0eb21e3057e78b42528ed466c5d1780951 Signed-off-by: jusung son --- src/notification_service.c | 170 +++++++++++++++++++++++++-------------------- 1 file changed, 96 insertions(+), 74 deletions(-) diff --git a/src/notification_service.c b/src/notification_service.c index eff5676..30fc09d 100755 --- a/src/notification_service.c +++ b/src/notification_service.c @@ -720,24 +720,29 @@ int notification_load_noti_by_tag(GVariant *parameters, GVariant **reply_body, u g_variant_get(parameters, "(&s&si)", &pkgname, &tag, ¶m_uid); ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid); if (ret != NOTIFICATION_ERROR_NONE) - return ret; + goto out; DbgPrint("_load_noti_by_tag pkgname : %s, tag : %s ", pkgname, tag); ret = notification_noti_get_by_tag(noti, pkgname, tag, param_uid); + if (ret != NOTIFICATION_ERROR_NONE) { + ErrPrint("There is no notification that is matched tag [%s]", tag); + goto out; + } - DbgPrint("notification_noti_get_by_tag ret : %d", ret); print_noti(noti); - *reply_body = notification_ipc_make_gvariant_from_noti(noti, true); - notification_free(noti); - if (*reply_body == NULL) { ErrPrint("cannot make reply_body"); - return NOTIFICATION_ERROR_OUT_OF_MEMORY; + ret = NOTIFICATION_ERROR_OUT_OF_MEMORY; } } else { ret = NOTIFICATION_ERROR_OUT_OF_MEMORY; } + +out: + if (noti) + notification_free(noti); + DbgPrint("_load_noti_by_tag done !!"); return ret; } @@ -756,26 +761,27 @@ int notification_load_noti_by_priv_id(GVariant *parameters, GVariant **reply_bod g_variant_get(parameters, "(&sii)", &pkgname, &priv_id, ¶m_uid); ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid); if (ret != NOTIFICATION_ERROR_NONE) - return ret; + goto out; DbgPrint("load_noti_by_priv_id pkgname : %s, priv_id : %d ", pkgname, priv_id); ret = notification_noti_get_by_priv_id(noti, priv_id); - - DbgPrint("notification_noti_get_by_priv_id ret : %d", ret); - print_noti(noti); + if (ret != NOTIFICATION_ERROR_NONE) + goto out; *reply_body = notification_ipc_make_gvariant_from_noti(noti, true); - notification_free(noti); - if (*reply_body == NULL) { ErrPrint("cannot make reply_body"); - return NOTIFICATION_ERROR_OUT_OF_MEMORY; + ret = NOTIFICATION_ERROR_OUT_OF_MEMORY; } } else { ret = NOTIFICATION_ERROR_OUT_OF_MEMORY; } - DbgPrint("_load_noti_by_priv_id done !!"); +out: + if (noti) + notification_free(noti); + + DbgPrint("notification_load_noti_by_priv_id done [%d]", ret); return ret; } @@ -1630,22 +1636,28 @@ int notification_add_noti_template(GVariant *parameters, GVariant **reply_body, g_variant_unref(body); if (ret != NOTIFICATION_ERROR_NONE) { ErrPrint("failed to make a notification:%d\n", ret); - return ret; + goto out; } ret = notification_noti_check_count_for_template(noti, &count); - if (count >= NOTI_TEMPLATE_LIMIT) - return NOTIFICATION_ERROR_MAX_EXCEEDED; + if (count >= NOTI_TEMPLATE_LIMIT) { + ErrPrint("Exceed limit value that is saved tamplate :%d\n", ret); + ret = NOTIFICATION_ERROR_MAX_EXCEEDED; + goto out; + } ret = notification_noti_add_template(noti, template_name); - if (ret != NOTIFICATION_ERROR_NONE) { + if (ret != NOTIFICATION_ERROR_NONE) ErrPrint("failed to add a notification:%d\n", ret); - return ret; - } } else { ret = NOTIFICATION_ERROR_OUT_OF_MEMORY; } +out: + if (noti) + notification_free(noti); + + DbgPrint("notification_add_noti_template is done [%d]", ret); return ret; } @@ -1663,27 +1675,30 @@ int notification_get_noti_template(GVariant *parameters, GVariant **reply_body, ret = aul_app_get_appid_bypid_for_uid(pid, appid, sizeof(appid), uid); if (ret != AUL_R_OK) { ErrPrint("failed to get appid:%d", ret); - return ret; + ret = NOTIFICATION_ERROR_INVALID_PARAMETER; + goto out; } ret = notification_noti_get_package_template(noti, appid, template_name); if (ret != NOTIFICATION_ERROR_NONE) { DbgPrint("failed to get template:%d", ret); - return ret; + goto out; } *reply_body = notification_ipc_make_gvariant_from_noti(noti, false); - notification_free(noti); - if (*reply_body == NULL) { ErrPrint("cannot make reply_body"); - return NOTIFICATION_ERROR_OUT_OF_MEMORY; + ret = NOTIFICATION_ERROR_OUT_OF_MEMORY; } } else { ret = NOTIFICATION_ERROR_OUT_OF_MEMORY; } - DbgPrint("_get_noti_template done !!"); +out: + if (noti) + notification_free(noti); + + DbgPrint("notification_get_noti_template is done [%d]", ret); return ret; } @@ -1700,23 +1715,24 @@ int notification_get_noti_package_template(GVariant *parameters, GVariant **repl ret = notification_noti_get_package_template(noti, pkgname, template_name); if (ret != NOTIFICATION_ERROR_NONE) { - DbgPrint("failed to get template:%d", ret); - return ret; + ErrPrint("failed to get template:%d", ret); + goto out; } *reply_body = notification_ipc_make_gvariant_from_noti(noti, false); - notification_free(noti); - if (*reply_body == NULL) { ErrPrint("cannot make reply_body"); - return NOTIFICATION_ERROR_OUT_OF_MEMORY; + ret = NOTIFICATION_ERROR_OUT_OF_MEMORY; } } else { ret = NOTIFICATION_ERROR_OUT_OF_MEMORY; } - DbgPrint("_get_noti_package_template done !!"); +out: + if (noti) + notification_free(noti); + DbgPrint("notification_get_noti_package_template is done [%d]", ret); return ret; } @@ -1868,53 +1884,60 @@ int notification_send_noti_event(GVariant *parameters, GVariant **reply_body) notification_h noti; noti = notification_create(NOTIFICATION_TYPE_NOTI); - if (noti != NULL) { g_variant_get(parameters, "(vi)", &coupled_body, &event_type); g_variant_get(coupled_body, "(v)", &body); ret = notification_ipc_make_noti_from_gvariant(noti, body); + g_variant_unref(coupled_body); + g_variant_unref(body); + if (ret != NOTIFICATION_ERROR_NONE) { ErrPrint("failed to make a notification from gvariant"); - return ret; + goto out; } - g_variant_unref(coupled_body); - g_variant_unref(body); - ret = notification_get_id(noti, NULL, &priv_id); if (ret != NOTIFICATION_ERROR_NONE) - return ret; + goto out; info = __find_sender_info_by_priv_id(priv_id); - if (info == NULL || info->busname == NULL) - return NOTIFICATION_ERROR_INVALID_PARAMETER; + if (info == NULL || info->busname == NULL) { + ret = NOTIFICATION_ERROR_INVALID_PARAMETER; + goto out; + } if (!info->watcher_id) { if (!is_existed_busname(info->busname)) { __event_list = g_list_remove(g_list_first(__event_list), info); __free_event_info(info); - return NOTIFICATION_ERROR_IO_ERROR; + ret = NOTIFICATION_ERROR_IO_ERROR; + goto out; } else { info->watcher_id = __insert_sender_watcher_id(info); } } ret = send_event_notify_by_busname(parameters, "send_event", info->busname, PROVIDER_NOTI_EVENT_INTERFACE_NAME); - notification_free(noti); + if (ret != NOTIFICATION_ERROR_NONE) { + ErrPrint("failed to send event"); + goto out; + } + *reply_body = g_variant_new("()"); + if (*reply_body == NULL) { + ErrPrint("cannot make reply body"); + ret = NOTIFICATION_ERROR_OUT_OF_MEMORY; + } } else { ret = NOTIFICATION_ERROR_OUT_OF_MEMORY; } - *reply_body = g_variant_new("()"); - if (*reply_body == NULL) { - ErrPrint("cannot make reply body"); - return NOTIFICATION_ERROR_OUT_OF_MEMORY; - } - - DbgPrint("notification_send_noti_event done !! %d", ret); +out: + if (noti) + notification_free(noti); + DbgPrint("notification_send_noti_event is done [%d]", ret); return ret; } @@ -1935,28 +1958,27 @@ int notification_send_noti_event_by_priv_id(GVariant *parameters, GVariant **rep ret = notification_noti_get_by_priv_id(noti, priv_id); if (ret != NOTIFICATION_ERROR_NONE) { ErrPrint("failed to get notification by priv id [%d]", ret); - notification_free(noti); - return ret; + goto out; } ret = notification_get_event_flag(noti, &event_flag); if (ret != NOTIFICATION_ERROR_NONE || event_flag == false) { - notification_free(noti); - return NOTIFICATION_ERROR_INVALID_PARAMETER; + ret = NOTIFICATION_ERROR_INVALID_PARAMETER; + goto out; } info = __find_sender_info_by_priv_id(priv_id); if (info == NULL || info->busname == NULL) { - notification_free(noti); - return NOTIFICATION_ERROR_INVALID_PARAMETER; + ret = NOTIFICATION_ERROR_INVALID_PARAMETER; + goto out; } if (!info->watcher_id) { if (!is_existed_busname(info->busname)) { __event_list = g_list_remove(g_list_first(__event_list), info); __free_event_info(info); - notification_free(noti); - return NOTIFICATION_ERROR_IO_ERROR; + ret = NOTIFICATION_ERROR_IO_ERROR; + goto out; } else { info->watcher_id = __insert_sender_watcher_id(info); } @@ -1965,23 +1987,25 @@ int notification_send_noti_event_by_priv_id(GVariant *parameters, GVariant **rep body = notification_ipc_make_gvariant_from_noti(noti, false); if (body == NULL) { ErrPrint("Can't make gvariant to noti"); - notification_free(noti); - return NOTIFICATION_ERROR_OUT_OF_MEMORY; + ret = NOTIFICATION_ERROR_OUT_OF_MEMORY; + goto out; } ret = send_event_notify_by_busname(g_variant_new("(vi)", body, event_type), "send_event", info->busname, PROVIDER_NOTI_EVENT_INTERFACE_NAME); - notification_free(noti); + *reply_body = g_variant_new("()"); + if (*reply_body == NULL) { + ErrPrint("cannot make reply body"); + ret = NOTIFICATION_ERROR_OUT_OF_MEMORY; + } } else { return NOTIFICATION_ERROR_OUT_OF_MEMORY; } - *reply_body = g_variant_new("()"); - if (*reply_body == NULL) { - ErrPrint("cannot make reply body"); - return NOTIFICATION_ERROR_OUT_OF_MEMORY; - } +out: + if (noti) + notification_free(noti); - DbgPrint("notification_send_noti_event_by_priv_id done !! %d", ret); + DbgPrint("notification_send_noti_event_by_priv_id done [%d]", ret); return ret; } @@ -2053,9 +2077,7 @@ HAPI int notification_delete_noti_by_appid(const char *appid, uid_t uid) ret = notification_noti_delete_all(NOTIFICATION_TYPE_NONE, appid, &num_deleted, &list_deleted, uid); if (ret != NOTIFICATION_ERROR_NONE) { ErrPrint("failed to delete notifications:%d\n", ret); - if (list_deleted != NULL) - free(list_deleted); - return ret; + goto out; } if (num_deleted > 0) { @@ -2070,18 +2092,18 @@ HAPI int notification_delete_noti_by_appid(const char *appid, uid_t uid) g_variant_unref(deleted_noti_list); if (ret != NOTIFICATION_ERROR_NONE) { ErrPrint("failed to send notify:%d\n", ret); - return ret; + goto out; } for (i = 0; i < num_deleted; i++) { ret = __delete_sender_info(*(list_deleted + i)); if (ret != NOTIFICATION_ERROR_NONE) - return ret; + goto out; } - - free(list_deleted); } - +out: + if (list_deleted != NULL) + free(list_deleted); return ret; } -- 2.7.4 From 3549f9d4b6fef242cdb732a263a4fe8b925d82e9 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Thu, 20 Apr 2017 07:26:42 +0900 Subject: [PATCH 11/16] Release version 1.4.10 Fix memory leak Signed-off-by: Seungha Son Change-Id: Icebf9b2b1cc1ea38846a4630948e0dfacf0d323e --- 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 4bff4cf..e6e47db 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.9 +Version: 1.4.10 Release: 1 Group: Applications/Core Applications License: Apache-2.0 -- 2.7.4 From ee13a9693c12e4d39c9483a5d167faecfd6a19f1 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 28 Apr 2017 07:34:07 +0900 Subject: [PATCH 12/16] Fix build problem Add a build dependency: - libtzplatform-config Change-Id: Ibaaebee560da79b7f02e3ef2866e63014bc8abd5 Signed-off-by: Hwankyu Jhun --- CMakeLists.txt | 1 + packaging/data-provider-master.spec | 1 + 2 files changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b8e3278..01b4bcd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ pkg_check_modules(pkg REQUIRED libsystemd-daemon capi-appfw-app-manager alarm-service + libtzplatform-config ) SET(PACKAGE "${PROJECT_NAME}") diff --git a/packaging/data-provider-master.spec b/packaging/data-provider-master.spec index e6e47db..c29dc4a 100755 --- a/packaging/data-provider-master.spec +++ b/packaging/data-provider-master.spec @@ -30,6 +30,7 @@ BuildRequires: pkgconfig(badge) BuildRequires: pkgconfig(shortcut) BuildRequires: pkgconfig(libsystemd-daemon) BuildRequires: pkgconfig(alarm-service) +BuildRequires: pkgconfig(libtzplatform-config) Requires(post): dbus -- 2.7.4 From a7262856463049b2b3a1d679159f197ecc6e3872 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 28 Apr 2017 07:48:20 +0900 Subject: [PATCH 13/16] Release version 1.4.11 Changes: - Fix build problem Change-Id: I9b515ebe66dd13bc4703b9522038d0ffbd4f5a78 Signed-off-by: Hwankyu Jhun --- 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 c29dc4a..97af8f9 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.10 +Version: 1.4.11 Release: 1 Group: Applications/Core Applications License: Apache-2.0 -- 2.7.4 From d982fb5e6db31ab10c0fb11cc6df79ca3004d2b4 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Wed, 10 May 2017 08:31:25 +0900 Subject: [PATCH 14/16] Remove unnecessary line Signed-off-by: Seungha Son Change-Id: I31ac9fb5efa661f97ebe71d6f187a0c63c4cc39a --- src/badge_service.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/badge_service.c b/src/badge_service.c index 24d01c1..69ecfca 100755 --- a/src/badge_service.c +++ b/src/badge_service.c @@ -341,8 +341,6 @@ int badge_insert(GVariant *parameters, GVariant **reply_body, uid_t uid) return ret; } - - ret = badge_db_get_allow_to_display_by_appid(pkgname, &allow_to_display, param_uid); if (ret != BADGE_ERROR_NONE) { ErrPrint("failed to get allow_to_display by appid : %d\n", ret); -- 2.7.4 From 3bd7ccaf1a4e4a056f4b18c8128c5f07464eb2c7 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Thu, 11 May 2017 16:47:57 +0900 Subject: [PATCH 15/16] Modify logic related with setting refresh If an application wants to get a notification_setting_h by using appid, the response time will be longer if DB data is not created. If the information is not in DB data, it shortens response time by sending initialized setting handle. Signed-off-by: Seungha Son Change-Id: Ie131b6d93309560c395d50f9b90921b2e41f7cfd --- src/notification_service.c | 77 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 14 deletions(-) diff --git a/src/notification_service.c b/src/notification_service.c index 30fc09d..de7796e 100755 --- a/src/notification_service.c +++ b/src/notification_service.c @@ -886,20 +886,64 @@ int notification_get_setting_array(GVariant *parameters, GVariant **reply_body, return ret; } +static bool __init_setting_handle_by_appid(const char *appid, notification_setting_h *setting, uid_t uid) +{ + bool ret = false; + int ret_pkgmgr; + char *pkgname = NULL; + notification_setting_h ret_setting = NULL; + pkgmgrinfo_appinfo_h handle = NULL; + + if (appid == NULL || setting == NULL) + return false; + + ret_pkgmgr = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); + if (ret_pkgmgr != PMINFO_R_OK) { + ErrPrint("failed to pkgmgrinfo_appinfo_get_appinfo [%s][%d]", appid, ret); + goto out; + } + + ret_pkgmgr = pkgmgrinfo_appinfo_get_pkgname(handle, &pkgname); + if (ret_pkgmgr != PMINFO_R_OK) { + ErrPrint("failed to pkgmgrinfo_appinfo_get_pkgname [%s][%d]", appid, ret); + goto out; + } + + ret_setting = (struct notification_setting *)malloc(sizeof(struct notification_setting)); + if (ret_setting == NULL) { + ErrPrint("failed to alloc memory"); + goto out; + } + + ret_setting->package_name = strdup(pkgname); + ret_setting->appid = strdup(appid); + 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); + + return ret; +} + /* get_setting_by_appid */ int notification_get_setting_by_appid(GVariant *parameters, GVariant **reply_body, uid_t uid) { + bool err; int ret; GVariant *body; char *appid = NULL; notification_setting_h setting = NULL; 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, "(&si)", &appid, ¶m_uid); ret = _validate_and_set_param_uid_with_uid(uid, ¶m_uid); if (ret != NOTIFICATION_ERROR_NONE) @@ -907,23 +951,28 @@ int notification_get_setting_by_appid(GVariant *parameters, GVariant **reply_bod DbgPrint("get setting by appid : %s uid : %d", appid, param_uid); ret = noti_setting_service_get_setting_by_appid(appid, &setting, param_uid); - if (ret == NOTIFICATION_ERROR_NONE) { - body = notification_ipc_make_gvariant_from_setting(setting); - notification_setting_free_notification(setting); - - if (body == NULL) { - ErrPrint("fail to make gvariant"); - return NOTIFICATION_ERROR_OUT_OF_MEMORY; - } - } else { + if (ret == NOTIFICATION_ERROR_NOT_EXIST_ID) { + err = __init_setting_handle_by_appid(appid, &setting, param_uid); + if (err == false) + return NOTIFICATION_ERROR_IO_ERROR; + ret = NOTIFICATION_ERROR_NONE; + } else if (ret != NOTIFICATION_ERROR_NONE) { return ret; } + body = notification_ipc_make_gvariant_from_setting(setting); + notification_setting_free_notification(setting); + if (body == NULL) { + ErrPrint("fail to make gvariant"); + return NOTIFICATION_ERROR_OUT_OF_MEMORY; + } + *reply_body = g_variant_new("(v)", body); if (*reply_body == NULL) { ErrPrint("cannot make reply_body"); return NOTIFICATION_ERROR_OUT_OF_MEMORY; } + return ret; } -- 2.7.4 From 58d3add8c90e97f085421deff1624b9b24aaf65c Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Fri, 19 May 2017 11:11:50 +0900 Subject: [PATCH 16/16] Release version 1.4.12 Changed: - Remove unnecessary Lines - Modify logic related with setting refresh Signed-off-by: Seungha Son Change-Id: Iaf0d3923f0da1a2d849b9c3893fc450e781882e9 --- 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 97af8f9..61aafdf 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.11 +Version: 1.4.12 Release: 1 Group: Applications/Core Applications License: Apache-2.0 -- 2.7.4