+libnotification (0.1.1-9) unstable; urgency=low
+
+ * Add content update API
+ * Git: slp/pkgs/n/notification
+ * Tag: libnotification_0.1.1-9
+
+ -- Mi-Ju Lee <miju52.lee@samsung.com> Wed, 25 Jan 2012 21:32:38 +0900
+
+libnotification (0.1.1-8) unstable; urgency=low
+
+ * Remove deprecated API
+ * Git: slp/pkgs/n/notification
+ * Tag: libnotification_0.1.1-8
+
+ -- Mi-Ju Lee <miju52.lee@samsung.com> Thu, 12 Jan 2012 16:32:56 +0900
+
+libnotification (0.1.1-7) unstable; urgency=low
+
+ * Deprecate some of the unused API
+ * Git: slp/pkgs/n/notification
+ * Tag: libnotification_0.1.1-7
+
+ -- Mi-Ju Lee <miju52.lee@samsung.com> Wed, 04 Jan 2012 18:54:12 +0900
+
+libnotification (0.1.1-6) unstable; urgency=low
+
+ * Add Error type for update API
+ * Git: slp/pkgs/n/notification
+ * Tag: libnotification_0.1.1-6
+
+ -- Mi-Ju Lee <miju52.lee@samsung.com> Wed, 04 Jan 2012 15:47:28 +0900
+
+libnotification (0.1.1-5) unstable; urgency=low
+
+ * Add notification update function
+ * Git: slp/pkgs/n/notification
+ * Tag: libnotification_0.1.1-5
+
+ -- Mi-Ju Lee <miju52.lee@samsung.com> Mon, 26 Dec 2011 17:54:37 +0900
+
libnotification (0.1.1-4) unstable; urgency=low
* Update pkgname to org.tizen
* @see notification_set_text()
*
*/
-notification_error_e notification_set_group_title(const char *pkgname,
- int group_id,
- const char *title,
- const char *loc_title,
- notification_count_display_type_e
- count_display);
-
-/**
- * @brief This function will be deprecated.
- * @see notification_get_text()
- *
- */
-notification_error_e notification_get_group_title(const char *pkgname,
- int group_id,
- char **title,
- char **loc_title,
- notification_count_display_type_e *count_display);
-
-/**
- * @brief This function will be deprecated.
- * @see notification_set_text()
- *
- */
notification_error_e notification_set_content(notification_h noti,
const char *content,
const char *loc_content);
char **loc_content);
/**
- * @brief This function will be deprecated.
- * @see notification_set_text()
- *
- */
-notification_error_e notification_set_default_content(notification_h noti,
- const char *content,
- const char *loc_content);
-
-/**
- * @brief This function will be deprecated.
- * @see notification_get_text()
- *
- */
-notification_error_e notification_get_default_content(notification_h noti,
- char **content,
- char **loc_content);
-
-/**
- * @brief This function will be deprecated.
- * @see notification_set_text()
- *
- */
-notification_error_e notification_set_group_content(const char *pkgname,
- int group_id,
- const char *content,
- const char *loc_content,
- notification_count_display_type_e count_display);
-
-/**
- * @brief This function will be deprecated.
- * @see notification_get_text()
- *
- */
-notification_error_e notification_get_group_content(const char *pkgname,
- int group_id,
- char **content,
- char **loc_content,
- notification_count_display_type_e *count_display);
-
-/**
* @brief This function set text.
* @details Set title, content string. If text is formated data(only support %d, %f, %s), type - value pair should be set.
* If %d, type NOTIFICATION_VARIABLE_TYPE_INT and value is integer value.
notification_error_e notification_get_args(notification_h noti, bundle ** args, bundle ** group_args); /* Do not use this */
/**
- * @brief This function will be deprecated.
- * @see notification_set_execute_option()
- *
- */
-notification_error_e notification_set_service_data(notification_h noti,
- bundle *service_data,
- bundle *group_service_data);
-
-/**
- * @brief This function will be deprecated.
- * @see notification_get_execute_option()
- *
- */
-notification_error_e notification_get_service_data(notification_h noti,
- bundle **service_data,
- bundle **group_service_data);
-
-/**
* @brief This function set execute option.
* @details When notification data selected in display application, application launched by appsvc_run_service with service_handle.
* @remarks
* @pre
* @post
* @see
+ * @par Sample code:
+ * @code
+#include <notification.h>
+...
+{
+ notification_h noti = NULL;
+ notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+ bundle *b = NULL;
+
+ ...
+
+ b = bundle_create();
+ appsvc_set_operation(b, APPSVC_OPERATION_VIEW);
+ appsvc_set_uri(b,"http://www.samsung.com");
+
+ noti_err = notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, b);
+ if(noti_err != NOTIFICATION_ERROR_NONE) {
+ notification_free(noti);
+ return;
+ }
+
+ bundle_free(b);
+}
+ * @endcode
*/
notification_error_e notification_set_execute_option(notification_h noti,
notification_execute_type_e type,
char **pkgname);
/**
- * @brief This function will be deprecated.
- * @see notification_set_badge()
- *
- */
-notification_error_e notification_set_unread_count(const char *pkgname,
- int group_id,
- int unread_count);
-
-/**
- * @brief This function will be deprecated.
- * @see notification_get_badge()
- *
- */
-notification_error_e notification_get_unread_count(const char *pkgname,
- int group_id,
- int *unread_count);
-
-/**
* @brief This function set application badge count.
* @details
* @remarks
int *priv_id);
/**
- * @brief This function update notification data. Not fully implemented yet.
+ * @brief This function update notification data.
* @details Display application update UI.
* @remarks
* @param[in] noti notification handle that is created by notification_new().
* @return NOTIFICATION_ERROR_NONE if success, other value if failure
* @retval NOTIFICATION_ERROR_NONE - success
* @retval NOTIFICATION_ERROR_INVALID_DATA - Invalide input value
+ * @retval NOTIFICATION_ERROR_NOT_EXIST_ID - not exist priv id
* @pre
* @post
* @see #notification_h
notification_error_e notification_update_size(notification_h noti,
int priv_id, double size);
+notification_error_e notification_update_content(notification_h noti,
+ int priv_id,
+ const char *content);
+
/**
* @brief This function create internal structure data and return notification handle.
* @details Available type is #NOTIFICATION_TYPE_NOTI and #NOTIFICATION_TYPE_ONGOING.
int priv_id);
/**
+ * @brief This function create notification clone.
+ * @details Newly created notification handle is returned.
+ * @remarks This clone notification handle should be call notification_free().
+ * @param[in] noti notification handle
+ * @param[out] clone newly created notification handle that has same with input noti.
+ * @return NOTIFICATION_ERROR_NONE if success, other value if failure.
+ * @retval NOTIFICATION_ERROR_NONE - success
+ * @retval NOTIFICATION_ERROR_INVALID_DATA - invalid parameter
+ * @pre
+ * @post
+ * @see #notification_type_e
+ * @see #notification_h
+ * @par Sample code:
+ * @code
+#include <notification.h>
+...
+{
+ notification_h noti = notification_new(NOTIFICATION_TYPE_NOTI, APP_GROUP_ID, NOTIFICATION_PRIV_ID_NONE);
+ notification_h clone = NULL;
+
+ notification_clone(noti, &clone);
+ ...
+}
+ * @endcode
+ */
+notification_error_e notification_clone(notification_h noti, notification_h *clone);
+
+/**
* @brief This function free internal structure data of notification handle.
* @details Internal data of notification handle is released. Notification data that inserted is not deleted.
* @remarks
NOTIFICATION_ERROR_FROM_DB = -3, /**< Error from DB query */
NOTIFICATION_ERROR_ALREADY_EXIST_ID = -4, /**< Already exist private ID */
NOTIFICATION_ERROR_FROM_DBUS = -5, /**< Error from DBus */
+ NOTIFICATION_ERROR_NOT_EXIST_ID = -6, /**< Not exist private ID */
} notification_error_e;
/**
int notification_noti_insert(notification_h noti);
+int notification_noti_update(notification_h noti);
+
int notification_noti_delete_all(notification_type_e type, const char *pkgname);
int notification_noti_delete_group_by_group_id(const char *pkgname,
notification_error_e notification_ongoing_update_size(const char *caller_pkgname,
int priv_id, double size);
+notification_error_e notification_ongoing_update_content(const char *caller_pkgname,
+ int priv_id, const char *content);
+
#endif /* __NOTIFICATION_ONGOING_H__ */
/**< Ticker notification */
NOTIFICATION_DISPLAY_APP_LOCK = 0x00000004,
/**< Lock screen */
- NOTIFICATION_DISPLAY_APP_INDICATOR = 0x00000004,/**< Indicator */
+ NOTIFICATION_DISPLAY_APP_INDICATOR = 0x00000008,/**< Indicator */
NOTIFICATION_DISPLAY_APP_ALL = 0xffffffff,
/**< All display application */
};
return noti_err;
}
-EXPORT_API notification_error_e notification_set_group_title(const char *pkgname,
- int group_id,
- const char *title,
- const char *loc_title,
- notification_count_display_type_e count_display)
-{
- char *caller_pkgname = NULL;
- notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
-
- if ((title == NULL && loc_title == NULL)) {
- return NOTIFICATION_ERROR_INVALID_DATA;
- }
-
- if (group_id < NOTIFICATION_GROUP_ID_DEFAULT) {
- return NOTIFICATION_ERROR_INVALID_DATA;
- }
-
- if (pkgname == NULL) {
- caller_pkgname = _notification_get_pkgname_by_pid();
-
- noti_err =
- notification_group_set_title(caller_pkgname, group_id,
- title, loc_title,
- count_display);
-
- if (caller_pkgname != NULL) {
- free(caller_pkgname);
- }
- } else {
- noti_err =
- notification_group_set_title(pkgname, group_id, title,
- loc_title, count_display);
- }
-
- return noti_err;
-}
-
-EXPORT_API notification_error_e notification_get_group_title(const char *pkgname,
- int group_id,
- char **title,
- char **loc_title,
- notification_count_display_type_e *count_display)
-{
- char *caller_pkgname = NULL;
- char *ret_title = NULL;
- char *ret_loc_title = NULL;
- notification_count_display_type_e ret_count_display;
- int ret = NOTIFICATION_ERROR_NONE;
-
- if (pkgname == NULL) {
- caller_pkgname = _notification_get_pkgname_by_pid();
-
- ret =
- notification_group_get_title(caller_pkgname, group_id,
- &ret_title, &ret_loc_title,
- &ret_count_display);
-
- if (caller_pkgname != NULL) {
- free(caller_pkgname);
- }
- } else {
- ret =
- notification_group_get_title(pkgname, group_id, &ret_title,
- &ret_loc_title,
- &ret_count_display);
- }
-
- if (ret != NOTIFICATION_ERROR_NONE) {
- return ret;
- }
-
- *title = ret_title;
- *loc_title = ret_loc_title;
- *count_display = ret_count_display;
-
- return NOTIFICATION_ERROR_NONE;
-}
-
EXPORT_API notification_error_e notification_set_content(notification_h noti,
const char *content,
const char *loc_content)
#endif
}
-EXPORT_API notification_error_e notification_set_default_content(notification_h noti,
- const char *content,
- const char *loc_content)
-{
- int noti_err = NOTIFICATION_ERROR_NONE;
-
- noti_err =
- notification_set_text(noti,
- NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF,
- content, loc_content,
- NOTIFICATION_VARIABLE_TYPE_NONE);
-
- return noti_err;
-}
-
-EXPORT_API notification_error_e notification_get_default_content(notification_h noti,
- char **content,
- char **loc_content)
-{
- int noti_err = NOTIFICATION_ERROR_NONE;
- char *ret_text = NULL;
-
- noti_err =
- notification_get_text(noti,
- NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF,
- &ret_text);
-
- if (content != NULL) {
- *content = ret_text;
- }
-
- if (loc_content != NULL) {
- *loc_content = NULL;
- }
-
- return noti_err;
-}
-
-EXPORT_API notification_error_e notification_set_group_content(const char *pkgname,
- int group_id,
- const char *content,
- const char *loc_content,
- notification_count_display_type_e count_display)
-{
- const char *caller_pkgname = NULL;
- if ((content == NULL && loc_content == NULL)) {
- return NOTIFICATION_ERROR_INVALID_DATA;
- }
-
- if (group_id < NOTIFICATION_GROUP_ID_DEFAULT) {
- return NOTIFICATION_ERROR_INVALID_DATA;
- }
-
- if (pkgname == NULL)
- caller_pkgname = _notification_get_pkgname_by_pid();
- else
- caller_pkgname = pkgname;
-
- notification_group_set_content(caller_pkgname, group_id, content,
- loc_content, count_display);
-
- return NOTIFICATION_ERROR_NONE;
-}
-
-EXPORT_API notification_error_e notification_get_group_content(const char *pkgname,
- int group_id,
- char **content,
- char **loc_content,
- notification_count_display_type_e *count_display)
-{
- const char *caller_pkgname = NULL;
- char *ret_content = NULL;
- char *ret_loc_content = NULL;
- notification_count_display_type_e ret_count_display;
- int ret = NOTIFICATION_ERROR_NONE;
-
- if (pkgname == NULL)
- caller_pkgname = _notification_get_pkgname_by_pid();
- else
- caller_pkgname = pkgname;
-
- ret =
- notification_group_get_content(caller_pkgname, group_id,
- &ret_content, &ret_loc_content,
- &ret_count_display);
- if (ret != NOTIFICATION_ERROR_NONE) {
- return ret;
- }
-
- *content = ret_content;
- *loc_content = ret_loc_content;
- *count_display = ret_count_display;
-
- return NOTIFICATION_ERROR_NONE;
-}
-
EXPORT_API notification_error_e notification_set_text(notification_h noti,
notification_text_type_e type,
const char *text,
/* Save text bundle */
noti->b_text = b;
}
+ } else {
+ /* Reset if text is NULL */
+ if (noti->b_text != NULL) {
+ /* If text bundle exist, store local bundle data */
+ b = noti->b_text;
+
+ /* Make type to key as char string */
+ snprintf(buf_key, sizeof(buf_key), "%d", type);
+
+ /* Get value using type key */
+ ret_val = bundle_get_val(b, buf_key);
+ if (ret_val != NULL) {
+ /* If value exist, remove this */
+ bundle_del(b, buf_key);
+ }
+ }
}
/* Save key if key is valid data */
/* Save key bundle */
noti->b_key = b;
}
+ } else {
+ /* Reset if key is NULL */
+ if (noti->b_key != NULL) {
+ /* If key bundle exist, store local bundle data */
+ b = noti->b_key;
+
+ /* Make type to key as char string */
+ snprintf(buf_key, sizeof(buf_key), "%d", type);
+
+ /* Get value using type key */
+ ret_val = bundle_get_val(b, buf_key);
+ if (ret_val != NULL) {
+ /* If value exist, remove this */
+ bundle_del(b, buf_key);
+ }
+ }
}
if (noti->b_format_args != NULL) {
&boolval);
if (ret == -1 || boolval == 0) {
/* Set flag as display option is OFF */
- display_option_flag = 1;
+ //display_option_flag = 1;
}
}
return NOTIFICATION_ERROR_NONE;
}
-EXPORT_API notification_error_e notification_set_service_data(notification_h noti,
- bundle * service_data,
- bundle * group_service_data)
-{
- int noti_err = NOTIFICATION_ERROR_NONE;
-
- noti_err =
- notification_set_execute_option(noti,
- NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
- NULL, NULL, service_data);
- if (noti_err != NOTIFICATION_ERROR_NONE) {
- return noti_err;
- }
-
- noti_err =
- notification_set_execute_option(noti,
- NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH,
- NULL, NULL, group_service_data);
-
- return noti_err;
-}
-
-EXPORT_API notification_error_e notification_get_service_data(notification_h noti,
- bundle ** service_data,
- bundle ** group_service_data)
-{
- int noti_err = NOTIFICATION_ERROR_NONE;
- bundle *get_service_data = NULL;
-
- noti_err =
- notification_get_execute_option(noti,
- NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
- NULL, &get_service_data);
- if (noti_err != NOTIFICATION_ERROR_NONE) {
- return noti_err;
- }
-
- if (service_data != NULL) {
- *service_data = get_service_data;
- }
-
- noti_err =
- notification_get_execute_option(noti,
- NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH,
- NULL, &get_service_data);
- if (noti_err != NOTIFICATION_ERROR_NONE) {
- return noti_err;
- }
-
- if (service_data != NULL) {
- *group_service_data = get_service_data;
- }
-
- return NOTIFICATION_ERROR_NONE;
-}
-
EXPORT_API notification_error_e notification_set_execute_option(notification_h noti,
notification_execute_type_e type,
const char *text,
return NOTIFICATION_ERROR_NONE;
}
-EXPORT_API notification_error_e notification_set_unread_count(const char *pkgname,
- int group_id,
- int unread_count)
-{
- int ret = NOTIFICATION_ERROR_NONE;
-
- ret = notification_set_badge(pkgname, group_id, unread_count);
-
- return ret;
-}
-
-EXPORT_API notification_error_e notification_get_unread_count(const char *pkgname,
- int group_id,
- int *unread_count)
-{
- int ret = NOTIFICATION_ERROR_NONE;
- int ret_unread_count = 0;
-
- ret = notification_get_badge(pkgname, group_id, &ret_unread_count);
-
- if (unread_count != NULL) {
- *unread_count = ret_unread_count;
- }
-
- return ret;
-}
-
EXPORT_API notification_error_e notification_set_badge(const char *pkgname,
int group_id, int count)
{
EXPORT_API notification_error_e notification_update(notification_h noti)
{
+ int ret = 0;
+
/* Check noti is valid data */
if (noti != NULL) {
- /* TODO : Update noti */
+ /* Update insert time ? */
+ noti->insert_time = time(NULL);
+
+ ret = notification_noti_update(noti);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ return ret;
+ }
}
/* Send changed notification */
return NOTIFICATION_ERROR_NONE;
}
+EXPORT_API notification_error_e notification_update_content(notification_h noti,
+ int priv_id,
+ const char *content)
+{
+ char *caller_pkgname = NULL;
+ int input_priv_id = 0;
+
+ if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
+ if (noti == NULL) {
+ return NOTIFICATION_ERROR_INVALID_DATA;
+ } else {
+ input_priv_id = noti->priv_id;
+ }
+ } else {
+ input_priv_id = priv_id;
+ }
+
+ if (noti == NULL) {
+ caller_pkgname = _notification_get_pkgname_by_pid();
+ } else {
+ caller_pkgname = strdup(noti->caller_pkgname);
+ }
+
+ notification_ongoing_update_content(caller_pkgname, input_priv_id,
+ content);
+
+ if (caller_pkgname) {
+ free(caller_pkgname);
+ }
+
+ return NOTIFICATION_ERROR_NONE;
+}
+
EXPORT_API notification_h notification_new(notification_type_e type,
int group_id, int priv_id)
{
return noti;
}
+EXPORT_API notification_error_e notification_clone(notification_h noti, notification_h *clone)
+{
+ notification_h new_noti = NULL;
+
+ if (noti == NULL || clone == NULL) {
+ NOTIFICATION_ERR("INVALID PARAMETER.");
+ return NOTIFICATION_ERROR_INVALID_DATA;
+ }
+
+ new_noti = (notification_h) malloc(sizeof(struct _notification));
+ if (new_noti == NULL) {
+ NOTIFICATION_ERR("NO MEMORY : noti == NULL");
+ return NOTIFICATION_ERROR_NO_MEMORY;
+ }
+ memset(new_noti, 0x00, sizeof(struct _notification));
+
+ new_noti->type = noti->type;
+
+ new_noti->group_id = noti->group_id;
+ new_noti->internal_group_id = noti->internal_group_id;
+ new_noti->priv_id = noti->priv_id;
+
+ if(noti->caller_pkgname != NULL) {
+ new_noti->caller_pkgname = strdup(noti->caller_pkgname);
+ } else {
+ new_noti->caller_pkgname = _notification_get_pkgname_by_pid();
+ }
+ if(noti->launch_pkgname != NULL) {
+ new_noti->launch_pkgname = strdup(noti->launch_pkgname);
+ } else {
+ new_noti->launch_pkgname = NULL;
+ }
+
+ if(noti->args != NULL) {
+ new_noti->args = bundle_dup(noti->args);
+ } else {
+ new_noti->args = NULL;
+ }
+ if(noti->group_args != NULL) {
+ new_noti->group_args = bundle_dup(noti->group_args);
+ } else {
+ new_noti->group_args = NULL;
+ }
+
+ if(noti->b_execute_option != NULL) {
+ new_noti->b_execute_option = bundle_dup(noti->b_execute_option);
+ } else {
+ new_noti->b_execute_option = NULL;
+ }
+ if(noti->b_service_responding != NULL) {
+ new_noti->b_service_responding = bundle_dup(noti->b_service_responding);
+ } else {
+ new_noti->b_service_responding = NULL;
+ }
+ if(noti->b_service_single_launch != NULL) {
+ new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch);
+ } else {
+ new_noti->b_service_single_launch = NULL;
+ }
+ if(noti->b_service_multi_launch != NULL) {
+ new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch);
+ } else {
+ new_noti->b_service_multi_launch = NULL;
+ }
+
+ new_noti->sound_type = noti->sound_type;
+ if(noti->sound_path != NULL) {
+ new_noti->sound_path = strdup(noti->sound_path);
+ } else {
+ new_noti->sound_path = NULL;
+ }
+ new_noti->vibration_type = noti->vibration_type;
+ if(noti->vibration_path != NULL) {
+ new_noti->vibration_path = strdup(noti->vibration_path);
+ } else {
+ new_noti->vibration_path = NULL;
+ }
+
+ if(noti->domain != NULL) {
+ new_noti->domain = strdup(noti->domain);
+ } else {
+ new_noti->domain = NULL;
+ }
+ if(noti->dir != NULL) {
+ new_noti->dir = strdup(noti->dir);
+ } else {
+ new_noti->dir = NULL;
+ }
+
+ if(noti->b_text != NULL) {
+ new_noti->b_text = bundle_dup(noti->b_text);
+ } else {
+ new_noti->b_text = NULL;
+ }
+ if(noti->b_key != NULL) {
+ new_noti->b_key = bundle_dup(noti->b_key);
+ } else {
+ new_noti->b_key = NULL;
+ }
+ if(noti->b_format_args != NULL) {
+ new_noti->b_format_args = bundle_dup(noti->b_format_args);
+ } else {
+ new_noti->b_format_args = NULL;
+ }
+ new_noti->num_format_args = noti->num_format_args;
+
+ if(noti->b_image_path != NULL) {
+ new_noti->b_image_path = bundle_dup(noti->b_image_path);
+ } else {
+ new_noti->b_image_path = NULL;
+ }
+
+ new_noti->time = noti->time;
+ new_noti->insert_time = noti->insert_time;
+
+ new_noti->flags_for_property = noti->flags_for_property;
+ new_noti->display_applist = noti->display_applist;
+
+ new_noti->progress_size = noti->progress_size;
+ new_noti->progress_percentage = noti->progress_percentage;
+
+ new_noti->app_icon_path = NULL;
+ new_noti->app_name = NULL;
+ new_noti->temp_title = NULL;
+ new_noti->temp_content = NULL;
+
+ *clone = new_noti;
+
+ return NOTIFICATION_ERROR_NONE;
+}
+
+
EXPORT_API notification_error_e notification_free(notification_h noti)
{
if (noti == NULL) {
#include <notification_group.h>
#include <notification_db.h>
-static int _notification_group_bind_query(sqlite3_stmt * stmt, const char *name,
- const char *str)
-{
- int ret = 0;
- int index = 0;
-
- index = sqlite3_bind_parameter_index(stmt, name);
- if (index == 0) {
- NOTIFICATION_ERR("Insert : invalid column name");
- return NOTIFICATION_ERROR_FROM_DB;
- }
-
- ret =
- sqlite3_bind_text(stmt, index, NOTIFICATION_CHECK_STR(str), -1,
- SQLITE_STATIC);
- if (ret != SQLITE_OK) {
- NOTIFICATION_ERR("Insert text : %s",
- NOTIFICATION_CHECK_STR(str));
- return NOTIFICATION_ERROR_FROM_DB;
- }
-
- return NOTIFICATION_ERROR_NONE;
-}
-
static int _notification_group_check_data_inserted(const char *pkgname,
int group_id, sqlite3 * db)
{
return NOTIFICATION_ERROR_NONE;
}
-notification_error_e notification_group_set_title(const char *pkgname,
- int group_id,
- const char *title,
- const char *loc_title,
- notification_count_display_type_e count_display)
-{
- sqlite3 *db;
- sqlite3_stmt *stmt = NULL;
- char query[NOTIFICATION_QUERY_MAX] = { 0, };
- int ret = 0;
- int result = NOTIFICATION_ERROR_NONE;
-
- // db open
- db = notification_db_open(DBPATH);
-
- // Check pkgname & group_id
- ret = _notification_group_check_data_inserted(pkgname, group_id, db);
- if (ret == NOTIFICATION_ERROR_NONE) {
- // not exist -> insert
- snprintf(query, sizeof(query), "insert into noti_group_data ("
- "caller_pkgname, group_id, unread_count, title, loc_title, count_display_title) values ("
- "'%s', %d, 0, $title, $loc_title, %d)",
- pkgname, group_id, count_display);
-
- } else {
- // exist -> update
- // not exist -> insert
- snprintf(query, sizeof(query), "update noti_group_data "
- "set title = $title, loc_title = $loc_title, count_display_title = %d "
- "where caller_pkgname = '%s' and group_id = %d",
- count_display, pkgname, group_id);
- }
-
- // insert
- ret = sqlite3_prepare_v2(db, query, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- NOTIFICATION_ERR("Insert Query : %s", query);
- NOTIFICATION_ERR("Insert DB error(%d) : %s", ret,
- sqlite3_errmsg(db));
- if (stmt) {
- sqlite3_finalize(stmt);
- }
-
- if (db) {
- notification_db_close(&db);
- }
- return NOTIFICATION_ERROR_FROM_DB;
- }
-
- ret = _notification_group_bind_query(stmt, "$title", title);
- if (ret != NOTIFICATION_ERROR_NONE) {
- NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
- return ret;
- }
-
- ret = _notification_group_bind_query(stmt, "$loc_title", loc_title);
- if (ret != NOTIFICATION_ERROR_NONE) {
- NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
- return ret;
- }
-
- ret = sqlite3_step(stmt);
- if (ret == SQLITE_OK || ret == SQLITE_DONE) {
- result = NOTIFICATION_ERROR_NONE;
- } else {
- result = NOTIFICATION_ERROR_FROM_DB;
- }
-
- if (stmt) {
- sqlite3_finalize(stmt);
- }
-
- if (db) {
- notification_db_close(&db);
- }
-
- return result;
-}
-
-notification_error_e notification_group_get_title(const char *pkgname,
- int group_id,
- char **ret_title,
- char **ret_loc_title,
- notification_count_display_type_e *count_display)
-{
- sqlite3 *db;
- sqlite3_stmt *stmt = NULL;
- char query[NOTIFICATION_QUERY_MAX] = { 0, };
- int ret = 0;
- int col = 0;
-
- // db open
- db = notification_db_open(DBPATH);
-
- snprintf(query, sizeof(query), "select "
- "title, loc_title, count_display_title "
- "from noti_group_data "
- "where caller_pkgname = '%s' and group_id = %d",
- pkgname, group_id);
-
- ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL);
- if (ret != SQLITE_OK) {
- NOTIFICATION_ERR("Select Query : %s", query);
- NOTIFICATION_ERR("Select DB error(%d) : %s", ret,
- sqlite3_errmsg(db));
-
- return NOTIFICATION_ERROR_FROM_DB;
- }
-
- ret = sqlite3_step(stmt);
- if (ret == SQLITE_ROW) {
- *ret_title = notification_db_column_text(stmt, col++);
- *ret_loc_title = notification_db_column_text(stmt, col++);
- *count_display = sqlite3_column_int(stmt, col++);
- }
-
- sqlite3_finalize(stmt);
-
- // db close
- if (db) {
- notification_db_close(&db);
- }
-
- return NOTIFICATION_ERROR_NONE;
-}
-
-notification_error_e notification_group_set_content(const char *pkgname,
- int group_id,
- const char *content,
- const char *loc_content,
- notification_count_display_type_e count_display)
-{
- sqlite3 *db;
- sqlite3_stmt *stmt = NULL;
- char query[NOTIFICATION_QUERY_MAX] = { 0, };
- int ret = 0;
- int result = NOTIFICATION_ERROR_NONE;
-
- // db open
- db = notification_db_open(DBPATH);
-
- // Check pkgname & group_id
- ret = _notification_group_check_data_inserted(pkgname, group_id, db);
- if (ret == NOTIFICATION_ERROR_NONE) {
- // not exist -> insert
- snprintf(query, sizeof(query), "insert into noti_group_data ("
- "caller_pkgname, group_id, unread_count, content, loc_content, count_display_content) values ("
- "'%s', %d, 0, $content, $loc_content, %d)",
- pkgname, group_id, count_display);
-// NOTIFICATION_INFO("Insert Query : %s", query);
- } else {
- // exist -> update
- // not exist -> insert
- snprintf(query, sizeof(query), "update noti_group_data "
- "set content = $content, loc_content = $loc_content, count_display_content = %d "
- "where caller_pkgname = '%s' and group_id = %d",
- count_display, pkgname, group_id);
-// NOTIFICATION_INFO("Insert Query : %s", query);
- }
-
- // insert
- ret = sqlite3_prepare_v2(db, query, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- NOTIFICATION_ERR("Insert Query : %s", query);
- NOTIFICATION_ERR("Insert DB error(%d) : %s", ret,
- sqlite3_errmsg(db));
- if (stmt) {
- sqlite3_finalize(stmt);
- }
-
- if (db) {
- notification_db_close(&db);
- }
- return NOTIFICATION_ERROR_FROM_DB;
- }
-
- ret = _notification_group_bind_query(stmt, "$content", content);
- if (ret != NOTIFICATION_ERROR_NONE) {
- NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
- return ret;
- }
-
- ret = _notification_group_bind_query(stmt, "$loc_content", loc_content);
- if (ret != NOTIFICATION_ERROR_NONE) {
- NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
- return ret;
- }
-
- ret = sqlite3_step(stmt);
- if (ret == SQLITE_OK || ret == SQLITE_DONE) {
- result = NOTIFICATION_ERROR_NONE;
- } else {
- result = NOTIFICATION_ERROR_FROM_DB;
- }
-
- if (stmt) {
- sqlite3_finalize(stmt);
- }
-
- if (db) {
- notification_db_close(&db);
- }
-
- return result;
-}
-
-notification_error_e notification_group_get_content(const char *pkgname,
- int group_id,
- char **ret_content,
- char **ret_loc_content,
- notification_count_display_type_e *count_display)
-{
- sqlite3 *db;
- sqlite3_stmt *stmt = NULL;
- char query[NOTIFICATION_QUERY_MAX] = { 0, };
- int ret = 0;
- int col = 0;
-
- // db open
- db = notification_db_open(DBPATH);
-
- snprintf(query, sizeof(query), "select "
- "content, loc_content, count_display_content "
- "from noti_group_data "
- "where caller_pkgname = '%s' and group_id = %d",
- pkgname, group_id);
-
- ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL);
- if (ret != SQLITE_OK) {
- NOTIFICATION_ERR("Select Query : %s", query);
- NOTIFICATION_ERR("Select DB error(%d) : %s", ret,
- sqlite3_errmsg(db));
-
- return NOTIFICATION_ERROR_FROM_DB;
- }
-
- ret = sqlite3_step(stmt);
- if (ret == SQLITE_ROW) {
- *ret_content = notification_db_column_text(stmt, col++);
- *ret_loc_content = notification_db_column_text(stmt, col++);
- *count_display = sqlite3_column_int(stmt, col++);
- }
-
- sqlite3_finalize(stmt);
-
- // db close
- if (db) {
- notification_db_close(&db);
- }
-
- return NOTIFICATION_ERROR_NONE;
-}
-
notification_error_e notification_group_set_badge(const char *pkgname,
int group_id, int count)
{
if (stmt) {
sqlite3_finalize(stmt);
}
-
- if (db) {
- notification_db_close(&db);
- }
return NOTIFICATION_ERROR_FROM_DB;
}
(ret_title));
if (ret != NOTIFICATION_ERROR_NONE) {
NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
+ if (stmt) {
+ sqlite3_finalize(stmt);
+ }
return ret;
}
}
return NOTIFICATION_ERROR_NONE;
}
+
+static int _notification_noti_make_update_query(notification_h noti, char *query,
+ int query_size)
+{
+ char *args = NULL;
+ char *group_args = NULL;
+ char *b_image_path = NULL;
+ char *b_execute_option = NULL;
+ char *b_service_responding = NULL;
+ char *b_service_single_launch = NULL;
+ char *b_service_multi_launch = NULL;
+ char *b_text = NULL;
+ char *b_key = NULL;
+ char *b_format_args = NULL;
+ int flag_simmode = 0;
+
+ /* Decode bundle to update DB */
+ if (noti->args) {
+ bundle_encode(noti->args, (bundle_raw **) & args, NULL);
+ }
+ if (noti->group_args) {
+ bundle_encode(noti->group_args, (bundle_raw **) & group_args,
+ NULL);
+ }
+
+ if (noti->b_execute_option) {
+ bundle_encode(noti->b_execute_option,
+ (bundle_raw **) & b_execute_option, NULL);
+ }
+ if (noti->b_service_responding) {
+ bundle_encode(noti->b_service_responding,
+ (bundle_raw **) & b_service_responding, NULL);
+ }
+ if (noti->b_service_single_launch) {
+ bundle_encode(noti->b_service_single_launch,
+ (bundle_raw **) & b_service_single_launch, NULL);
+ }
+ if (noti->b_service_multi_launch) {
+ bundle_encode(noti->b_service_multi_launch,
+ (bundle_raw **) & b_service_multi_launch, NULL);
+ }
+
+ if (noti->b_text) {
+ bundle_encode(noti->b_text, (bundle_raw **) & b_text, NULL);
+ }
+ if (noti->b_key) {
+ bundle_encode(noti->b_key, (bundle_raw **) & b_key, NULL);
+ }
+ if (noti->b_format_args) {
+ bundle_encode(noti->b_format_args,
+ (bundle_raw **) & b_format_args, NULL);
+ }
+
+ if (noti->b_image_path) {
+ bundle_encode(noti->b_image_path,
+ (bundle_raw **) & b_image_path, NULL);
+ }
+
+ /* Check only simmode property is enable */
+ if (noti->flags_for_property & NOTIFICATION_PROP_DISPLAY_ONLY_SIMMODE) {
+ flag_simmode = 1;
+ }
+
+ /* Make query */
+ snprintf(query, query_size, "update noti_list set "
+ "type = %d, "
+ "launch_pkgname = '%s', "
+ "image_path = '%s', "
+ "b_text = '%s', b_key = '%s', "
+ "b_format_args = '%s', num_format_args = %d, "
+ "text_domain = '%s', text_dir = '%s', "
+ "time = %d, insert_time = %d, "
+ "args = '%s', group_args = '%s', "
+ "b_execute_option = '%s', "
+ "b_service_responding = '%s', "
+ "b_service_single_launch = '%s', "
+ "b_service_multi_launch = '%s', "
+ "sound_type = %d, sound_path = '%s', "
+ "vibration_type = %d, vibration_path = '%s', "
+ "flags_for_property = %d, flag_simmode = %d, "
+ "display_applist = %d, "
+ "progress_size = %f, progress_percentage = %f "
+ "where priv_id = %d ",
+ noti->type,
+ NOTIFICATION_CHECK_STR(noti->launch_pkgname),
+ NOTIFICATION_CHECK_STR(b_image_path),
+ NOTIFICATION_CHECK_STR(b_text), NOTIFICATION_CHECK_STR(b_key),
+ NOTIFICATION_CHECK_STR(b_format_args), noti->num_format_args,
+ NOTIFICATION_CHECK_STR(noti->domain),
+ NOTIFICATION_CHECK_STR(noti->dir),
+ (int)noti->time, (int)noti->insert_time,
+ NOTIFICATION_CHECK_STR(args), NOTIFICATION_CHECK_STR(group_args),
+ NOTIFICATION_CHECK_STR(b_execute_option),
+ NOTIFICATION_CHECK_STR(b_service_responding),
+ NOTIFICATION_CHECK_STR(b_service_single_launch),
+ NOTIFICATION_CHECK_STR(b_service_multi_launch),
+ noti->sound_type, NOTIFICATION_CHECK_STR(noti->sound_path),
+ noti->vibration_type,
+ NOTIFICATION_CHECK_STR(noti->vibration_path),
+ noti->flags_for_property, flag_simmode, noti->display_applist,
+ noti->progress_size, noti->progress_percentage,
+ noti->priv_id);
+
+ /* Free decoded data */
+ if (args) {
+ free(args);
+ }
+ if (group_args) {
+ free(group_args);
+ }
+
+ if (b_execute_option) {
+ free(b_execute_option);
+ }
+ if (b_service_responding) {
+ free(b_service_responding);
+ }
+ if (b_service_single_launch) {
+ free(b_service_single_launch);
+ }
+ if (b_service_multi_launch) {
+ free(b_service_multi_launch);
+ }
+
+ if (b_text) {
+ free(b_text);
+ }
+ if (b_key) {
+ free(b_key);
+ }
+ if (b_format_args) {
+ free(b_format_args);
+ }
+
+ if (b_image_path) {
+ free(b_image_path);
+ }
+
+ return NOTIFICATION_ERROR_NONE;
+}
+
static notification_h _notification_noti_get_item(sqlite3_stmt * stmt)
{
notification_h noti = NULL;
int notification_noti_insert(notification_h noti)
{
- sqlite3 *db;
+ sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
char query[NOTIFICATION_QUERY_MAX] = { 0, };
- int ret = 0, result = 0;
+ int ret = 0;
char buf_key[32] = { 0, };
const char *title_key = NULL;
} else {
ret = _notification_noti_check_priv_id(noti, db);
if (ret != NOTIFICATION_ERROR_NONE) {
- return ret;
+ goto err;
}
}
/* Get internal group ID */
ret = _notification_noti_get_internal_group_id(noti, db);
if (ret != NOTIFICATION_ERROR_NONE) {
- return ret;
+ goto err;
}
/* make query */
ret = _notification_noti_make_query(noti, query, sizeof(query));
if (ret != NOTIFICATION_ERROR_NONE) {
- return ret;
+ goto err;
}
ret = sqlite3_prepare_v2(db, query, -1, &stmt, NULL);
NOTIFICATION_ERR("Insert Query : %s", query);
NOTIFICATION_ERR("Insert DB error(%d) : %s", ret,
sqlite3_errmsg(db));
- if (stmt) {
- sqlite3_finalize(stmt);
- }
-
- if (db) {
- notification_db_close(&db);
- }
- return NOTIFICATION_ERROR_FROM_DB;
+ ret = NOTIFICATION_ERROR_FROM_DB;
+ goto err;
}
/* Get title key */
ret = _notification_noti_bind_query(stmt, "$title_key", title_key);
if (ret != NOTIFICATION_ERROR_NONE) {
NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
- return ret;
+ goto err;
}
ret = sqlite3_step(stmt);
if (ret == SQLITE_OK || ret == SQLITE_DONE) {
- result = NOTIFICATION_ERROR_NONE;
+ ret = NOTIFICATION_ERROR_NONE;
} else {
- result = NOTIFICATION_ERROR_FROM_DB;
+ ret = NOTIFICATION_ERROR_FROM_DB;
+ }
+err:
+ if (stmt) {
+ sqlite3_finalize(stmt);
+ }
+
+ /* Close DB */
+ if (db) {
+ notification_db_close(&db);
+ }
+
+ return ret;
+}
+
+
+int notification_noti_update(notification_h noti)
+{
+ sqlite3 *db;
+ sqlite3_stmt *stmt = NULL;
+ char query[NOTIFICATION_QUERY_MAX] = { 0, };
+ int ret = 0;
+
+ /* Open DB */
+ db = notification_db_open(DBPATH);
+
+ /* Check private ID is exist */
+ ret = _notification_noti_check_priv_id(noti, db);
+ if (ret != NOTIFICATION_ERROR_ALREADY_EXIST_ID) {
+ ret = NOTIFICATION_ERROR_NOT_EXIST_ID;
+ goto err;
+ }
+
+ /* make update query */
+ ret = _notification_noti_make_update_query(noti, query, sizeof(query));
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ goto err;
}
+ ret = sqlite3_prepare_v2(db, query, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ NOTIFICATION_ERR("Insert Query : %s", query);
+ NOTIFICATION_ERR("Insert DB error(%d) : %s", ret,
+ sqlite3_errmsg(db));
+ ret = NOTIFICATION_ERROR_FROM_DB;
+ goto err;
+ }
+
+ ret = sqlite3_step(stmt);
+ if (ret == SQLITE_OK || ret == SQLITE_DONE) {
+ ret = NOTIFICATION_ERROR_NONE;
+ } else {
+ ret = NOTIFICATION_ERROR_FROM_DB;
+ }
+err:
if (stmt) {
sqlite3_finalize(stmt);
}
notification_db_close(&db);
}
- return result;
+ return ret;
}
int notification_noti_delete_all(notification_type_e type, const char *pkgname)
{
- sqlite3 *db;
+ sqlite3 *db = NULL;
char query[NOTIFICATION_QUERY_MAX] = { 0, };
char query_base[NOTIFICATION_QUERY_MAX] = { 0, };
char query_where[NOTIFICATION_QUERY_MAX] = { 0, };
int notification_noti_delete_group_by_group_id(const char *pkgname,
int group_id)
{
- sqlite3 *db;
+ sqlite3 *db = NULL;
char query[NOTIFICATION_QUERY_MAX] = { 0, };
/* Check pkgname is valid */
int notification_noti_delete_group_by_priv_id(const char *pkgname, int priv_id)
{
- sqlite3 *db;
+ sqlite3 *db = NULL;
char query[NOTIFICATION_QUERY_MAX] = { 0, };
int internal_group_id = 0;
int notification_noti_delete_by_priv_id(const char *pkgname, int priv_id)
{
- sqlite3 *db;
+ sqlite3 *db = NULL;
char query[NOTIFICATION_QUERY_MAX] = { 0, };
/* Check pkgname is valid */
NOTIFICATION_ERR("Select DB error(%d) : %s", ret,
sqlite3_errmsg(db));
- return NOTIFICATION_ERROR_FROM_DB;
+ ret = NOTIFICATION_ERROR_FROM_DB;
+ goto err;
}
ret = sqlite3_step(stmt);
get_count = sqlite3_column_int(stmt, 0);
}
- sqlite3_finalize(stmt);
+ ret = NOTIFICATION_ERROR_NONE;
+
+err:
+ if (stmt) {
+ sqlite3_finalize(stmt);
+ }
/* Close DB */
if (db) {
*count = get_count;
- return NOTIFICATION_ERROR_NONE;
+ return ret;
}
notification_error_e notification_noti_get_grouping_list(notification_type_e type,
notification_list_h *
list)
{
- sqlite3 *db;
+ sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
char query[NOTIFICATION_QUERY_MAX] = { 0, };
char query_base[NOTIFICATION_QUERY_MAX] = { 0, };
NOTIFICATION_ERR("Select DB error(%d) : %s", ret,
sqlite3_errmsg(db));
- return NOTIFICATION_ERROR_FROM_DB;
+ ret = NOTIFICATION_ERROR_FROM_DB;
+ goto err;
}
ret = sqlite3_step(stmt);
ret = sqlite3_step(stmt);
}
- sqlite3_finalize(stmt);
+ ret = NOTIFICATION_ERROR_NONE;
+
+err:
+ if (stmt) {
+ sqlite3_finalize(stmt);
+ }
/* Close DB */
if (db) {
*list = notification_list_get_head(get_list);
}
- return NOTIFICATION_ERROR_NONE;
+ return ret;
}
notification_error_e notification_noti_get_detail_list(const char *pkgname,
int priv_id, int count,
notification_list_h *list)
{
- sqlite3 *db;
+ sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
char query_base[NOTIFICATION_QUERY_MAX] = { 0, };
char query_where[NOTIFICATION_QUERY_MAX] = { 0, };
NOTIFICATION_ERR("Select DB error(%d) : %s", ret,
sqlite3_errmsg(db));
- return NOTIFICATION_ERROR_FROM_DB;
+ ret = NOTIFICATION_ERROR_FROM_DB;
+ goto err;
}
ret = sqlite3_step(stmt);
ret = sqlite3_step(stmt);
}
- sqlite3_finalize(stmt);
+ ret = NOTIFICATION_ERROR_NONE;
+
+err:
+ if (stmt) {
+ sqlite3_finalize(stmt);
+ }
/* Close DB */
if (db) {
*list = notification_list_get_head(get_list);
}
- return NOTIFICATION_ERROR_NONE;
+ return ret;
}
return NOTIFICATION_ERROR_FROM_DBUS;
}
+
+notification_error_e notification_ongoing_update_content(const char *caller_pkgname,
+ int priv_id, const char *content)
+{
+ DBusConnection *connection = NULL;
+ DBusMessage *signal = NULL;
+ DBusError err;
+ dbus_bool_t ret;
+
+ dbus_error_init(&err);
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+ if (!connection) {
+ NOTIFICATION_ERR("Fail to dbus_bus_get");
+ return NOTIFICATION_ERROR_FROM_DBUS;
+ }
+
+ signal =
+ dbus_message_new_signal("/dbus/signal", "notification.ongoing",
+ "update_content");
+ if (!signal) {
+ NOTIFICATION_ERR("Fail to dbus_message_new_signal");
+ return NOTIFICATION_ERROR_FROM_DBUS;
+ }
+
+ if(content == NULL) {
+ ret = dbus_message_append_args(signal,
+ DBUS_TYPE_STRING, &caller_pkgname,
+ DBUS_TYPE_INT32, &priv_id,
+ DBUS_TYPE_INVALID);
+ } else {
+ ret = dbus_message_append_args(signal,
+ DBUS_TYPE_STRING, &caller_pkgname,
+ DBUS_TYPE_INT32, &priv_id,
+ DBUS_TYPE_STRING, &content,
+ DBUS_TYPE_INVALID);
+ }
+ if (ret) {
+ ret = dbus_connection_send(connection, signal, NULL);
+ NOTIFICATION_INFO("Send content : %s(%d) %s",
+ caller_pkgname, priv_id, content);
+
+ if (ret) {
+ dbus_connection_flush(connection);
+ }
+ }
+
+ dbus_message_unref(signal);
+
+ if (ret) {
+ return NOTIFICATION_ERROR_NONE;
+ }
+
+ return NOTIFICATION_ERROR_FROM_DBUS;
+}
+