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: %s\n", strerror(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_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h event_handler)
1417 return NOTIFICATION_ERROR_NOT_SUPPORTED;
1420 EXPORT_API int notification_get_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h *event_handler)
1422 return NOTIFICATION_ERROR_NOT_SUPPORTED;
1425 EXPORT_API int notification_set_execute_option(notification_h noti,
1426 notification_execute_type_e type,
1429 bundle *service_handle)
1431 char buf_key[32] = { 0, };
1432 const char *ret_val = NULL;
1436 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1439 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1440 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1441 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1444 /* Create execute option bundle if does not exist */
1445 if (noti->b_execute_option == NULL) {
1446 noti->b_execute_option = bundle_create();
1449 b = noti->b_execute_option;
1454 snprintf(buf_key, sizeof(buf_key), "text%d", type);
1456 /* Check text key exist */
1457 ret_val = bundle_get_val(b, buf_key);
1458 if (ret_val != NULL) {
1459 /* Remove previous data */
1460 bundle_del(b, buf_key);
1464 bundle_add(b, buf_key, text);
1470 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1472 /* Check key key exist */
1473 ret_val = bundle_get_val(b, buf_key);
1474 if (ret_val != NULL) {
1475 /* Remove previous data */
1476 bundle_del(b, buf_key);
1480 bundle_add(b, buf_key, key);
1483 switch ((int)type) {
1484 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1485 /* Remove previous data if exist */
1486 if (noti->b_service_responding != NULL) {
1487 bundle_free(noti->b_service_responding);
1488 noti->b_service_responding = NULL;
1491 /* Save service handle */
1492 if (service_handle != NULL) {
1493 noti->b_service_responding = bundle_dup(service_handle);
1496 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1497 /* Remove previous data if exist */
1498 if (noti->b_service_single_launch != NULL) {
1499 bundle_free(noti->b_service_single_launch);
1500 noti->b_service_single_launch = NULL;
1503 /* Save service handle */
1504 if (service_handle != NULL) {
1505 noti->b_service_single_launch =
1506 bundle_dup(service_handle);
1509 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1510 /* Remove previous data if exist */
1511 if (noti->b_service_multi_launch != NULL) {
1512 bundle_free(noti->b_service_multi_launch);
1513 noti->b_service_multi_launch = NULL;
1516 /* Save service handle */
1517 if (service_handle != NULL) {
1518 noti->b_service_multi_launch =
1519 bundle_dup(service_handle);
1524 return NOTIFICATION_ERROR_NONE;
1527 EXPORT_API int notification_get_execute_option(notification_h noti,
1528 notification_execute_type_e type,
1530 bundle **service_handle)
1532 char buf_key[32] = { 0, };
1533 const char *ret_val = NULL;
1534 char *get_str = NULL;
1538 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1541 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1542 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1543 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1547 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1548 b = noti->b_service_responding;
1550 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1551 b = noti->b_service_single_launch;
1553 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1554 b = noti->b_service_multi_launch;
1562 // Get text domain and dir
1563 if (noti->domain == NULL || noti->dir == NULL) {
1564 _notification_get_text_domain(noti);
1568 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1570 /* Check key key exist */
1571 ret_val = bundle_get_val(b, buf_key);
1572 if (ret_val != NULL && noti->domain != NULL
1573 && noti->dir != NULL) {
1574 /* Get application string */
1575 bindtextdomain(noti->domain, noti->dir);
1577 get_str = dgettext(noti->domain, ret_val);
1580 } else if (ret_val != NULL) {
1581 /* Get system string */
1582 get_str = dgettext("sys_string", ret_val);
1586 /* Get basic text */
1587 snprintf(buf_key, sizeof(buf_key), "text%d",
1590 ret_val = bundle_get_val(b, buf_key);
1597 if (service_handle != NULL) {
1598 *service_handle = b;
1601 return NOTIFICATION_ERROR_NONE;
1604 EXPORT_API int notification_set_property(notification_h noti,
1607 /* Check noti is valid data */
1609 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1613 noti->flags_for_property = flags;
1615 return NOTIFICATION_ERROR_NONE;
1618 EXPORT_API int notification_get_property(notification_h noti,
1621 /* Check noti and flags are valid data */
1622 if (noti == NULL || flags == NULL) {
1623 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1627 *flags = noti->flags_for_property;
1629 return NOTIFICATION_ERROR_NONE;
1632 EXPORT_API int notification_set_display_applist(notification_h noti,
1635 /* Check noti is valid data */
1637 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1641 noti->display_applist = applist;
1643 return NOTIFICATION_ERROR_NONE;
1646 EXPORT_API int notification_get_display_applist(notification_h noti,
1649 /* Check noti and applist are valid data */
1650 if (noti == NULL || applist == NULL) {
1651 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1655 *applist = noti->display_applist;
1657 return NOTIFICATION_ERROR_NONE;
1660 EXPORT_API int notification_set_size(notification_h noti,
1663 /* Check noti is valid data */
1665 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1668 /* Save progress size */
1669 noti->progress_size = size;
1671 return NOTIFICATION_ERROR_NONE;
1674 EXPORT_API int notification_get_size(notification_h noti,
1677 /* Check noti and size is valid data */
1678 if (noti == NULL || size == NULL) {
1679 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1682 /* Set progress size */
1683 *size = noti->progress_size;
1685 return NOTIFICATION_ERROR_NONE;
1688 EXPORT_API int notification_set_progress(notification_h noti,
1691 /* Check noti is valid data */
1693 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1696 /* Save progress percentage */
1697 noti->progress_percentage = percentage;
1699 return NOTIFICATION_ERROR_NONE;
1702 EXPORT_API int notification_get_progress(notification_h noti,
1705 /* Check noti and percentage are valid data */
1706 if (noti == NULL || percentage == NULL) {
1707 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1710 /* Set progress percentage */
1711 *percentage = noti->progress_percentage;
1713 return NOTIFICATION_ERROR_NONE;
1716 EXPORT_API int notification_set_pkgname(notification_h noti,
1717 const char *pkgname)
1719 /* check noti and pkgname are valid data */
1720 if (noti == NULL || pkgname == NULL) {
1721 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1724 /* Remove previous caller pkgname */
1725 if (noti->caller_pkgname) {
1726 free(noti->caller_pkgname);
1727 noti->caller_pkgname = NULL;
1730 noti->caller_pkgname = strdup(pkgname);
1732 return NOTIFICATION_ERROR_NONE;
1735 EXPORT_API int notification_get_pkgname(notification_h noti,
1738 /* Check noti and pkgname are valid data */
1739 if (noti == NULL || pkgname == NULL) {
1740 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1743 /* Get caller pkgname */
1744 if (noti->caller_pkgname) {
1745 *pkgname = noti->caller_pkgname;
1750 return NOTIFICATION_ERROR_NONE;
1753 EXPORT_API int notification_set_layout(notification_h noti,
1754 notification_ly_type_e layout)
1756 /* check noti and pkgname are valid data */
1757 if (noti == NULL || (layout < NOTIFICATION_LY_NONE || layout >= NOTIFICATION_LY_MAX)) {
1758 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1761 noti->layout = layout;
1763 return NOTIFICATION_ERROR_NONE;
1766 EXPORT_API int notification_get_layout(notification_h noti,
1767 notification_ly_type_e *layout)
1769 /* Check noti and pkgname are valid data */
1770 if (noti == NULL || layout == NULL) {
1771 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1774 *layout = noti->layout;
1776 return NOTIFICATION_ERROR_NONE;
1779 EXPORT_API int notification_get_id(notification_h noti,
1780 int *group_id, int *priv_id)
1782 /* check noti is valid data */
1784 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1787 /* Check group_id is valid data */
1790 if (noti->group_id < NOTIFICATION_GROUP_ID_NONE) {
1791 *group_id = NOTIFICATION_GROUP_ID_NONE;
1793 *group_id = noti->group_id;
1797 /* Check priv_id is valid data */
1800 *priv_id = noti->priv_id;
1803 return NOTIFICATION_ERROR_NONE;
1806 EXPORT_API int notification_get_type(notification_h noti,
1807 notification_type_e *type)
1809 /* Check noti and type is valid data */
1810 if (noti == NULL || type == NULL) {
1811 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1817 return NOTIFICATION_ERROR_NONE;
1820 EXPORT_API int notification_post(notification_h noti)
1825 /* Check noti is vaild data */
1827 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1830 /* Check noti type is valid type */
1831 if (noti->type <= NOTIFICATION_TYPE_NONE
1832 || noti->type >= NOTIFICATION_TYPE_MAX) {
1833 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1836 /* Save insert time */
1837 noti->insert_time = time(NULL);
1839 ret = notification_ipc_request_insert(noti, &id);
1840 if (ret != NOTIFICATION_ERROR_NONE) {
1844 NOTIFICATION_DBG("from master:%d", id);
1846 return NOTIFICATION_ERROR_NONE;
1849 EXPORT_API int notification_insert(notification_h noti,
1855 /* Check noti is vaild data */
1857 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1860 /* Check noti type is valid type */
1861 if (noti->type <= NOTIFICATION_TYPE_NONE
1862 || noti->type >= NOTIFICATION_TYPE_MAX) {
1863 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1866 /* Save insert time */
1867 noti->insert_time = time(NULL);
1868 ret = notification_ipc_request_insert(noti, &id);
1869 if (ret != NOTIFICATION_ERROR_NONE) {
1873 NOTIFICATION_DBG("from master:%d", id);
1875 /* If priv_id is valid data, set priv_id */
1876 if (priv_id != NULL) {
1877 *priv_id = noti->priv_id;
1880 return NOTIFICATION_ERROR_NONE;
1883 EXPORT_API int notification_update(notification_h noti)
1887 /* Check noti is valid data */
1889 /* Update insert time ? */
1890 noti->insert_time = time(NULL);
1891 ret = notification_ipc_request_update(noti);
1893 notification_ipc_request_refresh();
1894 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1899 EXPORT_API int notification_update_async(notification_h noti,
1900 void (*result_cb)(int priv_id, int result, void *data), void *user_data)
1905 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1908 /* Update insert time ? */
1909 noti->insert_time = time(NULL);
1910 ret = notification_ipc_request_update_async(noti, result_cb, user_data);
1915 EXPORT_API int notifiation_clear(notification_type_e type)
1919 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1920 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1923 ret = notification_ipc_request_delete_multiple(type, NULL);
1928 EXPORT_API int notification_clear(notification_type_e type)
1932 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1933 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1936 ret = notification_ipc_request_delete_multiple(type, NULL);
1941 EXPORT_API int notification_delete_all(notification_type_e type)
1944 char *caller_pkgname = NULL;
1946 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1947 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1950 caller_pkgname = _notification_get_pkgname_by_pid();
1952 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
1954 if (caller_pkgname) {
1955 free(caller_pkgname);
1961 EXPORT_API int notification_delete_all_by_type(const char *pkgname,
1962 notification_type_e type)
1965 char *caller_pkgname = NULL;
1967 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1968 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1971 if (pkgname == NULL) {
1972 caller_pkgname = _notification_get_pkgname_by_pid();
1974 caller_pkgname = strdup(pkgname);
1977 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
1979 if (caller_pkgname) {
1980 free(caller_pkgname);
1986 EXPORT_API int notification_delete_by_priv_id(const char *pkgname,
1987 notification_type_e type,
1991 char *caller_pkgname = NULL;
1993 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
1994 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1997 if (pkgname == NULL) {
1998 caller_pkgname = _notification_get_pkgname_by_pid();
2000 caller_pkgname = strdup(pkgname);
2003 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
2005 if (caller_pkgname) {
2006 free(caller_pkgname);
2012 EXPORT_API int notification_delete(notification_h noti)
2017 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2020 ret = notification_ipc_request_delete_single(NOTIFICATION_TYPE_NONE, noti->caller_pkgname, noti->priv_id);
2025 EXPORT_API int notification_update_progress(notification_h noti,
2029 char *caller_pkgname = NULL;
2030 int input_priv_id = 0;
2032 double input_progress = 0.0;
2034 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2036 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2038 input_priv_id = noti->priv_id;
2041 input_priv_id = priv_id;
2045 caller_pkgname = _notification_get_pkgname_by_pid();
2047 caller_pkgname = strdup(noti->caller_pkgname);
2050 if (progress < 0.0) {
2051 input_progress = 0.0;
2052 } else if (progress > 1.0) {
2053 input_progress = 1.0;
2055 input_progress = progress;
2058 ret = notification_ongoing_update_progress(caller_pkgname, input_priv_id,
2061 if (caller_pkgname) {
2062 free(caller_pkgname);
2068 EXPORT_API int notification_update_size(notification_h noti,
2072 char *caller_pkgname = NULL;
2073 int input_priv_id = 0;
2075 double input_size = 0.0;
2077 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2079 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2081 input_priv_id = noti->priv_id;
2084 input_priv_id = priv_id;
2088 caller_pkgname = _notification_get_pkgname_by_pid();
2090 caller_pkgname = strdup(noti->caller_pkgname);
2099 ret = notification_ongoing_update_size(caller_pkgname, input_priv_id,
2102 if (caller_pkgname) {
2103 free(caller_pkgname);
2109 EXPORT_API int notification_update_content(notification_h noti,
2111 const char *content)
2113 char *caller_pkgname = NULL;
2114 int input_priv_id = 0;
2117 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2119 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2121 input_priv_id = noti->priv_id;
2124 input_priv_id = priv_id;
2128 caller_pkgname = _notification_get_pkgname_by_pid();
2130 caller_pkgname = strdup(noti->caller_pkgname);
2133 ret = notification_ongoing_update_content(caller_pkgname, input_priv_id,
2136 if (caller_pkgname) {
2137 free(caller_pkgname);
2143 static notification_h _notification_create(notification_type_e type)
2145 notification_h noti = NULL;
2147 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
2148 NOTIFICATION_ERR("INVALID TYPE : %d", type);
2149 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
2153 noti = (notification_h) calloc(1, sizeof(struct _notification));
2155 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2156 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2162 if (type == NOTIFICATION_TYPE_NOTI)
2163 noti->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2164 else if (type == NOTIFICATION_TYPE_ONGOING)
2165 noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
2167 noti->caller_pkgname = _notification_get_pkgname_by_pid();
2168 noti->group_id = NOTIFICATION_GROUP_ID_NONE;
2169 noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
2170 noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
2171 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
2172 noti->led_operation = NOTIFICATION_LED_OP_OFF;
2173 noti->display_applist = NOTIFICATION_DISPLAY_APP_ALL;
2176 * Other fields are already initialized with ZERO.
2178 set_last_result(NOTIFICATION_ERROR_NONE);
2182 EXPORT_API notification_h notification_new(notification_type_e type,
2183 int group_id, int priv_id)
2185 return _notification_create(type);
2188 EXPORT_API notification_h notification_create(notification_type_e type)
2190 return _notification_create(type);
2193 EXPORT_API notification_h notification_load(char *pkgname,
2197 notification_h noti = NULL;
2199 noti = (notification_h) calloc(1, sizeof(struct _notification));
2201 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2205 ret = notification_noti_get_by_priv_id(noti, pkgname, priv_id);
2206 if (ret != NOTIFICATION_ERROR_NONE) {
2207 notification_free(noti);
2214 EXPORT_API notification_h notification_load_by_tag(const char *tag)
2217 notification_h noti = NULL;
2218 char *caller_pkgname = NULL;
2221 NOTIFICATION_ERR("Invalid parameter");
2222 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
2226 caller_pkgname = _notification_get_pkgname_by_pid();
2227 if (!caller_pkgname) {
2228 NOTIFICATION_ERR("Failed to get a package name");
2229 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2234 noti = (notification_h) calloc(1, sizeof(struct _notification));
2236 NOTIFICATION_ERR("Failed to alloc a new notification");
2237 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2238 free(caller_pkgname);
2243 ret = notification_ipc_request_load_noti_by_tag(noti, caller_pkgname, tag);
2245 free(caller_pkgname);
2247 set_last_result(ret);
2249 if (ret != NOTIFICATION_ERROR_NONE) {
2250 notification_free(noti);
2257 EXPORT_API int notification_clone(notification_h noti, notification_h *clone)
2259 notification_h new_noti = NULL;
2261 if (noti == NULL || clone == NULL) {
2262 NOTIFICATION_ERR("INVALID PARAMETER.");
2263 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2266 new_noti = (notification_h) calloc(1, sizeof(struct _notification));
2267 if (new_noti == NULL) {
2268 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2269 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
2272 new_noti->type = noti->type;
2273 new_noti->layout = noti->layout;
2275 new_noti->group_id = noti->group_id;
2276 new_noti->internal_group_id = noti->internal_group_id;
2277 new_noti->priv_id = noti->priv_id;
2279 if(noti->caller_pkgname != NULL) {
2280 new_noti->caller_pkgname = strdup(noti->caller_pkgname);
2282 new_noti->caller_pkgname = _notification_get_pkgname_by_pid();
2284 if(noti->launch_pkgname != NULL) {
2285 new_noti->launch_pkgname = strdup(noti->launch_pkgname);
2287 new_noti->launch_pkgname = NULL;
2290 if(noti->args != NULL) {
2291 new_noti->args = bundle_dup(noti->args);
2293 new_noti->args = NULL;
2295 if(noti->group_args != NULL) {
2296 new_noti->group_args = bundle_dup(noti->group_args);
2298 new_noti->group_args = NULL;
2301 if(noti->b_execute_option != NULL) {
2302 new_noti->b_execute_option = bundle_dup(noti->b_execute_option);
2304 new_noti->b_execute_option = NULL;
2306 if(noti->b_service_responding != NULL) {
2307 new_noti->b_service_responding = bundle_dup(noti->b_service_responding);
2309 new_noti->b_service_responding = NULL;
2311 if(noti->b_service_single_launch != NULL) {
2312 new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch);
2314 new_noti->b_service_single_launch = NULL;
2316 if(noti->b_service_multi_launch != NULL) {
2317 new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch);
2319 new_noti->b_service_multi_launch = NULL;
2322 new_noti->sound_type = noti->sound_type;
2323 if(noti->sound_path != NULL) {
2324 new_noti->sound_path = strdup(noti->sound_path);
2326 new_noti->sound_path = NULL;
2328 new_noti->vibration_type = noti->vibration_type;
2329 if(noti->vibration_path != NULL) {
2330 new_noti->vibration_path = strdup(noti->vibration_path);
2332 new_noti->vibration_path = NULL;
2334 new_noti->led_operation = noti->led_operation;
2335 new_noti->led_argb = noti->led_argb;
2336 new_noti->led_on_ms = noti->led_on_ms;
2337 new_noti->led_off_ms = noti->led_off_ms;
2339 if(noti->domain != NULL) {
2340 new_noti->domain = strdup(noti->domain);
2342 new_noti->domain = NULL;
2344 if(noti->dir != NULL) {
2345 new_noti->dir = strdup(noti->dir);
2347 new_noti->dir = NULL;
2350 if(noti->b_text != NULL) {
2351 new_noti->b_text = bundle_dup(noti->b_text);
2353 new_noti->b_text = NULL;
2355 if(noti->b_key != NULL) {
2356 new_noti->b_key = bundle_dup(noti->b_key);
2358 new_noti->b_key = NULL;
2360 if(noti->b_format_args != NULL) {
2361 new_noti->b_format_args = bundle_dup(noti->b_format_args);
2363 new_noti->b_format_args = NULL;
2365 new_noti->num_format_args = noti->num_format_args;
2367 if(noti->b_image_path != NULL) {
2368 new_noti->b_image_path = bundle_dup(noti->b_image_path);
2370 new_noti->b_image_path = NULL;
2373 new_noti->time = noti->time;
2374 new_noti->insert_time = noti->insert_time;
2376 new_noti->flags_for_property = noti->flags_for_property;
2377 new_noti->display_applist = noti->display_applist;
2379 new_noti->progress_size = noti->progress_size;
2380 new_noti->progress_percentage = noti->progress_percentage;
2382 new_noti->app_icon_path = NULL;
2383 new_noti->app_name = NULL;
2384 new_noti->temp_title = NULL;
2385 new_noti->temp_content = NULL;
2389 return NOTIFICATION_ERROR_NONE;
2393 EXPORT_API int notification_free(notification_h noti)
2396 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2399 if (noti->caller_pkgname) {
2400 free(noti->caller_pkgname);
2402 if (noti->launch_pkgname) {
2403 free(noti->launch_pkgname);
2406 bundle_free(noti->args);
2408 if (noti->group_args) {
2409 bundle_free(noti->group_args);
2412 if (noti->b_execute_option) {
2413 bundle_free(noti->b_execute_option);
2415 if (noti->b_service_responding) {
2416 bundle_free(noti->b_service_responding);
2418 if (noti->b_service_single_launch) {
2419 bundle_free(noti->b_service_single_launch);
2421 if (noti->b_service_multi_launch) {
2422 bundle_free(noti->b_service_multi_launch);
2425 if (noti->sound_path) {
2426 free(noti->sound_path);
2428 if (noti->vibration_path) {
2429 free(noti->vibration_path);
2440 bundle_free(noti->b_text);
2443 bundle_free(noti->b_key);
2445 if (noti->b_format_args) {
2446 bundle_free(noti->b_format_args);
2449 if (noti->b_image_path) {
2450 bundle_free(noti->b_image_path);
2453 if (noti->app_icon_path) {
2454 free(noti->app_icon_path);
2456 if (noti->app_name) {
2457 free(noti->app_name);
2459 if (noti->temp_title) {
2460 free(noti->temp_title);
2462 if (noti->temp_content) {
2463 free(noti->temp_content);
2472 return NOTIFICATION_ERROR_NONE;
2476 notification_resister_changed_cb(void (*changed_cb)
2477 (void *data, notification_type_e type),
2480 notification_cb_list_s *noti_cb_list_new = NULL;
2481 notification_cb_list_s *noti_cb_list = NULL;
2483 if (changed_cb == NULL) {
2484 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2486 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
2487 return NOTIFICATION_ERROR_IO_ERROR;
2491 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
2493 noti_cb_list_new->next = NULL;
2494 noti_cb_list_new->prev = NULL;
2496 noti_cb_list_new->cb_type = NOTIFICATION_CB_NORMAL;
2497 noti_cb_list_new->changed_cb = changed_cb;
2498 noti_cb_list_new->detailed_changed_cb = NULL;
2499 noti_cb_list_new->data = user_data;
2501 if (g_notification_cb_list == NULL) {
2502 g_notification_cb_list = noti_cb_list_new;
2504 noti_cb_list = g_notification_cb_list;
2506 while (noti_cb_list->next != NULL) {
2507 noti_cb_list = noti_cb_list->next;
2510 noti_cb_list->next = noti_cb_list_new;
2511 noti_cb_list_new->prev = noti_cb_list;
2513 return NOTIFICATION_ERROR_NONE;
2517 notification_unresister_changed_cb(void (*changed_cb)
2518 (void *data, notification_type_e type))
2520 notification_cb_list_s *noti_cb_list = NULL;
2521 notification_cb_list_s *noti_cb_list_prev = NULL;
2522 notification_cb_list_s *noti_cb_list_next = NULL;
2524 noti_cb_list = g_notification_cb_list;
2526 if (changed_cb == NULL) {
2527 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2529 if (noti_cb_list == NULL) {
2530 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2533 while (noti_cb_list->prev != NULL) {
2534 noti_cb_list = noti_cb_list->prev;
2538 if (noti_cb_list->changed_cb == changed_cb) {
2539 noti_cb_list_prev = noti_cb_list->prev;
2540 noti_cb_list_next = noti_cb_list->next;
2542 if (noti_cb_list_prev == NULL) {
2543 g_notification_cb_list = noti_cb_list_next;
2545 noti_cb_list_prev->next = noti_cb_list_next;
2548 if (noti_cb_list_next == NULL) {
2549 if (noti_cb_list_prev != NULL) {
2550 noti_cb_list_prev->next = NULL;
2553 noti_cb_list_next->prev = noti_cb_list_prev;
2558 if (g_notification_cb_list == NULL)
2559 notification_ipc_monitor_fini();
2561 return NOTIFICATION_ERROR_NONE;
2563 noti_cb_list = noti_cb_list->next;
2564 } while (noti_cb_list != NULL);
2566 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2570 notification_register_detailed_changed_cb(
2571 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
2574 notification_cb_list_s *noti_cb_list_new = NULL;
2575 notification_cb_list_s *noti_cb_list = NULL;
2577 if (detailed_changed_cb == NULL) {
2578 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2580 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
2581 return NOTIFICATION_ERROR_IO_ERROR;
2585 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
2587 noti_cb_list_new->next = NULL;
2588 noti_cb_list_new->prev = NULL;
2590 noti_cb_list_new->cb_type = NOTIFICATION_CB_DETAILED;
2591 noti_cb_list_new->changed_cb = NULL;
2592 noti_cb_list_new->detailed_changed_cb = detailed_changed_cb;
2593 noti_cb_list_new->data = user_data;
2595 if (g_notification_cb_list == NULL) {
2596 g_notification_cb_list = noti_cb_list_new;
2598 noti_cb_list = g_notification_cb_list;
2600 while (noti_cb_list->next != NULL) {
2601 noti_cb_list = noti_cb_list->next;
2604 noti_cb_list->next = noti_cb_list_new;
2605 noti_cb_list_new->prev = noti_cb_list;
2607 return NOTIFICATION_ERROR_NONE;
2611 notification_unregister_detailed_changed_cb(
2612 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
2615 notification_cb_list_s *noti_cb_list = NULL;
2616 notification_cb_list_s *noti_cb_list_prev = NULL;
2617 notification_cb_list_s *noti_cb_list_next = NULL;
2619 noti_cb_list = g_notification_cb_list;
2621 if (detailed_changed_cb == NULL) {
2622 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2624 if (noti_cb_list == NULL) {
2625 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2628 while (noti_cb_list->prev != NULL) {
2629 noti_cb_list = noti_cb_list->prev;
2633 if (noti_cb_list->detailed_changed_cb == detailed_changed_cb) {
2634 noti_cb_list_prev = noti_cb_list->prev;
2635 noti_cb_list_next = noti_cb_list->next;
2637 if (noti_cb_list_prev == NULL) {
2638 g_notification_cb_list = noti_cb_list_next;
2640 noti_cb_list_prev->next = noti_cb_list_next;
2643 if (noti_cb_list_next == NULL) {
2644 if (noti_cb_list_prev != NULL) {
2645 noti_cb_list_prev->next = NULL;
2648 noti_cb_list_next->prev = noti_cb_list_prev;
2653 if (g_notification_cb_list == NULL)
2654 notification_ipc_monitor_fini();
2656 return NOTIFICATION_ERROR_NONE;
2658 noti_cb_list = noti_cb_list->next;
2659 } while (noti_cb_list != NULL);
2661 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2664 EXPORT_API int notification_get_count(notification_type_e type,
2665 const char *pkgname,
2667 int priv_id, int *count)
2672 if (count == NULL) {
2673 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2677 notification_noti_get_count(type, pkgname, group_id, priv_id,
2679 if (ret != NOTIFICATION_ERROR_NONE) {
2683 *count = noti_count;
2685 return NOTIFICATION_ERROR_NONE;
2688 EXPORT_API int notification_get_list(notification_type_e type,
2690 notification_list_h *list)
2692 notification_list_h get_list = NULL;
2696 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2699 ret = notification_noti_get_grouping_list(type, count, &get_list);
2700 if (ret != NOTIFICATION_ERROR_NONE) {
2706 return NOTIFICATION_ERROR_NONE;
2710 notification_get_grouping_list(notification_type_e type, int count,
2711 notification_list_h * list)
2713 notification_list_h get_list = NULL;
2717 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2720 ret = notification_noti_get_grouping_list(type, count, &get_list);
2721 if (ret != NOTIFICATION_ERROR_NONE) {
2727 return NOTIFICATION_ERROR_NONE;
2730 EXPORT_API int notification_get_detail_list(const char *pkgname,
2734 notification_list_h *list)
2736 notification_list_h get_list = NULL;
2740 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2744 notification_noti_get_detail_list(pkgname, group_id, priv_id, count,
2746 if (ret != NOTIFICATION_ERROR_NONE) {
2752 return NOTIFICATION_ERROR_NONE;
2755 EXPORT_API int notification_free_list(notification_list_h list)
2757 notification_list_h cur_list = NULL;
2758 notification_h noti = NULL;
2761 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2764 cur_list = notification_list_get_head(list);
2766 while (cur_list != NULL) {
2767 noti = notification_list_get_data(cur_list);
2768 cur_list = notification_list_remove(cur_list, noti);
2770 notification_free(noti);
2773 return NOTIFICATION_ERROR_NONE;
2776 EXPORT_API int notification_op_get_data(notification_op *noti_op, notification_op_data_type_e type,
2779 if (noti_op == NULL || data == NULL) {
2780 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2784 case NOTIFICATION_OP_DATA_TYPE:
2785 *((int*)data) = noti_op->type;
2787 case NOTIFICATION_OP_DATA_PRIV_ID:
2788 *((int*)data) = noti_op->priv_id;
2790 case NOTIFICATION_OP_DATA_NOTI:
2791 *((notification_h *)data) = noti_op->noti;
2793 case NOTIFICATION_OP_DATA_EXTRA_INFO_1:
2794 *((int*)data) = noti_op->extra_info_1;
2796 case NOTIFICATION_OP_DATA_EXTRA_INFO_2:
2797 *((int*)data) = noti_op->extra_info_2;
2800 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2804 return NOTIFICATION_ERROR_NONE;
2807 void notification_call_changed_cb(notification_op *op_list, int op_num)
2809 notification_cb_list_s *noti_cb_list = NULL;
2810 notification_type_e type = 0;
2812 if (g_notification_cb_list == NULL) {
2815 noti_cb_list = g_notification_cb_list;
2817 while (noti_cb_list->prev != NULL) {
2818 noti_cb_list = noti_cb_list->prev;
2821 if (op_list == NULL) {
2822 NOTIFICATION_ERR("invalid data");
2826 notification_get_type(op_list->noti, &type);
2828 while (noti_cb_list != NULL) {
2829 if (noti_cb_list->cb_type == NOTIFICATION_CB_NORMAL && noti_cb_list->changed_cb) {
2830 noti_cb_list->changed_cb(noti_cb_list->data,
2833 if (noti_cb_list->cb_type == NOTIFICATION_CB_DETAILED && noti_cb_list->detailed_changed_cb) {
2834 noti_cb_list->detailed_changed_cb(noti_cb_list->data,
2835 type, op_list, op_num);
2838 noti_cb_list = noti_cb_list->next;
2842 EXPORT_API int notification_is_service_ready(void)
2844 return notification_ipc_is_master_ready();
2848 notification_add_deferred_task(
2849 void (*deferred_task_cb)(void *data), void *user_data)
2851 if (deferred_task_cb == NULL) {
2852 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2855 return notification_ipc_add_deffered_task(deferred_task_cb, user_data);
2859 notification_del_deferred_task(
2860 void (*deferred_task_cb)(void *data))
2862 if (deferred_task_cb == NULL) {
2863 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2866 return notification_ipc_del_deffered_task(deferred_task_cb);
2869 /* notification_set_icon will be removed */
2870 EXPORT_API int notification_set_icon(notification_h noti,
2871 const char *icon_path)
2873 int ret_err = NOTIFICATION_ERROR_NONE;
2876 notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
2882 /* notification_get_icon will be removed */
2883 EXPORT_API int notification_get_icon(notification_h noti,
2886 int ret_err = NOTIFICATION_ERROR_NONE;
2887 char *ret_image_path = NULL;
2890 notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
2893 if (ret_err == NOTIFICATION_ERROR_NONE && icon_path != NULL) {
2894 *icon_path = ret_image_path;
2896 //NOTIFICATION_DBG("Get icon : %s", *icon_path);
2902 EXPORT_API int notification_set_title(notification_h noti,
2904 const char *loc_title)
2906 int noti_err = NOTIFICATION_ERROR_NONE;
2908 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
2910 NOTIFICATION_VARIABLE_TYPE_NONE);
2915 EXPORT_API int notification_get_title(notification_h noti,
2919 int noti_err = NOTIFICATION_ERROR_NONE;
2920 char *ret_text = NULL;
2923 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
2926 if (title != NULL) {
2930 if (loc_title != NULL) {
2937 EXPORT_API int notification_set_content(notification_h noti,
2938 const char *content,
2939 const char *loc_content)
2941 int noti_err = NOTIFICATION_ERROR_NONE;
2943 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
2944 content, loc_content,
2945 NOTIFICATION_VARIABLE_TYPE_NONE);
2950 EXPORT_API int notification_get_content(notification_h noti,
2954 int noti_err = NOTIFICATION_ERROR_NONE;
2955 char *ret_text = NULL;
2958 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
2961 if (content != NULL) {
2962 *content = ret_text;
2965 if (loc_content != NULL) {
2966 *loc_content = NULL;
2974 (VCONFKEY_SETAPPL_STATE_TICKER_NOTI_DISPLAY_CONTENT_BOOL, &boolval);
2976 if (ret == -1 || boolval == 0) {
2977 if (content != NULL && noti->default_content != NULL) {
2978 *content = noti->default_content;
2981 if (loc_content != NULL && noti->loc_default_content != NULL) {
2982 *loc_content = noti->loc_default_content;
2988 EXPORT_API int notification_set_args(notification_h noti,
2990 bundle * group_args)
2992 if (noti == NULL || args == NULL) {
2993 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2997 bundle_free(noti->args);
3000 noti->args = bundle_dup(args);
3002 if (noti->group_args) {
3003 bundle_free(noti->group_args);
3004 noti->group_args = NULL;
3007 if (group_args != NULL) {
3008 noti->group_args = bundle_dup(group_args);
3011 return NOTIFICATION_ERROR_NONE;
3014 EXPORT_API int notification_get_args(notification_h noti,
3016 bundle ** group_args)
3018 if (noti == NULL || args == NULL) {
3019 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3028 if (group_args != NULL && noti->group_args) {
3029 *group_args = noti->group_args;
3032 return NOTIFICATION_ERROR_NONE;
3035 EXPORT_API int notification_delete_group_by_group_id(const char *pkgname,
3036 notification_type_e type,
3040 char *caller_pkgname = NULL;
3042 if (pkgname == NULL) {
3043 caller_pkgname = _notification_get_pkgname_by_pid();
3045 caller_pkgname = strdup(pkgname);
3048 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
3049 if (ret != NOTIFICATION_ERROR_NONE) {
3050 if (caller_pkgname) {
3051 free(caller_pkgname);
3056 if (caller_pkgname) {
3057 free(caller_pkgname);
3059 return NOTIFICATION_ERROR_NONE;
3062 EXPORT_API int notification_delete_group_by_priv_id(const char *pkgname,
3063 notification_type_e type,
3067 char *caller_pkgname = NULL;
3069 if (pkgname == NULL) {
3070 caller_pkgname = _notification_get_pkgname_by_pid();
3072 caller_pkgname = strdup(pkgname);
3075 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
3076 if (ret != NOTIFICATION_ERROR_NONE) {
3077 if (caller_pkgname) {
3078 free(caller_pkgname);
3083 if (caller_pkgname) {
3084 free(caller_pkgname);
3086 return NOTIFICATION_ERROR_NONE;
3089 EXPORT_API int notification_set_tag(notification_h noti, const char *tag)
3091 /* Check noti is valid data */
3093 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3097 /* save input TAG */
3098 if (noti->tag != NULL) {
3101 noti->tag = strdup(tag);
3104 return NOTIFICATION_ERROR_NONE;
3108 EXPORT_API int notification_get_tag(notification_h noti, const char **tag)
3110 /* Check noti is valid data */
3112 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3115 /* Set sound type */
3117 return NOTIFICATION_ERROR_NONE;
3120 EXPORT_API int notification_register_toast_message(void (*posted_toast_cb) (void *data))
3122 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
3123 return NOTIFICATION_ERROR_IO_ERROR;
3126 posted_toast_message_cb = posted_toast_cb;
3128 return NOTIFICATION_ERROR_NONE;
3131 void notification_call_posted_toast_cb(const char *message)
3133 if (posted_toast_message_cb != NULL) {
3134 posted_toast_message_cb(message);