Move notification_get_text_input_max_length to internal
[platform/core/api/notification.git] / src / notification_internal.c
index a519d28..d1b8344 100755 (executable)
 #include <libintl.h>
 #include <dbus/dbus.h>
 #include <dbus/dbus-glib-lowlevel.h>
+#include <gio/gio.h>
 
 #include <app.h>
 #include <app_control_internal.h>
 #include <aul.h>
-#include <ail.h>
 #include <appsvc.h>
 #include <tizen.h>
 #include <vconf-keys.h>
 #include <notification_ipc.h>
 #include <notification_internal.h>
 
-typedef struct _notification_cb_list notification_cb_list_s;
+typedef struct _notification_cb_info notification_cb_info_s;
 
 typedef enum __notification_cb_type {
        NOTIFICATION_CB_NORMAL = 1,
        NOTIFICATION_CB_DETAILED,
 } _notification_cb_type_e;
 
-struct _notification_cb_list {
-       notification_cb_list_s *prev;
-       notification_cb_list_s *next;
-
+struct _notification_cb_info {
        _notification_cb_type_e cb_type;
        void (*changed_cb) (void *data, notification_type_e type);
        void (*detailed_changed_cb) (void *data, notification_type_e type, notification_op *op_list, int num_op);
        void *data;
 };
 
-static notification_cb_list_s *g_notification_cb_list = NULL;
+static GHashTable *_noti_cb_hash = NULL;
+
+/* LCOV_EXCL_START */
+static void __free_changed_cb_info(gpointer data)
+{
+       notification_cb_info_s *noti_cb_info = (notification_cb_info_s *)data;
+       if (noti_cb_info)
+               free(noti_cb_info);
+}
+/* LCOV_EXCL_STOP */
 
-void notification_call_changed_cb(notification_op *op_list, int op_num)
+/* LCOV_EXCL_START */
+static void __free_changed_cb_hash(gpointer data)
+{
+       GList *changed_cb_list = (GList *)data;
+       if (changed_cb_list)
+               g_list_free_full(changed_cb_list, __free_changed_cb_info);
+}
+/* LCOV_EXCL_STOP */
+
+void notification_call_changed_cb_for_uid(notification_op *op_list, int op_num, uid_t uid)
 {
-       notification_cb_list_s *noti_cb_list = NULL;
        notification_type_e type = 0;
+       GList *noti_cb_list = NULL;
+       notification_cb_info_s *noti_cb_info = NULL;
 
-       if (g_notification_cb_list == NULL)
+       if (_noti_cb_hash == NULL)
                return;
 
-       noti_cb_list = g_notification_cb_list;
-
-       while (noti_cb_list->prev != NULL)
-               noti_cb_list = noti_cb_list->prev;
+       noti_cb_list = (GList *)g_hash_table_lookup(_noti_cb_hash, GUINT_TO_POINTER(uid));
 
+       if (noti_cb_list == NULL)
+               return;
 
        if (op_list == NULL) {
                NOTIFICATION_ERR("invalid data");
-               return ;
+               return;
        }
 
+       noti_cb_list = g_list_first(noti_cb_list);
        notification_get_type(op_list->noti, &type);
 
-       while (noti_cb_list != NULL) {
-               if (noti_cb_list->cb_type == NOTIFICATION_CB_NORMAL && noti_cb_list->changed_cb) {
-                       noti_cb_list->changed_cb(noti_cb_list->data,
-                                                type);
+       for (; noti_cb_list != NULL; noti_cb_list = noti_cb_list->next) {
+               noti_cb_info = noti_cb_list->data;
+
+               if (noti_cb_info->cb_type == NOTIFICATION_CB_NORMAL && noti_cb_info->changed_cb) {
+                       noti_cb_info->changed_cb(noti_cb_info->data, type);
                }
-               if (noti_cb_list->cb_type == NOTIFICATION_CB_DETAILED && noti_cb_list->detailed_changed_cb) {
-                       noti_cb_list->detailed_changed_cb(noti_cb_list->data,
-                                               type, op_list, op_num);
+               if (noti_cb_info->cb_type == NOTIFICATION_CB_DETAILED && noti_cb_info->detailed_changed_cb) {
+                       noti_cb_info->detailed_changed_cb(noti_cb_info->data,
+                                       type, op_list, op_num);
                }
-
-               noti_cb_list = noti_cb_list->next;
        }
 }
 
@@ -114,106 +129,98 @@ EXPORT_API int notification_del_deferred_task(
        return notification_ipc_del_deffered_task(deferred_task_cb);
 }
 
-EXPORT_API int notification_resister_changed_cb(void (*changed_cb)
-                                (void *data, notification_type_e type),
-                                void *user_data)
+EXPORT_API int notification_resister_changed_cb_for_uid(
+               void (*changed_cb)(void *data, notification_type_e type),
+               void *user_data, uid_t uid)
 {
-       notification_cb_list_s *noti_cb_list_new = NULL;
-       notification_cb_list_s *noti_cb_list = NULL;
+       GList *noti_cb_list = NULL;
+       notification_cb_info_s *noti_cb_info_new = NULL;
 
        if (changed_cb == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       noti_cb_list_new =
-           (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
+       if (notification_ipc_monitor_init(uid) != NOTIFICATION_ERROR_NONE)
+               return NOTIFICATION_ERROR_IO_ERROR;
 
-       if (noti_cb_list_new == NULL) {
+       if (_noti_cb_hash == NULL)
+               _noti_cb_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, __free_changed_cb_hash);
+
+       noti_cb_info_new = (notification_cb_info_s *)malloc(sizeof(notification_cb_info_s));
+       if (noti_cb_info_new == NULL) {
                NOTIFICATION_ERR("malloc failed");
                return NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
 
-       noti_cb_list_new->next = NULL;
-       noti_cb_list_new->prev = NULL;
+       noti_cb_info_new->cb_type = NOTIFICATION_CB_NORMAL;
+       noti_cb_info_new->changed_cb = changed_cb;
+       noti_cb_info_new->detailed_changed_cb = NULL;
+       noti_cb_info_new->data = user_data;
 
-       noti_cb_list_new->cb_type = NOTIFICATION_CB_NORMAL;
-       noti_cb_list_new->changed_cb = changed_cb;
-       noti_cb_list_new->detailed_changed_cb = NULL;
-       noti_cb_list_new->data = user_data;
+       noti_cb_list = g_hash_table_lookup(_noti_cb_hash, GUINT_TO_POINTER(uid));
 
-       if (g_notification_cb_list == NULL) {
-               g_notification_cb_list = noti_cb_list_new;
+       if (noti_cb_list == NULL) {
+               noti_cb_list = g_list_append(noti_cb_list, noti_cb_info_new);
+               g_hash_table_insert(_noti_cb_hash, GUINT_TO_POINTER(uid), noti_cb_list);
        } else {
-               noti_cb_list = g_notification_cb_list;
-
-               while (noti_cb_list->next != NULL)
-                       noti_cb_list = noti_cb_list->next;
-
-
-               noti_cb_list->next = noti_cb_list_new;
-               noti_cb_list_new->prev = noti_cb_list;
-       }
-
-       if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
-               notification_unresister_changed_cb(changed_cb);
-               return NOTIFICATION_ERROR_IO_ERROR;
+               noti_cb_list = g_list_append(noti_cb_list, noti_cb_info_new);
        }
 
        return NOTIFICATION_ERROR_NONE;
 }
 
-EXPORT_API int notification_unresister_changed_cb(void (*changed_cb)
-                                  (void *data, notification_type_e type))
+EXPORT_API int notification_resister_changed_cb(
+               void (*changed_cb)(void *data, notification_type_e type),
+               void *user_data)
 {
-       notification_cb_list_s *noti_cb_list = NULL;
-       notification_cb_list_s *noti_cb_list_prev = NULL;
-       notification_cb_list_s *noti_cb_list_next = NULL;
+       return notification_resister_changed_cb_for_uid(changed_cb, user_data, getuid());
+}
 
-       noti_cb_list = g_notification_cb_list;
+EXPORT_API int notification_unresister_changed_cb_for_uid(
+               void (*changed_cb)(void *data, notification_type_e type), uid_t uid)
+{
+       notification_cb_info_s *noti_cb_info = NULL;
+       GList *noti_cb_list = NULL;
 
        if (changed_cb == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       if (noti_cb_list == NULL)
+       if (_noti_cb_hash == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       while (noti_cb_list->prev != NULL)
-               noti_cb_list = noti_cb_list->prev;
-
-
-       do {
-               if (noti_cb_list->changed_cb == changed_cb) {
-                       noti_cb_list_prev = noti_cb_list->prev;
-                       noti_cb_list_next = noti_cb_list->next;
+       noti_cb_list = (GList *)g_hash_table_lookup(_noti_cb_hash, GUINT_TO_POINTER(uid));
 
-                       if (noti_cb_list_prev == NULL)
-                               g_notification_cb_list = noti_cb_list_next;
-                       else
-                               noti_cb_list_prev->next = noti_cb_list_next;
+       if (noti_cb_list == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-                       if (noti_cb_list_next == NULL) {
-                               if (noti_cb_list_prev != NULL)
-                                       noti_cb_list_prev->next = NULL;
+       noti_cb_list = g_list_first(noti_cb_list);
 
-                       } else {
-                               noti_cb_list_next->prev = noti_cb_list_prev;
-                       }
+       for (; noti_cb_list != NULL; noti_cb_list = noti_cb_list->next) {
+               noti_cb_info = noti_cb_list->data;
+               if (noti_cb_info->changed_cb == changed_cb) {
+                       noti_cb_list = g_list_remove(g_list_first(noti_cb_list), noti_cb_info);
 
-                       free(noti_cb_list);
+                       if (noti_cb_list == NULL)
+                               g_hash_table_steal(_noti_cb_hash, GUINT_TO_POINTER(uid));
 
-                       if (g_notification_cb_list == NULL)
+                       if (g_hash_table_size(_noti_cb_hash) == 0)
                                notification_ipc_monitor_fini();
 
                        return NOTIFICATION_ERROR_NONE;
                }
-               noti_cb_list = noti_cb_list->next;
-       } while (noti_cb_list != NULL);
+       }
 
        return NOTIFICATION_ERROR_INVALID_PARAMETER;
 }
 
+EXPORT_API int notification_unresister_changed_cb(
+               void (*changed_cb)(void *data, notification_type_e type))
+{
+       return notification_unresister_changed_cb_for_uid(changed_cb, getuid());
+}
+
 EXPORT_API int notification_update_progress(notification_h noti,
-                                                            int priv_id,
-                                                            double progress)
+               int priv_id,
+               double progress)
 {
        char *caller_pkgname = NULL;
        int input_priv_id = 0;
@@ -243,7 +250,7 @@ EXPORT_API int notification_update_progress(notification_h noti,
                input_progress = progress;
 
        ret = notification_ongoing_update_progress(caller_pkgname, input_priv_id,
-                                            input_progress);
+                       input_progress);
 
        if (caller_pkgname)
                free(caller_pkgname);
@@ -252,8 +259,8 @@ EXPORT_API int notification_update_progress(notification_h noti,
 }
 
 EXPORT_API int notification_update_size(notification_h noti,
-                                                        int priv_id,
-                                                        double size)
+               int priv_id,
+               double size)
 {
        char *caller_pkgname = NULL;
        int input_priv_id = 0;
@@ -280,7 +287,7 @@ EXPORT_API int notification_update_size(notification_h noti,
                input_size = size;
 
        ret = notification_ongoing_update_size(caller_pkgname, input_priv_id,
-                                        input_size);
+                       input_size);
 
        if (caller_pkgname)
                free(caller_pkgname);
@@ -289,8 +296,8 @@ EXPORT_API int notification_update_size(notification_h noti,
 }
 
 EXPORT_API int notification_update_content(notification_h noti,
-                                                        int priv_id,
-                                                        const char *content)
+               int priv_id,
+               const char *content)
 {
        char *caller_pkgname = NULL;
        int input_priv_id = 0;
@@ -312,7 +319,7 @@ EXPORT_API int notification_update_content(notification_h noti,
                caller_pkgname = strdup(noti->caller_pkgname);
 
        ret = notification_ongoing_update_content(caller_pkgname, input_priv_id,
-                                        content);
+                       content);
 
        if (caller_pkgname)
                free(caller_pkgname);
@@ -321,58 +328,93 @@ EXPORT_API int notification_update_content(notification_h noti,
 }
 
 /* notification_set_icon will be removed */
+/* LCOV_EXCL_START */
 EXPORT_API int notification_set_icon(notification_h noti,
-                                                     const char *icon_path)
+               const char *icon_path)
 {
-       int ret_err = NOTIFICATION_ERROR_NONE;
-
-       ret_err =
-           notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
-                                  icon_path);
-
-       return ret_err;
+       return notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path);
 }
+/* LCOV_EXCL_STOP */
 
 /* notification_get_icon will be removed */
+/* LCOV_EXCL_START */
 EXPORT_API int notification_get_icon(notification_h noti,
-                                                     char **icon_path)
+               char **icon_path)
 {
        int ret_err = NOTIFICATION_ERROR_NONE;
        char *ret_image_path = NULL;
 
-       ret_err =
-           notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
-                                  &ret_image_path);
+       ret_err = notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
+                               &ret_image_path);
 
        if (ret_err == NOTIFICATION_ERROR_NONE && icon_path != NULL)
                *icon_path = ret_image_path;
 
        return ret_err;
 }
+/* LCOV_EXCL_STOP */
 
-EXPORT_API int notification_set_title(notification_h noti,
-                                                      const char *title,
-                                                      const char *loc_title)
+EXPORT_API int notification_translate_localized_text(notification_h noti)
 {
        int noti_err = NOTIFICATION_ERROR_NONE;
+       char *ret_text = NULL;
+       char buf_key[32];
+       char *bundle_val = NULL;
+       char *new_text;
+       bundle *b;
+       notification_text_type_e type = NOTIFICATION_TEXT_TYPE_TITLE;
+
+       for (; type < NOTIFICATION_TEXT_TYPE_MAX; type++) {
+               noti_err = notification_get_text(noti, type, &ret_text);
+               if (noti_err == NOTIFICATION_ERROR_NONE && ret_text) {
+                       if (noti->b_text == NULL) {
+                               noti->b_text = bundle_create();
+                               if (noti->b_text == NULL)
+                                       return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+                       }
 
-       noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
-                                        title, loc_title,
-                                        NOTIFICATION_VARIABLE_TYPE_NONE);
+                       b = noti->b_text;
+
+                       new_text = strdup(ret_text);
+
+                       snprintf(buf_key, sizeof(buf_key), "%d", type);
+                       bundle_get_str(b, buf_key, &bundle_val);
+                       if (bundle_val != NULL)
+                               bundle_del(b, buf_key);
+
+                       bundle_add_str(b, buf_key, new_text);
+                       free(new_text);
+                       new_text = NULL;
+
+                       noti->num_format_args = 0;
+                       bundle_val = NULL;
+               }
+       }
 
        return noti_err;
 }
 
+/* LCOV_EXCL_START */
+EXPORT_API int notification_set_title(notification_h noti,
+               const char *title,
+               const char *loc_title)
+{
+       return notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
+                               title, loc_title,
+                               NOTIFICATION_VARIABLE_TYPE_NONE);;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
 EXPORT_API int notification_get_title(notification_h noti,
-                                                      char **title,
-                                                      char **loc_title)
+               char **title,
+               char **loc_title)
 {
        int noti_err = NOTIFICATION_ERROR_NONE;
        char *ret_text = NULL;
 
-       noti_err =
-           notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
-                                 &ret_text);
+       noti_err = notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
+                               &ret_text);
 
        if (title != NULL)
                *title = ret_text;
@@ -382,30 +424,29 @@ EXPORT_API int notification_get_title(notification_h noti,
 
        return noti_err;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_set_content(notification_h noti,
-                                                        const char *content,
-                                                        const char *loc_content)
+               const char *content,
+               const char *loc_content)
 {
-       int noti_err = NOTIFICATION_ERROR_NONE;
-
-       noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
-                                        content, loc_content,
-                                        NOTIFICATION_VARIABLE_TYPE_NONE);
-
-       return noti_err;
+       return notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
+                               content, loc_content,
+                               NOTIFICATION_VARIABLE_TYPE_NONE);
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_get_content(notification_h noti,
-                                                        char **content,
-                                                        char **loc_content)
+               char **content,
+               char **loc_content)
 {
        int noti_err = NOTIFICATION_ERROR_NONE;
        char *ret_text = NULL;
 
-       noti_err =
-           notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
-                                 &ret_text);
+       noti_err = notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
+                               &ret_text);
 
        if (content != NULL)
                *content = ret_text;
@@ -414,24 +455,12 @@ EXPORT_API int notification_get_content(notification_h noti,
                *loc_content = NULL;
 
        return noti_err;
-
-#if 0
-       ret =
-           vconf_get_bool
-           (VCONFKEY_SETAPPL_STATE_TICKER_NOTI_DISPLAY_CONTENT_BOOL, &boolval);
-
-       if (ret == -1 || boolval == 0) {
-               if (content != NULL && noti->default_content != NULL)
-                       *content = noti->default_content;
-
-               if (loc_content != NULL && noti->loc_default_content != NULL)
-                       *loc_content = noti->loc_default_content;
-       }
-#endif
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_set_application(notification_h noti,
-                                                            const char *pkgname)
+               const char *pkgname)
 {
        if (noti == NULL || pkgname == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
@@ -443,9 +472,11 @@ EXPORT_API int notification_set_application(notification_h noti,
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_get_application(notification_h noti,
-                                                            char **pkgname)
+               char **pkgname)
 {
        if (noti == NULL || pkgname == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
@@ -457,7 +488,9 @@ EXPORT_API int notification_get_application(notification_h noti,
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_set_args(notification_h noti, bundle *args,
                bundle *group_args)
 {
@@ -479,10 +512,12 @@ EXPORT_API int notification_set_args(notification_h noti, bundle *args,
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_get_args(notification_h noti,
-                                                     bundle **args,
-                                                     bundle **group_args)
+               bundle **args,
+               bundle **group_args)
 {
        if (noti == NULL || args == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
@@ -497,9 +532,11 @@ EXPORT_API int notification_get_args(notification_h noti,
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
-EXPORT_API int notification_get_grouping_list(notification_type_e type, int count,
-                              notification_list_h *list)
+/* LCOV_EXCL_START */
+int notification_get_grouping_list_for_uid(notification_type_e type, int count,
+               notification_list_h *list, uid_t uid)
 {
        notification_list_h get_list = NULL;
        int ret = 0;
@@ -507,7 +544,7 @@ EXPORT_API int notification_get_grouping_list(notification_type_e type, int coun
        if (list == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       ret = notification_noti_get_grouping_list(type, count, &get_list);
+       ret = notification_noti_get_grouping_list(type, count, &get_list, uid);
        if (ret != NOTIFICATION_ERROR_NONE)
                return ret;
 
@@ -516,9 +553,17 @@ EXPORT_API int notification_get_grouping_list(notification_type_e type, int coun
        return NOTIFICATION_ERROR_NONE;
 }
 
+EXPORT_API int notification_get_grouping_list(notification_type_e type, int count,
+               notification_list_h *list)
+{
+       return notification_get_grouping_list_for_uid(type, count, list, getuid());
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
 EXPORT_API int notification_delete_group_by_group_id(const char *pkgname,
-                                                                     notification_type_e type,
-                                                                     int group_id)
+               notification_type_e type,
+               int group_id)
 {
        int ret = 0;
        char *caller_pkgname = NULL;
@@ -528,17 +573,19 @@ EXPORT_API int notification_delete_group_by_group_id(const char *pkgname,
        else
                caller_pkgname = strdup(pkgname);
 
-       ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
+       ret = notification_ipc_request_delete_multiple(type, caller_pkgname, getuid());
 
        if (caller_pkgname)
                free(caller_pkgname);
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
-EXPORT_API int notification_delete_group_by_priv_id(const char *pkgname,
-                                                                    notification_type_e type,
-                                                                    int priv_id)
+/* LCOV_EXCL_START */
+int notification_delete_group_by_priv_id_for_uid(const char *pkgname,
+               notification_type_e type,
+               int priv_id, uid_t uid)
 {
        int ret = 0;
        char *caller_pkgname = NULL;
@@ -548,18 +595,28 @@ EXPORT_API int notification_delete_group_by_priv_id(const char *pkgname,
        else
                caller_pkgname = strdup(pkgname);
 
-       ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
+       ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id, uid);
 
        if (caller_pkgname)
                free(caller_pkgname);
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
-EXPORT_API int notification_get_count(notification_type_e type,
-                                                      const char *pkgname,
-                                                      int group_id,
-                                                      int priv_id, int *count)
+/* LCOV_EXCL_START */
+EXPORT_API int notification_delete_group_by_priv_id(const char *pkgname,
+               notification_type_e type,
+               int priv_id)
+{
+       return notification_delete_group_by_priv_id_for_uid(pkgname, type, priv_id, getuid());
+}
+
+int notification_get_count_for_uid(notification_type_e type,
+               const char *pkgname,
+               int group_id,
+               int priv_id, int *count,
+               uid_t uid)
 {
        int ret = 0;
        char *caller_pkgname = NULL;
@@ -577,28 +634,42 @@ EXPORT_API int notification_get_count(notification_type_e type,
                        caller_pkgname,
                        group_id,
                        priv_id,
-                       count);
+                       count,
+                       uid);
 
        if (caller_pkgname)
                free(caller_pkgname);
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
-EXPORT_API int notification_clear(notification_type_e type)
+/* LCOV_EXCL_START */
+EXPORT_API int notification_get_count(notification_type_e type,
+               const char *pkgname,
+               int group_id,
+               int priv_id, int *count)
 {
-       int ret = 0;
+       return notification_get_count_for_uid(type, pkgname, group_id, priv_id, count, getuid());
+}
 
+int notification_clear_for_uid(notification_type_e type, uid_t uid)
+{
        if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       ret = notification_ipc_request_delete_multiple(type, NULL);
+       return notification_ipc_request_delete_multiple(type, NULL, uid);
+}
+/* LCOV_EXCL_STOP */
 
-       return ret;
+/* LCOV_EXCL_START */
+EXPORT_API int notification_clear(notification_type_e type)
+{
+       return notification_clear_for_uid(type, getuid());
 }
 
 EXPORT_API int notification_op_get_data(notification_op *noti_op, notification_op_data_type_e type,
-                                                      void *data)
+               void *data)
 {
        if (noti_op == NULL || data == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
@@ -626,11 +697,12 @@ EXPORT_API int notification_op_get_data(notification_op *noti_op, notification_o
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_set_pkgname(notification_h noti,
-                                                        const char *pkgname)
+               const char *pkgname)
 {
-       /* check noti and pkgname are valid data */
        if (noti == NULL || pkgname == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
@@ -644,9 +716,11 @@ EXPORT_API int notification_set_pkgname(notification_h noti,
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
-EXPORT_API int notification_delete_all_by_type(const char *pkgname,
-                                                               notification_type_e type)
+/* LCOV_EXCL_START */
+int notification_delete_all_by_type_for_uid(const char *pkgname,
+               notification_type_e type, uid_t uid)
 {
        int ret = 0;
        char *caller_pkgname = NULL;
@@ -659,17 +733,26 @@ EXPORT_API int notification_delete_all_by_type(const char *pkgname,
        else
                caller_pkgname = strdup(pkgname);
 
-       ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
+       ret = notification_ipc_request_delete_multiple(type, caller_pkgname, uid);
 
        if (caller_pkgname)
                free(caller_pkgname);
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
-EXPORT_API int notification_delete_by_priv_id(const char *pkgname,
-                                                              notification_type_e type,
-                                                              int priv_id)
+/* LCOV_EXCL_START */
+EXPORT_API int notification_delete_all_by_type(const char *pkgname,
+               notification_type_e type)
+{
+       return notification_delete_all_by_type_for_uid(pkgname, type, getuid());
+}
+
+int notification_delete_by_priv_id_for_uid(const char *pkgname,
+               notification_type_e type,
+               int priv_id,
+               uid_t uid)
 {
        int ret = 0;
        char *caller_pkgname = NULL;
@@ -682,19 +765,28 @@ EXPORT_API int notification_delete_by_priv_id(const char *pkgname,
        else
                caller_pkgname = strdup(pkgname);
 
-       ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
+       ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id, uid);
 
        if (caller_pkgname)
                free(caller_pkgname);
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
+EXPORT_API int notification_delete_by_priv_id(const char *pkgname,
+               notification_type_e type,
+               int priv_id)
+{
+       return notification_delete_by_priv_id_for_uid(pkgname, type, priv_id, getuid());
+}
 
 EXPORT_API int notification_set_execute_option(notification_h noti,
-                                                               notification_execute_type_e type,
-                                                               const char *text,
-                                                               const char *key,
-                                                               bundle *service_handle)
+               notification_execute_type_e type,
+               const char *text,
+               const char *key,
+               bundle *service_handle)
 {
        char buf_key[32] = { 0, };
        char *ret_val = NULL;
@@ -704,79 +796,62 @@ EXPORT_API int notification_set_execute_option(notification_h noti,
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
        if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
-           || type >= NOTIFICATION_EXECUTE_TYPE_MAX)
+                       || type >= NOTIFICATION_EXECUTE_TYPE_MAX)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Create execute option bundle if does not exist */
        if (noti->b_execute_option == NULL)
                noti->b_execute_option = bundle_create();
 
        b = noti->b_execute_option;
 
-       /* Save text */
        if (text != NULL) {
-               /* Make text key */
                snprintf(buf_key, sizeof(buf_key), "text%d", type);
 
-               /* Check text key exist */
                bundle_get_str(b, buf_key, &ret_val);
                if (ret_val != NULL)
-                       /* Remove previous data */
                        bundle_del(b, buf_key);
 
-               /* Add text data */
                bundle_add_str(b, buf_key, text);
        }
 
-       /* Save key */
        if (key != NULL) {
-               /* Make key key */
                snprintf(buf_key, sizeof(buf_key), "key%d", type);
 
-               /* Check key key exist */
                bundle_get_str(b, buf_key, &ret_val);
                if (ret_val != NULL)
-                       /* Remove previous data */
                        bundle_del(b, buf_key);
 
-               /* Add text data */
                bundle_add_str(b, buf_key, key);
        }
 
        switch ((int)type) {
        case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
-               /* Remove previous data if exist */
                if (noti->b_service_responding != NULL) {
                        bundle_free(noti->b_service_responding);
                        noti->b_service_responding = NULL;
                }
 
-               /* Save service handle */
                if (service_handle != NULL)
                        noti->b_service_responding = bundle_dup(service_handle);
 
                break;
        case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
-               /* Remove previous data if exist */
                if (noti->b_service_single_launch != NULL) {
                        bundle_free(noti->b_service_single_launch);
                        noti->b_service_single_launch = NULL;
                }
 
-               /* Save service handle */
                if (service_handle != NULL)
                        noti->b_service_single_launch =
                                bundle_dup(service_handle);
 
                break;
        case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
-               /* Remove previous data if exist */
                if (noti->b_service_multi_launch != NULL) {
                        bundle_free(noti->b_service_multi_launch);
                        noti->b_service_multi_launch = NULL;
                }
 
-               /* Save service handle */
                if (service_handle != NULL)
                        noti->b_service_multi_launch =
                                bundle_dup(service_handle);
@@ -786,33 +861,32 @@ EXPORT_API int notification_set_execute_option(notification_h noti,
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_get_id(notification_h noti,
-                                                   int *group_id, int *priv_id)
+               int *group_id, int *priv_id)
 {
-       /* check noti is valid data */
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Check group_id is valid data */
        if (group_id) {
-               /* Set group id */
                if (noti->group_id < NOTIFICATION_GROUP_ID_NONE)
                        *group_id = NOTIFICATION_GROUP_ID_NONE;
                else
                        *group_id = noti->group_id;
        }
 
-       /* Check priv_id is valid data */
        if (priv_id)
-               /* Set priv_id */
                *priv_id = noti->priv_id;
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
-EXPORT_API notification_h notification_load(char *pkgname,
-                                                     int priv_id)
+/* LCOV_EXCL_START */
+notification_h notification_load_for_uid(char *pkgname,
+               int priv_id, uid_t uid)
 {
        int ret = 0;
        notification_h noti = NULL;
@@ -823,7 +897,7 @@ EXPORT_API notification_h notification_load(char *pkgname,
                return NULL;
        }
 
-       ret = notification_ipc_request_load_noti_by_priv_id(noti, pkgname, priv_id);
+       ret = notification_ipc_request_load_noti_by_priv_id(noti, pkgname, priv_id, uid);
        if (ret != NOTIFICATION_ERROR_NONE) {
                notification_free(noti);
                return NULL;
@@ -831,30 +905,33 @@ EXPORT_API notification_h notification_load(char *pkgname,
 
        return noti;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
+EXPORT_API notification_h notification_load(char *pkgname,
+               int priv_id)
+{
+       return notification_load_for_uid(pkgname, priv_id, getuid());
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
 EXPORT_API notification_h notification_new(notification_type_e type,
-                                          int group_id, int priv_id)
+               int group_id, int priv_id)
 {
        return notification_create(type);
 }
 
 static void _notification_get_text_domain(notification_h noti)
 {
-/*
-       if (noti->domain != NULL) {
-
-       }
-
-       if (noti->dir != NULL) {
-
-       }
-*/
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_get_execute_option(notification_h noti,
-                                                               notification_execute_type_e type,
-                                                               const char **text,
-                                                               bundle **service_handle)
+               notification_execute_type_e type,
+               const char **text,
+               bundle **service_handle)
 {
        char buf_key[32] = { 0, };
        char *ret_val = NULL;
@@ -865,7 +942,7 @@ EXPORT_API int notification_get_execute_option(notification_h noti,
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
        if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
-           || type >= NOTIFICATION_EXECUTE_TYPE_MAX)
+                       || type >= NOTIFICATION_EXECUTE_TYPE_MAX)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
 
@@ -884,34 +961,27 @@ EXPORT_API int notification_get_execute_option(notification_h noti,
        }
 
        if (b != NULL) {
-       /* Return text */
                if (text != NULL) {
-                       /*  Get text domain and dir */
                        if (noti->domain == NULL || noti->dir == NULL)
                                _notification_get_text_domain(noti);
 
-                       /* Make key */
                        snprintf(buf_key, sizeof(buf_key), "key%d", type);
 
-                       /* Check key key exist */
                        bundle_get_str(b, buf_key, &ret_val);
                        if (ret_val != NULL && noti->domain != NULL
-                           && noti->dir != NULL) {
-                               /* Get application string */
+                                       && noti->dir != NULL) {
                                bindtextdomain(noti->domain, noti->dir);
 
                                get_str = dgettext(noti->domain, ret_val);
 
                                *text = get_str;
                        } else if (ret_val != NULL) {
-                               /* Get system string */
                                get_str = dgettext("sys_string", ret_val);
 
                                *text = get_str;
                        } else {
-                               /* Get basic text */
                                snprintf(buf_key, sizeof(buf_key), "text%d",
-                                        type);
+                                               type);
 
                                bundle_get_str(b, buf_key, &ret_val);
 
@@ -925,24 +995,24 @@ EXPORT_API int notification_get_execute_option(notification_h noti,
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
-EXPORT_API int notification_insert(notification_h noti,
-                                                   int *priv_id)
+EXPORT_API int notification_insert_for_uid(notification_h noti,
+               int *priv_id, uid_t uid)
 {
        int ret = 0;
        int id = 0;
 
-       /* Check noti is vaild data */
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Check noti type is valid type */
        if (noti->type <= NOTIFICATION_TYPE_NONE
-           || noti->type >= NOTIFICATION_TYPE_MAX)
+                       || noti->type >= NOTIFICATION_TYPE_MAX)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Save insert time */
+       noti->uid = uid;
        noti->insert_time = time(NULL);
+
        ret = notification_ipc_request_insert(noti, &id);
        if (ret != NOTIFICATION_ERROR_NONE)
                return ret;
@@ -957,119 +1027,387 @@ EXPORT_API int notification_insert(notification_h noti,
        return NOTIFICATION_ERROR_NONE;
 }
 
-EXPORT_API int notification_update_async(notification_h noti,
-               void (*result_cb)(int priv_id, int result, void *data), void *user_data)
+EXPORT_API int notification_insert(notification_h noti,
+               int *priv_id)
 {
-       int ret = 0;
+       return notification_insert_for_uid(noti, priv_id, getuid());
+}
 
+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)
+{
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
+       noti->uid = uid;
        /* Update insert time ? */
        noti->insert_time = time(NULL);
-       ret = notification_ipc_request_update_async(noti, result_cb, user_data);
 
-       return ret;
+       return notification_ipc_request_update_async(noti, result_cb, user_data);
 }
 
-EXPORT_API int notification_register_detailed_changed_cb(
+EXPORT_API int notification_update_async(notification_h noti,
+               void (*result_cb)(int priv_id, int result, void *data), void *user_data)
+{
+       return notification_update_async_for_uid(noti, result_cb, user_data, getuid());
+}
+
+EXPORT_API int notification_register_detailed_changed_cb_for_uid(
                void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
-               void *user_data)
+               void *user_data, uid_t uid)
 {
-       notification_cb_list_s *noti_cb_list_new = NULL;
-       notification_cb_list_s *noti_cb_list = NULL;
+       GList *noti_cb_list = NULL;
+       notification_cb_info_s *noti_cb_info_new = NULL;
 
        if (detailed_changed_cb == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE)
+       if (notification_ipc_monitor_init(uid) != NOTIFICATION_ERROR_NONE)
                return NOTIFICATION_ERROR_IO_ERROR;
 
-       noti_cb_list_new =
-           (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
+       if (_noti_cb_hash == NULL)
+               _noti_cb_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, __free_changed_cb_hash);
 
-       if (noti_cb_list_new == NULL) {
+       noti_cb_info_new = (notification_cb_info_s *)malloc(sizeof(notification_cb_info_s));
+       if (noti_cb_info_new == NULL) {
                NOTIFICATION_ERR("malloc failed");
                return NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
 
-       noti_cb_list_new->next = NULL;
-       noti_cb_list_new->prev = NULL;
+       noti_cb_info_new->cb_type = NOTIFICATION_CB_DETAILED;
+       noti_cb_info_new->changed_cb = NULL;
+       noti_cb_info_new->detailed_changed_cb = detailed_changed_cb;
+       noti_cb_info_new->data = user_data;
 
-       noti_cb_list_new->cb_type = NOTIFICATION_CB_DETAILED;
-       noti_cb_list_new->changed_cb = NULL;
-       noti_cb_list_new->detailed_changed_cb = detailed_changed_cb;
-       noti_cb_list_new->data = user_data;
+       noti_cb_list = g_hash_table_lookup(_noti_cb_hash, GUINT_TO_POINTER(uid));
 
-       if (g_notification_cb_list == NULL) {
-               g_notification_cb_list = noti_cb_list_new;
+       if (noti_cb_list == NULL) {
+               noti_cb_list = g_list_append(noti_cb_list, noti_cb_info_new);
+               g_hash_table_insert(_noti_cb_hash, GUINT_TO_POINTER(uid), noti_cb_list);
        } else {
-               noti_cb_list = g_notification_cb_list;
-
-               while (noti_cb_list->next != NULL)
-                       noti_cb_list = noti_cb_list->next;
-
-
-               noti_cb_list->next = noti_cb_list_new;
-               noti_cb_list_new->prev = noti_cb_list;
+               noti_cb_list = g_list_append(noti_cb_list, noti_cb_info_new);
        }
+
        return NOTIFICATION_ERROR_NONE;
 }
 
-EXPORT_API int notification_unregister_detailed_changed_cb(
+EXPORT_API int notification_register_detailed_changed_cb(
                void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
                void *user_data)
 {
-       notification_cb_list_s *noti_cb_list = NULL;
-       notification_cb_list_s *noti_cb_list_prev = NULL;
-       notification_cb_list_s *noti_cb_list_next = NULL;
+       return notification_register_detailed_changed_cb_for_uid(detailed_changed_cb, user_data, getuid());
+}
 
-       noti_cb_list = g_notification_cb_list;
+EXPORT_API int notification_unregister_detailed_changed_cb_for_uid(
+               void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
+               void *user_data, uid_t uid)
+{
+       notification_cb_info_s *noti_cb_info = NULL;
+       GList *noti_cb_list = NULL;
 
        if (detailed_changed_cb == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       if (noti_cb_list == NULL)
+       if (_noti_cb_hash == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
+       noti_cb_list = (GList *)g_hash_table_lookup(_noti_cb_hash, GUINT_TO_POINTER(uid));
 
-       while (noti_cb_list->prev != NULL)
-               noti_cb_list = noti_cb_list->prev;
-
-
-       do {
-               if (noti_cb_list->detailed_changed_cb == detailed_changed_cb) {
-                       noti_cb_list_prev = noti_cb_list->prev;
-                       noti_cb_list_next = noti_cb_list->next;
-
-                       if (noti_cb_list_prev == NULL)
-                               g_notification_cb_list = noti_cb_list_next;
-                       else
-                               noti_cb_list_prev->next = noti_cb_list_next;
+       if (noti_cb_list == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-                       if (noti_cb_list_next == NULL) {
-                               if (noti_cb_list_prev != NULL)
-                                       noti_cb_list_prev->next = NULL;
+       noti_cb_list = g_list_first(noti_cb_list);
 
-                       } else {
-                               noti_cb_list_next->prev = noti_cb_list_prev;
-                       }
+       for (; noti_cb_list != NULL; noti_cb_list = noti_cb_list->next) {
+               noti_cb_info = noti_cb_list->data;
+               if (noti_cb_info->detailed_changed_cb == detailed_changed_cb) {
+                       noti_cb_list = g_list_remove(g_list_first(noti_cb_list), noti_cb_info);
 
-                       free(noti_cb_list);
+                       if (noti_cb_list == NULL)
+                               g_hash_table_steal(_noti_cb_hash, GUINT_TO_POINTER(uid));
 
-                       if (g_notification_cb_list == NULL)
+                       if (g_hash_table_size(_noti_cb_hash) == 0)
                                notification_ipc_monitor_fini();
 
                        return NOTIFICATION_ERROR_NONE;
                }
-               noti_cb_list = noti_cb_list->next;
-       } while (noti_cb_list != NULL);
+       }
 
        return NOTIFICATION_ERROR_INVALID_PARAMETER;
 }
 
+EXPORT_API int notification_unregister_detailed_changed_cb(
+               void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
+               void *user_data)
+{
+       return notification_unregister_detailed_changed_cb_for_uid(detailed_changed_cb, user_data, getuid());
+}
+
+/* LCOV_EXCL_START */
 EXPORT_API int notification_is_service_ready(void)
 {
        return notification_ipc_is_master_ready();
 }
+/* LCOV_EXCL_STOP */
+
+EXPORT_API int notification_set_uid(notification_h noti,
+               uid_t uid)
+{
+       if (noti == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       noti->uid = uid;
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_get_uid(notification_h noti,
+               uid_t *uid)
+{
+       if (noti == NULL || uid == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       *uid = noti->uid;
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_post_for_uid(notification_h noti, uid_t uid)
+{
+       int ret = 0;
+       int id = 0;
+
+       if (noti == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       if (noti->type <= NOTIFICATION_TYPE_NONE
+                       || noti->type >= NOTIFICATION_TYPE_MAX)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
+       /* Save insert time */
+       noti->insert_time = time(NULL);
+       noti->uid = uid;
+
+       ret = notification_ipc_request_insert(noti, &id);
+       if (ret != NOTIFICATION_ERROR_NONE)
+               return ret;
+
+       noti->priv_id = id;
+       NOTIFICATION_DBG("from master:%d", id);
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_update_for_uid(notification_h noti, uid_t uid)
+{
+       if (noti == NULL) {
+               notification_ipc_request_refresh(uid);
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+       }
+
+       noti->uid = uid;
+       /* Update insert time ? */
+       noti->insert_time = time(NULL);
+
+       return notification_ipc_request_update(noti);
+}
+
+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,
+                               noti->caller_pkgname, noti->priv_id, uid);
+}
+
+EXPORT_API int notification_delete_all_for_uid(notification_type_e type, uid_t uid)
+{
+       int ret = 0;
+       char *caller_pkgname = NULL;
+
+       if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       caller_pkgname = notification_get_pkgname_by_pid();
+
+       ret = notification_ipc_request_delete_multiple(type, caller_pkgname, uid);
+
+       if (caller_pkgname)
+               free(caller_pkgname);
+
+       return ret;
+}
+
+EXPORT_API notification_h notification_load_by_tag_for_uid(const char *tag, uid_t uid)
+{
+       int ret = 0;
+       notification_h noti = NULL;
+       char *caller_pkgname = NULL;
+
+       if (tag == NULL) {
+               NOTIFICATION_ERR("Invalid parameter");
+               set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
+               return NULL;
+       }
+
+       caller_pkgname = notification_get_pkgname_by_pid();
+       if (!caller_pkgname) {
+               /* LCOV_EXCL_START */
+               NOTIFICATION_ERR("Failed to get a package name");
+               set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
+               return NULL;
+               /* LCOV_EXCL_STOP */
+       }
+
+       noti = (notification_h)calloc(1, sizeof(struct _notification));
+       if (noti == NULL) {
+               /* LCOV_EXCL_START */
+               NOTIFICATION_ERR("Failed to alloc a new notification");
+               set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
+               free(caller_pkgname);
+
+               return NULL;
+               /* LCOV_EXCL_STOP */
+       }
+
+       ret = notification_ipc_request_load_noti_by_tag(noti, caller_pkgname, (char *)tag, uid);
+       free(caller_pkgname);
+
+       set_last_result(ret);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               notification_free(noti);
+               return NULL;
+       }
+
+       return noti;
+}
+
+EXPORT_API notification_h notification_create_from_package_template(const char *pkgname, const char *template_name)
+{
+       int ret = 0;
+       notification_h noti = NULL;
+
+       if (pkgname == NULL || template_name == NULL) {
+               NOTIFICATION_ERR("Invalid parameter");
+               set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
+               return NULL;
+       }
+
+       noti = (notification_h)calloc(1, sizeof(struct _notification));
+       if (noti == NULL) {
+               NOTIFICATION_ERR("Failed to alloc a new notification");
+               set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
+               return NULL;
+       }
+
+       ret = notification_ipc_request_create_from_package_template(noti, pkgname, template_name);
+
+       set_last_result(ret);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               notification_free(noti);
+               return NULL;
+       }
+
+       return noti;
+}
+
+EXPORT_API int notification_set_default_button(notification_h noti, notification_button_index_e index)
+{
+       if (noti == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       if (index < 0 || index > NOTIFICATION_BUTTON_6)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       noti->default_button_index = index;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_get_default_button(notification_h noti, notification_button_index_e *index)
+{
+       if (noti == NULL || index == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       *index = noti->default_button_index;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_get_ongoing_value_type(notification_h noti, notification_ongoing_value_type_e *type)
+{
+       if (noti == NULL || type == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       *type = noti->ongoing_value_type;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_set_ongoing_value_type(notification_h noti, notification_ongoing_value_type_e type)
+{
+       if (noti == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       if (type < NOTIFICATION_ONGOING_VALUE_TYPE_PERCENT || type > NOTIFICATION_ONGOING_VALUE_TYPE_TIME)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       noti->ongoing_value_type = type;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_get_ongoing_time(notification_h noti, int *current, int *duration)
+{
+       if (noti == NULL || current == NULL || duration == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       *current = noti->ongoing_current;
+       *duration = noti->ongoing_duration;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_set_ongoing_time(notification_h noti, int current, int duration)
+{
+       if (noti == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       if (current < 0 || duration < 0 || current > duration)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       noti->ongoing_current = current;
+       noti->ongoing_duration = duration;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_get_hide_timeout(notification_h noti, int *timeout)
+{
+       if (noti == NULL || timeout == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       *timeout = noti->timeout;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_set_hide_timeout(notification_h noti, int timeout)
+{
+       if (noti == NULL || timeout < 0)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       noti->timeout = timeout;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_get_text_input_max_length(notification_h noti, int *text_input_max_length)
+{
+       if (noti == NULL || text_input_max_length == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       *text_input_max_length = noti->text_input_max_length;
+
+       return NOTIFICATION_ERROR_NONE;
+}