#include <badge_db.h>
#include <package-manager.h>
#include <tzplatform_config.h>
+#include <pkgmgr-info.h>
#include "debug.h"
#include "pkgmgr.h"
#define PROVIDER_OBJECT_PATH "/org/tizen/data_provider_service"
static GDBusConnection *_gdbus_conn = NULL;
+static GHashTable *_noti_pkg_privilege_info;
+static GHashTable *_badge_pkg_privilege_info;
uid_t get_sender_uid(const char *sender_name)
{
static int _package_install_cb(uid_t uid, const char *pkgname, enum pkgmgr_status status, double value, void *data)
{
- if (status == PKGMGR_STATUS_END) {
- 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);
+ int ret;
+ gpointer tmp;
+ int privilege_info;
+
+ if (status != PKGMGR_STATUS_END)
+ return 0;
+
+ if (uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER))
+ uid = tzplatform_getuid(TZ_SYS_DEFAULT_USER);
+
+ if (g_hash_table_contains(_noti_pkg_privilege_info, pkgname)) {
+ tmp = g_hash_table_lookup(_noti_pkg_privilege_info, pkgname);
+ privilege_info = GPOINTER_TO_UINT(tmp);
+ if (privilege_info == 1)
+ notification_setting_db_update_pkg_disabled(pkgname, false, uid);
+
+ g_hash_table_remove(_noti_pkg_privilege_info, pkgname);
+ } else {
+ /* In consideration of the reboot status, change the disable information. */
+ ret = notification_setting_db_update_pkg_disabled(pkgname, false, uid);
+ if (ret != NOTIFICATION_ERROR_NONE)
+ notification_setting_insert_package_for_uid(pkgname, uid);
+ }
+
+ if (g_hash_table_contains(_badge_pkg_privilege_info, pkgname)) {
+ tmp = g_hash_table_lookup(_badge_pkg_privilege_info, pkgname);
+ privilege_info = GPOINTER_TO_UINT(tmp);
+ if (privilege_info == 1)
+ badge_db_update_pkg_disabled(pkgname, false, uid);
+
+ g_hash_table_remove(_badge_pkg_privilege_info, pkgname);
+ } else {
+ /* In consideration of the reboot status, change the disable information. */
+ ret = badge_db_update_pkg_disabled(pkgname, false, uid);
+ if (ret != BADGE_ERROR_NONE)
+ badge_setting_insert_package_for_uid(pkgname, uid);
}
return 0;
static int _package_uninstall_cb(uid_t uid, const char *pkgname, enum pkgmgr_status status, double value, void *data)
{
- if (status == PKGMGR_STATUS_END) {
- if (uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER))
- uid = tzplatform_getuid(TZ_SYS_DEFAULT_USER);
+ int ret;
+ pkgmgrinfo_pkginfo_h pkginfo;
+
+ if (status != PKGMGR_STATUS_END)
+ return 0;
+
+ if (uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER))
+ uid = tzplatform_getuid(TZ_SYS_DEFAULT_USER);
+
+ ret = pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo(pkgname, uid, &pkginfo);
+ if (ret == PMINFO_R_OK) {
+ pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo);
+
+ if (_noti_pkg_privilege_info == NULL) {
+ _noti_pkg_privilege_info = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
+ _badge_pkg_privilege_info = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
+ }
+
+ ret = notification_setting_db_update_pkg_disabled(pkgname, true, uid);
+ if (ret == NOTIFICATION_ERROR_NONE)
+ g_hash_table_insert(_noti_pkg_privilege_info, strdup(pkgname), GUINT_TO_POINTER(1));
+ else
+ g_hash_table_insert(_noti_pkg_privilege_info, strdup(pkgname), GUINT_TO_POINTER(0));
+
+ ret = badge_db_update_pkg_disabled(pkgname, true, uid);
+ if (ret == BADGE_ERROR_NONE)
+ g_hash_table_insert(_badge_pkg_privilege_info, strdup(pkgname), GUINT_TO_POINTER(1));
+ else
+ g_hash_table_insert(_badge_pkg_privilege_info, strdup(pkgname), GUINT_TO_POINTER(0));
+ } else {
notification_setting_delete_package_for_uid(pkgname, uid);
badge_db_delete_by_pkgname(pkgname, uid);
badge_setting_delete_package_for_uid(pkgname, uid);