From 9001ae1ed9abf297d83e95fcfb13444dc42e2f18 Mon Sep 17 00:00:00 2001 From: Hyuk Lee Date: Mon, 26 Sep 2016 16:50:16 +0900 Subject: [PATCH] Change the dbus-glib to gdbus in mobile Change-Id: I2cd23d086221a31f34f62e87dea15027a1947ab8 Signed-off-by: Hyuk Lee --- CMakeLists.txt | 3 + packaging/org.tizen.bt-syspopup.spec | 3 + src/bt-syspopup-m.c | 152 ++++++++++++++++++++--------------- src/bt-syspopup-m.h | 7 +- 4 files changed, 99 insertions(+), 66 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dbb2996..6464287 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,9 @@ pkg_check_modules(pkgs REQUIRED capi-media-player dlog dbus-glib-1 + dbus-1 + glib-2.0 + gio-2.0 ecore ecore-input ecore-imf diff --git a/packaging/org.tizen.bt-syspopup.spec b/packaging/org.tizen.bt-syspopup.spec index 645966a..06ad2d4 100644 --- a/packaging/org.tizen.bt-syspopup.spec +++ b/packaging/org.tizen.bt-syspopup.spec @@ -26,6 +26,9 @@ BuildRequires: pkgconfig(syspopup) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(dbus-1) +BuildRequires: pkgconfig(gio-2.0) +BuildRequires: pkgconfig(gio-unix-2.0) BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(edbus) BuildRequires: pkgconfig(feedback) diff --git a/src/bt-syspopup-m.c b/src/bt-syspopup-m.c index e923be8..2279704 100644 --- a/src/bt-syspopup-m.c +++ b/src/bt-syspopup-m.c @@ -40,6 +40,9 @@ #include #include #include +#include +#include +#include static void __bluetooth_delete_input_view(struct bt_popup_appdata *ad); static void __bluetooth_win_del(void *data); @@ -477,11 +480,11 @@ static void __bluetooth_remove_all_event(struct bt_popup_appdata *ad) switch (ad->event_type) { case BT_EVENT_PIN_REQUEST: - dbus_g_proxy_call_no_reply(ad->agent_proxy, - "ReplyPinCode", - G_TYPE_UINT, BT_AGENT_CANCEL, - G_TYPE_STRING, "", G_TYPE_INVALID, - G_TYPE_INVALID); + g_dbus_proxy_call(ad->agent_proxy, + "ReplyPinCode", + g_variant_new("(us)", BT_AGENT_CANCEL, ""), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, NULL, NULL); break; @@ -494,20 +497,21 @@ static void __bluetooth_remove_all_event(struct bt_popup_appdata *ad) case BT_EVENT_PASSKEY_CONFIRM_REQUEST: - dbus_g_proxy_call_no_reply(ad->agent_proxy, - "ReplyConfirmation", - G_TYPE_UINT, BT_AGENT_CANCEL, - G_TYPE_INVALID, G_TYPE_INVALID); + g_dbus_proxy_call(ad->agent_proxy, + "ReplyConfirmation", + g_variant_new("(u)", BT_AGENT_CANCEL), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, NULL, NULL); break; case BT_EVENT_PASSKEY_REQUEST: - dbus_g_proxy_call_no_reply(ad->agent_proxy, - "ReplyPasskey", - G_TYPE_UINT, BT_AGENT_CANCEL, - G_TYPE_STRING, "", G_TYPE_INVALID, - G_TYPE_INVALID); + g_dbus_proxy_call(ad->agent_proxy, + "ReplyPasskey", + g_variant_new("(us)", BT_AGENT_CANCEL, ""), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, NULL, NULL); break; @@ -517,10 +521,11 @@ static void __bluetooth_remove_all_event(struct bt_popup_appdata *ad) case BT_EVENT_AUTHORIZE_REQUEST: - dbus_g_proxy_call_no_reply(ad->agent_proxy, - "ReplyAuthorize", - G_TYPE_UINT, BT_AGENT_CANCEL, - G_TYPE_INVALID, G_TYPE_INVALID); + g_dbus_proxy_call(ad->agent_proxy, + "ReplyAuthorize", + g_variant_new("(u)", BT_AGENT_CANCEL), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, NULL, NULL); break; @@ -554,10 +559,11 @@ static void __bluetooth_remove_all_event(struct bt_popup_appdata *ad) case BT_EVENT_MESSAGE_REQUEST: case BT_EVENT_EXCHANGE_REQUEST: - dbus_g_proxy_call_no_reply(ad->agent_proxy, - "ReplyAuthorize", - G_TYPE_UINT, BT_AGENT_CANCEL, - G_TYPE_INVALID, G_TYPE_INVALID); + g_dbus_proxy_call(ad->agent_proxy, + "ReplyAuthorize", + g_variant_new("(u)", BT_AGENT_CANCEL), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, NULL, NULL); break; @@ -661,15 +667,17 @@ static void __bluetooth_input_request_cb(void *data, (response == BT_AGENT_ACCEPT) ? "Accept" : "Cancel"); if (ad->event_type == BT_EVENT_PIN_REQUEST) { - dbus_g_proxy_call_no_reply(ad->agent_proxy, - "ReplyPinCode", G_TYPE_UINT, response, - G_TYPE_STRING, convert_input_text, - G_TYPE_INVALID, G_TYPE_INVALID); + g_dbus_proxy_call(ad->agent_proxy, + "ReplyPinCode", + g_variant_new("(us)", response, convert_input_text), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, NULL, NULL); } else { - dbus_g_proxy_call_no_reply(ad->agent_proxy, - "ReplyPasskey", G_TYPE_UINT, response, - G_TYPE_STRING, convert_input_text, - G_TYPE_INVALID, G_TYPE_INVALID); + g_dbus_proxy_call(ad->agent_proxy, + "ReplyPasskey", + g_variant_new("(us)", response, convert_input_text), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, NULL, NULL); } __bluetooth_delete_input_view(ad); @@ -698,13 +706,17 @@ static void __bluetooth_passkey_confirm_cb(void *data, const char *event = elm_object_text_get(obj); if (!g_strcmp0(event, BT_STR_CONFIRM)) { - dbus_g_proxy_call_no_reply(ad->agent_proxy, "ReplyConfirmation", - G_TYPE_UINT, BT_AGENT_ACCEPT, - G_TYPE_INVALID, G_TYPE_INVALID); + g_dbus_proxy_call(ad->agent_proxy, + "ReplyConfirmation", + g_variant_new("(u)", BT_AGENT_ACCEPT), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, NULL, NULL); } else { - dbus_g_proxy_call_no_reply(ad->agent_proxy, "ReplyConfirmation", - G_TYPE_UINT, BT_AGENT_CANCEL, - G_TYPE_INVALID, G_TYPE_INVALID); + g_dbus_proxy_call(ad->agent_proxy, + "ReplyConfirmation", + g_variant_new("(u)", BT_AGENT_CANCEL), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, NULL, NULL); } evas_object_del(obj); @@ -872,9 +884,11 @@ static void __bluetooth_authorization_request_cb(void *data, reply_val = BT_AGENT_CANCEL; } - dbus_g_proxy_call_no_reply(ad->agent_proxy, "ReplyAuthorize", - G_TYPE_UINT, reply_val, - G_TYPE_INVALID, G_TYPE_INVALID); + g_dbus_proxy_call(ad->agent_proxy, + "ReplyAuthorize", + g_variant_new("(u)", reply_val), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, NULL, NULL); ad->make_trusted = FALSE; @@ -904,13 +918,17 @@ static void __bluetooth_push_authorization_request_cb(void *data, const char *event = elm_object_text_get(obj); if (!g_strcmp0(event, BT_STR_OK)) - dbus_g_proxy_call_no_reply(ad->obex_proxy, "ReplyAuthorize", - G_TYPE_UINT, BT_AGENT_ACCEPT, - G_TYPE_INVALID, G_TYPE_INVALID); + g_dbus_proxy_call(ad->obex_proxy, + "ReplyAuthorize", + g_variant_new("(u)", BT_AGENT_ACCEPT), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, NULL, NULL); else - dbus_g_proxy_call_no_reply(ad->obex_proxy, "ReplyAuthorize", - G_TYPE_UINT, BT_AGENT_CANCEL, - G_TYPE_INVALID, G_TYPE_INVALID); + g_dbus_proxy_call(ad->obex_proxy, + "ReplyAuthorize", + g_variant_new("(u)", BT_AGENT_CANCEL), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, NULL, NULL); __bluetooth_win_del(ad); } @@ -1302,15 +1320,18 @@ static void __bluetooth_input_mouseup_cb(void *data, return; if (ad->event_type == BT_EVENT_PIN_REQUEST) { - dbus_g_proxy_call_no_reply(ad->agent_proxy, - "ReplyPinCode", G_TYPE_UINT, response, - G_TYPE_STRING, convert_input_text, - G_TYPE_INVALID, G_TYPE_INVALID); + g_dbus_proxy_call(ad->agent_proxy, + "ReplyPinCode", + g_variant_new("(us)", response, convert_input_text), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, NULL, NULL); + } else { - dbus_g_proxy_call_no_reply(ad->agent_proxy, - "ReplyPasskey", G_TYPE_UINT, response, - G_TYPE_STRING, convert_input_text, - G_TYPE_INVALID, G_TYPE_INVALID); + g_dbus_proxy_call(ad->agent_proxy, + "ReplyPasskey", + g_variant_new("(us)", response, convert_input_text), + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, NULL, NULL); } __bluetooth_delete_input_view(ad); free(convert_input_text); @@ -1884,11 +1905,14 @@ static void __bluetooth_delete_input_view(struct bt_popup_appdata *ad) FN_END; } -static DBusGProxy* __bluetooth_create_agent_proxy(DBusGConnection *conn, +static GDBusProxy* __bluetooth_create_agent_proxy(GDBusConnection *conn, const char *path) { - return dbus_g_proxy_new_for_name(conn, "org.projectx.bt", path, - "org.bluez.Agent1"); + return g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE, + NULL, "org.projectx.bt", + path, + "org.bluez.Agent1", + NULL, NULL); } static void @@ -2449,14 +2473,14 @@ static Evas_Object *__bluetooth_create_win(const char *name) static void __bluetooth_session_init(struct bt_popup_appdata *ad) { - DBusGConnection *conn = NULL; + GDBusConnection *conn = NULL; GError *err = NULL; #if 0 g_type_init(); #endif - conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err); + conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL); if (!conn) { BT_ERR("ERROR: Can't get on system bus [%s]", @@ -2467,10 +2491,12 @@ static void __bluetooth_session_init(struct bt_popup_appdata *ad) ad->conn = conn; - ad->obex_proxy = dbus_g_proxy_new_for_name(conn, - "org.bluez.frwk_agent", - "/org/obex/ops_agent", - "org.openobex.Agent"); + ad->obex_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE, + NULL, "org.bluez.frwk_agent", + "/org/obex/ops_agent", + "org.openobex.Agent", + NULL, &err); + if (!ad->obex_proxy) BT_ERR("Could not create obex dbus proxy"); @@ -2553,7 +2579,7 @@ static void __bluetooth_terminate(void *data) __bluetooth_ime_hide(); if (ad->conn) { - dbus_g_connection_unref(ad->conn); + g_object_unref(ad->conn); ad->conn = NULL; } diff --git a/src/bt-syspopup-m.h b/src/bt-syspopup-m.h index d8973d3..8dbdec2 100644 --- a/src/bt-syspopup-m.h +++ b/src/bt-syspopup-m.h @@ -29,6 +29,7 @@ #include #include #include +#include #define BT_PACKAGE_NAME "org.tizen.bt-syspopup" @@ -283,10 +284,10 @@ struct bt_popup_appdata { Ecore_Timer *timer; - DBusGProxy *agent_proxy; - DBusGProxy *obex_proxy; + GDBusProxy *agent_proxy; + GDBusProxy *obex_proxy; E_DBus_Connection *EDBusHandle; - DBusGConnection *conn; + GDBusConnection *conn; int changed_mode; bt_rotate_mode_t rotation; -- 2.7.4