#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"
-#endif
-
static struct info {
int server_fd;
+ int server_cl_fd;
+ int server_cl_fd_ref_cnt;
int client_fd;
const char *socket_file;
struct {
} server_cb;
int initialized;
int is_started_cb_set_svc;
- 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);
-static notification_error_e notification_ipc_monitor_deregister(void);
-static void _do_deffered_task(void);
-static void _master_started_cb_task(keynode_t *node, void *data);
+static Eina_Bool _do_deffered_task(void *data);
-/*!
- * functions to check state of master
+/*
+ * The concept of having to deffer a task till the "master" was
+ * started is now defunct since we use systemd to auto activate
+ * the service, with clients blissfully unaware of the state
+ * of the service at the time they attempt to use the socket.
+ *
+ * To enable backwards compatability we now setup an idle handler
+ * to cleanup all the deffered task. This keeps the call behavior
+ * as non-blocking and is true to the original spirit (i.e. run
+ * the task when the service is available)
*/
-static inline void _set_master_started_cb(vconf_callback_fn cb) {
- int ret = -1;
-
- ret = vconf_notify_key_changed(VCONFKEY_MASTER_STARTED,
- cb, NULL);
- if (ret != 0) {
- NOTIFICATION_ERR("failed to notify key(%s) : %d",
- VCONFKEY_MASTER_STARTED, ret);
- }
-}
-
-static inline void _unset_master_started_cb(vconf_callback_fn cb) {
- int ret = -1;
-
- ret = vconf_ignore_key_changed(VCONFKEY_MASTER_STARTED,
- cb);
- if (ret != 0) {
- NOTIFICATION_ERR("failed to notify key(%s) : %d",
- VCONFKEY_MASTER_STARTED, ret);
- }
-}
-
-int notification_ipc_is_master_ready(void)
-{
- int ret = -1, is_master_started = 0;
-
- ret = vconf_get_bool(VCONFKEY_MASTER_STARTED, &is_master_started);
- if (ret == 0 && is_master_started == 1) {
- NOTIFICATION_ERR("the master has been started");
- } else {
- is_master_started = 0;
- NOTIFICATION_ERR("the master has been stopped");
- }
-
- return is_master_started;
-}
notification_error_e
notification_ipc_add_deffered_task(
task_list *list_do = NULL;
task_list *list_temp = NULL;
- if (g_task_list == NULL) {
- return;
- }
-
- list_do = g_task_list;
- g_task_list = NULL;
- if (s_info.is_started_cb_set_task == 1) {
- _unset_master_started_cb(_master_started_cb_task);
- s_info.is_started_cb_set_task = 0;
- }
+
- while (list_do->prev != NULL) {
- list_do = list_do->prev;
- }
+ if (g_task_list) {
+ list_do = g_task_list;
+ g_task_list = NULL;
- while (list_do != NULL) {
- if (list_do->task_cb != NULL) {
- list_do->task_cb(list_do->data);
- NOTIFICATION_DBG("called:%p", list_do->task_cb);
- }
- list_temp = list_do->next;
- free(list_do);
- list_do = list_temp;
- }
-}
+ while (list_do->prev != NULL) {
+ list_do = list_do->prev;
+ }
-static void _master_started_cb_service(keynode_t *node,
- void *data) {
- int ret = NOTIFICATION_ERROR_NONE;
+ while (list_do != NULL) {
+ if (list_do->task_cb != NULL) {
+ list_do->task_cb(list_do->data);
+ NOTIFICATION_DBG("called:%p", list_do->task_cb);
+ }
+ list_temp = list_do->next;
+ free(list_do);
+ list_do = list_temp;
+ }
+ }
- if (notification_ipc_is_master_ready()) {
- NOTIFICATION_ERR("try to register a notification service");
- ret = notification_ipc_monitor_deregister();
- if (ret != NOTIFICATION_ERROR_NONE) {
- NOTIFICATION_ERR("failed to unregister a monitor");
- }
- ret = notification_ipc_monitor_register();
- if (ret != NOTIFICATION_ERROR_NONE) {
- NOTIFICATION_ERR("failed to register a monitor");
- }
- } else {
- NOTIFICATION_ERR("try to unregister a notification service");
- ret = notification_ipc_monitor_deregister();
- if (ret != NOTIFICATION_ERROR_NONE) {
- NOTIFICATION_ERR("failed to deregister a monitor");
- }
- }
-}
-
-static void _master_started_cb_task(keynode_t *node,
- void *data) {
-
- if (notification_ipc_is_master_ready()) {
- _do_deffered_task();
- }
+ return ECORE_CALLBACK_CANCEL;
}
/*!
return status;
}
- NOTIFICATION_ERR("failed to receive answer(delete)");
+
+ notification_error_e notification_ipc_noti_setting_property_set(const char *pkgname, const char *property, const char *value)
+ {
+ int status = 0;
+ int ret = 0;
+ struct packet *packet;
+ struct packet *result;
+
+ packet = packet_create("set_noti_property", "sss", pkgname, property, value);
+ result = com_core_packet_oneshot_send(NOTIFICATION_ADDR,
+ packet,
+ NOTIFICATION_IPC_TIMEOUT);
+ packet_destroy(packet);
+
+ if (result != NULL) {
+ if (packet_get(result, "ii", &status, &ret) != 2) {
+ NOTIFICATION_ERR("Failed to get a result packet");
+ packet_unref(result);
+ return NOTIFICATION_ERROR_IO;
+ }
+ packet_unref(result);
+ } else {
- NOTIFICATION_ERR("failed to receive answer(delete)");
+ return NOTIFICATION_ERROR_SERVICE_NOT_READY;
+ }
+
+ return status;
+ }
+
+ notification_error_e notification_ipc_noti_setting_property_get(const char *pkgname, const char *property, char **value)
+ {
+ int status = 0;
+ char *ret = NULL;
+ struct packet *packet;
+ struct packet *result;
+
+ packet = packet_create("get_noti_property", "ss", pkgname, property);
+ result = com_core_packet_oneshot_send(NOTIFICATION_ADDR,
+ packet,
+ NOTIFICATION_IPC_TIMEOUT);
+ packet_destroy(packet);
+
+ if (result != NULL) {
+ if (packet_get(result, "is", &status, &ret) != 2) {
+ NOTIFICATION_ERR("Failed to get a result packet");
+ packet_unref(result);
+ return NOTIFICATION_ERROR_IO;
+ }
+ if (status == NOTIFICATION_ERROR_NONE && ret != NULL) {
+ *value = strdup(ret);
+ }
+ packet_unref(result);
+ } else {
+ return NOTIFICATION_ERROR_SERVICE_NOT_READY;
+ }
+
+ return status;
+ }