summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJihoon Jung <jh8801.jung@samsung.com>2018-04-18 14:07:57 +0900
committerJihoon Jung <jh8801.jung@samsung.com>2018-04-18 14:08:23 +0900
commit119dee6d9a6c876ee00ebc70ff867b4c14a85053 (patch)
tree215ce0ab6895c916d7d8b907844878c64a318a0a
parent9c858c87affdde8f4ec87fb41bfe450855e89b5c (diff)
downloaddata-router-tizen_5.5.tar.gz
data-router-tizen_5.5.tar.bz2
data-router-tizen_5.5.zip
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com> Change-Id: I69d2edb5d573565cd1e685679eba6ac2d151ceb9
-rw-r--r--CMakeLists.txt2
-rwxr-xr-xpackaging/data-router.spec3
-rw-r--r--src/dr-ipc.c120
-rwxr-xr-xsrc/dr-main.c5
4 files changed, 60 insertions, 70 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fac016d..6a66e76 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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
)
diff --git a/packaging/data-router.spec b/packaging/data-router.spec
index f3df732..a14cacf 100755
--- a/packaging/data-router.spec
+++ b/packaging/data-router.spec
@@ -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
diff --git a/src/dr-ipc.c b/src/dr-ipc.c
index 13e66a5..fb8ebf4 100644
--- a/src/dr-ipc.c
+++ b/src/dr-ipc.c
@@ -21,10 +21,7 @@
*/
-
-#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>
@@ -44,7 +41,15 @@
#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;
}
diff --git a/src/dr-main.c b/src/dr-main.c
index 6c6951b..e6fd9b3 100755
--- a/src/dr-main.c
+++ b/src/dr-main.c
@@ -22,10 +22,7 @@
#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();