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 *translated_str = NULL;
554 char result_str[NOTI_TEXT_RESULT_LEN] = { 0, };
555 char buf_str[1024] = { 0, };
557 notification_variable_type_e ret_var_type = 0;
558 int ret_variable_int = 0;
559 double ret_variable_double = 0.0;
561 /* Check noti is valid data */
562 if (noti == NULL || text == NULL) {
563 return NOTIFICATION_ERROR_INVALID_PARAMETER;
566 /* Check text type is valid type */
567 if (type <= NOTIFICATION_TEXT_TYPE_NONE
568 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
569 return NOTIFICATION_ERROR_INVALID_PARAMETER;
573 if (noti->b_key != NULL) {
576 /* Get text domain and dir */
577 //_notification_get_text_domain(noti);
579 snprintf(buf_key, sizeof(buf_key), "%d", type);
581 ret_val = bundle_get_val(b, buf_key);
582 if (ret_val != NULL && noti->domain != NULL
583 && noti->dir != NULL) {
584 /* Get application string */
585 bindtextdomain(noti->domain, noti->dir);
587 get_str = dgettext(noti->domain, ret_val);
588 } else if (ret_val != NULL) {
589 /* Get system string */
590 get_str = dgettext("sys_string", ret_val);
596 if (get_str == NULL && noti->b_text != NULL) {
599 snprintf(buf_key, sizeof(buf_key), "%d", type);
601 get_str = bundle_get_val(b, buf_key);
606 /* Set display option is off type when option is off, type is noti */
607 /*if (get_str != NULL && display_option_flag == 1
608 && noti->type == NOTIFICATION_TYPE_NOTI) {
609 if (type == NOTIFICATION_TEXT_TYPE_CONTENT
610 || type == NOTIFICATION_TEXT_TYPE_GROUP_CONTENT) {
611 // Set check_type to option content string
612 if (type == NOTIFICATION_TEXT_TYPE_CONTENT) {
614 NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF;
615 } else if (type == NOTIFICATION_TEXT_TYPE_GROUP_CONTENT) {
617 NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF;
621 if (noti->b_key != NULL) {
624 // Get text domain and dir
625 _notification_get_text_domain(noti);
627 snprintf(buf_key, sizeof(buf_key), "%d",
630 ret_val = bundle_get_val(b, buf_key);
631 if (ret_val != NULL && noti->domain != NULL
632 && noti->dir != NULL) {
633 // Get application string
634 bindtextdomain(noti->domain, noti->dir);
637 dgettext(noti->domain, ret_val);
638 } else if (ret_val != NULL) {
641 dgettext("sys_string", ret_val);
643 get_check_type_str = NULL;
647 if (get_check_type_str == NULL && noti->b_text != NULL) {
650 snprintf(buf_key, sizeof(buf_key), "%d",
653 get_check_type_str = bundle_get_val(b, buf_key);
657 if (get_check_type_str != NULL) {
658 // Replace option off type string
659 get_str = get_check_type_str;
661 // Set default string
663 dgettext("sys_string", "IDS_COM_POP_MISSED_EVENT");
667 if (get_str != NULL) {
668 /* Get number format args */
669 b = noti->b_format_args;
670 noti->num_format_args = 0;
673 snprintf(buf_key, sizeof(buf_key), "num%d", check_type);
674 ret_val = bundle_get_val(b, buf_key);
675 if (ret_val != NULL) {
676 noti->num_format_args = atoi(ret_val);
680 if (noti->num_format_args == 0) {
681 *text = (char *)get_str;
683 /* Check first variable is count, LEFT pos */
684 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
685 check_type, num_args);
686 ret_val = bundle_get_val(b, buf_key);
687 ret_var_type = atoi(ret_val);
689 if (ret_var_type == NOTIFICATION_VARIABLE_TYPE_COUNT) {
691 snprintf(buf_key, sizeof(buf_key), "%dvalue%d",
692 check_type, num_args);
693 ret_val = bundle_get_val(b, buf_key);
694 ret_variable_int = atoi(ret_val);
696 if (ret_variable_int ==
697 NOTIFICATION_COUNT_POS_LEFT) {
698 notification_noti_get_count(noti->type,
699 noti->caller_pkgname,
703 snprintf(buf_str, sizeof(buf_str),
704 "%d ", ret_variable_int);
706 int src_len = strlen(result_str);
707 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
709 strncat(result_str, buf_str,
715 /* Check variable IN pos */
716 for (temp_str = (char *)get_str; *temp_str != '\0';
718 if (*temp_str != '%') {
719 strncat(result_str, temp_str, 1);
721 if (*(temp_str + 1) == '%') {
722 strncat(result_str, temp_str,
724 } else if (*(temp_str + 1) == 'd') {
726 ret_variable_int = 0;
730 "%dtype%d", check_type,
733 bundle_get_val(b, buf_key);
734 ret_var_type = atoi(ret_val);
736 NOTIFICATION_VARIABLE_TYPE_COUNT)
738 /* Get notification count */
739 notification_noti_get_count
741 noti->caller_pkgname,
761 sizeof(buf_str), "%d",
764 int src_len = strlen(result_str);
765 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
767 strncat(result_str, buf_str,
773 } else if (*(temp_str + 1) == 's') {
778 check_type, num_args);
780 bundle_get_val(b, buf_key);
782 if (ret_val != NULL && noti->domain != NULL && noti->dir != NULL) {
783 /* Get application string */
784 bindtextdomain(noti->domain, noti->dir);
785 translated_str = dgettext(noti->domain, ret_val);
786 NOTIFICATION_INFO("translated_str[%s]", translated_str);
787 } else if (ret_val != NULL) {
788 /* Get system string */
789 translated_str = dgettext("sys_string", ret_val);
790 NOTIFICATION_INFO("translated_str[%s]", translated_str);
792 translated_str = NULL;
795 strncpy(buf_str, sizeof(buf_str), translated_str);
797 int src_len = strlen(result_str);
798 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
800 strncat(result_str, buf_str,
806 } else if (*(temp_str + 1) == 'f') {
811 check_type, num_args);
813 bundle_get_val(b, buf_key);
814 ret_variable_double =
820 ret_variable_double);
822 int src_len = strlen(result_str);
823 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
825 strncat(result_str, buf_str,
831 } else if (*(temp_str + 1) >= '1' && *(temp_str + 1) <= '9') {
832 if (*(temp_str + 3) == 'd') {
834 ret_variable_int = 0;
838 "%dtype%d", check_type,
839 num_args + *(temp_str + 1) - 49);
841 bundle_get_val(b, buf_key);
842 ret_var_type = atoi(ret_val);
844 NOTIFICATION_VARIABLE_TYPE_COUNT)
846 /* Get notification count */
847 notification_noti_get_count
849 noti->caller_pkgname,
860 num_args + *(temp_str + 1) - 49);
869 sizeof(buf_str), "%d",
872 int src_len = strlen(result_str);
873 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
875 strncat(result_str, buf_str,
879 } else if (*(temp_str + 3) == 's') {
884 check_type, num_args + *(temp_str + 1) - 49);
886 bundle_get_val(b, buf_key);
889 sizeof(buf_str), "%s",
892 int src_len = strlen(result_str);
893 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
895 strncat(result_str, buf_str,
899 } else if (*(temp_str + 3) == 'f') {
904 check_type, num_args + *(temp_str + 1) - 49);
906 bundle_get_val(b, buf_key);
907 ret_variable_double =
913 ret_variable_double);
915 int src_len = strlen(result_str);
916 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
918 strncat(result_str, buf_str,
928 /* Check last variable is count, LEFT pos */
929 if (num_args < noti->num_format_args) {
930 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
931 check_type, num_args);
932 ret_val = bundle_get_val(b, buf_key);
933 ret_var_type = atoi(ret_val);
935 NOTIFICATION_VARIABLE_TYPE_COUNT) {
937 snprintf(buf_key, sizeof(buf_key),
938 "%dvalue%d", check_type,
940 ret_val = bundle_get_val(b, buf_key);
941 ret_variable_int = atoi(ret_val);
943 if (ret_variable_int ==
944 NOTIFICATION_COUNT_POS_RIGHT) {
945 notification_noti_get_count
947 noti->caller_pkgname,
952 sizeof(buf_str), " %d",
955 int src_len = strlen(result_str);
956 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
958 strncat(result_str, buf_str,
967 switch (check_type) {
968 case NOTIFICATION_TEXT_TYPE_TITLE:
969 case NOTIFICATION_TEXT_TYPE_GROUP_TITLE:
970 if (noti->temp_title != NULL)
971 free(noti->temp_title);
973 noti->temp_title = strdup(result_str);
975 *text = noti->temp_title;
977 case NOTIFICATION_TEXT_TYPE_CONTENT:
978 case NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
979 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT:
980 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
981 if (noti->temp_content !=
983 free(noti->temp_content);
985 noti->temp_content = strdup(result_str);
987 *text = noti->temp_content;
999 NOTIFICATION_INFO("text[%s]", *text);
1001 return NOTIFICATION_ERROR_NONE;
1004 EXPORT_API int notification_set_text_domain(notification_h noti,
1008 /* check noti and domain is valid data */
1009 if (noti == NULL || domain == NULL || dir == NULL) {
1010 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1015 /* Remove previous domain */
1019 noti->domain = strdup(domain);
1021 /* Check locale dir */
1023 /* Remove previous locale dir */
1026 /* Copy locale dir */
1027 noti->dir = strdup(dir);
1029 return NOTIFICATION_ERROR_NONE;
1032 EXPORT_API int notification_get_text_domain(notification_h noti,
1036 /* Check noti is valid data */
1038 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1042 if (domain != NULL && noti->domain != NULL) {
1043 *domain = noti->domain;
1046 /* Get locale dir */
1047 if (dir != NULL && noti->dir != NULL) {
1051 return NOTIFICATION_ERROR_NONE;
1054 EXPORT_API int notification_set_time_to_text(notification_h noti, notification_text_type_e type,
1057 int ret = NOTIFICATION_ERROR_NONE;
1058 char buf[256] = { 0, };
1059 char buf_tag[512] = { 0, };
1062 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1065 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1067 if (type <= NOTIFICATION_TEXT_TYPE_NONE
1068 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
1069 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1073 snprintf(buf, sizeof(buf), "%lu", time);
1074 ret = notification_noti_set_tag(TAG_TIME, buf, buf_tag, sizeof(buf_tag));
1076 if (ret != NOTIFICATION_ERROR_NONE) {
1080 return notification_set_text(noti, type, buf_tag, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1083 EXPORT_API int notification_get_time_from_text(notification_h noti, notification_text_type_e type,
1086 int ret = NOTIFICATION_ERROR_NONE;
1089 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1092 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1094 if (type <= NOTIFICATION_TEXT_TYPE_NONE
1095 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
1096 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1099 char *ret_text = NULL;
1100 ret = notification_get_text(noti, type, &ret_text);
1102 if (ret != NOTIFICATION_ERROR_NONE || ret_text == NULL) {
1103 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1106 if (notification_noti_get_tag_type(ret_text) == TAG_TYPE_INVALID) {
1107 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1110 char *tag_value = NULL;
1111 tag_value = notification_noti_strip_tag(ret_text);
1112 if (tag_value == NULL) {
1113 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1116 *time = atol(tag_value);
1119 return NOTIFICATION_ERROR_NONE;
1122 EXPORT_API int notification_set_sound(notification_h noti,
1123 notification_sound_type_e type,
1126 /* Check noti is valid data */
1128 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1131 /* Check type is valid */
1132 if (type < NOTIFICATION_SOUND_TYPE_NONE
1133 || type >= NOTIFICATION_SOUND_TYPE_MAX) {
1134 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1137 /* Save sound type */
1138 noti->sound_type = type;
1140 /* Save sound path if user data type */
1141 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA && path != NULL) {
1142 if (noti->sound_path != NULL) {
1143 free(noti->sound_path);
1146 noti->sound_path = strdup(path);
1148 if (noti->sound_path != NULL) {
1149 free(noti->sound_path);
1150 noti->sound_path = NULL;
1152 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA) {
1153 noti->sound_type = NOTIFICATION_SOUND_TYPE_DEFAULT;
1154 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1158 return NOTIFICATION_ERROR_NONE;
1161 EXPORT_API int notification_get_sound(notification_h noti,
1162 notification_sound_type_e *type,
1165 /* check noti and type is valid data */
1166 if (noti == NULL || type == NULL) {
1167 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1170 /* Set sound type */
1171 *type = noti->sound_type;
1173 /* Set sound path if user data type */
1174 if (noti->sound_type == NOTIFICATION_SOUND_TYPE_USER_DATA
1176 *path = noti->sound_path;
1179 return NOTIFICATION_ERROR_NONE;
1182 EXPORT_API int notification_set_vibration(notification_h noti,
1183 notification_vibration_type_e type,
1186 /* Check noti is valid data */
1188 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1191 /* Check type is valid */
1192 if (type < NOTIFICATION_VIBRATION_TYPE_NONE
1193 || type >= NOTIFICATION_VIBRATION_TYPE_MAX) {
1194 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1197 /* Save vibration type */
1198 noti->vibration_type = type;
1200 /* Save sound path if user data type */
1201 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA && path != NULL) {
1202 if (noti->vibration_path != NULL) {
1203 free(noti->vibration_path);
1206 noti->vibration_path = strdup(path);
1208 if (noti->vibration_path != NULL) {
1209 free(noti->vibration_path);
1210 noti->vibration_path = NULL;
1212 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA) {
1213 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
1214 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1218 return NOTIFICATION_ERROR_NONE;
1222 EXPORT_API int notification_get_vibration(notification_h noti,
1223 notification_vibration_type_e *type,
1226 /* check noti and type is valid data */
1227 if (noti == NULL || type == NULL) {
1228 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1231 /* Set vibration type */
1232 *type = noti->vibration_type;
1234 /* Set sound path if user data type */
1235 if (noti->vibration_type == NOTIFICATION_VIBRATION_TYPE_USER_DATA
1237 *path = noti->vibration_path;
1240 return NOTIFICATION_ERROR_NONE;
1243 EXPORT_API int notification_set_led(notification_h noti,
1244 notification_led_op_e operation,
1247 /* Check noti is valid data */
1249 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1252 /* Check operation is valid */
1253 if (operation < NOTIFICATION_LED_OP_OFF
1254 || operation >= NOTIFICATION_LED_OP_MAX) {
1255 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1258 /* Save led operation */
1259 noti->led_operation = operation;
1261 /* Save led argb if operation is turning on LED with custom color */
1262 if (operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR) {
1263 noti->led_argb = led_argb;
1266 return NOTIFICATION_ERROR_NONE;
1269 EXPORT_API int notification_get_led(notification_h noti,
1270 notification_led_op_e *operation,
1273 /* check noti and operation is valid data */
1274 if (noti == NULL || operation == NULL) {
1275 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1278 /* Set led operation */
1279 *operation = noti->led_operation;
1281 /* Save led argb if operation is turning on LED with custom color */
1282 if (noti->led_operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR
1283 && led_argb != NULL) {
1284 *led_argb = noti->led_argb;
1287 return NOTIFICATION_ERROR_NONE;
1290 EXPORT_API int notification_set_led_time_period(notification_h noti,
1291 int on_ms, int off_ms)
1293 /* Check noti is valid data */
1294 if (noti == NULL || on_ms < 0 || off_ms < 0) {
1295 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1298 /* Save led operation */
1299 noti->led_on_ms = on_ms;
1300 noti->led_off_ms = off_ms;
1302 return NOTIFICATION_ERROR_NONE;
1305 EXPORT_API int notification_get_led_time_period(notification_h noti,
1306 int *on_ms, int *off_ms)
1308 /* check noti and operation is valid data */
1310 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1314 *(on_ms) = noti->led_on_ms;
1316 *(off_ms) = noti->led_off_ms;
1318 return NOTIFICATION_ERROR_NONE;
1321 EXPORT_API int notification_set_application(notification_h noti,
1322 const char *pkgname)
1324 if (noti == NULL || pkgname == NULL) {
1325 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1328 if (noti->launch_pkgname) {
1329 free(noti->launch_pkgname);
1332 noti->launch_pkgname = strdup(pkgname);
1334 return NOTIFICATION_ERROR_NONE;
1337 EXPORT_API int notification_get_application(notification_h noti,
1340 if (noti == NULL || pkgname == NULL) {
1341 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1344 if (noti->launch_pkgname) {
1345 *pkgname = noti->launch_pkgname;
1347 *pkgname = noti->caller_pkgname;
1350 return NOTIFICATION_ERROR_NONE;
1353 EXPORT_API int notification_set_launch_option(notification_h noti,
1354 notification_launch_option_type type, void *option)
1358 app_control_h app_control = option;
1361 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1363 if (app_control == NULL) {
1364 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1366 if (type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL) {
1367 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1370 if ((ret = app_control_export_as_bundle(app_control, &b)) == APP_CONTROL_ERROR_NONE) {
1371 return notification_set_execute_option(noti,
1372 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
1376 NOTIFICATION_ERR("Failed to convert appcontrol to bundle:%d", ret);
1377 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1381 EXPORT_API int notification_get_launch_option(notification_h noti,
1382 notification_launch_option_type type, void *option)
1386 app_control_h *app_control = (app_control_h *)option;
1387 app_control_h app_control_new = NULL;
1390 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1392 if (app_control == NULL) {
1393 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1395 if (type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL) {
1396 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1399 ret = notification_get_execute_option(noti,
1400 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
1403 if (ret == NOTIFICATION_ERROR_NONE && b != NULL) {
1404 ret = app_control_create(&app_control_new);
1405 if (ret == APP_CONTROL_ERROR_NONE && app_control_new != NULL) {
1406 ret = app_control_import_from_bundle(app_control_new, b);
1407 if (ret == APP_CONTROL_ERROR_NONE) {
1408 *app_control = app_control_new;
1410 app_control_destroy(app_control_new);
1411 NOTIFICATION_ERR("Failed to import app control from bundle:%d", ret);
1412 return NOTIFICATION_ERROR_IO_ERROR;
1415 NOTIFICATION_ERR("Failed to create app control:%d", ret);
1416 return NOTIFICATION_ERROR_IO_ERROR;
1419 NOTIFICATION_ERR("Failed to get execute option:%d", ret);
1423 return NOTIFICATION_ERROR_NONE;
1426 EXPORT_API int notification_set_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h event_handler)
1428 int err = NOTIFICATION_ERROR_NONE;
1429 bundle *app_control_bundle = NULL;
1432 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1433 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1434 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1437 if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
1438 || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
1439 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1440 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1444 if ((err = app_control_export_as_bundle(event_handler, &app_control_bundle)) != APP_CONTROL_ERROR_NONE) {
1445 NOTIFICATION_ERR("app_control_to_bundle failed [%d]", err);
1449 if (noti->b_event_handler[event_type] != NULL) {
1450 bundle_free(noti->b_event_handler[event_type]);
1453 noti->b_event_handler[event_type] = app_control_bundle;
1459 EXPORT_API int notification_get_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h *event_handler)
1461 int err = NOTIFICATION_ERROR_NONE;
1463 app_control_h app_control_new = NULL;
1466 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1467 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1470 if (event_handler == NULL) {
1471 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1472 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1475 if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
1476 || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
1477 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1478 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1482 b = noti->b_event_handler[event_type];
1485 NOTIFICATION_DBG("No event handler\n");
1486 err = NOTIFICATION_ERROR_NOT_EXIST_ID;
1490 err = app_control_create(&app_control_new);
1491 if (err != APP_CONTROL_ERROR_NONE || app_control_new == NULL) {
1492 NOTIFICATION_ERR("app_control_create failed [%d]", err);
1493 err = NOTIFICATION_ERROR_IO_ERROR;
1497 err = app_control_import_from_bundle(app_control_new, b);
1498 if (err == APP_CONTROL_ERROR_NONE) {
1499 *event_handler = app_control_new;
1502 app_control_destroy(app_control_new);
1503 NOTIFICATION_ERR("Failed to import app control from bundle [%d]", err);
1504 err = NOTIFICATION_ERROR_IO_ERROR;
1510 *event_handler = app_control_new;
1515 EXPORT_API int notification_set_execute_option(notification_h noti,
1516 notification_execute_type_e type,
1519 bundle *service_handle)
1521 char buf_key[32] = { 0, };
1522 const char *ret_val = NULL;
1526 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1529 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1530 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1531 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1534 /* Create execute option bundle if does not exist */
1535 if (noti->b_execute_option == NULL) {
1536 noti->b_execute_option = bundle_create();
1539 b = noti->b_execute_option;
1544 snprintf(buf_key, sizeof(buf_key), "text%d", type);
1546 /* Check text key exist */
1547 ret_val = bundle_get_val(b, buf_key);
1548 if (ret_val != NULL) {
1549 /* Remove previous data */
1550 bundle_del(b, buf_key);
1554 bundle_add(b, buf_key, text);
1560 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1562 /* Check key key exist */
1563 ret_val = bundle_get_val(b, buf_key);
1564 if (ret_val != NULL) {
1565 /* Remove previous data */
1566 bundle_del(b, buf_key);
1570 bundle_add(b, buf_key, key);
1573 switch ((int)type) {
1574 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1575 /* Remove previous data if exist */
1576 if (noti->b_service_responding != NULL) {
1577 bundle_free(noti->b_service_responding);
1578 noti->b_service_responding = NULL;
1581 /* Save service handle */
1582 if (service_handle != NULL) {
1583 noti->b_service_responding = bundle_dup(service_handle);
1586 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1587 /* Remove previous data if exist */
1588 if (noti->b_service_single_launch != NULL) {
1589 bundle_free(noti->b_service_single_launch);
1590 noti->b_service_single_launch = NULL;
1593 /* Save service handle */
1594 if (service_handle != NULL) {
1595 noti->b_service_single_launch =
1596 bundle_dup(service_handle);
1599 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1600 /* Remove previous data if exist */
1601 if (noti->b_service_multi_launch != NULL) {
1602 bundle_free(noti->b_service_multi_launch);
1603 noti->b_service_multi_launch = NULL;
1606 /* Save service handle */
1607 if (service_handle != NULL) {
1608 noti->b_service_multi_launch =
1609 bundle_dup(service_handle);
1614 return NOTIFICATION_ERROR_NONE;
1617 EXPORT_API int notification_get_execute_option(notification_h noti,
1618 notification_execute_type_e type,
1620 bundle **service_handle)
1622 char buf_key[32] = { 0, };
1623 const char *ret_val = NULL;
1624 char *get_str = NULL;
1628 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1631 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1632 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1633 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1637 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1638 b = noti->b_service_responding;
1640 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1641 b = noti->b_service_single_launch;
1643 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1644 b = noti->b_service_multi_launch;
1652 // Get text domain and dir
1653 if (noti->domain == NULL || noti->dir == NULL) {
1654 _notification_get_text_domain(noti);
1658 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1660 /* Check key key exist */
1661 ret_val = bundle_get_val(b, buf_key);
1662 if (ret_val != NULL && noti->domain != NULL
1663 && noti->dir != NULL) {
1664 /* Get application string */
1665 bindtextdomain(noti->domain, noti->dir);
1667 get_str = dgettext(noti->domain, ret_val);
1670 } else if (ret_val != NULL) {
1671 /* Get system string */
1672 get_str = dgettext("sys_string", ret_val);
1676 /* Get basic text */
1677 snprintf(buf_key, sizeof(buf_key), "text%d",
1680 ret_val = bundle_get_val(b, buf_key);
1687 if (service_handle != NULL) {
1688 *service_handle = b;
1691 return NOTIFICATION_ERROR_NONE;
1694 EXPORT_API int notification_set_property(notification_h noti,
1697 /* Check noti is valid data */
1699 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1703 noti->flags_for_property = flags;
1705 return NOTIFICATION_ERROR_NONE;
1708 EXPORT_API int notification_get_property(notification_h noti,
1711 /* Check noti and flags are valid data */
1712 if (noti == NULL || flags == NULL) {
1713 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1717 *flags = noti->flags_for_property;
1719 return NOTIFICATION_ERROR_NONE;
1722 EXPORT_API int notification_set_display_applist(notification_h noti,
1725 /* Check noti is valid data */
1727 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1731 noti->display_applist = applist;
1733 return NOTIFICATION_ERROR_NONE;
1736 EXPORT_API int notification_get_display_applist(notification_h noti,
1739 /* Check noti and applist are valid data */
1740 if (noti == NULL || applist == NULL) {
1741 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1745 *applist = noti->display_applist;
1747 return NOTIFICATION_ERROR_NONE;
1750 EXPORT_API int notification_set_size(notification_h noti,
1753 /* Check noti is valid data */
1755 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1758 /* Save progress size */
1759 noti->progress_size = size;
1761 return NOTIFICATION_ERROR_NONE;
1764 EXPORT_API int notification_get_size(notification_h noti,
1767 /* Check noti and size is valid data */
1768 if (noti == NULL || size == NULL) {
1769 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1772 /* Set progress size */
1773 *size = noti->progress_size;
1775 return NOTIFICATION_ERROR_NONE;
1778 EXPORT_API int notification_set_progress(notification_h noti,
1781 /* Check noti is valid data */
1783 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1786 /* Save progress percentage */
1787 noti->progress_percentage = percentage;
1789 return NOTIFICATION_ERROR_NONE;
1792 EXPORT_API int notification_get_progress(notification_h noti,
1795 /* Check noti and percentage are valid data */
1796 if (noti == NULL || percentage == NULL) {
1797 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1800 /* Set progress percentage */
1801 *percentage = noti->progress_percentage;
1803 return NOTIFICATION_ERROR_NONE;
1806 EXPORT_API int notification_set_pkgname(notification_h noti,
1807 const char *pkgname)
1809 /* check noti and pkgname are valid data */
1810 if (noti == NULL || pkgname == NULL) {
1811 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1814 /* Remove previous caller pkgname */
1815 if (noti->caller_pkgname) {
1816 free(noti->caller_pkgname);
1817 noti->caller_pkgname = NULL;
1820 noti->caller_pkgname = strdup(pkgname);
1822 return NOTIFICATION_ERROR_NONE;
1825 EXPORT_API int notification_get_pkgname(notification_h noti,
1828 /* Check noti and pkgname are valid data */
1829 if (noti == NULL || pkgname == NULL) {
1830 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1833 /* Get caller pkgname */
1834 if (noti->caller_pkgname) {
1835 *pkgname = noti->caller_pkgname;
1840 return NOTIFICATION_ERROR_NONE;
1843 EXPORT_API int notification_set_layout(notification_h noti,
1844 notification_ly_type_e layout)
1846 /* check noti and pkgname are valid data */
1847 if (noti == NULL || (layout < NOTIFICATION_LY_NONE || layout >= NOTIFICATION_LY_MAX)) {
1848 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1851 noti->layout = layout;
1853 return NOTIFICATION_ERROR_NONE;
1856 EXPORT_API int notification_get_layout(notification_h noti,
1857 notification_ly_type_e *layout)
1859 /* Check noti and pkgname are valid data */
1860 if (noti == NULL || layout == NULL) {
1861 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1864 *layout = noti->layout;
1866 return NOTIFICATION_ERROR_NONE;
1869 EXPORT_API int notification_get_id(notification_h noti,
1870 int *group_id, int *priv_id)
1872 /* check noti is valid data */
1874 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1877 /* Check group_id is valid data */
1880 if (noti->group_id < NOTIFICATION_GROUP_ID_NONE) {
1881 *group_id = NOTIFICATION_GROUP_ID_NONE;
1883 *group_id = noti->group_id;
1887 /* Check priv_id is valid data */
1890 *priv_id = noti->priv_id;
1893 return NOTIFICATION_ERROR_NONE;
1896 EXPORT_API int notification_get_type(notification_h noti,
1897 notification_type_e *type)
1899 /* Check noti and type is valid data */
1900 if (noti == NULL || type == NULL) {
1901 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1907 return NOTIFICATION_ERROR_NONE;
1910 EXPORT_API int notification_post(notification_h noti)
1915 /* Check noti is vaild data */
1917 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1920 /* Check noti type is valid type */
1921 if (noti->type <= NOTIFICATION_TYPE_NONE
1922 || noti->type >= NOTIFICATION_TYPE_MAX) {
1923 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1926 /* Save insert time */
1927 noti->insert_time = time(NULL);
1929 ret = notification_ipc_request_insert(noti, &id);
1930 if (ret != NOTIFICATION_ERROR_NONE) {
1934 NOTIFICATION_DBG("from master:%d", id);
1936 return NOTIFICATION_ERROR_NONE;
1939 EXPORT_API int notification_insert(notification_h noti,
1945 /* Check noti is vaild data */
1947 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1950 /* Check noti type is valid type */
1951 if (noti->type <= NOTIFICATION_TYPE_NONE
1952 || noti->type >= NOTIFICATION_TYPE_MAX) {
1953 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1956 /* Save insert time */
1957 noti->insert_time = time(NULL);
1958 ret = notification_ipc_request_insert(noti, &id);
1959 if (ret != NOTIFICATION_ERROR_NONE) {
1963 NOTIFICATION_DBG("from master:%d", id);
1965 /* If priv_id is valid data, set priv_id */
1966 if (priv_id != NULL) {
1967 *priv_id = noti->priv_id;
1970 return NOTIFICATION_ERROR_NONE;
1973 EXPORT_API int notification_update(notification_h noti)
1977 /* Check noti is valid data */
1979 /* Update insert time ? */
1980 noti->insert_time = time(NULL);
1981 ret = notification_ipc_request_update(noti);
1983 notification_ipc_request_refresh();
1984 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1989 EXPORT_API int notification_update_async(notification_h noti,
1990 void (*result_cb)(int priv_id, int result, void *data), void *user_data)
1995 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1998 /* Update insert time ? */
1999 noti->insert_time = time(NULL);
2000 ret = notification_ipc_request_update_async(noti, result_cb, user_data);
2005 EXPORT_API int notifiation_clear(notification_type_e type)
2009 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
2010 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2013 ret = notification_ipc_request_delete_multiple(type, NULL);
2018 EXPORT_API int notification_clear(notification_type_e type)
2022 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
2023 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2026 ret = notification_ipc_request_delete_multiple(type, NULL);
2031 EXPORT_API int notification_delete_all(notification_type_e type)
2034 char *caller_pkgname = NULL;
2036 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
2037 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2040 caller_pkgname = notification_get_pkgname_by_pid();
2042 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
2044 if (caller_pkgname) {
2045 free(caller_pkgname);
2051 EXPORT_API int notification_delete_all_by_type(const char *pkgname,
2052 notification_type_e type)
2055 char *caller_pkgname = NULL;
2057 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
2058 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2061 if (pkgname == NULL) {
2062 caller_pkgname = notification_get_pkgname_by_pid();
2064 caller_pkgname = strdup(pkgname);
2067 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
2069 if (caller_pkgname) {
2070 free(caller_pkgname);
2076 EXPORT_API int notification_delete_by_priv_id(const char *pkgname,
2077 notification_type_e type,
2081 char *caller_pkgname = NULL;
2083 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2084 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2087 if (pkgname == NULL) {
2088 caller_pkgname = notification_get_pkgname_by_pid();
2090 caller_pkgname = strdup(pkgname);
2093 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
2095 if (caller_pkgname) {
2096 free(caller_pkgname);
2102 EXPORT_API int notification_delete(notification_h noti)
2107 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2110 ret = notification_ipc_request_delete_single(NOTIFICATION_TYPE_NONE, noti->caller_pkgname, noti->priv_id);
2115 EXPORT_API int notification_update_progress(notification_h noti,
2119 char *caller_pkgname = NULL;
2120 int input_priv_id = 0;
2122 double input_progress = 0.0;
2124 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2126 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2128 input_priv_id = noti->priv_id;
2131 input_priv_id = priv_id;
2135 caller_pkgname = notification_get_pkgname_by_pid();
2137 caller_pkgname = strdup(noti->caller_pkgname);
2140 if (progress < 0.0) {
2141 input_progress = 0.0;
2142 } else if (progress > 1.0) {
2143 input_progress = 1.0;
2145 input_progress = progress;
2148 ret = notification_ongoing_update_progress(caller_pkgname, input_priv_id,
2151 if (caller_pkgname) {
2152 free(caller_pkgname);
2158 EXPORT_API int notification_update_size(notification_h noti,
2162 char *caller_pkgname = NULL;
2163 int input_priv_id = 0;
2165 double input_size = 0.0;
2167 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2169 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2171 input_priv_id = noti->priv_id;
2174 input_priv_id = priv_id;
2178 caller_pkgname = notification_get_pkgname_by_pid();
2180 caller_pkgname = strdup(noti->caller_pkgname);
2189 ret = notification_ongoing_update_size(caller_pkgname, input_priv_id,
2192 if (caller_pkgname) {
2193 free(caller_pkgname);
2199 EXPORT_API int notification_update_content(notification_h noti,
2201 const char *content)
2203 char *caller_pkgname = NULL;
2204 int input_priv_id = 0;
2207 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2209 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2211 input_priv_id = noti->priv_id;
2214 input_priv_id = priv_id;
2218 caller_pkgname = notification_get_pkgname_by_pid();
2220 caller_pkgname = strdup(noti->caller_pkgname);
2223 ret = notification_ongoing_update_content(caller_pkgname, input_priv_id,
2226 if (caller_pkgname) {
2227 free(caller_pkgname);
2233 static notification_h _notification_create(notification_type_e type)
2235 notification_h noti = NULL;
2237 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
2238 NOTIFICATION_ERR("INVALID TYPE : %d", type);
2239 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
2243 noti = (notification_h) calloc(1, sizeof(struct _notification));
2245 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2246 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2252 if (type == NOTIFICATION_TYPE_NOTI)
2253 noti->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2254 else if (type == NOTIFICATION_TYPE_ONGOING)
2255 noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
2257 noti->caller_pkgname = notification_get_pkgname_by_pid();
2258 noti->group_id = NOTIFICATION_GROUP_ID_NONE;
2259 noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
2260 noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
2261 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
2262 noti->led_operation = NOTIFICATION_LED_OP_OFF;
2263 noti->display_applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_INDICATOR;
2266 * Other fields are already initialized with ZERO.
2268 set_last_result(NOTIFICATION_ERROR_NONE);
2272 EXPORT_API notification_h notification_new(notification_type_e type,
2273 int group_id, int priv_id)
2275 return _notification_create(type);
2278 EXPORT_API notification_h notification_create(notification_type_e type)
2280 return _notification_create(type);
2283 EXPORT_API notification_h notification_load(char *pkgname,
2287 notification_h noti = NULL;
2289 noti = (notification_h) calloc(1, sizeof(struct _notification));
2291 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2295 ret = notification_noti_get_by_priv_id(noti, pkgname, priv_id);
2296 if (ret != NOTIFICATION_ERROR_NONE) {
2297 notification_free(noti);
2304 EXPORT_API notification_h notification_load_by_tag(const char *tag)
2307 notification_h noti = NULL;
2308 char *caller_pkgname = NULL;
2311 NOTIFICATION_ERR("Invalid parameter");
2312 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
2316 caller_pkgname = notification_get_pkgname_by_pid();
2317 if (!caller_pkgname) {
2318 NOTIFICATION_ERR("Failed to get a package name");
2319 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2324 noti = (notification_h) calloc(1, sizeof(struct _notification));
2326 NOTIFICATION_ERR("Failed to alloc a new notification");
2327 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2328 free(caller_pkgname);
2333 ret = notification_ipc_request_load_noti_by_tag(noti, caller_pkgname, tag);
2335 free(caller_pkgname);
2337 set_last_result(ret);
2339 if (ret != NOTIFICATION_ERROR_NONE) {
2340 notification_free(noti);
2347 EXPORT_API int notification_clone(notification_h noti, notification_h *clone)
2350 notification_h new_noti = NULL;
2352 if (noti == NULL || clone == NULL) {
2353 NOTIFICATION_ERR("INVALID PARAMETER.");
2354 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2357 new_noti = (notification_h) calloc(1, sizeof(struct _notification));
2358 if (new_noti == NULL) {
2359 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2360 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
2363 new_noti->type = noti->type;
2364 new_noti->layout = noti->layout;
2366 new_noti->group_id = noti->group_id;
2367 new_noti->internal_group_id = noti->internal_group_id;
2368 new_noti->priv_id = noti->priv_id;
2370 if(noti->caller_pkgname != NULL) {
2371 new_noti->caller_pkgname = strdup(noti->caller_pkgname);
2373 new_noti->caller_pkgname = notification_get_pkgname_by_pid();
2375 if(noti->launch_pkgname != NULL) {
2376 new_noti->launch_pkgname = strdup(noti->launch_pkgname);
2378 new_noti->launch_pkgname = NULL;
2381 if(noti->args != NULL) {
2382 new_noti->args = bundle_dup(noti->args);
2384 new_noti->args = NULL;
2386 if(noti->group_args != NULL) {
2387 new_noti->group_args = bundle_dup(noti->group_args);
2389 new_noti->group_args = NULL;
2392 if(noti->b_execute_option != NULL) {
2393 new_noti->b_execute_option = bundle_dup(noti->b_execute_option);
2395 new_noti->b_execute_option = NULL;
2397 if(noti->b_service_responding != NULL) {
2398 new_noti->b_service_responding = bundle_dup(noti->b_service_responding);
2400 new_noti->b_service_responding = NULL;
2402 if(noti->b_service_single_launch != NULL) {
2403 new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch);
2405 new_noti->b_service_single_launch = NULL;
2407 if(noti->b_service_multi_launch != NULL) {
2408 new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch);
2410 new_noti->b_service_multi_launch = NULL;
2413 for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
2414 if(noti->b_event_handler[i] != NULL) {
2415 new_noti->b_event_handler[i] = bundle_dup(noti->b_event_handler[i]);
2417 new_noti->b_event_handler[i] = NULL;
2421 new_noti->sound_type = noti->sound_type;
2422 if(noti->sound_path != NULL) {
2423 new_noti->sound_path = strdup(noti->sound_path);
2425 new_noti->sound_path = NULL;
2427 new_noti->vibration_type = noti->vibration_type;
2428 if(noti->vibration_path != NULL) {
2429 new_noti->vibration_path = strdup(noti->vibration_path);
2431 new_noti->vibration_path = NULL;
2433 new_noti->led_operation = noti->led_operation;
2434 new_noti->led_argb = noti->led_argb;
2435 new_noti->led_on_ms = noti->led_on_ms;
2436 new_noti->led_off_ms = noti->led_off_ms;
2438 if(noti->domain != NULL) {
2439 new_noti->domain = strdup(noti->domain);
2441 new_noti->domain = NULL;
2443 if(noti->dir != NULL) {
2444 new_noti->dir = strdup(noti->dir);
2446 new_noti->dir = NULL;
2449 if(noti->b_text != NULL) {
2450 new_noti->b_text = bundle_dup(noti->b_text);
2452 new_noti->b_text = NULL;
2454 if(noti->b_key != NULL) {
2455 new_noti->b_key = bundle_dup(noti->b_key);
2457 new_noti->b_key = NULL;
2459 if(noti->b_format_args != NULL) {
2460 new_noti->b_format_args = bundle_dup(noti->b_format_args);
2462 new_noti->b_format_args = NULL;
2464 new_noti->num_format_args = noti->num_format_args;
2466 if(noti->b_image_path != NULL) {
2467 new_noti->b_image_path = bundle_dup(noti->b_image_path);
2469 new_noti->b_image_path = NULL;
2472 new_noti->time = noti->time;
2473 new_noti->insert_time = noti->insert_time;
2475 new_noti->flags_for_property = noti->flags_for_property;
2476 new_noti->display_applist = noti->display_applist;
2478 new_noti->progress_size = noti->progress_size;
2479 new_noti->progress_percentage = noti->progress_percentage;
2481 new_noti->app_icon_path = NULL;
2482 new_noti->app_name = NULL;
2483 new_noti->temp_title = NULL;
2484 new_noti->temp_content = NULL;
2488 return NOTIFICATION_ERROR_NONE;
2492 EXPORT_API int notification_free(notification_h noti)
2496 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2499 if (noti->caller_pkgname) {
2500 free(noti->caller_pkgname);
2502 if (noti->launch_pkgname) {
2503 free(noti->launch_pkgname);
2506 bundle_free(noti->args);
2508 if (noti->group_args) {
2509 bundle_free(noti->group_args);
2512 if (noti->b_execute_option) {
2513 bundle_free(noti->b_execute_option);
2515 if (noti->b_service_responding) {
2516 bundle_free(noti->b_service_responding);
2518 if (noti->b_service_single_launch) {
2519 bundle_free(noti->b_service_single_launch);
2521 if (noti->b_service_multi_launch) {
2522 bundle_free(noti->b_service_multi_launch);
2525 for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
2526 if(noti->b_event_handler[i] != NULL) {
2527 bundle_free(noti->b_event_handler[i]);
2531 if (noti->sound_path) {
2532 free(noti->sound_path);
2534 if (noti->vibration_path) {
2535 free(noti->vibration_path);
2546 bundle_free(noti->b_text);
2549 bundle_free(noti->b_key);
2551 if (noti->b_format_args) {
2552 bundle_free(noti->b_format_args);
2555 if (noti->b_image_path) {
2556 bundle_free(noti->b_image_path);
2559 if (noti->app_icon_path) {
2560 free(noti->app_icon_path);
2562 if (noti->app_name) {
2563 free(noti->app_name);
2565 if (noti->temp_title) {
2566 free(noti->temp_title);
2568 if (noti->temp_content) {
2569 free(noti->temp_content);
2578 return NOTIFICATION_ERROR_NONE;
2582 notification_resister_changed_cb(void (*changed_cb)
2583 (void *data, notification_type_e type),
2586 notification_cb_list_s *noti_cb_list_new = NULL;
2587 notification_cb_list_s *noti_cb_list = NULL;
2589 if (changed_cb == NULL) {
2590 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2592 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
2593 return NOTIFICATION_ERROR_IO_ERROR;
2597 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
2599 noti_cb_list_new->next = NULL;
2600 noti_cb_list_new->prev = NULL;
2602 noti_cb_list_new->cb_type = NOTIFICATION_CB_NORMAL;
2603 noti_cb_list_new->changed_cb = changed_cb;
2604 noti_cb_list_new->detailed_changed_cb = NULL;
2605 noti_cb_list_new->data = user_data;
2607 if (g_notification_cb_list == NULL) {
2608 g_notification_cb_list = noti_cb_list_new;
2610 noti_cb_list = g_notification_cb_list;
2612 while (noti_cb_list->next != NULL) {
2613 noti_cb_list = noti_cb_list->next;
2616 noti_cb_list->next = noti_cb_list_new;
2617 noti_cb_list_new->prev = noti_cb_list;
2619 return NOTIFICATION_ERROR_NONE;
2623 notification_unresister_changed_cb(void (*changed_cb)
2624 (void *data, notification_type_e type))
2626 notification_cb_list_s *noti_cb_list = NULL;
2627 notification_cb_list_s *noti_cb_list_prev = NULL;
2628 notification_cb_list_s *noti_cb_list_next = NULL;
2630 noti_cb_list = g_notification_cb_list;
2632 if (changed_cb == NULL) {
2633 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2635 if (noti_cb_list == NULL) {
2636 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2639 while (noti_cb_list->prev != NULL) {
2640 noti_cb_list = noti_cb_list->prev;
2644 if (noti_cb_list->changed_cb == changed_cb) {
2645 noti_cb_list_prev = noti_cb_list->prev;
2646 noti_cb_list_next = noti_cb_list->next;
2648 if (noti_cb_list_prev == NULL) {
2649 g_notification_cb_list = noti_cb_list_next;
2651 noti_cb_list_prev->next = noti_cb_list_next;
2654 if (noti_cb_list_next == NULL) {
2655 if (noti_cb_list_prev != NULL) {
2656 noti_cb_list_prev->next = NULL;
2659 noti_cb_list_next->prev = noti_cb_list_prev;
2664 if (g_notification_cb_list == NULL)
2665 notification_ipc_monitor_fini();
2667 return NOTIFICATION_ERROR_NONE;
2669 noti_cb_list = noti_cb_list->next;
2670 } while (noti_cb_list != NULL);
2672 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2676 notification_register_detailed_changed_cb(
2677 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
2680 notification_cb_list_s *noti_cb_list_new = NULL;
2681 notification_cb_list_s *noti_cb_list = NULL;
2683 if (detailed_changed_cb == NULL) {
2684 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2686 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
2687 return NOTIFICATION_ERROR_IO_ERROR;
2691 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
2693 noti_cb_list_new->next = NULL;
2694 noti_cb_list_new->prev = NULL;
2696 noti_cb_list_new->cb_type = NOTIFICATION_CB_DETAILED;
2697 noti_cb_list_new->changed_cb = NULL;
2698 noti_cb_list_new->detailed_changed_cb = detailed_changed_cb;
2699 noti_cb_list_new->data = user_data;
2701 if (g_notification_cb_list == NULL) {
2702 g_notification_cb_list = noti_cb_list_new;
2704 noti_cb_list = g_notification_cb_list;
2706 while (noti_cb_list->next != NULL) {
2707 noti_cb_list = noti_cb_list->next;
2710 noti_cb_list->next = noti_cb_list_new;
2711 noti_cb_list_new->prev = noti_cb_list;
2713 return NOTIFICATION_ERROR_NONE;
2717 notification_unregister_detailed_changed_cb(
2718 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
2721 notification_cb_list_s *noti_cb_list = NULL;
2722 notification_cb_list_s *noti_cb_list_prev = NULL;
2723 notification_cb_list_s *noti_cb_list_next = NULL;
2725 noti_cb_list = g_notification_cb_list;
2727 if (detailed_changed_cb == NULL) {
2728 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2730 if (noti_cb_list == NULL) {
2731 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2734 while (noti_cb_list->prev != NULL) {
2735 noti_cb_list = noti_cb_list->prev;
2739 if (noti_cb_list->detailed_changed_cb == detailed_changed_cb) {
2740 noti_cb_list_prev = noti_cb_list->prev;
2741 noti_cb_list_next = noti_cb_list->next;
2743 if (noti_cb_list_prev == NULL) {
2744 g_notification_cb_list = noti_cb_list_next;
2746 noti_cb_list_prev->next = noti_cb_list_next;
2749 if (noti_cb_list_next == NULL) {
2750 if (noti_cb_list_prev != NULL) {
2751 noti_cb_list_prev->next = NULL;
2754 noti_cb_list_next->prev = noti_cb_list_prev;
2759 if (g_notification_cb_list == NULL)
2760 notification_ipc_monitor_fini();
2762 return NOTIFICATION_ERROR_NONE;
2764 noti_cb_list = noti_cb_list->next;
2765 } while (noti_cb_list != NULL);
2767 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2770 EXPORT_API int notification_get_count(notification_type_e type,
2771 const char *pkgname,
2773 int priv_id, int *count)
2778 if (count == NULL) {
2779 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2783 notification_noti_get_count(type, pkgname, group_id, priv_id,
2785 if (ret != NOTIFICATION_ERROR_NONE) {
2789 *count = noti_count;
2791 return NOTIFICATION_ERROR_NONE;
2794 EXPORT_API int notification_get_list(notification_type_e type,
2796 notification_list_h *list)
2798 notification_list_h get_list = NULL;
2802 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2805 ret = notification_noti_get_grouping_list(type, count, &get_list);
2806 if (ret != NOTIFICATION_ERROR_NONE) {
2812 return NOTIFICATION_ERROR_NONE;
2816 notification_get_grouping_list(notification_type_e type, int count,
2817 notification_list_h * list)
2819 notification_list_h get_list = NULL;
2823 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2826 ret = notification_noti_get_grouping_list(type, count, &get_list);
2827 if (ret != NOTIFICATION_ERROR_NONE) {
2833 return NOTIFICATION_ERROR_NONE;
2836 EXPORT_API int notification_get_detail_list(const char *pkgname,
2840 notification_list_h *list)
2842 notification_list_h get_list = NULL;
2846 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2850 notification_noti_get_detail_list(pkgname, group_id, priv_id, count,
2852 if (ret != NOTIFICATION_ERROR_NONE) {
2858 return NOTIFICATION_ERROR_NONE;
2861 EXPORT_API int notification_free_list(notification_list_h list)
2863 notification_list_h cur_list = NULL;
2864 notification_h noti = NULL;
2867 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2870 cur_list = notification_list_get_head(list);
2872 while (cur_list != NULL) {
2873 noti = notification_list_get_data(cur_list);
2874 cur_list = notification_list_remove(cur_list, noti);
2876 notification_free(noti);
2879 return NOTIFICATION_ERROR_NONE;
2882 EXPORT_API int notification_op_get_data(notification_op *noti_op, notification_op_data_type_e type,
2885 if (noti_op == NULL || data == NULL) {
2886 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2890 case NOTIFICATION_OP_DATA_TYPE:
2891 *((int*)data) = noti_op->type;
2893 case NOTIFICATION_OP_DATA_PRIV_ID:
2894 *((int*)data) = noti_op->priv_id;
2896 case NOTIFICATION_OP_DATA_NOTI:
2897 *((notification_h *)data) = noti_op->noti;
2899 case NOTIFICATION_OP_DATA_EXTRA_INFO_1:
2900 *((int*)data) = noti_op->extra_info_1;
2902 case NOTIFICATION_OP_DATA_EXTRA_INFO_2:
2903 *((int*)data) = noti_op->extra_info_2;
2906 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2910 return NOTIFICATION_ERROR_NONE;
2913 void notification_call_changed_cb(notification_op *op_list, int op_num)
2915 notification_cb_list_s *noti_cb_list = NULL;
2916 notification_type_e type = 0;
2918 if (g_notification_cb_list == NULL) {
2921 noti_cb_list = g_notification_cb_list;
2923 while (noti_cb_list->prev != NULL) {
2924 noti_cb_list = noti_cb_list->prev;
2927 if (op_list == NULL) {
2928 NOTIFICATION_ERR("invalid data");
2932 notification_get_type(op_list->noti, &type);
2934 while (noti_cb_list != NULL) {
2935 if (noti_cb_list->cb_type == NOTIFICATION_CB_NORMAL && noti_cb_list->changed_cb) {
2936 noti_cb_list->changed_cb(noti_cb_list->data,
2939 if (noti_cb_list->cb_type == NOTIFICATION_CB_DETAILED && noti_cb_list->detailed_changed_cb) {
2940 noti_cb_list->detailed_changed_cb(noti_cb_list->data,
2941 type, op_list, op_num);
2944 noti_cb_list = noti_cb_list->next;
2948 EXPORT_API int notification_is_service_ready(void)
2950 return notification_ipc_is_master_ready();
2954 notification_add_deferred_task(
2955 void (*deferred_task_cb)(void *data), void *user_data)
2957 if (deferred_task_cb == NULL) {
2958 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2961 return notification_ipc_add_deffered_task(deferred_task_cb, user_data);
2965 notification_del_deferred_task(
2966 void (*deferred_task_cb)(void *data))
2968 if (deferred_task_cb == NULL) {
2969 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2972 return notification_ipc_del_deffered_task(deferred_task_cb);
2975 /* notification_set_icon will be removed */
2976 EXPORT_API int notification_set_icon(notification_h noti,
2977 const char *icon_path)
2979 int ret_err = NOTIFICATION_ERROR_NONE;
2982 notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
2988 /* notification_get_icon will be removed */
2989 EXPORT_API int notification_get_icon(notification_h noti,
2992 int ret_err = NOTIFICATION_ERROR_NONE;
2993 char *ret_image_path = NULL;
2996 notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
2999 if (ret_err == NOTIFICATION_ERROR_NONE && icon_path != NULL) {
3000 *icon_path = ret_image_path;
3002 //NOTIFICATION_DBG("Get icon : %s", *icon_path);
3008 EXPORT_API int notification_set_title(notification_h noti,
3010 const char *loc_title)
3012 int noti_err = NOTIFICATION_ERROR_NONE;
3014 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
3016 NOTIFICATION_VARIABLE_TYPE_NONE);
3021 EXPORT_API int notification_get_title(notification_h noti,
3025 int noti_err = NOTIFICATION_ERROR_NONE;
3026 char *ret_text = NULL;
3029 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
3032 if (title != NULL) {
3036 if (loc_title != NULL) {
3043 EXPORT_API int notification_set_content(notification_h noti,
3044 const char *content,
3045 const char *loc_content)
3047 int noti_err = NOTIFICATION_ERROR_NONE;
3049 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
3050 content, loc_content,
3051 NOTIFICATION_VARIABLE_TYPE_NONE);
3056 EXPORT_API int notification_get_content(notification_h noti,
3060 int noti_err = NOTIFICATION_ERROR_NONE;
3061 char *ret_text = NULL;
3064 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
3067 if (content != NULL) {
3068 *content = ret_text;
3071 if (loc_content != NULL) {
3072 *loc_content = NULL;
3080 (VCONFKEY_SETAPPL_STATE_TICKER_NOTI_DISPLAY_CONTENT_BOOL, &boolval);
3082 if (ret == -1 || boolval == 0) {
3083 if (content != NULL && noti->default_content != NULL) {
3084 *content = noti->default_content;
3087 if (loc_content != NULL && noti->loc_default_content != NULL) {
3088 *loc_content = noti->loc_default_content;
3094 EXPORT_API int notification_set_args(notification_h noti,
3096 bundle * group_args)
3098 if (noti == NULL || args == NULL) {
3099 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3103 bundle_free(noti->args);
3106 noti->args = bundle_dup(args);
3108 if (noti->group_args) {
3109 bundle_free(noti->group_args);
3110 noti->group_args = NULL;
3113 if (group_args != NULL) {
3114 noti->group_args = bundle_dup(group_args);
3117 return NOTIFICATION_ERROR_NONE;
3120 EXPORT_API int notification_get_args(notification_h noti,
3122 bundle ** group_args)
3124 if (noti == NULL || args == NULL) {
3125 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3134 if (group_args != NULL && noti->group_args) {
3135 *group_args = noti->group_args;
3138 return NOTIFICATION_ERROR_NONE;
3141 EXPORT_API int notification_delete_group_by_group_id(const char *pkgname,
3142 notification_type_e type,
3146 char *caller_pkgname = NULL;
3148 if (pkgname == NULL) {
3149 caller_pkgname = notification_get_pkgname_by_pid();
3151 caller_pkgname = strdup(pkgname);
3154 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
3155 if (ret != NOTIFICATION_ERROR_NONE) {
3156 if (caller_pkgname) {
3157 free(caller_pkgname);
3162 if (caller_pkgname) {
3163 free(caller_pkgname);
3165 return NOTIFICATION_ERROR_NONE;
3168 EXPORT_API int notification_delete_group_by_priv_id(const char *pkgname,
3169 notification_type_e type,
3173 char *caller_pkgname = NULL;
3175 if (pkgname == NULL) {
3176 caller_pkgname = notification_get_pkgname_by_pid();
3178 caller_pkgname = strdup(pkgname);
3181 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
3182 if (ret != NOTIFICATION_ERROR_NONE) {
3183 if (caller_pkgname) {
3184 free(caller_pkgname);
3189 if (caller_pkgname) {
3190 free(caller_pkgname);
3192 return NOTIFICATION_ERROR_NONE;
3195 EXPORT_API int notification_set_tag(notification_h noti, const char *tag)
3197 /* Check noti is valid data */
3199 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3203 /* save input TAG */
3204 if (noti->tag != NULL) {
3207 noti->tag = strdup(tag);
3210 return NOTIFICATION_ERROR_NONE;
3214 EXPORT_API int notification_get_tag(notification_h noti, const char **tag)
3216 /* Check noti is valid data */
3218 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3221 /* Set sound type */
3223 return NOTIFICATION_ERROR_NONE;
3226 EXPORT_API int notification_register_toast_message(void (*posted_toast_cb) (void *data))
3228 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
3229 return NOTIFICATION_ERROR_IO_ERROR;
3232 posted_toast_message_cb = posted_toast_cb;
3234 return NOTIFICATION_ERROR_NONE;
3237 void notification_call_posted_toast_cb(const char *message)
3239 if (posted_toast_message_cb != NULL) {
3240 posted_toast_message_cb((void*)message);
3244 EXPORT_API int notification_set_permission(notification_h handle, notification_permission_type_e permission_type, const char *app_id)
3246 return NOTIFICATION_ERROR_INVALID_OPERATION;
3249 EXPORT_API int notification_get_permission(notification_h handle, notification_permission_type_e *permission_type, const char **app_id)
3251 return NOTIFICATION_ERROR_INVALID_OPERATION;
3254 EXPORT_API int notification_set_ongoing_flag(notification_h noti, bool ongoing_flag)
3256 return NOTIFICATION_ERROR_INVALID_OPERATION;
3259 EXPORT_API int notification_get_ongoing_flag(notification_h noti, bool *ongoing_flag)
3261 return NOTIFICATION_ERROR_INVALID_OPERATION;