diff options
author | Rusty Lynch <rusty.lynch@intel.com> | 2013-09-10 09:26:55 -0700 |
---|---|---|
committer | Rusty Lynch <rusty.lynch@intel.com> | 2013-09-18 16:32:53 -0700 |
commit | 22075fff68729c4decd90672091c3c4075982435 (patch) | |
tree | 94134bba3456f2c4284345b95b08044beabd2659 | |
parent | e8870a00bc1273a32bdf6c63dfa84e8c4b251a4c (diff) | |
download | notification-22075fff68729c4decd90672091c3c4075982435.tar.gz notification-22075fff68729c4decd90672091c3c4075982435.tar.bz2 notification-22075fff68729c4decd90672091c3c4075982435.zip |
Remove vconf ipc based logic for syncronizing with mastersubmit/tizen_ivi_release/20131120.025937submit/tizen_ivi_release/20131120.021413submit/tizen_ivi_genivi/20140131.060719submit/tizen/20130918.233920ivi_oct_m2accepted/tizen_ivi_release/20131120.050538accepted/tizen/ivi/genivi/20140131.061721accepted/tizen/20130920.205126accepted/tizen/20130918.235413accepted/tizen/20130918.235403accepted/tizen/20130918.235338tizen_ivi_releasetizen_ivi_geniviaccepted/tizen/ivi/releaseaccepted/tizen/ivi/genivi
We now have systemd auto activation support for whatever process
provides the notification socket. As a result we can now greatly
simplify the client logic that was attempting to provide the same
capability as socket activation in that the client was able to
register with the server before the server was actually started.
Change-Id: I93a8af60cfba30f775cfa0af90c8c267c9678819
Signed-off-by: Rusty Lynch <rusty.lynch@intel.com>
-rwxr-xr-x | CMakeLists.txt | 3 | ||||
-rwxr-xr-x | include/notification_ipc.h | 1 | ||||
-rw-r--r-- | packaging/notification.changes | 4 | ||||
-rwxr-xr-x | packaging/notification.spec | 11 | ||||
-rwxr-xr-x | src/notification.c | 6 | ||||
-rwxr-xr-x | src/notification_ipc.c | 189 |
6 files changed, 57 insertions, 157 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index fba58f1..a7ab9c8 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,6 @@ INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED sqlite3 db-util - vconf bundle dlog ail @@ -42,6 +41,8 @@ pkg_check_modules(pkgs REQUIRED dbus-1 dbus-glib-1 com-core + ecore + eina ) FOREACH(flag ${pkgs_CFLAGS}) diff --git a/include/notification_ipc.h b/include/notification_ipc.h index 4dd2656..29f5b49 100755 --- a/include/notification_ipc.h +++ b/include/notification_ipc.h @@ -45,7 +45,6 @@ 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); -int notification_ipc_is_master_ready(void); notification_error_e notification_ipc_add_deffered_task(void (*deffered_task_cb)(void *data), void *user_data); notification_error_e notification_ipc_del_deffered_task(void (*deffered_task_cb)(void *data)); diff --git a/packaging/notification.changes b/packaging/notification.changes index 53a284b..ffb856b 100644 --- a/packaging/notification.changes +++ b/packaging/notification.changes @@ -1,3 +1,7 @@ +* Wed Sep 18 2013 Rusty Lynch <rusty.lynch@intel.com> accepted/tizen/20130918.224851@3d7a770 +- Remove vconf ipc based logic for syncronizing with master +- Fix rpm-lint errors + * Wed Jun 12 2013 Baptiste DURAND <baptiste.durand@eurogiciel.fr> accepted/tizen/20130602.020356@59093a0 - Replace manifest with default floor diff --git a/packaging/notification.spec b/packaging/notification.spec index 7a0ffcd..076308f 100755 --- a/packaging/notification.spec +++ b/packaging/notification.spec @@ -1,15 +1,14 @@ Name: notification -Summary: notification library +Summary: Notification Library Version: 0.2.3 Release: 1 -Group: Applications/Libraries +Group: System/API License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Source1001: notification.manifest BuildRequires: pkgconfig(sqlite3) BuildRequires: pkgconfig(db-util) BuildRequires: pkgconfig(heynoti) -BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(dlog) @@ -18,6 +17,8 @@ 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 @@ -25,7 +26,7 @@ Requires(post): /usr/bin/sqlite3 Requires(postun): /sbin/ldconfig %description -Notificaiton library. +Client library for sending notifications. %prep %setup -q @@ -37,7 +38,7 @@ Group: Development/Applications Requires: %{name} = %{version}-%{release} %description devel -Notificaiton library (devel). +Development files needed to build software that needs to system a system notification. %build %cmake . diff --git a/src/notification.c b/src/notification.c index ae82b03..8c85a90 100755 --- a/src/notification.c +++ b/src/notification.c @@ -2943,7 +2943,11 @@ void notification_call_changed_cb(notification_op *op_list, int op_num) EXPORT_API int notification_is_service_ready(void) { - return notification_ipc_is_master_ready(); + /* + * The notification service is now socket activated so as far + * as clients are concerned it is always ready + */ + return 1; } EXPORT_API notification_error_e diff --git a/src/notification_ipc.c b/src/notification_ipc.c index 0d5db8a..9ac5e3f 100755 --- a/src/notification_ipc.c +++ b/src/notification_ipc.c @@ -19,13 +19,13 @@ * */ +#include <Ecore.h> +#include <Eina.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <errno.h> -#include <vconf.h> - #include <packet.h> #include <com-core.h> #include <com-core_packet.h> @@ -38,10 +38,6 @@ #define NOTIFICATION_IPC_TIMEOUT 1.0 -#if !defined(VCONFKEY_MASTER_STARTED) -#define VCONFKEY_MASTER_STARTED "memory/data-provider-master/started" -#endif - static struct info { int server_fd; int client_fd; @@ -52,14 +48,12 @@ static struct info { } server_cb; int initialized; int is_started_cb_set_svc; - int is_started_cb_set_task; } s_info = { .server_fd = -1, .client_fd = -1, .socket_file = NOTIFICATION_ADDR, .initialized = 0, .is_started_cb_set_svc = 0, - .is_started_cb_set_task = 0, }; typedef struct _task_list task_list; @@ -73,50 +67,19 @@ struct _task_list { 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( @@ -133,11 +96,6 @@ notification_ipc_add_deffered_task( return NOTIFICATION_ERROR_NO_MEMORY; } - if (s_info.is_started_cb_set_task == 0) { - _set_master_started_cb(_master_started_cb_task); - s_info.is_started_cb_set_task = 1; - } - list_new->next = NULL; list_new->prev = NULL; @@ -156,6 +114,9 @@ notification_ipc_add_deffered_task( list->next = list_new; list_new->prev = list; } + + ecore_idler_add(_do_deffered_task, NULL); + return NOTIFICATION_ERROR_NONE; } @@ -199,10 +160,7 @@ notification_ipc_del_deffered_task( free(list_del); if (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; - } + ecore_idler_del(_do_deffered_task); } return NOTIFICATION_ERROR_NONE; @@ -213,59 +171,30 @@ notification_ipc_del_deffered_task( return NOTIFICATION_ERROR_INVALID_DATA; } -static void _do_deffered_task(void) { +static Eina_Bool _do_deffered_task(void *data) { 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; - } - - 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; - } -} - -static void _master_started_cb_service(keynode_t *node, - void *data) { - int ret = NOTIFICATION_ERROR_NONE; - - if (notification_ipc_is_master_ready()) { - ret = notification_ipc_monitor_register(); - if (ret != NOTIFICATION_ERROR_NONE) { - NOTIFICATION_ERR("failed to register a monitor"); - } - } else { - 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(); - } + if (g_task_list) { + list_do = g_task_list; + g_task_list = NULL; + + while (list_do->prev != NULL) { + list_do = list_do->prev; + } + + 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; + } + } + + return ECORE_CALLBACK_CANCEL; } /*! @@ -808,10 +737,7 @@ static int _handler_service_register(pid_t pid, int handle, const struct packet return ret; } -/*! - * functions to initialize and register a monitor - */ -static notification_error_e notification_ipc_monitor_register(void) +notification_error_e notification_ipc_monitor_init(void) { int ret; struct packet *packet; @@ -877,7 +803,7 @@ static notification_error_e notification_ipc_monitor_register(void) return ret; } -notification_error_e notification_ipc_monitor_deregister(void) +notification_error_e notification_ipc_monitor_fini(void) { if (s_info.initialized == 0) { return NOTIFICATION_ERROR_NONE; @@ -891,36 +817,6 @@ notification_error_e notification_ipc_monitor_deregister(void) return NOTIFICATION_ERROR_NONE; } -notification_error_e notification_ipc_monitor_init(void) -{ - int ret = NOTIFICATION_ERROR_NONE; - - if (notification_ipc_is_master_ready()) { - ret = notification_ipc_monitor_register(); - } - - if (s_info.is_started_cb_set_svc == 0) { - _set_master_started_cb(_master_started_cb_service); - s_info.is_started_cb_set_svc = 1; - } - - return ret; -} - -notification_error_e notification_ipc_monitor_fini(void) -{ - int ret = NOTIFICATION_ERROR_NONE; - - if (s_info.is_started_cb_set_svc == 1) { - _unset_master_started_cb(_master_started_cb_service); - s_info.is_started_cb_set_svc = 0; - } - - ret = notification_ipc_monitor_deregister(); - - return ret; -} - /*! * functions to request the service */ @@ -955,7 +851,6 @@ notification_error_e notification_ipc_request_insert(notification_h noti, int *p } packet_unref(result); } else { - notification_ipc_is_master_ready(); return NOTIFICATION_ERROR_SERVICE_NOT_READY; } @@ -987,7 +882,6 @@ notification_error_e notification_ipc_request_delete_single(notification_type_e } packet_unref(result); } else { - notification_ipc_is_master_ready(); return NOTIFICATION_ERROR_SERVICE_NOT_READY; } @@ -1016,7 +910,6 @@ 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(); return NOTIFICATION_ERROR_SERVICE_NOT_READY; } @@ -1044,7 +937,6 @@ notification_error_e notification_ipc_request_update(notification_h noti) } packet_unref(result); } else { - notification_ipc_is_master_ready(); return NOTIFICATION_ERROR_SERVICE_NOT_READY; } @@ -1071,7 +963,6 @@ notification_error_e notification_ipc_request_refresh(void) } packet_unref(result); } else { - notification_ipc_is_master_ready(); return NOTIFICATION_ERROR_SERVICE_NOT_READY; } |