#define REGULAR_UID_MIN 5000
+#define NOTIFICATION_CTOR __attribute__((constructor))
+#define NOTIFICATION_DTOR __attribute__((destructor))
+
typedef struct _notification_cb_info notification_cb_info_s;
typedef struct _notification_event_cb_info notification_event_cb_info_s;
static GHashTable *_noti_cb_hash = NULL;
static GList *__noti_event_cb_list = NULL;
+static GRecMutex __rec_mutex;
+static gint __init_mutex = 0;
+
+NOTIFICATION_CTOR __notification_init(void)
+{
+ g_rec_mutex_init(&__rec_mutex);
+}
+
+NOTIFICATION_DTOR __notification_fini(void)
+{
+ g_rec_mutex_clear(&__rec_mutex);
+}
+
+static void __notification_mutex_lock(void)
+{
+ g_rec_mutex_lock(&__rec_mutex);
+}
+
+static void __notification_mutex_unlock(void)
+{
+ g_rec_mutex_unlock(&__rec_mutex);
+}
+
/* LCOV_EXCL_START */
void notification_reset_event_handler_list(void)
{
WARN("noti id : [%d]", priv_id);
+ __notification_mutex_lock();
+
__noti_event_cb_list = g_list_first(__noti_event_cb_list);
find_list = g_list_find_custom(__noti_event_cb_list, GINT_TO_POINTER(priv_id),
(GCompareFunc)__priv_id_compare);
- if (find_list == NULL)
+ if (find_list == NULL) {
+ __notification_mutex_unlock();
return;
+ }
info = g_list_nth_data(find_list, 0);
info->cb(noti, event_type, info->userdata);
+
+ __notification_mutex_unlock();
+
WARN("done");
}
/* LCOV_EXCL_STOP */
if (__noti_event_cb_list == NULL)
return;
+ __notification_mutex_lock();
+
__noti_event_cb_list = g_list_first(__noti_event_cb_list);
delete_list = g_list_find_custom(__noti_event_cb_list, GINT_TO_POINTER(priv_id),
(GCompareFunc)__priv_id_compare);
- if (delete_list == NULL)
+ if (delete_list == NULL) {
+ __notification_mutex_unlock();
return;
+ }
info = g_list_nth_data(delete_list, 0);
__noti_event_cb_list = g_list_remove(g_list_first(__noti_event_cb_list), info);
if (__noti_event_cb_list == NULL)
notification_ipc_event_monitor_fini();
+
+ __notification_mutex_unlock();
+
WARN("done");
}
/* LCOV_EXCL_STOP */
else
caller_app_id = strdup(app_id);
+ __notification_mutex_lock();
+
ret = notification_ipc_request_delete_multiple(type, caller_app_id, getuid());
+ __notification_mutex_unlock();
+
+out:
if (caller_app_id)
free(caller_app_id);
else
caller_app_id = strdup(app_id);
+ __notification_mutex_lock();
+
ret = notification_ipc_request_delete_single(type, caller_app_id, priv_id, uid);
+ __notification_mutex_unlock();
+
+out:
if (caller_app_id)
free(caller_app_id);
int notification_clear_for_uid(notification_type_e type, uid_t uid)
{
+ int ret;
+
if (type <= NOTIFICATION_TYPE_NONE || type > NOTIFICATION_TYPE_MAX)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
- return notification_ipc_request_delete_multiple(type, NULL, uid);
+ __notification_mutex_lock();
+
+ ret = notification_ipc_request_delete_multiple(type, NULL, uid);
+
+ __notification_mutex_unlock();
+
+ return ret;
}
/* LCOV_EXCL_STOP */
else
caller_app_id = strdup(app_id);
+ __notification_mutex_lock();
+
ret = notification_ipc_request_delete_multiple(type, caller_app_id, uid);
+ __notification_mutex_unlock();
+
+out:
if (caller_app_id)
free(caller_app_id);
else
caller_app_id = strdup(app_id);
+ __notification_mutex_lock();
+
ret = notification_ipc_request_delete_single(type, caller_app_id, priv_id, uid);
+ __notification_mutex_unlock();
+
+out:
if (caller_app_id)
free(caller_app_id);
return NULL;
}
+ __notification_mutex_lock();
+
ret = notification_ipc_request_load_noti_by_priv_id(noti, app_id, priv_id, uid);
if (ret != NOTIFICATION_ERROR_NONE) {
notification_free(noti);
set_last_result(ret);
+ __notification_mutex_unlock();
return NULL;
}
+ __notification_mutex_unlock();
+
set_last_result(NOTIFICATION_ERROR_NONE);
return noti;
noti->uid = uid;
noti->insert_time = time(NULL);
+ __notification_mutex_lock();
+
ret = notification_ipc_request_insert(noti, &id);
if (ret != NOTIFICATION_ERROR_NONE)
- return ret;
+ goto out;
noti->priv_id = id;
ret = notification_get_event_flag(noti, &event_flag);
if (ret != NOTIFICATION_ERROR_NONE)
- return ret;
+ goto out;
if (event_flag == true) {
ret = notification_ipc_event_monitor_init();
if (ret != NOTIFICATION_ERROR_NONE)
- return ret;
+ goto out;
}
- return NOTIFICATION_ERROR_NONE;
+out:
+ __notification_mutex_unlock();
+
+ return ret;
}
EXPORT_API int notification_insert(notification_h noti,
EXPORT_API int notification_update_async_for_uid(notification_h noti,
void (*result_cb)(int priv_id, int result, void *data), void *user_data, uid_t uid)
{
+ int ret;
+
if (noti == NULL)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
/* Update insert time ? */
noti->insert_time = time(NULL);
- return notification_ipc_request_update_async(noti, result_cb, user_data);
+ __notification_mutex_lock();
+
+ ret = notification_ipc_request_update_async(noti, result_cb, user_data);
+
+ __notification_mutex_unlock();
+
+ return ret;
}
EXPORT_API int notification_update_async(notification_h noti,
noti->insert_time = time(NULL);
noti->uid = uid;
+ __notification_mutex_lock();
+
file_list = __copy_private_file(noti);
ret = notification_ipc_request_insert(noti, &id);
if (ret == NOTIFICATION_ERROR_NONE) {
ret = notification_get_event_flag(noti, &event_flag);
if (ret != NOTIFICATION_ERROR_NONE)
- return ret;
+ goto out;
if (event_flag == true) {
ret = notification_ipc_event_monitor_init();
if (ret != NOTIFICATION_ERROR_NONE)
- return ret;
+ goto out;
}
} else {
g_list_foreach(file_list, __remove_private_file, NULL);
}
+out:
if (file_list)
g_list_free_full(file_list, free);
+ __notification_mutex_unlock();
+
return ret;
}
EXPORT_API int notification_update_for_uid(notification_h noti, uid_t uid)
{
+ int ret;
+
+ __notification_mutex_lock();
+
if (noti == NULL) {
notification_ipc_request_refresh(uid);
+ __notification_mutex_unlock();
return NOTIFICATION_ERROR_INVALID_PARAMETER;
}
noti->insert_time = time(NULL);
WARN("updated notification id[%d]", noti->priv_id);
- return notification_ipc_request_update(noti);
+ ret = notification_ipc_request_update(noti);
+
+ __notification_mutex_unlock();
+
+ return ret;
}
EXPORT_API int notification_delete_for_uid(notification_h noti, uid_t uid)
if (noti == NULL)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
- return notification_ipc_request_delete_single(NOTIFICATION_TYPE_NONE,
+ int ret;
+
+ __notification_mutex_lock();
+
+ ret = notification_ipc_request_delete_single(NOTIFICATION_TYPE_NONE,
noti->caller_app_id, noti->priv_id, uid);
+
+ __notification_mutex_unlock();
+
+ return ret;
}
EXPORT_API int notification_delete_all_for_uid(notification_type_e type, uid_t uid)
caller_app_id = notification_get_app_id_by_pid(getpid());
+ __notification_mutex_lock();
+
ret = notification_ipc_request_delete_multiple(type, caller_app_id, uid);
+ __notification_mutex_unlock();
+
+out:
if (caller_app_id)
free(caller_app_id);
return NULL;
}
+ __notification_mutex_lock();
+
ret = notification_ipc_request_load_noti_by_tag(noti, caller_app_id, (char *)tag, uid);
- free(caller_app_id);
+ __notification_mutex_unlock();
+
+ free(caller_app_id);
set_last_result(ret);
if (ret != NOTIFICATION_ERROR_NONE) {
notification_free(noti);
noti->event_flag = true;
noti->uid = uid;
+ __notification_mutex_lock();
+
ret = notification_ipc_request_insert(noti, &priv_id);
if (ret != NOTIFICATION_ERROR_NONE)
- return ret;
+ goto out;
noti->priv_id = priv_id;
ret = notification_ipc_event_monitor_init();
if (ret != NOTIFICATION_ERROR_NONE)
- return ret;
+ goto out;
if (find_list) {
info = g_list_nth_data(find_list, 0);
info = (notification_event_cb_info_s *)malloc(sizeof(notification_event_cb_info_s));
if (info == NULL) {
ERR("Failed to alloc memory");
- return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ goto out;
}
info->priv_id = priv_id;
info->cb = cb;
WARN("new event cb appended id[%d]", priv_id);
}
+out:
+ __notification_mutex_unlock();
+
return ret;
}
/* LCOV_EXCL_STOP */
if (ret != NOTIFICATION_ERROR_NONE || event_flag == false)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
+ __notification_mutex_lock();
+
ret = notification_ipc_send_event(noti, event_type, -1);
+ __notification_mutex_unlock();
+
return ret;
}
(event_type == NOTIFICATION_EVENT_TYPE_CHECK_BOX)))
return NOTIFICATION_ERROR_INVALID_PARAMETER;
+ __notification_mutex_lock();
+
ret = notification_ipc_send_event(NULL, event_type, priv_id);
+
+ __notification_mutex_unlock();
+
return ret;
}
return ret;
}
+ __notification_mutex_lock();
+
ret = notification_ipc_check_event_receiver(priv_id, available);
+ __notification_mutex_unlock();
+
return ret;
}
int notification_delete_by_display_applist_for_uid(int display_applist, uid_t uid)
{
+ int ret;
+
if (display_applist < NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
- return notification_ipc_request_delete_by_display_applist(display_applist, uid);
+ __notification_mutex_lock();
+
+ ret = notification_ipc_request_delete_by_display_applist(display_applist, uid);
+
+ __notification_mutex_unlock();
+
+ return ret;
}
EXPORT_API int notification_delete_by_display_applist(int display_applist)