replace ecore_main_loop to g_main_loop 61/96861/7 accepted/tizen/3.0/common/20161116.143511 accepted/tizen/3.0/ivi/20161116.022241 accepted/tizen/3.0/mobile/20161116.022018 accepted/tizen/3.0/tv/20161116.022124 accepted/tizen/3.0/wearable/20161116.022202 submit/tizen_3.0/20161115.024443
authorJiwoong Im <jiwoong.im@samsung.com>
Thu, 10 Nov 2016 11:27:03 +0000 (20:27 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Mon, 14 Nov 2016 05:28:39 +0000 (14:28 +0900)
Change-Id: I3b232d30a681beeacb45a213b1a084c6121af014
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
CMakeLists.txt
include/eventsystem_daemon.h
packaging/esd.spec
src/esd_main.c

index 6d1c5e7..58baf5b 100644 (file)
@@ -18,7 +18,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src)
 ### Required packages
 INCLUDE(FindPkgConfig)
 
-pkg_check_modules(pkgs REQUIRED dlog bundle pkgmgr-info glib-2.0 gio-2.0 appsvc aul ecore vconf libtzplatform-config libsystemd-daemon cynara-client cynara-creds-gdbus cynara-session security-manager)
+pkg_check_modules(pkgs REQUIRED dlog bundle pkgmgr-info glib-2.0 gio-2.0 appsvc aul vconf libtzplatform-config libsystemd-daemon cynara-client cynara-creds-gdbus cynara-session security-manager)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 773c315..9fa24ce 100644 (file)
@@ -42,6 +42,10 @@ extern "C" {
 
 #define ESD_BOOT_COMPLETED "/tmp/esd_ready"
 
+#define LOGIND_INTERFACE "org.freedesktop.login1.Manager"
+#define LOGIND_PATH "/org/freedesktop/login1"
+#define LOGIND_SIGNAL_USER_NEW "UserNew"
+
 int __esd_register_vconf_callbacks(void);
 
 #ifdef __cplusplus
index 06fb481..2c70904 100644 (file)
@@ -7,7 +7,6 @@ License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1:    esd.service
 BuildRequires:  cmake
-BuildRequires:  pkgconfig(ecore)
 BuildRequires:  pkgconfig(aul)
 BuildRequires:  pkgconfig(bundle)
 BuildRequires:  pkgconfig(dlog)
index cad7621..7c9e270 100644 (file)
@@ -1,10 +1,10 @@
 #include <stdio.h>
+#include <stdlib.h>
 #include <glib.h>
 #include <aul.h>
 #include <unistd.h>
 #include <ctype.h>
 #include <dlog.h>
-#include <Ecore.h>
 #include <gio/gio.h>
 #include <package-manager.h>
 #include <pkgmgr-info.h>
@@ -132,9 +132,6 @@ typedef struct esd_info {
 } esd_info_s;
 static esd_info_s s_info;
 
-static Ecore_Fd_Handler *g_fd_handler;
-sd_login_monitor *g_sd_monitor;
-
 typedef struct __esd_appctrl_cb_data {
        char *appid;
        char *pkgid;
@@ -1047,64 +1044,21 @@ static int __esd_get_user_items(void)
        return ES_R_OK;
 }
 
-static Eina_Bool __esd_fd_handler_func(void *data, Ecore_Fd_Handler *fd_handler)
+static void __esd_signal_handler(GDBusConnection *connection,
+               const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal_name,
+               GVariant *parameters,
+               gpointer user_data)
 {
-       if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) {
-               _I("fd read");
-               __esd_get_user_items();
-       }
-
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static int __esd_start_sd_monitor(void)
-{
-       int ret = 0;
-       int fd = 0;
-
-       ret = __esd_get_user_items();
-       if (ret < 0)
-               return ES_R_ERROR;
-
-       ret = sd_login_monitor_new("uid", &g_sd_monitor);
-       if (ret < 0) {
-               _E("sd_login_monitor_new error (%d)", ret);
-               return ES_R_ERROR;
-       }
-
-       fd = sd_login_monitor_get_fd(g_sd_monitor);
-       if (fd < 0) {
-               _E("sd_login_monitor_get_fd error");
-               sd_login_monitor_unref(g_sd_monitor);
-               return ES_R_ERROR;
-       }
-
-       g_fd_handler = ecore_main_fd_handler_add(fd,
-               (Ecore_Fd_Handler_Flags)(ECORE_FD_READ | ECORE_FD_ERROR),
-               __esd_fd_handler_func, NULL, NULL, NULL);
-       if (g_fd_handler == NULL) {
-               _E("fd_handler is NULL");
-               sd_login_monitor_unref(g_sd_monitor);
-               return ES_R_ERROR;
-       }
-
-       _I("setup sd-monitor done");
-
-       return ES_R_OK;
-}
-
-static int __esd_stop_sd_monitor(void)
-{
-       _I("stop sd_monitor");
-       if (g_fd_handler) {
-               ecore_main_fd_handler_del(g_fd_handler);
-               g_fd_handler = NULL;
-       }
-
-       sd_login_monitor_unref(g_sd_monitor);
-       g_sd_monitor = 0;
+       guint uid;
+       if (g_strcmp0(signal_name, LOGIND_SIGNAL_USER_NEW))
+               return;
 
-       return ES_R_OK;
+       g_variant_get(parameters, "(uo)", &uid, NULL);
+       _I("New user login(%d)", uid);
+       __esd_get_user_items();
 }
 
 static GDBusNodeInfo *introspection_data;
@@ -1698,6 +1652,7 @@ static void __esd_on_bus_acquired(GDBusConnection *connection,
        _I("bus acquired(%s)", name);
 
        guint reg_id = 0;
+       guint s_id = 0;
        GError *error = NULL;
 
        reg_id = g_dbus_connection_register_object(connection,
@@ -1709,6 +1664,22 @@ static void __esd_on_bus_acquired(GDBusConnection *connection,
                _E("g_dbus_connection_register_object error(%s)", error->message);
                g_error_free(error);
        }
+
+       s_id = g_dbus_connection_signal_subscribe(connection,
+                       NULL,
+                       LOGIND_INTERFACE,
+                       LOGIND_SIGNAL_USER_NEW,
+                       LOGIND_PATH,
+                       NULL,
+                       G_DBUS_SIGNAL_FLAGS_NONE,
+                       __esd_signal_handler,
+                       NULL,
+                       NULL);
+
+       if (s_id == 0) {
+               _E("g_dbus_connection_signal_subscribe() is failed.");
+               g_object_unref(connection);
+       }
 }
 
 static void __esd_on_name_acquired(GDBusConnection *connection,
@@ -1730,7 +1701,7 @@ static void __esd_on_name_acquired(GDBusConnection *connection,
 
        __esd_trusted_busname_print_items();
 
-       __esd_start_sd_monitor();
+       __esd_get_user_items();
 
        __esd_dbus_name_monitor(connection);
 }
@@ -2091,8 +2062,6 @@ static int __esd_init()
 #if (GLIB_MAJOR_VERSION <= 2 && GLIB_MINOR_VERSION < 36)
        g_type_init();
 #endif
-       ecore_init();
-
        __esd_init_cynara();
 
        client = pkgmgr_client_new(PC_LISTENING);
@@ -2150,8 +2119,6 @@ static void __esd_finalize(void)
 
        _D("esd finalize");
 
-       __esd_stop_sd_monitor();
-
        if (trusted_busname_table) {
                g_hash_table_iter_init(&iter, trusted_busname_table);
                while (g_hash_table_iter_next(&iter, &key, &value)) {
@@ -2224,8 +2191,11 @@ static void __esd_finalize(void)
 
 int main(int argc, char *argv[])
 {
+       GMainLoop *mainloop = NULL;
        _I("event system daemon : main()");
 
+       mainloop = g_main_loop_new(NULL, FALSE);
+
        if (__esd_init() != 0) {
                _E("ESD Initialization failed!");
                return ES_R_ERROR;
@@ -2237,13 +2207,13 @@ int main(int argc, char *argv[])
                return ES_R_ERROR;
        }
 
-       ecore_main_loop_begin();
+       g_main_loop_run(mainloop);
 
        _E("shutdown");
 
        __esd_finalize();
 
-       ecore_shutdown();
+       g_main_loop_unref(mainloop);
 
        return 0;
 }