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
#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"
static struct info {
int server_fd;
+ int server_cl_fd;
+ int server_cl_fd_ref_cnt;
int client_fd;
const char *socket_file;
struct {
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,
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);
}
packet_unref(result);
} else {
- notification_ipc_is_master_ready();
+ NOTIFICATION_ERR("failed to receive answer(insert)");
return NOTIFICATION_ERROR_SERVICE_NOT_READY;
}
}
packet_unref(result);
} else {
- notification_ipc_is_master_ready();
+ NOTIFICATION_ERR("failed to receive answer(delete)");
return NOTIFICATION_ERROR_SERVICE_NOT_READY;
}
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;
}
}
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;
}
packet_unref(result);
} else {
- notification_ipc_is_master_ready();
+ NOTIFICATION_ERR("failed to receive answer(refresh)");
return NOTIFICATION_ERROR_SERVICE_NOT_READY;
}
dbus_message_unref(signal);
if (ret) {
- NOTIFICATION_INFO("Send progress info : %s(%d) %.2f",
- caller_pkgname, priv_id, progress);
return NOTIFICATION_ERROR_NONE;
}
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);
}
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);