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 #define REGULAR_UID_MIN 5000
54 char *notification_get_pkgname_by_pid(void)
56 char pkgname[NOTI_PKGNAME_LEN + 1] = { 0, };
57 int pid = 0, ret = AUL_R_OK;
60 char buf[NOTI_PKGNAME_LEN + 1] = { 0, };
64 ret = aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname));
65 if (ret != AUL_R_OK) {
67 snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
69 fd = open(buf, O_RDONLY);
73 ret = read(fd, pkgname, sizeof(pkgname) - 1);
82 * "ret" is not able to be larger than "sizeof(pkgname) - 1",
83 * if the system is not going wrong.
86 if (strlen(pkgname) <= 0)
90 dup_pkgname = strdup(pkgname);
92 NOTIFICATION_ERR("Heap: %d\n", errno);
97 EXPORT_API int notification_set_image(notification_h noti,
98 notification_image_type_e type,
99 const char *image_path)
102 char buf_key[32] = { 0, };
103 char *ret_val = NULL;
105 if (noti == NULL || image_path == NULL)
106 return NOTIFICATION_ERROR_INVALID_PARAMETER;
108 if (type <= NOTIFICATION_IMAGE_TYPE_NONE
109 || type >= NOTIFICATION_IMAGE_TYPE_MAX)
110 return NOTIFICATION_ERROR_INVALID_PARAMETER;
112 if (noti->b_image_path) {
113 b = noti->b_image_path;
115 snprintf(buf_key, sizeof(buf_key), "%d", type);
117 bundle_get_str(b, buf_key, &ret_val);
119 bundle_del(b, buf_key);
121 bundle_add_str(b, buf_key, image_path);
125 snprintf(buf_key, sizeof(buf_key), "%d", type);
127 bundle_add_str(b, buf_key, image_path);
129 noti->b_image_path = b;
132 return NOTIFICATION_ERROR_NONE;
135 EXPORT_API int notification_get_image(notification_h noti,
136 notification_image_type_e type,
140 char buf_key[32] = { 0, };
141 char *ret_val = NULL;
143 if (noti == NULL || image_path == NULL)
144 return NOTIFICATION_ERROR_INVALID_PARAMETER;
146 if (type <= NOTIFICATION_IMAGE_TYPE_NONE
147 || type >= NOTIFICATION_IMAGE_TYPE_MAX)
148 return NOTIFICATION_ERROR_INVALID_PARAMETER;
150 if (noti->b_image_path) {
151 b = noti->b_image_path;
153 snprintf(buf_key, sizeof(buf_key), "%d", type);
155 bundle_get_str(b, buf_key, &ret_val);
157 *image_path = ret_val;
159 /* If image path bundle does not exist, image path is NULL */
163 /* If image path is NULL and type is ICON, icon path set from AIL */
164 /* order : user icon -> launch_pkgname icon -> caller_pkgname icon -> service app icon */
165 if (*image_path == NULL && type == NOTIFICATION_IMAGE_TYPE_ICON) {
166 if (noti->app_icon_path != NULL)
167 *image_path = noti->app_icon_path;
172 return NOTIFICATION_ERROR_NONE;
175 EXPORT_API int notification_set_time(notification_h noti, time_t input_time)
178 return NOTIFICATION_ERROR_INVALID_PARAMETER;
181 noti->time = time(NULL);
183 noti->time = input_time;
185 return NOTIFICATION_ERROR_NONE;
188 EXPORT_API int notification_get_time(notification_h noti, time_t *ret_time)
190 if (noti == NULL || ret_time == NULL)
191 return NOTIFICATION_ERROR_INVALID_PARAMETER;
193 *ret_time = noti->time;
195 return NOTIFICATION_ERROR_NONE;
198 EXPORT_API int notification_get_insert_time(notification_h noti,
201 if (noti == NULL || ret_time == NULL)
202 return NOTIFICATION_ERROR_INVALID_PARAMETER;
204 *ret_time = noti->insert_time;
206 return NOTIFICATION_ERROR_NONE;
209 EXPORT_API int notification_set_text(notification_h noti,
210 notification_text_type_e type, const char *text,
211 const char *key, int args_type, ...)
214 char buf_key[32] = { 0, };
215 char buf_val[1024] = { 0, };
216 char *ret_val = NULL;
218 notification_variable_type_e var_type;
220 int noti_err = NOTIFICATION_ERROR_NONE;
221 int var_value_int = 0;
222 double var_value_double = 0.0;
223 char *var_value_string = NULL;
224 notification_count_pos_type_e var_value_count =
225 NOTIFICATION_COUNT_POS_NONE;
228 return NOTIFICATION_ERROR_INVALID_PARAMETER;
230 if (type <= NOTIFICATION_TEXT_TYPE_NONE
231 || type >= NOTIFICATION_TEXT_TYPE_MAX)
232 return NOTIFICATION_ERROR_INVALID_PARAMETER;
235 if (noti->b_text != NULL) {
238 snprintf(buf_key, sizeof(buf_key), "%d", type);
240 bundle_get_str(b, buf_key, &ret_val);
243 bundle_del(b, buf_key);
245 snprintf(buf_val, sizeof(buf_val), "%s", text);
247 bundle_add_str(b, buf_key, buf_val);
251 snprintf(buf_key, sizeof(buf_key), "%d", type);
252 snprintf(buf_val, sizeof(buf_val), "%s", text);
254 bundle_add_str(b, buf_key, buf_val);
259 if (noti->b_text != NULL) {
262 snprintf(buf_key, sizeof(buf_key), "%d", type);
264 bundle_get_str(b, buf_key, &ret_val);
266 bundle_del(b, buf_key);
271 if (noti->b_key != NULL) {
274 snprintf(buf_key, sizeof(buf_key), "%d", type);
276 bundle_get_str(b, buf_key, &ret_val);
278 bundle_del(b, buf_key);
280 snprintf(buf_val, sizeof(buf_val), "%s", key);
282 bundle_add_str(b, buf_key, buf_val);
286 snprintf(buf_key, sizeof(buf_key), "%d", type);
288 snprintf(buf_val, sizeof(buf_val), "%s", key);
290 bundle_add_str(b, buf_key, buf_val);
295 if (noti->b_key != NULL) {
298 snprintf(buf_key, sizeof(buf_key), "%d", type);
300 bundle_get_str(b, buf_key, &ret_val);
302 bundle_del(b, buf_key);
306 if (noti->b_format_args != NULL)
307 b = noti->b_format_args;
311 va_start(var_args, args_type);
313 var_type = args_type;
316 while (var_type != NOTIFICATION_VARIABLE_TYPE_NONE) {
318 snprintf(buf_key, sizeof(buf_key), "%dtype%d", type, num_args);
319 snprintf(buf_val, sizeof(buf_val), "%d", var_type);
321 bundle_get_str(b, buf_key, &ret_val);
323 bundle_del(b, buf_key);
325 bundle_add_str(b, buf_key, buf_val);
328 case NOTIFICATION_VARIABLE_TYPE_INT:
329 var_value_int = va_arg(var_args, int);
332 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
334 snprintf(buf_val, sizeof(buf_val), "%d", var_value_int);
336 bundle_get_str(b, buf_key, &ret_val);
338 bundle_del(b, buf_key);
340 bundle_add_str(b, buf_key, buf_val);
343 case NOTIFICATION_VARIABLE_TYPE_DOUBLE:
344 var_value_double = va_arg(var_args, double);
347 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
349 snprintf(buf_val, sizeof(buf_val), "%.2f",
352 bundle_get_str(b, buf_key, &ret_val);
354 bundle_del(b, buf_key);
356 bundle_add_str(b, buf_key, buf_val);
359 case NOTIFICATION_VARIABLE_TYPE_STRING:
360 var_value_string = va_arg(var_args, char *);
363 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
365 snprintf(buf_val, sizeof(buf_val), "%s",
368 bundle_get_str(b, buf_key, &ret_val);
370 bundle_del(b, buf_key);
372 bundle_add_str(b, buf_key, buf_val);
375 case NOTIFICATION_VARIABLE_TYPE_COUNT:
377 va_arg(var_args, notification_count_pos_type_e);
380 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
382 snprintf(buf_val, sizeof(buf_val), "%d",
385 bundle_get_str(b, buf_key, &ret_val);
387 bundle_del(b, buf_key);
389 bundle_add_str(b, buf_key, buf_val);
393 NOTIFICATION_ERR("Error. invalid variable type. : %d",
395 noti_err = NOTIFICATION_ERROR_INVALID_PARAMETER;
400 var_type = va_arg(var_args, notification_variable_type_e);
404 if (noti_err == NOTIFICATION_ERROR_NONE)
405 noti->num_format_args = num_args;
407 noti->num_format_args = 0;
409 snprintf(buf_key, sizeof(buf_key), "num%d", type);
410 snprintf(buf_val, sizeof(buf_val), "%d", noti->num_format_args);
412 bundle_get_str(b, buf_key, &ret_val);
414 bundle_del(b, buf_key);
416 bundle_add_str(b, buf_key, buf_val);
418 noti->b_format_args = b;
423 EXPORT_API int notification_get_text(notification_h noti,
424 notification_text_type_e type,
428 char buf_key[32] = { 0, };
429 char *ret_val = NULL;
430 char *get_str = NULL;
431 notification_text_type_e check_type = NOTIFICATION_TEXT_TYPE_NONE;
433 char *temp_str = NULL;
434 char *translated_str = NULL;
435 char result_str[NOTI_TEXT_RESULT_LEN] = { 0, };
436 char buf_str[1024] = { 0, };
438 notification_variable_type_e ret_var_type = 0;
439 int ret_variable_int = 0;
440 double ret_variable_double = 0.0;
444 if (noti == NULL || text == NULL)
445 return NOTIFICATION_ERROR_INVALID_PARAMETER;
447 if (type <= NOTIFICATION_TEXT_TYPE_NONE
448 || type >= NOTIFICATION_TEXT_TYPE_MAX)
449 return NOTIFICATION_ERROR_INVALID_PARAMETER;
452 if (noti->b_key != NULL) {
455 /* Get text domain and dir */
456 /* _notification_get_text_domain(noti); */
458 snprintf(buf_key, sizeof(buf_key), "%d", type);
460 bundle_get_str(b, buf_key, &ret_val);
461 if (ret_val != NULL && noti->domain != NULL
462 && noti->dir != NULL) {
463 /* Get application string */
464 bindtextdomain(noti->domain, noti->dir);
466 get_str = dgettext(noti->domain, ret_val);
467 if (get_str == ret_val) /* not found */
469 } else if (ret_val != NULL) {
470 /* Get system string */
471 get_str = dgettext("sys_string", ret_val);
472 if (get_str == ret_val) /* not found */
479 if (get_str == NULL && noti->b_text != NULL) {
482 snprintf(buf_key, sizeof(buf_key), "%d", type);
484 bundle_get_str(b, buf_key, &get_str);
487 if (get_str == NULL && ret_val != NULL)
488 get_str = ret_val; /* fallback for printing anything */
492 if (get_str != NULL) {
493 /* Get number format args */
494 b = noti->b_format_args;
495 noti->num_format_args = 0;
498 snprintf(buf_key, sizeof(buf_key), "num%d", check_type);
499 bundle_get_str(b, buf_key, &ret_val);
501 noti->num_format_args = atoi(ret_val);
504 if (noti->num_format_args == 0) {
505 *text = (char *)get_str;
507 /* Check first variable is count, LEFT pos */
508 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
509 check_type, num_args);
510 bundle_get_str(b, buf_key, &ret_val);
512 ret_var_type = atoi(ret_val);
514 if (ret_var_type == NOTIFICATION_VARIABLE_TYPE_COUNT) {
516 snprintf(buf_key, sizeof(buf_key), "%dvalue%d",
517 check_type, num_args);
518 bundle_get_str(b, buf_key, &ret_val);
520 ret_variable_int = atoi(ret_val);
522 if (ret_variable_int ==
523 NOTIFICATION_COUNT_POS_LEFT) {
524 notification_get_count(noti->type,
525 noti->caller_pkgname,
529 snprintf(buf_str, sizeof(buf_str),
530 "%d ", ret_variable_int);
532 src_len = strlen(result_str);
533 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
535 strncat(result_str, buf_str,
541 /* Check variable IN pos */
542 for (temp_str = (char *)get_str; *temp_str != '\0';
544 if (*temp_str != '%') {
545 strncat(result_str, temp_str, 1);
547 if (*(temp_str + 1) == '%') {
548 strncat(result_str, temp_str,
550 } else if (*(temp_str + 1) == 'd') {
552 ret_variable_int = 0;
556 "%dtype%d", check_type,
558 bundle_get_str(b, buf_key, &ret_val);
560 ret_var_type = atoi(ret_val);
563 NOTIFICATION_VARIABLE_TYPE_COUNT) {
564 /* Get notification count */
565 notification_get_count(noti->type,
566 noti->caller_pkgname,
577 bundle_get_str(b, buf_key, &ret_val);
579 ret_variable_int = atoi(ret_val);
583 sizeof(buf_str), "%d",
586 src_len = strlen(result_str);
587 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
589 strncat(result_str, buf_str,
595 } else if (*(temp_str + 1) == 's') {
600 check_type, num_args);
601 bundle_get_str(b, buf_key, &ret_val);
603 if (ret_val != NULL && noti->domain != NULL && noti->dir != NULL) {
604 /* Get application string */
605 bindtextdomain(noti->domain, noti->dir);
606 translated_str = dgettext(noti->domain, ret_val);
607 NOTIFICATION_INFO("translated_str[%s]", translated_str);
608 } else if (ret_val != NULL) {
609 /* Get system string */
610 translated_str = dgettext("sys_string", ret_val);
611 NOTIFICATION_INFO("translated_str[%s]", translated_str);
613 translated_str = NULL;
616 if (translated_str != NULL) {
617 strncpy(buf_str, translated_str, sizeof(buf_str) - 1);
618 src_len = strlen(result_str);
619 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
620 strncat(result_str, buf_str, max_len);
624 } else if (*(temp_str + 1) == 'f') {
629 check_type, num_args);
630 bundle_get_str(b, buf_key, &ret_val);
632 ret_variable_double = atof(ret_val);
637 ret_variable_double);
639 src_len = strlen(result_str);
640 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
641 strncat(result_str, buf_str, max_len);
645 } else if (*(temp_str + 1) >= '1' && *(temp_str + 1) <= '9') {
646 if (*(temp_str + 3) == 'd') {
648 ret_variable_int = 0;
652 "%dtype%d", check_type,
653 num_args + *(temp_str + 1) - 49);
654 bundle_get_str(b, buf_key, &ret_val);
656 ret_var_type = atoi(ret_val);
659 NOTIFICATION_VARIABLE_TYPE_COUNT) {
660 /* Get notification count */
661 notification_get_count(noti->type,
662 noti->caller_pkgname,
673 num_args + *(temp_str + 1) - 49);
674 bundle_get_str(b, buf_key, &ret_val);
676 ret_variable_int = atoi(ret_val);
681 sizeof(buf_str), "%d",
684 src_len = strlen(result_str);
685 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
687 strncat(result_str, buf_str, max_len);
690 } else if (*(temp_str + 3) == 's') {
695 check_type, num_args + *(temp_str + 1) - 49);
696 bundle_get_str(b, buf_key, &ret_val);
699 sizeof(buf_str), "%s",
702 src_len = strlen(result_str);
703 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
705 strncat(result_str, buf_str, max_len);
708 } else if (*(temp_str + 3) == 'f') {
713 check_type, num_args + *(temp_str + 1) - 49);
714 bundle_get_str(b, buf_key, &ret_val);
716 ret_variable_double = atof(ret_val);
721 ret_variable_double);
723 src_len = strlen(result_str);
724 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
726 strncat(result_str, buf_str, max_len);
735 /* Check last variable is count, LEFT pos */
736 if (num_args < noti->num_format_args) {
737 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
738 check_type, num_args);
739 bundle_get_str(b, buf_key, &ret_val);
741 ret_var_type = atoi(ret_val);
744 NOTIFICATION_VARIABLE_TYPE_COUNT) {
746 snprintf(buf_key, sizeof(buf_key),
747 "%dvalue%d", check_type,
749 bundle_get_str(b, buf_key, &ret_val);
751 ret_variable_int = atoi(ret_val);
753 if (ret_variable_int ==
754 NOTIFICATION_COUNT_POS_RIGHT) {
755 notification_get_count(noti->type,
756 noti->caller_pkgname,
761 sizeof(buf_str), " %d",
764 src_len = strlen(result_str);
765 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
767 strncat(result_str, buf_str, max_len);
775 switch (check_type) {
776 case NOTIFICATION_TEXT_TYPE_TITLE:
777 case NOTIFICATION_TEXT_TYPE_GROUP_TITLE:
778 if (noti->temp_title != NULL)
779 free(noti->temp_title);
781 noti->temp_title = strdup(result_str);
783 *text = noti->temp_title;
785 case NOTIFICATION_TEXT_TYPE_CONTENT:
786 case NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
787 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT:
788 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
789 if (noti->temp_content !=
791 free(noti->temp_content);
793 noti->temp_content = strdup(result_str);
795 *text = noti->temp_content;
807 return NOTIFICATION_ERROR_NONE;
810 EXPORT_API int notification_set_text_domain(notification_h noti,
814 if (noti == NULL || domain == NULL || dir == NULL)
815 return NOTIFICATION_ERROR_INVALID_PARAMETER;
820 noti->domain = strdup(domain);
825 noti->dir = strdup(dir);
827 return NOTIFICATION_ERROR_NONE;
830 EXPORT_API int notification_get_text_domain(notification_h noti,
835 return NOTIFICATION_ERROR_INVALID_PARAMETER;
837 if (domain != NULL && noti->domain != NULL)
838 *domain = noti->domain;
840 if (dir != NULL && noti->dir != NULL)
843 return NOTIFICATION_ERROR_NONE;
846 EXPORT_API int notification_set_time_to_text(notification_h noti, notification_text_type_e type,
849 int ret = NOTIFICATION_ERROR_NONE;
850 char buf[256] = { 0, };
851 char buf_tag[512] = { 0, };
854 return NOTIFICATION_ERROR_INVALID_PARAMETER;
857 return NOTIFICATION_ERROR_INVALID_PARAMETER;
859 if (type <= NOTIFICATION_TEXT_TYPE_NONE
860 || type >= NOTIFICATION_TEXT_TYPE_MAX)
861 return NOTIFICATION_ERROR_INVALID_PARAMETER;
864 snprintf(buf, sizeof(buf), "%lu", time);
865 ret = notification_noti_set_tag(TAG_TIME, buf, buf_tag, sizeof(buf_tag));
867 if (ret != NOTIFICATION_ERROR_NONE)
870 return notification_set_text(noti, type, buf_tag, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
873 EXPORT_API int notification_get_time_from_text(notification_h noti, notification_text_type_e type,
876 int ret = NOTIFICATION_ERROR_NONE;
877 char *ret_text = NULL;
881 return NOTIFICATION_ERROR_INVALID_PARAMETER;
884 return NOTIFICATION_ERROR_INVALID_PARAMETER;
886 if (type <= NOTIFICATION_TEXT_TYPE_NONE
887 || type >= NOTIFICATION_TEXT_TYPE_MAX)
888 return NOTIFICATION_ERROR_INVALID_PARAMETER;
890 ret = notification_get_text(noti, type, &ret_text);
892 if (ret != NOTIFICATION_ERROR_NONE || ret_text == NULL)
893 return NOTIFICATION_ERROR_INVALID_PARAMETER;
895 if (notification_noti_get_tag_type(ret_text) == TAG_TYPE_INVALID)
896 return NOTIFICATION_ERROR_INVALID_PARAMETER;
898 tag_value = notification_noti_strip_tag(ret_text);
899 if (tag_value == NULL)
900 return NOTIFICATION_ERROR_INVALID_PARAMETER;
902 *time = atol(tag_value);
905 return NOTIFICATION_ERROR_NONE;
908 EXPORT_API int notification_set_sound(notification_h noti,
909 notification_sound_type_e type,
913 return NOTIFICATION_ERROR_INVALID_PARAMETER;
915 if (type < NOTIFICATION_SOUND_TYPE_NONE
916 || type >= NOTIFICATION_SOUND_TYPE_MAX)
917 return NOTIFICATION_ERROR_INVALID_PARAMETER;
919 noti->sound_type = type;
921 /* Save sound path if user data type */
922 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA && path != NULL) {
923 if (noti->sound_path != NULL)
924 free(noti->sound_path);
926 noti->sound_path = strdup(path);
928 if (noti->sound_path != NULL) {
929 free(noti->sound_path);
930 noti->sound_path = NULL;
932 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA) {
933 noti->sound_type = NOTIFICATION_SOUND_TYPE_DEFAULT;
934 return NOTIFICATION_ERROR_INVALID_PARAMETER;
938 return NOTIFICATION_ERROR_NONE;
941 EXPORT_API int notification_get_sound(notification_h noti,
942 notification_sound_type_e *type,
945 if (noti == NULL || type == NULL)
946 return NOTIFICATION_ERROR_INVALID_PARAMETER;
948 *type = noti->sound_type;
950 /* Set sound path if user data type */
951 if (noti->sound_type == NOTIFICATION_SOUND_TYPE_USER_DATA
953 *path = noti->sound_path;
955 return NOTIFICATION_ERROR_NONE;
958 EXPORT_API int notification_set_vibration(notification_h noti,
959 notification_vibration_type_e type,
963 return NOTIFICATION_ERROR_INVALID_PARAMETER;
965 if (type < NOTIFICATION_VIBRATION_TYPE_NONE
966 || type >= NOTIFICATION_VIBRATION_TYPE_MAX)
967 return NOTIFICATION_ERROR_INVALID_PARAMETER;
969 noti->vibration_type = type;
971 /* Save sound path if user data type */
972 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA && path != NULL) {
973 if (noti->vibration_path != NULL)
974 free(noti->vibration_path);
976 noti->vibration_path = strdup(path);
978 if (noti->vibration_path != NULL) {
979 free(noti->vibration_path);
980 noti->vibration_path = NULL;
982 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA) {
983 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
984 return NOTIFICATION_ERROR_INVALID_PARAMETER;
988 return NOTIFICATION_ERROR_NONE;
992 EXPORT_API int notification_get_vibration(notification_h noti,
993 notification_vibration_type_e *type,
996 if (noti == NULL || type == NULL)
997 return NOTIFICATION_ERROR_INVALID_PARAMETER;
999 *type = noti->vibration_type;
1001 /* Set sound path if user data type */
1002 if (noti->vibration_type == NOTIFICATION_VIBRATION_TYPE_USER_DATA
1004 *path = noti->vibration_path;
1006 return NOTIFICATION_ERROR_NONE;
1009 EXPORT_API int notification_set_led(notification_h noti,
1010 notification_led_op_e operation,
1014 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1016 if (operation < NOTIFICATION_LED_OP_OFF
1017 || operation >= NOTIFICATION_LED_OP_MAX)
1018 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1020 noti->led_operation = operation;
1022 /* Save led argb if operation is turning on LED with custom color */
1023 if (operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR)
1024 noti->led_argb = led_argb;
1026 return NOTIFICATION_ERROR_NONE;
1029 EXPORT_API int notification_get_led(notification_h noti,
1030 notification_led_op_e *operation,
1033 if (noti == NULL || operation == NULL)
1034 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1036 *operation = noti->led_operation;
1038 /* Save led argb if operation is turning on LED with custom color */
1039 if (noti->led_operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR
1040 && led_argb != NULL)
1041 *led_argb = noti->led_argb;
1043 return NOTIFICATION_ERROR_NONE;
1046 EXPORT_API int notification_set_led_time_period(notification_h noti,
1047 int on_ms, int off_ms)
1049 if (noti == NULL || on_ms < 0 || off_ms < 0)
1050 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1052 noti->led_on_ms = on_ms;
1053 noti->led_off_ms = off_ms;
1055 return NOTIFICATION_ERROR_NONE;
1058 EXPORT_API int notification_get_led_time_period(notification_h noti,
1059 int *on_ms, int *off_ms)
1062 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1065 *(on_ms) = noti->led_on_ms;
1067 *(off_ms) = noti->led_off_ms;
1069 return NOTIFICATION_ERROR_NONE;
1072 EXPORT_API int notification_set_launch_option(notification_h noti,
1073 notification_launch_option_type type, void *option)
1075 int err = NOTIFICATION_ERROR_NONE;
1078 app_control_h app_control = option;
1080 if (noti == NULL || app_control == NULL || type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL) {
1081 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1085 if ((ret = app_control_export_as_bundle(app_control, &b)) != APP_CONTROL_ERROR_NONE) {
1086 NOTIFICATION_ERR("Failed to convert appcontrol to bundle:%d", ret);
1087 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1091 err = notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, b);
1100 EXPORT_API int notification_get_launch_option(notification_h noti,
1101 notification_launch_option_type type, void *option)
1105 app_control_h *app_control = (app_control_h *)option;
1106 app_control_h app_control_new = NULL;
1109 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1111 if (app_control == NULL)
1112 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1114 if (type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL)
1115 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1118 ret = notification_get_execute_option(noti,
1119 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
1122 if (ret == NOTIFICATION_ERROR_NONE && b != NULL) {
1123 ret = app_control_create(&app_control_new);
1124 if (ret == APP_CONTROL_ERROR_NONE && app_control_new != NULL) {
1125 ret = app_control_import_from_bundle(app_control_new, b);
1126 if (ret == APP_CONTROL_ERROR_NONE) {
1127 *app_control = app_control_new;
1129 app_control_destroy(app_control_new);
1130 NOTIFICATION_ERR("Failed to import app control from bundle:%d", ret);
1131 return NOTIFICATION_ERROR_IO_ERROR;
1134 NOTIFICATION_ERR("Failed to create app control:%d", ret);
1135 return NOTIFICATION_ERROR_IO_ERROR;
1138 NOTIFICATION_ERR("Failed to get execute option:%d", ret);
1142 return NOTIFICATION_ERROR_NONE;
1145 EXPORT_API int notification_set_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h event_handler)
1147 int err = NOTIFICATION_ERROR_NONE;
1148 bundle *app_control_bundle = NULL;
1151 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1152 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1156 if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
1157 || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
1158 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1159 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1163 if ((err = app_control_export_as_bundle(event_handler, &app_control_bundle)) != APP_CONTROL_ERROR_NONE) {
1164 NOTIFICATION_ERR("app_control_to_bundle failed [%d]", err);
1168 if (noti->b_event_handler[event_type] != NULL)
1169 bundle_free(noti->b_event_handler[event_type]);
1171 noti->b_event_handler[event_type] = app_control_bundle;
1177 EXPORT_API int notification_get_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h *event_handler)
1179 int err = NOTIFICATION_ERROR_NONE;
1181 app_control_h app_control_new = NULL;
1184 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1185 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1189 if (event_handler == NULL) {
1190 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1191 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1195 if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
1196 || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
1197 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1198 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1202 b = noti->b_event_handler[event_type];
1204 NOTIFICATION_DBG("No event handler\n");
1205 err = NOTIFICATION_ERROR_NOT_EXIST_ID;
1209 err = app_control_create(&app_control_new);
1210 if (err != APP_CONTROL_ERROR_NONE || app_control_new == NULL) {
1211 NOTIFICATION_ERR("app_control_create failed [%d]", err);
1212 err = NOTIFICATION_ERROR_IO_ERROR;
1216 err = app_control_import_from_bundle(app_control_new, b);
1217 if (err == APP_CONTROL_ERROR_NONE) {
1218 *event_handler = app_control_new;
1220 app_control_destroy(app_control_new);
1221 app_control_new = NULL;
1222 NOTIFICATION_ERR("Failed to import app control from bundle [%d]", err);
1223 err = NOTIFICATION_ERROR_IO_ERROR;
1229 *event_handler = app_control_new;
1238 EXPORT_API int notification_set_property(notification_h noti,
1242 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1244 noti->flags_for_property = flags;
1246 return NOTIFICATION_ERROR_NONE;
1249 EXPORT_API int notification_get_property(notification_h noti,
1252 if (noti == NULL || flags == NULL)
1253 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1255 *flags = noti->flags_for_property;
1257 return NOTIFICATION_ERROR_NONE;
1260 EXPORT_API int notification_set_display_applist(notification_h noti,
1264 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1266 if (applist == 0xffffffff) /* 0xffffffff means old NOTIFICATION_DISPLAY_APP_ALL */
1267 applist = NOTIFICATION_DISPLAY_APP_ALL;
1269 noti->display_applist = applist;
1271 return NOTIFICATION_ERROR_NONE;
1274 EXPORT_API int notification_get_display_applist(notification_h noti,
1277 if (noti == NULL || applist == NULL)
1278 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1280 *applist = noti->display_applist;
1282 return NOTIFICATION_ERROR_NONE;
1285 EXPORT_API int notification_set_size(notification_h noti,
1289 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1291 noti->progress_size = size;
1293 return NOTIFICATION_ERROR_NONE;
1296 EXPORT_API int notification_get_size(notification_h noti,
1299 if (noti == NULL || size == NULL)
1300 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1302 *size = noti->progress_size;
1304 return NOTIFICATION_ERROR_NONE;
1307 EXPORT_API int notification_set_progress(notification_h noti,
1311 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1313 noti->progress_percentage = percentage;
1315 return NOTIFICATION_ERROR_NONE;
1318 EXPORT_API int notification_get_progress(notification_h noti,
1321 if (noti == NULL || percentage == NULL)
1322 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1324 *percentage = noti->progress_percentage;
1326 return NOTIFICATION_ERROR_NONE;
1329 EXPORT_API int notification_get_pkgname(notification_h noti,
1332 if (noti == NULL || pkgname == NULL)
1333 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1335 if (noti->caller_pkgname)
1336 *pkgname = noti->caller_pkgname;
1340 return NOTIFICATION_ERROR_NONE;
1343 EXPORT_API int notification_set_layout(notification_h noti,
1344 notification_ly_type_e layout)
1346 if (noti == NULL || (layout < NOTIFICATION_LY_NONE || layout >= NOTIFICATION_LY_MAX))
1347 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1349 noti->layout = layout;
1351 return NOTIFICATION_ERROR_NONE;
1354 EXPORT_API int notification_get_layout(notification_h noti,
1355 notification_ly_type_e *layout)
1357 if (noti == NULL || layout == NULL)
1358 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1360 *layout = noti->layout;
1362 return NOTIFICATION_ERROR_NONE;
1367 EXPORT_API int notification_get_type(notification_h noti,
1368 notification_type_e *type)
1370 if (noti == NULL || type == NULL)
1371 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1375 return NOTIFICATION_ERROR_NONE;
1378 EXPORT_API int notification_post(notification_h noti)
1380 return notification_post_for_uid(noti, getuid());
1383 EXPORT_API int notification_update(notification_h noti)
1385 return notification_update_for_uid(noti, getuid());
1388 EXPORT_API int notification_delete_all(notification_type_e type)
1390 return notification_delete_all_for_uid(type, getuid());
1393 EXPORT_API int notification_delete(notification_h noti)
1395 return notification_delete_for_uid(noti, getuid());
1398 static notification_h _notification_create(notification_type_e type)
1400 notification_h noti = NULL;
1401 package_info_h package_info = NULL;
1402 char *app_id = NULL;
1403 char *domain_name = NULL;
1404 char *app_root_path = NULL;
1405 char locale_directory[PATH_MAX] = { 0, }; /* PATH_MAX 4096 */
1406 int err_app_manager = APP_MANAGER_ERROR_NONE;
1408 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1409 NOTIFICATION_ERR("INVALID TYPE : %d", type);
1410 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
1414 noti = (notification_h) calloc(1, sizeof(struct _notification));
1416 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
1417 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
1423 if (type == NOTIFICATION_TYPE_NOTI)
1424 noti->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
1425 else if (type == NOTIFICATION_TYPE_ONGOING)
1426 noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
1428 noti->group_id = NOTIFICATION_GROUP_ID_NONE;
1429 noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
1430 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
1431 noti->led_operation = NOTIFICATION_LED_OP_OFF;
1432 noti->display_applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_INDICATOR;
1433 noti->auto_remove = true;
1434 noti->ongoing_flag = false;
1436 if (getuid() >= REGULAR_UID_MIN) {
1437 noti->caller_pkgname = notification_get_pkgname_by_pid();
1439 err_app_manager = app_manager_get_app_id(getpid(), &app_id);
1440 if (err_app_manager != APP_MANAGER_ERROR_NONE || app_id == NULL) {
1441 NOTIFICATION_WARN("app_manager_get_app_id failed err[%d] app_id[%p]",
1442 err_app_manager, app_id);
1446 /* app name is used as domain name */
1447 /* domain_name is allocated by app_get_package_app_name */
1448 err_app_manager = app_get_package_app_name(app_id, &domain_name);
1450 if (err_app_manager != APP_ERROR_NONE || domain_name == NULL) {
1451 NOTIFICATION_WARN("app_get_package_app_name failed err[%d] domain_name[%p]",
1452 err_app_manager, domain_name);
1457 err_app_manager = package_info_create(noti->caller_pkgname, &package_info);
1459 if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || package_info == NULL) {
1460 NOTIFICATION_WARN("package_info_create failed err[%d] package_info[%p] caller_pkgname[%s]",
1461 err_app_manager, package_info, noti->caller_pkgname);
1465 err_app_manager = package_info_get_root_path(package_info, &app_root_path);
1467 if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || app_root_path == NULL) {
1468 NOTIFICATION_WARN("package_info_get_root_path failed err[%d] app_root_path[%p]",
1469 err_app_manager, app_root_path);
1473 snprintf(locale_directory, PATH_MAX, "%s/res/locale", app_root_path);
1475 noti->domain = strdup(domain_name);
1476 noti->dir = strdup(locale_directory);
1487 free(app_root_path);
1490 package_info_destroy(package_info);
1494 * Other fields are already initialized with ZERO.
1496 set_last_result(NOTIFICATION_ERROR_NONE);
1500 EXPORT_API notification_h notification_create(notification_type_e type)
1502 return _notification_create(type);
1505 EXPORT_API notification_h notification_load_by_tag(const char *tag)
1507 return notification_load_by_tag_for_uid(tag, getuid());
1510 EXPORT_API int notification_clone(notification_h noti, notification_h *clone)
1513 notification_h new_noti = NULL;
1515 if (noti == NULL || clone == NULL) {
1516 NOTIFICATION_ERR("INVALID PARAMETER.");
1517 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1520 new_noti = (notification_h) calloc(1, sizeof(struct _notification));
1521 if (new_noti == NULL) {
1522 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
1523 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
1526 new_noti->type = noti->type;
1527 new_noti->layout = noti->layout;
1529 new_noti->group_id = noti->group_id;
1530 new_noti->internal_group_id = noti->internal_group_id;
1531 new_noti->priv_id = noti->priv_id;
1533 if (noti->caller_pkgname != NULL)
1534 new_noti->caller_pkgname = strdup(noti->caller_pkgname);
1536 new_noti->caller_pkgname = notification_get_pkgname_by_pid();
1538 if (noti->launch_pkgname != NULL)
1539 new_noti->launch_pkgname = strdup(noti->launch_pkgname);
1541 new_noti->launch_pkgname = NULL;
1543 if (noti->args != NULL)
1544 new_noti->args = bundle_dup(noti->args);
1546 new_noti->args = NULL;
1548 if (noti->group_args != NULL)
1549 new_noti->group_args = bundle_dup(noti->group_args);
1551 new_noti->group_args = NULL;
1553 if (noti->b_execute_option != NULL)
1554 new_noti->b_execute_option = bundle_dup(noti->b_execute_option);
1556 new_noti->b_execute_option = NULL;
1558 if (noti->b_service_responding != NULL)
1559 new_noti->b_service_responding = bundle_dup(noti->b_service_responding);
1561 new_noti->b_service_responding = NULL;
1563 if (noti->b_service_single_launch != NULL)
1564 new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch);
1566 new_noti->b_service_single_launch = NULL;
1568 if (noti->b_service_multi_launch != NULL)
1569 new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch);
1571 new_noti->b_service_multi_launch = NULL;
1573 for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
1574 if (noti->b_event_handler[i] != NULL)
1575 new_noti->b_event_handler[i] = bundle_dup(noti->b_event_handler[i]);
1577 new_noti->b_event_handler[i] = NULL;
1580 new_noti->sound_type = noti->sound_type;
1581 if (noti->sound_path != NULL)
1582 new_noti->sound_path = strdup(noti->sound_path);
1584 new_noti->sound_path = NULL;
1586 new_noti->vibration_type = noti->vibration_type;
1587 if (noti->vibration_path != NULL)
1588 new_noti->vibration_path = strdup(noti->vibration_path);
1590 new_noti->vibration_path = NULL;
1592 new_noti->led_operation = noti->led_operation;
1593 new_noti->led_argb = noti->led_argb;
1594 new_noti->led_on_ms = noti->led_on_ms;
1595 new_noti->led_off_ms = noti->led_off_ms;
1597 if (noti->domain != NULL)
1598 new_noti->domain = strdup(noti->domain);
1600 new_noti->domain = NULL;
1602 if (noti->dir != NULL)
1603 new_noti->dir = strdup(noti->dir);
1605 new_noti->dir = NULL;
1607 if (noti->b_text != NULL)
1608 new_noti->b_text = bundle_dup(noti->b_text);
1610 new_noti->b_text = NULL;
1612 if (noti->b_key != NULL)
1613 new_noti->b_key = bundle_dup(noti->b_key);
1615 new_noti->b_key = NULL;
1617 if (noti->tag != NULL)
1618 new_noti->tag = strdup(noti->tag);
1620 new_noti->tag = NULL;
1622 if (noti->b_format_args != NULL)
1623 new_noti->b_format_args = bundle_dup(noti->b_format_args);
1625 new_noti->b_format_args = NULL;
1627 new_noti->num_format_args = noti->num_format_args;
1629 if (noti->b_image_path != NULL)
1630 new_noti->b_image_path = bundle_dup(noti->b_image_path);
1632 new_noti->b_image_path = NULL;
1634 new_noti->time = noti->time;
1635 new_noti->insert_time = noti->insert_time;
1637 new_noti->flags_for_property = noti->flags_for_property;
1638 new_noti->display_applist = noti->display_applist;
1640 new_noti->progress_size = noti->progress_size;
1641 new_noti->progress_percentage = noti->progress_percentage;
1643 new_noti->ongoing_flag = noti->ongoing_flag;
1644 new_noti->auto_remove = noti->auto_remove;
1645 new_noti->uid = noti->uid;
1647 new_noti->app_icon_path = NULL;
1648 new_noti->app_name = NULL;
1649 new_noti->temp_title = NULL;
1650 new_noti->temp_content = NULL;
1654 return NOTIFICATION_ERROR_NONE;
1658 EXPORT_API int notification_free(notification_h noti)
1662 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1664 if (noti->caller_pkgname)
1665 free(noti->caller_pkgname);
1667 if (noti->launch_pkgname)
1668 free(noti->launch_pkgname);
1671 bundle_free(noti->args);
1673 if (noti->group_args)
1674 bundle_free(noti->group_args);
1676 if (noti->b_execute_option)
1677 bundle_free(noti->b_execute_option);
1679 if (noti->b_service_responding)
1680 bundle_free(noti->b_service_responding);
1682 if (noti->b_service_single_launch)
1683 bundle_free(noti->b_service_single_launch);
1685 if (noti->b_service_multi_launch)
1686 bundle_free(noti->b_service_multi_launch);
1688 for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
1689 if (noti->b_event_handler[i] != NULL)
1690 bundle_free(noti->b_event_handler[i]);
1693 if (noti->sound_path)
1694 free(noti->sound_path);
1696 if (noti->vibration_path)
1697 free(noti->vibration_path);
1706 bundle_free(noti->b_text);
1709 bundle_free(noti->b_key);
1711 if (noti->b_format_args)
1712 bundle_free(noti->b_format_args);
1714 if (noti->b_image_path)
1715 bundle_free(noti->b_image_path);
1717 if (noti->app_icon_path)
1718 free(noti->app_icon_path);
1721 free(noti->app_name);
1723 if (noti->temp_title)
1724 free(noti->temp_title);
1726 if (noti->temp_content)
1727 free(noti->temp_content);
1734 return NOTIFICATION_ERROR_NONE;
1737 EXPORT_API int notification_set_tag(notification_h noti, const char *tag)
1740 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1743 if (noti->tag != NULL)
1746 noti->tag = strdup(tag);
1749 return NOTIFICATION_ERROR_NONE;
1753 EXPORT_API int notification_get_tag(notification_h noti, const char **tag)
1756 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1759 return NOTIFICATION_ERROR_NONE;
1762 /* LCOV_EXCL_START */
1763 void notification_call_posted_toast_cb(const char *message)
1765 if (posted_toast_message_cb != NULL)
1766 posted_toast_message_cb((void *)message);
1768 /* LCOV_EXCL_STOP */
1770 EXPORT_API int notification_set_ongoing_flag(notification_h noti, bool ongoing_flag)
1773 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1775 noti->ongoing_flag = ongoing_flag;
1777 return NOTIFICATION_ERROR_NONE;
1780 EXPORT_API int notification_get_ongoing_flag(notification_h noti, bool *ongoing_flag)
1782 if (noti == NULL || ongoing_flag == NULL)
1783 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1785 *ongoing_flag = noti->ongoing_flag;
1787 return NOTIFICATION_ERROR_NONE;
1791 EXPORT_API int notification_add_button(notification_h noti, notification_button_index_e button_index)
1793 if (noti == NULL || button_index < NOTIFICATION_BUTTON_1 || button_index > NOTIFICATION_BUTTON_6)
1794 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1796 return NOTIFICATION_ERROR_NONE;
1799 EXPORT_API int notification_remove_button(notification_h noti, notification_button_index_e button_index)
1801 if (noti == NULL || button_index < NOTIFICATION_BUTTON_1 || button_index > NOTIFICATION_BUTTON_6)
1802 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1804 if (noti->b_event_handler[button_index - 1]) {
1805 bundle_free(noti->b_event_handler[button_index - 1]);
1806 noti->b_event_handler[button_index - 1] = NULL;
1809 return NOTIFICATION_ERROR_NONE;
1812 EXPORT_API int notification_set_auto_remove(notification_h noti, bool auto_remove)
1815 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1817 noti->auto_remove = auto_remove;
1819 return NOTIFICATION_ERROR_NONE;
1822 EXPORT_API int notification_get_auto_remove(notification_h noti, bool *auto_remove)
1824 if (noti == NULL || auto_remove == NULL)
1825 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1827 *auto_remove = noti->auto_remove;
1829 return NOTIFICATION_ERROR_NONE;