4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>, Youngsub Ko <ys4610.ko@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
28 #include <dbus/dbus.h>
29 #include <dbus/dbus-glib-lowlevel.h>
34 #include <vconf-keys.h>
37 #include <notification.h>
38 #include <notification_list.h>
39 #include <notification_debug.h>
40 #include <notification_internal.h>
41 #include <notification_noti.h>
42 #include <notification_ongoing.h>
43 #include <notification_group.h>
45 typedef struct _notification_cb_list notification_cb_list_s;
47 typedef enum __notification_cb_type {
48 NOTIFICATION_CB_NORMAL = 1,
49 NOTIFICATION_CB_DETAILED,
50 } _notification_cb_type_e;
52 struct _notification_cb_list {
53 notification_cb_list_s *prev;
54 notification_cb_list_s *next;
56 _notification_cb_type_e cb_type;
57 void (*changed_cb) (void *data, notification_type_e type);
58 void (*detailed_changed_cb) (void *data, notification_type_e type, notification_op *op_list, int num_op);
62 static notification_cb_list_s *g_notification_cb_list = NULL;
63 static DBusConnection *g_dbus_handle;
65 #define NOTI_TEXT_RESULT_LEN 2048
66 #define NOTI_PKGNAME_LEN 512
67 #define NOTI_CHANGED_NOTI "notification_noti_changed"
68 #define NOTI_CHANGED_ONGOING "notification_ontoing_changed"
70 #define NOTI_DBUS_BUS_NAME "org.tizen.libnotification"
71 #define NOTI_DBUS_PATH "/org/tizen/libnotification"
72 #define NOTI_DBUS_INTERFACE "org.tizen.libnotification.signal"
74 static char *_notification_get_pkgname_by_pid(void)
76 char buf[NOTI_PKGNAME_LEN + 1] = { 0, };
77 char pkgname[NOTI_PKGNAME_LEN + 1] = { 0, };
78 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 snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
87 fd = open(buf, O_RDONLY);
92 ret = read(fd, pkgname, sizeof(pkgname) - 1);
98 if (ret > NOTI_PKGNAME_LEN)
99 pkgname[NOTI_PKGNAME_LEN] = '\0';
106 if (strlen(pkgname) <= 0) {
109 return strdup(pkgname);
113 static void _notification_pack_operation_msg(DBusMessageIter *iter, notification_op *op_list, int op_num)
117 if (op_list == NULL) {
120 dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &tmp_op_num);
124 dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &op_num);
125 for (i = 0; i < op_num; i++) {
126 NOTIFICATION_ERR("pack:%d/%d", i, op_num);
127 notification_op *op = op_list + i;
128 dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &(op->type));
129 dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &(op->priv_id));
130 dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &(op->extra_info_1));
131 dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &(op->extra_info_2));
135 static void _notification_unpack_operation_msg(DBusMessageIter *iter, notification_op **op_list, int *op_num)
139 if (iter == NULL || op_list == NULL || op_num == NULL) {
143 dbus_message_iter_get_basic(iter, op_num);
145 int tmp_op_num = *op_num;
147 if (tmp_op_num <= 0) {
153 *op_list = (notification_op*)malloc(sizeof(notification_op) * (tmp_op_num));
155 dbus_message_iter_next(iter);
157 if (*op_list != NULL) {
158 for (i = 0; i < tmp_op_num; i++) {
159 notification_op *op = (*op_list) + i;
160 dbus_message_iter_get_basic(iter, &(op->type));
161 dbus_message_iter_next(iter);
162 dbus_message_iter_get_basic(iter, &(op->priv_id));
163 dbus_message_iter_next(iter);
164 dbus_message_iter_get_basic(iter, &(op->extra_info_1));
165 dbus_message_iter_next(iter);
166 dbus_message_iter_get_basic(iter, &(op->extra_info_2));
167 dbus_message_iter_next(iter);
172 static char *_notification_get_icon(const char *package)
174 ail_appinfo_h handle;
179 ret = ail_package_get_appinfo(package, &handle);
180 if (ret != AIL_ERROR_OK) {
184 ret = ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &str);
185 if (ret != AIL_ERROR_OK) {
186 ail_package_destroy_appinfo(handle);
192 ret = ail_package_destroy_appinfo(handle);
193 if (ret != AIL_ERROR_OK) {
194 NOTIFICATION_ERR("Fail to ail_package_destroy_appinfo");
200 static char *_notification_get_name(const char *package)
202 ail_appinfo_h handle;
207 ret = ail_package_get_appinfo(package, &handle);
208 if (ret != AIL_ERROR_OK) {
212 ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
213 if (ret != AIL_ERROR_OK) {
214 ail_package_destroy_appinfo(handle);
220 ret = ail_package_destroy_appinfo(handle);
221 if (ret != AIL_ERROR_OK) {
222 NOTIFICATION_ERR("Fail to ail_package_destroy_appinfo");
228 static void _notification_get_text_domain(notification_h noti)
230 if (noti->domain != NULL) {
234 if (noti->dir != NULL) {
239 static void _notification_chagned_noti_cb(DBusMessage *message, void *data)
241 notification_cb_list_s *noti_cb_list = NULL;
242 DBusMessageIter iter;
245 notification_op *op_list = NULL;
247 if (g_notification_cb_list == NULL) {
251 noti_cb_list = g_notification_cb_list;
253 while (noti_cb_list->prev != NULL) {
254 noti_cb_list = noti_cb_list->prev;
257 if (message != NULL) {
258 if (dbus_message_iter_init(message, &iter)) {
259 _notification_unpack_operation_msg(&iter, &op_list, &op_num);
260 NOTIFICATION_ERR("operation num:%d", op_num);
264 while (noti_cb_list != NULL) {
265 if (noti_cb_list->cb_type == NOTIFICATION_CB_NORMAL && noti_cb_list->changed_cb) {
266 noti_cb_list->changed_cb(noti_cb_list->data,
267 NOTIFICATION_TYPE_NOTI);
269 if (noti_cb_list->cb_type == NOTIFICATION_CB_DETAILED && noti_cb_list->detailed_changed_cb) {
270 noti_cb_list->detailed_changed_cb(noti_cb_list->data,
271 NOTIFICATION_TYPE_NOTI, op_list, op_num);
274 noti_cb_list = noti_cb_list->next;
277 if (op_list != NULL) {
283 static void _notification_chagned_ongoing_cb(void *data)
285 notification_cb_list_s *noti_cb_list = NULL;
287 if (g_notification_cb_list == NULL) {
291 noti_cb_list = g_notification_cb_list;
293 while (noti_cb_list->prev != NULL) {
294 noti_cb_list = noti_cb_list->prev;
297 while (noti_cb_list != NULL) {
298 if (noti_cb_list->changed_cb) {
299 noti_cb_list->changed_cb(noti_cb_list->data,
300 NOTIFICATION_TYPE_ONGOING);
303 noti_cb_list = noti_cb_list->next;
308 static void _notification_pack_and_send_dbus_message(const char *type, notification_op *op_list , int op_num)
310 DBusConnection *connection = NULL;
311 DBusMessage *message = NULL;
312 DBusMessageIter iter;
318 NOTIFICATION_ERR("type is NULL");
322 dbus_error_init(&err);
323 connection = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
325 NOTIFICATION_ERR("Fail to dbus_bus_get : %s", err.message);
329 message = dbus_message_new_signal(NOTI_DBUS_PATH,
334 NOTIFICATION_ERR("fail to create dbus message");
335 goto release_n_return;
338 if (op_num > 0 && op_list != NULL) {
339 dbus_message_iter_init_append(message, &iter);
340 _notification_pack_operation_msg(&iter, op_list, op_num);
343 ret = dbus_connection_send(connection, message, NULL);
345 NOTIFICATION_ERR("fail to send dbus message : %s", type);
346 goto release_n_return;
349 dbus_connection_flush(connection);
351 NOTIFICATION_DBG("success to emit signal [%s]", type);
354 dbus_error_free(&err);
357 dbus_message_unref(message);
360 dbus_connection_unref(connection);
363 #define SET_DBUS_MESSAGE 30
365 static void _notification_changed(const char *type, notification_op *op_list , int op_num)
371 if (op_num <= SET_DBUS_MESSAGE) {
372 _notification_pack_and_send_dbus_message(type, op_list, op_num);
374 set_total = op_num / SET_DBUS_MESSAGE;
375 set_modular = op_num - (set_total * SET_DBUS_MESSAGE);
377 for (set = 0; set < set_total; set++) {
378 _notification_pack_and_send_dbus_message(type, op_list + (set * SET_DBUS_MESSAGE), SET_DBUS_MESSAGE);
381 if (set_modular > 0) {
382 _notification_pack_and_send_dbus_message(type,
383 op_list + (set_total * SET_DBUS_MESSAGE), set_modular);
388 static DBusHandlerResult _dbus_signal_filter(DBusConnection *conn,
389 DBusMessage *msg, void *user_data)
391 const char *interface = NULL;
393 interface = dbus_message_get_interface(msg);
394 NOTIFICATION_DBG("path : %s", dbus_message_get_path(msg));
395 NOTIFICATION_DBG("interface : %s", interface);
397 if (strcmp(NOTI_DBUS_INTERFACE, interface))
398 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
401 switch (dbus_message_get_type(msg)) {
402 case DBUS_MESSAGE_TYPE_SIGNAL:
403 _notification_chagned_noti_cb(msg, NULL);
404 return DBUS_HANDLER_RESULT_HANDLED;
408 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
411 static DBusConnection *_noti_changed_monitor_init()
414 DBusConnection *conn = NULL;
417 dbus_error_init(&err);
418 conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
420 printf("fail to get bus\n");
423 dbus_connection_setup_with_g_main(conn, NULL);
425 "path='%s',type='signal',interface='%s',member='%s'",
430 dbus_bus_add_match(conn, rule, &err);
431 if (dbus_connection_add_filter(conn,_dbus_signal_filter,
432 NULL, NULL) == FALSE) {
433 NOTIFICATION_ERR("fail to dbus_connection_add_filter");
434 dbus_connection_close(conn);
438 dbus_connection_set_exit_on_disconnect(conn, FALSE);
442 static void _noti_chanaged_monitor_fini()
444 DBusConnection *conn = g_dbus_handle;
449 dbus_connection_remove_filter(conn, _dbus_signal_filter, NULL);
452 "path='%s',type='signal',interface='%s',member='%s'",
456 dbus_bus_remove_match(conn, rule, NULL);
458 dbus_connection_close(conn);
459 g_dbus_handle = NULL;
462 notification_op *_notification_make_basic_op(notification_op_type_e type, int num_op, int *list_priv_id, int num_priv_id)
465 notification_op *op_list = NULL;
471 op_list = (notification_op *)malloc(sizeof(notification_op) * num_op);
472 memset(op_list, 0x0, sizeof(notification_op) * num_op);
474 for (i = 0; i < num_priv_id; i++) {
475 (op_list + i)->type = type;
476 if (list_priv_id != NULL) {
477 (op_list + i)->priv_id = *(list_priv_id + i);
484 /* notification_set_icon will be removed */
485 EXPORT_API notification_error_e notification_set_icon(notification_h noti,
486 const char *icon_path)
488 int ret_err = NOTIFICATION_ERROR_NONE;
491 notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
497 /* notification_get_icon will be removed */
498 EXPORT_API notification_error_e notification_get_icon(notification_h noti,
501 int ret_err = NOTIFICATION_ERROR_NONE;
502 char *ret_image_path = NULL;
505 notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
508 if (ret_err == NOTIFICATION_ERROR_NONE && icon_path != NULL) {
509 *icon_path = ret_image_path;
511 //NOTIFICATION_DBG("Get icon : %s", *icon_path);
517 EXPORT_API notification_error_e notification_set_image(notification_h noti,
518 notification_image_type_e type,
519 const char *image_path)
522 char buf_key[32] = { 0, };
523 const char *ret_val = NULL;
525 /* Check noti and image_path are valid data */
526 if (noti == NULL || image_path == NULL) {
527 return NOTIFICATION_ERROR_INVALID_DATA;
530 /* Check image type is valid type */
531 if (type <= NOTIFICATION_IMAGE_TYPE_NONE
532 || type >= NOTIFICATION_IMAGE_TYPE_MAX) {
533 return NOTIFICATION_ERROR_INVALID_DATA;
536 /* Check image path bundle is exist */
537 if (noti->b_image_path) {
538 /* If image path bundle is exist, store local bundle value */
539 b = noti->b_image_path;
541 /* Set image type to key as char string type */
542 snprintf(buf_key, sizeof(buf_key), "%d", type);
544 /* Get value using key */
545 ret_val = bundle_get_val(b, buf_key);
546 if (ret_val != NULL) {
547 /* If key is exist, remove this value to store new image path */
548 bundle_del(b, buf_key);
551 /* Add new image path with type key */
552 bundle_add(b, buf_key, image_path);
554 /* If image path bundle is not exist, create new one */
557 /* Set image type to key as char string type */
558 snprintf(buf_key, sizeof(buf_key), "%d", type);
560 /* Add new image path with type key */
561 bundle_add(b, buf_key, image_path);
563 /* Save to image path bundle */
564 noti->b_image_path = b;
567 return NOTIFICATION_ERROR_NONE;
570 EXPORT_API notification_error_e notification_get_image(notification_h noti,
571 notification_image_type_e type,
575 char buf_key[32] = { 0, };
576 const char *ret_val = NULL;
577 const char *pkgname = NULL;
579 /* Check noti and image_path is valid data */
580 if (noti == NULL || image_path == NULL) {
581 return NOTIFICATION_ERROR_INVALID_DATA;
584 /* Check image type is valid data */
585 if (type <= NOTIFICATION_IMAGE_TYPE_NONE
586 || type >= NOTIFICATION_IMAGE_TYPE_MAX) {
587 return NOTIFICATION_ERROR_INVALID_DATA;
590 /* Check image path bundle exist */
591 if (noti->b_image_path) {
592 /* If image path bundle exist, store local bundle data */
593 b = noti->b_image_path;
595 /* Set image type to key as char string type */
596 snprintf(buf_key, sizeof(buf_key), "%d", type);
598 /* Get value of key */
599 ret_val = bundle_get_val(b, buf_key);
601 *image_path = (char *)ret_val;
603 /* If image path bundle does not exist, image path is NULL */
607 /* If image path is NULL and type is ICON, icon path set from AIL */
608 /* order : user icon -> launch_pkgname icon -> caller_pkgname icon -> service app icon */
609 if (*image_path == NULL && type == NOTIFICATION_IMAGE_TYPE_ICON) {
610 /* Check App icon path is already set */
611 if (noti->app_icon_path != NULL) {
612 /* image path will be app icon path */
613 *image_path = noti->app_icon_path;
615 /* Get image path using launch_pkgname */
616 if (noti->launch_pkgname != NULL) {
617 noti->app_icon_path =
618 _notification_get_icon(noti->launch_pkgname);
621 /* If app icon path is NULL, get image path using caller_pkgname */
622 if (noti->app_icon_path == NULL
623 && noti->caller_pkgname != NULL) {
624 noti->app_icon_path =
625 _notification_get_icon(noti->caller_pkgname);
628 /* If app icon path is NULL, get image path using service data */
629 if (noti->app_icon_path == NULL
630 && noti->b_service_single_launch != NULL) {
632 appsvc_get_pkgname(noti->b_service_single_launch);
633 if (pkgname != NULL) {
634 noti->app_icon_path =
635 _notification_get_icon(pkgname);
639 *image_path = noti->app_icon_path;
643 return NOTIFICATION_ERROR_NONE;
646 EXPORT_API notification_error_e notification_set_time(notification_h noti,
649 /* Check noti is valid data */
651 return NOTIFICATION_ERROR_INVALID_DATA;
654 if (input_time == 0) {
655 /* If input time is 0, set current time */
656 noti->time = time(NULL);
658 /* save input time */
659 noti->time = input_time;
662 return NOTIFICATION_ERROR_NONE;
665 EXPORT_API notification_error_e notification_get_time(notification_h noti,
668 /* Check noti and time is valid data */
669 if (noti == NULL || ret_time == NULL) {
670 return NOTIFICATION_ERROR_INVALID_DATA;
673 /* Set time infomation */
674 *ret_time = noti->time;
676 return NOTIFICATION_ERROR_NONE;
679 EXPORT_API notification_error_e notification_get_insert_time(notification_h noti,
682 /* Check noti and ret_time is valid data */
683 if (noti == NULL || ret_time == NULL) {
684 return NOTIFICATION_ERROR_INVALID_DATA;
687 /* Set insert time information */
688 *ret_time = noti->insert_time;
690 return NOTIFICATION_ERROR_NONE;
693 EXPORT_API notification_error_e notification_set_title(notification_h noti,
695 const char *loc_title)
697 int noti_err = NOTIFICATION_ERROR_NONE;
699 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
701 NOTIFICATION_VARIABLE_TYPE_NONE);
706 EXPORT_API notification_error_e notification_get_title(notification_h noti,
710 int noti_err = NOTIFICATION_ERROR_NONE;
711 char *ret_text = NULL;
714 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
721 if (loc_title != NULL) {
728 EXPORT_API notification_error_e notification_set_content(notification_h noti,
730 const char *loc_content)
732 int noti_err = NOTIFICATION_ERROR_NONE;
734 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
735 content, loc_content,
736 NOTIFICATION_VARIABLE_TYPE_NONE);
741 EXPORT_API notification_error_e notification_get_content(notification_h noti,
745 int noti_err = NOTIFICATION_ERROR_NONE;
746 char *ret_text = NULL;
749 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
752 if (content != NULL) {
756 if (loc_content != NULL) {
765 (VCONFKEY_SETAPPL_STATE_TICKER_NOTI_DISPLAY_CONTENT_BOOL, &boolval);
767 if (ret == -1 || boolval == 0) {
768 if (content != NULL && noti->default_content != NULL) {
769 *content = noti->default_content;
772 if (loc_content != NULL && noti->loc_default_content != NULL) {
773 *loc_content = noti->loc_default_content;
779 EXPORT_API notification_error_e notification_set_text(notification_h noti,
780 notification_text_type_e type,
786 char buf_key[32] = { 0, };
787 char buf_val[1024] = { 0, };
788 const char *ret_val = NULL;
790 notification_variable_type_e var_type;
792 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
793 int var_value_int = 0;
794 double var_value_double = 0.0;
795 char *var_value_string = NULL;
796 notification_count_pos_type_e var_value_count =
797 NOTIFICATION_COUNT_POS_NONE;
799 /* Check noti is valid data */
801 return NOTIFICATION_ERROR_INVALID_DATA;
804 /* Check text type is valid type */
805 if (type <= NOTIFICATION_TEXT_TYPE_NONE
806 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
807 return NOTIFICATION_ERROR_INVALID_DATA;
810 /* Check text bundle exist */
812 if (noti->b_text != NULL) {
813 /* If text bundle exist, store local bundle data */
816 /* Make type to key as char string */
817 snprintf(buf_key, sizeof(buf_key), "%d", type);
819 /* Get value using type key */
820 ret_val = bundle_get_val(b, buf_key);
821 if (ret_val != NULL) {
822 /* If value exist, remove this to add new value */
823 bundle_del(b, buf_key);
826 snprintf(buf_val, sizeof(buf_val), "%s", text);
828 /* Add new text value */
829 bundle_add(b, buf_key, buf_val);
831 /* If text bundle does not exist, create new one */
834 /* Make type to key as char string */
835 snprintf(buf_key, sizeof(buf_key), "%d", type);
837 snprintf(buf_val, sizeof(buf_val), "%s", text);
839 /* Add new text value */
840 bundle_add(b, buf_key, buf_val);
842 /* Save text bundle */
846 /* Reset if text is NULL */
847 if (noti->b_text != NULL) {
848 /* If text bundle exist, store local bundle data */
851 /* Make type to key as char string */
852 snprintf(buf_key, sizeof(buf_key), "%d", type);
854 /* Get value using type key */
855 ret_val = bundle_get_val(b, buf_key);
856 if (ret_val != NULL) {
857 /* If value exist, remove this */
858 bundle_del(b, buf_key);
863 /* Save key if key is valid data */
865 /* Check key bundle exist */
866 if (noti->b_key != NULL) {
867 /* If key bundle exist, store local bundle data */
870 /* Make type to key as char string */
871 snprintf(buf_key, sizeof(buf_key), "%d", type);
873 /* Get value using type key */
874 ret_val = bundle_get_val(b, buf_key);
875 if (ret_val != NULL) {
876 /* If value exist, remove this to add new value */
877 bundle_del(b, buf_key);
880 snprintf(buf_val, sizeof(buf_val), "%s", key);
882 /* Add new key value */
883 bundle_add(b, buf_key, buf_val);
885 /* If key bundle does not exist, create new one */
888 /* Make type to key as char string */
889 snprintf(buf_key, sizeof(buf_key), "%d", type);
891 snprintf(buf_val, sizeof(buf_val), "%s", key);
893 /* Add new key value */
894 bundle_add(b, buf_key, buf_val);
896 /* Save key bundle */
900 /* Reset if key is NULL */
901 if (noti->b_key != NULL) {
902 /* If key bundle exist, store local bundle data */
905 /* Make type to key as char string */
906 snprintf(buf_key, sizeof(buf_key), "%d", type);
908 /* Get value using type key */
909 ret_val = bundle_get_val(b, buf_key);
910 if (ret_val != NULL) {
911 /* If value exist, remove this */
912 bundle_del(b, buf_key);
917 if (noti->b_format_args != NULL) {
918 b = noti->b_format_args;
923 va_start(var_args, args_type);
925 var_type = args_type;
928 while (var_type != NOTIFICATION_VARIABLE_TYPE_NONE) {
930 snprintf(buf_key, sizeof(buf_key), "%dtype%d", type, num_args);
931 snprintf(buf_val, sizeof(buf_val), "%d", var_type);
933 ret_val = bundle_get_val(b, buf_key);
934 if (ret_val != NULL) {
935 bundle_del(b, buf_key);
938 bundle_add(b, buf_key, buf_val);
941 case NOTIFICATION_VARIABLE_TYPE_INT:
942 var_value_int = va_arg(var_args, int);
945 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
947 snprintf(buf_val, sizeof(buf_val), "%d", var_value_int);
949 ret_val = bundle_get_val(b, buf_key);
950 if (ret_val != NULL) {
951 bundle_del(b, buf_key);
954 bundle_add(b, buf_key, buf_val);
956 case NOTIFICATION_VARIABLE_TYPE_DOUBLE:
957 var_value_double = va_arg(var_args, double);
960 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
962 snprintf(buf_val, sizeof(buf_val), "%.2f",
965 ret_val = bundle_get_val(b, buf_key);
966 if (ret_val != NULL) {
967 bundle_del(b, buf_key);
970 bundle_add(b, buf_key, buf_val);
972 case NOTIFICATION_VARIABLE_TYPE_STRING:
973 var_value_string = va_arg(var_args, char *);
976 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
978 snprintf(buf_val, sizeof(buf_val), "%s",
981 ret_val = bundle_get_val(b, buf_key);
982 if (ret_val != NULL) {
983 bundle_del(b, buf_key);
986 bundle_add(b, buf_key, buf_val);
988 case NOTIFICATION_VARIABLE_TYPE_COUNT:
990 va_arg(var_args, notification_count_pos_type_e);
993 snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
995 snprintf(buf_val, sizeof(buf_val), "%d",
998 ret_val = bundle_get_val(b, buf_key);
999 if (ret_val != NULL) {
1000 bundle_del(b, buf_key);
1003 bundle_add(b, buf_key, buf_val);
1006 NOTIFICATION_ERR("Error. invalid variable type. : %d",
1008 noti_err = NOTIFICATION_ERROR_INVALID_DATA;
1013 var_type = va_arg(var_args, notification_variable_type_e);
1017 if (noti_err == NOTIFICATION_ERROR_NONE) {
1018 noti->num_format_args = num_args;
1020 noti->num_format_args = 0;
1023 snprintf(buf_key, sizeof(buf_key), "num%d", type);
1024 snprintf(buf_val, sizeof(buf_val), "%d", noti->num_format_args);
1026 ret_val = bundle_get_val(b, buf_key);
1027 if (ret_val != NULL) {
1028 bundle_del(b, buf_key);
1031 bundle_add(b, buf_key, buf_val);
1033 noti->b_format_args = b;
1038 EXPORT_API notification_error_e notification_get_text(notification_h noti,
1039 notification_text_type_e type,
1043 char buf_key[32] = { 0, };
1044 const char *ret_val = NULL;
1045 const char *pkgname = NULL;
1046 const char *get_str = NULL;
1047 const char *get_check_type_str = NULL;
1050 notification_text_type_e check_type = NOTIFICATION_TEXT_TYPE_NONE;
1051 int display_option_flag = 0;
1053 char *temp_str = NULL;
1054 char result_str[NOTI_TEXT_RESULT_LEN] = { 0, };
1055 char buf_str[1024] = { 0, };
1057 notification_variable_type_e ret_var_type = 0;
1058 int ret_variable_int = 0;
1059 double ret_variable_double = 0.0;
1061 /* Check noti is valid data */
1062 if (noti == NULL || text == NULL) {
1063 return NOTIFICATION_ERROR_INVALID_DATA;
1066 /* Check text type is valid type */
1067 if (type <= NOTIFICATION_TEXT_TYPE_NONE
1068 || type >= NOTIFICATION_TEXT_TYPE_MAX) {
1069 return NOTIFICATION_ERROR_INVALID_DATA;
1073 if (noti->b_key != NULL) {
1076 /* Get text domain and dir */
1077 _notification_get_text_domain(noti);
1079 snprintf(buf_key, sizeof(buf_key), "%d", type);
1081 ret_val = bundle_get_val(b, buf_key);
1082 if (ret_val != NULL && noti->domain != NULL
1083 && noti->dir != NULL) {
1084 /* Get application string */
1085 bindtextdomain(noti->domain, noti->dir);
1087 get_str = dgettext(noti->domain, ret_val);
1088 } else if (ret_val != NULL) {
1089 /* Get system string */
1090 get_str = dgettext("sys_string", ret_val);
1096 if (get_str == NULL && noti->b_text != NULL) {
1098 /* Get basic text */
1099 snprintf(buf_key, sizeof(buf_key), "%d", type);
1101 get_str = bundle_get_val(b, buf_key);
1106 /* Set display option is off type when option is off, type is noti */
1107 if (get_str != NULL && display_option_flag == 1
1108 && noti->type == NOTIFICATION_TYPE_NOTI) {
1109 if (type == NOTIFICATION_TEXT_TYPE_CONTENT
1110 || type == NOTIFICATION_TEXT_TYPE_GROUP_CONTENT) {
1111 /* Set check_type to option content string */
1112 if (type == NOTIFICATION_TEXT_TYPE_CONTENT) {
1114 NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF;
1115 } else if (type == NOTIFICATION_TEXT_TYPE_GROUP_CONTENT) {
1117 NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF;
1121 if (noti->b_key != NULL) {
1124 /* Get text domain and dir */
1125 _notification_get_text_domain(noti);
1127 snprintf(buf_key, sizeof(buf_key), "%d",
1130 ret_val = bundle_get_val(b, buf_key);
1131 if (ret_val != NULL && noti->domain != NULL
1132 && noti->dir != NULL) {
1133 /* Get application string */
1134 bindtextdomain(noti->domain, noti->dir);
1136 get_check_type_str =
1137 dgettext(noti->domain, ret_val);
1138 } else if (ret_val != NULL) {
1139 /* Get system string */
1140 get_check_type_str =
1141 dgettext("sys_string", ret_val);
1143 get_check_type_str = NULL;
1147 if (get_check_type_str == NULL && noti->b_text != NULL) {
1149 /* Get basic text */
1150 snprintf(buf_key, sizeof(buf_key), "%d",
1153 get_check_type_str = bundle_get_val(b, buf_key);
1157 if (get_check_type_str != NULL) {
1158 /* Replace option off type string */
1159 get_str = get_check_type_str;
1161 /* Set default string */
1163 dgettext("sys_string", "IDS_COM_POP_MISSED_EVENT");
1167 if (get_str != NULL) {
1168 /* Get number format args */
1169 b = noti->b_format_args;
1170 noti->num_format_args = 0;
1173 snprintf(buf_key, sizeof(buf_key), "num%d", check_type);
1174 ret_val = bundle_get_val(b, buf_key);
1175 if (ret_val != NULL) {
1176 noti->num_format_args = atoi(ret_val);
1180 if (noti->num_format_args == 0) {
1181 *text = (char *)get_str;
1183 /* Check first variable is count, LEFT pos */
1184 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
1185 check_type, num_args);
1186 ret_val = bundle_get_val(b, buf_key);
1187 ret_var_type = atoi(ret_val);
1189 if (ret_var_type == NOTIFICATION_VARIABLE_TYPE_COUNT) {
1191 snprintf(buf_key, sizeof(buf_key), "%dvalue%d",
1192 check_type, num_args);
1193 ret_val = bundle_get_val(b, buf_key);
1194 ret_variable_int = atoi(ret_val);
1196 if (ret_variable_int ==
1197 NOTIFICATION_COUNT_POS_LEFT) {
1198 notification_noti_get_count(noti->type,
1199 noti->caller_pkgname,
1203 snprintf(buf_str, sizeof(buf_str),
1204 "%d ", ret_variable_int);
1206 int src_len = strlen(result_str);
1207 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
1209 strncat(result_str, buf_str,
1217 /* Check variable IN pos */
1218 for (temp_str = (char *)get_str; *temp_str != '\0';
1220 if (*temp_str != '%') {
1221 strncat(result_str, temp_str, 1);
1223 if (*(temp_str + 1) == '%') {
1224 strncat(result_str, temp_str,
1226 } else if (*(temp_str + 1) == 'd') {
1228 ret_variable_int = 0;
1232 "%dtype%d", check_type,
1235 bundle_get_val(b, buf_key);
1236 ret_var_type = atoi(ret_val);
1238 NOTIFICATION_VARIABLE_TYPE_COUNT)
1240 /* Get notification count */
1241 notification_noti_get_count
1243 noti->caller_pkgname,
1263 sizeof(buf_str), "%d",
1266 int src_len = strlen(result_str);
1267 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
1269 strncat(result_str, buf_str,
1275 } else if (*(temp_str + 1) == 's') {
1280 check_type, num_args);
1282 bundle_get_val(b, buf_key);
1285 sizeof(buf_str), "%s",
1288 int src_len = strlen(result_str);
1289 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
1291 strncat(result_str, buf_str,
1297 } else if (*(temp_str + 1) == 'f') {
1302 check_type, num_args);
1304 bundle_get_val(b, buf_key);
1305 ret_variable_double =
1311 ret_variable_double);
1313 int src_len = strlen(result_str);
1314 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
1316 strncat(result_str, buf_str,
1327 /* Check last variable is count, LEFT pos */
1328 if (num_args < noti->num_format_args) {
1329 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
1330 check_type, num_args);
1331 ret_val = bundle_get_val(b, buf_key);
1332 ret_var_type = atoi(ret_val);
1334 NOTIFICATION_VARIABLE_TYPE_COUNT) {
1336 snprintf(buf_key, sizeof(buf_key),
1337 "%dvalue%d", check_type,
1339 ret_val = bundle_get_val(b, buf_key);
1340 ret_variable_int = atoi(ret_val);
1342 if (ret_variable_int ==
1343 NOTIFICATION_COUNT_POS_RIGHT) {
1344 notification_noti_get_count
1346 noti->caller_pkgname,
1351 sizeof(buf_str), " %d",
1354 int src_len = strlen(result_str);
1355 int max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
1357 strncat(result_str, buf_str,
1366 switch (check_type) {
1367 case NOTIFICATION_TEXT_TYPE_TITLE:
1368 case NOTIFICATION_TEXT_TYPE_GROUP_TITLE:
1369 if (noti->temp_title != NULL)
1370 free(noti->temp_title);
1372 noti->temp_title = strdup(result_str);
1374 *text = noti->temp_title;
1376 case NOTIFICATION_TEXT_TYPE_CONTENT:
1377 case NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
1378 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT:
1379 case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
1380 if (noti->temp_content !=
1382 free(noti->temp_content);
1384 noti->temp_content = strdup(result_str);
1386 *text = noti->temp_content;
1395 if (check_type == NOTIFICATION_TEXT_TYPE_TITLE
1396 || check_type == NOTIFICATION_TEXT_TYPE_GROUP_TITLE) {
1397 /* Remove app name if exist, because pkgname is changed according to language setting */
1398 if (noti->app_name != NULL) {
1399 free(noti->app_name);
1400 noti->app_name = NULL;
1403 /* First, get app name from launch_pkgname */
1404 if (noti->launch_pkgname != NULL) {
1406 _notification_get_name(noti->
1410 /* Second, get app name from caller_pkgname */
1411 if (noti->app_name == NULL
1412 && noti->caller_pkgname != NULL) {
1414 _notification_get_name(noti->
1418 /* Third, get app name from service data */
1419 if (noti->app_name == NULL
1420 && noti->b_service_single_launch != NULL) {
1422 appsvc_get_pkgname(noti->
1423 b_service_single_launch);
1425 if (pkgname != NULL) {
1427 _notification_get_name(pkgname);
1431 *text = noti->app_name;
1437 return NOTIFICATION_ERROR_NONE;
1440 EXPORT_API notification_error_e notification_set_text_domain(notification_h noti,
1444 /* check noti and domain is valid data */
1445 if (noti == NULL || domain == NULL) {
1446 return NOTIFICATION_ERROR_INVALID_DATA;
1451 /* Remove previous domain */
1455 noti->domain = strdup(domain);
1457 /* Check locale dir */
1459 /* Remove previous locale dir */
1462 /* Copy locale dir */
1463 noti->dir = strdup(dir);
1465 return NOTIFICATION_ERROR_NONE;
1468 EXPORT_API notification_error_e notification_get_text_domain(notification_h noti,
1472 /* Check noti is valid data */
1474 return NOTIFICATION_ERROR_INVALID_DATA;
1478 if (domain != NULL && noti->domain != NULL) {
1479 *domain = noti->domain;
1482 /* Get locale dir */
1483 if (dir != NULL && noti->dir != NULL) {
1487 return NOTIFICATION_ERROR_NONE;
1490 EXPORT_API notification_error_e notification_set_time_to_text(notification_h noti, notification_text_type_e type,
1493 notification_error_e ret = NOTIFICATION_ERROR_NONE;
1494 char buf[256] = { 0, };
1495 char buf_tag[512] = { 0, };
1498 return NOTIFICATION_ERROR_INVALID_DATA;
1501 return NOTIFICATION_ERROR_INVALID_DATA;
1504 snprintf(buf, sizeof(buf), "%lu", time);
1505 ret = notification_noti_set_tag(TAG_TIME, buf, buf_tag, sizeof(buf_tag));
1507 if (ret != NOTIFICATION_ERROR_NONE) {
1511 return notification_set_text(noti, type, buf_tag, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
1514 EXPORT_API notification_error_e notification_get_time_from_text(notification_h noti, notification_text_type_e type,
1517 notification_error_e ret = NOTIFICATION_ERROR_NONE;
1518 char buf[256] = { 0, };
1519 char buf_tag[512] = { 0, };
1522 return NOTIFICATION_ERROR_INVALID_DATA;
1525 return NOTIFICATION_ERROR_INVALID_DATA;
1528 char *ret_text = NULL;
1529 ret = notification_get_text(noti, type, &ret_text);
1531 if (ret != NOTIFICATION_ERROR_NONE || ret_text == NULL) {
1532 return NOTIFICATION_ERROR_INVALID_DATA;
1535 if (notification_noti_get_tag_type(ret_text) == TAG_TYPE_INVALID) {
1536 return NOTIFICATION_ERROR_INVALID_DATA;
1539 char *tag_value = NULL;
1540 tag_value = notification_noti_strip_tag(ret_text);
1541 if (tag_value == NULL) {
1542 return NOTIFICATION_ERROR_INVALID_DATA;
1545 *time = atol(tag_value);
1548 return NOTIFICATION_ERROR_NONE;
1551 EXPORT_API notification_error_e notification_set_sound(notification_h noti,
1552 notification_sound_type_e type,
1555 /* Check noti is valid data */
1557 return NOTIFICATION_ERROR_INVALID_DATA;
1560 /* Check type is valid */
1561 if (type < NOTIFICATION_SOUND_TYPE_NONE
1562 || type >= NOTIFICATION_SOUND_TYPE_MAX) {
1563 return NOTIFICATION_ERROR_INVALID_DATA;
1566 /* Save sound type */
1567 noti->sound_type = type;
1569 /* Save sound path if user data type */
1570 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA && path != NULL) {
1571 if (noti->sound_path != NULL) {
1572 free(noti->sound_path);
1575 noti->sound_path = strdup(path);
1577 if (noti->sound_path != NULL) {
1578 free(noti->sound_path);
1579 noti->sound_path = NULL;
1583 return NOTIFICATION_ERROR_NONE;
1586 EXPORT_API notification_error_e notification_get_sound(notification_h noti,
1587 notification_sound_type_e *type,
1590 /* check noti and type is valid data */
1591 if (noti == NULL || type == NULL) {
1592 return NOTIFICATION_ERROR_INVALID_DATA;
1595 /* Set sound type */
1596 *type = noti->sound_type;
1598 /* Set sound path if user data type */
1599 if (noti->sound_type == NOTIFICATION_SOUND_TYPE_USER_DATA
1601 *path = noti->sound_path;
1604 return NOTIFICATION_ERROR_NONE;
1607 EXPORT_API notification_error_e notification_set_vibration(notification_h noti,
1608 notification_vibration_type_e type,
1611 /* Check noti is valid data */
1613 return NOTIFICATION_ERROR_INVALID_DATA;
1616 /* Check type is valid */
1617 if (type < NOTIFICATION_VIBRATION_TYPE_NONE
1618 || type >= NOTIFICATION_VIBRATION_TYPE_MAX) {
1619 return NOTIFICATION_ERROR_INVALID_DATA;
1622 /* Save vibration type */
1623 noti->vibration_type = type;
1625 /* Save sound path if user data type */
1626 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA && path != NULL) {
1627 if (noti->vibration_path != NULL) {
1628 free(noti->vibration_path);
1631 noti->vibration_path = strdup(path);
1633 if (noti->vibration_path != NULL) {
1634 free(noti->vibration_path);
1635 noti->vibration_path = NULL;
1639 return NOTIFICATION_ERROR_NONE;
1643 EXPORT_API notification_error_e notification_get_vibration(notification_h noti,
1644 notification_vibration_type_e *type,
1647 /* check noti and type is valid data */
1648 if (noti == NULL || type == NULL) {
1649 return NOTIFICATION_ERROR_INVALID_DATA;
1652 /* Set vibration type */
1653 *type = noti->vibration_type;
1655 /* Set sound path if user data type */
1656 if (noti->vibration_type == NOTIFICATION_VIBRATION_TYPE_USER_DATA
1658 *path = noti->vibration_path;
1661 return NOTIFICATION_ERROR_NONE;
1664 EXPORT_API notification_error_e notification_set_led(notification_h noti,
1665 notification_led_op_e operation,
1668 /* Check noti is valid data */
1670 return NOTIFICATION_ERROR_INVALID_DATA;
1673 /* Check operation is valid */
1674 if (operation < NOTIFICATION_LED_OP_OFF
1675 || operation >= NOTIFICATION_LED_OP_MAX) {
1676 return NOTIFICATION_ERROR_INVALID_DATA;
1679 /* Save led operation */
1680 noti->led_operation = operation;
1682 /* Save led argb if operation is turning on LED with custom color */
1683 if (operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR) {
1684 noti->led_argb = led_argb;
1687 return NOTIFICATION_ERROR_NONE;
1690 EXPORT_API notification_error_e notification_get_led(notification_h noti,
1691 notification_led_op_e *operation,
1694 /* check noti and operation is valid data */
1695 if (noti == NULL || operation == NULL) {
1696 return NOTIFICATION_ERROR_INVALID_DATA;
1699 /* Set led operation */
1700 *operation = noti->led_operation;
1702 /* Save led argb if operation is turning on LED with custom color */
1703 if (noti->led_operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR
1704 && led_argb != NULL) {
1705 *led_argb = noti->led_argb;
1708 return NOTIFICATION_ERROR_NONE;
1711 EXPORT_API notification_error_e notification_set_application(notification_h noti,
1712 const char *pkgname)
1714 if (noti == NULL || pkgname == NULL) {
1715 return NOTIFICATION_ERROR_INVALID_DATA;
1718 if (noti->launch_pkgname) {
1719 free(noti->launch_pkgname);
1722 noti->launch_pkgname = strdup(pkgname);
1724 return NOTIFICATION_ERROR_NONE;
1727 EXPORT_API notification_error_e notification_get_application(notification_h noti,
1730 if (noti == NULL || pkgname == NULL) {
1731 return NOTIFICATION_ERROR_INVALID_DATA;
1734 if (noti->launch_pkgname) {
1735 *pkgname = noti->launch_pkgname;
1737 *pkgname = noti->caller_pkgname;
1740 return NOTIFICATION_ERROR_NONE;
1743 EXPORT_API notification_error_e notification_set_args(notification_h noti,
1745 bundle * group_args)
1747 if (noti == NULL || args == NULL) {
1748 return NOTIFICATION_ERROR_INVALID_DATA;
1752 bundle_free(noti->args);
1755 noti->args = bundle_dup(args);
1757 if (noti->group_args) {
1758 bundle_free(noti->group_args);
1759 noti->group_args = NULL;
1762 if (group_args != NULL) {
1763 noti->group_args = bundle_dup(group_args);
1766 return NOTIFICATION_ERROR_NONE;
1769 EXPORT_API notification_error_e notification_get_args(notification_h noti,
1771 bundle ** group_args)
1773 if (noti == NULL || args == NULL) {
1774 return NOTIFICATION_ERROR_INVALID_DATA;
1783 if (group_args != NULL && noti->group_args) {
1784 *group_args = noti->group_args;
1787 return NOTIFICATION_ERROR_NONE;
1790 EXPORT_API notification_error_e notification_set_execute_option(notification_h noti,
1791 notification_execute_type_e type,
1794 bundle *service_handle)
1796 char buf_key[32] = { 0, };
1797 const char *ret_val = NULL;
1801 return NOTIFICATION_ERROR_INVALID_DATA;
1804 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1805 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1806 return NOTIFICATION_ERROR_INVALID_DATA;
1809 /* Create execute option bundle if does not exist */
1810 if (noti->b_execute_option != NULL) {
1811 noti->b_execute_option = bundle_create();
1814 b = noti->b_execute_option;
1819 snprintf(buf_key, sizeof(buf_key), "text%d", type);
1821 /* Check text key exist */
1822 ret_val = bundle_get_val(b, buf_key);
1823 if (ret_val != NULL) {
1824 /* Remove previous data */
1825 bundle_del(b, buf_key);
1829 bundle_add(b, buf_key, text);
1835 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1837 /* Check key key exist */
1838 ret_val = bundle_get_val(b, buf_key);
1839 if (ret_val != NULL) {
1840 /* Remove previous data */
1841 bundle_del(b, buf_key);
1845 bundle_add(b, buf_key, key);
1849 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1850 /* Remove previous data if exist */
1851 if (noti->b_service_responding != NULL) {
1852 bundle_free(noti->b_service_responding);
1853 noti->b_service_responding = NULL;
1856 /* Save service handle */
1857 if (service_handle != NULL) {
1858 noti->b_service_responding = bundle_dup(service_handle);
1861 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1862 /* Remove previous data if exist */
1863 if (noti->b_service_single_launch != NULL) {
1864 bundle_free(noti->b_service_single_launch);
1865 noti->b_service_single_launch = NULL;
1868 /* Save service handle */
1869 if (service_handle != NULL) {
1870 noti->b_service_single_launch =
1871 bundle_dup(service_handle);
1874 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1875 /* Remove previous data if exist */
1876 if (noti->b_service_multi_launch != NULL) {
1877 bundle_free(noti->b_service_multi_launch);
1878 noti->b_service_multi_launch = NULL;
1881 /* Save service handle */
1882 if (service_handle != NULL) {
1883 noti->b_service_multi_launch =
1884 bundle_dup(service_handle);
1889 return NOTIFICATION_ERROR_NONE;
1892 EXPORT_API notification_error_e notification_get_execute_option(notification_h noti,
1893 notification_execute_type_e type,
1895 bundle **service_handle)
1897 char buf_key[32] = { 0, };
1898 const char *ret_val = NULL;
1899 char *get_str = NULL;
1903 return NOTIFICATION_ERROR_INVALID_DATA;
1906 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1907 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1908 return NOTIFICATION_ERROR_INVALID_DATA;
1912 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1913 b = noti->b_service_responding;
1915 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1916 b = noti->b_service_single_launch;
1918 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1919 b = noti->b_service_multi_launch;
1929 // Get text domain and dir
1930 if (noti->domain == NULL || noti->dir == NULL) {
1931 _notification_get_text_domain(noti);
1935 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1937 /* Check key key exist */
1938 ret_val = bundle_get_val(b, buf_key);
1939 if (ret_val != NULL && noti->domain != NULL
1940 && noti->dir != NULL) {
1941 /* Get application string */
1942 bindtextdomain(noti->domain, noti->dir);
1944 get_str = dgettext(noti->domain, ret_val);
1947 } else if (ret_val != NULL) {
1948 /* Get system string */
1949 get_str = dgettext("sys_string", ret_val);
1953 /* Get basic text */
1954 snprintf(buf_key, sizeof(buf_key), "text%d",
1957 ret_val = bundle_get_val(b, buf_key);
1965 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1966 b = noti->b_service_responding;
1968 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1969 b = noti->b_service_single_launch;
1971 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1972 b = noti->b_service_multi_launch;
1979 if (service_handle != NULL) {
1980 *service_handle = b;
1983 return NOTIFICATION_ERROR_NONE;
1986 EXPORT_API notification_error_e notification_set_property(notification_h noti,
1989 /* Check noti is valid data */
1991 return NOTIFICATION_ERROR_INVALID_DATA;
1995 noti->flags_for_property = flags;
1997 return NOTIFICATION_ERROR_NONE;
2000 EXPORT_API notification_error_e notification_get_property(notification_h noti,
2003 /* Check noti and flags are valid data */
2004 if (noti == NULL || flags == NULL) {
2005 return NOTIFICATION_ERROR_INVALID_DATA;
2009 *flags = noti->flags_for_property;
2011 return NOTIFICATION_ERROR_NONE;
2014 EXPORT_API notification_error_e notification_set_display_applist(notification_h noti,
2017 /* Check noti is valid data */
2019 return NOTIFICATION_ERROR_INVALID_DATA;
2023 noti->display_applist = applist;
2025 return NOTIFICATION_ERROR_NONE;
2028 EXPORT_API notification_error_e notification_get_display_applist(notification_h noti,
2031 /* Check noti and applist are valid data */
2032 if (noti == NULL || applist == NULL) {
2033 return NOTIFICATION_ERROR_INVALID_DATA;
2037 *applist = noti->display_applist;
2039 return NOTIFICATION_ERROR_NONE;
2042 EXPORT_API notification_error_e notification_set_size(notification_h noti,
2045 /* Check noti is valid data */
2047 return NOTIFICATION_ERROR_INVALID_DATA;
2050 /* Save progress size */
2051 noti->progress_size = size;
2053 return NOTIFICATION_ERROR_NONE;
2056 EXPORT_API notification_error_e notification_get_size(notification_h noti,
2059 /* Check noti and size is valid data */
2060 if (noti == NULL || size == NULL) {
2061 return NOTIFICATION_ERROR_INVALID_DATA;
2064 /* Set progress size */
2065 *size = noti->progress_size;
2067 return NOTIFICATION_ERROR_NONE;
2070 EXPORT_API notification_error_e notification_set_progress(notification_h noti,
2073 /* Check noti is valid data */
2075 return NOTIFICATION_ERROR_INVALID_DATA;
2078 /* Save progress percentage */
2079 noti->progress_percentage = percentage;
2081 return NOTIFICATION_ERROR_NONE;
2084 EXPORT_API notification_error_e notification_get_progress(notification_h noti,
2087 /* Check noti and percentage are valid data */
2088 if (noti == NULL || percentage == NULL) {
2089 return NOTIFICATION_ERROR_INVALID_DATA;
2092 /* Set progress percentage */
2093 *percentage = noti->progress_percentage;
2095 return NOTIFICATION_ERROR_NONE;
2098 EXPORT_API notification_error_e notification_set_pkgname(notification_h noti,
2099 const char *pkgname)
2101 /* check noti and pkgname are valid data */
2102 if (noti == NULL || pkgname == NULL) {
2103 return NOTIFICATION_ERROR_INVALID_DATA;
2106 /* Remove previous caller pkgname */
2107 if (noti->caller_pkgname) {
2108 free(noti->caller_pkgname);
2109 noti->caller_pkgname = NULL;
2112 noti->caller_pkgname = strdup(pkgname);
2114 return NOTIFICATION_ERROR_NONE;
2117 EXPORT_API notification_error_e notification_get_pkgname(notification_h noti,
2120 /* Check noti and pkgname are valid data */
2121 if (noti == NULL || pkgname == NULL) {
2122 return NOTIFICATION_ERROR_INVALID_DATA;
2125 /* Get caller pkgname */
2126 if (noti->caller_pkgname) {
2127 *pkgname = noti->caller_pkgname;
2132 return NOTIFICATION_ERROR_NONE;
2135 EXPORT_API notification_error_e notification_set_layout(notification_h noti,
2136 notification_ly_type_e layout)
2138 /* check noti and pkgname are valid data */
2139 if (noti == NULL || (layout < NOTIFICATION_LY_NONE || layout >= NOTIFICATION_LY_MAX)) {
2140 return NOTIFICATION_ERROR_INVALID_DATA;
2143 noti->layout = layout;
2145 return NOTIFICATION_ERROR_NONE;
2148 EXPORT_API notification_error_e notification_get_layout(notification_h noti,
2149 notification_ly_type_e *layout)
2151 /* Check noti and pkgname are valid data */
2152 if (noti == NULL || layout == NULL) {
2153 return NOTIFICATION_ERROR_INVALID_DATA;
2156 *layout = noti->layout;
2158 return NOTIFICATION_ERROR_NONE;
2161 EXPORT_API notification_error_e notification_set_badge(const char *pkgname,
2162 int group_id, int count)
2164 char *caller_pkgname = NULL;
2165 int ret = NOTIFICATION_ERROR_NONE;
2167 /* Check count is valid count */
2169 return NOTIFICATION_ERROR_INVALID_DATA;
2173 if (pkgname == NULL) {
2174 caller_pkgname = _notification_get_pkgname_by_pid();
2176 /* Set count into Group DB */
2178 notification_group_set_badge(caller_pkgname, group_id,
2181 if (caller_pkgname != NULL) {
2182 free(caller_pkgname);
2185 /* Set count into Group DB */
2186 ret = notification_group_set_badge(pkgname, group_id, count);
2192 EXPORT_API notification_error_e notification_get_badge(const char *pkgname,
2193 int group_id, int *count)
2195 char *caller_pkgname = NULL;
2196 int ret = NOTIFICATION_ERROR_NONE;
2197 int ret_unread_count = 0;
2200 if (pkgname == NULL) {
2201 caller_pkgname = _notification_get_pkgname_by_pid();
2203 /* Get count from Group DB */
2205 notification_group_get_badge(caller_pkgname, group_id,
2208 if (caller_pkgname != NULL) {
2209 free(caller_pkgname);
2212 /* Get count from Group DB */
2214 notification_group_get_badge(pkgname, group_id,
2218 if (ret != NOTIFICATION_ERROR_NONE) {
2223 if (count != NULL) {
2224 *count = ret_unread_count;
2227 return NOTIFICATION_ERROR_NONE;
2230 EXPORT_API notification_error_e notification_get_id(notification_h noti,
2231 int *group_id, int *priv_id)
2233 /* check noti is valid data */
2235 return NOTIFICATION_ERROR_INVALID_DATA;
2238 /* Check group_id is valid data */
2241 if (noti->group_id < NOTIFICATION_GROUP_ID_NONE) {
2242 *group_id = NOTIFICATION_GROUP_ID_NONE;
2244 *group_id = noti->group_id;
2248 /* Check priv_id is valid data */
2251 *priv_id = noti->priv_id;
2254 return NOTIFICATION_ERROR_NONE;
2257 EXPORT_API notification_error_e notification_get_type(notification_h noti,
2258 notification_type_e *type)
2260 /* Check noti and type is valid data */
2261 if (noti == NULL || type == NULL) {
2262 return NOTIFICATION_ERROR_INVALID_DATA;
2268 return NOTIFICATION_ERROR_NONE;
2271 EXPORT_API notification_error_e notification_insert(notification_h noti,
2276 /* Check noti is vaild data */
2278 return NOTIFICATION_ERROR_INVALID_DATA;
2281 /* Check noti type is valid type */
2282 if (noti->type <= NOTIFICATION_TYPE_NONE
2283 || noti->type >= NOTIFICATION_TYPE_MAX) {
2284 return NOTIFICATION_ERROR_INVALID_DATA;
2287 /* Save insert time */
2288 noti->insert_time = time(NULL);
2290 /* Insert into DB */
2291 ret = notification_noti_insert(noti);
2292 if (ret != NOTIFICATION_ERROR_NONE) {
2296 /* Check disable update on insert property */
2297 if (noti->flags_for_property
2298 & NOTIFICATION_PROP_DISABLE_UPDATE_ON_INSERT) {
2299 /* Disable changed cb */
2301 /* Enable changed cb */
2302 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_INSERT, 1, &(noti->priv_id), 1);
2303 if (noti_op != NULL) {
2304 _notification_changed(NOTI_CHANGED_NOTI, noti_op, 1);
2309 /* If priv_id is valid data, set priv_id */
2310 if (priv_id != NULL) {
2311 *priv_id = noti->priv_id;
2314 return NOTIFICATION_ERROR_NONE;
2317 EXPORT_API notification_error_e notification_update(notification_h noti)
2321 /* Check noti is valid data */
2323 /* Update insert time ? */
2324 noti->insert_time = time(NULL);
2326 ret = notification_noti_update(noti);
2327 if (ret != NOTIFICATION_ERROR_NONE) {
2331 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_UPDATE, 1, &(noti->priv_id), 1);
2332 if (noti_op != NULL) {
2333 _notification_changed(NOTI_CHANGED_NOTI, noti_op, 1);
2337 /* Send changed notification */
2338 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_REFRESH, 1, NULL, 0);
2339 if (noti_op != NULL) {
2340 _notification_changed(NOTI_CHANGED_NOTI, noti_op, 1);
2344 return NOTIFICATION_ERROR_NONE;
2347 EXPORT_API notification_error_e notifiation_clear(notification_type_e type)
2350 int num_deleted = 0;
2351 int *list_deleted = NULL;
2353 /* Delete all notification of type */
2354 ret = notification_noti_delete_all(type, NULL, &num_deleted, &list_deleted);
2355 if (ret != NOTIFICATION_ERROR_NONE) {
2359 /* Send chagned notification */
2361 if (num_deleted > 0 && list_deleted != NULL) {
2362 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_DELETE, num_deleted, list_deleted, num_deleted);
2363 if (noti_op != NULL) {
2364 NOTIFICATION_ERR("noti_op %x", noti_op);
2365 _notification_changed(NOTI_CHANGED_NOTI, noti_op, num_deleted);
2370 if (list_deleted != NULL) {
2374 return NOTIFICATION_ERROR_NONE;
2377 EXPORT_API notification_error_e notification_delete_all_by_type(const char *pkgname,
2378 notification_type_e type)
2381 int num_deleted = 0;
2382 int *list_deleted = NULL;
2383 char *caller_pkgname = NULL;
2385 if (pkgname == NULL) {
2386 caller_pkgname = _notification_get_pkgname_by_pid();
2388 caller_pkgname = strdup(pkgname);
2391 ret = notification_noti_delete_all(type, caller_pkgname, &num_deleted, &list_deleted);
2392 if (ret != NOTIFICATION_ERROR_NONE) {
2393 free(caller_pkgname);
2397 /* Send chagned notification */
2398 if (num_deleted > 0 && list_deleted != NULL) {
2399 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_DELETE, num_deleted, list_deleted, num_deleted);
2400 if (noti_op != NULL) {
2401 _notification_changed(NOTI_CHANGED_NOTI, noti_op, num_deleted);
2405 if (caller_pkgname != NULL) {
2406 free(caller_pkgname);
2407 caller_pkgname = NULL;
2409 if (list_deleted != NULL) {
2411 list_deleted = NULL;
2417 EXPORT_API notification_error_e notification_delete_group_by_group_id(const char *pkgname,
2418 notification_type_e type,
2422 int num_deleted = 0;
2423 int *list_deleted = NULL;
2424 char *caller_pkgname = NULL;
2426 if (group_id < NOTIFICATION_GROUP_ID_NONE) {
2427 return NOTIFICATION_ERROR_INVALID_DATA;
2430 if (pkgname == NULL) {
2431 caller_pkgname = _notification_get_pkgname_by_pid();
2433 caller_pkgname = strdup(pkgname);
2437 notification_noti_delete_group_by_group_id(caller_pkgname,
2438 group_id, &num_deleted, &list_deleted);
2439 if (ret != NOTIFICATION_ERROR_NONE) {
2440 free(caller_pkgname);
2444 if (num_deleted > 0 && list_deleted != NULL) {
2445 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_DELETE, num_deleted, list_deleted, num_deleted);
2446 if (noti_op != NULL) {
2447 _notification_changed(NOTI_CHANGED_NOTI, noti_op, num_deleted);
2452 if (caller_pkgname != NULL) {
2453 free(caller_pkgname);
2454 caller_pkgname = NULL;
2456 if (list_deleted != NULL) {
2458 list_deleted = NULL;
2464 EXPORT_API notification_error_e notification_delete_group_by_priv_id(const char *pkgname,
2465 notification_type_e type,
2469 char *caller_pkgname = NULL;
2471 if (priv_id < NOTIFICATION_PRIV_ID_NONE) {
2472 return NOTIFICATION_ERROR_INVALID_DATA;
2475 if (pkgname == NULL) {
2476 caller_pkgname = _notification_get_pkgname_by_pid();
2478 caller_pkgname = strdup(pkgname);
2482 notification_noti_delete_group_by_priv_id(caller_pkgname, priv_id);
2483 if (ret != NOTIFICATION_ERROR_NONE) {
2484 free(caller_pkgname);
2488 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_DELETE, 1, NULL, 0);
2489 if (noti_op != NULL) {
2490 _notification_changed(NOTI_CHANGED_NOTI, noti_op, 1);
2494 free(caller_pkgname);
2499 EXPORT_API notification_error_e notification_delete_by_priv_id(const char *pkgname,
2500 notification_type_e type,
2504 char *caller_pkgname = NULL;
2506 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2507 return NOTIFICATION_ERROR_INVALID_DATA;
2510 if (pkgname == NULL) {
2511 caller_pkgname = _notification_get_pkgname_by_pid();
2513 caller_pkgname = strdup(pkgname);
2516 ret = notification_noti_delete_by_priv_id(caller_pkgname, priv_id);
2517 if (ret != NOTIFICATION_ERROR_NONE) {
2518 free(caller_pkgname);
2522 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_DELETE, 1, &priv_id, 1);
2523 if (noti_op != NULL) {
2524 _notification_changed(NOTI_CHANGED_NOTI, noti_op, 1);
2528 free(caller_pkgname);
2533 EXPORT_API notification_error_e notification_delete(notification_h noti)
2538 return NOTIFICATION_ERROR_INVALID_DATA;
2542 notification_noti_delete_by_priv_id(noti->caller_pkgname,
2544 if (ret != NOTIFICATION_ERROR_NONE) {
2548 if (noti->flags_for_property
2549 & NOTIFICATION_PROP_DISABLE_UPDATE_ON_DELETE) {
2550 NOTIFICATION_INFO("Disabled update while delete.");
2552 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_DELETE, 1, &(noti->priv_id), 1);
2553 if (noti_op != NULL) {
2554 _notification_changed(NOTI_CHANGED_NOTI, noti_op, 1);
2559 return NOTIFICATION_ERROR_NONE;
2562 EXPORT_API notification_error_e notification_update_progress(notification_h noti,
2566 char *caller_pkgname = NULL;
2567 int input_priv_id = 0;
2568 double input_progress = 0.0;
2570 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2572 return NOTIFICATION_ERROR_INVALID_DATA;
2574 input_priv_id = noti->priv_id;
2577 input_priv_id = priv_id;
2581 caller_pkgname = _notification_get_pkgname_by_pid();
2583 caller_pkgname = strdup(noti->caller_pkgname);
2586 if (progress < 0.0) {
2587 input_progress = 0.0;
2588 } else if (progress > 1.0) {
2589 input_progress = 1.0;
2591 input_progress = progress;
2594 notification_ongoing_update_progress(caller_pkgname, input_priv_id,
2597 if (caller_pkgname) {
2598 free(caller_pkgname);
2601 return NOTIFICATION_ERROR_NONE;
2604 EXPORT_API notification_error_e notification_update_size(notification_h noti,
2608 char *caller_pkgname = NULL;
2609 int input_priv_id = 0;
2610 double input_size = 0.0;
2612 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2614 return NOTIFICATION_ERROR_INVALID_DATA;
2616 input_priv_id = noti->priv_id;
2619 input_priv_id = priv_id;
2623 caller_pkgname = _notification_get_pkgname_by_pid();
2625 caller_pkgname = strdup(noti->caller_pkgname);
2634 notification_ongoing_update_size(caller_pkgname, input_priv_id,
2637 if (caller_pkgname) {
2638 free(caller_pkgname);
2641 return NOTIFICATION_ERROR_NONE;
2644 EXPORT_API notification_error_e notification_update_content(notification_h noti,
2646 const char *content)
2648 char *caller_pkgname = NULL;
2649 int input_priv_id = 0;
2651 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2653 return NOTIFICATION_ERROR_INVALID_DATA;
2655 input_priv_id = noti->priv_id;
2658 input_priv_id = priv_id;
2662 caller_pkgname = _notification_get_pkgname_by_pid();
2664 caller_pkgname = strdup(noti->caller_pkgname);
2667 notification_ongoing_update_content(caller_pkgname, input_priv_id,
2670 if (caller_pkgname) {
2671 free(caller_pkgname);
2674 return NOTIFICATION_ERROR_NONE;
2677 static notification_h _notification_create(notification_type_e type) {
2678 notification_h noti = NULL;
2680 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
2681 NOTIFICATION_ERR("INVALID TYPE : %d", type);
2685 noti = (notification_h) malloc(sizeof(struct _notification));
2687 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2690 memset(noti, 0x00, sizeof(struct _notification));
2694 if (type == NOTIFICATION_TYPE_NOTI)
2695 noti->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2696 else if (type == NOTIFICATION_TYPE_ONGOING)
2697 noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
2699 noti->group_id = NOTIFICATION_GROUP_ID_NONE;
2700 noti->internal_group_id = 0;
2701 noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
2703 noti->caller_pkgname = _notification_get_pkgname_by_pid();
2704 noti->launch_pkgname = NULL;
2706 noti->group_args = NULL;
2708 noti->b_execute_option = NULL;
2709 noti->b_service_responding = NULL;
2710 noti->b_service_single_launch = NULL;
2711 noti->b_service_multi_launch = NULL;
2713 noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
2714 noti->sound_path = NULL;
2716 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
2717 noti->vibration_path = NULL;
2719 noti->led_operation = NOTIFICATION_LED_OP_OFF;
2722 noti->domain = NULL;
2725 noti->b_text = NULL;
2727 noti->b_format_args = NULL;
2728 noti->num_format_args = 0;
2730 noti->b_image_path = NULL;
2733 noti->insert_time = 0;
2735 noti->flags_for_property = 0;
2736 noti->display_applist = NOTIFICATION_DISPLAY_APP_ALL;
2738 noti->progress_size = 0.0;
2739 noti->progress_percentage = 0.0;
2741 noti->app_icon_path = NULL;
2742 noti->app_name = NULL;
2743 noti->temp_title = NULL;
2744 noti->temp_content = NULL;
2749 EXPORT_API notification_h notification_new(notification_type_e type,
2750 int group_id, int priv_id)
2752 return _notification_create(type);
2755 EXPORT_API notification_h notification_create(notification_type_e type)
2757 return _notification_create(type);
2760 EXPORT_API notification_h notification_load(char *pkgname,
2764 notification_h noti = NULL;
2766 noti = (notification_h) malloc(sizeof(struct _notification));
2768 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2771 memset(noti, 0x00, sizeof(struct _notification));
2773 ret = notification_noti_get_by_priv_id(noti, pkgname, priv_id);
2774 if (ret != NOTIFICATION_ERROR_NONE) {
2775 notification_free(noti);
2782 EXPORT_API notification_error_e notification_clone(notification_h noti, notification_h *clone)
2784 notification_h new_noti = NULL;
2786 if (noti == NULL || clone == NULL) {
2787 NOTIFICATION_ERR("INVALID PARAMETER.");
2788 return NOTIFICATION_ERROR_INVALID_DATA;
2791 new_noti = (notification_h) malloc(sizeof(struct _notification));
2792 if (new_noti == NULL) {
2793 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2794 return NOTIFICATION_ERROR_NO_MEMORY;
2796 memset(new_noti, 0x00, sizeof(struct _notification));
2798 new_noti->type = noti->type;
2799 new_noti->layout = noti->layout;
2801 new_noti->group_id = noti->group_id;
2802 new_noti->internal_group_id = noti->internal_group_id;
2803 new_noti->priv_id = noti->priv_id;
2805 if(noti->caller_pkgname != NULL) {
2806 new_noti->caller_pkgname = strdup(noti->caller_pkgname);
2808 new_noti->caller_pkgname = _notification_get_pkgname_by_pid();
2810 if(noti->launch_pkgname != NULL) {
2811 new_noti->launch_pkgname = strdup(noti->launch_pkgname);
2813 new_noti->launch_pkgname = NULL;
2816 if(noti->args != NULL) {
2817 new_noti->args = bundle_dup(noti->args);
2819 new_noti->args = NULL;
2821 if(noti->group_args != NULL) {
2822 new_noti->group_args = bundle_dup(noti->group_args);
2824 new_noti->group_args = NULL;
2827 if(noti->b_execute_option != NULL) {
2828 new_noti->b_execute_option = bundle_dup(noti->b_execute_option);
2830 new_noti->b_execute_option = NULL;
2832 if(noti->b_service_responding != NULL) {
2833 new_noti->b_service_responding = bundle_dup(noti->b_service_responding);
2835 new_noti->b_service_responding = NULL;
2837 if(noti->b_service_single_launch != NULL) {
2838 new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch);
2840 new_noti->b_service_single_launch = NULL;
2842 if(noti->b_service_multi_launch != NULL) {
2843 new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch);
2845 new_noti->b_service_multi_launch = NULL;
2848 new_noti->sound_type = noti->sound_type;
2849 if(noti->sound_path != NULL) {
2850 new_noti->sound_path = strdup(noti->sound_path);
2852 new_noti->sound_path = NULL;
2854 new_noti->vibration_type = noti->vibration_type;
2855 if(noti->vibration_path != NULL) {
2856 new_noti->vibration_path = strdup(noti->vibration_path);
2858 new_noti->vibration_path = NULL;
2860 new_noti->led_operation = noti->led_operation;
2861 new_noti->led_argb = noti->led_argb;
2863 if(noti->domain != NULL) {
2864 new_noti->domain = strdup(noti->domain);
2866 new_noti->domain = NULL;
2868 if(noti->dir != NULL) {
2869 new_noti->dir = strdup(noti->dir);
2871 new_noti->dir = NULL;
2874 if(noti->b_text != NULL) {
2875 new_noti->b_text = bundle_dup(noti->b_text);
2877 new_noti->b_text = NULL;
2879 if(noti->b_key != NULL) {
2880 new_noti->b_key = bundle_dup(noti->b_key);
2882 new_noti->b_key = NULL;
2884 if(noti->b_format_args != NULL) {
2885 new_noti->b_format_args = bundle_dup(noti->b_format_args);
2887 new_noti->b_format_args = NULL;
2889 new_noti->num_format_args = noti->num_format_args;
2891 if(noti->b_image_path != NULL) {
2892 new_noti->b_image_path = bundle_dup(noti->b_image_path);
2894 new_noti->b_image_path = NULL;
2897 new_noti->time = noti->time;
2898 new_noti->insert_time = noti->insert_time;
2900 new_noti->flags_for_property = noti->flags_for_property;
2901 new_noti->display_applist = noti->display_applist;
2903 new_noti->progress_size = noti->progress_size;
2904 new_noti->progress_percentage = noti->progress_percentage;
2906 new_noti->app_icon_path = NULL;
2907 new_noti->app_name = NULL;
2908 new_noti->temp_title = NULL;
2909 new_noti->temp_content = NULL;
2913 return NOTIFICATION_ERROR_NONE;
2917 EXPORT_API notification_error_e notification_free(notification_h noti)
2920 return NOTIFICATION_ERROR_INVALID_DATA;
2923 if (noti->caller_pkgname) {
2924 free(noti->caller_pkgname);
2926 if (noti->launch_pkgname) {
2927 free(noti->launch_pkgname);
2930 bundle_free(noti->args);
2932 if (noti->group_args) {
2933 bundle_free(noti->group_args);
2936 if (noti->b_execute_option) {
2937 bundle_free(noti->b_execute_option);
2939 if (noti->b_service_responding) {
2940 bundle_free(noti->b_service_responding);
2942 if (noti->b_service_single_launch) {
2943 bundle_free(noti->b_service_single_launch);
2945 if (noti->b_service_multi_launch) {
2946 bundle_free(noti->b_service_multi_launch);
2949 if (noti->sound_path) {
2950 free(noti->sound_path);
2952 if (noti->vibration_path) {
2953 free(noti->vibration_path);
2964 bundle_free(noti->b_text);
2967 bundle_free(noti->b_key);
2969 if (noti->b_format_args) {
2970 bundle_free(noti->b_format_args);
2973 if (noti->b_image_path) {
2974 bundle_free(noti->b_image_path);
2977 if (noti->app_icon_path) {
2978 free(noti->app_icon_path);
2980 if (noti->app_name) {
2981 free(noti->app_name);
2983 if (noti->temp_title) {
2984 free(noti->temp_title);
2986 if (noti->temp_content) {
2987 free(noti->temp_content);
2992 return NOTIFICATION_ERROR_NONE;
2995 EXPORT_API notification_error_e
2996 notification_resister_changed_cb(void (*changed_cb)
2997 (void *data, notification_type_e type),
3000 notification_cb_list_s *noti_cb_list_new = NULL;
3001 notification_cb_list_s *noti_cb_list = NULL;
3003 if (!g_dbus_handle) {
3004 g_dbus_handle = _noti_changed_monitor_init();
3006 return NOTIFICATION_ERROR_FROM_DBUS;
3010 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
3012 noti_cb_list_new->next = NULL;
3013 noti_cb_list_new->prev = NULL;
3015 noti_cb_list_new->cb_type = NOTIFICATION_CB_NORMAL;
3016 noti_cb_list_new->changed_cb = changed_cb;
3017 noti_cb_list_new->detailed_changed_cb = NULL;
3018 noti_cb_list_new->data = user_data;
3020 if (g_notification_cb_list == NULL) {
3021 g_notification_cb_list = noti_cb_list_new;
3023 noti_cb_list = g_notification_cb_list;
3025 while (noti_cb_list->next != NULL) {
3026 noti_cb_list = noti_cb_list->next;
3029 noti_cb_list->next = noti_cb_list_new;
3030 noti_cb_list_new->prev = noti_cb_list;
3032 return NOTIFICATION_ERROR_NONE;
3035 EXPORT_API notification_error_e
3036 notification_unresister_changed_cb(void (*changed_cb)
3037 (void *data, notification_type_e type))
3039 notification_cb_list_s *noti_cb_list = NULL;
3040 notification_cb_list_s *noti_cb_list_prev = NULL;
3041 notification_cb_list_s *noti_cb_list_next = NULL;
3043 noti_cb_list = g_notification_cb_list;
3045 if (noti_cb_list == NULL) {
3046 return NOTIFICATION_ERROR_INVALID_DATA;
3049 while (noti_cb_list->prev != NULL) {
3050 noti_cb_list = noti_cb_list->prev;
3054 if (noti_cb_list->changed_cb == changed_cb) {
3055 noti_cb_list_prev = noti_cb_list->prev;
3056 noti_cb_list_next = noti_cb_list->next;
3058 if (noti_cb_list_prev == NULL) {
3059 g_notification_cb_list = noti_cb_list_next;
3061 noti_cb_list_prev->next = noti_cb_list_next;
3064 if (noti_cb_list_next == NULL) {
3065 if (noti_cb_list_prev != NULL) {
3066 noti_cb_list_prev->next = NULL;
3069 noti_cb_list_next->prev = noti_cb_list_prev;
3074 if (g_notification_cb_list == NULL)
3075 _noti_chanaged_monitor_fini();
3077 return NOTIFICATION_ERROR_NONE;
3079 noti_cb_list = noti_cb_list->next;
3080 } while (noti_cb_list != NULL);
3082 return NOTIFICATION_ERROR_INVALID_DATA;
3085 EXPORT_API notification_error_e
3086 notification_register_detailed_changed_cb(
3087 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
3090 notification_cb_list_s *noti_cb_list_new = NULL;
3091 notification_cb_list_s *noti_cb_list = NULL;
3093 if (!g_dbus_handle) {
3094 g_dbus_handle = _noti_changed_monitor_init();
3096 return NOTIFICATION_ERROR_FROM_DBUS;
3100 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
3102 noti_cb_list_new->next = NULL;
3103 noti_cb_list_new->prev = NULL;
3105 noti_cb_list_new->cb_type = NOTIFICATION_CB_DETAILED;
3106 noti_cb_list_new->changed_cb = NULL;
3107 noti_cb_list_new->detailed_changed_cb = detailed_changed_cb;
3108 noti_cb_list_new->data = user_data;
3110 if (g_notification_cb_list == NULL) {
3111 g_notification_cb_list = noti_cb_list_new;
3113 noti_cb_list = g_notification_cb_list;
3115 while (noti_cb_list->next != NULL) {
3116 noti_cb_list = noti_cb_list->next;
3119 noti_cb_list->next = noti_cb_list_new;
3120 noti_cb_list_new->prev = noti_cb_list;
3122 return NOTIFICATION_ERROR_NONE;
3125 EXPORT_API notification_error_e
3126 notification_unregister_detailed_changed_cb(
3127 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
3130 notification_cb_list_s *noti_cb_list = NULL;
3131 notification_cb_list_s *noti_cb_list_prev = NULL;
3132 notification_cb_list_s *noti_cb_list_next = NULL;
3134 noti_cb_list = g_notification_cb_list;
3136 if (noti_cb_list == NULL) {
3137 return NOTIFICATION_ERROR_INVALID_DATA;
3140 while (noti_cb_list->prev != NULL) {
3141 noti_cb_list = noti_cb_list->prev;
3145 if (noti_cb_list->detailed_changed_cb == detailed_changed_cb) {
3146 noti_cb_list_prev = noti_cb_list->prev;
3147 noti_cb_list_next = noti_cb_list->next;
3149 if (noti_cb_list_prev == NULL) {
3150 g_notification_cb_list = noti_cb_list_next;
3152 noti_cb_list_prev->next = noti_cb_list_next;
3155 if (noti_cb_list_next == NULL) {
3156 if (noti_cb_list_prev != NULL) {
3157 noti_cb_list_prev->next = NULL;
3160 noti_cb_list_next->prev = noti_cb_list_prev;
3165 if (g_notification_cb_list == NULL)
3166 _noti_chanaged_monitor_fini();
3168 return NOTIFICATION_ERROR_NONE;
3170 noti_cb_list = noti_cb_list->next;
3171 } while (noti_cb_list != NULL);
3173 return NOTIFICATION_ERROR_INVALID_DATA;
3176 EXPORT_API notification_error_e
3177 notification_resister_badge_changed_cb(void (*changed_cb)
3178 (void *data, const char *pkgname,
3179 int group_id), void *user_data)
3181 // Add DBus signal handler
3182 return NOTIFICATION_ERROR_NONE;
3185 EXPORT_API notification_error_e
3186 notification_unresister_badge_changed_cb(void (*changed_cb)
3187 (void *data, const char *pkgname,
3190 // Del DBus signal handler
3191 return NOTIFICATION_ERROR_NONE;
3194 EXPORT_API notification_error_e notification_get_count(notification_type_e type,
3195 const char *pkgname,
3197 int priv_id, int *count)
3203 notification_noti_get_count(type, pkgname, group_id, priv_id,
3205 if (ret != NOTIFICATION_ERROR_NONE) {
3209 if (count != NULL) {
3210 *count = noti_count;
3213 return NOTIFICATION_ERROR_NONE;
3216 EXPORT_API notification_error_e notification_get_list(notification_type_e type,
3218 notification_list_h *list)
3220 notification_list_h get_list = NULL;
3223 ret = notification_noti_get_grouping_list(type, count, &get_list);
3224 if (ret != NOTIFICATION_ERROR_NONE) {
3230 return NOTIFICATION_ERROR_NONE;
3233 EXPORT_API notification_error_e
3234 notification_get_grouping_list(notification_type_e type, int count,
3235 notification_list_h * list)
3237 notification_list_h get_list = NULL;
3240 ret = notification_noti_get_grouping_list(type, count, &get_list);
3241 if (ret != NOTIFICATION_ERROR_NONE) {
3247 return NOTIFICATION_ERROR_NONE;
3250 EXPORT_API notification_error_e notification_get_detail_list(const char *pkgname,
3254 notification_list_h *list)
3256 notification_list_h get_list = NULL;
3260 notification_noti_get_detail_list(pkgname, group_id, priv_id, count,
3262 if (ret != NOTIFICATION_ERROR_NONE) {
3268 return NOTIFICATION_ERROR_NONE;
3271 EXPORT_API notification_error_e notification_free_list(notification_list_h list)
3273 notification_list_h cur_list = NULL;
3274 notification_h noti = NULL;
3277 NOTIFICATION_ERR("INVALID DATA : list == NULL");
3278 return NOTIFICATION_ERROR_INVALID_DATA;
3281 cur_list = notification_list_get_head(list);
3283 while (cur_list != NULL) {
3284 noti = notification_list_get_data(cur_list);
3285 cur_list = notification_list_remove(cur_list, noti);
3287 notification_free(noti);
3290 return NOTIFICATION_ERROR_NONE;
3293 EXPORT_API notification_error_e notification_op_get_data(notification_op *noti_op, notification_op_data_type_e type,
3296 if (noti_op == NULL) {
3297 return NOTIFICATION_ERROR_INVALID_DATA;
3301 case NOTIFICATION_OP_DATA_TYPE:
3302 *((int*)data) = noti_op->type;
3304 case NOTIFICATION_OP_DATA_PRIV_ID:
3305 *((int*)data) = noti_op->priv_id;
3307 case NOTIFICATION_OP_DATA_EXTRA_INFO_1:
3308 *((int*)data) = noti_op->extra_info_1;
3310 case NOTIFICATION_OP_DATA_EXTRA_INFO_2:
3311 *((int*)data) = noti_op->extra_info_2;
3314 return NOTIFICATION_ERROR_INVALID_DATA;
3318 return NOTIFICATION_ERROR_NONE;