From: Jeonghoon Park Date: Sat, 18 Feb 2012 08:58:37 +0000 (+0900) Subject: update to latest X-Git-Tag: 2.0_alpha~3 X-Git-Url: http://review.tizen.org/git/?p=apps%2Fhome%2Fnotification.git;a=commitdiff_plain;h=86b3111ee38b3e7966e55921c0554da31e7c1cc9 update to latest --- diff --git a/debian/changelog b/debian/changelog index 8f686ab..9448d75 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,43 @@ +libnotification (0.1.1-9) unstable; urgency=low + + * Add content update API + * Git: slp/pkgs/n/notification + * Tag: libnotification_0.1.1-9 + + -- Mi-Ju Lee Wed, 25 Jan 2012 21:32:38 +0900 + +libnotification (0.1.1-8) unstable; urgency=low + + * Remove deprecated API + * Git: slp/pkgs/n/notification + * Tag: libnotification_0.1.1-8 + + -- Mi-Ju Lee Thu, 12 Jan 2012 16:32:56 +0900 + +libnotification (0.1.1-7) unstable; urgency=low + + * Deprecate some of the unused API + * Git: slp/pkgs/n/notification + * Tag: libnotification_0.1.1-7 + + -- Mi-Ju Lee Wed, 04 Jan 2012 18:54:12 +0900 + +libnotification (0.1.1-6) unstable; urgency=low + + * Add Error type for update API + * Git: slp/pkgs/n/notification + * Tag: libnotification_0.1.1-6 + + -- Mi-Ju Lee Wed, 04 Jan 2012 15:47:28 +0900 + +libnotification (0.1.1-5) unstable; urgency=low + + * Add notification update function + * Git: slp/pkgs/n/notification + * Tag: libnotification_0.1.1-5 + + -- Mi-Ju Lee Mon, 26 Dec 2011 17:54:37 +0900 + libnotification (0.1.1-4) unstable; urgency=low * Update pkgname to org.tizen diff --git a/include/notification.h b/include/notification.h old mode 100755 new mode 100644 index a833560..0644584 --- a/include/notification.h +++ b/include/notification.h @@ -256,29 +256,6 @@ notification_error_e notification_get_title(notification_h noti, * @see notification_set_text() * */ -notification_error_e notification_set_group_title(const char *pkgname, - int group_id, - const char *title, - const char *loc_title, - notification_count_display_type_e - count_display); - -/** - * @brief This function will be deprecated. - * @see notification_get_text() - * - */ -notification_error_e notification_get_group_title(const char *pkgname, - int group_id, - char **title, - char **loc_title, - notification_count_display_type_e *count_display); - -/** - * @brief This function will be deprecated. - * @see notification_set_text() - * - */ notification_error_e notification_set_content(notification_h noti, const char *content, const char *loc_content); @@ -293,46 +270,6 @@ notification_error_e notification_get_content(notification_h noti, char **loc_content); /** - * @brief This function will be deprecated. - * @see notification_set_text() - * - */ -notification_error_e notification_set_default_content(notification_h noti, - const char *content, - const char *loc_content); - -/** - * @brief This function will be deprecated. - * @see notification_get_text() - * - */ -notification_error_e notification_get_default_content(notification_h noti, - char **content, - char **loc_content); - -/** - * @brief This function will be deprecated. - * @see notification_set_text() - * - */ -notification_error_e notification_set_group_content(const char *pkgname, - int group_id, - const char *content, - const char *loc_content, - notification_count_display_type_e count_display); - -/** - * @brief This function will be deprecated. - * @see notification_get_text() - * - */ -notification_error_e notification_get_group_content(const char *pkgname, - int group_id, - char **content, - char **loc_content, - notification_count_display_type_e *count_display); - -/** * @brief This function set text. * @details Set title, content string. If text is formated data(only support %d, %f, %s), type - value pair should be set. * If %d, type NOTIFICATION_VARIABLE_TYPE_INT and value is integer value. @@ -646,24 +583,6 @@ notification_error_e notification_set_args(notification_h noti, bundle * args, b notification_error_e notification_get_args(notification_h noti, bundle ** args, bundle ** group_args); /* Do not use this */ /** - * @brief This function will be deprecated. - * @see notification_set_execute_option() - * - */ -notification_error_e notification_set_service_data(notification_h noti, - bundle *service_data, - bundle *group_service_data); - -/** - * @brief This function will be deprecated. - * @see notification_get_execute_option() - * - */ -notification_error_e notification_get_service_data(notification_h noti, - bundle **service_data, - bundle **group_service_data); - -/** * @brief This function set execute option. * @details When notification data selected in display application, application launched by appsvc_run_service with service_handle. * @remarks @@ -678,6 +597,30 @@ notification_error_e notification_get_service_data(notification_h noti, * @pre * @post * @see + * @par Sample code: + * @code +#include +... +{ + notification_h noti = NULL; + notification_error_e noti_err = NOTIFICATION_ERROR_NONE; + bundle *b = NULL; + + ... + + b = bundle_create(); + appsvc_set_operation(b, APPSVC_OPERATION_VIEW); + appsvc_set_uri(b,"http://www.samsung.com"); + + noti_err = notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, b); + if(noti_err != NOTIFICATION_ERROR_NONE) { + notification_free(noti); + return; + } + + bundle_free(b); +} + * @endcode */ notification_error_e notification_set_execute_option(notification_h noti, notification_execute_type_e type, @@ -1062,24 +1005,6 @@ notification_error_e notification_get_pkgname(notification_h noti, char **pkgname); /** - * @brief This function will be deprecated. - * @see notification_set_badge() - * - */ -notification_error_e notification_set_unread_count(const char *pkgname, - int group_id, - int unread_count); - -/** - * @brief This function will be deprecated. - * @see notification_get_badge() - * - */ -notification_error_e notification_get_unread_count(const char *pkgname, - int group_id, - int *unread_count); - -/** * @brief This function set application badge count. * @details * @remarks @@ -1230,13 +1155,14 @@ notification_error_e notification_insert(notification_h noti, int *priv_id); /** - * @brief This function update notification data. Not fully implemented yet. + * @brief This function update notification data. * @details Display application update UI. * @remarks * @param[in] noti notification handle that is created by notification_new(). * @return NOTIFICATION_ERROR_NONE if success, other value if failure * @retval NOTIFICATION_ERROR_NONE - success * @retval NOTIFICATION_ERROR_INVALID_DATA - Invalide input value + * @retval NOTIFICATION_ERROR_NOT_EXIST_ID - not exist priv id * @pre * @post * @see #notification_h @@ -1495,6 +1421,10 @@ notification_error_e notification_update_progress(notification_h noti, notification_error_e notification_update_size(notification_h noti, int priv_id, double size); +notification_error_e notification_update_content(notification_h noti, + int priv_id, + const char *content); + /** * @brief This function create internal structure data and return notification handle. * @details Available type is #NOTIFICATION_TYPE_NOTI and #NOTIFICATION_TYPE_ONGOING. @@ -1534,6 +1464,34 @@ notification_h notification_new(notification_type_e type, int group_id, int priv_id); /** + * @brief This function create notification clone. + * @details Newly created notification handle is returned. + * @remarks This clone notification handle should be call notification_free(). + * @param[in] noti notification handle + * @param[out] clone newly created notification handle that has same with input noti. + * @return NOTIFICATION_ERROR_NONE if success, other value if failure. + * @retval NOTIFICATION_ERROR_NONE - success + * @retval NOTIFICATION_ERROR_INVALID_DATA - invalid parameter + * @pre + * @post + * @see #notification_type_e + * @see #notification_h + * @par Sample code: + * @code +#include +... +{ + notification_h noti = notification_new(NOTIFICATION_TYPE_NOTI, APP_GROUP_ID, NOTIFICATION_PRIV_ID_NONE); + notification_h clone = NULL; + + notification_clone(noti, &clone); + ... +} + * @endcode + */ +notification_error_e notification_clone(notification_h noti, notification_h *clone); + +/** * @brief This function free internal structure data of notification handle. * @details Internal data of notification handle is released. Notification data that inserted is not deleted. * @remarks diff --git a/include/notification_error.h b/include/notification_error.h old mode 100755 new mode 100644 index 034a465..e91b57e --- a/include/notification_error.h +++ b/include/notification_error.h @@ -37,6 +37,7 @@ typedef enum _notification_error { NOTIFICATION_ERROR_FROM_DB = -3, /**< Error from DB query */ NOTIFICATION_ERROR_ALREADY_EXIST_ID = -4, /**< Already exist private ID */ NOTIFICATION_ERROR_FROM_DBUS = -5, /**< Error from DBus */ + NOTIFICATION_ERROR_NOT_EXIST_ID = -6, /**< Not exist private ID */ } notification_error_e; /** diff --git a/include/notification_noti.h b/include/notification_noti.h old mode 100755 new mode 100644 index a5d934e..9c84f60 --- a/include/notification_noti.h +++ b/include/notification_noti.h @@ -26,6 +26,8 @@ int notification_noti_insert(notification_h noti); +int notification_noti_update(notification_h noti); + int notification_noti_delete_all(notification_type_e type, const char *pkgname); int notification_noti_delete_group_by_group_id(const char *pkgname, diff --git a/include/notification_ongoing.h b/include/notification_ongoing.h old mode 100755 new mode 100644 index 6d04798..39f7c96 --- a/include/notification_ongoing.h +++ b/include/notification_ongoing.h @@ -30,4 +30,7 @@ notification_error_e notification_ongoing_update_progress(const char *caller_pkg notification_error_e notification_ongoing_update_size(const char *caller_pkgname, int priv_id, double size); +notification_error_e notification_ongoing_update_content(const char *caller_pkgname, + int priv_id, const char *content); + #endif /* __NOTIFICATION_ONGOING_H__ */ diff --git a/include/notification_type.h b/include/notification_type.h old mode 100755 new mode 100644 index b2584ba..744f7e8 --- a/include/notification_type.h +++ b/include/notification_type.h @@ -233,7 +233,7 @@ enum _notificaton_display_applist { /**< Ticker notification */ NOTIFICATION_DISPLAY_APP_LOCK = 0x00000004, /**< Lock screen */ - NOTIFICATION_DISPLAY_APP_INDICATOR = 0x00000004,/**< Indicator */ + NOTIFICATION_DISPLAY_APP_INDICATOR = 0x00000008,/**< Indicator */ NOTIFICATION_DISPLAY_APP_ALL = 0xffffffff, /**< All display application */ }; diff --git a/src/notification.c b/src/notification.c old mode 100755 new mode 100644 index d5fdacf..3525865 --- a/src/notification.c +++ b/src/notification.c @@ -460,84 +460,6 @@ EXPORT_API notification_error_e notification_get_title(notification_h noti, return noti_err; } -EXPORT_API notification_error_e notification_set_group_title(const char *pkgname, - int group_id, - const char *title, - const char *loc_title, - notification_count_display_type_e count_display) -{ - char *caller_pkgname = NULL; - notification_error_e noti_err = NOTIFICATION_ERROR_NONE; - - if ((title == NULL && loc_title == NULL)) { - return NOTIFICATION_ERROR_INVALID_DATA; - } - - if (group_id < NOTIFICATION_GROUP_ID_DEFAULT) { - return NOTIFICATION_ERROR_INVALID_DATA; - } - - if (pkgname == NULL) { - caller_pkgname = _notification_get_pkgname_by_pid(); - - noti_err = - notification_group_set_title(caller_pkgname, group_id, - title, loc_title, - count_display); - - if (caller_pkgname != NULL) { - free(caller_pkgname); - } - } else { - noti_err = - notification_group_set_title(pkgname, group_id, title, - loc_title, count_display); - } - - return noti_err; -} - -EXPORT_API notification_error_e notification_get_group_title(const char *pkgname, - int group_id, - char **title, - char **loc_title, - notification_count_display_type_e *count_display) -{ - char *caller_pkgname = NULL; - char *ret_title = NULL; - char *ret_loc_title = NULL; - notification_count_display_type_e ret_count_display; - int ret = NOTIFICATION_ERROR_NONE; - - if (pkgname == NULL) { - caller_pkgname = _notification_get_pkgname_by_pid(); - - ret = - notification_group_get_title(caller_pkgname, group_id, - &ret_title, &ret_loc_title, - &ret_count_display); - - if (caller_pkgname != NULL) { - free(caller_pkgname); - } - } else { - ret = - notification_group_get_title(pkgname, group_id, &ret_title, - &ret_loc_title, - &ret_count_display); - } - - if (ret != NOTIFICATION_ERROR_NONE) { - return ret; - } - - *title = ret_title; - *loc_title = ret_loc_title; - *count_display = ret_count_display; - - return NOTIFICATION_ERROR_NONE; -} - EXPORT_API notification_error_e notification_set_content(notification_h noti, const char *content, const char *loc_content) @@ -589,102 +511,6 @@ EXPORT_API notification_error_e notification_get_content(notification_h noti, #endif } -EXPORT_API notification_error_e notification_set_default_content(notification_h noti, - const char *content, - const char *loc_content) -{ - int noti_err = NOTIFICATION_ERROR_NONE; - - noti_err = - notification_set_text(noti, - NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, - content, loc_content, - NOTIFICATION_VARIABLE_TYPE_NONE); - - return noti_err; -} - -EXPORT_API notification_error_e notification_get_default_content(notification_h noti, - char **content, - char **loc_content) -{ - int noti_err = NOTIFICATION_ERROR_NONE; - char *ret_text = NULL; - - noti_err = - notification_get_text(noti, - NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF, - &ret_text); - - if (content != NULL) { - *content = ret_text; - } - - if (loc_content != NULL) { - *loc_content = NULL; - } - - return noti_err; -} - -EXPORT_API notification_error_e notification_set_group_content(const char *pkgname, - int group_id, - const char *content, - const char *loc_content, - notification_count_display_type_e count_display) -{ - const char *caller_pkgname = NULL; - if ((content == NULL && loc_content == NULL)) { - return NOTIFICATION_ERROR_INVALID_DATA; - } - - if (group_id < NOTIFICATION_GROUP_ID_DEFAULT) { - return NOTIFICATION_ERROR_INVALID_DATA; - } - - if (pkgname == NULL) - caller_pkgname = _notification_get_pkgname_by_pid(); - else - caller_pkgname = pkgname; - - notification_group_set_content(caller_pkgname, group_id, content, - loc_content, count_display); - - return NOTIFICATION_ERROR_NONE; -} - -EXPORT_API notification_error_e notification_get_group_content(const char *pkgname, - int group_id, - char **content, - char **loc_content, - notification_count_display_type_e *count_display) -{ - const char *caller_pkgname = NULL; - char *ret_content = NULL; - char *ret_loc_content = NULL; - notification_count_display_type_e ret_count_display; - int ret = NOTIFICATION_ERROR_NONE; - - if (pkgname == NULL) - caller_pkgname = _notification_get_pkgname_by_pid(); - else - caller_pkgname = pkgname; - - ret = - notification_group_get_content(caller_pkgname, group_id, - &ret_content, &ret_loc_content, - &ret_count_display); - if (ret != NOTIFICATION_ERROR_NONE) { - return ret; - } - - *content = ret_content; - *loc_content = ret_loc_content; - *count_display = ret_count_display; - - return NOTIFICATION_ERROR_NONE; -} - EXPORT_API notification_error_e notification_set_text(notification_h noti, notification_text_type_e type, const char *text, @@ -751,6 +577,22 @@ EXPORT_API notification_error_e notification_set_text(notification_h noti, /* Save text bundle */ noti->b_text = b; } + } else { + /* Reset if text is NULL */ + if (noti->b_text != NULL) { + /* If text bundle exist, store local bundle data */ + b = noti->b_text; + + /* Make type to key as char string */ + snprintf(buf_key, sizeof(buf_key), "%d", type); + + /* Get value using type key */ + ret_val = bundle_get_val(b, buf_key); + if (ret_val != NULL) { + /* If value exist, remove this */ + bundle_del(b, buf_key); + } + } } /* Save key if key is valid data */ @@ -789,6 +631,22 @@ EXPORT_API notification_error_e notification_set_text(notification_h noti, /* Save key bundle */ noti->b_key = b; } + } else { + /* Reset if key is NULL */ + if (noti->b_key != NULL) { + /* If key bundle exist, store local bundle data */ + b = noti->b_key; + + /* Make type to key as char string */ + snprintf(buf_key, sizeof(buf_key), "%d", type); + + /* Get value using type key */ + ret_val = bundle_get_val(b, buf_key); + if (ret_val != NULL) { + /* If value exist, remove this */ + bundle_del(b, buf_key); + } + } } if (noti->b_format_args != NULL) { @@ -955,7 +813,7 @@ EXPORT_API notification_error_e notification_get_text(notification_h noti, &boolval); if (ret == -1 || boolval == 0) { /* Set flag as display option is OFF */ - display_option_flag = 1; + //display_option_flag = 1; } } @@ -1551,62 +1409,6 @@ EXPORT_API notification_error_e notification_get_args(notification_h noti, return NOTIFICATION_ERROR_NONE; } -EXPORT_API notification_error_e notification_set_service_data(notification_h noti, - bundle * service_data, - bundle * group_service_data) -{ - int noti_err = NOTIFICATION_ERROR_NONE; - - noti_err = - notification_set_execute_option(noti, - NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, - NULL, NULL, service_data); - if (noti_err != NOTIFICATION_ERROR_NONE) { - return noti_err; - } - - noti_err = - notification_set_execute_option(noti, - NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, - NULL, NULL, group_service_data); - - return noti_err; -} - -EXPORT_API notification_error_e notification_get_service_data(notification_h noti, - bundle ** service_data, - bundle ** group_service_data) -{ - int noti_err = NOTIFICATION_ERROR_NONE; - bundle *get_service_data = NULL; - - noti_err = - notification_get_execute_option(noti, - NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, - NULL, &get_service_data); - if (noti_err != NOTIFICATION_ERROR_NONE) { - return noti_err; - } - - if (service_data != NULL) { - *service_data = get_service_data; - } - - noti_err = - notification_get_execute_option(noti, - NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, - NULL, &get_service_data); - if (noti_err != NOTIFICATION_ERROR_NONE) { - return noti_err; - } - - if (service_data != NULL) { - *group_service_data = get_service_data; - } - - return NOTIFICATION_ERROR_NONE; -} - EXPORT_API notification_error_e notification_set_execute_option(notification_h noti, notification_execute_type_e type, const char *text, @@ -1954,33 +1756,6 @@ EXPORT_API notification_error_e notification_get_pkgname(notification_h noti, return NOTIFICATION_ERROR_NONE; } -EXPORT_API notification_error_e notification_set_unread_count(const char *pkgname, - int group_id, - int unread_count) -{ - int ret = NOTIFICATION_ERROR_NONE; - - ret = notification_set_badge(pkgname, group_id, unread_count); - - return ret; -} - -EXPORT_API notification_error_e notification_get_unread_count(const char *pkgname, - int group_id, - int *unread_count) -{ - int ret = NOTIFICATION_ERROR_NONE; - int ret_unread_count = 0; - - ret = notification_get_badge(pkgname, group_id, &ret_unread_count); - - if (unread_count != NULL) { - *unread_count = ret_unread_count; - } - - return ret; -} - EXPORT_API notification_error_e notification_set_badge(const char *pkgname, int group_id, int count) { @@ -2135,9 +1910,17 @@ EXPORT_API notification_error_e notification_insert(notification_h noti, EXPORT_API notification_error_e notification_update(notification_h noti) { + int ret = 0; + /* Check noti is valid data */ if (noti != NULL) { - /* TODO : Update noti */ + /* Update insert time ? */ + noti->insert_time = time(NULL); + + ret = notification_noti_update(noti); + if (ret != NOTIFICATION_ERROR_NONE) { + return ret; + } } /* Send changed notification */ @@ -2387,6 +2170,39 @@ EXPORT_API notification_error_e notification_update_size(notification_h noti, return NOTIFICATION_ERROR_NONE; } +EXPORT_API notification_error_e notification_update_content(notification_h noti, + int priv_id, + const char *content) +{ + char *caller_pkgname = NULL; + int input_priv_id = 0; + + if (priv_id <= NOTIFICATION_PRIV_ID_NONE) { + if (noti == NULL) { + return NOTIFICATION_ERROR_INVALID_DATA; + } else { + input_priv_id = noti->priv_id; + } + } else { + input_priv_id = priv_id; + } + + if (noti == NULL) { + caller_pkgname = _notification_get_pkgname_by_pid(); + } else { + caller_pkgname = strdup(noti->caller_pkgname); + } + + notification_ongoing_update_content(caller_pkgname, input_priv_id, + content); + + if (caller_pkgname) { + free(caller_pkgname); + } + + return NOTIFICATION_ERROR_NONE; +} + EXPORT_API notification_h notification_new(notification_type_e type, int group_id, int priv_id) { @@ -2463,6 +2279,138 @@ EXPORT_API notification_h notification_new(notification_type_e type, return noti; } +EXPORT_API notification_error_e notification_clone(notification_h noti, notification_h *clone) +{ + notification_h new_noti = NULL; + + if (noti == NULL || clone == NULL) { + NOTIFICATION_ERR("INVALID PARAMETER."); + return NOTIFICATION_ERROR_INVALID_DATA; + } + + new_noti = (notification_h) malloc(sizeof(struct _notification)); + if (new_noti == NULL) { + NOTIFICATION_ERR("NO MEMORY : noti == NULL"); + return NOTIFICATION_ERROR_NO_MEMORY; + } + memset(new_noti, 0x00, sizeof(struct _notification)); + + new_noti->type = noti->type; + + new_noti->group_id = noti->group_id; + new_noti->internal_group_id = noti->internal_group_id; + new_noti->priv_id = noti->priv_id; + + if(noti->caller_pkgname != NULL) { + new_noti->caller_pkgname = strdup(noti->caller_pkgname); + } else { + new_noti->caller_pkgname = _notification_get_pkgname_by_pid(); + } + if(noti->launch_pkgname != NULL) { + new_noti->launch_pkgname = strdup(noti->launch_pkgname); + } else { + new_noti->launch_pkgname = NULL; + } + + if(noti->args != NULL) { + new_noti->args = bundle_dup(noti->args); + } else { + new_noti->args = NULL; + } + if(noti->group_args != NULL) { + new_noti->group_args = bundle_dup(noti->group_args); + } else { + new_noti->group_args = NULL; + } + + if(noti->b_execute_option != NULL) { + new_noti->b_execute_option = bundle_dup(noti->b_execute_option); + } else { + new_noti->b_execute_option = NULL; + } + if(noti->b_service_responding != NULL) { + new_noti->b_service_responding = bundle_dup(noti->b_service_responding); + } else { + new_noti->b_service_responding = NULL; + } + if(noti->b_service_single_launch != NULL) { + new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch); + } else { + new_noti->b_service_single_launch = NULL; + } + if(noti->b_service_multi_launch != NULL) { + new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch); + } else { + new_noti->b_service_multi_launch = NULL; + } + + new_noti->sound_type = noti->sound_type; + if(noti->sound_path != NULL) { + new_noti->sound_path = strdup(noti->sound_path); + } else { + new_noti->sound_path = NULL; + } + new_noti->vibration_type = noti->vibration_type; + if(noti->vibration_path != NULL) { + new_noti->vibration_path = strdup(noti->vibration_path); + } else { + new_noti->vibration_path = NULL; + } + + if(noti->domain != NULL) { + new_noti->domain = strdup(noti->domain); + } else { + new_noti->domain = NULL; + } + if(noti->dir != NULL) { + new_noti->dir = strdup(noti->dir); + } else { + new_noti->dir = NULL; + } + + if(noti->b_text != NULL) { + new_noti->b_text = bundle_dup(noti->b_text); + } else { + new_noti->b_text = NULL; + } + if(noti->b_key != NULL) { + new_noti->b_key = bundle_dup(noti->b_key); + } else { + new_noti->b_key = NULL; + } + if(noti->b_format_args != NULL) { + new_noti->b_format_args = bundle_dup(noti->b_format_args); + } else { + new_noti->b_format_args = NULL; + } + new_noti->num_format_args = noti->num_format_args; + + if(noti->b_image_path != NULL) { + new_noti->b_image_path = bundle_dup(noti->b_image_path); + } else { + new_noti->b_image_path = NULL; + } + + new_noti->time = noti->time; + new_noti->insert_time = noti->insert_time; + + new_noti->flags_for_property = noti->flags_for_property; + new_noti->display_applist = noti->display_applist; + + new_noti->progress_size = noti->progress_size; + new_noti->progress_percentage = noti->progress_percentage; + + new_noti->app_icon_path = NULL; + new_noti->app_name = NULL; + new_noti->temp_title = NULL; + new_noti->temp_content = NULL; + + *clone = new_noti; + + return NOTIFICATION_ERROR_NONE; +} + + EXPORT_API notification_error_e notification_free(notification_h noti) { if (noti == NULL) { diff --git a/src/notification_group.c b/src/notification_group.c old mode 100755 new mode 100644 index c310f8e..c217704 --- a/src/notification_group.c +++ b/src/notification_group.c @@ -27,30 +27,6 @@ #include #include -static int _notification_group_bind_query(sqlite3_stmt * stmt, const char *name, - const char *str) -{ - int ret = 0; - int index = 0; - - index = sqlite3_bind_parameter_index(stmt, name); - if (index == 0) { - NOTIFICATION_ERR("Insert : invalid column name"); - return NOTIFICATION_ERROR_FROM_DB; - } - - ret = - sqlite3_bind_text(stmt, index, NOTIFICATION_CHECK_STR(str), -1, - SQLITE_STATIC); - if (ret != SQLITE_OK) { - NOTIFICATION_ERR("Insert text : %s", - NOTIFICATION_CHECK_STR(str)); - return NOTIFICATION_ERROR_FROM_DB; - } - - return NOTIFICATION_ERROR_NONE; -} - static int _notification_group_check_data_inserted(const char *pkgname, int group_id, sqlite3 * db) { @@ -88,259 +64,6 @@ static int _notification_group_check_data_inserted(const char *pkgname, return NOTIFICATION_ERROR_NONE; } -notification_error_e notification_group_set_title(const char *pkgname, - int group_id, - const char *title, - const char *loc_title, - notification_count_display_type_e count_display) -{ - sqlite3 *db; - sqlite3_stmt *stmt = NULL; - char query[NOTIFICATION_QUERY_MAX] = { 0, }; - int ret = 0; - int result = NOTIFICATION_ERROR_NONE; - - // db open - db = notification_db_open(DBPATH); - - // Check pkgname & group_id - ret = _notification_group_check_data_inserted(pkgname, group_id, db); - if (ret == NOTIFICATION_ERROR_NONE) { - // not exist -> insert - snprintf(query, sizeof(query), "insert into noti_group_data (" - "caller_pkgname, group_id, unread_count, title, loc_title, count_display_title) values (" - "'%s', %d, 0, $title, $loc_title, %d)", - pkgname, group_id, count_display); - - } else { - // exist -> update - // not exist -> insert - snprintf(query, sizeof(query), "update noti_group_data " - "set title = $title, loc_title = $loc_title, count_display_title = %d " - "where caller_pkgname = '%s' and group_id = %d", - count_display, pkgname, group_id); - } - - // insert - ret = sqlite3_prepare_v2(db, query, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - NOTIFICATION_ERR("Insert Query : %s", query); - NOTIFICATION_ERR("Insert DB error(%d) : %s", ret, - sqlite3_errmsg(db)); - if (stmt) { - sqlite3_finalize(stmt); - } - - if (db) { - notification_db_close(&db); - } - return NOTIFICATION_ERROR_FROM_DB; - } - - ret = _notification_group_bind_query(stmt, "$title", title); - if (ret != NOTIFICATION_ERROR_NONE) { - NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db)); - return ret; - } - - ret = _notification_group_bind_query(stmt, "$loc_title", loc_title); - if (ret != NOTIFICATION_ERROR_NONE) { - NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db)); - return ret; - } - - ret = sqlite3_step(stmt); - if (ret == SQLITE_OK || ret == SQLITE_DONE) { - result = NOTIFICATION_ERROR_NONE; - } else { - result = NOTIFICATION_ERROR_FROM_DB; - } - - if (stmt) { - sqlite3_finalize(stmt); - } - - if (db) { - notification_db_close(&db); - } - - return result; -} - -notification_error_e notification_group_get_title(const char *pkgname, - int group_id, - char **ret_title, - char **ret_loc_title, - notification_count_display_type_e *count_display) -{ - sqlite3 *db; - sqlite3_stmt *stmt = NULL; - char query[NOTIFICATION_QUERY_MAX] = { 0, }; - int ret = 0; - int col = 0; - - // db open - db = notification_db_open(DBPATH); - - snprintf(query, sizeof(query), "select " - "title, loc_title, count_display_title " - "from noti_group_data " - "where caller_pkgname = '%s' and group_id = %d", - pkgname, group_id); - - ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL); - if (ret != SQLITE_OK) { - NOTIFICATION_ERR("Select Query : %s", query); - NOTIFICATION_ERR("Select DB error(%d) : %s", ret, - sqlite3_errmsg(db)); - - return NOTIFICATION_ERROR_FROM_DB; - } - - ret = sqlite3_step(stmt); - if (ret == SQLITE_ROW) { - *ret_title = notification_db_column_text(stmt, col++); - *ret_loc_title = notification_db_column_text(stmt, col++); - *count_display = sqlite3_column_int(stmt, col++); - } - - sqlite3_finalize(stmt); - - // db close - if (db) { - notification_db_close(&db); - } - - return NOTIFICATION_ERROR_NONE; -} - -notification_error_e notification_group_set_content(const char *pkgname, - int group_id, - const char *content, - const char *loc_content, - notification_count_display_type_e count_display) -{ - sqlite3 *db; - sqlite3_stmt *stmt = NULL; - char query[NOTIFICATION_QUERY_MAX] = { 0, }; - int ret = 0; - int result = NOTIFICATION_ERROR_NONE; - - // db open - db = notification_db_open(DBPATH); - - // Check pkgname & group_id - ret = _notification_group_check_data_inserted(pkgname, group_id, db); - if (ret == NOTIFICATION_ERROR_NONE) { - // not exist -> insert - snprintf(query, sizeof(query), "insert into noti_group_data (" - "caller_pkgname, group_id, unread_count, content, loc_content, count_display_content) values (" - "'%s', %d, 0, $content, $loc_content, %d)", - pkgname, group_id, count_display); -// NOTIFICATION_INFO("Insert Query : %s", query); - } else { - // exist -> update - // not exist -> insert - snprintf(query, sizeof(query), "update noti_group_data " - "set content = $content, loc_content = $loc_content, count_display_content = %d " - "where caller_pkgname = '%s' and group_id = %d", - count_display, pkgname, group_id); -// NOTIFICATION_INFO("Insert Query : %s", query); - } - - // insert - ret = sqlite3_prepare_v2(db, query, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - NOTIFICATION_ERR("Insert Query : %s", query); - NOTIFICATION_ERR("Insert DB error(%d) : %s", ret, - sqlite3_errmsg(db)); - if (stmt) { - sqlite3_finalize(stmt); - } - - if (db) { - notification_db_close(&db); - } - return NOTIFICATION_ERROR_FROM_DB; - } - - ret = _notification_group_bind_query(stmt, "$content", content); - if (ret != NOTIFICATION_ERROR_NONE) { - NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db)); - return ret; - } - - ret = _notification_group_bind_query(stmt, "$loc_content", loc_content); - if (ret != NOTIFICATION_ERROR_NONE) { - NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db)); - return ret; - } - - ret = sqlite3_step(stmt); - if (ret == SQLITE_OK || ret == SQLITE_DONE) { - result = NOTIFICATION_ERROR_NONE; - } else { - result = NOTIFICATION_ERROR_FROM_DB; - } - - if (stmt) { - sqlite3_finalize(stmt); - } - - if (db) { - notification_db_close(&db); - } - - return result; -} - -notification_error_e notification_group_get_content(const char *pkgname, - int group_id, - char **ret_content, - char **ret_loc_content, - notification_count_display_type_e *count_display) -{ - sqlite3 *db; - sqlite3_stmt *stmt = NULL; - char query[NOTIFICATION_QUERY_MAX] = { 0, }; - int ret = 0; - int col = 0; - - // db open - db = notification_db_open(DBPATH); - - snprintf(query, sizeof(query), "select " - "content, loc_content, count_display_content " - "from noti_group_data " - "where caller_pkgname = '%s' and group_id = %d", - pkgname, group_id); - - ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL); - if (ret != SQLITE_OK) { - NOTIFICATION_ERR("Select Query : %s", query); - NOTIFICATION_ERR("Select DB error(%d) : %s", ret, - sqlite3_errmsg(db)); - - return NOTIFICATION_ERROR_FROM_DB; - } - - ret = sqlite3_step(stmt); - if (ret == SQLITE_ROW) { - *ret_content = notification_db_column_text(stmt, col++); - *ret_loc_content = notification_db_column_text(stmt, col++); - *count_display = sqlite3_column_int(stmt, col++); - } - - sqlite3_finalize(stmt); - - // db close - if (db) { - notification_db_close(&db); - } - - return NOTIFICATION_ERROR_NONE; -} - notification_error_e notification_group_set_badge(const char *pkgname, int group_id, int count) { diff --git a/src/notification_noti.c b/src/notification_noti.c old mode 100755 new mode 100644 index 07fae45..bb0a60f --- a/src/notification_noti.c +++ b/src/notification_noti.c @@ -247,10 +247,6 @@ static int _notification_noti_get_internal_group_id(notification_h noti, if (stmt) { sqlite3_finalize(stmt); } - - if (db) { - notification_db_close(&db); - } return NOTIFICATION_ERROR_FROM_DB; } @@ -262,6 +258,9 @@ static int _notification_noti_get_internal_group_id(notification_h noti, (ret_title)); if (ret != NOTIFICATION_ERROR_NONE) { NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db)); + if (stmt) { + sqlite3_finalize(stmt); + } return ret; } } @@ -433,6 +432,147 @@ static int _notification_noti_make_query(notification_h noti, char *query, return NOTIFICATION_ERROR_NONE; } + +static int _notification_noti_make_update_query(notification_h noti, char *query, + int query_size) +{ + char *args = NULL; + char *group_args = NULL; + char *b_image_path = NULL; + char *b_execute_option = NULL; + char *b_service_responding = NULL; + char *b_service_single_launch = NULL; + char *b_service_multi_launch = NULL; + char *b_text = NULL; + char *b_key = NULL; + char *b_format_args = NULL; + int flag_simmode = 0; + + /* Decode bundle to update DB */ + if (noti->args) { + bundle_encode(noti->args, (bundle_raw **) & args, NULL); + } + if (noti->group_args) { + bundle_encode(noti->group_args, (bundle_raw **) & group_args, + NULL); + } + + if (noti->b_execute_option) { + bundle_encode(noti->b_execute_option, + (bundle_raw **) & b_execute_option, NULL); + } + if (noti->b_service_responding) { + bundle_encode(noti->b_service_responding, + (bundle_raw **) & b_service_responding, NULL); + } + if (noti->b_service_single_launch) { + bundle_encode(noti->b_service_single_launch, + (bundle_raw **) & b_service_single_launch, NULL); + } + if (noti->b_service_multi_launch) { + bundle_encode(noti->b_service_multi_launch, + (bundle_raw **) & b_service_multi_launch, NULL); + } + + if (noti->b_text) { + bundle_encode(noti->b_text, (bundle_raw **) & b_text, NULL); + } + if (noti->b_key) { + bundle_encode(noti->b_key, (bundle_raw **) & b_key, NULL); + } + if (noti->b_format_args) { + bundle_encode(noti->b_format_args, + (bundle_raw **) & b_format_args, NULL); + } + + if (noti->b_image_path) { + bundle_encode(noti->b_image_path, + (bundle_raw **) & b_image_path, NULL); + } + + /* Check only simmode property is enable */ + if (noti->flags_for_property & NOTIFICATION_PROP_DISPLAY_ONLY_SIMMODE) { + flag_simmode = 1; + } + + /* Make query */ + snprintf(query, query_size, "update noti_list set " + "type = %d, " + "launch_pkgname = '%s', " + "image_path = '%s', " + "b_text = '%s', b_key = '%s', " + "b_format_args = '%s', num_format_args = %d, " + "text_domain = '%s', text_dir = '%s', " + "time = %d, insert_time = %d, " + "args = '%s', group_args = '%s', " + "b_execute_option = '%s', " + "b_service_responding = '%s', " + "b_service_single_launch = '%s', " + "b_service_multi_launch = '%s', " + "sound_type = %d, sound_path = '%s', " + "vibration_type = %d, vibration_path = '%s', " + "flags_for_property = %d, flag_simmode = %d, " + "display_applist = %d, " + "progress_size = %f, progress_percentage = %f " + "where priv_id = %d ", + noti->type, + NOTIFICATION_CHECK_STR(noti->launch_pkgname), + NOTIFICATION_CHECK_STR(b_image_path), + NOTIFICATION_CHECK_STR(b_text), NOTIFICATION_CHECK_STR(b_key), + NOTIFICATION_CHECK_STR(b_format_args), noti->num_format_args, + NOTIFICATION_CHECK_STR(noti->domain), + NOTIFICATION_CHECK_STR(noti->dir), + (int)noti->time, (int)noti->insert_time, + NOTIFICATION_CHECK_STR(args), NOTIFICATION_CHECK_STR(group_args), + NOTIFICATION_CHECK_STR(b_execute_option), + NOTIFICATION_CHECK_STR(b_service_responding), + NOTIFICATION_CHECK_STR(b_service_single_launch), + NOTIFICATION_CHECK_STR(b_service_multi_launch), + noti->sound_type, NOTIFICATION_CHECK_STR(noti->sound_path), + noti->vibration_type, + NOTIFICATION_CHECK_STR(noti->vibration_path), + noti->flags_for_property, flag_simmode, noti->display_applist, + noti->progress_size, noti->progress_percentage, + noti->priv_id); + + /* Free decoded data */ + if (args) { + free(args); + } + if (group_args) { + free(group_args); + } + + if (b_execute_option) { + free(b_execute_option); + } + if (b_service_responding) { + free(b_service_responding); + } + if (b_service_single_launch) { + free(b_service_single_launch); + } + if (b_service_multi_launch) { + free(b_service_multi_launch); + } + + if (b_text) { + free(b_text); + } + if (b_key) { + free(b_key); + } + if (b_format_args) { + free(b_format_args); + } + + if (b_image_path) { + free(b_image_path); + } + + return NOTIFICATION_ERROR_NONE; +} + static notification_h _notification_noti_get_item(sqlite3_stmt * stmt) { notification_h noti = NULL; @@ -489,10 +629,10 @@ static notification_h _notification_noti_get_item(sqlite3_stmt * stmt) int notification_noti_insert(notification_h noti) { - sqlite3 *db; + sqlite3 *db = NULL; sqlite3_stmt *stmt = NULL; char query[NOTIFICATION_QUERY_MAX] = { 0, }; - int ret = 0, result = 0; + int ret = 0; char buf_key[32] = { 0, }; const char *title_key = NULL; @@ -505,20 +645,20 @@ int notification_noti_insert(notification_h noti) } else { ret = _notification_noti_check_priv_id(noti, db); if (ret != NOTIFICATION_ERROR_NONE) { - return ret; + goto err; } } /* Get internal group ID */ ret = _notification_noti_get_internal_group_id(noti, db); if (ret != NOTIFICATION_ERROR_NONE) { - return ret; + goto err; } /* make query */ ret = _notification_noti_make_query(noti, query, sizeof(query)); if (ret != NOTIFICATION_ERROR_NONE) { - return ret; + goto err; } ret = sqlite3_prepare_v2(db, query, -1, &stmt, NULL); @@ -526,14 +666,8 @@ int notification_noti_insert(notification_h noti) NOTIFICATION_ERR("Insert Query : %s", query); NOTIFICATION_ERR("Insert DB error(%d) : %s", ret, sqlite3_errmsg(db)); - if (stmt) { - sqlite3_finalize(stmt); - } - - if (db) { - notification_db_close(&db); - } - return NOTIFICATION_ERROR_FROM_DB; + ret = NOTIFICATION_ERROR_FROM_DB; + goto err; } /* Get title key */ @@ -559,16 +693,68 @@ int notification_noti_insert(notification_h noti) ret = _notification_noti_bind_query(stmt, "$title_key", title_key); if (ret != NOTIFICATION_ERROR_NONE) { NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db)); - return ret; + goto err; } ret = sqlite3_step(stmt); if (ret == SQLITE_OK || ret == SQLITE_DONE) { - result = NOTIFICATION_ERROR_NONE; + ret = NOTIFICATION_ERROR_NONE; } else { - result = NOTIFICATION_ERROR_FROM_DB; + ret = NOTIFICATION_ERROR_FROM_DB; + } +err: + if (stmt) { + sqlite3_finalize(stmt); + } + + /* Close DB */ + if (db) { + notification_db_close(&db); + } + + return ret; +} + + +int notification_noti_update(notification_h noti) +{ + sqlite3 *db; + sqlite3_stmt *stmt = NULL; + char query[NOTIFICATION_QUERY_MAX] = { 0, }; + int ret = 0; + + /* Open DB */ + db = notification_db_open(DBPATH); + + /* Check private ID is exist */ + ret = _notification_noti_check_priv_id(noti, db); + if (ret != NOTIFICATION_ERROR_ALREADY_EXIST_ID) { + ret = NOTIFICATION_ERROR_NOT_EXIST_ID; + goto err; + } + + /* make update query */ + ret = _notification_noti_make_update_query(noti, query, sizeof(query)); + if (ret != NOTIFICATION_ERROR_NONE) { + goto err; } + ret = sqlite3_prepare_v2(db, query, -1, &stmt, NULL); + if (ret != SQLITE_OK) { + NOTIFICATION_ERR("Insert Query : %s", query); + NOTIFICATION_ERR("Insert DB error(%d) : %s", ret, + sqlite3_errmsg(db)); + ret = NOTIFICATION_ERROR_FROM_DB; + goto err; + } + + ret = sqlite3_step(stmt); + if (ret == SQLITE_OK || ret == SQLITE_DONE) { + ret = NOTIFICATION_ERROR_NONE; + } else { + ret = NOTIFICATION_ERROR_FROM_DB; + } +err: if (stmt) { sqlite3_finalize(stmt); } @@ -578,12 +764,12 @@ int notification_noti_insert(notification_h noti) notification_db_close(&db); } - return result; + return ret; } int notification_noti_delete_all(notification_type_e type, const char *pkgname) { - sqlite3 *db; + sqlite3 *db = NULL; char query[NOTIFICATION_QUERY_MAX] = { 0, }; char query_base[NOTIFICATION_QUERY_MAX] = { 0, }; char query_where[NOTIFICATION_QUERY_MAX] = { 0, }; @@ -628,7 +814,7 @@ int notification_noti_delete_all(notification_type_e type, const char *pkgname) int notification_noti_delete_group_by_group_id(const char *pkgname, int group_id) { - sqlite3 *db; + sqlite3 *db = NULL; char query[NOTIFICATION_QUERY_MAX] = { 0, }; /* Check pkgname is valid */ @@ -657,7 +843,7 @@ int notification_noti_delete_group_by_group_id(const char *pkgname, int notification_noti_delete_group_by_priv_id(const char *pkgname, int priv_id) { - sqlite3 *db; + sqlite3 *db = NULL; char query[NOTIFICATION_QUERY_MAX] = { 0, }; int internal_group_id = 0; @@ -692,7 +878,7 @@ int notification_noti_delete_group_by_priv_id(const char *pkgname, int priv_id) int notification_noti_delete_by_priv_id(const char *pkgname, int priv_id) { - sqlite3 *db; + sqlite3 *db = NULL; char query[NOTIFICATION_QUERY_MAX] = { 0, }; /* Check pkgname is valid */ @@ -823,7 +1009,8 @@ notification_error_e notification_noti_get_count(notification_type_e type, NOTIFICATION_ERR("Select DB error(%d) : %s", ret, sqlite3_errmsg(db)); - return NOTIFICATION_ERROR_FROM_DB; + ret = NOTIFICATION_ERROR_FROM_DB; + goto err; } ret = sqlite3_step(stmt); @@ -831,7 +1018,12 @@ notification_error_e notification_noti_get_count(notification_type_e type, get_count = sqlite3_column_int(stmt, 0); } - sqlite3_finalize(stmt); + ret = NOTIFICATION_ERROR_NONE; + +err: + if (stmt) { + sqlite3_finalize(stmt); + } /* Close DB */ if (db) { @@ -840,7 +1032,7 @@ notification_error_e notification_noti_get_count(notification_type_e type, *count = get_count; - return NOTIFICATION_ERROR_NONE; + return ret; } notification_error_e notification_noti_get_grouping_list(notification_type_e type, @@ -848,7 +1040,7 @@ notification_error_e notification_noti_get_grouping_list(notification_type_e typ notification_list_h * list) { - sqlite3 *db; + sqlite3 *db = NULL; sqlite3_stmt *stmt = NULL; char query[NOTIFICATION_QUERY_MAX] = { 0, }; char query_base[NOTIFICATION_QUERY_MAX] = { 0, }; @@ -902,7 +1094,8 @@ notification_error_e notification_noti_get_grouping_list(notification_type_e typ NOTIFICATION_ERR("Select DB error(%d) : %s", ret, sqlite3_errmsg(db)); - return NOTIFICATION_ERROR_FROM_DB; + ret = NOTIFICATION_ERROR_FROM_DB; + goto err; } ret = sqlite3_step(stmt); @@ -925,7 +1118,12 @@ notification_error_e notification_noti_get_grouping_list(notification_type_e typ ret = sqlite3_step(stmt); } - sqlite3_finalize(stmt); + ret = NOTIFICATION_ERROR_NONE; + +err: + if (stmt) { + sqlite3_finalize(stmt); + } /* Close DB */ if (db) { @@ -936,7 +1134,7 @@ notification_error_e notification_noti_get_grouping_list(notification_type_e typ *list = notification_list_get_head(get_list); } - return NOTIFICATION_ERROR_NONE; + return ret; } notification_error_e notification_noti_get_detail_list(const char *pkgname, @@ -944,7 +1142,7 @@ notification_error_e notification_noti_get_detail_list(const char *pkgname, int priv_id, int count, notification_list_h *list) { - sqlite3 *db; + sqlite3 *db = NULL; sqlite3_stmt *stmt = NULL; char query_base[NOTIFICATION_QUERY_MAX] = { 0, }; char query_where[NOTIFICATION_QUERY_MAX] = { 0, }; @@ -997,7 +1195,8 @@ notification_error_e notification_noti_get_detail_list(const char *pkgname, NOTIFICATION_ERR("Select DB error(%d) : %s", ret, sqlite3_errmsg(db)); - return NOTIFICATION_ERROR_FROM_DB; + ret = NOTIFICATION_ERROR_FROM_DB; + goto err; } ret = sqlite3_step(stmt); @@ -1020,7 +1219,12 @@ notification_error_e notification_noti_get_detail_list(const char *pkgname, ret = sqlite3_step(stmt); } - sqlite3_finalize(stmt); + ret = NOTIFICATION_ERROR_NONE; + +err: + if (stmt) { + sqlite3_finalize(stmt); + } /* Close DB */ if (db) { @@ -1031,5 +1235,5 @@ notification_error_e notification_noti_get_detail_list(const char *pkgname, *list = notification_list_get_head(get_list); } - return NOTIFICATION_ERROR_NONE; + return ret; } diff --git a/src/notification_ongoing.c b/src/notification_ongoing.c old mode 100755 new mode 100644 index cd911d8..18a64e7 --- a/src/notification_ongoing.c +++ b/src/notification_ongoing.c @@ -127,3 +127,58 @@ notification_error_e notification_ongoing_update_size(const char *caller_pkgname return NOTIFICATION_ERROR_FROM_DBUS; } + +notification_error_e notification_ongoing_update_content(const char *caller_pkgname, + int priv_id, const char *content) +{ + DBusConnection *connection = NULL; + DBusMessage *signal = NULL; + DBusError err; + dbus_bool_t ret; + + dbus_error_init(&err); + connection = dbus_bus_get(DBUS_BUS_SYSTEM, &err); + if (!connection) { + NOTIFICATION_ERR("Fail to dbus_bus_get"); + return NOTIFICATION_ERROR_FROM_DBUS; + } + + signal = + dbus_message_new_signal("/dbus/signal", "notification.ongoing", + "update_content"); + if (!signal) { + NOTIFICATION_ERR("Fail to dbus_message_new_signal"); + return NOTIFICATION_ERROR_FROM_DBUS; + } + + if(content == NULL) { + ret = dbus_message_append_args(signal, + DBUS_TYPE_STRING, &caller_pkgname, + DBUS_TYPE_INT32, &priv_id, + DBUS_TYPE_INVALID); + } else { + ret = dbus_message_append_args(signal, + DBUS_TYPE_STRING, &caller_pkgname, + DBUS_TYPE_INT32, &priv_id, + DBUS_TYPE_STRING, &content, + DBUS_TYPE_INVALID); + } + if (ret) { + ret = dbus_connection_send(connection, signal, NULL); + NOTIFICATION_INFO("Send content : %s(%d) %s", + caller_pkgname, priv_id, content); + + if (ret) { + dbus_connection_flush(connection); + } + } + + dbus_message_unref(signal); + + if (ret) { + return NOTIFICATION_ERROR_NONE; + } + + return NOTIFICATION_ERROR_FROM_DBUS; +} +