4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>, Youngsub Ko <ys4610.ko@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
28 #include <sys/socket.h>
29 #include <sys/syscall.h>
33 #include <dbus/dbus.h>
34 #include <dbus/dbus-glib-lowlevel.h>
36 #include <app_control.h>
37 #include <app_control_internal.h>
41 #include <vconf-keys.h>
44 #include <notification.h>
45 #include <notification_list.h>
46 #include <notification_debug.h>
47 #include <notification_internal.h>
48 #include <notification_noti.h>
49 #include <notification_ongoing.h>
50 #include <notification_group.h>
51 #include <notification_ipc.h>
53 typedef struct _notification_cb_list notification_cb_list_s;
55 typedef enum __notification_cb_type {
56 NOTIFICATION_CB_NORMAL = 1,
57 NOTIFICATION_CB_DETAILED,
58 } _notification_cb_type_e;
60 struct _notification_cb_list {
61 notification_cb_list_s *prev;
62 notification_cb_list_s *next;
64 _notification_cb_type_e cb_type;
65 void (*changed_cb) (void *data, notification_type_e type);
66 void (*detailed_changed_cb) (void *data, notification_type_e type, notification_op *op_list, int num_op);
70 static notification_cb_list_s *g_notification_cb_list = NULL;
72 #define NOTI_TEXT_RESULT_LEN 2048
73 #define NOTI_PKGNAME_LEN 512
75 static char *_notification_get_pkgname_by_pid(void)
77 char pkgname[NOTI_PKGNAME_LEN + 1] = { 0, };
78 int pid = 0, ret = AUL_R_OK;
84 ret = aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname));
85 if (ret != AUL_R_OK) {
86 char buf[NOTI_PKGNAME_LEN + 1] = { 0, };
88 snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
90 fd = open(buf, O_RDONLY);
95 ret = read(fd, pkgname, sizeof(pkgname) - 1);
105 * "ret" is not able to be larger than "sizeof(pkgname) - 1",
106 * if the system is not going wrong.
109 if (strlen(pkgname) <= 0) {
114 dup_pkgname = strdup(pkgname);
116 NOTIFICATION_ERR("Heap: %s\n", strerror(errno));
121 static void _notification_get_text_domain(notification_h noti)
123 if (noti->domain != NULL) {
127 if (noti->dir != NULL) {
132 EXPORT_API notification_error_e notification_set_image(notification_h noti,
133 notification_image_type_e type,
134 const char *image_path)
137 char buf_key[32] = { 0, };
138 const char *ret_val = NULL;
140 /* Check noti and image_path are valid data */
141 if (noti == NULL || image_path == NULL) {
142 return NOTIFICATION_ERROR_INVALID_PARAMETER;
145 /* Check image type is valid type */
146 if (type <= NOTIFICATION_IMAGE_TYPE_NONE
147 || type >= NOTIFICATION_IMAGE_TYPE_MAX) {
148 return NOTIFICATION_ERROR_INVALID_PARAMETER;
151 /* Check image path bundle is exist */
152 if (noti->b_image_path) {
153 /* If image path bundle is exist, store local bundle value */
154 b = noti->b_image_path;
156 /* Set image type to key as char string type */
157 snprintf(buf_key, sizeof(buf_key), "%d", type);
159 /* Get value using key */
160 ret_val = bundle_get_val(b, buf_key);
161 if (ret_val != NULL) {
162 /* If key is exist, remove this value to store new image path */
163 bundle_del(b, buf_key);
166 /* Add new image path with type key */
167 bundle_add(b, buf_key, image_path);
169 /* If image path bundle is not exist, create new one */
172 /* Set image type to key as char string type */
173 snprintf(buf_key, sizeof(buf_key), "%d", type);
175 /* Add new image path with type key */
176 bundle_add(b, buf_key, image_path);
178 /* Save to image path bundle */
179 noti->b_image_path = b;
182 return NOTIFICATION_ERROR_NONE;
185 EXPORT_API notification_error_e notification_get_image(notification_h noti,
186 notification_image_type_e type,
190 char buf_key[32] = { 0, };
191 const char *ret_val = NULL;
193 /* Check noti and image_path is valid data */
194 if (noti == NULL || image_path == NULL) {
195 return NOTIFICATION_ERROR_INVALID_PARAMETER;
198 /* Check image type is valid data */
199 if (type <= NOTIFICATION_IMAGE_TYPE_NONE
200 || type >= NOTIFICATION_IMAGE_TYPE_MAX) {
201 return NOTIFICATION_ERROR_INVALID_PARAMETER;
204 /* Check image path bundle exist */
205 if (noti->b_image_path) {
206 /* If image path bundle exist, store local bundle data */
207 b = noti->b_image_path;
209 /* Set image type to key as char string type */
210 snprintf(buf_key, sizeof(buf_key), "%d", type);
212 /* Get value of key */
213 ret_val = bundle_get_val(b, buf_key);
215 *image_path = (char *)ret_val;
217 /* If image path bundle does not exist, image path is NULL */
221 /* If image path is NULL and type is ICON, icon path set from AIL */
222 /* order : user icon -> launch_pkgname icon -> caller_pkgname icon -> service app icon */
223 if (*image_path == NULL && type == NOTIFICATION_IMAGE_TYPE_ICON) {
224 /* Check App icon path is already set */
225 if (noti->app_icon_path != NULL) {
226 /* image path will be app icon path */
227 *image_path = noti->app_icon_path;
233 return NOTIFICATION_ERROR_NONE;
236 EXPORT_API notification_error_e notification_set_time(notification_h noti,
239 /* Check noti is valid data */
241 return NOTIFICATION_ERROR_INVALID_PARAMETER;
244 if (input_time == 0) {
245 /* If input time is 0, set current time */
246 noti->time = time(NULL);
248 /* save input time */
249 noti->time = input_time;
252 return NOTIFICATION_ERROR_NONE;
255 EXPORT_API notification_error_e notification_get_time(notification_h noti,
258 /* Check noti and time is valid data */
259 if (noti == NULL || ret_time == NULL) {
260 return NOTIFICATION_ERROR_INVALID_PARAMETER;
263 /* Set time infomation */
264 *ret_time = noti->time;
266 return NOTIFICATION_ERROR_NONE;
269 EXPORT_API notification_error_e notification_get_insert_time(notification_h noti,
272 /* Check noti and ret_time is valid data */
273 if (noti == NULL || ret_time == NULL) {
274 return NOTIFICATION_ERROR_INVALID_PARAMETER;
277 /* Set insert time information */
278 *ret_time = noti->insert_time;
280 return NOTIFICATION_ERROR_NONE;
283 EXPORT_API notification_error_e notification_set_text(notification_h noti,
284 notification_text_type_e type,
290 char buf_key[32] = { 0, };
291 char buf_val[1024] = { 0, };
292 const char *ret_val = NULL;
294 notification_variable_type_e var_type;
296 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
297 int var_value_int = 0;
298 double var_value_double = 0.0;
299 char *var_value_string = NULL;
300 notification_count_pos_type_e var_value_count =
301 NOTIFICATION_COUNT_POS_NONE;
303 /* Check noti is valid data */
305 return NOTIFICATION_ERROR_INVALID_PARAMETER;
308 /* Check text type is valid type */
309 if (type <= NOTIFICATION_TEXT_TYPE_NONE
310 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
311 return NOTIFICATION_ERROR_INVALID_PARAMETER;
314 /* Check text bundle exist */
316 if (noti->b_text != NULL) {
317 /* If text bundle exist, store local bundle data */
320 /* Make type to key as char string */
321 snprintf(buf_key, sizeof(buf_key), "%d", type);
323 /* Get value using type key */
324 ret_val = bundle_get_val(b, buf_key);
325 if (ret_val != NULL) {
326 /* If value exist, remove this to add new value */
327 bundle_del(b, buf_key);
330 snprintf(buf_val, sizeof(buf_val), "%s", text);
332 /* Add new text value */
333 bundle_add(b, buf_key, buf_val);
335 /* If text bundle does not exist, create new one */
338 /* Make type to key as char string */
339 snprintf(buf_key, sizeof(buf_key), "%d", type);
341 snprintf(buf_val, sizeof(buf_val), "%s", text);
343 /* Add new text value */
344 bundle_add(b, buf_key, buf_val);
346 /* Save text bundle */
350 /* Reset if text is NULL */
351 if (noti->b_text != NULL) {
352 /* If text bundle exist, store local bundle data */
355 /* Make type to key as char string */
356 snprintf(buf_key, sizeof(buf_key), "%d", type);
358 /* Get value using type key */
359 ret_val = bundle_get_val(b, buf_key);
360 if (ret_val != NULL) {
361 /* If value exist, remove this */
362 bundle_del(b, buf_key);
367 /* Save key if key is valid data */
369 /* Check key bundle exist */
370 if (noti->b_key != NULL) {
371 /* If key bundle exist, store local bundle data */
374 /* Make type to key as char string */
375 snprintf(buf_key, sizeof(buf_key), "%d", type);
377 /* Get value using type key */
378 ret_val = bundle_get_val(b, buf_key);
379 if (ret_val != NULL) {
380 /* If value exist, remove this to add new value */
381 bundle_del(b, buf_key);
384 snprintf(buf_val, sizeof(buf_val), "%s", key);
386 /* Add new key value */
387 bundle_add(b, buf_key, buf_val);
389 /* If key bundle does not exist, create new one */
392 /* Make type to key as char string */
393 snprintf(buf_key, sizeof(buf_key), "%d", type);
395 snprintf(buf_val, sizeof(buf_val), "%s", key);
397 /* Add new key value */
398 bundle_add(b, buf_key, buf_val);
400 /* Save key bundle */
404 /* Reset if key is NULL */
405 if (noti->b_key != NULL) {
406 /* If key bundle exist, store local bundle data */
409 /* Make type to key as char string */
410 snprintf(buf_key, sizeof(buf_key), "%d", type);
412 /* Get value using type key */
413 ret_val = bundle_get_val(b, buf_key);
414 if (ret_val != NULL) {
415 /* If value exist, remove this */
416 bundle_del(b, buf_key);
421 if (noti->b_format_args != NULL) {
422 b = noti->b_format_args;
427 va_start(var_args, args_type);
429 var_type = args_type;
432 while (var_type != NOTIFICATION_VARIABLE_TYPE_NONE) {
434 snprintf(buf_key, sizeof(buf_key), "%dtype%d", type, num_args);
435 snprintf(buf_val, sizeof(buf_val), "%d", var_type);
437 ret_val = bundle_get_val(b, buf_key);
438 if (ret_val != NULL) {
439 bundle_del(b, buf_key);
442 bundle_add(b, buf_key, buf_val);
445 case NOTIFICATION_VARIABLE_TYPE_INT:
446 var_value_int = va_arg(var_args, int);
449 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
451 snprintf(buf_val, sizeof(buf_val), "%d", var_value_int);
453 ret_val = bundle_get_val(b, buf_key);
454 if (ret_val != NULL) {
455 bundle_del(b, buf_key);
458 bundle_add(b, buf_key, buf_val);
460 case NOTIFICATION_VARIABLE_TYPE_DOUBLE:
461 var_value_double = va_arg(var_args, double);
464 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
466 snprintf(buf_val, sizeof(buf_val), "%.2f",
469 ret_val = bundle_get_val(b, buf_key);
470 if (ret_val != NULL) {
471 bundle_del(b, buf_key);
474 bundle_add(b, buf_key, buf_val);
476 case NOTIFICATION_VARIABLE_TYPE_STRING:
477 var_value_string = va_arg(var_args, char *);
480 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
482 snprintf(buf_val, sizeof(buf_val), "%s",
485 ret_val = bundle_get_val(b, buf_key);
486 if (ret_val != NULL) {
487 bundle_del(b, buf_key);
490 bundle_add(b, buf_key, buf_val);
492 case NOTIFICATION_VARIABLE_TYPE_COUNT:
494 va_arg(var_args, notification_count_pos_type_e);
497 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
499 snprintf(buf_val, sizeof(buf_val), "%d",
502 ret_val = bundle_get_val(b, buf_key);
503 if (ret_val != NULL) {
504 bundle_del(b, buf_key);
507 bundle_add(b, buf_key, buf_val);
510 NOTIFICATION_ERR("Error. invalid variable type. : %d",
512 noti_err = NOTIFICATION_ERROR_INVALID_PARAMETER;
517 var_type = va_arg(var_args, notification_variable_type_e);
521 if (noti_err == NOTIFICATION_ERROR_NONE) {
522 noti->num_format_args = num_args;
524 noti->num_format_args = 0;
527 snprintf(buf_key, sizeof(buf_key), "num%d", type);
528 snprintf(buf_val, sizeof(buf_val), "%d", noti->num_format_args);
530 ret_val = bundle_get_val(b, buf_key);
531 if (ret_val != NULL) {
532 bundle_del(b, buf_key);
535 bundle_add(b, buf_key, buf_val);
537 noti->b_format_args = b;
542 EXPORT_API notification_error_e notification_get_text(notification_h noti,
543 notification_text_type_e type,
547 char buf_key[32] = { 0, };
548 const char *ret_val = NULL;
549 const char *get_str = NULL;
550 const char *get_check_type_str = NULL;
551 notification_text_type_e check_type = NOTIFICATION_TEXT_TYPE_NONE;
552 int display_option_flag = 0;
554 char *temp_str = NULL;
555 char result_str[NOTI_TEXT_RESULT_LEN] = { 0, };
556 char buf_str[1024] = { 0, };
558 notification_variable_type_e ret_var_type = 0;
559 int ret_variable_int = 0;
560 double ret_variable_double = 0.0;
562 /* Check noti is valid data */
563 if (noti == NULL || text == NULL) {
564 return NOTIFICATION_ERROR_INVALID_PARAMETER;
567 /* Check text type is valid type */
568 if (type <= NOTIFICATION_TEXT_TYPE_NONE
569 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
570 return NOTIFICATION_ERROR_INVALID_PARAMETER;
574 if (noti->b_key != NULL) {
577 /* Get text domain and dir */
578 _notification_get_text_domain(noti);
580 snprintf(buf_key, sizeof(buf_key), "%d", type);
582 ret_val = bundle_get_val(b, buf_key);
583 if (ret_val != NULL && noti->domain != NULL
584 && noti->dir != NULL) {
585 /* Get application string */
586 bindtextdomain(noti->domain, noti->dir);
588 get_str = dgettext(noti->domain, ret_val);
589 } else if (ret_val != NULL) {
590 /* Get system string */
591 get_str = dgettext("sys_string", ret_val);
597 if (get_str == NULL && noti->b_text != NULL) {
600 snprintf(buf_key, sizeof(buf_key), "%d", type);
602 get_str = bundle_get_val(b, buf_key);
607 /* Set display option is off type when option is off, type is noti */
608 if (get_str != NULL && display_option_flag == 1
609 && noti->type == NOTIFICATION_TYPE_NOTI) {
610 if (type == NOTIFICATION_TEXT_TYPE_CONTENT
611 || type == NOTIFICATION_TEXT_TYPE_GROUP_CONTENT) {
612 /* Set check_type to option content string */
613 if (type == NOTIFICATION_TEXT_TYPE_CONTENT) {
615 NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF;
616 } else if (type == NOTIFICATION_TEXT_TYPE_GROUP_CONTENT) {
618 NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF;
622 if (noti->b_key != NULL) {
625 /* Get text domain and dir */
626 _notification_get_text_domain(noti);
628 snprintf(buf_key, sizeof(buf_key), "%d",
631 ret_val = bundle_get_val(b, buf_key);
632 if (ret_val != NULL && noti->domain != NULL
633 && noti->dir != NULL) {
634 /* Get application string */
635 bindtextdomain(noti->domain, noti->dir);
638 dgettext(noti->domain, ret_val);
639 } else if (ret_val != NULL) {
640 /* Get system string */
642 dgettext("sys_string", ret_val);
644 get_check_type_str = NULL;
648 if (get_check_type_str == NULL && noti->b_text != NULL) {
651 snprintf(buf_key, sizeof(buf_key), "%d",
654 get_check_type_str = bundle_get_val(b, buf_key);
658 if (get_check_type_str != NULL) {
659 /* Replace option off type string */
660 get_str = get_check_type_str;
662 /* Set default string */
664 dgettext("sys_string", "IDS_COM_POP_MISSED_EVENT");
668 if (get_str != NULL) {
669 /* Get number format args */
670 b = noti->b_format_args;
671 noti->num_format_args = 0;
674 snprintf(buf_key, sizeof(buf_key), "num%d", check_type);
675 ret_val = bundle_get_val(b, buf_key);
676 if (ret_val != NULL) {
677 noti->num_format_args = atoi(ret_val);
681 if (noti->num_format_args == 0) {
682 *text = (char *)get_str;
684 /* Check first variable is count, LEFT pos */
685 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
686 check_type, num_args);
687 ret_val = bundle_get_val(b, buf_key);
688 ret_var_type = atoi(ret_val);
690 if (ret_var_type == NOTIFICATION_VARIABLE_TYPE_COUNT) {
692 snprintf(buf_key, sizeof(buf_key), "%dvalue%d",
693 check_type, num_args);
694 ret_val = bundle_get_val(b, buf_key);
695 ret_variable_int = atoi(ret_val);
697 if (ret_variable_int ==
698 NOTIFICATION_COUNT_POS_LEFT) {
699 notification_noti_get_count(noti->type,
700 noti->caller_pkgname,
704 snprintf(buf_str, sizeof(buf_str),
705 "%d ", ret_variable_int);
707 int src_len = strlen(result_str);
708 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
710 strncat(result_str, buf_str,
718 /* Check variable IN pos */
719 for (temp_str = (char *)get_str; *temp_str != '\0';
721 if (*temp_str != '%') {
722 strncat(result_str, temp_str, 1);
724 if (*(temp_str + 1) == '%') {
725 strncat(result_str, temp_str,
727 } else if (*(temp_str + 1) == 'd') {
729 ret_variable_int = 0;
733 "%dtype%d", check_type,
736 bundle_get_val(b, buf_key);
737 ret_var_type = atoi(ret_val);
739 NOTIFICATION_VARIABLE_TYPE_COUNT)
741 /* Get notification count */
742 notification_noti_get_count
744 noti->caller_pkgname,
764 sizeof(buf_str), "%d",
767 int src_len = strlen(result_str);
768 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
770 strncat(result_str, buf_str,
776 } else if (*(temp_str + 1) == 's') {
781 check_type, num_args);
783 bundle_get_val(b, buf_key);
786 sizeof(buf_str), "%s",
789 int src_len = strlen(result_str);
790 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
792 strncat(result_str, buf_str,
798 } else if (*(temp_str + 1) == 'f') {
803 check_type, num_args);
805 bundle_get_val(b, buf_key);
806 ret_variable_double =
812 ret_variable_double);
814 int src_len = strlen(result_str);
815 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
817 strncat(result_str, buf_str,
828 /* Check last variable is count, LEFT pos */
829 if (num_args < noti->num_format_args) {
830 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
831 check_type, num_args);
832 ret_val = bundle_get_val(b, buf_key);
833 ret_var_type = atoi(ret_val);
835 NOTIFICATION_VARIABLE_TYPE_COUNT) {
837 snprintf(buf_key, sizeof(buf_key),
838 "%dvalue%d", check_type,
840 ret_val = bundle_get_val(b, buf_key);
841 ret_variable_int = atoi(ret_val);
843 if (ret_variable_int ==
844 NOTIFICATION_COUNT_POS_RIGHT) {
845 notification_noti_get_count
847 noti->caller_pkgname,
852 sizeof(buf_str), " %d",
855 int src_len = strlen(result_str);
856 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
858 strncat(result_str, buf_str,
867 switch (check_type) {
868 case NOTIFICATION_TEXT_TYPE_TITLE:
869 case NOTIFICATION_TEXT_TYPE_GROUP_TITLE:
870 if (noti->temp_title != NULL)
871 free(noti->temp_title);
873 noti->temp_title = strdup(result_str);
875 *text = noti->temp_title;
877 case NOTIFICATION_TEXT_TYPE_CONTENT:
878 case NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
879 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT:
880 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
881 if (noti->temp_content !=
883 free(noti->temp_content);
885 noti->temp_content = strdup(result_str);
887 *text = noti->temp_content;
899 return NOTIFICATION_ERROR_NONE;
902 EXPORT_API notification_error_e notification_set_text_domain(notification_h noti,
906 /* check noti and domain is valid data */
907 if (noti == NULL || domain == NULL) {
908 return NOTIFICATION_ERROR_INVALID_PARAMETER;
913 /* Remove previous domain */
917 noti->domain = strdup(domain);
919 /* Check locale dir */
921 /* Remove previous locale dir */
924 /* Copy locale dir */
925 noti->dir = strdup(dir);
927 return NOTIFICATION_ERROR_NONE;
930 EXPORT_API notification_error_e notification_get_text_domain(notification_h noti,
934 /* Check noti is valid data */
936 return NOTIFICATION_ERROR_INVALID_PARAMETER;
940 if (domain != NULL && noti->domain != NULL) {
941 *domain = noti->domain;
945 if (dir != NULL && noti->dir != NULL) {
949 return NOTIFICATION_ERROR_NONE;
952 EXPORT_API notification_error_e notification_set_time_to_text(notification_h noti, notification_text_type_e type,
955 notification_error_e ret = NOTIFICATION_ERROR_NONE;
956 char buf[256] = { 0, };
957 char buf_tag[512] = { 0, };
960 return NOTIFICATION_ERROR_INVALID_PARAMETER;
963 return NOTIFICATION_ERROR_INVALID_PARAMETER;
966 snprintf(buf, sizeof(buf), "%lu", time);
967 ret = notification_noti_set_tag(TAG_TIME, buf, buf_tag, sizeof(buf_tag));
969 if (ret != NOTIFICATION_ERROR_NONE) {
973 return notification_set_text(noti, type, buf_tag, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
976 EXPORT_API notification_error_e notification_get_time_from_text(notification_h noti, notification_text_type_e type,
979 notification_error_e ret = NOTIFICATION_ERROR_NONE;
982 return NOTIFICATION_ERROR_INVALID_PARAMETER;
985 return NOTIFICATION_ERROR_INVALID_PARAMETER;
988 char *ret_text = NULL;
989 ret = notification_get_text(noti, type, &ret_text);
991 if (ret != NOTIFICATION_ERROR_NONE || ret_text == NULL) {
992 return NOTIFICATION_ERROR_INVALID_PARAMETER;
995 if (notification_noti_get_tag_type(ret_text) == TAG_TYPE_INVALID) {
996 return NOTIFICATION_ERROR_INVALID_PARAMETER;
999 char *tag_value = NULL;
1000 tag_value = notification_noti_strip_tag(ret_text);
1001 if (tag_value == NULL) {
1002 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1005 *time = atol(tag_value);
1008 return NOTIFICATION_ERROR_NONE;
1011 EXPORT_API notification_error_e notification_set_sound(notification_h noti,
1012 notification_sound_type_e type,
1015 /* Check noti is valid data */
1017 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1020 /* Check type is valid */
1021 if (type < NOTIFICATION_SOUND_TYPE_NONE
1022 || type >= NOTIFICATION_SOUND_TYPE_MAX) {
1023 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1026 /* Save sound type */
1027 noti->sound_type = type;
1029 /* Save sound path if user data type */
1030 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA && path != NULL) {
1031 if (noti->sound_path != NULL) {
1032 free(noti->sound_path);
1035 noti->sound_path = strdup(path);
1037 if (noti->sound_path != NULL) {
1038 free(noti->sound_path);
1039 noti->sound_path = NULL;
1043 return NOTIFICATION_ERROR_NONE;
1046 EXPORT_API notification_error_e notification_get_sound(notification_h noti,
1047 notification_sound_type_e *type,
1050 /* check noti and type is valid data */
1051 if (noti == NULL || type == NULL) {
1052 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1055 /* Set sound type */
1056 *type = noti->sound_type;
1058 /* Set sound path if user data type */
1059 if (noti->sound_type == NOTIFICATION_SOUND_TYPE_USER_DATA
1061 *path = noti->sound_path;
1064 return NOTIFICATION_ERROR_NONE;
1067 EXPORT_API notification_error_e notification_set_vibration(notification_h noti,
1068 notification_vibration_type_e type,
1071 /* Check noti is valid data */
1073 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1076 /* Check type is valid */
1077 if (type < NOTIFICATION_VIBRATION_TYPE_NONE
1078 || type >= NOTIFICATION_VIBRATION_TYPE_MAX) {
1079 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1082 /* Save vibration type */
1083 noti->vibration_type = type;
1085 /* Save sound path if user data type */
1086 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA && path != NULL) {
1087 if (noti->vibration_path != NULL) {
1088 free(noti->vibration_path);
1091 noti->vibration_path = strdup(path);
1093 if (noti->vibration_path != NULL) {
1094 free(noti->vibration_path);
1095 noti->vibration_path = NULL;
1099 return NOTIFICATION_ERROR_NONE;
1103 EXPORT_API notification_error_e notification_get_vibration(notification_h noti,
1104 notification_vibration_type_e *type,
1107 /* check noti and type is valid data */
1108 if (noti == NULL || type == NULL) {
1109 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1112 /* Set vibration type */
1113 *type = noti->vibration_type;
1115 /* Set sound path if user data type */
1116 if (noti->vibration_type == NOTIFICATION_VIBRATION_TYPE_USER_DATA
1118 *path = noti->vibration_path;
1121 return NOTIFICATION_ERROR_NONE;
1124 EXPORT_API notification_error_e notification_set_led(notification_h noti,
1125 notification_led_op_e operation,
1128 /* Check noti is valid data */
1130 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1133 /* Check operation is valid */
1134 if (operation < NOTIFICATION_LED_OP_OFF
1135 || operation >= NOTIFICATION_LED_OP_MAX) {
1136 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1139 /* Save led operation */
1140 noti->led_operation = operation;
1142 /* Save led argb if operation is turning on LED with custom color */
1143 if (operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR) {
1144 noti->led_argb = led_argb;
1147 return NOTIFICATION_ERROR_NONE;
1150 EXPORT_API notification_error_e notification_get_led(notification_h noti,
1151 notification_led_op_e *operation,
1154 /* check noti and operation is valid data */
1155 if (noti == NULL || operation == NULL) {
1156 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1159 /* Set led operation */
1160 *operation = noti->led_operation;
1162 /* Save led argb if operation is turning on LED with custom color */
1163 if (noti->led_operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR
1164 && led_argb != NULL) {
1165 *led_argb = noti->led_argb;
1168 return NOTIFICATION_ERROR_NONE;
1171 EXPORT_API notification_error_e notification_set_led_time_period(notification_h noti,
1172 int on_ms, int off_ms)
1174 /* Check noti is valid data */
1176 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1179 /* Save led operation */
1180 noti->led_on_ms = on_ms;
1181 noti->led_off_ms = off_ms;
1183 return NOTIFICATION_ERROR_NONE;
1186 EXPORT_API notification_error_e notification_get_led_time_period(notification_h noti,
1187 int *on_ms, int *off_ms)
1189 /* check noti and operation is valid data */
1191 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1195 *(on_ms) = noti->led_on_ms;
1197 *(off_ms) = noti->led_off_ms;
1199 return NOTIFICATION_ERROR_NONE;
1202 EXPORT_API notification_error_e notification_set_application(notification_h noti,
1203 const char *pkgname)
1205 if (noti == NULL || pkgname == NULL) {
1206 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1209 if (noti->launch_pkgname) {
1210 free(noti->launch_pkgname);
1213 noti->launch_pkgname = strdup(pkgname);
1215 return NOTIFICATION_ERROR_NONE;
1218 EXPORT_API notification_error_e notification_get_application(notification_h noti,
1221 if (noti == NULL || pkgname == NULL) {
1222 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1225 if (noti->launch_pkgname) {
1226 *pkgname = noti->launch_pkgname;
1228 *pkgname = noti->caller_pkgname;
1231 return NOTIFICATION_ERROR_NONE;
1234 EXPORT_API int notification_set_launch_option(notification_h noti,
1235 notification_launch_option_type type, void *option)
1239 app_control_h app_control = option;
1242 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1244 if (app_control == NULL) {
1245 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1247 if (type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL) {
1248 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1251 if ((ret = app_control_to_bundle(app_control, &b)) == APP_CONTROL_ERROR_NONE) {
1252 return notification_set_execute_option(noti,
1253 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
1257 NOTIFICATION_ERR("Failed to convert appcontrol to bundle:%d", ret);
1258 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1262 EXPORT_API int notification_get_launch_option(notification_h noti,
1263 notification_launch_option_type type, void *option)
1267 app_control_h *app_control = (app_control_h *)option;
1268 app_control_h app_control_new = NULL;
1271 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1273 if (app_control == NULL) {
1274 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1276 if (type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL) {
1277 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1280 ret = notification_get_execute_option(noti,
1281 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
1284 if (ret == NOTIFICATION_ERROR_NONE && b != NULL) {
1285 ret = app_control_create(&app_control_new);
1286 if (ret == APP_CONTROL_ERROR_NONE && app_control_new != NULL) {
1287 ret = app_control_import_from_bundle(app_control_new, b);
1288 if (ret == APP_CONTROL_ERROR_NONE) {
1289 *app_control = app_control_new;
1291 app_control_destroy(app_control_new);
1292 NOTIFICATION_ERR("Failed to import app control from bundle:%d", ret);
1293 return NOTIFICATION_ERROR_IO_ERROR;
1296 NOTIFICATION_ERR("Failed to create app control:%d", ret);
1297 return NOTIFICATION_ERROR_IO_ERROR;
1300 NOTIFICATION_ERR("Failed to get execute option:%d", ret);
1304 return NOTIFICATION_ERROR_NONE;
1307 EXPORT_API notification_error_e notification_set_execute_option(notification_h noti,
1308 notification_execute_type_e type,
1311 bundle *service_handle)
1313 char buf_key[32] = { 0, };
1314 const char *ret_val = NULL;
1318 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1321 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1322 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1323 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1326 /* Create execute option bundle if does not exist */
1327 if (noti->b_execute_option != NULL) {
1328 noti->b_execute_option = bundle_create();
1331 b = noti->b_execute_option;
1336 snprintf(buf_key, sizeof(buf_key), "text%d", type);
1338 /* Check text key exist */
1339 ret_val = bundle_get_val(b, buf_key);
1340 if (ret_val != NULL) {
1341 /* Remove previous data */
1342 bundle_del(b, buf_key);
1346 bundle_add(b, buf_key, text);
1352 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1354 /* Check key 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, key);
1365 switch ((int)type) {
1366 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1367 /* Remove previous data if exist */
1368 if (noti->b_service_responding != NULL) {
1369 bundle_free(noti->b_service_responding);
1370 noti->b_service_responding = NULL;
1373 /* Save service handle */
1374 if (service_handle != NULL) {
1375 noti->b_service_responding = bundle_dup(service_handle);
1378 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1379 /* Remove previous data if exist */
1380 if (noti->b_service_single_launch != NULL) {
1381 bundle_free(noti->b_service_single_launch);
1382 noti->b_service_single_launch = NULL;
1385 /* Save service handle */
1386 if (service_handle != NULL) {
1387 noti->b_service_single_launch =
1388 bundle_dup(service_handle);
1391 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1392 /* Remove previous data if exist */
1393 if (noti->b_service_multi_launch != NULL) {
1394 bundle_free(noti->b_service_multi_launch);
1395 noti->b_service_multi_launch = NULL;
1398 /* Save service handle */
1399 if (service_handle != NULL) {
1400 noti->b_service_multi_launch =
1401 bundle_dup(service_handle);
1406 return NOTIFICATION_ERROR_NONE;
1409 EXPORT_API notification_error_e notification_get_execute_option(notification_h noti,
1410 notification_execute_type_e type,
1412 bundle **service_handle)
1414 char buf_key[32] = { 0, };
1415 const char *ret_val = NULL;
1416 char *get_str = NULL;
1420 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1423 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1424 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1425 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1429 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1430 b = noti->b_service_responding;
1432 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1433 b = noti->b_service_single_launch;
1435 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1436 b = noti->b_service_multi_launch;
1446 // Get text domain and dir
1447 if (noti->domain == NULL || noti->dir == NULL) {
1448 _notification_get_text_domain(noti);
1452 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1454 /* Check key key exist */
1455 ret_val = bundle_get_val(b, buf_key);
1456 if (ret_val != NULL && noti->domain != NULL
1457 && noti->dir != NULL) {
1458 /* Get application string */
1459 bindtextdomain(noti->domain, noti->dir);
1461 get_str = dgettext(noti->domain, ret_val);
1464 } else if (ret_val != NULL) {
1465 /* Get system string */
1466 get_str = dgettext("sys_string", ret_val);
1470 /* Get basic text */
1471 snprintf(buf_key, sizeof(buf_key), "text%d",
1474 ret_val = bundle_get_val(b, buf_key);
1482 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1483 b = noti->b_service_responding;
1485 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1486 b = noti->b_service_single_launch;
1488 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1489 b = noti->b_service_multi_launch;
1496 if (service_handle != NULL) {
1497 *service_handle = b;
1500 return NOTIFICATION_ERROR_NONE;
1503 EXPORT_API notification_error_e notification_set_property(notification_h noti,
1506 /* Check noti is valid data */
1508 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1512 noti->flags_for_property = flags;
1514 return NOTIFICATION_ERROR_NONE;
1517 EXPORT_API notification_error_e notification_get_property(notification_h noti,
1520 /* Check noti and flags are valid data */
1521 if (noti == NULL || flags == NULL) {
1522 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1526 *flags = noti->flags_for_property;
1528 return NOTIFICATION_ERROR_NONE;
1531 EXPORT_API notification_error_e notification_set_display_applist(notification_h noti,
1534 /* Check noti is valid data */
1536 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1540 noti->display_applist = applist;
1542 return NOTIFICATION_ERROR_NONE;
1545 EXPORT_API notification_error_e notification_get_display_applist(notification_h noti,
1548 /* Check noti and applist are valid data */
1549 if (noti == NULL || applist == NULL) {
1550 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1554 *applist = noti->display_applist;
1556 return NOTIFICATION_ERROR_NONE;
1559 EXPORT_API notification_error_e notification_set_size(notification_h noti,
1562 /* Check noti is valid data */
1564 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1567 /* Save progress size */
1568 noti->progress_size = size;
1570 return NOTIFICATION_ERROR_NONE;
1573 EXPORT_API notification_error_e notification_get_size(notification_h noti,
1576 /* Check noti and size is valid data */
1577 if (noti == NULL || size == NULL) {
1578 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1581 /* Set progress size */
1582 *size = noti->progress_size;
1584 return NOTIFICATION_ERROR_NONE;
1587 EXPORT_API notification_error_e notification_set_progress(notification_h noti,
1590 /* Check noti is valid data */
1592 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1595 /* Save progress percentage */
1596 noti->progress_percentage = percentage;
1598 return NOTIFICATION_ERROR_NONE;
1601 EXPORT_API notification_error_e notification_get_progress(notification_h noti,
1604 /* Check noti and percentage are valid data */
1605 if (noti == NULL || percentage == NULL) {
1606 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1609 /* Set progress percentage */
1610 *percentage = noti->progress_percentage;
1612 return NOTIFICATION_ERROR_NONE;
1615 EXPORT_API notification_error_e notification_set_pkgname(notification_h noti,
1616 const char *pkgname)
1618 /* check noti and pkgname are valid data */
1619 if (noti == NULL || pkgname == NULL) {
1620 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1623 /* Remove previous caller pkgname */
1624 if (noti->caller_pkgname) {
1625 free(noti->caller_pkgname);
1626 noti->caller_pkgname = NULL;
1629 noti->caller_pkgname = strdup(pkgname);
1631 return NOTIFICATION_ERROR_NONE;
1634 EXPORT_API notification_error_e notification_get_pkgname(notification_h noti,
1637 /* Check noti and pkgname are valid data */
1638 if (noti == NULL || pkgname == NULL) {
1639 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1642 /* Get caller pkgname */
1643 if (noti->caller_pkgname) {
1644 *pkgname = noti->caller_pkgname;
1649 return NOTIFICATION_ERROR_NONE;
1652 EXPORT_API notification_error_e notification_set_layout(notification_h noti,
1653 notification_ly_type_e layout)
1655 /* check noti and pkgname are valid data */
1656 if (noti == NULL || (layout < NOTIFICATION_LY_NONE || layout >= NOTIFICATION_LY_MAX)) {
1657 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1660 noti->layout = layout;
1662 return NOTIFICATION_ERROR_NONE;
1665 EXPORT_API notification_error_e notification_get_layout(notification_h noti,
1666 notification_ly_type_e *layout)
1668 /* Check noti and pkgname are valid data */
1669 if (noti == NULL || layout == NULL) {
1670 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1673 *layout = noti->layout;
1675 return NOTIFICATION_ERROR_NONE;
1678 EXPORT_API notification_error_e notification_get_id(notification_h noti,
1679 int *group_id, int *priv_id)
1681 /* check noti is valid data */
1683 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1686 /* Check group_id is valid data */
1689 if (noti->group_id < NOTIFICATION_GROUP_ID_NONE) {
1690 *group_id = NOTIFICATION_GROUP_ID_NONE;
1692 *group_id = noti->group_id;
1696 /* Check priv_id is valid data */
1699 *priv_id = noti->priv_id;
1702 return NOTIFICATION_ERROR_NONE;
1705 EXPORT_API notification_error_e notification_get_type(notification_h noti,
1706 notification_type_e *type)
1708 /* Check noti and type is valid data */
1709 if (noti == NULL || type == NULL) {
1710 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1716 return NOTIFICATION_ERROR_NONE;
1719 EXPORT_API int notification_post(notification_h noti)
1724 /* Check noti is valid data */
1726 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1729 /* Check noti type is valid type */
1730 if (noti->type <= NOTIFICATION_TYPE_NONE
1731 || noti->type >= NOTIFICATION_TYPE_MAX) {
1732 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1735 /* Save insert time */
1736 noti->insert_time = time(NULL);
1738 ret = notification_ipc_request_insert(noti, &id);
1739 if (ret != NOTIFICATION_ERROR_NONE) {
1743 NOTIFICATION_DBG("from master:%d", id);
1745 return NOTIFICATION_ERROR_NONE;
1748 EXPORT_API notification_error_e notification_insert(notification_h noti,
1754 /* Check noti is valid data */
1756 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1759 /* Check noti type is valid type */
1760 if (noti->type <= NOTIFICATION_TYPE_NONE
1761 || noti->type >= NOTIFICATION_TYPE_MAX) {
1762 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1765 /* Save insert time */
1766 noti->insert_time = time(NULL);
1767 ret = notification_ipc_request_insert(noti, &id);
1768 if (ret != NOTIFICATION_ERROR_NONE) {
1772 NOTIFICATION_DBG("from master:%d", id);
1774 /* If priv_id is valid data, set priv_id */
1775 if (priv_id != NULL) {
1776 *priv_id = noti->priv_id;
1779 return NOTIFICATION_ERROR_NONE;
1782 EXPORT_API notification_error_e notification_update(notification_h noti)
1786 /* Check noti is valid data */
1788 /* Update insert time ? */
1789 noti->insert_time = time(NULL);
1790 ret = notification_ipc_request_update(noti);
1791 if (ret != NOTIFICATION_ERROR_NONE) {
1795 ret = notification_ipc_request_refresh();
1796 if (ret != NOTIFICATION_ERROR_NONE) {
1800 return NOTIFICATION_ERROR_NONE;
1803 EXPORT_API notification_error_e notification_update_async(notification_h noti,
1804 void (*result_cb)(int priv_id, int result, void *data), void *user_data)
1808 /* Check noti is valid data */
1810 /* Update insert time ? */
1811 noti->insert_time = time(NULL);
1812 ret = notification_ipc_request_update_async(noti, result_cb, user_data);
1813 if (ret != NOTIFICATION_ERROR_NONE) {
1817 return NOTIFICATION_ERROR_NONE;
1820 EXPORT_API notification_error_e notifiation_clear(notification_type_e type)
1824 ret = notification_ipc_request_delete_multiple(type, NULL);
1825 if (ret != NOTIFICATION_ERROR_NONE) {
1829 return NOTIFICATION_ERROR_NONE;
1832 EXPORT_API notification_error_e notification_delete_all_by_type(const char *pkgname,
1833 notification_type_e type)
1836 char *caller_pkgname = NULL;
1838 if (pkgname == NULL) {
1839 caller_pkgname = _notification_get_pkgname_by_pid();
1841 caller_pkgname = strdup(pkgname);
1844 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
1845 if (ret != NOTIFICATION_ERROR_NONE) {
1846 if (caller_pkgname) {
1847 free(caller_pkgname);
1852 if (caller_pkgname) {
1853 free(caller_pkgname);
1855 return NOTIFICATION_ERROR_NONE;
1858 EXPORT_API notification_error_e notification_delete_by_priv_id(const char *pkgname,
1859 notification_type_e type,
1863 char *caller_pkgname = NULL;
1865 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
1866 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1869 if (pkgname == NULL) {
1870 caller_pkgname = _notification_get_pkgname_by_pid();
1872 caller_pkgname = strdup(pkgname);
1875 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
1876 if (ret != NOTIFICATION_ERROR_NONE) {
1877 if (caller_pkgname) {
1878 free(caller_pkgname);
1883 if (caller_pkgname) {
1884 free(caller_pkgname);
1889 EXPORT_API notification_error_e notification_delete(notification_h noti)
1894 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1897 ret = notification_ipc_request_delete_single(NOTIFICATION_TYPE_NONE, noti->caller_pkgname, noti->priv_id);
1898 if (ret != NOTIFICATION_ERROR_NONE) {
1902 return NOTIFICATION_ERROR_NONE;
1905 EXPORT_API notification_error_e notification_update_progress(notification_h noti,
1909 char *caller_pkgname = NULL;
1910 int input_priv_id = 0;
1911 double input_progress = 0.0;
1913 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
1915 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1917 input_priv_id = noti->priv_id;
1920 input_priv_id = priv_id;
1924 caller_pkgname = _notification_get_pkgname_by_pid();
1926 caller_pkgname = strdup(noti->caller_pkgname);
1929 if (progress < 0.0) {
1930 input_progress = 0.0;
1931 } else if (progress > 1.0) {
1932 input_progress = 1.0;
1934 input_progress = progress;
1937 notification_ongoing_update_progress(caller_pkgname, input_priv_id,
1940 if (caller_pkgname) {
1941 free(caller_pkgname);
1944 return NOTIFICATION_ERROR_NONE;
1947 EXPORT_API notification_error_e notification_update_size(notification_h noti,
1951 char *caller_pkgname = NULL;
1952 int input_priv_id = 0;
1953 double input_size = 0.0;
1955 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
1957 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1959 input_priv_id = noti->priv_id;
1962 input_priv_id = priv_id;
1966 caller_pkgname = _notification_get_pkgname_by_pid();
1968 caller_pkgname = strdup(noti->caller_pkgname);
1977 notification_ongoing_update_size(caller_pkgname, input_priv_id,
1980 if (caller_pkgname) {
1981 free(caller_pkgname);
1984 return NOTIFICATION_ERROR_NONE;
1987 EXPORT_API notification_error_e notification_update_content(notification_h noti,
1989 const char *content)
1991 char *caller_pkgname = NULL;
1992 int input_priv_id = 0;
1994 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
1996 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1998 input_priv_id = noti->priv_id;
2001 input_priv_id = priv_id;
2005 caller_pkgname = _notification_get_pkgname_by_pid();
2007 caller_pkgname = strdup(noti->caller_pkgname);
2010 notification_ongoing_update_content(caller_pkgname, input_priv_id,
2013 if (caller_pkgname) {
2014 free(caller_pkgname);
2017 return NOTIFICATION_ERROR_NONE;
2020 static notification_h _notification_create(notification_type_e type)
2022 notification_h noti = NULL;
2024 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
2025 NOTIFICATION_ERR("INVALID TYPE : %d", type);
2029 noti = (notification_h) calloc(1, sizeof(struct _notification));
2031 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2037 if (type == NOTIFICATION_TYPE_NOTI)
2038 noti->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2039 else if (type == NOTIFICATION_TYPE_ONGOING)
2040 noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
2042 noti->caller_pkgname = _notification_get_pkgname_by_pid();
2043 noti->group_id = NOTIFICATION_GROUP_ID_NONE;
2044 noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
2045 noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
2046 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
2047 noti->led_operation = NOTIFICATION_LED_OP_OFF;
2048 noti->display_applist = NOTIFICATION_DISPLAY_APP_ALL;
2051 * Other fields are already initialized with ZERO.
2056 EXPORT_API notification_h notification_new(notification_type_e type,
2057 int group_id, int priv_id)
2059 return _notification_create(type);
2062 EXPORT_API notification_h notification_create(notification_type_e type)
2064 return _notification_create(type);
2067 EXPORT_API notification_h notification_load(char *pkgname,
2071 notification_h noti = NULL;
2073 noti = (notification_h) calloc(1, sizeof(struct _notification));
2075 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2079 ret = notification_noti_get_by_priv_id(noti, pkgname, priv_id);
2080 if (ret != NOTIFICATION_ERROR_NONE) {
2081 notification_free(noti);
2088 EXPORT_API notification_h notification_load_by_tag(const char *tag)
2091 notification_h noti = NULL;
2092 char *caller_pkgname = NULL;
2095 NOTIFICATION_ERR("Invalid parameter");
2096 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
2100 caller_pkgname = _notification_get_pkgname_by_pid();
2101 if (!caller_pkgname) {
2102 NOTIFICATION_ERR("Failed to get a package name");
2103 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2108 noti = (notification_h) calloc(1, sizeof(struct _notification));
2110 NOTIFICATION_ERR("Failed to alloc a new notification");
2111 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
2112 free(caller_pkgname);
2117 ret = notification_ipc_request_load_noti_by_tag(noti, caller_pkgname, tag);
2119 free(caller_pkgname);
2121 set_last_result(ret);
2123 if (ret != NOTIFICATION_ERROR_NONE) {
2124 notification_free(noti);
2131 EXPORT_API notification_error_e notification_clone(notification_h noti, notification_h *clone)
2133 notification_h new_noti = NULL;
2135 if (noti == NULL || clone == NULL) {
2136 NOTIFICATION_ERR("INVALID PARAMETER.");
2137 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2140 new_noti = (notification_h) calloc(1, sizeof(struct _notification));
2141 if (new_noti == NULL) {
2142 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2143 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
2146 new_noti->type = noti->type;
2147 new_noti->layout = noti->layout;
2149 new_noti->group_id = noti->group_id;
2150 new_noti->internal_group_id = noti->internal_group_id;
2151 new_noti->priv_id = noti->priv_id;
2153 if(noti->caller_pkgname != NULL) {
2154 new_noti->caller_pkgname = strdup(noti->caller_pkgname);
2156 new_noti->caller_pkgname = _notification_get_pkgname_by_pid();
2158 if(noti->launch_pkgname != NULL) {
2159 new_noti->launch_pkgname = strdup(noti->launch_pkgname);
2161 new_noti->launch_pkgname = NULL;
2164 if(noti->args != NULL) {
2165 new_noti->args = bundle_dup(noti->args);
2167 new_noti->args = NULL;
2169 if(noti->group_args != NULL) {
2170 new_noti->group_args = bundle_dup(noti->group_args);
2172 new_noti->group_args = NULL;
2175 if(noti->b_execute_option != NULL) {
2176 new_noti->b_execute_option = bundle_dup(noti->b_execute_option);
2178 new_noti->b_execute_option = NULL;
2180 if(noti->b_service_responding != NULL) {
2181 new_noti->b_service_responding = bundle_dup(noti->b_service_responding);
2183 new_noti->b_service_responding = NULL;
2185 if(noti->b_service_single_launch != NULL) {
2186 new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch);
2188 new_noti->b_service_single_launch = NULL;
2190 if(noti->b_service_multi_launch != NULL) {
2191 new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch);
2193 new_noti->b_service_multi_launch = NULL;
2196 new_noti->sound_type = noti->sound_type;
2197 if(noti->sound_path != NULL) {
2198 new_noti->sound_path = strdup(noti->sound_path);
2200 new_noti->sound_path = NULL;
2202 new_noti->vibration_type = noti->vibration_type;
2203 if(noti->vibration_path != NULL) {
2204 new_noti->vibration_path = strdup(noti->vibration_path);
2206 new_noti->vibration_path = NULL;
2208 new_noti->led_operation = noti->led_operation;
2209 new_noti->led_argb = noti->led_argb;
2210 new_noti->led_on_ms = noti->led_on_ms;
2211 new_noti->led_off_ms = noti->led_off_ms;
2213 if(noti->domain != NULL) {
2214 new_noti->domain = strdup(noti->domain);
2216 new_noti->domain = NULL;
2218 if(noti->dir != NULL) {
2219 new_noti->dir = strdup(noti->dir);
2221 new_noti->dir = NULL;
2224 if(noti->b_text != NULL) {
2225 new_noti->b_text = bundle_dup(noti->b_text);
2227 new_noti->b_text = NULL;
2229 if(noti->b_key != NULL) {
2230 new_noti->b_key = bundle_dup(noti->b_key);
2232 new_noti->b_key = NULL;
2234 if(noti->b_format_args != NULL) {
2235 new_noti->b_format_args = bundle_dup(noti->b_format_args);
2237 new_noti->b_format_args = NULL;
2239 new_noti->num_format_args = noti->num_format_args;
2241 if(noti->b_image_path != NULL) {
2242 new_noti->b_image_path = bundle_dup(noti->b_image_path);
2244 new_noti->b_image_path = NULL;
2247 new_noti->time = noti->time;
2248 new_noti->insert_time = noti->insert_time;
2250 new_noti->flags_for_property = noti->flags_for_property;
2251 new_noti->display_applist = noti->display_applist;
2253 new_noti->progress_size = noti->progress_size;
2254 new_noti->progress_percentage = noti->progress_percentage;
2256 new_noti->app_icon_path = NULL;
2257 new_noti->app_name = NULL;
2258 new_noti->temp_title = NULL;
2259 new_noti->temp_content = NULL;
2263 return NOTIFICATION_ERROR_NONE;
2267 EXPORT_API notification_error_e notification_free(notification_h noti)
2270 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2273 if (noti->caller_pkgname) {
2274 free(noti->caller_pkgname);
2276 if (noti->launch_pkgname) {
2277 free(noti->launch_pkgname);
2280 bundle_free(noti->args);
2282 if (noti->group_args) {
2283 bundle_free(noti->group_args);
2286 if (noti->b_execute_option) {
2287 bundle_free(noti->b_execute_option);
2289 if (noti->b_service_responding) {
2290 bundle_free(noti->b_service_responding);
2292 if (noti->b_service_single_launch) {
2293 bundle_free(noti->b_service_single_launch);
2295 if (noti->b_service_multi_launch) {
2296 bundle_free(noti->b_service_multi_launch);
2299 if (noti->sound_path) {
2300 free(noti->sound_path);
2302 if (noti->vibration_path) {
2303 free(noti->vibration_path);
2314 bundle_free(noti->b_text);
2317 bundle_free(noti->b_key);
2319 if (noti->b_format_args) {
2320 bundle_free(noti->b_format_args);
2323 if (noti->b_image_path) {
2324 bundle_free(noti->b_image_path);
2327 if (noti->app_icon_path) {
2328 free(noti->app_icon_path);
2330 if (noti->app_name) {
2331 free(noti->app_name);
2333 if (noti->temp_title) {
2334 free(noti->temp_title);
2336 if (noti->temp_content) {
2337 free(noti->temp_content);
2342 return NOTIFICATION_ERROR_NONE;
2345 EXPORT_API notification_error_e
2346 notification_resister_changed_cb(void (*changed_cb)
2347 (void *data, notification_type_e type),
2350 notification_cb_list_s *noti_cb_list_new = NULL;
2351 notification_cb_list_s *noti_cb_list = NULL;
2353 if (changed_cb == NULL) {
2354 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2356 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
2357 return NOTIFICATION_ERROR_IO_ERROR;
2361 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
2363 noti_cb_list_new->next = NULL;
2364 noti_cb_list_new->prev = NULL;
2366 noti_cb_list_new->cb_type = NOTIFICATION_CB_NORMAL;
2367 noti_cb_list_new->changed_cb = changed_cb;
2368 noti_cb_list_new->detailed_changed_cb = NULL;
2369 noti_cb_list_new->data = user_data;
2371 if (g_notification_cb_list == NULL) {
2372 g_notification_cb_list = noti_cb_list_new;
2374 noti_cb_list = g_notification_cb_list;
2376 while (noti_cb_list->next != NULL) {
2377 noti_cb_list = noti_cb_list->next;
2380 noti_cb_list->next = noti_cb_list_new;
2381 noti_cb_list_new->prev = noti_cb_list;
2383 return NOTIFICATION_ERROR_NONE;
2386 EXPORT_API notification_error_e
2387 notification_unresister_changed_cb(void (*changed_cb)
2388 (void *data, notification_type_e type))
2390 notification_cb_list_s *noti_cb_list = NULL;
2391 notification_cb_list_s *noti_cb_list_prev = NULL;
2392 notification_cb_list_s *noti_cb_list_next = NULL;
2394 noti_cb_list = g_notification_cb_list;
2396 if (changed_cb == NULL) {
2397 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2399 if (noti_cb_list == NULL) {
2400 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2403 while (noti_cb_list->prev != NULL) {
2404 noti_cb_list = noti_cb_list->prev;
2408 if (noti_cb_list->changed_cb == changed_cb) {
2409 noti_cb_list_prev = noti_cb_list->prev;
2410 noti_cb_list_next = noti_cb_list->next;
2412 if (noti_cb_list_prev == NULL) {
2413 g_notification_cb_list = noti_cb_list_next;
2415 noti_cb_list_prev->next = noti_cb_list_next;
2418 if (noti_cb_list_next == NULL) {
2419 if (noti_cb_list_prev != NULL) {
2420 noti_cb_list_prev->next = NULL;
2423 noti_cb_list_next->prev = noti_cb_list_prev;
2428 if (g_notification_cb_list == NULL)
2429 notification_ipc_monitor_fini();
2431 return NOTIFICATION_ERROR_NONE;
2433 noti_cb_list = noti_cb_list->next;
2434 } while (noti_cb_list != NULL);
2436 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2439 EXPORT_API notification_error_e
2440 notification_register_detailed_changed_cb(
2441 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
2444 notification_cb_list_s *noti_cb_list_new = NULL;
2445 notification_cb_list_s *noti_cb_list = NULL;
2447 if (detailed_changed_cb == NULL) {
2448 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2450 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
2451 return NOTIFICATION_ERROR_IO_ERROR;
2455 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
2457 noti_cb_list_new->next = NULL;
2458 noti_cb_list_new->prev = NULL;
2460 noti_cb_list_new->cb_type = NOTIFICATION_CB_DETAILED;
2461 noti_cb_list_new->changed_cb = NULL;
2462 noti_cb_list_new->detailed_changed_cb = detailed_changed_cb;
2463 noti_cb_list_new->data = user_data;
2465 if (g_notification_cb_list == NULL) {
2466 g_notification_cb_list = noti_cb_list_new;
2468 noti_cb_list = g_notification_cb_list;
2470 while (noti_cb_list->next != NULL) {
2471 noti_cb_list = noti_cb_list->next;
2474 noti_cb_list->next = noti_cb_list_new;
2475 noti_cb_list_new->prev = noti_cb_list;
2477 return NOTIFICATION_ERROR_NONE;
2480 EXPORT_API notification_error_e
2481 notification_unregister_detailed_changed_cb(
2482 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
2485 notification_cb_list_s *noti_cb_list = NULL;
2486 notification_cb_list_s *noti_cb_list_prev = NULL;
2487 notification_cb_list_s *noti_cb_list_next = NULL;
2489 noti_cb_list = g_notification_cb_list;
2491 if (detailed_changed_cb == NULL) {
2492 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2494 if (noti_cb_list == NULL) {
2495 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2498 while (noti_cb_list->prev != NULL) {
2499 noti_cb_list = noti_cb_list->prev;
2503 if (noti_cb_list->detailed_changed_cb == detailed_changed_cb) {
2504 noti_cb_list_prev = noti_cb_list->prev;
2505 noti_cb_list_next = noti_cb_list->next;
2507 if (noti_cb_list_prev == NULL) {
2508 g_notification_cb_list = noti_cb_list_next;
2510 noti_cb_list_prev->next = noti_cb_list_next;
2513 if (noti_cb_list_next == NULL) {
2514 if (noti_cb_list_prev != NULL) {
2515 noti_cb_list_prev->next = NULL;
2518 noti_cb_list_next->prev = noti_cb_list_prev;
2523 if (g_notification_cb_list == NULL)
2524 notification_ipc_monitor_fini();
2526 return NOTIFICATION_ERROR_NONE;
2528 noti_cb_list = noti_cb_list->next;
2529 } while (noti_cb_list != NULL);
2531 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2534 EXPORT_API notification_error_e notification_get_count(notification_type_e type,
2535 const char *pkgname,
2537 int priv_id, int *count)
2542 if (count == NULL) {
2543 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2547 notification_noti_get_count(type, pkgname, group_id, priv_id,
2549 if (ret != NOTIFICATION_ERROR_NONE) {
2553 *count = noti_count;
2555 return NOTIFICATION_ERROR_NONE;
2558 EXPORT_API notification_error_e notification_get_list(notification_type_e type,
2560 notification_list_h *list)
2562 notification_list_h get_list = NULL;
2566 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2569 ret = notification_noti_get_grouping_list(type, count, &get_list);
2570 if (ret != NOTIFICATION_ERROR_NONE) {
2576 return NOTIFICATION_ERROR_NONE;
2579 EXPORT_API notification_error_e
2580 notification_get_grouping_list(notification_type_e type, int count,
2581 notification_list_h * list)
2583 notification_list_h get_list = NULL;
2587 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2590 ret = notification_noti_get_grouping_list(type, count, &get_list);
2591 if (ret != NOTIFICATION_ERROR_NONE) {
2597 return NOTIFICATION_ERROR_NONE;
2600 EXPORT_API notification_error_e notification_get_detail_list(const char *pkgname,
2604 notification_list_h *list)
2606 notification_list_h get_list = NULL;
2610 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2614 notification_noti_get_detail_list(pkgname, group_id, priv_id, count,
2616 if (ret != NOTIFICATION_ERROR_NONE) {
2622 return NOTIFICATION_ERROR_NONE;
2625 EXPORT_API notification_error_e notification_free_list(notification_list_h list)
2627 notification_list_h cur_list = NULL;
2628 notification_h noti = NULL;
2631 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2634 cur_list = notification_list_get_head(list);
2636 while (cur_list != NULL) {
2637 noti = notification_list_get_data(cur_list);
2638 cur_list = notification_list_remove(cur_list, noti);
2640 notification_free(noti);
2643 return NOTIFICATION_ERROR_NONE;
2646 EXPORT_API notification_error_e notification_op_get_data(notification_op *noti_op, notification_op_data_type_e type,
2649 if (noti_op == NULL || data == NULL) {
2650 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2654 case NOTIFICATION_OP_DATA_TYPE:
2655 *((int*)data) = noti_op->type;
2657 case NOTIFICATION_OP_DATA_PRIV_ID:
2658 *((int*)data) = noti_op->priv_id;
2660 case NOTIFICATION_OP_DATA_NOTI:
2661 *((notification_h *)data) = noti_op->noti;
2663 case NOTIFICATION_OP_DATA_EXTRA_INFO_1:
2664 *((int*)data) = noti_op->extra_info_1;
2666 case NOTIFICATION_OP_DATA_EXTRA_INFO_2:
2667 *((int*)data) = noti_op->extra_info_2;
2670 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2674 return NOTIFICATION_ERROR_NONE;
2677 void notification_call_changed_cb(notification_op *op_list, int op_num)
2679 notification_cb_list_s *noti_cb_list = NULL;
2682 if (g_notification_cb_list == NULL) {
2685 noti_cb_list = g_notification_cb_list;
2687 while (noti_cb_list->prev != NULL) {
2688 noti_cb_list = noti_cb_list->prev;
2691 if (op_list == NULL) {
2692 NOTIFICATION_ERR("invalid data");
2696 while (noti_cb_list != NULL) {
2697 if (noti_cb_list->cb_type == NOTIFICATION_CB_NORMAL && noti_cb_list->changed_cb) {
2698 noti_cb_list->changed_cb(noti_cb_list->data,
2699 NOTIFICATION_TYPE_NOTI);
2701 if (noti_cb_list->cb_type == NOTIFICATION_CB_DETAILED && noti_cb_list->detailed_changed_cb) {
2702 noti_cb_list->detailed_changed_cb(noti_cb_list->data,
2703 NOTIFICATION_TYPE_NOTI, op_list, op_num);
2706 noti_cb_list = noti_cb_list->next;
2710 EXPORT_API int notification_is_service_ready(void)
2713 * The notification service is now socket activated so as far
2714 * as clients are concerned it is always ready
2719 EXPORT_API notification_error_e
2720 notification_add_deffered_task(
2721 void (*deffered_task_cb)(void *data), void *user_data)
2723 if (deffered_task_cb == NULL) {
2724 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2727 return notification_ipc_add_deffered_task(deffered_task_cb, user_data);
2730 EXPORT_API notification_error_e
2731 notification_del_deffered_task(
2732 void (*deffered_task_cb)(void *data))
2734 if (deffered_task_cb == NULL) {
2735 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2738 return notification_ipc_del_deffered_task(deffered_task_cb);
2741 /* notification_set_icon will be removed */
2742 EXPORT_API notification_error_e notification_set_icon(notification_h noti,
2743 const char *icon_path)
2745 int ret_err = NOTIFICATION_ERROR_NONE;
2748 notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
2754 /* notification_get_icon will be removed */
2755 EXPORT_API notification_error_e notification_get_icon(notification_h noti,
2758 int ret_err = NOTIFICATION_ERROR_NONE;
2759 char *ret_image_path = NULL;
2762 notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
2765 if (ret_err == NOTIFICATION_ERROR_NONE && icon_path != NULL) {
2766 *icon_path = ret_image_path;
2768 //NOTIFICATION_DBG("Get icon : %s", *icon_path);
2774 EXPORT_API notification_error_e notification_set_title(notification_h noti,
2776 const char *loc_title)
2778 int noti_err = NOTIFICATION_ERROR_NONE;
2780 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
2782 NOTIFICATION_VARIABLE_TYPE_NONE);
2787 EXPORT_API notification_error_e notification_get_title(notification_h noti,
2791 int noti_err = NOTIFICATION_ERROR_NONE;
2792 char *ret_text = NULL;
2795 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
2798 if (title != NULL) {
2802 if (loc_title != NULL) {
2809 EXPORT_API notification_error_e notification_set_content(notification_h noti,
2810 const char *content,
2811 const char *loc_content)
2813 int noti_err = NOTIFICATION_ERROR_NONE;
2815 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
2816 content, loc_content,
2817 NOTIFICATION_VARIABLE_TYPE_NONE);
2822 EXPORT_API notification_error_e notification_get_content(notification_h noti,
2826 int noti_err = NOTIFICATION_ERROR_NONE;
2827 char *ret_text = NULL;
2830 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
2833 if (content != NULL) {
2834 *content = ret_text;
2837 if (loc_content != NULL) {
2838 *loc_content = NULL;
2846 (VCONFKEY_SETAPPL_STATE_TICKER_NOTI_DISPLAY_CONTENT_BOOL, &boolval);
2848 if (ret == -1 || boolval == 0) {
2849 if (content != NULL && noti->default_content != NULL) {
2850 *content = noti->default_content;
2853 if (loc_content != NULL && noti->loc_default_content != NULL) {
2854 *loc_content = noti->loc_default_content;
2860 EXPORT_API notification_error_e notification_set_args(notification_h noti,
2862 bundle * group_args)
2864 if (noti == NULL || args == NULL) {
2865 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2869 bundle_free(noti->args);
2872 noti->args = bundle_dup(args);
2874 if (noti->group_args) {
2875 bundle_free(noti->group_args);
2876 noti->group_args = NULL;
2879 if (group_args != NULL) {
2880 noti->group_args = bundle_dup(group_args);
2883 return NOTIFICATION_ERROR_NONE;
2886 EXPORT_API notification_error_e notification_get_args(notification_h noti,
2888 bundle ** group_args)
2890 if (noti == NULL || args == NULL) {
2891 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2900 if (group_args != NULL && noti->group_args) {
2901 *group_args = noti->group_args;
2904 return NOTIFICATION_ERROR_NONE;
2907 EXPORT_API notification_error_e notification_delete_group_by_group_id(const char *pkgname,
2908 notification_type_e type,
2912 char *caller_pkgname = NULL;
2914 if (pkgname == NULL) {
2915 caller_pkgname = _notification_get_pkgname_by_pid();
2917 caller_pkgname = strdup(pkgname);
2920 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
2921 if (ret != NOTIFICATION_ERROR_NONE) {
2922 if (caller_pkgname) {
2923 free(caller_pkgname);
2928 if (caller_pkgname) {
2929 free(caller_pkgname);
2931 return NOTIFICATION_ERROR_NONE;
2934 EXPORT_API notification_error_e notification_delete_group_by_priv_id(const char *pkgname,
2935 notification_type_e type,
2939 char *caller_pkgname = NULL;
2941 if (pkgname == NULL) {
2942 caller_pkgname = _notification_get_pkgname_by_pid();
2944 caller_pkgname = strdup(pkgname);
2947 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
2948 if (ret != NOTIFICATION_ERROR_NONE) {
2949 if (caller_pkgname) {
2950 free(caller_pkgname);
2955 if (caller_pkgname) {
2956 free(caller_pkgname);
2958 return NOTIFICATION_ERROR_NONE;
2961 EXPORT_API int notification_set_tag(notification_h noti, const char *tag)
2963 /* Check noti is valid data */
2965 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2969 /* save input TAG */
2970 if (noti->tag != NULL) {
2973 noti->tag = strdup(tag);
2976 return NOTIFICATION_ERROR_NONE;
2980 EXPORT_API int notification_get_tag(notification_h noti, const char **tag)
2982 /* Check noti is valid data */
2984 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2987 /* Set sound type */
2989 return NOTIFICATION_ERROR_NONE;
2992 EXPORT_API notification_error_e notification_wait_response(notification_h noti,
2997 bundle *b, *bc = NULL;
3000 int sock_fd, msg_fd;
3002 struct sockaddr_un sock_addr;
3003 char msg_buffer[1024];
3005 struct timeval timeout_tv;
3008 memset(msg_buffer, 0, sizeof(msg_buffer));
3010 /* a response packet *must* have an execute option TYPE_RESPONDING
3011 with an associated bundle.
3012 If its bundle does not already contain a "tid" hint (which
3013 complex applications such as xwalk may overwrite), we will
3014 try to find the TID and set it in the bundle ourselves. */
3015 notification_get_execute_option (noti, NOTIFICATION_EXECUTE_TYPE_RESPONDING,
3019 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3021 tid_c = bundle_get_val(b, "tid");
3022 if (tid_c == NULL) {
3023 tid = syscall(SYS_gettid);
3024 asprintf((char **)&tid_c, "%d", tid);
3026 bundle_add(bc, "tid", tid_c);
3027 notification_set_execute_option (noti, NOTIFICATION_EXECUTE_TYPE_RESPONDING,
3030 notification_update(noti);
3033 sock_fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
3035 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
3037 sock_addr.sun_family = AF_UNIX;
3038 asprintf(&sock_path, "/tmp/.notification-%s", tid_c);
3039 strncpy(sock_addr.sun_path, sock_path, sizeof(sock_addr.sun_path) - 1);
3040 if (bind(sock_fd, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) == -1) {
3043 free((char *)tid_c);
3044 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
3048 timeout_tv.tv_sec = timeout;
3049 timeout_tv.tv_usec = 0;
3050 setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout_tv, sizeof(timeout_tv));
3051 setsockopt(sock_fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout_tv, sizeof(timeout_tv));
3055 msg_fd = accept(sock_fd, NULL, 0);
3057 msg_size = read(msg_fd, msg_buffer, 1024);
3058 } while (msg_size > 0);
3060 resp = strtok(msg_buffer, "\n");
3062 *respi = atoi(resp);
3063 if (respc != NULL) {
3064 resp = strtok(NULL, "\n");
3079 free((char *)tid_c);
3081 return NOTIFICATION_ERROR_NONE;
3084 EXPORT_API notification_error_e notification_send_response(notification_h noti,
3089 notification_h notic;
3091 char *notic_pkgname;
3096 struct sockaddr_un sock_addr;
3099 notification_get_id(noti, NULL, ¬ic_id);
3100 notification_get_pkgname(noti, ¬ic_pkgname);
3101 notic = notification_load(notic_pkgname, notic_id);
3102 notification_get_execute_option (notic, NOTIFICATION_EXECUTE_TYPE_RESPONDING,
3106 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3108 tid_c = bundle_get_val(b, "tid");
3110 return NOTIFICATION_ERROR_INVALID_PARAMETER;
3113 sock_fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
3115 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
3117 sock_addr.sun_family = AF_UNIX;
3118 asprintf(&sock_path, "/tmp/.notification-%d", tid);
3119 strncpy(sock_addr.sun_path, sock_path, sizeof(sock_addr.sun_path) - 1);
3120 if (connect(sock_fd, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) == -1) {
3123 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
3127 asprintf(&msg_buffer, "%d\n%s\n", respi, respc);
3129 asprintf(&msg_buffer, "%d\n", respi);
3130 write(sock_fd, msg_buffer, strlen(msg_buffer) + 1);
3136 return NOTIFICATION_ERROR_NONE;