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 /* Check noti and image_path are valid data */
104 if (noti == NULL || image_path == NULL)
105 return NOTIFICATION_ERROR_INVALID_PARAMETER;
107 /* Check image type is valid type */
108 if (type <= NOTIFICATION_IMAGE_TYPE_NONE
109 || type >= NOTIFICATION_IMAGE_TYPE_MAX)
110 return NOTIFICATION_ERROR_INVALID_PARAMETER;
112 /* Check image path bundle is exist */
113 if (noti->b_image_path) {
114 /* If image path bundle is exist, store local bundle value */
115 b = noti->b_image_path;
117 /* Set image type to key as char string type */
118 snprintf(buf_key, sizeof(buf_key), "%d", type);
120 /* Get value using key */
121 bundle_get_str(b, buf_key, &ret_val);
123 /* If key is exist, remove this value to store new image path */
124 bundle_del(b, buf_key);
126 /* Add new image path with type key */
127 bundle_add_str(b, buf_key, image_path);
129 /* If image path bundle is not exist, create new one */
132 /* Set image type to key as char string type */
133 snprintf(buf_key, sizeof(buf_key), "%d", type);
135 /* Add new image path with type key */
136 bundle_add_str(b, buf_key, image_path);
138 /* Save to image path bundle */
139 noti->b_image_path = b;
142 return NOTIFICATION_ERROR_NONE;
145 EXPORT_API int notification_get_image(notification_h noti,
146 notification_image_type_e type,
150 char buf_key[32] = { 0, };
151 char *ret_val = NULL;
153 /* Check noti and image_path is valid data */
154 if (noti == NULL || image_path == NULL)
155 return NOTIFICATION_ERROR_INVALID_PARAMETER;
157 /* Check image type is valid data */
158 if (type <= NOTIFICATION_IMAGE_TYPE_NONE
159 || type >= NOTIFICATION_IMAGE_TYPE_MAX)
160 return NOTIFICATION_ERROR_INVALID_PARAMETER;
162 /* Check image path bundle exist */
163 if (noti->b_image_path) {
164 /* If image path bundle exist, store local bundle data */
165 b = noti->b_image_path;
167 /* Set image type to key as char string type */
168 snprintf(buf_key, sizeof(buf_key), "%d", type);
170 /* Get value of key */
171 bundle_get_str(b, buf_key, &ret_val);
173 *image_path = ret_val;
175 /* If image path bundle does not exist, image path is NULL */
179 /* If image path is NULL and type is ICON, icon path set from AIL */
180 /* order : user icon -> launch_pkgname icon -> caller_pkgname icon -> service app icon */
181 if (*image_path == NULL && type == NOTIFICATION_IMAGE_TYPE_ICON) {
182 /* Check App icon path is already set */
183 if (noti->app_icon_path != NULL)
184 /* image path will be app icon path */
185 *image_path = noti->app_icon_path;
190 return NOTIFICATION_ERROR_NONE;
193 EXPORT_API int notification_set_time(notification_h noti, time_t input_time)
195 /* Check noti is valid data */
197 return NOTIFICATION_ERROR_INVALID_PARAMETER;
200 /* If input time is 0, set current time */
201 noti->time = time(NULL);
203 /* save input time */
204 noti->time = input_time;
206 return NOTIFICATION_ERROR_NONE;
209 EXPORT_API int notification_get_time(notification_h noti, time_t *ret_time)
211 /* Check noti and time is valid data */
212 if (noti == NULL || ret_time == NULL)
213 return NOTIFICATION_ERROR_INVALID_PARAMETER;
215 /* Set time infomation */
216 *ret_time = noti->time;
218 return NOTIFICATION_ERROR_NONE;
221 EXPORT_API int notification_get_insert_time(notification_h noti,
224 /* Check noti and ret_time is valid data */
225 if (noti == NULL || ret_time == NULL)
226 return NOTIFICATION_ERROR_INVALID_PARAMETER;
228 /* Set insert time information */
229 *ret_time = noti->insert_time;
231 return NOTIFICATION_ERROR_NONE;
234 EXPORT_API int notification_set_text(notification_h noti,
235 notification_text_type_e type, const char *text,
236 const char *key, int args_type, ...)
239 char buf_key[32] = { 0, };
240 char buf_val[1024] = { 0, };
241 char *ret_val = NULL;
243 notification_variable_type_e var_type;
245 int noti_err = NOTIFICATION_ERROR_NONE;
246 int var_value_int = 0;
247 double var_value_double = 0.0;
248 char *var_value_string = NULL;
249 notification_count_pos_type_e var_value_count =
250 NOTIFICATION_COUNT_POS_NONE;
252 /* Check noti is valid data */
254 return NOTIFICATION_ERROR_INVALID_PARAMETER;
256 /* Check text type is valid type */
257 if (type <= NOTIFICATION_TEXT_TYPE_NONE
258 || type >= NOTIFICATION_TEXT_TYPE_MAX)
259 return NOTIFICATION_ERROR_INVALID_PARAMETER;
261 /* Check text bundle exist */
263 if (noti->b_text != NULL) {
264 /* If text bundle exist, store local bundle data */
267 /* Make type to key as char string */
268 snprintf(buf_key, sizeof(buf_key), "%d", type);
270 /* Get value using type key */
271 bundle_get_str(b, buf_key, &ret_val);
274 /* If value exist, remove this to add new value */
275 bundle_del(b, buf_key);
277 snprintf(buf_val, sizeof(buf_val), "%s", text);
279 /* Add new text value */
280 bundle_add_str(b, buf_key, buf_val);
282 /* If text bundle does not exist, create new one */
285 /* Make type to key as char string */
286 snprintf(buf_key, sizeof(buf_key), "%d", type);
288 snprintf(buf_val, sizeof(buf_val), "%s", text);
290 /* Add new text value */
291 bundle_add_str(b, buf_key, buf_val);
293 /* Save text bundle */
297 /* Reset if text is NULL */
298 if (noti->b_text != NULL) {
299 /* If text bundle exist, store local bundle data */
302 /* Make type to key as char string */
303 snprintf(buf_key, sizeof(buf_key), "%d", type);
305 /* Get value using type key */
306 bundle_get_str(b, buf_key, &ret_val);
308 /* If value exist, remove this */
309 bundle_del(b, buf_key);
313 /* Save key if key is valid data */
315 /* Check key bundle exist */
316 if (noti->b_key != NULL) {
317 /* If key bundle exist, store local bundle data */
320 /* Make type to key as char string */
321 snprintf(buf_key, sizeof(buf_key), "%d", type);
323 /* Get value using type key */
324 bundle_get_str(b, buf_key, &ret_val);
326 /* If value exist, remove this to add new value */
327 bundle_del(b, buf_key);
329 snprintf(buf_val, sizeof(buf_val), "%s", key);
331 /* Add new key value */
332 bundle_add_str(b, buf_key, buf_val);
334 /* If key bundle does not exist, create new one */
337 /* Make type to key as char string */
338 snprintf(buf_key, sizeof(buf_key), "%d", type);
340 snprintf(buf_val, sizeof(buf_val), "%s", key);
342 /* Add new key value */
343 bundle_add_str(b, buf_key, buf_val);
345 /* Save key bundle */
349 /* Reset if key is NULL */
350 if (noti->b_key != NULL) {
351 /* If key bundle exist, store local bundle data */
354 /* Make type to key as char string */
355 snprintf(buf_key, sizeof(buf_key), "%d", type);
357 /* Get value using type key */
358 bundle_get_str(b, buf_key, &ret_val);
360 /* If value exist, remove this */
361 bundle_del(b, buf_key);
365 if (noti->b_format_args != NULL)
366 b = noti->b_format_args;
370 va_start(var_args, args_type);
372 var_type = args_type;
375 while (var_type != NOTIFICATION_VARIABLE_TYPE_NONE) {
377 snprintf(buf_key, sizeof(buf_key), "%dtype%d", type, num_args);
378 snprintf(buf_val, sizeof(buf_val), "%d", var_type);
380 bundle_get_str(b, buf_key, &ret_val);
382 bundle_del(b, buf_key);
384 bundle_add_str(b, buf_key, buf_val);
387 case NOTIFICATION_VARIABLE_TYPE_INT:
388 var_value_int = va_arg(var_args, int);
391 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
393 snprintf(buf_val, sizeof(buf_val), "%d", var_value_int);
395 bundle_get_str(b, buf_key, &ret_val);
397 bundle_del(b, buf_key);
399 bundle_add_str(b, buf_key, buf_val);
402 case NOTIFICATION_VARIABLE_TYPE_DOUBLE:
403 var_value_double = va_arg(var_args, double);
406 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
408 snprintf(buf_val, sizeof(buf_val), "%.2f",
411 bundle_get_str(b, buf_key, &ret_val);
413 bundle_del(b, buf_key);
415 bundle_add_str(b, buf_key, buf_val);
418 case NOTIFICATION_VARIABLE_TYPE_STRING:
419 var_value_string = va_arg(var_args, char *);
422 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
424 snprintf(buf_val, sizeof(buf_val), "%s",
427 bundle_get_str(b, buf_key, &ret_val);
429 bundle_del(b, buf_key);
431 bundle_add_str(b, buf_key, buf_val);
434 case NOTIFICATION_VARIABLE_TYPE_COUNT:
436 va_arg(var_args, notification_count_pos_type_e);
439 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
441 snprintf(buf_val, sizeof(buf_val), "%d",
444 bundle_get_str(b, buf_key, &ret_val);
446 bundle_del(b, buf_key);
448 bundle_add_str(b, buf_key, buf_val);
452 NOTIFICATION_ERR("Error. invalid variable type. : %d",
454 noti_err = NOTIFICATION_ERROR_INVALID_PARAMETER;
459 var_type = va_arg(var_args, notification_variable_type_e);
463 if (noti_err == NOTIFICATION_ERROR_NONE)
464 noti->num_format_args = num_args;
466 noti->num_format_args = 0;
468 snprintf(buf_key, sizeof(buf_key), "num%d", type);
469 snprintf(buf_val, sizeof(buf_val), "%d", noti->num_format_args);
471 bundle_get_str(b, buf_key, &ret_val);
473 bundle_del(b, buf_key);
475 bundle_add_str(b, buf_key, buf_val);
477 noti->b_format_args = b;
482 EXPORT_API int notification_get_text(notification_h noti,
483 notification_text_type_e type,
487 char buf_key[32] = { 0, };
488 char *ret_val = NULL;
489 char *get_str = NULL;
490 notification_text_type_e check_type = NOTIFICATION_TEXT_TYPE_NONE;
491 /* int display_option_flag = 0; */
493 char *temp_str = NULL;
494 char *translated_str = NULL;
495 char result_str[NOTI_TEXT_RESULT_LEN] = { 0, };
496 char buf_str[1024] = { 0, };
498 notification_variable_type_e ret_var_type = 0;
499 int ret_variable_int = 0;
500 double ret_variable_double = 0.0;
504 /* Check noti is valid data */
505 if (noti == NULL || text == NULL)
506 return NOTIFICATION_ERROR_INVALID_PARAMETER;
508 /* Check text type is valid type */
509 if (type <= NOTIFICATION_TEXT_TYPE_NONE
510 || type >= NOTIFICATION_TEXT_TYPE_MAX)
511 return NOTIFICATION_ERROR_INVALID_PARAMETER;
515 if (noti->b_key != NULL) {
518 /* Get text domain and dir */
519 /* _notification_get_text_domain(noti); */
521 snprintf(buf_key, sizeof(buf_key), "%d", type);
523 bundle_get_str(b, buf_key, &ret_val);
524 if (ret_val != NULL && noti->domain != NULL
525 && noti->dir != NULL) {
526 /* Get application string */
527 bindtextdomain(noti->domain, noti->dir);
529 get_str = dgettext(noti->domain, ret_val);
530 } else if (ret_val != NULL) {
531 /* Get system string */
532 get_str = dgettext("sys_string", ret_val);
538 if (get_str == NULL && noti->b_text != NULL) {
541 snprintf(buf_key, sizeof(buf_key), "%d", type);
543 bundle_get_str(b, buf_key, &get_str);
548 if (get_str != NULL) {
549 /* Get number format args */
550 b = noti->b_format_args;
551 noti->num_format_args = 0;
554 snprintf(buf_key, sizeof(buf_key), "num%d", check_type);
555 bundle_get_str(b, buf_key, &ret_val);
557 noti->num_format_args = atoi(ret_val);
560 if (noti->num_format_args == 0) {
561 *text = (char *)get_str;
563 /* Check first variable is count, LEFT pos */
564 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
565 check_type, num_args);
566 bundle_get_str(b, buf_key, &ret_val);
568 ret_var_type = atoi(ret_val);
570 if (ret_var_type == NOTIFICATION_VARIABLE_TYPE_COUNT) {
572 snprintf(buf_key, sizeof(buf_key), "%dvalue%d",
573 check_type, num_args);
574 bundle_get_str(b, buf_key, &ret_val);
576 ret_variable_int = atoi(ret_val);
578 if (ret_variable_int ==
579 NOTIFICATION_COUNT_POS_LEFT) {
580 notification_get_count(noti->type,
581 noti->caller_pkgname,
585 snprintf(buf_str, sizeof(buf_str),
586 "%d ", ret_variable_int);
588 src_len = strlen(result_str);
589 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
591 strncat(result_str, buf_str,
597 /* Check variable IN pos */
598 for (temp_str = (char *)get_str; *temp_str != '\0';
600 if (*temp_str != '%') {
601 strncat(result_str, temp_str, 1);
603 if (*(temp_str + 1) == '%') {
604 strncat(result_str, temp_str,
606 } else if (*(temp_str + 1) == 'd') {
608 ret_variable_int = 0;
612 "%dtype%d", check_type,
614 bundle_get_str(b, buf_key, &ret_val);
616 ret_var_type = atoi(ret_val);
619 NOTIFICATION_VARIABLE_TYPE_COUNT) {
620 /* Get notification count */
621 notification_get_count(noti->type,
622 noti->caller_pkgname,
633 bundle_get_str(b, buf_key, &ret_val);
635 ret_variable_int = atoi(ret_val);
639 sizeof(buf_str), "%d",
642 src_len = strlen(result_str);
643 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
645 strncat(result_str, buf_str,
651 } else if (*(temp_str + 1) == 's') {
656 check_type, num_args);
657 bundle_get_str(b, buf_key, &ret_val);
659 if (ret_val != NULL && noti->domain != NULL && noti->dir != NULL) {
660 /* Get application string */
661 bindtextdomain(noti->domain, noti->dir);
662 translated_str = dgettext(noti->domain, ret_val);
663 NOTIFICATION_INFO("translated_str[%s]", translated_str);
664 } else if (ret_val != NULL) {
665 /* Get system string */
666 translated_str = dgettext("sys_string", ret_val);
667 NOTIFICATION_INFO("translated_str[%s]", translated_str);
669 translated_str = NULL;
672 if (translated_str != NULL) {
673 strncpy(buf_str, translated_str, sizeof(buf_str) - 1);
674 src_len = strlen(result_str);
675 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
676 strncat(result_str, buf_str, max_len);
680 } else if (*(temp_str + 1) == 'f') {
685 check_type, num_args);
686 bundle_get_str(b, buf_key, &ret_val);
688 ret_variable_double = atof(ret_val);
693 ret_variable_double);
695 src_len = strlen(result_str);
696 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
697 strncat(result_str, buf_str, max_len);
701 } else if (*(temp_str + 1) >= '1' && *(temp_str + 1) <= '9') {
702 if (*(temp_str + 3) == 'd') {
704 ret_variable_int = 0;
708 "%dtype%d", check_type,
709 num_args + *(temp_str + 1) - 49);
710 bundle_get_str(b, buf_key, &ret_val);
712 ret_var_type = atoi(ret_val);
715 NOTIFICATION_VARIABLE_TYPE_COUNT) {
716 /* Get notification count */
717 notification_get_count(noti->type,
718 noti->caller_pkgname,
729 num_args + *(temp_str + 1) - 49);
730 bundle_get_str(b, buf_key, &ret_val);
732 ret_variable_int = atoi(ret_val);
737 sizeof(buf_str), "%d",
740 src_len = strlen(result_str);
741 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
743 strncat(result_str, buf_str, max_len);
746 } else if (*(temp_str + 3) == 's') {
751 check_type, num_args + *(temp_str + 1) - 49);
752 bundle_get_str(b, buf_key, &ret_val);
755 sizeof(buf_str), "%s",
758 src_len = strlen(result_str);
759 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
761 strncat(result_str, buf_str, max_len);
764 } else if (*(temp_str + 3) == 'f') {
769 check_type, num_args + *(temp_str + 1) - 49);
770 bundle_get_str(b, buf_key, &ret_val);
772 ret_variable_double = atof(ret_val);
777 ret_variable_double);
779 src_len = strlen(result_str);
780 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
782 strncat(result_str, buf_str, max_len);
791 /* Check last variable is count, LEFT pos */
792 if (num_args < noti->num_format_args) {
793 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
794 check_type, num_args);
795 bundle_get_str(b, buf_key, &ret_val);
797 ret_var_type = atoi(ret_val);
800 NOTIFICATION_VARIABLE_TYPE_COUNT) {
802 snprintf(buf_key, sizeof(buf_key),
803 "%dvalue%d", check_type,
805 bundle_get_str(b, buf_key, &ret_val);
807 ret_variable_int = atoi(ret_val);
809 if (ret_variable_int ==
810 NOTIFICATION_COUNT_POS_RIGHT) {
811 notification_get_count(noti->type,
812 noti->caller_pkgname,
817 sizeof(buf_str), " %d",
820 src_len = strlen(result_str);
821 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
823 strncat(result_str, buf_str, max_len);
831 switch (check_type) {
832 case NOTIFICATION_TEXT_TYPE_TITLE:
833 case NOTIFICATION_TEXT_TYPE_GROUP_TITLE:
834 if (noti->temp_title != NULL)
835 free(noti->temp_title);
837 noti->temp_title = strdup(result_str);
839 *text = noti->temp_title;
841 case NOTIFICATION_TEXT_TYPE_CONTENT:
842 case NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
843 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT:
844 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
845 if (noti->temp_content !=
847 free(noti->temp_content);
849 noti->temp_content = strdup(result_str);
851 *text = noti->temp_content;
863 return NOTIFICATION_ERROR_NONE;
866 EXPORT_API int notification_set_text_domain(notification_h noti,
870 /* check noti and domain is valid data */
871 if (noti == NULL || domain == NULL || dir == NULL)
872 return NOTIFICATION_ERROR_INVALID_PARAMETER;
876 /* Remove previous domain */
880 noti->domain = strdup(domain);
882 /* Check locale dir */
884 /* Remove previous locale dir */
887 /* Copy locale dir */
888 noti->dir = strdup(dir);
890 return NOTIFICATION_ERROR_NONE;
893 EXPORT_API int notification_get_text_domain(notification_h noti,
897 /* Check noti is valid data */
899 return NOTIFICATION_ERROR_INVALID_PARAMETER;
902 if (domain != NULL && noti->domain != NULL)
903 *domain = noti->domain;
906 if (dir != NULL && noti->dir != NULL)
909 return NOTIFICATION_ERROR_NONE;
912 EXPORT_API int notification_set_time_to_text(notification_h noti, notification_text_type_e type,
915 int ret = NOTIFICATION_ERROR_NONE;
916 char buf[256] = { 0, };
917 char buf_tag[512] = { 0, };
920 return NOTIFICATION_ERROR_INVALID_PARAMETER;
923 return NOTIFICATION_ERROR_INVALID_PARAMETER;
925 if (type <= NOTIFICATION_TEXT_TYPE_NONE
926 || type >= NOTIFICATION_TEXT_TYPE_MAX)
927 return NOTIFICATION_ERROR_INVALID_PARAMETER;
930 snprintf(buf, sizeof(buf), "%lu", time);
931 ret = notification_noti_set_tag(TAG_TIME, buf, buf_tag, sizeof(buf_tag));
933 if (ret != NOTIFICATION_ERROR_NONE)
936 return notification_set_text(noti, type, buf_tag, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
939 EXPORT_API int notification_get_time_from_text(notification_h noti, notification_text_type_e type,
942 int ret = NOTIFICATION_ERROR_NONE;
943 char *ret_text = NULL;
947 return NOTIFICATION_ERROR_INVALID_PARAMETER;
950 return NOTIFICATION_ERROR_INVALID_PARAMETER;
952 if (type <= NOTIFICATION_TEXT_TYPE_NONE
953 || type >= NOTIFICATION_TEXT_TYPE_MAX)
954 return NOTIFICATION_ERROR_INVALID_PARAMETER;
956 ret = notification_get_text(noti, type, &ret_text);
958 if (ret != NOTIFICATION_ERROR_NONE || ret_text == NULL)
959 return NOTIFICATION_ERROR_INVALID_PARAMETER;
961 if (notification_noti_get_tag_type(ret_text) == TAG_TYPE_INVALID)
962 return NOTIFICATION_ERROR_INVALID_PARAMETER;
964 tag_value = notification_noti_strip_tag(ret_text);
965 if (tag_value == NULL)
966 return NOTIFICATION_ERROR_INVALID_PARAMETER;
968 *time = atol(tag_value);
971 return NOTIFICATION_ERROR_NONE;
974 EXPORT_API int notification_set_sound(notification_h noti,
975 notification_sound_type_e type,
978 /* Check noti is valid data */
980 return NOTIFICATION_ERROR_INVALID_PARAMETER;
983 /* Check type is valid */
984 if (type < NOTIFICATION_SOUND_TYPE_NONE
985 || type >= NOTIFICATION_SOUND_TYPE_MAX)
986 return NOTIFICATION_ERROR_INVALID_PARAMETER;
988 /* Save sound type */
989 noti->sound_type = type;
991 /* Save sound path if user data type */
992 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA && path != NULL) {
993 if (noti->sound_path != NULL)
994 free(noti->sound_path);
996 noti->sound_path = strdup(path);
998 if (noti->sound_path != NULL) {
999 free(noti->sound_path);
1000 noti->sound_path = NULL;
1002 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA) {
1003 noti->sound_type = NOTIFICATION_SOUND_TYPE_DEFAULT;
1004 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1008 return NOTIFICATION_ERROR_NONE;
1011 EXPORT_API int notification_get_sound(notification_h noti,
1012 notification_sound_type_e *type,
1015 /* check noti and type is valid data */
1016 if (noti == NULL || type == NULL)
1017 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1019 /* Set sound type */
1020 *type = noti->sound_type;
1022 /* Set sound path if user data type */
1023 if (noti->sound_type == NOTIFICATION_SOUND_TYPE_USER_DATA
1025 *path = noti->sound_path;
1027 return NOTIFICATION_ERROR_NONE;
1030 EXPORT_API int notification_set_vibration(notification_h noti,
1031 notification_vibration_type_e type,
1034 /* Check noti is valid data */
1036 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1038 /* Check type is valid */
1039 if (type < NOTIFICATION_VIBRATION_TYPE_NONE
1040 || type >= NOTIFICATION_VIBRATION_TYPE_MAX)
1041 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1043 /* Save vibration type */
1044 noti->vibration_type = type;
1046 /* Save sound path if user data type */
1047 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA && path != NULL) {
1048 if (noti->vibration_path != NULL)
1049 free(noti->vibration_path);
1051 noti->vibration_path = strdup(path);
1053 if (noti->vibration_path != NULL) {
1054 free(noti->vibration_path);
1055 noti->vibration_path = NULL;
1057 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA) {
1058 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
1059 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1063 return NOTIFICATION_ERROR_NONE;
1067 EXPORT_API int notification_get_vibration(notification_h noti,
1068 notification_vibration_type_e *type,
1071 /* check noti and type is valid data */
1072 if (noti == NULL || type == NULL)
1073 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1075 /* Set vibration type */
1076 *type = noti->vibration_type;
1078 /* Set sound path if user data type */
1079 if (noti->vibration_type == NOTIFICATION_VIBRATION_TYPE_USER_DATA
1081 *path = noti->vibration_path;
1083 return NOTIFICATION_ERROR_NONE;
1086 EXPORT_API int notification_set_led(notification_h noti,
1087 notification_led_op_e operation,
1090 /* Check noti is valid data */
1092 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1094 /* Check operation is valid */
1095 if (operation < NOTIFICATION_LED_OP_OFF
1096 || operation >= NOTIFICATION_LED_OP_MAX)
1097 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1099 /* Save led operation */
1100 noti->led_operation = operation;
1102 /* Save led argb if operation is turning on LED with custom color */
1103 if (operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR)
1104 noti->led_argb = led_argb;
1106 return NOTIFICATION_ERROR_NONE;
1109 EXPORT_API int notification_get_led(notification_h noti,
1110 notification_led_op_e *operation,
1113 /* check noti and operation is valid data */
1114 if (noti == NULL || operation == NULL)
1115 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1117 /* Set led operation */
1118 *operation = noti->led_operation;
1120 /* Save led argb if operation is turning on LED with custom color */
1121 if (noti->led_operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR
1122 && led_argb != NULL)
1123 *led_argb = noti->led_argb;
1125 return NOTIFICATION_ERROR_NONE;
1128 EXPORT_API int notification_set_led_time_period(notification_h noti,
1129 int on_ms, int off_ms)
1131 /* Check noti is valid data */
1132 if (noti == NULL || on_ms < 0 || off_ms < 0)
1133 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1135 /* Save led operation */
1136 noti->led_on_ms = on_ms;
1137 noti->led_off_ms = off_ms;
1139 return NOTIFICATION_ERROR_NONE;
1142 EXPORT_API int notification_get_led_time_period(notification_h noti,
1143 int *on_ms, int *off_ms)
1145 /* check noti and operation is valid data */
1147 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1150 *(on_ms) = noti->led_on_ms;
1152 *(off_ms) = noti->led_off_ms;
1154 return NOTIFICATION_ERROR_NONE;
1157 EXPORT_API int notification_set_launch_option(notification_h noti,
1158 notification_launch_option_type type, void *option)
1160 int err = NOTIFICATION_ERROR_NONE;
1163 app_control_h app_control = option;
1165 if (noti == NULL || app_control == NULL || type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL) {
1166 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1170 if ((ret = app_control_export_as_bundle(app_control, &b)) != APP_CONTROL_ERROR_NONE) {
1171 NOTIFICATION_ERR("Failed to convert appcontrol to bundle:%d", ret);
1172 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1176 err = notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, b);
1185 EXPORT_API int notification_get_launch_option(notification_h noti,
1186 notification_launch_option_type type, void *option)
1190 app_control_h *app_control = (app_control_h *)option;
1191 app_control_h app_control_new = NULL;
1194 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1196 if (app_control == NULL)
1197 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1199 if (type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL)
1200 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1203 ret = notification_get_execute_option(noti,
1204 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
1207 if (ret == NOTIFICATION_ERROR_NONE && b != NULL) {
1208 ret = app_control_create(&app_control_new);
1209 if (ret == APP_CONTROL_ERROR_NONE && app_control_new != NULL) {
1210 ret = app_control_import_from_bundle(app_control_new, b);
1211 if (ret == APP_CONTROL_ERROR_NONE) {
1212 *app_control = app_control_new;
1214 app_control_destroy(app_control_new);
1215 NOTIFICATION_ERR("Failed to import app control from bundle:%d", ret);
1216 return NOTIFICATION_ERROR_IO_ERROR;
1219 NOTIFICATION_ERR("Failed to create app control:%d", ret);
1220 return NOTIFICATION_ERROR_IO_ERROR;
1223 NOTIFICATION_ERR("Failed to get execute option:%d", ret);
1227 return NOTIFICATION_ERROR_NONE;
1230 EXPORT_API int notification_set_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h event_handler)
1232 int err = NOTIFICATION_ERROR_NONE;
1233 bundle *app_control_bundle = NULL;
1236 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1237 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1241 if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
1242 || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
1243 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1244 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1248 if ((err = app_control_export_as_bundle(event_handler, &app_control_bundle)) != APP_CONTROL_ERROR_NONE) {
1249 NOTIFICATION_ERR("app_control_to_bundle failed [%d]", err);
1253 if (noti->b_event_handler[event_type] != NULL)
1254 bundle_free(noti->b_event_handler[event_type]);
1256 noti->b_event_handler[event_type] = app_control_bundle;
1262 EXPORT_API int notification_get_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h *event_handler)
1264 int err = NOTIFICATION_ERROR_NONE;
1266 app_control_h app_control_new = NULL;
1269 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1270 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1273 if (event_handler == NULL) {
1274 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1275 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1278 if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
1279 || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
1280 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1281 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1285 b = noti->b_event_handler[event_type];
1288 NOTIFICATION_DBG("No event handler\n");
1289 err = NOTIFICATION_ERROR_NOT_EXIST_ID;
1293 err = app_control_create(&app_control_new);
1294 if (err != APP_CONTROL_ERROR_NONE || app_control_new == NULL) {
1295 NOTIFICATION_ERR("app_control_create failed [%d]", err);
1296 err = NOTIFICATION_ERROR_IO_ERROR;
1300 err = app_control_import_from_bundle(app_control_new, b);
1301 if (err == APP_CONTROL_ERROR_NONE) {
1302 *event_handler = app_control_new;
1304 app_control_destroy(app_control_new);
1305 app_control_new = NULL;
1306 NOTIFICATION_ERR("Failed to import app control from bundle [%d]", err);
1307 err = NOTIFICATION_ERROR_IO_ERROR;
1313 *event_handler = app_control_new;
1322 EXPORT_API int notification_set_property(notification_h noti,
1325 /* Check noti is valid data */
1327 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1330 noti->flags_for_property = flags;
1332 return NOTIFICATION_ERROR_NONE;
1335 EXPORT_API int notification_get_property(notification_h noti,
1338 /* Check noti and flags are valid data */
1339 if (noti == NULL || flags == NULL)
1340 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1343 *flags = noti->flags_for_property;
1345 return NOTIFICATION_ERROR_NONE;
1348 EXPORT_API int notification_set_display_applist(notification_h noti,
1351 /* Check noti is valid data */
1353 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1357 if (applist == 0xffffffff) /* 0xffffffff means old NOTIFICATION_DISPLAY_APP_ALL */
1358 applist = NOTIFICATION_DISPLAY_APP_ALL;
1360 noti->display_applist = applist;
1362 return NOTIFICATION_ERROR_NONE;
1365 EXPORT_API int notification_get_display_applist(notification_h noti,
1368 /* Check noti and applist are valid data */
1369 if (noti == NULL || applist == NULL)
1370 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1373 *applist = noti->display_applist;
1375 return NOTIFICATION_ERROR_NONE;
1378 EXPORT_API int notification_set_size(notification_h noti,
1381 /* Check noti is valid data */
1383 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1385 /* Save progress size */
1386 noti->progress_size = size;
1388 return NOTIFICATION_ERROR_NONE;
1391 EXPORT_API int notification_get_size(notification_h noti,
1394 /* Check noti and size is valid data */
1395 if (noti == NULL || size == NULL)
1396 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1398 /* Set progress size */
1399 *size = noti->progress_size;
1401 return NOTIFICATION_ERROR_NONE;
1404 EXPORT_API int notification_set_progress(notification_h noti,
1407 /* Check noti is valid data */
1409 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1411 /* Save progress percentage */
1412 noti->progress_percentage = percentage;
1414 return NOTIFICATION_ERROR_NONE;
1417 EXPORT_API int notification_get_progress(notification_h noti,
1420 /* Check noti and percentage are valid data */
1421 if (noti == NULL || percentage == NULL)
1422 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1424 /* Set progress percentage */
1425 *percentage = noti->progress_percentage;
1427 return NOTIFICATION_ERROR_NONE;
1430 EXPORT_API int notification_get_pkgname(notification_h noti,
1433 /* Check noti and pkgname are valid data */
1434 if (noti == NULL || pkgname == NULL)
1435 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1437 /* Get caller pkgname */
1438 if (noti->caller_pkgname)
1439 *pkgname = noti->caller_pkgname;
1443 return NOTIFICATION_ERROR_NONE;
1446 EXPORT_API int notification_set_layout(notification_h noti,
1447 notification_ly_type_e layout)
1449 /* check noti and pkgname are valid data */
1450 if (noti == NULL || (layout < NOTIFICATION_LY_NONE || layout >= NOTIFICATION_LY_MAX))
1451 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1453 noti->layout = layout;
1455 return NOTIFICATION_ERROR_NONE;
1458 EXPORT_API int notification_get_layout(notification_h noti,
1459 notification_ly_type_e *layout)
1461 /* Check noti and pkgname are valid data */
1462 if (noti == NULL || layout == NULL)
1463 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1465 *layout = noti->layout;
1467 return NOTIFICATION_ERROR_NONE;
1472 EXPORT_API int notification_get_type(notification_h noti,
1473 notification_type_e *type)
1475 /* Check noti and type is valid data */
1476 if (noti == NULL || type == NULL)
1477 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1482 return NOTIFICATION_ERROR_NONE;
1485 EXPORT_API int notification_post(notification_h noti)
1487 return notification_post_for_uid(noti, getuid());
1490 EXPORT_API int notification_update(notification_h noti)
1492 return notification_update_for_uid(noti, getuid());
1495 EXPORT_API int notification_delete_all(notification_type_e type)
1497 return notification_delete_all_for_uid(type, getuid());
1500 EXPORT_API int notification_delete(notification_h noti)
1502 return notification_delete_for_uid(noti, getuid());
1505 static notification_h _notification_create(notification_type_e type)
1507 notification_h noti = NULL;
1508 package_info_h package_info = NULL;
1509 char *app_id = NULL;
1510 char *domain_name = NULL;
1511 char *app_root_path = NULL;
1512 char locale_directory[PATH_MAX] = { 0, }; /* PATH_MAX 4096 */
1513 int err_app_manager = APP_MANAGER_ERROR_NONE;
1515 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1516 NOTIFICATION_ERR("INVALID TYPE : %d", type);
1517 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
1521 noti = (notification_h) calloc(1, sizeof(struct _notification));
1523 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
1524 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
1530 if (type == NOTIFICATION_TYPE_NOTI)
1531 noti->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
1532 else if (type == NOTIFICATION_TYPE_ONGOING)
1533 noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
1535 noti->caller_pkgname = notification_get_pkgname_by_pid();
1536 noti->group_id = NOTIFICATION_GROUP_ID_NONE;
1537 noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
1538 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
1539 noti->led_operation = NOTIFICATION_LED_OP_OFF;
1540 noti->display_applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_INDICATOR;
1541 noti->auto_remove = true;
1542 noti->ongoing_flag = false;
1544 err_app_manager = app_manager_get_app_id(getpid(), &app_id);
1545 if (err_app_manager != APP_MANAGER_ERROR_NONE || app_id == NULL) {
1546 NOTIFICATION_WARN("app_manager_get_app_id failed err[%d] app_id[%p]", err_app_manager, app_id);
1550 /* app name is used as domain name */
1551 /* domain_name is allocated by app_get_package_app_name */
1552 err_app_manager = app_get_package_app_name(app_id, &domain_name);
1554 if (err_app_manager != APP_ERROR_NONE || domain_name == NULL) {
1555 NOTIFICATION_WARN("app_get_package_app_name failed err[%d] domain_name[%p]", err_app_manager, domain_name);
1559 err_app_manager = package_info_create(noti->caller_pkgname, &package_info);
1561 if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || package_info == NULL) {
1562 NOTIFICATION_WARN("package_info_create failed err[%d] package_info[%p] caller_pkgname[%s]",
1563 err_app_manager, package_info, noti->caller_pkgname);
1567 err_app_manager = package_info_get_root_path(package_info, &app_root_path);
1569 if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || app_root_path == NULL) {
1570 NOTIFICATION_WARN("package_info_get_root_path failed err[%d] app_root_path[%p]", err_app_manager, app_root_path);
1574 snprintf(locale_directory, PATH_MAX, "%s/res/locale", app_root_path);
1576 noti->domain = strdup(domain_name);
1577 noti->dir = strdup(locale_directory);
1587 free(app_root_path);
1590 package_info_destroy(package_info);
1594 * Other fields are already initialized with ZERO.
1596 set_last_result(NOTIFICATION_ERROR_NONE);
1600 EXPORT_API notification_h notification_create(notification_type_e type)
1602 return _notification_create(type);
1605 EXPORT_API notification_h notification_load_by_tag(const char *tag)
1607 return notification_load_by_tag_for_uid(tag, getuid());
1610 EXPORT_API int notification_clone(notification_h noti, notification_h *clone)
1613 notification_h new_noti = NULL;
1615 if (noti == NULL || clone == NULL) {
1616 NOTIFICATION_ERR("INVALID PARAMETER.");
1617 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1620 new_noti = (notification_h) calloc(1, sizeof(struct _notification));
1621 if (new_noti == NULL) {
1622 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
1623 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
1626 new_noti->type = noti->type;
1627 new_noti->layout = noti->layout;
1629 new_noti->group_id = noti->group_id;
1630 new_noti->internal_group_id = noti->internal_group_id;
1631 new_noti->priv_id = noti->priv_id;
1633 if (noti->caller_pkgname != NULL)
1634 new_noti->caller_pkgname = strdup(noti->caller_pkgname);
1636 new_noti->caller_pkgname = notification_get_pkgname_by_pid();
1638 if (noti->launch_pkgname != NULL)
1639 new_noti->launch_pkgname = strdup(noti->launch_pkgname);
1641 new_noti->launch_pkgname = NULL;
1643 if (noti->args != NULL)
1644 new_noti->args = bundle_dup(noti->args);
1646 new_noti->args = NULL;
1648 if (noti->group_args != NULL)
1649 new_noti->group_args = bundle_dup(noti->group_args);
1651 new_noti->group_args = NULL;
1653 if (noti->b_execute_option != NULL)
1654 new_noti->b_execute_option = bundle_dup(noti->b_execute_option);
1656 new_noti->b_execute_option = NULL;
1658 if (noti->b_service_responding != NULL)
1659 new_noti->b_service_responding = bundle_dup(noti->b_service_responding);
1661 new_noti->b_service_responding = NULL;
1663 if (noti->b_service_single_launch != NULL)
1664 new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch);
1666 new_noti->b_service_single_launch = NULL;
1668 if (noti->b_service_multi_launch != NULL)
1669 new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch);
1671 new_noti->b_service_multi_launch = NULL;
1673 for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
1674 if (noti->b_event_handler[i] != NULL)
1675 new_noti->b_event_handler[i] = bundle_dup(noti->b_event_handler[i]);
1677 new_noti->b_event_handler[i] = NULL;
1680 new_noti->sound_type = noti->sound_type;
1681 if (noti->sound_path != NULL)
1682 new_noti->sound_path = strdup(noti->sound_path);
1684 new_noti->sound_path = NULL;
1686 new_noti->vibration_type = noti->vibration_type;
1687 if (noti->vibration_path != NULL)
1688 new_noti->vibration_path = strdup(noti->vibration_path);
1690 new_noti->vibration_path = NULL;
1692 new_noti->led_operation = noti->led_operation;
1693 new_noti->led_argb = noti->led_argb;
1694 new_noti->led_on_ms = noti->led_on_ms;
1695 new_noti->led_off_ms = noti->led_off_ms;
1697 if (noti->domain != NULL)
1698 new_noti->domain = strdup(noti->domain);
1700 new_noti->domain = NULL;
1702 if (noti->dir != NULL)
1703 new_noti->dir = strdup(noti->dir);
1705 new_noti->dir = NULL;
1707 if (noti->b_text != NULL)
1708 new_noti->b_text = bundle_dup(noti->b_text);
1710 new_noti->b_text = NULL;
1712 if (noti->b_key != NULL)
1713 new_noti->b_key = bundle_dup(noti->b_key);
1715 new_noti->b_key = NULL;
1717 if (noti->tag != NULL)
1718 new_noti->tag = strdup(noti->tag);
1720 new_noti->tag = NULL;
1722 if (noti->b_format_args != NULL)
1723 new_noti->b_format_args = bundle_dup(noti->b_format_args);
1725 new_noti->b_format_args = NULL;
1727 new_noti->num_format_args = noti->num_format_args;
1729 if (noti->b_image_path != NULL)
1730 new_noti->b_image_path = bundle_dup(noti->b_image_path);
1732 new_noti->b_image_path = NULL;
1734 new_noti->time = noti->time;
1735 new_noti->insert_time = noti->insert_time;
1737 new_noti->flags_for_property = noti->flags_for_property;
1738 new_noti->display_applist = noti->display_applist;
1740 new_noti->progress_size = noti->progress_size;
1741 new_noti->progress_percentage = noti->progress_percentage;
1743 new_noti->ongoing_flag = noti->ongoing_flag;
1744 new_noti->auto_remove = noti->auto_remove;
1745 new_noti->uid = noti->uid;
1747 new_noti->app_icon_path = NULL;
1748 new_noti->app_name = NULL;
1749 new_noti->temp_title = NULL;
1750 new_noti->temp_content = NULL;
1754 return NOTIFICATION_ERROR_NONE;
1758 EXPORT_API int notification_free(notification_h noti)
1762 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1764 if (noti->caller_pkgname)
1765 free(noti->caller_pkgname);
1767 if (noti->launch_pkgname)
1768 free(noti->launch_pkgname);
1771 bundle_free(noti->args);
1773 if (noti->group_args)
1774 bundle_free(noti->group_args);
1776 if (noti->b_execute_option)
1777 bundle_free(noti->b_execute_option);
1779 if (noti->b_service_responding)
1780 bundle_free(noti->b_service_responding);
1782 if (noti->b_service_single_launch)
1783 bundle_free(noti->b_service_single_launch);
1785 if (noti->b_service_multi_launch)
1786 bundle_free(noti->b_service_multi_launch);
1788 for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
1789 if (noti->b_event_handler[i] != NULL)
1790 bundle_free(noti->b_event_handler[i]);
1793 if (noti->sound_path)
1794 free(noti->sound_path);
1796 if (noti->vibration_path)
1797 free(noti->vibration_path);
1806 bundle_free(noti->b_text);
1809 bundle_free(noti->b_key);
1811 if (noti->b_format_args)
1812 bundle_free(noti->b_format_args);
1814 if (noti->b_image_path)
1815 bundle_free(noti->b_image_path);
1817 if (noti->app_icon_path)
1818 free(noti->app_icon_path);
1821 free(noti->app_name);
1823 if (noti->temp_title)
1824 free(noti->temp_title);
1826 if (noti->temp_content)
1827 free(noti->temp_content);
1834 return NOTIFICATION_ERROR_NONE;
1837 EXPORT_API int notification_set_tag(notification_h noti, const char *tag)
1839 /* Check noti is valid data */
1841 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1844 /* save input TAG */
1845 if (noti->tag != NULL)
1848 noti->tag = strdup(tag);
1851 return NOTIFICATION_ERROR_NONE;
1855 EXPORT_API int notification_get_tag(notification_h noti, const char **tag)
1857 /* Check noti is valid data */
1859 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1862 return NOTIFICATION_ERROR_NONE;
1865 /* LCOV_EXCL_START */
1866 void notification_call_posted_toast_cb(const char *message)
1868 if (posted_toast_message_cb != NULL)
1869 posted_toast_message_cb((void *)message);
1871 /* LCOV_EXCL_STOP */
1873 EXPORT_API int notification_set_ongoing_flag(notification_h noti, bool ongoing_flag)
1876 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1878 noti->ongoing_flag = ongoing_flag;
1880 return NOTIFICATION_ERROR_NONE;
1883 EXPORT_API int notification_get_ongoing_flag(notification_h noti, bool *ongoing_flag)
1885 if (noti == NULL || ongoing_flag == NULL)
1886 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1888 *ongoing_flag = noti->ongoing_flag;
1890 return NOTIFICATION_ERROR_NONE;
1894 EXPORT_API int notification_add_button(notification_h noti, notification_button_index_e button_index)
1896 if (noti == NULL || button_index < NOTIFICATION_BUTTON_1 || button_index > NOTIFICATION_BUTTON_6)
1897 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1899 return NOTIFICATION_ERROR_NONE;
1902 EXPORT_API int notification_remove_button(notification_h noti, notification_button_index_e button_index)
1904 if (noti == NULL || button_index < NOTIFICATION_BUTTON_1 || button_index > NOTIFICATION_BUTTON_6)
1905 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1907 if (noti->b_event_handler[button_index - 1]) {
1908 bundle_free(noti->b_event_handler[button_index - 1]);
1909 noti->b_event_handler[button_index - 1] = NULL;
1912 return NOTIFICATION_ERROR_NONE;
1915 EXPORT_API int notification_set_auto_remove(notification_h noti, bool auto_remove)
1918 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1920 noti->auto_remove = auto_remove;
1922 return NOTIFICATION_ERROR_NONE;
1925 EXPORT_API int notification_get_auto_remove(notification_h noti, bool *auto_remove)
1927 if (noti == NULL || auto_remove == NULL)
1928 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1930 *auto_remove = noti->auto_remove;
1932 return NOTIFICATION_ERROR_NONE;