summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeonghoon Park <jh1979.park@samsung.com>2012-02-18 17:58:37 +0900
committerJeonghoon Park <jh1979.park@samsung.com>2012-02-18 17:58:37 +0900
commit86b3111ee38b3e7966e55921c0554da31e7c1cc9 (patch)
tree82f5edaa3e611f2c1da86a7db3578eaec42e849c /src
parentf82d616f46273ffbb9f043ad162b8d6f1c6d410d (diff)
downloadnotification-86b3111ee38b3e7966e55921c0554da31e7c1cc9.tar.gz
notification-86b3111ee38b3e7966e55921c0554da31e7c1cc9.tar.bz2
notification-86b3111ee38b3e7966e55921c0554da31e7c1cc9.zip
update to latest
Diffstat (limited to 'src')
-rw-r--r--[-rwxr-xr-x]src/notification.c466
-rw-r--r--[-rwxr-xr-x]src/notification_group.c277
-rw-r--r--[-rwxr-xr-x]src/notification_noti.c276
-rw-r--r--[-rwxr-xr-x]src/notification_ongoing.c55
4 files changed, 502 insertions, 572 deletions
diff --git a/src/notification.c b/src/notification.c
index d5fdacf..3525865 100755..100644
--- a/src/notification.c
+++ b/src/notification.c
@@ -460,84 +460,6 @@ EXPORT_API notification_error_e notification_get_title(notification_h noti,
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)
@@ -589,102 +511,6 @@ EXPORT_API notification_error_e notification_get_content(notification_h noti,
#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,
@@ -751,6 +577,22 @@ EXPORT_API notification_error_e notification_set_text(notification_h noti,
/* 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 */
@@ -789,6 +631,22 @@ EXPORT_API notification_error_e notification_set_text(notification_h noti,
/* 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) {
@@ -955,7 +813,7 @@ EXPORT_API notification_error_e notification_get_text(notification_h noti,
&boolval);
if (ret == -1 || boolval == 0) {
/* Set flag as display option is OFF */
- display_option_flag = 1;
+ //display_option_flag = 1;
}
}
@@ -1551,62 +1409,6 @@ EXPORT_API notification_error_e notification_get_args(notification_h noti,
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,
@@ -1954,33 +1756,6 @@ EXPORT_API notification_error_e notification_get_pkgname(notification_h noti,
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)
{
@@ -2135,9 +1910,17 @@ EXPORT_API notification_error_e notification_insert(notification_h noti,
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 */
@@ -2387,6 +2170,39 @@ EXPORT_API notification_error_e notification_update_size(notification_h noti,
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)
{
@@ -2463,6 +2279,138 @@ EXPORT_API notification_h notification_new(notification_type_e type,
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) {
diff --git a/src/notification_group.c b/src/notification_group.c
index c310f8e..c217704 100755..100644
--- a/src/notification_group.c
+++ b/src/notification_group.c
@@ -27,30 +27,6 @@
#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)
{
@@ -88,259 +64,6 @@ static int _notification_group_check_data_inserted(const char *pkgname,
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)
{
diff --git a/src/notification_noti.c b/src/notification_noti.c
index 07fae45..bb0a60f 100755..100644
--- a/src/notification_noti.c
+++ b/src/notification_noti.c
@@ -247,10 +247,6 @@ static int _notification_noti_get_internal_group_id(notification_h noti,
if (stmt) {
sqlite3_finalize(stmt);
}
-
- if (db) {
- notification_db_close(&db);
- }
return NOTIFICATION_ERROR_FROM_DB;
}
@@ -262,6 +258,9 @@ static int _notification_noti_get_internal_group_id(notification_h noti,
(ret_title));
if (ret != NOTIFICATION_ERROR_NONE) {
NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
+ if (stmt) {
+ sqlite3_finalize(stmt);
+ }
return ret;
}
}
@@ -433,6 +432,147 @@ static int _notification_noti_make_query(notification_h noti, char *query,
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;
@@ -489,10 +629,10 @@ static notification_h _notification_noti_get_item(sqlite3_stmt * stmt)
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;
@@ -505,20 +645,20 @@ int notification_noti_insert(notification_h noti)
} 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);
@@ -526,14 +666,8 @@ int notification_noti_insert(notification_h noti)
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 */
@@ -559,16 +693,68 @@ int notification_noti_insert(notification_h noti)
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);
}
@@ -578,12 +764,12 @@ int notification_noti_insert(notification_h noti)
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, };
@@ -628,7 +814,7 @@ int notification_noti_delete_all(notification_type_e type, const char *pkgname)
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 */
@@ -657,7 +843,7 @@ int notification_noti_delete_group_by_group_id(const char *pkgname,
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;
@@ -692,7 +878,7 @@ int notification_noti_delete_group_by_priv_id(const char *pkgname, int priv_id)
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 */
@@ -823,7 +1009,8 @@ notification_error_e notification_noti_get_count(notification_type_e type,
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);
@@ -831,7 +1018,12 @@ notification_error_e notification_noti_get_count(notification_type_e type,
get_count = sqlite3_column_int(stmt, 0);
}
- sqlite3_finalize(stmt);
+ ret = NOTIFICATION_ERROR_NONE;
+
+err:
+ if (stmt) {
+ sqlite3_finalize(stmt);
+ }
/* Close DB */
if (db) {
@@ -840,7 +1032,7 @@ notification_error_e notification_noti_get_count(notification_type_e type,
*count = get_count;
- return NOTIFICATION_ERROR_NONE;
+ return ret;
}
notification_error_e notification_noti_get_grouping_list(notification_type_e type,
@@ -848,7 +1040,7 @@ notification_error_e notification_noti_get_grouping_list(notification_type_e typ
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, };
@@ -902,7 +1094,8 @@ notification_error_e notification_noti_get_grouping_list(notification_type_e typ
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);
@@ -925,7 +1118,12 @@ notification_error_e notification_noti_get_grouping_list(notification_type_e typ
ret = sqlite3_step(stmt);
}
- sqlite3_finalize(stmt);
+ ret = NOTIFICATION_ERROR_NONE;
+
+err:
+ if (stmt) {
+ sqlite3_finalize(stmt);
+ }
/* Close DB */
if (db) {
@@ -936,7 +1134,7 @@ notification_error_e notification_noti_get_grouping_list(notification_type_e typ
*list = notification_list_get_head(get_list);
}
- return NOTIFICATION_ERROR_NONE;
+ return ret;
}
notification_error_e notification_noti_get_detail_list(const char *pkgname,
@@ -944,7 +1142,7 @@ 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, };
@@ -997,7 +1195,8 @@ notification_error_e notification_noti_get_detail_list(const char *pkgname,
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);
@@ -1020,7 +1219,12 @@ notification_error_e notification_noti_get_detail_list(const char *pkgname,
ret = sqlite3_step(stmt);
}
- sqlite3_finalize(stmt);
+ ret = NOTIFICATION_ERROR_NONE;
+
+err:
+ if (stmt) {
+ sqlite3_finalize(stmt);
+ }
/* Close DB */
if (db) {
@@ -1031,5 +1235,5 @@ notification_error_e notification_noti_get_detail_list(const char *pkgname,
*list = notification_list_get_head(get_list);
}
- return NOTIFICATION_ERROR_NONE;
+ return ret;
}
diff --git a/src/notification_ongoing.c b/src/notification_ongoing.c
index cd911d8..18a64e7 100755..100644
--- a/src/notification_ongoing.c
+++ b/src/notification_ongoing.c
@@ -127,3 +127,58 @@ notification_error_e notification_ongoing_update_size(const char *caller_pkgname
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;
+}
+