From: youngsub ko Date: Wed, 23 Oct 2013 05:29:58 +0000 (+0900) Subject: Merge branch 'tizen_2.2' of ssh://review.tizendev.org:29418/apps/home/notification... X-Git-Tag: accepted/tizen/20131023.064031^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_ivi_panda;p=platform%2Fcore%2Fapi%2Fnotification.git Merge branch 'tizen_2.2' of ssh://review.tizendev.org:29418/apps/home/notification into work Conflicts: packaging/notification.spec src/notification_ipc.c --- abe7e659630557632e15ab7560855b535c4e8c5b diff --cc CMakeLists.txt index a7ab9c8,c69cbbf..bf6772f --- a/CMakeLists.txt +++ b/CMakeLists.txt @@@ -37,7 -40,7 +39,6 @@@ pkg_check_modules(pkgs REQUIRE dlog ail aul -- appsvc dbus-1 dbus-glib-1 com-core diff --cc packaging/notification.spec index 076308f,736314e..555c043 --- a/packaging/notification.spec +++ b/packaging/notification.spec @@@ -14,11 -14,9 +14,10 @@@ BuildRequires: pkgconfig(dbus-1 BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(ail) BuildRequires: pkgconfig(aul) --BuildRequires: pkgconfig(appsvc) BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(com-core) +BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(eina) BuildRequires: cmake Requires(post): /sbin/ldconfig @@@ -134,9 -140,10 +141,10 @@@ f chown :5000 /opt/dbspace/.notification.db chown :5000 /opt/dbspace/.notification.db-journal -chmod 640 /opt/dbspace/.notification.db -chmod 640 /opt/dbspace/.notification.db-journal +chmod 660 /opt/dbspace/.notification.db +chmod 660 /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 +vconftool set -t string memory/private/libstatus/message "" -i -g 5000 %postun -p /sbin/ldconfig diff --cc src/notification.c index 8c85a90,d82ebdc..27a440f --- a/src/notification.c +++ b/src/notification.c @@@ -30,7 -30,7 +30,6 @@@ #include #include --#include #include #include diff --cc src/notification_ipc.c index 9ac5e3f,e6a6fb1..1ea374a --- a/src/notification_ipc.c +++ b/src/notification_ipc.c @@@ -36,10 -36,16 +36,12 @@@ #include #include - #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 { @@@ -48,8 -54,11 +50,10 @@@ } 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, @@@ -65,21 -75,57 +69,26 @@@ 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); -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( @@@ -175,26 -226,61 +184,27 @@@ static Eina_Bool _do_deffered_task(voi 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; } /*! @@@ -968,3 -1194,62 +1080,60 @@@ notification_error_e notification_ipc_r return status; } + + 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 { - NOTIFICATION_ERR("failed to receive answer(delete)"); + return NOTIFICATION_ERROR_SERVICE_NOT_READY; + } + + return status; + }