Remove dbus-glib dependency 83/176283/1 accepted/tizen_5.0_unified accepted/tizen_5.5_unified accepted/tizen_5.5_unified_mobile_hotfix accepted/tizen_5.5_unified_wearable_hotfix accepted/tizen_6.0_unified accepted/tizen_6.0_unified_hotfix tizen_5.0 tizen_5.5 tizen_5.5_mobile_hotfix tizen_5.5_tv tizen_5.5_wearable_hotfix tizen_6.0 tizen_6.0_hotfix accepted/tizen/5.0/unified/20181102.020150 accepted/tizen/5.5/unified/20191031.025434 accepted/tizen/5.5/unified/mobile/hotfix/20201027.085050 accepted/tizen/5.5/unified/wearable/hotfix/20201027.114847 accepted/tizen/6.0/unified/20201030.120352 accepted/tizen/6.0/unified/hotfix/20201103.052143 accepted/tizen/6.5/unified/20211028.100138 accepted/tizen/unified/20180502.071115 submit/tizen/20180502.042150 submit/tizen_5.0/20181101.000003 submit/tizen_5.5/20191031.000003 submit/tizen_5.5_mobile_hotfix/20201026.185103 submit/tizen_5.5_wearable_hotfix/20201026.184303 submit/tizen_6.0/20201029.205103 submit/tizen_6.0_hotfix/20201102.192503 submit/tizen_6.0_hotfix/20201103.114803 submit/tizen_6.5/20211028.162201 tizen_5.5.m2_release tizen_6.0.m2_release tizen_6.5.m2_release
authorJihoon Jung <jh8801.jung@samsung.com>
Wed, 18 Apr 2018 05:07:57 +0000 (14:07 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Wed, 18 Apr 2018 05:08:23 +0000 (14:08 +0900)
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
Change-Id: I69d2edb5d573565cd1e685679eba6ac2d151ceb9

CMakeLists.txt
packaging/data-router.spec
src/dr-ipc.c
src/dr-main.c

index fac016d..6a66e76 100644 (file)
@@ -17,7 +17,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
 
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED glib-2.0
-                               dbus-glib-1
+                               gio-2.0
                                dlog vconf
                                )
 
index f3df732..a14cacf 100755 (executable)
@@ -7,8 +7,9 @@ License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1001:    data-router.manifest
 BuildRequires: cmake
+BuildRequires: pkgconfig(glib-2.0) >= 2.26
+BuildRequires: pkgconfig(gio-2.0)
 BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(dbus-glib-1)
 BuildRequires: pkgconfig(vconf)
 Requires(post): /usr/bin/vconftool
 
index 13e66a5..fb8ebf4 100644 (file)
  */
 
 
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <gio/gio.h>
 #include <glib.h>
 #include <stdlib.h>
 #include <string.h>
 #define BUF_SIZE               65536
 #define NETWORK_SERIAL_INTERFACE               "Capi.Network.Serial"
 
-DBusConnection *dbus_connection = NULL;
+#define DR_OBJECT_PATH "/DataRouter"
+#define DR_INTERFACE           "User.Data.Router.Introspectable"
+#define DR_SERIAL_STATUS_SIGNAL        "serial_status"
+#define DR_SERiAL_READY_SIGNAL "ready_for_serial"
+
+
+GDBusConnection *dbus_connection = NULL;
+static int serial_sig_id = -1;
+
 
 typedef enum {
        SERIAL_SESSION_DISCONNECTED,
@@ -62,87 +67,76 @@ typedef struct {
 
 dr_socket_info_t serial_session = {0, };
 
-
-static DBusHandlerResult __dbus_event_filter(DBusConnection *sys_conn,
-               DBusMessage *msg, void *data)
+static void __serial_ready_signal_cb(GDBusConnection *connection,
+                                       const gchar *sender_name,
+                                       const gchar *object_path,
+                                       const gchar *interface_name,
+                                       const gchar *signal_name,
+                                       GVariant *parameters,
+                                       gpointer user_data)
 {
-       const char *path = dbus_message_get_path(msg);
+       char *response = NULL;
 
-       if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL)
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       if (strcasecmp(signal_name, DR_SERiAL_READY_SIGNAL) == 0) {
+               g_variant_get(parameters, "(s)", &response);
 
-       if (path == NULL || strcmp(path, "/") == 0)
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
-       if (dbus_message_is_signal(msg, NETWORK_SERIAL_INTERFACE,
-                               "ready_for_serial")) {
-               char *res = NULL;
-               dbus_message_get_args(msg, NULL,
-                               DBUS_TYPE_STRING, &res,
-                               DBUS_TYPE_INVALID);
-
-               if (g_strcmp0(res, "OK") == 0)
-                       _send_serial_status_signal(SERIAL_OPENED);
-       } else {
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+               if (strcasecmp(response, "OK") == 0) _send_serial_status_signal(SERIAL_OPENED);
        }
-
-       return DBUS_HANDLER_RESULT_HANDLED;
 }
 
 gboolean _init_dbus_signal(void)
 {
-       DBG("+\n");
-       DBusGConnection *conn;
+       DBG("+");
        GError *err = NULL;
-       DBusError dbus_error;
 
-       conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
-       if (!conn) {
-               ERR(" DBUS get failed\n");
+       dbus_connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+       if (!dbus_connection) {
+               ERR(" DBUS get failed");
                g_error_free(err);
                return FALSE;
        }
-       dbus_connection = dbus_g_connection_get_connection(conn);
 
        /* Add the filter for network client functions */
-       dbus_error_init(&dbus_error);
-       dbus_connection_add_filter(dbus_connection, __dbus_event_filter, NULL, NULL);
-       dbus_bus_add_match(dbus_connection,
-                       "type=signal,interface=" NETWORK_SERIAL_INTERFACE
-                       ",member=ready_for_serial", &dbus_error);
-       if (dbus_error_is_set(&dbus_error)) {
-               ERR("Fail to add dbus filter signal\n");
-               dbus_error_free(&dbus_error);
-       }
+       serial_sig_id = g_dbus_connection_signal_subscribe(dbus_connection, NULL,
+                       NETWORK_SERIAL_INTERFACE,
+                       DR_SERiAL_READY_SIGNAL,
+                       NULL, NULL, 0,
+                       __serial_ready_signal_cb, NULL, NULL);
 
-       DBG("-\n");
+       DBG("-");
        return TRUE;
 }
 
+void _deinit_dbus_signal(void)
+{
+       if (serial_sig_id != -1)
+               g_dbus_connection_signal_unsubscribe(dbus_connection, serial_sig_id);
+
+       serial_sig_id = -1;
+
+       return;
+}
+
 void _send_serial_status_signal(int event)
 {
-       DBusMessage *msg = NULL;
-       if (dbus_connection == NULL) return;
-
-       msg = dbus_message_new_signal("/DataRouter",
-                       "User.Data.Router.Introspectable",
-                       "serial_status");
-       if (!msg) {
-               ERR("Unable to allocate D-Bus signal\n");
-               return;
+       GError *error = NULL;
+       gboolean ret;
+
+       ret =  g_dbus_connection_emit_signal(dbus_connection, NULL,
+                               DR_OBJECT_PATH, DR_INTERFACE,
+                               DR_SERIAL_STATUS_SIGNAL,
+                               g_variant_new("(i)", event),
+                               &error);
+       if (!ret) {
+               if (error != NULL) {
+                       ERR("D-Bus API failure: errCode[%x], message[%s]",
+                               error->code, error->message);
+                       g_clear_error(&error);
+               }
        }
 
-       if (!dbus_message_append_args(msg,
-                               DBUS_TYPE_INT32, &event,
-                               DBUS_TYPE_INVALID)) {
-               ERR("Event sending failed\n");
-               dbus_message_unref(msg);
-               return;
-       }
-       DBG("Send dbus signal : %s\n", event ? "SERIAL_OPENED" : "SERIAL_CLOSED");
-       dbus_connection_send(dbus_connection, msg, NULL);
-       dbus_message_unref(msg);
+       DBG("Send dbus signal : %s", event ? "SERIAL_OPENED" : "SERIAL_CLOSED");
+
        return;
 }
 
index 6c6951b..e6fd9b3 100755 (executable)
 
 
 #include <fcntl.h>
-#include <dbus/dbus-glib.h>
 #include <dirent.h>
-#include <dbus/dbus.h>
-
 
 #include "dr-modem.h"
 #include "dr-main.h"
@@ -103,8 +100,6 @@ int main(int argc, char *argv[])
        if (!g_thread_supported())
                g_thread_init(NULL);
 #endif
-       dbus_g_thread_init();
-
        _register_vconf_notification();
        _register_telephony_event();