2 * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <dbus/dbus.h>
24 #include <dbus/dbus-glib-lowlevel.h>
27 #include <app_internal.h>
28 #include <app_manager.h>
29 #include <app_control_internal.h>
30 #include <package_manager.h>
34 #include <vconf-keys.h>
37 #include <notification.h>
38 #include <notification_list.h>
39 #include <notification_debug.h>
40 #include <notification_private.h>
41 #include <notification_noti.h>
42 #include <notification_ongoing.h>
43 #include <notification_group.h>
44 #include <notification_ipc.h>
45 #include <notification_internal.h>
47 static void (*posted_toast_message_cb) (void *data);
49 #define NOTI_TEXT_RESULT_LEN 2048
50 #define NOTI_PKGNAME_LEN 512
52 char *notification_get_pkgname_by_pid(void)
54 char pkgname[NOTI_PKGNAME_LEN + 1] = { 0, };
55 int pid = 0, ret = AUL_R_OK;
58 char buf[NOTI_PKGNAME_LEN + 1] = { 0, };
62 ret = aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname));
63 if (ret != AUL_R_OK) {
65 snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
67 fd = open(buf, O_RDONLY);
71 ret = read(fd, pkgname, sizeof(pkgname) - 1);
80 * "ret" is not able to be larger than "sizeof(pkgname) - 1",
81 * if the system is not going wrong.
84 if (strlen(pkgname) <= 0)
88 dup_pkgname = strdup(pkgname);
90 NOTIFICATION_ERR("Heap: %d\n", errno);
95 EXPORT_API int notification_set_image(notification_h noti,
96 notification_image_type_e type,
97 const char *image_path)
100 char buf_key[32] = { 0, };
101 char *ret_val = NULL;
103 if (noti == NULL || image_path == NULL)
104 return NOTIFICATION_ERROR_INVALID_PARAMETER;
106 if (type <= NOTIFICATION_IMAGE_TYPE_NONE
107 || type >= NOTIFICATION_IMAGE_TYPE_MAX)
108 return NOTIFICATION_ERROR_INVALID_PARAMETER;
110 if (noti->b_image_path) {
111 b = noti->b_image_path;
113 snprintf(buf_key, sizeof(buf_key), "%d", type);
115 bundle_get_str(b, buf_key, &ret_val);
117 bundle_del(b, buf_key);
119 bundle_add_str(b, buf_key, image_path);
123 snprintf(buf_key, sizeof(buf_key), "%d", type);
125 bundle_add_str(b, buf_key, image_path);
127 noti->b_image_path = b;
130 return NOTIFICATION_ERROR_NONE;
133 EXPORT_API int notification_get_image(notification_h noti,
134 notification_image_type_e type,
138 char buf_key[32] = { 0, };
139 char *ret_val = NULL;
141 if (noti == NULL || image_path == NULL)
142 return NOTIFICATION_ERROR_INVALID_PARAMETER;
144 if (type <= NOTIFICATION_IMAGE_TYPE_NONE
145 || type >= NOTIFICATION_IMAGE_TYPE_MAX)
146 return NOTIFICATION_ERROR_INVALID_PARAMETER;
148 if (noti->b_image_path) {
149 b = noti->b_image_path;
151 snprintf(buf_key, sizeof(buf_key), "%d", type);
153 bundle_get_str(b, buf_key, &ret_val);
155 *image_path = ret_val;
157 /* If image path bundle does not exist, image path is NULL */
161 /* If image path is NULL and type is ICON, icon path set from AIL */
162 /* order : user icon -> launch_pkgname icon -> caller_pkgname icon -> service app icon */
163 if (*image_path == NULL && type == NOTIFICATION_IMAGE_TYPE_ICON) {
164 if (noti->app_icon_path != NULL)
165 *image_path = noti->app_icon_path;
170 return NOTIFICATION_ERROR_NONE;
173 EXPORT_API int notification_set_time(notification_h noti, time_t input_time)
176 return NOTIFICATION_ERROR_INVALID_PARAMETER;
179 noti->time = time(NULL);
181 noti->time = input_time;
183 return NOTIFICATION_ERROR_NONE;
186 EXPORT_API int notification_get_time(notification_h noti, time_t *ret_time)
188 if (noti == NULL || ret_time == NULL)
189 return NOTIFICATION_ERROR_INVALID_PARAMETER;
191 *ret_time = noti->time;
193 return NOTIFICATION_ERROR_NONE;
196 EXPORT_API int notification_get_insert_time(notification_h noti,
199 if (noti == NULL || ret_time == NULL)
200 return NOTIFICATION_ERROR_INVALID_PARAMETER;
202 *ret_time = noti->insert_time;
204 return NOTIFICATION_ERROR_NONE;
207 EXPORT_API int notification_set_text(notification_h noti,
208 notification_text_type_e type, const char *text,
209 const char *key, int args_type, ...)
212 char buf_key[32] = { 0, };
213 char buf_val[1024] = { 0, };
214 char *ret_val = NULL;
216 notification_variable_type_e var_type;
218 int noti_err = NOTIFICATION_ERROR_NONE;
219 int var_value_int = 0;
220 double var_value_double = 0.0;
221 char *var_value_string = NULL;
222 notification_count_pos_type_e var_value_count =
223 NOTIFICATION_COUNT_POS_NONE;
226 return NOTIFICATION_ERROR_INVALID_PARAMETER;
228 if (type <= NOTIFICATION_TEXT_TYPE_NONE
229 || type >= NOTIFICATION_TEXT_TYPE_MAX)
230 return NOTIFICATION_ERROR_INVALID_PARAMETER;
233 if (noti->b_text != NULL) {
236 snprintf(buf_key, sizeof(buf_key), "%d", type);
238 bundle_get_str(b, buf_key, &ret_val);
241 bundle_del(b, buf_key);
243 snprintf(buf_val, sizeof(buf_val), "%s", text);
245 bundle_add_str(b, buf_key, buf_val);
249 snprintf(buf_key, sizeof(buf_key), "%d", type);
250 snprintf(buf_val, sizeof(buf_val), "%s", text);
252 bundle_add_str(b, buf_key, buf_val);
257 if (noti->b_text != NULL) {
260 snprintf(buf_key, sizeof(buf_key), "%d", type);
262 bundle_get_str(b, buf_key, &ret_val);
264 bundle_del(b, buf_key);
269 if (noti->b_key != NULL) {
272 snprintf(buf_key, sizeof(buf_key), "%d", type);
274 bundle_get_str(b, buf_key, &ret_val);
276 bundle_del(b, buf_key);
278 snprintf(buf_val, sizeof(buf_val), "%s", key);
280 bundle_add_str(b, buf_key, buf_val);
284 snprintf(buf_key, sizeof(buf_key), "%d", type);
286 snprintf(buf_val, sizeof(buf_val), "%s", key);
288 bundle_add_str(b, buf_key, buf_val);
293 if (noti->b_key != NULL) {
296 snprintf(buf_key, sizeof(buf_key), "%d", type);
298 bundle_get_str(b, buf_key, &ret_val);
300 bundle_del(b, buf_key);
304 if (noti->b_format_args != NULL)
305 b = noti->b_format_args;
309 va_start(var_args, args_type);
311 var_type = args_type;
314 while (var_type != NOTIFICATION_VARIABLE_TYPE_NONE) {
316 snprintf(buf_key, sizeof(buf_key), "%dtype%d", type, num_args);
317 snprintf(buf_val, sizeof(buf_val), "%d", var_type);
319 bundle_get_str(b, buf_key, &ret_val);
321 bundle_del(b, buf_key);
323 bundle_add_str(b, buf_key, buf_val);
326 case NOTIFICATION_VARIABLE_TYPE_INT:
327 var_value_int = va_arg(var_args, int);
330 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
332 snprintf(buf_val, sizeof(buf_val), "%d", var_value_int);
334 bundle_get_str(b, buf_key, &ret_val);
336 bundle_del(b, buf_key);
338 bundle_add_str(b, buf_key, buf_val);
341 case NOTIFICATION_VARIABLE_TYPE_DOUBLE:
342 var_value_double = va_arg(var_args, double);
345 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
347 snprintf(buf_val, sizeof(buf_val), "%.2f",
350 bundle_get_str(b, buf_key, &ret_val);
352 bundle_del(b, buf_key);
354 bundle_add_str(b, buf_key, buf_val);
357 case NOTIFICATION_VARIABLE_TYPE_STRING:
358 var_value_string = va_arg(var_args, char *);
361 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
363 snprintf(buf_val, sizeof(buf_val), "%s",
366 bundle_get_str(b, buf_key, &ret_val);
368 bundle_del(b, buf_key);
370 bundle_add_str(b, buf_key, buf_val);
373 case NOTIFICATION_VARIABLE_TYPE_COUNT:
375 va_arg(var_args, notification_count_pos_type_e);
378 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
380 snprintf(buf_val, sizeof(buf_val), "%d",
383 bundle_get_str(b, buf_key, &ret_val);
385 bundle_del(b, buf_key);
387 bundle_add_str(b, buf_key, buf_val);
391 NOTIFICATION_ERR("Error. invalid variable type. : %d",
393 noti_err = NOTIFICATION_ERROR_INVALID_PARAMETER;
398 var_type = va_arg(var_args, notification_variable_type_e);
402 if (noti_err == NOTIFICATION_ERROR_NONE)
403 noti->num_format_args = num_args;
405 noti->num_format_args = 0;
407 snprintf(buf_key, sizeof(buf_key), "num%d", type);
408 snprintf(buf_val, sizeof(buf_val), "%d", noti->num_format_args);
410 bundle_get_str(b, buf_key, &ret_val);
412 bundle_del(b, buf_key);
414 bundle_add_str(b, buf_key, buf_val);
416 noti->b_format_args = b;
421 EXPORT_API int notification_get_text(notification_h noti,
422 notification_text_type_e type,
426 char buf_key[32] = { 0, };
427 char *ret_val = NULL;
428 char *get_str = NULL;
429 notification_text_type_e check_type = NOTIFICATION_TEXT_TYPE_NONE;
431 char *temp_str = NULL;
432 char *translated_str = NULL;
433 char result_str[NOTI_TEXT_RESULT_LEN] = { 0, };
434 char buf_str[1024] = { 0, };
436 notification_variable_type_e ret_var_type = 0;
437 int ret_variable_int = 0;
438 double ret_variable_double = 0.0;
442 if (noti == NULL || text == NULL)
443 return NOTIFICATION_ERROR_INVALID_PARAMETER;
445 if (type <= NOTIFICATION_TEXT_TYPE_NONE
446 || type >= NOTIFICATION_TEXT_TYPE_MAX)
447 return NOTIFICATION_ERROR_INVALID_PARAMETER;
450 if (noti->b_key != NULL) {
453 /* Get text domain and dir */
454 /* _notification_get_text_domain(noti); */
456 snprintf(buf_key, sizeof(buf_key), "%d", type);
458 bundle_get_str(b, buf_key, &ret_val);
459 if (ret_val != NULL && noti->domain != NULL
460 && noti->dir != NULL) {
461 /* Get application string */
462 bindtextdomain(noti->domain, noti->dir);
464 get_str = dgettext(noti->domain, ret_val);
465 if (get_str == ret_val) /* not found */
467 } else if (ret_val != NULL) {
468 /* Get system string */
469 get_str = dgettext("sys_string", ret_val);
470 if (get_str == ret_val) /* not found */
477 if (get_str == NULL && noti->b_text != NULL) {
480 snprintf(buf_key, sizeof(buf_key), "%d", type);
482 bundle_get_str(b, buf_key, &get_str);
485 if (get_str == NULL && ret_val != NULL)
486 get_str = ret_val; /* fallback for printing anything */
490 if (get_str != NULL) {
491 /* Get number format args */
492 b = noti->b_format_args;
493 noti->num_format_args = 0;
496 snprintf(buf_key, sizeof(buf_key), "num%d", check_type);
497 bundle_get_str(b, buf_key, &ret_val);
499 noti->num_format_args = atoi(ret_val);
502 if (noti->num_format_args == 0) {
503 *text = (char *)get_str;
505 /* Check first variable is count, LEFT pos */
506 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
507 check_type, num_args);
508 bundle_get_str(b, buf_key, &ret_val);
510 ret_var_type = atoi(ret_val);
512 if (ret_var_type == NOTIFICATION_VARIABLE_TYPE_COUNT) {
514 snprintf(buf_key, sizeof(buf_key), "%dvalue%d",
515 check_type, num_args);
516 bundle_get_str(b, buf_key, &ret_val);
518 ret_variable_int = atoi(ret_val);
520 if (ret_variable_int ==
521 NOTIFICATION_COUNT_POS_LEFT) {
522 notification_get_count(noti->type,
523 noti->caller_pkgname,
527 snprintf(buf_str, sizeof(buf_str),
528 "%d ", ret_variable_int);
530 src_len = strlen(result_str);
531 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
533 strncat(result_str, buf_str,
539 /* Check variable IN pos */
540 for (temp_str = (char *)get_str; *temp_str != '\0';
542 if (*temp_str != '%') {
543 strncat(result_str, temp_str, 1);
545 if (*(temp_str + 1) == '%') {
546 strncat(result_str, temp_str,
548 } else if (*(temp_str + 1) == 'd') {
550 ret_variable_int = 0;
554 "%dtype%d", check_type,
556 bundle_get_str(b, buf_key, &ret_val);
558 ret_var_type = atoi(ret_val);
561 NOTIFICATION_VARIABLE_TYPE_COUNT) {
562 /* Get notification count */
563 notification_get_count(noti->type,
564 noti->caller_pkgname,
575 bundle_get_str(b, buf_key, &ret_val);
577 ret_variable_int = atoi(ret_val);
581 sizeof(buf_str), "%d",
584 src_len = strlen(result_str);
585 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
587 strncat(result_str, buf_str,
593 } else if (*(temp_str + 1) == 's') {
598 check_type, num_args);
599 bundle_get_str(b, buf_key, &ret_val);
601 if (ret_val != NULL && noti->domain != NULL && noti->dir != NULL) {
602 /* Get application string */
603 bindtextdomain(noti->domain, noti->dir);
604 translated_str = dgettext(noti->domain, ret_val);
605 NOTIFICATION_INFO("translated_str[%s]", translated_str);
606 } else if (ret_val != NULL) {
607 /* Get system string */
608 translated_str = dgettext("sys_string", ret_val);
609 NOTIFICATION_INFO("translated_str[%s]", translated_str);
611 translated_str = NULL;
614 if (translated_str != NULL) {
615 strncpy(buf_str, translated_str, sizeof(buf_str) - 1);
616 src_len = strlen(result_str);
617 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
618 strncat(result_str, buf_str, max_len);
622 } else if (*(temp_str + 1) == 'f') {
627 check_type, num_args);
628 bundle_get_str(b, buf_key, &ret_val);
630 ret_variable_double = atof(ret_val);
635 ret_variable_double);
637 src_len = strlen(result_str);
638 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
639 strncat(result_str, buf_str, max_len);
643 } else if (*(temp_str + 1) >= '1' && *(temp_str + 1) <= '9') {
644 if (*(temp_str + 3) == 'd') {
646 ret_variable_int = 0;
650 "%dtype%d", check_type,
651 num_args + *(temp_str + 1) - 49);
652 bundle_get_str(b, buf_key, &ret_val);
654 ret_var_type = atoi(ret_val);
657 NOTIFICATION_VARIABLE_TYPE_COUNT) {
658 /* Get notification count */
659 notification_get_count(noti->type,
660 noti->caller_pkgname,
671 num_args + *(temp_str + 1) - 49);
672 bundle_get_str(b, buf_key, &ret_val);
674 ret_variable_int = atoi(ret_val);
679 sizeof(buf_str), "%d",
682 src_len = strlen(result_str);
683 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
685 strncat(result_str, buf_str, max_len);
688 } else if (*(temp_str + 3) == 's') {
693 check_type, num_args + *(temp_str + 1) - 49);
694 bundle_get_str(b, buf_key, &ret_val);
697 sizeof(buf_str), "%s",
700 src_len = strlen(result_str);
701 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
703 strncat(result_str, buf_str, max_len);
706 } else if (*(temp_str + 3) == 'f') {
711 check_type, num_args + *(temp_str + 1) - 49);
712 bundle_get_str(b, buf_key, &ret_val);
714 ret_variable_double = atof(ret_val);
719 ret_variable_double);
721 src_len = strlen(result_str);
722 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
724 strncat(result_str, buf_str, max_len);
733 /* Check last variable is count, LEFT pos */
734 if (num_args < noti->num_format_args) {
735 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
736 check_type, num_args);
737 bundle_get_str(b, buf_key, &ret_val);
739 ret_var_type = atoi(ret_val);
742 NOTIFICATION_VARIABLE_TYPE_COUNT) {
744 snprintf(buf_key, sizeof(buf_key),
745 "%dvalue%d", check_type,
747 bundle_get_str(b, buf_key, &ret_val);
749 ret_variable_int = atoi(ret_val);
751 if (ret_variable_int ==
752 NOTIFICATION_COUNT_POS_RIGHT) {
753 notification_get_count(noti->type,
754 noti->caller_pkgname,
759 sizeof(buf_str), " %d",
762 src_len = strlen(result_str);
763 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
765 strncat(result_str, buf_str, max_len);
773 switch (check_type) {
774 case NOTIFICATION_TEXT_TYPE_TITLE:
775 case NOTIFICATION_TEXT_TYPE_GROUP_TITLE:
776 if (noti->temp_title != NULL)
777 free(noti->temp_title);
779 noti->temp_title = strdup(result_str);
781 *text = noti->temp_title;
783 case NOTIFICATION_TEXT_TYPE_CONTENT:
784 case NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
785 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT:
786 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
787 if (noti->temp_content !=
789 free(noti->temp_content);
791 noti->temp_content = strdup(result_str);
793 *text = noti->temp_content;
805 return NOTIFICATION_ERROR_NONE;
808 EXPORT_API int notification_set_text_domain(notification_h noti,
812 if (noti == NULL || domain == NULL || dir == NULL)
813 return NOTIFICATION_ERROR_INVALID_PARAMETER;
818 noti->domain = strdup(domain);
823 noti->dir = strdup(dir);
825 return NOTIFICATION_ERROR_NONE;
828 EXPORT_API int notification_get_text_domain(notification_h noti,
833 return NOTIFICATION_ERROR_INVALID_PARAMETER;
835 if (domain != NULL && noti->domain != NULL)
836 *domain = noti->domain;
838 if (dir != NULL && noti->dir != NULL)
841 return NOTIFICATION_ERROR_NONE;
844 EXPORT_API int notification_set_time_to_text(notification_h noti, notification_text_type_e type,
847 int ret = NOTIFICATION_ERROR_NONE;
848 char buf[256] = { 0, };
849 char buf_tag[512] = { 0, };
852 return NOTIFICATION_ERROR_INVALID_PARAMETER;
855 return NOTIFICATION_ERROR_INVALID_PARAMETER;
857 if (type <= NOTIFICATION_TEXT_TYPE_NONE
858 || type >= NOTIFICATION_TEXT_TYPE_MAX)
859 return NOTIFICATION_ERROR_INVALID_PARAMETER;
862 snprintf(buf, sizeof(buf), "%lu", time);
863 ret = notification_noti_set_tag(TAG_TIME, buf, buf_tag, sizeof(buf_tag));
865 if (ret != NOTIFICATION_ERROR_NONE)
868 return notification_set_text(noti, type, buf_tag, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
871 EXPORT_API int notification_get_time_from_text(notification_h noti, notification_text_type_e type,
874 int ret = NOTIFICATION_ERROR_NONE;
875 char *ret_text = NULL;
879 return NOTIFICATION_ERROR_INVALID_PARAMETER;
882 return NOTIFICATION_ERROR_INVALID_PARAMETER;
884 if (type <= NOTIFICATION_TEXT_TYPE_NONE
885 || type >= NOTIFICATION_TEXT_TYPE_MAX)
886 return NOTIFICATION_ERROR_INVALID_PARAMETER;
888 ret = notification_get_text(noti, type, &ret_text);
890 if (ret != NOTIFICATION_ERROR_NONE || ret_text == NULL)
891 return NOTIFICATION_ERROR_INVALID_PARAMETER;
893 if (notification_noti_get_tag_type(ret_text) == TAG_TYPE_INVALID)
894 return NOTIFICATION_ERROR_INVALID_PARAMETER;
896 tag_value = notification_noti_strip_tag(ret_text);
897 if (tag_value == NULL)
898 return NOTIFICATION_ERROR_INVALID_PARAMETER;
900 *time = atol(tag_value);
903 return NOTIFICATION_ERROR_NONE;
906 EXPORT_API int notification_set_sound(notification_h noti,
907 notification_sound_type_e type,
911 return NOTIFICATION_ERROR_INVALID_PARAMETER;
913 if (type < NOTIFICATION_SOUND_TYPE_NONE
914 || type >= NOTIFICATION_SOUND_TYPE_MAX)
915 return NOTIFICATION_ERROR_INVALID_PARAMETER;
917 noti->sound_type = type;
919 /* Save sound path if user data type */
920 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA && path != NULL) {
921 if (noti->sound_path != NULL)
922 free(noti->sound_path);
924 noti->sound_path = strdup(path);
926 if (noti->sound_path != NULL) {
927 free(noti->sound_path);
928 noti->sound_path = NULL;
930 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA) {
931 noti->sound_type = NOTIFICATION_SOUND_TYPE_DEFAULT;
932 return NOTIFICATION_ERROR_INVALID_PARAMETER;
936 return NOTIFICATION_ERROR_NONE;
939 EXPORT_API int notification_get_sound(notification_h noti,
940 notification_sound_type_e *type,
943 if (noti == NULL || type == NULL)
944 return NOTIFICATION_ERROR_INVALID_PARAMETER;
946 *type = noti->sound_type;
948 /* Set sound path if user data type */
949 if (noti->sound_type == NOTIFICATION_SOUND_TYPE_USER_DATA
951 *path = noti->sound_path;
953 return NOTIFICATION_ERROR_NONE;
956 EXPORT_API int notification_set_vibration(notification_h noti,
957 notification_vibration_type_e type,
961 return NOTIFICATION_ERROR_INVALID_PARAMETER;
963 if (type < NOTIFICATION_VIBRATION_TYPE_NONE
964 || type >= NOTIFICATION_VIBRATION_TYPE_MAX)
965 return NOTIFICATION_ERROR_INVALID_PARAMETER;
967 noti->vibration_type = type;
969 /* Save sound path if user data type */
970 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA && path != NULL) {
971 if (noti->vibration_path != NULL)
972 free(noti->vibration_path);
974 noti->vibration_path = strdup(path);
976 if (noti->vibration_path != NULL) {
977 free(noti->vibration_path);
978 noti->vibration_path = NULL;
980 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA) {
981 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
982 return NOTIFICATION_ERROR_INVALID_PARAMETER;
986 return NOTIFICATION_ERROR_NONE;
990 EXPORT_API int notification_get_vibration(notification_h noti,
991 notification_vibration_type_e *type,
994 if (noti == NULL || type == NULL)
995 return NOTIFICATION_ERROR_INVALID_PARAMETER;
997 *type = noti->vibration_type;
999 /* Set sound path if user data type */
1000 if (noti->vibration_type == NOTIFICATION_VIBRATION_TYPE_USER_DATA
1002 *path = noti->vibration_path;
1004 return NOTIFICATION_ERROR_NONE;
1007 EXPORT_API int notification_set_led(notification_h noti,
1008 notification_led_op_e operation,
1012 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1014 if (operation < NOTIFICATION_LED_OP_OFF
1015 || operation >= NOTIFICATION_LED_OP_MAX)
1016 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1018 noti->led_operation = operation;
1020 /* Save led argb if operation is turning on LED with custom color */
1021 if (operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR)
1022 noti->led_argb = led_argb;
1024 return NOTIFICATION_ERROR_NONE;
1027 EXPORT_API int notification_get_led(notification_h noti,
1028 notification_led_op_e *operation,
1031 if (noti == NULL || operation == NULL)
1032 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1034 *operation = noti->led_operation;
1036 /* Save led argb if operation is turning on LED with custom color */
1037 if (noti->led_operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR
1038 && led_argb != NULL)
1039 *led_argb = noti->led_argb;
1041 return NOTIFICATION_ERROR_NONE;
1044 EXPORT_API int notification_set_led_time_period(notification_h noti,
1045 int on_ms, int off_ms)
1047 if (noti == NULL || on_ms < 0 || off_ms < 0)
1048 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1050 noti->led_on_ms = on_ms;
1051 noti->led_off_ms = off_ms;
1053 return NOTIFICATION_ERROR_NONE;
1056 EXPORT_API int notification_get_led_time_period(notification_h noti,
1057 int *on_ms, int *off_ms)
1060 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1063 *(on_ms) = noti->led_on_ms;
1065 *(off_ms) = noti->led_off_ms;
1067 return NOTIFICATION_ERROR_NONE;
1070 EXPORT_API int notification_set_launch_option(notification_h noti,
1071 notification_launch_option_type type, void *option)
1073 int err = NOTIFICATION_ERROR_NONE;
1076 app_control_h app_control = option;
1078 if (noti == NULL || app_control == NULL || type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL) {
1079 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1083 if ((ret = app_control_export_as_bundle(app_control, &b)) != APP_CONTROL_ERROR_NONE) {
1084 NOTIFICATION_ERR("Failed to convert appcontrol to bundle:%d", ret);
1085 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1089 err = notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, b);
1098 EXPORT_API int notification_get_launch_option(notification_h noti,
1099 notification_launch_option_type type, void *option)
1103 app_control_h *app_control = (app_control_h *)option;
1104 app_control_h app_control_new = NULL;
1107 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1109 if (app_control == NULL)
1110 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1112 if (type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL)
1113 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1116 ret = notification_get_execute_option(noti,
1117 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
1120 if (ret == NOTIFICATION_ERROR_NONE && b != NULL) {
1121 ret = app_control_create(&app_control_new);
1122 if (ret == APP_CONTROL_ERROR_NONE && app_control_new != NULL) {
1123 ret = app_control_import_from_bundle(app_control_new, b);
1124 if (ret == APP_CONTROL_ERROR_NONE) {
1125 *app_control = app_control_new;
1127 app_control_destroy(app_control_new);
1128 NOTIFICATION_ERR("Failed to import app control from bundle:%d", ret);
1129 return NOTIFICATION_ERROR_IO_ERROR;
1132 NOTIFICATION_ERR("Failed to create app control:%d", ret);
1133 return NOTIFICATION_ERROR_IO_ERROR;
1136 NOTIFICATION_ERR("Failed to get execute option:%d", ret);
1140 return NOTIFICATION_ERROR_NONE;
1143 EXPORT_API int notification_set_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h event_handler)
1145 int err = NOTIFICATION_ERROR_NONE;
1146 bundle *app_control_bundle = NULL;
1149 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1150 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1154 if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
1155 || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
1156 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1157 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1161 if ((err = app_control_export_as_bundle(event_handler, &app_control_bundle)) != APP_CONTROL_ERROR_NONE) {
1162 NOTIFICATION_ERR("app_control_to_bundle failed [%d]", err);
1166 if (noti->b_event_handler[event_type] != NULL)
1167 bundle_free(noti->b_event_handler[event_type]);
1169 noti->b_event_handler[event_type] = app_control_bundle;
1175 EXPORT_API int notification_get_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h *event_handler)
1177 int err = NOTIFICATION_ERROR_NONE;
1179 app_control_h app_control_new = NULL;
1182 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1183 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1187 if (event_handler == NULL) {
1188 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1189 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1193 if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
1194 || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
1195 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1196 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1200 b = noti->b_event_handler[event_type];
1202 NOTIFICATION_DBG("No event handler\n");
1203 err = NOTIFICATION_ERROR_NOT_EXIST_ID;
1207 err = app_control_create(&app_control_new);
1208 if (err != APP_CONTROL_ERROR_NONE || app_control_new == NULL) {
1209 NOTIFICATION_ERR("app_control_create failed [%d]", err);
1210 err = NOTIFICATION_ERROR_IO_ERROR;
1214 err = app_control_import_from_bundle(app_control_new, b);
1215 if (err == APP_CONTROL_ERROR_NONE) {
1216 *event_handler = app_control_new;
1218 app_control_destroy(app_control_new);
1219 app_control_new = NULL;
1220 NOTIFICATION_ERR("Failed to import app control from bundle [%d]", err);
1221 err = NOTIFICATION_ERROR_IO_ERROR;
1227 *event_handler = app_control_new;
1236 EXPORT_API int notification_set_property(notification_h noti,
1240 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1242 noti->flags_for_property = flags;
1244 return NOTIFICATION_ERROR_NONE;
1247 EXPORT_API int notification_get_property(notification_h noti,
1250 if (noti == NULL || flags == NULL)
1251 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1253 *flags = noti->flags_for_property;
1255 return NOTIFICATION_ERROR_NONE;
1258 EXPORT_API int notification_set_display_applist(notification_h noti,
1262 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1264 if (applist == 0xffffffff) /* 0xffffffff means old NOTIFICATION_DISPLAY_APP_ALL */
1265 applist = NOTIFICATION_DISPLAY_APP_ALL;
1267 noti->display_applist = applist;
1269 return NOTIFICATION_ERROR_NONE;
1272 EXPORT_API int notification_get_display_applist(notification_h noti,
1275 if (noti == NULL || applist == NULL)
1276 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1278 *applist = noti->display_applist;
1280 return NOTIFICATION_ERROR_NONE;
1283 EXPORT_API int notification_set_size(notification_h noti,
1287 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1289 noti->progress_size = size;
1291 return NOTIFICATION_ERROR_NONE;
1294 EXPORT_API int notification_get_size(notification_h noti,
1297 if (noti == NULL || size == NULL)
1298 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1300 *size = noti->progress_size;
1302 return NOTIFICATION_ERROR_NONE;
1305 EXPORT_API int notification_set_progress(notification_h noti,
1309 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1311 noti->progress_percentage = percentage;
1313 return NOTIFICATION_ERROR_NONE;
1316 EXPORT_API int notification_get_progress(notification_h noti,
1319 if (noti == NULL || percentage == NULL)
1320 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1322 *percentage = noti->progress_percentage;
1324 return NOTIFICATION_ERROR_NONE;
1327 EXPORT_API int notification_get_pkgname(notification_h noti,
1330 if (noti == NULL || pkgname == NULL)
1331 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1333 if (noti->caller_pkgname)
1334 *pkgname = noti->caller_pkgname;
1338 return NOTIFICATION_ERROR_NONE;
1341 EXPORT_API int notification_set_layout(notification_h noti,
1342 notification_ly_type_e layout)
1344 if (noti == NULL || (layout < NOTIFICATION_LY_NONE || layout >= NOTIFICATION_LY_MAX))
1345 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1347 noti->layout = layout;
1349 return NOTIFICATION_ERROR_NONE;
1352 EXPORT_API int notification_get_layout(notification_h noti,
1353 notification_ly_type_e *layout)
1355 if (noti == NULL || layout == NULL)
1356 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1358 *layout = noti->layout;
1360 return NOTIFICATION_ERROR_NONE;
1365 EXPORT_API int notification_get_type(notification_h noti,
1366 notification_type_e *type)
1368 if (noti == NULL || type == NULL)
1369 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1373 return NOTIFICATION_ERROR_NONE;
1376 EXPORT_API int notification_post(notification_h noti)
1378 return notification_post_for_uid(noti, getuid());
1381 EXPORT_API int notification_update(notification_h noti)
1383 return notification_update_for_uid(noti, getuid());
1386 EXPORT_API int notification_delete_all(notification_type_e type)
1388 return notification_delete_all_for_uid(type, getuid());
1391 EXPORT_API int notification_delete(notification_h noti)
1393 return notification_delete_for_uid(noti, getuid());
1396 static notification_h _notification_create(notification_type_e type)
1398 notification_h noti = NULL;
1399 package_info_h package_info = NULL;
1400 char *app_id = NULL;
1401 char *domain_name = NULL;
1402 char *app_root_path = NULL;
1403 char locale_directory[PATH_MAX] = { 0, }; /* PATH_MAX 4096 */
1404 int err_app_manager = APP_MANAGER_ERROR_NONE;
1406 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1407 NOTIFICATION_ERR("INVALID TYPE : %d", type);
1408 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
1412 noti = (notification_h) calloc(1, sizeof(struct _notification));
1414 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
1415 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
1421 if (type == NOTIFICATION_TYPE_NOTI)
1422 noti->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
1423 else if (type == NOTIFICATION_TYPE_ONGOING)
1424 noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
1426 noti->caller_pkgname = notification_get_pkgname_by_pid();
1427 noti->group_id = NOTIFICATION_GROUP_ID_NONE;
1428 noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
1429 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
1430 noti->led_operation = NOTIFICATION_LED_OP_OFF;
1431 noti->display_applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_INDICATOR;
1432 noti->auto_remove = true;
1433 noti->ongoing_flag = false;
1435 err_app_manager = app_manager_get_app_id(getpid(), &app_id);
1436 if (err_app_manager != APP_MANAGER_ERROR_NONE || app_id == NULL) {
1437 NOTIFICATION_WARN("app_manager_get_app_id failed err[%d] app_id[%p]", err_app_manager, app_id);
1441 /* app name is used as domain name */
1442 /* domain_name is allocated by app_get_package_app_name */
1443 err_app_manager = app_get_package_app_name(app_id, &domain_name);
1445 if (err_app_manager != APP_ERROR_NONE || domain_name == NULL) {
1446 NOTIFICATION_WARN("app_get_package_app_name failed err[%d] domain_name[%p]", err_app_manager, domain_name);
1450 err_app_manager = package_info_create(noti->caller_pkgname, &package_info);
1452 if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || package_info == NULL) {
1453 NOTIFICATION_WARN("package_info_create failed err[%d] package_info[%p] caller_pkgname[%s]",
1454 err_app_manager, package_info, noti->caller_pkgname);
1458 err_app_manager = package_info_get_root_path(package_info, &app_root_path);
1460 if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || app_root_path == NULL) {
1461 NOTIFICATION_WARN("package_info_get_root_path failed err[%d] app_root_path[%p]", err_app_manager, app_root_path);
1465 snprintf(locale_directory, PATH_MAX, "%s/res/locale", app_root_path);
1467 noti->domain = strdup(domain_name);
1468 noti->dir = strdup(locale_directory);
1478 free(app_root_path);
1481 package_info_destroy(package_info);
1485 * Other fields are already initialized with ZERO.
1487 set_last_result(NOTIFICATION_ERROR_NONE);
1491 EXPORT_API notification_h notification_create(notification_type_e type)
1493 return _notification_create(type);
1496 EXPORT_API notification_h notification_load_by_tag(const char *tag)
1498 return notification_load_by_tag_for_uid(tag, getuid());
1501 EXPORT_API int notification_clone(notification_h noti, notification_h *clone)
1504 notification_h new_noti = NULL;
1506 if (noti == NULL || clone == NULL) {
1507 NOTIFICATION_ERR("INVALID PARAMETER.");
1508 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1511 new_noti = (notification_h) calloc(1, sizeof(struct _notification));
1512 if (new_noti == NULL) {
1513 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
1514 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
1517 new_noti->type = noti->type;
1518 new_noti->layout = noti->layout;
1520 new_noti->group_id = noti->group_id;
1521 new_noti->internal_group_id = noti->internal_group_id;
1522 new_noti->priv_id = noti->priv_id;
1524 if (noti->caller_pkgname != NULL)
1525 new_noti->caller_pkgname = strdup(noti->caller_pkgname);
1527 new_noti->caller_pkgname = notification_get_pkgname_by_pid();
1529 if (noti->launch_pkgname != NULL)
1530 new_noti->launch_pkgname = strdup(noti->launch_pkgname);
1532 new_noti->launch_pkgname = NULL;
1534 if (noti->args != NULL)
1535 new_noti->args = bundle_dup(noti->args);
1537 new_noti->args = NULL;
1539 if (noti->group_args != NULL)
1540 new_noti->group_args = bundle_dup(noti->group_args);
1542 new_noti->group_args = NULL;
1544 if (noti->b_execute_option != NULL)
1545 new_noti->b_execute_option = bundle_dup(noti->b_execute_option);
1547 new_noti->b_execute_option = NULL;
1549 if (noti->b_service_responding != NULL)
1550 new_noti->b_service_responding = bundle_dup(noti->b_service_responding);
1552 new_noti->b_service_responding = NULL;
1554 if (noti->b_service_single_launch != NULL)
1555 new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch);
1557 new_noti->b_service_single_launch = NULL;
1559 if (noti->b_service_multi_launch != NULL)
1560 new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch);
1562 new_noti->b_service_multi_launch = NULL;
1564 for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
1565 if (noti->b_event_handler[i] != NULL)
1566 new_noti->b_event_handler[i] = bundle_dup(noti->b_event_handler[i]);
1568 new_noti->b_event_handler[i] = NULL;
1571 new_noti->sound_type = noti->sound_type;
1572 if (noti->sound_path != NULL)
1573 new_noti->sound_path = strdup(noti->sound_path);
1575 new_noti->sound_path = NULL;
1577 new_noti->vibration_type = noti->vibration_type;
1578 if (noti->vibration_path != NULL)
1579 new_noti->vibration_path = strdup(noti->vibration_path);
1581 new_noti->vibration_path = NULL;
1583 new_noti->led_operation = noti->led_operation;
1584 new_noti->led_argb = noti->led_argb;
1585 new_noti->led_on_ms = noti->led_on_ms;
1586 new_noti->led_off_ms = noti->led_off_ms;
1588 if (noti->domain != NULL)
1589 new_noti->domain = strdup(noti->domain);
1591 new_noti->domain = NULL;
1593 if (noti->dir != NULL)
1594 new_noti->dir = strdup(noti->dir);
1596 new_noti->dir = NULL;
1598 if (noti->b_text != NULL)
1599 new_noti->b_text = bundle_dup(noti->b_text);
1601 new_noti->b_text = NULL;
1603 if (noti->b_key != NULL)
1604 new_noti->b_key = bundle_dup(noti->b_key);
1606 new_noti->b_key = NULL;
1608 if (noti->tag != NULL)
1609 new_noti->tag = strdup(noti->tag);
1611 new_noti->tag = NULL;
1613 if (noti->b_format_args != NULL)
1614 new_noti->b_format_args = bundle_dup(noti->b_format_args);
1616 new_noti->b_format_args = NULL;
1618 new_noti->num_format_args = noti->num_format_args;
1620 if (noti->b_image_path != NULL)
1621 new_noti->b_image_path = bundle_dup(noti->b_image_path);
1623 new_noti->b_image_path = NULL;
1625 new_noti->time = noti->time;
1626 new_noti->insert_time = noti->insert_time;
1628 new_noti->flags_for_property = noti->flags_for_property;
1629 new_noti->display_applist = noti->display_applist;
1631 new_noti->progress_size = noti->progress_size;
1632 new_noti->progress_percentage = noti->progress_percentage;
1634 new_noti->ongoing_flag = noti->ongoing_flag;
1635 new_noti->auto_remove = noti->auto_remove;
1636 new_noti->uid = noti->uid;
1638 new_noti->app_icon_path = NULL;
1639 new_noti->app_name = NULL;
1640 new_noti->temp_title = NULL;
1641 new_noti->temp_content = NULL;
1645 return NOTIFICATION_ERROR_NONE;
1649 EXPORT_API int notification_free(notification_h noti)
1653 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1655 if (noti->caller_pkgname)
1656 free(noti->caller_pkgname);
1658 if (noti->launch_pkgname)
1659 free(noti->launch_pkgname);
1662 bundle_free(noti->args);
1664 if (noti->group_args)
1665 bundle_free(noti->group_args);
1667 if (noti->b_execute_option)
1668 bundle_free(noti->b_execute_option);
1670 if (noti->b_service_responding)
1671 bundle_free(noti->b_service_responding);
1673 if (noti->b_service_single_launch)
1674 bundle_free(noti->b_service_single_launch);
1676 if (noti->b_service_multi_launch)
1677 bundle_free(noti->b_service_multi_launch);
1679 for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
1680 if (noti->b_event_handler[i] != NULL)
1681 bundle_free(noti->b_event_handler[i]);
1684 if (noti->sound_path)
1685 free(noti->sound_path);
1687 if (noti->vibration_path)
1688 free(noti->vibration_path);
1697 bundle_free(noti->b_text);
1700 bundle_free(noti->b_key);
1702 if (noti->b_format_args)
1703 bundle_free(noti->b_format_args);
1705 if (noti->b_image_path)
1706 bundle_free(noti->b_image_path);
1708 if (noti->app_icon_path)
1709 free(noti->app_icon_path);
1712 free(noti->app_name);
1714 if (noti->temp_title)
1715 free(noti->temp_title);
1717 if (noti->temp_content)
1718 free(noti->temp_content);
1725 return NOTIFICATION_ERROR_NONE;
1728 EXPORT_API int notification_set_tag(notification_h noti, const char *tag)
1731 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1734 if (noti->tag != NULL)
1737 noti->tag = strdup(tag);
1740 return NOTIFICATION_ERROR_NONE;
1744 EXPORT_API int notification_get_tag(notification_h noti, const char **tag)
1747 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1750 return NOTIFICATION_ERROR_NONE;
1753 /* LCOV_EXCL_START */
1754 void notification_call_posted_toast_cb(const char *message)
1756 if (posted_toast_message_cb != NULL)
1757 posted_toast_message_cb((void *)message);
1759 /* LCOV_EXCL_STOP */
1761 EXPORT_API int notification_set_ongoing_flag(notification_h noti, bool ongoing_flag)
1764 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1766 noti->ongoing_flag = ongoing_flag;
1768 return NOTIFICATION_ERROR_NONE;
1771 EXPORT_API int notification_get_ongoing_flag(notification_h noti, bool *ongoing_flag)
1773 if (noti == NULL || ongoing_flag == NULL)
1774 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1776 *ongoing_flag = noti->ongoing_flag;
1778 return NOTIFICATION_ERROR_NONE;
1782 EXPORT_API int notification_add_button(notification_h noti, notification_button_index_e button_index)
1784 if (noti == NULL || button_index < NOTIFICATION_BUTTON_1 || button_index > NOTIFICATION_BUTTON_6)
1785 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1787 return NOTIFICATION_ERROR_NONE;
1790 EXPORT_API int notification_remove_button(notification_h noti, notification_button_index_e button_index)
1792 if (noti == NULL || button_index < NOTIFICATION_BUTTON_1 || button_index > NOTIFICATION_BUTTON_6)
1793 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1795 if (noti->b_event_handler[button_index - 1]) {
1796 bundle_free(noti->b_event_handler[button_index - 1]);
1797 noti->b_event_handler[button_index - 1] = NULL;
1800 return NOTIFICATION_ERROR_NONE;
1803 EXPORT_API int notification_set_auto_remove(notification_h noti, bool auto_remove)
1806 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1808 noti->auto_remove = auto_remove;
1810 return NOTIFICATION_ERROR_NONE;
1813 EXPORT_API int notification_get_auto_remove(notification_h noti, bool *auto_remove)
1815 if (noti == NULL || auto_remove == NULL)
1816 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1818 *auto_remove = noti->auto_remove;
1820 return NOTIFICATION_ERROR_NONE;