summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSangyoon Jang <s89.jang@samsung.com>2015-04-14 10:51:47 +0900
committerSangyoon Jang <s89.jang@samsung.com>2015-04-14 10:51:47 +0900
commitb9e802105c14c0940624523a60b4fa03a40acf91 (patch)
treee9b352c2f8eeb9209f491ff42c8f9b105ea5af60
parent449e7cdfd1b5ebf3e091710fd702a4e4558e1a32 (diff)
downloadapplication-b9e802105c14c0940624523a60b4fa03a40acf91.tar.gz
application-b9e802105c14c0940624523a60b4fa03a40acf91.tar.bz2
application-b9e802105c14c0940624523a60b4fa03a40acf91.zip
Remove ui_notification
TC-2496 there is a cyclic dependency between application api and notification api notification functions should be implemented at notification api Change-Id: Icc3c50ad923ab3a5c0cf685c2ef54e5bc2d2d09f Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
-rwxr-xr-xinclude/app.h1
-rwxr-xr-xinclude/app_ui_notification.h474
-rwxr-xr-xpackaging/capi-appfw-application.spec1
-rwxr-xr-xsrc/ui_notification.c1179
4 files changed, 0 insertions, 1655 deletions
diff --git a/include/app.h b/include/app.h
index bd8d68e..c8f1d78 100755
--- a/include/app.h
+++ b/include/app.h
@@ -25,7 +25,6 @@
#include <app_preference.h>
#include <app_storage.h>
#include <app_i18n.h>
-#include <app_ui_notification.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/app_ui_notification.h b/include/app_ui_notification.h
deleted file mode 100755
index 37a00bd..0000000
--- a/include/app_ui_notification.h
+++ /dev/null
@@ -1,474 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 __TIZEN_APPFW_UI_NOTIFICATION_H__
-#define __TIZEN_APPFW_UI_NOTIFICATION_H__
-
-#include <tizen.h>
-#include <time.h>
-#include <app_service.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /**
- * @addtogroup CAPI_UI_NOTIFICATION_MODULE
- * @{
- */
-
-/**
- * @brief Notification handle.
- */
-typedef struct ui_notification_s *ui_notification_h;
-
-/**
- * @brief Enumerations of error code for notification.
- */
-typedef enum {
- UI_NOTIFICATION_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
- UI_NOTIFICATION_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- UI_NOTIFICATION_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
- UI_NOTIFICATION_ERROR_DB_FAILED = TIZEN_ERROR_APPLICATION_CLASS | 0x31, /**< DB operation failed */
- UI_NOTIFICATION_ERROR_NO_SUCH_FILE = TIZEN_ERROR_NO_SUCH_FILE, /**< No such file */
- UI_NOTIFICATION_ERROR_INVALID_STATE = TIZEN_ERROR_APPLICATION_CLASS | 0x32, /**< Invalid state */
-} ui_notification_error_e;
-
-/**
- * @brief Enumeration of progress type for ongoing notification
- */
-typedef enum {
- UI_NOTIFICATION_PROGRESS_TYPE_SIZE, /**< Size in bytes */
- UI_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE, /**< Percentage (between 0.0 and 1.0) */
-} ui_notification_progress_type_e;
-
-/**
-* @brief Called to retrieve the notifications posted.
-* @remarks You should not free @a notification returned by this function.
-* @param[in] notification The notification handle
-* @param[in] user_data The user data passed from the foreach function
-* @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
-* @pre ui_notification_foreach_notification_posted() will invoke this callback.
-* @see ui_notification_foreach_notification_posted()
-* @see ui_notification_clone()
-*/
-typedef bool (*ui_notification_cb)(ui_notification_h notification, void *user_data);
-
-/**
- * @brief Creates a notification handle.
- * @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.
- * @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_destroy()
- */
-int ui_notification_create(bool ongoing, ui_notification_h *notification);
-
-/**
- * @brief Destroys the notification handle and releases all its resources.
- * @param[in] notification The notification handle
- * @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_create()
- */
-int ui_notification_destroy(ui_notification_h notification);
-
-/**
- * @brief Gets the identifier of the notification unique within the application
- * @remarks The system assigns an unique identifier to the notification when it is posted. \n
- * This function returns #UI_NOTIFICATION_ERROR_INVALID_STATE if the notification was not posted.
- * @param[in] notification The notification handle
- * @param[out] id The identifier for the notification unique within the application.
- * @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
- * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was not posted.
- * @see ui_notification_post()
- */
-int ui_notification_get_id(ui_notification_h notification, int *id);
-
-/**
- * @brief Checks whether the notification is ongoing or not
- * @param[in] notification The notification handle
- * @param[out] ongoing A boolean value that sets whether this is an ongoing notification.
- * @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_create()
- */
-int ui_notification_is_ongoing(ui_notification_h notification, bool *ongoing);
-
-/**
- * @brief Sets the full path of the icon image to display in the notification.
- * @remarks The @a path should be the absolute path. If the icon is not set, the icon of the application will be displayed. \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 absolute path to the specified icon \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_icon()
- */
-int ui_notification_set_icon(ui_notification_h notification, const char *path);
-
-/**
- * @brief Gets the absolute path to the icon to display in the notification.
- * @remarks The @a path must be released with free() by you.
- * @param[in] notification The notification handle
- * @param[out] path The absolute path to the icon
- * @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_icon()
- */
-int ui_notification_get_icon(ui_notification_h notification, char **path);
-
-/**
- * @brief Sets the time that the notification occurred.
- * @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] time The time that the notification occurred \n
- * If the @a time 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_time()
- */
-int ui_notification_set_time(ui_notification_h notification, struct tm *time);
-
-/**
- * @brief Gets the time that the notification occured.
- * @param[in] notification The notification handle
- * @param[out] time The time that the notification occured
- * @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_time()
- */
-int ui_notification_get_time(ui_notification_h notification, struct tm **time);
-
-/**
- * @brief Sets the title to display in the notification.
- * @remarks If the title is not set, the name of the application will be displayed. \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] title The title to display in the notification \n
- * If the @a title 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_title()
- */
-int ui_notification_set_title(ui_notification_h notification, const char *title);
-
-/**
- * @brief Gets the title to display in the notification.
- * @remarks The @a title must be released with free() by you.
- * @param[in] notification The notification handle
- * @param[out] title The title to display in the notification
- * @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_title()
- */
-int ui_notification_get_title(ui_notification_h notification, char **title);
-
-/**
- * @brief Sets the content to display in the notification
- * @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] content The content to display in the notification \n
- * If the @a content 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_content()
- */
-int ui_notification_set_content(ui_notification_h notification, const char *content);
-
-/**
- * @brief Gets the content to display in the notification
- * @remarks The @a content must be released with free() by you.
- * @param[in] notification The notification handle
- * @param[out] content The content to display in the notification
- * @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_content()
- */
-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
- * @remarks If the service is not set, the selected notification will be cleared from both the notification tray and the status bar without any action. \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] service The service handle to launch when the notification is selected \n
- * If the @a service 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_service()
- * @see service_create()
- */
-int ui_notification_set_service(ui_notification_h notification, service_h service);
-
-/**
- * @brief Gets the service to launch when the notification is selected from the notification tray
- * @remarks The @a service must be released with service_destroy() by you.
- * @param[in] notification The notification handle
- * @param[out] service The service handle to launch when the notification is selected
- * @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_service()
- */
-int ui_notification_get_service(ui_notification_h notification, service_h *service);
-
-/**
- * @brief Posts the notification to display in the notification tray and the status bar
- * @param[in] notification The notification handle
- * @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_DB_FAILED DB failed
- * @retval #UI_NOTIFICATION_ERROR_NO_SUCH_FILE DB No such icon file
- * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was already posted
- * @post The posted notification can be canceled or updated.
- * @see ui_notification_cancel()
- * @see ui_notification_cancel_all()
- * @see ui_notification_update()
- * @see ui_notification_update_progress()
- * @see ui_notification_foreach_notification_posted()
- */
-int ui_notification_post(ui_notification_h notification);
-
-/**
- * @brief Cancels the previously posted notification.
- * @details The previously posted notification is removed from the notification tray and the status bar.
- * @remarks The canceled @a notification is not be released automatically, must be released with ui_notification_destroy() by you.
- * @param[in] notification The notification handle
- * @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_INVALID_STATE The notification was not posted or the notification was either cleared or canceled.
- * @pre The notification must be posted before canceling it.
- * @see ui_notification_post()
- * @see ui_notification_cancel_all()
- */
-int ui_notification_cancel(ui_notification_h notification);
-
-/**
- * @brief Cancels all previously posted notifications by the current application.
- * @details All previously posted notifications are removed from the notification tray and the status bar.
- * @remarks The notifications posted by other applications are not canceled from the notification tray and the status bar.
- * @see ui_notification_post()
- * @see ui_notification_cancel()
- */
-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
- * @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_DB_FAILED DB failed
- * @retval #UI_NOTIFICATION_ERROR_NO_SUCH_FILE DB No such icon file
- * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was not posted or the notification was either cleared or canceled.
- * @pre The notification must be posted before updating it.
- * @see ui_notification_post()
- * @see ui_notification_update_progress()
- */
-int ui_notification_update(ui_notification_h notification);
-
-/**
- * @brief Updates the progress to the specified value
- * @remarks You cannot update the notification which was cleared or canceled.
- * @param[in] notification The notification handle \n
- * It must be ongoing notification. \n
- * If not, #UI_NOTIFICATION_ERROR_INVALID_PARAMETER will occur
- * @param[in] type The progress type
- * @param[in] value The value of the progress \n
- * The @a value must be greater than or equal to zero. \n
- * if @a type is #UI_NOTIFICATION_PROGRESS_TYPE_SIZE, it must be in bytes. \n
- * If @a type is #UI_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE, It must be a floating-point value between 0.0 and 1.0.
- * @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_INVALID_STATE The notification was not posted or the notification was canceled.
- * @pre The notification must be posted before updating the progress to the specified value
- * @see ui_notification_create()
- * @see ui_notification_post()
- * @see ui_notification_update()
- * @see #ui_notification_progress_type_e
- */
-int ui_notification_update_progress(ui_notification_h notification, ui_notification_progress_type_e type, double value);
-
-/**
- * @brief Retrieves all posted notifications.
- * @details This function calls ui_notification_cb() once for each notification which was posted and is being shown. \n
- * If ui_notification_cb() callback function returns false, then iteration will be finished.
- *
- * @param [in] ongoing A boolean value that sets whether the type is an ongoing notification.
- * @param [in] callback The iteration callback function
- * @param [in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise a negative error value.
- * @retval #UI_NOTIFICATION_ERROR_NONE Successful
- * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
- * @post This function invokes ui_notification_cb().
- * @see ui_notification_cb()
- */
-int ui_notification_foreach_notification_posted(bool ongoing, ui_notification_cb callback, void *user_data);
-
-/**
- * @brief Creates and returns a copy of the given notification handle.
- *
- * @remarks A newly created notification handle should be destroyed by calling ui_notification_destroy() if it is no longer needed.
- *
- * @param [out] clone If successful, a newly created notification handle will be returned.
- * @param [in] service The notification handle
- * @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_create()
- * @see ui_notification_destroy()
- */
-int ui_notification_clone(ui_notification_h *clone, ui_notification_h notification);
-
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __TIZEN_APPFW_UI_NOTIFICATION_H__ */
diff --git a/packaging/capi-appfw-application.spec b/packaging/capi-appfw-application.spec
index 59444c9..db4dbe5 100755
--- a/packaging/capi-appfw-application.spec
+++ b/packaging/capi-appfw-application.spec
@@ -14,7 +14,6 @@ BuildRequires: pkgconfig(appcore-efl)
BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(ail)
BuildRequires: pkgconfig(appsvc)
-BuildRequires: pkgconfig(notification)
BuildRequires: pkgconfig(elementary)
BuildRequires: pkgconfig(alarm-service)
BuildRequires: pkgconfig(capi-base-common)
diff --git a/src/ui_notification.c b/src/ui_notification.c
deleted file mode 100755
index 1610d02..0000000
--- a/src/ui_notification.c
+++ /dev/null
@@ -1,1179 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <dlog.h>
-#include <notification.h>
-
-#include <app.h>
-#include <app_service_private.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "CAPI_APPFW_APPLICATION_UI_NOTIFICATION"
-
-struct ui_notification_s {
- notification_h raw_handle;
- bool ongoing;
- bool posted;
- bool removed;
- char *icon;
- struct tm *time;
- 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)
-{
- int retcode;
- char *error_msg;
-
- switch (error)
- {
- case NOTIFICATION_ERROR_NONE:
- retcode = UI_NOTIFICATION_ERROR_NONE;
- break;
-
- case NOTIFICATION_ERROR_INVALID_DATA:
- retcode = UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- error_msg = "INVALID_PARAMETER";
- break;
-
- case NOTIFICATION_ERROR_NO_MEMORY:
- retcode = UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
- error_msg = "OUT_OF_MEMORY";
- break;
-
- case NOTIFICATION_ERROR_FROM_DB:
- retcode = UI_NOTIFICATION_ERROR_DB_FAILED;
- error_msg = "DB_FAILED";
- break;
-
- case NOTIFICATION_ERROR_ALREADY_EXIST_ID:
- case NOTIFICATION_ERROR_NOT_EXIST_ID:
- retcode = UI_NOTIFICATION_ERROR_INVALID_STATE;
- error_msg = "INVALID_STATE";
- break;
-
- default:
- retcode = UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- error_msg = "INVALID_PARAMETER";
- }
-
- if (retcode != UI_NOTIFICATION_ERROR_NONE)
- {
- LOGE("[%s] %s(0x%08x) : %s", func, error_msg, retcode, on_error);
- }
-
- return retcode;
-}
-
-
-int ui_notification_create(bool ongoing, ui_notification_h *notification)
-{
- ui_notification_h notification_out;
-
- if (notification == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x) : invalid output param", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- notification_out = (ui_notification_h)calloc(1, sizeof(struct ui_notification_s));
-
- if (notification_out == NULL)
- {
- LOGE("OUT_OF_MEMORY(0x%08x)", 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;
- notification_out->removed = false;
- notification_out->icon = NULL;
- notification_out->time = NULL;
- 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;
-}
-
-static int ui_notification_construct(bool ongoing, notification_h raw_handle, ui_notification_h *notification)
-{
- int retcode;
- ui_notification_h notification_out;
- char *icon;
- time_t time;
- char *title;
- char *content;
- bundle *service_data;
- const char *sound = NULL;
- notification_sound_type_e sound_type;
- notification_vibration_type_e vib_type;
-
- if (notification == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x) : invalid output param", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- notification_out = (ui_notification_h)calloc(1, sizeof(struct ui_notification_s));
-
- if (notification_out == NULL)
- {
- LOGE("OUT_OF_MEMORY(0x%08x)", UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
-
- retcode = ui_notification_error_handler(notification_clone(raw_handle, &(notification_out->raw_handle)),\
- __FUNCTION__, "failed to clone the notification handle");
-
- if (retcode != NOTIFICATION_ERROR_NONE)
- {
- free(notification_out);
- 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) && 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);
- LOGE("OUT_OF_MEMORY(0x%08x)", UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
-
- localtime_r(&time, notification_out->time);
- }
-
- if (!notification_get_text(raw_handle, NOTIFICATION_TEXT_TYPE_TITLE, &title) && title)
- {
- notification_out->title = strdup(title);
- }
-
- if (!notification_get_text(raw_handle, NOTIFICATION_TEXT_TYPE_CONTENT, &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))
- {
- service_h service;
-
- if (!service_create_request(service_data, &service))
- {
- notification_out->service = service;
- }
- }
-
- *notification = notification_out;
-
- return UI_NOTIFICATION_ERROR_NONE;
-}
-
-int ui_notification_destroy(ui_notification_h notification)
-{
- if (notification == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x) : invalid handle", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (notification->raw_handle)
- notification_free(notification->raw_handle);
-
- if (notification->icon)
- free(notification->icon);
-
- if (notification->time)
- free(notification->time);
-
- if (notification->title)
- free(notification->title);
-
- if (notification->content)
- free(notification->content);
-
- if (notification->sound)
- free(notification->sound);
-
- if (notification->service)
- service_destroy(notification->service);
-
- free(notification);
-
- return UI_NOTIFICATION_ERROR_NONE;
-}
-
-int ui_notification_get_id(ui_notification_h notification, int *id)
-{
- notification_h raw_handle = NULL;
-
- if (notification == NULL || id == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
- if (notification->raw_handle == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- raw_handle = notification->raw_handle;
- if (notification_get_id(raw_handle, NULL, id) != NOTIFICATION_ERROR_NONE) {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- return UI_NOTIFICATION_ERROR_NONE;
-}
-
-int ui_notification_clone(ui_notification_h *clone, ui_notification_h notification)
-{
- ui_notification_h notification_out;
- int retcode;
-
- if (clone == NULL || notification == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- notification_out = (ui_notification_h)calloc(1, sizeof(struct ui_notification_s));
-
- if (notification_out == NULL)
- {
- LOGE("OUT_OF_MEMORY(0x%08x)", UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
-
- if (notification->raw_handle != NULL)
- {
- retcode = notification_clone(notification->raw_handle, &(notification_out->raw_handle));
-
- if (retcode)
- {
- free(notification_out);
- return ui_notification_error_handler(retcode, __FUNCTION__, "failed to clone the handle");
- }
- }
-
- notification_out->ongoing = notification->ongoing;
-
- notification_out->posted = notification->posted;
-
- notification_out->removed = notification->removed;
-
- if (notification->icon)
- {
- notification_out->icon = strdup(notification->icon);
- }
-
- if (notification->time)
- {
- notification_out->time = malloc(sizeof(struct tm));
- if (notification_out->time != NULL)
- {
- memcpy(notification_out->time, notification->time, sizeof(struct tm));
- }
- }
-
- if (notification->title)
- {
- notification_out->title = strdup(notification->title);
- }
-
- if (notification->content)
- {
- 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);
- }
-
- *clone = notification_out;
-
- return UI_NOTIFICATION_ERROR_NONE;
-}
-
-int ui_notification_is_ongoing(ui_notification_h notification, bool *ongoing)
-{
- if (notification == NULL || ongoing == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- *ongoing = notification->ongoing;
-
- return UI_NOTIFICATION_ERROR_NONE;
-}
-
-int ui_notification_set_icon(ui_notification_h notification, const char *path)
-{
- char *path_dup = NULL;
-
- if (notification == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (path != NULL)
- {
- path_dup = strdup(path);
-
- if (path_dup == NULL)
- {
- LOGE("OUT_OF_MEMORY(0x%08x)", UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if (notification->icon != NULL)
- {
- free(notification->icon);
- }
-
- notification->icon = path_dup;
-
- return UI_NOTIFICATION_ERROR_NONE;
-}
-
-int ui_notification_get_icon(ui_notification_h notification, char **path)
-{
- char *path_dup = NULL;
-
- if (notification == NULL || path == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (notification->icon != NULL)
- {
- path_dup = strdup(notification->icon);
-
- if (path_dup == NULL)
- {
- LOGE("OUT_OF_MEMORY(0x%08x)", UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
- }
-
- *path = path_dup;
-
- return UI_NOTIFICATION_ERROR_NONE;
-}
-
-int ui_notification_set_time(ui_notification_h notification, struct tm *time)
-{
- struct tm *time_dup = NULL;
-
- if (notification == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (time != NULL)
- {
- time_dup = malloc(sizeof(struct tm));
-
- if (time_dup == NULL)
- {
- LOGE("OUT_OF_MEMORY(0x%08x)", UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
-
- memcpy(time_dup, time, sizeof(struct tm));
- }
-
- if (notification->time != NULL)
- {
- free(notification->time);
- }
-
- notification->time = time_dup;
-
- return UI_NOTIFICATION_ERROR_NONE;
-}
-
-int ui_notification_get_time(ui_notification_h notification, struct tm **time)
-{
- struct tm *time_dup = NULL;
-
- if (notification == NULL || time == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (notification->time != NULL)
- {
- time_dup = malloc(sizeof(struct tm));
-
- if (time_dup == NULL)
- {
- LOGE("OUT_OF_MEMORY(0x%08x)", UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
-
- memcpy(time_dup, notification->time, sizeof(struct tm));
- }
-
- *time = time_dup;
-
- return UI_NOTIFICATION_ERROR_NONE;
-}
-
-int ui_notification_set_title(ui_notification_h notification, const char *title)
-{
- char *title_dup = NULL;
-
- if (notification == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (title != NULL)
- {
- title_dup = strdup(title);
-
- if (title_dup == NULL)
- {
- LOGE("OUT_OF_MEMORY(0x%08x)", UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if (notification->title != NULL)
- {
- free(notification->title);
- }
-
- notification->title = title_dup;
-
- return UI_NOTIFICATION_ERROR_NONE;
-}
-
-int ui_notification_get_title(ui_notification_h notification, char **title)
-{
- char *title_dup = NULL;
-
- if (notification == NULL || title == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (notification->title != NULL)
- {
- title_dup = strdup(notification->title);
-
- if (title_dup == NULL)
- {
- LOGE("OUT_OF_MEMORY(0x%08x)", UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
- }
-
- *title = title_dup;
-
- return UI_NOTIFICATION_ERROR_NONE;
-}
-
-
-int ui_notification_set_content(ui_notification_h notification, const char *content)
-{
- char *content_dup = NULL;
-
- if (notification == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (content != NULL)
- {
- content_dup = strdup(content);
-
- if (content_dup == NULL)
- {
- LOGE("OUT_OF_MEMORY(0x%08x)", UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if (notification->content != NULL)
- {
- free(notification->content);
- }
-
- notification->content = content_dup;
-
- return UI_NOTIFICATION_ERROR_NONE;
-}
-
-int ui_notification_get_content(ui_notification_h notification, char **content)
-{
- char *content_dup = NULL;
-
- if (notification == NULL || content == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (notification->content != NULL)
- {
- content_dup = strdup(notification->content);
-
- if (content_dup == NULL)
- {
- LOGE("OUT_OF_MEMORY(0x%08x)", UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
- }
-
- *content = content_dup;
-
- return UI_NOTIFICATION_ERROR_NONE;
-}
-
-
-int ui_notification_set_service(ui_notification_h notification, service_h service)
-{
- int retcode;
- service_h service_dup = NULL;
-
- if (notification == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (service != NULL)
- {
- retcode = service_clone(&service_dup, service);
-
- if (retcode != SERVICE_ERROR_NONE)
- {
- if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
- {
- LOGE("OUT_OF_MEMORY(0x%08x)", UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
- else
- {
- LOGE("INVALID_PARAMETER(0x%08x) : invalid service handle", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
- }
- }
-
- if (notification->service != NULL)
- {
- service_destroy(notification->service);
- }
-
- notification->service = service_dup;
-
- return UI_NOTIFICATION_ERROR_NONE;
-}
-
-int ui_notification_get_service(ui_notification_h notification, service_h *service)
-{
- int retcode;
- service_h service_dup = NULL;
-
- if (notification == NULL || service == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (notification->service != NULL)
- {
- retcode = service_clone(&service_dup, notification->service);
-
- if (retcode != SERVICE_ERROR_NONE)
- {
- if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
- {
- LOGE("OUT_OF_MEMORY(0x%08x)", UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
- else
- {
- LOGE("INVALID_PARAMETER(0x%08x) : invalid service handle", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
- }
- }
-
- *service = service_dup;
-
- 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("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (path != NULL)
- {
- path_dup = strdup(path);
-
- if (path_dup == NULL)
- {
- LOGE("OUT_OF_MEMORY(0x%08x)", 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("INVALID_PARAMETER(0x%08x)", 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("OUT_OF_MEMORY(0x%08x)", 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("INVALID_PARAMETER(0x%08x)", 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("INVALID_PARAMETER(0x%08x)", 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;
-
- if (notification == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x) : invalid handle", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (notification->icon != NULL)
- {
- struct stat st;
-
- if (stat(notification->icon, &st) < 0)
- {
- LOGE("NO_SUCH_FILE(0x%08x) : invalid icon", UI_NOTIFICATION_ERROR_NO_SUCH_FILE);
- return UI_NOTIFICATION_ERROR_NO_SUCH_FILE;
- }
-
- notification_set_image(notification->raw_handle, NOTIFICATION_IMAGE_TYPE_ICON, notification->icon);
- }
-
- if (notification->time != NULL)
- {
- notification_set_time(notification->raw_handle, mktime(notification->time));
- }
-
- if (notification->title != NULL)
- {
- notification_set_text(notification->raw_handle, NOTIFICATION_TEXT_TYPE_TITLE, notification->title, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
- }
-
- if (notification->content != NULL)
- {
- notification_set_text(notification->raw_handle, NOTIFICATION_TEXT_TYPE_CONTENT, notification->content, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
- }
-
- if (notification->service != NULL && service_to_bundle(notification->service, &service_data) == SERVICE_ERROR_NONE)
- {
- notification_set_property(notification->raw_handle, 0);
- notification_set_execute_option(notification->raw_handle, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, service_data);
- }
- else
- {
- 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("NO_SUCH_FILE(0x%08x) : invalid sound file", 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;
-}
-
-int ui_notification_post(ui_notification_h notification)
-{
- int retcode;
-
- if (notification == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (notification->posted == true)
- {
- LOGE("INVALID_STATE(0x%08x) : the notification was already posted", UI_NOTIFICATION_ERROR_INVALID_STATE);
- return UI_NOTIFICATION_ERROR_INVALID_STATE;
- }
-
- if (notification->ongoing == true)
- {
- notification->raw_handle = notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
- }
- else
- {
- notification->raw_handle = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
- }
-
- if (notification->raw_handle == NULL)
- {
- LOGE("OUT_OF_MEMORY(0x%08x)", UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
-
- retcode = ui_notification_build_attributes(notification);
-
- if (retcode != UI_NOTIFICATION_ERROR_NONE)
- {
- return retcode;
- }
-
- retcode = ui_notification_error_handler(notification_insert(notification->raw_handle, NULL), __FUNCTION__, "failed to post a notification");
-
- if (retcode == UI_NOTIFICATION_ERROR_NONE)
- {
- notification->posted = true;
- }
-
- return retcode;
-}
-
-int ui_notification_update(ui_notification_h notification)
-{
- int retcode;
-
- if (notification == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (notification->posted == false)
- {
- LOGE("INVALID_STATE(0x%08x) : the notification was not posted", UI_NOTIFICATION_ERROR_INVALID_STATE);
- return UI_NOTIFICATION_ERROR_INVALID_STATE;
- }
-
- if (notification->removed == true)
- {
- LOGE("INVALID_STATE(0x%08x) : the notification was canceled or cleared", UI_NOTIFICATION_ERROR_INVALID_STATE);
- return UI_NOTIFICATION_ERROR_INVALID_STATE;
- }
-
- retcode = ui_notification_build_attributes(notification);
-
- if (retcode != UI_NOTIFICATION_ERROR_NONE)
- {
- return retcode;
- }
-
- retcode = ui_notification_error_handler(notification_update(notification->raw_handle), __FUNCTION__, "failed to post a notification");
-
- if (retcode == UI_NOTIFICATION_ERROR_INVALID_STATE)
- {
- notification->removed = true;
- }
-
- return retcode;
-}
-
-int ui_notification_update_progress(ui_notification_h notification, ui_notification_progress_type_e type, double value)
-{
- int retcode;
-
- if (notification == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (notification->raw_handle == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x) : invalid handle", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (notification->posted == false)
- {
- LOGE("INVALID_STATE(0x%08x) : the notification was not posted", UI_NOTIFICATION_ERROR_INVALID_STATE);
- return UI_NOTIFICATION_ERROR_INVALID_STATE;
- }
-
- if (notification->removed == true)
- {
- LOGE("INVALID_STATE(0x%08x) : the notification was canceled or cleared", UI_NOTIFICATION_ERROR_INVALID_STATE);
- return UI_NOTIFICATION_ERROR_INVALID_STATE;
- }
-
- if (value < 0)
- {
- LOGE("INVALID_PARAMETER(0x%08x) : the value must be greater than or equal to zero.", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- switch (type)
- {
- case UI_NOTIFICATION_PROGRESS_TYPE_SIZE:
- retcode = ui_notification_error_handler(
- 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),
- __FUNCTION__, "failed to update the progress");
- break;
-
- default:
- LOGE("INVALID_PARAMETER(0x%08x) : invalid progress type", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (retcode == UI_NOTIFICATION_ERROR_INVALID_STATE)
- {
- notification->removed = true;
- }
-
- return retcode;
-}
-
-int ui_notification_cancel(ui_notification_h notification)
-{
- int retcode;
-
- if (notification == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (notification->raw_handle == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x) : invalid handle", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (notification->posted == false)
- {
- LOGE("INVALID_STATE(0x%08x) : the notification was not posted", UI_NOTIFICATION_ERROR_INVALID_STATE);
- return UI_NOTIFICATION_ERROR_INVALID_STATE;
- }
-
- if (notification->removed == true)
- {
- LOGE("INVALID_STATE(0x%08x) : the notification was canceled or cleared", UI_NOTIFICATION_ERROR_INVALID_STATE);
- return UI_NOTIFICATION_ERROR_INVALID_STATE;
- }
-
- retcode = ui_notification_error_handler(notification_delete(notification->raw_handle), __FUNCTION__, "failed to cancel the notification");
-
- if (retcode == UI_NOTIFICATION_ERROR_NONE)
- {
- notification->removed = true;
- }
-
- return retcode;
-}
-
-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("INVALID_PARAMETER(0x%08x)", 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;
- char *handle_package = NULL;
- char cmdline[512] = {0,};
- char buf[64] = {0,};
-
- if (notification_get_pkgname(handle, &handle_package))
- {
- return false;
- }
-
- if (app_get_package(&package))
- {
- int ret = 0;
- int fd = -1;
- int pid = getpid();
-
- snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
-
- fd = open(buf, O_RDONLY);
- if (fd < 0) {
- return false;
- }
-
- ret = read(fd, cmdline, sizeof(cmdline) - 1);
- if (ret <= 0) {
- close(fd);
- return false;
- }
-
- cmdline[ret] = 0;
- close(fd);
-
- if (strlen(cmdline) == strlen(handle_package))
- {
- if (!strncmp(cmdline, handle_package, strlen(cmdline)))
- {
- return true;
- }
- }
- }
- else
- {
- if (strlen(package) == strlen(handle_package))
- {
- if (!strncmp(package, handle_package, strlen(package)))
- {
- return true;
- }
- }
- }
-
- return false;
-}
-
-int ui_notification_foreach_notification_posted(bool ongoing, ui_notification_cb callback, void *user_data)
-{
- notification_list_h raw_handle_list;
- notification_h raw_handle;
- notification_type_e notification_type = ongoing ? NOTIFICATION_TYPE_ONGOING : NOTIFICATION_TYPE_NOTI;
- ui_notification_h notification = NULL;
- bool iterate_next = true;
-
- if (callback == NULL)
- {
- LOGE("INVALID_PARAMETER(0x%08x)", UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
- }
-
- if (notification_get_grouping_list(notification_type, -1, &raw_handle_list))
- {
- LOGE("DB_FAILED(0x%08x) : failed to get a notification list", UI_NOTIFICATION_ERROR_DB_FAILED);
- return UI_NOTIFICATION_ERROR_DB_FAILED;
- }
-
- while (raw_handle_list != NULL)
- {
- raw_handle = notification_list_get_data(raw_handle_list);
-
- if (raw_handle != NULL && ui_notification_package_equal(raw_handle))
- {
- if (!ui_notification_construct(ongoing, raw_handle, &notification))
- {
- iterate_next = callback(notification, user_data);
-
- ui_notification_destroy(notification);
-
- if (iterate_next == false)
- {
- break;
- }
- }
- }
-
- raw_handle_list = notification_list_get_next(raw_handle_list);
- }
-
- notification_free_list(raw_handle_list);
-
- return UI_NOTIFICATION_ERROR_NONE;
-}
-