return ret;
}
+HAPI int notification_delete_noti_by_appid(const char *appid, uid_t uid)
+{
+ GVariant *deleted_noti_list;
+ GVariantBuilder *builder;
+ int num_deleted = 0;
+ int *list_deleted = NULL;
+ int ret;
+ int i;
+
+ 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;
+ }
+
+ if (num_deleted > 0) {
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a(i)"));
+
+ for (i = 0; i < num_deleted; i++)
+ g_variant_builder_add(builder, "(i)", *(list_deleted + i));
+
+ deleted_noti_list = g_variant_new("(a(i)i)", builder, uid);
+ ret = send_notify(deleted_noti_list, "delete_multiple_notify", &_monitoring_hash, PROVIDER_NOTI_INTERFACE_NAME, uid);
+ g_variant_builder_unref(builder);
+ g_variant_unref(deleted_noti_list);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ ErrPrint("failed to send notify:%d\n", ret);
+ return ret;
+ }
+
+ for (i = 0; i < num_deleted; i++) {
+ ret = __delete_sender_info(*(list_deleted + i), uid);
+ if (ret != NOTIFICATION_ERROR_NONE)
+ return ret;
+ }
+
+ free(list_deleted);
+ }
+
+ return ret;
+}
+
static void _notification_data_init(void)
{
int property = 0;
Eina_List *update_event;
Eina_List *download_event;
Eina_List *recover_event;
+ Eina_List *app_enable_event;
+ Eina_List *app_disable_event;
} s_info = {
.listen_pc = NULL,
.item_list = NULL,
.update_event = NULL,
.download_event = NULL,
.recover_event = NULL,
+ .app_enable_event = NULL,
+ .app_disable_event = NULL,
};
struct event_item {
}
}
+static inline void invoke_app_enable_event_handler(uid_t uid, const char *pkgname, enum pkgmgr_status status, double value)
+{
+ Eina_List *l;
+ struct event_item *item;
+
+ EINA_LIST_FOREACH(s_info.app_enable_event, l, item) {
+ if (item->cb)
+ item->cb(uid, pkgname, status, value, item->data);
+ }
+}
+
+static inline void invoke_app_disable_event_handler(uid_t uid, const char *pkgname, enum pkgmgr_status status, double value)
+{
+ Eina_List *l;
+ struct event_item *item;
+
+ EINA_LIST_FOREACH(s_info.app_disable_event, l, item) {
+ if (item->cb)
+ item->cb(uid, pkgname, status, value, item->data);
+ }
+}
+
static inline void invoke_callback(uid_t uid, const char *pkgname, struct item *item, double value)
{
switch (item->type) {
case PKGMGR_EVENT_RECOVER:
invoke_recover_event_handler(uid, pkgname, item->status, value);
break;
+ case PKGMGR_EVENT_APP_ENABLE:
+ invoke_app_enable_event_handler(uid, pkgname, item->status, value);
+ break;
+ case PKGMGR_EVENT_APP_DISABLE:
+ invoke_app_disable_event_handler(uid, pkgname, item->status, value);
+ break;
default:
ErrPrint("Unknown type: %d\n", item->type);
break;
case PKGMGR_EVENT_RECOVER:
expected_status = "recover";
break;
+ case PKGMGR_EVENT_APP_ENABLE:
+ expected_status = "app_enable_app";
+ break;
+ case PKGMGR_EVENT_APP_DISABLE:
+ expected_status = "app_disable_app";
+ break;
default:
return 0;
}
item->type = PKGMGR_EVENT_UPDATE;
} else if (!strcasecmp(val, "recover")) {
item->type = PKGMGR_EVENT_RECOVER;
+ } else if (!strcasecmp(val, "enable_app")) {
+ item->type = PKGMGR_EVENT_APP_ENABLE;
+ } else if (!strcasecmp(val, "disable_app")) {
+ item->type = PKGMGR_EVENT_APP_DISABLE;
} else {
free(item->pkgname);
free(item);
{ NULL, NULL },
};
-static int pkgmgr_cb(uid_t target_uid, int req_id, const char *type, const char *pkgname, const char *key, const char *val, const void *pmsg, void *data)
+static int status_cb(uid_t target_uid, int req_id, const char *type,
+ const char *pkgname, const char *key, const char *val,
+ const void *pmsg, void *data)
{
register int i;
int ret;
return SERVICE_COMMON_ERROR_NONE;
}
+static int app_status_cb(uid_t target_uid, int req_id, const char *pkg_type,
+ const char *pkgid, const char *appid, const char *key, const char *val,
+ const void *pmsg, void *data)
+{
+ register int i;
+ int ret;
+
+ for (i = 0; handler[i].key; i++) {
+ if (strcasecmp(key, handler[i].key))
+ continue;
+
+ ret = handler[i].func(target_uid, appid, val, data);
+ if (ret < 0) {
+ DbgPrint("REQ[%d], UID[%d], appid[%s], type[%s], key[%s], val[%s], ret = %d\n",
+ req_id, target_uid, appid, pkg_type, key, val, ret);
+ }
+ }
+
+ return SERVICE_COMMON_ERROR_NONE;
+}
+
HAPI int pkgmgr_init(void)
{
if (s_info.listen_pc)
if (!s_info.listen_pc)
return SERVICE_COMMON_ERROR_FAULT;
- if (pkgmgr_client_listen_status(s_info.listen_pc, pkgmgr_cb, NULL) != PKGMGR_R_OK)
+ /* the pkgmgr api returns an id greater than 1 */
+ if (pkgmgr_client_listen_status(s_info.listen_pc, status_cb, NULL) <= 0)
+ return SERVICE_COMMON_ERROR_FAULT;
+
+ if (pkgmgr_client_listen_app_status(s_info.listen_pc, app_status_cb, NULL) <= 0)
return SERVICE_COMMON_ERROR_FAULT;
return SERVICE_COMMON_ERROR_NONE;
free(item);
}
+ EINA_LIST_FREE(s_info.app_enable_event, item) {
+ free(item);
+ }
+
+ EINA_LIST_FREE(s_info.app_disable_event, item) {
+ free(item);
+ }
+
EINA_LIST_FREE(s_info.item_list, ctx) {
free(ctx->pkgname);
free(ctx->icon);
case PKGMGR_EVENT_RECOVER:
s_info.recover_event = eina_list_prepend(s_info.recover_event, item);
break;
+ case PKGMGR_EVENT_APP_ENABLE:
+ s_info.app_enable_event = eina_list_prepend(s_info.app_enable_event, item);
+ break;
+ case PKGMGR_EVENT_APP_DISABLE:
+ s_info.app_disable_event = eina_list_prepend(s_info.app_disable_event, item);
+ break;
default:
free(item);
return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
}
}
break;
+ case PKGMGR_EVENT_APP_ENABLE:
+ EINA_LIST_FOREACH(s_info.app_enable_event, l, item) {
+ if (item->cb == cb && item->data == data) {
+ s_info.app_enable_event = eina_list_remove(s_info.app_enable_event, item);
+ cbdata = item->data;
+ free(item);
+ break;
+ }
+ }
+ break;
+ case PKGMGR_EVENT_APP_DISABLE:
+ EINA_LIST_FOREACH(s_info.app_disable_event, l, item) {
+ if (item->cb == cb && item->data == data) {
+ s_info.app_disable_event = eina_list_remove(s_info.app_disable_event, item);
+ cbdata = item->data;
+ free(item);
+ break;
+ }
+ }
+ break;
default:
ErrPrint("Invalid type\n");
break;
#include <unistd.h>
#include <gio/gio.h>
#include <dlog.h>
-#include <notification.h>
#include <notification_setting.h>
#include <notification_setting_internal.h>
+#include <notification_setting_service.h>
#include <notification_noti.h>
#include <badge_setting.h>
#include <badge_setting_service.h>
+#include <package-manager.h>
-#include "service_common.h"
#include "debug.h"
-
#include "pkgmgr.h"
+#include "service_common.h"
#include "notification_service.h"
#include "badge_service.h"
#ifndef WEARABLE
badge_setting_delete_package_for_uid(pkgname, uid);
notification_noti_delete_template(pkgname);
}
+
+ return 0;
+}
+
+static int _app_enabled_cb(uid_t uid, const char *appid, enum pkgmgr_status status, double value, void *data)
+{
+ if (status == PKGMGR_STATUS_END)
+ notification_setting_db_update_app_disabled(appid, false, uid);
+
+ return 0;
+}
+
+static int _app_disabled_cb(uid_t uid, const char *appid, enum pkgmgr_status status, double value, void *data)
+{
+ if (status == PKGMGR_STATUS_END) {
+ notification_delete_noti_by_appid(appid, uid);
+ notification_setting_db_update_app_disabled(appid, true, uid);
+ }
+
return 0;
}
pkgmgr_add_event_callback(PKGMGR_EVENT_INSTALL, _package_install_cb, NULL);
pkgmgr_add_event_callback(PKGMGR_EVENT_UPDATE, _package_install_cb, NULL);
pkgmgr_add_event_callback(PKGMGR_EVENT_UNINSTALL, _package_uninstall_cb, NULL);
+ pkgmgr_add_event_callback(PKGMGR_EVENT_APP_ENABLE, _app_enabled_cb, NULL);
+ pkgmgr_add_event_callback(PKGMGR_EVENT_APP_DISABLE, _app_disabled_cb, NULL);
}