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 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 notification_text_type_e check_type = NOTIFICATION_TEXT_TYPE_NONE;
550 //int display_option_flag = 0;
552 char *temp_str = NULL;
553 char result_str[NOTI_TEXT_RESULT_LEN] = { 0, };
554 char buf_str[1024] = { 0, };
556 notification_variable_type_e ret_var_type = 0;
557 int ret_variable_int = 0;
558 double ret_variable_double = 0.0;
560 /* Check noti is valid data */
561 if (noti == NULL || text == NULL) {
562 return NOTIFICATION_ERROR_INVALID_PARAMETER;
565 /* Check text type is valid type */
566 if (type <= NOTIFICATION_TEXT_TYPE_NONE
567 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
568 return NOTIFICATION_ERROR_INVALID_PARAMETER;
572 if (noti->b_key != NULL) {
575 /* Get text domain and dir */
576 //_notification_get_text_domain(noti);
578 snprintf(buf_key, sizeof(buf_key), "%d", type);
580 ret_val = bundle_get_val(b, buf_key);
581 if (ret_val != NULL && noti->domain != NULL
582 && noti->dir != NULL) {
583 /* Get application string */
584 bindtextdomain(noti->domain, noti->dir);
586 get_str = dgettext(noti->domain, ret_val);
587 } else if (ret_val != NULL) {
588 /* Get system string */
589 get_str = dgettext("sys_string", ret_val);
595 if (get_str == NULL && noti->b_text != NULL) {
598 snprintf(buf_key, sizeof(buf_key), "%d", type);
600 get_str = bundle_get_val(b, buf_key);
605 /* Set display option is off type when option is off, type is noti */
606 /*if (get_str != NULL && display_option_flag == 1
607 && noti->type == NOTIFICATION_TYPE_NOTI) {
608 if (type == NOTIFICATION_TEXT_TYPE_CONTENT
609 || type == NOTIFICATION_TEXT_TYPE_GROUP_CONTENT) {
610 // Set check_type to option content string
611 if (type == NOTIFICATION_TEXT_TYPE_CONTENT) {
613 NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF;
614 } else if (type == NOTIFICATION_TEXT_TYPE_GROUP_CONTENT) {
616 NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF;
620 if (noti->b_key != NULL) {
623 // Get text domain and dir
624 _notification_get_text_domain(noti);
626 snprintf(buf_key, sizeof(buf_key), "%d",
629 ret_val = bundle_get_val(b, buf_key);
630 if (ret_val != NULL && noti->domain != NULL
631 && noti->dir != NULL) {
632 // Get application string
633 bindtextdomain(noti->domain, noti->dir);
636 dgettext(noti->domain, ret_val);
637 } else if (ret_val != NULL) {
640 dgettext("sys_string", ret_val);
642 get_check_type_str = NULL;
646 if (get_check_type_str == NULL && noti->b_text != NULL) {
649 snprintf(buf_key, sizeof(buf_key), "%d",
652 get_check_type_str = bundle_get_val(b, buf_key);
656 if (get_check_type_str != NULL) {
657 // Replace option off type string
658 get_str = get_check_type_str;
660 // Set default string
662 dgettext("sys_string", "IDS_COM_POP_MISSED_EVENT");
666 if (get_str != NULL) {
667 /* Get number format args */
668 b = noti->b_format_args;
669 noti->num_format_args = 0;
672 snprintf(buf_key, sizeof(buf_key), "num%d", check_type);
673 ret_val = bundle_get_val(b, buf_key);
674 if (ret_val != NULL) {
675 noti->num_format_args = atoi(ret_val);
679 if (noti->num_format_args == 0) {
680 *text = (char *)get_str;
682 /* Check first variable is count, LEFT pos */
683 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
684 check_type, num_args);
685 ret_val = bundle_get_val(b, buf_key);
686 ret_var_type = atoi(ret_val);
688 if (ret_var_type == NOTIFICATION_VARIABLE_TYPE_COUNT) {
690 snprintf(buf_key, sizeof(buf_key), "%dvalue%d",
691 check_type, num_args);
692 ret_val = bundle_get_val(b, buf_key);
693 ret_variable_int = atoi(ret_val);
695 if (ret_variable_int ==
696 NOTIFICATION_COUNT_POS_LEFT) {
697 notification_noti_get_count(noti->type,
698 noti->caller_pkgname,
702 snprintf(buf_str, sizeof(buf_str),
703 "%d ", ret_variable_int);
705 int src_len = strlen(result_str);
706 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
708 strncat(result_str, buf_str,
716 /* Check variable IN pos */
717 for (temp_str = (char *)get_str; *temp_str != '\0';
719 if (*temp_str != '%') {
720 strncat(result_str, temp_str, 1);
722 if (*(temp_str + 1) == '%') {
723 strncat(result_str, temp_str,
725 } else if (*(temp_str + 1) == 'd') {
727 ret_variable_int = 0;
731 "%dtype%d", check_type,
734 bundle_get_val(b, buf_key);
735 ret_var_type = atoi(ret_val);
737 NOTIFICATION_VARIABLE_TYPE_COUNT)
739 /* Get notification count */
740 notification_noti_get_count
742 noti->caller_pkgname,
762 sizeof(buf_str), "%d",
765 int src_len = strlen(result_str);
766 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
768 strncat(result_str, buf_str,
774 } else if (*(temp_str + 1) == 's') {
779 check_type, num_args);
781 bundle_get_val(b, buf_key);
784 sizeof(buf_str), "%s",
787 int src_len = strlen(result_str);
788 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
790 strncat(result_str, buf_str,
796 } else if (*(temp_str + 1) == 'f') {
801 check_type, num_args);
803 bundle_get_val(b, buf_key);
804 ret_variable_double =
810 ret_variable_double);
812 int src_len = strlen(result_str);
813 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
815 strncat(result_str, buf_str,
821 } else if (*(temp_str + 1) >= '1' && *(temp_str + 1) <= '9') {
822 if (*(temp_str + 3) == 'd') {
824 ret_variable_int = 0;
828 "%dtype%d", check_type,
829 num_args + *(temp_str + 1) - 49);
831 bundle_get_val(b, buf_key);
832 ret_var_type = atoi(ret_val);
834 NOTIFICATION_VARIABLE_TYPE_COUNT)
836 /* Get notification count */
837 notification_noti_get_count
839 noti->caller_pkgname,
850 num_args + *(temp_str + 1) - 49);
859 sizeof(buf_str), "%d",
862 int src_len = strlen(result_str);
863 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
865 strncat(result_str, buf_str,
869 } else if (*(temp_str + 3) == 's') {
874 check_type, num_args + *(temp_str + 1) - 49);
876 bundle_get_val(b, buf_key);
879 sizeof(buf_str), "%s",
882 int src_len = strlen(result_str);
883 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
885 strncat(result_str, buf_str,
889 } else if (*(temp_str + 3) == 'f') {
894 check_type, num_args + *(temp_str + 1) - 49);
896 bundle_get_val(b, buf_key);
897 ret_variable_double =
903 ret_variable_double);
905 int src_len = strlen(result_str);
906 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
908 strncat(result_str, buf_str,
918 /* Check last variable is count, LEFT pos */
919 if (num_args < noti->num_format_args) {
920 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
921 check_type, num_args);
922 ret_val = bundle_get_val(b, buf_key);
923 ret_var_type = atoi(ret_val);
925 NOTIFICATION_VARIABLE_TYPE_COUNT) {
927 snprintf(buf_key, sizeof(buf_key),
928 "%dvalue%d", check_type,
930 ret_val = bundle_get_val(b, buf_key);
931 ret_variable_int = atoi(ret_val);
933 if (ret_variable_int ==
934 NOTIFICATION_COUNT_POS_RIGHT) {
935 notification_noti_get_count
937 noti->caller_pkgname,
942 sizeof(buf_str), " %d",
945 int src_len = strlen(result_str);
946 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
948 strncat(result_str, buf_str,
957 switch (check_type) {
958 case NOTIFICATION_TEXT_TYPE_TITLE:
959 case NOTIFICATION_TEXT_TYPE_GROUP_TITLE:
960 if (noti->temp_title != NULL)
961 free(noti->temp_title);
963 noti->temp_title = strdup(result_str);
965 *text = noti->temp_title;
967 case NOTIFICATION_TEXT_TYPE_CONTENT:
968 case NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
969 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT:
970 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
971 if (noti->temp_content !=
973 free(noti->temp_content);
975 noti->temp_content = strdup(result_str);
977 *text = noti->temp_content;
989 return NOTIFICATION_ERROR_NONE;
992 EXPORT_API int notification_set_text_domain(notification_h noti,
996 /* check noti and domain is valid data */
997 if (noti == NULL || domain == NULL || dir == NULL) {
998 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1003 /* Remove previous domain */
1007 noti->domain = strdup(domain);
1009 /* Check locale dir */
1011 /* Remove previous locale dir */
1014 /* Copy locale dir */
1015 noti->dir = strdup(dir);
1017 return NOTIFICATION_ERROR_NONE;
1020 EXPORT_API int notification_get_text_domain(notification_h noti,
1024 /* Check noti is valid data */
1026 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1030 if (domain != NULL && noti->domain != NULL) {
1031 *domain = noti->domain;
1034 /* Get locale dir */
1035 if (dir != NULL && noti->dir != NULL) {
1039 return NOTIFICATION_ERROR_NONE;
1042 EXPORT_API int notification_set_time_to_text(notification_h noti, notification_text_type_e type,
1045 int ret = NOTIFICATION_ERROR_NONE;
1046 char buf[256] = { 0, };
1047 char buf_tag[512] = { 0, };
1050 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1053 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1055 if (type <= NOTIFICATION_TEXT_TYPE_NONE
1056 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
1057 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1061 snprintf(buf, sizeof(buf), "%lu", time);
1062 ret = notification_noti_set_tag(TAG_TIME, buf, buf_tag, sizeof(buf_tag));
1064 if (ret != NOTIFICATION_ERROR_NONE) {
1068 return notification_set_text(noti, type, buf_tag, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1071 EXPORT_API int notification_get_time_from_text(notification_h noti, notification_text_type_e type,
1074 int ret = NOTIFICATION_ERROR_NONE;
1077 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1080 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1082 if (type <= NOTIFICATION_TEXT_TYPE_NONE
1083 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
1084 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1087 char *ret_text = NULL;
1088 ret = notification_get_text(noti, type, &ret_text);
1090 if (ret != NOTIFICATION_ERROR_NONE || ret_text == NULL) {
1091 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1094 if (notification_noti_get_tag_type(ret_text) == TAG_TYPE_INVALID) {
1095 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1098 char *tag_value = NULL;
1099 tag_value = notification_noti_strip_tag(ret_text);
1100 if (tag_value == NULL) {
1101 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1104 *time = atol(tag_value);
1107 return NOTIFICATION_ERROR_NONE;
1110 EXPORT_API int notification_set_sound(notification_h noti,
1111 notification_sound_type_e type,
1114 /* Check noti is valid data */
1116 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1119 /* Check type is valid */
1120 if (type < NOTIFICATION_SOUND_TYPE_NONE
1121 || type >= NOTIFICATION_SOUND_TYPE_MAX) {
1122 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1125 /* Save sound type */
1126 noti->sound_type = type;
1128 /* Save sound path if user data type */
1129 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA && path != NULL) {
1130 if (noti->sound_path != NULL) {
1131 free(noti->sound_path);
1134 noti->sound_path = strdup(path);
1136 if (noti->sound_path != NULL) {
1137 free(noti->sound_path);
1138 noti->sound_path = NULL;
1140 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA) {
1141 noti->sound_type = NOTIFICATION_SOUND_TYPE_DEFAULT;
1142 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1146 return NOTIFICATION_ERROR_NONE;
1149 EXPORT_API int notification_get_sound(notification_h noti,
1150 notification_sound_type_e *type,
1153 /* check noti and type is valid data */
1154 if (noti == NULL || type == NULL) {
1155 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1158 /* Set sound type */
1159 *type = noti->sound_type;
1161 /* Set sound path if user data type */
1162 if (noti->sound_type == NOTIFICATION_SOUND_TYPE_USER_DATA
1164 *path = noti->sound_path;
1167 return NOTIFICATION_ERROR_NONE;
1170 EXPORT_API int notification_set_vibration(notification_h noti,
1171 notification_vibration_type_e type,
1174 /* Check noti is valid data */
1176 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1179 /* Check type is valid */
1180 if (type < NOTIFICATION_VIBRATION_TYPE_NONE
1181 || type >= NOTIFICATION_VIBRATION_TYPE_MAX) {
1182 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1185 /* Save vibration type */
1186 noti->vibration_type = type;
1188 /* Save sound path if user data type */
1189 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA && path != NULL) {
1190 if (noti->vibration_path != NULL) {
1191 free(noti->vibration_path);
1194 noti->vibration_path = strdup(path);
1196 if (noti->vibration_path != NULL) {
1197 free(noti->vibration_path);
1198 noti->vibration_path = NULL;
1200 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA) {
1201 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
1202 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1206 return NOTIFICATION_ERROR_NONE;
1210 EXPORT_API int notification_get_vibration(notification_h noti,
1211 notification_vibration_type_e *type,
1214 /* check noti and type is valid data */
1215 if (noti == NULL || type == NULL) {
1216 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1219 /* Set vibration type */
1220 *type = noti->vibration_type;
1222 /* Set sound path if user data type */
1223 if (noti->vibration_type == NOTIFICATION_VIBRATION_TYPE_USER_DATA
1225 *path = noti->vibration_path;
1228 return NOTIFICATION_ERROR_NONE;
1231 EXPORT_API int notification_set_led(notification_h noti,
1232 notification_led_op_e operation,
1235 /* Check noti is valid data */
1237 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1240 /* Check operation is valid */
1241 if (operation < NOTIFICATION_LED_OP_OFF
1242 || operation >= NOTIFICATION_LED_OP_MAX) {
1243 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1246 /* Save led operation */
1247 noti->led_operation = operation;
1249 /* Save led argb if operation is turning on LED with custom color */
1250 if (operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR) {
1251 noti->led_argb = led_argb;
1254 return NOTIFICATION_ERROR_NONE;
1257 EXPORT_API int notification_get_led(notification_h noti,
1258 notification_led_op_e *operation,
1261 /* check noti and operation is valid data */
1262 if (noti == NULL || operation == NULL) {
1263 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1266 /* Set led operation */
1267 *operation = noti->led_operation;
1269 /* Save led argb if operation is turning on LED with custom color */
1270 if (noti->led_operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR
1271 && led_argb != NULL) {
1272 *led_argb = noti->led_argb;
1275 return NOTIFICATION_ERROR_NONE;
1278 EXPORT_API int notification_set_led_time_period(notification_h noti,
1279 int on_ms, int off_ms)
1281 /* Check noti is valid data */
1282 if (noti == NULL || on_ms < 0 || off_ms < 0) {
1283 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1286 /* Save led operation */
1287 noti->led_on_ms = on_ms;
1288 noti->led_off_ms = off_ms;
1290 return NOTIFICATION_ERROR_NONE;
1293 EXPORT_API int notification_get_led_time_period(notification_h noti,
1294 int *on_ms, int *off_ms)
1296 /* check noti and operation is valid data */
1298 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1302 *(on_ms) = noti->led_on_ms;
1304 *(off_ms) = noti->led_off_ms;
1306 return NOTIFICATION_ERROR_NONE;
1309 EXPORT_API int notification_set_application(notification_h noti,
1310 const char *pkgname)
1312 if (noti == NULL || pkgname == NULL) {
1313 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1316 if (noti->launch_pkgname) {
1317 free(noti->launch_pkgname);
1320 noti->launch_pkgname = strdup(pkgname);
1322 return NOTIFICATION_ERROR_NONE;
1325 EXPORT_API int notification_get_application(notification_h noti,
1328 if (noti == NULL || pkgname == NULL) {
1329 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1332 if (noti->launch_pkgname) {
1333 *pkgname = noti->launch_pkgname;
1335 *pkgname = noti->caller_pkgname;
1338 return NOTIFICATION_ERROR_NONE;
1341 EXPORT_API int notification_set_launch_option(notification_h noti,
1342 notification_launch_option_type type, void *option)
1346 app_control_h app_control = option;
1349 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1351 if (app_control == NULL) {
1352 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1354 if (type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL) {
1355 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1358 if ((ret = app_control_to_bundle(app_control, &b)) == APP_CONTROL_ERROR_NONE) {
1359 return notification_set_execute_option(noti,
1360 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
1364 NOTIFICATION_ERR("Failed to convert appcontrol to bundle:%d", ret);
1365 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1369 EXPORT_API int notification_get_launch_option(notification_h noti,
1370 notification_launch_option_type type, void *option)
1374 app_control_h *app_control = (app_control_h *)option;
1375 app_control_h app_control_new = NULL;
1378 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1380 if (app_control == NULL) {
1381 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1383 if (type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL) {
1384 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1387 ret = notification_get_execute_option(noti,
1388 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
1391 if (ret == NOTIFICATION_ERROR_NONE && b != NULL) {
1392 ret = app_control_create(&app_control_new);
1393 if (ret == APP_CONTROL_ERROR_NONE && app_control_new != NULL) {
1394 ret = app_control_import_from_bundle(app_control_new, b);
1395 if (ret == APP_CONTROL_ERROR_NONE) {
1396 *app_control = app_control_new;
1398 app_control_destroy(app_control_new);
1399 NOTIFICATION_ERR("Failed to import app control from bundle:%d", ret);
1400 return NOTIFICATION_ERROR_IO_ERROR;
1403 NOTIFICATION_ERR("Failed to create app control:%d", ret);
1404 return NOTIFICATION_ERROR_IO_ERROR;
1407 NOTIFICATION_ERR("Failed to get execute option:%d", ret);
1411 return NOTIFICATION_ERROR_NONE;
1414 EXPORT_API int notification_set_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h event_handler)
1416 int err = NOTIFICATION_ERROR_NONE;
1417 bundle *app_control_bundle = NULL;
1420 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1421 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1422 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1425 if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
1426 || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
1427 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1428 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1432 if ((err = app_control_to_bundle(event_handler, &app_control_bundle)) != APP_CONTROL_ERROR_NONE) {
1433 NOTIFICATION_ERR("app_control_to_bundle failed [%d]", err);
1437 if (noti->b_event_handler[event_type] != NULL) {
1438 bundle_free(noti->b_event_handler[event_type]);
1441 noti->b_event_handler[event_type] = app_control_bundle;
1447 EXPORT_API int notification_get_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h *event_handler)
1449 int err = NOTIFICATION_ERROR_NONE;
1451 app_control_h app_control_new = NULL;
1454 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1455 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1458 if (event_handler == NULL) {
1459 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1460 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1463 if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
1464 || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
1465 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1466 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1470 b = noti->b_event_handler[event_type];
1473 NOTIFICATION_DBG("No event handler\n");
1474 err = NOTIFICATION_ERROR_NOT_EXIST_ID;
1478 err = app_control_create(&app_control_new);
1479 if (err != APP_CONTROL_ERROR_NONE || app_control_new == NULL) {
1480 NOTIFICATION_ERR("app_control_create failed [%d]", err);
1481 err = NOTIFICATION_ERROR_IO_ERROR;
1485 err = app_control_import_from_bundle(app_control_new, b);
1486 if (err == APP_CONTROL_ERROR_NONE) {
1487 *event_handler = app_control_new;
1490 app_control_destroy(app_control_new);
1491 NOTIFICATION_ERR("Failed to import app control from bundle [%d]", err);
1492 err = NOTIFICATION_ERROR_IO_ERROR;
1498 *event_handler = app_control_new;
1503 EXPORT_API int notification_set_execute_option(notification_h noti,
1504 notification_execute_type_e type,
1507 bundle *service_handle)
1509 char buf_key[32] = { 0, };
1510 const char *ret_val = NULL;
1514 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1517 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1518 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1519 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1522 /* Create execute option bundle if does not exist */
1523 if (noti->b_execute_option == NULL) {
1524 noti->b_execute_option = bundle_create();
1527 b = noti->b_execute_option;
1532 snprintf(buf_key, sizeof(buf_key), "text%d", type);
1534 /* Check text key exist */
1535 ret_val = bundle_get_val(b, buf_key);
1536 if (ret_val != NULL) {
1537 /* Remove previous data */
1538 bundle_del(b, buf_key);
1542 bundle_add(b, buf_key, text);
1548 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1550 /* Check key key exist */
1551 ret_val = bundle_get_val(b, buf_key);
1552 if (ret_val != NULL) {
1553 /* Remove previous data */
1554 bundle_del(b, buf_key);
1558 bundle_add(b, buf_key, key);
1561 switch ((int)type) {
1562 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1563 /* Remove previous data if exist */
1564 if (noti->b_service_responding != NULL) {
1565 bundle_free(noti->b_service_responding);
1566 noti->b_service_responding = NULL;
1569 /* Save service handle */
1570 if (service_handle != NULL) {
1571 noti->b_service_responding = bundle_dup(service_handle);
1574 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1575 /* Remove previous data if exist */
1576 if (noti->b_service_single_launch != NULL) {
1577 bundle_free(noti->b_service_single_launch);
1578 noti->b_service_single_launch = NULL;
1581 /* Save service handle */
1582 if (service_handle != NULL) {
1583 noti->b_service_single_launch =
1584 bundle_dup(service_handle);
1587 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1588 /* Remove previous data if exist */
1589 if (noti->b_service_multi_launch != NULL) {
1590 bundle_free(noti->b_service_multi_launch);
1591 noti->b_service_multi_launch = NULL;
1594 /* Save service handle */
1595 if (service_handle != NULL) {
1596 noti->b_service_multi_launch =
1597 bundle_dup(service_handle);
1602 return NOTIFICATION_ERROR_NONE;
1605 EXPORT_API int notification_get_execute_option(notification_h noti,
1606 notification_execute_type_e type,
1608 bundle **service_handle)
1610 char buf_key[32] = { 0, };
1611 const char *ret_val = NULL;
1612 char *get_str = NULL;
1616 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1619 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1620 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1621 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1625 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1626 b = noti->b_service_responding;
1628 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1629 b = noti->b_service_single_launch;
1631 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1632 b = noti->b_service_multi_launch;
1640 // Get text domain and dir
1641 if (noti->domain == NULL || noti->dir == NULL) {
1642 _notification_get_text_domain(noti);
1646 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1648 /* Check key key exist */
1649 ret_val = bundle_get_val(b, buf_key);
1650 if (ret_val != NULL && noti->domain != NULL
1651 && noti->dir != NULL) {
1652 /* Get application string */
1653 bindtextdomain(noti->domain, noti->dir);
1655 get_str = dgettext(noti->domain, ret_val);
1658 } else if (ret_val != NULL) {
1659 /* Get system string */
1660 get_str = dgettext("sys_string", ret_val);
1664 /* Get basic text */
1665 snprintf(buf_key, sizeof(buf_key), "text%d",
1668 ret_val = bundle_get_val(b, buf_key);
1675 if (service_handle != NULL) {
1676 *service_handle = b;
1679 return NOTIFICATION_ERROR_NONE;
1682 EXPORT_API int notification_set_property(notification_h noti,
1685 /* Check noti is valid data */
1687 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1691 noti->flags_for_property = flags;
1693 return NOTIFICATION_ERROR_NONE;
1696 EXPORT_API int notification_get_property(notification_h noti,
1699 /* Check noti and flags are valid data */
1700 if (noti == NULL || flags == NULL) {
1701 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1705 *flags = noti->flags_for_property;
1707 return NOTIFICATION_ERROR_NONE;
1710 EXPORT_API int notification_set_display_applist(notification_h noti,
1713 /* Check noti is valid data */
1715 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1719 noti->display_applist = applist;
1721 return NOTIFICATION_ERROR_NONE;
1724 EXPORT_API int notification_get_display_applist(notification_h noti,
1727 /* Check noti and applist are valid data */
1728 if (noti == NULL || applist == NULL) {
1729 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1733 *applist = noti->display_applist;
1735 return NOTIFICATION_ERROR_NONE;
1738 EXPORT_API int notification_set_size(notification_h noti,
1741 /* Check noti is valid data */
1743 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1746 /* Save progress size */
1747 noti->progress_size = size;
1749 return NOTIFICATION_ERROR_NONE;
1752 EXPORT_API int notification_get_size(notification_h noti,
1755 /* Check noti and size is valid data */
1756 if (noti == NULL || size == NULL) {
1757 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1760 /* Set progress size */
1761 *size = noti->progress_size;
1763 return NOTIFICATION_ERROR_NONE;
1766 EXPORT_API int notification_set_progress(notification_h noti,
1769 /* Check noti is valid data */
1771 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1774 /* Save progress percentage */
1775 noti->progress_percentage = percentage;
1777 return NOTIFICATION_ERROR_NONE;
1780 EXPORT_API int notification_get_progress(notification_h noti,
1783 /* Check noti and percentage are valid data */
1784 if (noti == NULL || percentage == NULL) {
1785 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1788 /* Set progress percentage */
1789 *percentage = noti->progress_percentage;
1791 return NOTIFICATION_ERROR_NONE;
1794 EXPORT_API int notification_set_pkgname(notification_h noti,
1795 const char *pkgname)
1797 /* check noti and pkgname are valid data */
1798 if (noti == NULL || pkgname == NULL) {
1799 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1802 /* Remove previous caller pkgname */
1803 if (noti->caller_pkgname) {
1804 free(noti->caller_pkgname);
1805 noti->caller_pkgname = NULL;
1808 noti->caller_pkgname = strdup(pkgname);
1810 return NOTIFICATION_ERROR_NONE;
1813 EXPORT_API int notification_get_pkgname(notification_h noti,
1816 /* Check noti and pkgname are valid data */
1817 if (noti == NULL || pkgname == NULL) {
1818 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1821 /* Get caller pkgname */
1822 if (noti->caller_pkgname) {
1823 *pkgname = noti->caller_pkgname;
1828 return NOTIFICATION_ERROR_NONE;
1831 EXPORT_API int notification_set_layout(notification_h noti,
1832 notification_ly_type_e layout)
1834 /* check noti and pkgname are valid data */
1835 if (noti == NULL || (layout < NOTIFICATION_LY_NONE || layout >= NOTIFICATION_LY_MAX)) {
1836 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1839 noti->layout = layout;
1841 return NOTIFICATION_ERROR_NONE;
1844 EXPORT_API int notification_get_layout(notification_h noti,
1845 notification_ly_type_e *layout)
1847 /* Check noti and pkgname are valid data */
1848 if (noti == NULL || layout == NULL) {
1849 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1852 *layout = noti->layout;
1854 return NOTIFICATION_ERROR_NONE;
1857 EXPORT_API int notification_get_id(notification_h noti,
1858 int *group_id, int *priv_id)
1860 /* check noti is valid data */
1862 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1865 /* Check group_id is valid data */
1868 if (noti->group_id < NOTIFICATION_GROUP_ID_NONE) {
1869 *group_id = NOTIFICATION_GROUP_ID_NONE;
1871 *group_id = noti->group_id;
1875 /* Check priv_id is valid data */
1878 *priv_id = noti->priv_id;
1881 return NOTIFICATION_ERROR_NONE;
1884 EXPORT_API int notification_get_type(notification_h noti,
1885 notification_type_e *type)
1887 /* Check noti and type is valid data */
1888 if (noti == NULL || type == NULL) {
1889 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1895 return NOTIFICATION_ERROR_NONE;
1898 EXPORT_API int notification_post(notification_h noti)
1903 /* Check noti is vaild data */
1905 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1908 /* Check noti type is valid type */
1909 if (noti->type <= NOTIFICATION_TYPE_NONE
1910 || noti->type >= NOTIFICATION_TYPE_MAX) {
1911 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1914 /* Save insert time */
1915 noti->insert_time = time(NULL);
1917 ret = notification_ipc_request_insert(noti, &id);
1918 if (ret != NOTIFICATION_ERROR_NONE) {
1922 NOTIFICATION_DBG("from master:%d", id);
1924 return NOTIFICATION_ERROR_NONE;
1927 EXPORT_API int notification_insert(notification_h noti,
1933 /* Check noti is vaild data */
1935 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1938 /* Check noti type is valid type */
1939 if (noti->type <= NOTIFICATION_TYPE_NONE
1940 || noti->type >= NOTIFICATION_TYPE_MAX) {
1941 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1944 /* Save insert time */
1945 noti->insert_time = time(NULL);
1946 ret = notification_ipc_request_insert(noti, &id);
1947 if (ret != NOTIFICATION_ERROR_NONE) {
1951 NOTIFICATION_DBG("from master:%d", id);
1953 /* If priv_id is valid data, set priv_id */
1954 if (priv_id != NULL) {
1955 *priv_id = noti->priv_id;
1958 return NOTIFICATION_ERROR_NONE;
1961 EXPORT_API int notification_update(notification_h noti)
1965 /* Check noti is valid data */
1967 /* Update insert time ? */
1968 noti->insert_time = time(NULL);
1969 ret = notification_ipc_request_update(noti);
1971 notification_ipc_request_refresh();
1972 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1977 EXPORT_API int notification_update_async(notification_h noti,
1978 void (*result_cb)(int priv_id, int result, void *data), void *user_data)
1983 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1986 /* Update insert time ? */
1987 noti->insert_time = time(NULL);
1988 ret = notification_ipc_request_update_async(noti, result_cb, user_data);
1993 EXPORT_API int notifiation_clear(notification_type_e type)
1997 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1998 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2001 ret = notification_ipc_request_delete_multiple(type, NULL);
2006 EXPORT_API int notification_clear(notification_type_e type)
2010 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
2011 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2014 ret = notification_ipc_request_delete_multiple(type, NULL);
2019 EXPORT_API int notification_delete_all(notification_type_e type)
2022 char *caller_pkgname = NULL;
2024 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
2025 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2028 caller_pkgname = notification_get_pkgname_by_pid();
2030 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
2032 if (caller_pkgname) {
2033 free(caller_pkgname);
2039 EXPORT_API int notification_delete_all_by_type(const char *pkgname,
2040 notification_type_e type)
2043 char *caller_pkgname = NULL;
2045 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
2046 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2049 if (pkgname == NULL) {
2050 caller_pkgname = notification_get_pkgname_by_pid();
2052 caller_pkgname = strdup(pkgname);
2055 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
2057 if (caller_pkgname) {
2058 free(caller_pkgname);
2064 EXPORT_API int notification_delete_by_priv_id(const char *pkgname,
2065 notification_type_e type,
2069 char *caller_pkgname = NULL;
2071 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2072 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2075 if (pkgname == NULL) {
2076 caller_pkgname = notification_get_pkgname_by_pid();
2078 caller_pkgname = strdup(pkgname);
2081 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
2083 if (caller_pkgname) {
2084 free(caller_pkgname);
2090 EXPORT_API int notification_delete(notification_h noti)
2095 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2098 ret = notification_ipc_request_delete_single(NOTIFICATION_TYPE_NONE, noti->caller_pkgname, noti->priv_id);
2103 EXPORT_API int notification_update_progress(notification_h noti,
2107 char *caller_pkgname = NULL;
2108 int input_priv_id = 0;
2110 double input_progress = 0.0;
2112 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2114 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2116 input_priv_id = noti->priv_id;
2119 input_priv_id = priv_id;
2123 caller_pkgname = notification_get_pkgname_by_pid();
2125 caller_pkgname = strdup(noti->caller_pkgname);
2128 if (progress < 0.0) {
2129 input_progress = 0.0;
2130 } else if (progress > 1.0) {
2131 input_progress = 1.0;
2133 input_progress = progress;
2136 ret = notification_ongoing_update_progress(caller_pkgname, input_priv_id,
2139 if (caller_pkgname) {
2140 free(caller_pkgname);
2146 EXPORT_API int notification_update_size(notification_h noti,
2150 char *caller_pkgname = NULL;
2151 int input_priv_id = 0;
2153 double input_size = 0.0;
2155 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2157 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2159 input_priv_id = noti->priv_id;
2162 input_priv_id = priv_id;
2166 caller_pkgname = notification_get_pkgname_by_pid();
2168 caller_pkgname = strdup(noti->caller_pkgname);
2177 ret = notification_ongoing_update_size(caller_pkgname, input_priv_id,
2180 if (caller_pkgname) {
2181 free(caller_pkgname);
2187 EXPORT_API int notification_update_content(notification_h noti,
2189 const char *content)
2191 char *caller_pkgname = NULL;
2192 int input_priv_id = 0;
2195 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2197 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2199 input_priv_id = noti->priv_id;
2202 input_priv_id = priv_id;
2206 caller_pkgname = notification_get_pkgname_by_pid();
2208 caller_pkgname = strdup(noti->caller_pkgname);
2211 ret = notification_ongoing_update_content(caller_pkgname, input_priv_id,
2214 if (caller_pkgname) {
2215 free(caller_pkgname);
2221 static notification_h _notification_create(notification_type_e type)
2223 notification_h noti = NULL;
2225 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
2226 NOTIFICATION_ERR("INVALID TYPE : %d", type);
2227 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
2231 noti = (notification_h) calloc(1, sizeof(struct _notification));
2233 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2234 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2240 if (type == NOTIFICATION_TYPE_NOTI)
2241 noti->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2242 else if (type == NOTIFICATION_TYPE_ONGOING)
2243 noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
2245 noti->caller_pkgname = notification_get_pkgname_by_pid();
2246 noti->group_id = NOTIFICATION_GROUP_ID_NONE;
2247 noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
2248 noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
2249 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
2250 noti->led_operation = NOTIFICATION_LED_OP_OFF;
2251 noti->display_applist = NOTIFICATION_DISPLAY_APP_ALL;
2254 * Other fields are already initialized with ZERO.
2256 set_last_result(NOTIFICATION_ERROR_NONE);
2260 EXPORT_API notification_h notification_new(notification_type_e type,
2261 int group_id, int priv_id)
2263 return _notification_create(type);
2266 EXPORT_API notification_h notification_create(notification_type_e type)
2268 return _notification_create(type);
2271 EXPORT_API notification_h notification_load(char *pkgname,
2275 notification_h noti = NULL;
2277 noti = (notification_h) calloc(1, sizeof(struct _notification));
2279 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2283 ret = notification_noti_get_by_priv_id(noti, pkgname, priv_id);
2284 if (ret != NOTIFICATION_ERROR_NONE) {
2285 notification_free(noti);
2292 EXPORT_API notification_h notification_load_by_tag(const char *tag)
2295 notification_h noti = NULL;
2296 char *caller_pkgname = NULL;
2299 NOTIFICATION_ERR("Invalid parameter");
2300 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
2304 caller_pkgname = notification_get_pkgname_by_pid();
2305 if (!caller_pkgname) {
2306 NOTIFICATION_ERR("Failed to get a package name");
2307 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2312 noti = (notification_h) calloc(1, sizeof(struct _notification));
2314 NOTIFICATION_ERR("Failed to alloc a new notification");
2315 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2316 free(caller_pkgname);
2321 ret = notification_ipc_request_load_noti_by_tag(noti, caller_pkgname, tag);
2323 free(caller_pkgname);
2325 set_last_result(ret);
2327 if (ret != NOTIFICATION_ERROR_NONE) {
2328 notification_free(noti);
2335 EXPORT_API int notification_clone(notification_h noti, notification_h *clone)
2338 notification_h new_noti = NULL;
2340 if (noti == NULL || clone == NULL) {
2341 NOTIFICATION_ERR("INVALID PARAMETER.");
2342 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2345 new_noti = (notification_h) calloc(1, sizeof(struct _notification));
2346 if (new_noti == NULL) {
2347 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2348 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
2351 new_noti->type = noti->type;
2352 new_noti->layout = noti->layout;
2354 new_noti->group_id = noti->group_id;
2355 new_noti->internal_group_id = noti->internal_group_id;
2356 new_noti->priv_id = noti->priv_id;
2358 if(noti->caller_pkgname != NULL) {
2359 new_noti->caller_pkgname = strdup(noti->caller_pkgname);
2361 new_noti->caller_pkgname = notification_get_pkgname_by_pid();
2363 if(noti->launch_pkgname != NULL) {
2364 new_noti->launch_pkgname = strdup(noti->launch_pkgname);
2366 new_noti->launch_pkgname = NULL;
2369 if(noti->args != NULL) {
2370 new_noti->args = bundle_dup(noti->args);
2372 new_noti->args = NULL;
2374 if(noti->group_args != NULL) {
2375 new_noti->group_args = bundle_dup(noti->group_args);
2377 new_noti->group_args = NULL;
2380 if(noti->b_execute_option != NULL) {
2381 new_noti->b_execute_option = bundle_dup(noti->b_execute_option);
2383 new_noti->b_execute_option = NULL;
2385 if(noti->b_service_responding != NULL) {
2386 new_noti->b_service_responding = bundle_dup(noti->b_service_responding);
2388 new_noti->b_service_responding = NULL;
2390 if(noti->b_service_single_launch != NULL) {
2391 new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch);
2393 new_noti->b_service_single_launch = NULL;
2395 if(noti->b_service_multi_launch != NULL) {
2396 new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch);
2398 new_noti->b_service_multi_launch = NULL;
2401 for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
2402 if(noti->b_event_handler[i] != NULL) {
2403 new_noti->b_event_handler[i] = bundle_dup(noti->b_event_handler[i]);
2405 new_noti->b_event_handler[i] = NULL;
2409 new_noti->sound_type = noti->sound_type;
2410 if(noti->sound_path != NULL) {
2411 new_noti->sound_path = strdup(noti->sound_path);
2413 new_noti->sound_path = NULL;
2415 new_noti->vibration_type = noti->vibration_type;
2416 if(noti->vibration_path != NULL) {
2417 new_noti->vibration_path = strdup(noti->vibration_path);
2419 new_noti->vibration_path = NULL;
2421 new_noti->led_operation = noti->led_operation;
2422 new_noti->led_argb = noti->led_argb;
2423 new_noti->led_on_ms = noti->led_on_ms;
2424 new_noti->led_off_ms = noti->led_off_ms;
2426 if(noti->domain != NULL) {
2427 new_noti->domain = strdup(noti->domain);
2429 new_noti->domain = NULL;
2431 if(noti->dir != NULL) {
2432 new_noti->dir = strdup(noti->dir);
2434 new_noti->dir = NULL;
2437 if(noti->b_text != NULL) {
2438 new_noti->b_text = bundle_dup(noti->b_text);
2440 new_noti->b_text = NULL;
2442 if(noti->b_key != NULL) {
2443 new_noti->b_key = bundle_dup(noti->b_key);
2445 new_noti->b_key = NULL;
2447 if(noti->b_format_args != NULL) {
2448 new_noti->b_format_args = bundle_dup(noti->b_format_args);
2450 new_noti->b_format_args = NULL;
2452 new_noti->num_format_args = noti->num_format_args;
2454 if(noti->b_image_path != NULL) {
2455 new_noti->b_image_path = bundle_dup(noti->b_image_path);
2457 new_noti->b_image_path = NULL;
2460 new_noti->time = noti->time;
2461 new_noti->insert_time = noti->insert_time;
2463 new_noti->flags_for_property = noti->flags_for_property;
2464 new_noti->display_applist = noti->display_applist;
2466 new_noti->progress_size = noti->progress_size;
2467 new_noti->progress_percentage = noti->progress_percentage;
2469 new_noti->app_icon_path = NULL;
2470 new_noti->app_name = NULL;
2471 new_noti->temp_title = NULL;
2472 new_noti->temp_content = NULL;
2476 return NOTIFICATION_ERROR_NONE;
2480 EXPORT_API int notification_free(notification_h noti)
2484 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2487 if (noti->caller_pkgname) {
2488 free(noti->caller_pkgname);
2490 if (noti->launch_pkgname) {
2491 free(noti->launch_pkgname);
2494 bundle_free(noti->args);
2496 if (noti->group_args) {
2497 bundle_free(noti->group_args);
2500 if (noti->b_execute_option) {
2501 bundle_free(noti->b_execute_option);
2503 if (noti->b_service_responding) {
2504 bundle_free(noti->b_service_responding);
2506 if (noti->b_service_single_launch) {
2507 bundle_free(noti->b_service_single_launch);
2509 if (noti->b_service_multi_launch) {
2510 bundle_free(noti->b_service_multi_launch);
2513 for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
2514 if(noti->b_event_handler[i] != NULL) {
2515 bundle_free(noti->b_event_handler[i]);
2519 if (noti->sound_path) {
2520 free(noti->sound_path);
2522 if (noti->vibration_path) {
2523 free(noti->vibration_path);
2534 bundle_free(noti->b_text);
2537 bundle_free(noti->b_key);
2539 if (noti->b_format_args) {
2540 bundle_free(noti->b_format_args);
2543 if (noti->b_image_path) {
2544 bundle_free(noti->b_image_path);
2547 if (noti->app_icon_path) {
2548 free(noti->app_icon_path);
2550 if (noti->app_name) {
2551 free(noti->app_name);
2553 if (noti->temp_title) {
2554 free(noti->temp_title);
2556 if (noti->temp_content) {
2557 free(noti->temp_content);
2566 return NOTIFICATION_ERROR_NONE;
2570 notification_resister_changed_cb(void (*changed_cb)
2571 (void *data, notification_type_e type),
2574 notification_cb_list_s *noti_cb_list_new = NULL;
2575 notification_cb_list_s *noti_cb_list = NULL;
2577 if (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_NORMAL;
2591 noti_cb_list_new->changed_cb = changed_cb;
2592 noti_cb_list_new->detailed_changed_cb = NULL;
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_unresister_changed_cb(void (*changed_cb)
2612 (void *data, notification_type_e type))
2614 notification_cb_list_s *noti_cb_list = NULL;
2615 notification_cb_list_s *noti_cb_list_prev = NULL;
2616 notification_cb_list_s *noti_cb_list_next = NULL;
2618 noti_cb_list = g_notification_cb_list;
2620 if (changed_cb == NULL) {
2621 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2623 if (noti_cb_list == NULL) {
2624 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2627 while (noti_cb_list->prev != NULL) {
2628 noti_cb_list = noti_cb_list->prev;
2632 if (noti_cb_list->changed_cb == changed_cb) {
2633 noti_cb_list_prev = noti_cb_list->prev;
2634 noti_cb_list_next = noti_cb_list->next;
2636 if (noti_cb_list_prev == NULL) {
2637 g_notification_cb_list = noti_cb_list_next;
2639 noti_cb_list_prev->next = noti_cb_list_next;
2642 if (noti_cb_list_next == NULL) {
2643 if (noti_cb_list_prev != NULL) {
2644 noti_cb_list_prev->next = NULL;
2647 noti_cb_list_next->prev = noti_cb_list_prev;
2652 if (g_notification_cb_list == NULL)
2653 notification_ipc_monitor_fini();
2655 return NOTIFICATION_ERROR_NONE;
2657 noti_cb_list = noti_cb_list->next;
2658 } while (noti_cb_list != NULL);
2660 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2664 notification_register_detailed_changed_cb(
2665 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
2668 notification_cb_list_s *noti_cb_list_new = NULL;
2669 notification_cb_list_s *noti_cb_list = NULL;
2671 if (detailed_changed_cb == NULL) {
2672 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2674 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
2675 return NOTIFICATION_ERROR_IO_ERROR;
2679 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
2681 noti_cb_list_new->next = NULL;
2682 noti_cb_list_new->prev = NULL;
2684 noti_cb_list_new->cb_type = NOTIFICATION_CB_DETAILED;
2685 noti_cb_list_new->changed_cb = NULL;
2686 noti_cb_list_new->detailed_changed_cb = detailed_changed_cb;
2687 noti_cb_list_new->data = user_data;
2689 if (g_notification_cb_list == NULL) {
2690 g_notification_cb_list = noti_cb_list_new;
2692 noti_cb_list = g_notification_cb_list;
2694 while (noti_cb_list->next != NULL) {
2695 noti_cb_list = noti_cb_list->next;
2698 noti_cb_list->next = noti_cb_list_new;
2699 noti_cb_list_new->prev = noti_cb_list;
2701 return NOTIFICATION_ERROR_NONE;
2705 notification_unregister_detailed_changed_cb(
2706 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
2709 notification_cb_list_s *noti_cb_list = NULL;
2710 notification_cb_list_s *noti_cb_list_prev = NULL;
2711 notification_cb_list_s *noti_cb_list_next = NULL;
2713 noti_cb_list = g_notification_cb_list;
2715 if (detailed_changed_cb == NULL) {
2716 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2718 if (noti_cb_list == NULL) {
2719 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2722 while (noti_cb_list->prev != NULL) {
2723 noti_cb_list = noti_cb_list->prev;
2727 if (noti_cb_list->detailed_changed_cb == detailed_changed_cb) {
2728 noti_cb_list_prev = noti_cb_list->prev;
2729 noti_cb_list_next = noti_cb_list->next;
2731 if (noti_cb_list_prev == NULL) {
2732 g_notification_cb_list = noti_cb_list_next;
2734 noti_cb_list_prev->next = noti_cb_list_next;
2737 if (noti_cb_list_next == NULL) {
2738 if (noti_cb_list_prev != NULL) {
2739 noti_cb_list_prev->next = NULL;
2742 noti_cb_list_next->prev = noti_cb_list_prev;
2747 if (g_notification_cb_list == NULL)
2748 notification_ipc_monitor_fini();
2750 return NOTIFICATION_ERROR_NONE;
2752 noti_cb_list = noti_cb_list->next;
2753 } while (noti_cb_list != NULL);
2755 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2758 EXPORT_API int notification_get_count(notification_type_e type,
2759 const char *pkgname,
2761 int priv_id, int *count)
2766 if (count == NULL) {
2767 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2771 notification_noti_get_count(type, pkgname, group_id, priv_id,
2773 if (ret != NOTIFICATION_ERROR_NONE) {
2777 *count = noti_count;
2779 return NOTIFICATION_ERROR_NONE;
2782 EXPORT_API int notification_get_list(notification_type_e type,
2784 notification_list_h *list)
2786 notification_list_h get_list = NULL;
2790 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2793 ret = notification_noti_get_grouping_list(type, count, &get_list);
2794 if (ret != NOTIFICATION_ERROR_NONE) {
2800 return NOTIFICATION_ERROR_NONE;
2804 notification_get_grouping_list(notification_type_e type, int count,
2805 notification_list_h * list)
2807 notification_list_h get_list = NULL;
2811 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2814 ret = notification_noti_get_grouping_list(type, count, &get_list);
2815 if (ret != NOTIFICATION_ERROR_NONE) {
2821 return NOTIFICATION_ERROR_NONE;
2824 EXPORT_API int notification_get_detail_list(const char *pkgname,
2828 notification_list_h *list)
2830 notification_list_h get_list = NULL;
2834 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2838 notification_noti_get_detail_list(pkgname, group_id, priv_id, count,
2840 if (ret != NOTIFICATION_ERROR_NONE) {
2846 return NOTIFICATION_ERROR_NONE;
2849 EXPORT_API int notification_free_list(notification_list_h list)
2851 notification_list_h cur_list = NULL;
2852 notification_h noti = NULL;
2855 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2858 cur_list = notification_list_get_head(list);
2860 while (cur_list != NULL) {
2861 noti = notification_list_get_data(cur_list);
2862 cur_list = notification_list_remove(cur_list, noti);
2864 notification_free(noti);
2867 return NOTIFICATION_ERROR_NONE;
2870 EXPORT_API int notification_op_get_data(notification_op *noti_op, notification_op_data_type_e type,
2873 if (noti_op == NULL || data == NULL) {
2874 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2878 case NOTIFICATION_OP_DATA_TYPE:
2879 *((int*)data) = noti_op->type;
2881 case NOTIFICATION_OP_DATA_PRIV_ID:
2882 *((int*)data) = noti_op->priv_id;
2884 case NOTIFICATION_OP_DATA_NOTI:
2885 *((notification_h *)data) = noti_op->noti;
2887 case NOTIFICATION_OP_DATA_EXTRA_INFO_1:
2888 *((int*)data) = noti_op->extra_info_1;
2890 case NOTIFICATION_OP_DATA_EXTRA_INFO_2:
2891 *((int*)data) = noti_op->extra_info_2;
2894 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2898 return NOTIFICATION_ERROR_NONE;
2901 void notification_call_changed_cb(notification_op *op_list, int op_num)
2903 notification_cb_list_s *noti_cb_list = NULL;
2904 notification_type_e type = 0;
2906 if (g_notification_cb_list == NULL) {
2909 noti_cb_list = g_notification_cb_list;
2911 while (noti_cb_list->prev != NULL) {
2912 noti_cb_list = noti_cb_list->prev;
2915 if (op_list == NULL) {
2916 NOTIFICATION_ERR("invalid data");
2920 notification_get_type(op_list->noti, &type);
2922 while (noti_cb_list != NULL) {
2923 if (noti_cb_list->cb_type == NOTIFICATION_CB_NORMAL && noti_cb_list->changed_cb) {
2924 noti_cb_list->changed_cb(noti_cb_list->data,
2927 if (noti_cb_list->cb_type == NOTIFICATION_CB_DETAILED && noti_cb_list->detailed_changed_cb) {
2928 noti_cb_list->detailed_changed_cb(noti_cb_list->data,
2929 type, op_list, op_num);
2932 noti_cb_list = noti_cb_list->next;
2936 EXPORT_API int notification_is_service_ready(void)
2938 return notification_ipc_is_master_ready();
2942 notification_add_deferred_task(
2943 void (*deferred_task_cb)(void *data), void *user_data)
2945 if (deferred_task_cb == NULL) {
2946 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2949 return notification_ipc_add_deffered_task(deferred_task_cb, user_data);
2953 notification_del_deferred_task(
2954 void (*deferred_task_cb)(void *data))
2956 if (deferred_task_cb == NULL) {
2957 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2960 return notification_ipc_del_deffered_task(deferred_task_cb);
2963 /* notification_set_icon will be removed */
2964 EXPORT_API int notification_set_icon(notification_h noti,
2965 const char *icon_path)
2967 int ret_err = NOTIFICATION_ERROR_NONE;
2970 notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
2976 /* notification_get_icon will be removed */
2977 EXPORT_API int notification_get_icon(notification_h noti,
2980 int ret_err = NOTIFICATION_ERROR_NONE;
2981 char *ret_image_path = NULL;
2984 notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
2987 if (ret_err == NOTIFICATION_ERROR_NONE && icon_path != NULL) {
2988 *icon_path = ret_image_path;
2990 //NOTIFICATION_DBG("Get icon : %s", *icon_path);
2996 EXPORT_API int notification_set_title(notification_h noti,
2998 const char *loc_title)
3000 int noti_err = NOTIFICATION_ERROR_NONE;
3002 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
3004 NOTIFICATION_VARIABLE_TYPE_NONE);
3009 EXPORT_API int notification_get_title(notification_h noti,
3013 int noti_err = NOTIFICATION_ERROR_NONE;
3014 char *ret_text = NULL;
3017 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
3020 if (title != NULL) {
3024 if (loc_title != NULL) {
3031 EXPORT_API int notification_set_content(notification_h noti,
3032 const char *content,
3033 const char *loc_content)
3035 int noti_err = NOTIFICATION_ERROR_NONE;
3037 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
3038 content, loc_content,
3039 NOTIFICATION_VARIABLE_TYPE_NONE);
3044 EXPORT_API int notification_get_content(notification_h noti,
3048 int noti_err = NOTIFICATION_ERROR_NONE;
3049 char *ret_text = NULL;
3052 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
3055 if (content != NULL) {
3056 *content = ret_text;
3059 if (loc_content != NULL) {
3060 *loc_content = NULL;
3068 (VCONFKEY_SETAPPL_STATE_TICKER_NOTI_DISPLAY_CONTENT_BOOL, &boolval);
3070 if (ret == -1 || boolval == 0) {
3071 if (content != NULL && noti->default_content != NULL) {
3072 *content = noti->default_content;
3075 if (loc_content != NULL && noti->loc_default_content != NULL) {
3076 *loc_content = noti->loc_default_content;
3082 EXPORT_API int notification_set_args(notification_h noti,
3084 bundle * group_args)
3086 if (noti == NULL || args == NULL) {
3087 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3091 bundle_free(noti->args);
3094 noti->args = bundle_dup(args);
3096 if (noti->group_args) {
3097 bundle_free(noti->group_args);
3098 noti->group_args = NULL;
3101 if (group_args != NULL) {
3102 noti->group_args = bundle_dup(group_args);
3105 return NOTIFICATION_ERROR_NONE;
3108 EXPORT_API int notification_get_args(notification_h noti,
3110 bundle ** group_args)
3112 if (noti == NULL || args == NULL) {
3113 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3122 if (group_args != NULL && noti->group_args) {
3123 *group_args = noti->group_args;
3126 return NOTIFICATION_ERROR_NONE;
3129 EXPORT_API int notification_delete_group_by_group_id(const char *pkgname,
3130 notification_type_e type,
3134 char *caller_pkgname = NULL;
3136 if (pkgname == NULL) {
3137 caller_pkgname = notification_get_pkgname_by_pid();
3139 caller_pkgname = strdup(pkgname);
3142 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
3143 if (ret != NOTIFICATION_ERROR_NONE) {
3144 if (caller_pkgname) {
3145 free(caller_pkgname);
3150 if (caller_pkgname) {
3151 free(caller_pkgname);
3153 return NOTIFICATION_ERROR_NONE;
3156 EXPORT_API int notification_delete_group_by_priv_id(const char *pkgname,
3157 notification_type_e type,
3161 char *caller_pkgname = NULL;
3163 if (pkgname == NULL) {
3164 caller_pkgname = notification_get_pkgname_by_pid();
3166 caller_pkgname = strdup(pkgname);
3169 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
3170 if (ret != NOTIFICATION_ERROR_NONE) {
3171 if (caller_pkgname) {
3172 free(caller_pkgname);
3177 if (caller_pkgname) {
3178 free(caller_pkgname);
3180 return NOTIFICATION_ERROR_NONE;
3183 EXPORT_API int notification_set_tag(notification_h noti, const char *tag)
3185 /* Check noti is valid data */
3187 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3191 /* save input TAG */
3192 if (noti->tag != NULL) {
3195 noti->tag = strdup(tag);
3198 return NOTIFICATION_ERROR_NONE;
3202 EXPORT_API int notification_get_tag(notification_h noti, const char **tag)
3204 /* Check noti is valid data */
3206 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3209 /* Set sound type */
3211 return NOTIFICATION_ERROR_NONE;
3214 EXPORT_API int notification_register_toast_message(void (*posted_toast_cb) (void *data))
3216 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
3217 return NOTIFICATION_ERROR_IO_ERROR;
3220 posted_toast_message_cb = posted_toast_cb;
3222 return NOTIFICATION_ERROR_NONE;
3225 void notification_call_posted_toast_cb(const char *message)
3227 if (posted_toast_message_cb != NULL) {
3228 posted_toast_message_cb((void*)message);
3232 EXPORT_API int notification_set_permission(notification_h handle, notification_permission_type_e permission_type, const char *app_id)
3234 return NOTIFICATION_ERROR_INVALID_OPERATION;
3237 EXPORT_API int notification_get_permission(notification_h handle, notification_permission_type_e *permission_type, const char **app_id)
3239 return NOTIFICATION_ERROR_INVALID_OPERATION;
3242 EXPORT_API int notification_set_ongoing_flag(notification_h noti, bool ongoing_flag)
3244 return NOTIFICATION_ERROR_INVALID_OPERATION;
3247 EXPORT_API int notification_get_ongoing_flag(notification_h noti, bool *ongoing_flag)
3249 return NOTIFICATION_ERROR_INVALID_OPERATION;