#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>
} 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;
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;
_I("bus acquired(%s)", name);
guint reg_id = 0;
+ guint s_id = 0;
GError *error = NULL;
reg_id = g_dbus_connection_register_object(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,
__esd_trusted_busname_print_items();
- __esd_start_sd_monitor();
+ __esd_get_user_items();
__esd_dbus_name_monitor(connection);
}
#if (GLIB_MAJOR_VERSION <= 2 && GLIB_MINOR_VERSION < 36)
g_type_init();
#endif
- ecore_init();
-
__esd_init_cynara();
client = pkgmgr_client_new(PC_LISTENING);
_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)) {
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;
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;
}