Add exception in case pkgname is null
[platform/core/api/notification.git] / src / notification_ipc.c
index 0453361..be7b43c 100755 (executable)
@@ -1,9 +1,5 @@
 /*
- *  libnotification
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +12,6 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- *
  */
 
 #include <stdio.h>
@@ -44,6 +39,7 @@
 #define DBUS_SERVICE_DBUS "org.freedesktop.DBus"
 #define DBUS_PATH_DBUS "/org/freedesktop/DBus"
 #define DBUS_INTERFACE_DBUS "org.freedesktop.DBus"
+#define ERR_BUFFER_SIZE                1024
 
 static const gchar *_bus_name = NULL;
 static GDBusConnection *_gdbus_conn = NULL;
@@ -67,27 +63,31 @@ struct _task_list {
 
 static task_list *g_task_list;
 
-static int _ipc_monitor_register(void);
+static int _ipc_monitor_register(uid_t uid);
 static int _ipc_monitor_deregister(void);
 static void _do_deffered_task(void);
 
-static void _print_noti(notification_h noti) {
+static void _print_noti(notification_h noti)
+{
        char *pkgname = NULL;
        char *text = NULL;
        char *content = NULL;
        const char *tag = NULL;
+       notification_vibration_type_e vib_type = NOTIFICATION_VIBRATION_TYPE_NONE;
 
        notification_get_pkgname(noti, &pkgname);
        notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, &text);
        notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, &content);
        notification_get_tag(noti, &tag);
+       notification_get_vibration(noti, &vib_type, NULL);
 
-       NOTIFICATION_DBG("client print_noti  pkgname  = %s ", pkgname );
-       NOTIFICATION_DBG("client print_noti  title  = %s ", text );
-       NOTIFICATION_DBG("client print_noti  content  = %s ", content );
-       NOTIFICATION_DBG("client print_noti  tag  = %s ", tag );
+       NOTIFICATION_DBG("client print_noti  pkgname  = %s ", pkgname);
+       NOTIFICATION_DBG("client print_noti  title  = %s ", text);
+       NOTIFICATION_DBG("client print_noti  content  = %s ", content);
+       NOTIFICATION_DBG("client print_noti  tag  = %s ", tag);
        NOTIFICATION_DBG("client print_noti  priv_id  = %d ", noti->priv_id);
        NOTIFICATION_DBG("client print_noti  vibration_path  = %s ", noti->vibration_path);
+       NOTIFICATION_DBG("client print_noti  vibration_type  = %d ", vib_type);
 }
 
 static inline char *_string_get(char *string)
@@ -101,12 +101,43 @@ static inline char *_string_get(char *string)
        return string;
 }
 
+static int _dbus_init()
+{
+       GError *error = NULL;
+
+       if (_gdbus_conn == NULL) {
+               _gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+
+               if (_gdbus_conn == NULL) {
+                       if (error != NULL) {
+                               NOTIFICATION_ERR("Failed to get dbus [%s]", error->message);
+                               g_error_free(error);
+                       }
+                       return NOTIFICATION_ERROR_IO_ERROR;
+               }
+               _bus_name = g_dbus_connection_get_unique_name(_gdbus_conn);
+               NOTIFICATION_DBG("bus name : %s", _bus_name);
+
+               notification_error_quark();
+
+       }
+       return NOTIFICATION_ERROR_NONE;
+}
 
+/* LCOV_EXCL_START */
 int notification_ipc_is_master_ready(void)
 {
        GVariant *result;
        GError *err = NULL;
        gboolean name_exist;
+       int ret = NOTIFICATION_ERROR_NONE;
+
+       ret = _dbus_init();
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               NOTIFICATION_ERR("Can't init dbus %d", ret);
+               is_master_started = 0;
+               return is_master_started;
+       }
 
        result = g_dbus_connection_call_sync(
                        _gdbus_conn,
@@ -123,9 +154,10 @@ int notification_ipc_is_master_ready(void)
 
        if (err || (result == NULL)) {
                if (err) {
-               NOTIFICATION_ERR("No reply. error = %s", err->message);
+                       NOTIFICATION_ERR("No reply. error = %s", err->message);
                        g_error_free(err);
                }
+               NOTIFICATION_ERR("is master ready fail");
                is_master_started = 0;
        } else {
                g_variant_get(result, "(b)", &name_exist);
@@ -140,11 +172,12 @@ int notification_ipc_is_master_ready(void)
                }
        }
 
-       if(result)
+       if (result)
                g_variant_unref(result);
 
        return is_master_started;
 }
+/* LCOV_EXCL_STOP */
 
 /* TODO: dbus activation isn't enough ? */
 /*
@@ -157,9 +190,7 @@ int notification_ipc_add_deffered_task(
        task_list *list;
        task_list *list_new;
 
-       list_new =
-           (task_list *) malloc(sizeof(task_list));
-
+       list_new = (task_list *) malloc(sizeof(task_list));
        if (list_new == NULL)
                return NOTIFICATION_ERROR_OUT_OF_MEMORY;
 
@@ -180,6 +211,7 @@ int notification_ipc_add_deffered_task(
                list->next = list_new;
                list_new->prev = list;
        }
+
        return NOTIFICATION_ERROR_NONE;
 }
 
@@ -224,6 +256,7 @@ int notification_ipc_del_deffered_task(
        return NOTIFICATION_ERROR_INVALID_PARAMETER;
 }
 
+/* LCOV_EXCL_START */
 static void _do_deffered_task(void)
 {
        task_list *list_do;
@@ -248,6 +281,7 @@ static void _do_deffered_task(void)
                list_do = list_temp;
        }
 }
+/* LCOV_EXCL_STOP */
 
 /*!
  * functions to create operation list
@@ -262,7 +296,6 @@ static notification_op *_ipc_create_op(notification_op_type_e type,
                return NULL;
 
        op_list = (notification_op *)malloc(sizeof(notification_op) * num_op);
-
        if (op_list == NULL) {
                NOTIFICATION_ERR("malloc failed");
                return NULL;
@@ -287,34 +320,34 @@ static notification_op *_ipc_create_op(notification_op_type_e type,
 static inline char *_dup_string(const char *string)
 {
        char *ret;
+       char err_buf[ERR_BUFFER_SIZE];
 
-       if (string == NULL)
-               return NULL;
-       if (string[0] == '\0')
+       if (string == NULL || string[0] == '\0')
                return NULL;
 
        ret = strdup(string);
        if (!ret)
-               NOTIFICATION_ERR("Error: %s\n", strerror(errno));
+               NOTIFICATION_ERR("Error: %s\n", strerror_r(errno, err_buf, sizeof(err_buf)));
 
        return ret;
 }
 
 static inline bundle *_create_bundle_from_bundle_raw(bundle_raw *string)
 {
-       if (string == NULL)
-               return NULL;
-       if (string[0] == '\0')
+       if (string == NULL || string[0] == '\0')
                return NULL;
 
        return bundle_decode(string, strlen((char *)string));
 }
 
+/* LCOV_EXCL_START */
 static void _add_noti_notify(GVariant *parameters)
 {
+       int ret;
        notification_h noti;
        notification_op *noti_op;
        GVariant *body = NULL;
+       uid_t uid;
 
        NOTIFICATION_DBG("add noti notify");
        noti = notification_create(NOTIFICATION_TYPE_NOTI);
@@ -332,72 +365,92 @@ static void _add_noti_notify(GVariant *parameters)
        } else {
                /* Enable changed cb */
                noti_op = _ipc_create_op(NOTIFICATION_OP_INSERT, 1, &(noti->priv_id), 1, &noti);
-
-               if (noti_op != NULL) {
-                       notification_call_changed_cb(noti_op, 1);
+               ret = notification_get_uid(noti, &uid);
+               if (noti_op != NULL && ret == NOTIFICATION_ERROR_NONE) {
+                       notification_call_changed_cb_for_uid(noti_op, 1, uid);
                        free(noti_op);
                }
        }
+       g_variant_unref(body);
        notification_free(noti);
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static void _update_noti_notify(GVariant *parameters)
 {
+       int ret;
        notification_h noti;
        notification_op *noti_op;
        GVariant *body = NULL;
+       uid_t uid;
 
        noti = notification_create(NOTIFICATION_TYPE_NOTI);
        if (!noti) {
                NOTIFICATION_ERR("failed to create a notification");
                return;
        }
+
        g_variant_get(parameters, "(v)", &body);
        notification_ipc_make_noti_from_gvariant(noti, body);
        _print_noti(noti);
 
        noti_op = _ipc_create_op(NOTIFICATION_OP_UPDATE, 1, &(noti->priv_id), 1, &noti);
-       if (noti_op != NULL) {
-               notification_call_changed_cb(noti_op, 1);
+       ret = notification_get_uid(noti, &uid);
+       if (noti_op != NULL && ret == NOTIFICATION_ERROR_NONE) {
+               notification_call_changed_cb_for_uid(noti_op, 1, uid);
                free(noti_op);
        }
+
+       g_variant_unref(body);
        notification_free(noti);
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static void _refresh_noti_notify(GVariant *parameters)
 {
+       uid_t uid;
        notification_op *noti_op = _ipc_create_op(NOTIFICATION_OP_REFRESH, 1, NULL, 0, NULL);
 
+       g_variant_get(parameters, "(i)", &uid);
+
        if (noti_op != NULL) {
-               notification_call_changed_cb(noti_op, 1);
+               notification_call_changed_cb_for_uid(noti_op, 1, uid);
                free(noti_op);
        }
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static void _delete_single_notify(GVariant *parameters)
 {
        int num_deleted;
        int priv_id;
        notification_op *noti_op;
+       uid_t uid;
 
        /* num_deleted ?? */
-       g_variant_get(parameters, "(ii)", &num_deleted, &priv_id);
+       g_variant_get(parameters, "(iii)", &num_deleted, &priv_id, &uid);
 
        noti_op = _ipc_create_op(NOTIFICATION_OP_DELETE, 1, &priv_id, 1, NULL);
        if (noti_op != NULL) {
-               notification_call_changed_cb(noti_op, 1);
+               notification_call_changed_cb_for_uid(noti_op, 1, uid);
                free(noti_op);
        }
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static void _delete_multiple_notify(GVariant *parameters)
 {
        int buf[100] = {0,};
        int idx = 0;
        notification_op *noti_op;
        GVariantIter *iter;
+       uid_t uid;
 
-       g_variant_get(parameters, "(a(i))", &iter);
+       g_variant_get(parameters, "(a(i)i)", &iter, &uid);
        while (g_variant_iter_loop(iter, "(i)", &buf[idx])) {
                NOTIFICATION_DBG("delete_noti_multiple priv_id : %d", buf[idx]);
                idx++;
@@ -406,15 +459,30 @@ static void _delete_multiple_notify(GVariant *parameters)
 
        NOTIFICATION_DBG("data num deleted:%d", idx);
        noti_op = _ipc_create_op(NOTIFICATION_OP_DELETE, idx, buf, idx, NULL);
-
        if (noti_op == NULL) {
                NOTIFICATION_ERR("_ipc_create_op failed");
                return;
        }
-       notification_call_changed_cb(noti_op, idx);
+
+       notification_call_changed_cb_for_uid(noti_op, idx, uid);
        free(noti_op);
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
+static void _change_dnd_notify(GVariant *parameters)
+{
+       int do_not_disturb;
+       uid_t uid;
+
+       g_variant_get(parameters, "(ii)", &do_not_disturb, &uid);
+       NOTIFICATION_DBG("do_not_disturb[%d], uid[%d]", do_not_disturb, uid);
+
+       notification_call_dnd_changed_cb_for_uid(do_not_disturb, uid);
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
 static void _handle_noti_notify(GDBusConnection *connection,
                const gchar     *sender_name,
                const gchar     *object_path,
@@ -423,7 +491,8 @@ static void _handle_noti_notify(GDBusConnection *connection,
                GVariant        *parameters,
                gpointer         user_data)
 {
-       NOTIFICATION_DBG("signal_name: %s", signal_name);
+       NOTIFICATION_DBG("own_name : %s signal_name: %s",
+                        g_dbus_connection_get_unique_name(connection), signal_name);
 
        if (g_strcmp0(signal_name, "add_noti_notify") == 0)
                _add_noti_notify(parameters);
@@ -435,8 +504,10 @@ static void _handle_noti_notify(GDBusConnection *connection,
                _delete_multiple_notify(parameters);
        else if (g_strcmp0(signal_name, "refresh_noti_notify") == 0)
                _refresh_noti_notify(parameters);
+       else if (g_strcmp0(signal_name, "change_dnd_notify") == 0)
+               _change_dnd_notify(parameters);
 }
-
+/* LCOV_EXCL_STOP */
 
 static int _dbus_signal_init()
 {
@@ -457,39 +528,16 @@ static int _dbus_signal_init()
 
                NOTIFICATION_DBG("subscribe id : %d", id);
                if (id == 0) {
+                       /* LCOV_EXCL_START */
                        ret = NOTIFICATION_ERROR_IO_ERROR;
                        NOTIFICATION_ERR("Failed to _register_noti_dbus_interface");
+                       /* LCOV_EXCL_STOP */
                } else {
                        monitor_id = id;
                        ret = NOTIFICATION_ERROR_NONE;
                }
        }
-       return ret;
-}
 
-
-static int _dbus_init()
-{
-       int ret = NOTIFICATION_ERROR_NONE;
-       GError *error = NULL;
-
-       if (_gdbus_conn == NULL) {
-               _gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
-
-               if (_gdbus_conn == NULL) {
-                       if (error != NULL) {
-                               NOTIFICATION_ERR("Failed to get dbus [%s]", error->message);
-                               g_error_free(error);
-                       }
-                       return NOTIFICATION_ERROR_IO_ERROR;
-               }
-               _bus_name = g_dbus_connection_get_unique_name(_gdbus_conn);
-               NOTIFICATION_DBG("bus name : %s", _bus_name);
-
-               notification_error_quark();
-
-               ret = NOTIFICATION_ERROR_NONE;
-       }
        return ret;
 }
 
@@ -505,10 +553,12 @@ static int _send_sync_noti(GVariant *body, GDBusMessage **reply, char *cmd)
                        PROVIDER_NOTI_INTERFACE_NAME,
                        cmd);
        if (!msg) {
+               /* LCOV_EXCL_START */
                NOTIFICATION_ERR("Can't allocate new method call");
                if (body)
                        g_variant_unref(body);
                return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+               /* LCOV_EXCL_STOP */
        }
 
        if (body != NULL)
@@ -526,6 +576,7 @@ static int _send_sync_noti(GVariant *body, GDBusMessage **reply, char *cmd)
        g_object_unref(msg);
 
        if (!*reply) {
+               /* LCOV_EXCL_START */
                ret = NOTIFICATION_ERROR_SERVICE_NOT_READY;
                if (err != NULL) {
                        NOTIFICATION_ERR("No reply. cmd = %s,  error = %s", cmd, err->message);
@@ -534,17 +585,22 @@ static int _send_sync_noti(GVariant *body, GDBusMessage **reply, char *cmd)
                        g_error_free(err);
                }
                return ret;
+               /* LCOV_EXCL_STOP */
        }
 
        if (g_dbus_message_to_gerror(*reply, &err)) {
-               ret = err->code;
-               NOTIFICATION_ERR("_send_sync_noti cmd = %s, error %s", cmd, err->message);
+               if (err->code == G_DBUS_ERROR_ACCESS_DENIED)
+                       ret = NOTIFICATION_ERROR_PERMISSION_DENIED;
+               else
+                       ret = err->code;
+
+               NOTIFICATION_ERR("_send_sync_noti cmd = %s, error %s, err code %d", cmd, err->message, ret);
                g_error_free(err);
                return ret;
        }
+
        NOTIFICATION_DBG("_send_sync_noti done !!");
        return NOTIFICATION_ERROR_NONE;
-
 }
 
 static void _send_message_with_reply_async_cb(GDBusConnection *connection,
@@ -569,16 +625,24 @@ static void _send_message_with_reply_async_cb(GDBusConnection *connection,
                        &err);
 
        if (!reply) {
+               /* LCOV_EXCL_START */
                if (err != NULL) {
                        NOTIFICATION_ERR("No reply. error = %s", err->message);
                        g_error_free(err);
                }
                result = NOTIFICATION_ERROR_SERVICE_NOT_READY;
+               /* LCOV_EXCL_STOP */
 
        } else if (g_dbus_message_to_gerror(reply, &err)) {
-               result = err->code;
-               g_error_free(err);
+               /* LCOV_EXCL_START */
+               if (err->code == G_DBUS_ERROR_ACCESS_DENIED)
+                       result = NOTIFICATION_ERROR_PERMISSION_DENIED;
+               else
+                       result = err->code;
+
                NOTIFICATION_ERR("_send_async_noti error %s", err->message);
+               g_error_free(err);
+               /* LCOV_EXCL_STOP */
        }
 
        NOTIFICATION_DBG("_send_async_noti done !![%d]", result);
@@ -589,7 +653,6 @@ static void _send_message_with_reply_async_cb(GDBusConnection *connection,
 
                if (cb_item->result_cb)
                        cb_item->result_cb(priv_id, result, cb_item->data);
-
        } else {
                if (cb_item->result_cb)
                        cb_item->result_cb(NOTIFICATION_PRIV_ID_NONE, result, cb_item->data);
@@ -610,8 +673,10 @@ static int _send_async_noti(GVariant *body, result_cb_item *cb_item, char *cmd)
                        PROVIDER_NOTI_INTERFACE_NAME,
                        cmd);
        if (!msg) {
+               /* LCOV_EXCL_START */
                NOTIFICATION_ERR("Can't allocate new method call");
                return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+               /* LCOV_EXCL_STOP */
        }
 
        if (body != NULL)
@@ -636,7 +701,7 @@ static int _send_async_noti(GVariant *body, result_cb_item *cb_item, char *cmd)
 int notification_ipc_request_insert(notification_h noti, int *priv_id)
 {
        int result;
-       int id;
+       int id = NOTIFICATION_PRIV_ID_NONE;
        GDBusMessage *reply = NULL;
        GVariant *body;
        GVariant *reply_body;
@@ -648,15 +713,16 @@ int notification_ipc_request_insert(notification_h noti, int *priv_id)
        }
 
        /* Initialize private ID */
-       noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
        noti->group_id = NOTIFICATION_GROUP_ID_NONE;
        noti->internal_group_id = NOTIFICATION_GROUP_ID_NONE;
 
        _print_noti(noti);
-       body = notification_ipc_make_gvariant_from_noti(noti);
+       body = notification_ipc_make_gvariant_from_noti(noti, false);
        if (body == NULL) {
+               /* LCOV_EXCL_START */
                NOTIFICATION_ERR("cannot make gvariant");
                return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+               /* LCOV_EXCL_STOP */
        }
 
        result = _send_sync_noti(body, &reply, "add_noti");
@@ -670,17 +736,17 @@ int notification_ipc_request_insert(notification_h noti, int *priv_id)
                        *priv_id = id;
        }
 
-       if(reply)
+       if (reply)
                g_object_unref(reply);
 
-       NOTIFICATION_DBG("notification_ipc_request_insert done [priv_id : %d, result: %d]", *priv_id, result);
+       NOTIFICATION_DBG("notification_ipc_request_insert done [priv_id : %d, result: %d]", id, result);
        return result;
 }
 
 int notification_ipc_request_update(notification_h noti)
 {
        int result;
-       int priv_id;
+       int priv_id = NOTIFICATION_PRIV_ID_NONE;
 
        GDBusMessage *reply = NULL;
        GVariant *body;
@@ -688,14 +754,18 @@ int notification_ipc_request_update(notification_h noti)
 
        result = _dbus_init();
        if (result != NOTIFICATION_ERROR_NONE) {
+               /* LCOV_EXCL_START */
                NOTIFICATION_ERR("Can't init dbus %d", result);
                return result;
+               /* LCOV_EXCL_STOP */
        }
 
-       body = notification_ipc_make_gvariant_from_noti(noti);
+       body = notification_ipc_make_gvariant_from_noti(noti, false);
        if (body == NULL) {
+               /* LCOV_EXCL_START */
                NOTIFICATION_ERR("cannot make gvariant");
                return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+               /* LCOV_EXCL_STOP */
        }
 
        result = _send_sync_noti(body, &reply, "update_noti");
@@ -704,7 +774,7 @@ int notification_ipc_request_update(notification_h noti)
                g_variant_get(reply_body, "(i)", &priv_id);
        }
 
-       if(reply)
+       if (reply)
                g_object_unref(reply);
 
        NOTIFICATION_DBG("notification_ipc_request_update done [result: %d, priv_id :%d]", result, priv_id);
@@ -720,8 +790,10 @@ int notification_ipc_request_update_async(notification_h noti,
 
        result = _dbus_init();
        if (result != NOTIFICATION_ERROR_NONE) {
+               /* LCOV_EXCL_START */
                NOTIFICATION_ERR("Can't init dbus %d", result);
                return result;
+               /* LCOV_EXCL_STOP */
        }
 
        cb_item = calloc(1, sizeof(result_cb_item));
@@ -731,19 +803,23 @@ int notification_ipc_request_update_async(notification_h noti,
        cb_item->result_cb = result_cb;
        cb_item->data = user_data;
 
-       body = notification_ipc_make_gvariant_from_noti(noti);
+       body = notification_ipc_make_gvariant_from_noti(noti, false);
        if (body == NULL) {
+               /* LCOV_EXCL_START */
                NOTIFICATION_ERR("cannot make gvariant");
                free(cb_item);
                return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+               /* LCOV_EXCL_STOP */
        }
 
        result = _send_async_noti(body, cb_item, "update_noti");
        NOTIFICATION_DBG("notification_ipc_request_update_async done [result: %d]", result);
 
        if (result != NOTIFICATION_ERROR_NONE) {
+               /* LCOV_EXCL_START */
                free(cb_item);
                cb_item = NULL;
+               /* LCOV_EXCL_STOP */
        }
 
        g_variant_unref(body);
@@ -751,7 +827,7 @@ int notification_ipc_request_update_async(notification_h noti,
        return result;
 }
 
-int notification_ipc_request_refresh(void)
+int notification_ipc_request_refresh(uid_t uid)
 {
        int result;
        GDBusMessage *reply = NULL;
@@ -763,17 +839,17 @@ int notification_ipc_request_refresh(void)
                return result;
        }
 
-       body = g_variant_new("(i)", NOTIFICATION_OP_REFRESH);
+       body = g_variant_new("(i)", uid);
        result = _send_sync_noti(body, &reply, "refresh_noti");
 
-       if(reply)
+       if (reply)
                g_object_unref(reply);
 
        NOTIFICATION_ERR("notification_ipc_request_refresh done [result: %d]", result);
        return result;
 }
 
-int notification_ipc_request_delete_single(notification_type_e type, char *pkgname, int priv_id)
+int notification_ipc_request_delete_single(notification_type_e type, char *pkgname, int priv_id, uid_t uid)
 {
        int result;
        int id;
@@ -787,7 +863,10 @@ int notification_ipc_request_delete_single(notification_type_e type, char *pkgna
                return result;
        }
 
-       body = g_variant_new("(si)", pkgname, priv_id);
+       if (!pkgname)
+               pkgname = "";
+
+       body = g_variant_new("(sii)", pkgname, priv_id, uid);
        result = _send_sync_noti(body, &reply, "del_noti_single");
 
        if (result == NOTIFICATION_ERROR_NONE) {
@@ -795,14 +874,14 @@ int notification_ipc_request_delete_single(notification_type_e type, char *pkgna
                g_variant_get(reply_body, "(i)", &id);
        }
 
-       if(reply)
+       if (reply)
                g_object_unref(reply);
 
        NOTIFICATION_ERR("notification_ipc_request_delete_single done [result: %d]", result);
        return result;
 }
 
-int notification_ipc_request_delete_multiple(notification_type_e type, char *pkgname)
+int notification_ipc_request_delete_multiple(notification_type_e type, char *pkgname, uid_t uid)
 {
        int result;
        int num_deleted;
@@ -816,7 +895,10 @@ int notification_ipc_request_delete_multiple(notification_type_e type, char *pkg
                return result;
        }
 
-       body = g_variant_new("(si)", pkgname, type);
+       if (!pkgname)
+               pkgname = "";
+
+       body = g_variant_new("(sii)", pkgname, type, uid);
        result = _send_sync_noti(body, &reply, "del_noti_multiple");
 
        if (result == NOTIFICATION_ERROR_NONE) {
@@ -825,13 +907,13 @@ int notification_ipc_request_delete_multiple(notification_type_e type, char *pkg
                NOTIFICATION_ERR("num deleted:%d", num_deleted);
        }
 
-       if(reply)
+       if (reply)
                g_object_unref(reply);
 
        return result;
 }
 
-int notification_ipc_request_load_noti_by_tag(notification_h noti, const char *pkgname, const char *tag)
+int notification_ipc_request_load_noti_by_tag(notification_h noti, const char *pkgname, const char *tag, uid_t uid)
 {
        int result;
        GDBusMessage *reply = NULL;
@@ -845,7 +927,10 @@ int notification_ipc_request_load_noti_by_tag(notification_h noti, const char *p
                return result;
        }
 
-       body = g_variant_new("(ss)", pkgname, tag);
+       if (!pkgname)
+               pkgname = "";
+
+       body = g_variant_new("(ssi)", pkgname, tag, uid);
        result = _send_sync_noti(body, &reply, "load_noti_by_tag");
 
        if (result == NOTIFICATION_ERROR_NONE) {
@@ -858,14 +943,15 @@ int notification_ipc_request_load_noti_by_tag(notification_h noti, const char *p
 
        }
 
-       if(reply)
+       if (reply)
                g_object_unref(reply);
 
        NOTIFICATION_DBG("notification_ipc_request_load_noti_by_tag done [result: %d]", result);
        return result;
 }
 
-int notification_ipc_request_load_noti_by_priv_id(notification_h noti, const char *pkgname, int priv_id)
+/* LCOV_EXCL_START */
+int notification_ipc_request_load_noti_by_priv_id(notification_h noti, const char *pkgname, int priv_id, uid_t uid)
 {
        int result;
        GDBusMessage *reply = NULL;
@@ -879,7 +965,10 @@ int notification_ipc_request_load_noti_by_priv_id(notification_h noti, const cha
                return result;
        }
 
-       body = g_variant_new("(si)", pkgname, priv_id);
+       if (!pkgname)
+               pkgname = "";
+
+       body = g_variant_new("(sii)", pkgname, priv_id, uid);
        result = _send_sync_noti(body, &reply, "load_noti_by_priv_id");
 
        if (result == NOTIFICATION_ERROR_NONE) {
@@ -891,15 +980,17 @@ int notification_ipc_request_load_noti_by_priv_id(notification_h noti, const cha
                _print_noti(noti);
        }
 
-       if(reply)
+       if (reply)
                g_object_unref(reply);
 
        NOTIFICATION_DBG("notification_ipc_request_load_noti_by_priv_id done [result: %d]", result);
        return result;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 int notification_ipc_request_get_count(notification_type_e type,
-                   const char *pkgname, int group_id, int priv_id, int *count)
+                   const char *pkgname, int group_id, int priv_id, int *count, uid_t uid)
 {
        int result;
        GDBusMessage *reply = NULL;
@@ -913,7 +1004,10 @@ int notification_ipc_request_get_count(notification_type_e type,
                return result;
        }
 
-       body = g_variant_new("(isii)", type, pkgname, group_id, priv_id);
+       if (!pkgname)
+               pkgname = "";
+
+       body = g_variant_new("(isiii)", type, pkgname, group_id, priv_id, uid);
        result = _send_sync_noti(body, &reply, "get_noti_count");
 
        if (result == NOTIFICATION_ERROR_NONE) {
@@ -924,15 +1018,16 @@ int notification_ipc_request_get_count(notification_type_e type,
                NOTIFICATION_DBG("noti count [%d]", re_count);
        }
 
-       if(reply)
+       if (reply)
                g_object_unref(reply);
 
        NOTIFICATION_DBG("notification_ipc_request_get_count done [result: %d]", result);
        return result;
 }
+/* LCOV_EXCL_STOP */
 
 int notification_ipc_request_load_noti_grouping_list(notification_type_e type, int count,
-               notification_list_h *list)
+               notification_list_h *list, uid_t uid)
 {
        int result;
        GDBusMessage *reply = NULL;
@@ -949,7 +1044,7 @@ int notification_ipc_request_load_noti_grouping_list(notification_type_e type, i
                return result;
        }
 
-       body = g_variant_new("(ii)", type, count);
+       body = g_variant_new("(iii)", type, count, uid);
        result = _send_sync_noti(body, &reply, "load_noti_grouping_list");
 
        if (result == NOTIFICATION_ERROR_NONE) {
@@ -958,15 +1053,21 @@ int notification_ipc_request_load_noti_grouping_list(notification_type_e type, i
 
                while (g_variant_iter_loop(iter, "(v)", &iter_body)) {
                        noti = notification_create(NOTIFICATION_TYPE_NOTI);
+                       if (!noti) {
+                               result = NOTIFICATION_ERROR_OUT_OF_MEMORY;
+                               NOTIFICATION_ERR("failed to create a notification");
+                               notification_free_list(*list);
+                               break;
+                       }
                        g_variant_get(iter_body, "(v)", &noti_body);
                        notification_ipc_make_noti_from_gvariant(noti, noti_body);
-                       _print_noti(noti);
                        *list = notification_list_append(*list, noti);
+                       g_variant_unref(noti_body);
                }
                g_variant_iter_free(iter);
        }
 
-       if(reply)
+       if (reply)
                g_object_unref(reply);
 
        NOTIFICATION_DBG("notification_ipc_request_load_noti_grouping_list done [result: %d]", result);
@@ -977,7 +1078,8 @@ int notification_ipc_request_load_noti_detail_list(const char *pkgname,
                int group_id,
                int priv_id,
                int count,
-               notification_list_h *list)
+               notification_list_h *list,
+               uid_t uid)
 {
        int result;
        GDBusMessage *reply = NULL;
@@ -994,7 +1096,7 @@ int notification_ipc_request_load_noti_detail_list(const char *pkgname,
                return result;
        }
 
-       body = g_variant_new("(siii)", pkgname, group_id, priv_id, count);
+       body = g_variant_new("(siiii)", pkgname, group_id, priv_id, count, uid);
        result = _send_sync_noti(body, &reply, "load_noti_detail_list");
 
        if (result == NOTIFICATION_ERROR_NONE) {
@@ -1003,15 +1105,21 @@ int notification_ipc_request_load_noti_detail_list(const char *pkgname,
 
                while (g_variant_iter_loop(iter, "(v)", &iter_body)) {
                        noti = notification_create(NOTIFICATION_TYPE_NOTI);
+                       if (!noti) {
+                               result = NOTIFICATION_ERROR_OUT_OF_MEMORY;
+                               NOTIFICATION_ERR("failed to create a notification");
+                               notification_free_list(*list);
+                               break;
+                       }
                        g_variant_get(iter_body, "(v)", &noti_body);
                        notification_ipc_make_noti_from_gvariant(noti, noti_body);
-                       _print_noti(noti);
                        *list = notification_list_append(*list, noti);
+                       g_variant_unref(noti_body);
                }
                g_variant_iter_free(iter);
        }
 
-       if(reply)
+       if (reply)
                g_object_unref(reply);
 
        NOTIFICATION_DBG("notification_ipc_request_load_noti_detail_list done [result: %d]", result);
@@ -1020,7 +1128,8 @@ int notification_ipc_request_load_noti_detail_list(const char *pkgname,
 
 int notification_ipc_request_get_setting_array(
                notification_setting_h *setting_array,
-               int *count)
+               int *count,
+               uid_t uid)
 {
        int result;
        GDBusMessage *reply = NULL;
@@ -1038,7 +1147,7 @@ int notification_ipc_request_get_setting_array(
                return result;
        }
 
-       result = _send_sync_noti(NULL, &reply, "get_setting_array");
+       result = _send_sync_noti(g_variant_new("(i)", uid), &reply, "get_setting_array");
 
        if (result == NOTIFICATION_ERROR_NONE) {
                reply_body = g_dbus_message_get_body(reply);
@@ -1065,7 +1174,7 @@ int notification_ipc_request_get_setting_array(
                g_variant_iter_free(iter);
        }
 
-       if(reply)
+       if (reply)
                g_object_unref(reply);
 
        NOTIFICATION_DBG("notification_ipc_request_get_setting_array done [result: %d]", result);
@@ -1073,7 +1182,7 @@ int notification_ipc_request_get_setting_array(
 }
 
 int notification_ipc_request_get_setting_by_package_name(
-               const char *package_name, notification_setting_h *setting)
+               const char *package_name, notification_setting_h *setting, uid_t uid)
 {
        int result;
        GDBusMessage *reply = NULL;
@@ -1088,7 +1197,7 @@ int notification_ipc_request_get_setting_by_package_name(
                return result;
        }
 
-       body = g_variant_new("(s)", package_name);
+       body = g_variant_new("(si)", package_name, uid);
        result = _send_sync_noti(body, &reply, "get_setting_by_package_name");
 
        if (result == NOTIFICATION_ERROR_NONE) {
@@ -1108,14 +1217,14 @@ int notification_ipc_request_get_setting_by_package_name(
                g_variant_unref(setting_body);
        }
 
-       if(reply)
+       if (reply)
                g_object_unref(reply);
 
        NOTIFICATION_DBG("notification_ipc_request_get_setting_by_package_name done [result: %d]", result);
        return result;
 }
 
-int notification_ipc_request_load_system_setting(notification_system_setting_h *setting)
+int notification_ipc_request_load_system_setting(notification_system_setting_h *setting, uid_t uid)
 {
        int result;
        GDBusMessage *reply = NULL;
@@ -1129,7 +1238,7 @@ int notification_ipc_request_load_system_setting(notification_system_setting_h *
                return result;
        }
 
-       result = _send_sync_noti(NULL, &reply, "load_system_setting");
+       result = _send_sync_noti(g_variant_new("(i)", uid), &reply, "load_system_setting");
 
        if (result == NOTIFICATION_ERROR_NONE) {
                reply_body = g_dbus_message_get_body(reply);
@@ -1147,14 +1256,14 @@ int notification_ipc_request_load_system_setting(notification_system_setting_h *
                g_variant_unref(setting_body);
        }
 
-       if(reply)
+       if (reply)
                g_object_unref(reply);
 
        NOTIFICATION_DBG("notification_ipc_request_load_system_setting done [result: %d]", result);
        return result;
 }
 
-int notification_ipc_update_setting(notification_setting_h setting)
+int notification_ipc_update_setting(notification_setting_h setting, uid_t uid)
 {
        int result;
        GDBusMessage *reply = NULL;
@@ -1166,22 +1275,23 @@ int notification_ipc_update_setting(notification_setting_h setting)
                return result;
        }
 
-       body = g_variant_new("(siii)",
+       body = g_variant_new("(siiii)",
                        setting->package_name,
                        (int)(setting->allow_to_notify),
                        (int)(setting->do_not_disturb_except),
-                       (int)(setting->visibility_class));
+                       (int)(setting->visibility_class),
+                       uid);
 
        result = _send_sync_noti(body, &reply, "update_noti_setting");
 
-       if(reply)
+       if (reply)
                g_object_unref(reply);
 
        NOTIFICATION_DBG("notification_ipc_update_setting done [result: %d]", result);
        return result;
 }
 
-int notification_ipc_update_system_setting(notification_system_setting_h system_setting)
+int notification_ipc_update_system_setting(notification_system_setting_h system_setting, uid_t uid)
 {
        int result;
        GDBusMessage *reply = NULL;
@@ -1193,9 +1303,17 @@ int notification_ipc_update_system_setting(notification_system_setting_h system_
                return result;
        }
 
-       body = g_variant_new("(ii)",
+       body = g_variant_new("(iiiiiiiiii)",
                        (int)(system_setting->do_not_disturb),
-                       (int)(system_setting->visibility_class));
+                       (int)(system_setting->visibility_class),
+                       (int)(system_setting->dnd_schedule_enabled),
+                       (int)(system_setting->dnd_schedule_day),
+                       (int)(system_setting->dnd_start_hour),
+                       (int)(system_setting->dnd_start_min),
+                       (int)(system_setting->dnd_end_hour),
+                       (int)(system_setting->dnd_end_min),
+                       (int)(system_setting->lock_screen_content_level),
+                       uid);
 
        result = _send_sync_noti(body, &reply, "update_noti_sys_setting");
 
@@ -1206,7 +1324,153 @@ int notification_ipc_update_system_setting(notification_system_setting_h system_
        return result;
 }
 
-EXPORT_API GVariant *notification_ipc_make_gvariant_from_noti(notification_h noti)
+int notification_ipc_request_save_as_template(notification_h noti, const char *template_name)
+{
+       int result;
+       GDBusMessage *reply = NULL;
+       GVariant *body;
+
+       result = _dbus_init();
+       if (result != NOTIFICATION_ERROR_NONE) {
+               NOTIFICATION_ERR("Can't init dbus %d", result);
+               return result;
+       }
+
+       body = notification_ipc_make_gvariant_from_noti(noti, false);
+       if (body == NULL) {
+               NOTIFICATION_ERR("cannot make gvariant");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+       }
+
+       result = _send_sync_noti(g_variant_new("(vs)", body, template_name), &reply, "save_as_template");
+
+       if (reply)
+               g_object_unref(reply);
+
+       NOTIFICATION_DBG("notification_ipc_request_save_as_template [result: %d]", result);
+       return result;
+}
+
+int notification_ipc_request_create_from_template(notification_h noti, const char *template_name)
+{
+       int result;
+       GDBusMessage *reply = NULL;
+       GVariant *body;
+       GVariant *reply_body;
+       GVariant *noti_body;
+
+       if (!template_name)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       result = _dbus_init();
+       if (result != NOTIFICATION_ERROR_NONE) {
+               NOTIFICATION_ERR("Can't init dbus %d", result);
+               return result;
+       }
+
+       body = g_variant_new("(s)", template_name);
+
+       result = _send_sync_noti(body, &reply, "create_from_template");
+       if (result == NOTIFICATION_ERROR_NONE) {
+               reply_body = g_dbus_message_get_body(reply);
+               g_variant_get(reply_body, "(v)", &noti_body);
+
+               notification_ipc_make_noti_from_gvariant(noti, noti_body);
+               g_variant_unref(noti_body);
+               _print_noti(noti);
+
+       }
+
+       if (reply)
+               g_object_unref(reply);
+
+       NOTIFICATION_DBG("notification_ipc_request_create_from_template done [result: %d]", result);
+
+       return result;
+}
+
+int notification_ipc_request_create_from_package_template(notification_h noti, const char *pkgname, const char *template_name)
+{
+       int result;
+       GDBusMessage *reply = NULL;
+       GVariant *body;
+       GVariant *reply_body;
+       GVariant *noti_body;
+
+       if (pkgname == NULL || template_name == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       result = _dbus_init();
+       if (result != NOTIFICATION_ERROR_NONE) {
+               NOTIFICATION_ERR("Can't init dbus %d", result);
+               return result;
+       }
+
+       body = g_variant_new("(ss)", pkgname, template_name);
+
+       result = _send_sync_noti(body, &reply, "create_from_package_template");
+       if (result == NOTIFICATION_ERROR_NONE) {
+               reply_body = g_dbus_message_get_body(reply);
+               g_variant_get(reply_body, "(v)", &noti_body);
+
+               notification_ipc_make_noti_from_gvariant(noti, noti_body);
+               g_variant_unref(noti_body);
+               _print_noti(noti);
+       }
+
+       if (reply)
+               g_object_unref(reply);
+
+       NOTIFICATION_DBG("notification_ipc_request_create_from_package_template [result: %d]", result);
+
+       return result;
+}
+
+int notification_ipc_get_noti_block_state(const char *pkgname, int *do_not_disturb,
+                                         int *do_not_disturb_except, int *allow_to_notify,
+                                         uid_t uid)
+{
+       int ret;
+       int dnd;
+       int dnd_except;
+       int allow;
+       GDBusMessage *reply = NULL;
+       GVariant *body;
+       GVariant *reply_body;
+       GVariant *result_body;
+
+       if (pkgname == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       ret = _dbus_init();
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               NOTIFICATION_ERR("Can't init dbus %d", ret);
+               return ret;
+       }
+
+       body = g_variant_new("(si)", pkgname, uid);
+
+       ret = _send_sync_noti(body, &reply, "get_noti_block_state");
+
+       if (ret == NOTIFICATION_ERROR_NONE) {
+               reply_body = g_dbus_message_get_body(reply);
+               g_variant_get(reply_body, "(v)", &result_body);
+               g_variant_get(result_body, "(iii)", &dnd, &dnd_except, &allow);
+               *do_not_disturb = dnd;
+               *do_not_disturb_except = dnd_except;
+               *allow_to_notify = allow;
+               g_variant_unref(result_body);
+       }
+
+       if (reply)
+               g_object_unref(reply);
+
+       NOTIFICATION_DBG("notification_ipc_get_noti_block_state done");
+
+       return ret;
+}
+
+EXPORT_API GVariant *notification_ipc_make_gvariant_from_noti(notification_h noti, bool translate)
 {
        NOTIFICATION_DBG("make gvariant from noti");
        int i = 0;
@@ -1226,6 +1490,9 @@ EXPORT_API GVariant *notification_ipc_make_gvariant_from_noti(notification_h not
        GVariant *result_body = NULL;
        GVariantBuilder builder;
 
+       if (translate)
+               notification_translate_localized_text(noti);
+
        g_variant_builder_init(&builder, G_VARIANT_TYPE("a{iv}"));
        g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_NOTI_TYPE, g_variant_new_int32(noti->type));
        g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_LAYOUT, g_variant_new_int32(noti->layout));
@@ -1351,8 +1618,7 @@ EXPORT_API GVariant *notification_ipc_make_gvariant_from_noti(notification_h not
        if (noti->sound_path)
                g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_SOUND_PATH, g_variant_new_string((const gchar *)noti->sound_path));
 
-       if (noti->vibration_type != NOTIFICATION_VIBRATION_TYPE_NONE)
-               g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_VIBRATION_TYPE, g_variant_new_int32(noti->vibration_type));
+       g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_VIBRATION_TYPE, g_variant_new_int32(noti->vibration_type));
 
        if (noti->vibration_path)
                g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_VIBRATION_PATH, g_variant_new_string((const gchar *)noti->vibration_path));
@@ -1395,10 +1661,10 @@ EXPORT_API GVariant *notification_ipc_make_gvariant_from_noti(notification_h not
        if (noti->tag != NULL)
                g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_TAG, g_variant_new_string((const gchar *)noti->tag));
 
-       if (noti->ongoing_flag != 0)
-               g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_ONGOING_FLAG, g_variant_new_int32(noti->ongoing_flag));
-       if (noti->auto_remove != 0)
-               g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_AUTO_REMOVE, g_variant_new_int32(noti->auto_remove));
+       g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_ONGOING_FLAG, g_variant_new_int32(noti->ongoing_flag));
+
+       g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_AUTO_REMOVE, g_variant_new_int32(noti->auto_remove));
+       g_variant_builder_add(&builder, "{iv}", NOTIFICATION_DATA_TYPE_UID, g_variant_new_int32(noti->uid));
 
        result_body = g_variant_builder_end(&builder);
        body = g_variant_new("(v)", result_body);
@@ -1406,8 +1672,8 @@ EXPORT_API GVariant *notification_ipc_make_gvariant_from_noti(notification_h not
        return body;
 }
 
-static gboolean _variant_to_int_dict(GHashTable **dict, GVariant *variant) {
-
+static gboolean _variant_to_int_dict(GHashTable **dict, GVariant *variant)
+{
        GVariantIter iter;
        int key;
        int *hash_key;
@@ -1421,7 +1687,7 @@ static gboolean _variant_to_int_dict(GHashTable **dict, GVariant *variant) {
        while (g_variant_iter_next(&iter, "{iv}", &key, &value)) {
                hash_key = (int *)calloc(sizeof(int), 1);
                if (hash_key == NULL) {
-                       g_hash_table_remove_all(*dict);
+                       g_hash_table_unref(*dict);
                        return FALSE;
                }
                *hash_key = key;
@@ -1509,14 +1775,14 @@ EXPORT_API int notification_ipc_make_noti_from_gvariant(notification_h noti,
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_SERVICE_RESPONDING, "&s", &b_service_responding);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_SERVICE_SINGLE_LAUNCH, "&s", &b_service_single_launch);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_SERVICE_MULTI_LAUNCH, "&s", &b_service_multi_launch);
-       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_BUTTON1_EVENT, "&s", &noti->b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1]);
-       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_BUTTON2_EVENT, "&s", &noti->b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2]);
-       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_BUTTON3_EVENT, "&s", &noti->b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3]);
-       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_BUTTON4_EVENT, "&s", &noti->b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_4]);
-       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_BUTTON5_EVENT, "&s", &noti->b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_5]);
-       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_BUTTON6_EVENT, "&s", &noti->b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_6]);
-       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_ICON_EVENT, "&s", &noti->b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_ICON]);
-       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_THUMBNAIL_EVENT, "&s", &noti->b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL]);
+       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_BUTTON1_EVENT, "&s", &b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1]);
+       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_BUTTON2_EVENT, "&s", &b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2]);
+       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_BUTTON3_EVENT, "&s", &b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3]);
+       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_BUTTON4_EVENT, "&s", &b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_4]);
+       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_BUTTON5_EVENT, "&s", &b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_5]);
+       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_BUTTON6_EVENT, "&s", &b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_6]);
+       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_ICON_EVENT, "&s", &b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_ICON]);
+       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_THUMBNAIL_EVENT, "&s", &b_event_handler[NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL]);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_DOMAIN, "&s", &domain);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_DIR, "&s", &dir);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_TEXT, "&s", &b_text);
@@ -1545,6 +1811,7 @@ EXPORT_API int notification_ipc_make_noti_from_gvariant(notification_h noti,
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_TAG, "&s", &tag);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_ONGOING_FLAG, "i", &noti->ongoing_flag);
        _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_AUTO_REMOVE, "i", &noti->auto_remove);
+       _variant_dict_lookup(dict, NOTIFICATION_DATA_TYPE_UID, "i", &noti->uid);
 
        noti->caller_pkgname = _dup_string(caller_pkgname);
        noti->launch_pkgname = _dup_string(launch_pkgname);
@@ -1575,7 +1842,7 @@ EXPORT_API int notification_ipc_make_noti_from_gvariant(notification_h noti,
        noti->temp_content = _dup_string(temp_content);
        noti->tag = _dup_string(tag);
 
-       g_hash_table_remove_all(dict);
+       g_hash_table_unref(dict);
 
        return NOTIFICATION_ERROR_NONE;
 }
@@ -1583,9 +1850,16 @@ EXPORT_API int notification_ipc_make_noti_from_gvariant(notification_h noti,
 EXPORT_API GVariant *notification_ipc_make_gvariant_from_system_setting(struct notification_system_setting *noti_setting)
 {
        GVariant *body = NULL;
-       body = g_variant_new("(ii)",
+       body = g_variant_new("(iiiiiiiii)",
                        noti_setting->do_not_disturb,
-                       noti_setting->visibility_class);
+                       noti_setting->visibility_class,
+                       noti_setting->dnd_schedule_enabled,
+                       noti_setting->dnd_schedule_day,
+                       noti_setting->dnd_start_hour,
+                       noti_setting->dnd_start_min,
+                       noti_setting->dnd_end_hour,
+                       noti_setting->dnd_end_min,
+                       noti_setting->lock_screen_content_level);
        return body;
 }
 
@@ -1594,24 +1868,45 @@ EXPORT_API int notification_ipc_make_system_setting_from_gvariant(struct notific
 {
        int do_not_disturb;
        int visibility_class;
+       int dnd_schedule_enabled;
+       int dnd_schedule_day;
+       int dnd_start_hour;
+       int dnd_start_min;
+       int dnd_end_hour;
+       int dnd_end_min;
+       int lock_screen_content_level;
 
        if (noti_setting == NULL) {
                NOTIFICATION_ERR("invalid data");
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
        }
+
        g_variant_get(variant,
-                       "(ii)",
+                       "(iiiiiiiii)",
                        &do_not_disturb,
-                       &visibility_class);
-
-       NOTIFICATION_DBG("system setting  #### %d, %d",
-                       do_not_disturb, visibility_class);
+                       &visibility_class,
+                       &dnd_schedule_enabled,
+                       &dnd_schedule_day,
+                       &dnd_start_hour,
+                       &dnd_start_min,
+                       &dnd_end_hour,
+                       &dnd_end_min,
+                       &lock_screen_content_level);
+
+       NOTIFICATION_DBG("system setting  #### %d, %d, %d, %d, [%d:%d] [%d:%d], %d",
+                       do_not_disturb, visibility_class, dnd_schedule_enabled,
+                       dnd_schedule_day, dnd_start_hour, dnd_start_min,
+                       dnd_end_hour, dnd_end_min, lock_screen_content_level);
 
        noti_setting->do_not_disturb = do_not_disturb;
        noti_setting->visibility_class = visibility_class;
-
-       NOTIFICATION_DBG("system setting2  #### %d, %d",
-                       noti_setting->do_not_disturb, noti_setting->visibility_class);
+       noti_setting->dnd_schedule_enabled = dnd_schedule_enabled;
+       noti_setting->dnd_schedule_day = dnd_schedule_day;
+       noti_setting->dnd_start_hour = dnd_start_hour;
+       noti_setting->dnd_start_min = dnd_start_min;
+       noti_setting->dnd_end_hour = dnd_end_hour;
+       noti_setting->dnd_end_min = dnd_end_min;
+       noti_setting->lock_screen_content_level = lock_screen_content_level;
 
        return NOTIFICATION_ERROR_NONE;
 }
@@ -1662,86 +1957,106 @@ EXPORT_API int notification_ipc_make_setting_from_gvariant(struct notification_s
        return NOTIFICATION_ERROR_NONE;
 }
 
-static int _send_service_register()
+static int _send_service_register(uid_t uid)
 {
-       NOTIFICATION_DBG("service register");
        GDBusMessage *reply = NULL;
        int result;
+       notification_op *noti_op = NULL;
 
-       result = _send_sync_noti(NULL, &reply, "noti_service_register");
+       result = _send_sync_noti(g_variant_new("(i)", uid), &reply, "noti_service_register");
 
-       if(reply)
+       if (reply)
                g_object_unref(reply);
 
-       NOTIFICATION_ERR("_send_service_register done = %s, result = %d", _bus_name, result);
+       NOTIFICATION_DBG("_send_service_register done = %s, result = %d", _bus_name, result);
+       noti_op = _ipc_create_op(NOTIFICATION_OP_SERVICE_READY, 1, NULL, 1, NULL);
+       if (noti_op != NULL) {
+               notification_call_changed_cb_for_uid(noti_op, 1, uid);
+               free(noti_op);
+       }
+
        return result;
 }
 
-static int _ipc_monitor_register(void)
+static int _ipc_monitor_register(uid_t uid)
 {
-       NOTIFICATION_ERR("register a service\n");
-
-       return  _send_service_register();
+       return  _send_service_register(uid);
 }
 
+/* LCOV_EXCL_START */
 static void _on_name_appeared(GDBusConnection *connection,
                const gchar     *name,
                const gchar     *name_owner,
                gpointer         user_data)
 {
-       NOTIFICATION_DBG("name appeared : %s", name);
+       int uid = GPOINTER_TO_INT(user_data);
+
+       NOTIFICATION_DBG("name appeared [%d] : %s", uid, name);
        is_master_started = 1;
-       _ipc_monitor_register();
+       _ipc_monitor_register(uid);
 
        /* TODO: dbus activation isn't enough ? */
        _do_deffered_task();
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static void _on_name_vanished(GDBusConnection *connection,
                const gchar     *name,
                gpointer         user_data)
 {
-       NOTIFICATION_DBG("name vanished : %s", name);
+       int uid = GPOINTER_TO_INT(user_data);
+
+       NOTIFICATION_DBG("name vanished [%d] : %s", uid, name);
        is_master_started = 0;
 }
+/* LCOV_EXCL_STOP */
 
-int notification_ipc_monitor_init(void)
+int notification_ipc_monitor_init(uid_t uid)
 {
        int ret;
 
        ret = _dbus_init();
        if (ret != NOTIFICATION_ERROR_NONE) {
+               /* LCOV_EXCL_START */
                NOTIFICATION_ERR("Can't init dbus %d", ret);
                return ret;
+               /* LCOV_EXCL_STOP */
        }
 
        ret = _dbus_signal_init();
        if (ret != NOTIFICATION_ERROR_NONE) {
+               /* LCOV_EXCL_START */
                NOTIFICATION_ERR("Can't signal_init %d", ret);
                return ret;
+               /* LCOV_EXCL_STOP */
        }
 
-       ret = _ipc_monitor_register();
+       ret = _ipc_monitor_register(uid);
        if (ret != NOTIFICATION_ERROR_NONE) {
+               /* LCOV_EXCL_START */
                NOTIFICATION_ERR("Can't init ipc_monitor_register %d", ret);
                return ret;
+               /* LCOV_EXCL_STOP */
        }
 
        if (provider_monitor_id == 0) {
+
                provider_monitor_id = g_bus_watch_name_on_connection(
                                _gdbus_conn,
                                PROVIDER_BUS_NAME,
                                G_BUS_NAME_WATCHER_FLAGS_NONE,
                                _on_name_appeared,
                                _on_name_vanished,
-                               NULL,
+                               GINT_TO_POINTER((int)uid),
                                NULL);
-
                if (provider_monitor_id == 0) {
+                       /* LCOV_EXCL_START */
                        g_dbus_connection_signal_unsubscribe(_gdbus_conn, monitor_id);
                        monitor_id = 0;
                        NOTIFICATION_ERR("watch on name fail");
                        return NOTIFICATION_ERROR_IO_ERROR;
+                       /* LCOV_EXCL_STOP */
                }
        }
 
@@ -1767,3 +2082,4 @@ int notification_ipc_monitor_fini(void)
 {
        return  _ipc_monitor_deregister();
 }
+