diff options
author | Sewook Park <sewook7.park@samsung.com> | 2012-08-21 19:56:22 +0900 |
---|---|---|
committer | Sewook Park <sewook7.park@samsung.com> | 2012-08-21 19:56:22 +0900 |
commit | 49ad159aae9fa6bce07ab325356ffb7cbf85a476 (patch) | |
tree | 031d8d6471792b39dbbc00ea10fd49edc3604de0 | |
parent | b7d00f250a7c4012b018ccbfdeebd976f1bd907f (diff) | |
download | application-49ad159aae9fa6bce07ab325356ffb7cbf85a476.tar.gz application-49ad159aae9fa6bce07ab325356ffb7cbf85a476.tar.bz2 application-49ad159aae9fa6bce07ab325356ffb7cbf85a476.zip |
Upload Tizen2.0 source
-rw-r--r--[-rwxr-xr-x] | debian/changelog | 182 | ||||
-rwxr-xr-x | include/app.h | 29 | ||||
-rwxr-xr-x | include/app_preference_private.h | 8 | ||||
-rwxr-xr-x | include/app_private.h | 4 | ||||
-rwxr-xr-x | include/app_service.h | 94 | ||||
-rw-r--r--[-rwxr-xr-x] | include/app_storage.h | 0 | ||||
-rwxr-xr-x | include/app_ui_notification.h | 101 | ||||
-rwxr-xr-x | packaging/capi-appfw-application.spec | 16 | ||||
-rwxr-xr-x | src/app_main.c | 3 | ||||
-rwxr-xr-x | src/app_package.c | 21 | ||||
-rwxr-xr-x | src/app_resource.c | 24 | ||||
-rwxr-xr-x | src/preference.c | 232 | ||||
-rwxr-xr-x | src/service.c | 243 | ||||
-rwxr-xr-x | src/ui_notification.c | 206 |
14 files changed, 977 insertions, 186 deletions
diff --git a/debian/changelog b/debian/changelog index 02ea77d..c9b21d9 100755..100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,23 @@ +capi-appfw-application (0.1.0-23) unstable; urgency=low + + * Updated UI Notification API + * Git: slp/api/application + * Tag: capi-appfw-application_0.1.0-23 + + -- Junghyuk Park <junghyuk.park@samsung.com> Thu, 31 May 2012 13:34:33 +0900 + +capi-appfw-application (0.1.0-22) unstable; urgency=low + + * Bug fixed : service_reply_cb() + * Git: slp/api/application + * Tag: capi-appfw-application_0.1.0-22 + + -- Junghyuk Park <junghyuk.park@samsung.com> Fri, 27 Apr 2012 14:56:37 +0900 + capi-appfw-application (0.1.0-21) unstable; urgency=low * Changed the definitions of service operation and extra-data - * Git: api/application + * Git: slp/api/application * Tag: capi-appfw-application_0.1.0-21 -- Junghyuk Park <junghyuk.park@samsung.com> Thu, 15 Mar 2012 16:09:18 +0900 @@ -9,7 +25,7 @@ capi-appfw-application (0.1.0-21) unstable; urgency=low capi-appfw-application (0.1.0-20) unstable; urgency=low * Updated for AIL API changes - * Git: api/application + * Git: slp/api/application * Tag: capi-appfw-application_0.1.0-20 -- Junghyuk Park <junghyuk.park@samsung.com> Mon, 05 Mar 2012 19:09:02 +0900 @@ -17,7 +33,7 @@ capi-appfw-application (0.1.0-20) unstable; urgency=low capi-appfw-application (0.1.0-19) unstable; urgency=low * Code refactoring - * Git: api/application + * Git: slp/api/application * Tag: capi-appfw-application_0.1.0-19 -- Junghyuk Park <junghyuk.park@samsung.com> Wed, 29 Feb 2012 15:29:59 +0900 @@ -25,7 +41,7 @@ capi-appfw-application (0.1.0-19) unstable; urgency=low capi-appfw-application (0.1.0-18) unstable; urgency=low * Bug fixed : service_foreach_extra_data() - * Git: api/application + * Git: slp/api/application * Tag: capi-appfw-application_0.1.0-18 -- Junghyuk Park <junghyuk.park@samsung.com> Tue, 21 Feb 2012 14:34:01 +0900 @@ -33,7 +49,7 @@ capi-appfw-application (0.1.0-18) unstable; urgency=low capi-appfw-application (0.1.0-17) unstable; urgency=low * Added version numbering - * Git: api/application + * Git: slp/api/application * Tag: capi-appfw-application_0.1.0-17 -- Junghyuk Park <junghyuk.park@samsung.com> Wed, 15 Feb 2012 10:43:30 +0900 @@ -43,7 +59,7 @@ capi-appfw-application (0.1.0-16) unstable; urgency=low * Refactoring code * Add alarm_get_service() API * Add ALARM_ERROR_OUT_OF_MEMORY error code - * Git: api/application + * Git: slp/api/application * Tag: capi-appfw-application_0.1.0-16 -- Junghyuk Park <junghyuk.park@samsung.com> Mon, 13 Feb 2012 11:52:20 +0300 @@ -51,7 +67,7 @@ capi-appfw-application (0.1.0-16) unstable; urgency=low capi-appfw-application (0.1.0-15) unstable; urgency=low * Fixed invalid parameter - * Git: api/application + * Git: slp/api/application * Tag: capi-appfw-application_0.1.0-15 -- Junghyuk Park <junghyuk.park@samsung.com> Mon, 30 Jan 2012 13:52:37 +0900 @@ -59,7 +75,7 @@ capi-appfw-application (0.1.0-15) unstable; urgency=low capi-appfw-application (0.1.0-14) unstable; urgency=low * Update UI-Notification API - * Git: api/application + * Git: slp/api/application * Tag: capi-appfw-application_0.1.0-14 @@ -68,7 +84,7 @@ capi-appfw-application (0.1.0-14) unstable; urgency=low capi-appfw-application (0.1.0-13) unstable; urgency=low * Update alarm API Doc - * Git: api/application + * Git: slp/api/application * Tag: capi-appfw-application_0.1.0-13 -- Junghyuk Park <junghyuk.park@samsung.com> Thu, 22 Dec 2011 11:01:24 +0300 @@ -76,13 +92,155 @@ capi-appfw-application (0.1.0-13) unstable; urgency=low capi-appfw-application (0.1.0-12) unstable; urgency=low * Fixed memory leak - * Git: api/application + * Git: slp/api/application * Tag: capi-appfw-application_0.1.0-12 -- Junghyuk Park <junghyuk.park@samsung.com> Wed, 21 Dec 2011 13:27:10 +0900 capi-appfw-application (0.1.0-11) unstable; urgency=low - * Initial release. + * Application API : changed function prototype + * Git: slp/api/application + * Tag: capi-appfw-application_0.1.0-11 + + -- Junghyuk Park <junghyuk.park@samsung.com> Wed, 14 Dec 2011 14:30:35 +0900 + +capi-appfw-application (0.1.0-10) unstable; urgency=low + + * Fixed bug : Service API + * Git: slp-source.sec.samsung.net:slp/api/application + * Tag: capi-appfw-application_0.1.0-10 + + -- Junghyuk Park <junghyuk.park@samsung.com> Wed, 07 Dec 2011 10:30:11 +0900 + +capi-appfw-application (0.1.0-9) unstable; urgency=low + + * Alarm API : Update boilerplate + * Git: slp-source.sec.samsung.net:slp/api/application + * Tag: capi-appfw-application_0.1.0-9 + + -- Junghyuk Park <junghyuk.park@samsung.com> Tue, 06 Dec 2011 19:09:32 +0900 + +capi-appfw-application (0.1.0-8) unstable; urgency=low + + * Alarm API : update alarm-id + * Git: slp-source.sec.samsung.net:slp/api/application + * Tag: capi-appfw-application_0.1.0-8 + + -- Junghyuk Park <junghyuk.park@samsung.com> Sat, 26 Nov 2011 15:24:08 +0900 + +capi-appfw-application (0.1.0-7) unstable; urgency=low + + * SLP API is renamed Tizen API + * Git: slp-source.sec.samsung.net:slp/api/application + * Tag: capi-appfw-application_0.1.0-7 + + -- Junghyuk Park <junghyuk.park@samsung.com> Wed, 23 Nov 2011 13:48:00 +0900 + +capi-appfw-application (0.1.0-6) unstable; urgency=low + + * Add UI Notification API + * Git: slp-source.sec.samsung.net:slp/api/application + * Tag: capi-appfw-application_0.1.0-6 + + -- Junghyuk Park <junghyuk.park@samsung.com> Mon, 21 Nov 2011 20:54:00 +0900 + +capi-appfw-application (0.1.0-5) unstable; urgency=low + + * DTS : improve functional coverage and conditional coverage + * Git: slp-source.sec.samsung.net:slp/api/application + * Tag: capi-appfw-application_0.1.0-5 + + -- Junghyuk Park <junghyuk.park@samsung.com> Fri, 04 Nov 2011 14:39:01 +0900 + +capi-appfw-application (0.1.0-4) unstable; urgency=low + + * Application API : enum for device orientation is changed + * Service API : array data type is added to extra-data + * Git: slp-source.sec.samsung.net:slp/api/application + * Tag: capi-appfw-application_0.1.0-4 + + -- Junghyuk Park <junghyuk.park@samsung.com> Mon, 24 Oct 2011 20:40:23 +0900 + +capi-appfw-application (0.1.0-3) unstable; urgency=low + + * Alarm API : added application launch by Service API + * Git: slp-source.sec.samsung.net:slp/api/application + * Tag: capi-appfw-application_0.1.0-3 + + -- Junghyuk Park <junghyuk.park@samsung.com> Mon, 10 Oct 2011 15:47:18 +0900 + +capi-appfw-application (0.1.0-2) unstable; urgency=low + + * Fixed bug : service_clone() causes segfault + * Git: slp-source.sec.samsung.net:slp/api/application + * Tag: capi-appfw-application_0.1.0-2 + + -- Junghyuk Park <junghyuk.park@samsung.com> Wed, 05 Oct 2011 16:12:14 +0900 + +capi-appfw-application (0.1.0-1) unstable; urgency=low + + * capi-appfw-application_0.1.0-1 + * Git: slp-source.sec.samsung.net:slp/api/application + * Tag: capi-appfw-application_0.1.0-1 + + -- Junghyuk Park <junghyuk.park@samsung.com> Tue, 27 Sep 2011 21:30:36 +0900 + +capi-appfw-application (0.0.1-7) unstable; urgency=low + + * Service API is added + * Git: slp-source.sec.samsung.net:slp/api/application + * Tag: capi-appfw-application_0.0.1-7 + + -- Junghyuk Park <junghyuk.park@samsung.com> Mon, 26 Sep 2011 17:06:56 +0900 + +capi-appfw-application (0.0.1-6) unstable; urgency=low + * bug fixed : preference API + * Git: slp-source.sec.samsung.net:slp/api/application + * Tag: capi-appfw-application_0.0.1-6 + + -- Junghyuk Park <junghyuk.park@samsung.com> Mon, 05 Sep 2011 21:48:32 +0900 + +capi-appfw-application (0.0.1-5) unstable; urgency=low + + * lib dependecny is updated : sqlite3 + * Git: slp-source.sec.samsung.net:slp/api/application + * Tag: capi-appfw-application_0.0.1-5 + + -- Junghyuk Park <junghyuk.park@samsung.com> Mon, 05 Sep 2011 20:19:00 +0900 + +capi-appfw-application (0.0.1-4) unstable; urgency=low + + * Application API is updated to support Service API + * Storage API is updated to support various storage type + * The file name of each header file of Application FW is updated + + -- Junghyuk Park <junghyuk.park@samsung.com> Mon, 05 Sep 2011 19:29:52 +0900 + +capi-appfw-application (0.0.1-3) unstable; urgency=low + + * System event callbacks are updated to apply Service API changes + * Service API is added to provide application service framework + * Preference API is added to provide persistent application data + * Event Notification API is added to provide interaction between applications + * Git: slp-source.sec.samsung.net:slp/api/application + * Tag: capi-appfw-application_0.0.1-3 + + -- Junghyuk Park <junghyuk.park@samsung.com> Mon, 22 Aug 2011 20:21:28 +0900 + +capi-appfw-application (0.0.1-2) unstable; urgency=low + + * GNU gettext macro is added + * Git: slp-source.sec.samsung.net:slp/api/application + * Tag: capi-appfw-application_0.0.1-2 + + -- Woongsuk Cho <ws77.cho@samsung.com> Tue, 09 Aug 2011 17:52:09 +0900 + +capi-appfw-application (0.0.1-1) unstable; urgency=low + + * Initial upload + * Git: slp-source.sec.samsung.net:slp/api/application + * Tag: capi-appfw-application_0.0.1-1 + + -- Woongsuk Cho <ws77.cho@samsung.com> Thu, 04 Aug 2011 18:36:24 +0900 - -- Junghyuk Park <junghyuk.park@samsung.com> Wed, 07 Dec 2011 11:35:51 +0900 diff --git a/include/app.h b/include/app.h index 386f9b1..362178b 100755 --- a/include/app.h +++ b/include/app.h @@ -288,6 +288,23 @@ int app_get_package(char **package); /** + * @brief Gets the ID of the application. + * + * @remarks @a ID must be released with free() by you. + * + * @param [out] id The ID of the application + * + * @return 0 on success, otherwise a negative error value. + * + * @retval #APP_ERROR_NONE Successful + * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_ERROR_INVALID_CONTEXT The application is illegally launched, not launched by the launch system. + * @retval #APP_ERROR_OUT_OF_MEMORY Out of memory + */ +int app_get_id(char **id); + + +/** * @brief Gets the localized name of the application. * * @remarks @a name must be released with free() by you. @@ -361,6 +378,18 @@ app_device_orientation_e app_get_device_orientation(void); /** + * @brief Sets whether reclaiming system cache is enabled in the pause state. + * + * @details If the reclaiming system cache is enabled, the system caches are released as possible when the application's state changes to the pause state. + * + * @remarks The reclaiming system cache is enabled by default + * + * @param [in] enable whether reclaiming system cache is enabled + */ +void app_set_reclaiming_system_cache_on_pause(bool enable); + + +/** * @} */ diff --git a/include/app_preference_private.h b/include/app_preference_private.h index 76000ad..aaf4a87 100755 --- a/include/app_preference_private.h +++ b/include/app_preference_private.h @@ -22,12 +22,12 @@ extern "C" { #endif -#define PREF_DB_NAME ".pref.db" -#define PREF_TBL_NAME "pref" +#define PREF_DB_NAME ".pref.db" +#define PREF_TBL_NAME "pref" #define PREF_F_KEY_NAME "pref_key" -#define PREF_F_TYPE_NAME "pref_type" +#define PREF_F_TYPE_NAME "pref_type" #define PREF_F_DATA_NAME "pref_data" -#define BUF_LEN (1024) +#define BUF_LEN (4096) typedef enum { diff --git a/include/app_private.h b/include/app_private.h index 621ee50..e949f8a 100755 --- a/include/app_private.h +++ b/include/app_private.h @@ -38,6 +38,10 @@ extern "C" { #define PATH_FMT_LOCALE_DIR PATH_FMT_RES_DIR "/locale" #define PATH_FMT_DATA_DIR PATH_FMT_APP_ROOT "/%s/data" +#define PATH_FMT_RO_APP_ROOT "/usr/apps" +#define PATH_FMT_RO_RES_DIR PATH_FMT_RO_APP_ROOT "/%s/res" +#define PATH_FMT_RO_LOCALE_DIR PATH_FMT_RO_RES_DIR "/locale" + typedef void (*app_finalizer_cb) (void *data); int app_error(app_error_e error, const char* function, const char *description); diff --git a/include/app_service.h b/include/app_service.h index 7c24317..1764ab6 100755 --- a/include/app_service.h +++ b/include/app_service.h @@ -18,6 +18,7 @@ #ifndef __TIZEN_APPFW_SERVICE_H__ #define __TIZEN_APPFW_SERVICE_H__ +#include <sys/types.h> #include <tizen.h> #ifdef __cplusplus @@ -167,6 +168,8 @@ typedef enum /** * @brief Called when the reply of the launch request is delivered. * + * @remarks The @a request and @a reply must not be deallocated by an application. + * * @param [in] request The service handle of the launch request that has sent * @param [in] reply The service handle in which the results of the callee are contained * @param [in] result The result code of the launch request @@ -336,6 +339,7 @@ int service_get_mime(service_h service, char **mime); /** * @brief Sets the package name of the application to explicitly launch * + * @remark This function is @b deprecated. Use service_set_app_id() instead. * @param [in] service The service handle * @param [in] package The package name of the application to explicitly launch \n * If the @a package is NULL, it clears the previous value. @@ -351,6 +355,7 @@ int service_set_package(service_h service, const char *package); /** * @brief Gets the package name of the application to explicitly launch * + * @remark This function is @b deprecated. Use service_get_app_id() instead. * @remarks The @a package must be released with free() by you. * @param [in] service The service handle * @param [out] package The package name of the application to explicitly launch @@ -364,6 +369,64 @@ int service_get_package(service_h service, char **package); /** + * @brief Sets the ID of the application to explicitly launch + * + * @param [in] service The service handle + * @param [in] app_id The ID of the application to explicitly launch \n + * If the @a app_id is NULL, it clears the previous value. + * @return 0 on success, otherwise a negative error value. + * @retval #SERVICE_ERROR_NONE Successful + * @retval #SERVICE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SERVICE_ERROR_OUT_OF_MEMORY Out of memory + * @see service_get_app_id() + */ +int service_set_app_id(service_h service, const char *app_id); + + +/** + * @brief Gets the ID of the application to explicitly launch + * + * @remarks The @a app_id must be released with free() by you. + * @param [in] service The service handle + * @param [out] app_id The ID of the application to explicitly launch + * @return 0 on success, otherwise a negative error value. + * @retval #SERVICE_ERROR_NONE Successful + * @retval #SERVICE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SERVICE_ERROR_OUT_OF_MEMORY Out of memory + * @see service_set_app_id() + */ +int service_get_app_id(service_h service, char **app_id); + +/** + * @brief Sets the window id of the application + * + * @param [in] service The service handle + * @param [in] id the window id of caller application \n + * If the @a id is not positive, it clears the previous value. + * @return 0 on success, otherwise a negative error value. + * @retval #SERVICE_ERROR_NONE Successful + * @retval #SERVICE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SERVICE_ERROR_OUT_OF_MEMORY Out of memory + * @see service_get_window() + */ +int service_set_window(service_h service, unsigned int id); + + +/** +* @brief Gets the window id of the application +* +* @param [in] service The service handle +* @param [out] id The window id of caller application +* @return 0 on success, otherwise a negative error value. +* @retval #SERVICE_ERROR_NONE Successful +* @retval #SERVICE_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #SERVICE_ERROR_OUT_OF_MEMORY Out of memory +* @see service_set_package() +*/ +int service_get_window(service_h service, unsigned int *id); + + +/** * @brief Adds the extra data to the service. * * @remarks The function replaces any existing value for the given key. @@ -520,7 +583,7 @@ int service_foreach_app_matched(service_h service, service_app_matched_cb callba * * @details The operation is mandatory information for the launch request. \n * If the operation is not specified, #SERVICE_OPERATION_DEFAULT is used by default. - * If the operation is #SERVICE_OPERATION_DEFAULT, the package information is mandatory to explicitly launch the application + * If the operation is #SERVICE_OPERATION_DEFAULT, the application ID is mandatory to explicitly launch the application * @param [in] service The service handle * @param [in] callback The callback function to be called when the reply is delivered * @param [in] user_data The user data to be passed to the callback function @@ -568,6 +631,35 @@ int service_reply_to_launch_request(service_h reply, service_h request, service_ int service_clone(service_h *clone, service_h service); +/** + * @brief Gets the application ID of the caller from the launch request + * + * @remarks The @a service must be the launch reqeust from app_service_cb(). + * @remarks This function returns #SERVICE_ERROR_INVALID_PARAMETER if the given service is not the launch request. + * @remarks The @a id must be released with free() by you. + * @param [in] service The service handle from app_service_cb() + * @param [out] id The application ID of the caller + * @return 0 on success, otherwise a negative error value. + * @retval #SERVICE_ERROR_NONE Successful + * @retval #SERVICE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SERVICE_ERROR_OUT_OF_MEMORY Out of memory + */ +int service_get_caller(service_h service, char **id); + + +/** + * @brief Check whether the caller is requesting a reply from the launch reqeust + * + * @remarks The @a service must be the launch reqeust from app_service_cb(). + * @remarks This function returns #SERVICE_ERROR_INVALID_PARAMETER if the given service is not the launch request. + * @param [in] service The service handle from app_service_cb() + * @param [out] requested whether a reply is requested by the caller + * @return 0 on success, otherwise a negative error value. + * @retval #SERVICE_ERROR_NONE Successful + * @retval #SERVICE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SERVICE_ERROR_OUT_OF_MEMORY Out of memory + */ +int service_is_reply_requested(service_h service, bool *requested); /** * @} diff --git a/include/app_storage.h b/include/app_storage.h index 0afe823..0afe823 100755..100644 --- a/include/app_storage.h +++ b/include/app_storage.h diff --git a/include/app_ui_notification.h b/include/app_ui_notification.h index 88240e5..ba17898 100755 --- a/include/app_ui_notification.h +++ b/include/app_ui_notification.h @@ -11,7 +11,7 @@ * 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. + * limitations under the License. */ @@ -71,7 +71,7 @@ typedef bool (*ui_notification_cb)(ui_notification_h notification, void *user_da /** * @brief Creates a notification handle. - * @remarks The @a notification must be released with ui_notification_destroy() by you. + * @remarks The @a notification must be released with ui_notification_destroy() by you. * @param[in] ongoing A boolean value that sets whether this is an ongoing notification. * @param[out] notification A UI notification handle to be newly created on success * @return 0 on success, otherwise a negative error value. @@ -168,7 +168,7 @@ int ui_notification_get_time(ui_notification_h notification, struct tm **time); * @retval #UI_NOTIFICATION_ERROR_NONE Successful * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory - * @see ui_notification_get_title() + * @see ui_notification_get_title() */ int ui_notification_set_title(ui_notification_h notification, const char *title); @@ -195,7 +195,7 @@ int ui_notification_get_title(ui_notification_h notification, char **title); * @retval #UI_NOTIFICATION_ERROR_NONE Successful * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory - * @see ui_notification_get_content() + * @see ui_notification_get_content() */ int ui_notification_set_content(ui_notification_h notification, const char *content); @@ -213,6 +213,60 @@ int ui_notification_set_content(ui_notification_h notification, const char *cont int ui_notification_get_content(ui_notification_h notification, char **content); /** + * @brief Sets the path of sound file to play when the notification is shown. + * @remarks The @a path should be the absolute path. \n + * The sound file is only supported wave file format. \n + * This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()). + * @param[in] notification The notification handle + * @param[in] path The path of sound file to play when the notification is shown \n + * If the @a path is NULL, it clears the previous value. + * @return 0 on success, otherwise a negative error value. + * @retval #UI_NOTIFICATION_ERROR_NONE Successful + * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory + * @see ui_notification_get_sound() + */ +int ui_notification_set_sound(ui_notification_h notification, const char *path); + +/** + * @brief Gets the path of sound file to play when the notification is shown. + * @remarks The @a path must be released with free() by you. + * @param[in] notification The notification handle + * @param[out] path The path of sound file to play when the notification is shown \n + * @return 0 on success, otherwise a negative error value. + * @retval #UI_NOTIFICATION_ERROR_NONE Successful + * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory + * @see ui_notification_set_sound() + */ +int ui_notification_get_sound(ui_notification_h notification, char **path); + +/** + * @brief Sets whether to use vibration when the notification is shown. + * @remarks This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()). + * @param[in] notification The notification handle + * @param[in] value A boolean value that sets whether to use vibration. + * @return 0 on success, otherwise a negative error value. + * @retval #UI_NOTIFICATION_ERROR_NONE Successful + * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory + * @see ui_notification_get_vibration() + */ +int ui_notification_set_vibration(ui_notification_h notification, bool value); + +/** + * @brief Gets whether to use vibration when the notification is shown. + * @param[in] notification The notification handle + * @param[out] value A boolean value that sets whether to use vibration. + * @return 0 on success, otherwise a negative error value. + * @retval #UI_NOTIFICATION_ERROR_NONE Successful + * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory + * @see ui_notification_set_vibration() + */ +int ui_notification_get_vibration(ui_notification_h notification, bool *value); + +/** * @brief Sets the service to launch when the notification is selected from the notification tray. * @details When the notification is selected from the notification tray, the application which is described by the specified service is launched. \n * If you want to launch the current application, use the explicit launch of the @ref CAPI_SERVICE_MODULE API @@ -239,7 +293,7 @@ int ui_notification_set_service(ui_notification_h notification, service_h servic * @retval #UI_NOTIFICATION_ERROR_NONE Successful * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory - * @see ui_notification_set_service() + * @see ui_notification_set_service() */ int ui_notification_get_service(ui_notification_h notification, service_h *service); @@ -286,6 +340,43 @@ int ui_notification_cancel(ui_notification_h notification); void ui_notification_cancel_all(void); /** + * @brief Cancels selected type of previously posted notifications by the current application. + * @details Selected type of previously posted notifications are removed from the notification tray and the status bar. + * @remarks The notifications posted by other applications are not cancelled from the notification tray and the status bar. + * @param[in] ongoing A boolean value that indicates whether the notification type is ongoing to cancel. + * @see ui_notification_post() + * @see ui_notification_cancel() + * @see ui_notification_cancel_all() + */ +void ui_notification_cancel_all_by_type(bool ongoing); + +/** + * @brief Cancels selected type of previously posted notifications by the given application. + * @details Selected type of previously posted notifications are removed from the notification tray and the status bar. + * @remark This function is @b deprecated. Use app_manager_app_context_cb() instead. + * @param[in] package The package name of the application to calcel the posted notifications. + * @param[in] ongoing A boolean value that indicates whether the notification type is ongoing to cancel. + * @see ui_notification_post() + * @see ui_notification_cancel() + * @see ui_notification_cancel_all() + */ +void ui_notification_cancel_all_by_package(const char *package, bool ongoing); + +/** + * @brief Cancels selected type of previously posted notifications by the given application ID. + * @details Selected type of previously posted notifications are removed from the notification tray and the status bar. + * @param[in] id The ID of the application to calcel the posted notifications. + * @param[in] ongoing A boolean value that indicates whether the notification type is ongoing to cancel. + * @return 0 on success, otherwise a negative error value. + * @retval #UI_NOTIFICATION_ERROR_NONE Successful + * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter + * @see ui_notification_post() + * @see ui_notification_cancel() + * @see ui_notification_cancel_all() + */ +int ui_notification_cancel_all_by_app_id(const char *app_id, bool ongoing); + +/** * @brief Updates the notification posted. * @remarks You cannot update the notification which was cleared or canceled. * @param[in] notification The notification handle diff --git a/packaging/capi-appfw-application.spec b/packaging/capi-appfw-application.spec index 2eecdf9..fa70aa2 100755 --- a/packaging/capi-appfw-application.spec +++ b/packaging/capi-appfw-application.spec @@ -1,9 +1,10 @@ +#sbs-git:slp/api/application capi-appfw-application 0.1.0 56d9b8e057f022f0e7fdb1853587158452e7ae1b Name: capi-appfw-application -Summary: An Application library in Tizen C API -Version: 0.1.0 -Release: 1 +Summary: An Application library in SLP C API +Version: 0.1.0 +Release: 26 Group: TO_BE/FILLED_IN -License: Apache-2.0 +License: TO BE FILLED IN Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: pkgconfig(dlog) @@ -24,15 +25,15 @@ Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig %description -An Application library in Tizen C API +An Application library in SLP C API %package devel -Summary: An Application library in Tizen C API (Development) +Summary: An Application library in SLP C API (Development) Group: TO_BE/FILLED_IN Requires: %{name} = %{version}-%{release} %description devel -An Application library in Tizen C API (DEV) +An Application library in SLP C API (DEV) %prep %setup -q @@ -63,3 +64,4 @@ rm -rf %{buildroot} %{_libdir}/libcapi-appfw-application.so + diff --git a/src/app_main.c b/src/app_main.c index e9a9cb8..058607f 100755 --- a/src/app_main.c +++ b/src/app_main.c @@ -147,6 +147,9 @@ int app_appcore_create(void *data) app_set_appcore_event_cb(app_context); snprintf(locale_dir, TIZEN_PATH_MAX, PATH_FMT_LOCALE_DIR, app_context->package); + if (access(locale_dir, R_OK) != 0) { + snprintf(locale_dir, TIZEN_PATH_MAX, PATH_FMT_RO_LOCALE_DIR, app_context->package); + } appcore_set_i18n(app_context->app_name, locale_dir); create_cb = app_context->callback->create; diff --git a/src/app_package.c b/src/app_package.c index b1b0646..a151744 100755 --- a/src/app_package.c +++ b/src/app_package.c @@ -69,26 +69,31 @@ int app_get_package_app_name(const char *package, char **name) int app_get_package(char **package) { - static char package_buf[TIZEN_PATH_MAX] = {0, }; + return app_get_id(package); +} - if (package == NULL) +int app_get_id(char **id) +{ + static char id_buf[TIZEN_PATH_MAX] = {0, }; + + if (id == NULL) { return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - if (package_buf[0] == '\0') + if (id_buf[0] == '\0') { - aul_app_get_pkgname_bypid(getpid(), package_buf, sizeof(package_buf)); + aul_app_get_pkgname_bypid(getpid(), id_buf, sizeof(id_buf)); } - if (package_buf[0] == '\0') + if (id_buf[0] == '\0') { - return app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the package"); + return app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the application ID"); } - *package = strdup(package_buf); + *id = strdup(id_buf); - if (*package == NULL) + if (*id == NULL) { return app_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); } diff --git a/src/app_resource.c b/src/app_resource.c index 6999ccd..219eb6c 100755 --- a/src/app_resource.c +++ b/src/app_resource.c @@ -25,6 +25,7 @@ #include <bundle.h> #include <appcore-common.h> +#include <appcore-efl.h> #include <aul.h> #include <dlog.h> @@ -38,6 +39,7 @@ #define LOG_TAG "TIZEN_N_APPLICATION" static const char *INSTALLED_PATH = "/opt/apps"; +static const char *RO_INSTALLED_PATH = "/usr/apps"; static const char *RES_DIRECTORY_NAME = "res"; static const char *DATA_DIRECTORY_NAME = "data"; @@ -45,6 +47,7 @@ static char * app_get_root_directory(char *buffer, int size) { char *package = NULL; char root_directory[TIZEN_PATH_MAX] = {0, }; + char bin_directory[TIZEN_PATH_MAX] = {0, }; if (app_get_package(&package) != APP_ERROR_NONE) { @@ -53,6 +56,11 @@ static char * app_get_root_directory(char *buffer, int size) } snprintf(root_directory, sizeof(root_directory), "%s/%s", INSTALLED_PATH, package); + snprintf(bin_directory, sizeof(bin_directory), "%s/bin", root_directory); + + if (access(bin_directory, R_OK) != 0) { + snprintf(root_directory, sizeof(root_directory), "%s/%s", RO_INSTALLED_PATH, package); + } free(package); @@ -99,6 +107,7 @@ char* app_get_data_directory(char *buffer, int size) if (data_directory[0] == '\0') { char *root_directory = NULL; + char *package = NULL; root_directory = calloc(1, TIZEN_PATH_MAX); @@ -108,13 +117,16 @@ char* app_get_data_directory(char *buffer, int size) return NULL; } - if (app_get_root_directory(root_directory, TIZEN_PATH_MAX) == NULL) + if (app_get_package(&package) != APP_ERROR_NONE) { - free(root_directory); - app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the path to the root directory"); + app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the package"); return NULL; } + snprintf(root_directory, TIZEN_PATH_MAX, "%s/%s", INSTALLED_PATH, package); + + free(package); + snprintf(data_directory, sizeof(data_directory), "%s/%s", root_directory, DATA_DIRECTORY_NAME); data_directory_length = strlen(data_directory); @@ -176,3 +188,9 @@ char* app_get_resource(const char *resource, char *buffer, int size) return buffer; } + +void app_set_reclaiming_system_cache_on_pause(bool enable) +{ + appcore_set_system_resource_reclaiming(enable); +} + diff --git a/src/preference.c b/src/preference.c index 63b779b..ee1606b 100755 --- a/src/preference.c +++ b/src/preference.c @@ -11,7 +11,7 @@ * 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. + * limitations under the License. */ @@ -63,7 +63,7 @@ static int _initialize(void) snprintf(db_path, sizeof(db_path), "%s/%s", data_path, PREF_DB_NAME); ret = sqlite3_open(db_path, &pref_db); - if (ret != SQLITE_OK) + if (ret != SQLITE_OK) { LOGE("[%s] IO_ERROR(0x%08x) : fail to open db(%s)", __FUNCTION__, PREFERENCE_ERROR_IO_ERROR, sqlite3_errmsg(pref_db)); pref_db = NULL; @@ -72,7 +72,7 @@ static int _initialize(void) ret = sqlite3_exec(pref_db, "CREATE TABLE IF NOT EXISTS pref ( pref_key TEXT PRIMARY KEY, pref_type TEXT, pref_data TEXT)", NULL, NULL, &errmsg); - if (ret != SQLITE_OK) + if (ret != SQLITE_OK) { LOGE("[%s] IO_ERROR(0x%08x) : fail to create db table(%s)", __FUNCTION__, PREFERENCE_ERROR_IO_ERROR, errmsg); sqlite3_free(errmsg); @@ -82,11 +82,11 @@ static int _initialize(void) } app_finalizer_add(_finish, NULL); - + return PREFERENCE_ERROR_NONE; } -//static int _write_data(const char *key, preference_type_e type, const char *data) +//static int _write_data(const char *key, preference_type_e type, const char *data) static int _write_data(const char *key, const char *type, const char *data) { int ret; @@ -108,15 +108,15 @@ static int _write_data(const char *key, const char *type, const char *data) } // to use sqlite3_update_hook, we have to use INSERT/UPDATE operation instead of REPLACE operation - if (exist) + if (exist) { - buf = sqlite3_mprintf("UPDATE %s SET %s='%s', %s='%s' WHERE %s='%s';", + buf = sqlite3_mprintf("UPDATE %s SET %s='%s', %s='%s' WHERE %s='%s';", PREF_TBL_NAME, PREF_F_TYPE_NAME, type, PREF_F_DATA_NAME, data, PREF_F_KEY_NAME, key); } - else + else { - buf = sqlite3_mprintf("INSERT INTO %s (%s, %s, %s) values ('%q', '%q', '%q');", - PREF_TBL_NAME, PREF_F_KEY_NAME, PREF_F_TYPE_NAME, PREF_F_DATA_NAME, key, type, data); + buf = sqlite3_mprintf("INSERT INTO %s (%s, %s, %s) values ('%q', '%q', '%q');", + PREF_TBL_NAME, PREF_F_KEY_NAME, PREF_F_TYPE_NAME, PREF_F_DATA_NAME, key, type, data); } if (buf == NULL) @@ -124,16 +124,16 @@ static int _write_data(const char *key, const char *type, const char *data) LOGE("[%s] IO_ERROR(0x%08x) : fail to create query string", __FUNCTION__, PREFERENCE_ERROR_IO_ERROR); return PREFERENCE_ERROR_IO_ERROR; } - + ret = sqlite3_exec(pref_db, buf, NULL, NULL, &errmsg); sqlite3_free(buf); - if (ret != SQLITE_OK) + if (ret != SQLITE_OK) { LOGE("[%s] IO_ERROR(0x%08x): fail to write data(%s)", __FUNCTION__, PREFERENCE_ERROR_IO_ERROR, errmsg); sqlite3_free(errmsg); return PREFERENCE_ERROR_IO_ERROR; } - + return PREFERENCE_ERROR_NONE; } @@ -147,13 +147,13 @@ static int _read_data(const char *key, char *type, char *data) int columns; char *errmsg; - if (key == NULL || key[0] == '\0' || data == NULL) - { + if (key == NULL || key[0] == '\0' || data == NULL) + { LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, PREFERENCE_ERROR_INVALID_PARAMETER); return PREFERENCE_ERROR_INVALID_PARAMETER; - } + } - if (pref_db == NULL) + if (pref_db == NULL) { if (_initialize() != PREFERENCE_ERROR_NONE) { @@ -162,7 +162,7 @@ static int _read_data(const char *key, char *type, char *data) } } - buf = sqlite3_mprintf("SELECT %s, %s, %s FROM %s WHERE %s='%q';", + buf = sqlite3_mprintf("SELECT %s, %s, %s FROM %s WHERE %s='%q';", PREF_F_KEY_NAME, PREF_F_TYPE_NAME, PREF_F_DATA_NAME, PREF_TBL_NAME, PREF_F_KEY_NAME, key); if (buf == NULL) @@ -173,25 +173,25 @@ static int _read_data(const char *key, char *type, char *data) ret = sqlite3_get_table(pref_db, buf, &result, &rows, &columns, &errmsg); sqlite3_free(buf); - if (ret != SQLITE_OK) + if (ret != SQLITE_OK) { LOGE("[%s] IO_ERROR(0x%08x) : fail to read data (%s)", __FUNCTION__, PREFERENCE_ERROR_IO_ERROR, errmsg); sqlite3_free(errmsg); - return PREFERENCE_ERROR_IO_ERROR; + return PREFERENCE_ERROR_IO_ERROR; } - - if (rows == 0) + + if (rows == 0) { LOGE("[%s] NO_KEY(0x%08x) : fail to find given key(%s)", __FUNCTION__, PREFERENCE_ERROR_NO_KEY, key); sqlite3_free_table(result); - return PREFERENCE_ERROR_NO_KEY; + return PREFERENCE_ERROR_NO_KEY; } - snprintf(type, strlen(result[4]) + 1, "%s", result[4]); // get type value - snprintf(data, strlen(result[5]) + 1, "%s", result[5]); // get data value - + snprintf(type, 2, "%s", result[4]); // get type value + snprintf(data, BUF_LEN, "%s", result[5]); // get data value + sqlite3_free_table(result); - + return PREFERENCE_ERROR_NONE; } @@ -210,21 +210,21 @@ int preference_get_int(const char *key, int *value) char type[2]; char data[BUF_LEN]; int ret; - + ret = _read_data(key, type, data); - if (ret == PREFERENCE_ERROR_NONE) + if (ret == PREFERENCE_ERROR_NONE) { if (atoi(type) == PREFERENCE_TYPE_INT) { *value = atoi(data); - } - else + } + else { LOGE("[%s] INVALID_PARAMETER(0x%08x) : param type(%d)", __FUNCTION__, PREFERENCE_ERROR_INVALID_PARAMETER, atoi(type)); return PREFERENCE_ERROR_INVALID_PARAMETER; } } - + return ret; } @@ -243,27 +243,33 @@ int preference_get_double(const char *key, double *value) char data[BUF_LEN]; int ret; - + ret = _read_data(key, type, data); - if (ret == PREFERENCE_ERROR_NONE) + if (ret == PREFERENCE_ERROR_NONE) { if (atoi(type) == PREFERENCE_TYPE_DOUBLE) { *value = atof(data); - } - else + } + else { LOGE("[%s] INVALID_PARAMETER(0x%08x) : param type(%d)", __FUNCTION__, PREFERENCE_ERROR_INVALID_PARAMETER, atoi(type)); return PREFERENCE_ERROR_INVALID_PARAMETER; } } - - return ret; + + return ret; } int preference_set_string(const char *key, const char *value) { char type[2]; + + if (strlen(value) > (BUF_LEN-1)) + { + LOGE("[%s] INVALID_PARAMETER(0x%08x) : param type(%d)", __FUNCTION__, PREFERENCE_ERROR_INVALID_PARAMETER, atoi(type)); + return PREFERENCE_ERROR_INVALID_PARAMETER; + } snprintf(type, 2, "%d", PREFERENCE_TYPE_STRING); return _write_data(key, type, value); } @@ -280,9 +286,9 @@ int preference_get_string(const char *key, char **value) LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, PREFERENCE_ERROR_INVALID_PARAMETER); return PREFERENCE_ERROR_INVALID_PARAMETER; } - + ret = _read_data(key, type, data); - if (ret == PREFERENCE_ERROR_NONE) + if (ret == PREFERENCE_ERROR_NONE) { if (atoi(type) == PREFERENCE_TYPE_STRING) { @@ -292,15 +298,15 @@ int preference_get_string(const char *key, char **value) LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, PREFERENCE_ERROR_OUT_OF_MEMORY); return PREFERENCE_ERROR_OUT_OF_MEMORY; } - } - else + } + else { LOGE("[%s] INVALID_PARAMETER(0x%08x) : param type(%d)", __FUNCTION__, PREFERENCE_ERROR_INVALID_PARAMETER, atoi(type)); return PREFERENCE_ERROR_INVALID_PARAMETER; } } - - return ret; + + return ret; } int preference_set_boolean(const char *key, bool value) @@ -318,22 +324,22 @@ int preference_get_boolean(const char *key, bool *value) char data[BUF_LEN]; int ret; - + ret = _read_data(key, type, data); - if (ret == PREFERENCE_ERROR_NONE) + if (ret == PREFERENCE_ERROR_NONE) { if (atoi(type) == PREFERENCE_TYPE_BOOLEAN) { *value = (bool)atoi(data); - } - else + } + else { LOGE("[%s] INVALID_PARAMETER(0x%08x) : param type(%d)", __FUNCTION__, PREFERENCE_ERROR_INVALID_PARAMETER, atoi(type)); return PREFERENCE_ERROR_INVALID_PARAMETER; } } - - return ret; + + return ret; } @@ -347,13 +353,13 @@ int preference_is_existing(const char *key, bool *exist) int columns; char *errmsg; - if (key == NULL || key[0] == '\0' || exist == NULL) + if (key == NULL || key[0] == '\0' || exist == NULL) { LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, PREFERENCE_ERROR_INVALID_PARAMETER); return PREFERENCE_ERROR_INVALID_PARAMETER; } - if (pref_db == NULL) + if (pref_db == NULL) { if (_initialize() != PREFERENCE_ERROR_NONE) { @@ -361,7 +367,7 @@ int preference_is_existing(const char *key, bool *exist) return PREFERENCE_ERROR_IO_ERROR; } } - + /* check data is exist */ buf = sqlite3_mprintf("SELECT %s FROM %s WHERE %s='%q';", PREF_F_KEY_NAME, PREF_TBL_NAME, PREF_F_KEY_NAME, key); @@ -370,16 +376,16 @@ int preference_is_existing(const char *key, bool *exist) LOGE("[%s] IO_ERROR(0x%08x) : fail to create query string", __FUNCTION__, PREFERENCE_ERROR_IO_ERROR); return PREFERENCE_ERROR_IO_ERROR; } - + ret = sqlite3_get_table(pref_db, buf, &result, &rows, &columns, &errmsg); sqlite3_free(buf); - if (ret != SQLITE_OK) + if (ret != SQLITE_OK) { LOGE("[%s] IO_ERROR(0x%08x) : fail to read data(%s)", __FUNCTION__, PREFERENCE_ERROR_IO_ERROR, errmsg); sqlite3_free(errmsg); return PREFERENCE_ERROR_IO_ERROR; } - + if (rows > 0) { *exist = true; @@ -404,9 +410,9 @@ static pref_changed_cb_node_t* _find_node(const char *key) tmp_node = head; - while (tmp_node) + while (tmp_node) { - if (strcmp(tmp_node->key, key) == 0) + if (strcmp(tmp_node->key, key) == 0) { break; } @@ -420,7 +426,7 @@ static pref_changed_cb_node_t* _find_node(const char *key) static int _add_node(const char *key, preference_changed_cb cb, void *user_data) { pref_changed_cb_node_t *tmp_node; - + if (key == NULL || key[0] == '\0' || cb == NULL) { LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, PREFERENCE_ERROR_INVALID_PARAMETER); @@ -463,30 +469,30 @@ static int _add_node(const char *key, preference_changed_cb cb, void *user_data) static int _remove_node(const char *key) { pref_changed_cb_node_t *tmp_node; - + if (key == NULL || key[0] == '\0' ) { LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, PREFERENCE_ERROR_INVALID_PARAMETER); return PREFERENCE_ERROR_INVALID_PARAMETER; } - + tmp_node = _find_node(key); - if (tmp_node == NULL) + if (tmp_node == NULL) { return PREFERENCE_ERROR_NONE; } - if (tmp_node->prev != NULL) + if (tmp_node->prev != NULL) { tmp_node->prev->next = tmp_node->next; - } - else + } + else { head = tmp_node->next; } - if (tmp_node->next != NULL) + if (tmp_node->next != NULL) { tmp_node->next->prev = tmp_node->prev; } @@ -495,7 +501,7 @@ static int _remove_node(const char *key) { free(tmp_node->key); } - + free(tmp_node); return PREFERENCE_ERROR_NONE; @@ -515,15 +521,15 @@ static void _remove_all_node(void) { free(tmp_node->key); } - + free(tmp_node); - } + } } static void _update_cb(void *data, int action, char const *db_name, char const *table_name, sqlite_int64 rowid) { - int ret; + int ret; char *buf; char **result; int rows; @@ -531,13 +537,13 @@ static void _update_cb(void *data, int action, char const *db_name, char const * char *errmsg; pref_changed_cb_node_t *tmp_node; - // skip INSERT/DELETE event - if (action != SQLITE_UPDATE) + // skip INSERT/DELETE event + if (action != SQLITE_UPDATE) { return; } - if (strcmp(table_name, PREF_TBL_NAME) != 0) + if (strcmp(table_name, PREF_TBL_NAME) != 0) { LOGI("[%s] given table name (%s) is not same", __FUNCTION__, table_name); return; @@ -550,22 +556,22 @@ static void _update_cb(void *data, int action, char const *db_name, char const * } ret = sqlite3_get_table(pref_db, buf, &result, &rows, &columns, &errmsg); sqlite3_free(buf); - if (ret != SQLITE_OK) + if (ret != SQLITE_OK) { LOGI("[%s] fail to read data(%s)", __FUNCTION__, errmsg); sqlite3_free(errmsg); return; } - - if (rows == 0) + + if (rows == 0) { - sqlite3_free_table(result); - return; + sqlite3_free_table(result); + return; } tmp_node = _find_node(result[1]); - if (tmp_node != NULL && tmp_node->cb != NULL) + if (tmp_node != NULL && tmp_node->cb != NULL) { tmp_node->cb(result[1], tmp_node->user_data); } @@ -579,19 +585,19 @@ int preference_remove(const char *key) int ret; char *buf; char *errmsg; - bool exist; - - ret = preference_is_existing(key, &exist); - if (ret != PREFERENCE_ERROR_NONE) - { - return ret; - } - - if (!exist) - { - return PREFERENCE_ERROR_NONE; - } - + bool exist; + + ret = preference_is_existing(key, &exist); + if (ret != PREFERENCE_ERROR_NONE) + { + return ret; + } + + if (!exist) + { + return PREFERENCE_ERROR_NONE; + } + /* insert data or update data if data already exist */ buf = sqlite3_mprintf("DELETE FROM %s WHERE %s = '%s';", PREF_TBL_NAME, PREF_F_KEY_NAME, key); @@ -601,10 +607,10 @@ int preference_remove(const char *key) LOGE("[%s] IO_ERROR(0x%08x) : fail to create query string", __FUNCTION__, PREFERENCE_ERROR_IO_ERROR); return PREFERENCE_ERROR_IO_ERROR; } - + ret = sqlite3_exec(pref_db, buf, NULL, NULL, &errmsg); sqlite3_free(buf); - if (ret != SQLITE_OK) + if (ret != SQLITE_OK) { LOGE("[%s] IO_ERROR(0x%08x) : fail to delete data (%s)", __FUNCTION__, PREFERENCE_ERROR_IO_ERROR, errmsg); sqlite3_free(errmsg); @@ -613,8 +619,8 @@ int preference_remove(const char *key) // if exist, remove changed cb _remove_node(key); - - return PREFERENCE_ERROR_NONE; + + return PREFERENCE_ERROR_NONE; } @@ -624,7 +630,7 @@ int preference_remove_all(void) char *buf; char *errmsg; - if (pref_db == NULL) + if (pref_db == NULL) { if (_initialize() != PREFERENCE_ERROR_NONE) { @@ -640,10 +646,10 @@ int preference_remove_all(void) LOGE("[%s] IO_ERROR(0x%08x) : fail to create query string", __FUNCTION__, PREFERENCE_ERROR_IO_ERROR); return PREFERENCE_ERROR_IO_ERROR; } - + ret = sqlite3_exec(pref_db, buf, NULL, NULL, &errmsg); sqlite3_free(buf); - if (ret != SQLITE_OK) + if (ret != SQLITE_OK) { LOGE("[%s] IO_ERROR(0x%08x) : fail to delete data (%s)", __FUNCTION__, PREFERENCE_ERROR_IO_ERROR, errmsg); sqlite3_free(errmsg); @@ -663,7 +669,7 @@ int preference_set_changed_cb(const char *key, preference_changed_cb callback, v bool exist; ret = preference_is_existing(key, &exist); - if (ret != PREFERENCE_ERROR_NONE) + if (ret != PREFERENCE_ERROR_NONE) { return ret; } @@ -672,27 +678,27 @@ int preference_set_changed_cb(const char *key, preference_changed_cb callback, v { LOGE("[%s] NO_KEY(0x%08x) : fail to find given key(%s)", __FUNCTION__, PREFERENCE_ERROR_NO_KEY, key); return PREFERENCE_ERROR_NO_KEY; - } - - if (!is_update_hook_registered) + } + + if (!is_update_hook_registered) { sqlite3_update_hook(pref_db, _update_cb, NULL); is_update_hook_registered = true; } - + return _add_node(key, callback, user_data); } int preference_unset_changed_cb(const char *key) { - if (pref_db == NULL) + if (pref_db == NULL) { if (_initialize() != PREFERENCE_ERROR_NONE) { return PREFERENCE_ERROR_IO_ERROR; } } - + return _remove_node(key); } @@ -706,7 +712,7 @@ int preference_foreach_item(preference_item_cb callback, void *user_data) char *errmsg; int i; - if (pref_db == NULL) + if (pref_db == NULL) { if (_initialize() != PREFERENCE_ERROR_NONE) { @@ -715,7 +721,7 @@ int preference_foreach_item(preference_item_cb callback, void *user_data) } } - if (callback == NULL) + if (callback == NULL) { LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, PREFERENCE_ERROR_INVALID_PARAMETER); return PREFERENCE_ERROR_INVALID_PARAMETER; @@ -727,19 +733,19 @@ int preference_foreach_item(preference_item_cb callback, void *user_data) LOGE("[%s] IO_ERROR(0x%08x) : fail to create query string", __FUNCTION__, PREFERENCE_ERROR_IO_ERROR); return PREFERENCE_ERROR_IO_ERROR; } - + ret = sqlite3_get_table(pref_db, buf, &result, &rows, &columns, &errmsg); sqlite3_free(buf); - if (ret != SQLITE_OK) + if (ret != SQLITE_OK) { LOGE("[%s] IO_ERROR(0x%08x) : fail to read data (%s)", __FUNCTION__, PREFERENCE_ERROR_IO_ERROR, errmsg); sqlite3_free(errmsg); return PREFERENCE_ERROR_IO_ERROR; } - - for (i = 1; i <= rows; i++) + + for (i = 1; i <= rows; i++) { - if (callback(result[i], user_data) != true) + if (callback(result[i], user_data) != true) { break; } diff --git a/src/service.c b/src/service.c index e53312c..c44e171 100755 --- a/src/service.c +++ b/src/service.c @@ -35,6 +35,10 @@ #define LOG_TAG "TIZEN_N_SERVICE" +#ifndef TIZEN_PATH_MAX +#define TIZEN_PATH_MAX 1024 +#endif + #define BUNDLE_KEY_PREFIX_AUL "__AUL_" #define BUNDLE_KEY_PREFIX_SERVICE "__APP_SVC_" @@ -43,6 +47,8 @@ #define BUNDLE_KEY_MIME "__APP_SVC_MIME_TYPE__" #define BUNDLE_KEY_DATA "__APP_SVC_DATA__" #define BUNDLE_KEY_PACKAGE "__APP_SVC_PKG_NAME__" +#define BUNDLE_KEY_WINDOW "__APP_SVC_K_WIN_ID__" + typedef enum { SERVICE_TYPE_REQUEST, @@ -62,6 +68,8 @@ typedef struct service_request_context_s { void *user_data; } *service_request_context_h; +extern int appsvc_allow_transient_app(bundle *b, unsigned int id); + static int service_create_reply(bundle *data, struct service_s **service); static const char* service_error_to_string(service_error_e error) @@ -193,7 +201,6 @@ static void service_request_result_broker(bundle *appsvc_bundle, int appsvc_requ } user_data = request_context->user_data; - reply_cb = request_context->reply_cb; if (reply_cb != NULL) @@ -205,6 +212,14 @@ static void service_request_result_broker(bundle *appsvc_bundle, int appsvc_requ service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, "invalid callback "); } + service_destroy(reply); + + if (request_context->service != NULL) + { + service_destroy(request_context->service); + } + + free(request_context); } @@ -287,11 +302,6 @@ int service_create_event(bundle *data, struct service_s **service) return SERVICE_ERROR_NONE; } -int service_impl_create_event(bundle *data, struct service_s **service) -{ - return service_create_event(data, service); -} - static int service_create_reply(bundle *data, struct service_s **service) { struct service_s *service_reply; @@ -485,16 +495,29 @@ int service_get_mime(service_h service, char **mime) int service_set_package(service_h service, const char *package) { + // TODO: this function must be deprecated + return service_set_app_id(service, package); +} + +int service_get_package(service_h service, char **package) +{ + // TODO: this function must be deprecated + return service_get_app_id(service, package); +} + + +int service_set_app_id(service_h service, const char *app_id) +{ if (service_valiate_service(service)) { return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - if (package != NULL) + if (app_id != NULL) { - if (appsvc_set_pkgname(service->data, package) != 0) + if (appsvc_set_pkgname(service->data, app_id) != 0) { - return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, "invalid package"); + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, "invalid application ID"); } } else @@ -505,24 +528,70 @@ int service_set_package(service_h service, const char *package) return SERVICE_ERROR_NONE; } -int service_get_package(service_h service, char **package) + +int service_get_app_id(service_h service, char **app_id) { - const char *package_value; + const char *app_id_value; - if (service_valiate_service(service) || package == NULL) + if (service_valiate_service(service) || app_id == NULL) + { + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + app_id_value = appsvc_get_pkgname(service->data); + + if (app_id_value != NULL) + { + *app_id = strdup(app_id_value); + } + else + { + *app_id = NULL; + } + + return SERVICE_ERROR_NONE; +} + +int service_set_window(service_h service, unsigned int id) +{ + if (service_valiate_service(service)) + { + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + if (id > 0) + { + if (appsvc_allow_transient_app(service->data, id) != 0) + { + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, "invalid id"); + } + } + else + { + bundle_del(service->data, BUNDLE_KEY_WINDOW); + } + + return SERVICE_ERROR_NONE; +} + +int service_get_window(service_h service, unsigned int *id) +{ + const char *window_id; + + if (service_valiate_service(service) || id == NULL) { return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - package_value = appsvc_get_pkgname(service->data); + window_id = bundle_get_val(service->data, BUNDLE_KEY_WINDOW); - if (package_value != NULL) + if (window_id != NULL) { - *package = strdup(package_value); + *id = atoi(window_id); } else { - *package = NULL; + *id = 0; } return SERVICE_ERROR_NONE; @@ -594,8 +663,9 @@ int service_send_launch_request(service_h service, service_reply_cb callback, vo if (callback != NULL) { + service_h request_clone = NULL; + request_context = calloc(1, sizeof(struct service_request_context_s)); - // request_context will be deallocated from service_request_result_broker() if (request_context == NULL) { @@ -603,7 +673,14 @@ int service_send_launch_request(service_h service, service_reply_cb callback, vo } request_context->reply_cb = callback; - request_context->service = service; + + if (service_clone(&request_clone, service) != SERVICE_ERROR_NONE) + { + free(request_context); + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, "failed to clone the service request handle"); + } + + request_context->service = request_clone; request_context->user_data = user_data; } @@ -1023,3 +1100,133 @@ int service_foreach_app_matched(service_h service, service_app_matched_cb callba return SERVICE_ERROR_NONE; } + +int service_get_caller(service_h service, char **package) +{ + const char *bundle_value; + pid_t caller_pid; + char package_buf[TIZEN_PATH_MAX] = {0, }; + char *package_dup; + + if (service_valiate_service(service) || package == NULL) + { + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + if (service->type != SERVICE_TYPE_EVENT) + { + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, "invalid service handle type"); + } + + bundle_value = bundle_get_val(service->data, AUL_K_ORG_CALLER_PID); + + if (bundle_value == NULL) + { + bundle_value = bundle_get_val(service->data, AUL_K_CALLER_PID); + } + + if (bundle_value == NULL) + { + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, "failed to retrieve the pid of the caller"); + } + + caller_pid = atoi(bundle_value); + + if (caller_pid <= 0) + { + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, "invalid pid of the caller"); + } + + if (aul_app_get_pkgname_bypid(caller_pid, package_buf, sizeof(package_buf)) != AUL_R_OK) + { + return service_error(SERVICE_ERROR_APP_NOT_FOUND, __FUNCTION__, "failed to get the package name of the caller"); + } + + package_dup = strdup(package_buf); + + if (package_dup == NULL) + { + return service_error(SERVICE_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); + } + + *package = package_dup; + + return SERVICE_ERROR_NONE; +} + + +int service_is_reply_requested(service_h service, bool *requested) +{ + const char *bundle_value; + + if (service_valiate_service(service) || requested == NULL) + { + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + if (service->type != SERVICE_TYPE_EVENT) + { + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, "invalid service handle type"); + } + + bundle_value = bundle_get_val(service->data, AUL_K_WAIT_RESULT); + + if (bundle_value != NULL) + { + *requested = true; + } + else + { + *requested = false; + } + + return SERVICE_ERROR_NONE; +} + +int service_import_from_bundle(service_h service, bundle *data) +{ + bundle *data_dup = NULL; + + if (service_valiate_service(service) || data == NULL) + { + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + data_dup = bundle_dup(data); + + if (data_dup == NULL) + { + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, "failed to duplicate the bundle"); + } + + if (service->data != NULL) + { + bundle_free(service->data); + } + + service->data = data_dup; + + return SERVICE_ERROR_NONE; +} + +int service_export_as_bundle(service_h service, bundle **data) +{ + bundle *data_dup = NULL; + + if (service_valiate_service(service) || data == NULL) + { + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + data_dup = bundle_dup(service->data); + + if (data_dup == NULL) + { + return service_error(SERVICE_ERROR_INVALID_PARAMETER, __FUNCTION__, "failed to duplicate the bundle"); + } + + *data = data_dup; + + return SERVICE_ERROR_NONE; +} + diff --git a/src/ui_notification.c b/src/ui_notification.c index 2b54902..0df0991 100755 --- a/src/ui_notification.c +++ b/src/ui_notification.c @@ -11,7 +11,7 @@ * 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. + * limitations under the License. */ @@ -43,6 +43,8 @@ struct ui_notification_s { char *title; char *content; service_h service; + char *sound; + bool vibration; }; static int ui_notification_error_handler(int error, const char *func, const char *on_error) @@ -69,7 +71,7 @@ static int ui_notification_error_handler(int error, const char *func, const char case NOTIFICATION_ERROR_FROM_DB: retcode = UI_NOTIFICATION_ERROR_DB_FAILED; error_msg = "DB_FAILED"; - break; + break; case NOTIFICATION_ERROR_ALREADY_EXIST_ID: case NOTIFICATION_ERROR_NOT_EXIST_ID: @@ -108,7 +110,7 @@ int ui_notification_create(bool ongoing, ui_notification_h *notification) LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_OUT_OF_MEMORY); return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY; } - + notification_out->raw_handle = NULL; notification_out->ongoing = ongoing; notification_out->posted = false; @@ -118,7 +120,9 @@ int ui_notification_create(bool ongoing, ui_notification_h *notification) notification_out->title = NULL; notification_out->content = NULL; notification_out->service = NULL; - + notification_out->sound = NULL; + notification_out->vibration = false; + *notification = notification_out; return UI_NOTIFICATION_ERROR_NONE; @@ -133,6 +137,9 @@ static int ui_notification_construct(bool ongoing, notification_h raw_handle, ui char *title; char *content; bundle *service_data; + const char *sound; + notification_sound_type_e sound_type; + notification_vibration_type_e vib_type; if (notification == NULL) { @@ -155,22 +162,22 @@ static int ui_notification_construct(bool ongoing, notification_h raw_handle, ui { return retcode; } - + notification_out->ongoing = ongoing; notification_out->posted = true; notification_out->removed = false; - if (!notification_get_image(raw_handle, NOTIFICATION_IMAGE_TYPE_ICON, &icon)) + if (!notification_get_image(raw_handle, NOTIFICATION_IMAGE_TYPE_ICON, &icon) && icon) { - notification_out->icon = icon; + notification_out->icon = strdup(icon); } if (!notification_get_time(raw_handle, &time)) { notification_out->time = malloc(sizeof(struct tm)); - + if (notification_out->time == NULL) { ui_notification_destroy(notification_out); @@ -181,14 +188,27 @@ static int ui_notification_construct(bool ongoing, notification_h raw_handle, ui localtime_r(&time, notification_out->time); } - if (!notification_get_text(raw_handle, NOTIFICATION_TEXT_TYPE_TITLE, &title)) + if (!notification_get_text(raw_handle, NOTIFICATION_TEXT_TYPE_TITLE, &title) && title) { - notification_out->title = title; + notification_out->title = strdup(title); } - if (! notification_get_text(raw_handle, NOTIFICATION_TEXT_TYPE_CONTENT, &content)) + if (!notification_get_text(raw_handle, NOTIFICATION_TEXT_TYPE_CONTENT, &content) && content) { - notification_out->content = content; + notification_out->content = strdup(content); + } + + if (!notification_get_sound(raw_handle, &sound_type, &sound) && sound) + { + notification_out->sound = strdup(sound); + } + + if (!notification_get_vibration(raw_handle, &vib_type, NULL)) + { + if (vib_type == NOTIFICATION_VIBRATION_TYPE_DEFAULT) + { + notification_out->vibration = true; + } } if (!notification_get_execute_option(raw_handle, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &service_data)) @@ -229,6 +249,9 @@ int ui_notification_destroy(ui_notification_h notification) if (notification->content) free(notification->content); + if (notification->sound) + free(notification->sound); + if (notification->service) service_destroy(notification->service); @@ -290,6 +313,13 @@ int ui_notification_clone(ui_notification_h *clone, ui_notification_h notificati notification_out->content = strdup(notification->content); } + if (notification->sound) + { + notification_out->sound = strdup(notification->sound); + } + + notification_out->vibration = notification->vibration; + if (notification->service) { service_clone(&(notification_out->service), notification->service); @@ -422,7 +452,7 @@ int ui_notification_get_time(ui_notification_h notification, struct tm **time) LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_OUT_OF_MEMORY); return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY; } - + memcpy(time_dup, notification->time, sizeof(struct tm)); } @@ -622,6 +652,91 @@ int ui_notification_get_service(ui_notification_h notification, service_h *servi return UI_NOTIFICATION_ERROR_NONE; } +int ui_notification_set_sound(ui_notification_h notification, const char *path) +{ + char *path_dup = NULL; + + if (notification == NULL) + { + LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER); + return UI_NOTIFICATION_ERROR_INVALID_PARAMETER; + } + + if (path != NULL) + { + path_dup = strdup(path); + + if (path_dup == NULL) + { + LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_OUT_OF_MEMORY); + return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY; + } + } + + if (notification->sound != NULL) + { + free(notification->sound); + } + + notification->sound = path_dup; + + return UI_NOTIFICATION_ERROR_NONE; +} + +int ui_notification_get_sound(ui_notification_h notification, char **path) +{ + char *path_dup = NULL; + + if (notification == NULL || path == NULL) + { + LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER); + return UI_NOTIFICATION_ERROR_INVALID_PARAMETER; + } + + if (notification->sound != NULL) + { + path_dup = strdup(notification->sound); + + if (path_dup == NULL) + { + LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_OUT_OF_MEMORY); + *path = NULL; + + return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY; + } + } + + *path = path_dup; + + return UI_NOTIFICATION_ERROR_NONE; +} + +int ui_notification_set_vibration(ui_notification_h notification, bool value) +{ + if (notification == NULL) + { + LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER); + return UI_NOTIFICATION_ERROR_INVALID_PARAMETER; + } + + notification->vibration = value; + + return UI_NOTIFICATION_ERROR_NONE; +} + +int ui_notification_get_vibration(ui_notification_h notification, bool *value) +{ + if (notification == NULL || value == NULL) + { + LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER); + return UI_NOTIFICATION_ERROR_INVALID_PARAMETER; + } + + *value = notification->vibration; + + return UI_NOTIFICATION_ERROR_NONE; +} + static int ui_notification_build_attributes(ui_notification_h notification) { bundle *service_data; @@ -635,7 +750,7 @@ static int ui_notification_build_attributes(ui_notification_h notification) if (notification->icon != NULL) { struct stat st; - + if (stat(notification->icon, &st) < 0) { LOGE("[%s] NO_SUCH_FILE(0x%08x) : invalid icon", __FUNCTION__, UI_NOTIFICATION_ERROR_NO_SUCH_FILE); @@ -670,6 +785,23 @@ static int ui_notification_build_attributes(ui_notification_h notification) notification_set_property(notification->raw_handle, NOTIFICATION_PROP_DISABLE_APP_LAUNCH); } + if (notification->sound != NULL) + { + struct stat st; + + if (stat(notification->sound, &st) < 0) + { + LOGE("[%s] NO_SUCH_FILE(0x%08x) : invalid sound file", __FUNCTION__, UI_NOTIFICATION_ERROR_NO_SUCH_FILE); + return UI_NOTIFICATION_ERROR_NO_SUCH_FILE; + } + notification_set_sound(notification->raw_handle, NOTIFICATION_SOUND_TYPE_USER_DATA, notification->sound); + } + + if (notification->vibration) + { + notification_set_vibration(notification->raw_handle, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL); + } + return UI_NOTIFICATION_ERROR_NONE; } @@ -801,7 +933,7 @@ int ui_notification_update_progress(ui_notification_h notification, ui_notifica notification_update_size(notification->raw_handle, NOTIFICATION_PRIV_ID_NONE, value), __FUNCTION__, "failed to update the progress"); break; - + case UI_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE: retcode = ui_notification_error_handler( notification_update_progress(notification->raw_handle, NOTIFICATION_PRIV_ID_NONE, value), @@ -864,6 +996,50 @@ void ui_notification_cancel_all(void) notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NONE); } +void ui_notification_cancel_all_by_type(bool ongoing) +{ + notification_type_e type = NOTIFICATION_TYPE_NONE; + + if (ongoing) + type = NOTIFICATION_TYPE_ONGOING; + else + type = NOTIFICATION_TYPE_NOTI; + + notification_delete_all_by_type(NULL, type); +} + +void ui_notification_cancel_all_by_package(const char *package, bool ongoing) +{ + notification_type_e type = NOTIFICATION_TYPE_NONE; + + if (ongoing) + type = NOTIFICATION_TYPE_ONGOING; + else + type = NOTIFICATION_TYPE_NOTI; + + notification_delete_all_by_type(package, type); +} + +int ui_notification_cancel_all_by_app_id(const char *app_id, bool ongoing) +{ + notification_type_e type = NOTIFICATION_TYPE_NONE; + + if (app_id == NULL) + { + LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER); + return UI_NOTIFICATION_ERROR_INVALID_PARAMETER; + } + + if (ongoing) + type = NOTIFICATION_TYPE_ONGOING; + else + type = NOTIFICATION_TYPE_NOTI; + + notification_delete_all_by_type(app_id, type); + + return UI_NOTIFICATION_ERROR_NONE; +} + static bool ui_notification_package_equal(notification_h handle) { char *package = NULL; |