diff options
author | youngsub ko <ys4610.ko@samsung.com> | 2013-10-23 14:29:58 +0900 |
---|---|---|
committer | youngsub ko <ys4610.ko@samsung.com> | 2013-10-23 14:29:58 +0900 |
commit | abe7e659630557632e15ab7560855b535c4e8c5b (patch) | |
tree | 45725459a74a42fe5ea46befab1c21f7ec5418ca | |
parent | 22075fff68729c4decd90672091c3c4075982435 (diff) | |
parent | 40112f57080d75ed37f32a37d17ba0572a442103 (diff) | |
download | notification-accepted/tizen_ivi_panda.tar.gz notification-accepted/tizen_ivi_panda.tar.bz2 notification-accepted/tizen_ivi_panda.zip |
Merge branch 'tizen_2.2' of ssh://review.tizendev.org:29418/apps/home/notification into worksubmit/tizen_ivi_stable/20131116.100111submit/tizen_ivi_panda/20140403.011821submit/tizen/20131023.055614accepted/tizen_ivi_stable/20131116.101645accepted/tizen/ivi/panda/20140403.015148accepted/tizen/20131112.015237accepted/tizen/20131023.171112accepted/tizen/20131023.064031tizen_ivi_pandaaccepted/tizen_ivi_pandaaccepted/tizen_genericaccepted/tizen/ivi/stable
Conflicts:
packaging/notification.spec
src/notification_ipc.c
-rwxr-xr-x | CMakeLists.txt | 5 | ||||
-rwxr-xr-x | doc/notification_doc.h | 64 | ||||
-rwxr-xr-x | include/notification.h | 717 | ||||
-rwxr-xr-x | include/notification_db.h | 2 | ||||
-rwxr-xr-x | include/notification_debug.h | 6 | ||||
-rwxr-xr-x | include/notification_error.h | 1 | ||||
-rwxr-xr-x | include/notification_ipc.h | 5 | ||||
-rwxr-xr-x | include/notification_list.h | 5 | ||||
-rwxr-xr-x | include/notification_noti.h | 1 | ||||
-rwxr-xr-x | include/notification_setting.h | 42 | ||||
-rwxr-xr-x | include/notification_status.h | 31 | ||||
-rwxr-xr-x | include/notification_type.h | 171 | ||||
-rwxr-xr-x | packaging/notification.spec | 17 | ||||
-rwxr-xr-x | src/notification.c | 332 | ||||
-rwxr-xr-x | src/notification_db.c | 7 | ||||
-rwxr-xr-x | src/notification_ipc.c | 171 | ||||
-rwxr-xr-x | src/notification_noti.c | 286 | ||||
-rwxr-xr-x | src/notification_ongoing.c | 9 | ||||
-rwxr-xr-x | src/notification_setting.c | 351 | ||||
-rwxr-xr-x | src/notification_status.c | 14 |
20 files changed, 1252 insertions, 985 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a7ab9c8..bf6772f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,13 +18,15 @@ SET(SRCS ./src/notification.c ./src/notification_db.c ./src/notification_list.c ./src/notification_status.c - ./src/notification_ipc.c) + ./src/notification_ipc.c + ./src/notification_setting.c) SET(HEADERS ./include/notification.h ./include/notification_error.h ./include/notification_type.h ./include/notification_list.h ./include/notification_status.h ./include/notification_ipc.h + ./include/notification_setting.h ./include/notification_noti.h) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) @@ -37,7 +39,6 @@ pkg_check_modules(pkgs REQUIRED dlog ail aul - appsvc dbus-1 dbus-glib-1 com-core diff --git a/doc/notification_doc.h b/doc/notification_doc.h new file mode 100755 index 0000000..a767e1b --- /dev/null +++ b/doc/notification_doc.h @@ -0,0 +1,64 @@ +/* + * libnotification + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/** + * + * @ingroup NOTIFICATION_LIBRARY + * @defgroup NOTIFICATION_MODULE notification APIs + * @brief Notification APIs + * + * @section NOTIFICATION_MODULE_HEADER Required Header + * \#include <notification.h> + * @section NOTIFICATION_MODULE_OVERVIEW Overview + * It provides functions for creating and inserting and updating notification. + * + * @ingroup NOTIFICATION_LIBRARY + * @defgroup NOTIFICATION_LIST notification list APIs + * @brief linked list of notification data + * + * @section NOTIFICATION_LIST_MODULE_HEADER Required Header + * \#include <notification_list.h> + * @section NOTIFICATION_LIST_MODULE_OVERVIEW Overview + * It provides functions for handling + * + * @ingroup NOTIFICATION_LIBRARY + * @defgroup NOTIFICATION_STATUS notification status APIs + * @brief APIs displaying plain text message on the indicator area + * + * @section NOTIFICATION_STATUS_MODULE_HEADER Required Header + * \#include <notification_status.h> + * @section NOTIFICATION_STATUS_MODULE_OVERVIEW Overview + * Notification status APIs + * + * @ingroup NOTIFICATION_LIBRARY + * @defgroup NOTIFICATION_TYPE notification type + * @brief Type for notification APIs + * + * @section NOTIFICATION_TYPE_MODULE_HEADER Required Header + * \#include <notification_type.h> + * @section NOTIFICATION_TYPE_MODULE_OVERVIEW Overview + * Type defines and enumerations for Notification APIs + * + * @ingroup NOTIFICATION_LIBRARY + * @defgroup NOTIFICATION_DEPRECATED deprecated APIs + * @brief deprecated APIs + * + */ diff --git a/include/notification.h b/include/notification.h index 2534a09..ddc7e9c 100755 --- a/include/notification.h +++ b/include/notification.h @@ -29,45 +29,24 @@ #include <notification_type.h> #include <notification_list.h> #include <notification_status.h> +#include <notification_setting.h> #ifdef __cplusplus extern "C" { #endif /** - * @defgroup NOTIFICATION_LIBRARY Notification Library - * @brief This notification library provides UI notification event. Inserted notification event is displaying Notification Tray, Indicator, etc. + * @file notification.h + * @brief This file contains the notification APIs */ /** - * @ingroup NOTIFICATION_LIBRARY - * @defgroup NOTIFICATION notification core API - * @brief Notification core API - */ - -/** - * @addtogroup NOTIFICATION + * @addtogroup NOTIFICATION_MODULE * @{ */ /** - * @brief This function will be deprecated. - * @see notification_set_image() - * - */ -notification_error_e notification_set_icon(notification_h noti, - const char *icon_path); - -/** - * @brief This function will be deprecated. - * @see notification_get_image() - * - */ -notification_error_e notification_get_icon(notification_h noti, - char **icon_path); - -/** - * @brief This function set image path according to type. + * @brief Set absolute path for image file to display on notification view * @details * @remarks * @param[in] noti notification handle @@ -106,7 +85,7 @@ notification_error_e notification_set_image(notification_h noti, const char *image_path); /** - * @brief This function get image path according to type. + * @brief Get absolute path for image file * @details * @remarks Do not free image_path. It will be freed when notification_free() or notification_free_list(). * @param[in] noti notification handle @@ -139,7 +118,7 @@ notification_error_e notification_get_image(notification_h noti, char **image_path); /** - * @brief This function set time infomation. + * @brief Set a timestamp * @details If input_time is 0, time information is set by current time. * @remarks * @param[in] noti notification handle @@ -175,7 +154,7 @@ notification_error_e notification_set_time(notification_h noti, time_t input_time); /** - * @brief This function get time information. + * @brief Get a timestamp * @details If ret_time is 0, time information is not set before. * @remarks * @param[in] noti notification handle @@ -205,7 +184,7 @@ notification_error_e notification_get_time(notification_h noti, time_t * ret_time); /** - * @brief This function get insert time information. + * @brief Get timestamp that the notification is inserted * @details If ret_time is 0, this notification data is not inserted before. * @remarks * @param[in] noti notification handle @@ -235,43 +214,7 @@ notification_error_e notification_get_insert_time(notification_h noti, time_t * ret_time); /** - * @brief This function will be deprecated. - * @see notification_set_text() - * - */ -notification_error_e notification_set_title(notification_h noti, - const char *title, - const char *loc_title); - -/** - * @brief This function will be deprecated. - * @see notification_get_text() - * - */ -notification_error_e notification_get_title(notification_h noti, - char **title, - char **loc_title); - -/** - * @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); - -/** - * @brief This function will be deprecated. - * @see notification_get_text() - * - */ -notification_error_e notification_get_content(notification_h noti, - char **content, - char **loc_content); - -/** - * @brief This function set text. + * @brief Set text to display on the notification view * @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. * If %f, type NOTIFICATION_VARIABLE_TYPE_DOUBLE and value is double value. @@ -321,7 +264,7 @@ notification_error_e notification_set_text(notification_h noti, int args_type, ...); /** - * @brief This function get text. + * @brief Get the text from the notification handle * @details * @remarks * @param[in] noti notification handle @@ -354,8 +297,8 @@ notification_error_e notification_get_text(notification_h noti, char **text); /** - * @brief This function set timestamp to text. the timestamp value will be converted to string - * @details set + * @brief Set a timestamp to display on the notification view + * @details the timestamp will be converted to formatted string and it will be displayed on the setted text area * @remarks * @param[in] noti notification handle * @param[in] type notification text type @@ -371,8 +314,8 @@ notification_error_e notification_set_time_to_text(notification_h noti, notifica time_t time); /** - * @brief This function get timestamp from text - * @details set + * @brief Get a timestamp from the notification handle + * @details * @remarks * @param[in] noti notification handle * @param[in] type notification text type @@ -388,7 +331,7 @@ notification_error_e notification_get_time_from_text(notification_h noti, notifi time_t *time); /** - * @brief This function set text domain. + * @brief Set text domain to localize the notification * @details * @remarks * @param[in] noti notification handle @@ -426,7 +369,7 @@ notification_error_e notification_set_text_domain(notification_h noti, const char *dir); /** - * @brief This function get text domain. + * @brief Get text domain from the notification handle * @details * @remarks Do not free returned domain and dir. These are freed when notification_free or notification_free_list. * @param[in] noti notification handle @@ -460,7 +403,7 @@ notification_error_e notification_get_text_domain(notification_h noti, char **dir); /** - * @brief This function set notification sound. + * @brief Set sound option for the notification * @details * @remarks * @param[in] noti notification handle @@ -492,7 +435,7 @@ notification_error_e notification_set_sound(notification_h noti, const char *path); /** - * @brief This function get notification sound. + * @brief Get sound option from the notification handle * @details * @remarks * @param[in] noti notification handle @@ -525,7 +468,7 @@ notification_error_e notification_get_sound(notification_h noti, const char **path); /** - * @brief This function set notification vibration. + * @brief Set vibrate option for the notification * @details * @remarks * @param[in] noti notification handle @@ -557,7 +500,7 @@ notification_error_e notification_set_vibration(notification_h noti, const char *path); /** - * @brief This function get notification vibration. + * @brief Get vibrate option from the notification handle * @details * @remarks * @param[in] noti notification handle @@ -590,7 +533,7 @@ notification_error_e notification_get_vibration(notification_h noti, const char **path); /** - * @brief This function set led notification. + * @brief Set option of displaying the LED * @details * @remarks * @param[in] noti notification handle @@ -622,7 +565,7 @@ notification_error_e notification_set_led(notification_h noti, int led_argb); /** - * @brief This function get notification led. + * @brief Get option of displaying the LED from the notification handle * @details * @remarks * @param[in] noti notification handle @@ -655,7 +598,7 @@ notification_error_e notification_get_led(notification_h noti, int *led_argb); /** - * @brief This function set time period of flashing LED + * @brief Set time period of flashing the LED * @details * @remarks * @param[in] noti notification handle @@ -686,7 +629,7 @@ notification_error_e notification_set_led_time_period(notification_h noti, int on_ms, int off_ms); /** - * @brief This function get time period of flashing LED + * @brief Get time period of flashing the LED from the notification handle * @details * @remarks * @param[in] noti notification handle @@ -719,35 +662,7 @@ notification_error_e notification_get_led_time_period(notification_h noti, int *on_ms, int *off_ms); /** - * @brief This function will be deprecated. - * @see notification_set_execute_option() - * - */ -notification_error_e notification_set_application(notification_h noti, const char *pkgname); /* Do not use this */ - -/** - * @brief This function will be deprecated. - * @see notification_get_execute_option() - * - */ -notification_error_e notification_get_application(notification_h noti, char **pkgname); /* Do not use this */ - -/** - * @brief This function will be deprecated. - * @see notification_set_execute_option() - * - */ -notification_error_e notification_set_args(notification_h noti, bundle * args, bundle * group_args); /* Do not use this */ - -/** - * @brief This function will be deprecated. - * @see notification_get_execute_option() - * - */ -notification_error_e notification_get_args(notification_h noti, bundle ** args, bundle ** group_args); /* Do not use this */ - -/** - * @brief This function set execute option. + * @brief Set execution option for a notification * @details When notification data selected in display application, application launched by appsvc_run_service with service_handle. * @remarks * @param[in] noti notification handle @@ -793,7 +708,7 @@ notification_error_e notification_set_execute_option(notification_h noti, bundle *service_handle); /** - * @brief This function get execute option. + * @brief Get execution option from the notification handle * @details * @remarks * @param[in] noti notification handle @@ -831,7 +746,7 @@ notification_error_e notification_get_execute_option(notification_h noti, bundle **service_handle); /** - * @brief This function set notification property. + * @brief Set the property of the notification * @details * @remarks * @param[in] noti notification handle @@ -868,7 +783,7 @@ notification_error_e notification_set_property(notification_h noti, int flags); /** - * @brief This function get notification property. + * @brief Get the property of the notification from the notification handle * @details * @remarks * @param[in] noti notification handle @@ -899,7 +814,7 @@ notification_error_e notification_get_property(notification_h noti, int *flags); /** - * @brief This function set display application list. + * @brief Set applications to display the notification * @details All display application is enable(NOTIFICATION_DISPLAY_APP_ALL) if you are not call this API. * @remarks * @param[in] noti notification handle @@ -937,7 +852,7 @@ notification_error_e notification_set_display_applist(notification_h noti, int applist); /** - * @brief This function get display application list. + * @brief Get application list to display the notification from the notification handle * @details * @remarks * @param[in] noti notification handle @@ -968,7 +883,7 @@ notification_error_e notification_get_display_applist(notification_h noti, int *applist); /** - * @brief This function set initial size for ongoing type. + * @brief Set initial size for ongoing type. * @details After notification_insert, it does not upate size. If you want to update size, please call notification_update_size(). * @remarks * @param[in] noti notification handle @@ -1004,7 +919,7 @@ notification_error_e notification_set_size(notification_h noti, double size); /** - * @brief This function get progress size. + * @brief Get progress size. * @details * @remarks * @param[in] noti notification handle @@ -1035,7 +950,7 @@ notification_error_e notification_get_size(notification_h noti, double *size); /** - * @brief This function set initial progress for ongoing type. + * @brief Set initial progress for ongoing type. * @details After notification_insert, it does not upate progress. If you want to update progress, please call notification_update_progress(). * @remarks * @param[in] noti notification handle @@ -1071,9 +986,9 @@ notification_error_e notification_set_progress(notification_h noti, double percentage); /** - * @brief This function get progress percentage. + * @brief Get progress from the notification handle * @details - * @remarks + * @remarks At the end of the operation, progress should be 1.0 * @param[in] noti notification handle * @param[out] percentage progress percentage * @return NOTIFICATION_ERROR_NONE if success, other value if failure @@ -1102,7 +1017,7 @@ notification_error_e notification_get_progress(notification_h noti, double *percentage); /** - * @brief This function set caller_pkgname. + * @brief Set the package name of caller * @details caller_pkgname is set automatically when notification_new. We are not recommend to use this API. * @remarks * @param[in] noti notification handle @@ -1126,7 +1041,7 @@ notification_error_e notification_get_progress(notification_h noti, return; } - noti_err = notification_set_pkgname(noti, "org.tizen.phone"); + noti_err = notification_set_pkgname(noti, "com.samsung.phone"); if(noti_err != NOTIFICATION_ERROR_NONE) { notification_free(noti); return; @@ -1138,7 +1053,7 @@ notification_error_e notification_set_pkgname(notification_h noti, const char *pkgname); /** - * @brief This function get caller pkgname. + * @brief Get the package name of caller from the notification handle * @details * @remarks * @param[in] noti notification handle @@ -1169,11 +1084,11 @@ notification_error_e notification_get_pkgname(notification_h noti, char **pkgname); /** - * @brief This function set layout type of notification - * @details caller can set displaying layout of notification with this API + * @brief Set the layout of the notification view + * @details caller can set displaying layout of notification * @remarks * @param[in] noti notification handle - * @param[in] layout type + * @param[in] type of layout * @return NOTIFICATION_ERROR_NONE if success, other value if failure * @retval NOTIFICATION_ERROR_NONE - success * @retval NOTIFICATION_ERROR_INVALID_DATA - Invalide input value @@ -1185,11 +1100,11 @@ notification_error_e notification_set_layout(notification_h noti, notification_ly_type_e layout); /** - * @brief This function get layout type of notification + * @brief Get the layout of the notification view from the notification handle * @details * @remarks * @param[in] noti notification handle - * @param[out] layout type of notification + * @param[out] type of layout * @return NOTIFICATION_ERROR_NONE if success, other value if failure * @retval NOTIFICATION_ERROR_NONE - success * @retval NOTIFICATION_ERROR_INVALID_DATA - Invalide input value @@ -1201,68 +1116,9 @@ notification_error_e notification_get_layout(notification_h noti, notification_ly_type_e *layout); /** - * @brief This function set application badge count. - * @details - * @remarks - * @param[in] pkgname If NULL, caller pkgname is set internally. - * @param[in] group_id group id - * @param[in] count badge count - * @return NOTIFICATION_ERROR_NONE if success, other value if failure - * @retval NOTIFICATION_ERROR_NONE - success - * @retval NOTIFICATION_ERROR_INVALID_DATA - Invalide input value - * @pre - * @post - * @see - * @par Sample code: -#include <notification.h> - ... - { - notification_error_e noti_err = NOTIFICATION_ERROR_NONE; - - noti_err = notification_set_badge(NULL, NOTIFICATION_GROUP_ID_NONE, 5); - if(noti_err != NOTIFICATION_ERROR_NONE) { - return; - } - } - * @endcode - */ -notification_error_e notification_set_badge(const char *pkgname, - int group_id, int count); - -/** - * @brief This function get application badge count. + * @brief Get Group ID and Private ID * @details - * @remarks - * @param[in] pkgname If NULL, caller pkgname is set internally. - * @param[in] group_id group id - * @param[out] count badge count - * @return NOTIFICATION_ERROR_NONE if success, other value if failure - * @retval NOTIFICATION_ERROR_NONE - success - * @retval NOTIFICATION_ERROR_INVALID_DATA - Invalide input value - * @pre - * @post - * @see - * @par Sample code: -#include <notification.h> - ... - { - notification_error_e noti_err = NOTIFICATION_ERROR_NONE; - int count = 0; - - noti_err = notification_get_badge(NULL, NOTIFICATION_GROUP_ID_NONE, &count); - if(noti_err != NOTIFICATION_ERROR_NONE) { - return; - } - } - * @endcode - */ -notification_error_e notification_get_badge(const char *pkgname, - int group_id, int *count); - -/** - * @brief This function get Group ID and Private ID - * @details - * @remarks + * @remarks ID is valid only after inserting the notification * @param[in] noti notification handle * @param[out] group_id Group ID * @param[out] priv_id Private ID @@ -1291,7 +1147,7 @@ notification_error_e notification_get_id(notification_h noti, int *group_id, int *priv_id); /** - * @brief This function get notification type + * @brief Get the type of notification * @details * @remarks * @param[in] noti notification handle @@ -1321,8 +1177,8 @@ notification_error_e notification_get_type(notification_h noti, notification_type_e * type); /** - * @brief This function insert notification data. - * @details Notification data is inserted to DB and then notification data is displaying display application. + * @brief Insert a notification + * @details A notification will be inserted to DB and then it will be appeared on the notification area * When notification_new() call, if priv_id is NOTIFICATION_PRIV_ID_NONE, priv_id is return internally set priv_id. * @remarks * @param[in] noti notification handle @@ -1351,8 +1207,8 @@ notification_error_e notification_insert(notification_h noti, int *priv_id); /** - * @brief This function update notification data. - * @details Display application update UI. + * @brief Update notification data. + * @details The updated notification will be appeared on the notification area * @remarks * @param[in] noti notification handle that is created by notification_new(). * @return NOTIFICATION_ERROR_NONE if success, other value if failure @@ -1379,44 +1235,19 @@ notification_error_e notification_insert(notification_h noti, notification_error_e notification_update(notification_h noti); /** - * @brief This function clear all notification of type. - * @details Not recommand API. Only for notification tray's clear button operation. - * @remarks - * @param[in] type notification type - * @return NOTIFICATION_ERROR_NONE if success, other value if failure - * @retval NOTIFICATION_ERROR_NONE - success - * @retval NOTIFICATION_ERROR_INVALID_DATA - Invalide input value - * @pre - * @post - * @see #notification_type_e - * @par Sample code: - * @code -#include <notification.h> -... - { - notification_error_e noti_err = NOTIFICATION_ERROR_NONE; - - noti_err = notifiation_clear(NOTIFICATION_TYPE_NOTI); - if(noti_err != NOTIFICATION_ERROR_NONE) { - return; - } -} - * @endcode - */ -notification_error_e notifiation_clear(notification_type_e type); - -/** - * @brief This function delete notification by type. - * @details If pkgname is NULL, caller_pkgname is set internally. - * @remarks - * @param[in] pkgname caller application package name or NULL - * @param[in] type notification type + * @brief Update a notification + * @details The updated notification will be appeared on the notification area + * @remarks This function update a notification in async manner + * @param[in] noti notification handle that is created by notification_new(). + * @param[in] result_cb callback called when update completed + * @param[in] user_data user data which you want to use in callback * @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 + * @see #notification_h * @par Sample code: * @code #include <notification.h> @@ -1424,29 +1255,27 @@ notification_error_e notifiation_clear(notification_type_e type); { notification_error_e noti_err = NOTIFICATION_ERROR_NONE; - noti_err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NOTI); + noti_err = notification_update_async(NULL, result_cb, data); if(noti_err != NOTIFICATION_ERROR_NONE) { return; } } * @endcode */ -notification_error_e notification_delete_all_by_type(const char *pkgname, - notification_type_e type); +notification_error_e notification_update_async(notification_h noti, + void (*result_cb)(int priv_id, int result, void *data), void *user_data); /** - * @brief This function delete group notification data by group ID. - * @details If pkgname is NULL, caller_pkgname is set internally. + * @brief This function clear all notification of type. + * @details Not recommand API. Only for notification tray's clear button operation. * @remarks - * @param[in] pkgname caller application package name or NULL * @param[in] type notification type - * @param[in] group_id group ID * @return NOTIFICATION_ERROR_NONE if success, other value if failure * @retval NOTIFICATION_ERROR_NONE - success * @retval NOTIFICATION_ERROR_INVALID_DATA - Invalide input value * @pre * @post - * @see + * @see #notification_type_e * @par Sample code: * @code #include <notification.h> @@ -1454,24 +1283,21 @@ notification_error_e notification_delete_all_by_type(const char *pkgname, { notification_error_e noti_err = NOTIFICATION_ERROR_NONE; - noti_err = notification_delete_group_by_group_id(NULL, NOTIFICATION_TYPE_NOTI, APP_GROUP_ID); + noti_err = notifiation_clear(NOTIFICATION_TYPE_NOTI); if(noti_err != NOTIFICATION_ERROR_NONE) { return; } } * @endcode */ -notification_error_e notification_delete_group_by_group_id(const char *pkgname, - notification_type_e type, - int group_id); +notification_error_e notifiation_clear(notification_type_e type); /** - * @brief This function delete group notification data that include priv_id. + * @brief Delete all the notifications of the type. * @details If pkgname is NULL, caller_pkgname is set internally. * @remarks * @param[in] pkgname caller application package name or NULL * @param[in] type notification type - * @param[in] priv_id priv ID * @return NOTIFICATION_ERROR_NONE if success, other value if failure * @retval NOTIFICATION_ERROR_NONE - success * @retval NOTIFICATION_ERROR_INVALID_DATA - Invalide input value @@ -1485,19 +1311,18 @@ notification_error_e notification_delete_group_by_group_id(const char *pkgname, { notification_error_e noti_err = NOTIFICATION_ERROR_NONE; - noti_err = notification_delete_group_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, APP_PRIV_ID); + noti_err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NOTI); if(noti_err != NOTIFICATION_ERROR_NONE) { return; } } * @endcode */ -notification_error_e notification_delete_group_by_priv_id(const char *pkgname, - notification_type_e type, - int priv_id); +notification_error_e notification_delete_all_by_type(const char *pkgname, + notification_type_e type); /** - * @brief This function delete notification data that private ID is priv_id. + * @brief Delete a notification by priv_id. * @details If pkgname is NULL, caller_pkgname is set internally. * @remarks * @param[in] pkgname caller application package name or NULL @@ -1528,7 +1353,7 @@ notification_error_e notification_delete_by_priv_id(const char *pkgname, int priv_id); /** - * @brief This function delete notification data from DB + * @brief Delete a notification with the given handle * @details notification_delete() remove notification data from DB and notification_free release menory of notification data. * @remarks * @param[in] noti notification handle @@ -1559,8 +1384,8 @@ notification_error_e notification_delete_by_priv_id(const char *pkgname, notification_error_e notification_delete(notification_h noti); /** - * @brief This function update progressive data of inserted notification data. Only work at NOTIFICATION_TYPE_ONGOING type. - * @details Display application update UI. + * @brief Update progress of inserted notification. Only for the ongoing notification(NOTIFICATION_TYPE_ONGOING) + * @details notification view on notification area could be updated * @remarks * @param[in] noti notification handle or NULL if priv_id is valid * @param[in] priv_id private ID @@ -1589,8 +1414,8 @@ notification_error_e notification_update_progress(notification_h noti, double progress); /** - * @brief This function update progressive data of inserted notification data. Only work at NOTIFICATION_TYPE_ONGOING type. - * @details Display application update UI. + * @brief Update size of inserted notification data. Only for the ongoing notification(NOTIFICATION_TYPE_ONGOING) + * @details notification view on notification area could be updated * @remarks * @param[in] noti notification handle or NULL if priv_id is valid * @param[in] priv_id private ID @@ -1617,12 +1442,38 @@ notification_error_e notification_update_progress(notification_h noti, notification_error_e notification_update_size(notification_h noti, int priv_id, double size); +/** + * @brief Update content of inserted notification data. Only for the ongoing notification(NOTIFICATION_TYPE_ONGOING) + * @details notification view on notification area could be updated + * @remarks + * @param[in] noti notification handle or NULL if priv_id is valid + * @param[in] priv_id private ID + * @param[in] content text to update + * @return NOTIFICATION_ERROR_NONE if success, other value if failure + * @retval NOTIFICATION_ERROR_NONE - success + * @retval NOTIFICATION_ERROR_INVALID_DATA - Invalide input value + * @pre + * @post + * @par Sample code: + * @code +#include <notification.h> +... + { + notification_error_e noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_update_content(NULL, APP_NOTI_PRIV_ID, "updated string"); + if(noti_err != NOTIFICATION_ERROR_NONE) { + return; + } +} + * @endcode + */ 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. + * @brief Create internal structure data and return notification handle. * @details Available type is #NOTIFICATION_TYPE_NOTI and #NOTIFICATION_TYPE_ONGOING. * #NOTIFICATION_TYPE_NOTI is remaining notification data evenif device is restarted. * #NOTIFICATION_TYPE_ONGOING can display progressive feather, but notification data is removed after device is restarted. @@ -1691,14 +1542,8 @@ notification_h notification_new(notification_type_e type, int group_id, notification_h notification_create(notification_type_e type); /** - * @brief This function create internal structure data and return notification handle. - * @details Available type is #NOTIFICATION_TYPE_NOTI and #NOTIFICATION_TYPE_ONGOING. - * #NOTIFICATION_TYPE_NOTI is remaining notification data evenif device is restarted. - * #NOTIFICATION_TYPE_ONGOING can display progressive feather, but notification data is removed after device is restarted. - * If group_id is #NOTIFICATION_GROUP_ID_NONE, notification data is not grouping. #NOTIFICATION_GROUP_ID_DEFAULT, - * notification data is grouping with same title. Positive number ( > 0 ) is grouping with same number. - * If priv_id is #NOTIFICATION_PRIV_ID_NONE, priv_id is set internally and return it when notification_insert() call. - * Positive number and zero ( >= 0 ) is application set private ID. These ID should have be unique each application package. + * @brief load a notification from the notification DB with private id + * @details * @remarks * @param[in] type notification type * @param[in] group_id Group ID @@ -1717,7 +1562,7 @@ notification_h notification_create(notification_type_e type); { notification_h noti = NULL; - noti = notification_load(NOTIFICATION_TYPE_NOTI, APP_GROUP_ID, NOTIFICATION_PRIV_ID_NONE); + noti = notification_load("org.tizen.app", priv_id); if(noti == NULL) { return; } @@ -1729,7 +1574,7 @@ notification_h notification_load(char *pkgname, int priv_id); /** - * @brief This function create notification clone. + * @brief Create a notification clone * @details Newly created notification handle is returned. * @remarks This clone notification handle should be call notification_free(). * @param[in] noti notification handle @@ -1757,7 +1602,7 @@ notification_h notification_load(char *pkgname, notification_error_e notification_clone(notification_h noti, notification_h *clone); /** - * @brief This function free internal structure data of notification handle. + * @brief Free internal structure data of notification handle. * @details Internal data of notification handle is released. Notification data that inserted is not deleted. * @remarks * @param[in] noti notification handle @@ -1791,267 +1636,240 @@ notification_error_e notification_clone(notification_h noti, notification_h *clo notification_error_e notification_free(notification_h noti); /** - * @brief This function register notification chagned callback. - * @details - * @remarks - * @param[in] changed_cb callback function - * @param[in] user_data user data - * @return NOTIFICATION_ERROR_NONE if success, other value if failure. - * @retval NOTIFICATION_ERROR_NONE - success - * @retval NOTIFICATION_ERROR_INVALID_DATA - invalid parameter - * @pre notification_new() - * @post - * @see notification_unresister_changed_cb() - * @par Sample code: - * @code -#include <notification.h> -... -{ - noti_err = notification_resister_changed_cb(app_changed_cb, user_data); - if(noti_err != NOTIFICATION_ERROR_NONE) { - return; - } -} - * @endcode + * @} */ -notification_error_e -notification_resister_changed_cb( - void (*changed_cb)(void *data, notification_type_e type), - void *user_data); /** - * @brief This function unregister notification chagned callback. - * @details + * @addtogroup NOTIFICATION_LIST + * @{ + */ + +/** + * @brief This function return notification list handle. + * @details If count is -1, all of notification list is returned. * @remarks - * @param[in] changed_cb callback function + * @param[in] type notification type + * @param[in] count returned notification data number + * @param[out] NOTIFICATION_ERROR_NONE if success, other value if failure. * @return NOTIFICATION_ERROR_NONE if success, other value if failure. * @retval NOTIFICATION_ERROR_NONE - success * @retval NOTIFICATION_ERROR_INVALID_DATA - invalid parameter - * @pre notification_new() + * @pre * @post - * @see notification_resister_changed_cb() + * @see #notification_list_h * @par Sample code: * @code #include <notification.h> ... { - noti_err = notification_unresister_changed_cb(app_changed_cb); + notification_list_h noti_list = NULL; + notification_error_e noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list); if(noti_err != NOTIFICATION_ERROR_NONE) { return; } } * @endcode */ -notification_error_e -notification_unresister_changed_cb( - void (*changed_cb)(void *data, notification_type_e type)); +notification_error_e notification_get_list(notification_type_e type, + int count, + notification_list_h * list); /** - * @brief This function register notification chagned callback. - * @details + * @brief This function will be deprecated. + * @see notification_get_grouping_list() + * + */ +notification_error_e notification_get_grouping_list(notification_type_e type, + int count, + notification_list_h *list); + +/** + * @brief This function return notification detail list handle of grouping data. + * @details If count is -1, all of notification list is returned. * @remarks - * @param[in] changed_cb callback function - * @param[in] user_data user data + * @param[in] pkgname caller application package name + * @param[in] group_id group id + * @param[in] priv_id private id + * @param[in] count returned notification data number + * @param[out] list notification list handle * @return NOTIFICATION_ERROR_NONE if success, other value if failure. * @retval NOTIFICATION_ERROR_NONE - success * @retval NOTIFICATION_ERROR_INVALID_DATA - invalid parameter - * @pre notification_new() + * @pre * @post - * @see notification_unresister_changed_cb() + * @see #notification_list_h * @par Sample code: * @code #include <notification.h> ... { - noti_err = notification_resister_changed_cb(app_changed_cb, user_data); + notification_list_h noti_list = NULL; + notification_error_e noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_get_detail_list(pkgname, group_id, priv_id, -1, ¬i_list); if(noti_err != NOTIFICATION_ERROR_NONE) { return; } } * @endcode */ -notification_error_e -notification_register_detailed_changed_cb( - void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op), - void *user_data); +notification_error_e notification_get_detail_list(const char *pkgname, + int group_id, + int priv_id, + int count, + notification_list_h *list); /** - * @brief This function unregister notification chagned callback. + * @brief Free notification list * @details * @remarks - * @param[in] changed_cb callback function + * @param[in] list notification list handle * @return NOTIFICATION_ERROR_NONE if success, other value if failure. * @retval NOTIFICATION_ERROR_NONE - success * @retval NOTIFICATION_ERROR_INVALID_DATA - invalid parameter - * @pre notification_new() + * @pre notification_get_grouping_list() or notification_get_detail_list () * @post - * @see notification_resister_changed_cb() + * @see #notification_list_h * @par Sample code: * @code #include <notification.h> ... { - noti_err = notification_unresister_changed_cb(app_changed_cb); + notification_list_h noti_list = NULL; + notification_error_e noti_err = NOTIFICATION_ERROR_NONE; + + ... + + noti_err = notification_free_list(noti_list); if(noti_err != NOTIFICATION_ERROR_NONE) { return; } } * @endcode */ -notification_error_e -notification_unregister_detailed_changed_cb( - void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op), - void *user_data); +notification_error_e notification_free_list(notification_list_h list); + +/** + * @} + */ /** - * @brief This function get notification data count. - * @details Count is the result of the conditions that type, pkgname, group_id, priv_id. + * @brief Register a callback for all notification events + * @details The registered callback could be called for all notification events * @remarks - * @param[in] type notification type - * @param[in] pkgname caller application package name - * @param[in] group_id group id - * @param[in] priv_id private id - * @param[out] count notification data number + * @param[in] changed_cb callback function + * @param[in] user_data user data * @return NOTIFICATION_ERROR_NONE if success, other value if failure. * @retval NOTIFICATION_ERROR_NONE - success * @retval NOTIFICATION_ERROR_INVALID_DATA - invalid parameter - * @pre + * @pre notification_new() * @post - * @see #notification_type_e + * @see notification_unresister_changed_cb() * @par Sample code: * @code #include <notification.h> ... { - notification_list_h noti_list = NULL; - notification_error_e noti_err = NOTIFICATION_ERROR_NONE; - int count = 0; - - noti_err = notification_get_count(NOTIFICATION_TYPE_NONE, NULL, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE, &count); + noti_err = notification_resister_changed_cb(app_changed_cb, user_data); if(noti_err != NOTIFICATION_ERROR_NONE) { return; } } * @endcode */ -notification_error_e notification_get_count(notification_type_e type, - const char *pkgname, - int group_id, int priv_id, - int *count); - -/** - * @brief This function will be deprecated. - * @see notification_get_grouping_list() - * - */ -notification_error_e notification_get_list(notification_type_e type, - int count, - notification_list_h * list); +notification_error_e +notification_resister_changed_cb( + void (*changed_cb)(void *data, notification_type_e type), + void *user_data); /** - * @brief This function return notification grouping list handle. - * @details If count is -1, all of notification list is returned. + * @brief Unregister a callback for all notification events + * @details * @remarks - * @param[in] type notification type - * @param[in] count returned notification data number - * @param[out] list notification list handle + * @param[in] changed_cb callback function * @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_list_h + * @see notification_resister_changed_cb() * @par Sample code: * @code #include <notification.h> ... { - notification_list_h noti_list = NULL; - notification_error_e noti_err = NOTIFICATION_ERROR_NONE; - - noti_err = notification_get_grouping_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list); + noti_err = notification_unresister_changed_cb(app_changed_cb); if(noti_err != NOTIFICATION_ERROR_NONE) { return; } } * @endcode */ -notification_error_e notification_get_grouping_list(notification_type_e type, - int count, - notification_list_h *list); +notification_error_e +notification_unresister_changed_cb( + void (*changed_cb)(void *data, notification_type_e type)); /** - * @brief This function return notification detail list handle of grouping data. - * @details If count is -1, all of notification list is returned. + * @brief Register a callback for all notification events + * @details The registered callback could be called for all notification events * @remarks - * @param[in] pkgname caller application package name - * @param[in] group_id group id - * @param[in] priv_id private id - * @param[in] count returned notification data number - * @param[out] list notification list handle + * @param[in] changed_cb callback function + * @param[in] user_data user data * @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_list_h + * @see notification_unregister_detailed_changed_cb() * @par Sample code: * @code #include <notification.h> ... { - notification_list_h noti_list = NULL; - notification_error_e noti_err = NOTIFICATION_ERROR_NONE; - - noti_err = notification_get_detail_list(pkgname, group_id, priv_id, -1, ¬i_list); + noti_err = notification_resister_changed_cb(app_changed_cb, user_data); if(noti_err != NOTIFICATION_ERROR_NONE) { return; } } * @endcode */ -notification_error_e notification_get_detail_list(const char *pkgname, - int group_id, - int priv_id, - int count, - notification_list_h *list); +notification_error_e +notification_register_detailed_changed_cb( + void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op), + void *user_data); /** - * @brief This function release notification list. + * @brief Unregister a callback for all notification events * @details * @remarks - * @param[in] list notification list handle + * @param[in] changed_cb callback function * @return NOTIFICATION_ERROR_NONE if success, other value if failure. * @retval NOTIFICATION_ERROR_NONE - success * @retval NOTIFICATION_ERROR_INVALID_DATA - invalid parameter - * @pre notification_get_grouping_list() or notification_get_detail_list () + * @pre * @post - * @see #notification_list_h + * @see notification_register_detailed_changed_cb() * @par Sample code: * @code #include <notification.h> ... { - notification_list_h noti_list = NULL; - notification_error_e noti_err = NOTIFICATION_ERROR_NONE; - - ... - - noti_err = notification_free_list(noti_list); + noti_err = notification_unresister_changed_cb(app_changed_cb); if(noti_err != NOTIFICATION_ERROR_NONE) { return; } } * @endcode */ -notification_error_e notification_free_list(notification_list_h list); - -/** - * @} - */ +notification_error_e +notification_unregister_detailed_changed_cb( + void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op), + void *user_data); /** - * @brief You can get the information about notification operation using this function + * @brief Get the information of notification event * @details * @remarks * @param[in] list notification list handle @@ -2080,6 +1898,121 @@ notification_error_e notification_add_deffered_task( notification_error_e notification_del_deffered_task( void (*deffered_task_cb)(void *data)); +/** + * @addtogroup NOTIFICATION_DEPRECATED + * @{ + */ + +/** + * @brief This function will be deprecated. + * @see notification_set_image() + * + */ +notification_error_e notification_set_icon(notification_h noti, + const char *icon_path); + +/** + * @brief This function will be deprecated. + * @see notification_get_image() + * + */ +notification_error_e notification_get_icon(notification_h noti, + char **icon_path); + +/** + * @brief This function will be deprecated. + * @see notification_set_text() + * + */ +notification_error_e notification_set_title(notification_h noti, + const char *title, + const char *loc_title); + +/** + * @brief This function will be deprecated. + * @see notification_get_text() + * + */ +notification_error_e notification_get_title(notification_h noti, + char **title, + char **loc_title); + +/** + * @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); + +/** + * @brief This function will be deprecated. + * @see notification_get_text() + * + */ +notification_error_e notification_get_content(notification_h noti, + char **content, + char **loc_content); + +/** + * @brief This function will be deprecated. + * @see notification_set_execute_option() + * + */ +notification_error_e notification_set_application(notification_h noti, const char *pkgname); /* Do not use this */ + +/** + * @brief This function will be deprecated. + * @see notification_get_execute_option() + * + */ +notification_error_e notification_get_application(notification_h noti, char **pkgname); /* Do not use this */ + +/** + * @brief This function will be deprecated. + * @see notification_set_execute_option() + * + */ +notification_error_e notification_set_args(notification_h noti, bundle * args, bundle * group_args); /* Do not use this */ + +/** + * @brief This function will be deprecated. + * @see notification_get_execute_option() + * + */ +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_delete_by_priv_id() + * + */ +notification_error_e notification_delete_group_by_group_id(const char *pkgname, + notification_type_e type, + int group_id); + +/** + * @brief This function will be deprecated. + * @see notification_delete_by_priv_id() + * + */ +notification_error_e notification_delete_group_by_priv_id(const char *pkgname, + notification_type_e type, + int priv_id); +/** + * @brief This function will be deprecated. + * + */ +notification_error_e notification_get_count(notification_type_e type, + const char *pkgname, + int group_id, int priv_id, + int *count); + +/** + * @} + */ + #ifdef __cplusplus } #endif diff --git a/include/notification_db.h b/include/notification_db.h index 171e5af..c9e3f79 100755 --- a/include/notification_db.h +++ b/include/notification_db.h @@ -44,7 +44,7 @@ sqlite3 *notification_db_open(const char *dbfile); int notification_db_close(sqlite3 ** db); -int notification_db_exec(sqlite3 * db, const char *query); +int notification_db_exec(sqlite3 * db, const char *query, int *num_changes); char *notification_db_column_text(sqlite3_stmt * stmt, int col); diff --git a/include/notification_debug.h b/include/notification_debug.h index 1950cd7..114a2ee 100755 --- a/include/notification_debug.h +++ b/include/notification_debug.h @@ -22,7 +22,7 @@ #ifndef __NOTIFICATION_DEBUG_H__ #define __NOTIFICATION_DEBUG_H__ -#define LOG_TAG "notification" +#define LOG_TAG "NOTIFICATION" #include <dlog.h> #ifndef EXPORT_API @@ -66,12 +66,12 @@ #define NOTIFICATION_WARN(fmt , args...) \ do{ \ - LOGI("[%s : %d] "fmt"\n",__func__,__LINE__,##args ); \ + LOGW("[%s : %d] "fmt"\n",__func__,__LINE__,##args ); \ } while(0) #define NOTIFICATION_ERR(fmt , args...) \ do{ \ - LOGI("[%s : %d] "fmt"\n",__func__,__LINE__,##args ); \ + LOGE("[%s : %d] "fmt"\n",__func__,__LINE__,##args ); \ } while(0) #endif /* _DLOG_H_ */ diff --git a/include/notification_error.h b/include/notification_error.h index 75512a2..9e0d114 100755 --- a/include/notification_error.h +++ b/include/notification_error.h @@ -40,6 +40,7 @@ typedef enum _notification_error { NOTIFICATION_ERROR_NOT_EXIST_ID = -6, /**< Not exist private ID */ NOTIFICATION_ERROR_IO = -7, /**< disk i/o error */ NOTIFICATION_ERROR_SERVICE_NOT_READY = -8, /**< no reponse from master */ + NOTIFICATION_ERROR_PERMISSION_DENIED = -9, /**< Permission denied */ } notification_error_e; /** diff --git a/include/notification_ipc.h b/include/notification_ipc.h index 29f5b49..8c7681b 100755 --- a/include/notification_ipc.h +++ b/include/notification_ipc.h @@ -41,6 +41,8 @@ struct packet *notification_ipc_make_packet_from_noti(notification_h noti, const notification_error_e notification_ipc_request_insert(notification_h noti, int *priv_id); notification_error_e notification_ipc_request_update(notification_h noti); +notification_error_e notification_ipc_request_update_async(notification_h noti, + void (*result_cb)(int priv_id, int result, void *data), void *user_data); notification_error_e notification_ipc_request_refresh(void); notification_error_e notification_ipc_request_delete_single(notification_type_e type, char *pkgname, int priv_id); notification_error_e notification_ipc_request_delete_multiple(notification_type_e type, char *pkgname); @@ -48,6 +50,9 @@ notification_error_e notification_ipc_request_delete_multiple(notification_type_ notification_error_e notification_ipc_add_deffered_task(void (*deffered_task_cb)(void *data), void *user_data); notification_error_e notification_ipc_del_deffered_task(void (*deffered_task_cb)(void *data)); +notification_error_e notification_ipc_noti_setting_property_set(const char *pkgname, const char *property, const char *value); +notification_error_e notification_ipc_noti_setting_property_get(const char *pkgname, const char *property, char **value); + #ifdef __cplusplus } #endif diff --git a/include/notification_list.h b/include/notification_list.h index adeb790..1a8082b 100755 --- a/include/notification_list.h +++ b/include/notification_list.h @@ -29,9 +29,8 @@ extern "C" { #endif /** - * @ingroup NOTIFICATION_LIBRARY - * @defgroup NOTIFICATION_LIST notification list - * @brief Notification List API + * @file notification.h + * @brief This file contains the notification list APIs */ /** diff --git a/include/notification_noti.h b/include/notification_noti.h index 77d960b..0c40bab 100755 --- a/include/notification_noti.h +++ b/include/notification_noti.h @@ -48,6 +48,7 @@ int notification_noti_delete_group_by_priv_id(const char *pkgname, int priv_id); int notification_noti_get_by_priv_id(notification_h noti, char *pkgname, int priv_id); int notification_noti_delete_by_priv_id(const char *pkgname, int priv_id); +int notification_noti_delete_by_priv_id_get_changes(const char *pkgname, int priv_id, int *num_changes); notification_error_e notification_noti_get_count(notification_type_e type, const char *pkgname, diff --git a/include/notification_setting.h b/include/notification_setting.h new file mode 100755 index 0000000..9e86d5b --- /dev/null +++ b/include/notification_setting.h @@ -0,0 +1,42 @@ +/* + * libnotification + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __NOTIFICATION_SETTING_H__ +#define __NOTIFICATION_SETTING_H__ + +#include <notification.h> + +typedef struct _notification_setting_h notification_setting_h; + +#ifdef __cplusplus +extern "C" { +#endif + +notification_error_e notification_setting_db_set(const char *pkgname, const char *property, const char *value); +notification_error_e notification_setting_db_get(const char *pkgname, const char *property, char **value); + +notification_error_e notification_setting_property_set(const char *pkgname, const char *property, const char *value); +notification_error_e notification_setting_property_get(const char *pkgname, const char *property, char **value); + +#ifdef __cplusplus +} +#endif +#endif /* __NOTIFICATION_SETTING_H__ */ diff --git a/include/notification_status.h b/include/notification_status.h index 8a98865..2a05f48 100755 --- a/include/notification_status.h +++ b/include/notification_status.h @@ -27,23 +27,6 @@ extern "C" { #endif /* __cplusplus */ /** - * @ingroup NOTIFICATION_LIBRARY - * @defgroup NOTIFICATION_STATUS_LIBRARY notification status library - * @brief This notification status library used to display simple plain message on small popup - */ - -/** - * @ingroup NOTIFICATION_STATUS_LIBRARY - * @defgroup NOTIFICATION_STATUS_LIBRARY_TYPE notification status library type - * @brief type used by notification status library - */ - -/** - * @addtogroup NOTIFICATION_STATUS_LIBRARY_TYPE - * @{ - */ - -/** * @brief Called when new message is posted * @param[in] message The message posted * @param[in] data user data @@ -53,15 +36,6 @@ extern "C" { typedef void (*notification_status_message_cb)(const char *message, void *data); /** - * @} - */ - -/** - * @addtogroup NOTIFICATION_STATUS_LIBRARY - * @{ - */ - -/** * @brief register callback for receiving message * @param[in] callback The callback function * @param[in] data user_data @@ -76,6 +50,11 @@ int notification_status_monitor_message_cb_set(notification_status_message_cb ca int notification_status_monitor_message_cb_unset(void); /** + * @addtogroup NOTIFICATION_STATUS + * @{ + */ + +/** * @brief This function send string(message) to notification status monitor * @details Send the message to notification status monitor. * @param[in] message messages you want to post diff --git a/include/notification_type.h b/include/notification_type.h index 1431bae..8aad6ef 100755 --- a/include/notification_type.h +++ b/include/notification_type.h @@ -27,9 +27,8 @@ extern "C" { #endif /** - * @ingroup NOTIFICATION_LIBRARY - * @defgroup NOTIFICATION_TYPE notification type - * @brief Notification type + * @file notification_type.h + * @brief This file contains defines and enumerations for Notification APIs */ /** @@ -38,41 +37,20 @@ extern "C" { */ /** - * @brief Enumeration for notification operation code - */ -typedef enum _notification_op_type { - NOTIFICATION_OP_NONE = 0, - NOTIFICATION_OP_INSERT = 1, - NOTIFICATION_OP_UPDATE, - NOTIFICATION_OP_DELETE, - NOTIFICATION_OP_DELETE_ALL, - NOTIFICATION_OP_REFRESH, - NOTIFICATION_OP_SERVICE_READY, -} notification_op_type_e; - -/** - * @brief Enumeration for notification operation data code - */ -typedef enum _notification_op_data_type { - NOTIFICATION_OP_DATA_MIN = 0, - NOTIFICATION_OP_DATA_TYPE, - NOTIFICATION_OP_DATA_PRIV_ID, - NOTIFICATION_OP_DATA_NOTI, - NOTIFICATION_OP_DATA_EXTRA_INFO_1, - NOTIFICATION_OP_DATA_EXTRA_INFO_2, - NOTIFICATION_OP_DATA_MAX, -} notification_op_data_type_e; - -/** * @brief Enumeration for notification layout type */ typedef enum _notification_ly_type { NOTIFICATION_LY_NONE = 0, NOTIFICATION_LY_NOTI_EVENT_SINGLE, + /**< layout for notification. used to inform single event*/ NOTIFICATION_LY_NOTI_EVENT_MULTIPLE, + /**< layout for notification. used to inform multiple event*/ NOTIFICATION_LY_NOTI_THUMBNAIL, + /**< layout for notification. used to display images*/ NOTIFICATION_LY_ONGOING_EVENT, + /**< layout for ongoing notification. used to display text message*/ NOTIFICATION_LY_ONGOING_PROGRESS, + /**< layout for ongoing notification. used to display progress*/ NOTIFICATION_LY_MAX, } notification_ly_type_e; @@ -81,9 +59,9 @@ typedef enum _notification_ly_type { */ typedef enum _notification_sound_type { NOTIFICATION_SOUND_TYPE_NONE = -1, - /**< Default value. Disable sound */ + /**< Default value. no sound */ NOTIFICATION_SOUND_TYPE_DEFAULT = 0, - /**< New chat sound */ + /**< default sound */ NOTIFICATION_SOUND_TYPE_USER_DATA, /**< User sound data */ NOTIFICATION_SOUND_TYPE_MAX, @@ -95,8 +73,8 @@ typedef enum _notification_sound_type { */ typedef enum _notification_vibration_type { NOTIFICATION_VIBRATION_TYPE_NONE = -1, - /**< Default value. Disable vibration */ - NOTIFICATION_VIBRATION_TYPE_DEFAULT = 0,/**< New chat vibration */ + /**< Default value. no vibration */ + NOTIFICATION_VIBRATION_TYPE_DEFAULT = 0,/**< default vibrate pattern */ NOTIFICATION_VIBRATION_TYPE_USER_DATA, /**< User vibration data */ NOTIFICATION_VIBRATION_TYPE_MAX,/**< Max flag */ @@ -107,10 +85,10 @@ typedef enum _notification_vibration_type { */ typedef enum _notification_led_op { NOTIFICATION_LED_OP_OFF = -1, - /**< Default value. Disable led */ - NOTIFICATION_LED_OP_ON = 0,/**< turn on led with default color */ + /**< Default value. Disable the LED notification */ + NOTIFICATION_LED_OP_ON = 0,/**< turn on the LED with default color */ NOTIFICATION_LED_OP_ON_CUSTOM_COLOR, - /**< turn on led with custom color */ + /**< turn on the LED with custom color */ NOTIFICATION_LED_OP_MAX,/**< Max flag */ } notification_led_op_e; @@ -126,39 +104,6 @@ typedef enum _notification_count_display_type { } notification_count_display_type_e; /** - * @brief Enumeration for notification count position in the text. - */ -typedef enum _notifcation_count_pos_type { - NOTIFICATION_COUNT_POS_NONE = -1, - /**< Count data is not displaying in the text */ - NOTIFICATION_COUNT_POS_LEFT = 0,/**< Count data is displaying at the left of the text */ - NOTIFICATION_COUNT_POS_IN, - /**< Count data is displaying in the text */ - NOTIFICATION_COUNT_POS_RIGHT, - /**< Count data is displaying at the right of the text */ - NOTIFICATION_COUNT_POS_MAX, - /**< Max flag */ -} notification_count_pos_type_e; - -/** - * @brief Enumeration for notification variable parameter type - */ -typedef enum _notification_variable_type { - NOTIFICATION_VARIABLE_TYPE_NONE = -1, - /**< Variable parameter type is NONE */ - NOTIFICATION_VARIABLE_TYPE_INT = 0, - /**< Variable parameter type is int */ - NOTIFICATION_VARIABLE_TYPE_DOUBLE, - /**< Variable parameter type is double */ - NOTIFICATION_VARIABLE_TYPE_STRING, - /**< Variable parameter type is string */ - NOTIFICATION_VARIABLE_TYPE_COUNT, - /**< Variable parameter type is count */ - NOTIFICATION_VARIABLE_TYPE_MAX, - /**< Max flag */ -} notification_variable_type_e; - -/** * @brief Enumeration for notification text type. */ typedef enum _notification_text_type { @@ -175,15 +120,15 @@ typedef enum _notification_text_type { NOTIFICATION_TEXT_TYPE_INFO_1, /**< box contents 1 */ NOTIFICATION_TEXT_TYPE_INFO_SUB_1, - /**< box contents 2 */ + /**< box contents 1-1 */ NOTIFICATION_TEXT_TYPE_INFO_2, - /**< box contents 3 */ + /**< box contents 2 */ NOTIFICATION_TEXT_TYPE_INFO_SUB_2, - /**< box contents 4 */ + /**< box contents 2-1 */ NOTIFICATION_TEXT_TYPE_INFO_3, - /**< box contents 5 */ + /**< box contents 3 */ NOTIFICATION_TEXT_TYPE_INFO_SUB_3, - /**< box contents 5 */ + /**< box contents 3-1 */ NOTIFICATION_TEXT_TYPE_GROUP_TITLE, /**< Group title */ NOTIFICATION_TEXT_TYPE_GROUP_CONTENT, @@ -215,15 +160,15 @@ typedef enum _notification_image_type { NOTIFICATION_IMAGE_TYPE_BACKGROUND, /**< image displayed on background */ NOTIFICATION_IMAGE_TYPE_LIST_1, - /**< image for multiple event */ + /**< image for thumbnail list */ NOTIFICATION_IMAGE_TYPE_LIST_2, - /**< image for multiple event */ + /**< image for thumbnail list */ NOTIFICATION_IMAGE_TYPE_LIST_3, - /**< image for multiple event */ + /**< image for thumbnail list */ NOTIFICATION_IMAGE_TYPE_LIST_4, - /**< image for multiple event */ + /**< image for thumbnail list */ NOTIFICATION_IMAGE_TYPE_LIST_5, - /**< image for multiple event */ + /**< image for thumbnail list */ NOTIFICATION_IMAGE_TYPE_MAX, /**< Max flag */ } notification_image_type_e; @@ -243,7 +188,7 @@ typedef enum _notification_execute_type { NOTIFICATION_EXECUTE_TYPE_NONE = -1, /**< No operation */ NOTIFICATION_EXECUTE_TYPE_RESPONDING = 0, - /**< Responding */ + /**< Responding action*/ NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,/**< Launching when notification data is single */ NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, /**< Launching when notification data is grouping(multi) */ @@ -318,6 +263,69 @@ enum _notificaton_display_applist { }; /** + * @} + */ + +/** + * @brief Enumeration for notification operation code + */ +typedef enum _notification_op_type { + NOTIFICATION_OP_NONE = 0, + NOTIFICATION_OP_INSERT = 1, + NOTIFICATION_OP_UPDATE, + NOTIFICATION_OP_DELETE, + NOTIFICATION_OP_DELETE_ALL, + NOTIFICATION_OP_REFRESH, + NOTIFICATION_OP_SERVICE_READY, +} notification_op_type_e; + +/** + * @brief Enumeration for notification operation data code + */ +typedef enum _notification_op_data_type { + NOTIFICATION_OP_DATA_MIN = 0, + NOTIFICATION_OP_DATA_TYPE, + NOTIFICATION_OP_DATA_PRIV_ID, + NOTIFICATION_OP_DATA_NOTI, + NOTIFICATION_OP_DATA_EXTRA_INFO_1, + NOTIFICATION_OP_DATA_EXTRA_INFO_2, + NOTIFICATION_OP_DATA_MAX, +} notification_op_data_type_e; + +/** + * @brief Enumeration for notification count position in the text. + */ +typedef enum _notifcation_count_pos_type { + NOTIFICATION_COUNT_POS_NONE = -1, + /**< Count data is not displaying in the text */ + NOTIFICATION_COUNT_POS_LEFT = 0,/**< Count data is displaying at the left of the text */ + NOTIFICATION_COUNT_POS_IN, + /**< Count data is displaying in the text */ + NOTIFICATION_COUNT_POS_RIGHT, + /**< Count data is displaying at the right of the text */ + NOTIFICATION_COUNT_POS_MAX, + /**< Max flag */ +} notification_count_pos_type_e; + +/** + * @brief Enumeration for notification variable parameter type + */ +typedef enum _notification_variable_type { + NOTIFICATION_VARIABLE_TYPE_NONE = -1, + /**< Variable parameter type is NONE */ + NOTIFICATION_VARIABLE_TYPE_INT = 0, + /**< Variable parameter type is int */ + NOTIFICATION_VARIABLE_TYPE_DOUBLE, + /**< Variable parameter type is double */ + NOTIFICATION_VARIABLE_TYPE_STRING, + /**< Variable parameter type is string */ + NOTIFICATION_VARIABLE_TYPE_COUNT, + /**< Variable parameter type is count */ + NOTIFICATION_VARIABLE_TYPE_MAX, + /**< Max flag */ +} notification_variable_type_e; + +/** * @brief Notification handle */ typedef struct _notification *notification_h; @@ -332,9 +340,6 @@ typedef struct _notification_op { int extra_info_2; notification_h noti; } notification_op; -/** - * @} - */ #ifdef __cplusplus } diff --git a/packaging/notification.spec b/packaging/notification.spec index 076308f..555c043 100755 --- a/packaging/notification.spec +++ b/packaging/notification.spec @@ -14,7 +14,6 @@ BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(ail) BuildRequires: pkgconfig(aul) -BuildRequires: pkgconfig(appsvc) BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(com-core) BuildRequires: pkgconfig(ecore) @@ -47,9 +46,17 @@ make %{?jobs:-j%jobs} %install %make_install +mkdir -p %{buildroot}/usr/share/license +cp -f LICENSE.APLv2.0 %{buildroot}/usr/share/license/%{name} + %post /sbin/ldconfig +if [ ! -d /opt/dbspace ] +then + mkdir /opt/dbspace +fi + if [ ! -f /opt/dbspace/.notification.db ] then sqlite3 /opt/dbspace/.notification.db 'PRAGMA journal_mode = PERSIST; @@ -136,20 +143,18 @@ chown :5000 /opt/dbspace/.notification.db chown :5000 /opt/dbspace/.notification.db-journal chmod 660 /opt/dbspace/.notification.db chmod 660 /opt/dbspace/.notification.db-journal +chsmack -a 'notification::db' /opt/dbspace/.notification.db* vconftool set -t string memory/private/libstatus/message "" -i -g 5000 %postun -p /sbin/ldconfig %files -%manifest %{name}.manifest -%license LICENSE.APLv2.0 %manifest notification.manifest %defattr(-,root,root,-) -%{_libdir}/libnotification.so.* +%{_libdir}/libnotification.so* +/usr/share/license/%{name} %files devel -%manifest %{name}.manifest %defattr(-,root,root,-) %{_includedir}/notification/*.h -%{_libdir}/libnotification.so %{_libdir}/pkgconfig/notification.pc diff --git a/src/notification.c b/src/notification.c index 8c85a90..27a440f 100755 --- a/src/notification.c +++ b/src/notification.c @@ -30,7 +30,6 @@ #include <aul.h> #include <ail.h> -#include <appsvc.h> #include <vconf-keys.h> #include <vconf.h> @@ -64,12 +63,6 @@ static notification_cb_list_s *g_notification_cb_list = NULL; #define NOTI_TEXT_RESULT_LEN 2048 #define NOTI_PKGNAME_LEN 512 -#define NOTI_CHANGED_NOTI "notification_noti_changed" -#define NOTI_CHANGED_ONGOING "notification_ontoing_changed" - -#define NOTI_DBUS_BUS_NAME "org.tizen.libnotification" -#define NOTI_DBUS_PATH "/org/tizen/libnotification" -#define NOTI_DBUS_INTERFACE "org.tizen.libnotification.signal" static char *_notification_get_pkgname_by_pid(void) { @@ -117,62 +110,6 @@ static char *_notification_get_pkgname_by_pid(void) return dup_pkgname; } -static char *_notification_get_icon(const char *package) -{ - ail_appinfo_h handle; - ail_error_e ret; - char *str = NULL; - char *icon = NULL; - - ret = ail_package_get_appinfo(package, &handle); - if (ret != AIL_ERROR_OK) { - return NULL; - } - - ret = ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &str); - if (ret != AIL_ERROR_OK) { - ail_package_destroy_appinfo(handle); - return NULL; - } - - icon = strdup(str); - - ret = ail_package_destroy_appinfo(handle); - if (ret != AIL_ERROR_OK) { - NOTIFICATION_ERR("Fail to ail_package_destroy_appinfo"); - } - - return icon; -} - -static char *_notification_get_name(const char *package) -{ - ail_appinfo_h handle; - ail_error_e ret; - char *str = NULL; - char *name = NULL; - - ret = ail_package_get_appinfo(package, &handle); - if (ret != AIL_ERROR_OK) { - return NULL; - } - - ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str); - if (ret != AIL_ERROR_OK) { - ail_package_destroy_appinfo(handle); - return NULL; - } - - name = strdup(str); - - ret = ail_package_destroy_appinfo(handle); - if (ret != AIL_ERROR_OK) { - NOTIFICATION_ERR("Fail to ail_package_destroy_appinfo"); - } - - return name; -} - static void _notification_get_text_domain(notification_h noti) { if (noti->domain != NULL) { @@ -277,7 +214,6 @@ EXPORT_API notification_error_e notification_get_image(notification_h noti, bundle *b = NULL; char buf_key[32] = { 0, }; const char *ret_val = NULL; - const char *pkgname = NULL; /* Check noti and image_path is valid data */ if (noti == NULL || image_path == NULL) { @@ -315,31 +251,7 @@ EXPORT_API notification_error_e notification_get_image(notification_h noti, /* image path will be app icon path */ *image_path = noti->app_icon_path; } else { - /* Get image path using launch_pkgname */ - if (noti->launch_pkgname != NULL) { - noti->app_icon_path = - _notification_get_icon(noti->launch_pkgname); - } - - /* If app icon path is NULL, get image path using caller_pkgname */ - if (noti->app_icon_path == NULL - && noti->caller_pkgname != NULL) { - noti->app_icon_path = - _notification_get_icon(noti->caller_pkgname); - } - - /* If app icon path is NULL, get image path using service data */ - if (noti->app_icon_path == NULL - && noti->b_service_single_launch != NULL) { - pkgname = - appsvc_get_pkgname(noti->b_service_single_launch); - if (pkgname != NULL) { - noti->app_icon_path = - _notification_get_icon(pkgname); - } - } - - *image_path = noti->app_icon_path; + *image_path = NULL; } } @@ -745,11 +657,8 @@ EXPORT_API notification_error_e notification_get_text(notification_h noti, bundle *b = NULL; char buf_key[32] = { 0, }; const char *ret_val = NULL; - const char *pkgname = NULL; const char *get_str = NULL; const char *get_check_type_str = NULL; - int ret = 0; - int boolval = 0; notification_text_type_e check_type = NOTIFICATION_TEXT_TYPE_NONE; int display_option_flag = 0; @@ -1095,46 +1004,7 @@ EXPORT_API notification_error_e notification_get_text(notification_h noti, } } else { - if (check_type == NOTIFICATION_TEXT_TYPE_TITLE - || check_type == NOTIFICATION_TEXT_TYPE_GROUP_TITLE) { - /* Remove app name if exist, because pkgname is changed according to language setting */ - if (noti->app_name != NULL) { - free(noti->app_name); - noti->app_name = NULL; - } - - /* First, get app name from launch_pkgname */ - if (noti->launch_pkgname != NULL) { - noti->app_name = - _notification_get_name(noti-> - launch_pkgname); - } - - /* Second, get app name from caller_pkgname */ - if (noti->app_name == NULL - && noti->caller_pkgname != NULL) { - noti->app_name = - _notification_get_name(noti-> - caller_pkgname); - } - - /* Third, get app name from service data */ - if (noti->app_name == NULL - && noti->b_service_single_launch != NULL) { - pkgname = - appsvc_get_pkgname(noti-> - b_service_single_launch); - - if (pkgname != NULL) { - noti->app_name = - _notification_get_name(pkgname); - } - } - - *text = noti->app_name; - } else { - *text = NULL; - } + *text = NULL; } return NOTIFICATION_ERROR_NONE; @@ -1218,8 +1088,6 @@ EXPORT_API notification_error_e notification_get_time_from_text(notification_h n time_t *time) { notification_error_e ret = NOTIFICATION_ERROR_NONE; - char buf[256] = { 0, }; - char buf_tag[512] = { 0, }; if (noti == NULL) { return NOTIFICATION_ERROR_INVALID_DATA; @@ -1580,44 +1448,48 @@ EXPORT_API notification_error_e notification_set_execute_option(notification_h n } switch (type) { - case NOTIFICATION_EXECUTE_TYPE_RESPONDING: - /* Remove previous data if exist */ - if (noti->b_service_responding != NULL) { - bundle_free(noti->b_service_responding); - noti->b_service_responding = NULL; - } + case NOTIFICATION_EXECUTE_TYPE_RESPONDING: + /* Remove previous data if exist */ + if (noti->b_service_responding != NULL) { + bundle_free(noti->b_service_responding); + noti->b_service_responding = NULL; + } - /* Save service handle */ - if (service_handle != NULL) { - noti->b_service_responding = bundle_dup(service_handle); - } - break; - case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH: - /* Remove previous data if exist */ - if (noti->b_service_single_launch != NULL) { - bundle_free(noti->b_service_single_launch); - noti->b_service_single_launch = NULL; - } + /* Save service handle */ + if (service_handle != NULL) { + noti->b_service_responding = bundle_dup(service_handle); + } + break; + case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH: + /* Remove previous data if exist */ + if (noti->b_service_single_launch != NULL) { + bundle_free(noti->b_service_single_launch); + noti->b_service_single_launch = NULL; + } - /* Save service handle */ - if (service_handle != NULL) { - noti->b_service_single_launch = - bundle_dup(service_handle); - } - break; - case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH: - /* Remove previous data if exist */ - if (noti->b_service_multi_launch != NULL) { - bundle_free(noti->b_service_multi_launch); - noti->b_service_multi_launch = NULL; - } + /* Save service handle */ + if (service_handle != NULL) { + noti->b_service_single_launch = + bundle_dup(service_handle); + } + break; + case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH: + /* Remove previous data if exist */ + if (noti->b_service_multi_launch != NULL) { + bundle_free(noti->b_service_multi_launch); + noti->b_service_multi_launch = NULL; + } - /* Save service handle */ - if (service_handle != NULL) { - noti->b_service_multi_launch = - bundle_dup(service_handle); - } - break; + /* Save service handle */ + if (service_handle != NULL) { + noti->b_service_multi_launch = + bundle_dup(service_handle); + } + break; + case NOTIFICATION_EXECUTE_TYPE_NONE: + case NOTIFICATION_EXECUTE_TYPE_MAX: + NOTIFICATION_ERR("invalid execution type"); + break; } return NOTIFICATION_ERROR_NONE; @@ -1892,75 +1764,6 @@ EXPORT_API notification_error_e notification_get_layout(notification_h noti, return NOTIFICATION_ERROR_NONE; } -EXPORT_API notification_error_e notification_set_badge(const char *pkgname, - int group_id, int count) -{ - char *caller_pkgname = NULL; - int ret = NOTIFICATION_ERROR_NONE; - - /* Check count is valid count */ - if (count < 0) { - return NOTIFICATION_ERROR_INVALID_DATA; - } - - /* Check pkgname */ - if (pkgname == NULL) { - caller_pkgname = _notification_get_pkgname_by_pid(); - - /* Set count into Group DB */ - ret = - notification_group_set_badge(caller_pkgname, group_id, - count); - - if (caller_pkgname != NULL) { - free(caller_pkgname); - } - } else { - /* Set count into Group DB */ - ret = notification_group_set_badge(pkgname, group_id, count); - } - - return ret; -} - -EXPORT_API notification_error_e notification_get_badge(const char *pkgname, - int group_id, int *count) -{ - char *caller_pkgname = NULL; - int ret = NOTIFICATION_ERROR_NONE; - int ret_unread_count = 0; - - /* Check pkgname */ - if (pkgname == NULL) { - caller_pkgname = _notification_get_pkgname_by_pid(); - - /* Get count from Group DB */ - ret = - notification_group_get_badge(caller_pkgname, group_id, - &ret_unread_count); - - if (caller_pkgname != NULL) { - free(caller_pkgname); - } - } else { - /* Get count from Group DB */ - ret = - notification_group_get_badge(pkgname, group_id, - &ret_unread_count); - } - - if (ret != NOTIFICATION_ERROR_NONE) { - return ret; - } - - /* Set count */ - if (count != NULL) { - *count = ret_unread_count; - } - - return NOTIFICATION_ERROR_NONE; -} - EXPORT_API notification_error_e notification_get_id(notification_h noti, int *group_id, int *priv_id) { @@ -2057,6 +1860,23 @@ EXPORT_API notification_error_e notification_update(notification_h noti) return NOTIFICATION_ERROR_NONE; } +EXPORT_API notification_error_e notification_update_async(notification_h noti, + void (*result_cb)(int priv_id, int result, void *data), void *user_data) +{ + int ret = 0; + + /* Check noti is valid data */ + if (noti != NULL) { + /* Update insert time ? */ + noti->insert_time = time(NULL); + ret = notification_ipc_request_update_async(noti, result_cb, user_data); + if (ret != NOTIFICATION_ERROR_NONE) { + return ret; + } + } + return NOTIFICATION_ERROR_NONE; +} + EXPORT_API notification_error_e notifiation_clear(notification_type_e type) { int ret = 0; @@ -2083,6 +1903,9 @@ EXPORT_API notification_error_e notification_delete_all_by_type(const char *pkgn ret = notification_ipc_request_delete_multiple(type, caller_pkgname); if (ret != NOTIFICATION_ERROR_NONE) { + if (caller_pkgname) { + free(caller_pkgname); + } return ret; } @@ -2107,6 +1930,9 @@ EXPORT_API notification_error_e notification_delete_group_by_group_id(const char ret = notification_ipc_request_delete_multiple(type, caller_pkgname); if (ret != NOTIFICATION_ERROR_NONE) { + if (caller_pkgname) { + free(caller_pkgname); + } return ret; } @@ -2131,6 +1957,9 @@ EXPORT_API notification_error_e notification_delete_group_by_priv_id(const char ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id); if (ret != NOTIFICATION_ERROR_NONE) { + if (caller_pkgname) { + free(caller_pkgname); + } return ret; } @@ -2159,6 +1988,9 @@ EXPORT_API notification_error_e notification_delete_by_priv_id(const char *pkgna ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id); if (ret != NOTIFICATION_ERROR_NONE) { + if (caller_pkgname) { + free(caller_pkgname); + } return ret; } @@ -2352,12 +2184,11 @@ EXPORT_API notification_h notification_load(char *pkgname, int ret = 0; notification_h noti = NULL; - noti = (notification_h) malloc(sizeof(struct _notification)); + noti = (notification_h) calloc(1, sizeof(struct _notification)); if (noti == NULL) { NOTIFICATION_ERR("NO MEMORY : noti == NULL"); return NULL; } - memset(noti, 0x00, sizeof(struct _notification)); ret = notification_noti_get_by_priv_id(noti, pkgname, priv_id); if (ret != NOTIFICATION_ERROR_NONE) { @@ -2377,12 +2208,11 @@ EXPORT_API notification_error_e notification_clone(notification_h noti, notifica return NOTIFICATION_ERROR_INVALID_DATA; } - new_noti = (notification_h) malloc(sizeof(struct _notification)); + new_noti = (notification_h) calloc(1, 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->layout = noti->layout; @@ -2760,24 +2590,6 @@ notification_unregister_detailed_changed_cb( return NOTIFICATION_ERROR_INVALID_DATA; } -EXPORT_API notification_error_e -notification_resister_badge_changed_cb(void (*changed_cb) - (void *data, const char *pkgname, - int group_id), void *user_data) -{ - // Add DBus signal handler - return NOTIFICATION_ERROR_NONE; -} - -EXPORT_API notification_error_e -notification_unresister_badge_changed_cb(void (*changed_cb) - (void *data, const char *pkgname, - int group_id)) -{ - // Del DBus signal handler - return NOTIFICATION_ERROR_NONE; -} - EXPORT_API notification_error_e notification_get_count(notification_type_e type, const char *pkgname, int group_id, diff --git a/src/notification_db.c b/src/notification_db.c index 6cfa2d6..0bc01e7 100755 --- a/src/notification_db.c +++ b/src/notification_db.c @@ -31,8 +31,6 @@ #include <notification_debug.h> #include <notification_db.h> -#define SDFTET "/opt/dbspace/.notification_noti.db" - sqlite3 *notification_db_open(const char *dbfile) { int ret = 0; @@ -66,7 +64,7 @@ int notification_db_close(sqlite3 ** db) return NOTIFICATION_ERROR_NONE; } -int notification_db_exec(sqlite3 * db, const char *query) +int notification_db_exec(sqlite3 * db, const char *query, int *num_changes) { int ret = 0; char *err_msg = NULL; @@ -81,6 +79,9 @@ int notification_db_exec(sqlite3 * db, const char *query) sqlite3_free(err_msg); return NOTIFICATION_ERROR_FROM_DB; } + if (num_changes != NULL) { + *num_changes = sqlite3_changes(db); + } return NOTIFICATION_ERROR_NONE; } diff --git a/src/notification_ipc.c b/src/notification_ipc.c index 9ac5e3f..1ea374a 100755 --- a/src/notification_ipc.c +++ b/src/notification_ipc.c @@ -36,10 +36,12 @@ #include <notification_internal.h> #include <notification_debug.h> -#define NOTIFICATION_IPC_TIMEOUT 1.0 +#define NOTIFICATION_IPC_TIMEOUT 0.0 static struct info { int server_fd; + int server_cl_fd; + int server_cl_fd_ref_cnt; int client_fd; const char *socket_file; struct { @@ -50,6 +52,8 @@ static struct info { int is_started_cb_set_svc; } s_info = { .server_fd = -1, + .server_cl_fd = -1, + .server_cl_fd_ref_cnt = 0, .client_fd = -1, .socket_file = NOTIFICATION_ADDR, .initialized = 0, @@ -65,6 +69,11 @@ struct _task_list { void *data; }; +typedef struct _result_cb_item { + void (*result_cb)(int priv_id, int result, void *data); + void *data; +} result_cb_item; + static task_list *g_task_list; static Eina_Bool _do_deffered_task(void *data); @@ -175,6 +184,7 @@ static Eina_Bool _do_deffered_task(void *data) { task_list *list_do = NULL; task_list *list_temp = NULL; + if (g_task_list) { list_do = g_task_list; g_task_list = NULL; @@ -776,6 +786,7 @@ notification_error_e notification_ipc_monitor_init(void) NOTIFICATION_ERR("register a service\n"); + com_core_packet_use_thread(1); s_info.server_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table); if (s_info.server_fd < 0) { NOTIFICATION_ERR("Failed to make a connection to the master\n"); @@ -785,6 +796,7 @@ notification_error_e notification_ipc_monitor_init(void) packet = packet_create("service_register", ""); if (!packet) { NOTIFICATION_ERR("Failed to build a packet\n"); + com_core_packet_client_fini(s_info.server_fd); return NOTIFICATION_ERROR_IO; } @@ -943,6 +955,106 @@ notification_error_e notification_ipc_request_update(notification_h noti) return status; } +static int _notification_ipc_update_cb(pid_t pid, int handle, const struct packet *packet, void *data) +{ + int status = 0; + int id = NOTIFICATION_PRIV_ID_NONE; + result_cb_item *cb_item = (result_cb_item *)data; + + if (cb_item == NULL) { + NOTIFICATION_ERR("Failed to get a callback item"); + return NOTIFICATION_ERROR_INVALID_DATA; + } + s_info.server_cl_fd_ref_cnt = (s_info.server_cl_fd_ref_cnt <= 1) ? 0 : s_info.server_cl_fd_ref_cnt - 1; + if (s_info.server_cl_fd_ref_cnt <= 0) { + NOTIFICATION_DBG("REFCNT: %d (fd: %d)", s_info.server_cl_fd_ref_cnt, s_info.server_cl_fd); + int fd_temp = s_info.server_cl_fd; + s_info.server_cl_fd = -1; + com_core_packet_client_fini(fd_temp); + NOTIFICATION_DBG("FD(%d) finalized", fd_temp); + } + + if (packet != NULL) { + if (packet_get(packet, "ii", &status, &id) != 2) { + NOTIFICATION_ERR("Failed to get a result packet"); + status = NOTIFICATION_ERROR_IO; + } + } + + if (cb_item->result_cb != NULL) { + cb_item->result_cb(id, status, cb_item->data); + } + free(cb_item); + + return status; +} + +notification_error_e notification_ipc_request_update_async(notification_h noti, + void (*result_cb)(int priv_id, int result, void *data), void *user_data) +{ + int ret = NOTIFICATION_ERROR_NONE; + int ret_con = 0; + struct packet *packet = NULL; + result_cb_item *cb_item = NULL; + + packet = notification_ipc_make_packet_from_noti(noti, "update_noti", 1); + if (packet == NULL) { + ret = NOTIFICATION_ERROR_INVALID_DATA; + goto fail; + } + + cb_item = calloc(1, sizeof(result_cb_item)); + if (cb_item == NULL) { + ret = NOTIFICATION_ERROR_NO_MEMORY; + goto fail; + } + + if (s_info.server_cl_fd < 0) { + com_core_packet_use_thread(1); + s_info.server_cl_fd = com_core_packet_client_init(s_info.socket_file, 0, NULL); + if (s_info.server_cl_fd < 0) { + NOTIFICATION_DBG("Failed to init client: %d", s_info.server_cl_fd); + ret = NOTIFICATION_ERROR_SERVICE_NOT_READY; + goto fail; + } + s_info.server_cl_fd_ref_cnt = 1; + } else { + s_info.server_cl_fd_ref_cnt++; + } + + cb_item->result_cb = result_cb; + cb_item->data = user_data; + + NOTIFICATION_INFO("Connection count:%d, fd:%d", s_info.server_cl_fd_ref_cnt, s_info.server_cl_fd); + + ret_con = com_core_packet_async_send(s_info.server_cl_fd, packet, 0.0f, + _notification_ipc_update_cb, cb_item); + if (ret_con < 0) { + NOTIFICATION_ERR("Failed to request update, %d\n", ret_con); + s_info.server_cl_fd_ref_cnt = (s_info.server_cl_fd_ref_cnt <= 1) ? 0 : s_info.server_cl_fd_ref_cnt - 1; + if (s_info.server_cl_fd_ref_cnt <= 0) { + int fd_temp = s_info.server_cl_fd; + s_info.server_cl_fd = -1; + com_core_packet_client_fini(fd_temp); + NOTIFICATION_INFO("FD(%d) finalized", fd_temp); + } + ret = NOTIFICATION_ERROR_IO; + goto fail; + } else { + ret = NOTIFICATION_ERROR_NONE; + goto success; + } + +fail: + if (cb_item) free(cb_item); + NOTIFICATION_ERR("Err: %d\n", ret); + +success: + if (packet) packet_destroy(packet); + + return ret; +} + notification_error_e notification_ipc_request_refresh(void) { int status = 0; @@ -968,3 +1080,60 @@ notification_error_e notification_ipc_request_refresh(void) return status; } + +notification_error_e notification_ipc_noti_setting_property_set(const char *pkgname, const char *property, const char *value) +{ + int status = 0; + int ret = 0; + struct packet *packet; + struct packet *result; + + packet = packet_create("set_noti_property", "sss", pkgname, property, value); + result = com_core_packet_oneshot_send(NOTIFICATION_ADDR, + packet, + NOTIFICATION_IPC_TIMEOUT); + packet_destroy(packet); + + if (result != NULL) { + if (packet_get(result, "ii", &status, &ret) != 2) { + NOTIFICATION_ERR("Failed to get a result packet"); + packet_unref(result); + return NOTIFICATION_ERROR_IO; + } + packet_unref(result); + } else { + return NOTIFICATION_ERROR_SERVICE_NOT_READY; + } + + return status; +} + +notification_error_e notification_ipc_noti_setting_property_get(const char *pkgname, const char *property, char **value) +{ + int status = 0; + char *ret = NULL; + struct packet *packet; + struct packet *result; + + packet = packet_create("get_noti_property", "ss", pkgname, property); + result = com_core_packet_oneshot_send(NOTIFICATION_ADDR, + packet, + NOTIFICATION_IPC_TIMEOUT); + packet_destroy(packet); + + if (result != NULL) { + if (packet_get(result, "is", &status, &ret) != 2) { + NOTIFICATION_ERR("Failed to get a result packet"); + packet_unref(result); + return NOTIFICATION_ERROR_IO; + } + if (status == NOTIFICATION_ERROR_NONE && ret != NULL) { + *value = strdup(ret); + } + packet_unref(result); + } else { + return NOTIFICATION_ERROR_SERVICE_NOT_READY; + } + + return status; +} diff --git a/src/notification_noti.c b/src/notification_noti.c index 996465e..0c447fb 100755 --- a/src/notification_noti.c +++ b/src/notification_noti.c @@ -31,6 +31,17 @@ #include <notification_debug.h> #include <notification_internal.h> +#define NOTI_BURST_DELETE_UNIT 10 + +static void __free_and_set(void **target_ptr, void *new_ptr) { + if (target_ptr != NULL) { + if (*target_ptr != NULL) { + free(*target_ptr); + } + *target_ptr = new_ptr; + } +} + static int _notification_noti_bind_query_text(sqlite3_stmt * stmt, const char *name, const char *str) { @@ -111,43 +122,6 @@ static int _notification_noti_check_priv_id(notification_h noti, sqlite3 * db) return NOTIFICATION_ERROR_NONE; } -static int _notification_noti_get_priv_id(notification_h noti, sqlite3 * db) -{ - sqlite3_stmt *stmt = NULL; - char query[NOTIFICATION_QUERY_MAX] = { 0, }; - int ret = NOTIFICATION_ERROR_NONE, result = 0; - - /* Make query to get max priv_id */ - snprintf(query, sizeof(query), - "select max(priv_id) from noti_list where caller_pkgname = '%s'", - noti->caller_pkgname); - - ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL); - if (ret != SQLITE_OK) { - NOTIFICATION_ERR("Get count DB err(%d) : %s", ret, - sqlite3_errmsg(db)); - return NOTIFICATION_ERROR_FROM_DB; - } - - ret = sqlite3_step(stmt); - if (ret == SQLITE_ROW) { - result = sqlite3_column_int(stmt, 0); - } else { - result = 0; - } - - sqlite3_finalize(stmt); - - if (result < 0) { - return NOTIFICATION_ERROR_FROM_DB; - } - - /* Increase result(max priv_id value) for next priv_id */ - noti->priv_id = result + 1; - - return NOTIFICATION_ERROR_NONE; -} - static int _notification_noti_get_internal_group_id_by_priv_id(const char *pkgname, int priv_id, sqlite3 * db) @@ -179,129 +153,6 @@ static int _notification_noti_get_internal_group_id_by_priv_id(const char *pkgna return result; } -static int _notification_noti_get_max_internal_group_id(notification_h noti, - sqlite3 * db) -{ - sqlite3_stmt *stmt = NULL; - char query[NOTIFICATION_QUERY_MAX] = { 0, }; - int ret = NOTIFICATION_ERROR_NONE, result = 0; - - /* Get max internal group id */ - snprintf(query, sizeof(query), - "select max(internal_group_id) from noti_list"); - - ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL); - if (ret != SQLITE_OK) { - NOTIFICATION_ERR("Get count DB err(%d) : %s", ret, - sqlite3_errmsg(db)); - return NOTIFICATION_ERROR_FROM_DB; - } - - ret = sqlite3_step(stmt); - if (ret == SQLITE_ROW) { - result = sqlite3_column_int(stmt, 0); - } else { - result = 0; - } - - sqlite3_finalize(stmt); - - return result; -} - -static int _notification_noti_get_internal_group_id(notification_h noti, - sqlite3 * db) -{ - sqlite3_stmt *stmt = NULL; - char query[NOTIFICATION_QUERY_MAX] = { 0, }; - int ret = NOTIFICATION_ERROR_NONE, result = 0; - const char *ret_title = NULL; - char buf_key[32] = { 0, }; - - if (noti->group_id == NOTIFICATION_GROUP_ID_NONE) { - /* If Group ID is NONE Get max internal group ID */ - result = _notification_noti_get_max_internal_group_id(noti, db); - if (result < 0) { - return NOTIFICATION_ERROR_FROM_DB; - } - - /* Internal Group ID is max internal group ID + 1 */ - noti->internal_group_id = result + 1; - - return NOTIFICATION_ERROR_NONE; - } else if (noti->group_id == NOTIFICATION_GROUP_ID_DEFAULT) { - /* If Group ID is DEFAULT, Get internal group id if it exist */ - if (noti->b_key != NULL) { - snprintf(buf_key, sizeof(buf_key), "%d", - NOTIFICATION_TEXT_TYPE_TITLE); - - ret_title = bundle_get_val(noti->b_key, buf_key); - } - - if (ret_title == NULL && noti->b_text != NULL) { - snprintf(buf_key, sizeof(buf_key), "%d", - NOTIFICATION_TEXT_TYPE_TITLE); - - ret_title = bundle_get_val(noti->b_text, buf_key); - } - - if (ret_title == NULL) { - ret_title = noti->caller_pkgname; - } - - snprintf(query, sizeof(query), - "select internal_group_id from noti_list where title_key = $title_key and group_id = %d", - NOTIFICATION_GROUP_ID_DEFAULT); - } else { - /* If Group ID is > DEFAULT, Get internal group id if it exit */ - snprintf(query, sizeof(query), - "select internal_group_id from noti_list where caller_pkgname = '%s' and group_id = %d", - NOTIFICATION_CHECK_STR(noti->caller_pkgname), - noti->group_id); - } - - ret = sqlite3_prepare_v2(db, query, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - NOTIFICATION_ERR("Select Query : %s", query); - NOTIFICATION_ERR("Select DB error(%d) : %s", ret, - sqlite3_errmsg(db)); - if (stmt) { - sqlite3_finalize(stmt); - } - return NOTIFICATION_ERROR_FROM_DB; - } - - /* Bind query */ - if (ret_title != NULL) { - ret = - _notification_noti_bind_query_text(stmt, "$title_key", - NOTIFICATION_CHECK_STR - (ret_title)); - if (ret != NOTIFICATION_ERROR_NONE) { - NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db)); - if (stmt) { - sqlite3_finalize(stmt); - } - return ret; - } - } - - ret = sqlite3_step(stmt); - if (ret == SQLITE_ROW) { - result = sqlite3_column_int(stmt, 0); - } else { - /* If there is not internal_group_id, create new one */ - result = _notification_noti_get_max_internal_group_id(noti, db); - result++; - } - - sqlite3_finalize(stmt); - - noti->internal_group_id = result; - - return NOTIFICATION_ERROR_NONE; -} - static int _notification_noti_make_query(notification_h noti, char *query, int query_size) { @@ -616,8 +467,8 @@ static void _notification_noti_populate_from_stmt(sqlite3_stmt * stmt, notificat noti->type = sqlite3_column_int(stmt, col++); noti->layout = sqlite3_column_int(stmt, col++); - noti->caller_pkgname = notification_db_column_text(stmt, col++); - noti->launch_pkgname = notification_db_column_text(stmt, col++); + __free_and_set((void **)&(noti->caller_pkgname), notification_db_column_text(stmt, col++)); + __free_and_set((void **)&(noti->launch_pkgname), notification_db_column_text(stmt, col++)); noti->b_image_path = notification_db_column_bundle(stmt, col++); noti->group_id = sqlite3_column_int(stmt, col++); noti->internal_group_id = 0; @@ -628,8 +479,8 @@ static void _notification_noti_populate_from_stmt(sqlite3_stmt * stmt, notificat noti->b_format_args = notification_db_column_bundle(stmt, col++); noti->num_format_args = sqlite3_column_int(stmt, col++); - noti->domain = notification_db_column_text(stmt, col++); - noti->dir = notification_db_column_text(stmt, col++); + __free_and_set((void **)&(noti->domain), notification_db_column_text(stmt, col++)); + __free_and_set((void **)&(noti->dir), notification_db_column_text(stmt, col++)); noti->time = sqlite3_column_int(stmt, col++); noti->insert_time = sqlite3_column_int(stmt, col++); noti->args = notification_db_column_bundle(stmt, col++); @@ -643,9 +494,9 @@ static void _notification_noti_populate_from_stmt(sqlite3_stmt * stmt, notificat notification_db_column_bundle(stmt, col++); noti->sound_type = sqlite3_column_int(stmt, col++); - noti->sound_path = notification_db_column_text(stmt, col++); + __free_and_set((void **)&(noti->sound_path), notification_db_column_text(stmt, col++)); noti->vibration_type = sqlite3_column_int(stmt, col++); - noti->vibration_path = notification_db_column_text(stmt, col++); + __free_and_set((void **)&(noti->vibration_path), notification_db_column_text(stmt, col++)); noti->led_operation = sqlite3_column_int(stmt, col++); noti->led_argb = sqlite3_column_int(stmt, col++); noti->led_on_ms = sqlite3_column_int(stmt, col++); @@ -666,7 +517,7 @@ static notification_h _notification_noti_get_item(sqlite3_stmt * stmt) { notification_h noti = NULL; - noti = malloc(sizeof(struct _notification)); + noti = (notification_h) calloc(1, sizeof(struct _notification)); if (noti == NULL) { return NULL; } @@ -745,7 +596,7 @@ static int _notification_noti_update_priv_id(sqlite3 * db, int rowid) "priv_id = %d, internal_group_id = %d where rowid = %d", rowid, rowid, rowid); - return notification_db_exec(db, query); + return notification_db_exec(db, query, NULL); } EXPORT_API int notification_noti_insert(notification_h noti) @@ -980,6 +831,7 @@ err: EXPORT_API int notification_noti_delete_all(notification_type_e type, const char *pkgname, int *num_deleted, int **list_deleted_rowid) { int ret = NOTIFICATION_ERROR_NONE; + int ret_tmp = NOTIFICATION_ERROR_NONE; int i = 0, data_cnt = 0; sqlite3 *db = NULL; sqlite3_stmt *stmt = NULL; @@ -1058,15 +910,26 @@ EXPORT_API int notification_noti_delete_all(notification_type_e type, const char if (data_cnt > 0) { query_where[0] = '\0'; + snprintf(query_base, sizeof(query_base) - 1, "delete from noti_list"); for (i = 0; i < data_cnt ; i++) { - snprintf(buf, sizeof(buf), "%s%d", (i == 0) ? "" : ",", *((*list_deleted_rowid) + i)); + if (i % NOTI_BURST_DELETE_UNIT == 0 && i != 0) { + snprintf(query, sizeof(query) - 1, "%s where priv_id in (%s)", query_base, query_where); + ret_tmp = notification_db_exec(db, query, NULL); + query_where[0] = '\0'; + if (ret == NOTIFICATION_ERROR_NONE) { + ret = ret_tmp; + } + } + snprintf(buf, sizeof(buf) - 1, "%s%d", (i % NOTI_BURST_DELETE_UNIT == 0) ? "" : ",", *((*list_deleted_rowid) + i)); strncat(query_where, buf,sizeof(query_where) - strlen(query_where) - 1); } - snprintf(query_base, sizeof(query_base), "delete from noti_list"); - snprintf(query, sizeof(query), "%s where priv_id in (%s)", query_base, query_where); - - NOTIFICATION_ERR("check : %s", query); - ret = notification_db_exec(db, query); + if ((i <= NOTI_BURST_DELETE_UNIT) || ((i % NOTI_BURST_DELETE_UNIT) > 0) ) { + snprintf(query, sizeof(query) - 1, "%s where priv_id in (%s)", query_base, query_where); + ret_tmp = notification_db_exec(db, query, NULL); + if (ret == NOTIFICATION_ERROR_NONE) { + ret = ret_tmp; + } + } } else { free(*list_deleted_rowid); *list_deleted_rowid = NULL; @@ -1080,7 +943,7 @@ EXPORT_API int notification_noti_delete_all(notification_type_e type, const char snprintf(query_base, sizeof(query_base), "delete from noti_list "); snprintf(query, sizeof(query), "%s %s", query_base, query_where); - ret = notification_db_exec(db, query); + ret = notification_db_exec(db, query, NULL); if (num_deleted != NULL) { *num_deleted = sqlite3_changes(db); @@ -1103,6 +966,7 @@ int notification_noti_delete_group_by_group_id(const char *pkgname, int group_id, int *num_deleted, int **list_deleted_rowid) { int ret = NOTIFICATION_ERROR_NONE; + int ret_tmp = NOTIFICATION_ERROR_NONE; sqlite3 *db = NULL; int i = 0, data_cnt = 0; sqlite3_stmt *stmt = NULL; @@ -1167,15 +1031,26 @@ int notification_noti_delete_group_by_group_id(const char *pkgname, if (data_cnt > 0) { query_where[0] = '\0'; + snprintf(query_base, sizeof(query_base) - 1, "delete from noti_list"); for (i = 0; i < data_cnt ; i++) { - snprintf(buf, sizeof(buf), "%s%d", (i == 0) ? "" : ",", *((*list_deleted_rowid) + i)); + if (i % NOTI_BURST_DELETE_UNIT == 0 && i != 0) { + snprintf(query, sizeof(query) - 1, "%s where priv_id in (%s)", query_base, query_where); + ret_tmp = notification_db_exec(db, query, NULL); + query_where[0] = '\0'; + if (ret == NOTIFICATION_ERROR_NONE) { + ret = ret_tmp; + } + } + snprintf(buf, sizeof(buf) - 1, "%s%d", (i % NOTI_BURST_DELETE_UNIT == 0) ? "" : ",", *((*list_deleted_rowid) + i)); strncat(query_where, buf,sizeof(query_where) - strlen(query_where) - 1); } - snprintf(query_base, sizeof(query_base), "delete from noti_list"); - snprintf(query, sizeof(query), "%s where priv_id in (%s)", query_base, query_where); - - NOTIFICATION_ERR("check : %s", query); - ret = notification_db_exec(db, query); + if ((i <= NOTI_BURST_DELETE_UNIT) || ((i % NOTI_BURST_DELETE_UNIT) > 0) ) { + snprintf(query, sizeof(query) - 1, "%s where priv_id in (%s)", query_base, query_where); + ret_tmp = notification_db_exec(db, query, NULL); + if (ret == NOTIFICATION_ERROR_NONE) { + ret = ret_tmp; + } + } } else { free(*list_deleted_rowid); *list_deleted_rowid = NULL; @@ -1189,7 +1064,7 @@ int notification_noti_delete_group_by_group_id(const char *pkgname, snprintf(query, sizeof(query), "delete from noti_list %s", query_where); /* execute DB */ - ret = notification_db_exec(db, query); + ret = notification_db_exec(db, query, NULL); } err: @@ -1233,7 +1108,7 @@ int notification_noti_delete_group_by_priv_id(const char *pkgname, int priv_id) pkgname, internal_group_id); /* execute DB */ - ret = notification_db_exec(db, query); + ret = notification_db_exec(db, query, NULL); /* Close DB */ notification_db_close(&db); @@ -1264,7 +1139,44 @@ EXPORT_API int notification_noti_delete_by_priv_id(const char *pkgname, int priv priv_id); /* execute DB */ - ret = notification_db_exec(db, query); + ret = notification_db_exec(db, query, NULL); + + /* Close DB */ + if (db) { + notification_db_close(&db); + } + + return ret; +} + +EXPORT_API int notification_noti_delete_by_priv_id_get_changes(const char *pkgname, int priv_id, int *num_changes) +{ + sqlite3 *db = NULL; + char query[NOTIFICATION_QUERY_MAX] = { 0, }; + int ret; + + /* Check pkgname is valid */ + if (pkgname == NULL) { + return NOTIFICATION_ERROR_INVALID_DATA; + } + + /* Open DB */ + db = notification_db_open(DBPATH); + if (!db) { + return NOTIFICATION_ERROR_FROM_DB; + } + + /* Make query */ + snprintf(query, sizeof(query), "delete from noti_list " + "where caller_pkgname = '%s' and priv_id = %d", pkgname, + priv_id); + + /* execute DB */ + ret = notification_db_exec(db, query, num_changes); + + if (num_changes != NULL) { + NOTIFICATION_DBG("deleted num:%d", *num_changes); + } /* Close DB */ if (db) { @@ -1550,12 +1462,10 @@ notification_error_e notification_noti_get_detail_list(const char *pkgname, if (priv_id == NOTIFICATION_PRIV_ID_NONE && group_id == NOTIFICATION_GROUP_ID_NONE) { if (status == VCONFKEY_TELEPHONY_SIM_INSERTED) { snprintf(query_where, sizeof(query_where), - "where caller_pkgname = '%s' ", - pkgname, internal_group_id); + "where caller_pkgname = '%s' ", pkgname); } else { snprintf(query_where, sizeof(query_where), - "where caller_pkgname = '%s' and flag_simmode = 0 ", - pkgname, internal_group_id); + "where caller_pkgname = '%s' and flag_simmode = 0 ", pkgname); } } else { internal_group_id = diff --git a/src/notification_ongoing.c b/src/notification_ongoing.c index f248bc1..eea1860 100755 --- a/src/notification_ongoing.c +++ b/src/notification_ongoing.c @@ -70,8 +70,6 @@ notification_error_e notification_ongoing_update_progress(const char *caller_pkg dbus_message_unref(signal); if (ret) { - NOTIFICATION_INFO("Send progress info : %s(%d) %.2f", - caller_pkgname, priv_id, progress); return NOTIFICATION_ERROR_NONE; } @@ -106,11 +104,8 @@ notification_error_e notification_ongoing_update_size(const char *caller_pkgname DBUS_TYPE_INT32, &priv_id, DBUS_TYPE_DOUBLE, &size, DBUS_TYPE_INVALID); - NOTIFICATION_INFO("arg..."); if (ret) { ret = dbus_connection_send(connection, signal, NULL); - NOTIFICATION_INFO("Send size info : %s(%d) %.2f", - caller_pkgname, priv_id, size); if (ret) { dbus_connection_flush(connection); @@ -120,8 +115,6 @@ notification_error_e notification_ongoing_update_size(const char *caller_pkgname dbus_message_unref(signal); if (ret) { - NOTIFICATION_INFO("Send size info : %s(%d) %.2f", - caller_pkgname, priv_id, size); return NOTIFICATION_ERROR_NONE; } @@ -165,8 +158,6 @@ notification_error_e notification_ongoing_update_content(const char *caller_pkgn } 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); diff --git a/src/notification_setting.c b/src/notification_setting.c new file mode 100755 index 0000000..246f964 --- /dev/null +++ b/src/notification_setting.c @@ -0,0 +1,351 @@ +/* + * libnotification + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <db-util.h> + +#include <notification.h> +#include <notification_db.h> +#include <notification_noti.h> +#include <notification_debug.h> +#include <notification_ipc.h> +#include <notification_setting.h> +#include <notification_internal.h> + +#define NOTIFICATION_SETTING_DB "notification_setting" +#define NOTIFICATION_SETTING_DB_PATH "/opt/usr/dbspace/.notification_parser.db" + +struct _notification_setting_h { + char *appid; + char *notification; + char *sounds; + char *contents; + char *badge; + char *pkgid; +}; + +struct prop_table { + const char *property; + const char *column; + const char *default_value; +}; + +static struct prop_table g_prop_table[] = { + { + .property = "OPT_NOTIFICATION", + .column = "notification", + .default_value = "ON", + }, + { + .property = "OPT_SOUNDS", + .column = "sounds", + .default_value = "ON", + }, + { + .property = "OPT_CONTENTS", + .column = "contents", + .default_value = "ON", + }, + { + .property = "OPT_BADGE", + .column = "badge", + .default_value = "ON", + }, + { + .property = NULL, + .column = NULL, + .default_value = NULL, + } +}; + +static const char *_get_prop_column(const char *property) +{ + int i; + + for (i = 0; g_prop_table[i].property; i++) { + if (strcmp(g_prop_table[i].property, property)) + continue; + + return g_prop_table[i].column; + } + + return NULL; +} + +#ifdef TBD +static const char *_get_prop_default_value(const char *property) +{ + int i; + + for (i = 0; g_prop_table[i].property; i++) { + if (strcmp(g_prop_table[i].property, property)) + continue; + + return g_prop_table[i].default_value; + } + + return NULL; +} +#endif + +static notification_error_e _is_record_exist(const char *pkgname, sqlite3 *db) +{ + sqlite3_stmt *stmt = NULL; + int count = 0; + int result = NOTIFICATION_ERROR_NONE; + char *sqlbuf = NULL; + int sqlret; + + if (!pkgname) + return NOTIFICATION_ERROR_INVALID_DATA; + + if (!db) + return NOTIFICATION_ERROR_INVALID_DATA; + + sqlbuf = sqlite3_mprintf("SELECT count(*) FROM %s WHERE " \ + "appid = %Q", + NOTIFICATION_SETTING_DB, pkgname); + + if (!sqlbuf) { + NOTIFICATION_ERR("fail to alloc sql query"); + return NOTIFICATION_ERROR_NO_MEMORY; + } + + sqlret = sqlite3_prepare_v2(db, sqlbuf, -1, &stmt, NULL); + if (sqlret != SQLITE_OK) { + NOTIFICATION_ERR("DB err [%s]", sqlite3_errmsg(db)); + NOTIFICATION_ERR("query[%s]", sqlbuf); + result = NOTIFICATION_ERROR_FROM_DB; + goto free_and_return; + } + + sqlret = sqlite3_step(stmt); + if (sqlret == SQLITE_ROW) + count = sqlite3_column_int(stmt, 0); + else + count = 0; + + if (count > 0) + result = NOTIFICATION_ERROR_ALREADY_EXIST_ID; + else + result = NOTIFICATION_ERROR_NOT_EXIST_ID; + +free_and_return: + if (sqlbuf) + sqlite3_free(sqlbuf); + + if (stmt) + sqlite3_finalize(stmt); + + return result; +} + +EXPORT_API notification_error_e notification_setting_db_set(const char *pkgname, const char *property, const char *value) +{ + notification_error_e ret = NOTIFICATION_ERROR_NONE; + notification_error_e result = NOTIFICATION_ERROR_NONE; + sqlite3 *db = NULL; + char *sqlbuf = NULL; + int sqlret; + char *err_msg = NULL; + const char *column = NULL; + + if (!pkgname) + return NOTIFICATION_ERROR_INVALID_DATA; + + if (!property) + return NOTIFICATION_ERROR_INVALID_DATA; + + if (!value) + return NOTIFICATION_ERROR_INVALID_DATA; + + column = _get_prop_column(property); + if (!column) + return NOTIFICATION_ERROR_INVALID_DATA; + + sqlret = db_util_open(NOTIFICATION_SETTING_DB_PATH, &db, 0); + if (sqlret != SQLITE_OK || !db) { + NOTIFICATION_ERR("fail to db_util_open - [%d]", sqlret); + return NOTIFICATION_ERROR_FROM_DB; + } + + ret = _is_record_exist(pkgname, db); + if (ret != NOTIFICATION_ERROR_ALREADY_EXIST_ID) { + result = ret; + goto return_close_db; + } + + sqlbuf = sqlite3_mprintf("UPDATE %s SET %s = %Q " \ + "WHERE appid = %Q", + NOTIFICATION_SETTING_DB, column, value, pkgname); + if (!sqlbuf) { + NOTIFICATION_ERR("fail to alloc query"); + result = NOTIFICATION_ERROR_NO_MEMORY; + goto return_close_db; + } + + sqlret = sqlite3_exec(db, sqlbuf, NULL, NULL, &err_msg); + if (sqlret != SQLITE_OK) { + NOTIFICATION_ERR("fail to set pkgname[%s] option[%s], value[%s], err[%d - %s]", + pkgname, value, property, sqlret, err_msg); + result = NOTIFICATION_ERROR_FROM_DB; + goto return_close_db; + } + +return_close_db: + if (err_msg) + sqlite3_free(err_msg); + + if (sqlbuf) + sqlite3_free(sqlbuf); + + sqlret = db_util_close(db); + if (sqlret != SQLITE_OK) + NOTIFICATION_WARN("fail to db_util_close - [%d]", sqlret); + + return result; +} + +EXPORT_API notification_error_e notification_setting_db_get(const char *pkgname, const char *property, char **value) +{ + notification_error_e ret = NOTIFICATION_ERROR_NONE; + notification_error_e result = NOTIFICATION_ERROR_NONE; + sqlite3 *db = NULL; + char *sqlbuf = NULL; + sqlite3_stmt *stmt = NULL; + int sqlret; + const char *column = NULL; + + if (!pkgname) + return NOTIFICATION_ERROR_INVALID_DATA; + + if (!property) + return NOTIFICATION_ERROR_INVALID_DATA; + + if (!value) + return NOTIFICATION_ERROR_INVALID_DATA; + + column = _get_prop_column(property); + if (!column) + return NOTIFICATION_ERROR_INVALID_DATA; + + sqlret = db_util_open(NOTIFICATION_SETTING_DB_PATH, &db, 0); + if (sqlret != SQLITE_OK || !db) { + NOTIFICATION_ERR("fail to db_util_open - [%d]", sqlret); + return NOTIFICATION_ERROR_FROM_DB; + } + + ret = _is_record_exist(pkgname, db); + if (ret != NOTIFICATION_ERROR_ALREADY_EXIST_ID) { + result = ret; + goto return_close_db; + } + + sqlbuf = sqlite3_mprintf("SELECT %s FROM %s " \ + "WHERE appid = %Q", + column, NOTIFICATION_SETTING_DB, pkgname); + if (!sqlbuf) { + NOTIFICATION_ERR("fail to alloc query"); + result = NOTIFICATION_ERROR_NO_MEMORY; + goto return_close_db; + } + + sqlret = sqlite3_prepare_v2(db, sqlbuf, -1, &stmt, NULL); + if (sqlret != SQLITE_OK) { + NOTIFICATION_ERR("fail to prepare %s - [%s]", + sqlbuf, sqlite3_errmsg(db)); + result = NOTIFICATION_ERROR_FROM_DB; + goto return_close_db; + } + + sqlret = sqlite3_step(stmt); + if (sqlret == SQLITE_ROW) { + int get_bytes = sqlite3_column_bytes(stmt, 0); + char *get_data = (char *)calloc(get_bytes + 1, sizeof(char)); + if (get_data != NULL) { + memcpy(get_data, sqlite3_column_text(stmt, 0), + get_bytes * sizeof(char)); + get_data[get_bytes] = '\0'; + *value = get_data; + } else { + NOTIFICATION_ERR("fail to alloc query"); + result = NOTIFICATION_ERROR_NO_MEMORY; + goto return_close_db; + } + } + +return_close_db: + if (sqlbuf) + sqlite3_free(sqlbuf); + + if (stmt) + sqlite3_finalize(stmt); + + sqlret = db_util_close(db); + if (sqlret != SQLITE_OK) + NOTIFICATION_WARN("fail to db_util_close - [%d]", sqlret); + + return result; +} + +EXPORT_API notification_error_e notification_setting_property_set(const char *pkgname, const char *property, const char *value) +{ + int ret = 0; + + if (!pkgname) + return NOTIFICATION_ERROR_INVALID_DATA; + + if (!property) + return NOTIFICATION_ERROR_INVALID_DATA; + + if (!value) + return NOTIFICATION_ERROR_INVALID_DATA; + + ret = notification_ipc_noti_setting_property_set(pkgname, property, value); + if (ret != NOTIFICATION_ERROR_NONE) { + return ret; + } + + return NOTIFICATION_ERROR_NONE; +} + +EXPORT_API notification_error_e notification_setting_property_get(const char *pkgname, const char *property, char **value) +{ + int ret = 0; + + if (!pkgname) + return NOTIFICATION_ERROR_INVALID_DATA; + + if (!property) + return NOTIFICATION_ERROR_INVALID_DATA; + + if (!value) + return NOTIFICATION_ERROR_INVALID_DATA; + + ret = notification_ipc_noti_setting_property_get(pkgname, property, value); + if (ret != NOTIFICATION_ERROR_NONE) { + return ret; + } + + return NOTIFICATION_ERROR_NONE; +} diff --git a/src/notification_status.c b/src/notification_status.c index 734d30d..97fbe41 100755 --- a/src/notification_status.c +++ b/src/notification_status.c @@ -26,14 +26,12 @@ #include <errno.h> #include <vconf.h> -#include "notification_error.h" -#include "notification_type.h" -#include "notification_debug.h" -#include "notification_status.h" - -#ifndef EXPORT_API -#define EXPORT_API __attribute__ ((visibility("default"))) -#endif +#include <notification.h> +#include <notification_db.h> +#include <notification_noti.h> +#include <notification_debug.h> +#include <notification_internal.h> +#include <notification_status.h> #define NOTIFICATION_STATUS_MESSAGE_KEY "memory/private/libstatus/message" |