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_application(notification_h noti,
1665 const char *pkgname)
1667 if (noti == NULL || pkgname == NULL) {
1668 return NOTIFICATION_ERROR_INVALID_DATA;
1671 if (noti->launch_pkgname) {
1672 free(noti->launch_pkgname);
1675 noti->launch_pkgname = strdup(pkgname);
1677 return NOTIFICATION_ERROR_NONE;
1680 EXPORT_API notification_error_e notification_get_application(notification_h noti,
1683 if (noti == NULL || pkgname == NULL) {
1684 return NOTIFICATION_ERROR_INVALID_DATA;
1687 if (noti->launch_pkgname) {
1688 *pkgname = noti->launch_pkgname;
1690 *pkgname = noti->caller_pkgname;
1693 return NOTIFICATION_ERROR_NONE;
1696 EXPORT_API notification_error_e notification_set_args(notification_h noti,
1698 bundle * group_args)
1700 if (noti == NULL || args == NULL) {
1701 return NOTIFICATION_ERROR_INVALID_DATA;
1705 bundle_free(noti->args);
1708 noti->args = bundle_dup(args);
1710 if (noti->group_args) {
1711 bundle_free(noti->group_args);
1712 noti->group_args = NULL;
1715 if (group_args != NULL) {
1716 noti->group_args = bundle_dup(group_args);
1719 return NOTIFICATION_ERROR_NONE;
1722 EXPORT_API notification_error_e notification_get_args(notification_h noti,
1724 bundle ** group_args)
1726 if (noti == NULL || args == NULL) {
1727 return NOTIFICATION_ERROR_INVALID_DATA;
1736 if (group_args != NULL && noti->group_args) {
1737 *group_args = noti->group_args;
1740 return NOTIFICATION_ERROR_NONE;
1743 EXPORT_API notification_error_e notification_set_execute_option(notification_h noti,
1744 notification_execute_type_e type,
1747 bundle *service_handle)
1749 char buf_key[32] = { 0, };
1750 const char *ret_val = NULL;
1754 return NOTIFICATION_ERROR_INVALID_DATA;
1757 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1758 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1759 return NOTIFICATION_ERROR_INVALID_DATA;
1762 /* Create execute option bundle if does not exist */
1763 if (noti->b_execute_option != NULL) {
1764 noti->b_execute_option = bundle_create();
1767 b = noti->b_execute_option;
1772 snprintf(buf_key, sizeof(buf_key), "text%d", type);
1774 /* Check text key exist */
1775 ret_val = bundle_get_val(b, buf_key);
1776 if (ret_val != NULL) {
1777 /* Remove previous data */
1778 bundle_del(b, buf_key);
1782 bundle_add(b, buf_key, text);
1788 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1790 /* Check key key exist */
1791 ret_val = bundle_get_val(b, buf_key);
1792 if (ret_val != NULL) {
1793 /* Remove previous data */
1794 bundle_del(b, buf_key);
1798 bundle_add(b, buf_key, key);
1802 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1803 /* Remove previous data if exist */
1804 if (noti->b_service_responding != NULL) {
1805 bundle_free(noti->b_service_responding);
1806 noti->b_service_responding = NULL;
1809 /* Save service handle */
1810 if (service_handle != NULL) {
1811 noti->b_service_responding = bundle_dup(service_handle);
1814 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1815 /* Remove previous data if exist */
1816 if (noti->b_service_single_launch != NULL) {
1817 bundle_free(noti->b_service_single_launch);
1818 noti->b_service_single_launch = NULL;
1821 /* Save service handle */
1822 if (service_handle != NULL) {
1823 noti->b_service_single_launch =
1824 bundle_dup(service_handle);
1827 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1828 /* Remove previous data if exist */
1829 if (noti->b_service_multi_launch != NULL) {
1830 bundle_free(noti->b_service_multi_launch);
1831 noti->b_service_multi_launch = NULL;
1834 /* Save service handle */
1835 if (service_handle != NULL) {
1836 noti->b_service_multi_launch =
1837 bundle_dup(service_handle);
1842 return NOTIFICATION_ERROR_NONE;
1845 EXPORT_API notification_error_e notification_get_execute_option(notification_h noti,
1846 notification_execute_type_e type,
1848 bundle **service_handle)
1850 char buf_key[32] = { 0, };
1851 const char *ret_val = NULL;
1852 char *get_str = NULL;
1856 return NOTIFICATION_ERROR_INVALID_DATA;
1859 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
1860 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
1861 return NOTIFICATION_ERROR_INVALID_DATA;
1865 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1866 b = noti->b_service_responding;
1868 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1869 b = noti->b_service_single_launch;
1871 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1872 b = noti->b_service_multi_launch;
1882 // Get text domain and dir
1883 if (noti->domain == NULL || noti->dir == NULL) {
1884 _notification_get_text_domain(noti);
1888 snprintf(buf_key, sizeof(buf_key), "key%d", type);
1890 /* Check key key exist */
1891 ret_val = bundle_get_val(b, buf_key);
1892 if (ret_val != NULL && noti->domain != NULL
1893 && noti->dir != NULL) {
1894 /* Get application string */
1895 bindtextdomain(noti->domain, noti->dir);
1897 get_str = dgettext(noti->domain, ret_val);
1900 } else if (ret_val != NULL) {
1901 /* Get system string */
1902 get_str = dgettext("sys_string", ret_val);
1906 /* Get basic text */
1907 snprintf(buf_key, sizeof(buf_key), "text%d",
1910 ret_val = bundle_get_val(b, buf_key);
1918 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
1919 b = noti->b_service_responding;
1921 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
1922 b = noti->b_service_single_launch;
1924 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
1925 b = noti->b_service_multi_launch;
1932 if (service_handle != NULL) {
1933 *service_handle = b;
1936 return NOTIFICATION_ERROR_NONE;
1939 EXPORT_API notification_error_e notification_set_property(notification_h noti,
1942 /* Check noti is valid data */
1944 return NOTIFICATION_ERROR_INVALID_DATA;
1948 noti->flags_for_property = flags;
1950 return NOTIFICATION_ERROR_NONE;
1953 EXPORT_API notification_error_e notification_get_property(notification_h noti,
1956 /* Check noti and flags are valid data */
1957 if (noti == NULL || flags == NULL) {
1958 return NOTIFICATION_ERROR_INVALID_DATA;
1962 *flags = noti->flags_for_property;
1964 return NOTIFICATION_ERROR_NONE;
1967 EXPORT_API notification_error_e notification_set_display_applist(notification_h noti,
1970 /* Check noti is valid data */
1972 return NOTIFICATION_ERROR_INVALID_DATA;
1976 noti->display_applist = applist;
1978 return NOTIFICATION_ERROR_NONE;
1981 EXPORT_API notification_error_e notification_get_display_applist(notification_h noti,
1984 /* Check noti and applist are valid data */
1985 if (noti == NULL || applist == NULL) {
1986 return NOTIFICATION_ERROR_INVALID_DATA;
1990 *applist = noti->display_applist;
1992 return NOTIFICATION_ERROR_NONE;
1995 EXPORT_API notification_error_e notification_set_size(notification_h noti,
1998 /* Check noti is valid data */
2000 return NOTIFICATION_ERROR_INVALID_DATA;
2003 /* Save progress size */
2004 noti->progress_size = size;
2006 return NOTIFICATION_ERROR_NONE;
2009 EXPORT_API notification_error_e notification_get_size(notification_h noti,
2012 /* Check noti and size is valid data */
2013 if (noti == NULL || size == NULL) {
2014 return NOTIFICATION_ERROR_INVALID_DATA;
2017 /* Set progress size */
2018 *size = noti->progress_size;
2020 return NOTIFICATION_ERROR_NONE;
2023 EXPORT_API notification_error_e notification_set_progress(notification_h noti,
2026 /* Check noti is valid data */
2028 return NOTIFICATION_ERROR_INVALID_DATA;
2031 /* Save progress percentage */
2032 noti->progress_percentage = percentage;
2034 return NOTIFICATION_ERROR_NONE;
2037 EXPORT_API notification_error_e notification_get_progress(notification_h noti,
2040 /* Check noti and percentage are valid data */
2041 if (noti == NULL || percentage == NULL) {
2042 return NOTIFICATION_ERROR_INVALID_DATA;
2045 /* Set progress percentage */
2046 *percentage = noti->progress_percentage;
2048 return NOTIFICATION_ERROR_NONE;
2051 EXPORT_API notification_error_e notification_set_pkgname(notification_h noti,
2052 const char *pkgname)
2054 /* check noti and pkgname are valid data */
2055 if (noti == NULL || pkgname == NULL) {
2056 return NOTIFICATION_ERROR_INVALID_DATA;
2059 /* Remove previous caller pkgname */
2060 if (noti->caller_pkgname) {
2061 free(noti->caller_pkgname);
2062 noti->caller_pkgname = NULL;
2065 noti->caller_pkgname = strdup(pkgname);
2067 return NOTIFICATION_ERROR_NONE;
2070 EXPORT_API notification_error_e notification_get_pkgname(notification_h noti,
2073 /* Check noti and pkgname are valid data */
2074 if (noti == NULL || pkgname == NULL) {
2075 return NOTIFICATION_ERROR_INVALID_DATA;
2078 /* Get caller pkgname */
2079 if (noti->caller_pkgname) {
2080 *pkgname = noti->caller_pkgname;
2085 return NOTIFICATION_ERROR_NONE;
2088 EXPORT_API notification_error_e notification_set_layout(notification_h noti,
2089 notification_ly_type_e layout)
2091 /* check noti and pkgname are valid data */
2092 if (noti == NULL || (layout < NOTIFICATION_LY_NONE || layout >= NOTIFICATION_LY_MAX)) {
2093 return NOTIFICATION_ERROR_INVALID_DATA;
2096 noti->layout = layout;
2098 return NOTIFICATION_ERROR_NONE;
2101 EXPORT_API notification_error_e notification_get_layout(notification_h noti,
2102 notification_ly_type_e *layout)
2104 /* Check noti and pkgname are valid data */
2105 if (noti == NULL || layout == NULL) {
2106 return NOTIFICATION_ERROR_INVALID_DATA;
2109 *layout = noti->layout;
2111 return NOTIFICATION_ERROR_NONE;
2114 EXPORT_API notification_error_e notification_set_badge(const char *pkgname,
2115 int group_id, int count)
2117 char *caller_pkgname = NULL;
2118 int ret = NOTIFICATION_ERROR_NONE;
2120 /* Check count is valid count */
2122 return NOTIFICATION_ERROR_INVALID_DATA;
2126 if (pkgname == NULL) {
2127 caller_pkgname = _notification_get_pkgname_by_pid();
2129 /* Set count into Group DB */
2131 notification_group_set_badge(caller_pkgname, group_id,
2134 if (caller_pkgname != NULL) {
2135 free(caller_pkgname);
2138 /* Set count into Group DB */
2139 ret = notification_group_set_badge(pkgname, group_id, count);
2145 EXPORT_API notification_error_e notification_get_badge(const char *pkgname,
2146 int group_id, int *count)
2148 char *caller_pkgname = NULL;
2149 int ret = NOTIFICATION_ERROR_NONE;
2150 int ret_unread_count = 0;
2153 if (pkgname == NULL) {
2154 caller_pkgname = _notification_get_pkgname_by_pid();
2156 /* Get count from Group DB */
2158 notification_group_get_badge(caller_pkgname, group_id,
2161 if (caller_pkgname != NULL) {
2162 free(caller_pkgname);
2165 /* Get count from Group DB */
2167 notification_group_get_badge(pkgname, group_id,
2171 if (ret != NOTIFICATION_ERROR_NONE) {
2176 if (count != NULL) {
2177 *count = ret_unread_count;
2180 return NOTIFICATION_ERROR_NONE;
2183 EXPORT_API notification_error_e notification_get_id(notification_h noti,
2184 int *group_id, int *priv_id)
2186 /* check noti is valid data */
2188 return NOTIFICATION_ERROR_INVALID_DATA;
2191 /* Check group_id is valid data */
2194 if (noti->group_id < NOTIFICATION_GROUP_ID_NONE) {
2195 *group_id = NOTIFICATION_GROUP_ID_NONE;
2197 *group_id = noti->group_id;
2201 /* Check priv_id is valid data */
2204 *priv_id = noti->priv_id;
2207 return NOTIFICATION_ERROR_NONE;
2210 EXPORT_API notification_error_e notification_get_type(notification_h noti,
2211 notification_type_e *type)
2213 /* Check noti and type is valid data */
2214 if (noti == NULL || type == NULL) {
2215 return NOTIFICATION_ERROR_INVALID_DATA;
2221 return NOTIFICATION_ERROR_NONE;
2224 EXPORT_API notification_error_e notification_insert(notification_h noti,
2229 /* Check noti is vaild data */
2231 return NOTIFICATION_ERROR_INVALID_DATA;
2234 /* Check noti type is valid type */
2235 if (noti->type <= NOTIFICATION_TYPE_NONE
2236 || noti->type >= NOTIFICATION_TYPE_MAX) {
2237 return NOTIFICATION_ERROR_INVALID_DATA;
2240 /* Save insert time */
2241 noti->insert_time = time(NULL);
2243 /* Insert into DB */
2244 ret = notification_noti_insert(noti);
2245 if (ret != NOTIFICATION_ERROR_NONE) {
2249 /* Check disable update on insert property */
2250 if (noti->flags_for_property
2251 & NOTIFICATION_PROP_DISABLE_UPDATE_ON_INSERT) {
2252 /* Disable changed cb */
2254 /* Enable changed cb */
2255 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_INSERT, 1, &(noti->priv_id), 1);
2256 if (noti_op != NULL) {
2257 _notification_changed(NOTI_CHANGED_NOTI, noti_op, 1);
2262 /* If priv_id is valid data, set priv_id */
2263 if (priv_id != NULL) {
2264 *priv_id = noti->priv_id;
2267 return NOTIFICATION_ERROR_NONE;
2270 EXPORT_API notification_error_e notification_update(notification_h noti)
2274 /* Check noti is valid data */
2276 /* Update insert time ? */
2277 noti->insert_time = time(NULL);
2279 ret = notification_noti_update(noti);
2280 if (ret != NOTIFICATION_ERROR_NONE) {
2284 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_UPDATE, 1, &(noti->priv_id), 1);
2285 if (noti_op != NULL) {
2286 _notification_changed(NOTI_CHANGED_NOTI, noti_op, 1);
2290 /* Send changed notification */
2291 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_REFRESH, 1, NULL, 0);
2292 if (noti_op != NULL) {
2293 _notification_changed(NOTI_CHANGED_NOTI, noti_op, 1);
2297 return NOTIFICATION_ERROR_NONE;
2300 EXPORT_API notification_error_e notifiation_clear(notification_type_e type)
2303 int num_deleted = 0;
2304 int *list_deleted = NULL;
2306 /* Delete all notification of type */
2307 ret = notification_noti_delete_all(type, NULL, &num_deleted, &list_deleted);
2308 if (ret != NOTIFICATION_ERROR_NONE) {
2312 /* Send chagned notification */
2314 if (num_deleted > 0 && list_deleted != NULL) {
2315 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_DELETE, num_deleted, list_deleted, num_deleted);
2316 if (noti_op != NULL) {
2317 NOTIFICATION_ERR("noti_op %x", noti_op);
2318 _notification_changed(NOTI_CHANGED_NOTI, noti_op, num_deleted);
2323 if (list_deleted != NULL) {
2327 return NOTIFICATION_ERROR_NONE;
2330 EXPORT_API notification_error_e notification_delete_all_by_type(const char *pkgname,
2331 notification_type_e type)
2334 int num_deleted = 0;
2335 int *list_deleted = NULL;
2336 char *caller_pkgname = NULL;
2338 if (pkgname == NULL) {
2339 caller_pkgname = _notification_get_pkgname_by_pid();
2341 caller_pkgname = strdup(pkgname);
2344 ret = notification_noti_delete_all(type, caller_pkgname, &num_deleted, &list_deleted);
2345 if (ret != NOTIFICATION_ERROR_NONE) {
2346 free(caller_pkgname);
2350 /* Send chagned notification */
2351 if (num_deleted > 0 && list_deleted != NULL) {
2352 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_DELETE, num_deleted, list_deleted, num_deleted);
2353 if (noti_op != NULL) {
2354 _notification_changed(NOTI_CHANGED_NOTI, noti_op, num_deleted);
2358 if (caller_pkgname != NULL) {
2359 free(caller_pkgname);
2360 caller_pkgname = NULL;
2362 if (list_deleted != NULL) {
2364 list_deleted = NULL;
2370 EXPORT_API notification_error_e notification_delete_group_by_group_id(const char *pkgname,
2371 notification_type_e type,
2375 int num_deleted = 0;
2376 int *list_deleted = NULL;
2377 char *caller_pkgname = NULL;
2379 if (group_id < NOTIFICATION_GROUP_ID_NONE) {
2380 return NOTIFICATION_ERROR_INVALID_DATA;
2383 if (pkgname == NULL) {
2384 caller_pkgname = _notification_get_pkgname_by_pid();
2386 caller_pkgname = strdup(pkgname);
2390 notification_noti_delete_group_by_group_id(caller_pkgname,
2391 group_id, &num_deleted, &list_deleted);
2392 if (ret != NOTIFICATION_ERROR_NONE) {
2393 free(caller_pkgname);
2397 if (num_deleted > 0 && list_deleted != NULL) {
2398 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_DELETE, num_deleted, list_deleted, num_deleted);
2399 if (noti_op != NULL) {
2400 _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_priv_id(const char *pkgname,
2418 notification_type_e type,
2422 char *caller_pkgname = NULL;
2424 if (priv_id < NOTIFICATION_PRIV_ID_NONE) {
2425 return NOTIFICATION_ERROR_INVALID_DATA;
2428 if (pkgname == NULL) {
2429 caller_pkgname = _notification_get_pkgname_by_pid();
2431 caller_pkgname = strdup(pkgname);
2435 notification_noti_delete_group_by_priv_id(caller_pkgname, priv_id);
2436 if (ret != NOTIFICATION_ERROR_NONE) {
2437 free(caller_pkgname);
2441 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_DELETE, 1, NULL, 0);
2442 if (noti_op != NULL) {
2443 _notification_changed(NOTI_CHANGED_NOTI, noti_op, 1);
2447 free(caller_pkgname);
2452 EXPORT_API notification_error_e notification_delete_by_priv_id(const char *pkgname,
2453 notification_type_e type,
2457 char *caller_pkgname = NULL;
2459 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2460 return NOTIFICATION_ERROR_INVALID_DATA;
2463 if (pkgname == NULL) {
2464 caller_pkgname = _notification_get_pkgname_by_pid();
2466 caller_pkgname = strdup(pkgname);
2469 ret = notification_noti_delete_by_priv_id(caller_pkgname, priv_id);
2470 if (ret != NOTIFICATION_ERROR_NONE) {
2471 free(caller_pkgname);
2475 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_DELETE, 1, &priv_id, 1);
2476 if (noti_op != NULL) {
2477 _notification_changed(NOTI_CHANGED_NOTI, noti_op, 1);
2481 free(caller_pkgname);
2486 EXPORT_API notification_error_e notification_delete(notification_h noti)
2491 return NOTIFICATION_ERROR_INVALID_DATA;
2495 notification_noti_delete_by_priv_id(noti->caller_pkgname,
2497 if (ret != NOTIFICATION_ERROR_NONE) {
2501 if (noti->flags_for_property
2502 & NOTIFICATION_PROP_DISABLE_UPDATE_ON_DELETE) {
2503 NOTIFICATION_INFO("Disabled update while delete.");
2505 notification_op *noti_op = _notification_make_basic_op(NOTIFICATION_OP_DELETE, 1, &(noti->priv_id), 1);
2506 if (noti_op != NULL) {
2507 _notification_changed(NOTI_CHANGED_NOTI, noti_op, 1);
2512 return NOTIFICATION_ERROR_NONE;
2515 EXPORT_API notification_error_e notification_update_progress(notification_h noti,
2519 char *caller_pkgname = NULL;
2520 int input_priv_id = 0;
2521 double input_progress = 0.0;
2523 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2525 return NOTIFICATION_ERROR_INVALID_DATA;
2527 input_priv_id = noti->priv_id;
2530 input_priv_id = priv_id;
2534 caller_pkgname = _notification_get_pkgname_by_pid();
2536 caller_pkgname = strdup(noti->caller_pkgname);
2539 if (progress < 0.0) {
2540 input_progress = 0.0;
2541 } else if (progress > 1.0) {
2542 input_progress = 1.0;
2544 input_progress = progress;
2547 notification_ongoing_update_progress(caller_pkgname, input_priv_id,
2550 if (caller_pkgname) {
2551 free(caller_pkgname);
2554 return NOTIFICATION_ERROR_NONE;
2557 EXPORT_API notification_error_e notification_update_size(notification_h noti,
2561 char *caller_pkgname = NULL;
2562 int input_priv_id = 0;
2563 double input_size = 0.0;
2565 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2567 return NOTIFICATION_ERROR_INVALID_DATA;
2569 input_priv_id = noti->priv_id;
2572 input_priv_id = priv_id;
2576 caller_pkgname = _notification_get_pkgname_by_pid();
2578 caller_pkgname = strdup(noti->caller_pkgname);
2587 notification_ongoing_update_size(caller_pkgname, input_priv_id,
2590 if (caller_pkgname) {
2591 free(caller_pkgname);
2594 return NOTIFICATION_ERROR_NONE;
2597 EXPORT_API notification_error_e notification_update_content(notification_h noti,
2599 const char *content)
2601 char *caller_pkgname = NULL;
2602 int input_priv_id = 0;
2604 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
2606 return NOTIFICATION_ERROR_INVALID_DATA;
2608 input_priv_id = noti->priv_id;
2611 input_priv_id = priv_id;
2615 caller_pkgname = _notification_get_pkgname_by_pid();
2617 caller_pkgname = strdup(noti->caller_pkgname);
2620 notification_ongoing_update_content(caller_pkgname, input_priv_id,
2623 if (caller_pkgname) {
2624 free(caller_pkgname);
2627 return NOTIFICATION_ERROR_NONE;
2630 static notification_h _notification_create(notification_type_e type) {
2631 notification_h noti = NULL;
2633 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
2634 NOTIFICATION_ERR("INVALID TYPE : %d", type);
2638 noti = (notification_h) malloc(sizeof(struct _notification));
2640 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2643 memset(noti, 0x00, sizeof(struct _notification));
2647 if (type == NOTIFICATION_TYPE_NOTI)
2648 noti->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
2649 else if (type == NOTIFICATION_TYPE_ONGOING)
2650 noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
2652 noti->group_id = NOTIFICATION_GROUP_ID_NONE;
2653 noti->internal_group_id = 0;
2654 noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
2656 noti->caller_pkgname = _notification_get_pkgname_by_pid();
2657 noti->launch_pkgname = NULL;
2659 noti->group_args = NULL;
2661 noti->b_execute_option = NULL;
2662 noti->b_service_responding = NULL;
2663 noti->b_service_single_launch = NULL;
2664 noti->b_service_multi_launch = NULL;
2666 noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
2667 noti->sound_path = NULL;
2669 noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
2670 noti->vibration_path = NULL;
2672 noti->domain = NULL;
2675 noti->b_text = NULL;
2677 noti->b_format_args = NULL;
2678 noti->num_format_args = 0;
2680 noti->b_image_path = NULL;
2683 noti->insert_time = 0;
2685 noti->flags_for_property = 0;
2686 noti->display_applist = NOTIFICATION_DISPLAY_APP_ALL;
2688 noti->progress_size = 0.0;
2689 noti->progress_percentage = 0.0;
2691 noti->app_icon_path = NULL;
2692 noti->app_name = NULL;
2693 noti->temp_title = NULL;
2694 noti->temp_content = NULL;
2699 EXPORT_API notification_h notification_new(notification_type_e type,
2700 int group_id, int priv_id)
2702 return _notification_create(type);
2705 EXPORT_API notification_h notification_create(notification_type_e type)
2707 return _notification_create(type);
2710 EXPORT_API notification_h notification_load(char *pkgname,
2714 notification_h noti = NULL;
2716 noti = (notification_h) malloc(sizeof(struct _notification));
2718 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2721 memset(noti, 0x00, sizeof(struct _notification));
2723 ret = notification_noti_get_by_priv_id(noti, pkgname, priv_id);
2724 if (ret != NOTIFICATION_ERROR_NONE) {
2725 notification_free(noti);
2732 EXPORT_API notification_error_e notification_clone(notification_h noti, notification_h *clone)
2734 notification_h new_noti = NULL;
2736 if (noti == NULL || clone == NULL) {
2737 NOTIFICATION_ERR("INVALID PARAMETER.");
2738 return NOTIFICATION_ERROR_INVALID_DATA;
2741 new_noti = (notification_h) malloc(sizeof(struct _notification));
2742 if (new_noti == NULL) {
2743 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
2744 return NOTIFICATION_ERROR_NO_MEMORY;
2746 memset(new_noti, 0x00, sizeof(struct _notification));
2748 new_noti->type = noti->type;
2749 new_noti->layout = noti->layout;
2751 new_noti->group_id = noti->group_id;
2752 new_noti->internal_group_id = noti->internal_group_id;
2753 new_noti->priv_id = noti->priv_id;
2755 if(noti->caller_pkgname != NULL) {
2756 new_noti->caller_pkgname = strdup(noti->caller_pkgname);
2758 new_noti->caller_pkgname = _notification_get_pkgname_by_pid();
2760 if(noti->launch_pkgname != NULL) {
2761 new_noti->launch_pkgname = strdup(noti->launch_pkgname);
2763 new_noti->launch_pkgname = NULL;
2766 if(noti->args != NULL) {
2767 new_noti->args = bundle_dup(noti->args);
2769 new_noti->args = NULL;
2771 if(noti->group_args != NULL) {
2772 new_noti->group_args = bundle_dup(noti->group_args);
2774 new_noti->group_args = NULL;
2777 if(noti->b_execute_option != NULL) {
2778 new_noti->b_execute_option = bundle_dup(noti->b_execute_option);
2780 new_noti->b_execute_option = NULL;
2782 if(noti->b_service_responding != NULL) {
2783 new_noti->b_service_responding = bundle_dup(noti->b_service_responding);
2785 new_noti->b_service_responding = NULL;
2787 if(noti->b_service_single_launch != NULL) {
2788 new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch);
2790 new_noti->b_service_single_launch = NULL;
2792 if(noti->b_service_multi_launch != NULL) {
2793 new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch);
2795 new_noti->b_service_multi_launch = NULL;
2798 new_noti->sound_type = noti->sound_type;
2799 if(noti->sound_path != NULL) {
2800 new_noti->sound_path = strdup(noti->sound_path);
2802 new_noti->sound_path = NULL;
2804 new_noti->vibration_type = noti->vibration_type;
2805 if(noti->vibration_path != NULL) {
2806 new_noti->vibration_path = strdup(noti->vibration_path);
2808 new_noti->vibration_path = NULL;
2811 if(noti->domain != NULL) {
2812 new_noti->domain = strdup(noti->domain);
2814 new_noti->domain = NULL;
2816 if(noti->dir != NULL) {
2817 new_noti->dir = strdup(noti->dir);
2819 new_noti->dir = NULL;
2822 if(noti->b_text != NULL) {
2823 new_noti->b_text = bundle_dup(noti->b_text);
2825 new_noti->b_text = NULL;
2827 if(noti->b_key != NULL) {
2828 new_noti->b_key = bundle_dup(noti->b_key);
2830 new_noti->b_key = NULL;
2832 if(noti->b_format_args != NULL) {
2833 new_noti->b_format_args = bundle_dup(noti->b_format_args);
2835 new_noti->b_format_args = NULL;
2837 new_noti->num_format_args = noti->num_format_args;
2839 if(noti->b_image_path != NULL) {
2840 new_noti->b_image_path = bundle_dup(noti->b_image_path);
2842 new_noti->b_image_path = NULL;
2845 new_noti->time = noti->time;
2846 new_noti->insert_time = noti->insert_time;
2848 new_noti->flags_for_property = noti->flags_for_property;
2849 new_noti->display_applist = noti->display_applist;
2851 new_noti->progress_size = noti->progress_size;
2852 new_noti->progress_percentage = noti->progress_percentage;
2854 new_noti->app_icon_path = NULL;
2855 new_noti->app_name = NULL;
2856 new_noti->temp_title = NULL;
2857 new_noti->temp_content = NULL;
2861 return NOTIFICATION_ERROR_NONE;
2865 EXPORT_API notification_error_e notification_free(notification_h noti)
2868 return NOTIFICATION_ERROR_INVALID_DATA;
2871 if (noti->caller_pkgname) {
2872 free(noti->caller_pkgname);
2874 if (noti->launch_pkgname) {
2875 free(noti->launch_pkgname);
2878 bundle_free(noti->args);
2880 if (noti->group_args) {
2881 bundle_free(noti->group_args);
2884 if (noti->b_execute_option) {
2885 bundle_free(noti->b_execute_option);
2887 if (noti->b_service_responding) {
2888 bundle_free(noti->b_service_responding);
2890 if (noti->b_service_single_launch) {
2891 bundle_free(noti->b_service_single_launch);
2893 if (noti->b_service_multi_launch) {
2894 bundle_free(noti->b_service_multi_launch);
2897 if (noti->sound_path) {
2898 free(noti->sound_path);
2900 if (noti->vibration_path) {
2901 free(noti->vibration_path);
2912 bundle_free(noti->b_text);
2915 bundle_free(noti->b_key);
2917 if (noti->b_format_args) {
2918 bundle_free(noti->b_format_args);
2921 if (noti->b_image_path) {
2922 bundle_free(noti->b_image_path);
2925 if (noti->app_icon_path) {
2926 free(noti->app_icon_path);
2928 if (noti->app_name) {
2929 free(noti->app_name);
2931 if (noti->temp_title) {
2932 free(noti->temp_title);
2934 if (noti->temp_content) {
2935 free(noti->temp_content);
2940 return NOTIFICATION_ERROR_NONE;
2943 EXPORT_API notification_error_e
2944 notification_resister_changed_cb(void (*changed_cb)
2945 (void *data, notification_type_e type),
2948 notification_cb_list_s *noti_cb_list_new = NULL;
2949 notification_cb_list_s *noti_cb_list = NULL;
2951 if (!g_dbus_handle) {
2952 g_dbus_handle = _noti_changed_monitor_init();
2954 return NOTIFICATION_ERROR_FROM_DBUS;
2958 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
2960 noti_cb_list_new->next = NULL;
2961 noti_cb_list_new->prev = NULL;
2963 noti_cb_list_new->cb_type = NOTIFICATION_CB_NORMAL;
2964 noti_cb_list_new->changed_cb = changed_cb;
2965 noti_cb_list_new->detailed_changed_cb = NULL;
2966 noti_cb_list_new->data = user_data;
2968 if (g_notification_cb_list == NULL) {
2969 g_notification_cb_list = noti_cb_list_new;
2971 noti_cb_list = g_notification_cb_list;
2973 while (noti_cb_list->next != NULL) {
2974 noti_cb_list = noti_cb_list->next;
2977 noti_cb_list->next = noti_cb_list_new;
2978 noti_cb_list_new->prev = noti_cb_list;
2980 return NOTIFICATION_ERROR_NONE;
2983 EXPORT_API notification_error_e
2984 notification_unresister_changed_cb(void (*changed_cb)
2985 (void *data, notification_type_e type))
2987 notification_cb_list_s *noti_cb_list = NULL;
2988 notification_cb_list_s *noti_cb_list_prev = NULL;
2989 notification_cb_list_s *noti_cb_list_next = NULL;
2991 noti_cb_list = g_notification_cb_list;
2993 if (noti_cb_list == NULL) {
2994 return NOTIFICATION_ERROR_INVALID_DATA;
2997 while (noti_cb_list->prev != NULL) {
2998 noti_cb_list = noti_cb_list->prev;
3002 if (noti_cb_list->changed_cb == changed_cb) {
3003 noti_cb_list_prev = noti_cb_list->prev;
3004 noti_cb_list_next = noti_cb_list->next;
3006 if (noti_cb_list_prev == NULL) {
3007 g_notification_cb_list = noti_cb_list_next;
3009 noti_cb_list_prev->next = noti_cb_list_next;
3012 if (noti_cb_list_next == NULL) {
3013 if (noti_cb_list_prev != NULL) {
3014 noti_cb_list_prev->next = NULL;
3017 noti_cb_list_next->prev = noti_cb_list_prev;
3022 if (g_notification_cb_list == NULL)
3023 _noti_chanaged_monitor_fini();
3025 return NOTIFICATION_ERROR_NONE;
3027 noti_cb_list = noti_cb_list->next;
3028 } while (noti_cb_list != NULL);
3030 return NOTIFICATION_ERROR_INVALID_DATA;
3033 EXPORT_API notification_error_e
3034 notification_register_detailed_changed_cb(
3035 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
3038 notification_cb_list_s *noti_cb_list_new = NULL;
3039 notification_cb_list_s *noti_cb_list = NULL;
3041 if (!g_dbus_handle) {
3042 g_dbus_handle = _noti_changed_monitor_init();
3044 return NOTIFICATION_ERROR_FROM_DBUS;
3048 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
3050 noti_cb_list_new->next = NULL;
3051 noti_cb_list_new->prev = NULL;
3053 noti_cb_list_new->cb_type = NOTIFICATION_CB_DETAILED;
3054 noti_cb_list_new->changed_cb = NULL;
3055 noti_cb_list_new->detailed_changed_cb = detailed_changed_cb;
3056 noti_cb_list_new->data = user_data;
3058 if (g_notification_cb_list == NULL) {
3059 g_notification_cb_list = noti_cb_list_new;
3061 noti_cb_list = g_notification_cb_list;
3063 while (noti_cb_list->next != NULL) {
3064 noti_cb_list = noti_cb_list->next;
3067 noti_cb_list->next = noti_cb_list_new;
3068 noti_cb_list_new->prev = noti_cb_list;
3070 return NOTIFICATION_ERROR_NONE;
3073 EXPORT_API notification_error_e
3074 notification_unregister_detailed_changed_cb(
3075 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
3078 notification_cb_list_s *noti_cb_list = NULL;
3079 notification_cb_list_s *noti_cb_list_prev = NULL;
3080 notification_cb_list_s *noti_cb_list_next = NULL;
3082 noti_cb_list = g_notification_cb_list;
3084 if (noti_cb_list == NULL) {
3085 return NOTIFICATION_ERROR_INVALID_DATA;
3088 while (noti_cb_list->prev != NULL) {
3089 noti_cb_list = noti_cb_list->prev;
3093 if (noti_cb_list->detailed_changed_cb == detailed_changed_cb) {
3094 noti_cb_list_prev = noti_cb_list->prev;
3095 noti_cb_list_next = noti_cb_list->next;
3097 if (noti_cb_list_prev == NULL) {
3098 g_notification_cb_list = noti_cb_list_next;
3100 noti_cb_list_prev->next = noti_cb_list_next;
3103 if (noti_cb_list_next == NULL) {
3104 if (noti_cb_list_prev != NULL) {
3105 noti_cb_list_prev->next = NULL;
3108 noti_cb_list_next->prev = noti_cb_list_prev;
3113 if (g_notification_cb_list == NULL)
3114 _noti_chanaged_monitor_fini();
3116 return NOTIFICATION_ERROR_NONE;
3118 noti_cb_list = noti_cb_list->next;
3119 } while (noti_cb_list != NULL);
3121 return NOTIFICATION_ERROR_INVALID_DATA;
3124 EXPORT_API notification_error_e
3125 notification_resister_badge_changed_cb(void (*changed_cb)
3126 (void *data, const char *pkgname,
3127 int group_id), void *user_data)
3129 // Add DBus signal handler
3130 return NOTIFICATION_ERROR_NONE;
3133 EXPORT_API notification_error_e
3134 notification_unresister_badge_changed_cb(void (*changed_cb)
3135 (void *data, const char *pkgname,
3138 // Del DBus signal handler
3139 return NOTIFICATION_ERROR_NONE;
3142 EXPORT_API notification_error_e notification_get_count(notification_type_e type,
3143 const char *pkgname,
3145 int priv_id, int *count)
3151 notification_noti_get_count(type, pkgname, group_id, priv_id,
3153 if (ret != NOTIFICATION_ERROR_NONE) {
3157 if (count != NULL) {
3158 *count = noti_count;
3161 return NOTIFICATION_ERROR_NONE;
3164 EXPORT_API notification_error_e notification_get_list(notification_type_e type,
3166 notification_list_h *list)
3168 notification_list_h get_list = NULL;
3171 ret = notification_noti_get_grouping_list(type, count, &get_list);
3172 if (ret != NOTIFICATION_ERROR_NONE) {
3178 return NOTIFICATION_ERROR_NONE;
3181 EXPORT_API notification_error_e
3182 notification_get_grouping_list(notification_type_e type, int count,
3183 notification_list_h * list)
3185 notification_list_h get_list = NULL;
3188 ret = notification_noti_get_grouping_list(type, count, &get_list);
3189 if (ret != NOTIFICATION_ERROR_NONE) {
3195 return NOTIFICATION_ERROR_NONE;
3198 EXPORT_API notification_error_e notification_get_detail_list(const char *pkgname,
3202 notification_list_h *list)
3204 notification_list_h get_list = NULL;
3208 notification_noti_get_detail_list(pkgname, group_id, priv_id, count,
3210 if (ret != NOTIFICATION_ERROR_NONE) {
3216 return NOTIFICATION_ERROR_NONE;
3219 EXPORT_API notification_error_e notification_free_list(notification_list_h list)
3221 notification_list_h cur_list = NULL;
3222 notification_h noti = NULL;
3225 NOTIFICATION_ERR("INVALID DATA : list == NULL");
3226 return NOTIFICATION_ERROR_INVALID_DATA;
3229 cur_list = notification_list_get_head(list);
3231 while (cur_list != NULL) {
3232 noti = notification_list_get_data(cur_list);
3233 cur_list = notification_list_remove(cur_list, noti);
3235 notification_free(noti);
3238 return NOTIFICATION_ERROR_NONE;
3241 EXPORT_API notification_error_e notification_op_get_data(notification_op *noti_op, notification_op_data_type_e type,
3244 if (noti_op == NULL) {
3245 return NOTIFICATION_ERROR_INVALID_DATA;
3249 case NOTIFICATION_OP_DATA_TYPE:
3250 *((int*)data) = noti_op->type;
3252 case NOTIFICATION_OP_DATA_PRIV_ID:
3253 *((int*)data) = noti_op->priv_id;
3255 case NOTIFICATION_OP_DATA_EXTRA_INFO_1:
3256 *((int*)data) = noti_op->extra_info_1;
3258 case NOTIFICATION_OP_DATA_EXTRA_INFO_2:
3259 *((int*)data) = noti_op->extra_info_2;
3262 return NOTIFICATION_ERROR_INVALID_DATA;
3266 return NOTIFICATION_ERROR_NONE;