Use gdbus instead of dbus-glib 00/57300/1 accepted/tizen/mobile/20160119.043317 accepted/tizen/tv/20160119.043344 accepted/tizen/wearable/20160119.043408 submit/tizen/20160119.013756
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 19 Jan 2016 00:26:11 +0000 (09:26 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 19 Jan 2016 00:30:05 +0000 (09:30 +0900)
Change-Id: I457f0b662fcbb24acfd7251b903aaee906955300
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
CMakeLists.txt
inc/sigchild.h
packaging/launchpad.spec

index 0eccf72..a9e71ec 100755 (executable)
@@ -8,10 +8,10 @@ INCLUDE(FindPkgConfig)
 PKG_CHECK_MODULES(${this_target_pool} REQUIRED
        dlog
        libsystemd-daemon
-       dbus-glib-1
        vconf
        security-manager
        bundle
+       gio-2.0
        )
 
 FOREACH(flag ${${this_target_pool}_CFLAGS})
index fc26343..9b08ec1 100644 (file)
  * limitations under the License.
  */
 
-#include <dbus/dbus.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/signalfd.h>
 #include <dirent.h>
+#include <gio/gio.h>
 
 #define AUL_DBUS_PATH                  "/aul/dbus_handler"
 #define AUL_DBUS_SIGNAL_INTERFACE      "org.tizen.aul.signal"
 #define AUL_DBUS_APPDEAD_SIGNAL                "app_dead"
 #define AUL_DBUS_APPLAUNCH_SIGNAL      "app_launch"
 
-static DBusConnection *bus = NULL;
+static GDBusConnection *bus = NULL;
 static sigset_t oldmask;
 
-static inline void __socket_garbage_collector()
+static inline void __socket_garbage_collector(void)
 {
        DIR *dp;
        struct dirent *dentry;
@@ -45,8 +45,8 @@ static inline void __socket_garbage_collector()
 
                snprintf(tmp, MAX_LOCAL_BUFSZ, "/proc/%s", dentry->d_name);
                if (access(tmp, F_OK) < 0) {    /* Flawfinder: ignore */
-                       snprintf(tmp, MAX_LOCAL_BUFSZ, "/run/user/%d/%s", getuid(),
-                                dentry->d_name);
+                       snprintf(tmp, MAX_LOCAL_BUFSZ, "/run/user/%d/%s",
+                                       getuid(), dentry->d_name);
                        unlink(tmp);
                        continue;
                }
@@ -56,74 +56,73 @@ static inline void __socket_garbage_collector()
 
 static inline int __send_app_dead_signal_dbus(int dead_pid)
 {
-       DBusMessage *message;
+       GError *err = NULL;
 
-       // send over session dbus for other applications
+       /* send over session dbus for other applications */
        if (bus == NULL)
                return -1;
 
-       message = dbus_message_new_signal(AUL_DBUS_PATH,
-                                         AUL_DBUS_SIGNAL_INTERFACE,
-                                         AUL_DBUS_APPDEAD_SIGNAL);
-
-       if (dbus_message_append_args(message,
-                                    DBUS_TYPE_UINT32, &dead_pid,
-                                    DBUS_TYPE_INVALID) == FALSE) {
-               _E("Failed to load data error");
+       if (g_dbus_connection_emit_signal(bus,
+                                       NULL,
+                                       AUL_DBUS_PATH,
+                                       AUL_DBUS_SIGNAL_INTERFACE,
+                                       AUL_DBUS_APPDEAD_SIGNAL,
+                                       g_variant_new("(u)", dead_pid),
+                                       &err) == FALSE) {
+               _E("g_dbus_connection_emit_signal() is failed: %s",
+                                       err->message);
+               g_error_free(err);
                return -1;
        }
 
-       if (dbus_connection_send(bus, message, NULL) == FALSE) {
-               _E("dbus send error");
+       if (g_dbus_connection_flush_sync(bus, NULL, &err) == FALSE) {
+               _E("g_dbus_connection_flush_sync() is failed: %s",
+                                       err->message);
+               g_error_free(err);
                return -1;
        }
 
-       dbus_connection_flush(bus);
-       dbus_message_unref(message);
-
-       _D("send_app_dead_signal_dbus done (pid=%d)\n",dead_pid);
+       _D("send_app_dead_signal_dbus done (pid=%d)", dead_pid);
 
        return 0;
 }
 
 static inline int __send_app_launch_signal_dbus(int launch_pid, const char *app_id)
 {
-       DBusMessage *message;
+       GError *err = NULL;
 
        if (bus == NULL)
                return -1;
 
-       message = dbus_message_new_signal(AUL_DBUS_PATH,
-                                         AUL_DBUS_SIGNAL_INTERFACE,
-                                         AUL_DBUS_APPLAUNCH_SIGNAL);
-
-       if (dbus_message_append_args(message,
-                                    DBUS_TYPE_UINT32, &launch_pid,
-                                    DBUS_TYPE_STRING, &app_id,
-                                    DBUS_TYPE_INVALID) == FALSE) {
-               _E("Failed to load data error");
+       if (g_dbus_connection_emit_signal(bus,
+                                       NULL,
+                                       AUL_DBUS_PATH,
+                                       AUL_DBUS_SIGNAL_INTERFACE,
+                                       AUL_DBUS_APPLAUNCH_SIGNAL,
+                                       g_variant_new("(us)", launch_pid, app_id),
+                                       &err) == FALSE) {
+               _E("g_dbus_connection_emit_signal() is failed: %s",
+                                       err->message);
+               g_error_free(err);
                return -1;
        }
 
-       if (dbus_connection_send(bus, message, NULL) == FALSE) {
-               _E("dbus send error");
+       if (g_dbus_connection_flush_sync(bus, NULL, &err) == FALSE) {
+               _E("g_dbus_connection_flush_sync() is failed: %s",
+                                       err->message);
+               g_error_free(err);
                return -1;
        }
 
-       dbus_connection_flush(bus);
-       dbus_message_unref(message);
-
-       _D("send_app_launch_signal_dbus done (pid=%d)",launch_pid);
+       _D("send_app_launch_signal_dbus done (pid=%d)", launch_pid);
 
        return 0;
 }
 
-static int __sigchild_action(void *data)
+static int __sigchild_action(pid_t dead_pid)
 {
-       pid_t dead_pid;
        char buf[MAX_LOCAL_BUFSZ];
 
-       dead_pid = (pid_t)(intptr_t)data;
        if (dead_pid <= 0)
                goto end;
 
@@ -149,7 +148,7 @@ static void __launchpad_process_sigchld(struct signalfd_siginfo *info)
        while ((child_pid = waitpid(-1, &status, WNOHANG)) > 0) {
                if (child_pid == child_pgid)
                        killpg(child_pgid, SIGKILL);
-               __sigchild_action((void *)(intptr_t)child_pid);
+               __sigchild_action(child_pid);
        }
 
        return;
@@ -158,14 +157,12 @@ static void __launchpad_process_sigchld(struct signalfd_siginfo *info)
 static inline int __signal_init(void)
 {
        int i;
-       DBusError error;
+       GError *error = NULL;
 
-       dbus_error_init(&error);
-       dbus_threads_init_default();
-       bus = dbus_bus_get_private(DBUS_BUS_SESSION, &error);
+       bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
        if (!bus) {
-               _E("Failed to connect to the D-BUS daemon: %s", error.message);
-               dbus_error_free(&error);
+               _E("Failed to connect to the D-BUS daemon: %s", error->message);
+               g_error_free(error);
                return -1;
        }
 
@@ -223,7 +220,7 @@ static inline int __signal_unblock_sigchld(void)
 static inline int __signal_fini(void)
 {
        if (bus)
-               dbus_connection_close(bus);
+               g_object_unref(bus);
 
 #ifndef PRELOAD_ACTIVATE
        int i;
index 8d87f02..d2331da 100644 (file)
@@ -11,7 +11,7 @@ Source102:  launchpad-process-pool.socket
 
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(bundle)
-BuildRequires:  pkgconfig(dbus-glib-1)
+BuildRequires:  pkgconfig(gio-2.0)
 BuildRequires:  pkgconfig(ecore)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(libsystemd-daemon)