Move notification_get_text_input_max_length to internal
[platform/core/api/notification.git] / src / notification.c
index f48e6b3..b1d84fd 100755 (executable)
@@ -49,6 +49,8 @@ static void (*posted_toast_message_cb) (void *data);
 #define NOTI_TEXT_RESULT_LEN 2048
 #define NOTI_PKGNAME_LEN       512
 
+#define REGULAR_UID_MIN 5000
+
 char *notification_get_pkgname_by_pid(void)
 {
        char pkgname[NOTI_PKGNAME_LEN + 1] = { 0, };
@@ -100,42 +102,30 @@ EXPORT_API int notification_set_image(notification_h noti,
        char buf_key[32] = { 0, };
        char *ret_val = NULL;
 
-       /* Check noti and image_path are valid data */
        if (noti == NULL || image_path == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Check image type is valid type */
        if (type <= NOTIFICATION_IMAGE_TYPE_NONE
            || type >= NOTIFICATION_IMAGE_TYPE_MAX)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Check image path bundle is exist */
        if (noti->b_image_path) {
-               /* If image path bundle is exist, store local bundle value */
                b = noti->b_image_path;
 
-               /* Set image type to key as char string type */
                snprintf(buf_key, sizeof(buf_key), "%d", type);
 
-               /* Get value using key */
                bundle_get_str(b, buf_key, &ret_val);
                if (ret_val != NULL)
-                       /* If key is exist, remove this value to store new image path */
                        bundle_del(b, buf_key);
 
-               /* Add new image path with type key */
                bundle_add_str(b, buf_key, image_path);
        } else {
-               /* If image path bundle is not exist, create new one */
                b = bundle_create();
 
-               /* Set image type to key as char string type */
                snprintf(buf_key, sizeof(buf_key), "%d", type);
 
-               /* Add new image path with type key */
                bundle_add_str(b, buf_key, image_path);
 
-               /* Save to image path bundle */
                noti->b_image_path = b;
        }
 
@@ -150,24 +140,18 @@ EXPORT_API int notification_get_image(notification_h noti,
        char buf_key[32] = { 0, };
        char *ret_val = NULL;
 
-       /* Check noti and image_path is valid data */
        if (noti == NULL || image_path == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Check image type is valid data */
        if (type <= NOTIFICATION_IMAGE_TYPE_NONE
            || type >= NOTIFICATION_IMAGE_TYPE_MAX)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Check image path bundle exist */
        if (noti->b_image_path) {
-               /* If image path bundle exist, store local bundle data */
                b = noti->b_image_path;
 
-               /* Set image type to key as char string type */
                snprintf(buf_key, sizeof(buf_key), "%d", type);
 
-               /* Get value of key */
                bundle_get_str(b, buf_key, &ret_val);
 
                *image_path = ret_val;
@@ -179,9 +163,7 @@ EXPORT_API int notification_get_image(notification_h noti,
        /* If image path is NULL and type is ICON, icon path set from AIL */
        /* order : user icon -> launch_pkgname icon -> caller_pkgname icon -> service app icon */
        if (*image_path == NULL && type == NOTIFICATION_IMAGE_TYPE_ICON) {
-               /* Check App icon path is already set */
                if (noti->app_icon_path != NULL)
-                       /* image path will be app icon path */
                        *image_path = noti->app_icon_path;
                else
                        *image_path = NULL;
@@ -192,15 +174,12 @@ EXPORT_API int notification_get_image(notification_h noti,
 
 EXPORT_API int notification_set_time(notification_h noti, time_t input_time)
 {
-       /* Check noti is valid data */
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
        if (input_time == 0)
-               /* If input time is 0, set current time */
                noti->time = time(NULL);
        else
-               /* save input time */
                noti->time = input_time;
 
        return NOTIFICATION_ERROR_NONE;
@@ -208,11 +187,9 @@ EXPORT_API int notification_set_time(notification_h noti, time_t input_time)
 
 EXPORT_API int notification_get_time(notification_h noti, time_t *ret_time)
 {
-       /* Check noti and time is valid data */
        if (noti == NULL || ret_time == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Set time infomation */
        *ret_time = noti->time;
 
        return NOTIFICATION_ERROR_NONE;
@@ -221,11 +198,9 @@ EXPORT_API int notification_get_time(notification_h noti, time_t *ret_time)
 EXPORT_API int notification_get_insert_time(notification_h noti,
                time_t *ret_time)
 {
-       /* Check noti and ret_time is valid data */
        if (noti == NULL || ret_time == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Set insert time information */
        *ret_time = noti->insert_time;
 
        return NOTIFICATION_ERROR_NONE;
@@ -249,115 +224,81 @@ EXPORT_API int notification_set_text(notification_h noti,
        notification_count_pos_type_e var_value_count =
            NOTIFICATION_COUNT_POS_NONE;
 
-       /* Check noti is valid data */
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Check text type is valid type */
        if (type <= NOTIFICATION_TEXT_TYPE_NONE
            || type >= NOTIFICATION_TEXT_TYPE_MAX)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Check text bundle exist */
        if (text != NULL) {
                if (noti->b_text != NULL) {
-                       /* If text bundle exist, store local bundle data */
                        b = noti->b_text;
 
-                       /* Make type to key as char string */
                        snprintf(buf_key, sizeof(buf_key), "%d", type);
 
-                       /* Get value using type key */
                        bundle_get_str(b, buf_key, &ret_val);
 
                        if (ret_val != NULL)
-                               /* If value exist, remove this to add new value */
                                bundle_del(b, buf_key);
 
                        snprintf(buf_val, sizeof(buf_val), "%s", text);
 
-                       /* Add new text value */
                        bundle_add_str(b, buf_key, buf_val);
                } else {
-                       /* If text bundle does not exist, create new one */
                        b = bundle_create();
 
-                       /* Make type to key as char string */
                        snprintf(buf_key, sizeof(buf_key), "%d", type);
-
                        snprintf(buf_val, sizeof(buf_val), "%s", text);
 
-                       /* Add new text value */
                        bundle_add_str(b, buf_key, buf_val);
 
-                       /* Save text bundle */
                        noti->b_text = b;
                }
        } else {
-               /* Reset if text is NULL */
                if (noti->b_text != NULL) {
-                       /* If text bundle exist, store local bundle data */
                        b = noti->b_text;
 
-                       /* Make type to key as char string */
                        snprintf(buf_key, sizeof(buf_key), "%d", type);
 
-                       /* Get value using type key */
                        bundle_get_str(b, buf_key, &ret_val);
                        if (ret_val != NULL)
-                               /* If value exist, remove this */
                                bundle_del(b, buf_key);
                }
        }
 
-       /* Save key if key is valid data */
        if (key != NULL) {
-               /* Check key bundle exist */
                if (noti->b_key != NULL) {
-                       /* If key bundle exist,  store local bundle data */
                        b = noti->b_key;
 
-                       /* Make type to key as char string */
                        snprintf(buf_key, sizeof(buf_key), "%d", type);
 
-                       /* Get value using type key */
                        bundle_get_str(b, buf_key, &ret_val);
                        if (ret_val != NULL)
-                               /* If value exist, remove this to add new value */
                                bundle_del(b, buf_key);
 
                        snprintf(buf_val, sizeof(buf_val), "%s", key);
 
-                       /* Add new key value */
                        bundle_add_str(b, buf_key, buf_val);
                } else {
-                       /* If key bundle does not exist, create new one */
                        b = bundle_create();
 
-                       /* Make type to key as char string */
                        snprintf(buf_key, sizeof(buf_key), "%d", type);
 
                        snprintf(buf_val, sizeof(buf_val), "%s", key);
 
-                       /* Add new key value */
                        bundle_add_str(b, buf_key, buf_val);
 
-                       /* Save key bundle */
                        noti->b_key = b;
                }
        } else {
-               /* Reset if key is NULL */
                if (noti->b_key != NULL) {
-                       /* If key bundle exist,  store local bundle data */
                        b = noti->b_key;
 
-                       /* Make type to key as char string */
                        snprintf(buf_key, sizeof(buf_key), "%d", type);
 
-                       /* Get value using type key */
                        bundle_get_str(b, buf_key, &ret_val);
                        if (ret_val != NULL)
-                               /* If value exist, remove this */
                                bundle_del(b, buf_key);
                }
        }
@@ -488,7 +429,6 @@ EXPORT_API int notification_get_text(notification_h noti,
        char *ret_val = NULL;
        char *get_str = NULL;
        notification_text_type_e check_type = NOTIFICATION_TEXT_TYPE_NONE;
-       /* int display_option_flag = 0; */
 
        char *temp_str = NULL;
        char *translated_str = NULL;
@@ -501,17 +441,14 @@ EXPORT_API int notification_get_text(notification_h noti,
        int src_len = 0;
        int max_len = 0;
 
-       /* Check noti is valid data */
        if (noti == NULL || text == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Check text type is valid type */
        if (type <= NOTIFICATION_TEXT_TYPE_NONE
            || type >= NOTIFICATION_TEXT_TYPE_MAX)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
 
-       /* Check key */
        if (noti->b_key != NULL) {
                b = noti->b_key;
 
@@ -527,9 +464,13 @@ EXPORT_API int notification_get_text(notification_h noti,
                        bindtextdomain(noti->domain, noti->dir);
 
                        get_str = dgettext(noti->domain, ret_val);
+                       if (get_str == ret_val) /* not found */
+                               get_str = NULL;
                } else if (ret_val != NULL) {
                        /* Get system string */
                        get_str = dgettext("sys_string", ret_val);
+                       if (get_str == ret_val) /* not found */
+                               get_str = NULL;
                } else {
                        get_str = NULL;
                }
@@ -537,12 +478,15 @@ EXPORT_API int notification_get_text(notification_h noti,
 
        if (get_str == NULL && noti->b_text != NULL) {
                b = noti->b_text;
-               /* Get basic text */
+
                snprintf(buf_key, sizeof(buf_key), "%d", type);
 
                bundle_get_str(b, buf_key, &get_str);
        }
 
+       if (get_str == NULL && ret_val != NULL)
+               get_str = ret_val; /* fallback for printing anything */
+
        check_type = type;
 
        if (get_str != NULL) {
@@ -867,24 +811,17 @@ EXPORT_API int notification_set_text_domain(notification_h noti,
                                                             const char *domain,
                                                             const char *dir)
 {
-       /* check noti and domain is valid data */
        if (noti == NULL || domain == NULL || dir == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Check domain */
        if (noti->domain)
-               /* Remove previous domain */
                free(noti->domain);
 
-       /* Copy domain */
        noti->domain = strdup(domain);
 
-       /* Check locale dir */
        if (noti->dir)
-               /* Remove previous locale dir */
                free(noti->dir);
 
-       /* Copy locale dir */
        noti->dir = strdup(dir);
 
        return NOTIFICATION_ERROR_NONE;
@@ -894,15 +831,12 @@ EXPORT_API int notification_get_text_domain(notification_h noti,
                                                             char **domain,
                                                             char **dir)
 {
-       /* Check noti is valid data */
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Get domain */
        if (domain != NULL && noti->domain != NULL)
                *domain = noti->domain;
 
-       /* Get locale dir */
        if (dir != NULL && noti->dir != NULL)
                *dir = noti->dir;
 
@@ -975,17 +909,13 @@ EXPORT_API int notification_set_sound(notification_h noti,
                                                       notification_sound_type_e type,
                                                       const char *path)
 {
-       /* Check noti is valid data */
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-
-       /* Check type is valid */
        if (type < NOTIFICATION_SOUND_TYPE_NONE
            || type >= NOTIFICATION_SOUND_TYPE_MAX)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Save sound type */
        noti->sound_type = type;
 
        /* Save sound path if user data type */
@@ -1012,11 +942,9 @@ EXPORT_API int notification_get_sound(notification_h noti,
                                                       notification_sound_type_e *type,
                                                       const char **path)
 {
-       /* check noti and type is valid data */
        if (noti == NULL || type == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Set sound type */
        *type = noti->sound_type;
 
        /* Set sound path if user data type */
@@ -1031,16 +959,13 @@ EXPORT_API int notification_set_vibration(notification_h noti,
                                                           notification_vibration_type_e type,
                                                           const char *path)
 {
-       /* Check noti is valid data */
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Check type is valid */
        if (type < NOTIFICATION_VIBRATION_TYPE_NONE
            || type >= NOTIFICATION_VIBRATION_TYPE_MAX)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Save vibration type */
        noti->vibration_type = type;
 
        /* Save sound path if user data type */
@@ -1068,11 +993,9 @@ EXPORT_API int notification_get_vibration(notification_h noti,
                                                           notification_vibration_type_e *type,
                                                           const char **path)
 {
-       /* check noti and type is valid data */
        if (noti == NULL || type == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Set vibration type */
        *type = noti->vibration_type;
 
        /* Set sound path if user data type */
@@ -1087,16 +1010,13 @@ EXPORT_API int notification_set_led(notification_h noti,
                                                           notification_led_op_e operation,
                                                           int led_argb)
 {
-       /* Check noti is valid data */
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Check operation is valid */
        if (operation < NOTIFICATION_LED_OP_OFF
            || operation >= NOTIFICATION_LED_OP_MAX)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Save led operation */
        noti->led_operation = operation;
 
        /* Save led argb if operation is turning on LED with custom color */
@@ -1110,11 +1030,9 @@ EXPORT_API int notification_get_led(notification_h noti,
                                                           notification_led_op_e *operation,
                                                           int *led_argb)
 {
-       /* check noti and operation is valid data */
        if (noti == NULL || operation == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Set led operation */
        *operation = noti->led_operation;
 
        /* Save led argb if operation is turning on LED with custom color */
@@ -1128,11 +1046,9 @@ EXPORT_API int notification_get_led(notification_h noti,
 EXPORT_API int notification_set_led_time_period(notification_h noti,
                                                                        int on_ms, int off_ms)
 {
-       /* Check noti is valid data */
        if (noti == NULL || on_ms < 0 || off_ms < 0)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Save led operation */
        noti->led_on_ms = on_ms;
        noti->led_off_ms = off_ms;
 
@@ -1142,7 +1058,6 @@ EXPORT_API int notification_set_led_time_period(notification_h noti,
 EXPORT_API int notification_get_led_time_period(notification_h noti,
                                                                        int *on_ms, int *off_ms)
 {
-       /* check noti and operation is valid data */
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
@@ -1239,7 +1154,7 @@ EXPORT_API int notification_set_event_handler(notification_h noti, notification_
        }
 
        if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
-               || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
+               || event_type >= NOTIFICATION_EVENT_TYPE_MAX) {
                NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
                err = NOTIFICATION_ERROR_INVALID_PARAMETER;
                goto out;
@@ -1270,20 +1185,21 @@ EXPORT_API int notification_get_event_handler(notification_h noti, notification_
                NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
                goto out;
        }
+
        if (event_handler == NULL) {
                err = NOTIFICATION_ERROR_INVALID_PARAMETER;
                NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
                goto out;
        }
+
        if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
-               || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
+               || event_type >= NOTIFICATION_EVENT_TYPE_MAX) {
                NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
                err = NOTIFICATION_ERROR_INVALID_PARAMETER;
                goto out;
        }
 
        b = noti->b_event_handler[event_type];
-
        if (b == NULL) {
                NOTIFICATION_DBG("No event handler\n");
                err = NOTIFICATION_ERROR_NOT_EXIST_ID;
@@ -1315,18 +1231,12 @@ out:
        return err;
 }
 
-
-
-
-
 EXPORT_API int notification_set_property(notification_h noti,
                                                          int flags)
 {
-       /* Check noti is valid data */
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Set flags */
        noti->flags_for_property = flags;
 
        return NOTIFICATION_ERROR_NONE;
@@ -1335,11 +1245,9 @@ EXPORT_API int notification_set_property(notification_h noti,
 EXPORT_API int notification_get_property(notification_h noti,
                                                          int *flags)
 {
-       /* Check noti and flags are valid data */
        if (noti == NULL || flags == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Set flags */
        *flags = noti->flags_for_property;
 
        return NOTIFICATION_ERROR_NONE;
@@ -1348,12 +1256,9 @@ EXPORT_API int notification_get_property(notification_h noti,
 EXPORT_API int notification_set_display_applist(notification_h noti,
                                                                 int applist)
 {
-       /* Check noti is valid data */
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-
-       /* Set app list */
        if (applist == 0xffffffff) /* 0xffffffff means old NOTIFICATION_DISPLAY_APP_ALL */
                applist = NOTIFICATION_DISPLAY_APP_ALL;
 
@@ -1365,11 +1270,9 @@ EXPORT_API int notification_set_display_applist(notification_h noti,
 EXPORT_API int notification_get_display_applist(notification_h noti,
                                                                 int *applist)
 {
-       /* Check noti and applist are valid data */
        if (noti == NULL || applist == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Set app list */
        *applist = noti->display_applist;
 
        return NOTIFICATION_ERROR_NONE;
@@ -1378,11 +1281,9 @@ EXPORT_API int notification_get_display_applist(notification_h noti,
 EXPORT_API int notification_set_size(notification_h noti,
                                                      double size)
 {
-       /* Check noti is valid data */
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Save progress size */
        noti->progress_size = size;
 
        return NOTIFICATION_ERROR_NONE;
@@ -1391,11 +1292,9 @@ EXPORT_API int notification_set_size(notification_h noti,
 EXPORT_API int notification_get_size(notification_h noti,
                                                      double *size)
 {
-       /* Check noti and size is valid data */
        if (noti == NULL || size == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Set progress size */
        *size = noti->progress_size;
 
        return NOTIFICATION_ERROR_NONE;
@@ -1404,11 +1303,9 @@ EXPORT_API int notification_get_size(notification_h noti,
 EXPORT_API int notification_set_progress(notification_h noti,
                                                          double percentage)
 {
-       /* Check noti is valid data */
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Save progress percentage */
        noti->progress_percentage = percentage;
 
        return NOTIFICATION_ERROR_NONE;
@@ -1417,11 +1314,9 @@ EXPORT_API int notification_set_progress(notification_h noti,
 EXPORT_API int notification_get_progress(notification_h noti,
                                                          double *percentage)
 {
-       /* Check noti and percentage are valid data */
        if (noti == NULL || percentage == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Set progress percentage */
        *percentage = noti->progress_percentage;
 
        return NOTIFICATION_ERROR_NONE;
@@ -1430,11 +1325,9 @@ EXPORT_API int notification_get_progress(notification_h noti,
 EXPORT_API int notification_get_pkgname(notification_h noti,
                                                         char **pkgname)
 {
-       /* Check noti and pkgname are valid data */
        if (noti == NULL || pkgname == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Get caller pkgname */
        if (noti->caller_pkgname)
                *pkgname = noti->caller_pkgname;
        else
@@ -1446,7 +1339,6 @@ EXPORT_API int notification_get_pkgname(notification_h noti,
 EXPORT_API int notification_set_layout(notification_h noti,
                notification_ly_type_e layout)
 {
-       /* check noti and pkgname are valid data */
        if (noti == NULL || (layout < NOTIFICATION_LY_NONE || layout >= NOTIFICATION_LY_MAX))
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
@@ -1458,7 +1350,6 @@ EXPORT_API int notification_set_layout(notification_h noti,
 EXPORT_API int notification_get_layout(notification_h noti,
                notification_ly_type_e *layout)
 {
-       /* Check noti and pkgname are valid data */
        if (noti == NULL || layout == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
@@ -1472,11 +1363,9 @@ EXPORT_API int notification_get_layout(notification_h noti,
 EXPORT_API int notification_get_type(notification_h noti,
                                                      notification_type_e *type)
 {
-       /* Check noti and type is valid data */
        if (noti == NULL || type == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
-       /* Set noti type */
        *type = noti->type;
 
        return NOTIFICATION_ERROR_NONE;
@@ -1518,7 +1407,7 @@ static notification_h _notification_create(notification_type_e type)
                return NULL;
        }
 
-       noti = (notification_h) calloc(1, sizeof(struct _notification));
+       noti = (notification_h)calloc(1, sizeof(struct _notification));
        if (noti == NULL) {
                NOTIFICATION_ERR("NO MEMORY : noti == NULL");
                set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
@@ -1532,7 +1421,6 @@ static notification_h _notification_create(notification_type_e type)
        else if (type == NOTIFICATION_TYPE_ONGOING)
                noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
 
-       noti->caller_pkgname = notification_get_pkgname_by_pid();
        noti->group_id = NOTIFICATION_GROUP_ID_NONE;
        noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
        noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
@@ -1540,41 +1428,51 @@ static notification_h _notification_create(notification_type_e type)
        noti->display_applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_INDICATOR;
        noti->auto_remove = true;
        noti->ongoing_flag = false;
+       noti->default_button_index = 0;
+       noti->type = NOTIFICATION_ONGOING_VALUE_TYPE_PERCENT;
+       noti->timeout = 0;
+
+       if (getuid() >= REGULAR_UID_MIN) {
+               noti->caller_pkgname = notification_get_pkgname_by_pid();
+
+               err_app_manager = app_manager_get_app_id(getpid(), &app_id);
+               if (err_app_manager != APP_MANAGER_ERROR_NONE || app_id == NULL) {
+                       NOTIFICATION_WARN("app_manager_get_app_id failed err[%d] app_id[%p]",
+                                       err_app_manager, app_id);
+                       goto out;
+               }
 
-       err_app_manager = app_manager_get_app_id(getpid(), &app_id);
-       if (err_app_manager != APP_MANAGER_ERROR_NONE || app_id == NULL) {
-               NOTIFICATION_WARN("app_manager_get_app_id failed err[%d] app_id[%p]", err_app_manager, app_id);
-               goto out;
-       }
-
-       /* app name is used as domain name */
-       /* domain_name is allocated by app_get_package_app_name */
-       err_app_manager = app_get_package_app_name(app_id, &domain_name);
+               /* app name is used as domain name */
+               /* domain_name is allocated by app_get_package_app_name */
+               err_app_manager = app_get_package_app_name(app_id, &domain_name);
 
-       if (err_app_manager != APP_ERROR_NONE || domain_name == NULL) {
-               NOTIFICATION_WARN("app_get_package_app_name failed err[%d] domain_name[%p]", err_app_manager, domain_name);
-               goto out;
-       }
+               if (err_app_manager != APP_ERROR_NONE || domain_name == NULL) {
+                       NOTIFICATION_WARN("app_get_package_app_name failed err[%d] domain_name[%p]",
+                                       err_app_manager, domain_name);
+                       goto out;
+               }
 
-       err_app_manager = package_info_create(noti->caller_pkgname, &package_info);
+               err_app_manager = package_info_create(noti->caller_pkgname, &package_info);
 
-       if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || package_info == NULL) {
-               NOTIFICATION_WARN("package_info_create failed err[%d] package_info[%p] caller_pkgname[%s]",
-                               err_app_manager, package_info, noti->caller_pkgname);
-               goto out;
-       }
+               if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || package_info == NULL) {
+                       NOTIFICATION_WARN("package_info_create failed err[%d] package_info[%p] caller_pkgname[%s]",
+                                       err_app_manager, package_info, noti->caller_pkgname);
+                       goto out;
+               }
 
-       err_app_manager = package_info_get_root_path(package_info, &app_root_path);
+               err_app_manager = package_info_get_root_path(package_info, &app_root_path);
 
-       if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || app_root_path == NULL) {
-               NOTIFICATION_WARN("package_info_get_root_path failed err[%d] app_root_path[%p]", err_app_manager, app_root_path);
-               goto out;
-       }
+               if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || app_root_path == NULL) {
+                       NOTIFICATION_WARN("package_info_get_root_path failed err[%d] app_root_path[%p]",
+                                       err_app_manager, app_root_path);
+                       goto out;
+               }
 
-       snprintf(locale_directory, PATH_MAX, "%s/res/locale", app_root_path);
+               snprintf(locale_directory, PATH_MAX, "%s/res/locale", app_root_path);
 
-       noti->domain = strdup(domain_name);
-       noti->dir    = strdup(locale_directory);
+               noti->domain = strdup(domain_name);
+               noti->dir    = strdup(locale_directory);
+       }
 
 out:
        if (domain_name)
@@ -1602,7 +1500,7 @@ EXPORT_API notification_h notification_create(notification_type_e type)
        return _notification_create(type);
 }
 
-EXPORT_API notification_h  notification_load_by_tag(const char *tag)
+EXPORT_API notification_h notification_load_by_tag(const char *tag)
 {
        return notification_load_by_tag_for_uid(tag, getuid());
 }
@@ -1741,7 +1639,14 @@ EXPORT_API int notification_clone(notification_h noti, notification_h *clone)
        new_noti->progress_percentage = noti->progress_percentage;
 
        new_noti->ongoing_flag = noti->ongoing_flag;
+       new_noti->ongoing_value_type = noti->ongoing_value_type;
+       new_noti->ongoing_current = noti->ongoing_current;
+       new_noti->ongoing_duration = noti->ongoing_duration;
        new_noti->auto_remove = noti->auto_remove;
+       new_noti->default_button_index = noti->default_button_index;
+       new_noti->timeout = noti->timeout;
+       new_noti->text_input_max_length = noti->text_input_max_length;
+       new_noti->uid = noti->uid;
 
        new_noti->app_icon_path = NULL;
        new_noti->app_name = NULL;
@@ -1835,12 +1740,10 @@ EXPORT_API int notification_free(notification_h noti)
 
 EXPORT_API int notification_set_tag(notification_h noti, const char *tag)
 {
-       /* Check noti is valid data */
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
        if (tag != NULL) {
-               /* save input TAG */
                if (noti->tag != NULL)
                        free(noti->tag);
 
@@ -1853,7 +1756,6 @@ EXPORT_API int notification_set_tag(notification_h noti, const char *tag)
 
 EXPORT_API int notification_get_tag(notification_h noti, const char **tag)
 {
-       /* Check noti is valid data */
        if (noti == NULL)
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
@@ -1931,3 +1833,86 @@ EXPORT_API int notification_get_auto_remove(notification_h noti, bool *auto_remo
        return NOTIFICATION_ERROR_NONE;
 }
 
+EXPORT_API int notification_save_as_template(notification_h noti, const char *template_name)
+{
+       if (noti == NULL || template_name == NULL) {
+               NOTIFICATION_ERR("Invalid parameter");
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+       }
+
+       return notification_ipc_request_save_as_template(noti, template_name);
+}
+
+EXPORT_API notification_h notification_create_from_template(const char *template_name)
+{
+       int ret = 0;
+       notification_h noti = NULL;
+
+       if (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_template(noti, template_name);
+
+       set_last_result(ret);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               notification_free(noti);
+               return NULL;
+       }
+
+       return noti;
+}
+
+EXPORT_API int notification_get_noti_block_state(notification_block_state_e *state)
+{
+       int ret;
+       char *pkgname;
+       int do_not_disturb;
+       int do_not_disturb_except;
+       int allow_to_notify;
+
+       if (state == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       pkgname = notification_get_pkgname_by_pid();
+
+       ret = notification_ipc_get_noti_block_state(pkgname, &do_not_disturb, &do_not_disturb_except, &allow_to_notify, getuid());
+
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               if (pkgname)
+                       free(pkgname);
+               return ret;
+       }
+
+       if (allow_to_notify) {
+               *state = NOTIFICATION_BLOCK_STATE_ALLOWED;
+               if (do_not_disturb && !do_not_disturb_except)
+                       *state = NOTIFICATION_BLOCK_STATE_DO_NOT_DISTURB;
+       } else {
+               *state = NOTIFICATION_BLOCK_STATE_BLOCKED;
+       }
+
+       if (pkgname)
+               free(pkgname);
+
+       return ret;
+}
+
+EXPORT_API int notification_set_text_input(notification_h noti, int text_input_max_length)
+{
+       if (noti == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       noti->text_input_max_length = text_input_max_length;
+
+       return NOTIFICATION_ERROR_NONE;
+}