summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdebian/changelog17
-rwxr-xr-xinclude/app.h8
-rwxr-xr-xinclude/app_service.h13
-rwxr-xr-xinclude/app_service_private.h4
-rwxr-xr-xinclude/app_ui_notification.h135
-rwxr-xr-xsrc/alarm.c80
-rwxr-xr-xsrc/preference.c2
-rwxr-xr-xsrc/service.c67
-rwxr-xr-xsrc/ui_notification.c553
9 files changed, 608 insertions, 271 deletions
diff --git a/debian/changelog b/debian/changelog
index 9ebfa2c..f7f9fcd 100755
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,20 @@
+capi-appfw-application (0.1.0-15) unstable; urgency=low
+
+ * Fixed invalid parameter
+ * Git: api/application
+ * Tag: capi-appfw-application_0.1.0-15
+
+ -- Junghyuk Park <junghyuk.park@samsung.com> Mon, 30 Jan 2012 13:52:37 +0900
+
+capi-appfw-application (0.1.0-14) unstable; urgency=low
+
+ * Update UI-Notification API
+ * Git: api/application
+ * Tag: capi-appfw-application_0.1.0-14
+
+
+ -- Junghyuk Park <junghyuk.park@samsung.com> Thu, 26 Jan 2012 16:07:50 +0900
+
capi-appfw-application (0.1.0-13) unstable; urgency=low
* Update alarm API Doc
diff --git a/include/app.h b/include/app.h
index 565ac7f..386f9b1 100755
--- a/include/app.h
+++ b/include/app.h
@@ -330,9 +330,9 @@ int app_get_version(char **version);
* and a null character is appended in @a buffer after the path stored.
*
* @param [in] resource The resource's path relative to the resource directory of the application package (e.g. edje/app.edj or images/background.png)
- * @param [in] buffer The buffer where the absolute path to the resource is stored.
+ * @param [in] buffer The pre-allocated buffer where the absolute path to the resource is stored.
* @param [in] size The size of @a buffer in bytes
- * @return @a buffer on success, otherwise null.
+ * @return @a buffer on success, otherwise NULL.
*/
char* app_get_resource(const char *resource, char *buffer, int size);
@@ -345,9 +345,9 @@ char* app_get_resource(const char *resource, char *buffer, int size);
* @remarks This function stores the absolute path into the @a buffer at most one less than @a size bytes
* and a null character is appended in @a buffer after the path stored.
*
- * @param [in] buffer The buffer where the absolute path to the application data directory
+ * @param [in] buffer The pre-allocated buffer where the absolute path to the application data directory
* @param [in] size The size of @a buffer in bytes
- * @return @a buffer on success, otherwise null.
+ * @return @a buffer on success, otherwise NULL.
*/
char* app_get_data_directory(char *buffer, int size);
diff --git a/include/app_service.h b/include/app_service.h
index 6e853ad..851d03b 100755
--- a/include/app_service.h
+++ b/include/app_service.h
@@ -240,7 +240,8 @@ int service_destroy(service_h service);
* If the operation is not specified, #SERVICE_OPERATION_DEFAULT is used for the launch request.
* If the operation is #SERVICE_OPERATION_DEFAULT, the package information is mandatory to explicitly launch the application
* @param [in] service The service handle
- * @param [in] operation The operation to be performed
+ * @param [in] operation The operation to be performed \n
+ * If the @a operation 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
@@ -278,7 +279,8 @@ int service_get_operation(service_h service, char **operation);
* @brief Sets the URI of the data.
*
* @param [in] service The service handle
- * @param [in] uri The URI of the data this service is operating on
+ * @param [in] uri The URI of the data this service is operating on \n
+ * If the @a uri 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
@@ -306,7 +308,8 @@ int service_get_uri(service_h service, char **uri);
* @brief Sets the explicit MIME type of the data
*
* @param [in] service The service handle
- * @param [in] mime the explicit MIME type of the data this service is operating on
+ * @param [in] mime the explicit MIME type of the data this service is operating on \n
+ * If the @a mime 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
@@ -334,7 +337,8 @@ int service_get_mime(service_h service, char **uri);
* @brief Sets the package name of the application to explicitly launch
*
* @param [in] service The service handle
- * @param [in] package The package name of the application to explicitly launch
+ * @param [in] package The package name of the application to explicitly launch \n
+ * If the @a package 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
@@ -471,7 +475,6 @@ int service_get_extra_data_array(service_h service, const char *key, char ***val
* @return 0 on success, otherwise a negative error value.
* @retval #SERVICE_ERROR_NONE Successful
* @retval #SERVICE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SERVICE_ERROR_KEY_NOT_FOUND Specified key not found
* @see service_add_extra_data()
* @see service_add_extra_data_array()
* @see service_remove_extra_data()
diff --git a/include/app_service_private.h b/include/app_service_private.h
index 172c823..6f71533 100755
--- a/include/app_service_private.h
+++ b/include/app_service_private.h
@@ -24,10 +24,12 @@
extern "C" {
#endif
-int service_to_bundle(service_h service, bundle **data);
+int service_create_request(bundle *data, service_h *service);
int service_create_event(bundle *data, service_h *service);
+int service_to_bundle(service_h service, bundle **data);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/app_ui_notification.h b/include/app_ui_notification.h
index f8edbe9..88240e5 100755
--- a/include/app_ui_notification.h
+++ b/include/app_ui_notification.h
@@ -46,7 +46,7 @@ typedef enum {
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_ALREADY_POSTED = TIZEN_ERROR_ALREADY_IN_PROGRESS, /**< Notification is already posted */
+ UI_NOTIFICATION_ERROR_INVALID_STATE = TIZEN_ERROR_APPLICATION_CLASS | 0x32, /**< Invalid state */
} ui_notification_error_e;
/**
@@ -58,6 +58,18 @@ typedef enum {
} 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.
@@ -81,16 +93,27 @@ int ui_notification_create(bool ongoing, ui_notification_h *notification);
int ui_notification_destroy(ui_notification_h notification);
/**
+ * @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 @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 (see ui_notification_post()).
+ * @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
+ * @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
- * @retval #UI_NOTIFICATION_ERROR_ALREADY_POSTED Notification is already posted
* @see ui_notification_get_icon()
*/
int ui_notification_set_icon(ui_notification_h notification, const char *path);
@@ -110,14 +133,14 @@ 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 (see ui_notification_post()).
+ * @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
+ * @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
- * @retval #UI_NOTIFICATION_ERROR_ALREADY_POSTED Notification is already posted
* @see ui_notification_get_time()
*/
int ui_notification_set_time(ui_notification_h notification, struct tm *time);
@@ -137,14 +160,14 @@ 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 (see ui_notification_post()).
+ * 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
+ * @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
- * @retval #UI_NOTIFICATION_ERROR_ALREADY_POSTED Notification is already posted
* @see ui_notification_get_title()
*/
int ui_notification_set_title(ui_notification_h notification, const char *title);
@@ -164,14 +187,14 @@ 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 (see ui_notification_post()).
+ * @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
+ * @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
- * @retval #UI_NOTIFICATION_ERROR_ALREADY_POSTED Notification is already posted
* @see ui_notification_get_content()
*/
int ui_notification_set_content(ui_notification_h notification, const char *content);
@@ -194,14 +217,14 @@ int ui_notification_get_content(ui_notification_h notification, char **content);
* @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 (see ui_notification_post()).
+ * 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
+ * @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
- * @retval #UI_NOTIFICATION_ERROR_ALREADY_POSTED Notification is already posted
* @see ui_notification_get_service()
* @see service_create()
*/
@@ -222,27 +245,32 @@ int ui_notification_get_service(ui_notification_h notification, service_h *servi
/**
* @brief Posts the notification to display in the notification tray and the status bar
- * @remarks You cannot alter the icon, time, title, content, and service after posting the notification.
* @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_ALREADY_POSTED Notification is already posted
- * @see ui_notification_remove()
- * @see ui_notification_remove_all()
+ * @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
+ * @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()
*/
@@ -251,32 +279,85 @@ 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
+ * @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 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_cancel()
+ * @see ui_notification_update_progress()
*/
-int ui_notification_cancel_all(void);
+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
- * 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.
+ * 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);
+
+
+/**
* @}
*/
diff --git a/src/alarm.c b/src/alarm.c
index 960e949..ea2b4d0 100755
--- a/src/alarm.c
+++ b/src/alarm.c
@@ -113,38 +113,6 @@ static int _remove_alarm_cb(alarm_id_t alarm_id, void* user_param)
return alarmmgr_remove_alarm(alarm_id);
}
-static int alarm_init()
-{
- static bool is_alarm_init = false;
-
- if (is_alarm_init == false)
- {
- char *package = NULL;
- int errnum;
-
- if (app_get_package(&package) != 0)
- {
- return -1;
- }
-
- errnum = alarmmgr_init(package);
-
- if (package != NULL)
- {
- free(package);
- }
-
- if (errnum != ALARMMGR_RESULT_SUCCESS)
- {
- return -1;
- }
-
- is_alarm_init = true;
- }
-
- return 0;
-}
-
int alarm_get_scheduled_date(int alarm_id, struct tm* date)
{
alarm_error_t result;
@@ -157,12 +125,6 @@ int alarm_get_scheduled_date(int alarm_id, struct tm* date)
return ALARM_ERROR_INVALID_PARAMETER;
}
- if (alarm_init() != 0)
- {
- LOGE("[%s] CONNECTION_FAIL(0x%08x)", __FUNCTION__, ALARM_ERROR_CONNECTION_FAIL);
- return ALARM_ERROR_CONNECTION_FAIL;
- }
-
entry = alarmmgr_create_alarm();
result = alarmmgr_get_info(alarm_id, entry);
@@ -219,12 +181,6 @@ int alarm_get_scheduled_period(int alarm_id, int* period)
return ALARM_ERROR_INVALID_PARAMETER;
}
- if (alarm_init() != 0)
- {
- LOGE("[%s] CONNECTION_FAIL(0x%08x)", __FUNCTION__, ALARM_ERROR_CONNECTION_FAIL);
- return ALARM_ERROR_CONNECTION_FAIL;
- }
-
entry = alarmmgr_create_alarm();
result = alarmmgr_get_info(alarm_id, entry);
@@ -280,12 +236,6 @@ int alarm_schedule_after_delay(service_h service, int delay, int period, int *al
return ALARM_ERROR_INVALID_PARAMETER;
}
- if (alarm_init() != 0)
- {
- LOGE("[%s] CONNECTION_FAIL(0x%08x)", __FUNCTION__, ALARM_ERROR_CONNECTION_FAIL);
- return ALARM_ERROR_CONNECTION_FAIL;
- }
-
result = alarmmgr_add_alarm_appsvc(ALARM_TYPE_DEFAULT, delay, period, bundle_data, alarm_id);
return convert_error_code_to_alarm(__FUNCTION__, result);
@@ -310,12 +260,6 @@ int alarm_schedule_at_date(service_h service, struct tm *date, int period_in_sec
return ALARM_ERROR_INVALID_PARAMETER;
}
- if (alarm_init() != 0)
- {
- LOGE("[%s] CONNECTION_FAIL(0x%08x)", __FUNCTION__, ALARM_ERROR_CONNECTION_FAIL);
- return ALARM_ERROR_CONNECTION_FAIL;
- }
-
alarm_info = alarmmgr_create_alarm();
internal_time.year = date->tm_year + 1900;
@@ -369,12 +313,6 @@ int alarm_cancel(int alarm_id)
{
int result;
- if (alarm_init() != 0)
- {
- LOGE("[%s] CONNECTION_FAIL(0x%08x)", __FUNCTION__, ALARM_ERROR_CONNECTION_FAIL);
- return ALARM_ERROR_CONNECTION_FAIL;
- }
-
result = alarmmgr_remove_alarm(alarm_id);
return convert_error_code_to_alarm(__FUNCTION__, result);
@@ -384,12 +322,6 @@ int alarm_cancel_all()
{
int result;
- if (alarm_init() != 0)
- {
- LOGE("[%s] CONNECTION_FAIL(0x%08x)", __FUNCTION__, ALARM_ERROR_CONNECTION_FAIL);
- return ALARM_ERROR_CONNECTION_FAIL;
- }
-
result = alarmmgr_enum_alarm_ids( _remove_alarm_cb, NULL);
return convert_error_code_to_alarm(__FUNCTION__, result);
@@ -453,12 +385,6 @@ int alarm_schedule_with_recurrence_week_flag(service_h service, struct tm *date,
return ALARM_ERROR_INVALID_PARAMETER;
}
- if (alarm_init() != 0)
- {
- LOGE("[%s] CONNECTION_FAIL(0x%08x)", __FUNCTION__, ALARM_ERROR_CONNECTION_FAIL);
- return ALARM_ERROR_CONNECTION_FAIL;
- }
-
alarm_info = alarmmgr_create_alarm();
internal_time.year = date->tm_year + 1900;
@@ -511,12 +437,6 @@ int alarm_get_scheduled_recurrence_week_flag(int alarm_id, int *week_flag)
return ALARM_ERROR_INVALID_PARAMETER;
}
- if (alarm_init() != 0)
- {
- LOGE("[%s] CONNECTION_FAIL(0x%08x)", __FUNCTION__, ALARM_ERROR_CONNECTION_FAIL);
- return ALARM_ERROR_CONNECTION_FAIL;
- }
-
entry = alarmmgr_create_alarm();
result = alarmmgr_get_info(alarm_id, entry);
diff --git a/src/preference.c b/src/preference.c
index 73c7871..4abbd82 100755
--- a/src/preference.c
+++ b/src/preference.c
@@ -115,7 +115,7 @@ static int _write_data(const char *key, const char *type, const char *data)
}
else
{
- buf = sqlite3_mprintf("INSERT INTO %s (%s, %s, %s) values ('%s', '%s', '%s');",
+ 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);
}
diff --git a/src/service.c b/src/service.c
index 3220161..e5e395a 100755
--- a/src/service.c
+++ b/src/service.c
@@ -27,6 +27,7 @@
#include <dlog.h>
#include <app_service.h>
+#include <app_service_private.h>
#ifdef LOG_TAG
#undef LOG_TAG
@@ -44,7 +45,7 @@
#define BUNDLE_KEY_PACKAGE "__APP_SVC_PKG_NAME__"
typedef enum {
- SERVICE_TYPE_USER,
+ SERVICE_TYPE_REQUEST,
SERVICE_TYPE_EVENT,
SERVICE_TYPE_REPLY,
} service_type_e;
@@ -61,8 +62,6 @@ typedef struct service_request_context_s {
void *user_data;
} *service_request_context_h;
-static int service_create_request(service_h *service);
-
static int service_create_reply(bundle *data, struct service_s **service);
static int service_validate_extra_data(const char *data)
@@ -167,10 +166,10 @@ static void service_request_result_broker(bundle *appsvc_bundle, int appsvc_requ
int service_create(service_h *service)
{
- return service_create_request(service);
+ return service_create_request(NULL, service);
}
-static int service_create_request(service_h *service)
+int service_create_request(bundle *data, service_h *service)
{
struct service_s *service_request;
@@ -188,9 +187,16 @@ static int service_create_request(service_h *service)
return SERVICE_ERROR_OUT_OF_MEMORY;
}
- service_request->type = SERVICE_TYPE_USER;
+ service_request->type = SERVICE_TYPE_REQUEST;
- service_request->data = bundle_create();
+ if (data != NULL)
+ {
+ service_request->data = bundle_dup(data);
+ }
+ else
+ {
+ service_request->data = bundle_create();
+ }
if (service_request->data == NULL)
{
@@ -656,7 +662,10 @@ int service_send_launch_request(service_h service, service_reply_cb callback, vo
static bool service_copy_reply_data_cb(service_h service, const char *key, void *user_data)
{
bundle *reply_data;
+ bool array = false;
char *value;
+ const char **value_array;
+ int value_array_length;
if (user_data == NULL)
{
@@ -666,9 +675,19 @@ static bool service_copy_reply_data_cb(service_h service, const char *key, void
reply_data = user_data;
- service_get_extra_data(service, key, &value);
-
- appsvc_add_data(reply_data, key, value);
+ if (!service_is_extra_data_array(service, key, &array))
+ {
+ if (array == true)
+ {
+ service_get_extra_data_array(service, key, (char***)&value_array, &value_array_length);
+ appsvc_add_data_array(reply_data, key, value_array, value_array_length);
+ }
+ else
+ {
+ service_get_extra_data(service, key, &value);
+ appsvc_add_data(reply_data, key, value);
+ }
+ }
return true;
}
@@ -960,8 +979,6 @@ int service_get_extra_data_array(service_h service, const char *key, char ***val
int service_is_extra_data_array(service_h service, const char *key, bool *array)
{
- int retval;
-
if (service_valiate_service(service))
{
LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid handle", __FUNCTION__, SERVICE_ERROR_INVALID_PARAMETER);
@@ -980,26 +997,20 @@ int service_is_extra_data_array(service_h service, const char *key, bool *array)
return SERVICE_ERROR_INVALID_PARAMETER;
}
- if (service_validate_internal_key(key))
+ if (!service_validate_internal_key(key))
{
- LOGE("[%s] KEY_REJECTED(0x%08x) : key(%s) rejected", __FUNCTION__, SERVICE_ERROR_KEY_REJECTED, key);
- return SERVICE_ERROR_KEY_REJECTED;
- }
-
- retval = appsvc_data_is_array(service->data, key);
-
- if (retval == 0)
- {
- *array = false;
- }
- else if (retval == 1)
- {
- *array = true;
+ if (!appsvc_data_is_array(service->data, key))
+ {
+ *array = false;
+ }
+ else
+ {
+ *array = true;
+ }
}
else
{
- LOGE("[%s] KEY_NOT_FOUND(0x%08x) : key(%s)", __FUNCTION__, SERVICE_ERROR_KEY_NOT_FOUND, key);
- return SERVICE_ERROR_KEY_NOT_FOUND;
+ *array = false;
}
return SERVICE_ERROR_NONE;
diff --git a/src/ui_notification.c b/src/ui_notification.c
index 0de048a..0129eb8 100755
--- a/src/ui_notification.c
+++ b/src/ui_notification.c
@@ -24,9 +24,8 @@
#include <dlog.h>
#include <notification.h>
-#include <app_service.h>
+#include <app.h>
#include <app_service_private.h>
-#include <app_ui_notification.h>
#ifdef LOG_TAG
#undef LOG_TAG
@@ -35,9 +34,10 @@
#define LOG_TAG "TIZEN_N_UI_NOTIFICATION"
struct ui_notification_s {
- notification_h core;
+ notification_h raw_handle;
bool ongoing;
bool posted;
+ bool removed;
char *icon;
struct tm *time;
char *title;
@@ -72,8 +72,9 @@ static int ui_notification_error_handler(int error, const char *func, const char
break;
case NOTIFICATION_ERROR_ALREADY_EXIST_ID:
- retcode = UI_NOTIFICATION_ERROR_ALREADY_POSTED;
- error_msg = "ALREADY_POSTED";
+ case NOTIFICATION_ERROR_NOT_EXIST_ID:
+ retcode = UI_NOTIFICATION_ERROR_INVALID_STATE;
+ error_msg = "INVALID_STATE";
break;
default:
@@ -100,16 +101,18 @@ int ui_notification_create(bool ongoing, ui_notification_h *notification)
return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
}
- notification_out = (ui_notification_h)malloc(sizeof(struct ui_notification_s));
+ notification_out = (ui_notification_h)calloc(1, sizeof(struct ui_notification_s));
if (notification_out == NULL)
{
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;
+ notification_out->removed = false;
notification_out->icon = NULL;
notification_out->time = NULL;
notification_out->title = NULL;
@@ -121,6 +124,88 @@ int ui_notification_create(bool ongoing, ui_notification_h *notification)
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;
+
+ if (notification == NULL)
+ {
+ LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid output param", __FUNCTION__, 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("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, 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)
+ {
+ 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))
+ {
+ notification_out->icon = 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("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, 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))
+ {
+ notification_out->title = title;
+ }
+
+ if (! notification_get_text(raw_handle, NOTIFICATION_TEXT_TYPE_CONTENT, &content))
+ {
+ notification_out->content = content;
+ }
+
+ 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)
@@ -129,8 +214,8 @@ int ui_notification_destroy(ui_notification_h notification)
return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
}
- if (notification->core)
- notification_free(notification->core);
+ if (notification->raw_handle)
+ notification_free(notification->raw_handle);
if (notification->icon)
free(notification->icon);
@@ -152,29 +237,101 @@ int ui_notification_destroy(ui_notification_h notification)
return UI_NOTIFICATION_ERROR_NONE;
}
-
-int ui_notification_set_icon(ui_notification_h notification, const char *path)
+int ui_notification_clone(ui_notification_h *clone, ui_notification_h notification)
{
- char *path_dup;
+ ui_notification_h notification_out;
+ int retcode;
- if (notification == NULL || path == NULL)
+ if (clone == NULL || notification == NULL)
{
LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
}
- if (notification->posted == true)
+ notification_out = (ui_notification_h)calloc(1, sizeof(struct ui_notification_s));
+
+ if (notification->raw_handle != NULL)
{
- LOGE("[%s] ALREADY_POSTED(0x%08x) : unable to change the notification", __FUNCTION__, UI_NOTIFICATION_ERROR_ALREADY_POSTED);
- return UI_NOTIFICATION_ERROR_ALREADY_POSTED;
+ retcode = notification_clone(notification->raw_handle, &(notification_out->raw_handle));
+
+ if (retcode)
+ {
+ return ui_notification_error_handler(retcode, __FUNCTION__, "failed to clone the handle");
+ }
}
- path_dup = strdup(path);
+ 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 (path_dup == NULL)
+ if (notification->time)
{
- LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ 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->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("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, 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("[%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->icon != NULL)
@@ -215,30 +372,27 @@ int ui_notification_get_icon(ui_notification_h notification, char **path)
int ui_notification_set_time(ui_notification_h notification, struct tm *time)
{
- struct tm *time_dup;
+ struct tm *time_dup = NULL;
- if (notification == NULL || time == NULL)
+ if (notification == NULL)
{
LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
}
- if (notification->posted == true)
+ if (time != NULL)
{
- LOGE("[%s] ALREADY_POSTED(0x%08x) : unable to change the notification", __FUNCTION__, UI_NOTIFICATION_ERROR_ALREADY_POSTED);
- return UI_NOTIFICATION_ERROR_ALREADY_POSTED;
- }
+ time_dup = malloc(sizeof(struct tm));
- time_dup = malloc(sizeof(struct tm));
+ if (time_dup == NULL)
+ {
+ LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
+ return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ }
- if (time_dup == NULL)
- {
- LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ memcpy(time_dup, time, sizeof(struct tm));
}
- memcpy(time_dup, time, sizeof(struct tm));
-
if (notification->time != NULL)
{
free(notification->time);
@@ -279,26 +433,23 @@ int ui_notification_get_time(ui_notification_h notification, struct tm **time)
int ui_notification_set_title(ui_notification_h notification, const char *title)
{
- char *title_dup;
+ char *title_dup = NULL;
- if (notification == NULL || title == NULL)
+ if (notification == NULL)
{
LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
}
- if (notification->posted == true)
+ if (title != NULL)
{
- LOGE("[%s] ALREADY_POSTED(0x%08x) : unable to change the notification", __FUNCTION__, UI_NOTIFICATION_ERROR_ALREADY_POSTED);
- return UI_NOTIFICATION_ERROR_ALREADY_POSTED;
- }
-
- title_dup = strdup(title);
+ title_dup = strdup(title);
- if (title_dup == NULL)
- {
- LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ if (title_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->title != NULL)
@@ -340,26 +491,23 @@ int ui_notification_get_title(ui_notification_h notification, char **title)
int ui_notification_set_content(ui_notification_h notification, const char *content)
{
- char *content_dup;
+ char *content_dup = NULL;
- if (notification == NULL || content == NULL)
+ if (notification == NULL)
{
LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
}
- if (notification->posted == true)
+ if (content != NULL)
{
- LOGE("[%s] ALREADY_POSTED(0x%08x) : unable to change the notification", __FUNCTION__, UI_NOTIFICATION_ERROR_ALREADY_POSTED);
- return UI_NOTIFICATION_ERROR_ALREADY_POSTED;
- }
+ content_dup = strdup(content);
- content_dup = strdup(content);
-
- if (content_dup == NULL)
- {
- LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ if (content_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->content != NULL)
@@ -402,33 +550,30 @@ int ui_notification_get_content(ui_notification_h notification, char **content)
int ui_notification_set_service(ui_notification_h notification, service_h service)
{
int retcode;
- service_h service_dup;
+ service_h service_dup = NULL;
- if (notification == NULL || service == NULL)
+ if (notification == NULL)
{
LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
}
- if (notification->posted == true)
+ if (service != NULL)
{
- LOGE("[%s] ALREADY_POSTED(0x%08x) : unable to change the notification", __FUNCTION__, UI_NOTIFICATION_ERROR_ALREADY_POSTED);
- return UI_NOTIFICATION_ERROR_ALREADY_POSTED;
- }
+ retcode = service_clone(&service_dup, service);
- retcode = service_clone(&service_dup, service);
-
- if (retcode != SERVICE_ERROR_NONE)
- {
- if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
- {
- LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
- return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
- }
- else
+ if (retcode != SERVICE_ERROR_NONE)
{
- LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid service handle", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
- return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
+ if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
+ {
+ LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
+ return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ }
+ else
+ {
+ LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid service handle", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
+ return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
+ }
}
}
@@ -477,12 +622,60 @@ int ui_notification_get_service(ui_notification_h notification, service_h *servi
return UI_NOTIFICATION_ERROR_NONE;
}
+static int ui_notification_build_attributes(ui_notification_h notification)
+{
+ bundle *service_data;
+
+ if (notification == NULL)
+ {
+ LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid handle", __FUNCTION__, 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("[%s] NO_SUCH_FILE(0x%08x) : invalid icon", __FUNCTION__, 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);
+ }
+
+ return UI_NOTIFICATION_ERROR_NONE;
+}
int ui_notification_post(ui_notification_h notification)
{
int retcode;
- notification_h core;
- bundle *service_data;
if (notification == NULL)
{
@@ -492,82 +685,83 @@ int ui_notification_post(ui_notification_h notification)
if (notification->posted == true)
{
- LOGE("[%s] ALREADY_POSTED(0x%08x) : unable to change the notification", __FUNCTION__, UI_NOTIFICATION_ERROR_ALREADY_POSTED);
- return UI_NOTIFICATION_ERROR_ALREADY_POSTED;
+ LOGE("[%s] INVALID_STATE(0x%08x) : the notification was already posted", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_STATE);
+ return UI_NOTIFICATION_ERROR_INVALID_STATE;
}
- // STEP 1: core handle
+ // STEP 1: notification handle
if (notification->ongoing == true)
{
- core = notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
+ notification->raw_handle = notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
}
else
{
- core = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
+ notification->raw_handle = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
}
- if (core == NULL)
+ if (notification->raw_handle == NULL)
{
LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
}
- notification->core = core;
+ retcode = ui_notification_build_attributes(notification);
- // STEP 2: icon
- if (notification->icon != NULL)
+ if (retcode != UI_NOTIFICATION_ERROR_NONE)
{
- 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);
- return UI_NOTIFICATION_ERROR_NO_SUCH_FILE;
- }
-
- notification_set_image(core, NOTIFICATION_IMAGE_TYPE_ICON, notification->icon);
+ return retcode;
}
- // STEP 3: time
- if (notification->time != NULL)
+ retcode = ui_notification_error_handler(notification_insert(notification->raw_handle, NULL), __FUNCTION__, "failed to post a notification");
+
+ if (retcode == UI_NOTIFICATION_ERROR_NONE)
{
- notification_set_time(core, mktime(notification->time));
+ notification->posted = true;
}
- // STEP 4: title
- if (notification->title != NULL)
+ return retcode;
+}
+
+int ui_notification_update(ui_notification_h notification)
+{
+ int retcode;
+
+ if (notification == NULL)
{
- notification_set_text(core, NOTIFICATION_TEXT_TYPE_TITLE, notification->title, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+ LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
+ return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
}
- // STEP 5: content
- if (notification->content != NULL)
+ if (notification->posted == false)
{
- notification_set_text(core, NOTIFICATION_TEXT_TYPE_CONTENT, notification->content, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+ LOGE("[%s] INVALID_STATE(0x%08x) : the notification was not posted", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_STATE);
+ return UI_NOTIFICATION_ERROR_INVALID_STATE;
}
- // STEP 6: service
- if (notification->service != NULL && service_to_bundle(notification->service, &service_data) == SERVICE_ERROR_NONE)
+ if (notification->removed == true)
{
- notification_set_execute_option(core, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, service_data);
+ LOGE("[%s] INVALID_STATE(0x%08x) : the notification was canceled or cleared", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_STATE);
+ return UI_NOTIFICATION_ERROR_INVALID_STATE;
}
- else
+
+ retcode = ui_notification_build_attributes(notification);
+
+ if (retcode != UI_NOTIFICATION_ERROR_NONE)
{
- notification_set_property(core, NOTIFICATION_PROP_DISABLE_APP_LAUNCH);
+ return retcode;
}
- // STEP 7: insert
- retcode = ui_notification_error_handler(notification_insert(core, NULL), __FUNCTION__, "failed to post a notification");
+ retcode = ui_notification_error_handler(notification_update(notification->raw_handle), __FUNCTION__, "failed to post a notification");
- if (retcode == UI_NOTIFICATION_ERROR_NONE)
+ if (retcode == UI_NOTIFICATION_ERROR_INVALID_STATE)
{
- notification->posted = true;
+ notification->removed = true;
}
return retcode;
}
-int ui_notification_update_progress(ui_notification_h notification, ui_notification_progress_type_e type, double value)
+int ui_notification_update_progress(ui_notification_h notification, ui_notification_progress_type_e type, double value)
{
int retcode;
@@ -577,23 +771,41 @@ int ui_notification_update_progress(ui_notification_h notification, ui_notificat
return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
}
- if (notification->core == NULL || notification->posted == false)
+ if (notification->raw_handle == NULL)
{
LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid handle", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
}
+ if (notification->posted == false)
+ {
+ LOGE("[%s] INVALID_STATE(0x%08x) : the notification was not posted", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_STATE);
+ return UI_NOTIFICATION_ERROR_INVALID_STATE;
+ }
+
+ if (notification->removed == true)
+ {
+ LOGE("[%s] INVALID_STATE(0x%08x) : the notification was canceled or cleared", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_STATE);
+ return UI_NOTIFICATION_ERROR_INVALID_STATE;
+ }
+
+ if (value < 0)
+ {
+ LOGE("[%s] INVALID_PARAMETER(0x%08x) : the value must be greater than or equal to zero.", __FUNCTION__, 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->core, NOTIFICATION_PRIV_ID_NONE, value),
+ 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->core, NOTIFICATION_PRIV_ID_NONE, value),
+ notification_update_progress(notification->raw_handle, NOTIFICATION_PRIV_ID_NONE, value),
__FUNCTION__, "failed to update the progress");
break;
@@ -602,6 +814,11 @@ int ui_notification_update_progress(ui_notification_h notification, ui_notificat
return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
}
+ if (retcode == UI_NOTIFICATION_ERROR_INVALID_STATE)
+ {
+ notification->removed = true;
+ }
+
return retcode;
}
@@ -615,23 +832,109 @@ int ui_notification_cancel(ui_notification_h notification)
return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
}
- if (notification->core == NULL || notification->posted == false)
+ if (notification->raw_handle == NULL)
{
LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid handle", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
}
- retcode = ui_notification_error_handler(
- notification_delete(notification->core),
- __FUNCTION__, "failed to cancel the notification");
+ if (notification->posted == false)
+ {
+ LOGE("[%s] INVALID_STATE(0x%08x) : the notification was not posted", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_STATE);
+ return UI_NOTIFICATION_ERROR_INVALID_STATE;
+ }
+
+ if (notification->removed == true)
+ {
+ LOGE("[%s] INVALID_STATE(0x%08x) : the notification was canceled or cleared", __FUNCTION__, 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;
}
-int ui_notification_cancel_all(void)
+void ui_notification_cancel_all(void)
+{
+ notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NONE);
+}
+
+static bool ui_notification_package_equal(notification_h handle)
{
- return ui_notification_error_handler(
- notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NONE),
- __FUNCTION__, "failed to cancel the notification");
+ char *package = NULL;
+ char *handle_package = NULL;
+
+ if (app_get_package(&package))
+ {
+ return false;
+ }
+
+ if (notification_get_pkgname(handle, &handle_package))
+ {
+ return false;
+ }
+
+ 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("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
+ return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (notification_get_grouping_list(notification_type, -1, &raw_handle_list))
+ {
+ LOGE("[%s] DB_FAILED(0x%08x) : failed to get a notification list", __FUNCTION__, 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;
}