summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryoungsub ko <ys4610.ko@samsung.com>2013-06-11 17:38:14 +0900
committeryoungsub ko <ys4610.ko@samsung.com>2013-06-11 17:38:14 +0900
commitfd84385bbf2ba55eb4e7377c6f89fcf9657bfe20 (patch)
tree83336c45704450ce399feb38369e09f5e2d0af19
parentd941ce91544c826bba40b8cb28c66378210ba9e9 (diff)
downloadnotification-fd84385bbf2ba55eb4e7377c6f89fcf9657bfe20.tar.gz
notification-fd84385bbf2ba55eb4e7377c6f89fcf9657bfe20.tar.bz2
notification-fd84385bbf2ba55eb4e7377c6f89fcf9657bfe20.zip
sync with private git
-rwxr-xr-xinclude/notification.h31
-rwxr-xr-xinclude/notification_ipc.h2
-rwxr-xr-xpackaging/notification.spec6
-rwxr-xr-xsrc/notification.c17
-rwxr-xr-xsrc/notification_ipc.c121
-rwxr-xr-xsrc/notification_ongoing.c7
6 files changed, 168 insertions, 16 deletions
diff --git a/include/notification.h b/include/notification.h
index 2534a09..9748dc6 100755
--- a/include/notification.h
+++ b/include/notification.h
@@ -1379,6 +1379,37 @@ notification_error_e notification_insert(notification_h noti,
notification_error_e notification_update(notification_h noti);
/**
+ * @brief This function updates notification data.
+ * @details Display application update UI.
+ * @remarks
+ * @param[in] noti notification handle that is created by notification_new().
+ * @param[in] result_cb callback called when update completed
+ * @param[in] user_data user data which you want to use in callback
+ * @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
+ * @par Sample code:
+ * @code
+#include <notification.h>
+...
+ {
+ notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+
+ noti_err = notification_update_async(NULL, result_cb, data);
+ if(noti_err != NOTIFICATION_ERROR_NONE) {
+ return;
+ }
+}
+ * @endcode
+ */
+notification_error_e notification_update_async(notification_h noti,
+ void (*result_cb)(int priv_id, int result, void *data), void *user_data);
+
+/**
* @brief This function clear all notification of type.
* @details Not recommand API. Only for notification tray's clear button operation.
* @remarks
diff --git a/include/notification_ipc.h b/include/notification_ipc.h
index 4dd2656..31bdca5 100755
--- a/include/notification_ipc.h
+++ b/include/notification_ipc.h
@@ -41,6 +41,8 @@ struct packet *notification_ipc_make_packet_from_noti(notification_h noti, const
notification_error_e notification_ipc_request_insert(notification_h noti, int *priv_id);
notification_error_e notification_ipc_request_update(notification_h noti);
+notification_error_e notification_ipc_request_update_async(notification_h noti,
+ void (*result_cb)(int priv_id, int result, void *data), void *user_data);
notification_error_e notification_ipc_request_refresh(void);
notification_error_e notification_ipc_request_delete_single(notification_type_e type, char *pkgname, int priv_id);
notification_error_e notification_ipc_request_delete_multiple(notification_type_e type, char *pkgname);
diff --git a/packaging/notification.spec b/packaging/notification.spec
index 41d9d3b..74b1bef 100755
--- a/packaging/notification.spec
+++ b/packaging/notification.spec
@@ -1,6 +1,6 @@
Name: notification
Summary: notification library
-Version: 0.2.5
+Version: 0.2.7
Release: 1
Group: TBD
License: Apache-2.0
@@ -140,8 +140,8 @@ fi
chown :5000 /opt/dbspace/.notification.db
chown :5000 /opt/dbspace/.notification.db-journal
-chmod 660 /opt/dbspace/.notification.db
-chmod 660 /opt/dbspace/.notification.db-journal
+chmod 640 /opt/dbspace/.notification.db
+chmod 640 /opt/dbspace/.notification.db-journal
chsmack -a 'notification::db' /opt/dbspace/.notification.db*
vconftool set -t string memory/private/libstatus/message "" -i -g 5000 -f
diff --git a/src/notification.c b/src/notification.c
index ae82b03..33435b2 100755
--- a/src/notification.c
+++ b/src/notification.c
@@ -2057,6 +2057,23 @@ EXPORT_API notification_error_e notification_update(notification_h noti)
return NOTIFICATION_ERROR_NONE;
}
+EXPORT_API notification_update_async(notification_h noti,
+ void (*result_cb)(int priv_id, int result, void *data), void *user_data)
+{
+ int ret = 0;
+
+ /* Check noti is valid data */
+ if (noti != NULL) {
+ /* Update insert time ? */
+ noti->insert_time = time(NULL);
+ ret = notification_ipc_request_update_async(noti, result_cb, user_data);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ return ret;
+ }
+ }
+ return NOTIFICATION_ERROR_NONE;
+}
+
EXPORT_API notification_error_e notifiation_clear(notification_type_e type)
{
int ret = 0;
diff --git a/src/notification_ipc.c b/src/notification_ipc.c
index 0d5db8a..3fc4f59 100755
--- a/src/notification_ipc.c
+++ b/src/notification_ipc.c
@@ -36,7 +36,7 @@
#include <notification_internal.h>
#include <notification_debug.h>
-#define NOTIFICATION_IPC_TIMEOUT 1.0
+#define NOTIFICATION_IPC_TIMEOUT 0.0
#if !defined(VCONFKEY_MASTER_STARTED)
#define VCONFKEY_MASTER_STARTED "memory/data-provider-master/started"
@@ -44,6 +44,8 @@
static struct info {
int server_fd;
+ int server_cl_fd;
+ int server_cl_fd_ref_cnt;
int client_fd;
const char *socket_file;
struct {
@@ -55,6 +57,8 @@ static struct info {
int is_started_cb_set_task;
} s_info = {
.server_fd = -1,
+ .server_cl_fd = -1,
+ .server_cl_fd_ref_cnt = 0,
.client_fd = -1,
.socket_file = NOTIFICATION_ADDR,
.initialized = 0,
@@ -71,6 +75,11 @@ struct _task_list {
void *data;
};
+typedef struct _result_cb_item {
+ void (*result_cb)(int priv_id, int result, void *data);
+ void *data;
+} result_cb_item;
+
static task_list *g_task_list;
static notification_error_e notification_ipc_monitor_register(void);
@@ -955,7 +964,7 @@ notification_error_e notification_ipc_request_insert(notification_h noti, int *p
}
packet_unref(result);
} else {
- notification_ipc_is_master_ready();
+ NOTIFICATION_ERR("failed to receive answer(insert)");
return NOTIFICATION_ERROR_SERVICE_NOT_READY;
}
@@ -987,7 +996,7 @@ notification_error_e notification_ipc_request_delete_single(notification_type_e
}
packet_unref(result);
} else {
- notification_ipc_is_master_ready();
+ NOTIFICATION_ERR("failed to receive answer(delete)");
return NOTIFICATION_ERROR_SERVICE_NOT_READY;
}
@@ -1016,7 +1025,7 @@ notification_error_e notification_ipc_request_delete_multiple(notification_type_
NOTIFICATION_ERR("num deleted:%d", num_deleted);
packet_unref(result);
} else {
- notification_ipc_is_master_ready();
+ NOTIFICATION_ERR("failed to receive answer(delete multiple)");
return NOTIFICATION_ERROR_SERVICE_NOT_READY;
}
@@ -1044,13 +1053,113 @@ notification_error_e notification_ipc_request_update(notification_h noti)
}
packet_unref(result);
} else {
- notification_ipc_is_master_ready();
+ NOTIFICATION_ERR("failed to receive answer(update)");
return NOTIFICATION_ERROR_SERVICE_NOT_READY;
}
return status;
}
+static int _notification_ipc_update_cb(pid_t pid, int handle, const struct packet *packet, void *data)
+{
+ int status = 0;
+ int id = NOTIFICATION_PRIV_ID_NONE;
+ result_cb_item *cb_item = (result_cb_item *)data;
+
+ if (cb_item == NULL) {
+ NOTIFICATION_ERR("Failed to get a callback item");
+ return NOTIFICATION_ERROR_INVALID_DATA;
+ }
+ s_info.server_cl_fd_ref_cnt = (s_info.server_cl_fd_ref_cnt <= 1) ? 0 : s_info.server_cl_fd_ref_cnt - 1;
+ if (s_info.server_cl_fd_ref_cnt <= 0) {
+ NOTIFICATION_DBG("REFCNT: %d (fd: %d)", s_info.server_cl_fd_ref_cnt, s_info.server_cl_fd);
+ int fd_temp = s_info.server_cl_fd;
+ s_info.server_cl_fd = -1;
+ com_core_packet_client_fini(fd_temp);
+ NOTIFICATION_DBG("FD(%d) finalized", fd_temp);
+ }
+
+ if (packet != NULL) {
+ if (packet_get(packet, "ii", &status, &id) != 2) {
+ NOTIFICATION_ERR("Failed to get a result packet");
+ status = NOTIFICATION_ERROR_IO;
+ }
+ }
+
+ if (cb_item->result_cb != NULL) {
+ cb_item->result_cb(id, status, cb_item->data);
+ }
+ free(cb_item);
+
+ return status;
+}
+
+notification_error_e notification_ipc_request_update_async(notification_h noti,
+ void (*result_cb)(int priv_id, int result, void *data), void *user_data)
+{
+ int ret = NOTIFICATION_ERROR_NONE;
+ int ret_con = 0;
+ struct packet *packet = NULL;
+ result_cb_item *cb_item = NULL;
+
+ packet = notification_ipc_make_packet_from_noti(noti, "update_noti", 1);
+ if (packet == NULL) {
+ ret = NOTIFICATION_ERROR_INVALID_DATA;
+ goto fail;
+ }
+
+ cb_item = calloc(1, sizeof(result_cb_item));
+ if (cb_item == NULL) {
+ ret = NOTIFICATION_ERROR_NO_MEMORY;
+ goto fail;
+ }
+
+ if (s_info.server_cl_fd < 0) {
+ com_core_packet_use_thread(1);
+ s_info.server_cl_fd = com_core_packet_client_init(s_info.socket_file, 0, NULL);
+ if (s_info.server_cl_fd < 0) {
+ NOTIFICATION_DBG("Failed to init client: %d", s_info.server_cl_fd);
+ ret = NOTIFICATION_ERROR_SERVICE_NOT_READY;
+ goto fail;
+ }
+ s_info.server_cl_fd_ref_cnt = 1;
+ } else {
+ s_info.server_cl_fd_ref_cnt++;
+ }
+
+ cb_item->result_cb = result_cb;
+ cb_item->data = user_data;
+
+ NOTIFICATION_INFO("Connection count:%d, fd:%d", s_info.server_cl_fd_ref_cnt, s_info.server_cl_fd);
+
+ ret_con = com_core_packet_async_send(s_info.server_cl_fd, packet, 0.0f,
+ _notification_ipc_update_cb, cb_item);
+ if (ret_con < 0) {
+ NOTIFICATION_ERR("Failed to request update, %d\n", ret_con);
+ s_info.server_cl_fd_ref_cnt = (s_info.server_cl_fd_ref_cnt <= 1) ? 0 : s_info.server_cl_fd_ref_cnt - 1;
+ if (s_info.server_cl_fd_ref_cnt <= 0) {
+ int fd_temp = s_info.server_cl_fd;
+ s_info.server_cl_fd = -1;
+ com_core_packet_client_fini(fd_temp);
+ NOTIFICATION_INFO("FD(%d) finalized", fd_temp);
+ }
+ ret = NOTIFICATION_ERROR_IO;
+ goto fail;
+ } else {
+ ret = NOTIFICATION_ERROR_NONE;
+ goto success;
+ }
+
+fail:
+ if (cb_item) free(cb_item);
+ NOTIFICATION_ERR("Err: %d\n", ret);
+
+success:
+ if (packet) packet_destroy(packet);
+
+ return ret;
+}
+
notification_error_e notification_ipc_request_refresh(void)
{
int status = 0;
@@ -1071,7 +1180,7 @@ notification_error_e notification_ipc_request_refresh(void)
}
packet_unref(result);
} else {
- notification_ipc_is_master_ready();
+ NOTIFICATION_ERR("failed to receive answer(refresh)");
return NOTIFICATION_ERROR_SERVICE_NOT_READY;
}
diff --git a/src/notification_ongoing.c b/src/notification_ongoing.c
index f248bc1..38fb585 100755
--- a/src/notification_ongoing.c
+++ b/src/notification_ongoing.c
@@ -70,8 +70,6 @@ notification_error_e notification_ongoing_update_progress(const char *caller_pkg
dbus_message_unref(signal);
if (ret) {
- NOTIFICATION_INFO("Send progress info : %s(%d) %.2f",
- caller_pkgname, priv_id, progress);
return NOTIFICATION_ERROR_NONE;
}
@@ -106,11 +104,8 @@ notification_error_e notification_ongoing_update_size(const char *caller_pkgname
DBUS_TYPE_INT32, &priv_id,
DBUS_TYPE_DOUBLE, &size,
DBUS_TYPE_INVALID);
- NOTIFICATION_INFO("arg...");
if (ret) {
ret = dbus_connection_send(connection, signal, NULL);
- NOTIFICATION_INFO("Send size info : %s(%d) %.2f",
- caller_pkgname, priv_id, size);
if (ret) {
dbus_connection_flush(connection);
@@ -165,8 +160,6 @@ notification_error_e notification_ongoing_update_content(const char *caller_pkgn
}
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);