4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
28 #include <dbus/dbus.h>
29 #include <dbus/dbus-glib-lowlevel.h>
32 #include <app_control_internal.h>
37 #include <vconf-keys.h>
40 #include <notification.h>
41 #include <notification_list.h>
42 #include <notification_debug.h>
43 #include <notification_private.h>
44 #include <notification_noti.h>
45 #include <notification_ongoing.h>
46 #include <notification_group.h>
47 #include <notification_ipc.h>
48 #include <notification_internal.h>
50 typedef struct _notification_cb_list notification_cb_list_s;
52 typedef enum __notification_cb_type {
53 NOTIFICATION_CB_NORMAL = 1,
54 NOTIFICATION_CB_DETAILED,
55 } _notification_cb_type_e;
57 struct _notification_cb_list {
58 notification_cb_list_s *prev;
59 notification_cb_list_s *next;
61 _notification_cb_type_e cb_type;
62 void (*changed_cb) (void *data, notification_type_e type);
63 void (*detailed_changed_cb) (void *data, notification_type_e type, notification_op *op_list, int num_op);
67 static notification_cb_list_s *g_notification_cb_list = NULL;
69 static void (*posted_toast_message_cb) (void *data);
71 #define NOTI_TEXT_RESULT_LEN 2048
72 #define NOTI_PKGNAME_LEN 512
74 static char *_notification_get_pkgname_by_pid(void)
76 char pkgname[NOTI_PKGNAME_LEN + 1] = { 0, };
77 int pid = 0, ret = AUL_R_OK;
83 ret = aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname));
84 if (ret != AUL_R_OK) {
85 char buf[NOTI_PKGNAME_LEN + 1] = { 0, };
87 snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
89 fd = open(buf, O_RDONLY);
94 ret = read(fd, pkgname, sizeof(pkgname) - 1);
104 * "ret" is not able to be larger than "sizeof(pkgname) - 1",
105 * if the system is not going wrong.
108 if (strlen(pkgname) <= 0) {
113 dup_pkgname = strdup(pkgname);
115 NOTIFICATION_ERR("Heap: %d\n", errno);
120 static void _notification_get_text_domain(notification_h noti)
122 if (noti->domain != NULL) {
126 if (noti->dir != NULL) {
131 EXPORT_API int notification_set_image(notification_h noti,
132 notification_image_type_e type,
133 const char *image_path)
136 char buf_key[32] = { 0, };
137 const char *ret_val = NULL;
139 /* Check noti and image_path are valid data */
140 if (noti == NULL || image_path == NULL) {
141 return NOTIFICATION_ERROR_INVALID_PARAMETER;
144 /* Check image type is valid type */
145 if (type <= NOTIFICATION_IMAGE_TYPE_NONE
146 || type >= NOTIFICATION_IMAGE_TYPE_MAX) {
147 return NOTIFICATION_ERROR_INVALID_PARAMETER;
150 /* Check image path bundle is exist */
151 if (noti->b_image_path) {
152 /* If image path bundle is exist, store local bundle value */
153 b = noti->b_image_path;
155 /* Set image type to key as char string type */
156 snprintf(buf_key, sizeof(buf_key), "%d", type);
158 /* Get value using key */
159 ret_val = bundle_get_val(b, buf_key);
160 if (ret_val != NULL) {
161 /* If key is exist, remove this value to store new image path */
162 bundle_del(b, buf_key);
165 /* Add new image path with type key */
166 bundle_add(b, buf_key, image_path);
168 /* If image path bundle is not exist, create new one */
171 /* Set image type to key as char string type */
172 snprintf(buf_key, sizeof(buf_key), "%d", type);
174 /* Add new image path with type key */
175 bundle_add(b, buf_key, image_path);
177 /* Save to image path bundle */
178 noti->b_image_path = b;
181 return NOTIFICATION_ERROR_NONE;
184 EXPORT_API int notification_get_image(notification_h noti,
185 notification_image_type_e type,
189 char buf_key[32] = { 0, };
190 const char *ret_val = NULL;
192 /* Check noti and image_path is valid data */
193 if (noti == NULL || image_path == NULL) {
194 return NOTIFICATION_ERROR_INVALID_PARAMETER;
197 /* Check image type is valid data */
198 if (type <= NOTIFICATION_IMAGE_TYPE_NONE
199 || type >= NOTIFICATION_IMAGE_TYPE_MAX) {
200 return NOTIFICATION_ERROR_INVALID_PARAMETER;
203 /* Check image path bundle exist */
204 if (noti->b_image_path) {
205 /* If image path bundle exist, store local bundle data */
206 b = noti->b_image_path;
208 /* Set image type to key as char string type */
209 snprintf(buf_key, sizeof(buf_key), "%d", type);
211 /* Get value of key */
212 ret_val = bundle_get_val(b, buf_key);
214 *image_path = (char *)ret_val;
216 /* If image path bundle does not exist, image path is NULL */
220 /* If image path is NULL and type is ICON, icon path set from AIL */
221 /* order : user icon -> launch_pkgname icon -> caller_pkgname icon -> service app icon */
222 if (*image_path == NULL && type == NOTIFICATION_IMAGE_TYPE_ICON) {
223 /* Check App icon path is already set */
224 if (noti->app_icon_path != NULL) {
225 /* image path will be app icon path */
226 *image_path = noti->app_icon_path;
232 return NOTIFICATION_ERROR_NONE;
235 EXPORT_API int notification_set_time(notification_h noti,
238 /* Check noti is valid data */
240 return NOTIFICATION_ERROR_INVALID_PARAMETER;
243 if (input_time == 0) {
244 /* If input time is 0, set current time */
245 noti->time = time(NULL);
247 /* save input time */
248 noti->time = input_time;
251 return NOTIFICATION_ERROR_NONE;
254 EXPORT_API int notification_get_time(notification_h noti,
257 /* Check noti and time is valid data */
258 if (noti == NULL || ret_time == NULL) {
259 return NOTIFICATION_ERROR_INVALID_PARAMETER;
262 /* Set time infomation */
263 *ret_time = noti->time;
265 return NOTIFICATION_ERROR_NONE;
268 EXPORT_API int notification_get_insert_time(notification_h noti,
271 /* Check noti and ret_time is valid data */
272 if (noti == NULL || ret_time == NULL) {
273 return NOTIFICATION_ERROR_INVALID_PARAMETER;
276 /* Set insert time information */
277 *ret_time = noti->insert_time;
279 return NOTIFICATION_ERROR_NONE;
282 EXPORT_API int notification_set_text(notification_h noti,
283 notification_text_type_e type,
289 char buf_key[32] = { 0, };
290 char buf_val[1024] = { 0, };
291 const char *ret_val = NULL;
293 notification_variable_type_e var_type;
295 int noti_err = NOTIFICATION_ERROR_NONE;
296 int var_value_int = 0;
297 double var_value_double = 0.0;
298 char *var_value_string = NULL;
299 notification_count_pos_type_e var_value_count =
300 NOTIFICATION_COUNT_POS_NONE;
302 /* Check noti is valid data */
304 return NOTIFICATION_ERROR_INVALID_PARAMETER;
307 /* Check text type is valid type */
308 if (type <= NOTIFICATION_TEXT_TYPE_NONE
309 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
310 return NOTIFICATION_ERROR_INVALID_PARAMETER;
313 /* Check text bundle exist */
315 if (noti->b_text != NULL) {
316 /* If text bundle exist, store local bundle data */
319 /* Make type to key as char string */
320 snprintf(buf_key, sizeof(buf_key), "%d", type);
322 /* Get value using type key */
323 ret_val = bundle_get_val(b, buf_key);
324 if (ret_val != NULL) {
325 /* If value exist, remove this to add new value */
326 bundle_del(b, buf_key);
329 snprintf(buf_val, sizeof(buf_val), "%s", text);
331 /* Add new text value */
332 bundle_add(b, buf_key, buf_val);
334 /* If text 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", text);
342 /* Add new text value */
343 bundle_add(b, buf_key, buf_val);
345 /* Save text bundle */
349 /* Reset if text is NULL */
350 if (noti->b_text != NULL) {
351 /* If text 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 ret_val = bundle_get_val(b, buf_key);
359 if (ret_val != NULL) {
360 /* If value exist, remove this */
361 bundle_del(b, buf_key);
366 /* Save key if key is valid data */
368 /* Check key bundle exist */
369 if (noti->b_key != NULL) {
370 /* If key bundle exist, store local bundle data */
373 /* Make type to key as char string */
374 snprintf(buf_key, sizeof(buf_key), "%d", type);
376 /* Get value using type key */
377 ret_val = bundle_get_val(b, buf_key);
378 if (ret_val != NULL) {
379 /* If value exist, remove this to add new value */
380 bundle_del(b, buf_key);
383 snprintf(buf_val, sizeof(buf_val), "%s", key);
385 /* Add new key value */
386 bundle_add(b, buf_key, buf_val);
388 /* If key bundle does not exist, create new one */
391 /* Make type to key as char string */
392 snprintf(buf_key, sizeof(buf_key), "%d", type);
394 snprintf(buf_val, sizeof(buf_val), "%s", key);
396 /* Add new key value */
397 bundle_add(b, buf_key, buf_val);
399 /* Save key bundle */
403 /* Reset if key is NULL */
404 if (noti->b_key != NULL) {
405 /* If key bundle exist, store local bundle data */
408 /* Make type to key as char string */
409 snprintf(buf_key, sizeof(buf_key), "%d", type);
411 /* Get value using type key */
412 ret_val = bundle_get_val(b, buf_key);
413 if (ret_val != NULL) {
414 /* If value exist, remove this */
415 bundle_del(b, buf_key);
420 if (noti->b_format_args != NULL) {
421 b = noti->b_format_args;
426 va_start(var_args, args_type);
428 var_type = args_type;
431 while (var_type != NOTIFICATION_VARIABLE_TYPE_NONE) {
433 snprintf(buf_key, sizeof(buf_key), "%dtype%d", type, num_args);
434 snprintf(buf_val, sizeof(buf_val), "%d", var_type);
436 ret_val = bundle_get_val(b, buf_key);
437 if (ret_val != NULL) {
438 bundle_del(b, buf_key);
441 bundle_add(b, buf_key, buf_val);
444 case NOTIFICATION_VARIABLE_TYPE_INT:
445 var_value_int = va_arg(var_args, int);
448 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
450 snprintf(buf_val, sizeof(buf_val), "%d", var_value_int);
452 ret_val = bundle_get_val(b, buf_key);
453 if (ret_val != NULL) {
454 bundle_del(b, buf_key);
457 bundle_add(b, buf_key, buf_val);
459 case NOTIFICATION_VARIABLE_TYPE_DOUBLE:
460 var_value_double = va_arg(var_args, double);
463 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
465 snprintf(buf_val, sizeof(buf_val), "%.2f",
468 ret_val = bundle_get_val(b, buf_key);
469 if (ret_val != NULL) {
470 bundle_del(b, buf_key);
473 bundle_add(b, buf_key, buf_val);
475 case NOTIFICATION_VARIABLE_TYPE_STRING:
476 var_value_string = va_arg(var_args, char *);
479 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
481 snprintf(buf_val, sizeof(buf_val), "%s",
484 ret_val = bundle_get_val(b, buf_key);
485 if (ret_val != NULL) {
486 bundle_del(b, buf_key);
489 bundle_add(b, buf_key, buf_val);
491 case NOTIFICATION_VARIABLE_TYPE_COUNT:
493 va_arg(var_args, notification_count_pos_type_e);
496 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
498 snprintf(buf_val, sizeof(buf_val), "%d",
501 ret_val = bundle_get_val(b, buf_key);
502 if (ret_val != NULL) {
503 bundle_del(b, buf_key);
506 bundle_add(b, buf_key, buf_val);
509 NOTIFICATION_ERR("Error. invalid variable type. : %d",
511 noti_err = NOTIFICATION_ERROR_INVALID_PARAMETER;
516 var_type = va_arg(var_args, notification_variable_type_e);
520 if (noti_err == NOTIFICATION_ERROR_NONE) {
521 noti->num_format_args = num_args;
523 noti->num_format_args = 0;
526 snprintf(buf_key, sizeof(buf_key), "num%d", type);
527 snprintf(buf_val, sizeof(buf_val), "%d", noti->num_format_args);
529 ret_val = bundle_get_val(b, buf_key);
530 if (ret_val != NULL) {
531 bundle_del(b, buf_key);
534 bundle_add(b, buf_key, buf_val);
536 noti->b_format_args = b;
541 EXPORT_API int notification_get_text(notification_h noti,
542 notification_text_type_e type,
546 char buf_key[32] = { 0, };
547 const char *ret_val = NULL;
548 const char *get_str = NULL;
549 const char *get_check_type_str = NULL;
550 notification_text_type_e check_type = NOTIFICATION_TEXT_TYPE_NONE;
551 //int display_option_flag = 0;
553 char *temp_str = NULL;
554 char result_str[NOTI_TEXT_RESULT_LEN] = { 0, };
555 char buf_str[1024] = { 0, };
557 notification_variable_type_e ret_var_type = 0;
558 int ret_variable_int = 0;
559 double ret_variable_double = 0.0;
561 /* Check noti is valid data */
562 if (noti == NULL || text == NULL) {
563 return NOTIFICATION_ERROR_INVALID_PARAMETER;
566 /* Check text type is valid type */
567 if (type <= NOTIFICATION_TEXT_TYPE_NONE
568 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
569 return NOTIFICATION_ERROR_INVALID_PARAMETER;
573 if (noti->b_key != NULL) {
576 /* Get text domain and dir */
577 //_notification_get_text_domain(noti);
579 snprintf(buf_key, sizeof(buf_key), "%d", type);
581 ret_val = bundle_get_val(b, buf_key);
582 if (ret_val != NULL && noti->domain != NULL
583 && noti->dir != NULL) {
584 /* Get application string */
585 bindtextdomain(noti->domain, noti->dir);
587 get_str = dgettext(noti->domain, ret_val);
588 } else if (ret_val != NULL) {
589 /* Get system string */
590 get_str = dgettext("sys_string", ret_val);
596 if (get_str == NULL && noti->b_text != NULL) {
599 snprintf(buf_key, sizeof(buf_key), "%d", type);
601 get_str = bundle_get_val(b, buf_key);
606 /* Set display option is off type when option is off, type is noti */
607 /*if (get_str != NULL && display_option_flag == 1
608 && noti->type == NOTIFICATION_TYPE_NOTI) {
609 if (type == NOTIFICATION_TEXT_TYPE_CONTENT
610 || type == NOTIFICATION_TEXT_TYPE_GROUP_CONTENT) {
611 // Set check_type to option content string
612 if (type == NOTIFICATION_TEXT_TYPE_CONTENT) {
614 NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF;
615 } else if (type == NOTIFICATION_TEXT_TYPE_GROUP_CONTENT) {
617 NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF;
621 if (noti->b_key != NULL) {
624 // Get text domain and dir
625 _notification_get_text_domain(noti);
627 snprintf(buf_key, sizeof(buf_key), "%d",
630 ret_val = bundle_get_val(b, buf_key);
631 if (ret_val != NULL && noti->domain != NULL
632 && noti->dir != NULL) {
633 // Get application string
634 bindtextdomain(noti->domain, noti->dir);
637 dgettext(noti->domain, ret_val);
638 } else if (ret_val != NULL) {
641 dgettext("sys_string", ret_val);
643 get_check_type_str = NULL;
647 if (get_check_type_str == NULL && noti->b_text != NULL) {
650 snprintf(buf_key, sizeof(buf_key), "%d",
653 get_check_type_str = bundle_get_val(b, buf_key);
657 if (get_check_type_str != NULL) {
658 // Replace option off type string
659 get_str = get_check_type_str;
661 // Set default string
663 dgettext("sys_string", "IDS_COM_POP_MISSED_EVENT");
667 if (get_str != NULL) {
668 /* Get number format args */
669 b = noti->b_format_args;
670 noti->num_format_args = 0;
673 snprintf(buf_key, sizeof(buf_key), "num%d", check_type);
674 ret_val = bundle_get_val(b, buf_key);
675 if (ret_val != NULL) {
676 noti->num_format_args = atoi(ret_val);
680 if (noti->num_format_args == 0) {
681 *text = (char *)get_str;
683 /* Check first variable is count, LEFT pos */
684 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
685 check_type, num_args);
686 ret_val = bundle_get_val(b, buf_key);
687 ret_var_type = atoi(ret_val);
689 if (ret_var_type == NOTIFICATION_VARIABLE_TYPE_COUNT) {
691 snprintf(buf_key, sizeof(buf_key), "%dvalue%d",
692 check_type, num_args);
693 ret_val = bundle_get_val(b, buf_key);
694 ret_variable_int = atoi(ret_val);
696 if (ret_variable_int ==
697 NOTIFICATION_COUNT_POS_LEFT) {
698 notification_noti_get_count(noti->type,
699 noti->caller_pkgname,
703 snprintf(buf_str, sizeof(buf_str),
704 "%d ", ret_variable_int);
706 int src_len = strlen(result_str);
707 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
709 strncat(result_str, buf_str,
717 /* Check variable IN pos */
718 for (temp_str = (char *)get_str; *temp_str != '\0';
720 if (*temp_str != '%') {
721 strncat(result_str, temp_str, 1);
723 if (*(temp_str + 1) == '%') {
724 strncat(result_str, temp_str,
726 } else if (*(temp_str + 1) == 'd') {
728 ret_variable_int = 0;
732 "%dtype%d", check_type,
735 bundle_get_val(b, buf_key);
736 ret_var_type = atoi(ret_val);
738 NOTIFICATION_VARIABLE_TYPE_COUNT)
740 /* Get notification count */
741 notification_noti_get_count
743 noti->caller_pkgname,
763 sizeof(buf_str), "%d",
766 int src_len = strlen(result_str);
767 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
769 strncat(result_str, buf_str,
775 } else if (*(temp_str + 1) == 's') {
780 check_type, num_args);
782 bundle_get_val(b, buf_key);
785 sizeof(buf_str), "%s",
788 int src_len = strlen(result_str);
789 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
791 strncat(result_str, buf_str,
797 } else if (*(temp_str + 1) == 'f') {
802 check_type, num_args);
804 bundle_get_val(b, buf_key);
805 ret_variable_double =
811 ret_variable_double);
813 int src_len = strlen(result_str);
814 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
816 strncat(result_str, buf_str,
822 } else if (*(temp_str + 1) >= '1' && *(temp_str + 1) <= '9') {
823 if (*(temp_str + 3) == 'd') {
825 ret_variable_int = 0;
829 "%dtype%d", check_type,
830 num_args + *(temp_str + 1) - 49);
832 bundle_get_val(b, buf_key);
833 ret_var_type = atoi(ret_val);
835 NOTIFICATION_VARIABLE_TYPE_COUNT)
837 /* Get notification count */
838 notification_noti_get_count
840 noti->caller_pkgname,
851 num_args + *(temp_str + 1) - 49);
860 sizeof(buf_str), "%d",
863 int src_len = strlen(result_str);
864 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
866 strncat(result_str, buf_str,
870 } else if (*(temp_str + 3) == 's') {
875 check_type, num_args + *(temp_str + 1) - 49);
877 bundle_get_val(b, buf_key);
880 sizeof(buf_str), "%s",
883 int src_len = strlen(result_str);
884 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
886 strncat(result_str, buf_str,
890 } else if (*(temp_str + 3) == 'f') {
895 check_type, num_args + *(temp_str + 1) - 49);
897 bundle_get_val(b, buf_key);
898 ret_variable_double =
904 ret_variable_double);
906 int src_len = strlen(result_str);
907 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
909 strncat(result_str, buf_str,
919 /* Check last variable is count, LEFT pos */
920 if (num_args < noti->num_format_args) {
921 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
922 check_type, num_args);
923 ret_val = bundle_get_val(b, buf_key);
924 ret_var_type = atoi(ret_val);
926 NOTIFICATION_VARIABLE_TYPE_COUNT) {
928 snprintf(buf_key, sizeof(buf_key),
929 "%dvalue%d", check_type,
931 ret_val = bundle_get_val(b, buf_key);
932 ret_variable_int = atoi(ret_val);
934 if (ret_variable_int ==
935 NOTIFICATION_COUNT_POS_RIGHT) {
936 notification_noti_get_count
938 noti->caller_pkgname,
943 sizeof(buf_str), " %d",
946 int src_len = strlen(result_str);
947 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
949 strncat(result_str, buf_str,
958 switch (check_type) {
959 case NOTIFICATION_TEXT_TYPE_TITLE:
960 case NOTIFICATION_TEXT_TYPE_GROUP_TITLE:
961 if (noti->temp_title != NULL)
962 free(noti->temp_title);
964 noti->temp_title = strdup(result_str);
966 *text = noti->temp_title;
968 case NOTIFICATION_TEXT_TYPE_CONTENT:
969 case NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
970 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT:
971 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
972 if (noti->temp_content !=
974 free(noti->temp_content);
976 noti->temp_content = strdup(result_str);
978 *text = noti->temp_content;
990 return NOTIFICATION_ERROR_NONE;
993 EXPORT_API int notification_set_text_domain(notification_h noti,
997 /* check noti and domain is valid data */
998 if (noti == NULL || domain == NULL || dir == NULL) {
999 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1004 /* Remove previous domain */
1008 noti->domain = strdup(domain);
1010 /* Check locale dir */
1012 /* Remove previous locale dir */
1015 /* Copy locale dir */
1016 noti->dir = strdup(dir);
1018 return NOTIFICATION_ERROR_NONE;
1021 EXPORT_API int notification_get_text_domain(notification_h noti,
1025 /* Check noti is valid data */
1027 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1031 if (domain != NULL && noti->domain != NULL) {
1032 *domain = noti->domain;
1035 /* Get locale dir */
1036 if (dir != NULL && noti->dir != NULL) {
1040 return NOTIFICATION_ERROR_NONE;
1043 EXPORT_API int notification_set_time_to_text(notification_h noti, notification_text_type_e type,
1046 int ret = NOTIFICATION_ERROR_NONE;
1047 char buf[256] = { 0, };
1048 char buf_tag[512] = { 0, };
1051 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1054 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1056 if (type <= NOTIFICATION_TEXT_TYPE_NONE
1057 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
1058 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1062 snprintf(buf, sizeof(buf), "%lu", time);
1063 ret = notification_noti_set_tag(TAG_TIME, buf, buf_tag, sizeof(buf_tag));
1065 if (ret != NOTIFICATION_ERROR_NONE) {
1069 return notification_set_text(noti, type, buf_tag, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1072 EXPORT_API int notification_get_time_from_text(notification_h noti, notification_text_type_e type,
1075 int ret = NOTIFICATION_ERROR_NONE;
1078 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1081 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1083 if (type <= NOTIFICATION_TEXT_TYPE_NONE
1084 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
1085 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1088 char *ret_text = NULL;
1089 ret = notification_get_text(noti, type, &ret_text);
1091 if (ret != NOTIFICATION_ERROR_NONE || ret_text == NULL) {
1092 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1095 if (notification_noti_get_tag_type(ret_text) == TAG_TYPE_INVALID) {
1096 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1099 char *tag_value = NULL;
1100 tag_value = notification_noti_strip_tag(ret_text);
1101 if (tag_value == NULL) {
1102 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1105 *time = atol(tag_value);
1108 return NOTIFICATION_ERROR_NONE;
1111 EXPORT_API int notification_set_sound(notification_h noti,
1112 notification_sound_type_e type,
1115 /* Check noti is valid data */
1117 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1120 /* Check type is valid */
1121 if (type < NOTIFICATION_SOUND_TYPE_NONE
1122 || type >= NOTIFICATION_SOUND_TYPE_MAX) {
1123 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1126 /* Save sound type */
1127 noti->sound_type = type;
1129 /* Save sound path if user data type */
1130 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA && path != NULL) {
1131 if (noti->sound_path != NULL) {
1132 free(noti->sound_path);
1135 noti->sound_path = strdup(path);
1137 if (noti->sound_path != NULL) {
1138 free(noti->sound_path);
1139 noti->sound_path = NULL;
1141 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA) {
1142 noti->sound_type = NOTIFICATION_SOUND_TYPE_DEFAULT;
1143 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1147 return NOTIFICATION_ERROR_NONE;
1150 EXPORT_API int notification_get_sound(notification_h noti,
1151 notification_sound_type_e *type,
1154 /* check noti and type is valid data */
1155 if (noti == NULL || type == NULL) {
1156 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1159 /* Set sound type */
1160 *type = noti->sound_type;
1162 /* Set sound path if user data type */
1163 if (noti->sound_type == NOTIFICATION_SOUND_TYPE_USER_DATA
1165 *path = noti->sound_path;
1168 return NOTIFICATION_ERROR_NONE;
1171 EXPORT_API int notification_set_vibration(notification_h noti,
1172 notification_vibration_type_e type,
1175 /* Check noti is valid data */
1177 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1180 /* Check type is valid */
1181 if (type < NOTIFICATION_VIBRATION_TYPE_NONE
1182 || type >= NOTIFICATION_VIBRATION_TYPE_MAX) {
1183 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1186 /* Save vibration type */
1187 noti->vibration_type = type;
1189 /* Save sound path if user data type */
1190 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA && path != NULL) {
1191 if (noti->vibration_path != NULL) {
1192 free(noti->vibration_path);
1195 noti->vibration_path = strdup(path);
1197 if (noti->vibration_path != NULL) {
1198 free(noti->vibration_path);
1199 noti->vibration_path = NULL;
1201 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA) {
1202 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
1203 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1207 return NOTIFICATION_ERROR_NONE;
1211 EXPORT_API int notification_get_vibration(notification_h noti,
1212 notification_vibration_type_e *type,
1215 /* check noti and type is valid data */
1216 if (noti == NULL || type == NULL) {
1217 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1220 /* Set vibration type */
1221 *type = noti->vibration_type;
1223 /* Set sound path if user data type */
1224 if (noti->vibration_type == NOTIFICATION_VIBRATION_TYPE_USER_DATA
1226 *path = noti->vibration_path;
1229 return NOTIFICATION_ERROR_NONE;
1232 EXPORT_API int notification_set_led(notification_h noti,
1233 notification_led_op_e operation,
1236 /* Check noti is valid data */
1238 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1241 /* Check operation is valid */
1242 if (operation < NOTIFICATION_LED_OP_OFF
1243 || operation >= NOTIFICATION_LED_OP_MAX) {
1244 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1247 /* Save led operation */
1248 noti->led_operation = operation;
1250 /* Save led argb if operation is turning on LED with custom color */
1251 if (operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR) {
1252 noti->led_argb = led_argb;
1255 return NOTIFICATION_ERROR_NONE;
1258 EXPORT_API int notification_get_led(notification_h noti,
1259 notification_led_op_e *operation,
1262 /* check noti and operation is valid data */
1263 if (noti == NULL || operation == NULL) {
1264 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1267 /* Set led operation */
1268 *operation = noti->led_operation;
1270 /* Save led argb if operation is turning on LED with custom color */
1271 if (noti->led_operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR
1272 && led_argb != NULL) {
1273 *led_argb = noti->led_argb;
1276 return NOTIFICATION_ERROR_NONE;
1279 EXPORT_API int notification_set_led_time_period(notification_h noti,
1280 int on_ms, int off_ms)
1282 /* Check noti is valid data */
1283 if (noti == NULL || on_ms < 0 || off_ms < 0) {
1284 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1287 /* Save led operation */
1288 noti->led_on_ms = on_ms;
1289 noti->led_off_ms = off_ms;
1291 return NOTIFICATION_ERROR_NONE;
1294 EXPORT_API int notification_get_led_time_period(notification_h noti,
1295 int *on_ms, int *off_ms)
1297 /* check noti and operation is valid data */
1299 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1303 *(on_ms) = noti->led_on_ms;
1305 *(off_ms) = noti->led_off_ms;
1307 return NOTIFICATION_ERROR_NONE;
1310 EXPORT_API int notification_set_application(notification_h noti,
1311 const char *pkgname)
1313 if (noti == NULL || pkgname == NULL) {
1314 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1317 if (noti->launch_pkgname) {
1318 free(noti->launch_pkgname);
1321 noti->launch_pkgname = strdup(pkgname);
1323 return NOTIFICATION_ERROR_NONE;
1326 EXPORT_API int notification_get_application(notification_h noti,
1329 if (noti == NULL || pkgname == NULL) {
1330 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1333 if (noti->launch_pkgname) {
1334 *pkgname = noti->launch_pkgname;
1336 *pkgname = noti->caller_pkgname;
1339 return NOTIFICATION_ERROR_NONE;
1342 EXPORT_API int notification_set_launch_option(notification_h noti,
1343 notification_launch_option_type type, void *option)
1347 app_control_h app_control = option;
1350 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1352 if (app_control == NULL) {
1353 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1355 if (type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL) {
1356 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1359 if ((ret = app_control_to_bundle(app_control, &b)) == APP_CONTROL_ERROR_NONE) {
1360 return notification_set_execute_option(noti,
1361 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
1365 NOTIFICATION_ERR("Failed to convert appcontrol to bundle:%d", ret);
1366 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1370 EXPORT_API int notification_get_launch_option(notification_h noti,
1371 notification_launch_option_type type, void *option)
1375 app_control_h *app_control = (app_control_h *)option;
1376 app_control_h app_control_new = NULL;
1379 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1381 if (app_control == NULL) {
1382 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1384 if (type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL) {
1385 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1388 ret = notification_get_execute_option(noti,
1389 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
1392 if (ret == NOTIFICATION_ERROR_NONE && b != NULL) {
1393 ret = app_control_create(&app_control_new);
1394 if (ret == APP_CONTROL_ERROR_NONE && app_control_new != NULL) {
1395 ret = app_control_import_from_bundle(app_control_new, b);
1396 if (ret == APP_CONTROL_ERROR_NONE) {
1397 *app_control = app_control_new;
1399 app_control_destroy(app_control_new);
1400 NOTIFICATION_ERR("Failed to import app control from bundle:%d", ret);
1401 return NOTIFICATION_ERROR_IO_ERROR;
1404 NOTIFICATION_ERR("Failed to create app control:%d", ret);
1405 return NOTIFICATION_ERROR_IO_ERROR;
1408 NOTIFICATION_ERR("Failed to get execute option:%d", ret);
1412 return NOTIFICATION_ERROR_NONE;
1415 EXPORT_API int notification_set_execute_option(notification_h noti,
1416 notification_execute_type_e type,
1419 bundle *service_handle)
1421 char buf_key[32] = { 0, };
1422 const char *ret_val = NULL;
1426 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1429 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1430 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1431 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1434 /* Create execute option bundle if does not exist */
1435 if (noti->b_execute_option == NULL) {
1436 noti->b_execute_option = bundle_create();
1439 b = noti->b_execute_option;
1444 snprintf(buf_key, sizeof(buf_key), "text%d", type);
1446 /* Check text key exist */
1447 ret_val = bundle_get_val(b, buf_key);
1448 if (ret_val != NULL) {
1449 /* Remove previous data */
1450 bundle_del(b, buf_key);
1454 bundle_add(b, buf_key, text);
1460 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1462 /* Check key key exist */
1463 ret_val = bundle_get_val(b, buf_key);
1464 if (ret_val != NULL) {
1465 /* Remove previous data */
1466 bundle_del(b, buf_key);
1470 bundle_add(b, buf_key, key);
1473 switch ((int)type) {
1474 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1475 /* Remove previous data if exist */
1476 if (noti->b_service_responding != NULL) {
1477 bundle_free(noti->b_service_responding);
1478 noti->b_service_responding = NULL;
1481 /* Save service handle */
1482 if (service_handle != NULL) {
1483 noti->b_service_responding = bundle_dup(service_handle);
1486 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1487 /* Remove previous data if exist */
1488 if (noti->b_service_single_launch != NULL) {
1489 bundle_free(noti->b_service_single_launch);
1490 noti->b_service_single_launch = NULL;
1493 /* Save service handle */
1494 if (service_handle != NULL) {
1495 noti->b_service_single_launch =
1496 bundle_dup(service_handle);
1499 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1500 /* Remove previous data if exist */
1501 if (noti->b_service_multi_launch != NULL) {
1502 bundle_free(noti->b_service_multi_launch);
1503 noti->b_service_multi_launch = NULL;
1506 /* Save service handle */
1507 if (service_handle != NULL) {
1508 noti->b_service_multi_launch =
1509 bundle_dup(service_handle);
1514 return NOTIFICATION_ERROR_NONE;
1517 EXPORT_API int notification_get_execute_option(notification_h noti,
1518 notification_execute_type_e type,
1520 bundle **service_handle)
1522 char buf_key[32] = { 0, };
1523 const char *ret_val = NULL;
1524 char *get_str = NULL;
1528 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1531 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1532 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1533 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1537 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1538 b = noti->b_service_responding;
1540 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1541 b = noti->b_service_single_launch;
1543 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1544 b = noti->b_service_multi_launch;
1552 // Get text domain and dir
1553 if (noti->domain == NULL || noti->dir == NULL) {
1554 _notification_get_text_domain(noti);
1558 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1560 /* Check key key exist */
1561 ret_val = bundle_get_val(b, buf_key);
1562 if (ret_val != NULL && noti->domain != NULL
1563 && noti->dir != NULL) {
1564 /* Get application string */
1565 bindtextdomain(noti->domain, noti->dir);
1567 get_str = dgettext(noti->domain, ret_val);
1570 } else if (ret_val != NULL) {
1571 /* Get system string */
1572 get_str = dgettext("sys_string", ret_val);
1576 /* Get basic text */
1577 snprintf(buf_key, sizeof(buf_key), "text%d",
1580 ret_val = bundle_get_val(b, buf_key);
1587 if (service_handle != NULL) {
1588 *service_handle = b;
1591 return NOTIFICATION_ERROR_NONE;
1594 EXPORT_API int notification_set_property(notification_h noti,
1597 /* Check noti is valid data */
1599 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1603 noti->flags_for_property = flags;
1605 return NOTIFICATION_ERROR_NONE;
1608 EXPORT_API int notification_get_property(notification_h noti,
1611 /* Check noti and flags are valid data */
1612 if (noti == NULL || flags == NULL) {
1613 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1617 *flags = noti->flags_for_property;
1619 return NOTIFICATION_ERROR_NONE;
1622 EXPORT_API int notification_set_display_applist(notification_h noti,
1625 /* Check noti is valid data */
1627 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1631 noti->display_applist = applist;
1633 return NOTIFICATION_ERROR_NONE;
1636 EXPORT_API int notification_get_display_applist(notification_h noti,
1639 /* Check noti and applist are valid data */
1640 if (noti == NULL || applist == NULL) {
1641 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1645 *applist = noti->display_applist;
1647 return NOTIFICATION_ERROR_NONE;
1650 EXPORT_API int notification_set_size(notification_h noti,
1653 /* Check noti is valid data */
1655 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1658 /* Save progress size */
1659 noti->progress_size = size;
1661 return NOTIFICATION_ERROR_NONE;
1664 EXPORT_API int notification_get_size(notification_h noti,
1667 /* Check noti and size is valid data */
1668 if (noti == NULL || size == NULL) {
1669 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1672 /* Set progress size */
1673 *size = noti->progress_size;
1675 return NOTIFICATION_ERROR_NONE;
1678 EXPORT_API int notification_set_progress(notification_h noti,
1681 /* Check noti is valid data */
1683 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1686 /* Save progress percentage */
1687 noti->progress_percentage = percentage;
1689 return NOTIFICATION_ERROR_NONE;
1692 EXPORT_API int notification_get_progress(notification_h noti,
1695 /* Check noti and percentage are valid data */
1696 if (noti == NULL || percentage == NULL) {
1697 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1700 /* Set progress percentage */
1701 *percentage = noti->progress_percentage;
1703 return NOTIFICATION_ERROR_NONE;
1706 EXPORT_API int notification_set_pkgname(notification_h noti,
1707 const char *pkgname)
1709 /* check noti and pkgname are valid data */
1710 if (noti == NULL || pkgname == NULL) {
1711 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1714 /* Remove previous caller pkgname */
1715 if (noti->caller_pkgname) {
1716 free(noti->caller_pkgname);
1717 noti->caller_pkgname = NULL;
1720 noti->caller_pkgname = strdup(pkgname);
1722 return NOTIFICATION_ERROR_NONE;
1725 EXPORT_API int notification_get_pkgname(notification_h noti,
1728 /* Check noti and pkgname are valid data */
1729 if (noti == NULL || pkgname == NULL) {
1730 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1733 /* Get caller pkgname */
1734 if (noti->caller_pkgname) {
1735 *pkgname = noti->caller_pkgname;
1740 return NOTIFICATION_ERROR_NONE;
1743 EXPORT_API int notification_set_layout(notification_h noti,
1744 notification_ly_type_e layout)
1746 /* check noti and pkgname are valid data */
1747 if (noti == NULL || (layout < NOTIFICATION_LY_NONE || layout >= NOTIFICATION_LY_MAX)) {
1748 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1751 noti->layout = layout;
1753 return NOTIFICATION_ERROR_NONE;
1756 EXPORT_API int notification_get_layout(notification_h noti,
1757 notification_ly_type_e *layout)
1759 /* Check noti and pkgname are valid data */
1760 if (noti == NULL || layout == NULL) {
1761 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1764 *layout = noti->layout;
1766 return NOTIFICATION_ERROR_NONE;
1769 EXPORT_API int notification_get_id(notification_h noti,
1770 int *group_id, int *priv_id)
1772 /* check noti is valid data */
1774 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1777 /* Check group_id is valid data */
1780 if (noti->group_id < NOTIFICATION_GROUP_ID_NONE) {
1781 *group_id = NOTIFICATION_GROUP_ID_NONE;
1783 *group_id = noti->group_id;
1787 /* Check priv_id is valid data */
1790 *priv_id = noti->priv_id;
1793 return NOTIFICATION_ERROR_NONE;
1796 EXPORT_API int notification_get_type(notification_h noti,
1797 notification_type_e *type)
1799 /* Check noti and type is valid data */
1800 if (noti == NULL || type == NULL) {
1801 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1807 return NOTIFICATION_ERROR_NONE;
1810 EXPORT_API int notification_post(notification_h noti)
1815 /* Check noti is vaild data */
1817 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1820 /* Check noti type is valid type */
1821 if (noti->type <= NOTIFICATION_TYPE_NONE
1822 || noti->type >= NOTIFICATION_TYPE_MAX) {
1823 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1826 /* Save insert time */
1827 noti->insert_time = time(NULL);
1829 ret = notification_ipc_request_insert(noti, &id);
1830 if (ret != NOTIFICATION_ERROR_NONE) {
1834 NOTIFICATION_DBG("from master:%d", id);
1836 return NOTIFICATION_ERROR_NONE;
1839 EXPORT_API int notification_insert(notification_h noti,
1845 /* Check noti is vaild data */
1847 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1850 /* Check noti type is valid type */
1851 if (noti->type <= NOTIFICATION_TYPE_NONE
1852 || noti->type >= NOTIFICATION_TYPE_MAX) {
1853 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1856 /* Save insert time */
1857 noti->insert_time = time(NULL);
1858 ret = notification_ipc_request_insert(noti, &id);
1859 if (ret != NOTIFICATION_ERROR_NONE) {
1863 NOTIFICATION_DBG("from master:%d", id);
1865 /* If priv_id is valid data, set priv_id */
1866 if (priv_id != NULL) {
1867 *priv_id = noti->priv_id;
1870 return NOTIFICATION_ERROR_NONE;
1873 EXPORT_API int notification_update(notification_h noti)
1877 /* Check noti is valid data */
1879 /* Update insert time ? */
1880 noti->insert_time = time(NULL);
1881 ret = notification_ipc_request_update(noti);
1883 notification_ipc_request_refresh();
1884 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1889 EXPORT_API int notification_update_async(notification_h noti,
1890 void (*result_cb)(int priv_id, int result, void *data), void *user_data)
1895 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1898 /* Update insert time ? */
1899 noti->insert_time = time(NULL);
1900 ret = notification_ipc_request_update_async(noti, result_cb, user_data);
1905 EXPORT_API int notifiation_clear(notification_type_e type)
1909 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1910 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1913 ret = notification_ipc_request_delete_multiple(type, NULL);
1918 EXPORT_API int notification_clear(notification_type_e type)
1922 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1923 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1926 ret = notification_ipc_request_delete_multiple(type, NULL);
1931 EXPORT_API int notification_delete_all(notification_type_e type)
1934 char *caller_pkgname = NULL;
1936 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1937 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1940 caller_pkgname = _notification_get_pkgname_by_pid();
1942 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
1944 if (caller_pkgname) {
1945 free(caller_pkgname);
1951 EXPORT_API int notification_delete_all_by_type(const char *pkgname,
1952 notification_type_e type)
1955 char *caller_pkgname = NULL;
1957 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1958 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1961 if (pkgname == NULL) {
1962 caller_pkgname = _notification_get_pkgname_by_pid();
1964 caller_pkgname = strdup(pkgname);
1967 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
1969 if (caller_pkgname) {
1970 free(caller_pkgname);
1976 EXPORT_API int notification_delete_by_priv_id(const char *pkgname,
1977 notification_type_e type,
1981 char *caller_pkgname = NULL;
1983 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
1984 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1987 if (pkgname == NULL) {
1988 caller_pkgname = _notification_get_pkgname_by_pid();
1990 caller_pkgname = strdup(pkgname);
1993 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
1995 if (caller_pkgname) {
1996 free(caller_pkgname);
2002 EXPORT_API int notification_delete(notification_h noti)
2007 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2010 ret = notification_ipc_request_delete_single(NOTIFICATION_TYPE_NONE, noti->caller_pkgname, noti->priv_id);
2015 EXPORT_API int notification_update_progress(notification_h noti,
2019 char *caller_pkgname = NULL;
2020 int input_priv_id = 0;
2022 double input_progress = 0.0;
2024 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2026 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2028 input_priv_id = noti->priv_id;
2031 input_priv_id = priv_id;
2035 caller_pkgname = _notification_get_pkgname_by_pid();
2037 caller_pkgname = strdup(noti->caller_pkgname);
2040 if (progress < 0.0) {
2041 input_progress = 0.0;
2042 } else if (progress > 1.0) {
2043 input_progress = 1.0;
2045 input_progress = progress;
2048 ret = notification_ongoing_update_progress(caller_pkgname, input_priv_id,
2051 if (caller_pkgname) {
2052 free(caller_pkgname);
2058 EXPORT_API int notification_update_size(notification_h noti,
2062 char *caller_pkgname = NULL;
2063 int input_priv_id = 0;
2065 double input_size = 0.0;
2067 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2069 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2071 input_priv_id = noti->priv_id;
2074 input_priv_id = priv_id;
2078 caller_pkgname = _notification_get_pkgname_by_pid();
2080 caller_pkgname = strdup(noti->caller_pkgname);
2089 ret = notification_ongoing_update_size(caller_pkgname, input_priv_id,
2092 if (caller_pkgname) {
2093 free(caller_pkgname);
2099 EXPORT_API int notification_update_content(notification_h noti,
2101 const char *content)
2103 char *caller_pkgname = NULL;
2104 int input_priv_id = 0;
2107 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2109 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2111 input_priv_id = noti->priv_id;
2114 input_priv_id = priv_id;
2118 caller_pkgname = _notification_get_pkgname_by_pid();
2120 caller_pkgname = strdup(noti->caller_pkgname);
2123 ret = notification_ongoing_update_content(caller_pkgname, input_priv_id,
2126 if (caller_pkgname) {
2127 free(caller_pkgname);
2133 static notification_h _notification_create(notification_type_e type)
2135 notification_h noti = NULL;
2137 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
2138 NOTIFICATION_ERR("INVALID TYPE : %d", type);
2139 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
2143 noti = (notification_h) calloc(1, sizeof(struct _notification));
2145 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2146 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2152 if (type == NOTIFICATION_TYPE_NOTI)
2153 noti->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2154 else if (type == NOTIFICATION_TYPE_ONGOING)
2155 noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
2157 noti->caller_pkgname = _notification_get_pkgname_by_pid();
2158 noti->group_id = NOTIFICATION_GROUP_ID_NONE;
2159 noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
2160 noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
2161 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
2162 noti->led_operation = NOTIFICATION_LED_OP_OFF;
2163 noti->display_applist = NOTIFICATION_DISPLAY_APP_ALL;
2166 * Other fields are already initialized with ZERO.
2168 set_last_result(NOTIFICATION_ERROR_NONE);
2172 EXPORT_API notification_h notification_new(notification_type_e type,
2173 int group_id, int priv_id)
2175 return _notification_create(type);
2178 EXPORT_API notification_h notification_create(notification_type_e type)
2180 return _notification_create(type);
2183 EXPORT_API notification_h notification_load(char *pkgname,
2187 notification_h noti = NULL;
2189 noti = (notification_h) calloc(1, sizeof(struct _notification));
2191 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2195 ret = notification_noti_get_by_priv_id(noti, pkgname, priv_id);
2196 if (ret != NOTIFICATION_ERROR_NONE) {
2197 notification_free(noti);
2204 EXPORT_API notification_h notification_load_by_tag(const char *tag)
2207 notification_h noti = NULL;
2208 char *caller_pkgname = NULL;
2211 NOTIFICATION_ERR("Invalid parameter");
2212 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
2216 caller_pkgname = _notification_get_pkgname_by_pid();
2217 if (!caller_pkgname) {
2218 NOTIFICATION_ERR("Failed to get a package name");
2219 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2224 noti = (notification_h) calloc(1, sizeof(struct _notification));
2226 NOTIFICATION_ERR("Failed to alloc a new notification");
2227 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2228 free(caller_pkgname);
2233 ret = notification_ipc_request_load_noti_by_tag(noti, caller_pkgname, tag);
2235 free(caller_pkgname);
2237 set_last_result(ret);
2239 if (ret != NOTIFICATION_ERROR_NONE) {
2240 notification_free(noti);
2247 EXPORT_API int notification_clone(notification_h noti, notification_h *clone)
2249 notification_h new_noti = NULL;
2251 if (noti == NULL || clone == NULL) {
2252 NOTIFICATION_ERR("INVALID PARAMETER.");
2253 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2256 new_noti = (notification_h) calloc(1, sizeof(struct _notification));
2257 if (new_noti == NULL) {
2258 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2259 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
2262 new_noti->type = noti->type;
2263 new_noti->layout = noti->layout;
2265 new_noti->group_id = noti->group_id;
2266 new_noti->internal_group_id = noti->internal_group_id;
2267 new_noti->priv_id = noti->priv_id;
2269 if(noti->caller_pkgname != NULL) {
2270 new_noti->caller_pkgname = strdup(noti->caller_pkgname);
2272 new_noti->caller_pkgname = _notification_get_pkgname_by_pid();
2274 if(noti->launch_pkgname != NULL) {
2275 new_noti->launch_pkgname = strdup(noti->launch_pkgname);
2277 new_noti->launch_pkgname = NULL;
2280 if(noti->args != NULL) {
2281 new_noti->args = bundle_dup(noti->args);
2283 new_noti->args = NULL;
2285 if(noti->group_args != NULL) {
2286 new_noti->group_args = bundle_dup(noti->group_args);
2288 new_noti->group_args = NULL;
2291 if(noti->b_execute_option != NULL) {
2292 new_noti->b_execute_option = bundle_dup(noti->b_execute_option);
2294 new_noti->b_execute_option = NULL;
2296 if(noti->b_service_responding != NULL) {
2297 new_noti->b_service_responding = bundle_dup(noti->b_service_responding);
2299 new_noti->b_service_responding = NULL;
2301 if(noti->b_service_single_launch != NULL) {
2302 new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch);
2304 new_noti->b_service_single_launch = NULL;
2306 if(noti->b_service_multi_launch != NULL) {
2307 new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch);
2309 new_noti->b_service_multi_launch = NULL;
2312 new_noti->sound_type = noti->sound_type;
2313 if(noti->sound_path != NULL) {
2314 new_noti->sound_path = strdup(noti->sound_path);
2316 new_noti->sound_path = NULL;
2318 new_noti->vibration_type = noti->vibration_type;
2319 if(noti->vibration_path != NULL) {
2320 new_noti->vibration_path = strdup(noti->vibration_path);
2322 new_noti->vibration_path = NULL;
2324 new_noti->led_operation = noti->led_operation;
2325 new_noti->led_argb = noti->led_argb;
2326 new_noti->led_on_ms = noti->led_on_ms;
2327 new_noti->led_off_ms = noti->led_off_ms;
2329 if(noti->domain != NULL) {
2330 new_noti->domain = strdup(noti->domain);
2332 new_noti->domain = NULL;
2334 if(noti->dir != NULL) {
2335 new_noti->dir = strdup(noti->dir);
2337 new_noti->dir = NULL;
2340 if(noti->b_text != NULL) {
2341 new_noti->b_text = bundle_dup(noti->b_text);
2343 new_noti->b_text = NULL;
2345 if(noti->b_key != NULL) {
2346 new_noti->b_key = bundle_dup(noti->b_key);
2348 new_noti->b_key = NULL;
2350 if(noti->b_format_args != NULL) {
2351 new_noti->b_format_args = bundle_dup(noti->b_format_args);
2353 new_noti->b_format_args = NULL;
2355 new_noti->num_format_args = noti->num_format_args;
2357 if(noti->b_image_path != NULL) {
2358 new_noti->b_image_path = bundle_dup(noti->b_image_path);
2360 new_noti->b_image_path = NULL;
2363 new_noti->time = noti->time;
2364 new_noti->insert_time = noti->insert_time;
2366 new_noti->flags_for_property = noti->flags_for_property;
2367 new_noti->display_applist = noti->display_applist;
2369 new_noti->progress_size = noti->progress_size;
2370 new_noti->progress_percentage = noti->progress_percentage;
2372 new_noti->app_icon_path = NULL;
2373 new_noti->app_name = NULL;
2374 new_noti->temp_title = NULL;
2375 new_noti->temp_content = NULL;
2379 return NOTIFICATION_ERROR_NONE;
2383 EXPORT_API int notification_free(notification_h noti)
2386 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2389 if (noti->caller_pkgname) {
2390 free(noti->caller_pkgname);
2392 if (noti->launch_pkgname) {
2393 free(noti->launch_pkgname);
2396 bundle_free(noti->args);
2398 if (noti->group_args) {
2399 bundle_free(noti->group_args);
2402 if (noti->b_execute_option) {
2403 bundle_free(noti->b_execute_option);
2405 if (noti->b_service_responding) {
2406 bundle_free(noti->b_service_responding);
2408 if (noti->b_service_single_launch) {
2409 bundle_free(noti->b_service_single_launch);
2411 if (noti->b_service_multi_launch) {
2412 bundle_free(noti->b_service_multi_launch);
2415 if (noti->sound_path) {
2416 free(noti->sound_path);
2418 if (noti->vibration_path) {
2419 free(noti->vibration_path);
2430 bundle_free(noti->b_text);
2433 bundle_free(noti->b_key);
2435 if (noti->b_format_args) {
2436 bundle_free(noti->b_format_args);
2439 if (noti->b_image_path) {
2440 bundle_free(noti->b_image_path);
2443 if (noti->app_icon_path) {
2444 free(noti->app_icon_path);
2446 if (noti->app_name) {
2447 free(noti->app_name);
2449 if (noti->temp_title) {
2450 free(noti->temp_title);
2452 if (noti->temp_content) {
2453 free(noti->temp_content);
2462 return NOTIFICATION_ERROR_NONE;
2466 notification_resister_changed_cb(void (*changed_cb)
2467 (void *data, notification_type_e type),
2470 notification_cb_list_s *noti_cb_list_new = NULL;
2471 notification_cb_list_s *noti_cb_list = NULL;
2473 if (changed_cb == NULL) {
2474 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2476 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
2477 return NOTIFICATION_ERROR_IO_ERROR;
2481 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
2483 noti_cb_list_new->next = NULL;
2484 noti_cb_list_new->prev = NULL;
2486 noti_cb_list_new->cb_type = NOTIFICATION_CB_NORMAL;
2487 noti_cb_list_new->changed_cb = changed_cb;
2488 noti_cb_list_new->detailed_changed_cb = NULL;
2489 noti_cb_list_new->data = user_data;
2491 if (g_notification_cb_list == NULL) {
2492 g_notification_cb_list = noti_cb_list_new;
2494 noti_cb_list = g_notification_cb_list;
2496 while (noti_cb_list->next != NULL) {
2497 noti_cb_list = noti_cb_list->next;
2500 noti_cb_list->next = noti_cb_list_new;
2501 noti_cb_list_new->prev = noti_cb_list;
2503 return NOTIFICATION_ERROR_NONE;
2507 notification_unresister_changed_cb(void (*changed_cb)
2508 (void *data, notification_type_e type))
2510 notification_cb_list_s *noti_cb_list = NULL;
2511 notification_cb_list_s *noti_cb_list_prev = NULL;
2512 notification_cb_list_s *noti_cb_list_next = NULL;
2514 noti_cb_list = g_notification_cb_list;
2516 if (changed_cb == NULL) {
2517 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2519 if (noti_cb_list == NULL) {
2520 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2523 while (noti_cb_list->prev != NULL) {
2524 noti_cb_list = noti_cb_list->prev;
2528 if (noti_cb_list->changed_cb == changed_cb) {
2529 noti_cb_list_prev = noti_cb_list->prev;
2530 noti_cb_list_next = noti_cb_list->next;
2532 if (noti_cb_list_prev == NULL) {
2533 g_notification_cb_list = noti_cb_list_next;
2535 noti_cb_list_prev->next = noti_cb_list_next;
2538 if (noti_cb_list_next == NULL) {
2539 if (noti_cb_list_prev != NULL) {
2540 noti_cb_list_prev->next = NULL;
2543 noti_cb_list_next->prev = noti_cb_list_prev;
2548 if (g_notification_cb_list == NULL)
2549 notification_ipc_monitor_fini();
2551 return NOTIFICATION_ERROR_NONE;
2553 noti_cb_list = noti_cb_list->next;
2554 } while (noti_cb_list != NULL);
2556 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2560 notification_register_detailed_changed_cb(
2561 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
2564 notification_cb_list_s *noti_cb_list_new = NULL;
2565 notification_cb_list_s *noti_cb_list = NULL;
2567 if (detailed_changed_cb == NULL) {
2568 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2570 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
2571 return NOTIFICATION_ERROR_IO_ERROR;
2575 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
2577 noti_cb_list_new->next = NULL;
2578 noti_cb_list_new->prev = NULL;
2580 noti_cb_list_new->cb_type = NOTIFICATION_CB_DETAILED;
2581 noti_cb_list_new->changed_cb = NULL;
2582 noti_cb_list_new->detailed_changed_cb = detailed_changed_cb;
2583 noti_cb_list_new->data = user_data;
2585 if (g_notification_cb_list == NULL) {
2586 g_notification_cb_list = noti_cb_list_new;
2588 noti_cb_list = g_notification_cb_list;
2590 while (noti_cb_list->next != NULL) {
2591 noti_cb_list = noti_cb_list->next;
2594 noti_cb_list->next = noti_cb_list_new;
2595 noti_cb_list_new->prev = noti_cb_list;
2597 return NOTIFICATION_ERROR_NONE;
2601 notification_unregister_detailed_changed_cb(
2602 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
2605 notification_cb_list_s *noti_cb_list = NULL;
2606 notification_cb_list_s *noti_cb_list_prev = NULL;
2607 notification_cb_list_s *noti_cb_list_next = NULL;
2609 noti_cb_list = g_notification_cb_list;
2611 if (detailed_changed_cb == NULL) {
2612 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2614 if (noti_cb_list == NULL) {
2615 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2618 while (noti_cb_list->prev != NULL) {
2619 noti_cb_list = noti_cb_list->prev;
2623 if (noti_cb_list->detailed_changed_cb == detailed_changed_cb) {
2624 noti_cb_list_prev = noti_cb_list->prev;
2625 noti_cb_list_next = noti_cb_list->next;
2627 if (noti_cb_list_prev == NULL) {
2628 g_notification_cb_list = noti_cb_list_next;
2630 noti_cb_list_prev->next = noti_cb_list_next;
2633 if (noti_cb_list_next == NULL) {
2634 if (noti_cb_list_prev != NULL) {
2635 noti_cb_list_prev->next = NULL;
2638 noti_cb_list_next->prev = noti_cb_list_prev;
2643 if (g_notification_cb_list == NULL)
2644 notification_ipc_monitor_fini();
2646 return NOTIFICATION_ERROR_NONE;
2648 noti_cb_list = noti_cb_list->next;
2649 } while (noti_cb_list != NULL);
2651 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2654 EXPORT_API int notification_get_count(notification_type_e type,
2655 const char *pkgname,
2657 int priv_id, int *count)
2662 if (count == NULL) {
2663 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2667 notification_noti_get_count(type, pkgname, group_id, priv_id,
2669 if (ret != NOTIFICATION_ERROR_NONE) {
2673 *count = noti_count;
2675 return NOTIFICATION_ERROR_NONE;
2678 EXPORT_API int notification_get_list(notification_type_e type,
2680 notification_list_h *list)
2682 notification_list_h get_list = NULL;
2686 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2689 ret = notification_noti_get_grouping_list(type, count, &get_list);
2690 if (ret != NOTIFICATION_ERROR_NONE) {
2696 return NOTIFICATION_ERROR_NONE;
2700 notification_get_grouping_list(notification_type_e type, int count,
2701 notification_list_h * list)
2703 notification_list_h get_list = NULL;
2707 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2710 ret = notification_noti_get_grouping_list(type, count, &get_list);
2711 if (ret != NOTIFICATION_ERROR_NONE) {
2717 return NOTIFICATION_ERROR_NONE;
2720 EXPORT_API int notification_get_detail_list(const char *pkgname,
2724 notification_list_h *list)
2726 notification_list_h get_list = NULL;
2730 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2734 notification_noti_get_detail_list(pkgname, group_id, priv_id, count,
2736 if (ret != NOTIFICATION_ERROR_NONE) {
2742 return NOTIFICATION_ERROR_NONE;
2745 EXPORT_API int notification_free_list(notification_list_h list)
2747 notification_list_h cur_list = NULL;
2748 notification_h noti = NULL;
2751 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2754 cur_list = notification_list_get_head(list);
2756 while (cur_list != NULL) {
2757 noti = notification_list_get_data(cur_list);
2758 cur_list = notification_list_remove(cur_list, noti);
2760 notification_free(noti);
2763 return NOTIFICATION_ERROR_NONE;
2766 EXPORT_API int notification_op_get_data(notification_op *noti_op, notification_op_data_type_e type,
2769 if (noti_op == NULL || data == NULL) {
2770 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2774 case NOTIFICATION_OP_DATA_TYPE:
2775 *((int*)data) = noti_op->type;
2777 case NOTIFICATION_OP_DATA_PRIV_ID:
2778 *((int*)data) = noti_op->priv_id;
2780 case NOTIFICATION_OP_DATA_NOTI:
2781 *((notification_h *)data) = noti_op->noti;
2783 case NOTIFICATION_OP_DATA_EXTRA_INFO_1:
2784 *((int*)data) = noti_op->extra_info_1;
2786 case NOTIFICATION_OP_DATA_EXTRA_INFO_2:
2787 *((int*)data) = noti_op->extra_info_2;
2790 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2794 return NOTIFICATION_ERROR_NONE;
2797 void notification_call_changed_cb(notification_op *op_list, int op_num)
2799 notification_cb_list_s *noti_cb_list = NULL;
2800 notification_type_e type = 0;
2802 if (g_notification_cb_list == NULL) {
2805 noti_cb_list = g_notification_cb_list;
2807 while (noti_cb_list->prev != NULL) {
2808 noti_cb_list = noti_cb_list->prev;
2811 if (op_list == NULL) {
2812 NOTIFICATION_ERR("invalid data");
2816 notification_get_type(op_list->noti, &type);
2818 while (noti_cb_list != NULL) {
2819 if (noti_cb_list->cb_type == NOTIFICATION_CB_NORMAL && noti_cb_list->changed_cb) {
2820 noti_cb_list->changed_cb(noti_cb_list->data,
2823 if (noti_cb_list->cb_type == NOTIFICATION_CB_DETAILED && noti_cb_list->detailed_changed_cb) {
2824 noti_cb_list->detailed_changed_cb(noti_cb_list->data,
2825 type, op_list, op_num);
2828 noti_cb_list = noti_cb_list->next;
2832 EXPORT_API int notification_is_service_ready(void)
2834 return notification_ipc_is_master_ready();
2838 notification_add_deferred_task(
2839 void (*deferred_task_cb)(void *data), void *user_data)
2841 if (deferred_task_cb == NULL) {
2842 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2845 return notification_ipc_add_deffered_task(deferred_task_cb, user_data);
2849 notification_del_deferred_task(
2850 void (*deferred_task_cb)(void *data))
2852 if (deferred_task_cb == NULL) {
2853 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2856 return notification_ipc_del_deffered_task(deferred_task_cb);
2859 /* notification_set_icon will be removed */
2860 EXPORT_API int notification_set_icon(notification_h noti,
2861 const char *icon_path)
2863 int ret_err = NOTIFICATION_ERROR_NONE;
2866 notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
2872 /* notification_get_icon will be removed */
2873 EXPORT_API int notification_get_icon(notification_h noti,
2876 int ret_err = NOTIFICATION_ERROR_NONE;
2877 char *ret_image_path = NULL;
2880 notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
2883 if (ret_err == NOTIFICATION_ERROR_NONE && icon_path != NULL) {
2884 *icon_path = ret_image_path;
2886 //NOTIFICATION_DBG("Get icon : %s", *icon_path);
2892 EXPORT_API int notification_set_title(notification_h noti,
2894 const char *loc_title)
2896 int noti_err = NOTIFICATION_ERROR_NONE;
2898 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
2900 NOTIFICATION_VARIABLE_TYPE_NONE);
2905 EXPORT_API int notification_get_title(notification_h noti,
2909 int noti_err = NOTIFICATION_ERROR_NONE;
2910 char *ret_text = NULL;
2913 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
2916 if (title != NULL) {
2920 if (loc_title != NULL) {
2927 EXPORT_API int notification_set_content(notification_h noti,
2928 const char *content,
2929 const char *loc_content)
2931 int noti_err = NOTIFICATION_ERROR_NONE;
2933 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
2934 content, loc_content,
2935 NOTIFICATION_VARIABLE_TYPE_NONE);
2940 EXPORT_API int notification_get_content(notification_h noti,
2944 int noti_err = NOTIFICATION_ERROR_NONE;
2945 char *ret_text = NULL;
2948 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
2951 if (content != NULL) {
2952 *content = ret_text;
2955 if (loc_content != NULL) {
2956 *loc_content = NULL;
2964 (VCONFKEY_SETAPPL_STATE_TICKER_NOTI_DISPLAY_CONTENT_BOOL, &boolval);
2966 if (ret == -1 || boolval == 0) {
2967 if (content != NULL && noti->default_content != NULL) {
2968 *content = noti->default_content;
2971 if (loc_content != NULL && noti->loc_default_content != NULL) {
2972 *loc_content = noti->loc_default_content;
2978 EXPORT_API int notification_set_args(notification_h noti,
2980 bundle * group_args)
2982 if (noti == NULL || args == NULL) {
2983 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2987 bundle_free(noti->args);
2990 noti->args = bundle_dup(args);
2992 if (noti->group_args) {
2993 bundle_free(noti->group_args);
2994 noti->group_args = NULL;
2997 if (group_args != NULL) {
2998 noti->group_args = bundle_dup(group_args);
3001 return NOTIFICATION_ERROR_NONE;
3004 EXPORT_API int notification_get_args(notification_h noti,
3006 bundle ** group_args)
3008 if (noti == NULL || args == NULL) {
3009 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3018 if (group_args != NULL && noti->group_args) {
3019 *group_args = noti->group_args;
3022 return NOTIFICATION_ERROR_NONE;
3025 EXPORT_API int notification_delete_group_by_group_id(const char *pkgname,
3026 notification_type_e type,
3030 char *caller_pkgname = NULL;
3032 if (pkgname == NULL) {
3033 caller_pkgname = _notification_get_pkgname_by_pid();
3035 caller_pkgname = strdup(pkgname);
3038 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
3039 if (ret != NOTIFICATION_ERROR_NONE) {
3040 if (caller_pkgname) {
3041 free(caller_pkgname);
3046 if (caller_pkgname) {
3047 free(caller_pkgname);
3049 return NOTIFICATION_ERROR_NONE;
3052 EXPORT_API int notification_delete_group_by_priv_id(const char *pkgname,
3053 notification_type_e type,
3057 char *caller_pkgname = NULL;
3059 if (pkgname == NULL) {
3060 caller_pkgname = _notification_get_pkgname_by_pid();
3062 caller_pkgname = strdup(pkgname);
3065 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
3066 if (ret != NOTIFICATION_ERROR_NONE) {
3067 if (caller_pkgname) {
3068 free(caller_pkgname);
3073 if (caller_pkgname) {
3074 free(caller_pkgname);
3076 return NOTIFICATION_ERROR_NONE;
3079 EXPORT_API int notification_set_tag(notification_h noti, const char *tag)
3081 /* Check noti is valid data */
3083 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3087 /* save input TAG */
3088 if (noti->tag != NULL) {
3091 noti->tag = strdup(tag);
3094 return NOTIFICATION_ERROR_NONE;
3098 EXPORT_API int notification_get_tag(notification_h noti, const char **tag)
3100 /* Check noti is valid data */
3102 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3105 /* Set sound type */
3107 return NOTIFICATION_ERROR_NONE;
3110 EXPORT_API int notification_register_toast_message(void (*posted_toast_cb) (void *data))
3112 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
3113 return NOTIFICATION_ERROR_IO_ERROR;
3116 posted_toast_message_cb = posted_toast_cb;
3118 return NOTIFICATION_ERROR_NONE;
3121 void notification_call_posted_toast_cb(const char *message)
3123 if (posted_toast_message_cb != NULL) {
3124 posted_toast_message_cb(message);