4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
28 #include <dbus/dbus.h>
29 #include <dbus/dbus-glib-lowlevel.h>
32 #include <app_control_internal.h>
37 #include <vconf-keys.h>
40 #include <notification.h>
41 #include <notification_list.h>
42 #include <notification_debug.h>
43 #include <notification_private.h>
44 #include <notification_noti.h>
45 #include <notification_ongoing.h>
46 #include <notification_group.h>
47 #include <notification_ipc.h>
48 #include <notification_internal.h>
50 typedef struct _notification_cb_list notification_cb_list_s;
52 typedef enum __notification_cb_type {
53 NOTIFICATION_CB_NORMAL = 1,
54 NOTIFICATION_CB_DETAILED,
55 } _notification_cb_type_e;
57 struct _notification_cb_list {
58 notification_cb_list_s *prev;
59 notification_cb_list_s *next;
61 _notification_cb_type_e cb_type;
62 void (*changed_cb) (void *data, notification_type_e type);
63 void (*detailed_changed_cb) (void *data, notification_type_e type, notification_op *op_list, int num_op);
67 static notification_cb_list_s *g_notification_cb_list = NULL;
69 static void (*posted_toast_message_cb) (void *data);
71 #define NOTI_TEXT_RESULT_LEN 2048
72 #define NOTI_PKGNAME_LEN 512
74 static char *_notification_get_pkgname_by_pid(void)
76 char pkgname[NOTI_PKGNAME_LEN + 1] = { 0, };
77 int pid = 0, ret = AUL_R_OK;
83 ret = aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname));
84 if (ret != AUL_R_OK) {
85 char buf[NOTI_PKGNAME_LEN + 1] = { 0, };
87 snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
89 fd = open(buf, O_RDONLY);
94 ret = read(fd, pkgname, sizeof(pkgname) - 1);
104 * "ret" is not able to be larger than "sizeof(pkgname) - 1",
105 * if the system is not going wrong.
108 if (strlen(pkgname) <= 0) {
113 dup_pkgname = strdup(pkgname);
115 NOTIFICATION_ERR("Heap: %s\n", strerror(errno));
120 static void _notification_get_text_domain(notification_h noti)
122 if (noti->domain != NULL) {
126 if (noti->dir != NULL) {
131 EXPORT_API int notification_set_image(notification_h noti,
132 notification_image_type_e type,
133 const char *image_path)
136 char buf_key[32] = { 0, };
137 const char *ret_val = NULL;
139 /* Check noti and image_path are valid data */
140 if (noti == NULL || image_path == NULL) {
141 return NOTIFICATION_ERROR_INVALID_PARAMETER;
144 /* Check image type is valid type */
145 if (type <= NOTIFICATION_IMAGE_TYPE_NONE
146 || type >= NOTIFICATION_IMAGE_TYPE_MAX) {
147 return NOTIFICATION_ERROR_INVALID_PARAMETER;
150 /* Check image path bundle is exist */
151 if (noti->b_image_path) {
152 /* If image path bundle is exist, store local bundle value */
153 b = noti->b_image_path;
155 /* Set image type to key as char string type */
156 snprintf(buf_key, sizeof(buf_key), "%d", type);
158 /* Get value using key */
159 ret_val = bundle_get_val(b, buf_key);
160 if (ret_val != NULL) {
161 /* If key is exist, remove this value to store new image path */
162 bundle_del(b, buf_key);
165 /* Add new image path with type key */
166 bundle_add(b, buf_key, image_path);
168 /* If image path bundle is not exist, create new one */
171 /* Set image type to key as char string type */
172 snprintf(buf_key, sizeof(buf_key), "%d", type);
174 /* Add new image path with type key */
175 bundle_add(b, buf_key, image_path);
177 /* Save to image path bundle */
178 noti->b_image_path = b;
181 return NOTIFICATION_ERROR_NONE;
184 EXPORT_API int notification_get_image(notification_h noti,
185 notification_image_type_e type,
189 char buf_key[32] = { 0, };
190 const char *ret_val = NULL;
192 /* Check noti and image_path is valid data */
193 if (noti == NULL || image_path == NULL) {
194 return NOTIFICATION_ERROR_INVALID_PARAMETER;
197 /* Check image type is valid data */
198 if (type <= NOTIFICATION_IMAGE_TYPE_NONE
199 || type >= NOTIFICATION_IMAGE_TYPE_MAX) {
200 return NOTIFICATION_ERROR_INVALID_PARAMETER;
203 /* Check image path bundle exist */
204 if (noti->b_image_path) {
205 /* If image path bundle exist, store local bundle data */
206 b = noti->b_image_path;
208 /* Set image type to key as char string type */
209 snprintf(buf_key, sizeof(buf_key), "%d", type);
211 /* Get value of key */
212 ret_val = bundle_get_val(b, buf_key);
214 *image_path = (char *)ret_val;
216 /* If image path bundle does not exist, image path is NULL */
220 /* If image path is NULL and type is ICON, icon path set from AIL */
221 /* order : user icon -> launch_pkgname icon -> caller_pkgname icon -> service app icon */
222 if (*image_path == NULL && type == NOTIFICATION_IMAGE_TYPE_ICON) {
223 /* Check App icon path is already set */
224 if (noti->app_icon_path != NULL) {
225 /* image path will be app icon path */
226 *image_path = noti->app_icon_path;
232 return NOTIFICATION_ERROR_NONE;
235 EXPORT_API int notification_set_time(notification_h noti,
238 /* Check noti is valid data */
240 return NOTIFICATION_ERROR_INVALID_PARAMETER;
243 if (input_time == 0) {
244 /* If input time is 0, set current time */
245 noti->time = time(NULL);
247 /* save input time */
248 noti->time = input_time;
251 return NOTIFICATION_ERROR_NONE;
254 EXPORT_API int notification_get_time(notification_h noti,
257 /* Check noti and time is valid data */
258 if (noti == NULL || ret_time == NULL) {
259 return NOTIFICATION_ERROR_INVALID_PARAMETER;
262 /* Set time infomation */
263 *ret_time = noti->time;
265 return NOTIFICATION_ERROR_NONE;
268 EXPORT_API int notification_get_insert_time(notification_h noti,
271 /* Check noti and ret_time is valid data */
272 if (noti == NULL || ret_time == NULL) {
273 return NOTIFICATION_ERROR_INVALID_PARAMETER;
276 /* Set insert time information */
277 *ret_time = noti->insert_time;
279 return NOTIFICATION_ERROR_NONE;
282 EXPORT_API int notification_set_text(notification_h noti,
283 notification_text_type_e type,
289 char buf_key[32] = { 0, };
290 char buf_val[1024] = { 0, };
291 const char *ret_val = NULL;
293 notification_variable_type_e var_type;
295 int noti_err = NOTIFICATION_ERROR_NONE;
296 int var_value_int = 0;
297 double var_value_double = 0.0;
298 char *var_value_string = NULL;
299 notification_count_pos_type_e var_value_count =
300 NOTIFICATION_COUNT_POS_NONE;
302 /* Check noti is valid data */
304 return NOTIFICATION_ERROR_INVALID_PARAMETER;
307 /* Check text type is valid type */
308 if (type <= NOTIFICATION_TEXT_TYPE_NONE
309 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
310 return NOTIFICATION_ERROR_INVALID_PARAMETER;
313 /* Check text bundle exist */
315 if (noti->b_text != NULL) {
316 /* If text bundle exist, store local bundle data */
319 /* Make type to key as char string */
320 snprintf(buf_key, sizeof(buf_key), "%d", type);
322 /* Get value using type key */
323 ret_val = bundle_get_val(b, buf_key);
324 if (ret_val != NULL) {
325 /* If value exist, remove this to add new value */
326 bundle_del(b, buf_key);
329 snprintf(buf_val, sizeof(buf_val), "%s", text);
331 /* Add new text value */
332 bundle_add(b, buf_key, buf_val);
334 /* If text bundle does not exist, create new one */
337 /* Make type to key as char string */
338 snprintf(buf_key, sizeof(buf_key), "%d", type);
340 snprintf(buf_val, sizeof(buf_val), "%s", text);
342 /* Add new text value */
343 bundle_add(b, buf_key, buf_val);
345 /* Save text bundle */
349 /* Reset if text is NULL */
350 if (noti->b_text != NULL) {
351 /* If text bundle exist, store local bundle data */
354 /* Make type to key as char string */
355 snprintf(buf_key, sizeof(buf_key), "%d", type);
357 /* Get value using type key */
358 ret_val = bundle_get_val(b, buf_key);
359 if (ret_val != NULL) {
360 /* If value exist, remove this */
361 bundle_del(b, buf_key);
366 /* Save key if key is valid data */
368 /* Check key bundle exist */
369 if (noti->b_key != NULL) {
370 /* If key bundle exist, store local bundle data */
373 /* Make type to key as char string */
374 snprintf(buf_key, sizeof(buf_key), "%d", type);
376 /* Get value using type key */
377 ret_val = bundle_get_val(b, buf_key);
378 if (ret_val != NULL) {
379 /* If value exist, remove this to add new value */
380 bundle_del(b, buf_key);
383 snprintf(buf_val, sizeof(buf_val), "%s", key);
385 /* Add new key value */
386 bundle_add(b, buf_key, buf_val);
388 /* If key bundle does not exist, create new one */
391 /* Make type to key as char string */
392 snprintf(buf_key, sizeof(buf_key), "%d", type);
394 snprintf(buf_val, sizeof(buf_val), "%s", key);
396 /* Add new key value */
397 bundle_add(b, buf_key, buf_val);
399 /* Save key bundle */
403 /* Reset if key is NULL */
404 if (noti->b_key != NULL) {
405 /* If key bundle exist, store local bundle data */
408 /* Make type to key as char string */
409 snprintf(buf_key, sizeof(buf_key), "%d", type);
411 /* Get value using type key */
412 ret_val = bundle_get_val(b, buf_key);
413 if (ret_val != NULL) {
414 /* If value exist, remove this */
415 bundle_del(b, buf_key);
420 if (noti->b_format_args != NULL) {
421 b = noti->b_format_args;
426 va_start(var_args, args_type);
428 var_type = args_type;
431 while (var_type != NOTIFICATION_VARIABLE_TYPE_NONE) {
433 snprintf(buf_key, sizeof(buf_key), "%dtype%d", type, num_args);
434 snprintf(buf_val, sizeof(buf_val), "%d", var_type);
436 ret_val = bundle_get_val(b, buf_key);
437 if (ret_val != NULL) {
438 bundle_del(b, buf_key);
441 bundle_add(b, buf_key, buf_val);
444 case NOTIFICATION_VARIABLE_TYPE_INT:
445 var_value_int = va_arg(var_args, int);
448 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
450 snprintf(buf_val, sizeof(buf_val), "%d", var_value_int);
452 ret_val = bundle_get_val(b, buf_key);
453 if (ret_val != NULL) {
454 bundle_del(b, buf_key);
457 bundle_add(b, buf_key, buf_val);
459 case NOTIFICATION_VARIABLE_TYPE_DOUBLE:
460 var_value_double = va_arg(var_args, double);
463 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
465 snprintf(buf_val, sizeof(buf_val), "%.2f",
468 ret_val = bundle_get_val(b, buf_key);
469 if (ret_val != NULL) {
470 bundle_del(b, buf_key);
473 bundle_add(b, buf_key, buf_val);
475 case NOTIFICATION_VARIABLE_TYPE_STRING:
476 var_value_string = va_arg(var_args, char *);
479 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
481 snprintf(buf_val, sizeof(buf_val), "%s",
484 ret_val = bundle_get_val(b, buf_key);
485 if (ret_val != NULL) {
486 bundle_del(b, buf_key);
489 bundle_add(b, buf_key, buf_val);
491 case NOTIFICATION_VARIABLE_TYPE_COUNT:
493 va_arg(var_args, notification_count_pos_type_e);
496 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
498 snprintf(buf_val, sizeof(buf_val), "%d",
501 ret_val = bundle_get_val(b, buf_key);
502 if (ret_val != NULL) {
503 bundle_del(b, buf_key);
506 bundle_add(b, buf_key, buf_val);
509 NOTIFICATION_ERR("Error. invalid variable type. : %d",
511 noti_err = NOTIFICATION_ERROR_INVALID_PARAMETER;
516 var_type = va_arg(var_args, notification_variable_type_e);
520 if (noti_err == NOTIFICATION_ERROR_NONE) {
521 noti->num_format_args = num_args;
523 noti->num_format_args = 0;
526 snprintf(buf_key, sizeof(buf_key), "num%d", type);
527 snprintf(buf_val, sizeof(buf_val), "%d", noti->num_format_args);
529 ret_val = bundle_get_val(b, buf_key);
530 if (ret_val != NULL) {
531 bundle_del(b, buf_key);
534 bundle_add(b, buf_key, buf_val);
536 noti->b_format_args = b;
541 EXPORT_API int notification_get_text(notification_h noti,
542 notification_text_type_e type,
546 char buf_key[32] = { 0, };
547 const char *ret_val = NULL;
548 const char *get_str = NULL;
549 const char *get_check_type_str = NULL;
550 notification_text_type_e check_type = NOTIFICATION_TEXT_TYPE_NONE;
551 //int display_option_flag = 0;
553 char *temp_str = NULL;
554 char result_str[NOTI_TEXT_RESULT_LEN] = { 0, };
555 char buf_str[1024] = { 0, };
557 notification_variable_type_e ret_var_type = 0;
558 int ret_variable_int = 0;
559 double ret_variable_double = 0.0;
561 /* Check noti is valid data */
562 if (noti == NULL || text == NULL) {
563 return NOTIFICATION_ERROR_INVALID_PARAMETER;
566 /* Check text type is valid type */
567 if (type <= NOTIFICATION_TEXT_TYPE_NONE
568 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
569 return NOTIFICATION_ERROR_INVALID_PARAMETER;
573 if (noti->b_key != NULL) {
576 /* Get text domain and dir */
577 //_notification_get_text_domain(noti);
579 snprintf(buf_key, sizeof(buf_key), "%d", type);
581 ret_val = bundle_get_val(b, buf_key);
582 if (ret_val != NULL && noti->domain != NULL
583 && noti->dir != NULL) {
584 /* Get application string */
585 bindtextdomain(noti->domain, noti->dir);
587 get_str = dgettext(noti->domain, ret_val);
588 } else if (ret_val != NULL) {
589 /* Get system string */
590 get_str = dgettext("sys_string", ret_val);
596 if (get_str == NULL && noti->b_text != NULL) {
599 snprintf(buf_key, sizeof(buf_key), "%d", type);
601 get_str = bundle_get_val(b, buf_key);
606 /* Set display option is off type when option is off, type is noti */
607 /*if (get_str != NULL && display_option_flag == 1
608 && noti->type == NOTIFICATION_TYPE_NOTI) {
609 if (type == NOTIFICATION_TEXT_TYPE_CONTENT
610 || type == NOTIFICATION_TEXT_TYPE_GROUP_CONTENT) {
611 // Set check_type to option content string
612 if (type == NOTIFICATION_TEXT_TYPE_CONTENT) {
614 NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF;
615 } else if (type == NOTIFICATION_TEXT_TYPE_GROUP_CONTENT) {
617 NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF;
621 if (noti->b_key != NULL) {
624 // Get text domain and dir
625 _notification_get_text_domain(noti);
627 snprintf(buf_key, sizeof(buf_key), "%d",
630 ret_val = bundle_get_val(b, buf_key);
631 if (ret_val != NULL && noti->domain != NULL
632 && noti->dir != NULL) {
633 // Get application string
634 bindtextdomain(noti->domain, noti->dir);
637 dgettext(noti->domain, ret_val);
638 } else if (ret_val != NULL) {
641 dgettext("sys_string", ret_val);
643 get_check_type_str = NULL;
647 if (get_check_type_str == NULL && noti->b_text != NULL) {
650 snprintf(buf_key, sizeof(buf_key), "%d",
653 get_check_type_str = bundle_get_val(b, buf_key);
657 if (get_check_type_str != NULL) {
658 // Replace option off type string
659 get_str = get_check_type_str;
661 // Set default string
663 dgettext("sys_string", "IDS_COM_POP_MISSED_EVENT");
667 if (get_str != NULL) {
668 /* Get number format args */
669 b = noti->b_format_args;
670 noti->num_format_args = 0;
673 snprintf(buf_key, sizeof(buf_key), "num%d", check_type);
674 ret_val = bundle_get_val(b, buf_key);
675 if (ret_val != NULL) {
676 noti->num_format_args = atoi(ret_val);
680 if (noti->num_format_args == 0) {
681 *text = (char *)get_str;
683 /* Check first variable is count, LEFT pos */
684 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
685 check_type, num_args);
686 ret_val = bundle_get_val(b, buf_key);
687 ret_var_type = atoi(ret_val);
689 if (ret_var_type == NOTIFICATION_VARIABLE_TYPE_COUNT) {
691 snprintf(buf_key, sizeof(buf_key), "%dvalue%d",
692 check_type, num_args);
693 ret_val = bundle_get_val(b, buf_key);
694 ret_variable_int = atoi(ret_val);
696 if (ret_variable_int ==
697 NOTIFICATION_COUNT_POS_LEFT) {
698 notification_noti_get_count(noti->type,
699 noti->caller_pkgname,
703 snprintf(buf_str, sizeof(buf_str),
704 "%d ", ret_variable_int);
706 int src_len = strlen(result_str);
707 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
709 strncat(result_str, buf_str,
717 /* Check variable IN pos */
718 for (temp_str = (char *)get_str; *temp_str != '\0';
720 if (*temp_str != '%') {
721 strncat(result_str, temp_str, 1);
723 if (*(temp_str + 1) == '%') {
724 strncat(result_str, temp_str,
726 } else if (*(temp_str + 1) == 'd') {
728 ret_variable_int = 0;
732 "%dtype%d", check_type,
735 bundle_get_val(b, buf_key);
736 ret_var_type = atoi(ret_val);
738 NOTIFICATION_VARIABLE_TYPE_COUNT)
740 /* Get notification count */
741 notification_noti_get_count
743 noti->caller_pkgname,
763 sizeof(buf_str), "%d",
766 int src_len = strlen(result_str);
767 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
769 strncat(result_str, buf_str,
775 } else if (*(temp_str + 1) == 's') {
780 check_type, num_args);
782 bundle_get_val(b, buf_key);
785 sizeof(buf_str), "%s",
788 int src_len = strlen(result_str);
789 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
791 strncat(result_str, buf_str,
797 } else if (*(temp_str + 1) == 'f') {
802 check_type, num_args);
804 bundle_get_val(b, buf_key);
805 ret_variable_double =
811 ret_variable_double);
813 int src_len = strlen(result_str);
814 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
816 strncat(result_str, buf_str,
827 /* Check last variable is count, LEFT pos */
828 if (num_args < noti->num_format_args) {
829 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
830 check_type, num_args);
831 ret_val = bundle_get_val(b, buf_key);
832 ret_var_type = atoi(ret_val);
834 NOTIFICATION_VARIABLE_TYPE_COUNT) {
836 snprintf(buf_key, sizeof(buf_key),
837 "%dvalue%d", check_type,
839 ret_val = bundle_get_val(b, buf_key);
840 ret_variable_int = atoi(ret_val);
842 if (ret_variable_int ==
843 NOTIFICATION_COUNT_POS_RIGHT) {
844 notification_noti_get_count
846 noti->caller_pkgname,
851 sizeof(buf_str), " %d",
854 int src_len = strlen(result_str);
855 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
857 strncat(result_str, buf_str,
866 switch (check_type) {
867 case NOTIFICATION_TEXT_TYPE_TITLE:
868 case NOTIFICATION_TEXT_TYPE_GROUP_TITLE:
869 if (noti->temp_title != NULL)
870 free(noti->temp_title);
872 noti->temp_title = strdup(result_str);
874 *text = noti->temp_title;
876 case NOTIFICATION_TEXT_TYPE_CONTENT:
877 case NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
878 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT:
879 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
880 if (noti->temp_content !=
882 free(noti->temp_content);
884 noti->temp_content = strdup(result_str);
886 *text = noti->temp_content;
898 return NOTIFICATION_ERROR_NONE;
901 EXPORT_API int notification_set_text_domain(notification_h noti,
905 /* check noti and domain is valid data */
906 if (noti == NULL || domain == NULL || dir == NULL) {
907 return NOTIFICATION_ERROR_INVALID_PARAMETER;
912 /* Remove previous domain */
916 noti->domain = strdup(domain);
918 /* Check locale dir */
920 /* Remove previous locale dir */
923 /* Copy locale dir */
924 noti->dir = strdup(dir);
926 return NOTIFICATION_ERROR_NONE;
929 EXPORT_API int notification_get_text_domain(notification_h noti,
933 /* Check noti is valid data */
935 return NOTIFICATION_ERROR_INVALID_PARAMETER;
939 if (domain != NULL && noti->domain != NULL) {
940 *domain = noti->domain;
944 if (dir != NULL && noti->dir != NULL) {
948 return NOTIFICATION_ERROR_NONE;
951 EXPORT_API int notification_set_time_to_text(notification_h noti, notification_text_type_e type,
954 int ret = NOTIFICATION_ERROR_NONE;
955 char buf[256] = { 0, };
956 char buf_tag[512] = { 0, };
959 return NOTIFICATION_ERROR_INVALID_PARAMETER;
962 return NOTIFICATION_ERROR_INVALID_PARAMETER;
964 if (type <= NOTIFICATION_TEXT_TYPE_NONE
965 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
966 return NOTIFICATION_ERROR_INVALID_PARAMETER;
970 snprintf(buf, sizeof(buf), "%lu", time);
971 ret = notification_noti_set_tag(TAG_TIME, buf, buf_tag, sizeof(buf_tag));
973 if (ret != NOTIFICATION_ERROR_NONE) {
977 return notification_set_text(noti, type, buf_tag, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
980 EXPORT_API int notification_get_time_from_text(notification_h noti, notification_text_type_e type,
983 int ret = NOTIFICATION_ERROR_NONE;
986 return NOTIFICATION_ERROR_INVALID_PARAMETER;
989 return NOTIFICATION_ERROR_INVALID_PARAMETER;
991 if (type <= NOTIFICATION_TEXT_TYPE_NONE
992 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
993 return NOTIFICATION_ERROR_INVALID_PARAMETER;
996 char *ret_text = NULL;
997 ret = notification_get_text(noti, type, &ret_text);
999 if (ret != NOTIFICATION_ERROR_NONE || ret_text == NULL) {
1000 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1003 if (notification_noti_get_tag_type(ret_text) == TAG_TYPE_INVALID) {
1004 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1007 char *tag_value = NULL;
1008 tag_value = notification_noti_strip_tag(ret_text);
1009 if (tag_value == NULL) {
1010 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1013 *time = atol(tag_value);
1016 return NOTIFICATION_ERROR_NONE;
1019 EXPORT_API int notification_set_sound(notification_h noti,
1020 notification_sound_type_e type,
1023 /* Check noti is valid data */
1025 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1028 /* Check type is valid */
1029 if (type < NOTIFICATION_SOUND_TYPE_NONE
1030 || type >= NOTIFICATION_SOUND_TYPE_MAX) {
1031 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1034 /* Save sound type */
1035 noti->sound_type = type;
1037 /* Save sound path if user data type */
1038 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA && path != NULL) {
1039 if (noti->sound_path != NULL) {
1040 free(noti->sound_path);
1043 noti->sound_path = strdup(path);
1045 if (noti->sound_path != NULL) {
1046 free(noti->sound_path);
1047 noti->sound_path = NULL;
1049 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA) {
1050 noti->sound_type = NOTIFICATION_SOUND_TYPE_DEFAULT;
1051 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1055 return NOTIFICATION_ERROR_NONE;
1058 EXPORT_API int notification_get_sound(notification_h noti,
1059 notification_sound_type_e *type,
1062 /* check noti and type is valid data */
1063 if (noti == NULL || type == NULL) {
1064 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1067 /* Set sound type */
1068 *type = noti->sound_type;
1070 /* Set sound path if user data type */
1071 if (noti->sound_type == NOTIFICATION_SOUND_TYPE_USER_DATA
1073 *path = noti->sound_path;
1076 return NOTIFICATION_ERROR_NONE;
1079 EXPORT_API int notification_set_vibration(notification_h noti,
1080 notification_vibration_type_e type,
1083 /* Check noti is valid data */
1085 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1088 /* Check type is valid */
1089 if (type < NOTIFICATION_VIBRATION_TYPE_NONE
1090 || type >= NOTIFICATION_VIBRATION_TYPE_MAX) {
1091 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1094 /* Save vibration type */
1095 noti->vibration_type = type;
1097 /* Save sound path if user data type */
1098 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA && path != NULL) {
1099 if (noti->vibration_path != NULL) {
1100 free(noti->vibration_path);
1103 noti->vibration_path = strdup(path);
1105 if (noti->vibration_path != NULL) {
1106 free(noti->vibration_path);
1107 noti->vibration_path = NULL;
1109 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA) {
1110 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
1111 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1115 return NOTIFICATION_ERROR_NONE;
1119 EXPORT_API int notification_get_vibration(notification_h noti,
1120 notification_vibration_type_e *type,
1123 /* check noti and type is valid data */
1124 if (noti == NULL || type == NULL) {
1125 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1128 /* Set vibration type */
1129 *type = noti->vibration_type;
1131 /* Set sound path if user data type */
1132 if (noti->vibration_type == NOTIFICATION_VIBRATION_TYPE_USER_DATA
1134 *path = noti->vibration_path;
1137 return NOTIFICATION_ERROR_NONE;
1140 EXPORT_API int notification_set_led(notification_h noti,
1141 notification_led_op_e operation,
1144 /* Check noti is valid data */
1146 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1149 /* Check operation is valid */
1150 if (operation < NOTIFICATION_LED_OP_OFF
1151 || operation >= NOTIFICATION_LED_OP_MAX) {
1152 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1155 /* Save led operation */
1156 noti->led_operation = operation;
1158 /* Save led argb if operation is turning on LED with custom color */
1159 if (operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR) {
1160 noti->led_argb = led_argb;
1163 return NOTIFICATION_ERROR_NONE;
1166 EXPORT_API int notification_get_led(notification_h noti,
1167 notification_led_op_e *operation,
1170 /* check noti and operation is valid data */
1171 if (noti == NULL || operation == NULL) {
1172 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1175 /* Set led operation */
1176 *operation = noti->led_operation;
1178 /* Save led argb if operation is turning on LED with custom color */
1179 if (noti->led_operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR
1180 && led_argb != NULL) {
1181 *led_argb = noti->led_argb;
1184 return NOTIFICATION_ERROR_NONE;
1187 EXPORT_API int notification_set_led_time_period(notification_h noti,
1188 int on_ms, int off_ms)
1190 /* Check noti is valid data */
1191 if (noti == NULL || on_ms < 0 || off_ms < 0) {
1192 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1195 /* Save led operation */
1196 noti->led_on_ms = on_ms;
1197 noti->led_off_ms = off_ms;
1199 return NOTIFICATION_ERROR_NONE;
1202 EXPORT_API int notification_get_led_time_period(notification_h noti,
1203 int *on_ms, int *off_ms)
1205 /* check noti and operation is valid data */
1207 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1211 *(on_ms) = noti->led_on_ms;
1213 *(off_ms) = noti->led_off_ms;
1215 return NOTIFICATION_ERROR_NONE;
1218 EXPORT_API int notification_set_application(notification_h noti,
1219 const char *pkgname)
1221 if (noti == NULL || pkgname == NULL) {
1222 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1225 if (noti->launch_pkgname) {
1226 free(noti->launch_pkgname);
1229 noti->launch_pkgname = strdup(pkgname);
1231 return NOTIFICATION_ERROR_NONE;
1234 EXPORT_API int notification_get_application(notification_h noti,
1237 if (noti == NULL || pkgname == NULL) {
1238 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1241 if (noti->launch_pkgname) {
1242 *pkgname = noti->launch_pkgname;
1244 *pkgname = noti->caller_pkgname;
1247 return NOTIFICATION_ERROR_NONE;
1250 EXPORT_API int notification_set_launch_option(notification_h noti,
1251 notification_launch_option_type type, void *option)
1255 app_control_h app_control = option;
1258 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1260 if (app_control == NULL) {
1261 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1263 if (type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL) {
1264 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1267 if ((ret = app_control_to_bundle(app_control, &b)) == APP_CONTROL_ERROR_NONE) {
1268 return notification_set_execute_option(noti,
1269 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
1273 NOTIFICATION_ERR("Failed to convert appcontrol to bundle:%d", ret);
1274 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1278 EXPORT_API int notification_get_launch_option(notification_h noti,
1279 notification_launch_option_type type, void *option)
1283 app_control_h *app_control = (app_control_h *)option;
1284 app_control_h app_control_new = NULL;
1287 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1289 if (app_control == NULL) {
1290 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1292 if (type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL) {
1293 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1296 ret = notification_get_execute_option(noti,
1297 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
1300 if (ret == NOTIFICATION_ERROR_NONE && b != NULL) {
1301 ret = app_control_create(&app_control_new);
1302 if (ret == APP_CONTROL_ERROR_NONE && app_control_new != NULL) {
1303 ret = app_control_import_from_bundle(app_control_new, b);
1304 if (ret == APP_CONTROL_ERROR_NONE) {
1305 *app_control = app_control_new;
1307 app_control_destroy(app_control_new);
1308 NOTIFICATION_ERR("Failed to import app control from bundle:%d", ret);
1309 return NOTIFICATION_ERROR_IO_ERROR;
1312 NOTIFICATION_ERR("Failed to create app control:%d", ret);
1313 return NOTIFICATION_ERROR_IO_ERROR;
1316 NOTIFICATION_ERR("Failed to get execute option:%d", ret);
1320 return NOTIFICATION_ERROR_NONE;
1323 EXPORT_API int notification_set_execute_option(notification_h noti,
1324 notification_execute_type_e type,
1327 bundle *service_handle)
1329 char buf_key[32] = { 0, };
1330 const char *ret_val = NULL;
1334 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1337 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1338 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1339 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1342 /* Create execute option bundle if does not exist */
1343 if (noti->b_execute_option == NULL) {
1344 noti->b_execute_option = bundle_create();
1347 b = noti->b_execute_option;
1352 snprintf(buf_key, sizeof(buf_key), "text%d", type);
1354 /* Check text key exist */
1355 ret_val = bundle_get_val(b, buf_key);
1356 if (ret_val != NULL) {
1357 /* Remove previous data */
1358 bundle_del(b, buf_key);
1362 bundle_add(b, buf_key, text);
1368 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1370 /* Check key key exist */
1371 ret_val = bundle_get_val(b, buf_key);
1372 if (ret_val != NULL) {
1373 /* Remove previous data */
1374 bundle_del(b, buf_key);
1378 bundle_add(b, buf_key, key);
1381 switch ((int)type) {
1382 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1383 /* Remove previous data if exist */
1384 if (noti->b_service_responding != NULL) {
1385 bundle_free(noti->b_service_responding);
1386 noti->b_service_responding = NULL;
1389 /* Save service handle */
1390 if (service_handle != NULL) {
1391 noti->b_service_responding = bundle_dup(service_handle);
1394 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1395 /* Remove previous data if exist */
1396 if (noti->b_service_single_launch != NULL) {
1397 bundle_free(noti->b_service_single_launch);
1398 noti->b_service_single_launch = NULL;
1401 /* Save service handle */
1402 if (service_handle != NULL) {
1403 noti->b_service_single_launch =
1404 bundle_dup(service_handle);
1407 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1408 /* Remove previous data if exist */
1409 if (noti->b_service_multi_launch != NULL) {
1410 bundle_free(noti->b_service_multi_launch);
1411 noti->b_service_multi_launch = NULL;
1414 /* Save service handle */
1415 if (service_handle != NULL) {
1416 noti->b_service_multi_launch =
1417 bundle_dup(service_handle);
1422 return NOTIFICATION_ERROR_NONE;
1425 EXPORT_API int notification_get_execute_option(notification_h noti,
1426 notification_execute_type_e type,
1428 bundle **service_handle)
1430 char buf_key[32] = { 0, };
1431 const char *ret_val = NULL;
1432 char *get_str = NULL;
1436 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1439 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1440 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1441 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1445 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1446 b = noti->b_service_responding;
1448 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1449 b = noti->b_service_single_launch;
1451 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1452 b = noti->b_service_multi_launch;
1460 // Get text domain and dir
1461 if (noti->domain == NULL || noti->dir == NULL) {
1462 _notification_get_text_domain(noti);
1466 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1468 /* Check key key exist */
1469 ret_val = bundle_get_val(b, buf_key);
1470 if (ret_val != NULL && noti->domain != NULL
1471 && noti->dir != NULL) {
1472 /* Get application string */
1473 bindtextdomain(noti->domain, noti->dir);
1475 get_str = dgettext(noti->domain, ret_val);
1478 } else if (ret_val != NULL) {
1479 /* Get system string */
1480 get_str = dgettext("sys_string", ret_val);
1484 /* Get basic text */
1485 snprintf(buf_key, sizeof(buf_key), "text%d",
1488 ret_val = bundle_get_val(b, buf_key);
1495 if (service_handle != NULL) {
1496 *service_handle = b;
1499 return NOTIFICATION_ERROR_NONE;
1502 EXPORT_API int notification_set_property(notification_h noti,
1505 /* Check noti is valid data */
1507 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1511 noti->flags_for_property = flags;
1513 return NOTIFICATION_ERROR_NONE;
1516 EXPORT_API int notification_get_property(notification_h noti,
1519 /* Check noti and flags are valid data */
1520 if (noti == NULL || flags == NULL) {
1521 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1525 *flags = noti->flags_for_property;
1527 return NOTIFICATION_ERROR_NONE;
1530 EXPORT_API int notification_set_display_applist(notification_h noti,
1533 /* Check noti is valid data */
1535 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1539 noti->display_applist = applist;
1541 return NOTIFICATION_ERROR_NONE;
1544 EXPORT_API int notification_get_display_applist(notification_h noti,
1547 /* Check noti and applist are valid data */
1548 if (noti == NULL || applist == NULL) {
1549 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1553 *applist = noti->display_applist;
1555 return NOTIFICATION_ERROR_NONE;
1558 EXPORT_API int notification_set_size(notification_h noti,
1561 /* Check noti is valid data */
1563 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1566 /* Save progress size */
1567 noti->progress_size = size;
1569 return NOTIFICATION_ERROR_NONE;
1572 EXPORT_API int notification_get_size(notification_h noti,
1575 /* Check noti and size is valid data */
1576 if (noti == NULL || size == NULL) {
1577 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1580 /* Set progress size */
1581 *size = noti->progress_size;
1583 return NOTIFICATION_ERROR_NONE;
1586 EXPORT_API int notification_set_progress(notification_h noti,
1589 /* Check noti is valid data */
1591 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1594 /* Save progress percentage */
1595 noti->progress_percentage = percentage;
1597 return NOTIFICATION_ERROR_NONE;
1600 EXPORT_API int notification_get_progress(notification_h noti,
1603 /* Check noti and percentage are valid data */
1604 if (noti == NULL || percentage == NULL) {
1605 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1608 /* Set progress percentage */
1609 *percentage = noti->progress_percentage;
1611 return NOTIFICATION_ERROR_NONE;
1614 EXPORT_API int notification_set_pkgname(notification_h noti,
1615 const char *pkgname)
1617 /* check noti and pkgname are valid data */
1618 if (noti == NULL || pkgname == NULL) {
1619 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1622 /* Remove previous caller pkgname */
1623 if (noti->caller_pkgname) {
1624 free(noti->caller_pkgname);
1625 noti->caller_pkgname = NULL;
1628 noti->caller_pkgname = strdup(pkgname);
1630 return NOTIFICATION_ERROR_NONE;
1633 EXPORT_API int notification_get_pkgname(notification_h noti,
1636 /* Check noti and pkgname are valid data */
1637 if (noti == NULL || pkgname == NULL) {
1638 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1641 /* Get caller pkgname */
1642 if (noti->caller_pkgname) {
1643 *pkgname = noti->caller_pkgname;
1648 return NOTIFICATION_ERROR_NONE;
1651 EXPORT_API int notification_set_layout(notification_h noti,
1652 notification_ly_type_e layout)
1654 /* check noti and pkgname are valid data */
1655 if (noti == NULL || (layout < NOTIFICATION_LY_NONE || layout >= NOTIFICATION_LY_MAX)) {
1656 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1659 noti->layout = layout;
1661 return NOTIFICATION_ERROR_NONE;
1664 EXPORT_API int notification_get_layout(notification_h noti,
1665 notification_ly_type_e *layout)
1667 /* Check noti and pkgname are valid data */
1668 if (noti == NULL || layout == NULL) {
1669 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1672 *layout = noti->layout;
1674 return NOTIFICATION_ERROR_NONE;
1677 EXPORT_API int notification_get_id(notification_h noti,
1678 int *group_id, int *priv_id)
1680 /* check noti is valid data */
1682 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1685 /* Check group_id is valid data */
1688 if (noti->group_id < NOTIFICATION_GROUP_ID_NONE) {
1689 *group_id = NOTIFICATION_GROUP_ID_NONE;
1691 *group_id = noti->group_id;
1695 /* Check priv_id is valid data */
1698 *priv_id = noti->priv_id;
1701 return NOTIFICATION_ERROR_NONE;
1704 EXPORT_API int notification_get_type(notification_h noti,
1705 notification_type_e *type)
1707 /* Check noti and type is valid data */
1708 if (noti == NULL || type == NULL) {
1709 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1715 return NOTIFICATION_ERROR_NONE;
1718 EXPORT_API int notification_post(notification_h noti)
1723 /* Check noti is vaild data */
1725 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1728 /* Check noti type is valid type */
1729 if (noti->type <= NOTIFICATION_TYPE_NONE
1730 || noti->type >= NOTIFICATION_TYPE_MAX) {
1731 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1734 /* Save insert time */
1735 noti->insert_time = time(NULL);
1737 ret = notification_ipc_request_insert(noti, &id);
1738 if (ret != NOTIFICATION_ERROR_NONE) {
1742 NOTIFICATION_DBG("from master:%d", id);
1744 return NOTIFICATION_ERROR_NONE;
1747 EXPORT_API int notification_insert(notification_h noti,
1753 /* Check noti is vaild data */
1755 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1758 /* Check noti type is valid type */
1759 if (noti->type <= NOTIFICATION_TYPE_NONE
1760 || noti->type >= NOTIFICATION_TYPE_MAX) {
1761 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1764 /* Save insert time */
1765 noti->insert_time = time(NULL);
1766 ret = notification_ipc_request_insert(noti, &id);
1767 if (ret != NOTIFICATION_ERROR_NONE) {
1771 NOTIFICATION_DBG("from master:%d", id);
1773 /* If priv_id is valid data, set priv_id */
1774 if (priv_id != NULL) {
1775 *priv_id = noti->priv_id;
1778 return NOTIFICATION_ERROR_NONE;
1781 EXPORT_API int notification_update(notification_h noti)
1785 /* Check noti is valid data */
1787 /* Update insert time ? */
1788 noti->insert_time = time(NULL);
1789 ret = notification_ipc_request_update(noti);
1791 notification_ipc_request_refresh();
1792 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1797 EXPORT_API int notification_update_async(notification_h noti,
1798 void (*result_cb)(int priv_id, int result, void *data), void *user_data)
1803 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1806 /* Update insert time ? */
1807 noti->insert_time = time(NULL);
1808 ret = notification_ipc_request_update_async(noti, result_cb, user_data);
1813 EXPORT_API int notifiation_clear(notification_type_e type)
1817 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1818 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1821 ret = notification_ipc_request_delete_multiple(type, NULL);
1826 EXPORT_API int notification_clear(notification_type_e type)
1830 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1831 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1834 ret = notification_ipc_request_delete_multiple(type, NULL);
1839 EXPORT_API int notification_delete_all(notification_type_e type)
1842 char *caller_pkgname = _notification_get_pkgname_by_pid();
1844 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1845 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1848 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
1850 if (caller_pkgname) {
1851 free(caller_pkgname);
1857 EXPORT_API int notification_delete_all_by_type(const char *pkgname,
1858 notification_type_e type)
1861 char *caller_pkgname = NULL;
1863 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1864 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1867 if (pkgname == NULL) {
1868 caller_pkgname = _notification_get_pkgname_by_pid();
1870 caller_pkgname = strdup(pkgname);
1873 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
1875 if (caller_pkgname) {
1876 free(caller_pkgname);
1882 EXPORT_API int notification_delete_by_priv_id(const char *pkgname,
1883 notification_type_e type,
1887 char *caller_pkgname = NULL;
1889 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
1890 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1893 if (pkgname == NULL) {
1894 caller_pkgname = _notification_get_pkgname_by_pid();
1896 caller_pkgname = strdup(pkgname);
1899 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
1901 if (caller_pkgname) {
1902 free(caller_pkgname);
1908 EXPORT_API int notification_delete(notification_h noti)
1913 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1916 ret = notification_ipc_request_delete_single(NOTIFICATION_TYPE_NONE, noti->caller_pkgname, noti->priv_id);
1921 EXPORT_API int notification_update_progress(notification_h noti,
1925 char *caller_pkgname = NULL;
1926 int input_priv_id = 0;
1928 double input_progress = 0.0;
1930 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
1932 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1934 input_priv_id = noti->priv_id;
1937 input_priv_id = priv_id;
1941 caller_pkgname = _notification_get_pkgname_by_pid();
1943 caller_pkgname = strdup(noti->caller_pkgname);
1946 if (progress < 0.0) {
1947 input_progress = 0.0;
1948 } else if (progress > 1.0) {
1949 input_progress = 1.0;
1951 input_progress = progress;
1954 ret = notification_ongoing_update_progress(caller_pkgname, input_priv_id,
1957 if (caller_pkgname) {
1958 free(caller_pkgname);
1964 EXPORT_API int notification_update_size(notification_h noti,
1968 char *caller_pkgname = NULL;
1969 int input_priv_id = 0;
1971 double input_size = 0.0;
1973 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
1975 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1977 input_priv_id = noti->priv_id;
1980 input_priv_id = priv_id;
1984 caller_pkgname = _notification_get_pkgname_by_pid();
1986 caller_pkgname = strdup(noti->caller_pkgname);
1995 ret = notification_ongoing_update_size(caller_pkgname, input_priv_id,
1998 if (caller_pkgname) {
1999 free(caller_pkgname);
2005 EXPORT_API int notification_update_content(notification_h noti,
2007 const char *content)
2009 char *caller_pkgname = NULL;
2010 int input_priv_id = 0;
2013 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2015 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2017 input_priv_id = noti->priv_id;
2020 input_priv_id = priv_id;
2024 caller_pkgname = _notification_get_pkgname_by_pid();
2026 caller_pkgname = strdup(noti->caller_pkgname);
2029 ret = notification_ongoing_update_content(caller_pkgname, input_priv_id,
2032 if (caller_pkgname) {
2033 free(caller_pkgname);
2039 static notification_h _notification_create(notification_type_e type)
2041 notification_h noti = NULL;
2043 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
2044 NOTIFICATION_ERR("INVALID TYPE : %d", type);
2045 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
2049 noti = (notification_h) calloc(1, sizeof(struct _notification));
2051 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2052 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2058 if (type == NOTIFICATION_TYPE_NOTI)
2059 noti->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2060 else if (type == NOTIFICATION_TYPE_ONGOING)
2061 noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
2063 noti->caller_pkgname = _notification_get_pkgname_by_pid();
2064 noti->group_id = NOTIFICATION_GROUP_ID_NONE;
2065 noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
2066 noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
2067 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
2068 noti->led_operation = NOTIFICATION_LED_OP_OFF;
2069 noti->display_applist = NOTIFICATION_DISPLAY_APP_ALL;
2072 * Other fields are already initialized with ZERO.
2074 set_last_result(NOTIFICATION_ERROR_NONE);
2078 EXPORT_API notification_h notification_new(notification_type_e type,
2079 int group_id, int priv_id)
2081 return _notification_create(type);
2084 EXPORT_API notification_h notification_create(notification_type_e type)
2086 return _notification_create(type);
2089 EXPORT_API notification_h notification_load(char *pkgname,
2093 notification_h noti = NULL;
2095 noti = (notification_h) calloc(1, sizeof(struct _notification));
2097 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2101 ret = notification_noti_get_by_priv_id(noti, pkgname, priv_id);
2102 if (ret != NOTIFICATION_ERROR_NONE) {
2103 notification_free(noti);
2110 EXPORT_API notification_h notification_load_by_tag(const char *tag)
2113 notification_h noti = NULL;
2114 char *caller_pkgname = NULL;
2117 NOTIFICATION_ERR("Invalid parameter");
2118 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
2122 caller_pkgname = _notification_get_pkgname_by_pid();
2123 if (!caller_pkgname) {
2124 NOTIFICATION_ERR("Failed to get a package name");
2125 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2130 noti = (notification_h) calloc(1, sizeof(struct _notification));
2132 NOTIFICATION_ERR("Failed to alloc a new notification");
2133 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2134 free(caller_pkgname);
2139 ret = notification_ipc_request_load_noti_by_tag(noti, caller_pkgname, tag);
2141 free(caller_pkgname);
2143 set_last_result(ret);
2145 if (ret != NOTIFICATION_ERROR_NONE) {
2146 notification_free(noti);
2153 EXPORT_API int notification_clone(notification_h noti, notification_h *clone)
2155 notification_h new_noti = NULL;
2157 if (noti == NULL || clone == NULL) {
2158 NOTIFICATION_ERR("INVALID PARAMETER.");
2159 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2162 new_noti = (notification_h) calloc(1, sizeof(struct _notification));
2163 if (new_noti == NULL) {
2164 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2165 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
2168 new_noti->type = noti->type;
2169 new_noti->layout = noti->layout;
2171 new_noti->group_id = noti->group_id;
2172 new_noti->internal_group_id = noti->internal_group_id;
2173 new_noti->priv_id = noti->priv_id;
2175 if(noti->caller_pkgname != NULL) {
2176 new_noti->caller_pkgname = strdup(noti->caller_pkgname);
2178 new_noti->caller_pkgname = _notification_get_pkgname_by_pid();
2180 if(noti->launch_pkgname != NULL) {
2181 new_noti->launch_pkgname = strdup(noti->launch_pkgname);
2183 new_noti->launch_pkgname = NULL;
2186 if(noti->args != NULL) {
2187 new_noti->args = bundle_dup(noti->args);
2189 new_noti->args = NULL;
2191 if(noti->group_args != NULL) {
2192 new_noti->group_args = bundle_dup(noti->group_args);
2194 new_noti->group_args = NULL;
2197 if(noti->b_execute_option != NULL) {
2198 new_noti->b_execute_option = bundle_dup(noti->b_execute_option);
2200 new_noti->b_execute_option = NULL;
2202 if(noti->b_service_responding != NULL) {
2203 new_noti->b_service_responding = bundle_dup(noti->b_service_responding);
2205 new_noti->b_service_responding = NULL;
2207 if(noti->b_service_single_launch != NULL) {
2208 new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch);
2210 new_noti->b_service_single_launch = NULL;
2212 if(noti->b_service_multi_launch != NULL) {
2213 new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch);
2215 new_noti->b_service_multi_launch = NULL;
2218 new_noti->sound_type = noti->sound_type;
2219 if(noti->sound_path != NULL) {
2220 new_noti->sound_path = strdup(noti->sound_path);
2222 new_noti->sound_path = NULL;
2224 new_noti->vibration_type = noti->vibration_type;
2225 if(noti->vibration_path != NULL) {
2226 new_noti->vibration_path = strdup(noti->vibration_path);
2228 new_noti->vibration_path = NULL;
2230 new_noti->led_operation = noti->led_operation;
2231 new_noti->led_argb = noti->led_argb;
2232 new_noti->led_on_ms = noti->led_on_ms;
2233 new_noti->led_off_ms = noti->led_off_ms;
2235 if(noti->domain != NULL) {
2236 new_noti->domain = strdup(noti->domain);
2238 new_noti->domain = NULL;
2240 if(noti->dir != NULL) {
2241 new_noti->dir = strdup(noti->dir);
2243 new_noti->dir = NULL;
2246 if(noti->b_text != NULL) {
2247 new_noti->b_text = bundle_dup(noti->b_text);
2249 new_noti->b_text = NULL;
2251 if(noti->b_key != NULL) {
2252 new_noti->b_key = bundle_dup(noti->b_key);
2254 new_noti->b_key = NULL;
2256 if(noti->b_format_args != NULL) {
2257 new_noti->b_format_args = bundle_dup(noti->b_format_args);
2259 new_noti->b_format_args = NULL;
2261 new_noti->num_format_args = noti->num_format_args;
2263 if(noti->b_image_path != NULL) {
2264 new_noti->b_image_path = bundle_dup(noti->b_image_path);
2266 new_noti->b_image_path = NULL;
2269 new_noti->time = noti->time;
2270 new_noti->insert_time = noti->insert_time;
2272 new_noti->flags_for_property = noti->flags_for_property;
2273 new_noti->display_applist = noti->display_applist;
2275 new_noti->progress_size = noti->progress_size;
2276 new_noti->progress_percentage = noti->progress_percentage;
2278 new_noti->app_icon_path = NULL;
2279 new_noti->app_name = NULL;
2280 new_noti->temp_title = NULL;
2281 new_noti->temp_content = NULL;
2285 return NOTIFICATION_ERROR_NONE;
2289 EXPORT_API int notification_free(notification_h noti)
2292 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2295 if (noti->caller_pkgname) {
2296 free(noti->caller_pkgname);
2298 if (noti->launch_pkgname) {
2299 free(noti->launch_pkgname);
2302 bundle_free(noti->args);
2304 if (noti->group_args) {
2305 bundle_free(noti->group_args);
2308 if (noti->b_execute_option) {
2309 bundle_free(noti->b_execute_option);
2311 if (noti->b_service_responding) {
2312 bundle_free(noti->b_service_responding);
2314 if (noti->b_service_single_launch) {
2315 bundle_free(noti->b_service_single_launch);
2317 if (noti->b_service_multi_launch) {
2318 bundle_free(noti->b_service_multi_launch);
2321 if (noti->sound_path) {
2322 free(noti->sound_path);
2324 if (noti->vibration_path) {
2325 free(noti->vibration_path);
2336 bundle_free(noti->b_text);
2339 bundle_free(noti->b_key);
2341 if (noti->b_format_args) {
2342 bundle_free(noti->b_format_args);
2345 if (noti->b_image_path) {
2346 bundle_free(noti->b_image_path);
2349 if (noti->app_icon_path) {
2350 free(noti->app_icon_path);
2352 if (noti->app_name) {
2353 free(noti->app_name);
2355 if (noti->temp_title) {
2356 free(noti->temp_title);
2358 if (noti->temp_content) {
2359 free(noti->temp_content);
2368 return NOTIFICATION_ERROR_NONE;
2372 notification_resister_changed_cb(void (*changed_cb)
2373 (void *data, notification_type_e type),
2376 notification_cb_list_s *noti_cb_list_new = NULL;
2377 notification_cb_list_s *noti_cb_list = NULL;
2379 if (changed_cb == NULL) {
2380 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2382 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
2383 return NOTIFICATION_ERROR_IO_ERROR;
2387 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
2389 noti_cb_list_new->next = NULL;
2390 noti_cb_list_new->prev = NULL;
2392 noti_cb_list_new->cb_type = NOTIFICATION_CB_NORMAL;
2393 noti_cb_list_new->changed_cb = changed_cb;
2394 noti_cb_list_new->detailed_changed_cb = NULL;
2395 noti_cb_list_new->data = user_data;
2397 if (g_notification_cb_list == NULL) {
2398 g_notification_cb_list = noti_cb_list_new;
2400 noti_cb_list = g_notification_cb_list;
2402 while (noti_cb_list->next != NULL) {
2403 noti_cb_list = noti_cb_list->next;
2406 noti_cb_list->next = noti_cb_list_new;
2407 noti_cb_list_new->prev = noti_cb_list;
2409 return NOTIFICATION_ERROR_NONE;
2413 notification_unresister_changed_cb(void (*changed_cb)
2414 (void *data, notification_type_e type))
2416 notification_cb_list_s *noti_cb_list = NULL;
2417 notification_cb_list_s *noti_cb_list_prev = NULL;
2418 notification_cb_list_s *noti_cb_list_next = NULL;
2420 noti_cb_list = g_notification_cb_list;
2422 if (changed_cb == NULL) {
2423 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2425 if (noti_cb_list == NULL) {
2426 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2429 while (noti_cb_list->prev != NULL) {
2430 noti_cb_list = noti_cb_list->prev;
2434 if (noti_cb_list->changed_cb == changed_cb) {
2435 noti_cb_list_prev = noti_cb_list->prev;
2436 noti_cb_list_next = noti_cb_list->next;
2438 if (noti_cb_list_prev == NULL) {
2439 g_notification_cb_list = noti_cb_list_next;
2441 noti_cb_list_prev->next = noti_cb_list_next;
2444 if (noti_cb_list_next == NULL) {
2445 if (noti_cb_list_prev != NULL) {
2446 noti_cb_list_prev->next = NULL;
2449 noti_cb_list_next->prev = noti_cb_list_prev;
2454 if (g_notification_cb_list == NULL)
2455 notification_ipc_monitor_fini();
2457 return NOTIFICATION_ERROR_NONE;
2459 noti_cb_list = noti_cb_list->next;
2460 } while (noti_cb_list != NULL);
2462 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2466 notification_register_detailed_changed_cb(
2467 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
2470 notification_cb_list_s *noti_cb_list_new = NULL;
2471 notification_cb_list_s *noti_cb_list = NULL;
2473 if (detailed_changed_cb == NULL) {
2474 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2476 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
2477 return NOTIFICATION_ERROR_IO_ERROR;
2481 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
2483 noti_cb_list_new->next = NULL;
2484 noti_cb_list_new->prev = NULL;
2486 noti_cb_list_new->cb_type = NOTIFICATION_CB_DETAILED;
2487 noti_cb_list_new->changed_cb = NULL;
2488 noti_cb_list_new->detailed_changed_cb = detailed_changed_cb;
2489 noti_cb_list_new->data = user_data;
2491 if (g_notification_cb_list == NULL) {
2492 g_notification_cb_list = noti_cb_list_new;
2494 noti_cb_list = g_notification_cb_list;
2496 while (noti_cb_list->next != NULL) {
2497 noti_cb_list = noti_cb_list->next;
2500 noti_cb_list->next = noti_cb_list_new;
2501 noti_cb_list_new->prev = noti_cb_list;
2503 return NOTIFICATION_ERROR_NONE;
2507 notification_unregister_detailed_changed_cb(
2508 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
2511 notification_cb_list_s *noti_cb_list = NULL;
2512 notification_cb_list_s *noti_cb_list_prev = NULL;
2513 notification_cb_list_s *noti_cb_list_next = NULL;
2515 noti_cb_list = g_notification_cb_list;
2517 if (detailed_changed_cb == NULL) {
2518 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2520 if (noti_cb_list == NULL) {
2521 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2524 while (noti_cb_list->prev != NULL) {
2525 noti_cb_list = noti_cb_list->prev;
2529 if (noti_cb_list->detailed_changed_cb == detailed_changed_cb) {
2530 noti_cb_list_prev = noti_cb_list->prev;
2531 noti_cb_list_next = noti_cb_list->next;
2533 if (noti_cb_list_prev == NULL) {
2534 g_notification_cb_list = noti_cb_list_next;
2536 noti_cb_list_prev->next = noti_cb_list_next;
2539 if (noti_cb_list_next == NULL) {
2540 if (noti_cb_list_prev != NULL) {
2541 noti_cb_list_prev->next = NULL;
2544 noti_cb_list_next->prev = noti_cb_list_prev;
2549 if (g_notification_cb_list == NULL)
2550 notification_ipc_monitor_fini();
2552 return NOTIFICATION_ERROR_NONE;
2554 noti_cb_list = noti_cb_list->next;
2555 } while (noti_cb_list != NULL);
2557 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2560 EXPORT_API int notification_get_count(notification_type_e type,
2561 const char *pkgname,
2563 int priv_id, int *count)
2568 if (count == NULL) {
2569 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2573 notification_noti_get_count(type, pkgname, group_id, priv_id,
2575 if (ret != NOTIFICATION_ERROR_NONE) {
2579 *count = noti_count;
2581 return NOTIFICATION_ERROR_NONE;
2584 EXPORT_API int notification_get_list(notification_type_e type,
2586 notification_list_h *list)
2588 notification_list_h get_list = NULL;
2592 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2595 ret = notification_noti_get_grouping_list(type, count, &get_list);
2596 if (ret != NOTIFICATION_ERROR_NONE) {
2602 return NOTIFICATION_ERROR_NONE;
2606 notification_get_grouping_list(notification_type_e type, int count,
2607 notification_list_h * list)
2609 notification_list_h get_list = NULL;
2613 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2616 ret = notification_noti_get_grouping_list(type, count, &get_list);
2617 if (ret != NOTIFICATION_ERROR_NONE) {
2623 return NOTIFICATION_ERROR_NONE;
2626 EXPORT_API int notification_get_detail_list(const char *pkgname,
2630 notification_list_h *list)
2632 notification_list_h get_list = NULL;
2636 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2640 notification_noti_get_detail_list(pkgname, group_id, priv_id, count,
2642 if (ret != NOTIFICATION_ERROR_NONE) {
2648 return NOTIFICATION_ERROR_NONE;
2651 EXPORT_API int notification_free_list(notification_list_h list)
2653 notification_list_h cur_list = NULL;
2654 notification_h noti = NULL;
2657 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2660 cur_list = notification_list_get_head(list);
2662 while (cur_list != NULL) {
2663 noti = notification_list_get_data(cur_list);
2664 cur_list = notification_list_remove(cur_list, noti);
2666 notification_free(noti);
2669 return NOTIFICATION_ERROR_NONE;
2672 EXPORT_API int notification_op_get_data(notification_op *noti_op, notification_op_data_type_e type,
2675 if (noti_op == NULL || data == NULL) {
2676 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2680 case NOTIFICATION_OP_DATA_TYPE:
2681 *((int*)data) = noti_op->type;
2683 case NOTIFICATION_OP_DATA_PRIV_ID:
2684 *((int*)data) = noti_op->priv_id;
2686 case NOTIFICATION_OP_DATA_NOTI:
2687 *((notification_h *)data) = noti_op->noti;
2689 case NOTIFICATION_OP_DATA_EXTRA_INFO_1:
2690 *((int*)data) = noti_op->extra_info_1;
2692 case NOTIFICATION_OP_DATA_EXTRA_INFO_2:
2693 *((int*)data) = noti_op->extra_info_2;
2696 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2700 return NOTIFICATION_ERROR_NONE;
2703 void notification_call_changed_cb(notification_op *op_list, int op_num)
2705 notification_cb_list_s *noti_cb_list = NULL;
2708 if (g_notification_cb_list == NULL) {
2711 noti_cb_list = g_notification_cb_list;
2713 while (noti_cb_list->prev != NULL) {
2714 noti_cb_list = noti_cb_list->prev;
2717 if (op_list == NULL) {
2718 NOTIFICATION_ERR("invalid data");
2722 while (noti_cb_list != NULL) {
2723 if (noti_cb_list->cb_type == NOTIFICATION_CB_NORMAL && noti_cb_list->changed_cb) {
2724 noti_cb_list->changed_cb(noti_cb_list->data,
2725 NOTIFICATION_TYPE_NOTI);
2727 if (noti_cb_list->cb_type == NOTIFICATION_CB_DETAILED && noti_cb_list->detailed_changed_cb) {
2728 noti_cb_list->detailed_changed_cb(noti_cb_list->data,
2729 NOTIFICATION_TYPE_NOTI, op_list, op_num);
2732 noti_cb_list = noti_cb_list->next;
2736 EXPORT_API int notification_is_service_ready(void)
2738 return notification_ipc_is_master_ready();
2742 notification_add_deferred_task(
2743 void (*deferred_task_cb)(void *data), void *user_data)
2745 if (deferred_task_cb == NULL) {
2746 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2749 return notification_ipc_add_deffered_task(deferred_task_cb, user_data);
2753 notification_del_deferred_task(
2754 void (*deferred_task_cb)(void *data))
2756 if (deferred_task_cb == NULL) {
2757 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2760 return notification_ipc_del_deffered_task(deferred_task_cb);
2763 /* notification_set_icon will be removed */
2764 EXPORT_API int notification_set_icon(notification_h noti,
2765 const char *icon_path)
2767 int ret_err = NOTIFICATION_ERROR_NONE;
2770 notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
2776 /* notification_get_icon will be removed */
2777 EXPORT_API int notification_get_icon(notification_h noti,
2780 int ret_err = NOTIFICATION_ERROR_NONE;
2781 char *ret_image_path = NULL;
2784 notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
2787 if (ret_err == NOTIFICATION_ERROR_NONE && icon_path != NULL) {
2788 *icon_path = ret_image_path;
2790 //NOTIFICATION_DBG("Get icon : %s", *icon_path);
2796 EXPORT_API int notification_set_title(notification_h noti,
2798 const char *loc_title)
2800 int noti_err = NOTIFICATION_ERROR_NONE;
2802 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
2804 NOTIFICATION_VARIABLE_TYPE_NONE);
2809 EXPORT_API int notification_get_title(notification_h noti,
2813 int noti_err = NOTIFICATION_ERROR_NONE;
2814 char *ret_text = NULL;
2817 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
2820 if (title != NULL) {
2824 if (loc_title != NULL) {
2831 EXPORT_API int notification_set_content(notification_h noti,
2832 const char *content,
2833 const char *loc_content)
2835 int noti_err = NOTIFICATION_ERROR_NONE;
2837 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
2838 content, loc_content,
2839 NOTIFICATION_VARIABLE_TYPE_NONE);
2844 EXPORT_API int notification_get_content(notification_h noti,
2848 int noti_err = NOTIFICATION_ERROR_NONE;
2849 char *ret_text = NULL;
2852 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
2855 if (content != NULL) {
2856 *content = ret_text;
2859 if (loc_content != NULL) {
2860 *loc_content = NULL;
2868 (VCONFKEY_SETAPPL_STATE_TICKER_NOTI_DISPLAY_CONTENT_BOOL, &boolval);
2870 if (ret == -1 || boolval == 0) {
2871 if (content != NULL && noti->default_content != NULL) {
2872 *content = noti->default_content;
2875 if (loc_content != NULL && noti->loc_default_content != NULL) {
2876 *loc_content = noti->loc_default_content;
2882 EXPORT_API int notification_set_args(notification_h noti,
2884 bundle * group_args)
2886 if (noti == NULL || args == NULL) {
2887 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2891 bundle_free(noti->args);
2894 noti->args = bundle_dup(args);
2896 if (noti->group_args) {
2897 bundle_free(noti->group_args);
2898 noti->group_args = NULL;
2901 if (group_args != NULL) {
2902 noti->group_args = bundle_dup(group_args);
2905 return NOTIFICATION_ERROR_NONE;
2908 EXPORT_API int notification_get_args(notification_h noti,
2910 bundle ** group_args)
2912 if (noti == NULL || args == NULL) {
2913 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2922 if (group_args != NULL && noti->group_args) {
2923 *group_args = noti->group_args;
2926 return NOTIFICATION_ERROR_NONE;
2929 EXPORT_API int notification_delete_group_by_group_id(const char *pkgname,
2930 notification_type_e type,
2934 char *caller_pkgname = NULL;
2936 if (pkgname == NULL) {
2937 caller_pkgname = _notification_get_pkgname_by_pid();
2939 caller_pkgname = strdup(pkgname);
2942 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
2943 if (ret != NOTIFICATION_ERROR_NONE) {
2944 if (caller_pkgname) {
2945 free(caller_pkgname);
2950 if (caller_pkgname) {
2951 free(caller_pkgname);
2953 return NOTIFICATION_ERROR_NONE;
2956 EXPORT_API int notification_delete_group_by_priv_id(const char *pkgname,
2957 notification_type_e type,
2961 char *caller_pkgname = NULL;
2963 if (pkgname == NULL) {
2964 caller_pkgname = _notification_get_pkgname_by_pid();
2966 caller_pkgname = strdup(pkgname);
2969 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
2970 if (ret != NOTIFICATION_ERROR_NONE) {
2971 if (caller_pkgname) {
2972 free(caller_pkgname);
2977 if (caller_pkgname) {
2978 free(caller_pkgname);
2980 return NOTIFICATION_ERROR_NONE;
2983 EXPORT_API int notification_set_tag(notification_h noti, const char *tag)
2985 /* Check noti is valid data */
2987 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2991 /* save input TAG */
2992 if (noti->tag != NULL) {
2995 noti->tag = strdup(tag);
2998 return NOTIFICATION_ERROR_NONE;
3002 EXPORT_API int notification_get_tag(notification_h noti, const char **tag)
3004 /* Check noti is valid data */
3006 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3009 /* Set sound type */
3011 return NOTIFICATION_ERROR_NONE;
3014 EXPORT_API int notification_register_toast_message(void (*posted_toast_cb) (void *data))
3016 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
3017 return NOTIFICATION_ERROR_IO_ERROR;
3020 posted_toast_message_cb = posted_toast_cb;
3022 return NOTIFICATION_ERROR_NONE;
3025 void notification_call_posted_toast_cb(const char *message)
3027 if (posted_toast_message_cb != NULL) {
3028 posted_toast_message_cb(message);