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>, Youngsub Ko <ys4610.ko@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>
34 #include <vconf-keys.h>
37 #include <notification.h>
38 #include <notification_list.h>
39 #include <notification_debug.h>
40 #include <notification_internal.h>
41 #include <notification_noti.h>
42 #include <notification_ongoing.h>
43 #include <notification_group.h>
44 #include <notification_ipc.h>
46 typedef struct _notification_cb_list notification_cb_list_s;
48 typedef enum __notification_cb_type {
49 NOTIFICATION_CB_NORMAL = 1,
50 NOTIFICATION_CB_DETAILED,
51 } _notification_cb_type_e;
53 struct _notification_cb_list {
54 notification_cb_list_s *prev;
55 notification_cb_list_s *next;
57 _notification_cb_type_e cb_type;
58 void (*changed_cb) (void *data, notification_type_e type);
59 void (*detailed_changed_cb) (void *data, notification_type_e type, notification_op *op_list, int num_op);
63 static notification_cb_list_s *g_notification_cb_list = NULL;
65 #define NOTI_TEXT_RESULT_LEN 2048
66 #define NOTI_PKGNAME_LEN 512
67 #define NOTI_CHANGED_NOTI "notification_noti_changed"
68 #define NOTI_CHANGED_ONGOING "notification_ontoing_changed"
70 #define NOTI_DBUS_BUS_NAME "org.tizen.libnotification"
71 #define NOTI_DBUS_PATH "/org/tizen/libnotification"
72 #define NOTI_DBUS_INTERFACE "org.tizen.libnotification.signal"
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 char *_notification_get_icon(const char *package)
122 ail_appinfo_h handle;
127 ret = ail_package_get_appinfo(package, &handle);
128 if (ret != AIL_ERROR_OK) {
132 ret = ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &str);
133 if (ret != AIL_ERROR_OK) {
134 ail_package_destroy_appinfo(handle);
140 ret = ail_package_destroy_appinfo(handle);
141 if (ret != AIL_ERROR_OK) {
142 NOTIFICATION_ERR("Fail to ail_package_destroy_appinfo");
148 static char *_notification_get_name(const char *package)
150 ail_appinfo_h handle;
155 ret = ail_package_get_appinfo(package, &handle);
156 if (ret != AIL_ERROR_OK) {
160 ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
161 if (ret != AIL_ERROR_OK) {
162 ail_package_destroy_appinfo(handle);
168 ret = ail_package_destroy_appinfo(handle);
169 if (ret != AIL_ERROR_OK) {
170 NOTIFICATION_ERR("Fail to ail_package_destroy_appinfo");
176 static void _notification_get_text_domain(notification_h noti)
178 if (noti->domain != NULL) {
182 if (noti->dir != NULL) {
187 /* notification_set_icon will be removed */
188 EXPORT_API notification_error_e notification_set_icon(notification_h noti,
189 const char *icon_path)
191 int ret_err = NOTIFICATION_ERROR_NONE;
194 notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
200 /* notification_get_icon will be removed */
201 EXPORT_API notification_error_e notification_get_icon(notification_h noti,
204 int ret_err = NOTIFICATION_ERROR_NONE;
205 char *ret_image_path = NULL;
208 notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
211 if (ret_err == NOTIFICATION_ERROR_NONE && icon_path != NULL) {
212 *icon_path = ret_image_path;
214 //NOTIFICATION_DBG("Get icon : %s", *icon_path);
220 EXPORT_API notification_error_e notification_set_image(notification_h noti,
221 notification_image_type_e type,
222 const char *image_path)
225 char buf_key[32] = { 0, };
226 const char *ret_val = NULL;
228 /* Check noti and image_path are valid data */
229 if (noti == NULL || image_path == NULL) {
230 return NOTIFICATION_ERROR_INVALID_DATA;
233 /* Check image type is valid type */
234 if (type <= NOTIFICATION_IMAGE_TYPE_NONE
235 || type >= NOTIFICATION_IMAGE_TYPE_MAX) {
236 return NOTIFICATION_ERROR_INVALID_DATA;
239 /* Check image path bundle is exist */
240 if (noti->b_image_path) {
241 /* If image path bundle is exist, store local bundle value */
242 b = noti->b_image_path;
244 /* Set image type to key as char string type */
245 snprintf(buf_key, sizeof(buf_key), "%d", type);
247 /* Get value using key */
248 ret_val = bundle_get_val(b, buf_key);
249 if (ret_val != NULL) {
250 /* If key is exist, remove this value to store new image path */
251 bundle_del(b, buf_key);
254 /* Add new image path with type key */
255 bundle_add(b, buf_key, image_path);
257 /* If image path bundle is not exist, create new one */
260 /* Set image type to key as char string type */
261 snprintf(buf_key, sizeof(buf_key), "%d", type);
263 /* Add new image path with type key */
264 bundle_add(b, buf_key, image_path);
266 /* Save to image path bundle */
267 noti->b_image_path = b;
270 return NOTIFICATION_ERROR_NONE;
273 EXPORT_API notification_error_e notification_get_image(notification_h noti,
274 notification_image_type_e type,
278 char buf_key[32] = { 0, };
279 const char *ret_val = NULL;
280 const char *pkgname = NULL;
282 /* Check noti and image_path is valid data */
283 if (noti == NULL || image_path == NULL) {
284 return NOTIFICATION_ERROR_INVALID_DATA;
287 /* Check image type is valid data */
288 if (type <= NOTIFICATION_IMAGE_TYPE_NONE
289 || type >= NOTIFICATION_IMAGE_TYPE_MAX) {
290 return NOTIFICATION_ERROR_INVALID_DATA;
293 /* Check image path bundle exist */
294 if (noti->b_image_path) {
295 /* If image path bundle exist, store local bundle data */
296 b = noti->b_image_path;
298 /* Set image type to key as char string type */
299 snprintf(buf_key, sizeof(buf_key), "%d", type);
301 /* Get value of key */
302 ret_val = bundle_get_val(b, buf_key);
304 *image_path = (char *)ret_val;
306 /* If image path bundle does not exist, image path is NULL */
310 /* If image path is NULL and type is ICON, icon path set from AIL */
311 /* order : user icon -> launch_pkgname icon -> caller_pkgname icon -> service app icon */
312 if (*image_path == NULL && type == NOTIFICATION_IMAGE_TYPE_ICON) {
313 /* Check App icon path is already set */
314 if (noti->app_icon_path != NULL) {
315 /* image path will be app icon path */
316 *image_path = noti->app_icon_path;
318 /* Get image path using launch_pkgname */
319 if (noti->launch_pkgname != NULL) {
320 noti->app_icon_path =
321 _notification_get_icon(noti->launch_pkgname);
324 /* If app icon path is NULL, get image path using caller_pkgname */
325 if (noti->app_icon_path == NULL
326 && noti->caller_pkgname != NULL) {
327 noti->app_icon_path =
328 _notification_get_icon(noti->caller_pkgname);
331 /* If app icon path is NULL, get image path using service data */
332 if (noti->app_icon_path == NULL
333 && noti->b_service_single_launch != NULL) {
335 appsvc_get_pkgname(noti->b_service_single_launch);
336 if (pkgname != NULL) {
337 noti->app_icon_path =
338 _notification_get_icon(pkgname);
342 *image_path = noti->app_icon_path;
346 return NOTIFICATION_ERROR_NONE;
349 EXPORT_API notification_error_e notification_set_time(notification_h noti,
352 /* Check noti is valid data */
354 return NOTIFICATION_ERROR_INVALID_DATA;
357 if (input_time == 0) {
358 /* If input time is 0, set current time */
359 noti->time = time(NULL);
361 /* save input time */
362 noti->time = input_time;
365 return NOTIFICATION_ERROR_NONE;
368 EXPORT_API notification_error_e notification_get_time(notification_h noti,
371 /* Check noti and time is valid data */
372 if (noti == NULL || ret_time == NULL) {
373 return NOTIFICATION_ERROR_INVALID_DATA;
376 /* Set time infomation */
377 *ret_time = noti->time;
379 return NOTIFICATION_ERROR_NONE;
382 EXPORT_API notification_error_e notification_get_insert_time(notification_h noti,
385 /* Check noti and ret_time is valid data */
386 if (noti == NULL || ret_time == NULL) {
387 return NOTIFICATION_ERROR_INVALID_DATA;
390 /* Set insert time information */
391 *ret_time = noti->insert_time;
393 return NOTIFICATION_ERROR_NONE;
396 EXPORT_API notification_error_e notification_set_title(notification_h noti,
398 const char *loc_title)
400 int noti_err = NOTIFICATION_ERROR_NONE;
402 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
404 NOTIFICATION_VARIABLE_TYPE_NONE);
409 EXPORT_API notification_error_e notification_get_title(notification_h noti,
413 int noti_err = NOTIFICATION_ERROR_NONE;
414 char *ret_text = NULL;
417 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
424 if (loc_title != NULL) {
431 EXPORT_API notification_error_e notification_set_content(notification_h noti,
433 const char *loc_content)
435 int noti_err = NOTIFICATION_ERROR_NONE;
437 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
438 content, loc_content,
439 NOTIFICATION_VARIABLE_TYPE_NONE);
444 EXPORT_API notification_error_e notification_get_content(notification_h noti,
448 int noti_err = NOTIFICATION_ERROR_NONE;
449 char *ret_text = NULL;
452 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
455 if (content != NULL) {
459 if (loc_content != NULL) {
468 (VCONFKEY_SETAPPL_STATE_TICKER_NOTI_DISPLAY_CONTENT_BOOL, &boolval);
470 if (ret == -1 || boolval == 0) {
471 if (content != NULL && noti->default_content != NULL) {
472 *content = noti->default_content;
475 if (loc_content != NULL && noti->loc_default_content != NULL) {
476 *loc_content = noti->loc_default_content;
482 EXPORT_API notification_error_e notification_set_text(notification_h noti,
483 notification_text_type_e type,
489 char buf_key[32] = { 0, };
490 char buf_val[1024] = { 0, };
491 const char *ret_val = NULL;
493 notification_variable_type_e var_type;
495 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
496 int var_value_int = 0;
497 double var_value_double = 0.0;
498 char *var_value_string = NULL;
499 notification_count_pos_type_e var_value_count =
500 NOTIFICATION_COUNT_POS_NONE;
502 /* Check noti is valid data */
504 return NOTIFICATION_ERROR_INVALID_DATA;
507 /* Check text type is valid type */
508 if (type <= NOTIFICATION_TEXT_TYPE_NONE
509 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
510 return NOTIFICATION_ERROR_INVALID_DATA;
513 /* Check text bundle exist */
515 if (noti->b_text != NULL) {
516 /* If text bundle exist, store local bundle data */
519 /* Make type to key as char string */
520 snprintf(buf_key, sizeof(buf_key), "%d", type);
522 /* Get value using type key */
523 ret_val = bundle_get_val(b, buf_key);
524 if (ret_val != NULL) {
525 /* If value exist, remove this to add new value */
526 bundle_del(b, buf_key);
529 snprintf(buf_val, sizeof(buf_val), "%s", text);
531 /* Add new text value */
532 bundle_add(b, buf_key, buf_val);
534 /* If text bundle does not exist, create new one */
537 /* Make type to key as char string */
538 snprintf(buf_key, sizeof(buf_key), "%d", type);
540 snprintf(buf_val, sizeof(buf_val), "%s", text);
542 /* Add new text value */
543 bundle_add(b, buf_key, buf_val);
545 /* Save text bundle */
549 /* Reset if text is NULL */
550 if (noti->b_text != NULL) {
551 /* If text bundle exist, store local bundle data */
554 /* Make type to key as char string */
555 snprintf(buf_key, sizeof(buf_key), "%d", type);
557 /* Get value using type key */
558 ret_val = bundle_get_val(b, buf_key);
559 if (ret_val != NULL) {
560 /* If value exist, remove this */
561 bundle_del(b, buf_key);
566 /* Save key if key is valid data */
568 /* Check key bundle exist */
569 if (noti->b_key != NULL) {
570 /* If key bundle exist, store local bundle data */
573 /* Make type to key as char string */
574 snprintf(buf_key, sizeof(buf_key), "%d", type);
576 /* Get value using type key */
577 ret_val = bundle_get_val(b, buf_key);
578 if (ret_val != NULL) {
579 /* If value exist, remove this to add new value */
580 bundle_del(b, buf_key);
583 snprintf(buf_val, sizeof(buf_val), "%s", key);
585 /* Add new key value */
586 bundle_add(b, buf_key, buf_val);
588 /* If key bundle does not exist, create new one */
591 /* Make type to key as char string */
592 snprintf(buf_key, sizeof(buf_key), "%d", type);
594 snprintf(buf_val, sizeof(buf_val), "%s", key);
596 /* Add new key value */
597 bundle_add(b, buf_key, buf_val);
599 /* Save key bundle */
603 /* Reset if key is NULL */
604 if (noti->b_key != NULL) {
605 /* If key bundle exist, store local bundle data */
608 /* Make type to key as char string */
609 snprintf(buf_key, sizeof(buf_key), "%d", type);
611 /* Get value using type key */
612 ret_val = bundle_get_val(b, buf_key);
613 if (ret_val != NULL) {
614 /* If value exist, remove this */
615 bundle_del(b, buf_key);
620 if (noti->b_format_args != NULL) {
621 b = noti->b_format_args;
626 va_start(var_args, args_type);
628 var_type = args_type;
631 while (var_type != NOTIFICATION_VARIABLE_TYPE_NONE) {
633 snprintf(buf_key, sizeof(buf_key), "%dtype%d", type, num_args);
634 snprintf(buf_val, sizeof(buf_val), "%d", var_type);
636 ret_val = bundle_get_val(b, buf_key);
637 if (ret_val != NULL) {
638 bundle_del(b, buf_key);
641 bundle_add(b, buf_key, buf_val);
644 case NOTIFICATION_VARIABLE_TYPE_INT:
645 var_value_int = va_arg(var_args, int);
648 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
650 snprintf(buf_val, sizeof(buf_val), "%d", var_value_int);
652 ret_val = bundle_get_val(b, buf_key);
653 if (ret_val != NULL) {
654 bundle_del(b, buf_key);
657 bundle_add(b, buf_key, buf_val);
659 case NOTIFICATION_VARIABLE_TYPE_DOUBLE:
660 var_value_double = va_arg(var_args, double);
663 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
665 snprintf(buf_val, sizeof(buf_val), "%.2f",
668 ret_val = bundle_get_val(b, buf_key);
669 if (ret_val != NULL) {
670 bundle_del(b, buf_key);
673 bundle_add(b, buf_key, buf_val);
675 case NOTIFICATION_VARIABLE_TYPE_STRING:
676 var_value_string = va_arg(var_args, char *);
679 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
681 snprintf(buf_val, sizeof(buf_val), "%s",
684 ret_val = bundle_get_val(b, buf_key);
685 if (ret_val != NULL) {
686 bundle_del(b, buf_key);
689 bundle_add(b, buf_key, buf_val);
691 case NOTIFICATION_VARIABLE_TYPE_COUNT:
693 va_arg(var_args, notification_count_pos_type_e);
696 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
698 snprintf(buf_val, sizeof(buf_val), "%d",
701 ret_val = bundle_get_val(b, buf_key);
702 if (ret_val != NULL) {
703 bundle_del(b, buf_key);
706 bundle_add(b, buf_key, buf_val);
709 NOTIFICATION_ERR("Error. invalid variable type. : %d",
711 noti_err = NOTIFICATION_ERROR_INVALID_DATA;
716 var_type = va_arg(var_args, notification_variable_type_e);
720 if (noti_err == NOTIFICATION_ERROR_NONE) {
721 noti->num_format_args = num_args;
723 noti->num_format_args = 0;
726 snprintf(buf_key, sizeof(buf_key), "num%d", type);
727 snprintf(buf_val, sizeof(buf_val), "%d", noti->num_format_args);
729 ret_val = bundle_get_val(b, buf_key);
730 if (ret_val != NULL) {
731 bundle_del(b, buf_key);
734 bundle_add(b, buf_key, buf_val);
736 noti->b_format_args = b;
741 EXPORT_API notification_error_e notification_get_text(notification_h noti,
742 notification_text_type_e type,
746 char buf_key[32] = { 0, };
747 const char *ret_val = NULL;
748 const char *pkgname = NULL;
749 const char *get_str = NULL;
750 const char *get_check_type_str = NULL;
753 notification_text_type_e check_type = NOTIFICATION_TEXT_TYPE_NONE;
754 int display_option_flag = 0;
756 char *temp_str = NULL;
757 char result_str[NOTI_TEXT_RESULT_LEN] = { 0, };
758 char buf_str[1024] = { 0, };
760 notification_variable_type_e ret_var_type = 0;
761 int ret_variable_int = 0;
762 double ret_variable_double = 0.0;
764 /* Check noti is valid data */
765 if (noti == NULL || text == NULL) {
766 return NOTIFICATION_ERROR_INVALID_DATA;
769 /* Check text type is valid type */
770 if (type <= NOTIFICATION_TEXT_TYPE_NONE
771 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
772 return NOTIFICATION_ERROR_INVALID_DATA;
776 if (noti->b_key != NULL) {
779 /* Get text domain and dir */
780 _notification_get_text_domain(noti);
782 snprintf(buf_key, sizeof(buf_key), "%d", type);
784 ret_val = bundle_get_val(b, buf_key);
785 if (ret_val != NULL && noti->domain != NULL
786 && noti->dir != NULL) {
787 /* Get application string */
788 bindtextdomain(noti->domain, noti->dir);
790 get_str = dgettext(noti->domain, ret_val);
791 } else if (ret_val != NULL) {
792 /* Get system string */
793 get_str = dgettext("sys_string", ret_val);
799 if (get_str == NULL && noti->b_text != NULL) {
802 snprintf(buf_key, sizeof(buf_key), "%d", type);
804 get_str = bundle_get_val(b, buf_key);
809 /* Set display option is off type when option is off, type is noti */
810 if (get_str != NULL && display_option_flag == 1
811 && noti->type == NOTIFICATION_TYPE_NOTI) {
812 if (type == NOTIFICATION_TEXT_TYPE_CONTENT
813 || type == NOTIFICATION_TEXT_TYPE_GROUP_CONTENT) {
814 /* Set check_type to option content string */
815 if (type == NOTIFICATION_TEXT_TYPE_CONTENT) {
817 NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF;
818 } else if (type == NOTIFICATION_TEXT_TYPE_GROUP_CONTENT) {
820 NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF;
824 if (noti->b_key != NULL) {
827 /* Get text domain and dir */
828 _notification_get_text_domain(noti);
830 snprintf(buf_key, sizeof(buf_key), "%d",
833 ret_val = bundle_get_val(b, buf_key);
834 if (ret_val != NULL && noti->domain != NULL
835 && noti->dir != NULL) {
836 /* Get application string */
837 bindtextdomain(noti->domain, noti->dir);
840 dgettext(noti->domain, ret_val);
841 } else if (ret_val != NULL) {
842 /* Get system string */
844 dgettext("sys_string", ret_val);
846 get_check_type_str = NULL;
850 if (get_check_type_str == NULL && noti->b_text != NULL) {
853 snprintf(buf_key, sizeof(buf_key), "%d",
856 get_check_type_str = bundle_get_val(b, buf_key);
860 if (get_check_type_str != NULL) {
861 /* Replace option off type string */
862 get_str = get_check_type_str;
864 /* Set default string */
866 dgettext("sys_string", "IDS_COM_POP_MISSED_EVENT");
870 if (get_str != NULL) {
871 /* Get number format args */
872 b = noti->b_format_args;
873 noti->num_format_args = 0;
876 snprintf(buf_key, sizeof(buf_key), "num%d", check_type);
877 ret_val = bundle_get_val(b, buf_key);
878 if (ret_val != NULL) {
879 noti->num_format_args = atoi(ret_val);
883 if (noti->num_format_args == 0) {
884 *text = (char *)get_str;
886 /* Check first variable is count, LEFT pos */
887 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
888 check_type, num_args);
889 ret_val = bundle_get_val(b, buf_key);
890 ret_var_type = atoi(ret_val);
892 if (ret_var_type == NOTIFICATION_VARIABLE_TYPE_COUNT) {
894 snprintf(buf_key, sizeof(buf_key), "%dvalue%d",
895 check_type, num_args);
896 ret_val = bundle_get_val(b, buf_key);
897 ret_variable_int = atoi(ret_val);
899 if (ret_variable_int ==
900 NOTIFICATION_COUNT_POS_LEFT) {
901 notification_noti_get_count(noti->type,
902 noti->caller_pkgname,
906 snprintf(buf_str, sizeof(buf_str),
907 "%d ", ret_variable_int);
909 int src_len = strlen(result_str);
910 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
912 strncat(result_str, buf_str,
920 /* Check variable IN pos */
921 for (temp_str = (char *)get_str; *temp_str != '\0';
923 if (*temp_str != '%') {
924 strncat(result_str, temp_str, 1);
926 if (*(temp_str + 1) == '%') {
927 strncat(result_str, temp_str,
929 } else if (*(temp_str + 1) == 'd') {
931 ret_variable_int = 0;
935 "%dtype%d", check_type,
938 bundle_get_val(b, buf_key);
939 ret_var_type = atoi(ret_val);
941 NOTIFICATION_VARIABLE_TYPE_COUNT)
943 /* Get notification count */
944 notification_noti_get_count
946 noti->caller_pkgname,
966 sizeof(buf_str), "%d",
969 int src_len = strlen(result_str);
970 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
972 strncat(result_str, buf_str,
978 } else if (*(temp_str + 1) == 's') {
983 check_type, num_args);
985 bundle_get_val(b, buf_key);
988 sizeof(buf_str), "%s",
991 int src_len = strlen(result_str);
992 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
994 strncat(result_str, buf_str,
1000 } else if (*(temp_str + 1) == 'f') {
1005 check_type, num_args);
1007 bundle_get_val(b, buf_key);
1008 ret_variable_double =
1014 ret_variable_double);
1016 int src_len = strlen(result_str);
1017 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
1019 strncat(result_str, buf_str,
1030 /* Check last variable is count, LEFT pos */
1031 if (num_args < noti->num_format_args) {
1032 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
1033 check_type, num_args);
1034 ret_val = bundle_get_val(b, buf_key);
1035 ret_var_type = atoi(ret_val);
1037 NOTIFICATION_VARIABLE_TYPE_COUNT) {
1039 snprintf(buf_key, sizeof(buf_key),
1040 "%dvalue%d", check_type,
1042 ret_val = bundle_get_val(b, buf_key);
1043 ret_variable_int = atoi(ret_val);
1045 if (ret_variable_int ==
1046 NOTIFICATION_COUNT_POS_RIGHT) {
1047 notification_noti_get_count
1049 noti->caller_pkgname,
1054 sizeof(buf_str), " %d",
1057 int src_len = strlen(result_str);
1058 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
1060 strncat(result_str, buf_str,
1069 switch (check_type) {
1070 case NOTIFICATION_TEXT_TYPE_TITLE:
1071 case NOTIFICATION_TEXT_TYPE_GROUP_TITLE:
1072 if (noti->temp_title != NULL)
1073 free(noti->temp_title);
1075 noti->temp_title = strdup(result_str);
1077 *text = noti->temp_title;
1079 case NOTIFICATION_TEXT_TYPE_CONTENT:
1080 case NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
1081 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT:
1082 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
1083 if (noti->temp_content !=
1085 free(noti->temp_content);
1087 noti->temp_content = strdup(result_str);
1089 *text = noti->temp_content;
1098 if (check_type == NOTIFICATION_TEXT_TYPE_TITLE
1099 || check_type == NOTIFICATION_TEXT_TYPE_GROUP_TITLE) {
1100 /* Remove app name if exist, because pkgname is changed according to language setting */
1101 if (noti->app_name != NULL) {
1102 free(noti->app_name);
1103 noti->app_name = NULL;
1106 /* First, get app name from launch_pkgname */
1107 if (noti->launch_pkgname != NULL) {
1109 _notification_get_name(noti->
1113 /* Second, get app name from caller_pkgname */
1114 if (noti->app_name == NULL
1115 && noti->caller_pkgname != NULL) {
1117 _notification_get_name(noti->
1121 /* Third, get app name from service data */
1122 if (noti->app_name == NULL
1123 && noti->b_service_single_launch != NULL) {
1125 appsvc_get_pkgname(noti->
1126 b_service_single_launch);
1128 if (pkgname != NULL) {
1130 _notification_get_name(pkgname);
1134 *text = noti->app_name;
1140 return NOTIFICATION_ERROR_NONE;
1143 EXPORT_API notification_error_e notification_set_text_domain(notification_h noti,
1147 /* check noti and domain is valid data */
1148 if (noti == NULL || domain == NULL) {
1149 return NOTIFICATION_ERROR_INVALID_DATA;
1154 /* Remove previous domain */
1158 noti->domain = strdup(domain);
1160 /* Check locale dir */
1162 /* Remove previous locale dir */
1165 /* Copy locale dir */
1166 noti->dir = strdup(dir);
1168 return NOTIFICATION_ERROR_NONE;
1171 EXPORT_API notification_error_e notification_get_text_domain(notification_h noti,
1175 /* Check noti is valid data */
1177 return NOTIFICATION_ERROR_INVALID_DATA;
1181 if (domain != NULL && noti->domain != NULL) {
1182 *domain = noti->domain;
1185 /* Get locale dir */
1186 if (dir != NULL && noti->dir != NULL) {
1190 return NOTIFICATION_ERROR_NONE;
1193 EXPORT_API notification_error_e notification_set_time_to_text(notification_h noti, notification_text_type_e type,
1196 notification_error_e ret = NOTIFICATION_ERROR_NONE;
1197 char buf[256] = { 0, };
1198 char buf_tag[512] = { 0, };
1201 return NOTIFICATION_ERROR_INVALID_DATA;
1204 return NOTIFICATION_ERROR_INVALID_DATA;
1207 snprintf(buf, sizeof(buf), "%lu", time);
1208 ret = notification_noti_set_tag(TAG_TIME, buf, buf_tag, sizeof(buf_tag));
1210 if (ret != NOTIFICATION_ERROR_NONE) {
1214 return notification_set_text(noti, type, buf_tag, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1217 EXPORT_API notification_error_e notification_get_time_from_text(notification_h noti, notification_text_type_e type,
1220 notification_error_e ret = NOTIFICATION_ERROR_NONE;
1221 char buf[256] = { 0, };
1222 char buf_tag[512] = { 0, };
1225 return NOTIFICATION_ERROR_INVALID_DATA;
1228 return NOTIFICATION_ERROR_INVALID_DATA;
1231 char *ret_text = NULL;
1232 ret = notification_get_text(noti, type, &ret_text);
1234 if (ret != NOTIFICATION_ERROR_NONE || ret_text == NULL) {
1235 return NOTIFICATION_ERROR_INVALID_DATA;
1238 if (notification_noti_get_tag_type(ret_text) == TAG_TYPE_INVALID) {
1239 return NOTIFICATION_ERROR_INVALID_DATA;
1242 char *tag_value = NULL;
1243 tag_value = notification_noti_strip_tag(ret_text);
1244 if (tag_value == NULL) {
1245 return NOTIFICATION_ERROR_INVALID_DATA;
1248 *time = atol(tag_value);
1251 return NOTIFICATION_ERROR_NONE;
1254 EXPORT_API notification_error_e notification_set_sound(notification_h noti,
1255 notification_sound_type_e type,
1258 /* Check noti is valid data */
1260 return NOTIFICATION_ERROR_INVALID_DATA;
1263 /* Check type is valid */
1264 if (type < NOTIFICATION_SOUND_TYPE_NONE
1265 || type >= NOTIFICATION_SOUND_TYPE_MAX) {
1266 return NOTIFICATION_ERROR_INVALID_DATA;
1269 /* Save sound type */
1270 noti->sound_type = type;
1272 /* Save sound path if user data type */
1273 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA && path != NULL) {
1274 if (noti->sound_path != NULL) {
1275 free(noti->sound_path);
1278 noti->sound_path = strdup(path);
1280 if (noti->sound_path != NULL) {
1281 free(noti->sound_path);
1282 noti->sound_path = NULL;
1286 return NOTIFICATION_ERROR_NONE;
1289 EXPORT_API notification_error_e notification_get_sound(notification_h noti,
1290 notification_sound_type_e *type,
1293 /* check noti and type is valid data */
1294 if (noti == NULL || type == NULL) {
1295 return NOTIFICATION_ERROR_INVALID_DATA;
1298 /* Set sound type */
1299 *type = noti->sound_type;
1301 /* Set sound path if user data type */
1302 if (noti->sound_type == NOTIFICATION_SOUND_TYPE_USER_DATA
1304 *path = noti->sound_path;
1307 return NOTIFICATION_ERROR_NONE;
1310 EXPORT_API notification_error_e notification_set_vibration(notification_h noti,
1311 notification_vibration_type_e type,
1314 /* Check noti is valid data */
1316 return NOTIFICATION_ERROR_INVALID_DATA;
1319 /* Check type is valid */
1320 if (type < NOTIFICATION_VIBRATION_TYPE_NONE
1321 || type >= NOTIFICATION_VIBRATION_TYPE_MAX) {
1322 return NOTIFICATION_ERROR_INVALID_DATA;
1325 /* Save vibration type */
1326 noti->vibration_type = type;
1328 /* Save sound path if user data type */
1329 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA && path != NULL) {
1330 if (noti->vibration_path != NULL) {
1331 free(noti->vibration_path);
1334 noti->vibration_path = strdup(path);
1336 if (noti->vibration_path != NULL) {
1337 free(noti->vibration_path);
1338 noti->vibration_path = NULL;
1342 return NOTIFICATION_ERROR_NONE;
1346 EXPORT_API notification_error_e notification_get_vibration(notification_h noti,
1347 notification_vibration_type_e *type,
1350 /* check noti and type is valid data */
1351 if (noti == NULL || type == NULL) {
1352 return NOTIFICATION_ERROR_INVALID_DATA;
1355 /* Set vibration type */
1356 *type = noti->vibration_type;
1358 /* Set sound path if user data type */
1359 if (noti->vibration_type == NOTIFICATION_VIBRATION_TYPE_USER_DATA
1361 *path = noti->vibration_path;
1364 return NOTIFICATION_ERROR_NONE;
1367 EXPORT_API notification_error_e notification_set_led(notification_h noti,
1368 notification_led_op_e operation,
1371 /* Check noti is valid data */
1373 return NOTIFICATION_ERROR_INVALID_DATA;
1376 /* Check operation is valid */
1377 if (operation < NOTIFICATION_LED_OP_OFF
1378 || operation >= NOTIFICATION_LED_OP_MAX) {
1379 return NOTIFICATION_ERROR_INVALID_DATA;
1382 /* Save led operation */
1383 noti->led_operation = operation;
1385 /* Save led argb if operation is turning on LED with custom color */
1386 if (operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR) {
1387 noti->led_argb = led_argb;
1390 return NOTIFICATION_ERROR_NONE;
1393 EXPORT_API notification_error_e notification_get_led(notification_h noti,
1394 notification_led_op_e *operation,
1397 /* check noti and operation is valid data */
1398 if (noti == NULL || operation == NULL) {
1399 return NOTIFICATION_ERROR_INVALID_DATA;
1402 /* Set led operation */
1403 *operation = noti->led_operation;
1405 /* Save led argb if operation is turning on LED with custom color */
1406 if (noti->led_operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR
1407 && led_argb != NULL) {
1408 *led_argb = noti->led_argb;
1411 return NOTIFICATION_ERROR_NONE;
1414 EXPORT_API notification_error_e notification_set_led_time_period(notification_h noti,
1415 int on_ms, int off_ms)
1417 /* Check noti is valid data */
1419 return NOTIFICATION_ERROR_INVALID_DATA;
1422 /* Save led operation */
1423 noti->led_on_ms = on_ms;
1424 noti->led_off_ms = off_ms;
1426 return NOTIFICATION_ERROR_NONE;
1429 EXPORT_API notification_error_e notification_get_led_time_period(notification_h noti,
1430 int *on_ms, int *off_ms)
1432 /* check noti and operation is valid data */
1434 return NOTIFICATION_ERROR_INVALID_DATA;
1437 /* Check noti is valid data */
1439 return NOTIFICATION_ERROR_INVALID_DATA;
1443 *(on_ms) = noti->led_on_ms;
1445 *(off_ms) = noti->led_off_ms;
1447 return NOTIFICATION_ERROR_NONE;
1450 EXPORT_API notification_error_e notification_set_application(notification_h noti,
1451 const char *pkgname)
1453 if (noti == NULL || pkgname == NULL) {
1454 return NOTIFICATION_ERROR_INVALID_DATA;
1457 if (noti->launch_pkgname) {
1458 free(noti->launch_pkgname);
1461 noti->launch_pkgname = strdup(pkgname);
1463 return NOTIFICATION_ERROR_NONE;
1466 EXPORT_API notification_error_e notification_get_application(notification_h noti,
1469 if (noti == NULL || pkgname == NULL) {
1470 return NOTIFICATION_ERROR_INVALID_DATA;
1473 if (noti->launch_pkgname) {
1474 *pkgname = noti->launch_pkgname;
1476 *pkgname = noti->caller_pkgname;
1479 return NOTIFICATION_ERROR_NONE;
1482 EXPORT_API notification_error_e notification_set_args(notification_h noti,
1484 bundle * group_args)
1486 if (noti == NULL || args == NULL) {
1487 return NOTIFICATION_ERROR_INVALID_DATA;
1491 bundle_free(noti->args);
1494 noti->args = bundle_dup(args);
1496 if (noti->group_args) {
1497 bundle_free(noti->group_args);
1498 noti->group_args = NULL;
1501 if (group_args != NULL) {
1502 noti->group_args = bundle_dup(group_args);
1505 return NOTIFICATION_ERROR_NONE;
1508 EXPORT_API notification_error_e notification_get_args(notification_h noti,
1510 bundle ** group_args)
1512 if (noti == NULL || args == NULL) {
1513 return NOTIFICATION_ERROR_INVALID_DATA;
1522 if (group_args != NULL && noti->group_args) {
1523 *group_args = noti->group_args;
1526 return NOTIFICATION_ERROR_NONE;
1529 EXPORT_API notification_error_e notification_set_execute_option(notification_h noti,
1530 notification_execute_type_e type,
1533 bundle *service_handle)
1535 char buf_key[32] = { 0, };
1536 const char *ret_val = NULL;
1540 return NOTIFICATION_ERROR_INVALID_DATA;
1543 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1544 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1545 return NOTIFICATION_ERROR_INVALID_DATA;
1548 /* Create execute option bundle if does not exist */
1549 if (noti->b_execute_option != NULL) {
1550 noti->b_execute_option = bundle_create();
1553 b = noti->b_execute_option;
1558 snprintf(buf_key, sizeof(buf_key), "text%d", type);
1560 /* Check text key exist */
1561 ret_val = bundle_get_val(b, buf_key);
1562 if (ret_val != NULL) {
1563 /* Remove previous data */
1564 bundle_del(b, buf_key);
1568 bundle_add(b, buf_key, text);
1574 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1576 /* Check key key exist */
1577 ret_val = bundle_get_val(b, buf_key);
1578 if (ret_val != NULL) {
1579 /* Remove previous data */
1580 bundle_del(b, buf_key);
1584 bundle_add(b, buf_key, key);
1588 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1589 /* Remove previous data if exist */
1590 if (noti->b_service_responding != NULL) {
1591 bundle_free(noti->b_service_responding);
1592 noti->b_service_responding = NULL;
1595 /* Save service handle */
1596 if (service_handle != NULL) {
1597 noti->b_service_responding = bundle_dup(service_handle);
1600 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1601 /* Remove previous data if exist */
1602 if (noti->b_service_single_launch != NULL) {
1603 bundle_free(noti->b_service_single_launch);
1604 noti->b_service_single_launch = NULL;
1607 /* Save service handle */
1608 if (service_handle != NULL) {
1609 noti->b_service_single_launch =
1610 bundle_dup(service_handle);
1613 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1614 /* Remove previous data if exist */
1615 if (noti->b_service_multi_launch != NULL) {
1616 bundle_free(noti->b_service_multi_launch);
1617 noti->b_service_multi_launch = NULL;
1620 /* Save service handle */
1621 if (service_handle != NULL) {
1622 noti->b_service_multi_launch =
1623 bundle_dup(service_handle);
1628 return NOTIFICATION_ERROR_NONE;
1631 EXPORT_API notification_error_e notification_get_execute_option(notification_h noti,
1632 notification_execute_type_e type,
1634 bundle **service_handle)
1636 char buf_key[32] = { 0, };
1637 const char *ret_val = NULL;
1638 char *get_str = NULL;
1642 return NOTIFICATION_ERROR_INVALID_DATA;
1645 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1646 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1647 return NOTIFICATION_ERROR_INVALID_DATA;
1651 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1652 b = noti->b_service_responding;
1654 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1655 b = noti->b_service_single_launch;
1657 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1658 b = noti->b_service_multi_launch;
1668 // Get text domain and dir
1669 if (noti->domain == NULL || noti->dir == NULL) {
1670 _notification_get_text_domain(noti);
1674 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1676 /* Check key key exist */
1677 ret_val = bundle_get_val(b, buf_key);
1678 if (ret_val != NULL && noti->domain != NULL
1679 && noti->dir != NULL) {
1680 /* Get application string */
1681 bindtextdomain(noti->domain, noti->dir);
1683 get_str = dgettext(noti->domain, ret_val);
1686 } else if (ret_val != NULL) {
1687 /* Get system string */
1688 get_str = dgettext("sys_string", ret_val);
1692 /* Get basic text */
1693 snprintf(buf_key, sizeof(buf_key), "text%d",
1696 ret_val = bundle_get_val(b, buf_key);
1704 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1705 b = noti->b_service_responding;
1707 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1708 b = noti->b_service_single_launch;
1710 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1711 b = noti->b_service_multi_launch;
1718 if (service_handle != NULL) {
1719 *service_handle = b;
1722 return NOTIFICATION_ERROR_NONE;
1725 EXPORT_API notification_error_e notification_set_property(notification_h noti,
1728 /* Check noti is valid data */
1730 return NOTIFICATION_ERROR_INVALID_DATA;
1734 noti->flags_for_property = flags;
1736 return NOTIFICATION_ERROR_NONE;
1739 EXPORT_API notification_error_e notification_get_property(notification_h noti,
1742 /* Check noti and flags are valid data */
1743 if (noti == NULL || flags == NULL) {
1744 return NOTIFICATION_ERROR_INVALID_DATA;
1748 *flags = noti->flags_for_property;
1750 return NOTIFICATION_ERROR_NONE;
1753 EXPORT_API notification_error_e notification_set_display_applist(notification_h noti,
1756 /* Check noti is valid data */
1758 return NOTIFICATION_ERROR_INVALID_DATA;
1762 noti->display_applist = applist;
1764 return NOTIFICATION_ERROR_NONE;
1767 EXPORT_API notification_error_e notification_get_display_applist(notification_h noti,
1770 /* Check noti and applist are valid data */
1771 if (noti == NULL || applist == NULL) {
1772 return NOTIFICATION_ERROR_INVALID_DATA;
1776 *applist = noti->display_applist;
1778 return NOTIFICATION_ERROR_NONE;
1781 EXPORT_API notification_error_e notification_set_size(notification_h noti,
1784 /* Check noti is valid data */
1786 return NOTIFICATION_ERROR_INVALID_DATA;
1789 /* Save progress size */
1790 noti->progress_size = size;
1792 return NOTIFICATION_ERROR_NONE;
1795 EXPORT_API notification_error_e notification_get_size(notification_h noti,
1798 /* Check noti and size is valid data */
1799 if (noti == NULL || size == NULL) {
1800 return NOTIFICATION_ERROR_INVALID_DATA;
1803 /* Set progress size */
1804 *size = noti->progress_size;
1806 return NOTIFICATION_ERROR_NONE;
1809 EXPORT_API notification_error_e notification_set_progress(notification_h noti,
1812 /* Check noti is valid data */
1814 return NOTIFICATION_ERROR_INVALID_DATA;
1817 /* Save progress percentage */
1818 noti->progress_percentage = percentage;
1820 return NOTIFICATION_ERROR_NONE;
1823 EXPORT_API notification_error_e notification_get_progress(notification_h noti,
1826 /* Check noti and percentage are valid data */
1827 if (noti == NULL || percentage == NULL) {
1828 return NOTIFICATION_ERROR_INVALID_DATA;
1831 /* Set progress percentage */
1832 *percentage = noti->progress_percentage;
1834 return NOTIFICATION_ERROR_NONE;
1837 EXPORT_API notification_error_e notification_set_pkgname(notification_h noti,
1838 const char *pkgname)
1840 /* check noti and pkgname are valid data */
1841 if (noti == NULL || pkgname == NULL) {
1842 return NOTIFICATION_ERROR_INVALID_DATA;
1845 /* Remove previous caller pkgname */
1846 if (noti->caller_pkgname) {
1847 free(noti->caller_pkgname);
1848 noti->caller_pkgname = NULL;
1851 noti->caller_pkgname = strdup(pkgname);
1853 return NOTIFICATION_ERROR_NONE;
1856 EXPORT_API notification_error_e notification_get_pkgname(notification_h noti,
1859 /* Check noti and pkgname are valid data */
1860 if (noti == NULL || pkgname == NULL) {
1861 return NOTIFICATION_ERROR_INVALID_DATA;
1864 /* Get caller pkgname */
1865 if (noti->caller_pkgname) {
1866 *pkgname = noti->caller_pkgname;
1871 return NOTIFICATION_ERROR_NONE;
1874 EXPORT_API notification_error_e notification_set_layout(notification_h noti,
1875 notification_ly_type_e layout)
1877 /* check noti and pkgname are valid data */
1878 if (noti == NULL || (layout < NOTIFICATION_LY_NONE || layout >= NOTIFICATION_LY_MAX)) {
1879 return NOTIFICATION_ERROR_INVALID_DATA;
1882 noti->layout = layout;
1884 return NOTIFICATION_ERROR_NONE;
1887 EXPORT_API notification_error_e notification_get_layout(notification_h noti,
1888 notification_ly_type_e *layout)
1890 /* Check noti and pkgname are valid data */
1891 if (noti == NULL || layout == NULL) {
1892 return NOTIFICATION_ERROR_INVALID_DATA;
1895 *layout = noti->layout;
1897 return NOTIFICATION_ERROR_NONE;
1900 EXPORT_API notification_error_e notification_set_badge(const char *pkgname,
1901 int group_id, int count)
1903 char *caller_pkgname = NULL;
1904 int ret = NOTIFICATION_ERROR_NONE;
1906 /* Check count is valid count */
1908 return NOTIFICATION_ERROR_INVALID_DATA;
1912 if (pkgname == NULL) {
1913 caller_pkgname = _notification_get_pkgname_by_pid();
1915 /* Set count into Group DB */
1917 notification_group_set_badge(caller_pkgname, group_id,
1920 if (caller_pkgname != NULL) {
1921 free(caller_pkgname);
1924 /* Set count into Group DB */
1925 ret = notification_group_set_badge(pkgname, group_id, count);
1931 EXPORT_API notification_error_e notification_get_badge(const char *pkgname,
1932 int group_id, int *count)
1934 char *caller_pkgname = NULL;
1935 int ret = NOTIFICATION_ERROR_NONE;
1936 int ret_unread_count = 0;
1939 if (pkgname == NULL) {
1940 caller_pkgname = _notification_get_pkgname_by_pid();
1942 /* Get count from Group DB */
1944 notification_group_get_badge(caller_pkgname, group_id,
1947 if (caller_pkgname != NULL) {
1948 free(caller_pkgname);
1951 /* Get count from Group DB */
1953 notification_group_get_badge(pkgname, group_id,
1957 if (ret != NOTIFICATION_ERROR_NONE) {
1962 if (count != NULL) {
1963 *count = ret_unread_count;
1966 return NOTIFICATION_ERROR_NONE;
1969 EXPORT_API notification_error_e notification_get_id(notification_h noti,
1970 int *group_id, int *priv_id)
1972 /* check noti is valid data */
1974 return NOTIFICATION_ERROR_INVALID_DATA;
1977 /* Check group_id is valid data */
1980 if (noti->group_id < NOTIFICATION_GROUP_ID_NONE) {
1981 *group_id = NOTIFICATION_GROUP_ID_NONE;
1983 *group_id = noti->group_id;
1987 /* Check priv_id is valid data */
1990 *priv_id = noti->priv_id;
1993 return NOTIFICATION_ERROR_NONE;
1996 EXPORT_API notification_error_e notification_get_type(notification_h noti,
1997 notification_type_e *type)
1999 /* Check noti and type is valid data */
2000 if (noti == NULL || type == NULL) {
2001 return NOTIFICATION_ERROR_INVALID_DATA;
2007 return NOTIFICATION_ERROR_NONE;
2010 EXPORT_API notification_error_e notification_insert(notification_h noti,
2016 /* Check noti is vaild data */
2018 return NOTIFICATION_ERROR_INVALID_DATA;
2021 /* Check noti type is valid type */
2022 if (noti->type <= NOTIFICATION_TYPE_NONE
2023 || noti->type >= NOTIFICATION_TYPE_MAX) {
2024 return NOTIFICATION_ERROR_INVALID_DATA;
2027 /* Save insert time */
2028 noti->insert_time = time(NULL);
2029 ret = notification_ipc_request_insert(noti, &id);
2030 if (ret != NOTIFICATION_ERROR_NONE) {
2034 NOTIFICATION_DBG("from master:%d", id);
2036 /* If priv_id is valid data, set priv_id */
2037 if (priv_id != NULL) {
2038 *priv_id = noti->priv_id;
2041 return NOTIFICATION_ERROR_NONE;
2044 EXPORT_API notification_error_e notification_update(notification_h noti)
2048 /* Check noti is valid data */
2050 /* Update insert time ? */
2051 noti->insert_time = time(NULL);
2052 ret = notification_ipc_request_update(noti);
2053 if (ret != NOTIFICATION_ERROR_NONE) {
2057 ret = notification_ipc_request_refresh();
2058 if (ret != NOTIFICATION_ERROR_NONE) {
2062 return NOTIFICATION_ERROR_NONE;
2065 EXPORT_API notification_error_e notifiation_clear(notification_type_e type)
2069 ret = notification_ipc_request_delete_multiple(type, NULL);
2070 if (ret != NOTIFICATION_ERROR_NONE) {
2074 return NOTIFICATION_ERROR_NONE;
2077 EXPORT_API notification_error_e notification_delete_all_by_type(const char *pkgname,
2078 notification_type_e type)
2081 char *caller_pkgname = NULL;
2083 if (pkgname == NULL) {
2084 caller_pkgname = _notification_get_pkgname_by_pid();
2086 caller_pkgname = strdup(pkgname);
2089 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
2090 if (ret != NOTIFICATION_ERROR_NONE) {
2094 if (caller_pkgname) {
2095 free(caller_pkgname);
2097 return NOTIFICATION_ERROR_NONE;
2100 EXPORT_API notification_error_e notification_delete_group_by_group_id(const char *pkgname,
2101 notification_type_e type,
2105 char *caller_pkgname = NULL;
2107 if (pkgname == NULL) {
2108 caller_pkgname = _notification_get_pkgname_by_pid();
2110 caller_pkgname = strdup(pkgname);
2113 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
2114 if (ret != NOTIFICATION_ERROR_NONE) {
2118 if (caller_pkgname) {
2119 free(caller_pkgname);
2121 return NOTIFICATION_ERROR_NONE;
2124 EXPORT_API notification_error_e notification_delete_group_by_priv_id(const char *pkgname,
2125 notification_type_e type,
2129 char *caller_pkgname = NULL;
2131 if (pkgname == NULL) {
2132 caller_pkgname = _notification_get_pkgname_by_pid();
2134 caller_pkgname = strdup(pkgname);
2137 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
2138 if (ret != NOTIFICATION_ERROR_NONE) {
2142 if (caller_pkgname) {
2143 free(caller_pkgname);
2145 return NOTIFICATION_ERROR_NONE;
2148 EXPORT_API notification_error_e notification_delete_by_priv_id(const char *pkgname,
2149 notification_type_e type,
2153 char *caller_pkgname = NULL;
2155 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2156 return NOTIFICATION_ERROR_INVALID_DATA;
2159 if (pkgname == NULL) {
2160 caller_pkgname = _notification_get_pkgname_by_pid();
2162 caller_pkgname = strdup(pkgname);
2165 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
2166 if (ret != NOTIFICATION_ERROR_NONE) {
2170 if (caller_pkgname) {
2171 free(caller_pkgname);
2176 EXPORT_API notification_error_e notification_delete(notification_h noti)
2181 return NOTIFICATION_ERROR_INVALID_DATA;
2184 ret = notification_ipc_request_delete_single(NOTIFICATION_TYPE_NONE, noti->caller_pkgname, noti->priv_id);
2185 if (ret != NOTIFICATION_ERROR_NONE) {
2189 return NOTIFICATION_ERROR_NONE;
2192 EXPORT_API notification_error_e notification_update_progress(notification_h noti,
2196 char *caller_pkgname = NULL;
2197 int input_priv_id = 0;
2198 double input_progress = 0.0;
2200 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2202 return NOTIFICATION_ERROR_INVALID_DATA;
2204 input_priv_id = noti->priv_id;
2207 input_priv_id = priv_id;
2211 caller_pkgname = _notification_get_pkgname_by_pid();
2213 caller_pkgname = strdup(noti->caller_pkgname);
2216 if (progress < 0.0) {
2217 input_progress = 0.0;
2218 } else if (progress > 1.0) {
2219 input_progress = 1.0;
2221 input_progress = progress;
2224 notification_ongoing_update_progress(caller_pkgname, input_priv_id,
2227 if (caller_pkgname) {
2228 free(caller_pkgname);
2231 return NOTIFICATION_ERROR_NONE;
2234 EXPORT_API notification_error_e notification_update_size(notification_h noti,
2238 char *caller_pkgname = NULL;
2239 int input_priv_id = 0;
2240 double input_size = 0.0;
2242 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2244 return NOTIFICATION_ERROR_INVALID_DATA;
2246 input_priv_id = noti->priv_id;
2249 input_priv_id = priv_id;
2253 caller_pkgname = _notification_get_pkgname_by_pid();
2255 caller_pkgname = strdup(noti->caller_pkgname);
2264 notification_ongoing_update_size(caller_pkgname, input_priv_id,
2267 if (caller_pkgname) {
2268 free(caller_pkgname);
2271 return NOTIFICATION_ERROR_NONE;
2274 EXPORT_API notification_error_e notification_update_content(notification_h noti,
2276 const char *content)
2278 char *caller_pkgname = NULL;
2279 int input_priv_id = 0;
2281 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2283 return NOTIFICATION_ERROR_INVALID_DATA;
2285 input_priv_id = noti->priv_id;
2288 input_priv_id = priv_id;
2292 caller_pkgname = _notification_get_pkgname_by_pid();
2294 caller_pkgname = strdup(noti->caller_pkgname);
2297 notification_ongoing_update_content(caller_pkgname, input_priv_id,
2300 if (caller_pkgname) {
2301 free(caller_pkgname);
2304 return NOTIFICATION_ERROR_NONE;
2307 static notification_h _notification_create(notification_type_e type)
2309 notification_h noti = NULL;
2311 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
2312 NOTIFICATION_ERR("INVALID TYPE : %d", type);
2316 noti = (notification_h) calloc(1, sizeof(struct _notification));
2318 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2324 if (type == NOTIFICATION_TYPE_NOTI)
2325 noti->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2326 else if (type == NOTIFICATION_TYPE_ONGOING)
2327 noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
2329 noti->caller_pkgname = _notification_get_pkgname_by_pid();
2330 noti->group_id = NOTIFICATION_GROUP_ID_NONE;
2331 noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
2332 noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
2333 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
2334 noti->led_operation = NOTIFICATION_LED_OP_OFF;
2335 noti->display_applist = NOTIFICATION_DISPLAY_APP_ALL;
2338 * Other fields are already initialized with ZERO.
2343 EXPORT_API notification_h notification_new(notification_type_e type,
2344 int group_id, int priv_id)
2346 return _notification_create(type);
2349 EXPORT_API notification_h notification_create(notification_type_e type)
2351 return _notification_create(type);
2354 EXPORT_API notification_h notification_load(char *pkgname,
2358 notification_h noti = NULL;
2360 noti = (notification_h) malloc(sizeof(struct _notification));
2362 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2365 memset(noti, 0x00, sizeof(struct _notification));
2367 ret = notification_noti_get_by_priv_id(noti, pkgname, priv_id);
2368 if (ret != NOTIFICATION_ERROR_NONE) {
2369 notification_free(noti);
2376 EXPORT_API notification_error_e notification_clone(notification_h noti, notification_h *clone)
2378 notification_h new_noti = NULL;
2380 if (noti == NULL || clone == NULL) {
2381 NOTIFICATION_ERR("INVALID PARAMETER.");
2382 return NOTIFICATION_ERROR_INVALID_DATA;
2385 new_noti = (notification_h) malloc(sizeof(struct _notification));
2386 if (new_noti == NULL) {
2387 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2388 return NOTIFICATION_ERROR_NO_MEMORY;
2390 memset(new_noti, 0x00, sizeof(struct _notification));
2392 new_noti->type = noti->type;
2393 new_noti->layout = noti->layout;
2395 new_noti->group_id = noti->group_id;
2396 new_noti->internal_group_id = noti->internal_group_id;
2397 new_noti->priv_id = noti->priv_id;
2399 if(noti->caller_pkgname != NULL) {
2400 new_noti->caller_pkgname = strdup(noti->caller_pkgname);
2402 new_noti->caller_pkgname = _notification_get_pkgname_by_pid();
2404 if(noti->launch_pkgname != NULL) {
2405 new_noti->launch_pkgname = strdup(noti->launch_pkgname);
2407 new_noti->launch_pkgname = NULL;
2410 if(noti->args != NULL) {
2411 new_noti->args = bundle_dup(noti->args);
2413 new_noti->args = NULL;
2415 if(noti->group_args != NULL) {
2416 new_noti->group_args = bundle_dup(noti->group_args);
2418 new_noti->group_args = NULL;
2421 if(noti->b_execute_option != NULL) {
2422 new_noti->b_execute_option = bundle_dup(noti->b_execute_option);
2424 new_noti->b_execute_option = NULL;
2426 if(noti->b_service_responding != NULL) {
2427 new_noti->b_service_responding = bundle_dup(noti->b_service_responding);
2429 new_noti->b_service_responding = NULL;
2431 if(noti->b_service_single_launch != NULL) {
2432 new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch);
2434 new_noti->b_service_single_launch = NULL;
2436 if(noti->b_service_multi_launch != NULL) {
2437 new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch);
2439 new_noti->b_service_multi_launch = NULL;
2442 new_noti->sound_type = noti->sound_type;
2443 if(noti->sound_path != NULL) {
2444 new_noti->sound_path = strdup(noti->sound_path);
2446 new_noti->sound_path = NULL;
2448 new_noti->vibration_type = noti->vibration_type;
2449 if(noti->vibration_path != NULL) {
2450 new_noti->vibration_path = strdup(noti->vibration_path);
2452 new_noti->vibration_path = NULL;
2454 new_noti->led_operation = noti->led_operation;
2455 new_noti->led_argb = noti->led_argb;
2456 new_noti->led_on_ms = noti->led_on_ms;
2457 new_noti->led_off_ms = noti->led_off_ms;
2459 if(noti->domain != NULL) {
2460 new_noti->domain = strdup(noti->domain);
2462 new_noti->domain = NULL;
2464 if(noti->dir != NULL) {
2465 new_noti->dir = strdup(noti->dir);
2467 new_noti->dir = NULL;
2470 if(noti->b_text != NULL) {
2471 new_noti->b_text = bundle_dup(noti->b_text);
2473 new_noti->b_text = NULL;
2475 if(noti->b_key != NULL) {
2476 new_noti->b_key = bundle_dup(noti->b_key);
2478 new_noti->b_key = NULL;
2480 if(noti->b_format_args != NULL) {
2481 new_noti->b_format_args = bundle_dup(noti->b_format_args);
2483 new_noti->b_format_args = NULL;
2485 new_noti->num_format_args = noti->num_format_args;
2487 if(noti->b_image_path != NULL) {
2488 new_noti->b_image_path = bundle_dup(noti->b_image_path);
2490 new_noti->b_image_path = NULL;
2493 new_noti->time = noti->time;
2494 new_noti->insert_time = noti->insert_time;
2496 new_noti->flags_for_property = noti->flags_for_property;
2497 new_noti->display_applist = noti->display_applist;
2499 new_noti->progress_size = noti->progress_size;
2500 new_noti->progress_percentage = noti->progress_percentage;
2502 new_noti->app_icon_path = NULL;
2503 new_noti->app_name = NULL;
2504 new_noti->temp_title = NULL;
2505 new_noti->temp_content = NULL;
2509 return NOTIFICATION_ERROR_NONE;
2513 EXPORT_API notification_error_e notification_free(notification_h noti)
2516 return NOTIFICATION_ERROR_INVALID_DATA;
2519 if (noti->caller_pkgname) {
2520 free(noti->caller_pkgname);
2522 if (noti->launch_pkgname) {
2523 free(noti->launch_pkgname);
2526 bundle_free(noti->args);
2528 if (noti->group_args) {
2529 bundle_free(noti->group_args);
2532 if (noti->b_execute_option) {
2533 bundle_free(noti->b_execute_option);
2535 if (noti->b_service_responding) {
2536 bundle_free(noti->b_service_responding);
2538 if (noti->b_service_single_launch) {
2539 bundle_free(noti->b_service_single_launch);
2541 if (noti->b_service_multi_launch) {
2542 bundle_free(noti->b_service_multi_launch);
2545 if (noti->sound_path) {
2546 free(noti->sound_path);
2548 if (noti->vibration_path) {
2549 free(noti->vibration_path);
2560 bundle_free(noti->b_text);
2563 bundle_free(noti->b_key);
2565 if (noti->b_format_args) {
2566 bundle_free(noti->b_format_args);
2569 if (noti->b_image_path) {
2570 bundle_free(noti->b_image_path);
2573 if (noti->app_icon_path) {
2574 free(noti->app_icon_path);
2576 if (noti->app_name) {
2577 free(noti->app_name);
2579 if (noti->temp_title) {
2580 free(noti->temp_title);
2582 if (noti->temp_content) {
2583 free(noti->temp_content);
2588 return NOTIFICATION_ERROR_NONE;
2591 EXPORT_API notification_error_e
2592 notification_resister_changed_cb(void (*changed_cb)
2593 (void *data, notification_type_e type),
2596 notification_cb_list_s *noti_cb_list_new = NULL;
2597 notification_cb_list_s *noti_cb_list = NULL;
2599 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
2600 return NOTIFICATION_ERROR_IO;
2604 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
2606 noti_cb_list_new->next = NULL;
2607 noti_cb_list_new->prev = NULL;
2609 noti_cb_list_new->cb_type = NOTIFICATION_CB_NORMAL;
2610 noti_cb_list_new->changed_cb = changed_cb;
2611 noti_cb_list_new->detailed_changed_cb = NULL;
2612 noti_cb_list_new->data = user_data;
2614 if (g_notification_cb_list == NULL) {
2615 g_notification_cb_list = noti_cb_list_new;
2617 noti_cb_list = g_notification_cb_list;
2619 while (noti_cb_list->next != NULL) {
2620 noti_cb_list = noti_cb_list->next;
2623 noti_cb_list->next = noti_cb_list_new;
2624 noti_cb_list_new->prev = noti_cb_list;
2626 return NOTIFICATION_ERROR_NONE;
2629 EXPORT_API notification_error_e
2630 notification_unresister_changed_cb(void (*changed_cb)
2631 (void *data, notification_type_e type))
2633 notification_cb_list_s *noti_cb_list = NULL;
2634 notification_cb_list_s *noti_cb_list_prev = NULL;
2635 notification_cb_list_s *noti_cb_list_next = NULL;
2637 noti_cb_list = g_notification_cb_list;
2639 if (noti_cb_list == NULL) {
2640 return NOTIFICATION_ERROR_INVALID_DATA;
2643 while (noti_cb_list->prev != NULL) {
2644 noti_cb_list = noti_cb_list->prev;
2648 if (noti_cb_list->changed_cb == changed_cb) {
2649 noti_cb_list_prev = noti_cb_list->prev;
2650 noti_cb_list_next = noti_cb_list->next;
2652 if (noti_cb_list_prev == NULL) {
2653 g_notification_cb_list = noti_cb_list_next;
2655 noti_cb_list_prev->next = noti_cb_list_next;
2658 if (noti_cb_list_next == NULL) {
2659 if (noti_cb_list_prev != NULL) {
2660 noti_cb_list_prev->next = NULL;
2663 noti_cb_list_next->prev = noti_cb_list_prev;
2668 if (g_notification_cb_list == NULL)
2669 notification_ipc_monitor_fini();
2671 return NOTIFICATION_ERROR_NONE;
2673 noti_cb_list = noti_cb_list->next;
2674 } while (noti_cb_list != NULL);
2676 return NOTIFICATION_ERROR_INVALID_DATA;
2679 EXPORT_API notification_error_e
2680 notification_register_detailed_changed_cb(
2681 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
2684 notification_cb_list_s *noti_cb_list_new = NULL;
2685 notification_cb_list_s *noti_cb_list = NULL;
2687 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
2688 return NOTIFICATION_ERROR_IO;
2692 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
2694 noti_cb_list_new->next = NULL;
2695 noti_cb_list_new->prev = NULL;
2697 noti_cb_list_new->cb_type = NOTIFICATION_CB_DETAILED;
2698 noti_cb_list_new->changed_cb = NULL;
2699 noti_cb_list_new->detailed_changed_cb = detailed_changed_cb;
2700 noti_cb_list_new->data = user_data;
2702 if (g_notification_cb_list == NULL) {
2703 g_notification_cb_list = noti_cb_list_new;
2705 noti_cb_list = g_notification_cb_list;
2707 while (noti_cb_list->next != NULL) {
2708 noti_cb_list = noti_cb_list->next;
2711 noti_cb_list->next = noti_cb_list_new;
2712 noti_cb_list_new->prev = noti_cb_list;
2714 return NOTIFICATION_ERROR_NONE;
2717 EXPORT_API notification_error_e
2718 notification_unregister_detailed_changed_cb(
2719 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
2722 notification_cb_list_s *noti_cb_list = NULL;
2723 notification_cb_list_s *noti_cb_list_prev = NULL;
2724 notification_cb_list_s *noti_cb_list_next = NULL;
2726 noti_cb_list = g_notification_cb_list;
2728 if (noti_cb_list == NULL) {
2729 return NOTIFICATION_ERROR_INVALID_DATA;
2732 while (noti_cb_list->prev != NULL) {
2733 noti_cb_list = noti_cb_list->prev;
2737 if (noti_cb_list->detailed_changed_cb == detailed_changed_cb) {
2738 noti_cb_list_prev = noti_cb_list->prev;
2739 noti_cb_list_next = noti_cb_list->next;
2741 if (noti_cb_list_prev == NULL) {
2742 g_notification_cb_list = noti_cb_list_next;
2744 noti_cb_list_prev->next = noti_cb_list_next;
2747 if (noti_cb_list_next == NULL) {
2748 if (noti_cb_list_prev != NULL) {
2749 noti_cb_list_prev->next = NULL;
2752 noti_cb_list_next->prev = noti_cb_list_prev;
2757 if (g_notification_cb_list == NULL)
2758 notification_ipc_monitor_fini();
2760 return NOTIFICATION_ERROR_NONE;
2762 noti_cb_list = noti_cb_list->next;
2763 } while (noti_cb_list != NULL);
2765 return NOTIFICATION_ERROR_INVALID_DATA;
2768 EXPORT_API notification_error_e
2769 notification_resister_badge_changed_cb(void (*changed_cb)
2770 (void *data, const char *pkgname,
2771 int group_id), void *user_data)
2773 // Add DBus signal handler
2774 return NOTIFICATION_ERROR_NONE;
2777 EXPORT_API notification_error_e
2778 notification_unresister_badge_changed_cb(void (*changed_cb)
2779 (void *data, const char *pkgname,
2782 // Del DBus signal handler
2783 return NOTIFICATION_ERROR_NONE;
2786 EXPORT_API notification_error_e notification_get_count(notification_type_e type,
2787 const char *pkgname,
2789 int priv_id, int *count)
2795 notification_noti_get_count(type, pkgname, group_id, priv_id,
2797 if (ret != NOTIFICATION_ERROR_NONE) {
2801 if (count != NULL) {
2802 *count = noti_count;
2805 return NOTIFICATION_ERROR_NONE;
2808 EXPORT_API notification_error_e notification_get_list(notification_type_e type,
2810 notification_list_h *list)
2812 notification_list_h get_list = NULL;
2815 ret = notification_noti_get_grouping_list(type, count, &get_list);
2816 if (ret != NOTIFICATION_ERROR_NONE) {
2822 return NOTIFICATION_ERROR_NONE;
2825 EXPORT_API notification_error_e
2826 notification_get_grouping_list(notification_type_e type, int count,
2827 notification_list_h * list)
2829 notification_list_h get_list = NULL;
2832 ret = notification_noti_get_grouping_list(type, count, &get_list);
2833 if (ret != NOTIFICATION_ERROR_NONE) {
2839 return NOTIFICATION_ERROR_NONE;
2842 EXPORT_API notification_error_e notification_get_detail_list(const char *pkgname,
2846 notification_list_h *list)
2848 notification_list_h get_list = NULL;
2852 notification_noti_get_detail_list(pkgname, group_id, priv_id, count,
2854 if (ret != NOTIFICATION_ERROR_NONE) {
2860 return NOTIFICATION_ERROR_NONE;
2863 EXPORT_API notification_error_e notification_free_list(notification_list_h list)
2865 notification_list_h cur_list = NULL;
2866 notification_h noti = NULL;
2869 NOTIFICATION_ERR("INVALID DATA : list == NULL");
2870 return NOTIFICATION_ERROR_INVALID_DATA;
2873 cur_list = notification_list_get_head(list);
2875 while (cur_list != NULL) {
2876 noti = notification_list_get_data(cur_list);
2877 cur_list = notification_list_remove(cur_list, noti);
2879 notification_free(noti);
2882 return NOTIFICATION_ERROR_NONE;
2885 EXPORT_API notification_error_e notification_op_get_data(notification_op *noti_op, notification_op_data_type_e type,
2888 if (noti_op == NULL || data == NULL) {
2889 return NOTIFICATION_ERROR_INVALID_DATA;
2893 case NOTIFICATION_OP_DATA_TYPE:
2894 *((int*)data) = noti_op->type;
2896 case NOTIFICATION_OP_DATA_PRIV_ID:
2897 *((int*)data) = noti_op->priv_id;
2899 case NOTIFICATION_OP_DATA_NOTI:
2900 *((notification_h *)data) = noti_op->noti;
2902 case NOTIFICATION_OP_DATA_EXTRA_INFO_1:
2903 *((int*)data) = noti_op->extra_info_1;
2905 case NOTIFICATION_OP_DATA_EXTRA_INFO_2:
2906 *((int*)data) = noti_op->extra_info_2;
2909 return NOTIFICATION_ERROR_INVALID_DATA;
2913 return NOTIFICATION_ERROR_NONE;
2916 void notification_call_changed_cb(notification_op *op_list, int op_num)
2918 notification_cb_list_s *noti_cb_list = NULL;
2921 if (g_notification_cb_list == NULL) {
2924 noti_cb_list = g_notification_cb_list;
2926 while (noti_cb_list->prev != NULL) {
2927 noti_cb_list = noti_cb_list->prev;
2930 if (op_list == NULL) {
2931 NOTIFICATION_ERR("invalid data");
2935 while (noti_cb_list != NULL) {
2936 if (noti_cb_list->cb_type == NOTIFICATION_CB_NORMAL && noti_cb_list->changed_cb) {
2937 noti_cb_list->changed_cb(noti_cb_list->data,
2938 NOTIFICATION_TYPE_NOTI);
2940 if (noti_cb_list->cb_type == NOTIFICATION_CB_DETAILED && noti_cb_list->detailed_changed_cb) {
2941 noti_cb_list->detailed_changed_cb(noti_cb_list->data,
2942 NOTIFICATION_TYPE_NOTI, op_list, op_num);
2945 noti_cb_list = noti_cb_list->next;
2949 EXPORT_API int notification_is_service_ready(void)
2951 return notification_ipc_is_master_ready();
2954 EXPORT_API notification_error_e
2955 notification_add_deffered_task(
2956 void (*deffered_task_cb)(void *data), void *user_data)
2958 return notification_ipc_add_deffered_task(deffered_task_cb, user_data);
2961 EXPORT_API notification_error_e
2962 notification_del_deffered_task(
2963 void (*deffered_task_cb)(void *data))
2965 return notification_ipc_del_deffered_task(deffered_task_cb);