Cody sync.: merge tizen 2.4 code from spin git 68/40668/1
authorseungku kim <seungku.kim@samsung.com>
Fri, 5 Jun 2015 06:27:12 +0000 (15:27 +0900)
committerseungku kim <seungku.kim@samsung.com>
Fri, 5 Jun 2015 06:28:11 +0000 (15:28 +0900)
---------------------------------------------------------
commit 423c7287ecde33358e7fcb97ca4ed6d35ea5285b
Author: Taejin Woo <tt.woo@samsung.com>
Date:   Fri Jun 5 13:39:08 2015 +0900

    Sync the vconf label from slp

    Change-Id: Id1cfe6ed873c21df05356207834f6d8017fb7c2e
Signed-off-by: Taejin Woo <tt.woo@samsung.com>
---------------------------------------------------------

Change-Id: I12b5952695a4d6848fd74b93f3750c08b036df84

107 files changed:
bluetooth-frwk-core.manifest [new file with mode: 0644]
bluetooth-frwk-test.manifest [new file with mode: 0644]
bluetooth-frwk.manifest [new file with mode: 0644]
bluetooth_log_dump.sh [new file with mode: 0644]
bt-api/CMakeLists.txt
bt-api/TFX79AA.tmp [deleted file]
bt-api/TFXF5A4.tmp [deleted file]
bt-api/bluetooth-api.pc.in
bt-api/bt-adapter-le.c
bt-api/bt-adapter.c
bt-api/bt-audio.c
bt-api/bt-common.c
bt-api/bt-device.c
bt-api/bt-event-handler.c
bt-api/bt-gatt-client.c
bt-api/bt-gatt-service.c
bt-api/bt-gatt.c [deleted file]
bt-api/bt-hdp.c
bt-api/bt-hid-device.c [new file with mode: 0644]
bt-api/bt-mdm.c [deleted file]
bt-api/bt-obex-server.c
bt-api/bt-request-sender.c
bt-api/bt-rfcomm-client.c
bt-api/bt-rfcomm-server.c
bt-api/bt-service-api.pc.in
bt-api/bt-telephony.c
bt-api/bt-telephony.xml [deleted file]
bt-api/include/bt-common.h
bt-api/include/bt-mdm.h [deleted file]
bt-core/CMakeLists.txt
bt-core/bluetooth-frwk-core [changed mode: 0755->0644]
bt-core/bluetooth-frwk-core.conf [deleted file]
bt-core/bt-core-adapter.c
bt-core/bt-core-adapter.xml [changed mode: 0755->0644]
bt-core/bt-core-dbus-handler.c
bt-core/bt-core-main.c
bt-core/bt-core-noti-handler.c
bt-core/bt-request-service.xml [changed mode: 0755->0644]
bt-core/include/bt-core-adapter.h
bt-core/include/bt-core-dbus-handler.h
bt-core/org.projectx.bt_core.service [changed mode: 0755->0644]
bt-service/CMakeLists.txt
bt-service/bluetooth-frwk-service [changed mode: 0755->0644]
bt-service/bluetooth-frwk-service.conf.in [deleted file]
bt-service/bluetooth-frwk-service.service [deleted file]
bt-service/bt-request-handler.c
bt-service/bt-service-adapter-le.c
bt-service/bt-service-adapter.c
bt-service/bt-service-agent.c
bt-service/bt-service-audio.c
bt-service/bt-service-avrcp-controller.c [new file with mode: 0644]
bt-service/bt-service-avrcp.c
bt-service/bt-service-common.c
bt-service/bt-service-device.c
bt-service/bt-service-event-receiver.c
bt-service/bt-service-event-sender.c
bt-service/bt-service-gap-agent.c
bt-service/bt-service-gap-agent.xml
bt-service/bt-service-headset-connection.c
bt-service/bt-service-hid.c
bt-service/bt-service-main.c
bt-service/bt-service-mdm.c [deleted file]
bt-service/bt-service-network.c
bt-service/bt-service-obex-agent.c
bt-service/bt-service-obex-agent.xml
bt-service/bt-service-obex-server.c
bt-service/bt-service-oob.c
bt-service/bt-service-opp-client.c
bt-service/bt-service-pbap.c
bt-service/bt-service-rfcomm-client.c
bt-service/bt-service-rfcomm-server.c
bt-service/bt-service-util.c
bt-service/include/bt-request-handler.h
bt-service/include/bt-service-adapter-le.h
bt-service/include/bt-service-adapter.h
bt-service/include/bt-service-agent.h
bt-service/include/bt-service-audio.h
bt-service/include/bt-service-avrcp-controller.h [moved from bt-service/include/bt-service-mdm.h with 51% similarity]
bt-service/include/bt-service-avrcp.h
bt-service/include/bt-service-common.h
bt-service/include/bt-service-device.h
bt-service/include/bt-service-event.h
bt-service/include/bt-service-gap-agent.h
bt-service/include/bt-service-obex-agent.h
bt-service/include/bt-service-opp-client.h
bt-service/include/bt-service-pbap.h
bt-service/include/bt-service-rfcomm-server.h
bt-service/include/bt-service-util.h
bt-service/mobile/stack_info [changed mode: 0755->0644]
bt-service/org.projectx.bt.service.in [deleted file]
bt-service/wearable/stack_info [changed mode: 0755->0644]
include/bluetooth-api.h
include/bluetooth-audio-api.h
include/bluetooth-hid-api.h
include/bluetooth-media-control.h
include/bluetooth-telephony-api.h
include/bt-internal-types.h
packaging/bluetooth-frwk-wearable.service
packaging/bluetooth-frwk.manifest [deleted file]
packaging/bluetooth-frwk.spec
packaging/bt-icon.png [deleted file]
test/CMakeLists.txt
test/bluetooth-frwk-test.c
test/gatt-test/TFXF4E2.tmp [deleted file]
test/gatt-test/bluetooth-gatt-test.c
test/handsfree/bluetooth-hf-test.c
test/le-adv/bluetooth-advertising-test.c

diff --git a/bluetooth-frwk-core.manifest b/bluetooth-frwk-core.manifest
new file mode 100644 (file)
index 0000000..c2a794d
--- /dev/null
@@ -0,0 +1,22 @@
+<manifest>
+       <define>
+               <domain name="bt-core"/>
+
+       <request>
+               <smack request="dbus" type="rwx"/>
+               <smack request="aul::launch" type="x"/>
+       </request>
+       <permit>
+               <smack permit="dbus" type="rwx"/>
+       </permit>
+       </define>
+       <assign>
+               <filesystem path="/etc/init.d/bluetooth-frwk-core" label="_" exec_label="none" />
+               <filesystem path="/usr/share/dbus-1/system-services/org.projectx.bt_core.service" label="_" exec_label="none" />
+               <filesystem path="/usr/bin/bt-core" label="_" exec_label="none"/>
+       </assign>
+
+       <request>
+               <domain name="bt-core"/>
+       </request>
+</manifest>
diff --git a/bluetooth-frwk-test.manifest b/bluetooth-frwk-test.manifest
new file mode 100644 (file)
index 0000000..5f737de
--- /dev/null
@@ -0,0 +1,13 @@
+<manifest>
+    <define>
+        <domain name="bt-frwk-test"/>
+       <request>
+               <smack request="bt-service::manager" type="w"/>
+               <smack request="bt-service::admin" type="w"/>
+               <smack request="bt-service::gap" type="w"/>
+       </request>
+    </define>
+    <request>
+        <domain name="bt-frwk-test"/>
+    </request>
+</manifest>
diff --git a/bluetooth-frwk.manifest b/bluetooth-frwk.manifest
new file mode 100644 (file)
index 0000000..fa6c8a6
--- /dev/null
@@ -0,0 +1,50 @@
+<manifest>
+       <define>
+               <domain name="bt-service"/>
+               <provide>
+                       <label name="bt-service::public"/>
+                       <label name="bt-service::platform"/>
+               </provide>
+               <request>
+                       <smack request="system::vconf" type="rwxat"/>
+                       <smack request="system::vconf_system" type="rw"/>
+                       <smack request="system::vconf_setting" type="rw"/>
+                       <smack request="system::share" type="rwxat"/>
+                       <smack request="system::ext_storage" type="rwxat"/>
+                       <smack request="system::media" type="rwxat"/>
+                       <smack request="system::homedir" type="rwxat"/>
+                       <smack request="dbus" type="rwx"/>
+                       <smack request="xorg" type="rwx"/>
+                       <smack request="device::app_logging" type="w"/>
+                       <smack request="syspopup::db" type="rwx"/>
+                       <smack request="device::dialout" type="rw"/>
+                       <smack request="sys-assert::core" type="rwxat"/>
+                       <smack request="alarm-server::alarm" type="w"/>
+                       <smack request="aul::launch" type="x"/>
+                       <smack request="security-server::api-cookie-check" type="w"/>
+                       <smack request="connman::get" type="rwx"/>
+                       <smack request="connman::set" type="rwx"/>
+                       <smack request="connman::profile" type="rwx"/>
+                       <smack request="telephony_framework::api_ps_public" type="rw"/>
+                       <smack request="bt-service::public" type="w"/>
+                       <smack request="bt-service::platform" type="w"/>
+                       <smack request="tizen::vconf::platform::r" type="rw"/>
+                       <smack request="tizen::vconf::platform::rw" type="rw"/>
+                       <smack request="tizen::vconf::public::r::platform::rw" type="rw"/>
+               </request>
+               <permit>
+                       <smack permit="dbus" type="rx"/>
+               </permit>
+       </define>
+       <assign>
+               <filesystem path="/etc/init.d/bluetooth-frwk" label="_" exec_label="none" />
+               <filesystem path="/usr/share/dbus-1/system-services/org.projectx.bt.service" label="_" exec_label="none" />
+               <filesystem path="/opt/etc/dump.d/module.d/bluetooth_log_dump.sh" label="_" exec_label="none"/>
+               <filesystem path="/usr/etc/bluetooth" label="_" exec_label="none"/>
+               <filesystem path="/usr/etc/bluetooth/stack_info" label="_" exec_label="none"/>
+               <filesystem path="/opt/var/lib/bluetooth" label="_" exec_label="none"/>
+       </assign>
+       <request>
+               <domain name="bt-service"/>
+       </request>
+</manifest>
diff --git a/bluetooth_log_dump.sh b/bluetooth_log_dump.sh
new file mode 100644 (file)
index 0000000..073e407
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+#--------------------------------------
+#    bluetooth
+#--------------------------------------
+
+BLUETOOTH_DEBUG=${1}/bluetooth
+PREV_PWD=${PWD}
+BT_DATA_DIR=/var/lib/bluetooth
+
+mkdir -p ${BLUETOOTH_DEBUG}
+
+if [ -e ${BT_DATA_DIR} ]
+then
+       cd ${BT_DATA_DIR}
+       /bin/tar -cvzf ${BLUETOOTH_DEBUG}/bt_log.tar.gz *
+fi
+
+cd ${PREV_PWD}
index 1991f5b..2ea3040 100644 (file)
@@ -22,6 +22,7 @@ bt-event-handler.c
 bt-scmst.c
 bt-gatt-service.c
 bt-pbap.c
+bt-hid-device.c
 bt-gatt-client.c)
 
 SET(HEADERS
@@ -34,11 +35,7 @@ bluetooth-scmst-api.h)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 SET(EXEC_PREFIX "\${prefix}")
-IF("${ARCH}" STREQUAL "aarch64")
-SET(LIBDIR "\${prefix}/lib64")
-ELSE()
 SET(LIBDIR "\${prefix}/lib")
-ENDIF("${ARCH}" STREQUAL "aarch64")
 SET(INCLUDEDIR "\${prefix}/include")
 SET(VERSION_MAJOR 1)
 SET(VERSION ${VERSION_MAJOR}.0.0)
@@ -56,10 +53,10 @@ SET(PKG_MODULES
        gmodule-2.0
        vconf
        libxml-2.0
+       security-server
        glib-2.0
        gio-2.0
        gio-unix-2.0
-       syspopup-caller
 )
 
 INCLUDE(FindPkgConfig)
@@ -88,15 +85,14 @@ EXEC_PROGRAM("${MARSHALTOOL}" ARGS "--prefix=marshal ${CMAKE_CURRENT_SOURCE_DIR}
 FIND_PROGRAM(DBUS_BINDING_TOOL NAMES dbus-binding-tool)
 EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=bt ${CMAKE_CURRENT_SOURCE_DIR}/bt-request-service.xml --mode=glib-client --output=${CMAKE_CURRENT_SOURCE_DIR}/include/bt-request-service.h")
 EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=bluetooth_gatt ${CMAKE_CURRENT_SOURCE_DIR}/bt-gatt.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/include/bt-gatt-glue.h")
-EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=bluetooth_telephony_method ${CMAKE_CURRENT_SOURCE_DIR}/bt-telephony.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/include/bt-telephony-glue.h")
 
 ADD_LIBRARY(bluetooth-api SHARED ${SRCS})
 SET_TARGET_PROPERTIES(bluetooth-api PROPERTIES SOVERSION ${VERSION_MAJOR})
 SET_TARGET_PROPERTIES(bluetooth-api PROPERTIES VERSION ${VERSION})
 TARGET_LINK_LIBRARIES(bluetooth-api ${packages_LDFLAGS})
 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-api.pc.in ${CMAKE_CURRENT_BINARY_DIR}/bluetooth-api.pc @ONLY)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/bluetooth-api.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-INSTALL(TARGETS bluetooth-api DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/bluetooth-api.pc DESTINATION lib/pkgconfig)
+INSTALL(TARGETS bluetooth-api DESTINATION lib COMPONENT RuntimeLibraries)
 
 FOREACH(hfile ${HEADERS})
        INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/${hfile} DESTINATION include/bt-service)
diff --git a/bt-api/TFX79AA.tmp b/bt-api/TFX79AA.tmp
deleted file mode 100755 (executable)
index e69de29..0000000
diff --git a/bt-api/TFXF5A4.tmp b/bt-api/TFXF5A4.tmp
deleted file mode 100755 (executable)
index 738f6b0..0000000
+++ /dev/null
@@ -1,1201 +0,0 @@
-/*
- * Bluetooth-frwk low energy
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hocheol Seo <hocheol.seo@samsung.com>
- *         Girishashok Joshi <girish.joshi@samsung.com>
- *         Chanyeol Park <chanyeol.park@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *             http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <string.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <glib.h>
-
-#include "bluetooth-api.h"
-#include "bt-common.h"
-#include "bt-internal-types.h"
-
-
-#define BLUEZ_CHAR_INTERFACE "org.bluez.Characteristic"
-
-#define GATT_OBJECT_PATH  "/org/bluez/gatt_attrib"
-
-typedef struct {
-       GObject parent;
-} BluetoothGattService;
-
-typedef struct {
-       GObjectClass parent;
-} BluetoothGattServiceClass;
-
-typedef struct {
-       char *char_uuid;
-       char **handle;
-} char_pty_req_t;
-
-GType bluetooth_gatt_service_get_type(void);
-
-#define BLUETOOTH_GATT_TYPE_SERVICE (bluetooth_gatt_service_get_type())
-
-#define BLUETOOTH_GATT_SERVICE(object) \
-               (G_TYPE_CHECK_INSTANCE_CAST((object), \
-               BLUETOOTH_GATT_TYPE_SERVICE, BluetoothGattService))
-
-#define BLUETOOTH_GATT_SERVICE_CLASS(klass)    \
-               (G_TYPE_CHECK_CLASS_CAST((klass), \
-               BLUETOOTH_GATT_TYPE_SERVICE, BluetoothGattServiceClass))
-
-#define BLUETOOTH_GATT_IS_SERVICE(object)      \
-               (G_TYPE_CHECK_INSTANCE_TYPE((object), BLUETOOTH_GATT_TYPE_SERVICE))
-
-#define BLUETOOTH_GATT_IS_SERVICE_CLASS(klass) \
-               (G_TYPE_CHECK_CLASS_TYPE((klass), BLUETOOTH_GATT_TYPE_SERVICE))
-
-#define BLUETOOTH_GATT_SERVICE_GET_CLASS(obj)  \
-               (G_TYPE_INSTANCE_GET_CLASS((obj), \
-               BLUETOOTH_GATT_TYPE_SERVICE, BluetoothGattServiceClass))
-
-G_DEFINE_TYPE(BluetoothGattService, bluetooth_gatt_service, G_TYPE_OBJECT)
-
-static gboolean bluetooth_gatt_value_changed(BluetoothGattService *agent,
-                                       gchar *obj_path,
-                                       GArray *byte_array,
-                                       DBusGMethodInvocation *context);
-
-#include "bt-gatt-glue.h"
-
-static void bluetooth_gatt_service_init(BluetoothGattService *obj)
-{
-       g_assert(obj != NULL);
-}
-
-static void bluetooth_gatt_service_finalize(GObject *obj)
-{
-       G_OBJECT_CLASS(bluetooth_gatt_service_parent_class)->finalize(obj);
-}
-
-static void bluetooth_gatt_service_class_init(BluetoothGattServiceClass *klass)
-{
-       GObjectClass *object_class = (GObjectClass *)klass;
-
-       g_assert(klass != NULL);
-
-       object_class->finalize = bluetooth_gatt_service_finalize;
-
-       dbus_g_object_type_install_info(BLUETOOTH_GATT_TYPE_SERVICE,
-                                       &dbus_glib_bluetooth_gatt_object_info);
-}
-
-static gboolean bluetooth_gatt_value_changed(BluetoothGattService *agent,
-                                       gchar *obj_path,
-                                       GArray *byte_array,
-                                       DBusGMethodInvocation *context)
-{
-       bt_gatt_char_value_t char_val;
-       bt_user_info_t *user_info;
-       BT_DBG("+");
-
-       char_val.char_handle = obj_path;
-       char_val.char_value = &g_array_index(byte_array, guint8, 0);
-       char_val.val_len = byte_array->len;
-       BT_DBG("Byte array length = %d", char_val.val_len);
-
-       user_info = _bt_get_user_data(BT_COMMON);
-
-       if (user_info->cb) {
-               _bt_common_event_cb(BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED,
-                               BLUETOOTH_ERROR_NONE, &char_val,
-                               user_info->cb, user_info->user_data);
-       }
-
-       BT_DBG("-");
-
-       return TRUE;
-}
-
-static void __add_value_changed_method(DBusGConnection *conn)
-{
-       static gboolean method_added = FALSE;
-       BluetoothGattService *bluetooth_gatt_obj = NULL;
-
-       if (method_added) {
-               BT_ERR("Method already added. \n");
-               return;
-       }
-
-       method_added = TRUE;
-
-       bluetooth_gatt_obj = g_object_new(BLUETOOTH_GATT_TYPE_SERVICE, NULL);
-
-       dbus_g_connection_register_g_object(conn, GATT_OBJECT_PATH,
-                       G_OBJECT(bluetooth_gatt_obj));
-
-}
-
-static char **__get_string_array_from_gptr_array(GPtrArray *gp)
-{
-       gchar *gp_path = NULL;
-       char **path = NULL;
-       int i;
-
-       if (gp->len == 0)
-               return NULL;
-
-       path = g_malloc0((gp->len + 1) * sizeof(char *));
-
-       for (i = 0; i < gp->len; i++) {
-               gp_path = g_ptr_array_index(gp, i);
-               path[i] = g_strdup(gp_path);
-               BT_DBG("path[%d] : [%s]", i, path[i]);
-       }
-
-       return path;
-}
-
-static void __bluetooth_internal_get_char_cb(DBusGProxy *proxy,
-                                       DBusGProxyCall *call,
-                                       gpointer user_data)
-{
-       GError *error = NULL;
-       GPtrArray *gp_array = NULL;
-       bt_gatt_discovered_char_t svc_char = { 0, };
-       bt_user_info_t *user_info;
-
-       svc_char.service_handle = user_data;
-
-       user_info = _bt_get_user_data(BT_COMMON);
-
-       if (!dbus_g_proxy_end_call(proxy, call, &error,
-               dbus_g_type_get_collection("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
-               &gp_array, G_TYPE_INVALID)) {
-               BT_ERR("Error : %s \n", error->message);
-               g_error_free(error);
-
-               if (user_info->cb) {
-                       _bt_common_event_cb(BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED,
-                                       BLUETOOTH_ERROR_NONE, &svc_char,
-                                       user_info->cb, user_info->user_data);
-               }
-               g_free(svc_char.service_handle);
-               g_object_unref(proxy);
-               return;
-       }
-
-       if (NULL != gp_array) {
-               svc_char.handle_info.count = gp_array->len;
-               svc_char.handle_info.handle = __get_string_array_from_gptr_array(gp_array);
-       }
-
-       if (user_info) {
-               _bt_common_event_cb(BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED,
-                               BLUETOOTH_ERROR_NONE, &svc_char,
-                               user_info->cb, user_info->user_data);
-       }
-
-       g_ptr_array_free(gp_array, TRUE);
-       g_free(svc_char.service_handle);
-       g_free(svc_char.handle_info.handle);
-       g_object_unref(proxy);
-}
-
-static void __bluetooth_internal_read_cb(GObject *source_object,
-                                       GAsyncResult *res,
-                                       gpointer user_data)
-{
-       GError *error = NULL;
-       bt_user_info_t *user_info;
-       bt_gatt_char_value_t rsp =  { 0, };
-       GDBusConnection *system_gconn = NULL;
-       GVariant *return_data;
-       GByteArray *gp_byte_array = NULL;
-       GVariantIter *iter;
-       guint8 g_byte;
-
-       user_info = _bt_get_user_data(BT_COMMON);
-
-       system_gconn = _bt_init_system_gdbus_conn();
-       return_data = g_dbus_connection_call_finish(system_gconn, res, &error);
-
-       if (error) {
-               BT_ERR("Error : %s \n", error->message);
-               if(return_data)
-                       g_variant_unref(return_data);
-               g_clear_error(&error);
-               return;
-       }
-
-       gp_byte_array = g_byte_array_new();
-       g_variant_get(return_data, "(ay)", &iter);
-
-       while (g_variant_iter_loop(iter, "y",  &g_byte)) {
-               g_byte_array_append(gp_byte_array, &g_byte, 1);
-       }
-
-       if (NULL != gp_byte_array) {
-               rsp.val_len = gp_byte_array->len;
-               rsp.char_value = gp_byte_array->data;
-       }
-
-       if (user_info) {
-               _bt_common_event_cb(BLUETOOTH_EVENT_GATT_READ_CHAR,
-                               BLUETOOTH_ERROR_NONE, &rsp,
-                               user_info->cb, user_info->user_data);
-       }
-
-       g_byte_array_free(gp_byte_array, TRUE);
-       g_variant_unref(return_data);
-       g_variant_iter_free(iter);
-       return;
-}
-
-static void __bluetooth_internal_write_cb(GObject *source_object,
-                                       GAsyncResult *res,
-                                       gpointer user_data)
-{
-       GError *error = NULL;
-       bt_user_info_t *user_info;
-       GDBusConnection *system_gconn = NULL;
-       GVariant *return_data;
-       int result = BLUETOOTH_ERROR_NONE;
-
-       BT_DBG("__bluetooth_internal_write_cb");
-       user_info = _bt_get_user_data(BT_COMMON);
-
-       system_gconn = _bt_init_system_gdbus_conn();
-       return_data = g_dbus_connection_call_finish(system_gconn, res, &error);
-
-       if (error) {
-               BT_ERR("Error : %s \n", error->message);
-               g_clear_error(&error);
-               result = BLUETOOTH_ERROR_INTERNAL;
-       }
-       if (user_info) {
-               _bt_common_event_cb(BLUETOOTH_EVENT_GATT_WRITE_CHAR,
-                               result, NULL,
-                               user_info->cb, user_info->user_data);
-       }
-       BT_DBG("BP 0>>>>>>");
-
-       if(return_data)
-               g_variant_unref(return_data);
-
-       return;
-}
-
-static void __bluetooth_internal_get_char_desc_cb(GObject *source_object,
-                                       GAsyncResult *res,
-                                       gpointer user_data)
-{
-       GError *error = NULL;
-       GByteArray *gp_byte_array = NULL;
-       bt_gatt_char_property_t svc_char_desc = { 0, };
-       bt_user_info_t *user_info;
-       GDBusConnection *system_gconn = NULL;
-       GVariant *return_data;
-       GVariantIter *iter;
-       guint8 g_byte;
-
-       svc_char_desc.handle = user_data;
-       svc_char_desc.val_len = 0x00;
-       svc_char_desc.description = NULL;
-
-       user_info = _bt_get_user_data(BT_COMMON);
-       system_gconn = _bt_init_system_gdbus_conn();
-       return_data = g_dbus_connection_call_finish(system_gconn, res, &error);
-       BT_DBG("result data received..");
-       if (error) {
-               BT_ERR("Error : %s \n", error->message);
-               g_clear_error(&error);
-               g_free(svc_char_desc.handle);
-               return;
-       }
-       gp_byte_array = g_byte_array_new();
-       g_variant_get(return_data, "(ay)", &iter);
-
-       /*Format*/
-       if (g_variant_iter_loop(iter, "y",  &g_byte))
-               svc_char_desc.format.format = g_byte;
-
-       /*Handle and UUIDs*/
-       while (g_variant_iter_loop(iter, "y",  &g_byte)) {
-               g_byte_array_append(gp_byte_array, &g_byte, 1);
-       }
-
-       if (NULL != gp_byte_array) {
-               svc_char_desc.val_len = gp_byte_array->len;
-               svc_char_desc.description = (char *)gp_byte_array->data;
-       }
-
-       if (user_info) {
-               _bt_common_event_cb(BLUETOOTH_EVENT_GATT_SVC_CHAR_DESC_DISCOVERED,
-                               BLUETOOTH_ERROR_NONE, &svc_char_desc,
-                               user_info->cb, user_info->user_data);
-       }
-
-       g_byte_array_free(gp_byte_array, TRUE);
-       g_free(svc_char_desc.handle);
-       g_variant_unref(return_data);
-       g_variant_iter_free(iter);
-}
-
-static void __free_char_req(char_pty_req_t *char_req)
-{
-       g_free(char_req->char_uuid);
-       g_strfreev(char_req->handle);
-       g_free(char_req);
-}
-
-static gboolean __filter_chars_with_uuid(gpointer data)
-{
-       int i = 0;
-       bt_gatt_char_property_t *char_pty;
-       char_pty_req_t *char_req = data;
-       bt_user_info_t *user_info;
-       int ret;
-
-       user_info = _bt_get_user_data(BT_COMMON);
-       if (user_info->cb == NULL) {
-               __free_char_req(char_req);
-               return FALSE;
-       }
-
-       char_pty = g_new0(bt_gatt_char_property_t, 1);
-
-       while (char_req->handle[i] != NULL) {
-               BT_DBG("char_pty[%d] = %s", i, char_req->handle[i]);
-               ret = bluetooth_gatt_get_characteristics_property(char_req->handle[i],
-                                                                       char_pty);
-               if (ret != BLUETOOTH_ERROR_NONE) {
-                       BT_ERR("get char property failed");
-                       goto done;
-               }
-
-               if (char_pty->uuid  && g_strstr_len(char_pty->uuid, -1,
-                                               char_req->char_uuid) != NULL) {
-                       BT_DBG("Requested Char recieved");
-                       ret = BLUETOOTH_ERROR_NONE;
-                       break;
-               }
-
-               bluetooth_gatt_free_char_property(char_pty);
-
-               i++;
-       }
-
-done:
-       if (char_req->handle[i] == NULL)
-               ret = BLUETOOTH_ERROR_NOT_FOUND;
-
-       _bt_common_event_cb(BLUETOOTH_EVENT_GATT_GET_CHAR_FROM_UUID, ret,
-                               char_pty, user_info->cb, user_info->user_data);
-
-       g_free(char_pty);
-       __free_char_req(char_req);
-
-       return FALSE;
-}
-
-static void __disc_char_from_uuid_cb(DBusGProxy *proxy,
-                                       DBusGProxyCall *call,
-                                       gpointer user_data)
-{
-       GError *error = NULL;
-       GPtrArray *gp_array = NULL;
-       bt_user_info_t *user_info;
-       char_pty_req_t *char_req = user_data;
-
-       user_info = _bt_get_user_data(BT_COMMON);
-       if (!user_info->cb) {
-               __free_char_req(char_req);
-               return;
-       }
-
-       if (!dbus_g_proxy_end_call(proxy, call, &error,
-               dbus_g_type_get_collection("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
-               &gp_array, G_TYPE_INVALID)) {
-               BT_ERR("Error : %s \n", error->message);
-               g_error_free(error);
-
-               _bt_common_event_cb(BLUETOOTH_EVENT_GATT_GET_CHAR_FROM_UUID,
-                                       BLUETOOTH_ERROR_INTERNAL, NULL,
-                                       user_info->cb, user_info->user_data);
-
-               __free_char_req(char_req);
-               g_object_unref(proxy);
-               return;
-       }
-
-       if (gp_array == NULL) {
-               _bt_common_event_cb(BLUETOOTH_EVENT_GATT_GET_CHAR_FROM_UUID,
-                                       BLUETOOTH_ERROR_NOT_FOUND, NULL,
-                                       user_info->cb, user_info->user_data);
-
-               __free_char_req(char_req);
-               g_object_unref(proxy);
-
-               return;
-       }
-
-       char_req->handle = __get_string_array_from_gptr_array(gp_array);
-
-       __filter_chars_with_uuid(char_req);
-
-       g_ptr_array_free(gp_array, TRUE);
-       g_object_unref(proxy);
-}
-
-
-static int __discover_char_from_uuid(const char *service_handle,
-                                                       const char *char_uuid){
-       DBusGProxy *service_proxy = NULL;
-       DBusGConnection *conn;
-       char_pty_req_t *char_req;
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       service_proxy = dbus_g_proxy_new_for_name(conn,
-                                               BT_BLUEZ_NAME, service_handle,
-                                               BLUEZ_CHAR_INTERFACE);
-       retv_if(service_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       char_req = g_new0(char_pty_req_t, 1);
-
-       char_req->char_uuid = g_strdup(char_uuid);
-       BT_DBG("Char uuid %s ", char_uuid);
-
-       if (!dbus_g_proxy_begin_call(service_proxy, "DiscoverCharacteristics",
-                       (DBusGProxyCallNotify)__disc_char_from_uuid_cb,
-                       char_req, NULL, G_TYPE_INVALID)) {
-               __free_char_req(char_req);
-               g_object_unref(service_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_free_primary_services(bt_gatt_handle_info_t *prim_svc)
-{
-       BT_DBG("+");
-
-       BT_CHECK_PARAMETER(prim_svc, return);
-
-       g_strfreev(prim_svc->handle);
-
-       memset(prim_svc, 0, sizeof(bt_gatt_handle_info_t));
-
-       BT_DBG("-");
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_free_service_property(bt_gatt_service_property_t *svc_pty)
-{
-       BT_DBG("+");
-
-       BT_CHECK_PARAMETER(svc_pty, return);
-
-       g_free(svc_pty->uuid);
-       g_free(svc_pty->handle);
-       g_strfreev(svc_pty->handle_info.handle);
-
-       memset(svc_pty, 0, sizeof(bt_gatt_service_property_t));
-
-       BT_DBG("-");
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_free_char_property(bt_gatt_char_property_t *char_pty)
-{
-       BT_DBG("+");
-
-       BT_CHECK_PARAMETER(char_pty, return);
-
-       g_free(char_pty->uuid);
-       g_free(char_pty->name);
-       g_free(char_pty->description);
-       g_free(char_pty->val);
-       g_free(char_pty->handle);
-
-       memset(char_pty, 0, sizeof(bt_gatt_char_property_t));
-
-       BT_DBG("-");
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_get_primary_services(const bluetooth_device_address_t *address,
-                                                               bt_gatt_handle_info_t *prim_svc)
-{
-       char device_address[BT_ADDRESS_STRING_SIZE] = { 0 };
-       gchar *device_path = NULL;
-       GError *error = NULL;
-
-       GVariant *result;
-       GVariantIter *iter;
-       GDBusConnection *conn;
-       GVariant *value = NULL;
-       gchar *g_str;
-
-       GPtrArray *gp_array  = NULL;
-       int ret = BLUETOOTH_ERROR_INTERNAL;
-
-       BT_DBG("+");
-
-       BT_CHECK_PARAMETER(address, return);
-       BT_CHECK_PARAMETER(prim_svc, return);
-
-       BT_CHECK_ENABLED(return);
-
-       /* About org.tizen.device1 interface, dbus SMACK is not working. So use bt-service's
-         privilege checking logic */
-       if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_GATT_GET_PRIMARY_SERVICES)
-            == BLUETOOTH_ERROR_PERMISSION_DEINED) {
-               BT_ERR("Don't have a privilege to use this API");
-               return BLUETOOTH_ERROR_PERMISSION_DEINED;
-       }
-
-       _bt_convert_addr_type_to_string(device_address,
-                               (unsigned char *)address->addr);
-
-       BT_INFO("bluetooth address [%s]\n", device_address);
-
-       device_path = _bt_get_device_object_path(device_address);
-
-       retv_if(device_path == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       conn = _bt_init_system_gdbus_conn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       result = g_dbus_connection_call_sync(conn,
-                               BT_BLUEZ_NAME,
-                               device_path,
-                               BT_DEVICE_INTERFACE,
-                               "GetPrimServices",
-                               NULL,
-                               G_VARIANT_TYPE ("(ao)"),
-                               G_DBUS_CALL_FLAGS_NONE,
-                               -1,
-                               NULL,
-                               &error);
-               if (error) {
-                       BT_ERR("GetPrimServices Call Error %s[%s]", error->message,
-                                                                device_address);
-                       g_clear_error(&error);
-                       return BLUETOOTH_ERROR_INTERNAL;
-               }
-               g_free(device_path);
-
-               gp_array = g_ptr_array_new();
-               g_variant_get(result, "(ao)", &iter);
-               while ((value = g_variant_iter_next_value(iter))) {
-                       g_variant_get(value, "o", &g_str);
-                       g_ptr_array_add(gp_array, (gpointer)g_str);
-                }
-
-       if (gp_array == NULL) {
-               BT_ERR("gp_array == NULL");
-               goto done;
-       }
-
-       prim_svc->count = gp_array->len;
-       prim_svc->handle = __get_string_array_from_gptr_array(gp_array);
-
-       g_ptr_array_free(gp_array, TRUE);
-       g_variant_iter_free(iter);
-       g_variant_unref(result);
-
-       ret = BLUETOOTH_ERROR_NONE;
-done:
-       BT_DBG("-");
-       return ret;
-}
-
-BT_EXPORT_API int bluetooth_gatt_discover_service_characteristics(const char *service_handle)
-{
-       DBusGProxy *service_proxy = NULL;
-       char *handle;
-       DBusGConnection *conn;
-
-       BT_CHECK_PARAMETER(service_handle, return);
-
-       BT_CHECK_ENABLED(return);
-
-       /* Because this API is async call, so can't use dbus SMACK */
-       if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_GATT_DISCOVER_CHARACTERISTICS)
-            == BLUETOOTH_ERROR_PERMISSION_DEINED) {
-               BT_ERR("Don't have a privilege to use this API");
-               return BLUETOOTH_ERROR_PERMISSION_DEINED;
-       }
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       service_proxy = dbus_g_proxy_new_for_name(conn,
-                                               BT_BLUEZ_NAME, service_handle,
-                                               BLUEZ_CHAR_INTERFACE);
-
-       retv_if(service_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       handle = g_strdup(service_handle);
-       BT_DBG("Requested characteristic handle:%s \n ", handle);
-
-       if (!dbus_g_proxy_begin_call(service_proxy, "DiscoverCharacteristics",
-                       (DBusGProxyCallNotify)__bluetooth_internal_get_char_cb,
-                       handle, NULL, G_TYPE_INVALID)) {
-               g_free(handle);
-               g_object_unref(service_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_get_service_property(const char *service_handle,
-                                               bt_gatt_service_property_t *service)
-{
-       DBusGProxy *service_proxy = NULL;
-       GHashTable *hash = NULL;
-       GError *error = NULL;
-       GValue *value = NULL;
-       GPtrArray *gp_array  = NULL ;
-       DBusGConnection *conn;
-       int ret = BLUETOOTH_ERROR_NONE;
-
-       BT_CHECK_PARAMETER(service_handle, return);
-       BT_CHECK_PARAMETER(service, return);
-
-       BT_CHECK_ENABLED(return);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       service_proxy = dbus_g_proxy_new_for_name(conn,
-                                               BT_BLUEZ_NAME, service_handle,
-                                               BLUEZ_CHAR_INTERFACE);
-
-       retv_if(service_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_g_proxy_call(service_proxy, "GetProperties", &error, G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                               &hash, G_TYPE_INVALID);
-
-       g_object_unref(service_proxy);
-
-       if (error != NULL) {
-               BT_ERR("GetProperties Call Error %s\n", error->message);
-
-               if (g_strrstr(error->message, BT_ACCESS_DENIED_MSG))
-                       ret = BLUETOOTH_ERROR_ACCESS_DENIED;
-               else
-                       ret = BLUETOOTH_ERROR_INTERNAL;
-
-               g_error_free(error);
-               return ret;
-       }
-
-       retv_if(hash == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       memset(service, 0, sizeof(bt_gatt_service_property_t));
-
-       value = g_hash_table_lookup(hash, "UUID");
-       service->uuid = value ? g_value_dup_string(value) : NULL;
-       if (service->uuid) {
-               BT_DBG("svc_pty.uuid = [%s] \n", service->uuid);
-       }
-
-       value = g_hash_table_lookup(hash, "Characteristics");
-       gp_array = value ? g_value_get_boxed(value) : NULL;
-       if (gp_array) {
-               service->handle_info.count = gp_array->len;
-               service->handle_info.handle = __get_string_array_from_gptr_array(gp_array);
-       }
-
-       service->handle = g_strdup(service_handle);
-       g_hash_table_destroy(hash);
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_watch_characteristics(const char *service_handle)
-{
-       DBusGProxy *watch_proxy = NULL;
-       GError *error = NULL;
-       DBusGConnection *conn;
-       int ret = BLUETOOTH_ERROR_NONE;
-
-       BT_CHECK_PARAMETER(service_handle, return);
-
-       BT_CHECK_ENABLED(return);
-
-       BT_DBG("Entered service handle:%s \n ", service_handle);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       watch_proxy = dbus_g_proxy_new_for_name(conn,
-                               BT_BLUEZ_NAME, service_handle,
-                               BLUEZ_CHAR_INTERFACE);
-
-       retv_if(watch_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       __add_value_changed_method(conn);
-
-       dbus_g_proxy_call(watch_proxy, "RegisterCharacteristicsWatcher", &error,
-                               DBUS_TYPE_G_OBJECT_PATH, GATT_OBJECT_PATH,
-                               G_TYPE_INVALID, G_TYPE_INVALID);
-       if (error) {
-               BT_ERR("Method call  Fail: %s", error->message);
-
-               if (g_strrstr(error->message, BT_ACCESS_DENIED_MSG))
-                       ret = BLUETOOTH_ERROR_ACCESS_DENIED;
-               else
-                       ret = BLUETOOTH_ERROR_INTERNAL;
-
-               g_error_free(error);
-               g_object_unref(watch_proxy);
-               return ret;
-       }
-
-       g_object_unref(watch_proxy);
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_unwatch_characteristics(const char *service_handle)
-{
-       DBusGProxy *watch_proxy = NULL;
-       GError *error = NULL;
-       DBusGConnection *conn;
-       int ret = BLUETOOTH_ERROR_NONE;
-
-       BT_CHECK_PARAMETER(service_handle, return);
-
-       BT_CHECK_ENABLED(return);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       watch_proxy = dbus_g_proxy_new_for_name(conn,
-                               BT_BLUEZ_NAME, service_handle,
-                               BLUEZ_CHAR_INTERFACE);
-
-       retv_if(watch_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_g_proxy_call(watch_proxy, "UnregisterCharacteristicsWatcher", &error,
-                               DBUS_TYPE_G_OBJECT_PATH, GATT_OBJECT_PATH,
-                               G_TYPE_INVALID, G_TYPE_INVALID);
-       if (error) {
-               BT_ERR("Method call  Fail: %s", error->message);
-
-               if (g_strrstr(error->message, BT_ACCESS_DENIED_MSG))
-                       ret = BLUETOOTH_ERROR_ACCESS_DENIED;
-               else
-                       ret = BLUETOOTH_ERROR_INTERNAL;
-
-               g_error_free(error);
-               g_object_unref(watch_proxy);
-               return ret;
-       }
-
-       g_object_unref(watch_proxy);
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_get_characteristics_property(const char *char_handle,
-                                               bt_gatt_char_property_t *characteristic)
-{
-       DBusGProxy *characteristic_proxy = NULL;
-       GHashTable *hash = NULL;
-       GError *error = NULL;
-       GValue *value = NULL;
-       GByteArray *gb_array = NULL;
-       DBusGConnection *conn;
-       int ret = BLUETOOTH_ERROR_NONE;
-
-       BT_CHECK_PARAMETER(char_handle, return);
-       BT_CHECK_PARAMETER(characteristic, return);
-
-       BT_CHECK_ENABLED(return);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       characteristic_proxy = dbus_g_proxy_new_for_name(conn,
-                                               BT_BLUEZ_NAME, char_handle,
-                                               BLUEZ_CHAR_INTERFACE);
-
-       retv_if(characteristic_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_g_proxy_call(characteristic_proxy, "GetProperties", &error, G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                               &hash, G_TYPE_INVALID);
-       if (error != NULL) {
-               BT_ERR("GetProperties Call Error %s\n", error->message);
-
-               if (g_strrstr(error->message, BT_ACCESS_DENIED_MSG))
-                       ret = BLUETOOTH_ERROR_ACCESS_DENIED;
-               else
-                       ret = BLUETOOTH_ERROR_INTERNAL;
-
-               g_error_free(error);
-               g_object_unref(characteristic_proxy);
-               return ret;
-       }
-       g_object_unref(characteristic_proxy);
-
-       retv_if(hash == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       memset(characteristic, 0, sizeof(bt_gatt_char_property_t));
-
-       value = g_hash_table_lookup(hash, "UUID");
-       characteristic->uuid = value ? g_value_dup_string(value) : NULL;
-       if (characteristic->uuid) {
-               BT_DBG("characteristic->uuid = [%s] \n", characteristic->uuid);
-       }
-
-       value = g_hash_table_lookup(hash, "Name");
-       characteristic->name = value ? g_value_dup_string(value) : NULL;
-       if (characteristic->name) {
-               DBG_SECURE("characteristic->name = [%s] \n", characteristic->name);
-       }
-
-       value = g_hash_table_lookup(hash, "Description");
-       characteristic->description = value ? g_value_dup_string(value) : NULL;
-       if (characteristic->description) {
-               BT_DBG("characteristic->description = [%s] \n", characteristic->description);
-       }
-
-       value = g_hash_table_lookup(hash, "Value");
-
-       gb_array = value ? g_value_get_boxed(value) : NULL;
-       if (gb_array) {
-               if (gb_array->len) {
-                       BT_DBG("gb_array->len  = %d \n", gb_array->len);
-                       characteristic->val_len = gb_array->len;
-
-                       characteristic->val = g_malloc0(gb_array->len * sizeof(unsigned char));
-                       memcpy(characteristic->val, gb_array->data, gb_array->len);
-               } else {
-                       characteristic->val = NULL;
-                       characteristic->val_len = 0;
-               }
-       } else {
-               characteristic->val = NULL;
-               characteristic->val_len = 0;
-       }
-       characteristic->handle = g_strdup(char_handle);
-       g_hash_table_destroy(hash);
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_set_characteristics_value(const char *char_handle,
-                                               const guint8 *value, int length)
-{
-       GVariant *val;
-       char *handle;
-       GVariantBuilder *builder;
-       GError *error = NULL;
-       DBusGConnection *conn;
-       int i = 0;
-       int ret = BLUETOOTH_ERROR_NONE;
-
-       BT_CHECK_PARAMETER(char_handle, return);
-       BT_CHECK_PARAMETER(value, return);
-       retv_if(length == 0, BLUETOOTH_ERROR_INVALID_PARAM);
-
-       BT_CHECK_ENABLED(return);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       BT_DBG("Requested characteristic handle:%s \n ", char_handle);
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
-
-       for (i = 0; i < length; i++) {
-               g_variant_builder_add(builder, "y", value[i]);
-               BT_DBG("value idx:%d, %d", i, value[i]);
-       }
-
-       val = g_variant_new("ay", builder);
-
-       handle = g_strdup(char_handle);
-       BT_DBG("BP 0");
-
-       g_dbus_connection_call_sync(conn,
-                               BT_BLUEZ_NAME,
-                               char_handle,
-                               BLUEZ_CHAR_INTERFACE,
-                               "SetProperty",
-                               g_variant_new("(sv)",
-                                       "Value", val),
-                               NULL,
-                               G_DBUS_CALL_FLAGS_NONE,
-                               -1,
-                               NULL,
-                               &error);
-
-       if (error) {
-               BT_ERR("Set value Fail: %s", error->message);
-
-               if (g_strrstr(error->message, BT_ACCESS_DENIED_MSG))
-                       ret = BLUETOOTH_ERROR_ACCESS_DENIED;
-               else
-                       ret = BLUETOOTH_ERROR_INTERNAL;
-
-               g_error_free(error);
-               g_variant_builder_unref(builder);
-               return ret;
-       }
-       BT_DBG("BP 1");
-
-       g_variant_builder_unref(builder);
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_set_characteristics_value_request(
-               const char *char_handle, const guint8 *value, int length)
-{
-       GVariant *val;
-       GError *error = NULL;
-       GDBusConnection *conn;
-       char *handle;
-       GVariantBuilder *builder;
-       int i;
-
-       BT_CHECK_PARAMETER(char_handle, return);
-       BT_CHECK_PARAMETER(value, return);
-       retv_if(length == 0, BLUETOOTH_ERROR_INVALID_PARAM);
-
-       BT_CHECK_ENABLED(return);
-
-       /* Because this API is async call, so can't use dbus SMACK */
-       if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_GATT_SET_PROPERTY_REQUEST)
-            == BLUETOOTH_ERROR_PERMISSION_DEINED) {
-               BT_ERR("Don't have a privilege to use this API");
-               return BLUETOOTH_ERROR_PERMISSION_DEINED;
-       }
-
-       conn = _bt_init_system_gdbus_conn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
-
-       for (i = 0; i < length; i++) {
-               g_variant_builder_add(builder, "y", value[i]);
-       }
-
-       val = g_variant_new("ay", builder);
-
-       handle = g_strdup(char_handle);
-
-       g_dbus_connection_call(conn,
-                               BT_BLUEZ_NAME,
-                               char_handle,
-                               BLUEZ_CHAR_INTERFACE,
-                               "SetPropertyRequest",
-                               g_variant_new("(sv)",
-                                       "Value", val),
-                               NULL,
-                               G_DBUS_CALL_FLAGS_NONE,
-                               -1,
-                               NULL,
-                               (GAsyncReadyCallback)
-                               __bluetooth_internal_write_cb,
-                               handle);
-
-       if (error) {
-               BT_ERR("Set value Fail: %s", error->message);
-               g_clear_error(&error);
-               g_variant_builder_unref(builder);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-       g_variant_builder_unref(builder);
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_get_service_from_uuid(bluetooth_device_address_t *address,
-                                       const char *service_uuid,
-                                       bt_gatt_service_property_t *service)
-{
-       int i;
-       int ret;
-       bt_gatt_handle_info_t prim_svc;
-
-       BT_CHECK_PARAMETER(address, return);
-       BT_CHECK_PARAMETER(service_uuid, return);
-       BT_CHECK_PARAMETER(service, return);
-
-       BT_CHECK_ENABLED(return);
-
-       ret = bluetooth_gatt_get_primary_services(address, &prim_svc);
-       if (ret != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Get primary service failed ");
-               return ret;
-       }
-
-       for (i = 0; i < prim_svc.count; i++) {
-
-               BT_DBG("prim_svc [%d] = %s", i, prim_svc.handle[i]);
-
-               ret = bluetooth_gatt_get_service_property(prim_svc.handle[i],
-                                                               service);
-               if (ret != BLUETOOTH_ERROR_NONE) {
-                       BT_ERR("Get service property failed ");
-                       bluetooth_gatt_free_primary_services(&prim_svc);
-                       return ret;
-               }
-
-               BT_DBG("Service uuid %s", service->uuid);
-
-               if (g_strstr_len(service->uuid, -1, service_uuid)) {
-                       BT_INFO("Found requested service");
-                       ret = BLUETOOTH_ERROR_NONE;
-                       break;
-               }
-
-               bluetooth_gatt_free_service_property(service);
-       }
-
-       if (i == prim_svc.count)
-               ret = BLUETOOTH_ERROR_NOT_FOUND;
-
-       bluetooth_gatt_free_primary_services(&prim_svc);
-
-       return ret;
-}
-
-BT_EXPORT_API int bluetooth_gatt_get_char_from_uuid(const char *service_handle,
-                                               const char *char_uuid)
-{
-       char **char_handles;
-       char_pty_req_t *char_pty;
-       int i;
-       bt_gatt_service_property_t svc_pty;
-       int ret;
-
-       BT_CHECK_PARAMETER(service_handle, return);
-       BT_CHECK_PARAMETER(char_uuid, return);
-
-       BT_CHECK_ENABLED(return);
-
-       ret = bluetooth_gatt_get_service_property(service_handle, &svc_pty);
-       if (ret != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Get primary service failed ");
-               return ret;
-       }
-
-       if (bluetooth_gatt_get_service_property(service_handle, &svc_pty) !=
-                                                       BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Invalid service");
-               return BLUETOOTH_ERROR_NOT_FOUND;
-       }
-
-       char_handles = svc_pty.handle_info.handle;
-
-       if (char_handles == NULL)
-               return __discover_char_from_uuid(svc_pty.handle, char_uuid);
-
-       char_pty = g_new0(char_pty_req_t, 1);
-
-       char_pty->handle = g_malloc0((svc_pty.handle_info.count + 1) *
-                                                       sizeof(char *));
-       for (i = 0; i < svc_pty.handle_info.count; i++) {
-               char_pty->handle[i] = char_handles[i];
-               BT_DBG("char_path[%d] : [%s]", i, char_pty->handle[i]);
-       }
-       char_pty->char_uuid = g_strdup(char_uuid);
-
-       g_idle_add(__filter_chars_with_uuid, char_pty);
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_read_characteristic_value(const char *characteristic)
-{
-        GDBusConnection *conn;
-       char *handle;
-
-       BT_CHECK_PARAMETER(characteristic, return);
-       BT_CHECK_ENABLED(return);
-
-       /* Because this API is async call, so can't use dbus SMACK */
-       if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_GATT_READ_CHARACTERISTIC)
-            == BLUETOOTH_ERROR_PERMISSION_DEINED) {
-               BT_ERR("Don't have a privilege to use this API");
-               return BLUETOOTH_ERROR_PERMISSION_DEINED;
-       }
-
-       conn = _bt_init_system_gdbus_conn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       handle = g_strdup(characteristic);
-       g_dbus_connection_call(conn,
-                               BT_BLUEZ_NAME,
-                               characteristic,
-                               BLUEZ_CHAR_INTERFACE,
-                               "ReadCharacteristic",
-                               NULL,
-                               G_VARIANT_TYPE("(ay)"),
-                               G_DBUS_CALL_FLAGS_NONE,
-                               -1,
-                               NULL,
-                               (GAsyncReadyCallback)
-                               __bluetooth_internal_read_cb,
-                               handle);
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_discover_characteristic_descriptor
-                                                               (const char *characteristic_handle)
-{
-       char *handle;
-       GDBusConnection *conn;
-
-       BT_CHECK_PARAMETER(characteristic_handle, return);
-
-       BT_CHECK_ENABLED(return);
-
-       /* Because this API is async call, so can't use dbus SMACK */
-       if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_GATT_DISCOVER_CHARACTERISTICS_DESCRIPTOR)
-            == BLUETOOTH_ERROR_PERMISSION_DEINED) {
-               BT_ERR("Don't have a privilege to use this API");
-               return BLUETOOTH_ERROR_PERMISSION_DEINED;
-       }
-
-       conn = _bt_init_system_gdbus_conn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-       handle = g_strdup(characteristic_handle);
-       g_dbus_connection_call(conn,
-                                       BT_BLUEZ_NAME,
-                                       characteristic_handle,
-                                       BLUEZ_CHAR_INTERFACE,
-                                       "DiscoverCharacteristicsDescriptor",
-                                       NULL,
-                                       G_VARIANT_TYPE("(ay)"),
-                                       G_DBUS_CALL_FLAGS_NONE,
-                                       -1,
-                                       NULL,
-                                       (GAsyncReadyCallback)
-                                       __bluetooth_internal_get_char_desc_cb,
-                                       handle);
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
index e577fa3..c7210a4 100644 (file)
@@ -1,6 +1,6 @@
 prefix=@PREFIX@
 exec_prefix=@EXEC_PREFIX@
-libdir=@LIB_INSTALL_DIR@
+libdir=@LIBDIR@
 includedir=@INCLUDEDIR@
 
 Name: bluetooth-api
index a00c1ad..552a410 100644 (file)
 #include "bt-request-sender.h"
 #include "bt-event-handler.h"
 
+static gboolean is_le_scanning = FALSE;
+
 BT_EXPORT_API int bluetooth_check_adapter_le(void)
 {
        int ret;
-       int value = 1;
+       int value;
 
        ret = _bt_get_adapter_path(_bt_gdbus_get_system_gconn(), NULL);
 
@@ -42,7 +44,6 @@ BT_EXPORT_API int bluetooth_check_adapter_le(void)
                return BLUETOOTH_ADAPTER_LE_DISABLED;
        }
 
-#ifdef ENABLE_TIZEN_2_4
        ret = vconf_get_int(VCONFKEY_BT_LE_STATUS, &value);
        if (ret != 0) {
                BT_ERR("fail to get vconf key!");
@@ -52,9 +53,6 @@ BT_EXPORT_API int bluetooth_check_adapter_le(void)
        BT_DBG("value : %d", value);
        return value == VCONFKEY_BT_LE_STATUS_ON ? BLUETOOTH_ADAPTER_LE_ENABLED :
                                                BLUETOOTH_ADAPTER_LE_DISABLED;
-#else
-       return value = BLUETOOTH_ADAPTER_LE_DISABLED;
-#endif
 }
 
 BT_EXPORT_API int bluetooth_enable_adapter_le(void)
@@ -91,6 +89,17 @@ BT_EXPORT_API int bluetooth_disable_adapter_le(void)
        return result;
 }
 
+void _bt_set_le_scan_status(gboolean mode)
+{
+       BT_DBG("set LE scan mode : %d", mode);
+       is_le_scanning = mode;
+}
+
+BT_EXPORT_API gboolean bluetooth_is_le_scanning(void)
+{
+       return is_le_scanning;
+}
+
 BT_EXPORT_API int bluetooth_start_le_discovery(void)
 {
        int result;
@@ -105,6 +114,9 @@ BT_EXPORT_API int bluetooth_start_le_discovery(void)
 
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
+       if (result == BLUETOOTH_ERROR_NONE)
+               _bt_set_le_scan_status(TRUE);
+
        return result;
 }
 
@@ -120,9 +132,11 @@ BT_EXPORT_API int bluetooth_stop_le_discovery(void)
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_STOP_LE_DISCOVERY,
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
-
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
+       if (result == BLUETOOTH_ERROR_NONE)
+               _bt_set_le_scan_status(FALSE);
+
        return result;
 }
 
@@ -151,6 +165,67 @@ BT_EXPORT_API int bluetooth_is_le_discovering(void)
        return is_discovering;
 }
 
+BT_EXPORT_API int bluetooth_register_scan_filter(bluetooth_le_scan_filter_t *filter, int *slot_id)
+{
+       int result;
+
+       BT_CHECK_ENABLED_ANY(return);
+
+       BT_INIT_PARAMS();
+       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       g_array_append_vals(in_param1, filter, sizeof(bluetooth_le_scan_filter_t));
+
+       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_REGISTER_SCAN_FILTER,
+               in_param1, in_param2, in_param3, in_param4, &out_param);
+
+       if (result == BLUETOOTH_ERROR_NONE) {
+               *slot_id = g_array_index(out_param, int, 0);
+       } else {
+               BT_ERR("Fail to send request");
+       }
+
+       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       return result;
+}
+
+BT_EXPORT_API int bluetooth_unregister_scan_filter(int slot_id)
+{
+       int result;
+
+       BT_CHECK_ENABLED_ANY(return);
+
+       BT_INIT_PARAMS();
+       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       g_array_append_vals(in_param1, &slot_id, sizeof(int));
+
+       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_UNREGISTER_SCAN_FILTER,
+               in_param1, in_param2, in_param3, in_param4, &out_param);
+
+       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       return result;
+}
+
+BT_EXPORT_API int bluetooth_unregister_all_scan_filters(void)
+{
+       int result;
+
+       BT_CHECK_ENABLED_ANY(return);
+
+       BT_INIT_PARAMS();
+       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_UNREGISTER_ALL_SCAN_FILTERS,
+               in_param1, in_param2, in_param3, in_param4, &out_param);
+
+       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       return result;
+}
+
 #ifdef TIZEN_WEARABLE
 gboolean __bluetooth_is_privileged_process(void)
 {
@@ -175,7 +250,7 @@ gboolean __bluetooth_is_privileged_process(void)
 }
 #endif
 
-BT_EXPORT_API int bluetooth_set_advertising(gboolean enable)
+BT_EXPORT_API int bluetooth_set_advertising(int handle, gboolean enable)
 {
        int result;
        gboolean use_reserved_slot = FALSE;
@@ -189,8 +264,9 @@ BT_EXPORT_API int bluetooth_set_advertising(gboolean enable)
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-       g_array_append_vals(in_param1, &enable, sizeof(gboolean));
-       g_array_append_vals(in_param2, &use_reserved_slot, sizeof(gboolean));
+       g_array_append_vals(in_param1, &handle, sizeof(int));
+       g_array_append_vals(in_param2, &enable, sizeof(gboolean));
+       g_array_append_vals(in_param3, &use_reserved_slot, sizeof(gboolean));
 
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_SET_ADVERTISING,
                in_param1, in_param2, in_param3, in_param4, &out_param);
@@ -200,7 +276,7 @@ BT_EXPORT_API int bluetooth_set_advertising(gboolean enable)
        return result;
 }
 
-BT_EXPORT_API int bluetooth_set_custom_advertising(gboolean enable,
+BT_EXPORT_API int bluetooth_set_custom_advertising(int handle, gboolean enable,
                                                bluetooth_advertising_params_t *params)
 {
        int result;
@@ -215,9 +291,10 @@ BT_EXPORT_API int bluetooth_set_custom_advertising(gboolean enable,
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-       g_array_append_vals(in_param1, &enable, sizeof(gboolean));
-       g_array_append_vals(in_param2, params, sizeof(bluetooth_advertising_params_t));
-       g_array_append_vals(in_param3, &use_reserved_slot, sizeof(gboolean));
+       g_array_append_vals(in_param1, &handle, sizeof(int));
+       g_array_append_vals(in_param2, &enable, sizeof(gboolean));
+       g_array_append_vals(in_param3, params, sizeof(bluetooth_advertising_params_t));
+       g_array_append_vals(in_param4, &use_reserved_slot, sizeof(gboolean));
 
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_SET_CUSTOM_ADVERTISING,
                in_param1, in_param2, in_param3, in_param4, &out_param);
@@ -255,7 +332,7 @@ BT_EXPORT_API int bluetooth_get_advertising_data(bluetooth_advertising_data_t *a
        return result;
 }
 
-BT_EXPORT_API int bluetooth_set_advertising_data(const bluetooth_advertising_data_t *value, int length)
+BT_EXPORT_API int bluetooth_set_advertising_data(int handle, const bluetooth_advertising_data_t *value, int length)
 {
        int result;
        gboolean use_reserved_slot = FALSE;
@@ -273,9 +350,10 @@ BT_EXPORT_API int bluetooth_set_advertising_data(const bluetooth_advertising_dat
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-       g_array_append_vals(in_param1, value, sizeof(bluetooth_advertising_data_t));
-       g_array_append_vals(in_param2, &length, sizeof(int));
-       g_array_append_vals(in_param3, &use_reserved_slot, sizeof(gboolean));
+       g_array_append_vals(in_param1, &handle, sizeof(int));
+       g_array_append_vals(in_param2, value, sizeof(bluetooth_advertising_data_t));
+       g_array_append_vals(in_param3, &length, sizeof(int));
+       g_array_append_vals(in_param4, &use_reserved_slot, sizeof(gboolean));
 
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_SET_ADVERTISING_DATA,
                in_param1, in_param2, in_param3, in_param4, &out_param);
@@ -313,7 +391,7 @@ BT_EXPORT_API int bluetooth_get_scan_response_data(bluetooth_scan_resp_data_t *v
        return result;
 }
 
-BT_EXPORT_API int bluetooth_set_scan_response_data(
+BT_EXPORT_API int bluetooth_set_scan_response_data(int handle,
                        const bluetooth_scan_resp_data_t *value, int length)
 {
        int result;
@@ -332,9 +410,10 @@ BT_EXPORT_API int bluetooth_set_scan_response_data(
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-       g_array_append_vals(in_param1, value, length);
-       g_array_append_vals(in_param2, &length, sizeof(int));
-       g_array_append_vals(in_param3, &use_reserved_slot, sizeof(gboolean));
+       g_array_append_vals(in_param1, &handle, sizeof(int));
+       g_array_append_vals(in_param2, value, length);
+       g_array_append_vals(in_param3, &length, sizeof(int));
+       g_array_append_vals(in_param4, &use_reserved_slot, sizeof(gboolean));
 
        result = _bt_send_request(BT_BLUEZ_SERVICE, BT_SET_SCAN_RESPONSE_DATA,
                in_param1, in_param2, in_param3, in_param4, &out_param);
@@ -464,6 +543,17 @@ BT_EXPORT_API int bluetooth_enable_le_privacy(gboolean enable_privacy)
        return result;
 }
 
+BT_EXPORT_API int bluetooth_check_privilege_advertising_parameter(void)
+{
+       if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_SET_ADVERTISING_PARAMETERS)
+                    == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+               BT_ERR("Don't have a privilege to use this API");
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       }
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
 BT_EXPORT_API int bluetooth_le_register_callback(bluetooth_cb_func_ptr callback_ptr, void *user_data)
 {
        int ret;
@@ -483,4 +573,4 @@ BT_EXPORT_API int bluetooth_le_unregister_callback(void)
        _bt_unregister_event(BT_LE_ADAPTER_EVENT);
 
        return BLUETOOTH_ERROR_NONE;
-}
\ No newline at end of file
+}
index 422dde5..6eb7fe7 100644 (file)
@@ -22,9 +22,6 @@
  */
 
 #include <vconf.h>
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
-#include <syspopup_caller.h>
-#endif
 
 #include "bluetooth-api.h"
 #include "bt-internal-types.h"
@@ -75,18 +72,15 @@ BT_EXPORT_API int bluetooth_check_adapter(void)
        ret = _bt_get_adapter_path(_bt_gdbus_get_system_gconn(), NULL);
 
        if (ret != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("error in get adapter ");
                return BLUETOOTH_ADAPTER_DISABLED;
        }
 
        /* check VCONFKEY_BT_STATUS */
        if (vconf_get_int(VCONFKEY_BT_STATUS, &value) != 0) {
-               BT_ERR("fail to get vconf key! return disabled");
+               BT_ERR("fail to get vconf key!");
                return BLUETOOTH_ADAPTER_DISABLED;
        }
 
-       BT_ERR("get status from vconf key \n");
-
        return value == VCONFKEY_BT_STATUS_OFF ? BLUETOOTH_ADAPTER_DISABLED :
                                                BLUETOOTH_ADAPTER_ENABLED;
 }
@@ -94,16 +88,21 @@ BT_EXPORT_API int bluetooth_check_adapter(void)
 BT_EXPORT_API int bluetooth_enable_adapter(void)
 {
        int result;
+       bt_user_info_t *user_info;
 
        BT_INFO("");
        retv_if(bluetooth_check_adapter() == BLUETOOTH_ADAPTER_ENABLED,
                                BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED);
 
+       user_info = _bt_get_user_data(BT_COMMON);
+       retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL);
+
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_ENABLE_ADAPTER,
-               in_param1, in_param2, in_param3, in_param4, &out_param);
+       result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_ENABLE_ADAPTER,
+               in_param1, in_param2, in_param3, in_param4,
+               user_info->cb, user_info->user_data);
 
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
@@ -113,16 +112,20 @@ BT_EXPORT_API int bluetooth_enable_adapter(void)
 BT_EXPORT_API int bluetooth_disable_adapter(void)
 {
        int result;
+       bt_user_info_t *user_info;
 
        BT_INFO("");
-
        BT_CHECK_ENABLED(return);
 
+       user_info = _bt_get_user_data(BT_COMMON);
+       retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL);
+
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_DISABLE_ADAPTER,
-               in_param1, in_param2, in_param3, in_param4, &out_param);
+       result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_DISABLE_ADAPTER,
+               in_param1, in_param2, in_param3, in_param4,
+               user_info->cb, user_info->user_data);
 
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
@@ -168,6 +171,7 @@ BT_EXPORT_API int bluetooth_get_local_address(bluetooth_device_address_t *local_
        int result;
 
        BT_CHECK_PARAMETER(local_address, return);
+       BT_CHECK_ENABLED_ANY(return);
 
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
@@ -212,6 +216,7 @@ BT_EXPORT_API int bluetooth_get_local_name(bluetooth_device_name_t *local_name)
        int result;
 
        BT_CHECK_PARAMETER(local_name, return);
+       BT_CHECK_ENABLED_ANY(return);
 
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
@@ -284,6 +289,25 @@ BT_EXPORT_API int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t
 
        BT_CHECK_PARAMETER(discoverable_mode_ptr, return);
 
+#ifndef TIZEN_WEARABLE
+       int timeout = 0;
+       /* Requirement in OSP */
+       if (bluetooth_check_adapter() == BLUETOOTH_ADAPTER_DISABLED) {
+               if (vconf_get_int(BT_FILE_VISIBLE_TIME, &timeout) != 0) {
+                       BT_ERR("Fail to get the timeout value");
+                       return BLUETOOTH_ERROR_INTERNAL;
+               }
+
+               if (timeout == -1) {
+                       *discoverable_mode_ptr = BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE;
+               } else {
+                       *discoverable_mode_ptr = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
+               }
+
+               return BLUETOOTH_ERROR_NONE;
+       }
+#endif
+
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
@@ -291,8 +315,7 @@ BT_EXPORT_API int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t
                in_param1, in_param2, in_param3, in_param4, &out_param);
 
        if (result == BLUETOOTH_ERROR_NONE) {
-               *discoverable_mode_ptr = g_array_index(out_param,
-                                       int, 0);
+               *discoverable_mode_ptr = g_array_index(out_param, int, 0);
        }
 
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
index 343f114..a816cb7 100644 (file)
@@ -57,13 +57,20 @@ BT_EXPORT_API int bluetooth_audio_init(bt_audio_func_ptr cb, void *user_data)
                return ret;
        }
 
+       ret = _bt_register_event(BT_A2DP_SOURCE_EVENT, (void *)cb, user_data);
+       if (ret != BLUETOOTH_ERROR_NONE &&
+                       ret != BLUETOOTH_ERROR_ALREADY_INITIALIZED) {
+               _bt_deinit_event_handler();
+               return ret;
+       }
+
        return BLUETOOTH_ERROR_NONE;
 }
 
 BT_EXPORT_API int bluetooth_audio_deinit(void)
 {
        _bt_unregister_event(BT_HEADSET_EVENT);
-
+       _bt_unregister_event(BT_A2DP_SOURCE_EVENT);
        _bt_set_user_data(BT_AUDIO, NULL, NULL);
 
        return BLUETOOTH_ERROR_NONE;
@@ -225,6 +232,37 @@ BT_EXPORT_API int bluetooth_av_connect(bluetooth_device_address_t *remote_addres
        return result;
 }
 
+BT_EXPORT_API int bluetooth_av_source_connect(bluetooth_device_address_t *remote_address)
+{
+       int result;
+       bt_user_info_t *user_info;
+
+       BT_CHECK_PARAMETER(remote_address, return);
+       BT_CHECK_ENABLED(return);
+
+       if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_AV_SOURCE_CONNECT)
+                == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+               BT_ERR("Don't have a privilege to use this API");
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       }
+
+       user_info = _bt_get_user_data(BT_AUDIO);
+       retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       BT_INIT_PARAMS();
+       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       g_array_append_vals(in_param1, remote_address, sizeof(bluetooth_device_address_t));
+
+       result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_AV_SOURCE_CONNECT,
+               in_param1, in_param2, in_param3, in_param4,
+               user_info->cb, user_info->user_data);
+
+       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       return result;
+}
+
 BT_EXPORT_API int bluetooth_av_disconnect(bluetooth_device_address_t *remote_address)
 {
        int result;
@@ -256,6 +294,37 @@ BT_EXPORT_API int bluetooth_av_disconnect(bluetooth_device_address_t *remote_add
        return result;
 }
 
+BT_EXPORT_API int bluetooth_av_source_disconnect(bluetooth_device_address_t *remote_address)
+{
+       int result;
+       bt_user_info_t *user_info;
+
+       BT_CHECK_PARAMETER(remote_address, return);
+       BT_CHECK_ENABLED(return);
+
+       if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_AV_SOURCE_DISCONNECT)
+            == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+               BT_ERR("Don't have a privilege to use this API");
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       }
+
+       user_info = _bt_get_user_data(BT_AUDIO);
+       retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       BT_INIT_PARAMS();
+       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       g_array_append_vals(in_param1, remote_address, sizeof(bluetooth_device_address_t));
+
+       result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_AV_SOURCE_DISCONNECT,
+               in_param1, in_param2, in_param3, in_param4,
+               user_info->cb, user_info->user_data);
+
+       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       return result;
+}
+
 BT_EXPORT_API int bluetooth_ag_get_headset_volume(unsigned int *speaker_gain)
 {
        int result;
@@ -356,6 +425,9 @@ static int __bt_hf_agent_read_call_list(DBusMessage *reply,
        BT_DBG("Call count = %d", call_count);
 
        *call_list = g_malloc0(sizeof(bt_hf_call_list_s));
+       /* Fix : NULL_RETURNS */
+       retv_if(*call_list == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
+
        (*call_list)->count = call_count;
        dbus_message_iter_next(&iter);
        dbus_message_iter_recurse(&iter, &iter_struct);
@@ -367,6 +439,8 @@ static int __bt_hf_agent_read_call_list(DBusMessage *reply,
                DBusMessageIter entry_iter;
 
                call_info = g_malloc0(sizeof(bt_hf_call_status_info_t));
+               /* Fix : NULL_RETURNS */
+               retv_if(call_info == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
 
                dbus_message_iter_recurse(&iter_struct,&entry_iter);
 
@@ -690,7 +764,8 @@ BT_EXPORT_API int bluetooth_hf_send_xsat_cmd(int app_id, char *xsat_cmd)
        BT_CHECK_ENABLED(return);
 
        strcpy(buffer, "AT+XSAT=");
-       snprintf(buffer + strlen(buffer), sizeof(buffer), "%d,", app_id);
+       /* Fix : OVERRUN */
+       snprintf(buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), "%d,", app_id);
        strncat(buffer, xsat_cmd, (sizeof(buffer) - 1) - strlen(buffer));
        BT_DBG("Xsat cmd received = %s", buffer);
        reply = __bt_hf_agent_dbus_send(BT_HF_OBJECT_PATH, BT_HF_INTERFACE,
@@ -940,7 +1015,7 @@ BT_EXPORT_API int bluetooth_hf_get_audio_connected(unsigned int *audio_connected
        return BLUETOOTH_ERROR_NONE;
 }
 
-BT_EXPORT_API int bluetooth_hf_is_hf_connected(gboolean *hf_connected)
+BT_EXPORT_API int bluetooth_hf_is_connected(gboolean *hf_connected)
 {
        DBusMessage *reply;
        DBusError err;
index b2864bb..e1699e5 100644 (file)
@@ -26,6 +26,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <stdlib.h>
+#include <security-server.h>
 #include <sys/socket.h>
 
 
@@ -46,13 +47,15 @@ static bt_user_info_t user_info[BT_MAX_USER_INFO];
 static DBusGConnection *system_conn = NULL;
 static GDBusConnection *system_gdbus_conn = NULL;
 
-static guint bus_id;
-
 static char *cookie;
 static size_t cookie_size;
 
+static guint bus_id;
+
 static GDBusConnection *system_gconn = NULL;
 
+#define DBUS_TIMEOUT 20 * 1000 /* 20 Seconds */
+
 GDBusConnection *_bt_gdbus_init_system_gconn(void)
 {
        GError *error = NULL;
@@ -156,6 +159,18 @@ void _bt_headset_event_cb(int event, int result, void *param,
                                        user_data);
 }
 
+void _bt_a2dp_source_event_cb(int event, int result, void *param,
+                                       void *callback, void *user_data)
+{
+       bt_audio_event_param_t bt_event = { 0, };
+       bt_event.event = event;
+       bt_event.result = result;
+       bt_event.param_data = param;
+       if (callback)
+               ((bt_audio_func_ptr)callback)(bt_event.event, &bt_event,
+                                       user_data);
+}
+
 void _bt_hf_event_cb(int event, int result, void *param,
                                        void *callback, void *user_data)
 {
@@ -293,31 +308,12 @@ static const gchar rfcomm_agent_xml[] =
 "          <arg type='h' name='fd' direction='in'/>"
 "          <arg type='a{sv}' name='properties' direction='in'/>"
 "     </method>"
+"     <method name='RequestDisconnection'>"
+"          <arg type='o' name='device' direction='in'/>"
+"     </method>"
 "  </interface>"
 "</node>";
 
-/* Remote socket address */
-struct sockaddr_remote {
-       sa_family_t     family;
-       bluetooth_device_address_t      remote_bdaddr;
-       unsigned char   channel;
-};
-
-static void __get_remote_address(int fd, bluetooth_device_address_t *bdaddr)
-{
-       struct sockaddr_remote address;
-       socklen_t address_len;
-
-       address_len = sizeof(address);
-       if (getpeername(fd, (struct sockaddr *) &address, &address_len) != 0) {
-               BT_DBG("getpeername failed");
-               return;
-       }
-
-       memcpy(bdaddr->addr, address.remote_bdaddr.addr,
-                                       BLUETOOTH_ADDRESS_LENGTH);
-}
-
 static void __new_connection_method(GDBusConnection *connection,
                                            const gchar *sender,
                                            const gchar *object_path,
@@ -335,7 +331,7 @@ static void __new_connection_method(GDBusConnection *connection,
                GVariantBuilder *properties;
                char *obj_path;
                char addr[20];
-               bluetooth_device_address_t remote_addr, remote_addr1;
+               bluetooth_device_address_t  remote_addr1;
                bt_new_connection_cb cb = user_data;
                int fd;
 
@@ -362,16 +358,18 @@ static void __new_connection_method(GDBusConnection *connection,
                        g_error_free(err);
                        return;
                }
+               BT_INFO("Object Path %s", obj_path);
 
-               __get_remote_address(fd, &remote_addr);
-               _bt_swap_addr(remote_addr1.addr, remote_addr.addr);
-               _bt_convert_addr_type_to_string(addr, remote_addr1.addr);
+               _bt_device_path_to_address(obj_path, addr);
+               _bt_convert_addr_string_to_type(remote_addr1.addr, (const char *)addr);
                BT_INFO("fd: %d, address %s", fd, addr);
 
                g_dbus_method_invocation_return_value(invocation, NULL);
 
                if (cb)
                        cb(object_path, fd, &remote_addr1);
+       } else if (g_strcmp0(method_name, "RequestDisconnection") == 0) {
+               g_dbus_method_invocation_return_value(invocation, NULL);
        }
 }
 
@@ -473,11 +471,37 @@ static GDBusProxy *__bt_gdbus_get_profile_proxy(void)
        if (err) {
                BT_ERR("Unable to create proxy: %s", err->message);
                g_clear_error(&err);
+               return NULL;
        }
 
        return profile_gproxy;
 }
 
+static GDBusProxy *__bt_gdbus_get_device_proxy(char *object_path)
+{
+       GDBusConnection *gconn;
+       GError *err = NULL;
+       GDBusProxy *device_gproxy;
+
+       gconn = __get_gdbus_connection();
+       if (gconn == NULL)
+               return NULL;
+
+       device_gproxy = g_dbus_proxy_new_sync(gconn, G_DBUS_PROXY_FLAGS_NONE,
+                                               NULL, BT_BLUEZ_NAME,
+                                               object_path,
+                                               BT_DEVICE_INTERFACE,
+                                               NULL, &err);
+
+       if (err) {
+               BT_ERR("Unable to create proxy: %s", err->message);
+               g_clear_error(&err);
+               return NULL;
+       }
+
+       return device_gproxy;
+}
+
 void _bt_unregister_gdbus(int object_id)
 {
        GDBusConnection *gconn;
@@ -520,6 +544,105 @@ int _bt_register_new_conn(const char *path, bt_new_connection_cb cb)
        return id;
 }
 
+static GDBusProxy * __bt_gdbus_get_adapter_proxy()
+{
+       GError *err = NULL;
+       GDBusProxy *manager_proxy = NULL;
+       GDBusProxy *adapter_proxy = NULL;
+       GDBusConnection *conn;
+       GVariant *result = NULL;
+       char *adapter_path = NULL;
+
+       conn = __get_gdbus_connection();
+       retv_if(conn == NULL, NULL);
+
+       manager_proxy =  g_dbus_proxy_new_sync(conn,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       BT_BLUEZ_NAME,
+                       BT_MANAGER_PATH,
+                       BT_MANAGER_INTERFACE,
+                       NULL, &err);
+
+       if (!manager_proxy) {
+               BT_ERR("Unable to create proxy: %s", err->message);
+               goto fail;
+       }
+
+       result = g_dbus_proxy_call_sync(manager_proxy, "DefaultAdapter", NULL,
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+       if (!result) {
+               if (err != NULL)
+                       BT_ERR("Fail to get DefaultAdapter (Error: %s)", err->message);
+               else
+                       BT_ERR("Fail to get DefaultAdapter");
+
+               goto fail;
+       }
+
+       if (g_strcmp0(g_variant_get_type_string(result), "(o)")) {
+               BT_ERR("Incorrect result\n");
+               goto fail;
+       }
+
+       g_variant_get(result, "(&o)", &adapter_path);
+
+       if (adapter_path == NULL ||
+               strlen(adapter_path) >= BT_ADAPTER_OBJECT_PATH_MAX) {
+               BT_ERR("Adapter path is inproper\n");
+               goto fail;
+       }
+
+       BT_INFO("Adapter Path %s", adapter_path);
+
+       adapter_proxy = g_dbus_proxy_new_sync(conn,
+                                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                                       BT_BLUEZ_NAME,
+                                       adapter_path,
+                                       BT_ADAPTER_INTERFACE,
+                                       NULL, &err);
+       if (err) {
+               BT_ERR("DBus Error message: [%s]", err->message);
+               g_clear_error(&err);
+       }
+
+fail:
+       if (manager_proxy)
+               g_object_unref(manager_proxy);
+       if (result)
+               g_variant_unref(result);
+       return adapter_proxy;
+}
+
+int _bt_register_new_conn_ex(const char *path, const char *bus_name,bt_new_connection_cb cb)
+{
+       GDBusConnection *gconn;
+       int id;
+       GError *error = NULL;
+
+       gconn = __get_gdbus_connection();
+       if (gconn == NULL)
+               return -1;
+
+       if (new_conn_node == NULL)
+               new_conn_node = _bt_get_gdbus_node_ex(rfcomm_agent_xml, bus_name);
+
+       if (new_conn_node == NULL)
+               return -1;
+
+       id = g_dbus_connection_register_object(gconn, path,
+                                               new_conn_node->interfaces[0],
+                                               &method_table,
+                                               cb, NULL, &error);
+       if (id == 0) {
+               BT_ERR("Failed to register: %s", error->message);
+               g_error_free(error);
+               return -1;
+       }
+
+       BT_DBG("NEW CONNECTION ID %d", id);
+
+       return id;
+}
 
 int _bt_register_profile(bt_register_profile_info_t *info, gboolean use_default_rfcomm)
 {
@@ -562,7 +685,6 @@ int _bt_register_profile(bt_register_profile_info_t *info, gboolean use_default_
                                                "Service",
                                                g_variant_new_string(info->service));
 
-
        ret = g_dbus_proxy_call_sync(proxy, "RegisterProfile",
                                        g_variant_new("(osa{sv})", info->obj_path,
                                                                info->uuid,
@@ -588,7 +710,7 @@ int _bt_register_profile(bt_register_profile_info_t *info, gboolean use_default_
        return result;
 }
 
-int _bt_register_profile_platform(bt_register_profile_info_t *info, gboolean use_default_rfcomm)
+int _bt_register_profile_ex(bt_register_profile_info_t *info, gboolean use_default_rfcomm, const char *name, const char *path)
 {
        GVariantBuilder *option_builder;
        GVariant *ret;
@@ -629,6 +751,73 @@ int _bt_register_profile_platform(bt_register_profile_info_t *info, gboolean use
                                                "Service",
                                                g_variant_new_string(info->service));
 
+       ret = g_dbus_proxy_call_sync(proxy, "RegisterProfile2",
+                                       g_variant_new("(osssa{sv})", info->obj_path,
+                                                               info->uuid,
+                                                               name,
+                                                               path,
+                                                               option_builder),
+                                       G_DBUS_CALL_FLAGS_NONE, -1,
+                                       NULL, &err);
+       if (err) {
+               BT_ERR("RegisterProfile failed: %s", err->message);
+
+               if (g_strrstr(err->message, BT_ACCESS_DENIED_MSG))
+                       result = BLUETOOTH_ERROR_ACCESS_DENIED;
+               else
+                       result = BLUETOOTH_ERROR_INTERNAL;
+
+               g_clear_error(&err);
+       }
+
+       g_variant_builder_unref(option_builder);
+
+       if (ret)
+               g_variant_unref(ret);
+
+       return result;
+}
+
+int _bt_register_profile_platform(bt_register_profile_info_t *info, gboolean use_default_rfcomm)
+{
+       GVariantBuilder *option_builder;
+       GVariant *ret;
+       GDBusProxy *proxy;
+       GError *err = NULL;
+       int result = BLUETOOTH_ERROR_NONE;
+
+       proxy = __bt_gdbus_get_profile_proxy();
+       if (proxy == NULL) {
+               BT_ERR("Getting profile proxy failed");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       option_builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       if (info->authentication)
+               g_variant_builder_add(option_builder, "{sv}",
+                                               "RequireAuthentication",
+                                               g_variant_new_boolean(TRUE));
+       if (info->authorization)
+               g_variant_builder_add(option_builder, "{sv}",
+                                               "RequireAuthorization",
+                                               g_variant_new_boolean(TRUE));
+       if (info->role)
+               g_variant_builder_add(option_builder, "{sv}",
+                                               "Role",
+                                               g_variant_new_string(info->role));
+
+       /* Setting RFCOMM channel to default value 0; would allow bluez to assign
+        * RFCOMM channels based on the availability when two services want
+        * to use the RFCOMM along with SPP. Hence bluez makes sure that no
+        * two services use the same SPP RFCOMM channel. */
+       if (use_default_rfcomm)
+               g_variant_builder_add(option_builder, "{sv}",
+                                               "Channel",
+                                               g_variant_new_uint16(RFCOMM_DEFAULT_PROFILE_CHANNEL));
+       if (info->service)
+               g_variant_builder_add(option_builder, "{sv}",
+                                               "Service",
+                                               g_variant_new_string(info->service));
 
        ret = g_dbus_proxy_call_sync(proxy, "RegisterProfile1",
                                        g_variant_new("(osa{sv})", info->obj_path,
@@ -636,6 +825,7 @@ int _bt_register_profile_platform(bt_register_profile_info_t *info, gboolean use
                                                                option_builder),
                                        G_DBUS_CALL_FLAGS_NONE, -1,
                                        NULL, &err);
+
        if (err) {
                BT_ERR("RegisterProfile failed: %s", err->message);
 
@@ -703,53 +893,74 @@ GDBusNodeInfo * _bt_get_gdbus_node(const gchar *xml_data)
        return g_dbus_node_info_new_for_xml(xml_data, NULL);
 }
 
+GDBusNodeInfo * _bt_get_gdbus_node_ex(const gchar *xml_data, const char *bus_name)
+{
+       if (bus_id == 0) {
+               char *name = g_strdup(bus_name);
+               bus_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
+                                               name,
+                                               G_BUS_NAME_OWNER_FLAGS_NONE,
+                                               NULL,
+                                               NULL,
+                                               NULL,
+                                               NULL,
+                                               NULL);
+               BT_DBG("Got bus id %d", bus_id);
+               g_free(name);
+       }
+
+       return g_dbus_node_info_new_for_xml(xml_data, NULL);
+}
+
 int _bt_connect_profile(char *address, char *uuid, void *cb,
                                                        gpointer func_data)
 {
+       GDBusProxy *proxy;
+       GDBusProxy *adapter_proxy;
        char *object_path;
-       DBusGProxy *proxy;
-       DBusGConnection *conn;
-       DBusGProxy *adapter_proxy;
-       GError *error = NULL;
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+       GError *err = NULL;
 
        object_path = _bt_get_device_object_path(address);
+
        if (object_path == NULL) {
+               GVariant *ret = NULL;
                BT_ERR("No searched device");
+               adapter_proxy = __bt_gdbus_get_adapter_proxy();
 
-               adapter_proxy = _bt_get_adapter_proxy(conn);
-               retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+               ret = g_dbus_proxy_call_sync(adapter_proxy, "CreateDevice",
+                               g_variant_new("(s)", address),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               DBUS_TIMEOUT, NULL,
+                               &err);
 
-               dbus_g_proxy_call(adapter_proxy, "CreateDevice", &error,
-                       G_TYPE_STRING, address,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
-
-               if (error != NULL) {
-                       BT_ERR("CreateDevice Fail: %s", error->message);
-                       g_error_free(error);
+               if (err != NULL) {
+                       BT_ERR("CreateDevice Failed: %s", err->message);
+                       g_clear_error(&err);
                }
-
+               if (ret)
+                       g_variant_unref(ret);
+               g_object_unref(adapter_proxy);
                object_path = _bt_get_device_object_path(address);
-       }
-       retv_if(object_path == NULL, BLUETOOTH_ERROR_INTERNAL);
 
+               if (object_path == NULL)
+                       return BLUETOOTH_ERROR_INTERNAL;
+       }
 
-       proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               object_path, BT_DEVICE_INTERFACE);
+       proxy = __bt_gdbus_get_device_proxy(object_path);
        g_free(object_path);
-       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       if (!dbus_g_proxy_begin_call(proxy, "ConnectProfile",
-                       (DBusGProxyCallNotify)cb,
-                       func_data, NULL,
-                       G_TYPE_STRING, uuid,
-                       G_TYPE_INVALID)) {
-               BT_ERR("Connect Dbus Call Error");
-               g_object_unref(proxy);
+       if (proxy == NULL) {
+               BT_ERR("Error while getting proxy");
                return BLUETOOTH_ERROR_INTERNAL;
        }
+
+       g_dbus_proxy_call(proxy, "ConnectProfile",
+                       g_variant_new("(s)", uuid),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       DBUS_TIMEOUT, NULL,
+                       (GAsyncReadyCallback)cb,
+                       func_data);
+       BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
 
@@ -757,50 +968,43 @@ int _bt_discover_services(char *address, char *uuid, void *cb,
                gpointer func_data)
 {
        char *object_path;
-       DBusGProxy *proxy;
-       DBusGConnection *conn;
-       DBusGProxy *adapter_proxy;
-       GError *error = NULL;
-
-       int timeout = 10000;
-       BT_DBG("+");
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
+       GDBusProxy *proxy;
+       GDBusProxy *adapter_proxy;
+       GError *err = NULL;
        object_path = _bt_get_device_object_path(address);
        if (object_path == NULL) {
+               GVariant *ret = NULL;
                BT_ERR("No searched device");
-
-               adapter_proxy = _bt_get_adapter_proxy(conn);
+               adapter_proxy = __bt_gdbus_get_adapter_proxy();
                retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-               dbus_g_proxy_call(adapter_proxy, "CreateDevice", &error,
-                       G_TYPE_STRING, address,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
-
-               if (error != NULL) {
-                       BT_ERR("CreateDevice Fail: %s", error->message);
-                       g_error_free(error);
+               ret = g_dbus_proxy_call_sync(adapter_proxy, "CreateDevice",
+                               g_variant_new("(s)", address),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               DBUS_TIMEOUT, NULL,
+                               &err);
+               if (err != NULL) {
+                       BT_ERR("CreateDevice Failed: %s", err->message);
+                       g_clear_error(&err);
                }
-
+               if (ret)
+                       g_variant_unref(ret);
+               g_object_unref(adapter_proxy);
                object_path = _bt_get_device_object_path(address);
+               if (object_path == NULL)
+                       return BLUETOOTH_ERROR_INTERNAL;
        }
-       retv_if(object_path == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               object_path, BT_DEVICE_INTERFACE);
+       proxy = __bt_gdbus_get_device_proxy(object_path);
        g_free(object_path);
-       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       if (!dbus_g_proxy_begin_call_with_timeout(proxy, "DiscoverServices",
-                       (DBusGProxyCallNotify)cb,
-                       func_data, NULL, timeout,
-                       G_TYPE_STRING, uuid,
-                       G_TYPE_INVALID)) {
-               BT_ERR("Error: While calling DiscoverServices");
-               g_object_unref(proxy);
+       if (proxy == NULL) {
+               BT_ERR("Error while getting proxy");
                return BLUETOOTH_ERROR_INTERNAL;
        }
+       g_dbus_proxy_call(proxy, "DiscoverServices",
+                       g_variant_new("(s)", uuid),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       DBUS_TIMEOUT, NULL,
+                       (GAsyncReadyCallback)cb,
+                       func_data);
        BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
@@ -808,122 +1012,231 @@ int _bt_discover_services(char *address, char *uuid, void *cb,
 int _bt_cancel_discovers(char *address)
 {
        char *object_path;
-       DBusGProxy *proxy;
-       DBusGConnection *conn;
-       BT_DBG("+");
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
+       GDBusProxy *proxy;
+       GDBusProxy *adapter_proxy;
+       GError *err = NULL;
        object_path = _bt_get_device_object_path(address);
-       retv_if(object_path == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               object_path, BT_DEVICE_INTERFACE);
+       if (object_path == NULL) {
+               GVariant *ret = NULL;
+               BT_ERR("No searched device");
+               adapter_proxy = __bt_gdbus_get_adapter_proxy();
+               retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+               ret = g_dbus_proxy_call_sync(adapter_proxy, "CreateDevice",
+                               g_variant_new("(s)", address),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               DBUS_TIMEOUT, NULL,
+                               &err);
+               if (err != NULL) {
+                       BT_ERR("CreateDevice Failed: %s", err->message);
+                       g_clear_error(&err);
+               }
+               if (ret)
+                       g_variant_unref(ret);
+               g_object_unref(adapter_proxy);
+               object_path = _bt_get_device_object_path(address);
+               if (object_path == NULL)
+                       return BLUETOOTH_ERROR_INTERNAL;
+       }
+       proxy = __bt_gdbus_get_device_proxy(object_path);
        g_free(object_path);
-       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-       if (!dbus_g_proxy_call(proxy,
-                       "CancelDiscovery",
-                       NULL,
-                       G_TYPE_INVALID, G_TYPE_INVALID)) {
-               BT_ERR("Error: while CancelDiscovery");
-               g_object_unref(proxy);
+       g_dbus_proxy_call_sync(proxy, "CancelDiscovery",
+               NULL,
+               G_DBUS_CALL_FLAGS_NONE,
+               DBUS_TIMEOUT, NULL,
+               &err);
+       if (err) {
+               BT_ERR("DBus Error message: [%s]", err->message);
+               g_clear_error(&err);
                return BLUETOOTH_ERROR_INTERNAL;
        }
-       g_object_unref(proxy);
-       BT_DBG("-");
+       if (proxy)
+               g_object_unref(proxy);
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_discover_service_uuids(char *address, char *remote_uuid)
 {
        char *object_path;
-       DBusGProxy *proxy;
-       DBusGConnection *conn;
-       GHashTable *hash = NULL;
-       GValue *value;
-       char **uuid_value;
+       GDBusProxy *proxy;
+       GDBusConnection *gconn;
+       GError *err = NULL;
+       char **uuid_value = NULL;
+       gsize size;
        int i =0;
+       GVariant *value = NULL;
+       GVariant *ret = NULL;
        int result = BLUETOOTH_ERROR_INTERNAL;
+       BT_INFO("+");
        retv_if(remote_uuid == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
+       gconn = __get_gdbus_connection();
+       retv_if(gconn == NULL, BLUETOOTH_ERROR_INTERNAL);
        object_path = _bt_get_device_object_path(address);
        retv_if(object_path == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               object_path, BT_PROPERTIES_INTERFACE);
-       g_free(object_path);
-
+       proxy = g_dbus_proxy_new_sync(gconn, G_DBUS_PROXY_FLAGS_NONE, NULL,
+                               BT_BLUEZ_NAME, object_path, BT_PROPERTIES_INTERFACE, NULL,
+                               &err);
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       if (!dbus_g_proxy_call(proxy, "GetAll", NULL,
-                       G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                       G_TYPE_INVALID,
-                       dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
-                       G_TYPE_VALUE), &hash, G_TYPE_INVALID)) {
-                       BT_ERR("Dbus error while GetAll");
-                       g_object_unref(proxy);
-                       return BLUETOOTH_ERROR_INTERNAL;
+       if (err) {
+               BT_ERR("DBus Error: [%s]", err->message);
+               g_clear_error(&err);
        }
-       g_object_unref(proxy);
-       BT_DBG("Remote uuids %s", remote_uuid);
-       value = g_hash_table_lookup(hash, "UUIDs");
-       if (value == NULL) {
-               BT_ERR("No uuids found");
+       ret = g_dbus_proxy_call_sync(proxy, "GetAll",
+                       g_variant_new("(s)", BT_DEVICE_INTERFACE),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       DBUS_TIMEOUT, NULL,
+                       &err);
+       if (err) {
+               result = BLUETOOTH_ERROR_INTERNAL;
+               BT_ERR("DBus Error : %s", err->message);
+               g_clear_error(&err);
                goto done;
        }
-
-       uuid_value = g_value_get_boxed(value);
-       if(uuid_value == NULL) {
-               BT_ERR("Error: while obtaining uuids");
+       if (ret == NULL) {
+               BT_ERR("g_dbus_proxy_call_sync function return NULL");
+               result = BLUETOOTH_ERROR_INTERNAL;
                goto done;
        }
 
-       for (i = 0; uuid_value[i] != NULL; i++) {
-               BT_DBG("Remote uuids %s", uuid_value[i]);
-               if (strcasecmp(uuid_value[i], remote_uuid) == 0) {
-                       result = BLUETOOTH_ERROR_NONE;
-                       goto done;
+       g_variant_get(ret, "(@a{sv})", &value);
+       g_variant_unref(ret);
+       if (value) {
+               GVariant *temp_value = g_variant_lookup_value(value, "UUIDs",
+                       G_VARIANT_TYPE_STRING_ARRAY);
+
+               size = g_variant_get_size(temp_value);
+               if (size > 0) {
+                       uuid_value = (char **)g_variant_get_strv(temp_value, &size);
+                       BT_DBG("Size items %d", size);
+               }
+               if (temp_value)
+                       g_variant_unref(temp_value);
+               for (i = 0; uuid_value[i] != NULL; i++) {
+                       BT_DBG("Remote uuids %s", uuid_value[i]);
+                       if (strcasecmp(uuid_value[i], remote_uuid) == 0) {
+                               result = BLUETOOTH_ERROR_NONE;
+                               goto done;
+                       }
                }
        }
-       BT_INFO("Specified uuid not found on remote device");
+
 done:
-       if (hash)
-               g_hash_table_destroy(hash);
+       if (proxy)
+               g_object_unref(proxy);
+       if (value)
+               g_variant_unref(value);
+       if (uuid_value)
+               g_free(uuid_value);
 
+       BT_DBG("-");
        return result;
 }
 
-int _bt_disconnect_profile(char *address, char *uuid, void *cb,
-                                                       gpointer func_data)
+int _bt_get_cod_by_address(char *address, bluetooth_device_class_t *dev_class)
 {
        char *object_path;
-       DBusGProxy *proxy;
-       DBusGConnection *conn;
+       GDBusProxy *proxy;
+       GDBusConnection *gconn;
+       GError *err = NULL;
+       GVariant *value = NULL;
+       GVariant *result = NULL;
+       unsigned int  class = 0x00;
+       int ret = BLUETOOTH_ERROR_INTERNAL;
 
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+       gconn = __get_gdbus_connection();
+       retv_if(gconn == NULL, BLUETOOTH_ERROR_INTERNAL);
+               object_path = _bt_get_device_object_path(address);
 
-       object_path = _bt_get_device_object_path(address);
        retv_if(object_path == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-
-       proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               object_path, BT_DEVICE_INTERFACE);
-       g_free(object_path);
+       proxy = g_dbus_proxy_new_sync(gconn, G_DBUS_PROXY_FLAGS_NONE, NULL,
+                               BT_BLUEZ_NAME, object_path, BT_PROPERTIES_INTERFACE, NULL,
+                               &err);
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+       if (err) {
+               BT_ERR("DBus Error: [%s]", err->message);
+               g_clear_error(&err);
+       }
 
-       if (!dbus_g_proxy_begin_call(proxy, "DisconnectProfile",
-                       (DBusGProxyCallNotify)cb,
-                       func_data, NULL,
-                       G_TYPE_STRING, uuid,
-                       G_TYPE_INVALID)) {
-               BT_ERR("Connect Dbus Call Error");
+       result = g_dbus_proxy_call_sync(proxy, "GetAll",
+                       g_variant_new("(s)", BT_DEVICE_INTERFACE),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       DBUS_TIMEOUT, NULL,
+                       &err);
+       if (err) {
+               ret = BLUETOOTH_ERROR_INTERNAL;
+               BT_ERR("DBus Error : %s", err->message);
+               g_clear_error(&err);
+               goto done;
+       }
+       if (result == NULL) {
+               BT_ERR("g_dbus_proxy_call_sync function return NULL");
+               ret = BLUETOOTH_ERROR_INTERNAL;
+               goto done;
+       }
+       g_variant_get(result, "(@a{sv})", &value);
+       g_variant_unref(result);
+       if (value) {
+               GVariant *temp_value = g_variant_lookup_value(value, "Class",
+                       G_VARIANT_TYPE_UINT32);
+               class = g_variant_get_uint32(temp_value);
+               _bt_divide_device_class(dev_class, class);
+               if (temp_value)
+                       g_variant_unref(temp_value);
+       }
+
+done:
+       if (proxy)
                g_object_unref(proxy);
+       if (value)
+               g_variant_unref(value);
+
+       BT_DBG("-");
+       return ret;
+}
+
+int _bt_disconnect_profile(char *address, char *uuid, void *cb,
+                                                       gpointer func_data)
+{
+       GDBusProxy *proxy;
+       char *object_path;
+       GError *err = NULL;
+       GDBusProxy *adapter_proxy;
+       object_path = _bt_get_device_object_path(address);
+       if (object_path == NULL) {
+               GVariant *ret = NULL;
+               BT_ERR("No searched device");
+               adapter_proxy = __bt_gdbus_get_adapter_proxy();
+               retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+               ret = g_dbus_proxy_call_sync(adapter_proxy, "CreateDevice",
+                               g_variant_new("(s)", address),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               DBUS_TIMEOUT, NULL,
+                               &err);
+               if (err != NULL) {
+                       BT_ERR("CreateDevice Failed: %s", err->message);
+                       g_error_free(err);
+               }
+               if (ret)
+                       g_variant_unref(ret);
+               g_object_unref(adapter_proxy);
+               object_path = _bt_get_device_object_path(address);
+               if (object_path == NULL)
+                       return BLUETOOTH_ERROR_INTERNAL;
+       }
+       proxy = __bt_gdbus_get_device_proxy(object_path);
+       g_free(object_path);
+       if (proxy == NULL) {
+               BT_ERR("Error while getting proxy");
                return BLUETOOTH_ERROR_INTERNAL;
        }
+       g_dbus_proxy_call(proxy, "DisconnectProfile",
+                       g_variant_new("(s)", uuid),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       DBUS_TIMEOUT, NULL,
+                       (GAsyncReadyCallback)cb,
+                       func_data);
+       BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
 
@@ -1016,132 +1329,74 @@ void _bt_convert_device_path_to_address(const char *device_path,
        }
 }
 
-static char *__bt_extract_adapter_path(DBusMessageIter *msg_iter)
+static char *__bt_extract_device_path(GVariantIter *iter, char *address)
 {
        char *object_path = NULL;
-       DBusMessageIter value_iter;
-
+       char device_address[BT_ADDRESS_STRING_SIZE] = { 0 };
        /* Parse the signature:  oa{sa{sv}}} */
-       retv_if(dbus_message_iter_get_arg_type(msg_iter) !=
-                               DBUS_TYPE_OBJECT_PATH, NULL);
-
-       dbus_message_iter_get_basic(msg_iter, &object_path);
-       retv_if(object_path == NULL, NULL);
+       while (g_variant_iter_loop(iter, "{&oa{sa{sv}}}", &object_path,
+                       NULL)) {
+               retv_if(object_path == NULL, NULL);
+               _bt_convert_device_path_to_address(object_path, device_address);
 
-       /* object array (oa) */
-       retv_if(dbus_message_iter_next(msg_iter) == FALSE, NULL);
-       retv_if(dbus_message_iter_get_arg_type(msg_iter) !=
-                               DBUS_TYPE_ARRAY, NULL);
-
-       dbus_message_iter_recurse(msg_iter, &value_iter);
-
-       /* string array (sa) */
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                                       DBUS_TYPE_DICT_ENTRY) {
-               char *interface_name = NULL;
-               DBusMessageIter interface_iter;
-
-               dbus_message_iter_recurse(&value_iter, &interface_iter);
-
-               retv_if(dbus_message_iter_get_arg_type(&interface_iter) !=
-                       DBUS_TYPE_STRING, NULL);
-
-               dbus_message_iter_get_basic(&interface_iter, &interface_name);
-
-               if (g_strcmp0(interface_name, "org.bluez.Adapter1") == 0) {
-                       /* Tizen don't allow the multi-adapter */
-                       BT_DBG("Found an adapter: %s", object_path);
+               if (g_strcmp0(address, device_address) == 0) {
                        return g_strdup(object_path);
                }
-
-               dbus_message_iter_next(&value_iter);
        }
-
-       return NULL;
-}
-
-static char *__bt_extract_device_path(DBusMessageIter *msg_iter, char *address)
-{
-       char *object_path = NULL;
-       char device_address[BT_ADDRESS_STRING_SIZE] = { 0 };
-
-       /* Parse the signature:  oa{sa{sv}}} */
-       retv_if(dbus_message_iter_get_arg_type(msg_iter) !=
-                               DBUS_TYPE_OBJECT_PATH, NULL);
-
-       dbus_message_iter_get_basic(msg_iter, &object_path);
-       retv_if(object_path == NULL, NULL);
-
-       _bt_convert_device_path_to_address(object_path, device_address);
-
-       if (g_strcmp0(address, device_address) == 0) {
-               return g_strdup(object_path);
-       }
-
        return NULL;
 }
 
 char *_bt_get_device_object_path(char *address)
 {
-       DBusMessage *msg;
-       DBusMessage *reply;
-       DBusMessageIter reply_iter;
-       DBusMessageIter value_iter;
-       DBusError err;
-       DBusConnection *conn;
+       GError *err = NULL;
+       GDBusProxy *proxy = NULL;
+       GVariant *result = NULL;
+       GVariantIter *iter = NULL;
+       GDBusConnection *conn = NULL;
        char *object_path = NULL;
 
-       conn = _bt_get_system_conn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, NULL);
 
-       msg = dbus_message_new_method_call(BT_BLUEZ_NAME, BT_MANAGER_PATH,
-                                               BT_MANAGER_INTERFACE,
-                                               "GetManagedObjects");
-
-       retv_if(msg == NULL, NULL);
-
-       /* Synchronous call */
-       dbus_error_init(&err);
-       reply = dbus_connection_send_with_reply_and_block(
-                                       conn, msg,
-                                       -1, &err);
-       dbus_message_unref(msg);
-
-       if (!reply) {
-               BT_ERR("Can't get managed objects");
+       proxy =  g_dbus_proxy_new_sync(conn,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       BT_BLUEZ_NAME,
+                       BT_MANAGER_PATH,
+                       BT_MANAGER_INTERFACE,
+                       NULL, &err);
 
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("%s", err.message);
-                       dbus_error_free(&err);
-               }
-               return NULL;
+       if (!proxy) {
+               BT_ERR("Unable to create proxy: %s", err->message);
+               goto fail;
        }
 
-       if (dbus_message_iter_init(reply, &reply_iter) == FALSE) {
-           BT_ERR("Fail to iterate the reply");
-           dbus_message_unref(reply);
-           return NULL;
-       }
+       result = g_dbus_proxy_call_sync(proxy, "GetManagedObjects", NULL,
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+       if (!result) {
+               if (err != NULL)
+                       BT_ERR("Fail to get GetManagedObjects (Error: %s)", err->message);
+               else
+                       BT_ERR("Fail to get GetManagedObjects");
 
-       dbus_message_iter_recurse(&reply_iter, &value_iter);
+               goto fail;
+       }
 
-       /* signature of GetManagedObjects:  a{oa{sa{sv}}} */
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                                               DBUS_TYPE_DICT_ENTRY) {
-               DBusMessageIter msg_iter;
+       g_variant_get(result, "(a{oa{sa{sv}}})", &iter);
+       object_path = __bt_extract_device_path(iter, address);
 
-               dbus_message_iter_recurse(&value_iter, &msg_iter);
+       g_variant_unref(result);
+       g_object_unref(proxy);
+       g_variant_iter_free(iter);
+       return object_path;
 
-               object_path = __bt_extract_device_path(&msg_iter, address);
-               if (object_path != NULL) {
-                       BT_DBG("Found the device path %s", object_path);
-                       break;
-               }
+fail:
+       g_clear_error(&err);
 
-               dbus_message_iter_next(&value_iter);
-       }
+       if (result)
+               g_variant_unref(result);
 
-       dbus_message_unref(reply);
+       if (proxy)
+               g_object_unref(proxy);
 
        return object_path;
 }
@@ -1149,12 +1404,43 @@ char *_bt_get_device_object_path(char *address)
 
 DBusGProxy *_bt_get_adapter_proxy(DBusGConnection *conn)
 {
+       GError *err = NULL;
+       DBusGProxy *manager_proxy = NULL;
        DBusGProxy *adapter_proxy = NULL;
+       char *adapter_path = NULL;
 
        retv_if(conn == NULL, NULL);
 
-       adapter_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                       BT_BLUEZ_HCI_PATH, BT_PROPERTIES_INTERFACE);
+       manager_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
+                               BT_MANAGER_PATH, BT_MANAGER_INTERFACE);
+
+       retv_if(manager_proxy == NULL, NULL);
+
+       if (!dbus_g_proxy_call(manager_proxy, "DefaultAdapter", &err,
+                               G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH,
+                               &adapter_path,
+                               G_TYPE_INVALID)) {
+               if (err != NULL) {
+                       BT_ERR("Getting DefaultAdapter failed: [%s]\n", err->message);
+                       g_error_free(err);
+               }
+               g_object_unref(manager_proxy);
+               return NULL;
+       }
+
+       if (adapter_path == NULL || strlen(adapter_path) >= BT_ADAPTER_OBJECT_PATH_MAX) {
+               BT_ERR("Adapter path is inproper\n");
+               g_free(adapter_path);
+               g_object_unref(manager_proxy);
+               return NULL;
+       }
+
+       adapter_proxy = dbus_g_proxy_new_for_name(conn,
+                                       BT_BLUEZ_NAME,
+                                       adapter_path,
+                                       BT_ADAPTER_INTERFACE);
+       g_free(adapter_path);
+       g_object_unref(manager_proxy);
 
        return adapter_proxy;
 }
@@ -1228,6 +1514,39 @@ DBusConnection *_bt_get_system_conn(void)
        return dbus_g_connection_get_connection(g_conn);
 }
 
+void _bt_generate_cookie(void)
+{
+       int retval;
+
+       ret_if(cookie != NULL);
+
+       cookie_size = security_server_get_cookie_size();
+
+       cookie = g_malloc0((cookie_size*sizeof(char))+1);
+
+       retval = security_server_request_cookie(cookie, cookie_size);
+       if(retval < 0) {
+               BT_ERR("Fail to get cookie: %d", retval);
+       }
+}
+
+void _bt_destroy_cookie(void)
+{
+       g_free(cookie);
+       cookie = NULL;
+       cookie_size = 0;
+}
+
+char *_bt_get_cookie(void)
+{
+       return cookie;
+}
+
+int _bt_get_cookie_size(void)
+{
+       return cookie_size;
+}
+
 int _bt_register_osp_server_in_agent(int type, char *uuid, char *path, int fd)
 {
        int ret;
@@ -1257,7 +1576,6 @@ int _bt_unregister_osp_server_in_agent(int type, char *uuid)
 {
        int ret;
        char uuid_str[BLUETOOTH_UUID_STRING_MAX] = { 0, };
-       char path_str[BLUETOOTH_PATH_STRING] = { 0, };
 
        BT_DBG("+");
        BT_INIT_PARAMS();
@@ -1389,6 +1707,7 @@ BT_EXPORT_API int bluetooth_register_callback(bluetooth_cb_func_ptr callback_ptr
                return ret;
        }
 
+       _bt_generate_cookie();
 
        _bt_set_user_data(BT_COMMON, (void *)callback_ptr, user_data);
 
@@ -1422,6 +1741,8 @@ BT_EXPORT_API int bluetooth_unregister_callback(void)
 {
        int ret;
 
+       _bt_destroy_cookie();
+
        ret = _bt_deinit_event_handler();
        if (ret != BLUETOOTH_ERROR_NONE) {
                BT_ERR("Fail to deinit the event handler");
index dadaed2..b46c014 100644 (file)
@@ -415,3 +415,29 @@ BT_EXPORT_API int bluetooth_le_conn_update(const bluetooth_device_address_t *add
 
        return result;
 }
+
+BT_EXPORT_API int bluetooth_get_connected_link_type(
+               const bluetooth_device_address_t *device_address,
+               bluetooth_connected_link_t *connected)
+{
+       int result;
+
+       BT_CHECK_PARAMETER(device_address, return);
+       BT_CHECK_ENABLED(return);
+
+       BT_INIT_PARAMS();
+       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
+
+       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_CONNECTED_LINK_TYPE,
+                       in_param1, in_param2, in_param3, in_param4, &out_param);
+
+       if (result == BLUETOOTH_ERROR_NONE) {
+               *connected = g_array_index(out_param, guint, 0);
+       }
+
+       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       return result;
+}
index 3292c6f..6db2141 100644 (file)
@@ -234,6 +234,9 @@ static int __bt_call_list_add(bt_hf_call_list_s *list, char * number,
        }
        handle = (bt_hf_call_list_s *)list;
        call_status = g_malloc0(sizeof(bt_hf_call_status_info_t));
+       /* Fix : NULL_RETURNS */
+       retv_if(call_status == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
+
        call_status->number = g_strdup(number);
        call_status->direction= dir;
        call_status->status = status;
@@ -252,7 +255,7 @@ static bluetooth_device_info_t *__bt_get_device_info_in_message(GVariant *parame
        unsigned int dev_class = 0;
        short rssi = 0;
        gboolean paired = FALSE;
-       gboolean connected = FALSE;
+       guint connected = 0;
        gboolean trust = FALSE;
        gsize uuid_count;
        int result = BLUETOOTH_ERROR_NONE;
@@ -262,7 +265,7 @@ static bluetooth_device_info_t *__bt_get_device_info_in_message(GVariant *parame
        GVariant *manufacturer_var = NULL;
        const char *manufacturer_data = NULL;
 
-       g_variant_get(parameters, "(i&sun&sbbb@asn@ay)", &result, &address,
+       g_variant_get(parameters, "(isunsbub@asn@ay)", &result, &address,
                        &dev_class, &rssi, &name, &paired,
                        &connected, &trust,  &string_var, &manufacturer_data_len, &manufacturer_var);
 
@@ -278,6 +281,11 @@ static bluetooth_device_info_t *__bt_get_device_info_in_message(GVariant *parame
                manufacturer_data = (char *)g_variant_get_data(manufacturer_var);
 
        dev_info = g_malloc0(sizeof(bluetooth_device_info_t));
+       /* Fix : NULL_RETURNS */
+       if (dev_info == NULL) {
+               result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
+               goto done;
+       }
 
        dev_info->rssi = rssi;
        dev_info->paired = paired;
@@ -303,7 +311,7 @@ static bluetooth_device_info_t *__bt_get_device_info_in_message(GVariant *parame
        if (manufacturer_data)
                for (i = 0; i < manufacturer_data_len; i++)
                        dev_info->manufacturer_data.data[i] = manufacturer_data[i];
-
+done:
        *ret = result;
        g_free(uuids);
        g_variant_unref(string_var);
@@ -339,7 +347,11 @@ static bluetooth_le_device_info_t *__bt_get_le_device_info_in_message(GVariant *
                scan_data = (char *)g_variant_get_data(scan_var);
 
        le_dev_info = g_malloc0(sizeof(bluetooth_le_device_info_t));
-
+       /* Fix : NULL_RETURNS */
+       if (le_dev_info == NULL) {
+               result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
+               goto done;
+       }
        _bt_convert_addr_string_to_type(le_dev_info->device_address.addr, address);
        le_dev_info->addr_type = addr_type;
        le_dev_info->rssi = rssi;
@@ -355,6 +367,7 @@ static bluetooth_le_device_info_t *__bt_get_le_device_info_in_message(GVariant *
                if (scan_data)
                        le_dev_info->scan_resp_data.data.data[i] = scan_data[i];
 
+done:
        *ret = result;
 
        g_variant_unref(adv_var);
@@ -367,6 +380,8 @@ gboolean __bt_reliable_disable_cb(gpointer user_data)
        BT_DBG("+");
        bt_event_info_t *event_info = user_data;
 
+       _bt_set_le_scan_status(FALSE);
+
        if (is_initialized != FALSE) {
                _bt_common_event_cb(BLUETOOTH_EVENT_DISABLED,
                                BLUETOOTH_ERROR_NONE, NULL,
@@ -444,6 +459,7 @@ void __bt_adapter_event_filter(GDBusConnection *connection,
                                        (GSourceFunc)__bt_reliable_disable_cb,
                                        event_info);
                }
+
                _bt_common_event_cb(BLUETOOTH_EVENT_DISABLED,
                                result, NULL,
                                event_info->cb, event_info->user_data);
@@ -487,19 +503,18 @@ void __bt_adapter_event_filter(GDBusConnection *connection,
                                result, NULL,
                                event_info->cb, event_info->user_data);
        } else if (strcasecmp(signal_name, BT_ADVERTISING_STARTED) == 0) {
-               bluetooth_advertising_params_t adv_params = {0, };
-
-               g_variant_get(parameters, "(idd)", &result,
-                               &adv_params.interval_min,
-                               &adv_params.interval_max);
+               int adv_handle;
 
+               g_variant_get(parameters, "(ii)", &result, &adv_handle);
                _bt_common_event_cb(BLUETOOTH_EVENT_ADVERTISING_STARTED,
-                               result, &adv_params,
+                               result, &adv_handle,
                                event_info->cb, event_info->user_data);
        } else if (strcasecmp(signal_name, BT_ADVERTISING_STOPPED) == 0) {
-               g_variant_get(parameters, "(i)", &result);
+               int adv_handle;
+
+               g_variant_get(parameters, "(ii)", &result, &adv_handle);
                _bt_common_event_cb(BLUETOOTH_EVENT_ADVERTISING_STOPPED,
-                               result, NULL,
+                               result, &adv_handle,
                                event_info->cb, event_info->user_data);
        } else if (strcasecmp(signal_name, BT_ADVERTISING_MANUFACTURER_DATA_CHANGED) == 0) {
                GVariant *var = NULL;
@@ -561,16 +576,6 @@ void __bt_adapter_event_filter(GDBusConnection *connection,
                                event_info->cb, event_info->user_data);
 
                g_free(device_info);
-       } else if (strcasecmp(signal_name, BT_DEVICE_DISAPPEARED) == 0) {
-               bluetooth_device_info_t *device_info;
-
-               device_info = __bt_get_device_info_in_message(parameters, &result);
-               ret_if(device_info == NULL);
-
-               _bt_common_event_cb(BLUETOOTH_EVENT_REMOTE_DEVICE_DISAPPEARED,
-                               result, device_info,
-                               event_info->cb, event_info->user_data);
-               g_free(device_info);
        } else if (strcasecmp(signal_name, BT_BOND_CREATED) == 0) {
                bluetooth_device_info_t *device_info;
 
@@ -724,6 +729,38 @@ void __bt_device_event_filter(GDBusConnection *connection,
                _bt_common_event_cb(BLUETOOTH_EVENT_GATT_DISCONNECTED,
                                result, &dev_address,
                                event_info->cb, event_info->user_data);
+       } else if (strcasecmp(signal_name, BT_GATT_CHAR_VAL_CHANGED) == 0) {
+               const char *char_handle = NULL;
+               int len = 0;
+               const char * value = NULL;
+               GVariant *char_value_var = NULL;
+               bt_gatt_char_value_t char_val = { 0, };
+               BT_DBG("BT_GATT_CHAR_VAL_CHANGED");
+
+               g_variant_get(parameters, "(i&s@ay)", &result, &char_handle, &char_value_var);
+
+               len = g_variant_get_size(char_value_var);
+               if (len > 0)
+                       value = (char *)g_variant_get_data(char_value_var);
+
+               char_val.char_handle = g_strdup(char_handle);
+               char_val.val_len = len;
+               /* Fix : FORWARD_NULL : g_variant_get_data can return NULL */
+               if (char_val.val_len > 0 && value != NULL) {
+                       char_val.char_value = (unsigned char*) g_malloc0(char_val.val_len);
+                       /* Fix : NULL_RETURNS */
+                       if (char_val.char_value == NULL) {
+                               BT_ERR("BLUETOOTH_ERROR_OUT_OF_MEMORY");
+                               g_free(char_val.char_handle);
+                               return;
+                       }
+                       memcpy(char_val.char_value, value, len);
+                       _bt_common_event_cb(BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED,
+                                       result, &char_val,
+                                       event_info->cb, event_info->user_data);
+                       g_free(char_val.char_value);
+               }
+               g_free(char_val.char_handle);
        } else if (strcasecmp(signal_name, BT_DEVICE_CONNECTED) == 0) {
                const char *address = NULL;
                unsigned char addr_type;
@@ -957,6 +994,21 @@ void __bt_headset_event_filter(GDBusConnection *connection,
                _bt_headset_event_cb(BLUETOOTH_EVENT_AV_DISCONNECTED,
                                result, address,
                                event_info->cb, event_info->user_data);
+       } else if (strcasecmp(signal_name, BT_A2DP_SOURCE_CONNECTED) == 0) {
+               char *address = NULL;
+
+               g_variant_get(parameters, "(i&s)", &result, &address);
+               _bt_a2dp_source_event_cb(BLUETOOTH_EVENT_AV_SOURCE_CONNECTED,
+                                               result, address,
+                                               event_info->cb, event_info->user_data);
+       } else if (strcasecmp(signal_name, BT_A2DP_SOURCE_DISCONNECTED) == 0) {
+               char *address = NULL;
+
+               g_variant_get(parameters, "(i&s)", &result, &address);
+
+               _bt_a2dp_source_event_cb(BLUETOOTH_EVENT_AV_SOURCE_DISCONNECTED,
+                                               result, address,
+                                               event_info->cb, event_info->user_data);
        } else if (strcasecmp(signal_name, BT_SPEAKER_GAIN) == 0) {
                unsigned int gain;
                guint16 spkr_gain;
@@ -984,6 +1036,93 @@ void __bt_headset_event_filter(GDBusConnection *connection,
        }
 }
 
+void __bt_hid_device_event_filter(GDBusConnection *connection,
+                                                const gchar *sender_name,
+                                                const gchar *object_path,
+                                                const gchar *interface_name,
+                                                const gchar *signal_name,
+                                                GVariant *parameters,
+                                                gpointer user_data)
+{
+       bt_event_info_t *event_info;
+       int result = BLUETOOTH_ERROR_NONE;
+
+       event_info = (bt_event_info_t *)user_data;
+       ret_if(event_info == NULL);
+
+       if (strcasecmp(object_path, BT_HID_DEVICE_PATH) != 0)
+               return;
+       if (strcasecmp(interface_name, BT_EVENT_SERVICE) != 0)
+               return;
+
+       ret_if(signal_name == NULL);
+
+       if (strcasecmp(signal_name, BT_HID_DEVICE_CONNECTED) == 0) {
+               const char *address = NULL;
+               bluetooth_device_address_t dev_address = { {0} };
+
+               g_variant_get(parameters, "(i&s)", &result, &address);
+
+               _bt_convert_addr_string_to_type(dev_address.addr,
+                                               address);
+
+               _bt_input_event_cb(BLUETOOTH_HID_DEVICE_CONNECTED,
+                               result, &dev_address,
+                               event_info->cb, event_info->user_data);
+       } else if (strcasecmp(signal_name, BT_HID_DEVICE_DISCONNECTED) == 0) {
+               const char *address = NULL;
+               bluetooth_device_address_t dev_address = { {0} };
+
+               g_variant_get(parameters, "(i&s)", &result, &address);
+
+               BT_DBG("address: %s", address);
+
+               _bt_convert_addr_string_to_type(dev_address.addr,
+                                               address);
+
+               _bt_input_event_cb(BLUETOOTH_HID_DEVICE_DISCONNECTED,
+                               result, &dev_address,
+                               event_info->cb, event_info->user_data);
+       }
+}
+void __bt_a2dp_source_event_filter(GDBusConnection *connection,
+                                                const gchar *sender_name,
+                                                const gchar *object_path,
+                                                const gchar *interface_name,
+                                                const gchar *signal_name,
+                                                GVariant *parameters,
+                                                gpointer user_data)
+{
+       bt_event_info_t *event_info;
+       int result = BLUETOOTH_ERROR_NONE;
+       event_info = (bt_event_info_t *)user_data;
+       ret_if(event_info == NULL);
+
+       if (strcasecmp(object_path, BT_A2DP_SOURCE_PATH) != 0)
+               return;
+       if (strcasecmp(interface_name, BT_EVENT_SERVICE) != 0)
+               return;
+
+       ret_if(signal_name == NULL);
+
+       if (strcasecmp(signal_name, BT_A2DP_SOURCE_CONNECTED) == 0) {
+               char *address = NULL;
+
+               g_variant_get(parameters, "(i&s)", &result, &address);
+               _bt_a2dp_source_event_cb(BLUETOOTH_EVENT_AV_SOURCE_CONNECTED,
+                                               result, address,
+                                               event_info->cb, event_info->user_data);
+       } else if (strcasecmp(signal_name, BT_A2DP_SOURCE_DISCONNECTED) == 0) {
+               char *address = NULL;
+
+               g_variant_get(parameters, "(i&s)", &result, &address);
+
+               _bt_a2dp_source_event_cb(BLUETOOTH_EVENT_AV_SOURCE_DISCONNECTED,
+                                               result, address,
+                                               event_info->cb, event_info->user_data);
+       }
+}
+
 void __bt_network_event_filter(GDBusConnection *connection,
                                                 const gchar *sender_name,
                                                 const gchar *object_path,
@@ -1216,7 +1355,6 @@ void __bt_avrcp_control_event_filter(GDBusConnection *connection,
                                result, &status,
                                event_info->cb, event_info->user_data);
        } else if (strcasecmp(signal_name, BT_MEDIA_TRACK_CHANGE) == 0) {
-               GVariant *var = NULL;
                media_metadata_attributes_t metadata;
                const char *title;
                const char *artist;
@@ -1581,30 +1719,44 @@ void __bt_pbap_client_event_filter(GDBusConnection *connection,
                return;
 
        ret_if(signal_name == NULL);
-
+       BT_DBG("Type: %s", g_variant_get_type_string(parameters));
        if (strcasecmp(signal_name, BT_PBAP_CONNECTED) == 0) {
                bt_pbap_connected_t connected = { { { 0 }, }, };
                char *address = NULL;
-               int enabled = -1;
-
-               g_variant_get(parameters, "(i&si)", &result, &address, &enabled);
 
+               g_variant_get(parameters, "(is)", &result, &address);
                BT_DBG("address: %s", address);
-               BT_DBG("enabled: %d", enabled);
 
                _bt_convert_addr_string_to_type(connected.btaddr.addr,
                                                address);
-               connected.connected = enabled;
+               if (result == 0)
+                       connected.connected = 1;
+               else
+                       connected.connected = 0;
 
                _bt_common_event_cb(BLUETOOTH_PBAP_CONNECTED,
                                result, &connected,
                                event_info->cb, event_info->user_data);
+       } else if (strcasecmp(signal_name, BT_PBAP_DISCONNECTED) == 0) {
+               bt_pbap_connected_t disconnected = { { { 0 }, }, };
+               char *address = NULL;
+
+               g_variant_get(parameters, "(is)", &result, &address);
+               BT_DBG("address: %s", address);
+
+               _bt_convert_addr_string_to_type(disconnected.btaddr.addr,
+                                               address);
+               disconnected.connected = 0;
+
+               _bt_common_event_cb(BLUETOOTH_PBAP_CONNECTED,
+                               result, &disconnected,
+                               event_info->cb, event_info->user_data);
        } else if (strcasecmp(signal_name, BT_PBAP_PHONEBOOK_SIZE) == 0) {
                bt_pbap_phonebook_size_t pb_size = { { { 0 }, }, };
                char *address = NULL;
                int size = 0;
 
-               g_variant_get(parameters, "(i&si)", &result, &address, &size);
+               g_variant_get(parameters, "(isi)", &result, &address, &size);
 
                BT_DBG("address: %s", address);
                BT_DBG("size: %d", size);
@@ -1622,7 +1774,7 @@ void __bt_pbap_client_event_filter(GDBusConnection *connection,
                char *vcf_file = NULL;
                int success = -1;
 
-               g_variant_get(parameters, "(i&s&si)", &result, &address, &vcf_file, &success);
+               g_variant_get(parameters, "(issi)", &result, &address, &vcf_file, &success);
 
                BT_DBG("address: %s", address);
                BT_DBG("vcf_file: %s", vcf_file);
@@ -1644,12 +1796,14 @@ void __bt_pbap_client_event_filter(GDBusConnection *connection,
                int success = -1;
                int i = 0;
 
-               g_variant_get(parameters, "(i&s@as)", &result, &address, &string_var);
+               g_variant_get(parameters, "(isv)", &result, &address, &string_var);
 
                list = (gchar **)g_variant_get_strv(string_var, &count);
 
                success = !result;
                BT_DBG("address: %s", address);
+               BT_DBG("result: %d", result);
+               BT_DBG("count: %d", count);
                for(i = 0; i < count; i++)
                        BT_DBG("%s", list[i]);
                BT_DBG("success: %d", success);
@@ -1671,7 +1825,7 @@ void __bt_pbap_client_event_filter(GDBusConnection *connection,
                char *vcf_file = NULL;
                int success = -1;
 
-               g_variant_get(parameters, "(i&s&si)", &result, &address, &vcf_file, &success);
+               g_variant_get(parameters, "(issi)", &result, &address, &vcf_file, &success);
 
                BT_DBG("address: %s", address);
                BT_DBG("vcf_file: %s", vcf_file);
@@ -1693,7 +1847,7 @@ void __bt_pbap_client_event_filter(GDBusConnection *connection,
                int success = -1;
                int i = 0;
 
-               g_variant_get(parameters, "(i&s@as)", &result, &address, &string_var);
+               g_variant_get(parameters, "(is@as)", &result, &address, &string_var);
 
                list = (gchar **)g_variant_get_strv(string_var, &count);
                success = !result;
@@ -2278,6 +2432,16 @@ int _bt_register_event(int event_type, void *event_cb, void *user_data)
                path = BT_HF_AGENT_PATH;
                interface = BT_HF_SERVICE_INTERFACE;
                break;
+       case BT_A2DP_SOURCE_EVENT:
+               BT_DBG("BT_A2DP_SOURCE_EVENT");
+               event_func = __bt_a2dp_source_event_filter;
+               path = BT_A2DP_SOURCE_PATH;
+               break;
+       case BT_HID_DEVICE_EVENT:
+               BT_DBG("BT_HID_DEVICE_EVENT");
+               event_func = __bt_hid_device_event_filter;
+               path = BT_HID_DEVICE_PATH;
+               break;
        default:
                BT_ERR("Unknown event");
                return BLUETOOTH_ERROR_INTERNAL;
index 081da9e..1d80967 100644 (file)
@@ -54,7 +54,7 @@ BT_EXPORT_API int bluetooth_gatt_free_service_property(bt_gatt_service_property_
 
        g_free(svc_pty->uuid);
        g_free(svc_pty->handle);
-       g_strfreev(svc_pty->handle_info.handle);
+       g_strfreev(svc_pty->include_handles.handle);
        g_strfreev(svc_pty->char_handle.handle);
 
        memset(svc_pty, 0, sizeof(bt_gatt_service_property_t));
@@ -109,6 +109,10 @@ static char **__get_string_array_from_gptr_array(GPtrArray *gp)
 
        path = g_malloc0((gp->len + 1) * sizeof(char *));
 
+       /* Fix : NULL_RETURNS */
+       if (path == NULL)
+               return NULL;
+
        for (i = 0; i < gp->len; i++) {
                gp_path = g_ptr_array_index(gp, i);
                path[i] = g_strdup(gp_path);
@@ -125,7 +129,7 @@ BT_EXPORT_API int bluetooth_gatt_get_service_property(const char *service_handle
        GError *error = NULL;
        GVariant *result = NULL;
        GDBusConnection *g_conn;
-       int len;
+       gsize len;
        char *char_handle = NULL;
        GPtrArray *gp_array  = NULL ;
        GVariantIter *property_iter, *char_iter;
@@ -184,8 +188,8 @@ BT_EXPORT_API int bluetooth_gatt_get_service_property(const char *service_handle
                                g_ptr_array_add(gp_array, (gpointer)char_handle);
                        }
                        if (gp_array->len != 0) {
-                               service->handle_info.count = gp_array->len;
-                               service->handle_info.handle =
+                               service->include_handles.count = gp_array->len;
+                               service->include_handles.handle =
                                                __get_string_array_from_gptr_array(gp_array);
                        }
                        g_ptr_array_free(gp_array, TRUE);
@@ -294,7 +298,6 @@ BT_EXPORT_API int bluetooth_gatt_get_service_from_uuid(bluetooth_device_address_
        GVariantIter *iter;
        GVariantIter *svc_iter;
        GVariantIter *interface_iter;
-       GError *error = NULL;
        char *object_path = NULL;
        char *interface_str = NULL;
        char device_address[BT_ADDRESS_STRING_SIZE] = { 0 };
@@ -397,7 +400,7 @@ static void __bluetooth_internal_get_char_cb(GDBusProxy *proxy,
        g_variant_get(value, "(v)", &char_value);
        g_variant_get(char_value, "ao", &char_iter);
 
-       int len = g_variant_get_size(char_iter);
+       int len = g_variant_get_size((GVariant *)char_iter);
        if (len > 0) {
                gp_array = g_ptr_array_new();
                for (i = 0; i < len; i++) {
@@ -510,7 +513,7 @@ BT_EXPORT_API int bluetooth_gatt_get_characteristics_property(
        const gchar *key;
        gchar* permission;
        char *char_desc_handle = NULL;
-       int len;
+       gsize len;
        GVariantIter *property_iter;
        GVariantIter *char_value_iter;
        GVariantIter *char_perm_iter;
@@ -644,7 +647,7 @@ void bluetooth_gatt_get_char_from_uuid_cb(GDBusProxy *proxy,
 
        g_variant_get(value, "(ao)", &char_iter);
 
-       len = g_variant_get_size(char_iter);
+       len = g_variant_get_size((GVariant *)char_iter);
 
        for (i = 0; i < len; i++) {
                g_variant_iter_loop(char_iter, "o",  &char_handle);
@@ -722,7 +725,7 @@ BT_EXPORT_API int bluetooth_gatt_get_char_descriptor_property(
        GVariantIter *property_iter;
        const gchar *key;
        guint8 char_value;
-       int len;
+       gsize len;
        GVariant *value = NULL;
        GByteArray *gb_array = NULL;
        GVariantIter *desc_value_iter;
@@ -968,6 +971,65 @@ static void __bluetooth_internal_write_cb(GObject *source_object,
        return;
 }
 
+BT_EXPORT_API int bluetooth_gatt_set_characteristics_value_by_type(
+               const char *char_handle, const guint8 *value, int length, guint8 write_type)
+{
+       GVariant *val;
+       GVariantBuilder *builder;
+       GDBusConnection *conn;
+       int i = 0;
+       int ret = BLUETOOTH_ERROR_NONE;
+
+       BT_CHECK_PARAMETER(char_handle, return);
+       BT_CHECK_PARAMETER(value, return);
+       retv_if(length == 0, BLUETOOTH_ERROR_INVALID_PARAM);
+       BT_CHECK_ENABLED(return);
+
+       conn = _bt_gdbus_get_system_gconn();
+       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
+
+       for (i = 0; i < length; i++) {
+               g_variant_builder_add(builder, "y", value[i]);
+       }
+
+       val = g_variant_new("ay", builder);
+
+       if (write_type ==
+               BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_WRITE_NO_RESPONSE) {
+               g_dbus_connection_call(conn,
+                               BT_BLUEZ_NAME,
+                               char_handle,
+                               GATT_CHAR_INTERFACE,
+                               "WriteValuebyType",
+                               g_variant_new("(y@ay)", write_type, val),
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1, NULL,
+                               (GAsyncReadyCallback)__bluetooth_internal_write_cb,
+                               NULL);
+       } else if (write_type ==
+                       BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_WRITE) {
+               g_dbus_connection_call(conn,
+                               BT_BLUEZ_NAME,
+                               char_handle,
+                               GATT_CHAR_INTERFACE,
+                               "WriteValuebyType",
+                               g_variant_new("(y@ay)", write_type, val),
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1, NULL,
+                               (GAsyncReadyCallback)__bluetooth_internal_write_cb,
+                               NULL);
+       } else
+               ret = BLUETOOTH_ERROR_INVALID_PARAM;
+
+
+       g_variant_builder_unref(builder);
+       return ret;
+}
+
 BT_EXPORT_API int bluetooth_gatt_set_characteristics_value_request(
                        const char *char_handle, const guint8 *value, int length)
 {
@@ -1022,8 +1084,8 @@ static int __bluetooth_gatt_descriptor_iter(const char *char_handle,
        GVariant *result = NULL;
        GDBusConnection *g_conn;
        int i, ret = BLUETOOTH_ERROR_NONE;
-       char *uuid = NULL;
-       int len = 0;
+       const char *uuid = NULL;
+       gsize len = 0;
        GVariantIter *desc_value_iter, *property_iter;
        const gchar *key;
        char_descriptor_type_t desc_type = TYPE_NONE;
@@ -1090,10 +1152,10 @@ static int __bluetooth_gatt_descriptor_iter(const char *char_handle,
                                case USER_DESC:
                                        BT_DBG("User descriptor");
                                        g_variant_get(value, "ay", &desc_value_iter);
-                                       len = g_variant_get_size(desc_value_iter);
+                                       len = g_variant_get_size((GVariant *)desc_value_iter);
 
                                        if (len > 0) {
-                                               characteristic->description = (guint8 *)g_malloc0(len + 1);
+                                               characteristic->description = (char *)g_malloc0(len + 1);
                                                if (!characteristic->description) {
                                                        ret = BLUETOOTH_ERROR_OUT_OF_MEMORY;
                                                        goto done;
@@ -1111,6 +1173,7 @@ static int __bluetooth_gatt_descriptor_iter(const char *char_handle,
                                case SERVER_CONF :
                                        BT_DBG(" SERVER_CONF");
                                        break;
+                               default:break;
                        }
                }
        }
@@ -1164,7 +1227,7 @@ static void bluetooth_gatt_get_char_desc_cb(GDBusProxy *proxy,
        g_variant_get(value, "(v)", &char_value);
        g_variant_get(char_value, "ao", &char_iter);
 
-       int len = g_variant_get_size(char_iter);
+       int len = g_variant_get_size((GVariant *)char_iter);
        if (len > 0) {
                for (i = 0; i < len; i++) {
                        g_variant_iter_loop(char_iter, "o",  &char_handle);
@@ -1264,8 +1327,8 @@ static void __bluetooth_internal_read_desc_cb(GObject *source_object,
        }
 
        if (gp_byte_array->len != 0) {
-               char_value.val_len = gp_byte_array->len;
-               char_value.description= gp_byte_array->data;
+               char_value.val_len = (unsigned int )gp_byte_array->len;
+               char_value.description= (char *)gp_byte_array->data;
        }
 
        if (user_info) {
@@ -1396,8 +1459,6 @@ BT_EXPORT_API int bluetooth_gatt_watch_characteristics(const char *char_handle)
        GError *error = NULL;
        int ret = BLUETOOTH_ERROR_NONE;
        BT_DBG("+");
-/* Implementation in Bluez is not complete */
-#if 0
        BT_CHECK_PARAMETER(char_handle, return);
 
        BT_CHECK_ENABLED(return);
@@ -1419,23 +1480,36 @@ BT_EXPORT_API int bluetooth_gatt_watch_characteristics(const char *char_handle)
 
        if (error) {
                BT_ERR("Watch Failed: %s", error->message);
+               if (g_strrstr(error->message, "Already notifying"))
+                       ret = BLUETOOTH_ERROR_NONE;
+               else if (g_strrstr(error->message, "In Progress"))
+                       ret = BLUETOOTH_ERROR_IN_PROGRESS;
+               else if (g_strrstr(error->message, "Operation is not supported"))
+                       ret = BLUETOOTH_ERROR_NOT_SUPPORT;
+/*failed because of either Insufficient Authorization or Write Not Permitted */
+               else if (g_strrstr(error->message, "Write not permitted") ||
+                               g_strrstr(error->message, "Operation Not Authorized"))
+                       ret = BLUETOOTH_ERROR_PERMISSION_DEINED;
+/* failed because of either Insufficient Authentication,
+       Insufficient Encryption Key Size, or Insufficient Encryption. */
+               else if (g_strrstr(error->message, "Not paired"))
+                       ret = BLUETOOTH_ERROR_NOT_PAIRED;
+               else
+                       ret = BLUETOOTH_ERROR_INTERNAL;
+
                g_clear_error(&error);
-               ret = BLUETOOTH_ERROR_INTERNAL;
        }
-#endif
        BT_DBG("-");
        return ret;
 }
 
-BT_EXPORT_API int bluetooth_gatt_unwatch_characteristics(const char *service_handle)
+BT_EXPORT_API int bluetooth_gatt_unwatch_characteristics(const char *char_handle)
 {
 
        GDBusConnection *conn;
        GError *error = NULL;
        int ret = BLUETOOTH_ERROR_NONE;
        BT_DBG("+");
-/* Implementation in Bluez is not complete */
-#if 0
        BT_CHECK_PARAMETER(char_handle, return);
 
        BT_CHECK_ENABLED(return);
@@ -1460,7 +1534,6 @@ BT_EXPORT_API int bluetooth_gatt_unwatch_characteristics(const char *service_han
                g_clear_error(&error);
                ret =  BLUETOOTH_ERROR_INTERNAL;
        }
-#endif
        BT_DBG("-");
        return ret;
 }
index a9b670f..c027d40 100644 (file)
@@ -96,6 +96,13 @@ static const gchar properties_introspection_xml[] =
 "              <arg type='s' name='name' direction='in'/>"
 "              <arg type='v' name='value' direction='in'/>"
 "       </method>"
+"       <method name='ReadValue'>"
+"              <arg type='s' name='address' direction='in'/>"
+"              <arg type='s' name='path' direction='in'/>"
+"              <arg type='y' name='id' direction='in'/>"
+"              <arg type='q' name='offset' direction='in'/>"
+"              <arg type='ay' name='Value' direction='out'/>"
+"       </method>"
 "  </interface>"
 "</node>";
 
@@ -128,7 +135,15 @@ struct gatt_desc_info {
        int value_length;
 };
 
+struct gatt_req_info {
+       gchar *attr_path;
+       gchar *svc_path;
+       guint  request_id;
+       guint  offset;
+};
+
 static GSList *gatt_services = NULL;
+static GSList *gatt_requests = NULL;
 
 #define BT_GATT_SERVICE_NAME   "org.frwk.gatt_service"
 #define BT_GATT_SERVICE_PATH "/org/frwk/gatt_service"
@@ -142,6 +157,11 @@ static GSList *gatt_services = NULL;
 
 static GDBusProxy *manager_gproxy = NULL;
 
+static struct gatt_char_info *__bt_gatt_find_gatt_char_info(
+                       const char *service_path, const char *char_path);
+
+static struct gatt_req_info *__bt_gatt_find_request_info(guint request_id);
+
 static void __bt_gatt_manager_method_call(GDBusConnection *connection,
                                        const gchar *sender,
                                        const gchar *object_path,
@@ -352,6 +372,80 @@ static void __bt_gatt_prop_method_call(GDBusConnection *connection,
                                        GDBusMethodInvocation *invocation,
                                        gpointer user_data)
 {
+       GVariantBuilder *inner_builder = NULL;
+       int i;
+
+       if (g_strcmp0(method_name, "ReadValue") == 0) {
+               gchar *addr = NULL;
+               gchar *attr_path = NULL;
+               guint8 req_id = 1;
+               guint16 offset = 0;
+               bt_gatt_read_req_t read_req = {0, };
+               bt_user_info_t *user_info = NULL;
+               struct gatt_req_info *req_info = NULL;
+
+               g_variant_get(parameters, "(&s&syq)", &addr, &attr_path, &req_id, &offset);
+
+               BT_DBG("Application path = %s", object_path);
+               BT_DBG("Attribute path = %s", attr_path);
+
+               BT_DBG("Remote Device address number = %s", addr);
+               BT_DBG("Request id = %d, Offset = %d", req_id, offset);
+
+               BT_DBG("Sender = %s", sender);
+
+               read_req.char_handle = g_strdup(attr_path);
+               read_req.address = g_strdup(addr);
+               read_req.req_id = req_id;
+               read_req.offset = offset;
+               user_info = _bt_get_user_data(BT_COMMON);
+
+               /* Store requets information */
+               req_info = g_new0(struct gatt_req_info, 1);
+               req_info->attr_path = g_strdup(attr_path);
+               req_info->svc_path = g_strdup(object_path);
+               req_info->request_id= req_id;
+               req_info->offset = offset;
+               gatt_requests = g_slist_append(gatt_requests, req_info);
+
+               inner_builder = g_variant_builder_new(G_VARIANT_TYPE ("ay"));
+
+               if (user_info != NULL) {
+                       struct gatt_char_info *char_info;
+
+                       read_req.service_handle = g_strdup(object_path);
+                       _bt_common_event_cb(
+                               BLUETOOTH_EVENT_GATT_SERVER_READ_REQUESTED,
+                               BLUETOOTH_ERROR_NONE, &read_req,
+                               user_info->cb, user_info->user_data);
+
+                       char_info = __bt_gatt_find_gatt_char_info(req_info->svc_path, req_info->attr_path);
+                       if (char_info) {
+                               for (i = req_info->offset; i < char_info->value_length; i++)
+                                       g_variant_builder_add(inner_builder, "y", char_info->char_value[i]);
+                       }
+               }
+
+               g_dbus_method_invocation_return_value(invocation,
+                                       g_variant_new("(ay)", inner_builder));
+               if (inner_builder)
+                       g_variant_builder_unref(inner_builder);
+
+               if (read_req.char_handle)
+                       g_free(read_req.char_handle);
+               if (read_req.address)
+                       g_free(read_req.address);
+
+               gatt_requests = g_slist_remove(gatt_requests, req_info);
+               if (req_info->attr_path)
+                       g_free(req_info->attr_path);
+               if (req_info->svc_path)
+                       g_free(req_info->svc_path);
+
+               g_free(req_info);
+
+               return;
+       }
        g_dbus_method_invocation_return_value(invocation, NULL);
 }
 
@@ -413,13 +507,16 @@ static gboolean __bt_gatt_char_set_property(GDBusConnection *connection,
                int len = 0, i;
 
                g_variant_get(value, "ay", &var);
-               len = g_variant_get_size(var);
+               len = g_variant_get_size((GVariant *)value);
+               BT_DBG("length of characteristic value = %d", len);
 
-               char_val.char_handle = object_path;
+               char_val.char_handle = (char *)object_path;
                if (len > 0) {
                        char_val.char_value = (guint8 *)malloc(len);
-                       if (!char_val.char_value)
+                       if (!char_val.char_value) {
+                               g_variant_iter_free(var);
                                return FALSE;
+                       }
                }
                for (i = 0; i < len; i++)
                        g_variant_iter_loop(var, "y",  &char_val.char_value[i]);
@@ -431,12 +528,12 @@ static gboolean __bt_gatt_char_set_property(GDBusConnection *connection,
                                BLUETOOTH_ERROR_NONE, &char_val,
                                user_info->cb, user_info->user_data);
 
-               bluetooth_gatt_update_characteristic(object_path, char_val.char_value,
+               bluetooth_gatt_update_characteristic(object_path, (const char *)char_val.char_value,
                                                                        char_val.val_len);
 
                free(char_val.char_value);
+               g_variant_iter_free(var);
        }
-
        return TRUE;
 }
 
@@ -591,6 +688,56 @@ static struct gatt_desc_info *__bt_gatt_find_gatt_desc_info(
        return NULL;
 }
 
+static struct gatt_req_info *__bt_gatt_find_request_info(guint request_id)
+{
+       GSList *l;
+
+       for (l = gatt_requests; l != NULL; l = l->next) {
+               struct gatt_req_info *req_info = l->data;
+
+               if (req_info && req_info->request_id == request_id) {
+                       return req_info;
+               }
+       }
+       BT_ERR("Gatt Request not found");
+       return NULL;
+}
+
+static int char_info_cmp(gconstpointer a1, gconstpointer a2)
+{
+       const struct gatt_char_info *attrib1 = a1;
+       const struct gatt_char_info *attrib2 = a2;
+
+       return g_strcmp0(attrib1->char_path, attrib2->char_path);
+}
+
+static void __bt_gatt_update_attribute_info(struct gatt_req_info *req_info,
+                       char *value, int value_length)
+{
+       GSList *l1, *l2;
+       int found = 0;
+       for (l1 = gatt_services; l1 != NULL; l1 = l1->next) {
+               struct gatt_service_info *serv_info = l1->data;
+
+               if (serv_info && g_strcmp0(serv_info->serv_path, req_info->svc_path) == 0) {
+
+                       for (l2 = serv_info->char_data; l2 != NULL; l2 = l2->next) {
+                               struct gatt_char_info *char_info = l2->data;
+
+                               if (char_info && g_strcmp0(char_info->char_path, req_info->attr_path)
+                                                       == 0) {
+                                       memcpy(&char_info->char_value[req_info->offset], value, value_length);
+                                       serv_info->char_data = g_slist_insert_sorted (serv_info->char_data, char_info, char_info_cmp);
+                                       found = 1;
+                                       break;
+                               }
+                       }
+               }
+               if (found)
+                       break;
+       }
+}
+
 
 static GDBusProxy *__bt_gatt_gdbus_init_manager_proxy(const gchar *service,
                                const gchar *path, const gchar *interface)
@@ -755,9 +902,9 @@ void get_service_cb(GObject *object, GAsyncResult *res, gpointer user_data)
        GVariantIter *iter = NULL;
        const gchar *key = NULL;
        GVariant *value = NULL;
-       gchar *service = NULL;
-       gchar *characteristic = NULL;
-       gchar *descriptor = NULL;
+       const gchar *service = NULL;
+       const gchar *characteristic = NULL;
+       const gchar *descriptor = NULL;
        int n_char = 1;
 
        BT_DBG(" ");
@@ -796,7 +943,7 @@ void get_service_cb(GObject *object, GAsyncResult *res, gpointer user_data)
                 * Send respponse to CAPI layer. */
 
                g_variant_unref(result);
-               if (char_cmp);
+               if (char_cmp)
                        g_free(char_cmp);
        }
 }
@@ -905,7 +1052,6 @@ static GDBusConnection *__bt_gatt_get_gdbus_connection(void)
 
 BT_EXPORT_API int bluetooth_gatt_init(void)
 {
-       guint object_id;
        GDBusConnection *conn;
        GDBusNodeInfo *obj_info;
        GError *error = NULL;
@@ -1170,6 +1316,7 @@ BT_EXPORT_API int bluetooth_gatt_set_characteristic_value(
        GVariant *char_val = NULL;
        GError *error = NULL;
        int i = 0;
+       int res = BLUETOOTH_ERROR_NONE;
 
        line_argv = g_strsplit_set(characteristic, "/", 0);
        serv_path = g_strdup_printf("/%s", line_argv[1]);
@@ -1177,13 +1324,20 @@ BT_EXPORT_API int bluetooth_gatt_set_characteristic_value(
        char_info = __bt_gatt_find_gatt_char_info(serv_path, characteristic);
 
        if (char_info == NULL) {
-               g_strfreev(line_argv);
-               return BLUETOOTH_ERROR_INVALID_PARAM;
+               /* Fix : RESOURCE_LEAK */
+               res = BLUETOOTH_ERROR_INVALID_PARAM;
+               goto done;
        }
 
        char_info->value_length = value_length;
 
        char_info->char_value = (char *)malloc(value_length);
+       /* Fix : NULL_RETURNS */
+       if (char_info->char_value == NULL) {
+               res = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
+               goto done;
+       }
+
        for (i = 0; i < value_length; i++)
                char_info->char_value[i] = char_value[i];
 
@@ -1210,12 +1364,14 @@ BT_EXPORT_API int bluetooth_gatt_set_characteristic_value(
                        char_info->char_path, builder),
                        &error);
 
-       g_strfreev(line_argv);
        g_variant_builder_unref(inner_builder);
        g_variant_builder_unref(builder);
        g_variant_builder_unref(builder1);
+done:
+       g_strfreev(line_argv);
+       g_free(serv_path);
 
-       return BLUETOOTH_ERROR_NONE;
+       return res;
 }
 
 BT_EXPORT_API int bluetooth_gatt_add_descriptor(
@@ -1243,9 +1399,6 @@ BT_EXPORT_API int bluetooth_gatt_add_descriptor(
        serv_path = g_strdup_printf("/%s", line_argv[1]);
 
        char_info = __bt_gatt_find_gatt_char_info(serv_path, char_path);
-
-       g_free(serv_path);
-
        if (char_info == NULL) {
                g_strfreev(line_argv);
                return BLUETOOTH_ERROR_INVALID_PARAM;
@@ -1334,13 +1487,19 @@ BT_EXPORT_API int bluetooth_gatt_set_descriptor_value(
 
        desc_info = __bt_gatt_find_gatt_desc_info(serv_path, char_path, desc_path);
 
-       if (desc_info == NULL) {
-               g_strfreev(line_argv);
-               return BLUETOOTH_ERROR_INVALID_PARAM;
-       }
+       /* Free the allocated memory */
+       g_strfreev(line_argv);
+       g_free(serv_path);
+       g_free(char_path);
+
+       /* Fix : NULL_RETURNS */
+       retv_if(desc_info == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
 
        desc_info->desc_value = (char *)malloc(value_length);
 
+       /* Fix : NULL_RETURNS */
+       retv_if(desc_info->desc_value == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
+
        for (i = 0; i < value_length; i++)
                desc_info->desc_value[i] = desc_value[i];
 
@@ -1368,7 +1527,6 @@ BT_EXPORT_API int bluetooth_gatt_set_descriptor_value(
                                desc_info->desc_path, builder),
                                &error);
 
-       g_strfreev(line_argv);
        g_variant_builder_unref(inner_builder);
        g_variant_builder_unref(builder);
        g_variant_builder_unref(builder1);
@@ -1495,10 +1653,8 @@ BT_EXPORT_API int bluetooth_gatt_update_characteristic(
        if (!__bt_gatt_get_service_state(serv_path)) {
                BT_DBG("service not registered for this characteristic \n");
                g_strfreev(line_argv);
-               g_free(serv_path);
                return BLUETOOTH_ERROR_INTERNAL;
        }
-       g_free(serv_path);
 
        outer_builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
        invalidated_builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
@@ -1606,7 +1762,7 @@ BT_EXPORT_API int bluetooth_gatt_unregister_service(const char *svc_path)
                struct gatt_service_info *info = tmp->data;
 
                if (g_strcmp0(info->serv_path, svc_path) == 0) {
-                       g_slist_delete_link(gatt_services, tmp->data);
+                       gatt_services = g_slist_delete_link(gatt_services, tmp->data);
                }
        }
 
@@ -1617,3 +1773,18 @@ BT_EXPORT_API int bluetooth_gatt_unregister_service(const char *svc_path)
 
        return err;
 }
+
+BT_EXPORT_API int bluetooth_gatt_send_response(int request_id,
+                                               int offset, char *value, int value_length)
+{
+       struct gatt_req_info *req_info = NULL;
+
+       req_info = __bt_gatt_find_request_info(request_id);
+
+       if (req_info) {
+               __bt_gatt_update_attribute_info(req_info, value, value_length);
+       } else
+               return BLUETOOTH_ERROR_INTERNAL;
+
+       return BLUETOOTH_ERROR_NONE;
+}
diff --git a/bt-api/bt-gatt.c b/bt-api/bt-gatt.c
deleted file mode 100644 (file)
index 725c2e1..0000000
+++ /dev/null
@@ -1,863 +0,0 @@
-/*
- * bluetooth-frwk
- *
- * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *              http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <string.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <glib.h>
-
-#include "bluetooth-api.h"
-#include "bt-common.h"
-#include "bt-internal-types.h"
-
-
-#define BLUEZ_CHAR_INTERFACE "org.bluez.Characteristic"
-
-#define GATT_OBJECT_PATH  "/org/bluez/gatt_attrib"
-
-typedef struct {
-       GObject parent;
-} BluetoothGattService;
-
-typedef struct {
-       GObjectClass parent;
-} BluetoothGattServiceClass;
-
-typedef struct {
-       char *char_uuid;
-       char **handle;
-} char_pty_req_t;
-
-GType bluetooth_gatt_service_get_type(void);
-
-#define BLUETOOTH_GATT_TYPE_SERVICE (bluetooth_gatt_service_get_type())
-
-#define BLUETOOTH_GATT_SERVICE(object) \
-               (G_TYPE_CHECK_INSTANCE_CAST((object), \
-               BLUETOOTH_GATT_TYPE_SERVICE, BluetoothGattService))
-
-#define BLUETOOTH_GATT_SERVICE_CLASS(klass)    \
-               (G_TYPE_CHECK_CLASS_CAST((klass), \
-               BLUETOOTH_GATT_TYPE_SERVICE, BluetoothGattServiceClass))
-
-#define BLUETOOTH_GATT_IS_SERVICE(object)      \
-               (G_TYPE_CHECK_INSTANCE_TYPE((object), BLUETOOTH_GATT_TYPE_SERVICE))
-
-#define BLUETOOTH_GATT_IS_SERVICE_CLASS(klass) \
-               (G_TYPE_CHECK_CLASS_TYPE((klass), BLUETOOTH_GATT_TYPE_SERVICE))
-
-#define BLUETOOTH_GATT_SERVICE_GET_CLASS(obj)  \
-               (G_TYPE_INSTANCE_GET_CLASS((obj), \
-               BLUETOOTH_GATT_TYPE_SERVICE, BluetoothGattServiceClass))
-
-G_DEFINE_TYPE(BluetoothGattService, bluetooth_gatt_service, G_TYPE_OBJECT)
-
-static gboolean bluetooth_gatt_value_changed(BluetoothGattService *agent,
-                                       gchar *obj_path,
-                                       GArray *byte_array,
-                                       DBusGMethodInvocation *context);
-
-#include "bt-gatt-glue.h"
-
-static void bluetooth_gatt_service_init(BluetoothGattService *obj)
-{
-       g_assert(obj != NULL);
-}
-
-static void bluetooth_gatt_service_finalize(GObject *obj)
-{
-       G_OBJECT_CLASS(bluetooth_gatt_service_parent_class)->finalize(obj);
-}
-
-static void bluetooth_gatt_service_class_init(BluetoothGattServiceClass *klass)
-{
-       GObjectClass *object_class = (GObjectClass *)klass;
-
-       g_assert(klass != NULL);
-
-       object_class->finalize = bluetooth_gatt_service_finalize;
-
-       dbus_g_object_type_install_info(BLUETOOTH_GATT_TYPE_SERVICE,
-                                       &dbus_glib_bluetooth_gatt_object_info);
-}
-
-static gboolean bluetooth_gatt_value_changed(BluetoothGattService *agent,
-                                       gchar *obj_path,
-                                       GArray *byte_array,
-                                       DBusGMethodInvocation *context)
-{
-       bt_gatt_char_value_t char_val;
-       bt_user_info_t *user_info;
-       BT_DBG("+");
-
-       char_val.char_handle = obj_path;
-       char_val.char_value = &g_array_index(byte_array, guint8, 0);
-       char_val.val_len = byte_array->len;
-       BT_DBG("Byte array length = %d", char_val.val_len);
-
-       user_info = _bt_get_user_data(BT_COMMON);
-
-       if (user_info) {
-               _bt_common_event_cb(BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED,
-                               BLUETOOTH_ERROR_NONE, &char_val,
-                               user_info->cb, user_info->user_data);
-       }
-
-       BT_DBG("-");
-
-       return TRUE;
-}
-
-static void __add_value_changed_method(DBusGConnection *conn)
-{
-       static gboolean method_added = FALSE;
-       BluetoothGattService *bluetooth_gatt_obj = NULL;
-
-       if (method_added) {
-               BT_ERR("Method already added. \n");
-               return;
-       }
-
-       method_added = TRUE;
-
-       bluetooth_gatt_obj = g_object_new(BLUETOOTH_GATT_TYPE_SERVICE, NULL);
-
-       dbus_g_connection_register_g_object(conn, GATT_OBJECT_PATH,
-                       G_OBJECT(bluetooth_gatt_obj));
-
-}
-
-static char **__get_string_array_from_gptr_array(GPtrArray *gp)
-{
-       gchar *gp_path = NULL;
-       char **path = NULL;
-       int i;
-
-       if (gp->len == 0)
-               return NULL;
-
-       path = g_malloc0((gp->len + 1) * sizeof(char *));
-
-       for (i = 0; i < gp->len; i++) {
-               gp_path = g_ptr_array_index(gp, i);
-               path[i] = g_strdup(gp_path);
-               BT_DBG("path[%d] : [%s]", i, path[i]);
-       }
-
-       return path;
-}
-
-static void __bluetooth_internal_get_char_cb(DBusGProxy *proxy,
-                                       DBusGProxyCall *call,
-                                       gpointer user_data)
-{
-       GError *error = NULL;
-       GPtrArray *gp_array = NULL;
-       bt_gatt_discovered_char_t svc_char = { 0, };
-       bt_user_info_t *user_info;
-
-       svc_char.service_handle = user_data;
-
-       user_info = _bt_get_user_data(BT_COMMON);
-
-       if (!dbus_g_proxy_end_call(proxy, call, &error,
-               dbus_g_type_get_collection("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
-               &gp_array, G_TYPE_INVALID)) {
-               BT_ERR("Error : %s \n", error->message);
-               g_error_free(error);
-
-               if (user_info) {
-                       _bt_common_event_cb(BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED,
-                                       BLUETOOTH_ERROR_NONE, &svc_char,
-                                       user_info->cb, user_info->user_data);
-               }
-               g_free(svc_char.service_handle);
-               g_object_unref(proxy);
-               return;
-       }
-
-       if (NULL != gp_array) {
-               svc_char.handle_info.count = gp_array->len;
-               svc_char.handle_info.handle = __get_string_array_from_gptr_array(gp_array);
-       }
-
-       if (user_info) {
-               _bt_common_event_cb(BLUETOOTH_EVENT_GATT_SVC_CHAR_DISCOVERED,
-                               BLUETOOTH_ERROR_NONE, &svc_char,
-                               user_info->cb, user_info->user_data);
-       }
-
-       g_ptr_array_free(gp_array, TRUE);
-       g_free(svc_char.service_handle);
-       g_free(svc_char.handle_info.handle);
-       g_object_unref(proxy);
-}
-
-static void __free_char_req(char_pty_req_t *char_req)
-{
-       g_free(char_req->char_uuid);
-       g_strfreev(char_req->handle);
-       g_free(char_req);
-}
-
-static gboolean __filter_chars_with_uuid(gpointer data)
-{
-       int i = 0;
-       bt_gatt_char_property_t *char_pty;
-       char_pty_req_t *char_req = data;
-       bt_user_info_t *user_info;
-       int ret;
-
-       user_info = _bt_get_user_data(BT_COMMON);
-       if (user_info == NULL) {
-               __free_char_req(char_req);
-               return FALSE;
-       }
-
-       char_pty = g_new0(bt_gatt_char_property_t, 1);
-
-       while (char_req->handle[i] != NULL) {
-               BT_DBG("char_pty[%d] = %s", i, char_req->handle[i]);
-               ret = bluetooth_gatt_get_characteristics_property(char_req->handle[i],
-                                                                       char_pty);
-               if (ret != BLUETOOTH_ERROR_NONE) {
-                       BT_ERR("get char property failed");
-                       goto done;
-               }
-
-               if (char_pty->uuid  && g_strstr_len(char_pty->uuid, -1,
-                                               char_req->char_uuid) != NULL) {
-                       BT_DBG("Requested Char recieved");
-                       ret = BLUETOOTH_ERROR_NONE;
-                       break;
-               }
-
-               bluetooth_gatt_free_char_property(char_pty);
-
-               i++;
-       }
-
-done:
-       if (char_req->handle[i] == NULL)
-               ret = BLUETOOTH_ERROR_NOT_FOUND;
-
-       _bt_common_event_cb(BLUETOOTH_EVENT_GATT_GET_CHAR_FROM_UUID, ret,
-                               char_pty, user_info->cb, user_info->user_data);
-
-       g_free(char_pty);
-       __free_char_req(char_req);
-
-       return FALSE;
-}
-
-static void __disc_char_from_uuid_cb(DBusGProxy *proxy,
-                                       DBusGProxyCall *call,
-                                       gpointer user_data)
-{
-       GError *error = NULL;
-       GPtrArray *gp_array = NULL;
-       bt_user_info_t *user_info;
-       char_pty_req_t *char_req = user_data;
-
-       user_info = _bt_get_user_data(BT_COMMON);
-       if (!user_info) {
-               __free_char_req(char_req);
-               return;
-       }
-
-       if (!dbus_g_proxy_end_call(proxy, call, &error,
-               dbus_g_type_get_collection("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
-               &gp_array, G_TYPE_INVALID)) {
-               BT_ERR("Error : %s \n", error->message);
-               g_error_free(error);
-
-               _bt_common_event_cb(BLUETOOTH_EVENT_GATT_GET_CHAR_FROM_UUID,
-                                       BLUETOOTH_ERROR_INTERNAL, NULL,
-                                       user_info->cb, user_info->user_data);
-
-               __free_char_req(char_req);
-               g_object_unref(proxy);
-               return;
-       }
-
-       if (gp_array == NULL) {
-               _bt_common_event_cb(BLUETOOTH_EVENT_GATT_GET_CHAR_FROM_UUID,
-                                       BLUETOOTH_ERROR_NOT_FOUND, NULL,
-                                       user_info->cb, user_info->user_data);
-
-               __free_char_req(char_req);
-               g_object_unref(proxy);
-
-               return;
-       }
-
-       char_req->handle = __get_string_array_from_gptr_array(gp_array);
-
-       __filter_chars_with_uuid(char_req);
-
-       g_ptr_array_free(gp_array, TRUE);
-       g_object_unref(proxy);
-}
-
-
-static int __discover_char_from_uuid(const char *service_handle,
-                                                       const char *char_uuid){
-       DBusGProxy *service_proxy = NULL;
-       DBusGConnection *conn;
-       char_pty_req_t *char_req;
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       service_proxy = dbus_g_proxy_new_for_name(conn,
-                                               BT_BLUEZ_NAME, service_handle,
-                                               BLUEZ_CHAR_INTERFACE);
-       retv_if(service_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       char_req = g_new0(char_pty_req_t, 1);
-
-       char_req->char_uuid = g_strdup(char_uuid);
-       BT_DBG("Char uuid %s ", char_uuid);
-
-       if (!dbus_g_proxy_begin_call(service_proxy, "DiscoverCharacteristics",
-                       (DBusGProxyCallNotify)__disc_char_from_uuid_cb,
-                       char_req, NULL, G_TYPE_INVALID)) {
-               __free_char_req(char_req);
-               g_object_unref(service_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_free_primary_services(bt_gatt_handle_info_t *prim_svc)
-{
-       BT_DBG("+");
-
-       BT_CHECK_PARAMETER(prim_svc, return);
-
-       g_strfreev(prim_svc->handle);
-
-       memset(prim_svc, 0, sizeof(bt_gatt_handle_info_t));
-
-       BT_DBG("-");
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_free_service_property(bt_gatt_service_property_t *svc_pty)
-{
-       BT_DBG("+");
-
-       BT_CHECK_PARAMETER(svc_pty, return);
-
-       g_free(svc_pty->uuid);
-       g_free(svc_pty->handle);
-       g_strfreev(svc_pty->handle_info.handle);
-
-       memset(svc_pty, 0, sizeof(bt_gatt_service_property_t));
-
-       BT_DBG("-");
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_free_char_property(bt_gatt_char_property_t *char_pty)
-{
-       BT_DBG("+");
-
-       BT_CHECK_PARAMETER(char_pty, return);
-
-       g_free(char_pty->uuid);
-       g_free(char_pty->name);
-       g_free(char_pty->description);
-       g_free(char_pty->val);
-       g_free(char_pty->handle);
-
-       memset(char_pty, 0, sizeof(bt_gatt_char_property_t));
-
-       BT_DBG("-");
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_get_primary_services(const bluetooth_device_address_t *address,
-                                                               bt_gatt_handle_info_t *prim_svc)
-{
-       char device_address[BT_ADDRESS_STRING_SIZE] = { 0 };
-       gchar *device_path = NULL;
-       GError *error = NULL;
-       DBusGProxy *device_proxy = NULL;
-       GHashTable *hash = NULL;
-       GValue *value = NULL;
-       GPtrArray *gp_array  = NULL;
-       DBusGProxy *adapter_proxy;
-       DBusGConnection *conn;
-       int ret = BLUETOOTH_ERROR_INTERNAL;
-
-       BT_DBG("+");
-
-       BT_CHECK_PARAMETER(address, return);
-       BT_CHECK_PARAMETER(prim_svc, return);
-
-       BT_CHECK_ENABLED(return);
-
-       _bt_convert_addr_type_to_string(device_address,
-                               (unsigned char *)address->addr);
-
-       BT_DBG("bluetooth address [%s]\n", device_address);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       adapter_proxy = _bt_get_adapter_proxy(conn);
-       retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_g_proxy_call(adapter_proxy, "FindDevice", &error,
-               G_TYPE_STRING, device_address, G_TYPE_INVALID,
-               DBUS_TYPE_G_OBJECT_PATH, &device_path, G_TYPE_INVALID);
-       if (error) {
-               BT_ERR("FindDevice Call Error %s[%s]", error->message, device_address);
-               g_error_free(error);
-               g_object_unref(adapter_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       g_object_unref(adapter_proxy);
-
-       retv_if(device_path == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                                     device_path, BT_DEVICE_INTERFACE);
-       g_free(device_path);
-       retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_g_proxy_call(device_proxy, "GetProperties", &error, G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                               &hash, G_TYPE_INVALID);
-       if (error) {
-               BT_ERR("GetProperties Call Error %s[%s]", error->message, device_address);
-               g_error_free(error);
-               g_object_unref(device_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       g_object_unref(device_proxy);
-
-       retv_if(hash == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       value = g_hash_table_lookup(hash, "Services");
-       if (value == NULL) {
-               BT_ERR("value == NULL");
-               goto done;
-       }
-
-       gp_array = g_value_get_boxed(value);
-       if (gp_array == NULL) {
-               BT_ERR("gp_array == NULL");
-               goto done;
-       }
-
-       prim_svc->count = gp_array->len;
-       prim_svc->handle = __get_string_array_from_gptr_array(gp_array);
-
-       ret = BLUETOOTH_ERROR_NONE;
-done:
-       g_hash_table_destroy(hash);
-       BT_DBG("-");
-       return ret;
-}
-
-BT_EXPORT_API int bluetooth_gatt_discover_service_characteristics(const char *service_handle)
-{
-       DBusGProxy *service_proxy = NULL;
-       char *handle;
-       DBusGConnection *conn;
-
-       BT_CHECK_PARAMETER(service_handle, return);
-
-       BT_CHECK_ENABLED(return);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       service_proxy = dbus_g_proxy_new_for_name(conn,
-                                               BT_BLUEZ_NAME, service_handle,
-                                               BLUEZ_CHAR_INTERFACE);
-
-       retv_if(service_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       handle = g_strdup(service_handle);
-       BT_DBG("Requested characteristic handle:%s \n ", handle);
-
-       if (!dbus_g_proxy_begin_call(service_proxy, "DiscoverCharacteristics",
-                       (DBusGProxyCallNotify)__bluetooth_internal_get_char_cb,
-                       handle, NULL, G_TYPE_INVALID)) {
-               g_free(handle);
-               g_object_unref(service_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_get_service_property(const char *service_handle,
-                                               bt_gatt_service_property_t *service)
-{
-       DBusGProxy *service_proxy = NULL;
-       GHashTable *hash = NULL;
-       GError *error = NULL;
-       GValue *value = NULL;
-       GPtrArray *gp_array  = NULL ;
-       DBusGConnection *conn;
-
-       BT_CHECK_PARAMETER(service_handle, return);
-       BT_CHECK_PARAMETER(service, return);
-
-       BT_CHECK_ENABLED(return);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       service_proxy = dbus_g_proxy_new_for_name(conn,
-                                               BT_BLUEZ_NAME, service_handle,
-                                               BLUEZ_CHAR_INTERFACE);
-
-       retv_if(service_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_g_proxy_call(service_proxy, "GetProperties", &error, G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                               &hash, G_TYPE_INVALID);
-       if (error != NULL) {
-               BT_ERR("GetProperties Call Error %s\n", error->message);
-               g_error_free(error);
-               g_object_unref(service_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-       g_object_unref(service_proxy);
-
-       retv_if(hash == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       memset(service, 0, sizeof(bt_gatt_service_property_t));
-
-       value = g_hash_table_lookup(hash, "UUID");
-       service->uuid = value ? g_value_dup_string(value) : NULL;
-       if (service->uuid) {
-               BT_DBG("svc_pty.uuid = [%s] \n", service->uuid);
-       }
-
-       value = g_hash_table_lookup(hash, "Characteristics");
-       gp_array = value ? g_value_get_boxed(value) : NULL;
-       if (gp_array) {
-               service->handle_info.count = gp_array->len;
-               service->handle_info.handle = __get_string_array_from_gptr_array(gp_array);
-       }
-
-       service->handle = g_strdup(service_handle);
-       g_hash_table_destroy(hash);
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_watch_characteristics(const char *service_handle)
-{
-       DBusGProxy *watch_proxy = NULL;
-       GError *error = NULL;
-       DBusGConnection *conn;
-
-       BT_CHECK_PARAMETER(service_handle, return);
-
-       BT_CHECK_ENABLED(return);
-
-       BT_DBG("Entered service handle:%s \n ", service_handle);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       watch_proxy = dbus_g_proxy_new_for_name(conn,
-                               BT_BLUEZ_NAME, service_handle,
-                               BLUEZ_CHAR_INTERFACE);
-
-       retv_if(watch_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       __add_value_changed_method(conn);
-
-       dbus_g_proxy_call(watch_proxy, "RegisterCharacteristicsWatcher", &error,
-                               DBUS_TYPE_G_OBJECT_PATH, GATT_OBJECT_PATH,
-                               G_TYPE_INVALID, G_TYPE_INVALID);
-       if (error) {
-               BT_ERR("Method call  Fail: %s", error->message);
-               g_error_free(error);
-               g_object_unref(watch_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       g_object_unref(watch_proxy);
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_unwatch_characteristics(const char *service_handle)
-{
-       DBusGProxy *watch_proxy = NULL;
-       GError *error = NULL;
-       DBusGConnection *conn;
-
-       BT_CHECK_PARAMETER(service_handle, return);
-
-       BT_CHECK_ENABLED(return);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       watch_proxy = dbus_g_proxy_new_for_name(conn,
-                               BT_BLUEZ_NAME, service_handle,
-                               BLUEZ_CHAR_INTERFACE);
-
-       retv_if(watch_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_g_proxy_call(watch_proxy, "UnregisterCharacteristicsWatcher", &error,
-                               DBUS_TYPE_G_OBJECT_PATH, GATT_OBJECT_PATH,
-                               G_TYPE_INVALID, G_TYPE_INVALID);
-       if (error) {
-               BT_ERR("Method call  Fail: %s", error->message);
-               g_error_free(error);
-               g_object_unref(watch_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       g_object_unref(watch_proxy);
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_get_characteristics_property(const char *char_handle,
-                                               bt_gatt_char_property_t *characteristic)
-{
-       DBusGProxy *characteristic_proxy = NULL;
-       GHashTable *hash = NULL;
-       GError *error = NULL;
-       GValue *value = NULL;
-       GByteArray *gb_array = NULL;
-       DBusGConnection *conn;
-
-       BT_CHECK_PARAMETER(char_handle, return);
-       BT_CHECK_PARAMETER(characteristic, return);
-
-       BT_CHECK_ENABLED(return);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       characteristic_proxy = dbus_g_proxy_new_for_name(conn,
-                                               BT_BLUEZ_NAME, char_handle,
-                                               BLUEZ_CHAR_INTERFACE);
-
-       retv_if(characteristic_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_g_proxy_call(characteristic_proxy, "GetProperties", &error, G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                               &hash, G_TYPE_INVALID);
-       if (error != NULL) {
-               BT_ERR("GetProperties Call Error %s\n", error->message);
-               g_error_free(error);
-               g_object_unref(characteristic_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-       g_object_unref(characteristic_proxy);
-
-       retv_if(hash == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       memset(characteristic, 0, sizeof(bt_gatt_char_property_t));
-
-       value = g_hash_table_lookup(hash, "UUID");
-       characteristic->uuid = value ? g_value_dup_string(value) : NULL;
-       if (characteristic->uuid) {
-               BT_DBG("characteristic->uuid = [%s] \n", characteristic->uuid);
-       }
-
-       value = g_hash_table_lookup(hash, "Name");
-       characteristic->name = value ? g_value_dup_string(value) : NULL;
-       if (characteristic->name) {
-               BT_DBG("characteristic->name = [%s] \n", characteristic->name);
-       }
-
-       value = g_hash_table_lookup(hash, "Description");
-       characteristic->description = value ? g_value_dup_string(value) : NULL;
-       if (characteristic->description) {
-               BT_DBG("characteristic->description = [%s] \n", characteristic->description);
-       }
-
-       value = g_hash_table_lookup(hash, "Value");
-
-       gb_array = value ? g_value_get_boxed(value) : NULL;
-       if (gb_array) {
-               if (gb_array->len) {
-                       BT_DBG("gb_array->len  = %d \n", gb_array->len);
-                       characteristic->val_len = gb_array->len;
-
-                       characteristic->val = g_malloc0(gb_array->len * sizeof(unsigned char));
-                       memcpy(characteristic->val, gb_array->data, gb_array->len);
-               } else {
-                       characteristic->val = NULL;
-                       characteristic->val_len = 0;
-               }
-       } else {
-               characteristic->val = NULL;
-               characteristic->val_len = 0;
-       }
-       characteristic->handle = g_strdup(char_handle);
-       g_hash_table_destroy(hash);
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_set_characteristics_value(const char *char_handle,
-                                               const guint8 *value, int length)
-{
-       DBusGProxy *characteristic_proxy = NULL;
-       GValue *val;
-       GByteArray *gbarray;
-       GError *error = NULL;
-       DBusGConnection *conn;
-
-       BT_CHECK_PARAMETER(char_handle, return);
-       BT_CHECK_PARAMETER(value, return);
-       retv_if(length == 0, BLUETOOTH_ERROR_INVALID_PARAM);
-
-       BT_CHECK_ENABLED(return);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       BT_DBG("Requested characteristic handle:%s \n ", char_handle);
-
-       characteristic_proxy = dbus_g_proxy_new_for_name(conn,
-                                                       BT_BLUEZ_NAME, char_handle,
-                                                       BLUEZ_CHAR_INTERFACE);
-
-       retv_if(characteristic_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       gbarray = g_byte_array_new();
-       g_byte_array_append(gbarray, (guint8 *)value, length);
-
-       val = g_new0(GValue, 1);
-       g_value_init(val, DBUS_TYPE_G_UCHAR_ARRAY);
-       g_value_take_boxed(val, gbarray);
-
-       dbus_g_proxy_call(characteristic_proxy, "SetProperty",
-               &error, G_TYPE_STRING, "Value",
-               G_TYPE_VALUE, val, G_TYPE_INVALID, G_TYPE_INVALID);
-
-       g_object_unref(characteristic_proxy);
-       g_free(val);
-
-       if (error) {
-               BT_ERR("Set value Fail: %s", error->message);
-               g_error_free(error);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-BT_EXPORT_API int bluetooth_gatt_get_service_from_uuid(bluetooth_device_address_t *address,
-                                       const char *service_uuid,
-                                       bt_gatt_service_property_t *service)
-{
-       int i;
-       int ret;
-       bt_gatt_handle_info_t prim_svc;
-
-       BT_CHECK_PARAMETER(address, return);
-       BT_CHECK_PARAMETER(service_uuid, return);
-       BT_CHECK_PARAMETER(service, return);
-
-       BT_CHECK_ENABLED(return);
-
-       ret = bluetooth_gatt_get_primary_services(address, &prim_svc);
-       if (ret != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Get primary service failed ");
-               return ret;
-       }
-
-       for (i = 0; i < prim_svc.count; i++) {
-
-               BT_DBG("prim_svc [%d] = %s", i, prim_svc.handle[i]);
-
-               ret = bluetooth_gatt_get_service_property(prim_svc.handle[i],
-                                                               service);
-               if (ret != BLUETOOTH_ERROR_NONE) {
-                       BT_ERR("Get service property failed ");
-                       bluetooth_gatt_free_primary_services(&prim_svc);
-                       return ret;
-               }
-
-               BT_DBG("Service uuid %s", service->uuid);
-
-               if (g_strstr_len(service->uuid, -1, service_uuid)) {
-                       BT_DBG("Found requested service");
-                       ret = BLUETOOTH_ERROR_NONE;
-                       break;
-               }
-
-               bluetooth_gatt_free_service_property(service);
-       }
-
-       if (i == prim_svc.count)
-               ret = BLUETOOTH_ERROR_NOT_FOUND;
-
-       bluetooth_gatt_free_primary_services(&prim_svc);
-
-       return ret;
-}
-
-BT_EXPORT_API int bluetooth_gatt_get_char_from_uuid(const char *service_handle,
-                                               const char *char_uuid)
-{
-       char **char_handles;
-       char_pty_req_t *char_pty;
-       int i;
-       bt_gatt_service_property_t svc_pty;
-
-       BT_CHECK_PARAMETER(service_handle, return);
-       BT_CHECK_PARAMETER(char_uuid, return);
-
-       BT_CHECK_ENABLED(return);
-
-       if (bluetooth_gatt_get_service_property(service_handle, &svc_pty) !=
-                                                       BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Invalid service");
-               return BLUETOOTH_ERROR_NOT_FOUND;
-       }
-
-       char_handles = svc_pty.handle_info.handle;
-
-       if (char_handles == NULL)
-               return __discover_char_from_uuid(svc_pty.handle, char_uuid);
-
-       char_pty = g_new0(char_pty_req_t, 1);
-
-       char_pty->handle = g_malloc0((svc_pty.handle_info.count + 1) *
-                                                       sizeof(char *));
-       for (i = 0; i < svc_pty.handle_info.count; i++) {
-               char_pty->handle[i] = char_handles[i];
-               BT_DBG("char_path[%d] : [%s]", i, char_pty->handle[i]);
-       }
-       char_pty->char_uuid = g_strdup(char_uuid);
-
-       g_idle_add(__filter_chars_with_uuid, char_pty);
-
-       return BLUETOOTH_ERROR_NONE;
-}
index 98dffc6..3a9e145 100644 (file)
@@ -380,11 +380,9 @@ static void __bt_hdp_internal_handle_connect(DBusMessage *msg)
                                BLUETOOTH_ERROR_CONNECTION_ERROR, NULL,
                                user_info->cb, user_info->user_data);
        } else {
-               if (user_info->cb) {
-                       _bt_common_event_cb(BLUETOOTH_EVENT_HDP_CONNECTED,
-                                       BLUETOOTH_ERROR_NONE, NULL,
-                                       user_info->cb, user_info->user_data);
-               }
+               _bt_common_event_cb(BLUETOOTH_EVENT_HDP_CONNECTED,
+                               BLUETOOTH_ERROR_NONE, NULL,
+                               user_info->cb, user_info->user_data);
        }
 
        BT_DBG("-");
@@ -1170,11 +1168,9 @@ static void __bt_hdp_disconnect_request_cb(DBusGProxy *hdp_proxy, DBusGProxyCall
                                BLUETOOTH_ERROR_CONNECTION_ERROR, disconn_ind,
                                user_info->cb, user_info->user_data);
        } else {
-               if (user_info->cb) {
-                       _bt_common_event_cb(BLUETOOTH_EVENT_HDP_DISCONNECTED,
-                                       BLUETOOTH_ERROR_NONE, disconn_ind,
-                                       user_info->cb, user_info->user_data);
-               }
+               _bt_common_event_cb(BLUETOOTH_EVENT_HDP_DISCONNECTED,
+                               BLUETOOTH_ERROR_NONE, disconn_ind,
+                               user_info->cb, user_info->user_data);
                BT_INFO("HDP disconnection Dbus Call is done\n");
        }
 
diff --git a/bt-api/bt-hid-device.c b/bt-api/bt-hid-device.c
new file mode 100644 (file)
index 0000000..bd046ad
--- /dev/null
@@ -0,0 +1,737 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Girishashok Joshi <girish.joshi@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *             http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <gio/gio.h>
+#include <gio/gunixfdlist.h>
+#include <sys/socket.h>
+
+#include "bluetooth-api.h"
+#include "bt-internal-types.h"
+#include "bluetooth-hid-api.h"
+#include "bt-common.h"
+#include "bt-request-sender.h"
+#include "bt-event-handler.h"
+
+#define HID_UUID               "00001124-0000-1000-8000-00805f9b34fb"
+#define        REPORTID_MOUSE  1
+#define BT_HID_BUFFER_LEN 100
+
+/* HIDP header masks */
+#define HIDP_HEADER_TRANS_MASK                 0xf0
+#define HIDP_HEADER_PARAM_MASK                 0x0f
+
+/* HIDP transaction types */
+#define HIDP_TRANS_HANDSHAKE                   0x00
+#define HIDP_TRANS_HID_CONTROL                 0x10
+#define HIDP_TRANS_GET_REPORT                  0x40
+#define HIDP_TRANS_SET_REPORT                  0x50
+#define HIDP_TRANS_GET_PROTOCOL                        0x60
+#define HIDP_TRANS_SET_PROTOCOL                        0x70
+#define HIDP_TRANS_GET_IDLE                    0x80
+#define HIDP_TRANS_SET_IDLE                    0x90
+#define HIDP_TRANS_DATA                                0xa0
+#define HIDP_TRANS_DATC                                0xb0
+
+#define HIDP_DATA_RTYPE_INPUT                  0x01
+#define HIDP_DATA_RTYPE_OUTPUT                 0x02
+
+#define HIDP_HSHK_SUCCESSFUL   0x00
+#define HIDP_HSHK_NOT_READY    0x01
+#define HIDP_HSHK_ERR_INVALID_REPORT_ID        0x02
+#define HIDP_HSHK_ERR_UNSUPPORTED_REQUEST      0x03
+#define HIDP_HSHK_ERR_INVALID_PARAMETER        0x04
+#define HIDP_HSHK_ERR_UNKNOWN  0x0E
+#define HIDP_HSHK_ERR_FATAL    0x0F
+
+typedef struct {
+       guint object_id;
+       gchar *path;
+       int id;
+       char *uuid;
+       GSList *device_list;
+} hid_info_t;
+
+typedef struct {
+       int ctrl_fd;
+       int intr_fd;
+       GIOChannel *ctrl_data_io;
+       GIOChannel *intr_data_io;
+       guint ctrl_data_id;
+       guint intr_data_id;
+       char *address;
+       guint disconnect_idle_id;
+} hid_connected_device_info_t;
+
+struct reports{
+       guint8 type;
+       guint8 rep_data[20];
+}__attribute__((__packed__));
+
+static hid_info_t *hid_info = NULL;
+
+/* Variable for privilege, only for write API,
+  before we should reduce time to bt-service dbus calling
+  -1 : Don't have a permission to access API
+  0 : Initial value, not yet check
+  1 : Have a permission to access API
+*/
+static int privilege_token_send_mouse = 0;
+static int privilege_token_send_key = 0;
+static int privilege_token_reply = 0;
+
+static gboolean __hid_disconnect(hid_connected_device_info_t *info);
+
+static hid_connected_device_info_t *__find_hid_info_with_address(const char *remote_addr)
+{
+       GSList *l;
+
+       for ( l = hid_info->device_list; l != NULL; l = l->next) {
+               hid_connected_device_info_t *info = l->data;
+               if (g_strcmp0((const char *)info->address, (const char *)remote_addr) == 0)
+                       return info;
+       }
+       return NULL;
+}
+
+static void __hid_connected_cb(hid_connected_device_info_t *info,
+                       bt_event_info_t *event_info)
+{
+       bluetooth_hid_request_t conn_info;
+
+       memset(&conn_info, 0x00, sizeof(bluetooth_hid_request_t));
+       if (info->intr_fd != -1 && info->ctrl_fd == -1)
+               conn_info.socket_fd = info->intr_fd;
+       else
+               conn_info.socket_fd = info->ctrl_fd;
+       _bt_convert_addr_string_to_type (conn_info.device_addr.addr , info->address);
+
+       BT_INFO_C("Connected [HID Device]");
+       _bt_common_event_cb(BLUETOOTH_HID_DEVICE_CONNECTED,
+                       BLUETOOTH_ERROR_NONE, &conn_info,
+                       event_info->cb, event_info->user_data);
+}
+
+static gboolean __hid_disconnect(hid_connected_device_info_t *info)
+{
+       bluetooth_hid_request_t disconn_info;
+       int fd = info->ctrl_fd;
+       bt_event_info_t *event_info;
+
+       BT_INFO_C("Disconnected [HID Device]");
+       hid_info->device_list = g_slist_remove(hid_info->device_list, info);
+       if (info->ctrl_data_id > 0) {
+               g_source_remove(info->ctrl_data_id);
+               info->ctrl_data_id = 0;
+       }
+       if (info->intr_data_id > 0) {
+               g_source_remove(info->intr_data_id);
+               info->intr_data_id = 0;
+       }
+
+       if (info->intr_fd >= 0) {
+               close(info->ctrl_fd);
+               close(info->intr_fd);
+               info->intr_fd = -1;
+               info->ctrl_fd = -1;
+       }
+
+       if (info->ctrl_data_io) {
+               g_io_channel_shutdown(info->ctrl_data_io, TRUE, NULL);
+               g_io_channel_unref(info->ctrl_data_io);
+               info->ctrl_data_io = NULL;
+       }
+       if (info->intr_data_io) {
+               g_io_channel_shutdown(info->intr_data_io, TRUE, NULL);
+               g_io_channel_unref(info->intr_data_io);
+               info->intr_data_io = NULL;
+       }
+       info->disconnect_idle_id = 0;
+       event_info = _bt_event_get_cb_data(BT_HID_DEVICE_EVENT);
+       if (event_info == NULL)
+               return FALSE;
+
+       memset(&disconn_info, 0x00, sizeof(bluetooth_hid_request_t));
+       disconn_info.socket_fd = fd;
+       _bt_convert_addr_string_to_type (disconn_info.device_addr.addr , info->address);
+       _bt_common_event_cb(BLUETOOTH_HID_DEVICE_DISCONNECTED,
+                       BLUETOOTH_ERROR_NONE, &disconn_info,
+                       event_info->cb, event_info->user_data);
+       if (info->address)
+               g_free(info->address);
+       g_free(info);
+       info = NULL;
+       BT_DBG("-");
+       return FALSE;
+}
+
+void __free_hid_info(hid_info_t *info)
+{
+       BT_DBG("");
+
+       _bt_unregister_gdbus(info->object_id);
+
+       while (info->device_list) {
+               hid_connected_device_info_t *dev_info = NULL;
+               dev_info = (hid_connected_device_info_t *)info->device_list->data;
+
+               if (dev_info->disconnect_idle_id > 0) {
+                       BT_INFO("Disconnect idle still not process remove source");
+                       g_source_remove(dev_info->disconnect_idle_id);
+                       dev_info->disconnect_idle_id = 0;
+               }
+               __hid_disconnect(dev_info);
+       }
+
+       g_free(info->path);
+       g_free(info->uuid);
+       g_free(info);
+}
+
+static gboolean __received_cb(GIOChannel *chan, GIOCondition cond,
+                                                               gpointer data)
+{
+       hid_connected_device_info_t *info = data;
+       GIOStatus status = G_IO_STATUS_NORMAL;
+       char buffer[20];
+       gsize len = 0;
+       GError *err = NULL;
+       guint8  header, type, param;
+       bt_event_info_t *event_info;
+       retv_if(info == NULL, FALSE);
+
+       if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
+               BT_ERR_C("HID  disconnected: %d", info->ctrl_fd);
+               if (info->disconnect_idle_id > 0) {
+                       BT_INFO("Disconnect idle still not process remove source");
+                       g_source_remove(info->disconnect_idle_id);
+                       info->disconnect_idle_id = 0;
+               }
+               __hid_disconnect(info);
+               return FALSE;
+       }
+       status = g_io_channel_read_chars(chan, buffer, BT_RFCOMM_BUFFER_LEN,
+                       &len, &err);
+       if (status == G_IO_STATUS_NORMAL) {
+               BT_INFO("Parsing Data");
+               bluetooth_hid_received_data_t data = {0};
+               header = buffer[0];
+               type = header & HIDP_HEADER_TRANS_MASK;
+               param = header & HIDP_HEADER_PARAM_MASK;
+               BT_INFO("type %d , param %d", type, param);
+               BT_INFO("Data Reveived from %s" , info->address);
+               data.address = g_strdup(info->address);
+               switch (type) {
+                       case HIDP_TRANS_HANDSHAKE:
+                               BT_INFO("TRANS HANDSHAKE");
+                               data.type = HTYPE_TRANS_HANDSHAKE;
+                               data.buffer_size = len;
+                               data.buffer = (char *) malloc(sizeof(char) * len);
+                               memcpy(data.buffer, buffer, len);
+                       break;
+                       case HIDP_TRANS_HID_CONTROL:
+                               BT_INFO("HID CONTROL");
+                               data.type = HTYPE_TRANS_HID_CONTROL;
+                               data.buffer_size = len;
+                               data.buffer = (char *) malloc(sizeof(char) * len);
+                               memcpy(data.buffer, buffer, len);
+                       break;
+                       case HIDP_TRANS_DATA:
+                               BT_INFO("TRANS DATA");
+                               data.type = HTYPE_TRANS_DATA;
+                               if ( param & HIDP_DATA_RTYPE_INPUT) {
+                                       BT_INFO("Input Report");
+                                       data.param = PTYPE_DATA_RTYPE_INPUT;
+                                       data.buffer_size = len;
+                                       data.buffer = (char *) malloc(sizeof(char) * len);
+                                       memcpy(data.buffer, buffer, len);
+                               }
+                               else {
+                                       BT_INFO("Out Report");
+                                       data.param = PTYPE_DATA_RTYPE_OUTPUT;
+                                       data.buffer_size = len;
+                                       data.buffer = (char *) malloc(sizeof(char) * len);
+                                       memcpy(data.buffer, buffer, len);
+                               }
+                       break;
+                       case HIDP_TRANS_GET_REPORT: {
+                               BT_INFO("Get Report");
+                               data.type = HTYPE_TRANS_GET_REPORT;
+                               if (param & HIDP_DATA_RTYPE_INPUT) {
+                                       BT_INFO("Input Report");
+                                       data.param = PTYPE_DATA_RTYPE_INPUT;
+                               } else {
+                                       BT_INFO("Output Report");
+                                       data.param = PTYPE_DATA_RTYPE_OUTPUT;
+                               }
+                               data.buffer_size = len;
+                               data.buffer = (char *) malloc(sizeof(char) * len);
+                               memcpy(data.buffer, buffer, len);
+                               break;
+                       }
+                       case HIDP_TRANS_SET_REPORT: {
+                               BT_INFO("Set Report");
+                               data.type = HTYPE_TRANS_SET_REPORT;
+                               if (param & HIDP_DATA_RTYPE_INPUT) {
+                                       BT_INFO("Input Report");
+                                       data.param = PTYPE_DATA_RTYPE_INPUT;
+                               } else {
+                                       BT_INFO("Output Report");
+                                       data.param = PTYPE_DATA_RTYPE_OUTPUT;
+                               }
+                               data.buffer_size = len;
+                               data.buffer = (char *) malloc(sizeof(char) * len);
+                               memcpy(data.buffer, buffer, len);
+                               break;
+                       }
+                       case HIDP_TRANS_GET_PROTOCOL:{
+                               BT_INFO("Get_PROTOCOL");
+                               data.type = HTYPE_TRANS_GET_PROTOCOL;
+                               data.param = PTYPE_DATA_RTYPE_INPUT;
+                               data.buffer_size = len;
+                               data.buffer = (char *) malloc(sizeof(char) * len);
+                               memcpy(data.buffer, buffer, len);
+                               break;
+                       }
+                       case HIDP_TRANS_SET_PROTOCOL:{
+                               BT_INFO("Set_PROTOCOL");
+                               data.type = HTYPE_TRANS_SET_PROTOCOL;
+                               data.param = PTYPE_DATA_RTYPE_INPUT;
+                               data.buffer_size = len;
+                               data.buffer = (char *) malloc(sizeof(char) * len);
+                               memcpy(data.buffer, buffer, len);
+                               break;
+                       }
+                       default: {
+                               BT_INFO("unsupported HIDP control message");
+                               BT_ERR("Send Handshake Message");
+                               guint8 type = HIDP_TRANS_HANDSHAKE |
+                                       HIDP_HSHK_ERR_UNSUPPORTED_REQUEST;
+                               data.type = HTYPE_TRANS_UNKNOWN;
+                               int fd = g_io_channel_unix_get_fd(chan);
+                               int bytes = write(fd,  &type, sizeof(type));
+                               BT_INFO("Bytes Written %d", bytes);
+                               break;
+                       }
+               }
+               event_info = _bt_event_get_cb_data(BT_HID_DEVICE_EVENT);
+               if (event_info == NULL)
+                       return FALSE;
+
+               _bt_common_event_cb(BLUETOOTH_HID_DEVICE_DATA_RECEIVED,
+                               BLUETOOTH_ERROR_NONE, &data,
+                               event_info->cb, event_info->user_data);
+               if (data.buffer)
+                       g_free(data.buffer);
+               if (data.address)
+                       g_free((char *)data.address);
+       } else {
+               BT_INFO("Error while reading data");
+       }
+       return TRUE;
+}
+
+int new_hid_connection(const char *path, int fd, bluetooth_device_address_t *addr)
+{
+       hid_info_t *info = NULL;
+       hid_connected_device_info_t *dev_info = NULL;
+       bt_event_info_t *event_info = NULL;
+       char address[18];
+       info = hid_info;
+
+       if (info == NULL)
+               return -1;
+       _bt_convert_addr_type_to_string((char *)address, addr->addr);
+       BT_INFO("Address [%s]", address);
+       dev_info = __find_hid_info_with_address(address);
+       if (dev_info == NULL) {
+               dev_info = (hid_connected_device_info_t *)
+                       g_malloc0(sizeof(hid_connected_device_info_t));
+               dev_info->intr_fd = -1;
+               dev_info->ctrl_fd = -1;
+               dev_info->intr_fd = fd;
+               dev_info->address = g_strdup(address);
+               dev_info->intr_data_io = g_io_channel_unix_new(dev_info->intr_fd);
+               g_io_channel_set_encoding(dev_info->intr_data_io, NULL, NULL);
+               g_io_channel_set_flags(dev_info->intr_data_io, G_IO_FLAG_NONBLOCK, NULL);
+
+               dev_info->intr_data_id = g_io_add_watch(dev_info->intr_data_io,
+                               G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+                               __received_cb, dev_info);
+               hid_info->device_list = g_slist_append(hid_info->device_list, dev_info);
+       } else {
+               dev_info->ctrl_fd = fd;
+               dev_info->ctrl_data_io = g_io_channel_unix_new(dev_info->ctrl_fd);
+               g_io_channel_set_encoding(dev_info->ctrl_data_io, NULL, NULL);
+               g_io_channel_set_flags(dev_info->ctrl_data_io, G_IO_FLAG_NONBLOCK, NULL);
+
+               dev_info->ctrl_data_id = g_io_add_watch(dev_info->ctrl_data_io,
+                               G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+                               __received_cb, dev_info);
+       }
+       if (dev_info->ctrl_fd != -1 && dev_info->intr_fd != -1) {
+               event_info = _bt_event_get_cb_data(BT_HID_DEVICE_EVENT);
+               if (event_info)
+                       __hid_connected_cb(dev_info, event_info);
+       }
+
+       return 0;
+}
+static hid_info_t *__register_method()
+{
+       int object_id;
+       hid_info_t *info = NULL;
+       char *path = NULL;
+       path = g_strdup_printf("/org/socket/server/%d", getpid());
+
+       object_id = _bt_register_new_conn(path, new_hid_connection);
+       if (object_id < 0) {
+               return NULL;
+       }
+       info = g_new(hid_info_t, 1);
+       info->object_id = (guint)object_id;
+       info->path = path;
+       info->id = 0;
+       info->device_list = NULL;
+
+       return info;
+}
+
+BT_EXPORT_API int bluetooth_hid_device_init(hid_cb_func_ptr callback_ptr, void *user_data)
+{
+       int ret;
+
+       /* Register HID Device events */
+       BT_INFO("BT_HID_DEVICE_EVENT");
+       ret = _bt_register_event(BT_HID_DEVICE_EVENT , (void *)callback_ptr, user_data);
+
+       if (ret != BLUETOOTH_ERROR_NONE &&
+            ret != BLUETOOTH_ERROR_ALREADY_INITIALIZED) {
+               BT_ERR("Fail to init the event handler");
+               return ret;
+       }
+
+       _bt_set_user_data(BT_HID, (void *)callback_ptr, user_data);
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_hid_device_deinit(void)
+{
+       int ret;
+
+       ret = _bt_unregister_event(BT_HID_DEVICE_EVENT);
+
+       if (ret != BLUETOOTH_ERROR_NONE) {
+               BT_ERR("Fail to deinit the event handler");
+               return ret;
+       }
+
+       _bt_set_user_data(BT_HID, NULL, NULL);
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_hid_device_activate(void)
+{
+       bt_register_profile_info_t profile_info;
+       int result = BLUETOOTH_ERROR_NONE;
+
+       if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_HID_DEVICE_ACTIVATE)
+                == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+               BT_ERR("Don't have a privilege to use this API");
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       }
+
+       if (hid_info != NULL)
+               return BLUETOOTH_ERROR_IN_PROGRESS;
+
+       hid_info = __register_method();
+       if (hid_info == NULL)
+               return BLUETOOTH_ERROR_INTERNAL;
+
+       hid_info->uuid = g_strdup(HID_UUID);
+
+       profile_info.authentication = TRUE;
+       profile_info.authorization = TRUE;
+       profile_info.obj_path = hid_info->path;
+       profile_info.role = g_strdup("Hid");
+       profile_info.service = hid_info->uuid;
+       profile_info.uuid = hid_info->uuid;
+
+       BT_INFO("uuid %s", profile_info.uuid);
+       result = _bt_register_profile_platform(&profile_info, FALSE);
+
+       return result;
+}
+
+BT_EXPORT_API int bluetooth_hid_device_deactivate(void)
+{
+       if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_HID_DEVICE_DEACTIVATE)
+                == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+               BT_ERR("Don't have a privilege to use this API");
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       }
+
+       if (hid_info == NULL)
+               return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+
+       _bt_unregister_profile(hid_info->path);
+
+       __free_hid_info(hid_info);
+       hid_info = NULL;
+       return BLUETOOTH_ERROR_NONE;
+}
+
+BT_EXPORT_API int bluetooth_hid_device_connect(const char *remote_addr)
+{
+       char device_address[BT_ADDRESS_STRING_SIZE] = {0};
+       hid_connected_device_info_t *info = NULL;
+       BT_DBG("+");
+       BT_CHECK_PARAMETER(remote_addr, return);
+
+       info = __find_hid_info_with_address(remote_addr);
+       if (info) {
+               BT_ERR("Connection Already Exists");
+               return BLUETOOTH_ERROR_ALREADY_CONNECT;
+       }
+       if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_HID_DEVICE_CONNECT)
+                == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+               BT_ERR("Don't have a privilege to use this API");
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       }
+
+       memcpy(device_address, remote_addr, BT_ADDRESS_STRING_SIZE);
+       _bt_connect_profile(device_address, HID_UUID, NULL, NULL);
+
+       return BLUETOOTH_ERROR_NONE;
+}
+BT_EXPORT_API int bluetooth_hid_device_disconnect(const char *remote_addr)
+{
+       if (_bt_check_privilege(BT_CHECK_PRIVILEGE, BT_HID_DEVICE_DISCONNECT)
+                == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+               BT_ERR("Don't have a privilege to use this API");
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       }
+       hid_connected_device_info_t *info = NULL;
+
+       info = __find_hid_info_with_address(remote_addr);
+       if (info == NULL)
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+
+       _bt_disconnect_profile((char *)remote_addr, HID_UUID, NULL, NULL);
+
+       info->disconnect_idle_id = g_idle_add((GSourceFunc)__hid_disconnect, info);
+
+       BT_DBG("-");
+       return BLUETOOTH_ERROR_NONE;
+}
+BT_EXPORT_API int bluetooth_hid_device_send_mouse_event(const char *remote_addr,
+                                       hid_send_mouse_event_t send_event)
+{
+       int result;
+       int written = 0;
+       hid_connected_device_info_t *info = NULL;
+
+       switch (privilege_token_send_mouse) {
+       case 0:
+               result = _bt_check_privilege(BT_BLUEZ_SERVICE, BT_HID_DEVICE_SEND_MOUSE_EVENT);
+
+               if (result == BLUETOOTH_ERROR_NONE) {
+                       privilege_token_send_mouse = 1; /* Have a permission */
+               } else if (result == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+                       BT_ERR("Don't have a privilege to use this API");
+                       privilege_token_send_mouse = -1; /* Don't have a permission */
+                       return BLUETOOTH_ERROR_PERMISSION_DEINED;
+               } else {
+                       /* Just break - It is not related with permission error */
+               }
+               break;
+       case 1:
+               /* Already have a privilege */
+               break;
+       case -1:
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       default:
+               /* Invalid privilge token value */
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+       info = __find_hid_info_with_address(remote_addr);
+       if (info == NULL) {
+               BT_ERR("Connection Information not found");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+       int socket_fd;
+
+       if (info == NULL)
+               return -1;
+
+       if (info->intr_fd != -1 && info->ctrl_fd == -1)
+               socket_fd = info->intr_fd;
+       else
+               socket_fd = info->ctrl_fd;
+
+       written = write(socket_fd, &send_event, sizeof(send_event));
+
+       return written;
+}
+
+BT_EXPORT_API int bluetooth_hid_device_send_key_event(const char *remote_addr,
+                                       hid_send_key_event_t send_event)
+{
+       int result;
+       int written = 0;
+       hid_connected_device_info_t *info = NULL;
+
+       switch (privilege_token_send_key) {
+       case 0:
+               result = _bt_check_privilege(BT_BLUEZ_SERVICE, BT_HID_DEVICE_SEND_KEY_EVENT);
+
+               if (result == BLUETOOTH_ERROR_NONE) {
+                       privilege_token_send_key = 1; /* Have a permission */
+               } else if (result == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+                       BT_ERR("Don't have a privilege to use this API");
+                       privilege_token_send_key = -1; /* Don't have a permission */
+                       return BLUETOOTH_ERROR_PERMISSION_DEINED;
+               } else {
+                       /* Just break - It is not related with permission error */
+               }
+               break;
+       case 1:
+               /* Already have a privilege */
+               break;
+       case -1:
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       default:
+               /* Invalid privilge token value */
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       info = __find_hid_info_with_address(remote_addr);
+       if (info == NULL) {
+               BT_ERR("Connection Information not found");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       int socket_fd;
+
+       if (info == NULL)
+               return -1;
+
+       if (info->intr_fd != -1 && info->ctrl_fd == -1)
+               socket_fd = info->intr_fd;
+       else
+               socket_fd = info->ctrl_fd;
+
+       written = write(socket_fd, &send_event, sizeof(send_event));
+       return written;
+}
+
+BT_EXPORT_API int bluetooth_hid_device_reply_to_report(const char *remote_addr,
+                               bt_hid_header_type_t htype,
+                               bt_hid_param_type_t ptype,
+                               const char *data,
+                               unsigned int data_len)
+{
+       int result;
+       struct reports output_report = { 0 };
+       int bytes = 0;
+       hid_connected_device_info_t *info = NULL;
+       info = __find_hid_info_with_address(remote_addr);
+       if (info == NULL) {
+               BT_ERR("Connection Information not found");
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       }
+
+       switch (privilege_token_reply) {
+       case 0:
+               result = _bt_check_privilege(BT_BLUEZ_SERVICE, BT_HID_DEVICE_SEND_REPLY_TO_REPORT);
+
+               if (result == BLUETOOTH_ERROR_NONE) {
+                       privilege_token_reply = 1; /* Have a permission */
+               } else if (result == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+                       BT_ERR("Don't have a privilege to use this API");
+                       privilege_token_reply = -1; /* Don't have a permission */
+                       return BLUETOOTH_ERROR_PERMISSION_DEINED;
+               } else {
+                       /* Just break - It is not related with permission error */
+               }
+               break;
+       case 1:
+               /* Already have a privilege */
+               break;
+       case -1:
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       default:
+               /* Invalid privilge token value */
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       BT_INFO("htype %d ptype %d", htype, ptype);
+       switch(htype) {
+               case HTYPE_TRANS_GET_REPORT: {
+                       switch(ptype) {
+                               case PTYPE_DATA_RTYPE_INPUT: {
+                                       output_report.type = HIDP_TRANS_DATA |
+                                                       HIDP_DATA_RTYPE_INPUT;
+                                       memcpy(output_report.rep_data, data, data_len);
+                                       bytes = write(info->intr_fd, &output_report,
+                                                               sizeof(output_report));
+                                       BT_DBG("Bytes Written %d", bytes);
+                                       break;
+                               }
+                               default:
+                                       BT_INFO("Not Supported");
+                                       break;
+                       }
+                       break;
+               case HTYPE_TRANS_GET_PROTOCOL: {
+                       BT_DBG("Replying to Get_PROTOCOL");
+                       output_report.type = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUTPUT;
+                       output_report.rep_data[0] = data[0];
+                       bytes = write(info->intr_fd, &output_report, 2);
+                       BT_DBG("Bytes Written %d", bytes);
+                       break;
+               }
+               case HTYPE_TRANS_SET_PROTOCOL: {
+                       BT_DBG("Reply to Set_Protocol");
+                       output_report.type = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_INPUT;
+                       memcpy(output_report.rep_data, data, data_len);
+                       bytes = write(info->ctrl_fd, &output_report,
+                                       sizeof(output_report));
+                       BT_DBG("Bytes Written %d", bytes);
+                       break;
+               }
+               case HTYPE_TRANS_HANDSHAKE: {
+                       BT_DBG("Replying Handshake");
+                       output_report.type = HIDP_TRANS_HANDSHAKE | data[0];
+                       memset(output_report.rep_data, 0, sizeof(output_report.rep_data));
+                       bytes = write(info->intr_fd,  &output_report.type,
+                                       sizeof(output_report.type));
+                       BT_DBG("Bytes Written %d", bytes);
+                       break;
+               }
+                       default:
+                               break;
+               }
+       }
+       return bytes;
+}
diff --git a/bt-api/bt-mdm.c b/bt-api/bt-mdm.c
deleted file mode 100644 (file)
index 6c5584b..0000000
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
- *              Girishashok Joshi <girish.joshi@samsung.com>
- *              Chanyeol Park <chanyeol.park@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *             http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifdef TIZEN_MDM_ENABLE
-#include <syspopup_caller.h>
-#include "bt-internal-types.h"
-#include "bt-common.h"
-#include "bt-mdm.h"
-
-int _bt_launch_mdm_popup(char *mode)
-{
-       int ret = 0;
-       bundle *b;
-
-       b = bundle_create();
-       retv_if(b == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       bundle_add(b, "mode", mode);
-
-       ret = syspopup_launch(BT_MDM_SYSPOPUP, b);
-
-       if (ret < 0)
-               BT_ERR("Popup launch failed: %d\n", ret);
-
-       bundle_free(b);
-
-       return ret;
-}
-
-bt_mdm_status_e _bt_check_mdm_handsfree_only(void)
-{
-       mdm_bt_allow_t mode;
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS) return BT_MDM_NO_SERVICE;
-
-       mode = mdm_get_allow_bluetooth_mode();
-       mdm_release_service();
-
-       return (mode == MDM_BT_HANDSFREE_ONLY ? BT_MDM_RESTRICTED : BT_MDM_ALLOWED);
-}
-
-#ifdef MDM_PHASE_2
-bt_mdm_status_e _bt_check_mdm_pairing_restriction(void)
-{
-       bt_mdm_status_e mdm_status = BT_MDM_ALLOWED;
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS)
-               return BT_MDM_NO_SERVICE;
-
-       if (mdm_get_bluetooth_pairing_state() == MDM_RESTRICTED) {
-               /* Not allow to visible on */
-               BT_ERR("Pairing Restricted");
-               mdm_status = BT_MDM_RESTRICTED;
-       }
-       mdm_release_service();
-
-       return mdm_status;
-}
-
-bt_mdm_status_e _bt_check_mdm_transfer_restriction(void)
-{
-       bt_mdm_status_e mdm_status = BT_MDM_ALLOWED;
-
-       mdm_status = _bt_check_mdm_blacklist_uuid(BT_OPP_UUID);
-
-       if (mdm_status == BT_MDM_NO_SERVICE || mdm_status == BT_MDM_RESTRICTED) {
-               return mdm_status;
-       }
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS) return BT_MDM_NO_SERVICE;
-
-       if (mdm_get_bluetooth_data_transfer_state() == MDM_RESTRICTED ||
-            mdm_get_allow_bluetooth_mode() == MDM_BT_HANDSFREE_ONLY) {
-               /* Not allow to visible on */
-               BT_ERR("Restricted to set visible mode");
-               mdm_status = BT_MDM_RESTRICTED;
-       }
-       mdm_release_service();
-
-       return mdm_status;
-}
-
-bt_mdm_status_e _bt_check_mdm_hsp_restriction(void)
-{
-       bt_mdm_status_e mdm_status = BT_MDM_ALLOWED;
-
-       mdm_status = _bt_check_mdm_blacklist_uuid(BT_HFP_AUDIO_GATEWAY_UUID);
-
-       if (mdm_status == BT_MDM_NO_SERVICE || mdm_status == BT_MDM_RESTRICTED) {
-               return mdm_status;
-       }
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS) return BT_MDM_NO_SERVICE;
-
-       if (mdm_get_bluetooth_profile_state(BLUETOOTH_HSP_PROFILE) == MDM_RESTRICTED ||
-               mdm_get_bluetooth_profile_state(BLUETOOTH_HFP_PROFILE) == MDM_RESTRICTED) {
-               /* Not allow to visible on */
-               BT_ERR("Restrict hsp / hfp profile");
-               mdm_status = BT_MDM_RESTRICTED;
-       }
-       mdm_release_service();
-
-       return mdm_status;
-}
-
-bt_mdm_status_e _bt_check_mdm_a2dp_restriction(void)
-{
-       bt_mdm_status_e mdm_status = BT_MDM_ALLOWED;
-
-       mdm_status = _bt_check_mdm_blacklist_uuid(BT_A2DP_UUID);
-
-       if (mdm_status == BT_MDM_NO_SERVICE || mdm_status == BT_MDM_RESTRICTED) {
-               return mdm_status;
-       }
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS) return BT_MDM_NO_SERVICE;
-
-       if (mdm_get_bluetooth_profile_state(BLUETOOTH_A2DP_PROFILE) == MDM_RESTRICTED) {
-               /* Not allow to visible on */
-               BT_ERR("Restrict a2dp profile");
-               mdm_status = BT_MDM_RESTRICTED;
-       }
-       mdm_release_service();
-
-       return mdm_status;
-}
-
-bt_mdm_status_e _bt_check_mdm_avrcp_restriction(void)
-{
-       bt_mdm_status_e mdm_status = BT_MDM_ALLOWED;
-
-
-       mdm_status = _bt_check_mdm_blacklist_uuid(BT_AVRCP_TARGET_UUID);
-
-       if (mdm_status == BT_MDM_NO_SERVICE || mdm_status == BT_MDM_RESTRICTED) {
-               return mdm_status;
-       }
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS) return BT_MDM_NO_SERVICE;
-
-       if (mdm_get_bluetooth_profile_state(BLUETOOTH_AVRCP_PROFILE) == MDM_RESTRICTED) {
-               /* Not allow to visible on */
-               BT_ERR("Restrict avrcp profile");
-               mdm_status = BT_MDM_RESTRICTED;
-       }
-       mdm_release_service();
-
-       return mdm_status;
-}
-
-bt_mdm_status_e _bt_check_mdm_spp_restriction(void)
-{
-       bt_mdm_status_e mdm_status = BT_MDM_ALLOWED;
-
-       mdm_status = _bt_check_mdm_blacklist_uuid(BT_SPP_UUID);
-
-       if (mdm_status == BT_MDM_NO_SERVICE || mdm_status == BT_MDM_RESTRICTED) {
-               return mdm_status;
-       }
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS) return BT_MDM_NO_SERVICE;
-
-       if (mdm_get_bluetooth_profile_state(BLUETOOTH_SPP_PROFILE) == MDM_RESTRICTED) {
-               /* Not allow to visible on */
-               BT_ERR("Restrict spp profile");
-               mdm_status = BT_MDM_RESTRICTED;
-       }
-       mdm_release_service();
-
-       return mdm_status;
-}
-
-bt_mdm_status_e _bt_check_mdm_whitelist_devices(const bluetooth_device_address_t *address)
-{
-       mdm_data_t *lp_data = NULL;
-       GList *whitelist = NULL;
-       char *device_name;
-       bluetooth_device_info_t dev_info;
-       bt_mdm_status_e mdm_status = BT_MDM_ALLOWED;
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS) return BT_MDM_NO_SERVICE;
-
-       memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
-
-       if (bluetooth_get_bonded_device(address,
-                               &dev_info) != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Not paired device");
-               return mdm_status;
-       }
-
-       lp_data = mdm_get_bluetooth_devices_from_whitelist();
-       if (lp_data == NULL) {
-               BT_ERR("No whitelist");
-               mdm_release_service();
-               return mdm_status;
-       }
-
-       for (whitelist = (GList *)lp_data->data; whitelist; whitelist = whitelist->next) {
-               device_name = whitelist->data;
-
-               DBG_SECURE("whitelist device name: %s", device_name);
-
-               if (g_strcmp0(dev_info.device_name.name,
-                                       device_name) == 0) {
-                       mdm_status = BT_MDM_RESTRICTED;
-                       break;
-               }
-       }
-
-       mdm_free_data(lp_data);
-       mdm_release_service();
-
-       return mdm_status;
-}
-
-bt_mdm_status_e _bt_check_mdm_whitelist_uuid(char *uuid)
-{
-       mdm_data_t *lp_data;
-       GList *blacklist;
-       char *blacklist_uuid;
-       bt_mdm_status_e mdm_status = BT_MDM_ALLOWED;
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS)
-               return BT_MDM_NO_SERVICE;
-
-       if (uuid == NULL)
-               return mdm_status;
-
-       lp_data = mdm_get_bluetooth_uuids_from_blacklist();
-       if (lp_data == NULL) {
-               BT_ERR("No blacklist");
-               mdm_release_service();
-               return mdm_status;
-       }
-
-       for (blacklist = (GList *)lp_data->data; blacklist; blacklist = blacklist->next) {
-               blacklist_uuid = blacklist->data;
-
-               BT_DBG("blacklist_uuid: %s", blacklist_uuid);
-
-               if (g_strcmp0(blacklist_uuid, uuid) == 0) {
-                       mdm_status = BT_MDM_RESTRICTED;
-                       break;
-               }
-       }
-
-       mdm_free_data(lp_data);
-       mdm_release_service();
-
-       return mdm_status;
-}
-
-bt_mdm_status_e _bt_check_mdm_blacklist_devices(const bluetooth_device_address_t *address)
-{
-       mdm_data_t *lp_data;
-       GList *blacklist;
-       char *device_name;
-       bluetooth_device_info_t dev_info;
-       bt_mdm_status_e mdm_status = BT_MDM_ALLOWED;
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS) return BT_MDM_NO_SERVICE;
-
-       memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
-
-       if (bluetooth_get_bonded_device(address,
-                               &dev_info) != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Not paired device");
-               return mdm_status;
-       }
-
-       lp_data = mdm_get_bluetooth_devices_from_blacklist();
-       if (lp_data == NULL) {
-               BT_ERR("No blacklist");
-               mdm_release_service();
-               return mdm_status;
-       }
-
-       for (blacklist = (GList *)lp_data->data; blacklist; blacklist = blacklist->next) {
-               device_name = blacklist->data;
-
-               DBG_SECURE("blacklist name: %s", device_name);
-
-               if (g_strcmp0(dev_info.device_name.name,
-                                       device_name) == 0) {
-                       mdm_status = BT_MDM_RESTRICTED;
-                       break;
-               }
-       }
-
-       mdm_free_data(lp_data);
-       mdm_release_service();
-
-       return mdm_status;
-}
-
-bt_mdm_status_e _bt_check_mdm_blacklist_uuid(char *uuid)
-{
-       mdm_data_t *lp_data;
-       GList *blacklist;
-       char *blacklist_uuid;
-       bt_mdm_status_e mdm_status = BT_MDM_ALLOWED;
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS)
-               return BT_MDM_NO_SERVICE;
-
-       if (uuid == NULL)
-               return mdm_status;
-
-       lp_data = mdm_get_bluetooth_uuids_from_blacklist();
-       if (lp_data == NULL) {
-               BT_ERR("No blacklist");
-               mdm_release_service();
-               return mdm_status;
-       }
-
-       for (blacklist = (GList *)lp_data->data; blacklist; blacklist = blacklist->next) {
-               blacklist_uuid = blacklist->data;
-
-               BT_DBG("blacklist_uuid: %s", blacklist_uuid);
-
-               if (g_strcmp0(blacklist_uuid, uuid) == 0) {
-                       mdm_status = BT_MDM_RESTRICTED;
-                       break;
-               }
-       }
-
-       mdm_free_data(lp_data);
-       mdm_release_service();
-
-       return mdm_status;
-}
-#endif
-#endif
-
index b4b6513..6a79be3 100644 (file)
@@ -37,6 +37,7 @@ BT_EXPORT_API int bluetooth_obex_server_init(const char *dst_path)
        bt_user_info_t *user_info;
        gboolean native_service = TRUE;
        char path[BT_FILE_PATH_MAX];
+       int res;
 
        BT_CHECK_ENABLED(return);
 
@@ -61,8 +62,10 @@ BT_EXPORT_API int bluetooth_obex_server_init(const char *dst_path)
 
        if (result == BLUETOOTH_ERROR_NONE) {
                _bt_set_obex_server_id(BT_NATIVE_SERVER);
-                _bt_register_event(BT_OPP_SERVER_EVENT, user_info->cb,
+               res = _bt_register_event(BT_OPP_SERVER_EVENT, user_info->cb,
                                        user_info->user_data);
+               if (res != BLUETOOTH_ERROR_NONE)
+                       BT_ERR("Fail to _bt_register_event(%d)", res);
        } else {
                BT_ERR("Fail to send request");
        }
@@ -109,6 +112,7 @@ BT_EXPORT_API int bluetooth_obex_server_init_without_agent(const char *dst_path)
        bt_user_info_t *user_info;
        gboolean native_service = FALSE;
        char path[BT_FILE_PATH_MAX];
+       int res;
 
        BT_CHECK_ENABLED(return);
 
@@ -133,8 +137,11 @@ BT_EXPORT_API int bluetooth_obex_server_init_without_agent(const char *dst_path)
 
        if (result == BLUETOOTH_ERROR_NONE) {
                _bt_set_obex_server_id(BT_CUSTOM_SERVER);
-               _bt_register_event(BT_OPP_SERVER_EVENT, user_info->cb,
+               res = _bt_register_event(BT_OPP_SERVER_EVENT, user_info->cb,
                                        user_info->user_data);
+               if (res != BLUETOOTH_ERROR_NONE)
+                       BT_ERR("Fail to _bt_register_event(%d)", res);
+
        } else {
                BT_ERR("Fail to send request");
        }
index 44fc216..b1c1c77 100644 (file)
@@ -175,6 +175,18 @@ static void __bt_get_event_info(int service_function, GArray *output,
                ret_if(output == NULL);
                *param_data = &g_array_index(output, char, 0);
                break;
+       case BT_AV_SOURCE_CONNECT:
+               *event_type = BT_A2DP_SOURCE_EVENT;
+               *event = BLUETOOTH_EVENT_AV_SOURCE_CONNECTED;
+               ret_if(output == NULL);
+               *param_data = &g_array_index(output, char, 0);
+               break;
+       case BT_AV_SOURCE_DISCONNECT:
+               *event_type = BT_A2DP_SOURCE_EVENT;
+               *event = BLUETOOTH_EVENT_AV_SOURCE_DISCONNECTED;
+               ret_if (output == NULL);
+               *param_data = &g_array_index (output, char, 0);
+               break;
        case BT_HF_CONNECT:
                *event_type = BT_HF_AGENT_EVENT;
                *event = BLUETOOTH_EVENT_HF_CONNECTED;
@@ -257,9 +269,9 @@ static void __send_request_cb(GDBusProxy *proxy,
        GError *error = NULL;
        GVariant *value;
        GVariant *param1;
-       GVariant *param2;
+//     GVariant *param2;
        GArray *out_param1 = NULL;
-       GArray *out_param2 = NULL;
+//     GArray *out_param2 = NULL;
 
        BT_DBG("+");
        memset(&bt_event, 0x00, sizeof(bluetooth_event_param_t));
@@ -280,7 +292,7 @@ static void __send_request_cb(GDBusProxy *proxy,
                                &bt_event.event, &event_type,
                                &bt_event.param_data);
        } else {
-               g_variant_get(value, "(@ay@ay)", &param1, &param2);
+               g_variant_get(value, "(iv)", &result, &param1);
                g_variant_unref(value);
 
                if (param1) {
@@ -289,15 +301,15 @@ static void __send_request_cb(GDBusProxy *proxy,
                        g_variant_unref(param1);
                }
 
-               if (param2) {
-                       out_param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
-                       __bt_fill_garray_from_variant(param2, out_param2);
-                       result = g_array_index(out_param2, int, 0);
-                       g_variant_unref(param2);
-                       g_array_free(out_param2, TRUE);
-               } else {
-                       result = BLUETOOTH_ERROR_INTERNAL;
-               }
+//             if (param2) {
+//                     out_param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
+//                     __bt_fill_garray_from_variant(param2, out_param2);
+//                     result = g_array_index(out_param2, int, 0);
+//                     g_variant_unref(param2);
+//                     g_array_free(out_param2, TRUE);
+//             } else {
+//                     result = BLUETOOTH_ERROR_INTERNAL;
+//             }
 
                ret_if(cb_data == NULL);
 
@@ -344,6 +356,10 @@ static void __send_request_cb(GDBusProxy *proxy,
                ((media_cb_func_ptr)cb_data->cb)(bt_event.event,
                                (media_event_param_t *)&bt_event,
                                cb_data->user_data);
+       } else if (event_type == BT_A2DP_SOURCE_EVENT) {
+               ((bt_audio_func_ptr)cb_data->cb)(bt_event.event,
+                               (bt_audio_event_param_t *)&bt_event,
+                               cb_data->user_data);
        } else {
                BT_INFO("Not handled event type : %d", event_type);
        }
@@ -363,9 +379,11 @@ int _bt_sync_send_request(int service_type, int service_function,
                        GArray **out_param1)
 {
        int result = BLUETOOTH_ERROR_NONE;
+       char *cookie;
        GError *error = NULL;
        GArray *in_param5 = NULL;
-       GArray *out_param2 = NULL;
+//     GArray *out_param2 = NULL;
+
        GDBusProxy  *proxy;
        GVariant *ret;
        GVariant *param1;
@@ -385,6 +403,13 @@ int _bt_sync_send_request(int service_type, int service_function,
 
                in_param5 = g_array_new(TRUE, TRUE, sizeof(gchar));
 
+               cookie = _bt_get_cookie();
+
+               if (cookie) {
+                       g_array_append_vals(in_param5, cookie,
+                                       _bt_get_cookie_size());
+               }
+
                param1 = g_variant_new_from_data((const GVariantType *)"ay",
                                        in_param1->data, in_param1->len,
                                        TRUE, NULL, NULL);
@@ -431,9 +456,9 @@ int _bt_sync_send_request(int service_type, int service_function,
                }
 
                param1 = NULL;
-               param2 = NULL;
+//             param2 = NULL;
 
-               g_variant_get(ret, "(@ay@ay)", &param1, &param2);
+               g_variant_get(ret, "(iv)", &result, &param1);
 
                if (param1) {
                        *out_param1 = g_array_new(TRUE, TRUE, sizeof(gchar));
@@ -441,15 +466,15 @@ int _bt_sync_send_request(int service_type, int service_function,
                        g_variant_unref(param1);
                }
 
-               if (param2) {
-                       out_param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
-                       __bt_fill_garray_from_variant(param2, out_param2);
-                       result = g_array_index(out_param2, int, 0);
-                       g_variant_unref(param2);
-                       g_array_free(out_param2, TRUE);
-               } else {
-                       result = BLUETOOTH_ERROR_INTERNAL;
-               }
+//             if (param2) {
+//                     out_param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
+//                     __bt_fill_garray_from_variant(param2, out_param2);
+//                     result = g_array_index(out_param2, int, 0);
+//                     g_variant_unref(param2);
+//                     g_array_free(out_param2, TRUE);
+//             } else {
+//                     result = BLUETOOTH_ERROR_INTERNAL;
+//             }
 
                g_variant_unref(ret);
                break;
@@ -468,6 +493,8 @@ int _bt_async_send_request(int service_type, int service_function,
 {
        GArray* in_param5 = NULL;
        bt_req_info_t *cb_data;
+       char *cookie;
+
        GDBusProxy *proxy;
        int timeout;
        GVariant *param1;
@@ -504,6 +531,12 @@ int _bt_async_send_request(int service_type, int service_function,
 
                in_param5 = g_array_new(TRUE, TRUE, sizeof(gchar));
 
+               cookie = _bt_get_cookie();
+
+               if (cookie) {
+                       g_array_append_vals(in_param5, cookie,
+                                       _bt_get_cookie_size());
+               }
                param1 = g_variant_new_from_data((const GVariantType *)"ay",
                                        in_param1->data, in_param1->len,
                                        TRUE, NULL, NULL);
index 2d2dafa..6a8a5d1 100644 (file)
@@ -167,19 +167,6 @@ static rfcomm_conn_info_t *__get_conn_info_from_fd(rfcomm_cb_data_t *info,
        return NULL;
 }
 
-static rfcomm_conn_info_t * __get_conn_info_for_disconnection(
-       rfcomm_cb_data_t *info)
-{
-       GSList *l;
-       rfcomm_conn_info_t *device_node = NULL;
-       for(l = info->rfcomm_conns; l != NULL; l = l->next) {
-               device_node = l->data;
-               if (device_node && device_node->disconnected == TRUE)
-                       return device_node;
-       }
-       return NULL;
-}
-
 static rfcomm_conn_info_t *__get_conn_info_from_address(rfcomm_cb_data_t *info,
                char *dev_address)
 {
@@ -249,6 +236,9 @@ static rfcomm_cb_data_t *__find_rfcomm_info_from_uuid(const char *uuid)
 static void _bt_rfcomm_disconnect_conn_info(rfcomm_conn_info_t *conn_info,
        rfcomm_cb_data_t *info)
 {
+       if (conn_info == NULL)
+               return;
+
        bluetooth_rfcomm_disconnection_t disconn_info;
        bt_event_info_t *event_info = NULL;
        if (conn_info->disconnected == FALSE)
@@ -407,7 +397,7 @@ static void __client_connected_cb(rfcomm_cb_data_t *cb_data, char *dev_address,
                return;
        }
        conn_info.socket_fd = conn_list_info->fd;
-//     conn_info.server_id = -1;
+       conn_info.server_id = -1;
 
        BT_DBG("Connection Result[%d] BT_ADDRESS[%s] UUID[%s] FD[%d]",
                        result, conn_list_info->bt_addr, cb_data->uuid, conn_list_info->fd);
@@ -453,7 +443,7 @@ int new_connection(const char *path, int fd, bluetooth_device_address_t *addr)
        return 0;
 }
 
-static void __bt_connect_response_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+static void __bt_connect_response_cb(GDBusProxy *proxy, GAsyncResult *res,
                                                        gpointer user_data)
 
 {
@@ -467,7 +457,7 @@ static void __bt_connect_response_cb(DBusGProxy *proxy, DBusGProxyCall *call,
 
        cb_data = user_data;
 
-       if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_INVALID)) {
+       if (!g_dbus_proxy_call_finish(proxy, res, &error)) {
                int result;
 
                BT_ERR("Error : %s \n", error->message);
@@ -476,23 +466,24 @@ static void __bt_connect_response_cb(DBusGProxy *proxy, DBusGProxyCall *call,
                        result = BLUETOOTH_ERROR_DEVICE_BUSY;
                else
                        result = BLUETOOTH_ERROR_INTERNAL;
-               path = dbus_g_proxy_get_path(proxy);
+               path = g_dbus_proxy_get_object_path(proxy);
                _bt_convert_device_path_to_address(path, dev_address);
                __rfcomm_client_connected_cb(cb_data, dev_address, result);
 
                g_error_free(error);
-               g_object_unref(proxy);
        }
+       if (proxy)
+               g_object_unref(proxy);
+
        BT_DBG("-");
 }
 
-static void __bt_discover_service_response_cb(DBusGProxy *proxy,
-                               DBusGProxyCall *call, gpointer user_data)
+static void __bt_discover_service_response_cb(GDBusProxy *proxy,
+                               GAsyncResult *res, gpointer user_data)
 {
        rfcomm_cb_data_t *cb_data;
        int ret = 0;
        GError *err = NULL;
-       GHashTable *hash = NULL;
        bt_register_profile_info_t info = {0};
        int result = BLUETOOTH_ERROR_NONE;
        char dev_address[BT_ADDRESS_STRING_SIZE];
@@ -504,14 +495,14 @@ static void __bt_discover_service_response_cb(DBusGProxy *proxy,
 
        cb_data = user_data;
 
-       path = dbus_g_proxy_get_path(proxy);
+       path = g_dbus_proxy_get_object_path(proxy);
+
        _bt_convert_device_path_to_address(path, dev_address);
        BT_DBG("Device Adress [%s]", dev_address);
-       dbus_g_proxy_end_call(proxy, call, &err,
-                       dbus_g_type_get_map("GHashTable",
-                 G_TYPE_UINT, G_TYPE_STRING), &hash,
-                 G_TYPE_INVALID);
-       g_object_unref(proxy);
+       g_dbus_proxy_call_finish(proxy, res, &err);
+       if (proxy)
+               g_object_unref(proxy);
+
        if (err != NULL) {
                BT_ERR("Error occured in Proxy call [%s]\n", err->message);
                if (!strcmp("Operation canceled", err->message)) {
@@ -559,9 +550,7 @@ static void __bt_discover_service_response_cb(DBusGProxy *proxy,
        }
 done:
        if (err)
-               g_error_free(err);
-       if (hash)
-               g_hash_table_destroy(hash);
+               g_clear_error(&err);
 }
 
 BT_EXPORT_API int bluetooth_rfcomm_connect(
@@ -676,7 +665,7 @@ BT_EXPORT_API int bluetooth_rfcomm_connect(
 #endif
 }
 
-BT_EXPORT_API int bluetooth_rfcomm_client_is_connected(bluetooth_device_address_t *device_address, gboolean *connected)
+BT_EXPORT_API int bluetooth_rfcomm_client_is_connected(const bluetooth_device_address_t *device_address, gboolean *connected)
 {
        GSList *l;
        GSList *conn_list = NULL;
@@ -687,7 +676,7 @@ BT_EXPORT_API int bluetooth_rfcomm_client_is_connected(bluetooth_device_address_
        BT_CHECK_PARAMETER(device_address, return);
        BT_CHECK_PARAMETER(connected, return);
 
-       _bt_convert_addr_type_to_string(address, device_address->addr);
+       _bt_convert_addr_type_to_string(address, (unsigned char *)device_address->addr);
        *connected = FALSE;
 
        for (l = rfcomm_clients; l != NULL; l = l->next) {
index 86ffc54..3028291 100644 (file)
@@ -93,6 +93,20 @@ static rfcomm_info_t *__find_rfcomm_info_with_path(const gchar *path)
        return NULL;
 }
 
+static rfcomm_info_t *__find_rfcomm_info_with_uuid(const char *uuid)
+{
+       GSList *l;
+
+       for (l = rfcomm_nodes; l != NULL; l = l->next) {
+               rfcomm_info_t *info = l->data;
+
+               if (g_strcmp0(info->uuid, uuid) == 0)
+                       return info;
+       }
+
+       return NULL;
+}
+
 gboolean _check_uuid_path(char *path, char *uuid)
 {
        rfcomm_info_t *info = NULL;
@@ -115,7 +129,7 @@ static void __connected_cb(rfcomm_info_t *info, bt_event_info_t *event_info)
        g_strlcpy(conn_info.uuid, info->uuid, BLUETOOTH_UUID_STRING_MAX);
        conn_info.socket_fd = info->fd;
        conn_info.device_addr = info->addr;
-//     conn_info.server_id = info->id;
+       conn_info.server_id = info->id;
 
        BT_INFO_C("Connected [RFCOMM Server]");
        _bt_common_event_cb(BLUETOOTH_EVENT_RFCOMM_CONNECTED,
@@ -302,6 +316,26 @@ static rfcomm_info_t *__register_method()
        return info;
 }
 
+static rfcomm_info_t *__register_method_2(const char *path,const char *bus_name)
+{
+       rfcomm_info_t *info;
+       int object_id;
+
+       object_id = _bt_register_new_conn_ex(path, bus_name, new_server_connection);
+       if (object_id < 0) {
+               return NULL;
+       }
+       info = g_new(rfcomm_info_t, 1);
+       info->object_id = (guint)object_id;
+       info->path = g_strdup(path);
+       info->id = -1;
+       info->fd = -1;
+
+       rfcomm_nodes = g_slist_append(rfcomm_nodes, info);
+
+       return info;
+}
+
 void free_rfcomm_info(rfcomm_info_t *info)
 {
        bt_event_info_t *event_info;
@@ -391,6 +425,35 @@ BT_EXPORT_API int bluetooth_rfcomm_create_socket(const char *uuid)
 #endif
 }
 
+BT_EXPORT_API int bluetooth_rfcomm_create_socket_ex(const char *uuid, const char *bus_name, const char *path)
+{
+#ifdef RFCOMM_DIRECT
+       rfcomm_info_t *info;
+
+       BT_CHECK_ENABLED(return);
+       BT_CHECK_PARAMETER(path, return);
+       BT_INFO("PATH Provided %s", path);
+
+       if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_RFCOMM_CREATE_SOCKET_EX)
+               == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+               BT_ERR("Don't have a privilege to use this API");
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       }
+
+       BT_INFO("<<<<<<<<< RFCOMM Create socket from app >>>>>>>>>");
+       info = __register_method_2(path, bus_name);
+       if (info == NULL)
+               return BLUETOOTH_ERROR_IN_PROGRESS;
+       info->uuid = g_strdup(uuid);
+       info->disconnect_idle_id = 0;
+
+       return BLUETOOTH_ERROR_NONE;
+#else
+       return BLUETOOTH_ERROR_NOT_SUPPORT;
+#endif
+}
+
+
 BT_EXPORT_API int bluetooth_rfcomm_remove_socket(int socket_fd)
 {
 #ifdef RFCOMM_DIRECT
@@ -442,6 +505,37 @@ BT_EXPORT_API int bluetooth_rfcomm_remove_socket(int socket_fd)
 #endif
 }
 
+BT_EXPORT_API int bluetooth_rfcomm_remove_socket_ex(const char *uuid)
+{
+#ifdef RFCOMM_DIRECT
+       rfcomm_info_t *info;
+
+       BT_CHECK_ENABLED(return);
+
+       if (_bt_check_privilege(BT_BLUEZ_SERVICE, BT_RFCOMM_REMOVE_SOCKET)
+               == BLUETOOTH_ERROR_PERMISSION_DEINED) {
+               BT_ERR("Don't have a privilege to use this API");
+               return BLUETOOTH_ERROR_PERMISSION_DEINED;
+       }
+
+       BT_INFO("<<<<<<<<< RFCOMM Remove socket request from app, uuid=[%s] >>>>>>>>>>>", uuid);
+
+       info = __find_rfcomm_info_with_uuid(uuid);
+       if (info == NULL)
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+
+       _bt_unregister_osp_server_in_agent(BT_RFCOMM_SERVER, info->uuid);
+       _bt_unregister_profile(info->path);
+
+       rfcomm_nodes = g_slist_remove(rfcomm_nodes, info);
+       free_rfcomm_info(info);
+
+       return BLUETOOTH_ERROR_NONE;
+#else
+       return BLUETOOTH_ERROR_NOT_SUPPORT;
+#endif
+}
+
 BT_EXPORT_API int bluetooth_rfcomm_server_disconnect(int socket_fd)
 {
 #ifdef RFCOMM_DIRECT
@@ -466,7 +560,8 @@ BT_EXPORT_API int bluetooth_rfcomm_server_disconnect(int socket_fd)
        BT_DBG("Address %s", address);
        _bt_disconnect_profile(address, info->uuid, NULL,NULL);
 
-       info->disconnect_idle_id = g_idle_add(__rfcomm_server_disconnect, info);
+       info->disconnect_idle_id = g_idle_add((GSourceFunc)
+                                                       __rfcomm_server_disconnect, info);
        BT_DBG("-");
 
        return BLUETOOTH_ERROR_NONE;
@@ -523,7 +618,7 @@ BT_EXPORT_API gboolean bluetooth_rfcomm_is_server_uuid_available(const char *uui
        return available;
 }
 
-BT_EXPORT_API int bluetooth_rfcomm_server_is_connected(bluetooth_device_address_t *device_address, gboolean *connected)
+BT_EXPORT_API int bluetooth_rfcomm_server_is_connected(const bluetooth_device_address_t *device_address, gboolean *connected)
 {
        GSList *l;
        rfcomm_info_t *info;
@@ -533,7 +628,7 @@ BT_EXPORT_API int bluetooth_rfcomm_server_is_connected(bluetooth_device_address_
        BT_CHECK_PARAMETER(device_address, return);
        BT_CHECK_PARAMETER(connected, return);
 
-       _bt_convert_addr_type_to_string(input_addr, device_address->addr);
+       _bt_convert_addr_type_to_string(input_addr, (unsigned char *)device_address->addr);
 
        *connected = FALSE;
 
@@ -580,6 +675,7 @@ BT_EXPORT_API int bluetooth_rfcomm_listen_and_accept(int socket_fd, int max_pend
        profile_info.role = NULL;
        profile_info.service = info->uuid;
        profile_info.uuid = info->uuid;
+
        BT_INFO("uuid %s", profile_info.uuid);
        result = _bt_register_profile(&profile_info, TRUE);
 
@@ -603,6 +699,38 @@ BT_EXPORT_API int bluetooth_rfcomm_listen_and_accept(int socket_fd, int max_pend
 #endif
 }
 
+BT_EXPORT_API int bluetooth_rfcomm_listen_and_accept_ex(const char *uuid, int max_pending_connection, const char *bus_name, const char *path)
+{
+#ifdef RFCOMM_DIRECT
+       rfcomm_info_t *info;
+
+       BT_CHECK_ENABLED(return);
+
+       BT_INFO("<<<<<<<<< RFCOMM Listen & accept from app >>>>>>>>>>>");
+
+       info = __find_rfcomm_info_with_uuid(uuid);
+       if (info == NULL)
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+
+       bt_register_profile_info_t profile_info;
+       int result;
+
+       profile_info.authentication = TRUE;
+       profile_info.authorization = TRUE;
+       profile_info.obj_path = info->path;
+       profile_info.role = NULL;
+       profile_info.service = info->uuid;
+       profile_info.uuid = info->uuid;
+
+       BT_INFO("uuid %s", profile_info.uuid);
+       result = _bt_register_profile_ex(&profile_info, TRUE, bus_name, path);
+
+       return result;
+#else
+       return BLUETOOTH_ERROR_NOT_SUPPORT;
+#endif
+}
+
 BT_EXPORT_API int bluetooth_rfcomm_listen(int socket_fd, int max_pending_connection)
 {
 #ifdef RFCOMM_DIRECT
@@ -662,7 +790,7 @@ BT_EXPORT_API int bluetooth_rfcomm_listen(int socket_fd, int max_pending_connect
 #endif
 }
 
-BT_EXPORT_API int bluetooth_rfcomm_accept_connection(int server_fd, int *client_fd)
+BT_EXPORT_API int bluetooth_rfcomm_accept_connection(int server_fd)
 {
        int result;
 
@@ -678,14 +806,8 @@ BT_EXPORT_API int bluetooth_rfcomm_accept_connection(int server_fd, int *client_
 
        BT_DBG("result: %x", result);
 
-       if (result == BLUETOOTH_ERROR_NONE) {
-               *client_fd = g_array_index(out_param, int, 0);
-       }
-
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-       BT_DBG("client_fd: %d", *client_fd);
-
        return result;
 }
 
index 0012031..d0d81d4 100644 (file)
@@ -1,6 +1,6 @@
 prefix=@PREFIX@
 exec_prefix=@EXEC_PREFIX@
-libdir=@LIB_INSTALL_DIR@
+libdir=@LIBDIR@
 includedir=@INCLUDEDIR@
 
 Name: bt-service
index a01efaa..e8db5cf 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Contact:    Hocheol Seo <hocheol.seo@samsung.com>
- *             GirishAshok Joshi <girish.joshi@samsung.com>
+ *             Jaganath K <jaganath.k@samsung.com>
  *             Chanyeol Park <chanyeol.park@samsung.com>
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
 #define BT_MSBC_CODEC_ID 2
 
 typedef struct {
-       DBusGConnection *conn;
-       DBusGProxy *proxy;
-       DBusGProxy *dbus_proxy;
-       DBusGProxy *manager_proxy;
+       GDBusConnection *conn;
+       GDBusProxy *proxy;
+       GDBusProxy *dbus_proxy;
+       GDBusProxy *manager_proxy;
 } telephony_dbus_info_t;
 
 typedef struct {
@@ -60,7 +60,6 @@ typedef struct {
 char *src_addr = NULL;
 
 
-
 #define BLUETOOTH_TELEPHONY_ERROR (__bluetooth_telephony_error_quark())
 
 #define BLUEZ_SERVICE_NAME "org.bluez"
@@ -73,9 +72,10 @@ char *src_addr = NULL;
 #define HFP_AGENT_SERVICE "org.bluez.ag_agent"
 
 
-#define HFP_AGENT_PATH "/org/bluez/hfp_ag"
+#define HFP_AGENT_PATH "/org/bluez/hfp_agent"
 #define HFP_AGENT_INTERFACE "Org.Hfp.App.Interface"
 
+#define TELEPHONY_APP_INTERFACE "org.tizen.csd.Call.Instance"
 #define CSD_CALL_APP_PATH "/org/tizen/csd/%d"
 #define HFP_NREC_STATUS_CHANGE "NrecStatusChanged"
 #define HFP_ANSWER_CALL "Answer"
@@ -85,6 +85,18 @@ char *src_addr = NULL;
 
 #define DEFAULT_ADAPTER_OBJECT_PATH "/org/bluez/hci0"
 
+/*Below Inrospection data is exposed to bluez from agent*/
+static const gchar bt_telephony_introspection_xml[] =
+"<node name='/'>"
+" <interface name='org.tizen.csd.Call.Instance'>"
+"     <method name='SendDtmf'>"
+"          <arg type='s' name='dtmf' direction='in'/>"
+"     </method>"
+"     <method name='VendorCmd'>"
+"          <arg type='s' name='vendor' direction='in'/>"
+"     </method>"
+" </interface>"
+"</node>";
 
 #define BT_TELEPHONY_CHECK_ENABLED() \
        do { \
@@ -105,68 +117,16 @@ static gboolean is_initialized = FALSE;
                } \
        } while (0)
 
-#define BLUETOOTH_TELEPHONY_METHOD (bluetooth_telephony_method_get_type())
-#define BLUETOOTH_TELEPHONY_METHOD_GET_OBJECT(obj) \
-               (G_TYPE_CHECK_INSTANCE_CAST((obj), \
-               BLUETOOTH_TELEPHONY_METHOD, BluetoothTelephonyMethod))
-
-#define BLUETOOTH_TELEPHONY_METHOD_IS_OBJECT(obj) \
-               (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
-               BLUETOOTH_TELEPHONY_METHOD))
-
-#define BLUETOOTH_TELEPHONY_METHOD_CLASS(class) \
-               (G_TYPE_CHECK_CLASS_CAST((class), \
-               BLUETOOTH_TELEPHONY_METHOD, BluetoothTelephonyMethodClass))
-
-#define BLUETOOTH_TELEPHONY_METHOD_GET_AGENT_CLASS(obj) \
-               (G_TYPE_INSTANCE_GET_CLASS((obj), \
-               BLUETOOTH_TELEPHONY_METHOD, BluetoothTelephonyMethodClass))
-
-#define BLUETOOTH_TELEPHONY_METHOD_IS_AGENT_CLASS(class) \
-               (G_TYPE_CHECK_CLASS_TYPE((class), BLUETOOTH_TELEPHONY_METHOD))
-
-#define BLUETOOTH_TELEPHONY_METHOD_AGENT_GET_PRIVATE(obj) \
-               (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
-               BLUETOOTH_TELEPHONY_METHOD, BluetoothTelephonyMethodPrivate))
-
-typedef struct _BluetoothTelephonyMethod BluetoothTelephonyMethod;
-typedef struct _BluetoothTelephonyMethodClass BluetoothTelephonyMethodClass;
-
-struct _BluetoothTelephonyMethod {
-       GObject parent;
-};
-
-struct _BluetoothTelephonyMethodClass {
-       GObjectClass parent_class;
-};
-
-BluetoothTelephonyMethod *bluetooth_telephony_method_new(void);
-GType bluetooth_telephony_method_get_type(void);
-
-G_DEFINE_TYPE(BluetoothTelephonyMethod, bluetooth_telephony_method, G_TYPE_OBJECT)
-
-
-static DBusHandlerResult __bt_telephony_adapter_filter(DBusConnection *conn,
-                       DBusMessage *msg, void *data);
-
-static int __bt_telephony_get_object_path(DBusMessage *msg, char **path);
-
-static char *__bt_extract_device_path(DBusMessageIter *msg_iter, char *address);
+static void __bt_telephony_adapter_filter(GDBusConnection *connection,
+                                       const gchar *sender_name,
+                                       const gchar *object_path,
+                                       const gchar *interface_name,
+                                       const gchar *signal_name,
+                                       GVariant *parameters,
+                                       gpointer user_data);
 
-static char *__bt_get_default_adapter_path(DBusMessageIter *msg_iter);
+static int __bt_telephony_get_src_addr(GVariant *value);
 
-static int __bt_telephony_get_src_addr(DBusMessage *msg);
-
-static gboolean bluetooth_telephony_method_send_dtmf(
-                               BluetoothTelephonyMethod *object,
-                               gchar *dtmf, DBusGMethodInvocation *context);
-
-static gboolean bluetooth_telephony_method_vendor_cmd(
-                               BluetoothTelephonyMethod *object,
-                               gchar *at_cmd, DBusGMethodInvocation *context);
-#include "bt-telephony-glue.h"
-
-static GObject *object;
 static bt_telephony_info_t telephony_info;
 static telephony_dbus_info_t telephony_dbus_info;
 static gboolean is_active = FALSE;
@@ -175,29 +135,102 @@ static gboolean is_active = FALSE;
 static int __bt_telephony_get_error(const char *error_message);
 static void __bt_telephony_event_cb(int event, int result, void *param_data);
 static GQuark __bluetooth_telephony_error_quark(void);
-static DBusMessage* __bluetooth_telephony_dbus_method_send(const char *path,
-                       const char *interface, const char *method, DBusError *err,  int type, ...);
+static GVariant *__bluetooth_telephony_dbus_method_send(const char *path,
+               const char *interface, const char *method,
+               GError **err, GVariant *parameters);
 static int __bluetooth_telephony_send_call_status(
                        bt_telephony_call_status_t call_status,
                        unsigned int call_id, const char *ph_number);
-static GError *__bluetooth_telephony_error(bluetooth_telephony_error_t error,
-                                       const char *err_msg);
+static void __bluetooth_telephony_error(GDBusMethodInvocation *invocation,
+               bluetooth_telephony_error_t error, const char *err_msg);
 
-static DBusHandlerResult __bluetooth_telephony_event_filter(
-                                               DBusConnection *conn,
-                                               DBusMessage *msg, void *data);
+static void __bluetooth_telephony_event_filter(GDBusConnection *connection,
+                                                const gchar *sender_name,
+                                                const gchar *object_path,
+                                                const gchar *interface_name,
+                                                const gchar *signal_name,
+                                                GVariant *parameters,
+                                                gpointer user_data);
 
 static int __bluetooth_telephony_proxy_init(void);
 static void __bluetooth_telephony_proxy_deinit(void);
 static int __bluetooth_telephony_register(void);
 static int __bluetooth_telephony_unregister(void);
-static int __bluetooth_get_default_adapter_path(DBusGConnection *GConn,
-                                                       char *path);
+
 static gboolean __bluetooth_telephony_is_headset(uint32_t device_class);
 static int __bluetooth_telephony_get_connected_device(void);
-static DBusGProxy *__bluetooth_telephony_get_connected_device_proxy(void);
+static GDBusProxy *__bluetooth_telephony_get_connected_device_proxy(void);
 
 /*Function Definition*/
+static void __bt_telephony_method(GDBusConnection *connection,
+                       const gchar *sender,
+                       const gchar *object_path,
+                       const gchar *interface_name,
+                       const gchar *method_name,
+                       GVariant *parameters,
+                       GDBusMethodInvocation *invocation,
+                       gpointer user_data)
+{
+       FN_START;
+
+       BT_INFO("method %s", method_name);
+       BT_INFO("object_path %s", object_path);
+
+       if (g_strcmp0(method_name, "SendDtmf") == 0) {
+               gchar *dtmf;
+               telephony_event_dtmf_t call_data = { 0, };
+
+               g_variant_get(parameters, "(&s)", &dtmf);
+
+               if (dtmf == NULL) {
+                       BT_ERR("Number dial failed");
+                       __bluetooth_telephony_error(invocation,
+                                       BLUETOOTH_TELEPHONY_ERROR_INVALID_DTMF,
+                                       "Invalid dtmf");
+               } else {
+                       DBG_SECURE("Dtmf = %s", dtmf);
+
+                       call_data.dtmf = g_strdup(dtmf);
+                       __bt_telephony_event_cb(
+                               BLUETOOTH_EVENT_TELEPHONY_SEND_DTMF,
+                               BLUETOOTH_TELEPHONY_ERROR_NONE,
+                               (void *)&call_data);
+
+                       g_free(call_data.dtmf);
+
+                       g_dbus_method_invocation_return_value(invocation, NULL);
+               }
+       } else if (g_strcmp0(method_name, "VendorCmd") == 0) {
+               gchar *at_cmd;
+
+               g_variant_get(parameters, "(&s)", &at_cmd);
+               BT_INFO("Vendor %s", at_cmd);
+               if (at_cmd == NULL) {
+                       BT_ERR("Vendor command is NULL\n");
+                       __bluetooth_telephony_error(invocation,
+                                       BLUETOOTH_TELEPHONY_ERROR_APPLICATION,
+                                       "Invalid at vendor cmd");
+               } else {
+                       DBG_SECURE("Vendor AT cmd = %s", at_cmd);
+
+                       __bt_telephony_event_cb(
+                               BLUETOOTH_EVENT_TELEPHONY_VENDOR_AT_CMD,
+                               BLUETOOTH_TELEPHONY_ERROR_NONE,
+                               at_cmd);
+
+                       g_dbus_method_invocation_return_value(invocation, NULL);
+               }
+       }
+
+       BT_INFO("-");
+}
+
+static const GDBusInterfaceVTable method_table = {
+       __bt_telephony_method,
+       NULL,
+       NULL,
+};
+
 static int __bt_telephony_get_error(const char *error_message)
 {
        if (error_message == NULL) {
@@ -222,7 +255,8 @@ static int __bt_telephony_get_error(const char *error_message)
                return BLUETOOTH_TELEPHONY_ERROR_NO_MEMORY;
        else if (g_strcmp0(error_message, "I/O error") == 0)
                return BLUETOOTH_TELEPHONY_ERROR_I_O_ERROR;
-       else if (g_strcmp0(error_message, "Operation currently not available") == 0)
+       else if (g_strcmp0(error_message,
+                       "Operation currently not available") == 0)
                return BLUETOOTH_TELEPHONY_ERROR_OPERATION_NOT_AVAILABLE;
        else if (g_strrstr(error_message, BT_ACCESS_DENIED_MSG))
                return BLUETOOTH_TELEPHONY_ERROR_PERMISSION_DENIED;
@@ -232,43 +266,27 @@ static int __bt_telephony_get_error(const char *error_message)
 
 static int __bt_telephony_check_privilege(void)
 {
-       DBusMessage *msg;
-       DBusMessage *reply;
-       DBusError err;
-       DBusConnection *conn;
+       GVariant *reply;
+       GError *err = NULL;
        int ret;
 
-       conn = _bt_get_system_conn();
-       retv_if(conn == NULL, BLUETOOTH_TELEPHONY_ERROR_INTERNAL);
-
-       msg = dbus_message_new_method_call(HFP_AGENT_SERVICE,
+       FN_START;
+       reply = __bluetooth_telephony_dbus_method_send(
                        HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
-                       "CheckPrivilege");
-       if (!msg) {
-               BT_ERR("Unable to allocate new D-Bus message \n");
-               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
-       }
-
-       dbus_error_init(&err);
-
-       reply = dbus_connection_send_with_reply_and_block(conn,
-                                               msg, -1, &err);
-
-       dbus_message_unref(msg);
+                       "CheckPrivilege", &err, NULL);
 
        if (!reply) {
                BT_ERR("Error returned in method call");
-               if (dbus_error_is_set(&err)) {
-                       ret = __bt_telephony_get_error(err.message);
-                       BT_ERR("Error here %d\n", ret);
-                       dbus_error_free(&err);
+               if (err) {
+                       ret = __bt_telephony_get_error(err->message);
+                       g_error_free(err);
                        return ret;
                }
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
+       g_variant_unref(reply);
 
-       dbus_message_unref(reply);
-
+       FN_END;
        return BLUETOOTH_TELEPHONY_ERROR_NONE;
 }
 
@@ -294,44 +312,35 @@ static GQuark __bluetooth_telephony_error_quark(void)
        return quark;
 }
 
-static DBusMessage* __bluetooth_telephony_dbus_method_send(const char *path,
-                       const char *interface, const char *method, DBusError *err,  int type, ...)
+static GVariant *__bluetooth_telephony_dbus_method_send(const char *path,
+               const char *interface, const char *method,
+               GError **err, GVariant *parameters)
 {
-       DBusMessage *msg;
-       DBusMessage *reply;
-       va_list args;
 #ifdef TIZEN_WEARABLE
        int timeout = 4000;
 #else
        int timeout = -1;
 #endif
+       GVariant *reply;
+       GDBusProxy *proxy;
+       GDBusConnection *conn;
 
        FN_START;
 
-       msg = dbus_message_new_method_call(HFP_AGENT_SERVICE,
-                       path, interface, method);
-       if (!msg) {
-               BT_ERR("Unable to allocate new D-Bus %s message \n", method);
-               return NULL;
-       }
-
-       va_start(args, type);
+       conn = telephony_dbus_info.conn;
+       retv_if(conn == NULL, NULL);
 
-       if (!dbus_message_append_args_valist(msg, type, args)) {
-               dbus_message_unref(msg);
-               va_end(args);
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                       NULL, HFP_AGENT_SERVICE, path, interface, NULL, err);
+       if (proxy == NULL) {
+               BT_ERR("Unable to allocate new proxy");
                return NULL;
        }
 
-       va_end(args);
-
-       dbus_error_init(err);
-
-       reply = dbus_connection_send_with_reply_and_block(
-               dbus_g_connection_get_connection(telephony_dbus_info.conn),
-               msg, timeout, err);
-       dbus_message_unref(msg);
+       reply = g_dbus_proxy_call_sync(proxy, method, parameters,
+                               G_DBUS_CALL_FLAGS_NONE, timeout, NULL, err);
 
+       g_object_unref(proxy);
        FN_END;
        return reply;
 }
@@ -340,8 +349,9 @@ static int __bluetooth_telephony_send_call_status(
                        bt_telephony_call_status_t call_status,
                        unsigned int call_id, const char *ph_number)
 {
-       DBusMessage *reply;
-       DBusError err;
+       GVariant *reply;
+       GVariant *param;
+       GError *err = NULL;
        char *path = g_strdup(telephony_info.call_path);
        char *phone_number;
        int ret;
@@ -353,93 +363,46 @@ static int __bluetooth_telephony_send_call_status(
        else
                phone_number = g_strdup(ph_number);
 
+       param = g_variant_new("(ssii)", path, phone_number,
+                       call_status, call_id);
        reply = __bluetooth_telephony_dbus_method_send(
                        HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
-                       "ChangeCallStatus", &err, DBUS_TYPE_STRING, &path,
-                       DBUS_TYPE_STRING, &phone_number,
-                       DBUS_TYPE_INT32, &call_status,
-                       DBUS_TYPE_INT32, &call_id, DBUS_TYPE_INVALID);
+                       "ChangeCallStatus", &err, param);
 
        g_free(path);
        g_free(phone_number);
 
        if (!reply) {
-               BT_ERR("Error returned in method call\n");
-               if (dbus_error_is_set(&err)) {
-                       ret = __bt_telephony_get_error(err.message);
-                       dbus_error_free(&err);
+               BT_ERR("Error returned in method call");
+               if (err) {
+                       ret = __bt_telephony_get_error(err->message);
+                       g_error_free(err);
                        return ret;
                }
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
 
-       dbus_message_unref(reply);
+       g_variant_unref(reply);
 
        return BLUETOOTH_TELEPHONY_ERROR_NONE;
 }
 
-static GError *__bluetooth_telephony_error(bluetooth_telephony_error_t error,
-                                       const char *err_msg)
-{
-       return g_error_new(BLUETOOTH_TELEPHONY_ERROR, error, err_msg, NULL);
-}
-
-static void bluetooth_telephony_method_init(BluetoothTelephonyMethod *object)
+static void __bluetooth_telephony_error(GDBusMethodInvocation *invocation,
+               bluetooth_telephony_error_t error, const char *err_msg)
 {
-       FN_START;
-       BT_DBG("agent %p\n", object);
-       FN_END;
-}
-
-static void __bluetooth_telephony_method_finalize(
-                                       BluetoothTelephonyMethod *object)
-{
-       FN_START;
-       G_OBJECT_CLASS(bluetooth_telephony_method_parent_class)->finalize((
-                                                       GObject *)object);
-       FN_END;
+       g_dbus_method_invocation_return_error(invocation,
+                       BLUETOOTH_TELEPHONY_ERROR, error,
+                       err_msg, NULL);
 }
 
-static BluetoothTelephonyMethod *__bluetooth_telephony_method_new(void)
-{
-       BluetoothTelephonyMethod *obj;
-
-       FN_START;
-       obj = g_object_new(BLUETOOTH_TELEPHONY_METHOD, NULL);
-       FN_END;
-
-       return obj;
-}
-
-static void bluetooth_telephony_method_class_init(
-                                       BluetoothTelephonyMethodClass *klass)
-{
-       GObjectClass *object_class = NULL;
-       FN_START;
-
-       object_class = G_OBJECT_CLASS(klass);
-       object_class->finalize = (void *)__bluetooth_telephony_method_finalize;
-
-       /*Registration of the Framework methods */
-       dbus_g_object_type_install_info(BLUETOOTH_TELEPHONY_METHOD,
-                       &dbus_glib_bluetooth_telephony_method_object_info);
-       FN_END;
-       return;
-}
-
-static void __bluetooth_telephony_answer_call(DBusMessage *msg)
+static void __bluetooth_telephony_answer_call(GVariant *var)
 {
        telephony_event_callid_t call_data = { 0, };
        unsigned int callid;
 
        FN_START;
-       if (!dbus_message_get_args(msg, NULL,
-                               DBUS_TYPE_UINT32, &callid,
-                               DBUS_TYPE_INVALID)) {
-               BT_ERR("Error Getting parameters");
-               return;
-       }
 
+       g_variant_get(var, "(u)", &callid);
        BT_DBG("call_id = [%d]", callid);
        call_data.callid = callid;
 
@@ -449,19 +412,14 @@ static void __bluetooth_telephony_answer_call(DBusMessage *msg)
        FN_END;
 }
 
-static void __bluetooth_telephony_release_call(DBusMessage *msg)
+static void __bluetooth_telephony_release_call(GVariant *var)
 {
        telephony_event_callid_t call_data = { 0, };
        unsigned int callid;
 
        FN_START;
-       if (!dbus_message_get_args(msg, NULL,
-                               DBUS_TYPE_UINT32, &callid,
-                               DBUS_TYPE_INVALID)) {
-               BT_ERR("Error Getting parameters");
-               return;
-       }
 
+       g_variant_get(var, "(u)", &callid);
        BT_DBG("call_id = [%d]", callid);
        call_data.callid = callid;
 
@@ -471,19 +429,14 @@ static void __bluetooth_telephony_release_call(DBusMessage *msg)
        FN_END;
 }
 
-static void __bluetooth_telephony_reject_call(DBusMessage *msg)
+static void __bluetooth_telephony_reject_call(GVariant *var)
 {
        telephony_event_callid_t call_data = { 0, };
        unsigned int callid;
 
        FN_START;
-       if (!dbus_message_get_args(msg, NULL,
-                               DBUS_TYPE_UINT32, &callid,
-                               DBUS_TYPE_INVALID)) {
-               BT_ERR("Error Getting parameters");
-               return;
-       }
 
+       g_variant_get(var, "(u)", &callid);
        BT_DBG("call_id = [%d]", callid);
        call_data.callid = callid;
 
@@ -493,19 +446,14 @@ static void __bluetooth_telephony_reject_call(DBusMessage *msg)
        FN_END;
 }
 
-static void __bluetooth_telephony_threeway_call(DBusMessage *msg)
+static void __bluetooth_telephony_threeway_call(GVariant *var)
 {
        int event = 0;
        unsigned int chld_value;
 
        FN_START;
-       if (!dbus_message_get_args(msg, NULL,
-                               DBUS_TYPE_UINT32, &chld_value,
-                               DBUS_TYPE_INVALID)) {
-               BT_ERR("Error Getting parameters");
-               return;
-       }
 
+       g_variant_get(var, "(u)", &chld_value);
        BT_DBG("chld value  = [%d]", chld_value);
 
        switch (chld_value) {
@@ -531,76 +479,11 @@ static void __bluetooth_telephony_threeway_call(DBusMessage *msg)
        FN_END;
 }
 
-static gboolean bluetooth_telephony_method_send_dtmf(
-                               BluetoothTelephonyMethod *object,
-                               gchar *dtmf, DBusGMethodInvocation *context)
-{
-       telephony_event_dtmf_t call_data = { 0, };
-       GError *err;
-
-       FN_START;
-
-       if (dtmf == NULL) {
-               BT_ERR("Number dial failed");
-               err = __bluetooth_telephony_error(
-                               BLUETOOTH_TELEPHONY_ERROR_INVALID_DTMF,
-                               "Invalid dtmf");
-               dbus_g_method_return_error(context, err);
-               g_error_free(err);
-               return FALSE;
-       }
-
-       DBG_SECURE("Dtmf = %s", dtmf);
-
-       call_data.dtmf = g_strdup(dtmf);
-
-       __bt_telephony_event_cb(BLUETOOTH_EVENT_TELEPHONY_SEND_DTMF,
-               BLUETOOTH_TELEPHONY_ERROR_NONE, (void *)&call_data);
-
-       dbus_g_method_return(context);
-       g_free(call_data.dtmf);
-       FN_END;
-       return TRUE;
-}
-
-static gboolean bluetooth_telephony_method_vendor_cmd(
-                               BluetoothTelephonyMethod *object,
-                               gchar *at_cmd, DBusGMethodInvocation *context)
-{
-       GError *err;
-
-       FN_START;
-
-       if (at_cmd == NULL) {
-               BT_ERR("Vendor command is NULL\n");
-               err = __bluetooth_telephony_error(
-                               BLUETOOTH_TELEPHONY_ERROR_APPLICATION,
-                               "Invalid at vendor cmd");
-               dbus_g_method_return_error(context, err);
-               g_error_free(err);
-               return FALSE;
-       }
-
-       DBG_SECURE("Vendor AT cmd = %s", at_cmd);
-
-       __bt_telephony_event_cb(BLUETOOTH_EVENT_TELEPHONY_VENDOR_AT_CMD,
-               BLUETOOTH_TELEPHONY_ERROR_NONE, at_cmd);
-
-       dbus_g_method_return(context);
-       FN_END;
-       return TRUE;
-}
-
-static void __bluetooth_handle_nrec_status_change(DBusMessage *msg)
+static void __bluetooth_handle_nrec_status_change(GVariant *var)
 {
        gboolean status = FALSE;
 
-       if (!dbus_message_get_args(msg, NULL,
-                               DBUS_TYPE_BOOLEAN, &status,
-                               DBUS_TYPE_INVALID)) {
-               BT_ERR("Error Getting parameters");
-               return;
-       }
+       g_variant_get(var, "(b)", &status);
        BT_INFO("NREC status = %d", status);
 
        __bt_telephony_event_cb(BLUETOOTH_EVENT_TELEPHONY_NREC_CHANGED,
@@ -608,226 +491,236 @@ static void __bluetooth_handle_nrec_status_change(DBusMessage *msg)
 
 }
 
-static DBusHandlerResult __bluetooth_telephony_event_filter(
-                                               DBusConnection *conn,
-                                               DBusMessage *msg, void *data)
+static void __bluetooth_telephony_event_filter(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 *dev_addr = NULL;
-       DBusMessageIter item_iter;
-       DBusMessageIter value_iter;
-       const char *property;
-
-       /* Check NREC status change Signal*/
-       if (dbus_message_is_signal(msg, HFP_AGENT_SERVICE,
-                               HFP_NREC_STATUS_CHANGE)) {
-               __bluetooth_handle_nrec_status_change(msg);
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-       }
+       BT_DBG("+");
 
-       if (dbus_message_is_signal(msg, HFP_AGENT_SERVICE,
-                               HFP_ANSWER_CALL)) {
-               __bluetooth_telephony_answer_call(msg);
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-       }
+       if (strcasecmp(interface_name, HFP_AGENT_SERVICE) == 0) {
+               if (strcasecmp(signal_name, HFP_NREC_STATUS_CHANGE) == 0)
+                       __bluetooth_handle_nrec_status_change(parameters);
+               else if (strcasecmp(signal_name, HFP_ANSWER_CALL) == 0)
+                       __bluetooth_telephony_answer_call(parameters);
+               else if (strcasecmp(signal_name, HFP_REJECT_CALL) == 0)
+                       __bluetooth_telephony_reject_call(parameters);
+               else if (strcasecmp(signal_name, HFP_RELEASE_CALL) == 0)
+                       __bluetooth_telephony_release_call(parameters);
+               else if (strcasecmp(signal_name, HFP_THREEWAY_CALL) == 0)
+                       __bluetooth_telephony_threeway_call(parameters);
+       } else if (strcasecmp(interface_name, BLUEZ_HEADSET_INTERFACE) == 0) {
+               if (strcasecmp(signal_name, "PropertyChanged") == 0) {
+                       GVariant *values;
+                       gchar *property;
+
+                       g_variant_get(parameters, "(&sv)", &property, &values);
+                       BT_DBG("Property: %s", property);
+
+                       if (strcasecmp(property, "State") == 0) {
+                               gchar *state;
+                               state = (gchar *)g_variant_get_string(values, NULL);
+
+                               if (NULL == state) {
+                                       BT_ERR("State is null");
+                                       return;
+                               }
+                               BT_DBG("state: %s", state);
+                               if (g_strcmp0(state, "connected") == 0) {
+                                       telephony_info.headset_state = BLUETOOTH_STATE_CONNECTED;
+                               } else if (g_strcmp0(state, "playing") == 0) {
+                                       telephony_info.headset_state = BLUETOOTH_STATE_PLAYING;
+                               } else if (g_strcmp0(state, "disconnected") == 0) {
+                                       /* Headset state: playing -> disconnected */
+                                       if (telephony_info.headset_state == BLUETOOTH_STATE_PLAYING) {
+                                               __bt_telephony_event_cb(
+                                                               BLUETOOTH_EVENT_TELEPHONY_AUDIO_DISCONNECTED,
+                                                               BLUETOOTH_TELEPHONY_ERROR_NONE, NULL);
+                                       }
+
+                                       telephony_info.headset_state = BLUETOOTH_STATE_DISCONNETED;
+                               }
+                       } else if (strcasecmp(property, "Connected") == 0) {
+                               gboolean connected = FALSE;
+                               char *dev_addr = NULL;
+                               connected = g_variant_get_boolean(values);
+                               BT_INFO("connected %d", connected);
+                               if (connected) {
+                                       /*Get device address*/
+                                       if (object_path != NULL)
+                                               dev_addr = strstr(object_path, "dev_");
+
+                                       if (dev_addr != NULL) {
+                                               dev_addr += 4;
+                                               g_strlcpy(telephony_info.address,
+                                                               dev_addr,
+                                                               sizeof(telephony_info.address));
+                                               g_strdelimit(telephony_info.address, "_", ':');
+                                               BT_DBG("address is %s",
+                                                               telephony_info.address);
 
-       if (dbus_message_is_signal(msg, HFP_AGENT_SERVICE,
-                               HFP_REJECT_CALL)) {
-               __bluetooth_telephony_reject_call(msg);
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-       }
+                                               telephony_info.headset_state =
+                                                               BLUETOOTH_STATE_CONNECTED;
 
-       if (dbus_message_is_signal(msg, HFP_AGENT_SERVICE,
-                               HFP_RELEASE_CALL)) {
-               __bluetooth_telephony_release_call(msg);
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-       }
+                                               if (telephony_dbus_info.proxy != NULL) {
+                                                       g_object_unref(telephony_dbus_info.proxy);
+                                                       telephony_dbus_info.proxy = NULL;
+                                               }
 
-       if (dbus_message_is_signal(msg, HFP_AGENT_SERVICE,
-                               HFP_THREEWAY_CALL)) {
-               __bluetooth_telephony_threeway_call(msg);
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-       }
+                                               telephony_dbus_info.proxy =
+                                                               __bluetooth_telephony_get_connected_device_proxy();
 
-       if (!dbus_message_has_interface(msg, BLUEZ_HEADSET_INTERFACE))
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+                                               BT_INFO("Headset Connected");
 
-       if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL)
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+                                               __bt_telephony_event_cb(
+                                                               BLUETOOTH_EVENT_TELEPHONY_HFP_CONNECTED,
+                                                               BLUETOOTH_TELEPHONY_ERROR_NONE, NULL);
+                                       }
+                               } else { /*Device disconnected*/
+                                       memset(telephony_info.address, 0x00,
+                                                       sizeof(telephony_info.address));
+                                       telephony_info.headset_state =
+                                                       BLUETOOTH_STATE_DISCONNETED;
 
-       dbus_message_iter_init(msg, &item_iter);
-       if (dbus_message_iter_get_arg_type(&item_iter) != DBUS_TYPE_STRING) {
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-       }
+                                       if (telephony_dbus_info.proxy != NULL) {
+                                               g_object_unref(telephony_dbus_info.proxy);
+                                               telephony_dbus_info.proxy = NULL;
+                                       }
 
-       dbus_message_iter_get_basic(&item_iter, &property);
+                                       BT_INFO("Headset Disconnected");
 
-       if (property == NULL)
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+                                       __bt_telephony_event_cb(
+                                                       BLUETOOTH_EVENT_TELEPHONY_HFP_DISCONNECTED,
+                                                       BLUETOOTH_TELEPHONY_ERROR_NONE, NULL);
+                               }
+                       } else if (strcasecmp(property, "SpeakerGain") == 0) {
+                               unsigned int spkr_gain;
+                               guint16 gain = g_variant_get_uint16(values);
 
-       BT_DBG("Property (%s)", property);
+                               spkr_gain = (unsigned int)gain;
+                               BT_DBG("spk_gain[%d]", spkr_gain);
 
-       if (g_strcmp0(property, "State") == 0) {
-               char *state = NULL;
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_recurse(&item_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &state);
-               if (NULL == state) {
-                       BT_ERR("State is null");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-               }
-               BT_DBG("State : %s", state);
-
-               if (g_strcmp0(state, "connected") == 0) {
-                       telephony_info.headset_state = BLUETOOTH_STATE_CONNECTED;
-               } else if (g_strcmp0(state, "playing") == 0) {
-                       telephony_info.headset_state = BLUETOOTH_STATE_PLAYING;
-               } else if (g_strcmp0(state, "disconnected") == 0) {
-                       /* Headset state: playing -> disconnected */
-                       if (telephony_info.headset_state == BLUETOOTH_STATE_PLAYING) {
                                __bt_telephony_event_cb(
-                                        BLUETOOTH_EVENT_TELEPHONY_AUDIO_DISCONNECTED,
-                                        BLUETOOTH_TELEPHONY_ERROR_NONE, NULL);
-                       }
-
-                       telephony_info.headset_state = BLUETOOTH_STATE_DISCONNETED;
-               }
-
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-       }
-
-       if (g_strcmp0(property, "Connected") == 0) {
-               gboolean connected = FALSE;
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_recurse(&item_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &connected);
-               BT_DBG("Connected : %d", connected);
-
-               if (connected) {
-                       /*Get device address*/
-                       if (path != NULL)
-                               dev_addr = strstr(path, "dev_");
-
-                       if (dev_addr != NULL) {
-                               dev_addr += 4;
-                               g_strlcpy(telephony_info.address,
-                                       dev_addr,
-                                       sizeof(telephony_info.address));
-                               g_strdelimit(telephony_info.address, "_", ':');
-                               BT_DBG("address is %s",
-                                       telephony_info.address);
+                                               BLUETOOTH_EVENT_TELEPHONY_SET_SPEAKER_GAIN,
+                                               BLUETOOTH_TELEPHONY_ERROR_NONE,
+                                               (void *)&spkr_gain);
+                       } else if (strcasecmp(property, "MicrophoneGain") == 0) {
+                               unsigned int mic_gain;
+                               guint16 gain = g_variant_get_uint16(values);
 
-                               telephony_info.headset_state =
-                                               BLUETOOTH_STATE_CONNECTED;
+                               mic_gain = (unsigned int)gain;
+                               BT_DBG("mic_gain[%d]", mic_gain);
 
-                               if (telephony_dbus_info.proxy != NULL) {
-                                       g_object_unref(telephony_dbus_info.proxy);
-                                       telephony_dbus_info.proxy = NULL;
+                               __bt_telephony_event_cb(
+                                               BLUETOOTH_EVENT_TELEPHONY_SET_MIC_GAIN,
+                                               BLUETOOTH_TELEPHONY_ERROR_NONE,
+                                               (void *)&mic_gain);
+                       } else if (strcasecmp(property, "Playing") == 0) {
+                               gboolean audio_sink_playing;
+
+                               audio_sink_playing = g_variant_get_boolean(values);
+                               if (audio_sink_playing) {
+                                       telephony_info.headset_state = BLUETOOTH_STATE_PLAYING;
+                                       __bt_telephony_event_cb(
+                                                       BLUETOOTH_EVENT_TELEPHONY_AUDIO_CONNECTED,
+                                                       BLUETOOTH_TELEPHONY_ERROR_NONE, NULL);
+                               } else {
+                                       telephony_info.headset_state =
+                                                       BLUETOOTH_STATE_CONNECTED;
+                                       __bt_telephony_event_cb(
+                                                       BLUETOOTH_EVENT_TELEPHONY_AUDIO_DISCONNECTED,
+                                                       BLUETOOTH_TELEPHONY_ERROR_NONE, NULL);
                                }
-
-                               telephony_dbus_info.proxy =
-                                               __bluetooth_telephony_get_connected_device_proxy();
-
-                               BT_INFO("Headset Connected");
-
-                                __bt_telephony_event_cb(
-                                               BLUETOOTH_EVENT_TELEPHONY_HFP_CONNECTED,
-                                               BLUETOOTH_TELEPHONY_ERROR_NONE, NULL);
-                       }
-               } else { /*Device disconnected*/
-                       memset(telephony_info.address, 0x00,
-                                       sizeof(telephony_info.address));
-                       telephony_info.headset_state =
-                                               BLUETOOTH_STATE_DISCONNETED;
-
-                       if (telephony_dbus_info.proxy != NULL) {
-                               g_object_unref(telephony_dbus_info.proxy);
-                               telephony_dbus_info.proxy = NULL;
                        }
 
-                       BT_INFO("Headset Disconnected");
-
-                        __bt_telephony_event_cb(
-                                       BLUETOOTH_EVENT_TELEPHONY_HFP_DISCONNECTED,
-                                       BLUETOOTH_TELEPHONY_ERROR_NONE, NULL);
+                       g_variant_unref(values);
                }
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
        }
+       BT_DBG("-");
+}
 
-       if (g_strcmp0(property, "SpeakerGain") == 0) {
-               unsigned int spkr_gain;
-               guint16 gain;
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_recurse(&item_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &gain);
+static GDBusNodeInfo *__bt_telephony_create_method_node_info
+                                       (const gchar *introspection_data)
+{
+       GError *err = NULL;
+       GDBusNodeInfo *node_info = NULL;
 
-               spkr_gain = (unsigned int)gain;
-               BT_DBG("spk_gain[%d]", spkr_gain);
+       if (introspection_data == NULL)
+               return NULL;
 
-               __bt_telephony_event_cb(
-                                       BLUETOOTH_EVENT_TELEPHONY_SET_SPEAKER_GAIN,
-                                       BLUETOOTH_TELEPHONY_ERROR_NONE,
-                                       (void *)&spkr_gain);
+       node_info = g_dbus_node_info_new_for_xml(introspection_data, &err);
 
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       if (err) {
+               BT_ERR("Unable to create node: %s", err->message);
+               g_clear_error(&err);
        }
+       return node_info;
+}
 
-       if (g_strcmp0(property, "MicrophoneGain") == 0) {
-               unsigned int mic_gain;
-               guint16 gain;
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_recurse(&item_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &gain);
 
-               mic_gain = (unsigned int)gain;
-               BT_DBG("mic_gain[%d]", mic_gain);
+int __bluetooth_telephony_register_object(int reg, GDBusNodeInfo *node_info)
+{
+       static guint bt_tel_id = 0;
+       GError *error =  NULL;
+       gchar *path;
 
-               __bt_telephony_event_cb(
-                                       BLUETOOTH_EVENT_TELEPHONY_SET_MIC_GAIN,
-                                       BLUETOOTH_TELEPHONY_ERROR_NONE,
-                                       (void *)&mic_gain);
+       if (reg == TRUE) {
+               if (node_info == NULL)
+                       return BLUETOOTH_TELEPHONY_ERROR_INVALID_PARAM;
 
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-       }
+               path = g_strdup(telephony_info.call_path);
+               BT_DBG("path is [%s]", path);
 
-       if (g_strcmp0(property, "Playing") == 0) {
-               gboolean audio_sink_playing = FALSE;
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_recurse(&item_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &audio_sink_playing);
+               bt_tel_id = g_dbus_connection_register_object(telephony_dbus_info.conn,
+                               path, node_info->interfaces[0],
+                               &method_table,
+                               NULL, NULL, &error);
 
-               if (audio_sink_playing) {
-                       telephony_info.headset_state = BLUETOOTH_STATE_PLAYING;
-                        __bt_telephony_event_cb(
-                               BLUETOOTH_EVENT_TELEPHONY_AUDIO_CONNECTED,
-                               BLUETOOTH_TELEPHONY_ERROR_NONE, NULL);
-               } else {
-                       telephony_info.headset_state =
-                                               BLUETOOTH_STATE_CONNECTED;
-                       __bt_telephony_event_cb(
-                               BLUETOOTH_EVENT_TELEPHONY_AUDIO_DISCONNECTED,
-                               BLUETOOTH_TELEPHONY_ERROR_NONE, NULL);
+               g_free(path);
+               if (bt_tel_id == 0) {
+                       BT_ERR("Failed to register: %s", error->message);
+                       g_error_free(error);
+                       return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
+               }
+       } else {
+               if (bt_tel_id > 0) {
+                       g_dbus_connection_unregister_object(telephony_dbus_info.conn,
+                                       bt_tel_id);
+                       bt_tel_id = 0;
                }
-
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
        }
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
 
+       return BLUETOOTH_TELEPHONY_ERROR_NONE;
+}
 
 static int __bluetooth_telephony_proxy_init(void)
 {
        FN_START;
+       guint owner_id;
+       GDBusNodeInfo *node_info;
 
-       object = (GObject *)__bluetooth_telephony_method_new();
-
-       if (NULL == object)
-               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
+       owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
+                               TELEPHONY_APP_INTERFACE,
+                               G_BUS_NAME_OWNER_FLAGS_NONE,
+                               NULL, NULL, NULL,
+                               NULL, NULL);
+       BT_DBG("owner_id is [%d]", owner_id);
 
-       BT_DBG("telephony_object = %x", object);
+       node_info = __bt_telephony_create_method_node_info(
+                               bt_telephony_introspection_xml);
 
-       dbus_g_connection_register_g_object(telephony_dbus_info.conn,
-                       telephony_info.call_path, G_OBJECT(object));
+       if (node_info == NULL) {
+               BT_ERR("node_info NULL");
+               return BLUETOOTH_TELEPHONY_ERROR_INVALID_PARAM;
+       }
+       if (__bluetooth_telephony_register_object(TRUE, node_info) !=
+                       BLUETOOTH_TELEPHONY_ERROR_NONE) {
+               BT_ERR("Registation of Method Failed");
+               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
+       }
 
        FN_END;
        return BLUETOOTH_TELEPHONY_ERROR_NONE;
@@ -837,11 +730,7 @@ static void __bluetooth_telephony_proxy_deinit(void)
 {
        FN_START;
 
-       dbus_g_connection_unregister_g_object(telephony_dbus_info.conn,
-                               G_OBJECT(object));
-
-       g_object_unref(object);
-       object = NULL;
+       __bluetooth_telephony_register_object(FALSE, NULL);
 
        FN_END;
        return;
@@ -849,32 +738,35 @@ static void __bluetooth_telephony_proxy_deinit(void)
 
 static int __bluetooth_telephony_register(void)
 {
-       DBusMessage *reply;
-       DBusError err;
+       GVariant *reply;
+       GVariant *param;
+       GError *err = NULL;
        char *path = g_strdup(telephony_info.call_path);
        int ret;
 
        FN_START;
 
+       param = g_variant_new("(ss)", path, src_addr);
+       BT_DBG("Path[%s] Src_Address[%s]", path, src_addr);
+
        reply =  __bluetooth_telephony_dbus_method_send(
                        HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
-                       "RegisterApplication", &err, DBUS_TYPE_STRING, &path,
-                       DBUS_TYPE_STRING, &src_addr,
-                       DBUS_TYPE_INVALID);
+                       "RegisterApplication", &err, param);
 
        g_free(path);
+
        if (!reply) {
                BT_ERR("Error returned in method call");
-               if (dbus_error_is_set(&err)) {
-                       ret = __bt_telephony_get_error(err.message);
+               if (err) {
+                       ret = __bt_telephony_get_error(err->message);
                        BT_ERR("Error here %d\n", ret);
-                       dbus_error_free(&err);
+                       g_error_free(err);
                        return ret;
                }
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
 
-       dbus_message_unref(reply);
+       g_variant_unref(reply);
        BT_DBG("__bluetooth_telephony_register completed");
        FN_END;
        return BLUETOOTH_TELEPHONY_ERROR_NONE;
@@ -882,118 +774,42 @@ static int __bluetooth_telephony_register(void)
 
 static  int __bluetooth_telephony_unregister(void)
 {
-       DBusMessage *reply;
-       DBusError err;
+       GVariant *reply;
+       GVariant *param;
+       GError *err = NULL;
        char *path = g_strdup(telephony_info.call_path);
        int ret;
 
        FN_START;
 
+       param = g_variant_new("(s)", path);
        reply = __bluetooth_telephony_dbus_method_send(
                        HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
-                       "UnregisterApplication", &err, DBUS_TYPE_STRING, &path,
-                       DBUS_TYPE_INVALID);
+                       "UnregisterApplication", &err, param);
 
        g_free(path);
+
        if (!reply) {
                BT_ERR("Error returned in method call");
-               if (dbus_error_is_set(&err)) {
-                       ret = __bt_telephony_get_error(err.message);
-                       dbus_error_free(&err);
+               if (err) {
+                       ret = __bt_telephony_get_error(err->message);
+                       g_error_free(err);
                        return ret;
                }
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
 
-       dbus_message_unref(reply);
+       g_variant_unref(reply);
        BT_DBG("__bluetooth_telephony_unregister completed");
        FN_END;
        return BLUETOOTH_TELEPHONY_ERROR_NONE;
 }
 
-static int __bluetooth_get_default_adapter_path(DBusGConnection *GConn,
-                                                       char *path)
-{
-       DBusMessage *msg;
-       DBusMessage *reply;
-       DBusMessageIter reply_iter;
-       DBusMessageIter value_iter;
-       DBusError err;
-       DBusConnection *conn;
-       char *adapter_path = NULL;
-
-       BT_DBG("+");
-
-       conn = dbus_g_connection_get_connection(telephony_dbus_info.conn);
-
-       retv_if(conn == NULL, NULL);
-
-       msg = dbus_message_new_method_call(BT_BLUEZ_NAME, BT_MANAGER_PATH,
-                       BT_MANAGER_INTERFACE,
-                       "GetManagedObjects");
-
-       retv_if(msg == NULL, NULL);
-       /* Synchronous call */
-       dbus_error_init(&err);
-       reply = dbus_connection_send_with_reply_and_block(
-                               conn, msg, -1, &err);
-       dbus_message_unref(msg);
-
-       if (!reply) {
-               BT_ERR("Can't get managed objects");
-
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("%s", err.message);
-                       dbus_error_free(&err);
-               }
-               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
-       }
-
-       if (dbus_message_iter_init(reply, &reply_iter) == FALSE) {
-        BT_ERR("Fail to iterate the reply");
-        return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_recurse(&reply_iter, &value_iter);
-
-       /* signature of GetManagedObjects:  a{oa{sa{sv}}} */
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                               DBUS_TYPE_DICT_ENTRY) {
-               DBusMessageIter msg_iter;
-
-               dbus_message_iter_recurse(&value_iter, &msg_iter);
-
-               adapter_path = __bt_get_default_adapter_path(&msg_iter);
-               if (adapter_path != NULL) {
-                       BT_DBG("Found the adapter path");
-                       break;
-               }
-               dbus_message_iter_next(&value_iter);
-       }
-
-       if (adapter_path == NULL) {
-               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
-       }
-
-       if (strlen(adapter_path) >= BT_ADAPTER_PATH_LEN) {
-               BT_ERR("Path too long.\n");
-               g_free(adapter_path);
-               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
-       }
-
-       BT_DBG("object path = %s", adapter_path);
-       g_strlcpy(path, adapter_path, BT_ADAPTER_PATH_LEN);
-       g_free(adapter_path);
-       BT_DBG("-");
-       return BLUETOOTH_TELEPHONY_ERROR_NONE;
-}
-
 #ifndef TIZEN_WEARABLE
 static void __bluetooth_telephony_init_headset_state(void)
 {
-       DBusMessage *reply;
-       DBusError err;
-
+       GVariant *reply;
+       GError *err = NULL;
        gboolean status = FALSE;
 
        FN_START;
@@ -1002,30 +818,21 @@ static void __bluetooth_telephony_init_headset_state(void)
                BT_ERR("Bluetooth telephony not initilized");
                return;
        }
+
        reply = __bluetooth_telephony_dbus_method_send(
                        HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
-                       "IsConnected", &err, DBUS_TYPE_INVALID);
-
+                       "IsConnected", &err, NULL);
        if (!reply) {
                BT_ERR("Error returned in method call\n");
-               if (dbus_error_is_set(&err)) {
-                       __bt_telephony_get_error(err.message);
-                       dbus_error_free(&err);
+               if (err) {
+                       __bt_telephony_get_error(err->message);
+                       g_error_free(err);
                }
                return;
        }
 
-       if (!dbus_message_get_args(reply, &err,
-                       DBUS_TYPE_BOOLEAN, &status,
-                       DBUS_TYPE_INVALID)) {
-               BT_ERR("Error to get features");
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("error message: %s", err.message);
-                       dbus_error_free(&err);
-               }
-               dbus_message_unref(reply);
-               return;
-       }
+       g_variant_get(reply, "(b)", &status);
+       g_variant_unref(reply);
 
        BT_INFO("Headset Connected Status = [%d]", status);
        if (status)
@@ -1081,18 +888,14 @@ static gboolean __bluetooth_telephony_is_headset(uint32_t device_class)
        return flag;
 }
 
-static gboolean __bluetooth_telephony_is_headset_by_uuid(GValue *value)
+static gboolean __bluetooth_telephony_is_headset_by_uuid(gchar **uuids)
 {
        int i;
-       char **uuids;
        char **parts;
        unsigned int service = 0;
 
        FN_START;
 
-       retv_if(value == NULL, FALSE);
-
-       uuids = g_value_get_boxed(value);
        retv_if(uuids == NULL, FALSE);
 
        for (i = 0; uuids[i] != NULL; i++) {
@@ -1118,195 +921,236 @@ static gboolean __bluetooth_telephony_is_headset_by_uuid(GValue *value)
 
 static int __bluetooth_telephony_get_connected_device(void)
 {
-       DBusMessage *msg;
-       DBusMessage *reply;
-       DBusMessageIter reply_iter;
-       DBusMessageIter value_iter;
-       DBusError err;
-       DBusConnection *conn;
-       DBusGProxy *headset_agent_proxy = NULL;
-
+       GDBusConnection *conn;
+       GDBusProxy *headset_agent_proxy = NULL;
+       GDBusProxy *manager_proxy = NULL;
+       GDBusProxy *proxy = NULL;
+       GVariant *reply = NULL;
+       GVariant *getall = NULL;
+       GVariant *isPlayingReply = NULL;
+       GVariant *isConnectedReply = NULL;
+       GVariant *param = NULL;
+       GVariant *var_path = NULL;
+       GVariant *path_values = NULL;
+       GVariant *value = NULL;
        GError *error = NULL;
-       uint32_t device_class;
-       gboolean playing = FALSE;
-       gboolean connected = FALSE;
-       GHashTable *list_hash = NULL;
-       GValue *value = {0};
-       char *object_path = NULL;
-       DBusGProxy *proxy = NULL;
-       const gchar *address;
+       GVariantIter iter;
+       GVariantIter iter_path;
+       GVariantIter property_iter;
+       int ret = BLUETOOTH_TELEPHONY_ERROR_NONE;
 
        FN_START;
-       conn = _bt_get_system_conn();
+       conn = _bt_gdbus_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_TELEPHONY_ERROR_INTERNAL);
 
-       msg = dbus_message_new_method_call(BLUEZ_SERVICE_NAME, "/",
-                                               BLUEZ_MANAGER_INTERFACE,
-                                               "GetManagedObjects");
-
-       retv_if(msg == NULL, BLUETOOTH_TELEPHONY_ERROR_INTERNAL);
+       manager_proxy = g_dbus_proxy_new_sync(
+                       conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       BLUEZ_SERVICE_NAME, "/",
+                       BLUEZ_MANAGER_INTERFACE, NULL, &error);
+       if (manager_proxy == NULL) {
+               BT_ERR("Unable to allocate new proxy \n");
+               ret = BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
+               if (error) {
+                       ret = __bt_telephony_get_error(error->message);
+                       BT_ERR("Error here %d\n", ret);
+                       g_error_free(error);
+               }
+               goto done;
+       }
 
        /* Synchronous call */
-       dbus_error_init(&err);
-       reply = dbus_connection_send_with_reply_and_block(
-                                       conn, msg,
-                                       -1, &err);
-       dbus_message_unref(msg);
+       reply = g_dbus_proxy_call_sync(manager_proxy, "GetManagedObjects", NULL,
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+       g_object_unref(manager_proxy);
 
        if (!reply) {
                BT_ERR("Can't get managed objects");
-
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("%s", err.message);
-                       dbus_error_free(&err);
+               ret = BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
+               if (error) {
+                       ret = __bt_telephony_get_error(error->message);
+                       BT_ERR("Error here %d\n", ret);
+                       g_error_free(error);
                }
-               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
-       }
-
-       if (dbus_message_iter_init(reply, &reply_iter) == FALSE) {
-               BT_ERR("Fail to iterate the reply");
-               dbus_message_unref(reply);
-               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
+               goto done;
        }
 
-       dbus_message_iter_recurse(&reply_iter, &value_iter);
-
        /* signature of GetManagedObjects:      a{oa{sa{sv}}} */
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                                               DBUS_TYPE_DICT_ENTRY) {
-               DBusMessageIter msg_iter;
-
-               dbus_message_iter_recurse(&value_iter, &msg_iter);
-
-               /* Parse the signature: oa{sa{sv}}} */
-               retv_if(dbus_message_iter_get_arg_type(&msg_iter) !=
-                               DBUS_TYPE_OBJECT_PATH,
-                               BLUETOOTH_TELEPHONY_ERROR_INTERNAL);
-
-               dbus_message_iter_get_basic(&msg_iter, &object_path);
-
-               if (object_path) {
-                       proxy = dbus_g_proxy_new_for_name(
-                                               telephony_dbus_info.conn,
-                                               BLUEZ_SERVICE_NAME,
-                                               object_path,
-                                               BLUEZ_PROPERTIES_INTERFACE);
-                       if (proxy == NULL)
+       g_variant_iter_init(&iter, reply);
+
+       while ((param = g_variant_iter_next_value(&iter))) {
+               g_variant_iter_init(&iter_path, param);
+
+               while ((var_path = g_variant_iter_next_value(&iter_path))) {
+                       gsize len;
+                       uint32_t device_class = 0;
+                       gboolean playing = FALSE;
+                       gboolean connected = FALSE;
+                       char *object_path = NULL;
+                       gchar *address = NULL;
+                       const gchar *key;
+                       gchar **uuids = NULL;
+                       GVariant *getall_param = NULL;
+
+                       g_variant_get(var_path, "{&o*}", &object_path,
+                                       &path_values);
+                       g_variant_unref(path_values); /* path_values unused*/
+
+                       proxy = g_dbus_proxy_new_sync(telephony_dbus_info.conn,
+                                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                                       BLUEZ_SERVICE_NAME, object_path,
+                                       BLUEZ_PROPERTIES_INTERFACE, NULL, &error);
+                       if (proxy == NULL) {
+                               BT_ERR("Unable to allocate new proxy \n");
+                               ret = BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
+                               if (error) {
+                                       ret = __bt_telephony_get_error(error->message);
+                                       BT_ERR("Error here %d\n", ret);
+                                       g_error_free(error);
+                               }
                                goto done;
+                       }
 
-                       dbus_g_proxy_call(proxy, "GetAll", &error,
-                                               G_TYPE_STRING,
-                                               BLUEZ_DEVICE_INTERFACE,
-                                               G_TYPE_INVALID,
-                                               dbus_g_type_get_map("GHashTable",
-                                                       G_TYPE_STRING,
-                                                       G_TYPE_VALUE),
-                                               &list_hash,
-                                               G_TYPE_INVALID);
-                       if (list_hash == NULL)
-                               goto done;
 
-                       if (error) {
-                               BT_ERR("error in GetBasicProperties [%s]\n", error->message);
-                               g_error_free(error);
+                       getall_param = g_variant_new("s", BLUEZ_DEVICE_INTERFACE);
+                       getall = g_dbus_proxy_call_sync(proxy,
+                                       "GetAll", getall_param,
+                                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+                       g_object_unref(proxy);
+
+                       if (!getall) {
+                               BT_ERR("Can't get managed objects");
+                               ret = BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
+                               if (error) {
+                                       ret = __bt_telephony_get_error(error->message);
+                                       BT_ERR("Error here %d\n", ret);
+                                       g_error_free(error);
+                               }
                                goto done;
                        }
 
-                       value = g_hash_table_lookup(list_hash, "Class");
-                       device_class = value ? g_value_get_uint(value) : 0;
+                       g_variant_iter_init(&property_iter, getall);
+
+                       while (g_variant_iter_loop(&property_iter, "{&sv}", &key, &value)) {
+                               if (!g_strcmp0(key, "Class")) {
+                                       device_class = g_variant_get_uint32(value);
+                                       BT_DBG("Device Class: %d", device_class);
+                               } else if (!g_strcmp0(key, "UUID")) {
+                                       int i = 0;
+                                       uuids = (gchar **)g_variant_get_strv(value, &len);
+                                       BT_DBG_UUID(uuids, len, i);
+                               } else if (!g_strcmp0(key, "Address")) {
+                                       address = (gchar *)g_variant_get_string(
+                                                                       value,
+                                                                       NULL);
+                                       BT_DBG("Device Class: %s", address);
+                               }
+                               g_variant_unref(value);
+                       }
+                       g_variant_unref(getall);
 
                        if (device_class == 0) {
                                BT_DBG("COD is NULL (maybe paired by nfc)...  Checking UUIDs");
-                               value = g_hash_table_lookup(list_hash, "UUIDs");
-                               if (!__bluetooth_telephony_is_headset_by_uuid(value)) {
+                               if (!__bluetooth_telephony_is_headset_by_uuid(uuids)) {
                                        BT_DBG("UUID checking completed. None HF device");
-                                       g_object_unref(proxy);
-                                       proxy = NULL;
-                                       g_hash_table_destroy(list_hash);
-                                       dbus_message_iter_next(&value_iter);
                                        continue;
                                }
                                BT_DBG("UUID checking completed. HF device");
                        } else {
-                               if (!__bluetooth_telephony_is_headset(device_class)) {
-                                       g_object_unref(proxy);
-                                       proxy = NULL;
-                                       g_hash_table_destroy(list_hash);
-                                       dbus_message_iter_next(&value_iter);
+                               if (!__bluetooth_telephony_is_headset(device_class))
                                        continue;
-                               }
                        }
 
                        /* this is headset; Check for Connection */
-                       headset_agent_proxy = dbus_g_proxy_new_for_name(
-                                               telephony_dbus_info.conn,
-                                               HFP_AGENT_SERVICE, object_path,
-                                               HFP_AGENT_INTERFACE);
-
+                       headset_agent_proxy = g_dbus_proxy_new_sync(telephony_dbus_info.conn,
+                                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                                       HFP_AGENT_SERVICE, object_path,
+                                       HFP_AGENT_INTERFACE, NULL, &error);
                        if (headset_agent_proxy == NULL) {
-                               g_hash_table_destroy(list_hash);
+                               BT_ERR("Unable to allocate new headset_agent_proxy");
+                               ret = BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
+                               if (error) {
+                                       ret = __bt_telephony_get_error(error->message);
+                                       BT_ERR("Error here %d\n", ret);
+                                       g_error_free(error);
+                               }
                                goto done;
                        }
 
-                       dbus_g_proxy_call(headset_agent_proxy, "IsConnected",
-                                       &error, G_TYPE_INVALID,
-                                       G_TYPE_BOOLEAN, &connected,
-                                       G_TYPE_INVALID);
+                       isConnectedReply = g_dbus_proxy_call_sync(headset_agent_proxy,
+                                       "IsConnected", NULL,
+                                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+
+                       if (!isConnectedReply) {
+                               BT_ERR("Can't get managed objects");
+                               ret = BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
+                               if (error) {
+                                       ret = __bt_telephony_get_error(error->message);
+                                       BT_ERR("Error here %d\n", ret);
+                                       g_error_free(error);
+                               }
+                               goto done;
+                       } else {
+                               connected = g_variant_get_boolean(isConnectedReply);
+                               g_variant_unref(isConnectedReply);
 
-                       if (error == NULL) {
                                if (connected) {
-                                       value = g_hash_table_lookup(list_hash,
-                                                                       "Address");
-                                       address = value ? g_value_get_string(
-                                                               value) : NULL;
-
                                        g_strlcpy(telephony_info.address,
                                                        address,
                                                        sizeof(telephony_info.address));
-                                       dbus_g_proxy_call(headset_agent_proxy,
-                                                               "IsPlaying",
-                                                               &error,
-                                                               G_TYPE_INVALID,
-                                                               G_TYPE_BOOLEAN,
-                                                               &playing,
-                                                               G_TYPE_INVALID);
-                                       if (playing)
-                                               telephony_info.headset_state =
-                                                       BLUETOOTH_STATE_PLAYING;
-                                       else
-                                               telephony_info.headset_state =
-                                                       BLUETOOTH_STATE_CONNECTED;
 
-                                       g_hash_table_destroy(list_hash);
+                                       isPlayingReply = g_dbus_proxy_call_sync(headset_agent_proxy,
+                                                       "IsPlaying", NULL,
+                                                       G_DBUS_CALL_FLAGS_NONE,
+                                                       -1, NULL, &error);
+                                       if (!isPlayingReply) {
+                                               BT_ERR("Can't get managed objects");
+                                               ret = BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
+                                               if (error) {
+                                                       ret = __bt_telephony_get_error(error->message);
+                                                       BT_ERR("Error here %d\n", ret);
+                                                       g_error_free(error);
+                                               }
+                                       } else {
+                                               playing = g_variant_get_boolean(isPlayingReply);
+                                               g_variant_unref(isPlayingReply);
+
+                                               if (playing)
+                                                       telephony_info.headset_state =
+                                                               BLUETOOTH_STATE_PLAYING;
+                                               else
+                                                       telephony_info.headset_state =
+                                                               BLUETOOTH_STATE_CONNECTED;
+                                       }
+
                                        goto done;
                                }
-                       } else {
-                               g_error_free(error);
                        }
 
-                       g_hash_table_destroy(list_hash);
-                       g_object_unref(proxy);
-                       proxy = NULL;
-               } /* end of if(object_path) */
-
-       dbus_message_iter_next(&value_iter);
-       } /* end of while */
+                       g_object_unref(headset_agent_proxy);
+                       g_variant_unref(var_path);
+               }
+               g_variant_unref(param);
+       }
 
 done:
-       if (proxy)
-               g_object_unref(proxy);
-
-       dbus_message_unref(reply);
-
+       if (headset_agent_proxy)
+               g_object_unref(headset_agent_proxy);
+       if (reply)
+               g_variant_unref(reply);
+       if (var_path)
+               g_variant_unref(var_path);
+       if (param)
+               g_variant_unref(param);
        FN_END;
-       return BLUETOOTH_TELEPHONY_ERROR_NONE;
+       return ret;
 }
 
-static DBusGProxy *__bluetooth_telephony_get_connected_device_proxy(void)
+static GDBusProxy *__bluetooth_telephony_get_connected_device_proxy(void)
 {
-       DBusGProxy *proxy = NULL;
-       char *object_path = NULL;
-
+       GDBusProxy *proxy = NULL;
+       GError *error = NULL;
+       int ret;
        FN_START;
 
        if (strlen(telephony_info.address) == 0)
@@ -1315,38 +1159,152 @@ static DBusGProxy *__bluetooth_telephony_get_connected_device_proxy(void)
        if (strlen(telephony_info.address) == 0)
                return NULL;
 
-       if (telephony_info.obj_path) {
-               g_free(telephony_info.obj_path);
-               telephony_info.obj_path = NULL;
+       proxy = g_dbus_proxy_new_sync(telephony_dbus_info.conn,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       HFP_AGENT_SERVICE, HFP_AGENT_PATH,
+                       HFP_AGENT_INTERFACE, NULL, &error);
+       if (proxy == NULL) {
+               BT_ERR("Unable to allocate new proxy");
+               if (error) {
+                       ret = __bt_telephony_get_error(error->message);
+                       BT_ERR("Error here %d\n", ret);
+                       g_error_free(error);
+               }
+               return NULL;
        }
 
-       object_path = _bt_get_device_object_path(telephony_info.address);
-       g_strlcpy(telephony_info.obj_path, object_path, BT_ADAPTER_PATH_LEN);
-
-       proxy = dbus_g_proxy_new_for_name(telephony_dbus_info.conn,
-                       HFP_AGENT_SERVICE, telephony_info.obj_path,
-                       HFP_AGENT_INTERFACE);
-
        FN_END;
        return proxy;
 }
 
+int __bt_telephony_subscribe_adapter_signal(GDBusConnection *conn,
+               int subscribe)
+{
+       if (conn == NULL)
+               return -1;
+
+       static int subscribe_adapter_id = -1;
+       if (subscribe == TRUE) {
+               if (subscribe_adapter_id == -1) {
+                       subscribe_adapter_id = g_dbus_connection_signal_subscribe(conn,
+                                       NULL, "org.freedesktop.DBus.ObjectManager",
+                                       "InterfacesAdded", NULL, NULL, 0,
+                                       __bt_telephony_adapter_filter,
+                                       NULL, NULL);
+               }
+               return BLUETOOTH_TELEPHONY_ERROR_NONE;
+       } else {
+               if (subscribe_adapter_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subscribe_adapter_id);
+                       subscribe_adapter_id = -1;
+               }
+               return BLUETOOTH_TELEPHONY_ERROR_NONE;
+       }
+}
+
+int __bt_telephony_event_subscribe_signal(GDBusConnection *conn,
+               int subscribe)
+{
+       if (conn == NULL)
+               return -1;
+
+       static int subscribe_event1_id = -1;
+       static int subscribe_event2_id = -1;
+       static int subscribe_event3_id = -1;
+       static int subscribe_event4_id = -1;
+       static int subscribe_event5_id = -1;
+       static int subscribe_event6_id = -1;
+       if (subscribe == TRUE) {
+               if (subscribe_event1_id == -1) {
+                       subscribe_event1_id = g_dbus_connection_signal_subscribe(conn,
+                                       NULL, BLUEZ_HEADSET_INTERFACE,
+                                       "PropertyChanged", NULL, NULL, 0,
+                                       __bluetooth_telephony_event_filter,
+                                       NULL, NULL);
+               }
+               if (subscribe_event2_id == -1) {
+                       subscribe_event2_id = g_dbus_connection_signal_subscribe(conn,
+                                       NULL, HFP_AGENT_SERVICE,
+                                       HFP_NREC_STATUS_CHANGE, NULL, NULL, 0,
+                                       __bluetooth_telephony_event_filter,
+                                       NULL, NULL);
+               }
+
+               if (subscribe_event3_id == -1) {
+                       subscribe_event3_id = g_dbus_connection_signal_subscribe(conn,
+                                       NULL, HFP_AGENT_SERVICE,
+                                       HFP_ANSWER_CALL, NULL, NULL, 0,
+                                       __bluetooth_telephony_event_filter,
+                                       NULL, NULL);
+               }
+               if (subscribe_event4_id == -1) {
+                       subscribe_event4_id = g_dbus_connection_signal_subscribe(conn,
+                                       NULL, HFP_AGENT_SERVICE,
+                                       HFP_REJECT_CALL, NULL, NULL, 0,
+                                       __bluetooth_telephony_event_filter,
+                                       NULL, NULL);
+               }
+               if (subscribe_event5_id == -1) {
+                       subscribe_event5_id = g_dbus_connection_signal_subscribe(conn,
+                                       NULL, HFP_AGENT_SERVICE,
+                                       HFP_RELEASE_CALL, NULL, NULL, 0,
+                                       __bluetooth_telephony_event_filter,
+                                       NULL, NULL);
+               }
+               if (subscribe_event6_id == -1) {
+                       subscribe_event6_id = g_dbus_connection_signal_subscribe(conn,
+                                       NULL, HFP_AGENT_SERVICE,
+                                       HFP_THREEWAY_CALL, NULL, NULL, 0,
+                                       __bluetooth_telephony_event_filter,
+                                       NULL, NULL);
+               }
+
+               return BLUETOOTH_TELEPHONY_ERROR_NONE;
+       } else {
+               if (subscribe_event1_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subscribe_event1_id);
+                       subscribe_event1_id = -1;
+               }
+               if (subscribe_event2_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subscribe_event2_id);
+                       subscribe_event2_id = -1;
+               }
+               if (subscribe_event3_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subscribe_event3_id);
+                       subscribe_event3_id = -1;
+               }
+               if (subscribe_event4_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subscribe_event4_id);
+                       subscribe_event4_id = -1;
+               }
+               if (subscribe_event5_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subscribe_event5_id);
+                       subscribe_event5_id = -1;
+               }
+               if (subscribe_event6_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subscribe_event6_id);
+                       subscribe_event6_id = -1;
+               }
+               return BLUETOOTH_TELEPHONY_ERROR_NONE;
+       }
+}
 
 BT_EXPORT_API int bluetooth_telephony_init(bt_telephony_func_ptr cb,
                                                        void  *user_data)
 {
-       DBusError dbus_error;
-       DBusConnection *conn;
-       int ret = BLUETOOTH_TELEPHONY_ERROR_NONE;
-       GError *error = NULL;
-       char object_path[BT_ADAPTER_PATH_LEN] = {0};
-       DBusConnection *dbus_conn;
        bluetooth_device_address_t loc_address = { {0} };
        char src_address[BT_ADDRESS_STRING_SIZE] = { 0 };
-
+       int ret = BLUETOOTH_TELEPHONY_ERROR_NONE;
+       GError *error = NULL;
 
        FN_START;
-       g_type_init();
 
        if (is_initialized == TRUE) {
                BT_ERR("Bluetooth telephony already initilized");
@@ -1355,14 +1313,10 @@ BT_EXPORT_API int bluetooth_telephony_init(bt_telephony_func_ptr cb,
 
        is_initialized = TRUE;
 
-       telephony_dbus_info.conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+       telephony_dbus_info.conn = _bt_gdbus_init_system_gconn();
        if (!telephony_dbus_info.conn) {
-               if (NULL != error) {
-                       BT_ERR("dbus_g_bus_get() failed:[%d:%s]\n",
-                                       error->code, error->message);
-                       g_error_free(error);
-               }
                is_initialized = FALSE;
+               BT_ERR("Could not get DBus Connection");
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
 
@@ -1374,33 +1328,37 @@ BT_EXPORT_API int bluetooth_telephony_init(bt_telephony_func_ptr cb,
 
        if (__bluetooth_telephony_proxy_init()) {
                BT_ERR("__bluetooth_telephony_proxy_init failed\n");
-               dbus_g_connection_unref(telephony_dbus_info.conn);
                telephony_dbus_info.conn = NULL;
                is_initialized = FALSE;
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
 
-       telephony_dbus_info.manager_proxy = dbus_g_proxy_new_for_name(
-                                               telephony_dbus_info.conn,
-                                               BLUEZ_SERVICE_NAME,
-                                               "/", BLUEZ_MANAGER_INTERFACE);
-
+       telephony_dbus_info.manager_proxy = g_dbus_proxy_new_sync(
+                       telephony_dbus_info.conn,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       BLUEZ_SERVICE_NAME, "/",
+                       BLUEZ_MANAGER_INTERFACE, NULL, &error);
        if (telephony_dbus_info.manager_proxy == NULL) {
-               BT_ERR("Could not create a manager proxy\n");
+               BT_ERR("Could not create a manager proxy");
                __bluetooth_telephony_proxy_deinit();
-               dbus_g_connection_unref(telephony_dbus_info.conn);
                telephony_dbus_info.conn = NULL;
                is_initialized = FALSE;
+               if (error) {
+                       ret = __bt_telephony_get_error(error->message);
+                       BT_ERR("Error here %d\n", ret);
+                       g_error_free(error);
+                       return ret;
+               }
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
 
-       telephony_dbus_info.dbus_proxy = dbus_g_proxy_new_for_name(
-                       telephony_dbus_info.conn, DBUS_SERVICE_DBUS,
-                       DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
-
+       telephony_dbus_info.dbus_proxy = g_dbus_proxy_new_sync(
+                       telephony_dbus_info.conn,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
+                       DBUS_INTERFACE_DBUS, NULL, &error);
        if (NULL == telephony_dbus_info.dbus_proxy) {
                __bluetooth_telephony_proxy_deinit();
-               dbus_g_connection_unref(telephony_dbus_info.conn);
                telephony_dbus_info.conn = NULL;
                g_object_unref(telephony_dbus_info.manager_proxy);
                telephony_dbus_info.manager_proxy = NULL;
@@ -1408,24 +1366,8 @@ BT_EXPORT_API int bluetooth_telephony_init(bt_telephony_func_ptr cb,
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
 
-       dbus_conn = dbus_g_connection_get_connection(telephony_dbus_info.conn);
-
-       /*Add Signal callback for BT enabled*/
-       if (!dbus_connection_add_filter(dbus_conn,
-                               __bt_telephony_adapter_filter,
-                               NULL, NULL)) {
-               BT_ERR("Fail to add filter");
-               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
-       }
-
-       dbus_error_init(&dbus_error);
-       dbus_bus_add_match(dbus_conn,
-                       "type='signal',interface='org.freedesktop.DBus.ObjectManager'"
-                       ",member='InterfacesAdded'",
-                       &dbus_error);
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add match: %s\n", dbus_error.message);
-               dbus_error_free(&dbus_error);
+       if (__bt_telephony_subscribe_adapter_signal(telephony_dbus_info.conn, TRUE) != 0) {
+               BT_ERR("Fail to Subscribe Adapter Signal");
                goto fail;
        }
 
@@ -1434,72 +1376,8 @@ BT_EXPORT_API int bluetooth_telephony_init(bt_telephony_func_ptr cb,
        telephony_info.user_data = user_data;
        telephony_info.headset_state = BLUETOOTH_STATE_DISCONNETED;
 
-       dbus_error_init(&dbus_error);
-       conn = dbus_g_connection_get_connection(telephony_dbus_info.conn);
-       dbus_connection_add_filter(conn, __bluetooth_telephony_event_filter,
-                               NULL, NULL);
-       dbus_bus_add_match(conn,
-                       "type='signal',interface='"BLUEZ_HEADSET_INTERFACE
-                       "',member='PropertyChanged'", &dbus_error);
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add dbus filter signal\n");
-               dbus_error_free(&dbus_error);
-               goto fail;
-       }
-
-       dbus_error_init(&dbus_error);
-       dbus_bus_add_match(conn,
-                       "type='signal',interface='"HFP_AGENT_SERVICE
-                       "',member='"HFP_NREC_STATUS_CHANGE"'" , &dbus_error);
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add dbus filter signal\n");
-               dbus_error_free(&dbus_error);
-               goto fail;
-       }
-
-       dbus_error_init(&dbus_error);
-       dbus_bus_add_match(conn,
-                       "type='signal',interface='"HFP_AGENT_SERVICE
-                       "',member='"HFP_ANSWER_CALL"'" , &dbus_error);
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add dbus filter signal\n");
-               dbus_error_free(&dbus_error);
-               goto fail;
-       }
-
-       /*Check for BT status*/
-       ret = __bluetooth_get_default_adapter_path(telephony_dbus_info.conn,
-                                                               object_path);
-       if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE)
-               return BLUETOOTH_TELEPHONY_ERROR_NONE;
-
-       dbus_error_init(&dbus_error);
-       dbus_bus_add_match(conn,
-                       "type='signal',interface='"HFP_AGENT_SERVICE
-                       "',member='"HFP_REJECT_CALL"'" , &dbus_error);
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add dbus filter signal\n");
-               dbus_error_free(&dbus_error);
-               goto fail;
-       }
-
-       dbus_error_init(&dbus_error);
-       dbus_bus_add_match(conn,
-                       "type='signal',interface='"HFP_AGENT_SERVICE
-                       "',member='"HFP_RELEASE_CALL"'" , &dbus_error);
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add dbus filter signal\n");
-               dbus_error_free(&dbus_error);
-               goto fail;
-       }
-
-       dbus_error_init(&dbus_error);
-       dbus_bus_add_match(conn,
-                       "type='signal',interface='"HFP_AGENT_SERVICE
-                       "',member='"HFP_THREEWAY_CALL"'" , &dbus_error);
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add dbus filter signal\n");
-               dbus_error_free(&dbus_error);
+       if (__bt_telephony_event_subscribe_signal(telephony_dbus_info.conn, TRUE) != 0) {
+               BT_ERR("Fail to Subscribe telephony event Signal");
                goto fail;
        }
 
@@ -1537,75 +1415,13 @@ fail:
 
 BT_EXPORT_API int bluetooth_telephony_deinit(void)
 {
-       DBusConnection *conn;
-       DBusError error;
-
        FN_START;
        BT_TELEPHONY_CHECK_INITIALIZED();
 
        is_initialized = FALSE;
 
-       conn = dbus_g_connection_get_connection(telephony_dbus_info.conn);
-
-       dbus_error_init(&error);
-       dbus_bus_remove_match(conn,
-                       "type='signal',interface='"BLUEZ_HEADSET_INTERFACE
-                       "',member='PropertyChanged'", &error);
-       if (dbus_error_is_set(&error)) {
-               BT_ERR("Fail to remove dbus filter signal\n");
-               dbus_error_free(&error);
-               /* Need to re initilize before use */
-               dbus_error_init(&error);
-       }
-
-       dbus_error_init(&error);
-       dbus_bus_remove_match(conn,
-                       "type='signal',interface='"HFP_AGENT_SERVICE
-                       "',member='"HFP_NREC_STATUS_CHANGE"'", &error);
-       if (dbus_error_is_set(&error)) {
-               BT_ERR("Fail to remove dbus filter signal\n");
-               dbus_error_free(&error);
-       }
-
-       dbus_error_init(&error);
-       dbus_bus_remove_match(conn,
-                       "type='signal',interface='"HFP_AGENT_SERVICE
-                       "',member='"HFP_ANSWER_CALL"'", &error);
-       if (dbus_error_is_set(&error)) {
-               BT_ERR("Fail to remove dbus filter signal\n");
-               dbus_error_free(&error);
-       }
-
-       dbus_error_init(&error);
-       dbus_bus_remove_match(conn,
-                       "type='signal',interface='"HFP_AGENT_SERVICE
-                       "',member='"HFP_REJECT_CALL"'", &error);
-       if (dbus_error_is_set(&error)) {
-               BT_ERR("Fail to remove dbus filter signal\n");
-               dbus_error_free(&error);
-       }
-
-       dbus_error_init(&error);
-       dbus_bus_remove_match(conn,
-                       "type='signal',interface='"HFP_AGENT_SERVICE
-                       "',member='"HFP_RELEASE_CALL"'", &error);
-       if (dbus_error_is_set(&error)) {
-               BT_ERR("Fail to remove dbus filter signal\n");
-               dbus_error_free(&error);
-       }
-
-       dbus_error_init(&error);
-       dbus_bus_remove_match(conn,
-                       "type='signal',interface='"HFP_AGENT_SERVICE
-                       "',member='"HFP_THREEWAY_CALL"'", &error);
-       if (dbus_error_is_set(&error)) {
-               BT_ERR("Fail to remove dbus filter signal\n");
-               dbus_error_free(&error);
-       }
-
-       dbus_connection_remove_filter(conn,
-                               __bluetooth_telephony_event_filter,
-                               NULL);
+       if (__bt_telephony_event_subscribe_signal(telephony_dbus_info.conn, FALSE) != 0)
+               BT_ERR("Fail to UnSubscribe telephony event Signal");
 
        if (bluetooth_check_adapter() != BLUETOOTH_ADAPTER_DISABLED ||
                bluetooth_check_adapter_le() != BLUETOOTH_ADAPTER_LE_DISABLED)
@@ -1619,20 +1435,9 @@ BT_EXPORT_API int bluetooth_telephony_deinit(void)
        telephony_info.headset_state = BLUETOOTH_STATE_DISCONNETED;
 
        /* Remove BT enabled signal */
-       dbus_error_init(&error);
-       dbus_bus_remove_match(conn,
-                       "type='signal',interface='org.freedesktop.DBus.ObjectManager'"
-                       ",member='InterfacesAdded'",
-                       &error);
-       if (dbus_error_is_set(&error)) {
-               BT_ERR("Fail to remove dbus filter signal\n");
-               dbus_error_free(&error);
-       }
-
-       dbus_connection_remove_filter(dbus_g_connection_get_connection(
-                               telephony_dbus_info.conn),
-                               __bt_telephony_adapter_filter,
-                               NULL);
+       if (__bt_telephony_subscribe_adapter_signal(telephony_dbus_info.conn, FALSE) != 0)
+               BT_ERR("Fail to UnSubscribe Adapter event Signal");
+
        g_free(src_addr);
        src_addr = NULL;
 
@@ -1642,7 +1447,6 @@ BT_EXPORT_API int bluetooth_telephony_deinit(void)
        }
 
        if (telephony_dbus_info.conn != NULL) {
-               dbus_g_connection_unref(telephony_dbus_info.conn);
                telephony_dbus_info.conn = NULL;
        }
 
@@ -1657,9 +1461,8 @@ BT_EXPORT_API int bluetooth_telephony_deinit(void)
 
 BT_EXPORT_API gboolean bluetooth_telephony_is_sco_connected(void)
 {
-       DBusMessage *reply;
-       DBusError err;
-
+       GVariant *reply;
+       GError *err = NULL;
        gboolean status = FALSE;
 
        FN_START;
@@ -1669,28 +1472,18 @@ BT_EXPORT_API gboolean bluetooth_telephony_is_sco_connected(void)
 
        reply = __bluetooth_telephony_dbus_method_send(
                        HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
-                       "IsPlaying", &err, DBUS_TYPE_INVALID);
+                       "IsPlaying", &err, NULL);
 
        if (!reply) {
                BT_ERR("Error returned in method call\n");
-               if (dbus_error_is_set(&err)) {
-                       __bt_telephony_get_error(err.message);
-                       dbus_error_free(&err);
-               }
-               return FALSE;
-       }
-
-       if (!dbus_message_get_args(reply, &err,
-                       DBUS_TYPE_BOOLEAN, &status,
-                       DBUS_TYPE_INVALID)) {
-               BT_ERR("Error to get features");
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("error message: %s", err.message);
-                       dbus_error_free(&err);
+               if (err) {
+                       __bt_telephony_get_error(err->message);
+                       g_error_free(err);
                }
-               dbus_message_unref(reply);
                return FALSE;
        }
+       g_variant_get(reply, "(b)", &status);
+       g_variant_unref(reply);
 
 #ifdef TIZEN_WEARABLE
        if (status == TRUE && telephony_info.headset_state != BLUETOOTH_STATE_PLAYING)
@@ -1703,11 +1496,10 @@ BT_EXPORT_API gboolean bluetooth_telephony_is_sco_connected(void)
 
 BT_EXPORT_API int bluetooth_telephony_is_nrec_enabled(gboolean *status)
 {
-       DBusMessage *reply;
-       DBusError err;
-       DBusMessageIter reply_iter;
-       DBusMessageIter reply_iter_entry;
-       const char *property;
+       GVariant *reply;
+       GError *err = NULL;
+       GVariantIter iter;
+       GVariant *param_inner;
 
        FN_START;
 
@@ -1722,61 +1514,47 @@ BT_EXPORT_API int bluetooth_telephony_is_nrec_enabled(gboolean *status)
 
        reply = __bluetooth_telephony_dbus_method_send(
                        HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
-                       "GetProperties", &err, DBUS_TYPE_INVALID);
+                       "GetProperties", &err, NULL);
 
        if (!reply) {
                BT_ERR("Error returned in method call\n");
-               if (dbus_error_is_set(&err)) {
-                       BT_DBG("Error message = %s", err.message);
-                       dbus_error_free(&err);
+               if (err) {
+                       BT_DBG("Error message = %s", err->message);
+                       g_error_free(err);
                }
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
 
-       dbus_message_iter_init(reply, &reply_iter);
-
-       if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_ARRAY) {
-               BT_ERR("Can't get reply arguments - DBUS_TYPE_ARRAY");
-               dbus_message_unref(reply);
-               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_recurse(&reply_iter, &reply_iter_entry);
-
-       /*Parse the dict */
-       while (dbus_message_iter_get_arg_type(&reply_iter_entry) ==
-                                               DBUS_TYPE_DICT_ENTRY) {
-
-               DBusMessageIter dict_entry, dict_entry_val;
-               dbus_message_iter_recurse(&reply_iter_entry, &dict_entry);
-               dbus_message_iter_get_basic(&dict_entry, &property);
-               BT_DBG("String received = %s", property);
+       g_variant_iter_init(&iter, reply);
+       while ((param_inner = g_variant_iter_next_value(&iter))) {
+               GVariant *value;
 
-               if (g_strcmp0("nrec", property) == 0) {
-                       dbus_message_iter_next(&dict_entry);
-                       dbus_message_iter_recurse(&dict_entry, &dict_entry_val);
-                       if (dbus_message_iter_get_arg_type(&dict_entry_val) !=
-                                               DBUS_TYPE_BOOLEAN)
-                               continue;
-
-                       dbus_message_iter_get_basic(&dict_entry_val, status);
+               value = g_variant_lookup_value(param_inner,
+                                       "nrec", G_VARIANT_TYPE_BOOLEAN);
+               if (value) {
+                       BT_DBG("Property NREC Found");
+                       *status = g_variant_get_boolean(value);
                        BT_DBG("NREC status = [%d]", *status);
+                       g_variant_unref(value);
+                       g_variant_unref(param_inner);
+                       break;
                }
-               dbus_message_iter_next(&reply_iter_entry);
+               g_variant_unref(param_inner);
        }
-       dbus_message_unref(reply);
+       BT_DBG("NREC status = [%d]", *status);
+       g_variant_unref(reply);
+
        FN_END;
        return BLUETOOTH_TELEPHONY_ERROR_NONE;
 }
 
 BT_EXPORT_API int bluetooth_telephony_is_wbs_mode(gboolean *status)
 {
-       DBusMessage *reply;
-       DBusError err;
-       DBusMessageIter reply_iter;
-       DBusMessageIter reply_iter_entry;
+       GVariant *reply;
+       GError *err = NULL;
        unsigned int codec;
-       const char *property;
+       GVariantIter iter;
+       GVariant *param_inner;
 
        FN_START;
 
@@ -1790,50 +1568,41 @@ BT_EXPORT_API int bluetooth_telephony_is_wbs_mode(gboolean *status)
 
        reply = __bluetooth_telephony_dbus_method_send(
                        HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
-                       "GetProperties", &err, DBUS_TYPE_INVALID);
+                       "GetProperties", &err, NULL);
 
        if (!reply) {
                BT_ERR("Error returned in method call");
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("Error message = %s", err.message);
-                       dbus_error_free(&err);
+               if (err) {
+                       BT_ERR("Error message = %s", err->message);
+                       g_error_free(err);
                }
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
 
-       dbus_message_iter_init(reply, &reply_iter);
-
-       if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_ARRAY) {
-               BT_ERR("Can't get reply arguments - DBUS_TYPE_ARRAY");
-               dbus_message_unref(reply);
-               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_recurse(&reply_iter, &reply_iter_entry);
-
-       /*Parse the dict */
-       while (dbus_message_iter_get_arg_type(&reply_iter_entry) ==
-                                               DBUS_TYPE_DICT_ENTRY) {
+       g_variant_iter_init(&iter, reply);
+       while ((param_inner = g_variant_iter_next_value(&iter))) {
+               GVariant *value;
 
-               DBusMessageIter dict_entry, dict_entry_val;
-               dbus_message_iter_recurse(&reply_iter_entry, &dict_entry);
-               dbus_message_iter_get_basic(&dict_entry, &property);
-               BT_DBG("String received = %s", property);
-
-               if (g_strcmp0("codec", property) == 0) {
-                       dbus_message_iter_next(&dict_entry);
-                       dbus_message_iter_recurse(&dict_entry, &dict_entry_val);
-                       if (dbus_message_iter_get_arg_type(&dict_entry_val) !=
-                                               DBUS_TYPE_UINT32)
-                               continue;
-
-                       dbus_message_iter_get_basic(&dict_entry_val, &codec);
+               value = g_variant_lookup_value(param_inner,
+                                       "codec", G_VARIANT_TYPE_UINT32);
+               if (value) {
+                       BT_DBG("Property CODEC Found");
+                       codec = g_variant_get_uint32(value);
+                       g_variant_unref(value);
                        BT_DBG("Codec = [%d]", codec);
+
                        *status = codec == BT_MSBC_CODEC_ID ? TRUE : FALSE;
+                       BT_DBG("NREC status = [%d]", *status);
+                       g_variant_unref(value);
+                       g_variant_unref(param_inner);
+                       break;
                }
-               dbus_message_iter_next(&reply_iter_entry);
+               g_variant_unref(param_inner);
        }
-       dbus_message_unref(reply);
+
+       g_variant_unref(reply);
+       BT_DBG("MSBC status = [%d]", *status);
+
        FN_END;
        return BLUETOOTH_TELEPHONY_ERROR_NONE;
 }
@@ -1841,7 +1610,7 @@ BT_EXPORT_API int bluetooth_telephony_is_wbs_mode(gboolean *status)
 BT_EXPORT_API int bluetooth_telephony_send_vendor_cmd(const char *cmd)
 {
        GError *error = NULL;
-       int ret;
+       GVariant *reply, *parameters;
 
        FN_START;
 
@@ -1857,25 +1626,22 @@ BT_EXPORT_API int bluetooth_telephony_send_vendor_cmd(const char *cmd)
        if (telephony_dbus_info.proxy == NULL)
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
 
-       if (!dbus_g_proxy_call(telephony_dbus_info.proxy, "SendVendorAtCmd",
-                       &error,
-                       G_TYPE_STRING, cmd,
-                       G_TYPE_INVALID, G_TYPE_INVALID)) {
-               if (error != NULL) {
-                       ret = __bt_telephony_get_error(error->message);
-                       g_error_free(error);
-                       return ret;
-               }
+       parameters = g_variant_new("s", cmd);
+       reply = g_dbus_proxy_call_sync(telephony_dbus_info.proxy,
+                       "SendVendorAtCmd", parameters,
+                               G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+       g_variant_unref(reply);
 
-       }
        FN_END;
        return BLUETOOTH_TELEPHONY_ERROR_NONE;
 }
 
 BT_EXPORT_API int bluetooth_telephony_start_voice_recognition(void)
 {
-       DBusMessage *reply;
-       DBusError err;
+       GVariant *reply;
+       GVariant *param;
+       GError *err = NULL;
        int ret;
        gboolean state = TRUE;
 
@@ -1884,31 +1650,31 @@ BT_EXPORT_API int bluetooth_telephony_start_voice_recognition(void)
        BT_TELEPHONY_CHECK_INITIALIZED();
        BT_TELEPHONY_CHECK_ENABLED();
 
+       param = g_variant_new("(b)", &state);
        reply = __bluetooth_telephony_dbus_method_send(
                        HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
-                       "SetVoiceDial", &err, DBUS_TYPE_BOOLEAN, &state,
-                       DBUS_TYPE_INVALID);
+                       "SetVoiceDial", &err, param);
 
        if (!reply) {
                BT_ERR("Error returned in method call\n");
-               if (dbus_error_is_set(&err)) {
-                       ret = __bt_telephony_get_error(err.message);
-                       dbus_error_free(&err);
+               if (err) {
+                       ret = __bt_telephony_get_error(err->message);
+                       g_error_free(err);
                        return ret;
                }
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
 
-       dbus_message_unref(reply);
-
+       g_variant_unref(reply);
        FN_END;
        return BLUETOOTH_TELEPHONY_ERROR_NONE;
 }
 
 BT_EXPORT_API int bluetooth_telephony_stop_voice_recognition(void)
 {
-       DBusMessage *reply;
-       DBusError err;
+       GVariant *reply;
+       GVariant *param;
+       GError *err = NULL;
        int ret;
        gboolean state = FALSE;
 
@@ -1917,55 +1683,55 @@ BT_EXPORT_API int bluetooth_telephony_stop_voice_recognition(void)
        BT_TELEPHONY_CHECK_INITIALIZED();
        BT_TELEPHONY_CHECK_ENABLED();
 
+       param = g_variant_new("(b)", &state);
        reply = __bluetooth_telephony_dbus_method_send(
                        HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
-                       "SetVoiceDial", &err, DBUS_TYPE_BOOLEAN, &state,
-                       DBUS_TYPE_INVALID);
+                       "SetVoiceDial", &err, param);
 
        if (!reply) {
                BT_ERR("Error returned in method call\n");
-               if (dbus_error_is_set(&err)) {
-                       ret = __bt_telephony_get_error(err.message);
-                       dbus_error_free(&err);
+               if (err) {
+                       ret = __bt_telephony_get_error(err->message);
+                       g_error_free(err);
                        return ret;
                }
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
 
-       dbus_message_unref(reply);
+       g_variant_unref(reply);
 
        FN_END;
        return BLUETOOTH_TELEPHONY_ERROR_NONE;
 }
 
-static void __bluetooth_telephony_sco_start_cb(
-                       DBusPendingCall *call, gpointer user_data)
+static void __bluetooth_telephony_sco_start_cb(GDBusProxy *proxy,
+               GAsyncResult *res, gpointer user_data)
 {
-       DBusMessage *reply;
-       DBusError derr;
-       DBusMessage *msg = user_data;
-
-       reply = dbus_pending_call_steal_reply(call);
-       dbus_error_init(&derr);
+       GError *error = NULL;
+       GVariant *value;
 
-       if (dbus_set_error_from_message(&derr, reply)) {
-               BT_ERR("hs_sco_cb error: %s, %s",
-                       derr.name, derr.message);
-               dbus_error_free(&derr);
-               goto done;
+       value = g_dbus_proxy_call_finish(proxy, res, &error);
+       if (value == NULL) {
+               if (error != NULL) {
+                       BT_ERR("sco_close_cb error. errCode[%x],message[%s]",
+                                       error->code, error->message);
+                       g_clear_error(&error);
+               } else {
+                       BT_ERR("SCo Start Failed");
+               }
        }
-       dbus_pending_call_unref(call);
-done:
+
        BT_DBG("sco_start_cb : -");
-       dbus_message_unref(msg);
-       dbus_message_unref(reply);
+       g_object_unref(proxy);
+       g_variant_unref(value);
 }
 
 BT_EXPORT_API int bluetooth_telephony_audio_open(void)
 {
-       DBusConnection *conn;
-       DBusMessage *msg;
-       DBusPendingCall *c;
+       GDBusConnection *conn;
+       GDBusProxy *proxy;
+       GError *err = NULL;
+       int ret;
 
        FN_START;
 
@@ -1979,7 +1745,7 @@ BT_EXPORT_API int bluetooth_telephony_audio_open(void)
                return BLUETOOTH_TELEPHONY_ERROR_PERMISSION_DENIED;
        }
 
-       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+       conn = _bt_gdbus_get_system_gconn();
        if (!conn) {
                BT_DBG("No System Bus found\n");
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
@@ -1988,53 +1754,54 @@ BT_EXPORT_API int bluetooth_telephony_audio_open(void)
        if (telephony_info.headset_state == BLUETOOTH_STATE_PLAYING)
                return BLUETOOTH_TELEPHONY_ERROR_ALREADY_CONNECTED;
 
-       msg = dbus_message_new_method_call(HFP_AGENT_SERVICE,
-                       HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
-                       "Play");
-       if (msg == NULL) {
-               BT_ERR("dbus method call failed");
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       HFP_AGENT_SERVICE, HFP_AGENT_PATH,
+                       HFP_AGENT_INTERFACE, NULL, &err);
+       if (proxy == NULL) {
+               BT_ERR("Unable to allocate new proxy");
+               if (err) {
+                       ret = __bt_telephony_get_error(err->message);
+                       BT_ERR("Error here %d\n", ret);
+                       g_error_free(err);
+                       return ret;
+               }
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
 
-       if (dbus_connection_send_with_reply(conn, msg, &c, -1) == FALSE) {
-               BT_DBG("HFP_AGENT: send with reply failed");
-               dbus_message_unref(msg);
-               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
-       }
-       dbus_pending_call_set_notify(c, __bluetooth_telephony_sco_start_cb,
-                               msg, NULL);
+       g_dbus_proxy_call(proxy, "Play", NULL, G_DBUS_CALL_FLAGS_NONE,
+                       -1, NULL, (GAsyncReadyCallback)__bluetooth_telephony_sco_start_cb, NULL);
 
        FN_END;
        return BLUETOOTH_TELEPHONY_ERROR_NONE;
 }
 
-static void __bluetooth_telephony_sco_close_cb(DBusPendingCall *call, gpointer user_data)
+static void __bluetooth_telephony_sco_close_cb(GDBusProxy *proxy,
+               GAsyncResult *res, gpointer user_data)
 {
-       DBusMessage *reply;
-       DBusError derr;
-       DBusMessage *msg = user_data;
-
-       reply = dbus_pending_call_steal_reply(call);
-       dbus_error_init(&derr);
+       GError *error = NULL;
+       GVariant *value;
 
-       if (dbus_set_error_from_message(&derr, reply)) {
-               BT_ERR("sco_close_cb error: %s, %s",
-                       derr.name, derr.message);
-               dbus_error_free(&derr);
-               goto done;
+       value = g_dbus_proxy_call_finish(proxy, res, &error);
+       if (value == NULL) {
+               if (error != NULL) {
+                       BT_ERR("sco_close_cb error. errCode[%x],message[%s]",
+                                       error->code, error->message);
+                       g_clear_error(&error);
+               } else {
+                       BT_ERR("SCo close Failed");
+               }
        }
 
-       dbus_pending_call_unref(call);
-done:
        BT_DBG("sco_close_cb : -");
-       dbus_message_unref(msg);
-       dbus_message_unref(reply);
+       g_object_unref(proxy);
+       g_variant_unref(value);
 }
 BT_EXPORT_API int bluetooth_telephony_audio_close(void)
 {
-       DBusConnection *conn;
-       DBusMessage *msg;
-       DBusPendingCall *c;
+       GDBusConnection *conn;
+       GDBusProxy *proxy;
+       GError *err = NULL;
+       int ret;
 
        FN_START;
 
@@ -2048,7 +1815,7 @@ BT_EXPORT_API int bluetooth_telephony_audio_close(void)
                return BLUETOOTH_TELEPHONY_ERROR_PERMISSION_DENIED;
        }
 
-       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+       conn = _bt_gdbus_get_system_gconn();
        if (!conn) {
                BT_DBG("No System Bus found\n");
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
@@ -2057,23 +1824,24 @@ BT_EXPORT_API int bluetooth_telephony_audio_close(void)
        if (telephony_info.headset_state != BLUETOOTH_STATE_PLAYING)
                return BLUETOOTH_TELEPHONY_ERROR_NOT_CONNECTED;
 
-       msg = dbus_message_new_method_call(HFP_AGENT_SERVICE,
-                               HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
-                               "Stop");
-       if (msg == NULL) {
-               BT_ERR("dbus method call failed");
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       HFP_AGENT_SERVICE, HFP_AGENT_PATH,
+                       HFP_AGENT_INTERFACE, NULL, &err);
+       if (proxy == NULL) {
+               BT_ERR("Unable to allocate new proxy");
+               if (err) {
+                       ret = __bt_telephony_get_error(err->message);
+                       BT_ERR("Error here %d\n", ret);
+                       g_error_free(err);
+                       return ret;
+               }
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
 
-       if (dbus_connection_send_with_reply(conn, msg, &c, -1) == FALSE) {
-               BT_DBG("HFP_AGENT: send with reply failed");
-               dbus_message_unref(msg);
-               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
-       }
-       telephony_info.headset_state = BLUETOOTH_STATE_CONNECTED;
+       g_dbus_proxy_call(proxy, "Stop", NULL, G_DBUS_CALL_FLAGS_NONE,
+                       -1, NULL, (GAsyncReadyCallback)__bluetooth_telephony_sco_close_cb, NULL);
 
-       dbus_pending_call_set_notify(c, __bluetooth_telephony_sco_close_cb,
-                                                               msg, NULL);
+       telephony_info.headset_state = BLUETOOTH_STATE_CONNECTED;
 
        FN_END;
        return BLUETOOTH_TELEPHONY_ERROR_NONE;
@@ -2122,7 +1890,7 @@ BT_EXPORT_API int bluetooth_telephony_call_answered(unsigned int call_id,
                if (!bluetooth_telephony_is_sco_connected()) {
                        ret = bluetooth_telephony_audio_open();
                        if (ret != 0) {
-                               BT_ERR("Audio connection call Failed = %d", ret);
+                               BT_ERR("Audio connection call Failed[%d]", ret);
                                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
                        }
                }
@@ -2240,7 +2008,7 @@ BT_EXPORT_API int bluetooth_telephony_call_swapped(void *call_list,
                                        call_status->call_status);
 
                if (NULL != call_status->phone_number)
-                       DBG_SECURE(" call number [%s]", call_status->phone_number);
+                       DBG_SECURE("Number [%s]", call_status->phone_number);
 
                switch (call_status->call_status) {
                case BLUETOOTH_CALL_STATE_HELD:
@@ -2266,8 +2034,10 @@ BT_EXPORT_API int bluetooth_telephony_call_swapped(void *call_list,
                break;
 
                default:
-                       if ((call_status->call_status < BLUETOOTH_CALL_STATE_NONE) ||
-                               (call_status->call_status >= BLUETOOTH_CALL_STATE_ERROR)) {
+                       if ((call_status->call_status <
+                                       BLUETOOTH_CALL_STATE_NONE) ||
+                               (call_status->call_status >=
+                                       BLUETOOTH_CALL_STATE_ERROR)) {
                                BT_ERR("Unknown Call state");
                                return BLUETOOTH_TELEPHONY_ERROR_NOT_AVAILABLE;
                        }
@@ -2302,8 +2072,9 @@ BT_EXPORT_API int bluetooth_telephony_indicate_outgoing_call(
                        const char *ph_number, unsigned int call_id,
                        unsigned int bt_audio)
 {
-       DBusMessage *reply;
-       DBusError err;
+       GVariant *reply;
+       GVariant *param;
+       GError *err = NULL;
        const char *path = telephony_info.call_path;
        int ret;
 
@@ -2315,23 +2086,22 @@ BT_EXPORT_API int bluetooth_telephony_indicate_outgoing_call(
        if (NULL == ph_number)
                return BLUETOOTH_TELEPHONY_ERROR_INVALID_PARAM;
 
+       param = g_variant_new("(ssi)", path, ph_number, call_id);
        reply = __bluetooth_telephony_dbus_method_send(
                        HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
-                       "OutgoingCall", &err, DBUS_TYPE_STRING, &path,
-                       DBUS_TYPE_STRING, &ph_number, DBUS_TYPE_INT32,
-                       &call_id, DBUS_TYPE_INVALID);
+                       "OutgoingCall", &err, param);
 
        if (!reply) {
                BT_ERR("Error returned in method call\n");
-               if (dbus_error_is_set(&err)) {
-                       ret = __bt_telephony_get_error(err.message);
-                       dbus_error_free(&err);
+               if (err) {
+                       ret = __bt_telephony_get_error(err->message);
+                       g_error_free(err);
                        return ret;
                }
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
 
-       dbus_message_unref(reply);
+       g_variant_unref(reply);
 
        telephony_info.call_count++;
        BT_DBG(" ag_info.ag_call_count = [%d]", telephony_info.call_count);
@@ -2353,8 +2123,9 @@ BT_EXPORT_API int bluetooth_telephony_indicate_outgoing_call(
 BT_EXPORT_API int bluetooth_telephony_indicate_incoming_call(
                const char *ph_number, unsigned int call_id)
 {
-       DBusMessage *reply;
-       DBusError err;
+       GVariant *reply;
+       GVariant *param;
+       GError *err = NULL;
        const char *path = telephony_info.call_path;
        int ret;
 
@@ -2366,24 +2137,22 @@ BT_EXPORT_API int bluetooth_telephony_indicate_incoming_call(
        if (NULL == ph_number)
                return BLUETOOTH_TELEPHONY_ERROR_INVALID_PARAM;
 
+       param = g_variant_new("(ssi)", path, ph_number, call_id);
        reply = __bluetooth_telephony_dbus_method_send(
                        HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
-                       "IncomingCall", &err, DBUS_TYPE_STRING, &path,
-                       DBUS_TYPE_STRING, &ph_number, DBUS_TYPE_INT32,
-                       &call_id, DBUS_TYPE_INVALID);
+                       "IncomingCall", &err, param);
 
        if (!reply) {
                BT_ERR("Error returned in method call\n");
-               if (dbus_error_is_set(&err)) {
-                       ret = __bt_telephony_get_error(err.message);
-                       dbus_error_free(&err);
+               if (err) {
+                       ret = __bt_telephony_get_error(err->message);
+                       g_error_free(err);
                        return ret;
                }
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
 
-       dbus_message_unref(reply);
-
+       g_variant_unref(reply);
        telephony_info.call_count++;
        BT_DBG("telephony_info.call_count = [%d]", telephony_info.call_count);
        FN_END;
@@ -2393,8 +2162,9 @@ BT_EXPORT_API int bluetooth_telephony_indicate_incoming_call(
 BT_EXPORT_API int bluetooth_telephony_set_speaker_gain(
                                                unsigned short speaker_gain)
 {
-       DBusMessage *reply;
-       DBusError err;
+       GVariant *reply;
+       GVariant *param;
+       GError *err = NULL;
        int ret;
 
        FN_START;
@@ -2404,32 +2174,31 @@ BT_EXPORT_API int bluetooth_telephony_set_speaker_gain(
 
        BT_DBG("set speaker_gain= [%d]", speaker_gain);
 
+       param = g_variant_new("(q)", speaker_gain);
        reply = __bluetooth_telephony_dbus_method_send(
                        HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
-                       "SetSpeakerGain", &err, DBUS_TYPE_UINT16,
-                       &speaker_gain, DBUS_TYPE_INVALID);
+                       "SetSpeakerGain", &err, param);
 
        if (!reply) {
                BT_ERR("Error returned in method call\n");
-               if (dbus_error_is_set(&err)) {
-                       ret = __bt_telephony_get_error(err.message);
-                       dbus_error_free(&err);
+               if (err) {
+                       ret = __bt_telephony_get_error(err->message);
+                       g_error_free(err);
                        return ret;
                }
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
 
-       dbus_message_unref(reply);
+       g_variant_unref(reply);
        FN_END;
-
        return BLUETOOTH_TELEPHONY_ERROR_NONE;
 }
 
 BT_EXPORT_API int bluetooth_telephony_get_headset_volume(
                                                unsigned int *speaker_gain)
 {
-       DBusMessage *reply;
-       DBusError err;
+       GVariant *reply;
+       GError *err = NULL;
        int ret;
        guint16 gain;
 
@@ -2440,246 +2209,146 @@ BT_EXPORT_API int bluetooth_telephony_get_headset_volume(
 
        reply = __bluetooth_telephony_dbus_method_send(
                        HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
-                       "GetSpeakerGain", &err, DBUS_TYPE_INVALID);
+                       "GetSpeakerGain", &err, NULL);
 
        if (!reply) {
                BT_ERR("Error returned in method call\n");
-               if (dbus_error_is_set(&err)) {
-                       ret = __bt_telephony_get_error(err.message);
-                       dbus_error_free(&err);
+               if (err) {
+                       ret = __bt_telephony_get_error(err->message);
+                       g_error_free(err);
                        return ret;
                }
                return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
        }
-
-       if (!dbus_message_get_args(reply, &err,
-                       DBUS_TYPE_UINT16, &gain,
-                       DBUS_TYPE_INVALID)) {
-               BT_ERR("Error to get features");
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("error message: %s", err.message);
-                       dbus_error_free(&err);
-               }
-               dbus_message_unref(reply);
-               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
-       }
+       g_variant_get(reply, "(q)", &gain);
        *speaker_gain = gain;
        BT_DBG("Get speaker_gain= [%d]", *speaker_gain);
 
-       dbus_message_unref(reply);
+       g_variant_unref(reply);
+
        FN_END;
        return BLUETOOTH_TELEPHONY_ERROR_NONE;
 }
 
-static DBusHandlerResult __bt_telephony_adapter_filter(DBusConnection *conn,
-                                               DBusMessage *msg, void *data)
+BT_EXPORT_API int bluetooth_telephony_is_connected(gboolean *ag_connected)
 {
+       GVariant *reply;
+       GError *err = NULL;
        int ret;
-       char *object_path = NULL;
-       const char *member = dbus_message_get_member(msg);
-       FN_START;
-
-       if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL)
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
-       if (member == NULL)
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
-       if (strcasecmp(member, "InterfacesAdded") == 0) {
-               if (__bt_telephony_get_object_path(msg, &object_path)) {
-                       BT_ERR("Fail to get the path");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-               }
+       gboolean ag_connected_from_bt_agent;
 
-               if (strcasecmp(object_path, DEFAULT_ADAPTER_OBJECT_PATH) == 0) {
+       BT_CHECK_ENABLED(return);
 
-                       BT_DBG("Adapter added [%s]", object_path);
-                       BT_DBG("BlueZ is Activated and flag need to be reset");
-                       BT_DBG("Send enabled to application");
-
-                       if (__bt_telephony_get_src_addr(msg)) {
-                               BT_ERR("Fail to get the local adapter address");
-                               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-                       }
+       reply = __bluetooth_telephony_dbus_method_send(
+                       HFP_AGENT_PATH, HFP_AGENT_INTERFACE,
+                       "IsConnected", &err, NULL);
 
-                       ret = __bluetooth_telephony_register();
-                       if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE)
-                               BT_ERR("__bluetooth_telephony_register failed");
+       if (!reply) {
+               BT_ERR("Error returned in method call\n");
+               if (err) {
+                       ret = __bt_telephony_get_error(err->message);
+                       g_error_free(err);
+                       return ret;
                }
+               return BLUETOOTH_ERROR_INTERNAL;
        }
+       g_variant_get(reply, "(b)", &ag_connected_from_bt_agent);
+       *ag_connected = ag_connected_from_bt_agent;
 
-       FN_END;
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-static int __bt_telephony_get_object_path(DBusMessage *msg, char **path)
-{
-       DBusMessageIter item_iter;
-       dbus_message_iter_init(msg, &item_iter);
-       FN_START;
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_OBJECT_PATH) {
-               BT_ERR("This is bad format dbus");
-               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, path);
+       BT_DBG("Conn Status: %s", *ag_connected ? "Connected" : "Disconnected");
 
-       if (*path == NULL)
-               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
+       g_variant_unref(reply);
 
-       FN_END;
-       return BLUETOOTH_TELEPHONY_ERROR_NONE;
+       return BLUETOOTH_ERROR_NONE;
 }
 
-
-static int __bt_telephony_get_src_addr(DBusMessage *msg)
+static void __bt_telephony_adapter_filter(GDBusConnection *connection,
+                                       const gchar *sender_name,
+                                       const gchar *object_path,
+                                       const gchar *interface_name,
+                                       const gchar *signal_name,
+                                       GVariant *parameters,
+                                       gpointer user_data)
 {
-       char *object_path;
-       const char *property = NULL;
-       char *interface_name;
-       DBusMessageIter item_iter;
-       DBusMessageIter value_iter;
-       DBusMessageIter msg_iter, dict_iter;
-       DBusMessageIter in_iter, in2_iter;
-       char *bd_addr;
        FN_START;
+       int ret;
+       char *path = NULL;
 
-       dbus_message_iter_init(msg, &item_iter);
-
-       /* signature of InterfacesAdded signal is oa{sa{sv}} */
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                               != DBUS_TYPE_OBJECT_PATH) {
-               BT_ERR("This is bad format dbus");
-               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, &object_path);
-       retv_if(object_path == NULL,
-                               BLUETOOTH_TELEPHONY_ERROR_INTERNAL);
-
-       if (strcasecmp(object_path, DEFAULT_ADAPTER_OBJECT_PATH) == 0) {
-               /* get address from here */
-               retv_if(dbus_message_iter_next(&item_iter) == FALSE,
-                               BLUETOOTH_TELEPHONY_ERROR_INTERNAL);
-
-               /* signature a{sa{sv}} */
-               retv_if(dbus_message_iter_get_arg_type(&item_iter) !=
-                               DBUS_TYPE_ARRAY,
-                               BLUETOOTH_TELEPHONY_ERROR_INTERNAL);
-               dbus_message_iter_recurse(&item_iter, &value_iter);
-               while (dbus_message_iter_get_arg_type(&value_iter) ==
-                                       DBUS_TYPE_DICT_ENTRY) {
-                       dbus_message_iter_recurse(&value_iter, &msg_iter);
-                       if (dbus_message_iter_get_arg_type(&msg_iter)
-                                       != DBUS_TYPE_STRING) {
-                               BT_ERR("This is bad format dbus");
-                               return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
-                       }
-
-                       dbus_message_iter_get_basic(&msg_iter, &interface_name);
-                       retv_if(interface_name == NULL,
-                               BLUETOOTH_TELEPHONY_ERROR_INTERNAL);
-
-                       BT_DBG("interface name is %s", interface_name);
-
-                       if (strcasecmp(interface_name, BLUEZ_ADAPTER_INTERFACE) == 0) {
-                               retv_if(!dbus_message_iter_next(&msg_iter),
-                                       BLUETOOTH_TELEPHONY_ERROR_INTERNAL);
-                               dbus_message_iter_recurse(&msg_iter, &in_iter);
+       if (strcasecmp(signal_name, "InterfacesAdded") == 0) {
+               GVariant *optional_param = NULL;
 
-                               if (dbus_message_iter_get_arg_type(&in_iter)
-                                               != DBUS_TYPE_DICT_ENTRY) {
-                                       BT_ERR("This is bad format dbus");
-                                       return BLUETOOTH_TELEPHONY_ERROR_INTERNAL;
-                               }
+               g_variant_get(parameters, "(&o@a{sa{sv}})",
+                                                       &path, &optional_param);
 
-                               dbus_message_iter_recurse(&in_iter, &dict_iter);
-                               dbus_message_iter_get_basic(
-                                                       &dict_iter, &property);
+               if (!path) {
+                       BT_ERR("Invalid adapter path");
+                       return;
+               }
 
-                               retv_if(property == NULL,
-                               BLUETOOTH_TELEPHONY_ERROR_INTERNAL);
-                               retv_if(!dbus_message_iter_next(&dict_iter),
-                                       BLUETOOTH_TELEPHONY_ERROR_INTERNAL);
+               BT_INFO("Adapter Path = [%s]", path);
+               if (strcasecmp(path, DEFAULT_ADAPTER_OBJECT_PATH) == 0) {
+                       if (__bt_telephony_get_src_addr(optional_param))
+                               BT_ERR("Fail to get the local adapter address");
 
-                               if (strcasecmp(property, "Address") == 0) {
-                                       dbus_message_iter_recurse
-                                               (&dict_iter, &in2_iter);
-                                       dbus_message_iter_get_basic
-                                               (&in2_iter, &bd_addr);
-                                       src_addr = g_strdup(bd_addr);
-                                       break;
-                               }
-                       }
-                       dbus_message_iter_next(&value_iter);
+                       ret = __bluetooth_telephony_register();
+                       if (ret != BLUETOOTH_TELEPHONY_ERROR_NONE)
+                               BT_ERR("__bluetooth_telephony_register failed");
                }
        }
-       BT_DBG("default adapter address is src_addr = %s", src_addr);
-       FN_END;
-       return BLUETOOTH_TELEPHONY_ERROR_NONE;
-}
-
-static char *__bt_extract_device_path(DBusMessageIter *msg_iter, char *address)
-{
-       char *object_path = NULL;
-       char device_address[BT_ADDRESS_STRING_SIZE] = { 0 };
-       BT_DBG("+");
-
-       /* Parse the signature: oa{sa{sv}}} */
-       retv_if(dbus_message_iter_get_arg_type(msg_iter) !=
-                               DBUS_TYPE_OBJECT_PATH, NULL);
-
-       dbus_message_iter_get_basic(msg_iter, &object_path);
-       retv_if(object_path == NULL, NULL);
-
-       _bt_convert_device_path_to_address(object_path, device_address);
 
-       if (g_strcmp0(address, device_address) == 0) {
-               return g_strdup(object_path);
-       }
-       BT_DBG("-");
-       return NULL;
+       FN_END;
 }
 
-static char *__bt_get_default_adapter_path(DBusMessageIter *msg_iter)
+static int __bt_telephony_get_src_addr(GVariant *value)
 {
-       char *object_path = NULL;
-       DBusMessageIter value_iter;
-       BT_DBG("+");
-
-       /* Parse the signature:  oa{sa{sv}}} */
-       retv_if(dbus_message_iter_get_arg_type(msg_iter) !=
-                       DBUS_TYPE_OBJECT_PATH, NULL);
-
-       dbus_message_iter_get_basic(msg_iter, &object_path);
-
-       retv_if(dbus_message_iter_next(msg_iter) == FALSE, NULL);
-       retv_if(dbus_message_iter_get_arg_type(msg_iter) !=
-                       DBUS_TYPE_ARRAY, NULL);
-
-       dbus_message_iter_recurse(msg_iter, &value_iter);
-
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                 DBUS_TYPE_DICT_ENTRY) {
-               char *interface_name = NULL;
-               DBusMessageIter interface_iter;
-
-               dbus_message_iter_recurse(&value_iter, &interface_iter);
-
-               retv_if(dbus_message_iter_get_arg_type(&interface_iter) !=
-                               DBUS_TYPE_STRING, NULL);
+       GVariantIter iter;
+       GVariant *param = NULL;
+       FN_START;
 
-               dbus_message_iter_get_basic(&interface_iter, &interface_name);
+       /* signature a{sa{sv}} */
+       g_variant_iter_init(&iter, value);
+       while ((param = g_variant_iter_next_value(&iter))) {
+               char *interface_name;
+               GVariant *interface_var = NULL;
+               GVariant *param_inner = NULL;
+
+               g_variant_get(param, "{&s*}", &interface_name, &interface_var);
+               g_variant_unref(param);
+
+               BT_DBG("interface_name: %s", interface_name);
+               /* format of interface_var: a{sv}*/
+               if (strcasecmp(interface_name, BLUEZ_ADAPTER_INTERFACE) == 0) {
+                       GVariantIter iter_inner;
+
+                       g_variant_iter_init(&iter_inner, interface_var);
+                       while ((param_inner = g_variant_iter_next_value(&iter_inner))) {
+                               char *property_name;
+                               GVariant *property_var;
+
+                               g_variant_get(param_inner, "{&sv}",
+                                               &property_name,
+                                               &property_var);
+                               g_variant_unref(param_inner);
+
+                               if (strcasecmp(property_name, "Address") == 0) {
+                                       const gchar *bd_addr;
+
+                                       bd_addr = g_variant_get_string(
+                                                               property_var,
+                                                               NULL);
+                                       src_addr = g_strdup(bd_addr);
+                                       BT_DBG("Address: %s", src_addr);
 
-               if (g_strcmp0(interface_name, "org.bluez.Adapter1") == 0) {
-                       return g_strdup(object_path);
+                                       g_variant_unref(interface_var);
+                                       g_variant_unref(property_var);
+                                       goto done;
+                               }
+                               g_variant_unref(property_var);
+                       }
                }
-       dbus_message_iter_next(&value_iter);
+               g_variant_unref(interface_var);
        }
-       BT_DBG("Adapter Not Found");
-       BT_DBG("-");
-       return NULL;
-}
 
+done:
+       return BLUETOOTH_ERROR_NONE;
+}
diff --git a/bt-api/bt-telephony.xml b/bt-api/bt-telephony.xml
deleted file mode 100644 (file)
index 54f394e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<node>
-  <interface name="org.tizen.csd.Call.Instance">
-    <method name="SendDtmf">
-      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
-      <arg type="s" name="dtmf"/>
-    </method>
-    <method name="VendorCmd">
-      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
-      <arg type="s" name="vendor"/>
-    </method>
-
-  </interface>
-  </node>
index 20f0e33..828bebe 100644 (file)
@@ -60,6 +60,12 @@ extern "C" {
 #define BT_ERR(fmt, args...) \
         SLOGE(fmt, ##args)
 
+#define BT_DBG_UUID(uuids, len, i) \
+       BT_DBG("***UUIDs***"); \
+       for (i = 0; i < len; i++) { \
+               BT_DBG("%s", uuids[i]); \
+       }
+
 #define BT_INFO_C(fmt, arg...) \
        SLOGI_IF(TRUE,  LOG_COLOR_GREEN" "fmt" "LOG_COLOR_RESET, ##arg)
 #define BT_ERR_C(fmt, arg...) \
@@ -143,7 +149,7 @@ extern "C" {
        do { \
                if (arg == NULL) \
                { \
-                       BT_ERR("INVALID PARAMETER"); \
+                       BT_ERR("%s is NULL", #arg); \
                        func BLUETOOTH_ERROR_INVALID_PARAM; \
                } \
        } while (0)
@@ -186,6 +192,7 @@ extern "C" {
 #define BT_EVENT_FREEDESKTOP "org.freedesktop.DBus"
 #define BT_FREEDESKTOP_PATH "/org/freedesktop/DBus"
 
+#define BT_EVENT_MANAGER "org.bluez.Manager"
 #define BT_MANAGER_PATH "/"
 
 
@@ -193,7 +200,6 @@ extern "C" {
 #define BT_ADAPTER_INTERFACE "org.bluez.Adapter1"
 #define BT_DEVICE_INTERFACE "org.bluez.Device1"
 #define BT_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
-#define BT_BLUEZ_HCI_PATH "/org/bluez/hci0"
 
 
 #define BT_SERIAL_INTERFACE "org.bluez.Serial"
@@ -260,6 +266,9 @@ void _bt_input_event_cb(int event, int result, void *param,
 void _bt_headset_event_cb(int event, int result, void *param,
                                        void *callback, void *user_data);
 
+void _bt_a2dp_source_event_cb(int event, int result, void *param,
+                                       void *callback, void *user_data);
+
 void _bt_hf_event_cb(int event, int result, void *param,
                                        void *callback, void *user_data);
 
@@ -304,18 +313,24 @@ int _bt_cancel_discovers(char *address);
 int _bt_discover_services(char *address, char *uuid, void *cb,
                gpointer func_data);
 int _bt_discover_service_uuids(char *address, char *remote_uuid);
+int _bt_get_cod_by_address(char *address, bluetooth_device_class_t *dev_class);
+
+void _bt_set_le_scan_status(gboolean mode);
 
 int _bt_register_profile(bt_register_profile_info_t *info, gboolean use_default_rfcomm);
 int _bt_register_profile_platform(bt_register_profile_info_t *info, gboolean use_default_rfcomm);
+int _bt_register_profile_ex(bt_register_profile_info_t *info, gboolean use_default_rfcomm, const char *name, const char *path);
 
 void _bt_unregister_profile(char *path);
 GDBusNodeInfo * _bt_get_gdbus_node(const gchar *xml_data);
+GDBusNodeInfo * _bt_get_gdbus_node_ex(const gchar *xml_data, const char *bus_name);
 int __rfcomm_assign_id(void);
 void __rfcomm_delete_id(int id);
 void _bt_unregister_gdbus(int object_id);
 typedef int (*bt_new_connection_cb) (const char *path, int fd,
                                        bluetooth_device_address_t *address);
 int _bt_register_new_conn(const char *path, bt_new_connection_cb cb);
+int _bt_register_new_conn_ex(const char *path, const char *bus_name,bt_new_connection_cb cb);
 void _bt_swap_addr(unsigned char *dst, const unsigned char *src);
 
 DBusGProxy *_bt_get_adapter_proxy(DBusGConnection *conn);
@@ -330,9 +345,17 @@ DBusConnection *_bt_get_system_conn(void);
 
 GDBusConnection *_bt_init_system_gdbus_conn(void);
 
+char *_bt_get_cookie(void);
+
+int _bt_get_cookie_size(void);
+
 int _bt_register_osp_server_in_agent(int type, char *uuid, char *path, int fd);
 int _bt_unregister_osp_server_in_agent(int type, char *uuid);
 
+void _bt_generate_cookie(void);
+
+void _bt_destroy_cookie(void);
+
 int _bt_check_privilege(int service_type, int service_function);
 
 GDBusConnection *_bt_gdbus_init_system_gconn(void);
diff --git a/bt-api/include/bt-mdm.h b/bt-api/include/bt-mdm.h
deleted file mode 100644 (file)
index 4b01f3a..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
- *              Girishashok Joshi <girish.joshi@samsung.com>
- *              Chanyeol Park <chanyeol.park@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *             http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-#ifndef _BT_MDM_H_
-#define _BT_MDM_H_
-
-#include <sys/types.h>
-#include <glib.h>
-#include <mdm.h>
-#include "bluetooth-api.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum {
-       BT_MDM_NO_SERVICE,
-       BT_MDM_ALLOWED,
-       BT_MDM_RESTRICTED
-} bt_mdm_status_e;
-
-int _bt_launch_mdm_popup(char *mode);
-
-bt_mdm_status_e _bt_check_mdm_handsfree_only(void);
-
-#ifdef MDM_PHASE_2
-
-bt_mdm_status_e _bt_check_mdm_pairing_restriction(void);
-
-bt_mdm_status_e _bt_check_mdm_transfer_restriction(void);
-
-bt_mdm_status_e _bt_check_mdm_hsp_restriction(void);
-
-bt_mdm_status_e _bt_check_mdm_a2dp_restriction(void);
-
-bt_mdm_status_e _bt_check_mdm_avrcp_restriction(void);
-
-bt_mdm_status_e _bt_check_mdm_spp_restriction(void);
-
-bt_mdm_status_e _bt_check_mdm_blacklist_devices(const bluetooth_device_address_t *address);
-
-bt_mdm_status_e _bt_check_mdm_blacklist_uuid(char *uuid);
-#endif
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /*_BT_SERVICE_MDM_H_*/
-
index b1e9153..e886b86 100644 (file)
@@ -22,15 +22,15 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dbus-glib-1 dlog vconf gio-2.0 gio-unix-2.0)
+pkg_check_modules(pkgs REQUIRED dbus-glib-1 dlog vconf gio-2.0 gio-unix-2.0 eventsystem)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-SET(CMAKE_C_FLAGS_RELEASE "-O2")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -fPIE")
+SET(CMAKE_C_FLAGS_RELEASE "-O2 -fPIE")
 
 FIND_PROGRAM(UNAME NAMES uname)
 EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
@@ -39,17 +39,13 @@ IF("${ARCH}" STREQUAL "arm")
        MESSAGE("add -DTARGET")
 ENDIF("${ARCH}" STREQUAL "arm")
 
-FIND_PROGRAM(DBUS_BINDING_TOOL NAMES dbus-binding-tool)
-EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=bt ${CMAKE_CURRENT_SOURCE_DIR}/bt-request-service.xml --mode=glib-client --output=${CMAKE_CURRENT_SOURCE_DIR}/include/bt-request-service.h")
-EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=bt_core ${CMAKE_CURRENT_SOURCE_DIR}/bt-core-adapter.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/include/bt-core-adapter-method.h")
-
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DVENDOR=\"${APP_VENDOR}\"")
 ADD_DEFINITIONS("-DAPPNAME=\"${APP_NAME}\"")
 ADD_DEFINITIONS("-DAPP_DIR=\"${APP_DIR}\"")
 ADD_DEFINITIONS("-DAPP_SYSCONFDIR=\"${APP_SYSCONFDIR}\"")
 
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
 
 ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
@@ -60,4 +56,3 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.projectx.bt_core.service DESTINATION share/dbus-1/system-services)
 
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-core.conf DESTINATION /etc/dbus-1/system.d)
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/bt-core/bluetooth-frwk-core.conf b/bt-core/bluetooth-frwk-core.conf
deleted file mode 100755 (executable)
index 815a54a..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-<busconfig>
-    <policy user="root">
-        <allow own="org.projectx.bt_core"/>
-    </policy>
-    <policy at_console="true">
-        <allow send_destination="org.projectx.bt_core" />
-    </policy>
-    <policy context="default">
-        <allow send_destination="org.projectx.bt_core" />
-    </policy>
-</busconfig>
-
index 364036f..aebf6df 100644 (file)
@@ -23,6 +23,8 @@
 
 #include <vconf.h>
 #include <vconf-keys.h>
+#include <bundle.h>
+#include <eventsystem.h>
 
 #include "bt-core-main.h"
 #include "bt-core-adapter.h"
@@ -35,9 +37,7 @@ static bt_le_status_t adapter_le_status = BT_LE_DEACTIVATED;
 static gboolean is_recovery_mode = FALSE;
 
 static int bt_status_before[BT_MODE_MAX] = { VCONFKEY_BT_STATUS_OFF, };
-static int bt_le_status_before[BT_MODE_MAX] = { 0, };
-
-static DBusGConnection *conn = NULL;
+static int bt_le_status_before[BT_MODE_MAX] = { VCONFKEY_BT_LE_STATUS_OFF, };
 
 static void __bt_core_set_status(bt_status_t status)
 {
@@ -86,7 +86,7 @@ gboolean _bt_core_is_recovery_mode(void)
 
 gboolean _bt_core_is_flight_mode_enabled(void)
 {
-#ifdef TIZEN_TELEPHONY_ENABLED
+#ifdef TIZEN_BT_FLIGHTMODE_ENABLED
        int isFlightMode = 0;
        int ret = -1;
 
@@ -100,70 +100,6 @@ gboolean _bt_core_is_flight_mode_enabled(void)
 #endif
 }
 
-static gboolean bt_core_enable_adapter(BtCore *agent,
-                                               DBusGMethodInvocation *context);
-
-static gboolean bt_core_disable_adapter(BtCore *agent,
-                                               DBusGMethodInvocation *context);
-
-static gboolean bt_core_recover_adapter(BtCore *agent,
-                                               DBusGMethodInvocation *context);
-
-static gboolean bt_core_enable_adapter_le(BtCore *agent,
-                                               DBusGMethodInvocation *context);
-
-static gboolean bt_core_disable_adapter_le(BtCore *agent,
-                                               DBusGMethodInvocation *context);
-
-static gboolean bt_core_reset_adapter(BtCore *agent,
-                                               DBusGMethodInvocation *context);
-
-static gboolean bt_core_enable_core(BtCore *agent,
-                                               DBusGMethodInvocation *context);
-
-static int __execute_command(const char *cmd, char *const arg_list[]);
-
-#include "bt-core-adapter-method.h"
-
-
-G_DEFINE_TYPE(BtCore, bt_core, G_TYPE_OBJECT);
-
-/*This is part of platform provided code skeleton for client server model*/
-static void bt_core_class_init (BtCoreClass *bt_core_class)
-{
-       dbus_g_object_type_install_info(G_TYPE_FROM_CLASS(bt_core_class),
-                                       &dbus_glib_bt_core_object_info);
-}
-
-/*This is part of platform provided code skeleton for client server model*/
-static void bt_core_init (BtCore *core)
-{
-}
-
-typedef enum {
-       BT_CORE_ERROR_REJECT,
-       BT_CORE_ERROR_CANCEL,
-       BT_CORE_ERROR_TIMEOUT,
-} BtCoreError;
-
-#define BT_CORE_ERROR (bt_core_error_quark())
-
-static GQuark bt_core_error_quark(void)
-{
-       static GQuark quark = 0;
-       if (!quark)
-               quark = g_quark_from_static_string("BtCore");
-
-       return quark;
-}
-
-#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
-
-static GError *bt_core_error(BtCoreError error, const char *err_msg)
-{
-       return g_error_new(BT_CORE_ERROR, error, err_msg, NULL);
-}
-
 static int __execute_command(const char *cmd, char *const arg_list[])
 {
        int pid;
@@ -198,58 +134,29 @@ static int __execute_command(const char *cmd, char *const arg_list[])
        return 0;
 }
 
-static DBusGProxy *_bt_get_connman_proxy(void)
-{
-       DBusGProxy *proxy;
-
-       if (conn == NULL) {
-               conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
-               retv_if(conn == NULL, NULL);
-       }
-
-       proxy = dbus_g_proxy_new_for_name(conn,
-                       CONNMAN_DBUS_NAME,
-                       CONNMAN_BLUETOOTH_TECHNOLOGY_PATH,
-                       CONNMAN_BLUETOTOH_TECHNOLOGY_INTERFACE);
-       retv_if(proxy == NULL, NULL);
-
-       return proxy;
-}
-
-static int _bt_power_adapter(gboolean powered)
+int _bt_enable_adapter(void)
 {
-       GValue state = { 0 };
-       GError *error = NULL;
-       DBusGProxy *proxy;
-
-       proxy = _bt_get_connman_proxy();
-       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       g_value_init(&state, G_TYPE_BOOLEAN);
-       g_value_set_boolean(&state, powered);
+       int ret;
+       bt_status_t status;
+       bt_le_status_t le_status;
 
-       BT_DBG("set power property state: %d to connman", powered);
+       BT_INFO("");
 
-       dbus_g_proxy_call(proxy, "SetProperty", &error,
-                               G_TYPE_STRING, "Powered",
-                               G_TYPE_VALUE, &state,
-                               G_TYPE_INVALID, G_TYPE_INVALID);
+       status = _bt_core_get_status();
+       if (status != BT_DEACTIVATED) {
+               BT_ERR("Invalid state %d", status);
+               return -1;
+       }
 
-       if (error != NULL) {
-               BT_ERR("Powered set err: \n [%s]", error->message);
-               g_error_free(error);
-               g_value_unset(&state);
-               return BLUETOOTH_ERROR_INTERNAL;
+       le_status = _bt_core_get_le_status();
+       if (le_status == BT_LE_ACTIVATED) {
+               /* Turn on PSCAN, (ISCAN if needed) */
+               /* Return with 0 for the Enabled response. */
+               __bt_core_set_status(BT_ACTIVATED);
+               BT_INFO("BR/EDR is enabled.");
+               return 0;
        }
-       return BLUETOOTH_ERROR_NONE;
-}
 
-int _bt_enable_adapter(void)
-{
-       int ret;
-       bt_status_t status;
-       bt_le_status_t le_status;
-#ifdef __TIZEN_MOBILE__
        __bt_core_set_status(BT_ACTIVATING);
 
        ret = __execute_command("/usr/etc/bluetooth/bt-stack-up.sh", NULL);
@@ -259,42 +166,65 @@ int _bt_enable_adapter(void)
                __bt_core_set_status(BT_DEACTIVATED);
                return -1;
        }
-#else
-       _bt_power_adapter(TRUE);
-#endif
 
        return 0;
 }
 
 int _bt_disable_adapter(void)
 {
+       bt_status_t status;
+       bt_le_status_t le_status;
+
        BT_INFO_C("Disable adapter");
-#ifdef __TIZEN_MOBILE__
+
+       le_status = _bt_core_get_le_status();
+       BT_DBG("le_status : %d", le_status);
+       if (le_status == BT_LE_ACTIVATED) {
+               /* Turn off PSCAN, (ISCAN if needed) */
+               /* Return with 0 for the Disabled response. */
+               __bt_core_set_status(BT_DEACTIVATED);
+               BT_INFO("BR/EDR is disabled. now LE only mode");
+               return 0;
+       }
+
+       status = _bt_core_get_status();
+       if (status == BT_ACTIVATING) {
+               /* Forcely terminate */
+               if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0) {
+                       BT_ERR("running script failed");
+               }
+               _bt_core_terminate();
+               return 0;
+       } else if (status != BT_ACTIVATED) {
+               BT_ERR("Invalid state %d", status);
+       }
+
        __bt_core_set_status(BT_DEACTIVATING);
 
        if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0) {
                BT_ERR("running script failed");
-               __bt_core_set_status(BT_ACTIVATED);
+               __bt_core_set_status( BT_ACTIVATED);
                return -1;
        }
-#else
-       _bt_power_adapter(FALSE);
-#endif
+
        return 0;
 }
 
 int _bt_enable_adapter_le(void)
 {
        BT_DBG("");
-#ifdef __TIZEN_MOBILE__
+
        int ret;
        bt_status_t status;
+       bt_le_status_t le_status;
+       le_status = _bt_core_get_le_status();
+       retv_if(le_status != BT_LE_DEACTIVATED, -1);
 
        status = _bt_core_get_status();
        if (status == BT_DEACTIVATED) {
                __bt_core_set_le_status(BT_LE_ACTIVATING);
                BT_DBG("Activate BT");
-               ret = system("/usr/etc/bluetooth/bt-stack-up.sh &");
+               ret = __execute_command("/usr/etc/bluetooth/bt-stack-up.sh", NULL);
                if (ret < 0) {
                        BT_ERR("running script failed");
                        ret = __execute_command("/usr/etc/bluetooth/bt-dev-end.sh &", NULL);
@@ -305,9 +235,6 @@ int _bt_enable_adapter_le(void)
        } else {
                __bt_core_set_le_status(BT_LE_ACTIVATED);
        }
-#else
-       _bt_power_adapter(TRUE);
-#endif
        return 0;
 }
 
@@ -315,8 +242,12 @@ int _bt_disable_adapter_le(void)
 {
        BT_DBG("+");
 
-#ifdef __TIZEN_MOBILE__
        bt_status_t status;
+       bt_le_status_t le_status;
+
+       le_status = _bt_core_get_le_status();
+       retv_if(le_status == BT_LE_DEACTIVATED, 0);
+       retv_if(le_status == BT_LE_DEACTIVATING, -1);
 
        status = _bt_core_get_status();
        BT_DBG("status : %d", status);
@@ -330,10 +261,8 @@ int _bt_disable_adapter_le(void)
                        return -1;
                }
        }
+
        __bt_core_set_le_status(BT_LE_DEACTIVATED);
-#else
-       _bt_power_adapter(FALSE);
-#endif
 
        BT_DBG("-");
        return 0;
@@ -364,14 +293,12 @@ int _bt_core_service_request_adapter(int service_function)
 static void __bt_core_update_status(void)
 {
        int bt_status = VCONFKEY_BT_STATUS_OFF;
-       int bt_le_status = 0;
+       int bt_le_status = VCONFKEY_BT_LE_STATUS_OFF;
 
        if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0)
                BT_ERR("no bluetooth device info, so BT was disabled at previous session");
-#ifdef ENABLE_TIZEN_2_4
        if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status) < 0)
                BT_ERR("no bluetooth le info, so BT LE was disabled at previous session");
-#endif
 
        BT_INFO("bt_status = %d, bt_le_status = %d", bt_status, bt_le_status);
 
@@ -380,80 +307,49 @@ static void __bt_core_update_status(void)
        else
                __bt_core_set_status(BT_ACTIVATED);
 
-       if (bt_le_status == 0)
+       if (bt_le_status == VCONFKEY_BT_LE_STATUS_OFF)
                __bt_core_set_le_status(BT_LE_DEACTIVATED);
        else
                __bt_core_set_le_status(BT_LE_ACTIVATED);
 }
 
-static gboolean bt_core_enable_adapter(BtCore *agent,
-                                               DBusGMethodInvocation *context)
+gboolean _bt_core_enable_adapter(void)
 {
-       char *sender = dbus_g_method_get_sender(context);
        int ret;
 
-       if (sender == NULL)
-               return FALSE;
-
        _bt_set_flightmode_request(FALSE);
        if (vconf_set_int(BT_OFF_DUE_TO_FLIGHT_MODE, 0) != 0)
                BT_ERR("Set vconf failed");
 
        ret = _bt_enable_adapter();
-       if (ret < 0) {
-               GError *error = bt_core_error(BT_CORE_ERROR_REJECT,
-                                                       "Activation failed");
-               dbus_g_method_return_error(context, error);
-               g_error_free(error);
-               g_free(sender);
+       if (ret < 0)
                return FALSE;
-       } else {
-               dbus_g_method_return(context);
-       }
-
-       g_free(sender);
-       return TRUE;
+       else
+               return TRUE;
 }
 
-static gboolean bt_core_disable_adapter(BtCore *agent,
-                                               DBusGMethodInvocation *context)
+gboolean _bt_core_disable_adapter(void)
 {
-       char *sender = dbus_g_method_get_sender(context);
        int ret;
 
-       if (sender == NULL)
-               return FALSE;
-
        _bt_set_flightmode_request(FALSE);
        if (vconf_set_int(BT_OFF_DUE_TO_FLIGHT_MODE, 0) != 0)
                BT_ERR("Set vconf failed");
 
        ret = _bt_disable_adapter();
-       if (ret < 0) {
-               GError *error = bt_core_error(BT_CORE_ERROR_REJECT,
-                                                       "Deactivation failed");
-               dbus_g_method_return_error(context, error);
-               g_error_free(error);
-               g_free(sender);
+       if (ret < 0)
                return FALSE;
-       } else {
-               dbus_g_method_return(context);
-       }
-
-       g_free(sender);
-       return TRUE;
+       else
+               return TRUE;
 }
 
-static gboolean bt_core_recover_adapter(BtCore *agent,
-                                               DBusGMethodInvocation *context)
+gboolean _bt_core_recover_adapter(void)
 {
        int ret;
        int ret_le;
 
        BT_INFO_C("Recover bt adapter");
 
-       dbus_g_method_return(context);
-
        _bt_set_flightmode_request(FALSE);
        if (vconf_set_int(BT_OFF_DUE_TO_FLIGHT_MODE, 0) != 0)
                BT_ERR("Set vconf failed");
@@ -481,94 +377,38 @@ static gboolean bt_core_recover_adapter(BtCore *agent,
        return TRUE;
 }
 
-static gboolean bt_core_enable_adapter_le(BtCore *agent,
-                                               DBusGMethodInvocation *context)
+gboolean _bt_core_enable_adapter_le(void)
 {
-       char *sender = dbus_g_method_get_sender(context);
        int ret;
 
-       if (sender == NULL)
-               return FALSE;
-
        ret = _bt_enable_adapter_le();
-       if (ret < 0) {
-               GError *error = bt_core_error(BT_CORE_ERROR_REJECT,
-                                                       "LE Activation failed");
-               dbus_g_method_return_error(context, error);
-               g_error_free(error);
-               g_free(sender);
-               BT_DBG("-");
+       if (ret < 0)
                return FALSE;
-       } else {
-               dbus_g_method_return(context);
-       }
-
-       g_free(sender);
-       BT_DBG("-");
-       return TRUE;
+       else
+               return TRUE;
 }
 
-static gboolean bt_core_disable_adapter_le(BtCore *agent,
-                                               DBusGMethodInvocation *context)
+gboolean _bt_core_disable_adapter_le(void)
 {
        BT_DBG("+");
 
-       char *sender = dbus_g_method_get_sender(context);
-       BT_DBG("sender : %s", sender);
        int ret;
 
-       if (sender == NULL)
-               return FALSE;
-
        ret = _bt_disable_adapter_le();
-       if (ret < 0) {
-               GError *error = bt_core_error(BT_CORE_ERROR_REJECT,
-                                                       "LE Deactivation failed");
-               dbus_g_method_return_error(context, error);
-               g_error_free(error);
-               g_free(sender);
+       if (ret < 0)
                return FALSE;
-       } else {
-               dbus_g_method_return(context);
-       }
-
-       g_free(sender);
-       BT_DBG("-");
-       return TRUE;
+       else
+               return TRUE;
 }
 
-static int __bt_reset_adapter(void)
+gboolean __bt_core_reset_adapter(void)
 {
        /* Forcely terminate */
        if (__execute_command("/usr/etc/bluetooth/bt-reset-env.sh", NULL) < 0) {
                BT_ERR("running script failed");
        }
        _bt_core_terminate();
-       return 0;
-}
 
-static gboolean bt_core_reset_adapter(BtCore *agent,
-                                               DBusGMethodInvocation *context)
-{
-       char *sender = dbus_g_method_get_sender(context);
-       int ret;
-
-       if (sender == NULL)
-               return FALSE;
-
-       ret = __bt_reset_adapter();
-       if (ret < 0) {
-               GError *error = bt_core_error(BT_CORE_ERROR_REJECT,
-                                                       "Deactivation failed");
-               dbus_g_method_return_error(context, error);
-               g_error_free(error);
-               g_free(sender);
-               return FALSE;
-       } else {
-               dbus_g_method_return(context);
-       }
-
-       g_free(sender);
        return TRUE;
 }
 
@@ -581,25 +421,57 @@ static gboolean __bt_core_enable_core_timeout_cb(gpointer data)
        return FALSE;
 }
 
-static gboolean bt_core_enable_core(BtCore *agent,
-                                               DBusGMethodInvocation *context)
+gboolean _bt_core_enable_core(void)
 {
-       char *sender = dbus_g_method_get_sender(context);
-
-       if (sender == NULL)
-               return FALSE;
-
        BT_DBG("+");
 
        __bt_core_update_status();
 
        g_timeout_add(200, (GSourceFunc)__bt_core_enable_core_timeout_cb, NULL);
 
-       dbus_g_method_return(context);
+       BT_DBG("-");
+       return TRUE;
+}
 
-       g_free(sender);
+gboolean _bt_core_factory_test_mode(const char *type, const char *arg)
+{
+
+       char *cmd = NULL;
+       char *arg_list[3] = { NULL, NULL, NULL };
+
+       BT_DBG("Test item : %s", type);
+
+       if (g_strcmp0(type, "Enable_RF_Test") == 0) {
+               cmd = "/usr/etc/bluetooth/bt-edutm-on.sh";
+               arg_list[0] = "bt-edutm-on.sh";
+       } else if (g_strcmp0(type, "Disable_RF_Test") == 0) {
+               cmd = "/usr/etc/bluetooth/bt-edutm-off.sh";
+               arg_list[0] = "bt-edutm-off.sh";
+       } else if (g_strcmp0(type, "Slave_Mode") == 0) {
+               cmd = "/usr/etc/bluetooth/bt-mode-slave.sh";
+               arg_list[0] = "bt-mode-slave.sh";
+       } else if (g_strcmp0(type, "Master_Mode") == 0) {
+               cmd = "/usr/etc/bluetooth/bt-mode-master.sh";
+               arg_list[0] = "bt-mode-master.sh";
+       } else if (g_strcmp0(type, "SSP_Debug_Mode") == 0) {
+               cmd = "/usr/etc/bluetooth/bt-set-ssp-debug-mode.sh";
+               arg_list[0] = "bt-set-ssp-debug-mode.sh";
+               arg_list[1] = (char *)arg;
+       } else if (g_strcmp0(type, "RF_Channel") == 0) {
+               cmd = "/usr/etc/bluetooth/bt-enable-rf-channel.sh";
+               arg_list[0] = "bt-enable-rf-channel.sh";
+               arg_list[1] = (char *)arg;
+       } else {
+               _bt_core_terminate();
+               return FALSE;
+       }
 
-       BT_DBG("-");
+       BT_DBG("Run %s", cmd);
+       if (__execute_command(cmd, arg_list) < 0) {
+               BT_ERR("running script failed");
+       }
+
+       _bt_core_terminate();
        return TRUE;
 }
 
@@ -712,10 +584,8 @@ static gboolean __bt_core_disable_timeout_cb(gpointer data)
        if (adapter_status_le == BT_LE_ACTIVATED) {
                int bt_le_status_before_mode = 0;
 
-#ifdef ENABLE_TIZEN_2_4
                if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status_before_mode) == 0)
                        _bt_core_set_bt_le_status(BT_FLIGHT_MODE, bt_le_status_before_mode);
-#endif
 
                _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
                _bt_disable_adapter_le();
@@ -724,6 +594,24 @@ static gboolean __bt_core_disable_timeout_cb(gpointer data)
        return FALSE;
 }
 
+static int __bt_eventsystem_set_value(const char *event, const char *key, const char *value)
+{
+       int ret;
+       bundle *b = NULL;
+
+       b = bundle_create();
+
+       bundle_add_str(b, key, value);
+
+       ret = eventsystem_request_sending_system_event(event, b);
+
+       BT_DBG("request_sending_system_event result: %d", ret);
+
+       bundle_free(b);
+
+       return ret;
+}
+
 void _bt_core_adapter_added_cb(void)
 {
        bt_status_t status;
@@ -750,7 +638,6 @@ void _bt_core_adapter_added_cb(void)
                return;
        }
        _bt_set_flightmode_request(FALSE);
-
        _bt_core_terminate();
 }
 
@@ -767,10 +654,16 @@ void _bt_core_adapter_removed_cb(void)
        __bt_core_set_le_status(BT_LE_DEACTIVATED);
        if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
                BT_ERR("Set vconf failed");
-#ifdef ENABLE_TIZEN_2_4
        if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_OFF) != 0)
                BT_ERR("Set vconf failed");
-#endif
+
+       if (__bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_STATE,
+                                               EVT_VAL_BT_OFF) != ES_R_OK)
+               BT_ERR("Fail to set value");
+
+       if (__bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_LE_STATE,
+                                               EVT_VAL_BT_LE_OFF) != ES_R_OK)
+               BT_ERR("Fail to set value");
 
        if (is_recovery_mode == TRUE)
        {
@@ -794,7 +687,7 @@ void _bt_core_adapter_removed_cb(void)
                return;
        }
        _bt_set_flightmode_request(FALSE);
-       
+
        if (flight_mode_value == 1 || power_saving_mode == 1){
                BT_DBG("Bt Core not terminated");
                return;
@@ -802,4 +695,3 @@ void _bt_core_adapter_removed_cb(void)
 
        _bt_core_terminate();
 }
-
old mode 100755 (executable)
new mode 100644 (file)
index 54da4a2..872dd23 100644 (file)
 #include "bt-core-common.h"
 #include "bt-core-dbus-handler.h"
 #include "bt-internal-types.h"
-#include "bt-request-service.h"
 #include "bt-core-noti-handler.h"
 #include "bt-core-main.h"
 
 #define BT_SERVICE_NAME                "org.projectx.bt"
 #define BT_SERVICE_PATH                "/org/projectx/bt_service"
 
-DBusGProxy *service_proxy = NULL;
-DBusGConnection *service_conn = NULL;
-
 static GDBusConnection *service_gconn;
 static GDBusProxy *service_gproxy;
 
@@ -56,13 +52,10 @@ void _bt_core_fill_garray_from_variant(GVariant *var, GArray *param)
        }
 }
 
-static GDBusProxy *__bt_core_gdbus_init_service_proxy(void)
+static GDBusConnection * _bt_core_get_gdbus_connection(void)
 {
-       GDBusProxy *proxy;
        GError *err = NULL;
 
-       g_type_init();
-
        if (service_gconn == NULL)
                service_gconn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
 
@@ -74,7 +67,22 @@ static GDBusProxy *__bt_core_gdbus_init_service_proxy(void)
                return NULL;
        }
 
-       proxy =  g_dbus_proxy_new_sync(service_gconn,
+       return service_gconn;
+}
+
+static GDBusProxy *__bt_core_gdbus_init_service_proxy(void)
+{
+       GDBusProxy *proxy;
+       GError *err = NULL;
+       GDBusConnection *conn;
+
+       g_type_init();
+
+       conn = _bt_core_get_gdbus_connection();
+       if (!conn)
+               return NULL;
+
+       proxy =  g_dbus_proxy_new_sync(conn,
                        G_DBUS_PROXY_FLAGS_NONE, NULL,
                        BT_SERVICE_NAME,
                        BT_SERVICE_PATH,
@@ -86,8 +94,6 @@ static GDBusProxy *__bt_core_gdbus_init_service_proxy(void)
                         g_clear_error(&err);
                }
 
-               g_object_unref(service_gconn);
-               service_gconn = NULL;
                return NULL;
        }
 
@@ -103,9 +109,11 @@ GDBusProxy *_bt_core_gdbus_get_service_proxy(void)
 
 void _bt_core_gdbus_deinit_proxys(void)
 {
+       BT_DBG("");
+
        if (service_gproxy) {
-               g_object_unref(service_proxy);
-               service_proxy = NULL;
+               g_object_unref(service_gproxy);
+               service_gproxy = NULL;
        }
 
        if (service_gconn) {
@@ -208,259 +216,273 @@ int _bt_core_service_request(int service_type, int service_function,
        return result;
 }
 
-
-static int __bt_core_get_object_path(DBusMessage *msg, char **path)
+static const gchar bt_core_introspection_xml[] =
+"<node name='/'>"
+"  <interface name='org.projectx.btcore'>"
+"     <method name='EnableAdapter'>"
+"     </method>"
+"     <method name='DisableAdapter'>"
+"     </method>"
+"     <method name='RecoverAdapter'>"
+"     </method>"
+"     <method name='ResetAdapter'>"
+"     </method>"
+"     <method name='EnableAdapterLe'>"
+"     </method>"
+"     <method name='DisableAdapterLe'>"
+"     </method>"
+"     <method name='EnableCore'>"
+"     </method>"
+"     <method name='FactoryTestMode'>"
+"          <arg type='s' name='type' direction='in'/>"
+"          <arg type='s' name='arg' direction='in'/>"
+"         <arg type='i' name='ret' direction='out'/>"
+"     </method>"
+" </interface>"
+"</node>";
+
+static guint obj_id, sig_id1, sig_id2, sig_id3;
+
+static void __bt_core_dbus_method(GDBusConnection *connection,
+                       const gchar *sender,
+                       const gchar *object_path,
+                       const gchar *interface_name,
+                       const gchar *method_name,
+                       GVariant *parameters,
+                       GDBusMethodInvocation *invocation,
+                       gpointer user_data)
 {
-       DBusMessageIter item_iter;
-
-       dbus_message_iter_init(msg, &item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_OBJECT_PATH) {
-               BT_ERR("This is bad format dbus");
-               return BLUETOOTH_ERROR_INTERNAL;
+       gboolean ret;
+
+       BT_DBG("method %s", method_name);
+
+       if (g_strcmp0(method_name, "EnableAdapter") == 0) {
+               ret = _bt_core_enable_adapter();
+       } else if (g_strcmp0(method_name, "DisableAdapter") == 0) {
+               ret = _bt_core_disable_adapter();
+       } else if (g_strcmp0(method_name, "RecoverAdapter") == 0) {
+               ret = _bt_core_recover_adapter();
+       } else if (g_strcmp0(method_name, "ResetAdapter") == 0) {
+               ret = __bt_core_reset_adapter();
+       } else if (g_strcmp0(method_name, "EnableAdapterLe") == 0) {
+               ret = _bt_core_enable_adapter_le();
+       } else if (g_strcmp0(method_name, "DisableAdapterLe") == 0) {
+               ret = _bt_core_disable_adapter_le();
+       } else if (g_strcmp0(method_name, "EnableCore") == 0) {
+               ret = _bt_core_enable_core();
+       } else if (g_strcmp0(method_name, "FactoryTestMode") == 0) {
+               const char *type = NULL;
+               const char *arg = NULL;
+
+               g_variant_get(parameters, "(&s&s)", &type, &arg);
+               ret = _bt_core_factory_test_mode(type, arg);
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", ret));
+                return;
+       } else {
+               ret = FALSE;
        }
 
-       dbus_message_iter_get_basic(&item_iter, path);
-
-       if (*path == NULL)
-               return BLUETOOTH_ERROR_INTERNAL;
+       if (!ret) {
+               GQuark quark = g_quark_from_string("bt-core");
+               GError *err = g_error_new(quark, 0, "Failed");
+               g_dbus_method_invocation_return_gerror(invocation, err);
+               g_error_free(err);
+       } else {
+               g_dbus_method_invocation_return_value(invocation, NULL);
+       }
 
-       return BLUETOOTH_ERROR_NONE;
+       BT_DBG("-");
 }
 
-static int __bt_core_get_owner_info(DBusMessage *msg, char **name,
-                               char **previous, char **current)
+static const GDBusInterfaceVTable method_table = {
+       __bt_core_dbus_method,
+       NULL,
+       NULL,
+};
+
+static GDBusNodeInfo *__bt_core_create_node_info(
+                                       const gchar *introspection_data)
 {
-       DBusMessageIter item_iter;
+       GError *err = NULL;
+       GDBusNodeInfo *node_info = NULL;
 
-       dbus_message_iter_init(msg, &item_iter);
+       if (introspection_data == NULL)
+               return NULL;
 
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+       node_info = g_dbus_node_info_new_for_xml(introspection_data, &err);
 
-       dbus_message_iter_get_basic(&item_iter, name);
+       if (err) {
+               BT_ERR("Unable to create node: %s", err->message);
+               g_clear_error(&err);
+       }
+       return node_info;
+}
 
-       if (*name == NULL)
-               return BLUETOOTH_ERROR_INTERNAL;
+gboolean __is_interface_and_signal_valid(const gchar *interface_name,
+                                               const gchar *signal_name)
+{
+       if (g_strcmp0(interface_name, "org.freedesktop.DBus") &&
+               g_strcmp0(interface_name, "org.freedesktop.DBus.ObjectManager"))
+               return FALSE;
 
-       dbus_message_iter_next(&item_iter);
+       if (g_strcmp0(signal_name, "NameOwnerChanged") &&
+               g_strcmp0(signal_name, "InterfacesAdded") &&
+               g_strcmp0(signal_name, "InterfacesRemoved"))
+               return FALSE;
 
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+       return TRUE;
+}
 
-       dbus_message_iter_get_basic(&item_iter, previous);
+static void __handle_name_owner_changed(const char *name)
+{
+       gboolean flight_mode_status;
 
-       if (*previous == NULL)
-               return BLUETOOTH_ERROR_INTERNAL;
+       BT_DBG("");
 
-       dbus_message_iter_next(&item_iter);
+       flight_mode_status = _bt_core_is_flight_mode_enabled();
 
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus");
-               return BLUETOOTH_ERROR_INTERNAL;
+       if (flight_mode_status == FALSE && _bt_is_flightmode_request() == TRUE) {
+               BT_DBG("flightmode requested");
+               return;
        }
 
-       dbus_message_iter_get_basic(&item_iter, current);
-
-       if (*current == NULL)
-               return BLUETOOTH_ERROR_INTERNAL;
-
-       return BLUETOOTH_ERROR_NONE;
+       if ((g_strcmp0(name, "org.bluez") == 0) ||
+               (g_strcmp0(name, "org.projectx.bt") == 0)) {
+               BT_DBG("%s is terminated", name);
+               if (_bt_check_terminating_condition() == TRUE) {
+                       _bt_disable_adapter();
+                       _bt_disable_adapter_le();
+                       _bt_core_terminate();
+               }
+       }
 }
 
-static DBusHandlerResult __bt_core_event_filter(DBusConnection *conn,
-                                          DBusMessage *msg, void *data)
+static void __bt_core_event_filter(GDBusConnection *connection,
+                                                const gchar *sender_name,
+                                                const gchar *object_path,
+                                                const gchar *interface_name,
+                                                const gchar *signal_name,
+                                                GVariant *parameters,
+                                                gpointer user_data)
 {
-       char *object_path = NULL;
-       const char *member = dbus_message_get_member(msg);
-
-       if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL)
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       if (!__is_interface_and_signal_valid(interface_name, signal_name))
+               return;
 
-       if (member == NULL)
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       if (!g_strcmp0(signal_name, "InterfacesAdded")) {
+               char *obj_path = NULL;
+               GVariant *optional_param;
 
-       if (strcasecmp(member, "InterfacesAdded") == 0) {
-               if (__bt_core_get_object_path(msg, &object_path)) {
-                       BT_ERR("Fail to get the path");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-               }
+               g_variant_get(parameters, "(&o@a{sa{sv}})",
+                                               &obj_path, &optional_param);
 
-               if (strcasecmp(object_path, "/org/bluez/hci0") == 0) {
+               if (g_strcmp0(obj_path, "/org/bluez/hci0") == 0) {
                        _bt_core_adapter_added_cb();
                }
-       } else if (strcasecmp(member, "InterfacesRemoved") == 0) {
-               if (__bt_core_get_object_path(msg, &object_path)) {
-                       BT_ERR("Fail to get the path");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-               }
+       } else if (!g_strcmp0(signal_name, "InterfacesRemoved")) {
+               char *obj_path = NULL;
+               GVariant *optional_param;
 
-               if (strcasecmp(object_path, "/org/bluez/hci0") == 0) {
-#ifdef __TIZEN_MOBILE__
+               g_variant_get(parameters, "(&o@as)", &obj_path,
+                                                       &optional_param);
+
+               if (g_strcmp0(obj_path, "/org/bluez/hci0") == 0) {
                        _bt_core_adapter_removed_cb();
-#else
-                       _bt_core_terminate();
-#endif
-               }
-       } else if (strcasecmp(member, "NameOwnerChanged") == 0) {
-               char *name = NULL;
-               char *previous = NULL;
-               char *current = NULL;
-               gboolean flight_mode_status;
-
-               if (__bt_core_get_owner_info(msg, &name, &previous, &current)) {
-                       BT_ERR("Fail to get the owner info");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
                }
+       } else { /* NameOwnerChanged */
+               const char *name = NULL;
+               const char *old_owner = NULL;
+               const char *new_owner = NULL;
 
-               if (*current != '\0')
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+               g_variant_get(parameters, "(&s&s&s)", &name, &old_owner,
+                                                               &new_owner);
 
-               if (vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode_status) != 0)
-                       BT_ERR("Fail to get the flight_mode status value");
-               if (flight_mode_status == FALSE && _bt_is_flightmode_request() == TRUE) {
-                       BT_DBG("flightmode requested");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-               }
-
-               if (strcasecmp(name, "org.bluez") == 0) {
-                       BT_DBG("Bluetoothd is terminated");
-                       if (_bt_check_terminating_condition() == TRUE) {
-                               _bt_disable_adapter();
-                               _bt_disable_adapter_le();
-                               _bt_core_terminate();
-                       }
-               } else if (strcasecmp(name, "org.projectx.bt") == 0) {
-                       BT_DBG("bt-service is terminated");
-                       if (_bt_check_terminating_condition() == TRUE) {
-                               _bt_disable_adapter();
-                               _bt_disable_adapter_le();
-                       }
-               }
+               if (new_owner != NULL && *new_owner == '\0')
+                       __handle_name_owner_changed(name);
        }
-
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
 
-DBusGProxy *_bt_core_register_event_filter(DBusGConnection *g_conn,
-                                               BtCore *bt_core)
+gboolean _bt_core_register_dbus(void)
 {
-       DBusError dbus_error;
-       DBusConnection *conn;
-       DBusGProxy *proxy;
-       GError *err = NULL;
-       guint result = 0;
-
-       if (g_conn == NULL)
-               return NULL;
-
-       conn = dbus_g_connection_get_connection(g_conn);
-       if (conn == NULL)
-               return NULL;
-
-       proxy = dbus_g_proxy_new_for_name(g_conn, DBUS_SERVICE_DBUS,
-                               DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
-       if (proxy == NULL) {
-               BT_ERR("proxy is NULL");
-               return NULL;
-       }
-
-       if (!dbus_g_proxy_call(proxy, "RequestName", &err, G_TYPE_STRING,
-                       BT_CORE_NAME, G_TYPE_UINT, 0, G_TYPE_INVALID,
-                       G_TYPE_UINT, &result, G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("RequestName RPC failed[%s]\n", err->message);
-                       g_error_free(err);
-               }
-               g_object_unref(proxy);
-               return NULL;
+       GError *error = NULL;
+       guint owner_id;
+       GDBusNodeInfo *node_info;
+       gchar *path;
+       GDBusConnection *conn;
+
+       conn = _bt_core_get_gdbus_connection();
+       if (!conn)
+               return FALSE;
+
+       owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
+                               BT_CORE_NAME,
+                               G_BUS_NAME_OWNER_FLAGS_NONE,
+                               NULL, NULL, NULL,
+                               NULL, NULL);
+
+       BT_DBG("owner_id is [%d]", owner_id);
+
+       node_info = __bt_core_create_node_info(bt_core_introspection_xml);
+       if (node_info == NULL)
+               return FALSE;
+
+       path = g_strdup(BT_CORE_PATH);
+       BT_DBG("path is [%s]", path);
+
+       obj_id = g_dbus_connection_register_object(conn, path,
+                                       node_info->interfaces[0],
+                                       &method_table,
+                                       NULL, NULL, &error);
+       if (obj_id == 0) {
+               BT_ERR("Failed to register: %s", error->message);
+               g_error_free(error);
+               g_free(path);
+               return FALSE;
        }
 
-       if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
-               BT_ERR("Failed to get the primary well-known name.\n");
-               g_object_unref(proxy);
-               return NULL;
-       }
+       g_free(path);
+
+       sig_id1 = g_dbus_connection_signal_subscribe(conn,
+                               NULL, "org.freedesktop.DBus",
+                               "NameOwnerChanged", NULL, NULL, 0,
+                               __bt_core_event_filter, NULL, NULL);
+       sig_id2 = g_dbus_connection_signal_subscribe(conn,
+                               NULL, "org.freedesktop.DBus.ObjectManager",
+                               "InterfacesAdded", NULL, NULL,
+                               0, __bt_core_event_filter, NULL, NULL);
+       sig_id2 = g_dbus_connection_signal_subscribe(conn,
+                               NULL, "org.freedesktop.DBus.ObjectManager",
+                               "InterfacesRemoved", NULL,
+                               NULL, 0, __bt_core_event_filter, NULL, NULL);
+
+       return TRUE;
+}
 
-       if (!dbus_connection_add_filter(conn, __bt_core_event_filter,
-                                       NULL, NULL)) {
-               BT_ERR("Fail to add filter");
-               g_object_unref(proxy);
-               return NULL;
-       }
+void  _bt_core_unregister_dbus(void)
+{
+       GDBusConnection *conn;
 
-       dbus_error_init(&dbus_error);
+       BT_DBG("");
 
-       dbus_bus_add_match(conn,
-                       "type='signal',interface='org.freedesktop.DBus'"
-                       ",member='NameOwnerChanged'",
-                       &dbus_error);
+       conn = _bt_core_get_gdbus_connection();
+       if (!conn)
+               return;
 
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add match: %s\n", dbus_error.message);
-               dbus_error_free(&dbus_error);
-               g_object_unref(proxy);
-               return NULL;
+       if (obj_id > 0) {
+               g_dbus_connection_unregister_object(conn, obj_id);
+               obj_id = 0;
        }
 
-       dbus_bus_add_match(conn,
-                       "type='signal',interface='org.freedesktop.DBus.ObjectManager'"
-                       ",member='InterfacesAdded'",
-                       &dbus_error);
-
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add match: %s\n", dbus_error.message);
-               dbus_error_free(&dbus_error);
-               g_object_unref(proxy);
-               return NULL;
+       if (sig_id1 > 0) {
+               g_dbus_connection_signal_unsubscribe(conn, sig_id1);
+               sig_id1 = 0;
        }
-
-       dbus_bus_add_match(conn,
-                       "type='signal',interface='org.freedesktop.DBus.ObjectManager'"
-                       ",member='InterfacesRemoved'",
-                       &dbus_error);
-
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add match: %s\n", dbus_error.message);
-               dbus_error_free(&dbus_error);
-               g_object_unref(proxy);
-               return NULL;
+       if (sig_id2 > 0) {
+               g_dbus_connection_signal_unsubscribe(conn, sig_id2);
+               sig_id2 = 0;
        }
-
-       dbus_g_connection_register_g_object(g_conn, BT_CORE_PATH,
-                                       G_OBJECT(bt_core));
-
-       return proxy;
-}
-
-void _bt_unregister_event_filter(DBusGConnection *g_conn,
-                                       BtCore *bt_core,
-                                       DBusGProxy *dbus_proxy)
-{
-       DBusConnection *conn;
-
-       if (g_conn == NULL ||
-            bt_core == NULL ||
-             dbus_proxy == NULL) {
-               BT_ERR("Invalid parameter");
-               return;
+       if (sig_id3 > 0) {
+               g_dbus_connection_signal_unsubscribe(conn, sig_id3);
+               sig_id3 = 0;
        }
-
-       conn = dbus_g_connection_get_connection(g_conn);
-
-       dbus_connection_remove_filter(conn, __bt_core_event_filter, NULL);
-
-       dbus_g_connection_unregister_g_object(g_conn, G_OBJECT(bt_core));
-
-       g_object_unref(bt_core);
-       g_object_unref(dbus_proxy);
 }
-
index 3c68e78..5c399c3 100644 (file)
@@ -80,7 +80,7 @@ static void __bt_core_sigterm_handler(int signo)
 static gboolean __bt_check_bt_core(void *data)
 {
        int bt_status = VCONFKEY_BT_STATUS_OFF;
-       int bt_le_status = 0;
+       int bt_le_status = VCONFKEY_BT_LE_STATUS_OFF;
        bt_status_t status = BT_DEACTIVATED;
        bt_le_status_t le_status = BT_LE_DEACTIVATED;
        int flight_mode_deactivation = 0;
@@ -95,11 +95,9 @@ static gboolean __bt_check_bt_core(void *data)
                BT_DBG("no bluetooth device info, so BT was disabled at previous session");
        }
 
-#ifdef ENABLE_TIZEN_2_4
        if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status) < 0) {
                BT_ERR("no bluetooth le info, so BT LE was disabled at previous session");
        }
-#endif
 
        if (vconf_get_int(BT_OFF_DUE_TO_FLIGHT_MODE, &flight_mode_deactivation) != 0)
                BT_ERR("Fail to get the flight_mode_deactivation value");
@@ -110,8 +108,8 @@ static gboolean __bt_check_bt_core(void *data)
        if (vconf_get_int(BT_OFF_DUE_TO_TIMEOUT, &bt_off_due_to_timeout) != 0)
                BT_ERR("Fail to get BT_OFF_DUE_TO_TIMEOUT");
 
-       if ((bt_status != VCONFKEY_BT_STATUS_OFF || bt_off_due_to_timeout)
-               && (status == BT_DEACTIVATED)) {
+       if ((bt_status != VCONFKEY_BT_STATUS_OFF || bt_off_due_to_timeout) &&
+               (status == BT_DEACTIVATED)) {
                BT_DBG("Previous session was enabled.");
 
                /* Enable the BT */
@@ -126,7 +124,7 @@ static gboolean __bt_check_bt_core(void *data)
                _bt_core_set_bt_status(BT_POWER_SAVING_MODE, ps_mode_deactivation);
        }
 
-       if ((bt_le_status == 1) && (le_status == BT_LE_DEACTIVATED)) {
+       if ((bt_le_status == VCONFKEY_BT_LE_STATUS_ON) && (le_status == BT_LE_DEACTIVATED)) {
                BT_DBG("Previous session was le enabled. Turn BT LE on automatically.");
 
                /* Enable the BT LE */
@@ -147,32 +145,18 @@ static gboolean __bt_check_bt_core(void *data)
 
 int main(void)
 {
-       DBusGConnection *conn = NULL;
-       GError *error = NULL;
-       BtCore *bt_core = NULL;
-
-       DBusGProxy *dbus_proxy = NULL;
+       gboolean ret;
        struct sigaction sa;
 
        g_type_init();
        BT_INFO_C("Starting bt-core daemeon");
 
-       conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
-       if (error != NULL) {
-               BT_ERR("ERROR: Can't get on system bus [%s]", error->message);
-               g_error_free(error);
+       ret = _bt_core_register_dbus();
+       if (!ret) {
+               BT_ERR("_bt_core_register_dbus failed");
                goto fail;
        }
 
-       bt_core = g_object_new(BT_CORE_TYPE, NULL);
-
-       dbus_proxy = _bt_core_register_event_filter(conn, bt_core);
-       if (!dbus_proxy) {
-               BT_ERR("__bt_core_register_event_filter failed");
-               g_object_unref(bt_core);
-               bt_core = NULL;
-               goto fail;
-       }
 
        memset(&sa, 0, sizeof(sa));
        sa.sa_handler = __bt_core_sigterm_handler;
@@ -180,18 +164,21 @@ int main(void)
        sigaction(SIGTERM, &sa, NULL);
 
        g_timeout_add(500, (GSourceFunc)__bt_check_bt_core, NULL);
+
        main_loop = g_main_loop_new(NULL, FALSE);
+       if (!main_loop) {
+               BT_ERR("creating main loop failed");
+               goto fail;
+       }
+
        g_main_loop_run(main_loop);
 
 fail:
-
-       _bt_unregister_event_filter(conn, bt_core, dbus_proxy);
+       _bt_core_unregister_dbus();
 
        if (main_loop)
                g_main_loop_unref(main_loop);
 
-       dbus_g_connection_unref(conn);
-
        BT_INFO_C("Terminating bt-core daemon");
 
        return 0;
index e9d8a91..3d642de 100644 (file)
@@ -97,10 +97,8 @@ static void __bt_core_handle_adapter_with_flight_mode(gboolean flight_mode)
                if (adapter_status_le == BT_LE_ACTIVATED) {
                        int bt_le_status_before_mode = 0;
 
-#ifdef ENABLE_TIZEN_2_4
                        if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status_before_mode) == 0)
                                _bt_core_set_bt_le_status(BT_FLIGHT_MODE, bt_le_status_before_mode);
-#endif
 
                        _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
                        _bt_disable_adapter_le();
@@ -170,10 +168,9 @@ static void __bt_core_handle_adapter_with_power_saving_mode(int power_saving_mod
                }
                if (adapter_status_le == BT_LE_ACTIVATED) {
                        int bt_le_status_before_mode = 0;
-#ifdef ENABLE_TIZEN_2_4
                        if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status_before_mode) == 0)
                                _bt_core_set_bt_le_status(BT_POWER_SAVING_MODE, bt_le_status_before_mode);
-#endif
+
                        /* Disable the BT LE */
                        _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
                        _bt_disable_adapter_le();
@@ -210,7 +207,7 @@ static void __bt_core_handle_adapter_with_power_saving_mode(int power_saving_mod
                }
        }
 }
-
+#ifdef TIZEN_BT_FLIGHTMODE_ENABLED
 static void __bt_core_flight_mode_cb(keynode_t *node, void *data)
 {
        gboolean flight_mode = FALSE;
@@ -228,6 +225,7 @@ static void __bt_core_flight_mode_cb(keynode_t *node, void *data)
 
        __bt_core_handle_adapter_with_flight_mode(flight_mode);
 }
+#endif
 
 #ifndef TIZEN_WEARABLE
 static void __bt_core_power_saving_mode_cb(keynode_t *node, void *data)
@@ -257,14 +255,12 @@ void _bt_core_init_vconf_value(void)
        _bt_core_handle_flight_mode_noti();
        _bt_core_handle_power_saving_mode_noti();
 
-       if (vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode) != 0)
-               BT_ERR("Fail to get the flight_mode status value");
+       flight_mode = _bt_core_is_flight_mode_enabled();
+
 #ifndef TIZEN_WEARABLE
-#ifdef ENABLE_TIZEN_2_4
        if (vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &power_saving_mode) != 0)
                BT_ERR("Fail to get the power_saving_mode status value");
 #endif
-#endif
        BT_DBG("flight_mode = %d, power_saving_mode = %d", flight_mode, power_saving_mode);
 
        if (flight_mode == TRUE)
@@ -277,16 +273,15 @@ void _bt_core_init_vconf_value(void)
 
 void _bt_core_handle_flight_mode_noti(void)
 {
-#ifdef TIZEN_TELEPHONY_ENABLED
+#ifdef TIZEN_BT_FLIGHTMODE_ENABLED
        int ret;
 
        BT_DBG("+");
 
        ret = vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
-               (vconf_callback_fn)__bt_core_flight_mode_cb, NULL);
+                       (vconf_callback_fn)__bt_core_flight_mode_cb, NULL);
        if (ret < 0)
                BT_ERR("Unable to register key handler");
-
 #else
        BT_DBG("Telephony is disabled");
 #endif
@@ -298,10 +293,9 @@ void _bt_core_handle_power_saving_mode_noti(void)
        int ret;
 
        BT_DBG("+");
-#ifdef ENABLE_TIZEN_2_4
        ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
                        (vconf_callback_fn)__bt_core_power_saving_mode_cb, NULL);
-#endif
+
        if (ret < 0)
                BT_ERR("Unable to register key handler");
 #endif
@@ -309,17 +303,15 @@ void _bt_core_handle_power_saving_mode_noti(void)
 
 void _bt_core_unregister_vconf_handler(void)
 {
-#ifdef TIZEN_TELEPHONY_ENABLED
+#ifdef TIZEN_BT_FLIGHTMODE_ENABLED
        vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
-               (vconf_callback_fn)__bt_core_flight_mode_cb);
+                       (vconf_callback_fn)__bt_core_flight_mode_cb);
 #endif
 
 #ifndef TIZEN_WEARABLE
-#ifdef ENABLE_TIZEN_2_4
        vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE,
                        (vconf_callback_fn)__bt_core_power_saving_mode_cb);
 #endif
-#endif
 
        return;
 }
old mode 100755 (executable)
new mode 100644 (file)
index d129661..54b7fc7 100644 (file)
 #include <sys/wait.h>
 #include <dlog.h>
 #include <glib.h>
-#include <glib-object.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#define CONNMAN_DBUS_NAME "net.connman"
-#define CONNMAN_BLUETOOTH_TECHNOLOGY_PATH "/net/connman/technology/bluetooth"
-#define CONNMAN_BLUETOTOH_TECHNOLOGY_INTERFACE "net.connman.Technology"
-
-#define BT_CORE_NAME "org.projectx.bt_core"
-#define BT_CORE_PATH "/org/projectx/bt_core"
-
-#define BT_CORE_TYPE (bt_core_get_type())
-
 typedef enum {
        BT_DEACTIVATED,
        BT_ACTIVATED,
@@ -82,7 +72,16 @@ int _bt_core_service_request_adapter(int service_function);
 
 void _bt_core_adapter_added_cb(void);
 void _bt_core_adapter_removed_cb(void);
-GType bt_core_get_type (void);
+
+gboolean _bt_core_enable_adapter(void);
+gboolean _bt_core_disable_adapter(void);
+gboolean _bt_core_recover_adapter(void);
+gboolean _bt_core_enable_adapter_le(void);
+gboolean _bt_core_disable_adapter_le(void);
+gboolean __bt_core_reset_adapter(void);
+gboolean _bt_core_enable_core(void);
+gboolean _bt_core_factory_test_mode(const char *type, const char *arg);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index d61d5a5..95695da 100644 (file)
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <dlog.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
 #include <glib.h>
 #include <gio/gio.h>
-#include <glib-object.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -52,20 +48,6 @@ extern "C" {
 #define BT_CORE_NAME "org.projectx.bt_core"
 #define BT_CORE_PATH "/org/projectx/bt_core"
 
-typedef struct _BtCore
-{
-    GObject object;
-} BtCore;
-
-typedef struct _BtCoreClass
-{
-    GObjectClass object_class;
-} BtCoreClass;
-
-
-DBusGProxy *_bt_core_register_event_filter(DBusGConnection *g_conn, BtCore *bt_core);
-void _bt_unregister_event_filter(DBusGConnection *g_conn, BtCore *bt_core, DBusGProxy *dbus_proxy);
-
 int _bt_core_service_request(int service_type, int service_function,
                        GArray *in_param1, GArray *in_param2,
                        GArray *in_param3, GArray *in_param4,
@@ -74,6 +56,9 @@ void _bt_core_fill_garray_from_variant(GVariant *var, GArray *param);
 GDBusProxy *_bt_core_gdbus_get_service_proxy(void);
 void _bt_core_gdbus_deinit_proxys(void);
 
+gboolean _bt_core_register_dbus(void);
+void  _bt_core_unregister_dbus(void);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
old mode 100755 (executable)
new mode 100644 (file)
index 9e762cf..cf61657 100644 (file)
@@ -22,24 +22,13 @@ bt-service-obex-server.c
 bt-service-rfcomm-client.c
 bt-service-rfcomm-server.c
 bt-service-avrcp.c
+bt-service-avrcp-controller.c
 bt-request-handler.c
 bt-service-agent.c
 bt-service-gap-agent.c
 bt-service-pbap.c
 )
 
-IF(LIBNOTIFY_SUPPORT)
-LIST(APPEND SRCS
-bt-popup.c
-)
-ENDIF(LIBNOTIFY_SUPPORT)
-
-IF(LIBNOTIFICATION_SUPPORT)
-LIST(APPEND SRCS
-bt-service-agent-notification.c
-)
-ENDIF(LIBNOTIFICATION_SUPPORT)
-
 IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
        SET(CMAKE_BUILD_TYPE "Release")
 ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
@@ -49,24 +38,19 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
 
 SET(PKG_MODULES
-       vconf
        aul
        vconf
+       libprivilege-control
        syspopup-caller
        dbus-glib-1
-       status
+       gio-2.0
        alarm-service
-       notification
-#      libnotify
-#      gdk-pixbuf-2.0
-#      gtk+-3.0
+       security-server
        capi-content-mime-type
        capi-network-connection
        pkgmgr
-#      journal
-       libprivilege-control
-       cynara-client
-       cynara-creds-dbus
+       journal
+       eventsystem
 )
 
 IF("$ENV{CFLAGS}" MATCHES "-DTIZEN_NETWORK_TETHERING_ENABLE")
@@ -99,12 +83,12 @@ EXEC_PROGRAM("${MARSHALTOOL}" ARGS "--prefix=marshal ${CMAKE_CURRENT_SOURCE_DIR}
 EXEC_PROGRAM("${MARSHALTOOL}" ARGS "--prefix=marshal ${CMAKE_CURRENT_SOURCE_DIR}/marshal.list --body > ${CMAKE_CURRENT_SOURCE_DIR}/marshal.c")
 
 FIND_PROGRAM(DBUS_BINDING_TOOL NAMES dbus-binding-tool)
-EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=bt ${CMAKE_CURRENT_SOURCE_DIR}/bt-request-service.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/include/bt-service-method.h")
-EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=bt_obex_agent ${CMAKE_CURRENT_SOURCE_DIR}/bt-service-obex-agent.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/include/bt-obex-agent-method.h")
+#EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=bt ${CMAKE_CURRENT_SOURCE_DIR}/bt-request-service.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/include/bt-service-method.h")
+#EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=bt_obex_agent ${CMAKE_CURRENT_SOURCE_DIR}/bt-service-obex-agent.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/include/bt-obex-agent-method.h")
 
-EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=gap_agent ${CMAKE_CURRENT_SOURCE_DIR}/bt-service-gap-agent1.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/include/bt-gap-agent-method.h")
+#EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=gap_agent ${CMAKE_CURRENT_SOURCE_DIR}/bt-service-gap-agent1.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/include/bt-gap-agent-method.h")
 
-EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=bt_media_agent ${CMAKE_CURRENT_SOURCE_DIR}/bt-service-media-agent.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/include/bt-media-agent-method.h")
+#EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=bt_media_agent ${CMAKE_CURRENT_SOURCE_DIR}/bt-service-media-agent.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/include/bt-media-agent-method.h")
 
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DVENDOR=\"${APP_VENDOR}\"")
@@ -113,39 +97,21 @@ ADD_DEFINITIONS("-DAPP_DIR=\"${APP_DIR}\"")
 ADD_DEFINITIONS("-DAPP_LOCALEDIR=\"${APP_LOCALEDIR}\"")
 ADD_DEFINITIONS("-DAPP_SYSCONFDIR=\"${APP_SYSCONFDIR}\"")
 
-IF(LIBNOTIFY_SUPPORT OR LIBNOTIFICATION_SUPPORT)
-       ADD_DEFINITIONS("-DDATA_DIR_ICON=\"${SHARE_INSTALL_PREFIX}\"")
-       MESSAGE("Icon used for notification is : ${SHARE_INSTALL_PREFIX}/icons/default/bt-icon.png")
-ENDIF(LIBNOTIFY_SUPPORT OR LIBNOTIFICATION_SUPPORT)
-
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
 
 ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${service_pkgs_LDFLAGS})
 
-# to permit usage of bluetooth_cancel_bonding in bt-popup.c. This build bluetooth-api first.
-IF(LIBNOTIFY_SUPPORT)
-       ADD_DEPENDENCIES(${PROJECT_NAME} bluetooth-api)
-       TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${service_pkgs_LDFLAGS} bluetooth-api)
-ELSE(LIBNOTIFY_SUPPORT)
-       TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${service_pkgs_LDFLAGS})
-ENDIF(LIBNOTIFY_SUPPORT)
-
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/org.projectx.bt.service.in ${CMAKE_CURRENT_SOURCE_DIR}/org.projectx.bt.service)
+INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-service DESTINATION /etc/rc.d/init.d)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.projectx.bt.service DESTINATION share/dbus-1/system-services)
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
 
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/auto-pair-blacklist DESTINATION /opt/var/lib/bluetooth/)
-
-# install booting script
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-service.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-service.conf)
-
 IF (TIZEN_WEARABLE)
        INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/wearable/stack_info DESTINATION /usr/etc/bluetooth/)
 ELSE ()
        INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mobile/stack_info DESTINATION /usr/etc/bluetooth/)
 ENDIF (TIZEN_WEARABLE)
 
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-service.conf DESTINATION /etc/dbus-1/system.d)
-
-
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/bt-service/bluetooth-frwk-service.conf.in b/bt-service/bluetooth-frwk-service.conf.in
deleted file mode 100644 (file)
index 03f609b..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-<busconfig>
-    <policy group="@TZ_SYS_USER_GROUP@">
-        <allow own="org.projectx.bt"/>
-        <allow own="org.projectx.bt_event"/>
-       <allow send_type="method_call"/>
-    </policy>
-    <policy at_console="true">
-        <allow send_destination="org.projectx.bt"/>
-    </policy>
-    <policy context="default">
-        <allow send_destination="org.projectx.bt"/>
-    </policy>
-</busconfig>
-
diff --git a/bt-service/bluetooth-frwk-service.service b/bt-service/bluetooth-frwk-service.service
deleted file mode 100644 (file)
index 248b842..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# bt-service check previous BT-connection status and re-activate BT when boot.
-
-[Unit]
-Description=Bluetooth Framework Service
-
-[Service]
-Type=dbus
-BusName=org.projectx.bt
-ExecStart=/usr/bin/bt-service
-RemainAfterExit=yes
-
-[Install]
-WantedBy=tizen-middleware.target
index 7a35ec5..a9b1460 100644 (file)
  */
 
 #include <string.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
-#include <dbus/dbus-glib-lowlevel.h>
 #include <glib.h>
 #include <dlog.h>
-#include <cynara-client.h>
-#include <cynara-creds-dbus.h>
+#include <security-server.h>
+#include <gio/gio.h>
 
 #include "bluetooth-api.h"
 #include "bt-service-common.h"
@@ -42,6 +39,7 @@
 #include "bt-service-audio.h"
 #include "bt-service-oob.h"
 #include "bt-service-avrcp.h"
+#include "bt-service-avrcp-controller.h"
 #include "bt-service-opp-client.h"
 #include "bt-service-obex-server.h"
 #include "bt-service-rfcomm-client.h"
 #include "bt-request-handler.h"
 #include "bt-service-pbap.h"
 
-/* auto generated header by bt-request-service.xml*/
-#include "bt-service-method.h"
+static GDBusConnection *bt_service_conn;
+static guint owner_id = 0;
+
+static const gchar bt_service_introspection_xml[] =
+"<node name='/org/projectx/bt_service'>"
+"      <interface name='org.projectx.bt'>"
+"              <method name='service_request'>"
+                       /* Input Parameters */
+"                      <arg type='i' name='service_type' direction='in' />"
+"                      <arg type='i' name='service_function' direction='in' />"
+"                      <arg type='i' name='request_type' direction='in' />"
+"                      <arg type='ay' name='input_param1' direction='in' />"
+"                      <arg type='ay' name='input_param2' direction='in' />"
+"                      <arg type='ay' name='input_param3' direction='in' />"
+"                      <arg type='ay' name='input_param4' direction='in' />"
+"                      <arg type='ay' name='input_param5' direction='in' />"
+                       /* Return Parameters */
+"                      <arg type='i' name='output_param1' direction='out' />"
+"                      <arg type='v' name='output_param2' direction='out' />"
+"              </method>"
+"      </interface>"
+"</node>";
+
+GDBusNodeInfo *node_info = NULL;
+
+static void __bt_service_method(GDBusConnection *connection,
+               const gchar *sender,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *method_name,
+               GVariant *parameters,
+               GDBusMethodInvocation *invocation,
+               gpointer user_data);
+
+int __bt_bluez_request(int function_name,
+               int request_type,
+               int request_id,
+               GDBusMethodInvocation *context,
+               GVariant *in_param1,
+               GVariant *in_param2,
+               GVariant *in_param3,
+               GVariant *in_param4,
+               GArray **out_param1);
+int __bt_obexd_request(int function_name,
+               int request_type,
+               int request_id,
+               GDBusMethodInvocation *context,
+               GVariant *in_param1,
+               GVariant *in_param2,
+               GVariant *in_param3,
+               GVariant *in_param4,
+               GArray **out_param1);
+int __bt_agent_request(int function_name,
+               int request_type,
+               int request_id,
+               GDBusMethodInvocation *context,
+               GVariant *in_param1,
+               GVariant *in_param2,
+               GVariant *in_param3,
+               GVariant *in_param4,
+               GArray **out_param1);
+int __bt_core_request(int function_name,
+               int request_type,
+               int request_id,
+               GDBusMethodInvocation *context,
+               GVariant *in_param1);
 
-DBusGConnection *bt_service_conn;
-BtService *service_object;
+gboolean __bt_service_check_privilege(int function_name,
+                                       int service_type,
+                                       GVariant *param);
 
-cynara *p_cynara;
-cynara_configuration *conf;
+/* Function definitions*/
+static void __bt_fill_garray_from_variant(GVariant *var, GArray *param)
+{
+       char *data;
+       int size;
 
-GType bt_service_get_type(void);
+       size = g_variant_get_size(var);
+       if (size > 0) {
+               data = (char *)g_variant_get_data(var);
+               if (data)
+                       param = g_array_append_vals(param, data, size);
 
-G_DEFINE_TYPE(BtService, bt_service, G_TYPE_OBJECT);
+       }
+}
 
-/*This is part of platform provided code skeleton for client server model*/
-static void bt_service_class_init(BtServiceClass *service_class)
+static void __bt_service_get_parameters(GVariant *in_param,
+               void *value, int size)
 {
-       dbus_g_object_type_install_info(G_TYPE_FROM_CLASS(service_class),
-                                       &dbus_glib_bt_object_info);
+       void *buf = NULL;
+       buf = (void *)g_variant_get_data(in_param);
+       memcpy(value, buf, size);
 }
 
-/*This is part of platform provided code skeleton for client server model*/
-static void bt_service_init(BtService *service)
+static void __bt_service_method(GDBusConnection *connection,
+               const gchar *sender,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *method_name,
+               GVariant *parameters,
+               GDBusMethodInvocation *invocation,
+               gpointer user_data)
 {
+       FN_START;
+       BT_DBG("Method[%s] Object Path[%s] Interface Name[%s]",
+                       method_name, object_path, interface_name);
+
+       if (g_strcmp0(method_name, "service_request") == 0) {
+               int service_type;
+               int service_function;
+               int request_type;
+               GVariant *param1 = NULL;
+               GVariant *param2 = NULL;
+               GVariant *param3 = NULL;
+               GVariant *param4 = NULL;
+               GVariant *param5 = NULL;
+               GArray *out_param1 = NULL;
+               GVariant *out_var = NULL;
+               int result = 0;
+               int request_id = -1;
+
+               g_variant_get(parameters, "(iii@ay@ay@ay@ay@ay)", &service_type,
+                               &service_function, &request_type,
+                               &param1, &param2, &param3, &param4, &param5);
+
+               out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
+
+               if (service_type == BT_CORE_SERVICE) {
+                       BT_DBG("No need to check privilege from bt-core");
+               } else if (__bt_service_check_privilege(service_function,
+                                       service_type, param5) == FALSE) {
+                       result = BLUETOOTH_ERROR_PERMISSION_DEINED;
+                       BT_ERR("Priviledge Check Failed");
+
+                       goto fail;
+               }
+
+               if (request_type == BT_ASYNC_REQ
+                               || service_function == BT_OBEX_SERVER_ACCEPT_CONNECTION) {
+                       /* Set the timer */
+                       request_id = _bt_assign_request_id();
+                       BT_DBG("Request ID: %d", request_id);
+
+                       if (request_id < 0) {
+                               BT_ERR("Fail to assign the request id");
+                               result = BLUETOOTH_ERROR_INTERNAL;
+
+                               goto fail;
+                       }
+               }
+
+               BT_DBG("SERVICE TYPE [%d] SERVICE FUNC [%d]",
+                               service_type, service_function);
+               switch (service_type) {
+               case BT_BLUEZ_SERVICE:
+                       result = __bt_bluez_request(service_function,
+                                       request_type, request_id,
+                                       invocation, param1, param2,
+                                       param3, param4, &out_param1);
+                       break;
+               case BT_OBEX_SERVICE:
+                       result = __bt_obexd_request(service_function,
+                                       request_type, request_id,
+                                       invocation, param1,
+                                       param2, param3,
+                                       param4, &out_param1);
+                       break;
+               case BT_AGENT_SERVICE:
+                       result = __bt_agent_request(service_function,
+                                       request_type, request_id,
+                                       invocation, param1,
+                                       param2, param3,
+                                       param4, &out_param1);
+                       break;
+               case BT_CORE_SERVICE:
+                       result = __bt_core_request(service_function,
+                                       request_type, request_id,
+                                       invocation, param1);
+                       break;
+               case BT_CHECK_PRIVILEGE:
+                       result = BLUETOOTH_ERROR_NONE;
+                       break;
+               default:
+                       BT_ERR("Unknown service type");
+                       result = BLUETOOTH_ERROR_INTERNAL;
+                       goto fail;
+               }
+
+               if (result != BLUETOOTH_ERROR_NONE) {
+                       goto fail;
+               }
+
+               if ((request_type == BT_ASYNC_REQ ||
+                       service_function == BT_OBEX_SERVER_ACCEPT_CONNECTION) &&
+                       service_function != BT_OPP_PUSH_FILES) {
+                       BT_DBG("INSERT INTO REQ LIST");
+                       _bt_insert_request_list(request_id, service_function,
+                                               NULL, invocation);
+               } else {
+                       /* Return result */
+                       if (service_type == BT_CHECK_PRIVILEGE ||
+                                       service_function != BT_OPP_PUSH_FILES) {
+                               out_var = g_variant_new_from_data((const GVariantType *)"ay",
+                                               out_param1->data, out_param1->len,
+                                               TRUE, NULL, NULL);
+
+                               GVariant *temp = g_variant_new("(iv)", result, out_var);
+                               g_dbus_method_invocation_return_value(invocation, temp);
+
+                               g_array_free(out_param1, TRUE);
+                               out_param1 = NULL;
+                       }
+               }
+
+               g_variant_unref(param1);
+               g_variant_unref(param2);
+               g_variant_unref(param3);
+               g_variant_unref(param4);
+               g_variant_unref(param5);
+               FN_END;
+               return;
+fail:
+               BT_ERR_C("Request is failed [%s] [%x]",
+                               _bt_convert_error_to_string(result), result);
+
+               out_var = g_variant_new_from_data((const GVariantType *)"ay",
+                               out_param1->data, out_param1->len,
+                               TRUE, NULL, NULL);
+
+               GVariant *temp = g_variant_new("(iv)", result, out_var);
+               g_dbus_method_invocation_return_value(invocation, temp);
+
+               g_array_free(out_param1, TRUE);
+               out_param1 = NULL;
+
+               if (request_type == BT_ASYNC_REQ)
+                       _bt_delete_request_id(request_id);
+
+               g_variant_unref(param1);
+               g_variant_unref(param2);
+               g_variant_unref(param3);
+               g_variant_unref(param4);
+               g_variant_unref(param5);
+       }
+
+       FN_END;
+       return;
 }
 
-static int __bt_bluez_request(int function_name,
+
+static const GDBusInterfaceVTable method_table = {
+       __bt_service_method,
+       NULL,
+       NULL,
+};
+
+int __bt_bluez_request(int function_name,
                int request_type,
                int request_id,
-               DBusGMethodInvocation *context,
-               GArray *in_param1,
-               GArray *in_param2,
-               GArray *in_param3,
-               GArray *in_param4,
+               GDBusMethodInvocation *context,
+               GVariant *in_param1,
+               GVariant *in_param2,
+               GVariant *in_param3,
+               GVariant *in_param4,
                GArray **out_param1)
 {
        int result = BLUETOOTH_ERROR_NONE;
@@ -107,8 +336,8 @@ static int __bt_bluez_request(int function_name,
                break;
        case BT_CHECK_ADAPTER: {
                int enabled = BT_ADAPTER_DISABLED;
+
                result = _bt_check_adapter(&enabled);
-               BT_DBG("_bt_check_adapter result is %d", result);
 
                g_array_append_vals(*out_param1, &enabled,
                                sizeof(int));
@@ -141,9 +370,8 @@ static int __bt_bluez_request(int function_name,
        }
        case BT_SET_LOCAL_NAME: {
                bluetooth_device_name_t local_name = { {0} };
-
-               local_name = g_array_index(in_param1,
-                               bluetooth_device_name_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &local_name, sizeof(bluetooth_device_name_t));
 
                result = _bt_set_local_name(local_name.name);
 
@@ -153,7 +381,7 @@ static int __bt_bluez_request(int function_name,
                char *uuid;
                gboolean used = FALSE;
 
-               uuid = &g_array_index(in_param1, char, 0);
+               uuid = (char *)g_variant_get_data(in_param1);
 
                result = _bt_is_service_used(uuid, &used);
 
@@ -175,8 +403,8 @@ static int __bt_bluez_request(int function_name,
                int mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
                int time = 0;
 
-               mode = g_array_index(in_param1, int, 0);
-               time = g_array_index(in_param2, int, 0);
+               __bt_service_get_parameters(in_param1, &mode, sizeof(int));
+               __bt_service_get_parameters(in_param2, &time, sizeof(int));
 
                result = _bt_set_discoverable_mode(mode, time);
                break;
@@ -190,36 +418,91 @@ static int __bt_bluez_request(int function_name,
                break;
        }
        case BT_START_DISCOVERY:
-               BT_DBG("_bt_start_discovery ");
                result = _bt_start_discovery();
 
                break;
        case BT_START_CUSTOM_DISCOVERY: {
                bt_discovery_role_type_t role;
-               role = g_array_index(in_param1, bt_discovery_role_type_t, 0);
 
+               __bt_service_get_parameters(in_param1,
+                               &role, sizeof(bt_discovery_role_type_t));
                result = _bt_start_custom_discovery(role);
+
                break;
        }
        case BT_CANCEL_DISCOVERY:
                result = _bt_cancel_discovery();
                break;
-       case BT_START_LE_DISCOVERY:
-               result = _bt_start_le_discovery();
-               break;
-       case BT_STOP_LE_DISCOVERY:
-               result = _bt_stop_le_discovery();
-               break;
        case BT_IS_DISCOVERYING: {
                gboolean discovering = FALSE;
                discovering = _bt_is_discovering();
-               g_array_append_vals(*out_param1, &discovering, sizeof(gboolean));
+               g_array_append_vals(*out_param1,
+                               &discovering, sizeof(gboolean));
+               break;
+       }
+       case BT_START_LE_DISCOVERY: {
+               char *sender = NULL;
+
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+               result = _bt_start_le_scan(sender);
+
+               break;
+       }
+       case BT_STOP_LE_DISCOVERY: {
+               char *sender = NULL;
+
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+               result = _bt_stop_le_scan(sender);
+
                break;
        }
        case BT_IS_LE_DISCOVERYING: {
                gboolean le_discovering = FALSE;
-               le_discovering = _bt_is_le_discovering();
-               g_array_append_vals(*out_param1, &le_discovering, sizeof(gboolean));
+
+               le_discovering = _bt_is_le_scanning();
+               g_array_append_vals(*out_param1,
+                               &le_discovering, sizeof(gboolean));
+
+               break;
+       }
+       case BT_REGISTER_SCAN_FILTER: {
+               char *sender = NULL;
+               bluetooth_le_scan_filter_t scan_filter;
+               int slot_id;
+
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+               __bt_service_get_parameters(in_param1, &scan_filter,
+                               sizeof(bluetooth_le_scan_filter_t));
+               BT_DBG("bluetooth_le_scan_filter_t [features : %.2x]",
+                               scan_filter.added_features);
+
+               result = _bt_register_scan_filter(sender,
+                               &scan_filter, &slot_id);
+
+               g_array_append_vals(*out_param1, &slot_id, sizeof(int));
+               break;
+       }
+       case BT_UNREGISTER_SCAN_FILTER:{
+               char *sender = NULL;
+               int slot_id;
+
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+               __bt_service_get_parameters(in_param1, &slot_id, sizeof(int));
+               BT_DBG("Remove scan filter [Slot ID : %d]", slot_id);
+
+               result = _bt_unregister_scan_filter(sender, slot_id);
+
+               break;
+       }
+       case BT_UNREGISTER_ALL_SCAN_FILTERS:{
+               char *sender = NULL;
+
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+
+               BT_DBG("Remove all scan filters [Sender : %s]", sender);
+
+               result = _bt_unregister_all_scan_filters(sender);
+
                break;
        }
        case BT_ENABLE_RSSI: {
@@ -229,17 +512,22 @@ static int __bt_bluez_request(int function_name,
                int low_threshold;
                int in_range_threshold;
                int high_threshold;
+
                BT_DBG("Enable RSSI");
 
-               bd_addr = g_array_index(in_param1, bluetooth_device_address_t, 0);
-               link_type = g_array_index(in_param2, int, 0);
-               rssi_threshold = g_array_index(in_param3, bt_rssi_threshold_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &bd_addr, sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2,
+                               &link_type, sizeof(int));
+               __bt_service_get_parameters(in_param3,
+                               &rssi_threshold, sizeof(bt_rssi_threshold_t));
 
                low_threshold = rssi_threshold.low_threshold;
                in_range_threshold = rssi_threshold.in_range_threshold;
                high_threshold = rssi_threshold.high_threshold;
 
-               result = _bt_enable_rssi(&bd_addr, link_type ,low_threshold,
+               result = _bt_enable_rssi(&bd_addr,
+                               link_type, low_threshold,
                                in_range_threshold, high_threshold);
                break;
        }
@@ -249,8 +537,11 @@ static int __bt_bluez_request(int function_name,
 
                BT_DBG("Get RSSI Strength");
 
-               bd_addr = g_array_index(in_param1, bluetooth_device_address_t, 0);
-               link_type = g_array_index(in_param2, int, 0);
+               __bt_service_get_parameters(in_param1,
+                               &bd_addr, sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2,
+                               &link_type, sizeof(int));
+
                result = _bt_get_rssi_strength(&bd_addr, link_type);
                break;
        }
@@ -258,46 +549,60 @@ static int __bt_bluez_request(int function_name,
                gboolean is_connectable;
 
                is_connectable = _bt_is_connectable();
-               g_array_append_vals(*out_param1, &is_connectable, sizeof(gboolean));
+               g_array_append_vals(*out_param1,
+                               &is_connectable, sizeof(gboolean));
                break;
        }
        case BT_SET_CONNECTABLE: {
                gboolean is_connectable;
 
-               is_connectable = g_array_index(in_param1, gboolean, 0);
-
+               __bt_service_get_parameters(in_param1,
+                               &is_connectable, sizeof(gboolean));
                result = _bt_set_connectable(is_connectable);
                break;
        }
        case BT_SET_ADVERTISING: {
-               gboolean enable = FALSE;
                char *sender = NULL;
+               int adv_handle;
+               gboolean enable = FALSE;
                gboolean use_reserved_slot = FALSE;
 
-               enable = g_array_index(in_param1, gboolean, 0);
-               use_reserved_slot = g_array_index(in_param2, gboolean, 0);
-               sender = dbus_g_method_get_sender(context);
-               result = _bt_set_advertising(enable, sender, use_reserved_slot);
-               g_free(sender);
+               __bt_service_get_parameters(in_param1,
+                               &adv_handle, sizeof(int));
+               __bt_service_get_parameters(in_param2,
+                               &enable, sizeof(gboolean));
+               __bt_service_get_parameters(in_param3,
+                               &use_reserved_slot, sizeof(gboolean));
+
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+
+               result = _bt_set_advertising(sender, adv_handle,
+                               enable, use_reserved_slot);
                break;
        }
        case BT_SET_CUSTOM_ADVERTISING: {
+               char *sender = NULL;
+               int adv_handle;
                gboolean enable = FALSE;
                bluetooth_advertising_params_t adv_params;
-               char *sender = NULL;
                gboolean use_reserved_slot = FALSE;
 
-               enable = g_array_index(in_param1, gboolean, 0);
-               adv_params = g_array_index(in_param2,
-                                       bluetooth_advertising_params_t, 0);
-               use_reserved_slot = g_array_index(in_param3, gboolean, 0);
-               sender = dbus_g_method_get_sender(context);
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+
+               __bt_service_get_parameters(in_param1, &adv_handle,
+                               sizeof(int));
+               __bt_service_get_parameters(in_param2, &enable,
+                               sizeof(gboolean));
+               __bt_service_get_parameters(in_param3, &adv_params,
+                               sizeof(bluetooth_advertising_params_t));
+               __bt_service_get_parameters(in_param4, &use_reserved_slot,
+                               sizeof(gboolean));
 
                BT_DBG("bluetooth_advertising_params_t [%f %f %d %d]",
                                adv_params.interval_min, adv_params.interval_max,
                                adv_params.filter_policy, adv_params.type);
-               result = _bt_set_custom_advertising(enable, &adv_params, sender, use_reserved_slot);
-               g_free(sender);
+               result = _bt_set_custom_advertising(sender, adv_handle,
+                               enable, &adv_params, use_reserved_slot);
                break;
        }
        case BT_GET_ADVERTISING_DATA: {
@@ -308,25 +613,28 @@ static int __bt_bluez_request(int function_name,
                if (result == BLUETOOTH_ERROR_NONE) {
                        g_array_append_vals(*out_param1, adv.data, length);
                }
-
                break;
        }
        case BT_SET_ADVERTISING_DATA: {
+               char *sender = NULL;
+               int adv_handle;
                bluetooth_advertising_data_t adv = { {0} };
                int length;
-               char *sender = NULL;
                gboolean use_reserved_slot = FALSE;
 
-               sender = dbus_g_method_get_sender(context);
-
-               adv = g_array_index(in_param1,
-                               bluetooth_advertising_data_t, 0);
-               length = g_array_index(in_param2, int, 0);
-               use_reserved_slot = g_array_index(in_param3, gboolean, 0);
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
 
-               result = _bt_set_advertising_data(&adv, length, sender, use_reserved_slot);
+               __bt_service_get_parameters(in_param1,
+                               &adv_handle, sizeof(int));
+               __bt_service_get_parameters(in_param2,
+                               &adv, sizeof(bluetooth_advertising_data_t));
+               __bt_service_get_parameters(in_param3,
+                               &length, sizeof(int));
+               __bt_service_get_parameters(in_param4,
+                               &use_reserved_slot, sizeof(gboolean));
 
-               g_free(sender);
+               result = _bt_set_advertising_data(sender, adv_handle,
+                               &adv, length, use_reserved_slot);
                break;
        }
        case BT_GET_SCAN_RESPONSE_DATA: {
@@ -341,37 +649,40 @@ static int __bt_bluez_request(int function_name,
                break;
        }
        case BT_SET_SCAN_RESPONSE_DATA: {
+               char *sender = NULL;
+               int adv_handle;
                bluetooth_scan_resp_data_t rsp = { {0} };
                int length;
-               char *sender = NULL;
                gboolean use_reserved_slot = FALSE;
 
-               sender = dbus_g_method_get_sender(context);
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
 
-               rsp = g_array_index(in_param1,
-                               bluetooth_scan_resp_data_t, 0);
-               length = g_array_index(in_param2, int, 0);
-               use_reserved_slot = g_array_index(in_param3, gboolean, 0);
+               __bt_service_get_parameters(in_param1,
+                               &adv_handle, sizeof(int));
+               __bt_service_get_parameters(in_param2,
+                               &rsp, sizeof(bluetooth_scan_resp_data_t));
+               __bt_service_get_parameters(in_param3,
+                               &length, sizeof(int));
+               __bt_service_get_parameters(in_param4,
+                               &use_reserved_slot, sizeof(gboolean));
 
-               result = _bt_set_scan_response_data(&rsp, length, sender, use_reserved_slot);
+               result = _bt_set_scan_response_data(sender, adv_handle,
+                               &rsp, length, use_reserved_slot);
 
-               g_free(sender);
                break;
        }
        case BT_SET_MANUFACTURER_DATA: {
                bluetooth_manufacturer_data_t m_data = { 0 };
-
-               m_data = g_array_index(in_param1,
-                               bluetooth_manufacturer_data_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &m_data, sizeof(bluetooth_manufacturer_data_t));
 
                result = _bt_set_manufacturer_data(&m_data);
                break;
        }
        case BT_SET_SCAN_PARAMETERS: {
                bluetooth_le_scan_params_t scan_params;
-
-               scan_params = g_array_index(in_param1,
-                                       bluetooth_le_scan_params_t, 0);
+               __bt_service_get_parameters(in_param1, &scan_params,
+                               sizeof(bluetooth_le_scan_params_t));
 
                BT_DBG("bluetooth_le_scan_params_t [%f %f %d]",
                                scan_params.interval, scan_params.window,
@@ -384,10 +695,10 @@ static int __bt_bluez_request(int function_name,
                bluetooth_device_address_t local_address = { {0} };
                bluetooth_le_conn_update_t parameters = {0};
 
-               local_address = g_array_index(in_param1,
-                                       bluetooth_device_address_t, 0);
-               parameters = g_array_index(in_param2,
-                                       bluetooth_le_conn_update_t, 0);
+               __bt_service_get_parameters(in_param1, &local_address,
+                               sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2, &parameters,
+                               sizeof(bluetooth_le_conn_update_t));
 
                result =  _bt_le_conn_update(local_address.addr,
                                        parameters.interval_min,
@@ -400,16 +711,18 @@ static int __bt_bluez_request(int function_name,
                gboolean advertising = FALSE;
                advertising = _bt_is_advertising();
 
-               g_array_append_vals(*out_param1, &advertising, sizeof(gboolean));
+               g_array_append_vals(*out_param1, &advertising,
+                               sizeof(gboolean));
                break;
        }
        case BT_ADD_WHITE_LIST: {
                bluetooth_device_address_t address = { {0} };
                int addr_type = 0;
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
-               addr_type = g_array_index(in_param2, int, 0);
+               __bt_service_get_parameters(in_param1, &address,
+                               sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2, &addr_type,
+                               sizeof(int));
 
                result = _bt_add_white_list(&address, addr_type);
                break;
@@ -418,9 +731,10 @@ static int __bt_bluez_request(int function_name,
                bluetooth_device_address_t address = { {0} };
                int addr_type = 0;
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
-               addr_type = g_array_index(in_param2, int, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2,
+                               &addr_type, sizeof(int));
 
                result = _bt_remove_white_list(&address, addr_type);
                break;
@@ -429,16 +743,16 @@ static int __bt_bluez_request(int function_name,
                result = _bt_clear_white_list();
                break;
        }
-       case BT_GET_BONDED_DEVICES:
+       case BT_GET_BONDED_DEVICES: {
                result = _bt_get_bonded_devices(out_param1);
                break;
-
+       }
        case BT_GET_BONDED_DEVICE: {
                bluetooth_device_address_t address = { {0} };
                bluetooth_device_info_t dev_info;
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
                result = _bt_get_bonded_device_info(&address, &dev_info);
@@ -452,8 +766,8 @@ static int __bt_bluez_request(int function_name,
        case BT_BOND_DEVICE: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                result = _bt_bond_device(request_id, &address,
                                BLUETOOTH_DEV_CONN_DEFAULT, out_param1);
@@ -463,11 +777,10 @@ static int __bt_bluez_request(int function_name,
                bluetooth_device_address_t address = { {0} };
                unsigned short conn_type = 0;
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
-
-               conn_type = g_array_index(in_param2,
-                               unsigned short, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2,
+                               &conn_type, sizeof(unsigned short));
 
                result = _bt_bond_device(request_id, &address,
                                conn_type, out_param1);
@@ -480,8 +793,8 @@ static int __bt_bluez_request(int function_name,
        case BT_UNBOND_DEVICE: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                result = _bt_unbond_device(request_id, &address, out_param1);
 
@@ -491,10 +804,9 @@ static int __bt_bluez_request(int function_name,
                bluetooth_device_address_t address = { {0} };
                const char *local_name;
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
-
-               local_name = &g_array_index(in_param2, char, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+               local_name = (const char *)g_variant_get_data(in_param2);
 
                result = _bt_set_alias(&address, local_name);
                break;
@@ -502,8 +814,8 @@ static int __bt_bluez_request(int function_name,
        case BT_SEARCH_SERVICE: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                result = _bt_search_device(request_id, &address);
                if (result != BLUETOOTH_ERROR_NONE) {
@@ -520,10 +832,10 @@ static int __bt_bluez_request(int function_name,
                bluetooth_device_address_t address = { {0} };
                gboolean authorize;
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
-
-               authorize = g_array_index(in_param2, gboolean, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2,
+                               &authorize, sizeof(gboolean));
 
                result = _bt_set_authorization(&address, authorize);
                break;
@@ -533,13 +845,13 @@ static int __bt_bluez_request(int function_name,
                int type;
                gboolean connected = FALSE;
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
-
-               type = g_array_index(in_param2, int, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2,
+                               &type, sizeof(int));
 
                result = _bt_is_device_connected(&address, type, &connected);
-
+               BT_DBG("is_connected: %d", connected);
                if (result == BLUETOOTH_ERROR_NONE) {
                        g_array_append_vals(*out_param1, &connected,
                                                sizeof(gboolean));
@@ -547,11 +859,28 @@ static int __bt_bluez_request(int function_name,
 
                break;
        }
+       case BT_GET_CONNECTED_LINK_TYPE: {
+               bluetooth_device_address_t address = { {0} };
+               bluetooth_connected_link_t connected = BLUETOOTH_CONNECTED_LINK_NONE;
+
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+
+               result = _bt_get_connected_link(&address, &connected);
+
+               if (result == BLUETOOTH_ERROR_NONE) {
+                       g_array_append_vals(*out_param1, &connected,
+                                       sizeof(guint));
+               }
+
+               break;
+       }
+
        case BT_HID_CONNECT: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                result = _bt_hid_connect(request_id, &address);
                if (result != BLUETOOTH_ERROR_NONE) {
@@ -563,8 +892,8 @@ static int __bt_bluez_request(int function_name,
        case BT_HID_DISCONNECT: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                result = _bt_hid_disconnect(request_id, &address);
                if (result != BLUETOOTH_ERROR_NONE) {
@@ -583,10 +912,10 @@ static int __bt_bluez_request(int function_name,
                bluetooth_device_address_t address = { {0} };
                int role;
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
-
-               role = g_array_index(in_param2, int, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2,
+                               &role, sizeof(int));
 
                result = _bt_network_connect(request_id, role, &address);
                if (result != BLUETOOTH_ERROR_NONE) {
@@ -598,8 +927,8 @@ static int __bt_bluez_request(int function_name,
        case BT_NETWORK_DISCONNECT: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                result = _bt_network_disconnect(request_id, &address);
                if (result != BLUETOOTH_ERROR_NONE) {
@@ -611,8 +940,8 @@ static int __bt_bluez_request(int function_name,
        case BT_NETWORK_SERVER_DISCONNECT: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                result = _bt_network_server_disconnect(request_id, &address);
                if (result != BLUETOOTH_ERROR_NONE) {
@@ -625,8 +954,8 @@ static int __bt_bluez_request(int function_name,
        case BT_AUDIO_CONNECT: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                result = _bt_audio_connect(request_id, BT_AUDIO_ALL,
                                        &address, out_param1);
@@ -635,8 +964,8 @@ static int __bt_bluez_request(int function_name,
        case BT_AUDIO_DISCONNECT: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                result = _bt_audio_disconnect(request_id, BT_AUDIO_ALL,
                                        &address, out_param1);
@@ -645,8 +974,8 @@ static int __bt_bluez_request(int function_name,
        case BT_AG_CONNECT: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                result = _bt_audio_connect(request_id, BT_AUDIO_HSP,
                                        &address, out_param1);
@@ -655,8 +984,8 @@ static int __bt_bluez_request(int function_name,
        case BT_AG_DISCONNECT: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                result = _bt_audio_disconnect(request_id, BT_AUDIO_HSP,
                                        &address, out_param1);
@@ -665,8 +994,8 @@ static int __bt_bluez_request(int function_name,
        case BT_AV_CONNECT: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                result = _bt_audio_connect(request_id, BT_AUDIO_A2DP,
                                        &address, out_param1);
@@ -675,8 +1004,8 @@ static int __bt_bluez_request(int function_name,
        case BT_AV_DISCONNECT: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                result = _bt_audio_disconnect(request_id, BT_AUDIO_A2DP,
                                        &address, out_param1);
@@ -685,8 +1014,8 @@ static int __bt_bluez_request(int function_name,
        case BT_AVRCP_CONTROL_CONNECT: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                result = _bt_audio_connect(request_id, BT_AVRCP,
                                        &address, out_param1);
@@ -695,54 +1024,56 @@ static int __bt_bluez_request(int function_name,
        case BT_AVRCP_CONTROL_DISCONNECT: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                result = _bt_audio_disconnect(request_id, BT_AVRCP,
                                        &address, out_param1);
                break;
        }
-       case BT_HF_CONNECT: {
+       case BT_AV_SOURCE_CONNECT: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1, &address,
+                               sizeof(bluetooth_device_address_t));
 
-               result = _bt_hf_connect(request_id, &address, out_param1);
+               result = _bt_audio_connect(request_id, BT_AUDIO_A2DP_SOURCE,
+                                       &address, out_param1);
                break;
        }
-       case BT_HF_DISCONNECT: {
+       case BT_AV_SOURCE_DISCONNECT: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1, &address,
+                               sizeof(bluetooth_device_address_t));
 
-               result = _bt_hf_disconnect(request_id, &address, out_param1);
+               result = _bt_audio_disconnect(request_id, BT_AUDIO_A2DP_SOURCE,
+                                       &address, out_param1);
                break;
        }
-       case BT_GET_SPEAKER_GAIN: {
-               unsigned int volume;
+       case BT_HF_CONNECT: {
+               bluetooth_device_address_t address = { {0} };
 
-               result = _bt_audio_get_speaker_gain(&volume);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
-               g_array_append_vals(*out_param1, &volume,
-                               sizeof(unsigned int));
+               result = _bt_hf_connect(request_id, &address, out_param1);
                break;
        }
-       case BT_SET_SPEAKER_GAIN: {
-               unsigned int volume;
-
-               volume = g_array_index(in_param1,
-                               unsigned int, 0);
+       case BT_HF_DISCONNECT: {
+               bluetooth_device_address_t address = { {0} };
 
-               result = _bt_audio_set_speaker_gain(volume);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
+               result = _bt_hf_disconnect(request_id, &address, out_param1);
                break;
        }
        case BT_SET_CONTENT_PROTECT: {
                gboolean status;
 
-               status = g_array_index(in_param1, gboolean, 0);
+               __bt_service_get_parameters(in_param1,
+                               &status, sizeof(gboolean));
 
                result = _bt_audio_set_content_protect(status);
 
@@ -763,11 +1094,10 @@ static int __bt_bluez_request(int function_name,
                bluetooth_device_address_t address = { {0} };
                bt_oob_data_t local_oob_data;
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
-
-               local_oob_data = g_array_index(in_param2,
-                               bt_oob_data_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2,
+                               &local_oob_data, sizeof(bt_oob_data_t));
 
                result = _bt_oob_add_remote_data(&address, &local_oob_data);
 
@@ -776,8 +1106,8 @@ static int __bt_bluez_request(int function_name,
        case BT_OOB_REMOVE_REMOTE_DATA: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                result = _bt_oob_remove_remote_data(&address);
 
@@ -790,8 +1120,8 @@ static int __bt_bluez_request(int function_name,
                memset(&data, 0x00, sizeof(media_metadata_t));
                memset(&meta_data, 0x00, sizeof(media_metadata_attributes_t));
 
-               data = g_array_index(in_param1,
-                               media_metadata_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &data, sizeof(media_metadata_t));
 
                meta_data.title = g_strdup(data.title);
                meta_data.artist = g_strdup(data.artist);
@@ -814,8 +1144,10 @@ static int __bt_bluez_request(int function_name,
                int type;
                unsigned int value;
 
-               type = g_array_index(in_param1, int, 0);
-               value = g_array_index(in_param2, unsigned int, 0);
+               __bt_service_get_parameters(in_param1,
+                               &type, sizeof(int));
+               __bt_service_get_parameters(in_param2,
+                               &value, sizeof(unsigned int));
 
                result = _bt_avrcp_set_property(type, value);
 
@@ -825,9 +1157,8 @@ static int __bt_bluez_request(int function_name,
                media_player_settings_t properties;
 
                memset(&properties, 0x00, sizeof(media_player_settings_t));
-
-               properties = g_array_index(in_param1,
-                               media_player_settings_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &properties, sizeof(media_player_settings_t));
 
                result = _bt_avrcp_set_properties(&properties);
 
@@ -836,8 +1167,7 @@ static int __bt_bluez_request(int function_name,
        case BT_AVRCP_HANDLE_CONTROL: {
                int type;
 
-               type = g_array_index(in_param1,
-                               int, 0);
+               __bt_service_get_parameters(in_param1, &type, sizeof(int));
 
                result = _bt_avrcp_control_cmd(type);
 
@@ -847,8 +1177,10 @@ static int __bt_bluez_request(int function_name,
                int type;
                unsigned int value;
 
-               type = g_array_index(in_param1, int, 0);
-               value = g_array_index(in_param2, unsigned int, 0);
+               __bt_service_get_parameters(in_param1,
+                               &type, sizeof(int));
+               __bt_service_get_parameters(in_param2,
+                               &value, sizeof(unsigned int));
 
                result = _bt_avrcp_control_set_property(type, value);
 
@@ -858,8 +1190,7 @@ static int __bt_bluez_request(int function_name,
                int type;
                unsigned int value;
 
-               type = g_array_index(in_param1,
-                               int, 0);
+               __bt_service_get_parameters(in_param1, &type, sizeof(int));
 
                result = _bt_avrcp_control_get_property(type, &value);
                g_array_append_vals(*out_param1, &value, sizeof(int));
@@ -924,8 +1255,8 @@ static int __bt_bluez_request(int function_name,
                char *input_string;
                int connect_type;
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
 
                input_string = &g_array_index(in_param2, char, 0);
 
@@ -1025,9 +1356,12 @@ static int __bt_bluez_request(int function_name,
                int pending;
                gboolean is_native;
 
-               socket_fd = g_array_index(in_param1, int, 0);
-               pending = g_array_index(in_param2, int, 0);
-               is_native = g_array_index(in_param3, gboolean, 0);
+               __bt_service_get_parameters(in_param1, &socket_fd,
+                               sizeof(int));
+               __bt_service_get_parameters(in_param2, &pending,
+                               sizeof(int));
+               __bt_service_get_parameters(in_param3, &is_native,
+                               sizeof(gboolean));
 
                result = _bt_rfcomm_listen(socket_fd, pending, is_native);
                break;
@@ -1036,7 +1370,7 @@ static int __bt_bluez_request(int function_name,
                gboolean available = TRUE;
                char *uuid;
 
-               uuid = &g_array_index(in_param1, char, 0);
+               uuid = (char *)g_variant_get_data(in_param1);
 
                result = _bt_rfcomm_is_uuid_available(uuid, &available);
 
@@ -1046,7 +1380,7 @@ static int __bt_bluez_request(int function_name,
        case BT_RFCOMM_ACCEPT_CONNECTION: {
                int socket_fd;
 
-               socket_fd = g_array_index(in_param1, int, 0);
+               __bt_service_get_parameters(in_param1, &socket_fd, sizeof(int));
                BT_DBG(" socket fd %d", socket_fd);
                result = _bt_rfcomm_accept_connection();
                break;
@@ -1054,20 +1388,27 @@ static int __bt_bluez_request(int function_name,
        case BT_RFCOMM_REJECT_CONNECTION: {
                int socket_fd;
 
-               socket_fd = g_array_index(in_param1, int, 0);
+               __bt_service_get_parameters(in_param1, &socket_fd, sizeof(int));
                BT_DBG(" socket fd %d", socket_fd);
                result = _bt_rfcomm_reject_connection();
                break;
        }
+       case BT_RFCOMM_CREATE_SOCKET_EX: {
+               result = BLUETOOTH_ERROR_NONE;
+               break;
+       }
+       case BT_RFCOMM_REMOVE_SOCKET_EX: {
+               result = BLUETOOTH_ERROR_NONE;
+               break;
+       }
        case BT_CONNECT_LE: {
                bluetooth_device_address_t address = { {0} };
                gboolean auto_connect;
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
-
-               auto_connect = g_array_index(in_param2,
-                               gboolean, 0);
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2,
+                               &auto_connect, sizeof(gboolean));
 
                result = _bt_connect_le_device(&address, auto_connect);
 
@@ -1076,8 +1417,8 @@ static int __bt_bluez_request(int function_name,
        case BT_DISCONNECT_LE: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1, &address,
+                               sizeof(bluetooth_device_address_t));
 
                result = _bt_disconnect_le_device(&address);
 
@@ -1086,7 +1427,8 @@ static int __bt_bluez_request(int function_name,
        case BT_SET_LE_PRIVACY: {
                gboolean set_privacy;
 
-               set_privacy = g_array_index(in_param1, gboolean, 0);
+               __bt_service_get_parameters(in_param1, &set_privacy,
+                               sizeof(gboolean));
 
                result = _bt_set_le_privacy(set_privacy);
 
@@ -1111,14 +1453,14 @@ static int __bt_bluez_request(int function_name,
        return result;
 }
 
-static int __bt_obexd_request(int function_name,
+int __bt_obexd_request(int function_name,
                int request_type,
                int request_id,
-               DBusGMethodInvocation *context,
-               GArray *in_param1,
-               GArray *in_param2,
-               GArray *in_param3,
-               GArray *in_param4,
+               GDBusMethodInvocation *context,
+               GVariant *in_param1,
+               GVariant *in_param2,
+               GVariant *in_param3,
+               GVariant *in_param4,
                GArray **out_param1)
 {
        BT_DBG("+");
@@ -1135,18 +1477,20 @@ static int __bt_obexd_request(int function_name,
                bt_file_path_t path;
                char **file_path;
                int file_count;
+               GArray *param2;
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
-
-               file_count = g_array_index(in_param3, int, 0);
+               __bt_service_get_parameters(in_param1, &address,
+                               sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param3, &file_count,
+                               sizeof(int));
 
                file_path = g_new0(char *, file_count + 1);
 
-               for (i = 0; i < file_count; i++) {
-                       path = g_array_index(in_param2,
-                                       bt_file_path_t, i);
+               param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
+               __bt_fill_garray_from_variant(in_param2, param2);
 
+               for (i = 0; i < file_count; i++) {
+                       path = g_array_index(param2, bt_file_path_t, i);
                        file_path[i] = g_strdup(path.path);
                }
                BT_DBG("_bt_opp_client_push_files");
@@ -1157,8 +1501,8 @@ static int __bt_obexd_request(int function_name,
                for (i = 0; i < file_count; i++) {
                        g_free(file_path[i]);
                }
-
                g_free(file_path);
+               g_array_free(param2, TRUE);
 
                break;
        }
@@ -1182,22 +1526,27 @@ static int __bt_obexd_request(int function_name,
                char *path;
                char *sender;
 
-               sender = dbus_g_method_get_sender(context);
-               path = &g_array_index(in_param1, char, 0);
-               is_native = g_array_index(in_param2, gboolean, 0);
-               app_pid = g_array_index(in_param3, int, 0);
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+
+               path = (char *)g_variant_get_data(in_param1);
+               __bt_service_get_parameters(in_param2, &is_native,
+                               sizeof(gboolean));
+               __bt_service_get_parameters(in_param3, &app_pid,
+                               sizeof(int));
 
-               result = _bt_obex_server_allocate(sender, path, app_pid, is_native);
+               result = _bt_obex_server_allocate(sender,
+                               path, app_pid, is_native);
 
-               g_free(sender);
                break;
        }
        case BT_OBEX_SERVER_DEALLOCATE: {
                int app_pid;
                gboolean is_native;
 
-               is_native = g_array_index(in_param1, gboolean, 0);
-               app_pid = g_array_index(in_param2, int, 0);
+               __bt_service_get_parameters(in_param1, &is_native,
+                               sizeof(gboolean));
+               __bt_service_get_parameters(in_param2, &app_pid,
+                               sizeof(int));
 
                result = _bt_obex_server_deallocate(app_pid, is_native);
                break;
@@ -1225,7 +1574,7 @@ static int __bt_obexd_request(int function_name,
        case BT_OBEX_SERVER_ACCEPT_FILE: {
                char *file_name;
 
-               file_name = &g_array_index(in_param1, char, 0);
+               file_name = (char *)g_variant_get_data(in_param1);
 
                result = _bt_obex_server_accept_authorize(file_name, TRUE);
 
@@ -1240,8 +1589,9 @@ static int __bt_obexd_request(int function_name,
                gboolean is_native;
                char *destination_path;
 
-               destination_path = &g_array_index(in_param1, char, 0);
-               is_native = g_array_index(in_param2, gboolean, 0);
+               destination_path = (char *)g_variant_get_data(in_param1);
+               __bt_service_get_parameters(in_param2, &is_native,
+                               sizeof(gboolean));
 
                result = _bt_obex_server_set_destination_path(destination_path,
                                                        is_native);
@@ -1251,7 +1601,7 @@ static int __bt_obexd_request(int function_name,
        case BT_OBEX_SERVER_SET_ROOT: {
                char *root;
 
-               root = &g_array_index(in_param1, char, 0);
+               root = (char *)g_variant_get_data(in_param1);
 
                result = _bt_obex_server_set_root(root);
 
@@ -1260,7 +1610,8 @@ static int __bt_obexd_request(int function_name,
        case BT_OBEX_SERVER_CANCEL_TRANSFER: {
                int transfer_id;
 
-               transfer_id = g_array_index(in_param1, int, 0);
+               __bt_service_get_parameters(in_param1, &transfer_id,
+                               sizeof(int));
 
                result = _bt_obex_server_cancel_transfer(transfer_id);
 
@@ -1283,8 +1634,8 @@ static int __bt_obexd_request(int function_name,
        case BT_PBAP_CONNECT: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1, &address,
+                               sizeof(bluetooth_device_address_t));
 
                result = _bt_pbap_connect(&address);
                break;
@@ -1292,8 +1643,8 @@ static int __bt_obexd_request(int function_name,
        case BT_PBAP_DISCONNECT: {
                bluetooth_device_address_t address = { {0} };
 
-               address = g_array_index(in_param1,
-                               bluetooth_device_address_t, 0);
+               __bt_service_get_parameters(in_param1, &address,
+                               sizeof(bluetooth_device_address_t));
 
                result = _bt_pbap_disconnect(&address);
                break;
@@ -1302,11 +1653,13 @@ static int __bt_obexd_request(int function_name,
                bluetooth_device_address_t address = { {0} };
                bt_pbap_folder_t folder = { 0, };
 
-               address = g_array_index(in_param1, bluetooth_device_address_t, 0);
-               folder = g_array_index(in_param2, bt_pbap_folder_t, 0);
+               __bt_service_get_parameters(in_param1, &address,
+                               sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2, &folder,
+                               sizeof(bt_pbap_folder_t));
 
-               result = _bt_pbap_get_phonebook_size(&address, folder.addressbook,
-                                       folder.folder_type);
+               result = _bt_pbap_get_phonebook_size(&address,
+                               folder.addressbook, folder.folder_type);
                break;
        }
        case BT_PBAP_GET_PHONEBOOK: {
@@ -1314,9 +1667,12 @@ static int __bt_obexd_request(int function_name,
                bt_pbap_folder_t folder = { 0, };
                bt_pbap_pull_parameters_t app_param = { 0, };
 
-               address = g_array_index(in_param1, bluetooth_device_address_t, 0);
-               folder = g_array_index(in_param2, bt_pbap_folder_t, 0);
-               app_param = g_array_index(in_param3, bt_pbap_pull_parameters_t, 0);
+               __bt_service_get_parameters(in_param1, &address,
+                               sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2, &folder,
+                               sizeof(bt_pbap_folder_t));
+               __bt_service_get_parameters(in_param3, &app_param,
+                               sizeof(bt_pbap_pull_parameters_t));
 
                result = _bt_pbap_get_phonebook(&address, folder.addressbook,
                                folder.folder_type, &app_param);
@@ -1327,9 +1683,12 @@ static int __bt_obexd_request(int function_name,
                bt_pbap_folder_t folder = { 0, };
                bt_pbap_list_parameters_t app_param = { 0, };
 
-               address = g_array_index(in_param1, bluetooth_device_address_t, 0);
-               folder = g_array_index(in_param2, bt_pbap_folder_t, 0);
-               app_param = g_array_index(in_param3, bt_pbap_list_parameters_t, 0);
+               __bt_service_get_parameters(in_param1, &address,
+                               sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2, &folder,
+                               sizeof(bt_pbap_folder_t));
+               __bt_service_get_parameters(in_param3, &app_param,
+                               sizeof(bt_pbap_list_parameters_t));
 
                result = _bt_pbap_get_list(&address, folder.addressbook,
                                folder.folder_type, &app_param);
@@ -1340,9 +1699,12 @@ static int __bt_obexd_request(int function_name,
                bt_pbap_folder_t folder = { 0, };
                bt_pbap_pull_vcard_parameters_t app_param = { 0, };
 
-               address = g_array_index(in_param1, bluetooth_device_address_t, 0);
-               folder = g_array_index(in_param2, bt_pbap_folder_t, 0);
-               app_param = g_array_index(in_param3, bt_pbap_pull_vcard_parameters_t, 0);
+               __bt_service_get_parameters(in_param1, &address,
+                               sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2, &folder,
+                               sizeof(bt_pbap_folder_t));
+               __bt_service_get_parameters(in_param3, &app_param,
+                               sizeof(bt_pbap_pull_vcard_parameters_t));
 
                result = _bt_pbap_pull_vcard(&address, folder.addressbook,
                                folder.folder_type, &app_param);
@@ -1353,9 +1715,12 @@ static int __bt_obexd_request(int function_name,
                bt_pbap_folder_t folder = { 0, };
                bt_pbap_search_parameters_t app_param = { 0, };
 
-               address = g_array_index(in_param1, bluetooth_device_address_t, 0);
-               folder = g_array_index(in_param2, bt_pbap_folder_t, 0);
-               app_param = g_array_index(in_param3, bt_pbap_search_parameters_t, 0);
+               __bt_service_get_parameters(in_param1, &address,
+                               sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2, &folder,
+                               sizeof(bt_pbap_folder_t));
+               __bt_service_get_parameters(in_param3, &app_param,
+                               sizeof(bt_pbap_search_parameters_t));
 
                result = _bt_pbap_phonebook_search(&address, folder.addressbook,
                                folder.folder_type, &app_param);
@@ -1368,41 +1733,44 @@ static int __bt_obexd_request(int function_name,
                break;
        }
 
-       BT_DBG("-");
+       FN_END;
 
        return result;
 }
 
-static int __bt_agent_request(int function_name,
+int __bt_agent_request(int function_name,
                int request_type,
                int request_id,
-               DBusGMethodInvocation *context,
-               GArray *in_param1,
-               GArray *in_param2,
-               GArray *in_param3,
-               GArray *in_param4,
+               GDBusMethodInvocation *context,
+               GVariant *in_param1,
+               GVariant *in_param2,
+               GVariant *in_param3,
+               GVariant *in_param4,
                GArray **out_param1)
 {
        int result;
-       switch(function_name) {
+       switch (function_name) {
        case BT_SET_AUTHORIZATION: {
                int type;
                char *uuid;
                char *path;
                int fd;
 
-               type = g_array_index(in_param1, int, 0);
-               uuid = &g_array_index(in_param2, char, 0);
-               path = &g_array_index(in_param3, char, 0);
-               fd = g_array_index(in_param4, int, 0);
+               __bt_service_get_parameters(in_param1, &type, sizeof(int));
+               uuid = (char *)g_variant_get_data(in_param2);
+               path = (char *)g_variant_get_data(in_param3);
+               __bt_service_get_parameters(in_param4, &fd, sizeof(int));
+
                result = _bt_register_osp_server_in_agent(type, uuid, path, fd);
                break;
        }
        case BT_UNSET_AUTHORIZATION: {
                int type;
                char *uuid;
-               type = g_array_index(in_param1, int, 0);
-               uuid = &g_array_index(in_param2, char, 0);
+
+               __bt_service_get_parameters(in_param1, &type, sizeof(int));
+               uuid = (char *)g_variant_get_data(in_param2);
+
                result = _bt_unregister_osp_server_in_agent(type, uuid);
                break;
        }
@@ -1415,11 +1783,11 @@ static int __bt_agent_request(int function_name,
        return result;
 }
 
-static int __bt_core_request(int function_name,
+int __bt_core_request(int function_name,
                int request_type,
                int request_id,
-               DBusGMethodInvocation *context,
-               GArray *in_param1)
+               GDBusMethodInvocation *context,
+               GVariant *in_param1)
 {
        int result;
 
@@ -1452,13 +1820,10 @@ static int __bt_core_request(int function_name,
                if (status == BT_DEACTIVATING) {
                                BT_DBG("Disabling in progress");
                                result = BLUETOOTH_ERROR_IN_PROGRESS;
-               }
-               else if (status == BT_DEACTIVATED) {
+               } else if (status == BT_DEACTIVATED) {
                                BT_DBG("Already disabled");
                                result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
-               }
-               else
-               {
+               } else {
                        _bt_adapter_set_status(BT_DEACTIVATING);
                        result = BLUETOOTH_ERROR_NONE;
                }
@@ -1473,8 +1838,7 @@ static int __bt_core_request(int function_name,
                if (le_status == BT_LE_ACTIVATING) {
                        BT_DBG("Enabling in progress");
                        result = BLUETOOTH_ERROR_IN_PROGRESS;
-               }
-               else if (le_status == BT_LE_ACTIVATED) {
+               } else if (le_status == BT_LE_ACTIVATED) {
                        BT_DBG("Already enabled");
                        result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
                } else {
@@ -1493,13 +1857,10 @@ static int __bt_core_request(int function_name,
                if (le_status == BT_LE_DEACTIVATING) {
                                BT_DBG("Disabling in progress");
                                result = BLUETOOTH_ERROR_IN_PROGRESS;
-               }
-               else if (le_status == BT_LE_DEACTIVATED) {
+               } else if (le_status == BT_LE_DEACTIVATED) {
                                BT_DBG("Already disabled");
                                result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
-               }
-               else
-               {
+               } else {
                        _bt_adapter_set_le_status(BT_LE_DEACTIVATING);
                        result = BLUETOOTH_ERROR_NONE;
                }
@@ -1517,60 +1878,18 @@ static int __bt_core_request(int function_name,
 
 gboolean __bt_service_check_privilege(int function_name,
                                        int service_type,
-                                       const char *unique_name)
+                                       GVariant *param)
 {
+       char *cookie = NULL;
        int ret_val;
+       int len;
        gboolean result = TRUE;
-       char *client_creds = NULL;
-       char *user_creds = NULL;
-       char *client_session = "";
-       DBusConnection *conn = NULL;
-       int client_creds_method = CLIENT_METHOD_SMACK;
-       int user_creds_method = USER_METHOD_UID;
-       char err_msg[256] = {0, };
-
-       retv_if(unique_name == NULL, FALSE);
-
-       BT_DBG("unique_name: %s", unique_name);
-
-       if (bt_service_conn)
-               conn = dbus_g_connection_get_connection(bt_service_conn);
-
-       retv_if(conn == NULL, FALSE);
 
-       ret_val = cynara_creds_get_default_client_method(&client_creds_method);
-       if (ret_val != CYNARA_API_SUCCESS) {
-               cynara_strerror(ret_val, err_msg, sizeof(err_msg));
-               BT_ERR("Fail to get default client method: %s", err_msg);
-               return FALSE;
-       }
-
-       ret_val = cynara_creds_get_default_user_method(&user_creds_method);
-       if (ret_val != CYNARA_API_SUCCESS) {
-               cynara_strerror(ret_val, err_msg, sizeof(err_msg));
-               BT_ERR("Fail to get default user method: %s", err_msg);
-               return FALSE;
-       }
-
-       ret_val = cynara_creds_dbus_get_client(conn, unique_name, client_creds_method, &client_creds);
-       if (ret_val != CYNARA_API_SUCCESS) {
-               cynara_strerror(ret_val, err_msg, sizeof(err_msg));
-               BT_ERR("Fail to get client credential: %s", err_msg);
-               return FALSE;
-       }
+       len = g_variant_get_size(param);
+       if (len > 0)
+               cookie = (char *)g_variant_get_data(param);
 
-       BT_DBG("client_creds: %s", client_creds);
-
-       ret_val = cynara_creds_dbus_get_user(conn, unique_name, user_creds_method, &user_creds);
-       if (ret_val != CYNARA_API_SUCCESS) {
-               cynara_strerror(ret_val, err_msg, sizeof(err_msg));
-               BT_ERR("Fail to get user credential: %s", err_msg);
-               if (client_creds)
-                       free(client_creds);
-               return FALSE;
-       }
-
-       BT_DBG("user_creds: %s", user_creds);
+       retv_if(cookie == NULL, FALSE);
 
        switch (function_name) {
        case BT_SET_LOCAL_NAME:
@@ -1581,6 +1900,7 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_OOB_REMOVE_REMOTE_DATA:
        case BT_SET_ADVERTISING:
        case BT_SET_CUSTOM_ADVERTISING:
+       case BT_SET_ADVERTISING_PARAMETERS:
        case BT_START_LE_DISCOVERY:
        case BT_STOP_LE_DISCOVERY:
 
@@ -1619,6 +1939,8 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_AV_DISCONNECT:
        case BT_AVRCP_CONTROL_CONNECT:
        case BT_AVRCP_CONTROL_DISCONNECT:
+       case BT_AV_SOURCE_CONNECT:
+       case BT_AV_SOURCE_DISCONNECT:
        case BT_HF_CONNECT:
        case BT_HF_DISCONNECT:
 
@@ -1646,11 +1968,11 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_GATT_SET_PROPERTY_REQUEST:
        case BT_GATT_READ_CHARACTERISTIC:
        case BT_GATT_DISCOVER_CHARACTERISTICS_DESCRIPTOR:
-               ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
-                                                                                BT_PRIVILEGE_PUBLIC);
 
-               if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
-                       BT_ERR("Fail to access: %s", BT_PRIVILEGE_PUBLIC);
+               ret_val = security_server_check_privilege_by_cookie(cookie,
+                                               BT_PRIVILEGE_PUBLIC, "w");
+               if (ret_val == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
+                       BT_ERR("[SMACK] Fail to access: %s", BT_PRIVILEGE_PUBLIC);
                        result = FALSE;
                }
        break;
@@ -1672,9 +1994,27 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_CANCEL_SEARCH_SERVICE:
        case BT_ENABLE_RSSI:
 
+       case BT_HID_DEVICE_ACTIVATE:
+       case BT_HID_DEVICE_DEACTIVATE:
+       case BT_HID_DEVICE_CONNECT:
+       case BT_HID_DEVICE_DISCONNECT:
+       case BT_HID_DEVICE_SEND_MOUSE_EVENT:
+       case BT_HID_DEVICE_SEND_KEY_EVENT:
+       case BT_HID_DEVICE_SEND_REPLY_TO_REPORT:
+
        case BT_RFCOMM_ACCEPT_CONNECTION:
        case BT_RFCOMM_REJECT_CONNECTION:
        case BT_RFCOMM_LISTEN:
+       case BT_RFCOMM_CREATE_SOCKET_EX:
+       case BT_RFCOMM_REMOVE_SOCKET_EX:
+
+       case BT_PBAP_CONNECT:
+       case BT_PBAP_DISCONNECT:
+       case BT_PBAP_GET_PHONEBOOK_SIZE:
+       case BT_PBAP_GET_PHONEBOOK:
+       case BT_PBAP_GET_LIST:
+       case BT_PBAP_PULL_VCARD:
+       case BT_PBAP_PHONEBOOK_SEARCH:
 
        case BT_AVRCP_SET_TRACK_INFO:
        case BT_AVRCP_SET_PROPERTY:
@@ -1688,11 +2028,12 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_BOND_DEVICE_BY_TYPE:
        case BT_SET_LE_PRIVACY:
        case BT_LE_CONN_UPDATE:
-               ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
-                                                                                BT_PRIVILEGE_PLATFORM);
 
-               if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
-                       BT_ERR("Fail to access: %s", BT_PRIVILEGE_PLATFORM);
+               ret_val = security_server_check_privilege_by_cookie(cookie,
+                                               BT_PRIVILEGE_PLATFORM, "w");
+
+               if (ret_val == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
+                       BT_ERR("[SMACK] Fail to access: %s", BT_PRIVILEGE_PLATFORM);
                        result = FALSE;
                }
        break;
@@ -1712,6 +2053,7 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_GET_BONDED_DEVICES:
        case BT_GET_BONDED_DEVICE:
        case BT_IS_DEVICE_CONNECTED:
+       case BT_GET_CONNECTED_LINK_TYPE:
        case BT_GET_SPEAKER_GAIN:
        case BT_SET_SPEAKER_GAIN:
        case BT_OOB_READ_LOCAL_DATA:
@@ -1720,9 +2062,13 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_GET_ADVERTISING_DATA:
        case BT_GET_SCAN_RESPONSE_DATA:
        case BT_IS_ADVERTISING:
+       case BT_REGISTER_SCAN_FILTER:
+       case BT_UNREGISTER_SCAN_FILTER:
+       case BT_UNREGISTER_ALL_SCAN_FILTERS:
 
        case BT_OBEX_SERVER_ALLOCATE:
        case BT_OBEX_SERVER_DEALLOCATE:
+       case BT_OBEX_SERVER_IS_ACTIVATED:
 
                /* Non-privilege control */
                break;
@@ -1732,188 +2078,95 @@ gboolean __bt_service_check_privilege(int function_name,
                break;
        }
 
-       if (client_creds)
-               free(client_creds);
-
-       if (user_creds)
-               free(user_creds);
-
        return result;
 }
 
-gboolean bt_service_request(
-               BtService *service,
-               int service_type,
-               int service_function,
-               int request_type,
-               GArray *in_param1,
-               GArray *in_param2,
-               GArray *in_param3,
-               GArray *in_param4,
-               GArray *in_param5,
-               DBusGMethodInvocation *context)
+GDBusNodeInfo *__bt_service_create_method_node_info
+                                       (const gchar *introspection_data)
 {
-       BT_DBG("+");
-
-       int result;
-       int request_id = -1;
-       GArray *out_param1 = NULL;
-       GArray *out_param2 = NULL;
-       char *sender = NULL;
-
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-       sender = dbus_g_method_get_sender(context);
-
-       if (service_type == BT_CORE_SERVICE) {
-               BT_DBG("No need to check privilege from bt-core");
-       } else if (__bt_service_check_privilege(service_function,
-                               service_type, (const char *)sender) == FALSE) {
-               BT_ERR("Client don't have the privilege to excute this function");
+       GError *err = NULL;
+       GDBusNodeInfo *node_info = NULL;
 
-               result = BLUETOOTH_ERROR_PERMISSION_DEINED;
-               goto fail;
+       if (introspection_data == NULL) {
+               ERR("Introspection XML not present: %s", err->message);
+               return NULL;
        }
 
-       if (request_type == BT_ASYNC_REQ
-            || service_function == BT_OBEX_SERVER_ACCEPT_CONNECTION
-             || service_function == BT_RFCOMM_ACCEPT_CONNECTION) {
-               /* Set the timer */
-               request_id = _bt_assign_request_id();
-               BT_DBG("Request ID: %d", request_id);
+       node_info = g_dbus_node_info_new_for_xml(introspection_data, &err);
 
-               if (request_id < 0) {
-                       BT_ERR("Fail to assign the request id");
-                       result = BLUETOOTH_ERROR_INTERNAL;
-                       goto fail;
-               }
+       if (err) {
+               ERR("Unable to create node: %s", err->message);
+               g_clear_error(&err);
        }
+       return node_info;
+}
 
-       BT_DBG("SERVICE TYPE %d", service_type);
-
-       switch (service_type) {
-       case BT_BLUEZ_SERVICE:
-               result = __bt_bluez_request(service_function, request_type,
-                                       request_id, context, in_param1, in_param2,
-                                       in_param3, in_param4, &out_param1);
-               break;
-       case BT_OBEX_SERVICE:
-               result = __bt_obexd_request(service_function, request_type,
-                                       request_id, context, in_param1,
-                                       in_param2, in_param3,
-                                       in_param4, &out_param1);
-               break;
-       case BT_AGENT_SERVICE:
-               result = __bt_agent_request(service_function, request_type,
-                                       request_id, context, in_param1,
-                                       in_param2, in_param3,
-                                       in_param4, &out_param1);
-               break;
-       case BT_CORE_SERVICE:
-               result = __bt_core_request(service_function, request_type,
-                                       request_id, context, in_param1);
-               break;
-       case BT_CHECK_PRIVILEGE:
-               result = BLUETOOTH_ERROR_NONE;
-               break;
-       default:
-               BT_ERR("Unknown service type");
-               result = BLUETOOTH_ERROR_INTERNAL;
-               goto fail;
-       }
-
-       if (result != BLUETOOTH_ERROR_NONE) {
-               goto fail;
-       }
-
-       g_array_append_vals(out_param2, &result, sizeof(int));
-
-       if ((request_type == BT_ASYNC_REQ ||
-               service_function == BT_OBEX_SERVER_ACCEPT_CONNECTION) &&
-               service_function != BT_OPP_PUSH_FILES) {
-               _bt_insert_request_list(request_id, service_function,
-                                       NULL, context);
+int __bt_service_register_object(GDBusConnection *conn,
+               GDBusNodeInfo *node_info, gboolean reg)
+{
+       static guint service_id = 0;
+       GError *error = NULL;
+
+       if (reg) {
+               if (node_info == NULL)
+                       return -1;
+
+               service_id = g_dbus_connection_register_object(conn,
+                               BT_SERVICE_PATH,
+                               node_info->interfaces[0],
+                               &method_table,
+                               NULL, NULL, &error);
+               if (service_id == 0)
+                       return -1;
        } else {
-               /* Return result */
-               if (service_type == BT_CHECK_PRIVILEGE ||
-                       service_function != BT_OPP_PUSH_FILES)
-                       dbus_g_method_return(context, out_param1, out_param2);
+               if (service_id > 0) {
+                       g_dbus_connection_unregister_object(conn,
+                                       service_id);
+                       service_id = 0;
+               }
        }
 
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
-       g_free(sender);
-
-       return TRUE;
-fail:
-       BT_ERR_C("Request is failed [%s] [%x]", _bt_convert_error_to_string(result), result);
-       g_array_append_vals(out_param2, &result, sizeof(int));
-       dbus_g_method_return(context, out_param1, out_param2);
-
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
-       g_free(sender);
-
-       if (request_type == BT_ASYNC_REQ)
-               _bt_delete_request_id(request_id);
-
-       BT_DBG("-");
-
-       return FALSE;
+       return 0;
 }
 
 int _bt_service_register(void)
 {
-       BtService *bt_service;
-       DBusGConnection *conn;
-       DBusGProxy *proxy;
+       GDBusConnection *conn;
        GError *err = NULL;
-       guint result = 0;
+       int result;
 
-       conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
+       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       proxy = dbus_g_proxy_new_for_name(conn, DBUS_SERVICE_DBUS,
-                               DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
-
-       if (proxy == NULL) {
-               BT_ERR("proxy is NULL");
+       owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
+                               BT_SERVICE_NAME,
+                               G_BUS_NAME_OWNER_FLAGS_NONE,
+                               NULL, NULL, NULL,
+                               NULL, NULL);
+       BT_DBG("owner_id is [%d]", owner_id);
+       if (owner_id == 0)
                goto fail;
-       }
 
-       if (!dbus_g_proxy_call(proxy, "RequestName", &err, G_TYPE_STRING,
-                       BT_SERVICE_NAME, G_TYPE_UINT, 0, G_TYPE_INVALID,
-                       G_TYPE_UINT, &result, G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("RequestName RPC failed[%s]\n", err->message);
-                       g_error_free(err);
-               }
-               g_object_unref(proxy);
+       node_info = __bt_service_create_method_node_info(
+                       bt_service_introspection_xml);
 
+       if (node_info == NULL)
                goto fail;
-       }
 
-       g_object_unref(proxy);
+       result = __bt_service_register_object(conn, node_info, TRUE);
+       g_dbus_node_info_unref(node_info);
+       node_info = NULL;
 
-       if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
-               BT_ERR("Failed to get the primary well-known name.\n");
+       if (result != BLUETOOTH_ERROR_NONE)
                goto fail;
-       }
-
-       bt_service = g_object_new(BT_SERVICE_TYPE, NULL);
-
-       dbus_g_connection_register_g_object(conn, BT_SERVICE_PATH,
-                                       G_OBJECT(bt_service));
 
-       service_object = bt_service;
        bt_service_conn = conn;
 
        return BLUETOOTH_ERROR_NONE;
 
 fail:
        if (bt_service_conn) {
-               dbus_g_connection_unref(bt_service_conn);
+               g_object_unref(bt_service_conn);
                bt_service_conn = NULL;
        }
 
@@ -1923,52 +2176,19 @@ fail:
 void _bt_service_unregister(void)
 {
        if (bt_service_conn) {
-               if (service_object) {
-                       dbus_g_connection_unregister_g_object(bt_service_conn,
-                                               G_OBJECT(service_object));
-                       g_object_unref(service_object);
-                       service_object = NULL;
+               __bt_service_register_object(bt_service_conn, NULL, FALSE);
+               if (bt_service_conn) {
+                       g_object_unref(bt_service_conn);
+                       bt_service_conn = NULL;
+               }
+               if (node_info) {
+                       g_dbus_node_info_unref(node_info);
+                       node_info = NULL;
+               }
+               if (owner_id > 0) {
+                       g_bus_unown_name(owner_id);
+                       owner_id = 0;
                }
-
-               dbus_g_connection_unref(bt_service_conn);
-               bt_service_conn = NULL;
-       }
-}
-
-int _bt_service_cynara_init(void)
-{
-       int result;
-       char err_msg[256] = {0, };
-
-       retv_if(p_cynara != NULL, BLUETOOTH_ERROR_ALREADY_INITIALIZED);
-
-       result = cynara_initialize(&p_cynara, conf);
-
-       if (result != CYNARA_API_SUCCESS) {
-               cynara_strerror(result, err_msg, sizeof(err_msg));
-               BT_ERR("Fail to initialize cynara: [%s]", err_msg);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-void _bt_service_cynara_deinit(void)
-{
-       int result;
-       char err_msg[256] = {0, };
-
-       ret_if(p_cynara == NULL);
-
-       result = cynara_finish(p_cynara);
-
-       if (result != CYNARA_API_SUCCESS) {
-               cynara_strerror(result, err_msg, sizeof(err_msg));
-               BT_ERR("Fail to finish cynara: [%s]", err_msg);
-               return;
        }
-
-       p_cynara = NULL;
-       conf = NULL;
 }
 
index bfc64fa..e13fd20 100644 (file)
  */
 
 #include <stdio.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
+//#include <dbus/dbus-glib.h>
+//#include <dbus/dbus.h>
+#include <gio/gio.h>
 #include <glib.h>
 #include <dlog.h>
 #include <string.h>
 #include <vconf.h>
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
 #include <syspopup_caller.h>
-#endif
 #include <aul.h>
-#include <notification.h>
-#ifdef ENABLE_TIZEN_2_4
 #include <journal/device.h>
-#endif
 
 #include "bt-internal-types.h"
 #include "bt-service-common.h"
@@ -61,9 +57,16 @@ typedef struct {
 
 typedef struct {
        char *sender;
+       int adv_handle;
        gboolean is_advertising;
 } bt_adapter_le_adv_slot_t;
 
+typedef struct {
+       char *sender;
+       GSList *filter_list;
+       gboolean is_scanning;
+} bt_adapter_le_scanner_t;
+
 static bluetooth_advertising_params_t adv_params = {
        BT_DEFAULT_ADV_MIN_INTERVAL,
        BT_DEFAULT_ADV_MAX_INTERVAL,
@@ -77,6 +80,12 @@ static int resp_data_len;
 static bt_adapter_le_feature_info_t le_feature_info = { 1, 0, 0 };
 static bt_adapter_le_adv_slot_t *le_adv_slot = NULL;
 
+GSList *scanner_list = NULL;
+static gboolean is_le_set_scan_parameter = FALSE;
+static gboolean is_le_scanning = FALSE;
+static gboolean scan_filter_enabled = FALSE;
+static bt_le_scan_type_t le_scan_type = BT_LE_PASSIVE_SCAN;
+
 void __bt_free_le_adv_slot(void)
 {
        int i;
@@ -130,12 +139,12 @@ gboolean _bt_update_le_feature_support(const char *item, const char *value)
 static gboolean __bt_is_factory_test_mode(void)
 {
        int mode = 0;
-#ifdef ENABLE_TIZEN_2_4
+
        if (vconf_get_bool(VCONFKEY_BT_DUT_MODE, &mode)) {
                BT_ERR("Get the DUT Mode fail");
                return TRUE;
        }
-#endif
+
        if (mode != FALSE) {
                BT_INFO("DUT Test Mode !!");
                return TRUE;
@@ -144,31 +153,28 @@ static gboolean __bt_is_factory_test_mode(void)
        return FALSE;
 }
 
-int __bt_get_available_adv_slot_id(const char *sender, gboolean use_reserved_slot)
+int __bt_get_available_adv_slot_id(const char *sender, int adv_handle, gboolean use_reserved_slot)
 {
        int i;
 
        if (le_adv_slot == NULL)
                return -1;
 
-       if (use_reserved_slot == TRUE) {
-               if (le_feature_info.adv_inst_max > 1)
-                       return 0;
-               else if (le_adv_slot[0].sender == NULL ||
-                       g_strcmp0(le_adv_slot[0].sender, sender) == 0)
-                       return 0;
-               else
-                       return -1;
-       }
-
        for (i = 0; i < le_feature_info.adv_inst_max; i++) {
                if (le_adv_slot[i].sender == NULL)
                        continue;
-               if (g_strcmp0(le_adv_slot[i].sender, sender) == 0)
+               if ((g_strcmp0(le_adv_slot[i].sender, sender) == 0) && (le_adv_slot[i].adv_handle == adv_handle))
                        return i;
        }
 
-       for (i = 0; i < le_feature_info.adv_inst_max; i++) {
+       if (le_feature_info.adv_inst_max <= 2)
+               i = 0;
+       else if (le_feature_info.adv_inst_max > 2 && use_reserved_slot == TRUE)
+               i = 0;
+       else
+               i = 2;
+
+       for (; i < le_feature_info.adv_inst_max; i++) {
                if (le_adv_slot[i].sender == NULL)
                        return i;
        }
@@ -176,17 +182,19 @@ int __bt_get_available_adv_slot_id(const char *sender, gboolean use_reserved_slo
        return -1;
 }
 
-void __bt_register_adv_slot_owner(const char *sender, int slot_id)
+void __bt_register_adv_slot_owner(const char *sender, int adv_handle, int slot_id)
 {
-       if (le_adv_slot[slot_id].sender == NULL)
+       if (le_adv_slot[slot_id].sender == NULL) {
                le_adv_slot[slot_id].sender = strdup(sender);
+               le_adv_slot[slot_id].adv_handle = adv_handle;
+       }
 }
 
 void __bt_unregister_adv_slot_owner(int slot_id)
 {
        g_free(le_adv_slot[slot_id].sender);
        le_adv_slot[slot_id].sender = NULL;
-       le_adv_slot[slot_id].is_advertising = FALSE;
+       le_adv_slot[slot_id].adv_handle = 0;
 }
 
 const char* _bt_get_adv_slot_owner(int slot_id)
@@ -197,6 +205,14 @@ const char* _bt_get_adv_slot_owner(int slot_id)
        return le_adv_slot[slot_id].sender;
 }
 
+int _bt_get_adv_slot_adv_handle(int slot_id)
+{
+       if (le_adv_slot == NULL)
+               return 0;
+
+       return le_adv_slot[slot_id].adv_handle;
+}
+
 void _bt_set_advertising_status(int slot_id, gboolean mode)
 {
        le_adv_slot[slot_id].is_advertising = mode;
@@ -226,7 +242,7 @@ void _bt_stop_advertising_by_terminated_process(const char* terminated_name)
                if (le_adv_slot[i].sender != NULL) {
                        if (strcasecmp(terminated_name, le_adv_slot[i].sender) == 0) {
                                BT_ERR("Stop advertising by terminated process(%s).", terminated_name);
-                               _bt_set_advertising(FALSE, terminated_name, FALSE);
+                               _bt_set_advertising(terminated_name, le_adv_slot[i].adv_handle, FALSE, FALSE);
                        }
                }
        }
@@ -242,10 +258,11 @@ gboolean _bt_get_advertising_params(bluetooth_advertising_params_t *params)
        return TRUE;
 }
 
-int _bt_set_advertising(gboolean enable, const char *sender, gboolean use_reserved_slot)
+int _bt_set_advertising(const char *sender, int adv_handle, gboolean enable, gboolean use_reserved_slot)
 {
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        GError *error = NULL;
+       GVariant *ret;
        int slot_id;
 
        if (__bt_is_factory_test_mode()) {
@@ -258,7 +275,7 @@ int _bt_set_advertising(gboolean enable, const char *sender, gboolean use_reserv
                return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
        }
 
-       slot_id = __bt_get_available_adv_slot_id(sender, use_reserved_slot);
+       slot_id = __bt_get_available_adv_slot_id(sender, adv_handle, use_reserved_slot);
        if (slot_id == -1) {
                BT_ERR("There is NO available slot!!");
                return BLUETOOTH_ERROR_NO_RESOURCES;
@@ -267,39 +284,42 @@ int _bt_set_advertising(gboolean enable, const char *sender, gboolean use_reserv
        if (le_adv_slot[slot_id].is_advertising == TRUE && enable == TRUE)
                return BLUETOOTH_ERROR_IN_PROGRESS;
 
-       if (le_adv_slot[slot_id].is_advertising == FALSE && enable == FALSE)
+       if (le_adv_slot[slot_id].sender != NULL && le_adv_slot[slot_id].is_advertising == FALSE && enable == FALSE)
                return BLUETOOTH_ERROR_NOT_IN_OPERATION;
 
        proxy = _bt_get_adapter_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call(proxy, "SetAdvertising", &error,
-                       G_TYPE_BOOLEAN, enable,
-                       G_TYPE_INT, slot_id,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
+       ret = g_dbus_proxy_call_sync(proxy, "SetAdvertising",
+                               g_variant_new("(bi)", enable, slot_id),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
 
        if (error) {
                BT_ERR("SetAdvertising Fail: %s", error->message);
-               g_error_free(error);
+               g_clear_error(&error);
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       le_adv_slot[slot_id].is_advertising = enable;
-
        if (enable == TRUE)
-               __bt_register_adv_slot_owner(sender, slot_id);
-       else
-               __bt_unregister_adv_slot_owner(slot_id);
+               __bt_register_adv_slot_owner(sender, adv_handle, slot_id);
 
+       le_adv_slot[slot_id].is_advertising = enable;
        BT_INFO("Set advertising [%d]", enable);
 
+       if (ret)
+               g_variant_unref(ret);
+
        return BLUETOOTH_ERROR_NONE;
 }
 
-int _bt_set_custom_advertising(gboolean enable, bluetooth_advertising_params_t *params,
-                               const char *sender, gboolean use_reserved_slot)
+int _bt_set_custom_advertising(const char *sender, int adv_handle,
+                               gboolean enable, bluetooth_advertising_params_t *params, gboolean use_reserved_slot)
 {
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
+       GVariant *ret;
        GError *error = NULL;
        guint32 min = 0;
        guint32 max = 0;
@@ -317,10 +337,16 @@ int _bt_set_custom_advertising(gboolean enable, bluetooth_advertising_params_t *
                return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
        }
 
+       slot_id = __bt_get_available_adv_slot_id(sender, adv_handle, use_reserved_slot);
+       if (slot_id == -1) {
+               BT_ERR("There is NO available slot!!");
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+       }
+
        if (le_adv_slot[slot_id].is_advertising == TRUE && enable == TRUE)
                return BLUETOOTH_ERROR_IN_PROGRESS;
 
-       if (le_adv_slot[slot_id].is_advertising == FALSE && enable == FALSE)
+       if (le_adv_slot[slot_id].sender != NULL && le_adv_slot[slot_id].is_advertising == FALSE && enable == FALSE)
                return BLUETOOTH_ERROR_NOT_IN_OPERATION;
 
        proxy = _bt_get_adapter_proxy();
@@ -342,23 +368,15 @@ int _bt_set_custom_advertising(gboolean enable, bluetooth_advertising_params_t *
        min = params->interval_min / BT_ADV_INTERVAL_SPLIT;
        max = params->interval_max / BT_ADV_INTERVAL_SPLIT;
 
-       slot_id = __bt_get_available_adv_slot_id(sender, use_reserved_slot);
-       if (slot_id == -1) {
-               BT_ERR("There is NO available slot!!");
-               return BLUETOOTH_ERROR_NO_RESOURCES;
-       }
-
-       dbus_g_proxy_call(proxy, "SetAdvertisingParameters", &error,
-                       G_TYPE_UINT, min,
-                       G_TYPE_UINT, max,
-                       G_TYPE_UINT, params->filter_policy,
-                       G_TYPE_UINT, params->type,
-                       G_TYPE_INT, slot_id,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
+       ret = g_dbus_proxy_call_sync(proxy, "SetAdvertisingParameters",
+                       g_variant_new("(uuuui)", min, max, 
+                       params->filter_policy, params->type,
+                       slot_id), G_DBUS_CALL_FLAGS_NONE,
+                       -1, NULL, &error);
 
        if (error) {
                BT_ERR("SetAdvertisingParameters Fail: %s", error->message);
-               g_error_free(error);
+               g_clear_error(&error);
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
@@ -367,25 +385,32 @@ int _bt_set_custom_advertising(gboolean enable, bluetooth_advertising_params_t *
        adv_params.filter_policy = params->filter_policy;
        adv_params.type= params->type;
 
-       dbus_g_proxy_call(proxy, "SetAdvertising", &error,
-                       G_TYPE_BOOLEAN, enable,
-                       G_TYPE_INT, slot_id,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
+       if (ret)
+               g_variant_unref(ret);
+
+       ret = g_dbus_proxy_call_sync(proxy, "SetAdvertising",
+                               g_variant_new("(bi)", enable, slot_id),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
 
        if (error) {
                BT_ERR("SetAdvertising Fail: %s", error->message);
-               g_error_free(error);
+               g_clear_error(&error);
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       le_adv_slot[slot_id].is_advertising = enable;
-
        if (enable == TRUE)
-               __bt_register_adv_slot_owner(sender, slot_id);
+               __bt_register_adv_slot_owner(sender, adv_handle, slot_id);
        else
                __bt_unregister_adv_slot_owner(slot_id);
 
+       le_adv_slot[slot_id].is_advertising = enable;
        BT_INFO_C("Set advertising [%d]", enable);
+       if (ret)
+               g_variant_unref(ret);
+
        return BLUETOOTH_ERROR_NONE;
 }
 
@@ -449,12 +474,14 @@ int _bt_get_advertising_data(bluetooth_advertising_data_t *adv, int *length)
        return BLUETOOTH_ERROR_NONE;
 }
 
-int _bt_set_advertising_data(bluetooth_advertising_data_t *adv, int length,
-                               const char *sender, gboolean use_reserved_slot)
+int _bt_set_advertising_data(const char *sender, int adv_handle,
+                               bluetooth_advertising_data_t *adv, int length, gboolean use_reserved_slot)
 {
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        GError *error = NULL;
-       GArray *arr;
+       GVariant *ret, *ad_data, *param = NULL;
+       GVariant *temp = NULL;
+       GVariantBuilder *builder;
        int i;
        char *old_mdata = NULL;
        char *new_mdata = NULL;
@@ -477,31 +504,31 @@ int _bt_set_advertising_data(bluetooth_advertising_data_t *adv, int length,
        proxy = _bt_get_adapter_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       arr = g_array_new(TRUE, TRUE, sizeof(guint8));
-
-       for (i = 0; i < length; i++)
-               g_array_append_vals(arr, &(adv->data[i]), sizeof(guint8));
-
-       slot_id = __bt_get_available_adv_slot_id(sender, use_reserved_slot);
+       slot_id = __bt_get_available_adv_slot_id(sender, adv_handle, use_reserved_slot);
        if (slot_id == -1) {
                BT_ERR("There is NO available slot!!");
                return BLUETOOTH_ERROR_NO_RESOURCES;
        }
 
-       dbus_g_proxy_call(proxy, "SetAdvertisingData", &error,
-                       DBUS_TYPE_G_UCHAR_ARRAY, arr,
-                       G_TYPE_INT, slot_id,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
+       builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
+       for (i = 0; i < length; i++) {
+               g_variant_builder_add(builder, "y", adv->data[i]);
+       }
 
-       g_array_free(arr, TRUE);
+       temp = g_variant_new("ay", builder);
+       g_variant_builder_unref(builder);
+       ret = g_dbus_proxy_call_sync(proxy, "SetAdvertisingData",
+                               g_variant_new("(@ayi)", temp, slot_id),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1, NULL, &error);
 
        if (error) {
                BT_ERR("SetAdvertisingData Fail: %s", error->message);
-               g_error_free(error);
+               g_clear_error(&error);
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       __bt_register_adv_slot_owner(sender, slot_id);
+       __bt_register_adv_slot_owner(sender, adv_handle, slot_id);
 
        __bt_get_ad_data_by_type((char *)adv_data.data, adv_data_len, 0xff,
                        &old_mdata, &old_len);
@@ -510,11 +537,12 @@ int _bt_set_advertising_data(bluetooth_advertising_data_t *adv, int length,
        if (old_len != new_len ||
                        (old_mdata && new_mdata &&
                         memcmp(old_mdata, new_mdata, new_len))) {
+              ad_data = g_variant_new_from_data((const GVariantType *)"ay",
+                                            new_mdata, new_len, TRUE, NULL, NULL);
+               param = g_variant_new("(@ay)", ad_data);
                _bt_send_event(BT_ADAPTER_EVENT,
                                BLUETOOTH_EVENT_ADVERTISING_MANUFACTURER_DATA_CHANGED,
-                               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                               &new_mdata, new_len,
-                               DBUS_TYPE_INVALID);
+                               param);
        }
        g_free(new_mdata);
        g_free(old_mdata);
@@ -524,6 +552,8 @@ int _bt_set_advertising_data(bluetooth_advertising_data_t *adv, int length,
        adv_data_len = length;
 
        BT_INFO("Set advertising data");
+       if (ret)
+               g_variant_unref(ret);
 
        return BLUETOOTH_ERROR_NONE;
 }
@@ -539,12 +569,14 @@ int _bt_get_scan_response_data(bluetooth_scan_resp_data_t *response, int *length
        return BLUETOOTH_ERROR_NONE;
 }
 
-int _bt_set_scan_response_data(bluetooth_scan_resp_data_t *response, int length,
-                               const char *sender, gboolean use_reserved_slot)
+int _bt_set_scan_response_data(const char *sender, int adv_handle,
+                               bluetooth_scan_resp_data_t *response, int length, gboolean use_reserved_slot)
 {
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        GError *error = NULL;
-       GArray *arr;
+       GVariant *ret, *scan_data,  *param = NULL;
+       GVariant *temp = NULL;
+       GVariantBuilder *builder;
        int i;
        char *old_mdata = NULL;
        char *new_mdata = NULL;
@@ -567,31 +599,30 @@ int _bt_set_scan_response_data(bluetooth_scan_resp_data_t *response, int length,
        proxy = _bt_get_adapter_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       arr = g_array_new(TRUE, TRUE, sizeof(guint8));
-
-       for (i = 0; i < length; i++)
-               g_array_append_vals(arr, &(response->data[i]), sizeof(guint8));
-
-       slot_id = __bt_get_available_adv_slot_id(sender, use_reserved_slot);
+       slot_id = __bt_get_available_adv_slot_id(sender, adv_handle, use_reserved_slot);
        if (slot_id == -1) {
                BT_ERR("There is NO available slot!!");
                return BLUETOOTH_ERROR_NO_RESOURCES;
        }
+       builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
+       for (i = 0; i < length; i++) {
+               g_variant_builder_add(builder, "y", response->data[i]);
+       }
 
-       dbus_g_proxy_call(proxy, "SetScanRespData", &error,
-                       DBUS_TYPE_G_UCHAR_ARRAY, arr,
-                       G_TYPE_INT, slot_id,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
-
-       g_array_free(arr, TRUE);
+       temp = g_variant_new("ay", builder);
+       g_variant_builder_unref(builder);
+       ret = g_dbus_proxy_call_sync(proxy, "SetScanRespData",
+                               g_variant_new("(@ayi)", temp, slot_id),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1, NULL, &error);
 
        if (error) {
                BT_ERR("SetScanRespData Fail: %s", error->message);
-               g_error_free(error);
+               g_clear_error(&error);
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       __bt_register_adv_slot_owner(sender, slot_id);
+       __bt_register_adv_slot_owner(sender, adv_handle, slot_id);
 
        /* Compare with previous scan resp data */
        __bt_get_ad_data_by_type((char *)resp_data.data, resp_data_len, 0xff,
@@ -601,11 +632,12 @@ int _bt_set_scan_response_data(bluetooth_scan_resp_data_t *response, int length,
        if (old_len != new_len ||
                        (old_mdata && new_mdata &&
                         memcmp(old_mdata, new_mdata, new_len))) {
+               scan_data = g_variant_new_from_data((const GVariantType *)"ay",
+                                            new_mdata, new_len, TRUE, NULL, NULL);
+               param = g_variant_new("(@ay)", scan_data);
                _bt_send_event(BT_ADAPTER_EVENT,
                                BLUETOOTH_EVENT_SCAN_RESPONSE_MANUFACTURER_DATA_CHANGED,
-                               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                               &new_mdata, new_len,
-                               DBUS_TYPE_INVALID);
+                               param);
        }
        g_free(new_mdata);
        g_free(old_mdata);
@@ -614,14 +646,17 @@ int _bt_set_scan_response_data(bluetooth_scan_resp_data_t *response, int length,
        memcpy(&resp_data, response, length);
        resp_data_len = length;
 
+       if (ret)
+               g_variant_unref(ret);
        BT_INFO("Set scan response data");
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_set_scan_parameters(bluetooth_le_scan_params_t *params)
 {
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        GError *error = NULL;
+       GVariant *ret;
        guint32 itv = 0;
        guint32 win = 0;
 
@@ -647,29 +682,1016 @@ int _bt_set_scan_parameters(bluetooth_le_scan_params_t *params)
        itv = params->interval / BT_ADV_INTERVAL_SPLIT;
        win = params->window / BT_ADV_INTERVAL_SPLIT;
 
-       dbus_g_proxy_call(proxy, "SetScanParameters", &error,
-                       G_TYPE_UINT, params->type,
-                       G_TYPE_UINT, itv,
-                       G_TYPE_UINT, win,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
+       ret = g_dbus_proxy_call_sync(proxy, "SetScanParameters",
+                       g_variant_new("(uuu)", params->type, itv, win),
+                       G_DBUS_CALL_FLAGS_NONE, -1,
+                       NULL, &error);
 
        if (error) {
                BT_ERR("SetScanParameters Fail: %s", error->message);
-               g_error_free(error);
+               g_clear_error(&error);
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       _bt_set_le_discovery_type(params->type);
+       _bt_set_le_scan_type(params->type);
+
+       is_le_set_scan_parameter = TRUE;
 
+       if (ret)
+               g_variant_unref(ret);
        BT_INFO("Set scan parameters");
        return BLUETOOTH_ERROR_NONE;
 }
 
+bt_adapter_le_scanner_t* __bt_find_scanner_from_list(const char *sender)
+{
+       GSList *l;
+       bt_adapter_le_scanner_t *scanner;
+
+       for (l = scanner_list; l != NULL; l = g_slist_next(l)) {
+               scanner = l->data;
+               if (g_strcmp0(scanner->sender, sender) == 0)
+                       return scanner;
+       }
+
+       return NULL;
+}
+
+int __bt_get_available_scan_filter_slot_id(void)
+{
+       GSList *l;
+       bt_adapter_le_scanner_t *scanner;
+       GSList *fl;
+       bluetooth_le_scan_filter_t *filter_data;
+       gboolean *slot_check_list;
+       int i;
+
+       if (le_feature_info.max_filter == 0) {
+               BT_ERR("Scan filter is NOT Supported");
+               return -1;
+       }
+       slot_check_list = g_malloc0(sizeof(gboolean) * le_feature_info.max_filter);
+
+       for (l = scanner_list; l != NULL; l = g_slist_next(l)) {
+               scanner = l->data;
+               for (fl = scanner->filter_list; fl != NULL; fl = g_slist_next(fl)) {
+                       filter_data = fl->data;
+                       if (filter_data->slot_id < le_feature_info.max_filter) {
+                               slot_check_list[filter_data->slot_id] = TRUE;
+                       }
+               }
+       }
+
+       for (i = 0; i < le_feature_info.max_filter; i++) {
+               if (slot_check_list[i] == FALSE) {
+                       g_free(slot_check_list);
+                       return i;
+               }
+       }
+
+       BT_ERR("There is NO available slot for scan filter.");
+       g_free(slot_check_list);
+       return -1;
+}
+
+int _bt_register_scan_filter(const char *sender, bluetooth_le_scan_filter_t *filter, int *slot_id)
+{
+       GDBusProxy *proxy;
+       GError *error = NULL;
+       GVariant *ret, *param;
+       GVariant *arr_uuid_param, *arr_uuid_mask_param;
+       GVariant *arr_data_param, *arr_data_mask_param;
+       GArray *arr_uuid;
+       GArray *arr_uuid_mask;
+       GArray *arr_data;
+       GArray *arr_data_mask;
+       bt_adapter_le_scanner_t *scanner = NULL;
+       bluetooth_le_scan_filter_t *filter_data = NULL;
+       int feature_selection = 0;
+
+       *slot_id = __bt_get_available_scan_filter_slot_id();
+       if (*slot_id == -1)
+               return BLUETOOTH_ERROR_NO_RESOURCES;
+
+       proxy = _bt_get_adapter_proxy();
+       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       arr_uuid = g_array_new(TRUE, TRUE, sizeof(guint8));
+       arr_uuid_mask = g_array_new(TRUE, TRUE, sizeof(guint8));
+       arr_data = g_array_new(TRUE, TRUE, sizeof(guint8));
+       arr_data_mask = g_array_new(TRUE, TRUE, sizeof(guint8));
+
+       arr_uuid_param = g_variant_new_from_data((const GVariantType *)"ay",
+                                            arr_uuid, filter->service_uuid.data_len * sizeof(guint8), TRUE, NULL, NULL);
+       arr_uuid_mask_param = g_variant_new_from_data((const GVariantType *)"ay",
+                                            arr_uuid_mask, filter->service_uuid_mask.data_len * sizeof(guint8), TRUE, NULL, NULL);
+       arr_data_param = g_variant_new_from_data((const GVariantType *)"ay",
+                                            arr_data, filter->service_data.data_len * sizeof(guint8), TRUE, NULL, NULL);
+       arr_data_mask_param = g_variant_new_from_data((const GVariantType *)"ay",
+                                            arr_data_mask, filter->service_data_mask.data_len * sizeof(guint8), TRUE, NULL, NULL);
+
+       if (filter->added_features & BLUETOOTH_LE_SCAN_FILTER_FEATURE_DEVICE_ADDRESS) {
+               char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+               feature_selection |= BLUETOOTH_LE_SCAN_FILTER_FEATURE_DEVICE_ADDRESS;
+
+               _bt_convert_addr_type_to_string(address, filter->device_address.addr);
+
+               param = g_variant_new("(iiiiii@ay@aysu@ay@ay)",
+                                       0,      // client_if
+                                       0,      // action (Add - 0x00, Delete - 0x01, Clear - 0x02)
+                                       BLUETOOTH_LE_SCAN_FILTER_FEATURE_DEVICE_ADDRESS,        // filter_type
+                                       slot_id,        // filter_index
+                                       0,      // company_id
+                                       0,      // company_id_mask
+                                       arr_uuid_param, // p_uuid
+                                       arr_uuid_mask_param,    // p_uuid_mask
+                                       address,        // string
+                                       0,      // address_type
+                                       arr_data_param, // p_data
+                                       arr_data_mask_param);   // p_mask
+
+               ret = g_dbus_proxy_call_sync(proxy, "scan_filter_add_remove",
+                                                       param, G_DBUS_CALL_FLAGS_NONE,
+                                                       -1, NULL, &error);
+
+               if (error) {
+                       BT_ERR("scan_filter_add_remove Fail: %s", error->message);
+                       g_clear_error(&error);
+               }
+               if (ret)
+                       g_variant_unref(ret);
+       }
+
+       if (filter->added_features & BLUETOOTH_LE_SCAN_FILTER_FEATURE_DEVICE_NAME) {
+               feature_selection |= BLUETOOTH_LE_SCAN_FILTER_FEATURE_DEVICE_NAME;
+
+               param = g_variant_new("(iiiiii@ay@aysu@ay@ay)",
+                                       0,      // client_if
+                                       0,      // action (Add - 0x00, Delete - 0x01, Clear - 0x02)
+                                       BLUETOOTH_LE_SCAN_FILTER_FEATURE_DEVICE_NAME,   // filter_type
+                                       slot_id,        // filter_index
+                                       0,      // company_id
+                                       0,      // company_id_mask
+                                       arr_uuid_param, // p_uuid
+                                       arr_uuid_mask_param,    // p_uuid_mask
+                                       filter->device_name,    // string
+                                       0,      // address_type
+                                       arr_data_param, // p_data
+                                       arr_data_mask_param);
+
+               ret = g_dbus_proxy_call_sync(proxy, "scan_filter_add_remove",
+                                               param, G_DBUS_CALL_FLAGS_NONE,
+                                               -1, NULL, &error);
+
+               if (error) {
+                       BT_ERR("scan_filter_add_remove Fail: %s", error->message);
+                       g_clear_error(&error);
+               }
+               if (ret)
+                       g_variant_unref(ret);
+       }
+
+       if (filter->added_features & BLUETOOTH_LE_SCAN_FILTER_FEATURE_SERVICE_UUID) {
+               feature_selection |= BLUETOOTH_LE_SCAN_FILTER_FEATURE_SERVICE_UUID;
+
+               g_array_append_vals(arr_uuid, filter->service_uuid.data.data, filter->service_uuid.data_len * sizeof(guint8));
+               g_array_append_vals(arr_uuid_mask, filter->service_uuid_mask.data.data, filter->service_uuid_mask.data_len * sizeof(guint8));
+
+               arr_uuid_param = g_variant_new_from_data((const GVariantType *)"ay",
+                                            arr_uuid, filter->service_uuid.data_len * sizeof(guint8), TRUE, NULL, NULL);
+               arr_uuid_mask_param = g_variant_new_from_data((const GVariantType *)"ay",
+                                            arr_uuid, filter->service_uuid_mask.data_len * sizeof(guint8), TRUE, NULL, NULL);
+
+               param = g_variant_new("(iiiiii@ay@aysu@ay@ay)",
+                                       0,      // client_if
+                                       0,      // action (Add - 0x00, Delete - 0x01, Clear - 0x02)
+                                       BLUETOOTH_LE_SCAN_FILTER_FEATURE_SERVICE_UUID,  // filter_type
+                                       slot_id,        // filter_index
+                                       0,      // company_id
+                                       0,      // company_id_mask
+                                       arr_uuid_param, // p_uuid
+                                       arr_uuid_mask_param,    // p_uuid_mask
+                                       NULL,   // string
+                                       0,      // address_type
+                                       arr_data_param, // p_data
+                                       arr_data_mask_param);
+
+               ret = g_dbus_proxy_call_sync(proxy, "scan_filter_add_remove",
+                                               param, G_DBUS_CALL_FLAGS_NONE,
+                                               -1, NULL, &error);
+
+               if (error) {
+                       BT_ERR("scan_filter_add_remove Fail: %s", error->message);
+                       g_clear_error(&error);
+               }
+               if (ret)
+                       g_variant_unref(ret);
+       }
+
+       if (filter->added_features & BLUETOOTH_LE_SCAN_FILTER_FEATURE_SERVICE_SOLICITATION_UUID) {
+               feature_selection |= BLUETOOTH_LE_SCAN_FILTER_FEATURE_SERVICE_SOLICITATION_UUID;
+
+               g_array_append_vals(arr_uuid, filter->service_solicitation_uuid.data.data, filter->service_solicitation_uuid.data_len * sizeof(guint8));
+               g_array_append_vals(arr_uuid_mask, filter->service_solicitation_uuid_mask.data.data, filter->service_solicitation_uuid_mask.data_len * sizeof(guint8));
+
+               arr_uuid_param = g_variant_new_from_data((const GVariantType *)"ay",
+                                            arr_uuid, filter->service_solicitation_uuid.data_len * sizeof(guint8), TRUE, NULL, NULL);
+               arr_uuid_mask_param = g_variant_new_from_data((const GVariantType *)"ay",
+                                            arr_uuid, filter->service_solicitation_uuid_mask.data_len * sizeof(guint8), TRUE, NULL, NULL);
+
+               param = g_variant_new("(iiiiii@ay@aysu@ay@ay)",
+                                       0,      // client_if
+                                       0,      // action (Add - 0x00, Delete - 0x01, Clear - 0x02)
+                                       BLUETOOTH_LE_SCAN_FILTER_FEATURE_SERVICE_SOLICITATION_UUID,     // filter_type
+                                       slot_id,        // filter_index
+                                       0,      // company_id
+                                       0,      // company_id_mask
+                                       arr_uuid_param, // p_uuid
+                                       arr_uuid_mask_param,    // p_uuid_mask
+                                       NULL,   // string
+                                       0,      // address_type
+                                       arr_data_param, // p_data
+                                       arr_data_mask_param);
+
+               ret = g_dbus_proxy_call_sync(proxy, "scan_filter_add_remove", param,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1, NULL, &error);
+
+               if (error) {
+                       BT_ERR("scan_filter_add_remove Fail: %s", error->message);
+                       g_clear_error(&error);
+               }
+               if (ret)
+                       g_variant_unref(ret);
+       }
+
+       if (filter->added_features & BLUETOOTH_LE_SCAN_FILTER_FEATURE_SERVICE_DATA) {
+               feature_selection |= BLUETOOTH_LE_SCAN_FILTER_FEATURE_SERVICE_DATA;
+
+               g_array_append_vals(arr_data, filter->service_data.data.data, filter->service_data.data_len * sizeof(guint8));
+               g_array_append_vals(arr_data_mask, filter->service_data_mask.data.data, filter->service_data_mask.data_len * sizeof(guint8));
+
+               arr_data_param = g_variant_new_from_data((const GVariantType *)"ay",
+                                            arr_uuid, filter->service_data.data_len * sizeof(guint8), TRUE, NULL, NULL);
+               arr_data_mask_param = g_variant_new_from_data((const GVariantType *)"ay",
+                                            arr_uuid, filter->service_data_mask.data_len * sizeof(guint8), TRUE, NULL, NULL);
+
+               param = g_variant_new("(iiiiii@ay@aysu@ay@ay)",
+                                       0,      // client_if
+                                       0,      // action (Add - 0x00, Delete - 0x01, Clear - 0x02)
+                                       BLUETOOTH_LE_SCAN_FILTER_FEATURE_SERVICE_DATA,  // filter_type
+                                       slot_id,        // filter_index
+                                       0,      // company_id
+                                       0,      // company_id_mask
+                                       arr_uuid_param, // p_uuid
+                                       arr_uuid_mask_param,    // p_uuid_mask
+                                       NULL,   // string
+                                       0,      // address_type
+                                       arr_data_param, // p_data
+                                       arr_data_mask_param);
+
+               ret = g_dbus_proxy_call_sync(proxy, "scan_filter_add_remove", param,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1, NULL, &error);
+
+               if (error) {
+                       BT_ERR("scan_filter_add_remove Fail: %s", error->message);
+                       g_clear_error(&error);
+               }
+               if (ret)
+                       g_variant_unref(ret);
+       }
+
+       if (filter->added_features & BLUETOOTH_LE_SCAN_FILTER_FEATURE_MANUFACTURER_DATA) {
+               feature_selection |= BLUETOOTH_LE_SCAN_FILTER_FEATURE_MANUFACTURER_DATA;
+
+               g_array_append_vals(arr_data, filter->manufacturer_data.data.data, filter->manufacturer_data.data_len * sizeof(guint8));
+               g_array_append_vals(arr_data_mask, filter->manufacturer_data_mask.data.data, filter->manufacturer_data_mask.data_len * sizeof(guint8));
+
+               arr_data_param = g_variant_new_from_data((const GVariantType *)"ay",
+                                            arr_uuid, filter->manufacturer_data.data_len * sizeof(guint8), TRUE, NULL, NULL);
+               arr_data_mask_param = g_variant_new_from_data((const GVariantType *)"ay",
+                                            arr_uuid, filter->manufacturer_data_mask.data_len * sizeof(guint8), TRUE, NULL, NULL);
+
+               param = g_variant_new("(iiiiii@ay@aysu@ay@ay)",
+                                       0,      // client_if
+                                       0,      // action (Add - 0x00, Delete - 0x01, Clear - 0x02)
+                                       BLUETOOTH_LE_SCAN_FILTER_FEATURE_MANUFACTURER_DATA,     // filter_type
+                                       slot_id,        // filter_index
+                                       filter->manufacturer_id,        // company_id
+                                       0xFFFF, // company_id_mask
+                                       arr_uuid_param, // p_uuid
+                                       arr_uuid_mask_param,    // p_uuid_mask
+                                       NULL,   // string
+                                       0,      // address_type
+                                       arr_data_param, // p_data
+                                       arr_data_mask_param);
+
+               ret = g_dbus_proxy_call_sync(proxy, "scan_filter_add_remove", param,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1, NULL, &error);
+
+               if (error) {
+                       BT_ERR("scan_filter_add_remove Fail: %s", error->message);
+                       g_clear_error(&error);
+               }
+               if (ret)
+                       g_variant_unref(ret);
+       }
+
+       g_array_free(arr_uuid, TRUE);
+       g_array_free(arr_uuid_mask, TRUE);
+       g_array_free(arr_data, TRUE);
+       g_array_free(arr_data_mask, TRUE);
+
+       BT_DBG("Filter selection %.2x", feature_selection);
+
+       param = g_variant_new("(iiiiiiiiiiii)",
+                               0,      // client_if
+                               0,      // action (Add - 0x00, Delete - 0x01, Clear - 0x02)
+                               slot_id,        // filter_index
+                               feature_selection,      // feat_seln
+                               0,      // list_logic_type (OR - 0x00, AND - 0x01)
+                               1,      // filt_logic_type (OR - 0x00, AND - 0x01)
+                               -127,   // rssi_high_thres
+                               -127,   // rssi_low_thres
+                               0,      // dely_mode (Immediate - 0x00, on found - 0x01, batched - 0x02)
+                               0,      // found_timeout
+                               0,      // lost_timeout
+                               0);     // found_timeout_cnt
+       ret = g_dbus_proxy_call_sync(proxy, "scan_filter_param_setup",
+                               param, G_DBUS_CALL_FLAGS_NONE,
+                               -1, NULL, &error);
+
+       if (error) {
+               BT_ERR("scan_filter_add_remove Fail: %s", error->message);
+               g_clear_error(&error);
+       }
+
+       scanner = __bt_find_scanner_from_list(sender);
+       if (scanner == NULL) {
+               scanner = g_malloc0(sizeof(bt_adapter_le_scanner_t));
+               scanner->sender = strdup(sender);
+               scanner_list = g_slist_append(scanner_list, scanner);
+       }
+
+       filter_data = g_malloc0(sizeof(bluetooth_le_scan_filter_t));
+       memcpy(filter_data, filter, sizeof(bluetooth_le_scan_filter_t));
+       filter_data->slot_id = *slot_id;
+
+       scanner->filter_list = g_slist_append(scanner->filter_list, filter_data);
+
+       if (ret)
+               g_variant_unref(ret);
+       return BLUETOOTH_ERROR_NONE;
+}
+
+int _bt_unregister_scan_filter(const char *sender, int slot_id)
+{
+       GDBusProxy *proxy;
+       GError *error = NULL;
+       GVariant *ret;
+       bt_adapter_le_scanner_t *scanner = NULL;
+       bluetooth_le_scan_filter_t *filter_data = NULL;
+       GSList *l;
+       gboolean is_slot_id_found = FALSE;
+
+       scanner = __bt_find_scanner_from_list(sender);
+       if (scanner == NULL) {
+               BT_ERR("There is NO available scanner.");
+               return BLUETOOTH_ERROR_NOT_FOUND;
+       }
+
+       for (l = scanner->filter_list; l != NULL; l = g_slist_next(l)) {
+               filter_data = l->data;
+               if (filter_data->slot_id == slot_id) {
+                       is_slot_id_found = TRUE;
+                       break;
+               }
+       }
+       if (is_slot_id_found == FALSE) {
+               BT_ERR("There is NO registered slot.");
+               return BLUETOOTH_ERROR_NOT_FOUND;
+       }
+
+       proxy = _bt_get_adapter_proxy();
+       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       ret = g_dbus_proxy_call_sync(proxy, "scan_filter_clear",
+                               g_variant_new("(ii)", 0, slot_id),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1, NULL, &error);
+
+       if (error) {
+               BT_ERR("scan_filter_clear Fail: %s", error->message);
+               g_clear_error(&error);
+       }
+
+       scanner->filter_list = g_slist_remove(scanner->filter_list, filter_data);
+       g_free(filter_data);
+
+       if (ret)
+               g_variant_unref(ret);
+       return BLUETOOTH_ERROR_NONE;
+}
+
+int _bt_unregister_all_scan_filters(const char *sender)
+{
+       GDBusProxy *proxy;
+       GError *error = NULL;
+       GVariant *ret;
+       bt_adapter_le_scanner_t *scanner = NULL;
+       bluetooth_le_scan_filter_t *filter_data = NULL;
+       GSList *l;
+
+       scanner = __bt_find_scanner_from_list(sender);
+       if (scanner == NULL) {
+               BT_ERR("There is NO available scanner.");
+               return BLUETOOTH_ERROR_NOT_FOUND;
+       }
+
+       proxy = _bt_get_adapter_proxy();
+       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       for (l = scanner->filter_list; l != NULL; l = g_slist_next(l)) {
+               filter_data = l->data;
+
+               ret = g_dbus_proxy_call_sync(proxy, "scan_filter_clear",
+                                       g_variant_new("(ii)", 0, filter_data->slot_id),
+                                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+               if (error) {
+                       BT_ERR("scan_filter_clear Fail: %s", error->message);
+                       g_clear_error(&error);
+               }
+               if (ret)
+                       g_variant_unref(ret);
+       }
+
+       g_slist_free_full(scanner->filter_list, g_free);
+       scanner->filter_list = NULL;
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+int _bt_start_le_scan(const char *sender)
+{
+       GDBusProxy *proxy;
+       GError *error = NULL;
+       GVariant *ret;
+       bt_adapter_le_scanner_t *scanner = __bt_find_scanner_from_list(sender);
+
+       if (scanner == NULL) {
+               scanner = g_malloc0(sizeof(bt_adapter_le_scanner_t));
+               scanner->sender = strdup(sender);
+               scanner_list = g_slist_append(scanner_list, scanner);
+       }
+
+       if (scanner->is_scanning == TRUE) {
+               BT_ERR("BT is already in LE scanning");
+               return BLUETOOTH_ERROR_IN_PROGRESS;
+       }
+       scanner->is_scanning = TRUE;
+
+       proxy = _bt_get_adapter_proxy();
+       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       if (_bt_is_le_scanning()) {
+               if (scan_filter_enabled == TRUE) {
+                       if (scanner->filter_list == NULL) {
+                               ret = g_dbus_proxy_call_sync(proxy, "scan_filter_enable",
+                                               g_variant_new("(ib)", 0, FALSE),
+                                               G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+                               if (error) {
+                                       BT_ERR("scan_filter_clear Fail: %s", error->message);
+                                       g_clear_error(&error);
+                               }
+
+                               if (ret)
+                                       g_variant_unref(ret);
+                               BT_INFO("Disable LE Scan Filter");
+                               scan_filter_enabled = FALSE;
+                       } else {
+                               BT_INFO("LE Filter Scan is continue");
+                       }
+               } else {
+                       BT_INFO("LE Full Scan is already on progress");
+               }
+               return BLUETOOTH_ERROR_NONE;
+       } else {
+               if (is_le_set_scan_parameter == FALSE) {
+                       /* Set default scan parameter same with BT_ADAPTER_LE_SCAN_MODE_LOW_ENERGY */
+                       bluetooth_le_scan_params_t scan_params;
+                       scan_params.type = 1;
+                       scan_params.interval = 5000;
+                       scan_params.window = 500;
+                       _bt_set_scan_parameters(&scan_params);
+               }
+
+               if (scanner->filter_list == NULL) {
+                       BT_INFO("Start LE Full Scan");
+                       scan_filter_enabled = FALSE;
+               } else {
+                       ret = g_dbus_proxy_call_sync(proxy, "scan_filter_enable",
+                                       g_variant_new("(ib)", 0, TRUE),
+                                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+                       if (error) {
+                               BT_ERR("scan_filter_clear Fail: %s", error->message);
+                               g_clear_error(&error);
+                       }
+
+                       if (ret)
+                               g_variant_unref(ret);
+                       BT_INFO("Enable LE Scan Filter");
+                       scan_filter_enabled = TRUE;
+               }
+       }
+
+       ret = g_dbus_proxy_call_sync(proxy, "StartLEDiscovery",
+                               NULL,G_DBUS_CALL_FLAGS_NONE,
+                               -1, NULL, &error);
+
+       if (error) {
+               BT_ERR("StartLEDiscovery Fail: %s", error->message);
+               g_clear_error(&error);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       if (ret)
+               g_variant_unref(ret);
+       return BLUETOOTH_ERROR_NONE;
+}
+
+int _bt_stop_le_scan(const char *sender)
+{
+       GDBusProxy *proxy;
+       GError *error = NULL;
+       GVariant *ret;
+       bt_adapter_le_scanner_t *scanner = __bt_find_scanner_from_list(sender);
+       GSList *l;
+       gboolean next_scanning = FALSE;
+       gboolean need_scan_filter = TRUE;
+
+       if (scanner == NULL || scanner->is_scanning == FALSE)
+               return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+
+       scanner->is_scanning = FALSE;
+
+       for (l = scanner_list; l != NULL; l = g_slist_next(l)) {
+               scanner = l->data;
+               if (scanner->is_scanning == TRUE) {
+                       next_scanning = TRUE;
+                       if (scanner->filter_list == NULL)
+                               need_scan_filter = FALSE;
+               }
+       }
+
+       proxy = _bt_get_adapter_proxy();
+       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       if (next_scanning == TRUE) {
+               if (scan_filter_enabled == FALSE && need_scan_filter == TRUE) {
+                       ret = g_dbus_proxy_call_sync(proxy, "scan_filter_enable",
+                                       g_variant_new("(ib)", 0, TRUE),
+                                       G_DBUS_CALL_FLAGS_NONE,
+                                       -1, NULL, &error);
+
+                       if (error) {
+                               BT_ERR("scan_filter_clear Fail: %s", error->message);
+                               g_clear_error(&error);
+                       }
+
+                       if (ret)
+                               g_variant_unref(ret);
+                       BT_INFO("Enable LE Scan Filter");
+                       scan_filter_enabled = TRUE;
+               }
+               return BLUETOOTH_ERROR_NONE;
+       } else {
+               if (scan_filter_enabled == TRUE) {
+                       ret = g_dbus_proxy_call_sync(proxy, "scan_filter_enable",
+                                       g_variant_new("(ib)", 0, FALSE),
+                                       G_DBUS_CALL_FLAGS_NONE,
+                                       -1, NULL, &error);
+
+                       if (error) {
+                               BT_ERR("scan_filter_clear Fail: %s", error->message);
+                               g_clear_error(&error);
+                       }
+
+                       if (ret)
+                               g_variant_unref(ret);
+                       BT_INFO("Disable LE Scan Filter");
+               } else {
+                       BT_INFO("Just stop LE scan");
+               }
+       }
+
+       ret = g_dbus_proxy_call_sync(proxy, "StopLEDiscovery",
+                               NULL,G_DBUS_CALL_FLAGS_NONE,
+                               -1, NULL, &error);
+       if (ret == NULL) {
+               BT_ERR("LE Scan stop failed");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       scan_filter_enabled = FALSE;
+       is_le_set_scan_parameter = FALSE;
+       if (ret)
+               g_variant_unref(ret);
+       return BLUETOOTH_ERROR_NONE;
+}
+
+void _bt_set_le_scan_status(gboolean mode)
+{
+       is_le_scanning = mode;
+}
+
+gboolean _bt_is_le_scanning(void)
+{
+       return is_le_scanning;
+}
+
+void _bt_set_le_scan_type(bt_le_scan_type_t type)
+{
+       le_scan_type = type;
+}
+
+bt_le_scan_type_t _bt_get_le_scan_type(void)
+{
+       return le_scan_type;
+}
+
+static gboolean __bt_check_scan_result_uuid(const char *adv_data,
+               int adv_data_len, const char *svc_uuid, int uuid_len,
+               const char *uuid_mask, char ad_type)
+{
+       char *data = NULL;
+       int data_len = 0;
+       int i;
+
+       __bt_get_ad_data_by_type((char*)adv_data, adv_data_len,
+                       ad_type, &data, &data_len);
+       if (data != NULL) {
+               _bt_swap_byte_ordering(data, data_len);
+               for (i = 0; i < data_len; i += uuid_len) {
+                       if (uuid_len > (data_len - i))
+                               break;
+
+                       if (_bt_byte_arr_cmp_with_mask(data + i,
+                               svc_uuid, uuid_mask, uuid_len) == 0) {
+                               g_free(data);
+                               return TRUE;
+                       }
+               }
+               g_free(data);
+       }
+
+       return FALSE;
+}
+
+static gboolean __bt_check_scan_result_with_filter(const char *device_address,
+               const char *adv_data, int adv_data_len,
+               const char *scan_data, int scan_data_len,
+               const bt_adapter_le_scanner_t *scanner)
+{
+       GSList *l;
+       bluetooth_le_scan_filter_t *filter_data = NULL;
+       char *data = NULL;
+       int data_len = 0;
+       gboolean is_matched = FALSE;
+
+       if (scanner->filter_list == NULL) {
+               BT_INFO("This scanner is on Full Scan.");
+               return TRUE;
+       }
+
+       for (l = scanner->filter_list; l != NULL; l = g_slist_next(l)) {
+               filter_data = l->data;
+
+               if (filter_data->added_features &
+                       BLUETOOTH_LE_SCAN_FILTER_FEATURE_DEVICE_ADDRESS) {
+                       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+
+                       _bt_convert_addr_type_to_string(address,
+                                       filter_data->device_address.addr);
+                       if (strncmp(address, device_address,
+                                       BT_ADDRESS_STRING_SIZE) != 0)
+                               continue;
+               }
+
+               if (filter_data->added_features &
+                       BLUETOOTH_LE_SCAN_FILTER_FEATURE_SERVICE_UUID) {
+                       is_matched = FALSE;
+
+                       if (__bt_check_scan_result_uuid(adv_data,
+                               adv_data_len,
+                               (char*)filter_data->service_uuid.data.data,
+                               filter_data->service_uuid.data_len,
+                               (char*)filter_data->service_uuid_mask.data.data,
+                               BT_LE_AD_TYPE_INCOMP_LIST_16_BIT_SERVICE_CLASS_UUIDS)
+                               == TRUE)
+                               is_matched = TRUE;
+                       if (__bt_check_scan_result_uuid(adv_data,
+                               adv_data_len,
+                               (char*)filter_data->service_uuid.data.data,
+                               filter_data->service_uuid.data_len,
+                               (char*)filter_data->service_uuid_mask.data.data,
+                               BT_LE_AD_TYPE_COMP_LIST_16_BIT_SERVICE_CLASS_UUIDS)
+                               == TRUE)
+                               is_matched = TRUE;
+                       if (__bt_check_scan_result_uuid(adv_data,
+                               adv_data_len,
+                               (char*)filter_data->service_uuid.data.data,
+                               filter_data->service_uuid.data_len,
+                               (char*)filter_data->service_uuid_mask.data.data,
+                               BT_LE_AD_TYPE_INCOMP_LIST_128_BIT_SERVICE_CLASS_UUIDS)
+                               == TRUE)
+                               is_matched = TRUE;
+                       if (__bt_check_scan_result_uuid(adv_data,
+                               adv_data_len,
+                               (char*)filter_data->service_uuid.data.data,
+                               filter_data->service_uuid.data_len,
+                               (char*)filter_data->service_uuid_mask.data.data,
+                               BT_LE_AD_TYPE_COMP_LIST_128_BIT_SERVICE_CLASS_UUIDS)
+                               == TRUE)
+                               is_matched = TRUE;
+                       if (__bt_check_scan_result_uuid(scan_data,
+                               scan_data_len,
+                               (char*)filter_data->service_uuid.data.data,
+                               filter_data->service_uuid.data_len,
+                               (char*)filter_data->service_uuid_mask.data.data,
+                               BT_LE_AD_TYPE_INCOMP_LIST_16_BIT_SERVICE_CLASS_UUIDS)
+                               == TRUE)
+                               is_matched = TRUE;
+                       if (__bt_check_scan_result_uuid(scan_data,
+                               scan_data_len,
+                               (char*)filter_data->service_uuid.data.data,
+                               filter_data->service_uuid.data_len,
+                               (char*)filter_data->service_uuid_mask.data.data,
+                               BT_LE_AD_TYPE_COMP_LIST_16_BIT_SERVICE_CLASS_UUIDS)
+                               == TRUE)
+                               is_matched = TRUE;
+                       if (__bt_check_scan_result_uuid(scan_data,
+                               scan_data_len,
+                               (char*)filter_data->service_uuid.data.data,
+                               filter_data->service_uuid.data_len,
+                               (char*)filter_data->service_uuid_mask.data.data,
+                               BT_LE_AD_TYPE_INCOMP_LIST_128_BIT_SERVICE_CLASS_UUIDS)
+                               == TRUE)
+                               is_matched = TRUE;
+                       if (__bt_check_scan_result_uuid(scan_data,
+                               scan_data_len,
+                               (char*)filter_data->service_uuid.data.data,
+                               filter_data->service_uuid.data_len,
+                               (char*)filter_data->service_uuid_mask.data.data,
+                               BT_LE_AD_TYPE_COMP_LIST_128_BIT_SERVICE_CLASS_UUIDS)
+                               == TRUE)
+                               is_matched = TRUE;
+
+                       if (is_matched == FALSE)
+                               continue;
+               }
+               if (filter_data->added_features &
+                       BLUETOOTH_LE_SCAN_FILTER_FEATURE_SERVICE_SOLICITATION_UUID) {
+                       is_matched = FALSE;
+
+                       if (__bt_check_scan_result_uuid(adv_data,
+                               adv_data_len,
+                               (char*)filter_data->service_solicitation_uuid.data.data,
+                               filter_data->service_solicitation_uuid.data_len,
+                               (char*)filter_data->service_solicitation_uuid_mask.data.data,
+                               BT_LE_AD_TYPE_LIST_16_BIT_SERVICE_SOLICITATION_UUIDS)
+                               == TRUE)
+                               is_matched = TRUE;
+                       if (__bt_check_scan_result_uuid(adv_data,
+                               adv_data_len,
+                               (char*)filter_data->service_solicitation_uuid.data.data,
+                               filter_data->service_solicitation_uuid.data_len,
+                               (char*)filter_data->service_solicitation_uuid_mask.data.data,
+                               BT_LE_AD_TYPE_LIST_128_BIT_SERVICE_SOLICITATION_UUIDS)
+                               == TRUE)
+                               is_matched = TRUE;
+                       if (__bt_check_scan_result_uuid(scan_data,
+                               scan_data_len,
+                               (char*)filter_data->service_solicitation_uuid.data.data,
+                               filter_data->service_solicitation_uuid.data_len,
+                               (char*)filter_data->service_solicitation_uuid_mask.data.data,
+                               BT_LE_AD_TYPE_LIST_16_BIT_SERVICE_SOLICITATION_UUIDS)
+                               == TRUE)
+                               is_matched = TRUE;
+                       if (__bt_check_scan_result_uuid(scan_data,
+                               scan_data_len,
+                               (char*)filter_data->service_solicitation_uuid.data.data,
+                               filter_data->service_solicitation_uuid.data_len,
+                               (char*)filter_data->service_solicitation_uuid_mask.data.data,
+                               BT_LE_AD_TYPE_LIST_128_BIT_SERVICE_SOLICITATION_UUIDS)
+                               == TRUE)
+                               is_matched = TRUE;
+
+                       if (is_matched == FALSE)
+                               continue;
+               }
+               if (filter_data->added_features &
+                       BLUETOOTH_LE_SCAN_FILTER_FEATURE_DEVICE_NAME) {
+                       char name[BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX] = {0, };
+                       data = NULL;
+                       data_len = 0;
+                       is_matched = FALSE;
+
+                       __bt_get_ad_data_by_type((char*)adv_data, adv_data_len,
+                                       BT_LE_AD_TYPE_COMPLETE_LOCAL_NAME,
+                                       &data, &data_len);
+                       if (data != NULL) {
+                               if (data_len >= BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX)
+                                       data_len = BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX - 1;
+                               memcpy(name, data, data_len);
+                               name[data_len] = '\0';
+                               g_free(data);
+                               data = NULL;
+                               if (strncmp(filter_data->device_name,
+                                               name, data_len) == 0)
+                                       is_matched = TRUE;
+                       }
+                       __bt_get_ad_data_by_type((char*)scan_data,
+                               scan_data_len,
+                               BT_LE_AD_TYPE_COMPLETE_LOCAL_NAME,
+                               &data, &data_len);
+                       if (data != NULL) {
+                               if (data_len >= BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX)
+                                       data_len = BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX - 1;
+                               memcpy(name, data, data_len);
+                               name[data_len] = '\0';
+                               g_free(data);
+                               data = NULL;
+                               if (strncmp(filter_data->device_name,
+                                               name, data_len) == 0)
+                                       is_matched = TRUE;
+                       }
+
+                       if (is_matched == FALSE)
+                               continue;
+               }
+               if (filter_data->added_features &
+                       BLUETOOTH_LE_SCAN_FILTER_FEATURE_MANUFACTURER_DATA) {
+                       data = NULL;
+                       data_len = 0;
+                       is_matched = FALSE;
+
+                       __bt_get_ad_data_by_type((char*)adv_data,
+                               adv_data_len,
+                               BT_LE_AD_TYPE_MANUFACTURER_SPECIFIC_DATA,
+                               &data, &data_len);
+                       if (data != NULL) {
+                               if (data_len >= BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX)
+                                       data_len = BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX - 1;
+                               if (_bt_byte_arr_cmp_with_mask(data,
+                                       (char*)filter_data->manufacturer_data.data.data,
+                                       (char*)filter_data->manufacturer_data_mask.data.data,
+                                       data_len) == 0) {
+                                       is_matched = TRUE;
+                               }
+                               g_free(data);
+                               data = NULL;
+                       }
+                       __bt_get_ad_data_by_type((char*)scan_data,
+                               scan_data_len,
+                               BT_LE_AD_TYPE_MANUFACTURER_SPECIFIC_DATA,
+                               &data, &data_len);
+                       if (data != NULL) {
+                               if (data_len >= BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX)
+                                       data_len = BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX - 1;
+                               if (_bt_byte_arr_cmp_with_mask(data,
+                                       (char*)filter_data->manufacturer_data.data.data,
+                                       (char*)filter_data->manufacturer_data_mask.data.data,
+                                       data_len) == 0) {
+                                       is_matched = TRUE;
+                               }
+                               g_free(data);
+                               data = NULL;
+                       }
+
+                       if (is_matched == FALSE)
+                               continue;
+               }
+               if (filter_data->added_features &
+                       BLUETOOTH_LE_SCAN_FILTER_FEATURE_SERVICE_DATA) {
+                       data = NULL;
+                       data_len = 0;
+                       is_matched = FALSE;
+
+                       __bt_get_ad_data_by_type((char*)adv_data,
+                               adv_data_len,
+                               BT_LE_AD_TYPE_SERVICE_DATA,
+                               &data, &data_len);
+                       if (data != NULL) {
+                               if (data_len >= BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX)
+                                       data_len = BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX - 1;
+                               if (_bt_byte_arr_cmp_with_mask(data,
+                                       (char*)filter_data->service_data.data.data,
+                                       (char*)filter_data->service_data_mask.data.data,
+                                       data_len) == 0) {
+                                       is_matched = TRUE;
+                               }
+                               g_free(data);
+                               data = NULL;
+                       }
+                       __bt_get_ad_data_by_type((char*)scan_data,
+                               scan_data_len,
+                               BT_LE_AD_TYPE_SERVICE_DATA,
+                               &data, &data_len);
+                       if (data != NULL) {
+                               if (data_len >= BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX)
+                                       data_len = BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX - 1;
+                               if (_bt_byte_arr_cmp_with_mask(data,
+                                       (char*)filter_data->service_data.data.data,
+                                       (char*)filter_data->service_data_mask.data.data,
+                                       data_len) == 0) {
+                                       is_matched = TRUE;
+                               }
+                               g_free(data);
+                               data = NULL;
+                       }
+
+                       if (is_matched == FALSE)
+                               continue;
+               }
+
+               BT_INFO("The scan result is conformable.");
+               return TRUE;
+       }
+
+       BT_INFO("The scan result is NOT conformable.");
+       return FALSE;
+}
+
+void _bt_send_scan_result_event(const bt_remote_le_dev_info_t *le_dev_info,
+                               const bt_le_adv_info_t *adv_info)
+{
+       int result = BLUETOOTH_ERROR_NONE;
+       GSList *l;
+       GVariant *scan_data_param, *adv_data_param;
+       GVariant *param;
+       bt_adapter_le_scanner_t *scanner = NULL;
+       const char *adv_data = NULL;
+       int adv_data_len = 0;
+       const char *scan_data = NULL;
+       int scan_data_len = 0;
+
+       ret_if(le_dev_info == NULL);
+       if (_bt_get_le_scan_type() == BT_LE_ACTIVE_SCAN)
+               ret_if(adv_info == NULL);
+
+       if (_bt_get_le_scan_type() == BT_LE_PASSIVE_SCAN) {
+               adv_data = le_dev_info->adv_data;
+               adv_data_len = le_dev_info->adv_data_len;
+               scan_data = le_dev_info->adv_data;
+               scan_data_len = 0;
+       } else {
+               adv_data = adv_info->data;
+               adv_data_len = adv_info->data_len;
+               scan_data = le_dev_info->adv_data;
+               scan_data_len = le_dev_info->adv_data_len;
+       }
+
+       for (l = scanner_list; l != NULL; l = g_slist_next(l)) {
+               scanner = l->data;
+               if (scanner->is_scanning == FALSE)
+                       continue;
+
+               if (__bt_check_scan_result_with_filter(le_dev_info->address,
+                       adv_data, adv_data_len, scan_data, scan_data_len,
+                       scanner) == FALSE)
+                       continue;
+
+               adv_data_param = g_variant_new_from_data((const GVariantType *)"ay",
+                                                       adv_data, adv_data_len, TRUE, NULL, NULL);
+               scan_data_param = g_variant_new_from_data((const GVariantType *)"ay",
+                                                       scan_data, scan_data_len, TRUE, NULL, NULL);
+
+               param = g_variant_new("(isnnn@ayn@ay)",
+                                       result,
+                                       le_dev_info->address,
+                                       le_dev_info->addr_type,
+                                       le_dev_info->rssi,
+                                       adv_data_len,
+                                       adv_data_param,
+                                       scan_data_len,
+                                       scan_data_param);
+
+               _bt_send_event_to_dest(scanner->sender, BT_LE_ADAPTER_EVENT,
+                               BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND, param);
+       }
+}
+
 int _bt_add_white_list(bluetooth_device_address_t *device_address, bluetooth_device_address_type_t address_type)
 {
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        GError *error = NULL;
+       GVariant *ret;
 
        if (__bt_is_factory_test_mode()) {
                BT_ERR("Unable to add white list in factory binary !!");
@@ -687,17 +1709,19 @@ int _bt_add_white_list(bluetooth_device_address_t *device_address, bluetooth_dev
        proxy = _bt_get_adapter_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call(proxy, "AddDeviceWhiteList", &error,
-                 G_TYPE_STRING, address,
-                 G_TYPE_UINT, address_type,
-                 G_TYPE_INVALID, G_TYPE_INVALID);
+       ret = g_dbus_proxy_call_sync(proxy, "AddDeviceWhiteList",
+                         g_variant_new("(su)", address, address_type),
+                         G_DBUS_CALL_FLAGS_NONE, -1,
+                         NULL, &error);
 
        if (error) {
                BT_ERR("AddDeviceWhiteList Fail: %s", error->message);
-               g_error_free(error);
+               g_clear_error(&error);
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
+       if (ret)
+               g_variant_unref(ret);
        BT_INFO("Add white list");
 
        return BLUETOOTH_ERROR_NONE;
@@ -705,9 +1729,10 @@ int _bt_add_white_list(bluetooth_device_address_t *device_address, bluetooth_dev
 
 int _bt_remove_white_list(bluetooth_device_address_t *device_address, bluetooth_device_address_type_t address_type)
 {
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        GError *error = NULL;
+       GVariant *ret;
 
        if (__bt_is_factory_test_mode()) {
                BT_ERR("Unable to remove white list in factory binary !!");
@@ -725,17 +1750,19 @@ int _bt_remove_white_list(bluetooth_device_address_t *device_address, bluetooth_
        proxy = _bt_get_adapter_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call(proxy, "RemoveDeviceWhiteList", &error,
-                 G_TYPE_STRING, address,
-                  G_TYPE_UINT, address_type,
-                 G_TYPE_INVALID, G_TYPE_INVALID);
+       ret = g_dbus_proxy_call_sync(proxy, "RemoveDeviceWhiteList",
+                         g_variant_new("(su)", address, address_type),
+                         G_DBUS_CALL_FLAGS_NONE, -1,
+                         NULL, &error);
 
        if (error) {
                BT_ERR("RemoveDeviceWhiteList Fail: %s", error->message);
-               g_error_free(error);
+               g_clear_error(&error);
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
+       if (ret)
+               g_variant_unref(ret);
        BT_INFO("Remove white list");
 
        return BLUETOOTH_ERROR_NONE;
@@ -743,8 +1770,9 @@ int _bt_remove_white_list(bluetooth_device_address_t *device_address, bluetooth_
 
 int _bt_clear_white_list(void)
 {
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        GError *error = NULL;
+       GVariant *ret;
 
        if (__bt_is_factory_test_mode()) {
                BT_ERR("Unable to clear white list in factory binary !!");
@@ -754,14 +1782,17 @@ int _bt_clear_white_list(void)
        proxy = _bt_get_adapter_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call(proxy, "ClearDeviceWhiteList", &error,
-                 G_TYPE_INVALID, G_TYPE_INVALID);
+       ret = g_dbus_proxy_call_sync(proxy, "ClearDeviceWhiteList",
+                               NULL,G_DBUS_CALL_FLAGS_NONE,
+                               -1, NULL, &error);
 
        if (error) {
                BT_ERR("ClearDeviceWhiteList Fail: %s", error->message);
-               g_error_free(error);
+               g_clear_error(&error);
                return BLUETOOTH_ERROR_INTERNAL;
        }
+       if (ret)
+               g_variant_unref(ret);
 
        BT_INFO("Clear white list");
 
index 561643c..f677a32 100644 (file)
  */
 
 #include <stdio.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
+#include <gio/gio.h>
 #include <glib.h>
 #include <dlog.h>
 #include <string.h>
 #include <vconf.h>
-#include <status.h>
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
 #include <syspopup_caller.h>
-#endif
-#ifdef __TIZEN_MOBILE__
 #include <aul.h>
-#endif
-#include <notification.h>
-#ifdef ENABLE_TIZEN_2_4
 #include <journal/device.h>
-#endif
+#include <bundle.h>
+#include <eventsystem.h>
+#include <bundle_internal.h>
 
 #include "alarm.h"
-
 #include "bluetooth-api.h"
 #include "bt-internal-types.h"
-
 #include "bt-service-common.h"
 #include "bt-service-event.h"
 #include "bt-service-adapter.h"
@@ -54,6 +46,7 @@
 #include "bt-service-agent.h"
 #include "bt-service-main.h"
 #include "bt-service-avrcp.h"
+#include "bt-service-device.h"
 
 typedef struct {
        guint event_id;
@@ -66,42 +59,47 @@ typedef struct {
 bt_adapter_timer_t visible_timer = {0, };
 
 static gboolean is_discovering;
-static gboolean is_le_discovering;
-static bt_le_discovery_type_t le_discovery_type = BT_LE_PASSIVE_SCAN;
 static gboolean cancel_by_user;
 static bt_status_t adapter_status = BT_DEACTIVATED;
 static bt_le_status_t adapter_le_status = BT_LE_DEACTIVATED;
 static void *adapter_agent = NULL;
-static DBusGProxy *core_proxy = NULL;
+static GDBusProxy *core_proxy = NULL;
 static guint timer_id = 0;
 static guint le_timer_id = 0;
 
+static int status_reg_id;
+
 #define BT_CORE_NAME "org.projectx.bt_core"
 #define BT_CORE_PATH "/org/projectx/bt_core"
 #define BT_CORE_INTERFACE "org.projectx.btcore"
 
 #define BT_DISABLE_TIME 500 /* 500 ms */
 
-DBusGProxy *_bt_init_core_proxy(void)
+GDBusProxy *_bt_init_core_proxy(void)
 {
-       DBusGProxy *proxy;
-       DBusGConnection *conn;
+       GDBusProxy *proxy;
+       GDBusConnection *conn;
 
        conn = _bt_get_system_gconn();
        if (!conn)
                return NULL;
 
-       proxy = dbus_g_proxy_new_for_name(conn, BT_CORE_NAME,
-                       BT_CORE_PATH, BT_CORE_INTERFACE);
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                       NULL,
+                                       BT_CORE_NAME,
+                                       BT_CORE_PATH,
+                                       BT_CORE_INTERFACE,
+                                       NULL, NULL);
+
        if (!proxy)
                return NULL;
 
-       core_proxy = proxy;
+       core_proxy = proxy;
 
-       return proxy;
+       return proxy;
 }
 
-static DBusGProxy *__bt_get_core_proxy(void)
+static GDBusProxy *__bt_get_core_proxy(void)
 {
        return (core_proxy) ? core_proxy : _bt_init_core_proxy();
 }
@@ -110,12 +108,10 @@ static gboolean __bt_is_factory_test_mode(void)
 {
        int mode = 0;
 
-#ifdef ENABLE_TIZEN_2_4
        if (vconf_get_bool(VCONFKEY_BT_DUT_MODE, &mode)) {
                BT_ERR("Get the DUT Mode fail");
                return TRUE;
        }
-#endif
 
        if (mode != FALSE) {
                BT_INFO("DUT Test Mode !!");
@@ -138,9 +134,7 @@ static gboolean __bt_timeout_handler(gpointer user_data)
        /* Send event to application */
        _bt_send_event(BT_ADAPTER_EVENT,
                        BLUETOOTH_EVENT_DISCOVERABLE_TIMEOUT_CHANGED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_INT16, &time_diff,
-                       DBUS_TYPE_INVALID);
+                       g_variant_new("(in)", result, time_diff));
 
        if (visible_timer.timeout <= time_diff) {
                g_source_remove(visible_timer.event_id);
@@ -170,9 +164,7 @@ static int __bt_visibility_alarm_cb(alarm_id_t alarm_id, void* user_param)
        if (visible_timer.event_id) {
                _bt_send_event(BT_ADAPTER_EVENT,
                                BLUETOOTH_EVENT_DISCOVERABLE_TIMEOUT_CHANGED,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_INT16, &timeout,
-                               DBUS_TYPE_INVALID);
+                               g_variant_new("(in)", result, timeout));
                g_source_remove(visible_timer.event_id);
                visible_timer.event_id = 0;
                visible_timer.timeout = 0;
@@ -224,12 +216,13 @@ int __bt_set_visible_time(int timeout)
 
        visible_timer.timeout = timeout;
 
+       if (timeout <= 0)
+               return BLUETOOTH_ERROR_NONE;
+
 #ifndef TIZEN_WEARABLE
        if (vconf_set_int(BT_FILE_VISIBLE_TIME, timeout) != 0)
                BT_ERR("Set vconf failed");
 #endif
-       if (timeout <= 0)
-               return BLUETOOTH_ERROR_NONE;
 
        if (!visible_timer.alarm_init) {
                /* Set Alarm timer to switch off BT */
@@ -254,273 +247,58 @@ int __bt_set_visible_time(int timeout)
        return BLUETOOTH_ERROR_NONE;
 }
 
-static void __bt_get_service_list(GValue *value, bluetooth_device_info_t *dev)
+static void __bt_get_service_list(GVariant *value, bluetooth_device_info_t *dev)
 {
-       int i;
-       char **uuids;
+       int i = 0;
        char **parts;
+       GVariantIter *iter;
+       gchar *uuid = NULL;
 
        ret_if(value == NULL);
        ret_if(dev == NULL);
 
-       uuids = g_value_get_boxed(value);
-       ret_if(uuids == NULL);
-
        dev->service_index = 0;
 
-       for (i = 0; uuids[i] != NULL; i++) {
-               g_strlcpy(dev->uuids[i], uuids[i], BLUETOOTH_UUID_STRING_MAX);
-
-               parts = g_strsplit(uuids[i], "-", -1);
+       g_variant_get(value, "as", &iter);
+       while (g_variant_iter_loop(iter, "s", &uuid)) {
+               g_strlcpy(dev->uuids[i], uuid, BLUETOOTH_UUID_STRING_MAX);
+               parts = g_strsplit(uuid, "-", -1);
 
-               if (parts == NULL || parts[0] == NULL)
+               if (parts == NULL || parts[0] == NULL) {
+                       g_free(uuid);
                        break;
+               }
 
                dev->service_list_array[i] = g_ascii_strtoull(parts[0], NULL, 16);
                g_strfreev(parts);
 
                dev->service_index++;
+               i++;
        }
-}
-
-static bt_remote_dev_info_t *__bt_parse_remote_device_info(
-                                       DBusMessageIter *item_iter)
-{
-       DBusMessageIter value_iter;
-       bt_remote_dev_info_t *dev_info;
-
-       dbus_message_iter_recurse(item_iter, &value_iter);
-
-       if (dbus_message_iter_get_arg_type(&value_iter) !=
-                                       DBUS_TYPE_DICT_ENTRY) {
-               BT_DBG("No entry");
-               return NULL;
-       }
-
-       dev_info = g_malloc0(sizeof(bt_remote_dev_info_t));
-
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                                               DBUS_TYPE_DICT_ENTRY) {
-               char *value = NULL;
-               char *key;
-               DBusMessageIter dict_entry;
-               DBusMessageIter iter_dict_val;
-
-               dbus_message_iter_recurse(&value_iter, &dict_entry);
-
-               dbus_message_iter_get_basic(&dict_entry, &key);
-
-               if (key == NULL) {
-                       dbus_message_iter_next(&value_iter);
-                       continue;
-               }
-
-               if (!dbus_message_iter_next(&dict_entry)) {
-                       dbus_message_iter_next(&value_iter);
-                       continue;
-               }
-               dbus_message_iter_recurse(&dict_entry, &iter_dict_val);
-
-               if (strcasecmp(key, "Address") == 0) {
-                       const char *address = NULL;
-                       dbus_message_iter_get_basic(&iter_dict_val,
-                                                       &address);
-                       dev_info->address = g_strdup(address);
-               } else if (strcasecmp(key, "Class") == 0) {
-                       dbus_message_iter_get_basic(&iter_dict_val,
-                                               &dev_info->class);
-               } else if (strcasecmp(key, "Name") == 0) {
-                       dbus_message_iter_get_basic(&iter_dict_val,
-                                                       &value);
-                       if (dev_info->name == NULL)
-                               dev_info->name = g_strdup(value);
-               } else if (strcasecmp(key, "Connected") == 0) {
-                       dbus_message_iter_get_basic(&iter_dict_val,
-                                               &dev_info->connected);
-               } else if (strcasecmp(key, "Paired") == 0) {
-                       dbus_message_iter_get_basic(&iter_dict_val,
-                                               &dev_info->paired);
-               } else if (strcasecmp(key, "Trusted") == 0) {
-                       dbus_message_iter_get_basic(&iter_dict_val,
-                                               &dev_info->trust);
-               } else if (strcasecmp(key, "RSSI") == 0) {
-                       dbus_message_iter_get_basic(&iter_dict_val,
-                                               &dev_info->rssi);
-               } else if (strcasecmp(key, "UUIDs") == 0) {
-                       DBusMessageIter uuid_iter;
-                       DBusMessageIter tmp_iter;
-                       int i = 0;
-
-                       dbus_message_iter_recurse(&iter_dict_val,
-                                                       &uuid_iter);
-                       tmp_iter = uuid_iter;
-
-                       /* Store the uuid count */
-                       while (dbus_message_iter_get_arg_type(&tmp_iter) !=
-                                                       DBUS_TYPE_INVALID) {
-
-                               dbus_message_iter_get_basic(&tmp_iter,
-                                                               &value);
-
-                               dev_info->uuid_count++;
-                               if (!dbus_message_iter_next(&tmp_iter))
-                                       break;
-                       }
-
-                       /* Store the uuids */
-                       if (dev_info->uuid_count > 0) {
-                               dev_info->uuids = g_new0(char *,
-                                               dev_info->uuid_count + 1);
-                       } else {
-                               dbus_message_iter_next(&value_iter);
-                               continue;
-                       }
-
-                       while (dbus_message_iter_get_arg_type(&uuid_iter) !=
-                                                       DBUS_TYPE_INVALID) {
-                               dbus_message_iter_get_basic(&uuid_iter,
-                                                               &value);
-                               dev_info->uuids[i] = g_strdup(value);
-                               i++;
-                               if (!dbus_message_iter_next(&uuid_iter)) {
-                                       break;
-                               }
-                       }
-               }
-
-               dbus_message_iter_next(&value_iter);
-       }
-
-       return dev_info;
-}
-
-static void __bt_extract_remote_devinfo(DBusMessageIter *msg_iter,
-                                               GArray **dev_list)
-{
-       bt_remote_dev_info_t *dev_info = NULL;
-       char *object_path = NULL;
-       DBusMessageIter value_iter;
-
-       /* Parse the signature:  oa{sa{sv}}} */
-       ret_if(dbus_message_iter_get_arg_type(msg_iter) !=
-                                       DBUS_TYPE_OBJECT_PATH);
-
-       dbus_message_iter_get_basic(msg_iter, &object_path);
-       ret_if(object_path == NULL);
-
-       /* object array (oa) */
-       ret_if(dbus_message_iter_next(msg_iter) == FALSE);
-       ret_if(dbus_message_iter_get_arg_type(msg_iter) != DBUS_TYPE_ARRAY);
-
-       dbus_message_iter_recurse(msg_iter, &value_iter);
-
-       /* string array (sa) */
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                                       DBUS_TYPE_DICT_ENTRY) {
-               char *interface_name = NULL;
-               DBusMessageIter interface_iter;
-
-               dbus_message_iter_recurse(&value_iter, &interface_iter);
-
-               ret_if(dbus_message_iter_get_arg_type(&interface_iter) !=
-                                                       DBUS_TYPE_STRING);
-
-               dbus_message_iter_get_basic(&interface_iter, &interface_name);
-
-               ret_if(dbus_message_iter_next(&interface_iter) == FALSE);
-
-               ret_if(dbus_message_iter_get_arg_type(&interface_iter) !=
-                                                       DBUS_TYPE_ARRAY);
-
-               if (g_strcmp0(interface_name, "org.bluez.Device1") == 0) {
-                       BT_DBG("Found a device: %s", object_path);
-                       dev_info = __bt_parse_remote_device_info(
-                                                       &interface_iter);
-
-                       if (dev_info) {
-                               g_array_append_vals(*dev_list, dev_info,
-                                       sizeof(bt_remote_dev_info_t));
-                       }
-               }
-
-               dbus_message_iter_next(&value_iter);
-       }
-}
-
-int _bt_get_remote_found_devices(GArray **dev_list)
-{
-       DBusMessage *msg;
-       DBusMessage *reply;
-       DBusMessageIter reply_iter;
-       DBusMessageIter value_iter;
-       DBusError err;
-       DBusConnection *conn;
-
-       conn = _bt_get_system_conn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       msg = dbus_message_new_method_call(BT_BLUEZ_NAME, BT_MANAGER_PATH,
-                                               BT_MANAGER_INTERFACE,
-                                               "GetManagedObjects");
-
-       retv_if(msg == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       /* Synchronous call */
-       dbus_error_init(&err);
-       reply = dbus_connection_send_with_reply_and_block(
-                                       conn, msg,
-                                       -1, &err);
-       dbus_message_unref(msg);
-
-       if (!reply) {
-               BT_ERR("Can't get managed objects");
-
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("%s", err.message);
-                       dbus_error_free(&err);
-               }
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       if (dbus_message_iter_init(reply, &reply_iter) == FALSE) {
-               BT_ERR("Fail to iterate the reply");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_recurse(&reply_iter, &value_iter);
-
-       /* signature of GetManagedObjects:  a{oa{sa{sv}}} */
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                                               DBUS_TYPE_DICT_ENTRY) {
-               DBusMessageIter msg_iter;
-
-               dbus_message_iter_recurse(&value_iter, &msg_iter);
-
-               __bt_extract_remote_devinfo(&msg_iter, dev_list);
-
-               dbus_message_iter_next(&value_iter);
-       }
-
-       return BLUETOOTH_ERROR_NONE;
+       g_variant_iter_free(iter);
 }
 
 static int __bt_get_bonded_device_info(gchar *device_path,
                bluetooth_device_info_t *dev_info)
 {
-       GValue *value = { 0 };
-       GError *err = NULL;
-       DBusGProxy *device_proxy;
-       const gchar *address;
-       const gchar *name;
-       unsigned int cod;
-       gint rssi;
-       gboolean trust;
-       gboolean paired;
-       gboolean connected;
+       GError *error = NULL;
+       GDBusProxy *device_proxy;
+       const gchar *address = NULL;
+       const gchar *name = NULL;
+       unsigned int cod = 0;
+       gint rssi = 0;
+       gboolean trust = FALSE;
+       gboolean paired = FALSE;
+       guchar connected = 0;
        GByteArray *manufacturer_data = NULL;
-       GHashTable *hash = NULL;
        int ret;
-       DBusGConnection *conn;
+       GDBusConnection *conn;
+       GVariant *result;
+       GVariantIter *property_iter;
+       const gchar *key;
+       GVariant *value;
+       guint8 char_value;
+       GVariantIter *char_value_iter;
 
        BT_CHECK_PARAMETER(device_path, return);
        BT_CHECK_PARAMETER(dev_info, return);
@@ -528,94 +306,95 @@ static int __bt_get_bonded_device_info(gchar *device_path,
        conn = _bt_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               device_path, BT_PROPERTIES_INTERFACE);
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                       NULL,
+                                       BT_BLUEZ_NAME,
+                                       device_path,
+                                       BT_PROPERTIES_INTERFACE,
+                                       NULL, NULL);
 
        retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call(device_proxy, "GetAll", &err,
-                               G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                               G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
-                               G_TYPE_VALUE), &hash, G_TYPE_INVALID);
-
-       g_object_unref(device_proxy);
-
-       if (err != NULL) {
-               BT_ERR("Error occured in Proxy call [%s]\n", err->message);
-               g_error_free(err);
+       result = g_dbus_proxy_call_sync(device_proxy,
+                               "GetAll",
+                               g_variant_new("(s)", BT_DEVICE_INTERFACE),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               BT_ERR("Error occured in Proxy call");
+               if (error != NULL) {
+                       BT_ERR("Error occured in Proxy call (Error: %s)", error->message);
+                       g_clear_error(&error);
+               }
+               g_object_unref(device_proxy);
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       if (hash != NULL) {
-               value = g_hash_table_lookup(hash, "Paired");
-               paired = g_value_get_boolean(value);
-
-               value = g_hash_table_lookup(hash, "Address");
-               address = value ? g_value_get_string(value) : NULL;
-
-               value = g_hash_table_lookup(hash, "Alias");
-               name = value ? g_value_get_string(value) : NULL;
-
-               if (name != NULL)
-                       BT_DBG("Alias Name [%s]", name);
-               else {
-                       value = g_hash_table_lookup(hash, "Name");
-                       name = value ? g_value_get_string(value) : NULL;
-               }
-
-               value = g_hash_table_lookup(hash, "Class");
-               cod = value ? g_value_get_uint(value) : 0;
-
-               value = g_hash_table_lookup(hash, "Connected");
-               connected = value ? g_value_get_boolean(value) : FALSE;
-
-               value = g_hash_table_lookup(hash, "Trusted");
-               trust = value ? g_value_get_boolean(value) : FALSE;
-
-               BT_DBG("paired: %d", paired);
-               BT_DBG("trust: %d", trust);
+       g_object_unref(device_proxy);
 
-               if ((paired == FALSE) && (trust == FALSE)) {
-                       return BLUETOOTH_ERROR_NOT_PAIRED;
+       g_variant_get(result, "(a{sv})", &property_iter);
+
+       while (g_variant_iter_loop(property_iter, "{sv}", &key, &value)) {
+               if (!g_strcmp0(key,"Paired")) {
+                       paired = g_variant_get_boolean(value);
+               } else if(!g_strcmp0(key, "Address")) {
+                       address = g_variant_get_string(value, NULL);
+               } else if (!g_strcmp0(key, "Alias")) {
+                       name = g_variant_get_string(value, NULL);
+               } else if (!g_strcmp0(key, "Name")) {
+                       if (!name)
+                               name = g_variant_get_string(value, NULL);
+               } else if (!g_strcmp0(key, "Class")) {
+                       cod = g_variant_get_uint32(value);
+               } else if (!g_strcmp0(key, "Connected")) {
+                       connected = g_variant_get_byte(value);
+               } else if (!g_strcmp0(key, "Trusted")) {
+                       trust = g_variant_get_boolean(value);
+               } else if (!g_strcmp0(key, "RSSI")) {
+                       rssi = g_variant_get_int16(value);
+               } else if (!g_strcmp0(key, "UUIDs")) {
+                       __bt_get_service_list(value, dev_info);
+               } else if (!g_strcmp0(key, "ManufacturerDataLen")) {
+                       dev_info->manufacturer_data.data_len = g_variant_get_uint16(value);
+               } else if (!g_strcmp0(key, "ManufacturerData")) {
+                       manufacturer_data = g_byte_array_new();
+                       g_variant_get(value, "ay", &char_value_iter);
+                       while(g_variant_iter_loop(char_value_iter, "y",  &char_value)) {
+                               g_byte_array_append(manufacturer_data, &char_value, 1);
+                       }
+                       if (manufacturer_data) {
+                               if (manufacturer_data->len > 0) {
+                                       memcpy(dev_info->manufacturer_data.data, manufacturer_data->data,
+                                               manufacturer_data->len);
+                               }
+                       }
                }
+       }
 
-               value = g_hash_table_lookup(hash, "RSSI");
-               rssi = value ? g_value_get_int(value) : 0;
-
-               value = g_hash_table_lookup(hash, "UUIDs");
-               __bt_get_service_list(value, dev_info);
+       BT_DBG("trust: %d, paired: %d", trust, paired);
 
-               value = g_hash_table_lookup(hash, "ManufacturerDataLen");
-               dev_info->manufacturer_data.data_len = value ? g_value_get_uint(value) : 0;
+       g_variant_unref(result);
 
-               value = g_hash_table_lookup(hash, "ManufacturerData");
-               manufacturer_data = value ? g_value_get_boxed(value) : NULL;
-               if (manufacturer_data) {
-                       if (manufacturer_data->len > 0) {
-                               BT_DBG("manufacturer_data->len  = %d", manufacturer_data->len);
-                               memcpy(dev_info->manufacturer_data.data, manufacturer_data->data, manufacturer_data->len);
-                       }
-               }
+       if ((paired == FALSE) && (trust == FALSE)) {
+               return BLUETOOTH_ERROR_NOT_PAIRED;
+       }
 
-               _bt_convert_addr_string_to_type(dev_info->device_address.addr,
-                                               address);
+       _bt_convert_addr_string_to_type(dev_info->device_address.addr,
+                                       address);
 
-               _bt_divide_device_class(&dev_info->device_class, cod);
+       _bt_divide_device_class(&dev_info->device_class, cod);
 
-               g_strlcpy(dev_info->device_name.name, name,
-                               BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1);
+       g_strlcpy(dev_info->device_name.name, name,
+                       BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1);
 
-               dev_info->rssi = rssi;
-               dev_info->trust = trust;
-               dev_info->paired = paired;
-               dev_info->connected = connected;
-               g_hash_table_destroy(hash);
-               ret = BLUETOOTH_ERROR_NONE;
-       } else {
-               BT_ERR("Hash is NULL\n");
-               ret = BLUETOOTH_ERROR_INTERNAL;
-       }
+       dev_info->rssi = rssi;
+       dev_info->trust = trust;
+       dev_info->paired = paired;
+       dev_info->connected = connected;
+       ret = BLUETOOTH_ERROR_NONE;
 
        return ret;
 }
@@ -625,21 +404,6 @@ void _bt_set_discovery_status(gboolean mode)
        is_discovering = mode;
 }
 
-void _bt_set_le_discovery_status(gboolean mode)
-{
-       is_le_discovering = mode;
-}
-
-void _bt_set_le_discovery_type(bt_le_discovery_type_t type)
-{
-       le_discovery_type = type;
-}
-
-bt_le_discovery_type_t _bt_get_le_discovery_type(void)
-{
-       return le_discovery_type;
-}
-
 void _bt_set_cancel_by_user(gboolean value)
 {
        cancel_by_user = value;
@@ -656,30 +420,6 @@ void _bt_adapter_set_status(bt_status_t status)
        adapter_status = status;
 }
 
-#ifdef __TIZEN_MOBILE__
-static void __launch_bt_service(int status, int run_type)
-{
-       bundle *kb;
-       char status_val[5] = { 0, };
-       char run_type_val[5] = { 0, };
-
-       snprintf(status_val, sizeof(status_val), "%d", status);
-       snprintf(run_type_val, sizeof(run_type_val), "%d", run_type);
-
-       BT_DBG("status: %s, run_type: %s", status_val, run_type_val);
-
-       kb = bundle_create();
-
-       bundle_add(kb, "launch-type", "setstate");
-       bundle_add(kb, "status", status_val);
-       bundle_add(kb, "run-type", run_type_val);
-
-       aul_launch_app("org.tizen.bluetooth", kb);
-
-       bundle_free(kb);
-}
-#endif
-
 bt_status_t _bt_adapter_get_status(void)
 {
        return adapter_status;
@@ -717,50 +457,7 @@ static void __bt_phone_name_changed_cb(keynode_t *node, void *data)
        }
 }
 
-#ifdef TIZEN_WEARABLE
-static char * __bt_change_dev_name(const char *default_name)
-{
-       FILE *fp = NULL;
-       char *buf = NULL;
-       char *name = NULL;
-       int result;
-
-       if ((fp = fopen("/csa/bluetooth/.bd_addr", "r")) == NULL) {
-               BT_ERR("Unable to open bd_addr");
-               return NULL;
-       }
-
-       result = fseek(fp, -4, SEEK_END);
-       if (result < 0) {
-               BT_ERR("fseek is failed");
-               fclose(fp);
-               return NULL;
-       }
-
-       buf = (char *)malloc(sizeof(char) * 5);
-       if (buf == NULL) {
-               BT_ERR("malloc is failed");
-               fclose(fp);
-               return NULL;
-       }
-       memset(buf, 0, 5);
-
-       result = fread(buf, 1, 4, fp);
-       if (result)
-               BT_DBG("Size Read: [%d]", result);
-       else
-               BT_ERR("Error reading file: code[%d]", result);
-
-       name = g_strdup_printf("%s (%s)", default_name, buf);
-
-       BT_INFO("%s", name);
-
-       free(buf);
-       fclose(fp);
-
-       return name ;
-}
-#else
+#ifndef TIZEN_WEARABLE
 static void __bt_set_visible_mode(void)
 {
        int timeout = 0;
@@ -768,7 +465,14 @@ static void __bt_set_visible_mode(void)
        if (vconf_get_int(BT_FILE_VISIBLE_TIME, &timeout) != 0)
                 BT_ERR("Fail to get the timeout value");
 
-       /* -1: Always on */
+       if (timeout == -1) {
+               if (_bt_set_discoverable_mode(
+                       BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE,
+                       timeout) != BLUETOOTH_ERROR_NONE) {
+                       if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
+                               BT_ERR("Set vconf failed");
+               }
+       }
 }
 #endif
 
@@ -786,27 +490,17 @@ static void __bt_set_local_name(void)
                if (!g_utf8_validate(phone_name, -1, (const char **)&ptr))
                        *ptr = '\0';
 
-#ifdef TIZEN_WEARABLE
-               if (strstr(phone_name, "(") == NULL) {
-                       char *tmp = __bt_change_dev_name(phone_name);
-                       if (tmp != NULL) {
-                               free(phone_name);
-                               phone_name = tmp;
-                       }
-               }
-#endif
                _bt_set_local_name(phone_name);
        }
        free(phone_name);
 }
 
-int __bt_set_enabled(void)
+static int __bt_set_enabled(void)
 {
        int adapter_status = BT_ADAPTER_DISABLED;
        int result = BLUETOOTH_ERROR_NONE;
 
        _bt_check_adapter(&adapter_status);
-       adapter_status = BT_ADAPTER_ENABLED;
 
        if (adapter_status == BT_ADAPTER_DISABLED) {
                BT_ERR("Bluetoothd is not running");
@@ -826,9 +520,13 @@ int __bt_set_enabled(void)
        if (vconf_set_int(VCONFKEY_BT_DEVICE, VCONFKEY_BT_DEVICE_NONE) != 0)
                BT_ERR("Set vconf failed\n");
 
+       if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_STATE,
+                                               EVT_VAL_BT_ON) != ES_R_OK)
+               BT_ERR("Fail to set value");
+
        /* Send enabled event to API */
        _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_ENABLED,
-                               DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
+                               g_variant_new("(i)", result));
 
        return BLUETOOTH_ERROR_NONE;
 }
@@ -858,6 +556,10 @@ void _bt_set_disabled(int result)
                /* Update Bluetooth Status to notify other modules */
                if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
                        BT_ERR("Set vconf failed");
+
+               if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_STATE,
+                                                       EVT_VAL_BT_OFF) != ES_R_OK)
+                       BT_ERR("Fail to set value");
        }
 
        if (vconf_set_int(VCONFKEY_BT_DEVICE, VCONFKEY_BT_DEVICE_NONE) != 0)
@@ -865,17 +567,13 @@ void _bt_set_disabled(int result)
 
        _bt_adapter_set_status(BT_DEACTIVATED);
 
-               /* Send disabled event */
-       _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISABLED,
-                       DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
-
-#if 0
        if (_bt_adapter_get_le_status() != BT_LE_DEACTIVATED) {
                /* Send disabled event */
                _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISABLED,
-                               DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
+                               g_variant_new("(i)", result));
        }
-#endif
+
+       BT_INFO("Adapter disabled");
 }
 
 static int __bt_set_le_enabled(void)
@@ -886,11 +584,14 @@ static int __bt_set_le_enabled(void)
 
        __bt_set_local_name();
 
-#ifdef ENABLE_TIZEN_2_4
        /* Update Bluetooth Status to notify other modules */
        if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_ON) != 0)
                BT_ERR("Set vconf failed\n");
-#endif
+
+       if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_LE_STATE,
+                                               EVT_VAL_BT_LE_ON) != ES_R_OK)
+               BT_ERR("Fail to set value");
+
        /* Send enabled event to API */
        /*
        _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_ENABLED,
@@ -908,7 +609,7 @@ static int __bt_set_le_enabled(void)
 
        /* Send enabled event to API */
        _bt_send_event(BT_LE_ADAPTER_EVENT, BLUETOOTH_EVENT_LE_ENABLED,
-                               DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
+                               g_variant_new("(i)", result));
 
        BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
@@ -925,16 +626,18 @@ void _bt_set_le_disabled(int result)
 
        /* Update Bluetooth Status to notify other modules */
        BT_DBG("Update vconf for BT LE normal Deactivation");
-#ifdef ENABLE_TIZEN_2_4
        if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_OFF) != 0)
                BT_ERR("Set vconf failed\n");
        _bt_adapter_set_le_status(BT_LE_DEACTIVATED);
-#endif
+
+       if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_LE_STATE,
+                                               EVT_VAL_BT_LE_OFF) != ES_R_OK)
+               BT_ERR("Fail to set value");
 
        if (_bt_adapter_get_status() != BT_DEACTIVATED) {
                /* Send disabled event */
                _bt_send_event(BT_LE_ADAPTER_EVENT, BLUETOOTH_EVENT_LE_DISABLED,
-                               DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
+                               g_variant_new_int32(result));
        }
 }
 
@@ -945,19 +648,36 @@ void *_bt_get_adapter_agent(void)
 
 int _bt_enable_core(void)
 {
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
+       GVariant *result;
+       GError *error = NULL;
 
        proxy = __bt_get_core_proxy();
        retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
 
-       if (dbus_g_proxy_call(proxy, "EnableCore", NULL,
-                       G_TYPE_INVALID, G_TYPE_INVALID) == FALSE) {
-               BT_ERR("Bt core call failed");
+       /* Clean up the process */
+       result = g_dbus_proxy_call_sync(proxy,
+                               "EnableCore",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Bt core call failed(Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Bt core call failed");
+               return BLUETOOTH_ERROR_INTERNAL;
        }
 
+       g_variant_unref(result);
        return BLUETOOTH_ERROR_NONE;
 }
 
+#if defined(TIZEN_BT_FLIGHTMODE_ENABLED) || !defined(TIZEN_WEARABLE)
 static void __bt_service_flight_ps_mode_cb(keynode_t *node, void *data)
 {
        gboolean flight_mode = FALSE;
@@ -985,29 +705,25 @@ static void __bt_service_flight_ps_mode_cb(keynode_t *node, void *data)
 
        _bt_enable_core();
 }
+#endif
 
 void _bt_service_register_vconf_handler(void)
 {
-       int ret;
        BT_DBG("+");
 
 #ifdef TIZEN_TELEPHONY_ENABLED
-       ret = vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
-               (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL);
-       if (ret < 0)
+       if (vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+                       (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
                BT_ERR("Unable to register key handler");
 #else
        BT_DBG("Telephony is disabled");
 #endif
 
 #ifndef TIZEN_WEARABLE
-#ifdef ENABLE_TIZEN_2_4
-       ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
-                       (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL);
-       if (ret < 0)
+       if (vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
+                       (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
                BT_ERR("Unable to register key handler");
 #endif
-#endif
 }
 
 void _bt_service_unregister_vconf_handler(void)
@@ -1016,50 +732,27 @@ void _bt_service_unregister_vconf_handler(void)
 
 #ifdef TIZEN_TELEPHONY_ENABLED
        vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
-               (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
+                       (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
 #endif
 
 #ifndef TIZEN_WEARABLE
-#ifdef ENABLE_TIZEN_2_4
        vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE,
                        (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
 #endif
-#endif
 }
 
-static int _bt_set_powered(gboolean is_powered)
+static void __bt_state_event_handler(const char *event_name, bundle *data, void *user_data)
 {
-       DBusGProxy *proxy;
-       GValue powered = { 0 };
-       GError *error = NULL;
+       const char *bt_status = NULL;
+       const char *bt_le_status = NULL;
+       const char *bt_transfering_status = NULL;
+       BT_DBG("bt state set event(%s) received", event_name);
 
-       if (__bt_is_factory_test_mode()) {
-               BT_ERR("Unable to set power in factory binary !!");
-               return BLUETOOTH_ERROR_NOT_SUPPORT;
-       }
+       bt_status = bundle_get_val(data, EVT_KEY_BT_STATE);
+       BT_DBG("bt_state: (%s)", bt_status);
 
-       proxy = _bt_get_adapter_properties_proxy();
-
-       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       g_value_init(&powered, G_TYPE_BOOLEAN);
-       g_value_set_boolean(&powered, is_powered);
-
-       dbus_g_proxy_call(proxy, "Set", &error,
-                                                       G_TYPE_STRING, BT_ADAPTER_INTERFACE,
-                                                       G_TYPE_STRING, "Powered",
-                                                       G_TYPE_VALUE, &powered,
-                                                       G_TYPE_INVALID, G_TYPE_INVALID);
-
-       g_value_unset(&powered);
-       if (error != NULL) {
-               BT_ERR("Powered set err:\n [%s]", error->message);
-               g_error_free(error);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       BT_INFO("Set powered [%d]", is_powered);
-       return BLUETOOTH_ERROR_NONE;
+       bt_le_status = bundle_get_val(data, EVT_KEY_BT_LE_STATE);
+       BT_DBG("bt_state: (%s)", bt_le_status);
 }
 
 void _bt_handle_adapter_added(void)
@@ -1083,26 +776,18 @@ void _bt_handle_adapter_added(void)
        adapter_agent = _bt_create_agent(BT_ADAPTER_AGENT_PATH, TRUE);
        if (!adapter_agent) {
                BT_ERR("Fail to register agent");
-               //return;
+               return;
        }
 
-#ifdef __TIZEN_MOBILE__
-       if (!aul_app_is_running("org.tizen.bluetooth"))
-                       __launch_bt_service(0, 0);
-
        if (_bt_register_media_player() != BLUETOOTH_ERROR_NONE)
                BT_ERR("Fail to register media player");
 
-#endif
-
        if (_bt_register_obex_server() != BLUETOOTH_ERROR_NONE)
                BT_ERR("Fail to init obex server");
 
-#ifndef TIZEN_WEARABLE
-/*
+#ifdef TIZEN_BT_PAN_NAP_ENABLE
        if (_bt_network_activate() != BLUETOOTH_ERROR_NONE)
                BT_ERR("Fail to activate network");
-*/
 #endif
 
        /* add the vconf noti handler */
@@ -1115,18 +800,19 @@ void _bt_handle_adapter_added(void)
                __bt_set_le_enabled();
                _bt_adapter_set_le_status(BT_LE_ACTIVATED);
        }
-
-       BT_ERR("Activating BT ......");
-
        if (status == BT_ACTIVATING) {
                __bt_set_enabled();
                _bt_adapter_set_status(BT_ACTIVATED);
        }
-#ifdef ENABLE_TIZEN_2_4
        journal_bt_on();
-#endif
 
        _bt_service_register_vconf_handler();
+
+       /* eventsystem */
+       if (eventsystem_register_event(SYS_EVENT_BT_STATE, &status_reg_id,
+                       (eventsystem_handler)__bt_state_event_handler, NULL) != ES_R_OK) {
+               BT_ERR("Fail to register system event");
+       }
 }
 
 void _bt_handle_adapter_removed(void)
@@ -1134,9 +820,7 @@ void _bt_handle_adapter_removed(void)
        int ret;
 
        _bt_adapter_set_status(BT_DEACTIVATED);
-#ifdef ENABLE_TIZEN_2_4
        journal_bt_off();
-#endif
 
        __bt_visibility_alarm_remove();
 
@@ -1155,11 +839,18 @@ void _bt_handle_adapter_removed(void)
        adapter_agent = NULL;
 
        _bt_reliable_terminate_service(NULL);
+
+       if (eventsystem_unregister_event(status_reg_id) != ES_R_OK) {
+               BT_ERR("Fail to unregister system event");
+       }
+
 }
 
 static gboolean __bt_enable_timeout_cb(gpointer user_data)
 {
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
+       GVariant *result;
+       GError *error = NULL;
 
        timer_id = 0;
 
@@ -1172,16 +863,27 @@ static gboolean __bt_enable_timeout_cb(gpointer user_data)
                return FALSE;
 
        /* Clean up the process */
-       if (dbus_g_proxy_call(proxy, "DisableAdapter", NULL,
-                               G_TYPE_INVALID, G_TYPE_INVALID) == FALSE) {
-               BT_ERR("Bt core call failed");
+       result = g_dbus_proxy_call_sync(proxy,
+                               "DisableAdapter",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Bt core call failed(Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else {
+                       BT_ERR("Bt core call failed");
+               }
+               return FALSE;
        }
 
+       g_variant_unref(result);
        _bt_set_disabled(BLUETOOTH_ERROR_TIMEOUT);
 
-       /* Display notification */
-       notification_status_message_post(BT_STR_NOT_SUPPORT);
-
        _bt_terminate_service(NULL);
 
        return FALSE;
@@ -1189,7 +891,9 @@ static gboolean __bt_enable_timeout_cb(gpointer user_data)
 
 static gboolean __bt_enable_le_timeout_cb(gpointer user_data)
 {
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
+       GVariant *result;
+       GError *error = NULL;
 
        le_timer_id = 0;
 
@@ -1202,18 +906,28 @@ static gboolean __bt_enable_le_timeout_cb(gpointer user_data)
                return FALSE;
 
        /* Clean up the process */
-       if (dbus_g_proxy_call(proxy, "DisableAdapterLe", NULL,
-                               G_TYPE_INVALID, G_TYPE_INVALID) == FALSE) {
-               BT_ERR("Bt core call failed");
+       result = g_dbus_proxy_call_sync(proxy,
+                               "DisableAdapterLe",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Bt core call failed(Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Bt core call failed");
+               return FALSE;
        }
 
+       g_variant_unref(result);
        _bt_adapter_set_le_status(BT_LE_DEACTIVATED);
 
        _bt_set_le_disabled(BLUETOOTH_ERROR_TIMEOUT);
 
-       /* Display notification */
-       notification_status_message_post(BT_STR_NOT_SUPPORT);
-
        if (_bt_adapter_get_status() == BT_DEACTIVATED)
                _bt_terminate_service(NULL);
 
@@ -1248,11 +962,13 @@ void _bt_adapter_start_enable_timer(void)
 
 int _bt_enable_adapter(void)
 {
-       DBusGProxy *proxy;
-       GError *err = NULL;
+       GDBusProxy *proxy;
+       GError *error = NULL;
        int ret;
+       GVariant *result = NULL;
        bt_status_t status = _bt_adapter_get_status();
        bt_le_status_t le_status = _bt_adapter_get_le_status();
+
        BT_DBG("");
 
        if (status == BT_ACTIVATING) {
@@ -1285,32 +1001,34 @@ int _bt_enable_adapter(void)
                        return BLUETOOTH_ERROR_INTERNAL;
                }
        }
-        if (dbus_g_proxy_call_with_timeout(proxy, "EnableAdapter",
-                                       BT_ENABLE_TIMEOUT, &err,
-                                       G_TYPE_INVALID,
-                                       G_TYPE_INVALID) == FALSE) {
 
-               _bt_adapter_set_status(BT_DEACTIVATED);
-
-               if (err != NULL) {
-                       BT_ERR("Bt core call failed: [%s]", err->message);
-                       g_error_free(err);
+       result = g_dbus_proxy_call_sync(proxy, "EnableAdapter",
+                                        NULL,
+                                        G_DBUS_CALL_FLAGS_NONE, BT_ENABLE_TIMEOUT,
+                                        NULL, &error);
+        if (error) {
+                BT_ERR("EnableAdapterLe failed: %s", error->message);
+               _bt_adapter_set_status(BT_DEACTIVATED);
+               g_clear_error(&error);
+               error = NULL;
+               result = g_dbus_proxy_call_sync(proxy,
+                               "DisableAdapter",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+               if (error != NULL) {
+                               BT_ERR("Bt core call failed(Error: %s)", error->message);
+                               g_clear_error(&error);
                }
-
-               /* Clean up the process */
-               if (dbus_g_proxy_call(proxy, "DisableAdapter", NULL,
-                               G_TYPE_INVALID, G_TYPE_INVALID) == FALSE) {
-                               BT_ERR("Bt core call failed");
-               }
-
-               /* Display notification */
-               notification_status_message_post(BT_STR_NOT_SUPPORT);
-
+               g_variant_unref(result);
                /* Terminate myself */
                g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
                return BLUETOOTH_ERROR_INTERNAL;
        }
-
+       g_variant_unref(result);
        if (le_status == BT_LE_ACTIVATED) {
                __bt_set_enabled();
        } else {
@@ -1323,10 +1041,11 @@ int _bt_enable_adapter(void)
 static gboolean __bt_disconnect_all(void)
 {
        int i;
-       DBusGConnection *conn;
-       DBusGProxy *dev_proxy;
+       GDBusConnection *conn;
+       GDBusProxy *dev_proxy;
        gboolean ret = FALSE;
-
+       GVariant *result;
+       GError *error = NULL;
        GArray *device_list;
        bluetooth_device_info_t info;
        guint size;
@@ -1353,7 +1072,7 @@ static gboolean __bt_disconnect_all(void)
                info = g_array_index(device_list,
                                bluetooth_device_info_t, i);
 
-               if (info.connected == TRUE) {
+               if (info.connected != BLUETOOTH_CONNECTED_LINK_NONE) {
                        BT_DBG("Found Connected device");
                        _bt_convert_addr_type_to_string(address, info.device_address.addr);
                        device_path = _bt_get_device_object_path(address);
@@ -1362,17 +1081,36 @@ static gboolean __bt_disconnect_all(void)
 
                        BT_DBG("Disconnecting : %s", device_path);
 
-                       dev_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                                       device_path, BT_DEVICE_INTERFACE);
+                       dev_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                       NULL,
+                                                       BT_BLUEZ_NAME,
+                                                       device_path,
+                                                       BT_DEVICE_INTERFACE,
+                                                       NULL, NULL);
+
                        if (dev_proxy == NULL)
                                continue;
 
-                       if(!dbus_g_proxy_call(dev_proxy, "Disconnect",
-                                               NULL, G_TYPE_INVALID, G_TYPE_INVALID)) {
-                               BT_ERR("Disconnect fail error.");
+                       result = g_dbus_proxy_call_sync(dev_proxy,
+                                               "Disconnect",
+                                               NULL,
+                                               G_DBUS_CALL_FLAGS_NONE,
+                                               -1,
+                                               NULL,
+                                               &error);
+
+                       if (!result) {
+                               if (error != NULL) {
+                                       BT_ERR("Disconnect call failed(Error: %s)", error->message);
+                                       g_clear_error(&error);
+                               } else
+                                       BT_ERR("Disconnect call failed");
                                g_object_unref(dev_proxy);
                                return FALSE;
                        }
+
+                       g_variant_unref(result);
+                       g_object_unref(dev_proxy);
                }
        }
        ret = TRUE;
@@ -1392,9 +1130,11 @@ static gboolean __bt_set_disabled_timeout_cb(gpointer user_data)
 int __bt_disable_cb(void)
 {
        FN_START;
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        bt_le_status_t le_status;
        int ret;
+       GVariant *result;
+       GError *error = NULL;
 
        _bt_adapter_set_status(BT_DEACTIVATING);
        le_status = _bt_adapter_get_le_status();
@@ -1420,18 +1160,31 @@ int __bt_disable_cb(void)
        proxy = __bt_get_core_proxy();
        retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
 
-       if (dbus_g_proxy_call(proxy, "DisableAdapter", NULL,
-                       G_TYPE_INVALID, G_TYPE_INVALID) == FALSE) {
-               BT_ERR("Bt core call failed");
+       result = g_dbus_proxy_call_sync(proxy,
+                               "DisableAdapter",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to DisableAdapter (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Failed to DisableAdapter");
                _bt_adapter_set_status(BT_ACTIVATED);
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
+       g_variant_unref(result);
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_disable_adapter(void)
 {
+       BT_DBG("+");
        int ret;
 
        if (_bt_adapter_get_status() == BT_DEACTIVATING) {
@@ -1450,7 +1203,6 @@ int _bt_disable_adapter(void)
        }
 
        __bt_disconnect_all();
-
        ret = __bt_disable_cb();
 
        BT_DBG("-");
@@ -1460,7 +1212,9 @@ int _bt_disable_adapter(void)
 int _bt_recover_adapter(void)
 {
        BT_DBG("+");
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
+       GVariant *result;
+       GError *error = NULL;
 
        if (_bt_adapter_get_status() == BT_DEACTIVATING) {
                BT_DBG("Disabling in progress");
@@ -1477,21 +1231,35 @@ int _bt_recover_adapter(void)
        proxy = __bt_get_core_proxy();
        retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
 
-       if (dbus_g_proxy_call(proxy, "RecoverAdapter", NULL,
-                                      G_TYPE_INVALID, G_TYPE_INVALID) == FALSE) {
-               BT_ERR("Bt core call failed");
+       result = g_dbus_proxy_call_sync(proxy,
+                               "RecoverAdapter",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to RecoverAdapter (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Failed to RecoverAdapter");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
+       g_variant_unref(result);
        __bt_disconnect_all();
 
-       BT_ERR("-");
+       BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_reset_adapter(void)
 {
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
+       GVariant *result;
+       GError *error = NULL;
 
        BT_DBG("");
 
@@ -1499,12 +1267,24 @@ int _bt_reset_adapter(void)
        if (!proxy)
                return BLUETOOTH_ERROR_INTERNAL;
 
-       if (dbus_g_proxy_call(proxy, "ResetAdapter", NULL,
-                                      G_TYPE_INVALID, G_TYPE_INVALID) == FALSE) {
-               BT_ERR("Bt core call failed");
+       result = g_dbus_proxy_call_sync(proxy,
+                               "ResetAdapter",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to ResetAdapter (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Failed to ResetAdapter");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
+       g_variant_unref(result);
        /* Terminate myself */
        if (_bt_adapter_get_status() == BT_DEACTIVATED) {
                g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
@@ -1515,6 +1295,7 @@ int _bt_reset_adapter(void)
 
 int _bt_check_adapter(int *status)
 {
+
        char *adapter_path = NULL;
 
        BT_CHECK_PARAMETER(status, return);
@@ -1528,17 +1309,17 @@ int _bt_check_adapter(int *status)
                *status = BT_ADAPTER_ENABLED;
 
        g_free(adapter_path);
-
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_enable_adapter_le(void)
 {
        BT_DBG("+");
-       DBusGProxy *proxy;
-       GError *err = NULL;
+       GDBusProxy *proxy;
+       GError *error = NULL;
        bt_status_t status = _bt_adapter_get_status();
        bt_le_status_t le_status = _bt_adapter_get_le_status();
+       GVariant *result;
 
        if (le_status == BT_LE_ACTIVATING) {
                BT_ERR("Enabling in progress");
@@ -1560,38 +1341,41 @@ int _bt_enable_adapter_le(void)
        proxy = __bt_get_core_proxy();
        retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
 
-#if 0 // vconf key not found so commenting to resolve build issues.
-       if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_ON) != 0)
-               BT_ERR("Set vconf failed");
-#endif
-
-       if (dbus_g_proxy_call_with_timeout(proxy, "EnableAdapterLe",
-                               BT_ENABLE_TIMEOUT, &err,
-                               G_TYPE_INVALID,
-                               G_TYPE_INVALID) == FALSE) {
-
+       result = g_dbus_proxy_call_sync(proxy, "EnableAdapterLe",
+                                       NULL,
+                                       G_DBUS_CALL_FLAGS_NONE, BT_ENABLE_TIMEOUT,
+                                       NULL, &error);
+       if (error) {
+               BT_ERR("EnableAdapterLe failed: %s", error->message);
                _bt_adapter_set_le_status(BT_DEACTIVATED);
-
-               if (err != NULL) {
-                       BT_ERR("Bt core call failed: [%s]", err->message);
-                       g_error_free(err);
-               }
+               g_clear_error(&error);
 
                /* Clean up the process */
-               if (dbus_g_proxy_call(proxy, "DisableAdapterLe", NULL,
-                                       G_TYPE_INVALID, G_TYPE_INVALID) == FALSE) {
-                       BT_ERR("Bt core call failed");
+               result = g_dbus_proxy_call_sync(proxy,
+                                       "DisableAdapterLe",
+                                       NULL,
+                                       G_DBUS_CALL_FLAGS_NONE,
+                                       -1,
+                                       NULL,
+                                       &error);
+
+               if (!result) {
+                               BT_ERR("Bt core call failed");
+                               if (error) {
+                                       BT_ERR("EnableAdapterLE Failed %s", error->message);
+                                       g_clear_error(&error);
+                               }
                }
-
-               /* Display notification */
-               notification_status_message_post(BT_STR_NOT_SUPPORT);
-
+               g_variant_unref(result);
                /* Terminate myself */
                if (_bt_adapter_get_status() == BT_DEACTIVATED)
                        g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
+       if (result)
+               g_variant_unref(result);
+
        _bt_adapter_start_le_enable_timer();
 
        if (status == BT_ACTIVATED) {
@@ -1606,8 +1390,10 @@ int _bt_enable_adapter_le(void)
 int _bt_disable_adapter_le(void)
 {
        BT_DBG("+");
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        bt_le_status_t bt_le_state;
+       GVariant *result;
+       GError *error = NULL;
 
        bt_le_state = _bt_adapter_get_le_status();
        if (bt_le_state == BT_LE_DEACTIVATING) {
@@ -1625,18 +1411,26 @@ int _bt_disable_adapter_le(void)
        proxy = __bt_get_core_proxy();
        if (!proxy)
                return BLUETOOTH_ERROR_INTERNAL;
-#if 0 // vconf key not found so commenting to resolve build issues.
-       if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_OFF) != 0)
-               BT_ERR("Set vconf failed");
-#endif
 
-       if (dbus_g_proxy_call(proxy, "DisableAdapterLe", NULL,
-                                      G_TYPE_INVALID, G_TYPE_INVALID) == FALSE) {
-               BT_ERR("Bt core call failed");
+       result = g_dbus_proxy_call_sync(proxy,
+                               "DisableAdapterLe",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Bt core call failed (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Bt core call failed");
                _bt_adapter_set_le_status(BT_LE_ACTIVATED);
                return BLUETOOTH_ERROR_INTERNAL;
-       }
+       }
 
+       g_variant_unref(result);
        _bt_set_le_disabled(BLUETOOTH_ERROR_NONE);
        BT_DBG("le status : %d", _bt_adapter_get_le_status());
        BT_DBG("-");
@@ -1646,30 +1440,38 @@ int _bt_disable_adapter_le(void)
 int _bt_get_local_address(bluetooth_device_address_t *local_address)
 {
 
-       DBusGProxy *proxy;
-       GError *err = NULL;
-       char *address;
-       GValue address_v = { 0 };
+       GDBusProxy *proxy;
+       GError *error = NULL;
+       const char *address;
+       GVariant *result;
+       GVariant *temp;
 
        BT_CHECK_PARAMETER(local_address, return);
 
        proxy = _bt_get_adapter_properties_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       if (!dbus_g_proxy_call(proxy, "Get", &err,
-                       G_TYPE_STRING, BT_ADAPTER_INTERFACE,
-                       G_TYPE_STRING, "Address",
-                       G_TYPE_INVALID,
-                       G_TYPE_VALUE, &address_v,
-                       G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("Getting property failed: [%s]\n", err->message);
-                       g_error_free(err);
+       result = g_dbus_proxy_call_sync(proxy,
+                               "Get",
+                               g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
+                                       "Address"),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               BT_ERR("Failed to get local address");
+               if (error != NULL) {
+                       BT_ERR("Failed to get local address (Error: %s)", error->message);
+                       g_clear_error(&error);
                }
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       address = (char *)g_value_get_string(&address_v);
+       g_variant_get(result, "(v)", &temp);
+       address = g_variant_get_string(temp, NULL);
+       BT_DBG("Address:%s", address);
 
        if (address) {
                _bt_convert_addr_string_to_type(local_address->addr, address);
@@ -1677,40 +1479,48 @@ int _bt_get_local_address(bluetooth_device_address_t *local_address)
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
+       g_variant_unref(result);
+       g_variant_unref(temp);
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_get_local_version(bluetooth_version_t *local_version)
 {
-       DBusGProxy *proxy;
-       GHashTable *hash = NULL;
-       char *ver = NULL;
+       GDBusProxy *proxy;
+       const char *ver = NULL;
        char *ptr = NULL;
        int ret = BLUETOOTH_ERROR_NONE;
+       GVariant *result;
+       GVariant *temp;
 
        BT_CHECK_PARAMETER(local_version, return);
 
-       GError *err = NULL;
-       GValue version_v = { 0 };
+       GError *error = NULL;
 
        proxy = _bt_get_adapter_properties_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       if (!dbus_g_proxy_call(proxy, "Get", &err,
-                       G_TYPE_STRING, BT_ADAPTER_INTERFACE,
-                       G_TYPE_STRING, "Version",
-                       G_TYPE_INVALID,
-                       G_TYPE_VALUE, &version_v,
-                       G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("Getting property failed: [%s]\n", err->message);
-                       g_error_free(err);
-               }
+       result = g_dbus_proxy_call_sync(proxy,
+                               "Get",
+                               g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
+                                       "Version"),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to get local version (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Failed to get local version");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       ver = (char *)g_value_get_string(&version_v);
-
+       g_variant_get(result, "(v)", &temp);
+       ver = g_variant_get_string(temp, NULL);
+       BT_DBG("VERSION: %s", ver);
 
        if (ver && (strlen(ver) > 0)) {
                /* Check the utf8 valitation & Fill the NULL in the invalid location*/
@@ -1724,40 +1534,47 @@ int _bt_get_local_version(bluetooth_version_t *local_version)
                ret = BLUETOOTH_ERROR_INTERNAL;
        }
 
-       g_hash_table_destroy(hash);
+       g_variant_unref(result);
+       g_variant_unref(temp);
        return ret;
 }
 
 int _bt_get_local_name(bluetooth_device_name_t *local_name)
 {
-       DBusGProxy *proxy;
-       GHashTable *hash = NULL;
-       char *name = NULL;
+       GDBusProxy *proxy;
+       const char *name = NULL;
        char *ptr = NULL;
        int ret = BLUETOOTH_ERROR_NONE;
-
-       GError *err = NULL;
-       GValue name_v = { 0 };
+       GVariant *result;
+       GVariant *temp;
+       GError *error = NULL;
 
        BT_CHECK_PARAMETER(local_name, return);
 
        proxy = _bt_get_adapter_properties_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       if (!dbus_g_proxy_call(proxy, "Get", &err,
-                       G_TYPE_STRING, BT_ADAPTER_INTERFACE,
-                       G_TYPE_STRING, "Alias",
-                       G_TYPE_INVALID,
-                       G_TYPE_VALUE, &name_v,
-                       G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("Getting property failed: [%s]\n", err->message);
-                       g_error_free(err);
-               }
+       result = g_dbus_proxy_call_sync(proxy,
+                               "Get",
+                               g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
+                                       "Alias"),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to get local name (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Failed to get local name");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       name = (char *)g_value_get_string(&name_v);
+       g_variant_get(result, "(v)", &temp);
+       name = g_variant_get_string(temp, NULL);
+       BT_DBG("LOCAL NAME:%s", name);
 
        if (name && (strlen(name) > 0)) {
                /* Check the utf8 valitation & Fill the NULL in the invalid location*/
@@ -1769,17 +1586,17 @@ int _bt_get_local_name(bluetooth_device_name_t *local_name)
        } else {
                ret = BLUETOOTH_ERROR_INTERNAL;
        }
-
-       g_hash_table_destroy(hash);
+       g_variant_unref(result);
+       g_variant_unref(temp);
        return ret;
 }
 
 int _bt_set_local_name(char *local_name)
 {
-       GValue name = { 0 };
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        GError *error = NULL;
        char *ptr = NULL;
+       GVariant *result;
 
        BT_CHECK_PARAMETER(local_name, return);
 
@@ -1790,34 +1607,36 @@ int _bt_set_local_name(char *local_name)
        if (!g_utf8_validate(local_name, -1, (const char **)&ptr))
                *ptr = '\0';
 
-       g_value_init(&name, G_TYPE_STRING);
-       g_value_set_string(&name, local_name);
-
-       dbus_g_proxy_call(proxy, "Set", &error,
-                       G_TYPE_STRING, BT_ADAPTER_INTERFACE,
-                       G_TYPE_STRING, "Alias",
-                       G_TYPE_VALUE, &name,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
-
-       g_value_unset(&name);
-
-       if (error) {
-               BT_ERR("SetProperty Fail: %s", error->message);
-               g_error_free(error);
+       result = g_dbus_proxy_call_sync(proxy,
+                               "Set",
+                               g_variant_new("(ssv)", BT_ADAPTER_INTERFACE,
+                                       "Alias", g_variant_new("s", local_name)),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to set Alias (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Failed to set Alias");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
+       g_variant_unref(result);
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_is_service_used(char *service_uuid, gboolean *used)
 {
-       char **uuids;
-       int i;
-       DBusGProxy *proxy;
-       GError *err = NULL;
-       GValue uuids_v = { 0 };
+       GDBusProxy *proxy;
+       GError *error = NULL;
        int ret = BLUETOOTH_ERROR_NONE;
+       GVariant *result;
+       GVariantIter *iter;
+       gchar *uuid;
 
        BT_DBG("+");
        BT_CHECK_PARAMETER(service_uuid, return);
@@ -1826,64 +1645,79 @@ int _bt_is_service_used(char *service_uuid, gboolean *used)
        proxy = _bt_get_adapter_properties_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       if (!dbus_g_proxy_call(proxy, "Get", &err,
-                       G_TYPE_STRING, BT_ADAPTER_INTERFACE,
-                       G_TYPE_STRING, "UUIDs",
-                       G_TYPE_INVALID,
-                       G_TYPE_VALUE, &uuids_v,
-                       G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("Getting property failed: [%s]\n", err->message);
-                       g_error_free(err);
-               }
+       result = g_dbus_proxy_call_sync(proxy,
+                               "Get",
+                               g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
+                                       "UUIDs"),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to get UUIDs (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Failed to get UUIDs");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       uuids = g_value_get_boxed(&uuids_v);
-
-       if (uuids == NULL) {
-               /* Normal case */
-               *used = FALSE;
-               goto done;
-       }
-
-       for (i = 0; uuids[i] != NULL; i++) {
-               if (strcasecmp(uuids[i], service_uuid) == 0) {
+       g_variant_get(result, "as", &iter);
+       while (g_variant_iter_loop(iter, "s", &uuid)) {
+               if (strcasecmp(uuid, service_uuid) == 0) {
                        *used = TRUE;
+                       g_free(uuid);
                        goto done;
                }
        }
 
        *used = FALSE;
+
 done:
+       g_variant_iter_free(iter);
+       g_variant_unref(result);
        BT_DBG("Service Used? %d", *used);
        return ret;
 }
 
-
 static gboolean __bt_get_discoverable_property(void)
 {
-       DBusGProxy *proxy;
-       GValue discoverable_v = { 0 };
-       GError *err = NULL;
+       GDBusProxy *proxy;
+       gboolean discoverable_v;
+       GError *error = NULL;
+       GVariant *result;
+       GVariant *temp;
 
        proxy = _bt_get_adapter_properties_proxy();
        retv_if(proxy == NULL, FALSE);
 
-       if (!dbus_g_proxy_call(proxy, "Get", &err,
-                       G_TYPE_STRING, BT_ADAPTER_INTERFACE,
-                       G_TYPE_STRING, "Discoverable",
-                       G_TYPE_INVALID,
-                       G_TYPE_VALUE, &discoverable_v,
-                       G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("Getting property failed: [%s]\n", err->message);
-                       g_error_free(err);
-               }
-               return FALSE;
+       result = g_dbus_proxy_call_sync(proxy,
+                               "Get",
+                               g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
+                                       "Discoverable"),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to get Discoverable property (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Failed to get Discoverable property");
+               return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       return g_value_get_boolean(&discoverable_v);
+       g_variant_get(result, "(v)", &temp);
+       discoverable_v = g_variant_get_boolean(temp);
+       BT_DBG("discoverable_v:%d", discoverable_v);
+
+       g_variant_unref(result);
+       g_variant_unref(temp);
+
+       return discoverable_v;
 }
 
 int _bt_get_discoverable_mode(int *mode)
@@ -1914,19 +1748,13 @@ int _bt_set_discoverable_mode(int discoverable_mode, int timeout)
        gboolean inq_scan;
        gboolean pg_scan;
        GError *error = NULL;
-       GValue connectable = { 0 };
-       GValue discoverable = { 0 };
-       GValue val_timeout = { 0 };
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
+       GVariant *result;
 
        proxy = _bt_get_adapter_properties_proxy();
 
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       g_value_init(&connectable, G_TYPE_BOOLEAN);
-       g_value_init(&discoverable, G_TYPE_BOOLEAN);
-       g_value_init(&val_timeout, G_TYPE_UINT);
-
        switch (discoverable_mode) {
        case BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE:
                pg_scan = TRUE;
@@ -1949,48 +1777,58 @@ int _bt_set_discoverable_mode(int discoverable_mode, int timeout)
        BT_INFO("Req. discoverable_mode : %d, timeout : %d",
                        discoverable_mode, timeout);
 
-       g_value_set_boolean(&connectable, pg_scan);
-       g_value_set_boolean(&discoverable, inq_scan);
-       g_value_set_uint(&val_timeout, timeout);
-
-       dbus_g_proxy_call(proxy, "Set", &error,
-                               G_TYPE_STRING, BT_ADAPTER_INTERFACE,
-                               G_TYPE_STRING, "Connectable",
-                               G_TYPE_VALUE, &connectable,
-                               G_TYPE_INVALID, G_TYPE_INVALID);
-
-       if (error != NULL) {
-               BT_ERR("Connectable set err:[%s]", error->message);
-               g_error_free(error);
-               ret = BLUETOOTH_ERROR_INTERNAL;
-               goto done;
+       result = g_dbus_proxy_call_sync(proxy,
+                               "Set",
+                               g_variant_new("(ssv)", BT_ADAPTER_INTERFACE,
+                                       "Connectable", g_variant_new("b", pg_scan)),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to set connectable property (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Failed to set connectable property");
+               return BLUETOOTH_ERROR_INTERNAL;
        }
-
-       dbus_g_proxy_call(proxy, "Set", &error,
-                               G_TYPE_STRING, BT_ADAPTER_INTERFACE,
-                               G_TYPE_STRING, "Discoverable",
-                               G_TYPE_VALUE, &discoverable,
-                               G_TYPE_INVALID, G_TYPE_INVALID);
-
-
-       if (error != NULL) {
-               BT_ERR("Discoverable set err:[%s]", error->message);
-               g_error_free(error);
-               ret = BLUETOOTH_ERROR_INTERNAL;
-               goto done;
+       g_variant_unref(result);
+       result = g_dbus_proxy_call_sync(proxy,
+                               "Set",
+                               g_variant_new("(ssv)", BT_ADAPTER_INTERFACE, "Discoverable",
+                                               g_variant_new("b", inq_scan)),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to set Discoverable property (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Failed to set Discoverable property");
+               return BLUETOOTH_ERROR_INTERNAL;
        }
-
-       dbus_g_proxy_call(proxy, "Set", &error,
-                               G_TYPE_STRING, BT_ADAPTER_INTERFACE,
-                               G_TYPE_STRING, "DiscoverableTimeout",
-                               G_TYPE_VALUE, &val_timeout,
-                               G_TYPE_INVALID, G_TYPE_INVALID);
-
-       if (error != NULL) {
-               BT_ERR("Timeout set err:[%s]", error->message);
-               g_error_free(error);
-               ret = BLUETOOTH_ERROR_INTERNAL;
-               goto done;
+       g_variant_unref(result);
+       result = g_dbus_proxy_call_sync(proxy,
+                               "Set",
+                               g_variant_new("(ssv)", BT_ADAPTER_INTERFACE,
+                                       "DiscoverableTimeout", g_variant_new("u", timeout)),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to set DiscoverableTimeout property (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Failed to set DiscoverableTimeout property");
+               return BLUETOOTH_ERROR_INTERNAL;
        }
 
        if (discoverable_mode == BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE)
@@ -1998,18 +1836,16 @@ int _bt_set_discoverable_mode(int discoverable_mode, int timeout)
 
        ret = __bt_set_visible_time(timeout);
 
-done:
-       g_value_unset(&val_timeout);
-       g_value_unset(&connectable);
-       g_value_unset(&discoverable);
+       g_variant_unref(result);
 
        return ret;
 }
 
 int _bt_start_discovery(void)
 {
-       DBusGProxy *proxy;
-       GError *err = NULL;
+       GDBusProxy *proxy;
+       GError *error = NULL;
+       GVariant *result;
 
        if (_bt_is_discovering() == TRUE) {
                BT_ERR("BT is already in discovering");
@@ -2022,28 +1858,35 @@ int _bt_start_discovery(void)
        proxy = _bt_get_adapter_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       if (!dbus_g_proxy_call(proxy, "StartDiscovery", &err,
-                              G_TYPE_INVALID, G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("StartDiscovery failed: [%s]\n", err->message);
-                       g_error_free(err);
-               }
-               BT_ERR("Discover start failed");
+       result = g_dbus_proxy_call_sync(proxy,
+                               "StartDiscovery",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("StartDiscovery failed (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("StartDiscovery failed");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
        is_discovering = TRUE;
        cancel_by_user = FALSE;
        /* discovery status will be change in event */
-               BT_ERR("_bt_start_discovery 3");
-
+       g_variant_unref(result);
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_start_custom_discovery(bt_discovery_role_type_t role)
 {
-       DBusGProxy *proxy;
-
+       GDBusProxy *proxy;
+       GVariant *result;
+       GError *error = NULL;
        const gchar *disc_type;
 
        if (_bt_is_discovering() == TRUE) {
@@ -2063,24 +1906,35 @@ int _bt_start_custom_discovery(bt_discovery_role_type_t role)
        else
                return BLUETOOTH_ERROR_INVALID_PARAM;
 
-       if (!dbus_g_proxy_call(proxy, "StartCustomDiscovery", NULL,
-                        G_TYPE_STRING, disc_type,
-                              G_TYPE_INVALID, G_TYPE_INVALID)) {
-               BT_ERR("StartCustomDiscovery failed");
+       result = g_dbus_proxy_call_sync(proxy,
+                               "StartCustomDiscovery",
+                               g_variant_new("s", disc_type),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("StartCustomDiscovery failed (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("StartCustomDiscovery failed");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
        is_discovering = TRUE;
        cancel_by_user = FALSE;
        /* discovery status will be change in event */
-
+       g_variant_unref(result);
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_cancel_discovery(void)
 {
-       DBusGProxy *proxy;
-       GError *err = NULL;
+       GDBusProxy *proxy;
+       GError *error = NULL;
+       GVariant *result;
 
        if (_bt_is_discovering() == FALSE) {
                BT_ERR("BT is not in discovering");
@@ -2090,109 +1944,79 @@ int _bt_cancel_discovery(void)
        proxy = _bt_get_adapter_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       if (!dbus_g_proxy_call(proxy, "StopDiscovery", &err,
-                              G_TYPE_INVALID, G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("StopDiscovery failed: [%s]\n", err->message);
-                       g_error_free(err);
-               }
+       result = g_dbus_proxy_call_sync(proxy,
+                               "StopDiscovery",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("StopDiscovery failed (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("StopDiscovery failed");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
        cancel_by_user = TRUE;
        /* discovery status will be change in event */
-
+       g_variant_unref(result);
        return BLUETOOTH_ERROR_NONE;
 }
 
-int _bt_start_le_discovery(void)
-{
-   DBusGProxy *proxy;
-
-   if (_bt_is_le_discovering() == TRUE) {
-       BT_ERR("BT is already in LE discovering");
-       return BLUETOOTH_ERROR_IN_PROGRESS;
-   }
-
-   proxy = _bt_get_adapter_proxy();
-   retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-   if (!dbus_g_proxy_call(proxy, "StartLEDiscovery", NULL,
-                  G_TYPE_INVALID, G_TYPE_INVALID)) {
-       BT_ERR("LE Discover start failed");
-       return BLUETOOTH_ERROR_INTERNAL;
-   }
-
-   is_le_discovering = TRUE;
-
-   return BLUETOOTH_ERROR_NONE;
-}
-
-int _bt_stop_le_discovery(void)
-{
-   DBusGProxy *proxy;
-
-   if (_bt_is_le_discovering() == FALSE) {
-       BT_ERR("BT is not in LE discovering");
-       return BLUETOOTH_ERROR_NOT_IN_OPERATION;
-   }
-
-   proxy = _bt_get_adapter_proxy();
-   retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-   if (!dbus_g_proxy_call(proxy, "StopLEDiscovery", NULL,
-                  G_TYPE_INVALID, G_TYPE_INVALID)) {
-       BT_ERR("LE Discover stop failed");
-       return BLUETOOTH_ERROR_INTERNAL;
-   }
-
-   return BLUETOOTH_ERROR_NONE;
-}
-
 gboolean _bt_is_discovering(void)
 {
        return is_discovering;
 }
 
-gboolean _bt_is_le_discovering(void)
-{
-   return is_le_discovering;
-}
-
 gboolean _bt_is_connectable(void)
 {
-       DBusGProxy *proxy;
-       GValue connectable_v = { 0 };
-       GError *err = NULL;
+       GDBusProxy *proxy;
+       GError *error = NULL;
        gboolean is_connectable = FALSE;
+       GVariant *result;
+       GVariant *temp;
 
        proxy = _bt_get_adapter_properties_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       if (!dbus_g_proxy_call(proxy, "Get", &err,
-                       G_TYPE_STRING, BT_ADAPTER_INTERFACE,
-                       G_TYPE_STRING, "Connectable",
-                       G_TYPE_INVALID,
-                       G_TYPE_VALUE, &connectable_v,
-                       G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("Getting property failed: [%s]\n", err->message);
-                       g_error_free(err);
-               }
+       result = g_dbus_proxy_call_sync(proxy,
+                               "Get",
+                               g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
+                                       "Connectable"),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to get connectable property (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Failed to get connectable property");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       is_connectable = g_value_get_boolean(&connectable_v);
-       BT_INFO("Get connectable [%d]", is_connectable);
+       g_variant_get(result, "(v)", &temp);
+       is_connectable = g_variant_get_boolean(temp);
+       BT_DBG("discoverable_v:%d", is_connectable);
+
+       g_variant_unref(result);
+       g_variant_unref(temp);
 
+       BT_INFO("Get connectable [%d]", is_connectable);
        return is_connectable;
 }
 
 int _bt_set_connectable(gboolean is_connectable)
 {
-       DBusGProxy *proxy;
-       GValue connectable = { 0 };
+       GDBusProxy *proxy;
        GError *error = NULL;
+       GVariant *result;
 
        if (__bt_is_factory_test_mode()) {
                BT_ERR("Unable to set connectable in factory binary !!");
@@ -2203,32 +2027,37 @@ int _bt_set_connectable(gboolean is_connectable)
 
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       g_value_init(&connectable, G_TYPE_BOOLEAN);
-       g_value_set_boolean(&connectable, is_connectable);
-
-       dbus_g_proxy_call(proxy, "Set", &error,
-                               G_TYPE_STRING, BT_ADAPTER_INTERFACE,
-                               G_TYPE_STRING, "Connectable",
-                               G_TYPE_VALUE, &connectable,
-                               G_TYPE_INVALID, G_TYPE_INVALID);
-
-       g_value_unset(&connectable);
-       if (error != NULL) {
-               BT_ERR("Connectable set err:[%s]", error->message);
-               g_error_free(error);
+       result = g_dbus_proxy_call_sync(proxy,
+                               "Set",
+                               g_variant_new("(ssv)", BT_ADAPTER_INTERFACE, "Connectable",
+                                               g_variant_new("b", is_connectable)),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to set connectable property (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Failed to set connectable property");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
        BT_INFO("Set connectable [%d]", is_connectable);
+       g_variant_unref(result);
        return BLUETOOTH_ERROR_NONE;
 }
 
 gboolean _bt_get_discovering_property(bt_discovery_role_type_t discovery_type)
 {
-       DBusGProxy *proxy;
-       GValue discovering_v = { 0 };
-       GError *err = NULL;
+       GDBusProxy *proxy;
+       gboolean discovering_v;
+       GError *error = NULL;
        char *discovering_type =  NULL;
+       GVariant *result;
+       GVariant *temp;
 
        proxy = _bt_get_adapter_properties_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
@@ -2238,297 +2067,244 @@ gboolean _bt_get_discovering_property(bt_discovery_role_type_t discovery_type)
        else if (discovery_type == DISCOVERY_ROLE_LE)
                discovering_type = "LEDiscovering";
 
-       if (!dbus_g_proxy_call(proxy, "Get", &err,
-                       G_TYPE_STRING, BT_ADAPTER_INTERFACE,
-                       G_TYPE_STRING, discovering_type,
-                       G_TYPE_INVALID,
-                       G_TYPE_VALUE, &discovering_v,
-                       G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("Getting property failed: [%s]\n", err->message);
-                       g_error_free(err);
-               }
+       result = g_dbus_proxy_call_sync(proxy,
+                               "Get",
+                               g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
+                                       discovering_type),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to get discovering property (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Failed to get discovering property");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       return g_value_get_boolean(&discovering_v);
+       g_variant_get(result, "(v)", &temp);
+       discovering_v = g_variant_get_boolean(temp);
+       BT_DBG("discoverable_v:%d", discovering_v);
+
+       g_variant_unref(result);
+       g_variant_unref(temp);
+
+       return discovering_v;
 }
 
 unsigned int _bt_get_discoverable_timeout_property(void)
 {
-       DBusGProxy *proxy;
-       GValue timeout_v = { 0 };
-       GError *err = NULL;
+       GDBusProxy *proxy;
+       unsigned int timeout_v;
+       GError *error = NULL;
+       GVariant *result;
+       GVariant *temp;
 
        proxy = _bt_get_adapter_properties_proxy();
        retv_if(proxy == NULL, 0);
 
-       if (!dbus_g_proxy_call(proxy, "Get", &err,
-                       G_TYPE_STRING, BT_ADAPTER_INTERFACE,
-                       G_TYPE_STRING, "DiscoverableTimeout",
-                       G_TYPE_INVALID,
-                       G_TYPE_VALUE, &timeout_v,
-                       G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("Getting property failed: [%s]\n", err->message);
-                       g_error_free(err);
+       result = g_dbus_proxy_call_sync(proxy,
+                               "Get",
+                               g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
+                                       "DiscoverableTimeout"),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               BT_ERR("Fail to get discoverable timeout");
+               if (error != NULL) {
+                       BT_ERR("Fail to get discoverable timeout (Error: %s)", error->message);
+                       g_clear_error(&error);
                }
                return 0;
        }
 
-       return g_value_get_uint(&timeout_v);
+       g_variant_get(result, "(v)", &temp);
+       timeout_v = g_variant_get_uint32(temp);
+       BT_DBG("discoverable_v:%d", timeout_v);
+
+       g_variant_unref(result);
+       g_variant_unref(temp);
+
+       return timeout_v;
 }
 
-static bluetooth_device_info_t *__bt_parse_device_info(DBusMessageIter *item_iter)
+static bluetooth_device_info_t *__bt_parse_device_info(GVariantIter *item_iter)
 {
-       DBusMessageIter value_iter;
        bluetooth_device_info_t *dev_info;
-
-       dbus_message_iter_recurse(item_iter, &value_iter);
-
-       if (dbus_message_iter_get_arg_type(&value_iter) != DBUS_TYPE_DICT_ENTRY) {
-               BT_DBG("No entry");
-               return NULL;
-       }
+       GVariant *value;
+       const gchar *key;
+       GByteArray *manufacturer_data = NULL;
+       guint8 char_value;
+       GVariantIter *char_value_iter;
 
        dev_info = g_malloc0(sizeof(bluetooth_device_info_t));
 
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                                               DBUS_TYPE_DICT_ENTRY) {
-               char *value = NULL;
-               char *key;
-               DBusMessageIter dict_entry;
-               DBusMessageIter iter_dict_val;
-
-               dbus_message_iter_recurse(&value_iter, &dict_entry);
-
-               dbus_message_iter_get_basic(&dict_entry, &key);
+       while (g_variant_iter_loop(item_iter, "{sv}", &key, &value)) {
 
-               if (key == NULL) {
-                       dbus_message_iter_next(&value_iter);
+               if (key == NULL)
                        continue;
-               }
-
-               if (!dbus_message_iter_next(&dict_entry)) {
-                       dbus_message_iter_next(&value_iter);
-                       continue;
-               }
-               dbus_message_iter_recurse(&dict_entry, &iter_dict_val);
 
-               if (strcasecmp(key, "Address") == 0) {
+               if (!g_strcmp0(key, "Address")) {
                        const char *address = NULL;
-                       dbus_message_iter_get_basic(&iter_dict_val, &address);
+                       address = g_variant_get_string(value, NULL);
                        _bt_convert_addr_string_to_type(dev_info->device_address.addr,
                                                        address);
-
-               } else if (strcasecmp(key, "Class") == 0) {
+               } else if(!g_strcmp0(key, "Class")) {
                        unsigned int cod;
-                       dbus_message_iter_get_basic(&iter_dict_val, &cod);
+                       cod = g_variant_get_uint32(value);
                        _bt_divide_device_class(&dev_info->device_class, cod);
-               } else if (strcasecmp(key, "Name") == 0) {
-                       dbus_message_iter_get_basic(&iter_dict_val, &value);
-
+               } else if(!g_strcmp0(key, "Name")) {
+                       const char *name = NULL;
+                       name = g_variant_get_string(value, NULL);
                        /* If there is no Alias */
                        if (strlen(dev_info->device_name.name) == 0) {
-                               g_strlcpy(dev_info->device_name.name, value,
+                               g_strlcpy(dev_info->device_name.name, name,
                                                BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1);
                        }
-               } else if (strcasecmp(key, "Alias") == 0) {
-                       dbus_message_iter_get_basic(&iter_dict_val, &value);
-
+               } else if(!g_strcmp0(key, "Alias")) {
+                       const char *alias = NULL;
+                       alias = g_variant_get_string(value, NULL);
                        /* Overwrite the name */
-                       if (value) {
+                       if (alias) {
                                memset(dev_info->device_name.name, 0x00,
                                                BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1);
-                               g_strlcpy(dev_info->device_name.name, value,
+                               g_strlcpy(dev_info->device_name.name, alias,
                                                BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1);
                        }
-               } else if (strcasecmp(key, "Connected") == 0) {
-                       dbus_message_iter_get_basic(&iter_dict_val,
-                                               &dev_info->connected);
-               } else if (strcasecmp(key, "Paired") == 0) {
-                       dbus_message_iter_get_basic(&iter_dict_val,
-                                               &dev_info->paired);
-               } else if (strcasecmp(key, "Trusted") == 0) {
-                       dbus_message_iter_get_basic(&iter_dict_val,
-                                               &dev_info->trust);
-               } else if (strcasecmp(key, "RSSI") == 0) {
-                       dbus_message_iter_get_basic(&iter_dict_val,
-                                               &dev_info->rssi);
-               } else if (strcasecmp(key, "UUIDs") == 0) {
-                       DBusMessageIter uuid_iter;
+               } else if (!g_strcmp0(key, "Connected")) {
+                       dev_info->connected = g_variant_get_byte(value);
+               } else if (!g_strcmp0(key, "Paired")) {
+                       dev_info->paired = g_variant_get_boolean(value);
+               } else if (!g_strcmp0(key, "Trusted")) {
+                       dev_info->trust = g_variant_get_boolean(value);
+               } else if (!g_strcmp0(key, "RSSI")) {
+                       dev_info->rssi = g_variant_get_int16(value);
+               } else if (!g_strcmp0(key, "UUIDs")) {
+                       GVariantIter *iter;
+                       gchar *uuid = NULL;
                        char **parts;
                        int i = 0;
 
-                       dbus_message_iter_recurse(&iter_dict_val, &uuid_iter);
+                       dev_info->service_index = 0;
+                       g_variant_get(value, "as", &iter);
+                       while (g_variant_iter_loop(iter, "s", &uuid)) {
+                               g_strlcpy(dev_info->uuids[i], uuid, BLUETOOTH_UUID_STRING_MAX);
+                               parts = g_strsplit(uuid, "-", -1);
 
-                       while (dbus_message_iter_get_arg_type(&uuid_iter) != DBUS_TYPE_INVALID) {
-                               dbus_message_iter_get_basic(&uuid_iter,
-                                                       &value);
-
-                               g_strlcpy(dev_info->uuids[i], value,
-                                               BLUETOOTH_UUID_STRING_MAX);
-
-                               parts = g_strsplit(value, "-", -1);
-
-                               if (parts == NULL || parts[0] == NULL)
+                               if (parts == NULL || parts[0] == NULL) {
+                                       g_free(uuid);
                                        break;
+                               }
 
                                dev_info->service_list_array[i] = g_ascii_strtoull(parts[0], NULL, 16);
                                g_strfreev(parts);
 
                                i++;
-                               if (!dbus_message_iter_next(&uuid_iter)) {
-                                       break;
-                               }
                        }
-
                        dev_info->service_index = i;
+                       g_variant_iter_free(iter);
                } else if (strcasecmp(key, "ManufacturerDataLen") == 0) {
-                       dbus_message_iter_get_basic(&iter_dict_val,
-                                                               &dev_info->manufacturer_data.data_len);
+                       dev_info->manufacturer_data.data_len = g_variant_get_uint16(value);
                } else if (strcasecmp(key, "ManufacturerData") == 0) {
-                       DBusMessageIter manufacturer_iter;
-                       int i = 0;
-                       char byte = 0;
-
-                       dbus_message_iter_recurse(&iter_dict_val, &manufacturer_iter);
-
-                       while (dbus_message_iter_get_arg_type(&manufacturer_iter) == DBUS_TYPE_BYTE) {
-                               dbus_message_iter_get_basic(&manufacturer_iter, &byte);
-                               dev_info->manufacturer_data.data[i] = byte;
-                               i++;
-                               dbus_message_iter_next(&manufacturer_iter);
+                       manufacturer_data = g_byte_array_new();
+                       g_variant_get(value, "ay", &char_value_iter);
+                       while(g_variant_iter_loop(char_value_iter, "y",  &char_value)) {
+                               g_byte_array_append(manufacturer_data, &char_value, 1);
+                       }
+                       if (manufacturer_data) {
+                               if (manufacturer_data->len > 0) {
+                                       memcpy(dev_info->manufacturer_data.data, manufacturer_data->data, manufacturer_data->len);
+                               }
                        }
+                       g_variant_iter_free(char_value_iter);
+                       g_byte_array_free(manufacturer_data, TRUE);
                }
-
-               dbus_message_iter_next(&value_iter);
        }
 
        return dev_info;
 }
 
-static void __bt_extract_device_info(DBusMessageIter *msg_iter,
+static void __bt_extract_device_info(GVariantIter *iter,
                                                        GArray **dev_list)
 {
        bluetooth_device_info_t *dev_info = NULL;
        char *object_path = NULL;
-       DBusMessageIter value_iter;
+       GVariantIter *interface_iter;
+       GVariantIter *svc_iter;
+       char *interface_str = NULL;
 
        /* Parse the signature:  oa{sa{sv}}} */
-       ret_if(dbus_message_iter_get_arg_type(msg_iter) !=
-                               DBUS_TYPE_OBJECT_PATH);
-
-       dbus_message_iter_get_basic(msg_iter, &object_path);
-       ret_if(object_path == NULL);
-
-       /* object array (oa) */
-       ret_if(dbus_message_iter_next(msg_iter) == FALSE);
-       ret_if(dbus_message_iter_get_arg_type(msg_iter) != DBUS_TYPE_ARRAY);
-
-       dbus_message_iter_recurse(msg_iter, &value_iter);
-
-       /* string array (sa) */
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                                       DBUS_TYPE_DICT_ENTRY) {
-               char *interface_name = NULL;
-               DBusMessageIter interface_iter;
-
-               dbus_message_iter_recurse(&value_iter, &interface_iter);
-
-               ret_if(dbus_message_iter_get_arg_type(&interface_iter) !=
-                                                       DBUS_TYPE_STRING);
+       while (g_variant_iter_loop(iter, "{&oa{sa{sv}}}", &object_path,
+               &interface_iter)) {
 
-               dbus_message_iter_get_basic(&interface_iter, &interface_name);
-
-               ret_if(dbus_message_iter_next(&interface_iter) == FALSE);
-
-               ret_if(dbus_message_iter_get_arg_type(&interface_iter) !=
-                                                       DBUS_TYPE_ARRAY);
-
-               if (g_strcmp0(interface_name, "org.bluez.Device1") == 0) {
-                       BT_DBG("Found a device: %s", object_path);
-                       dev_info = __bt_parse_device_info(&interface_iter);
-
-                       if (dev_info) {
-                               if (dev_info->paired == FALSE)
-                                       goto not_paired;
-
-                               g_array_append_vals(*dev_list, dev_info,
-                                               sizeof(bluetooth_device_info_t));
+               if (object_path == NULL)
+                       continue;
 
-                               g_free(dev_info);
+               while (g_variant_iter_loop(interface_iter, "{sa{sv}}",
+                               &interface_str, &svc_iter)) {
+                       if (g_strcmp0(interface_str, "org.bluez.Device1") == 0) {
+                               BT_DBG("Found a device: %s", object_path);
+                               dev_info = __bt_parse_device_info(svc_iter);
+                               if (dev_info) {
+                                       if (dev_info->paired == TRUE) {
+                                               g_array_append_vals(*dev_list, dev_info,
+                                                               sizeof(bluetooth_device_info_t));
+                                       }
+                                       g_free(dev_info);
+                               }
+                               g_free(interface_str);
+                               g_variant_iter_free(svc_iter);
+                               break;
                        }
-
-                       return;
                }
-
-               dbus_message_iter_next(&value_iter);
        }
-
-       BT_DBG("There is no device interface");
-
-not_paired:
-       BT_DBG("Not paired");
-       g_free(dev_info);
+       BT_DBG("-");
 }
 
 int _bt_get_bonded_devices(GArray **dev_list)
 {
        BT_DBG("+");
-       DBusMessage *msg;
-       DBusMessage *reply;
-       DBusMessageIter reply_iter;
-       DBusMessageIter value_iter;
-       DBusError err;
-       DBusConnection *conn;
+       GDBusConnection *conn;
+       GDBusProxy *manager_proxy;
+       GVariant *result = NULL;
+       GVariantIter *iter = NULL;
+       GError *error = NULL;
 
        conn = _bt_get_system_conn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       msg = dbus_message_new_method_call(BT_BLUEZ_NAME, BT_MANAGER_PATH,
-                                               BT_MANAGER_INTERFACE,
-                                               "GetManagedObjects");
-
-       retv_if(msg == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       /* Synchronous call */
-       dbus_error_init(&err);
-       reply = dbus_connection_send_with_reply_and_block(
-                                       conn, msg,
-                                       -1, &err);
-       dbus_message_unref(msg);
-
-       if (!reply) {
-               BT_ERR("Can't get managed objects");
-
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("%s", err.message);
-                       dbus_error_free(&err);
-               }
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       if (dbus_message_iter_init(reply, &reply_iter) == FALSE) {
-               BT_ERR("Fail to iterate the reply");
-               dbus_message_unref(reply);
+       manager_proxy = _bt_get_manager_proxy();
+       retv_if(manager_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       result = g_dbus_proxy_call_sync(manager_proxy, "GetManagedObjects",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               NULL);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to GetManagedObjects (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Failed to Failed to GetManagedObjects");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       dbus_message_iter_recurse(&reply_iter, &value_iter);
-
        /* signature of GetManagedObjects:  a{oa{sa{sv}}} */
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                                               DBUS_TYPE_DICT_ENTRY) {
-               DBusMessageIter msg_iter;
+       g_variant_get(result, "(a{oa{sa{sv}}})", &iter);
 
-               dbus_message_iter_recurse(&value_iter, &msg_iter);
+       __bt_extract_device_info(iter, dev_list);
+       g_variant_iter_free(iter);
+       g_variant_unref(result);
 
-               __bt_extract_device_info(&msg_iter, dev_list);
-
-               dbus_message_iter_next(&value_iter);
-       }
-       dbus_message_unref(reply);
        BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
@@ -2537,7 +2313,7 @@ int _bt_get_bonded_device_info(bluetooth_device_address_t *device_address,
                                bluetooth_device_info_t *dev_info)
 {
        char *object_path = NULL;
-       DBusGProxy *adapter_proxy;
+       GDBusProxy *adapter_proxy;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        int ret = BLUETOOTH_ERROR_NONE;
 
@@ -2577,9 +2353,9 @@ int _bt_get_timeout_value(int *timeout)
 
 int _bt_set_le_privacy(gboolean set_privacy)
 {
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        GError *error = NULL;
-       int ret = BLUETOOTH_ERROR_NONE;
+       GVariant *result = NULL;
 
        if (__bt_is_factory_test_mode()) {
                BT_ERR("Unable to set le privacy in factory binary !!");
@@ -2594,31 +2370,36 @@ int _bt_set_le_privacy(gboolean set_privacy)
        proxy = _bt_get_adapter_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call(proxy, "SetLePrivacy", &error,
-                                  G_TYPE_BOOLEAN, set_privacy,
-                                  G_TYPE_INVALID, G_TYPE_INVALID);
-
-       if (error) {
-               BT_ERR("SetLePrivacy Failed :[%s]", error->message);
-               if (g_strrstr(error->message, BT_SERVICE_ERR_MSG_NOT_SUPPORTED))
-                       ret = BLUETOOTH_ERROR_NOT_SUPPORT;
-               else
-                       ret = BLUETOOTH_ERROR_INTERNAL;
-               g_error_free(error);
-               return ret;
+       result = g_dbus_proxy_call_sync(proxy,
+                               "SetLePrivacy",
+                               g_variant_new("(b)", set_privacy),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to SetLePrivacy (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else
+                       BT_ERR("Failed to SetLePrivacy");
+               return BLUETOOTH_ERROR_INTERNAL;
        }
 
+       g_variant_unref(result);
        BT_INFO("SetLePrivacy as %d", set_privacy);
-
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_set_manufacturer_data(bluetooth_manufacturer_data_t *m_data)
 {
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        GError *error = NULL;
-       GArray *arr;
        int i;
+       GVariant *val;
+       GVariant *result;
+       GVariantBuilder *builder;
 
        BT_CHECK_PARAMETER(m_data, return);
 
@@ -2630,30 +2411,48 @@ int _bt_set_manufacturer_data(bluetooth_manufacturer_data_t *m_data)
        proxy = _bt_get_adapter_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       arr = g_array_new(TRUE, TRUE, sizeof(guint8));
-
-       for (i = 0; i < (m_data->data_len) + 2; i++)
-               g_array_append_vals(arr, &(m_data->data[i]), sizeof(guint8));
+       builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
 
-       dbus_g_proxy_call(proxy, "SetManufacturerData", &error,
-                       DBUS_TYPE_G_UCHAR_ARRAY, arr,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
+       for (i = 0; i < (m_data->data_len) + 2; i++) {
+               g_variant_builder_add(builder, "y", m_data->data[i]);
+       }
 
-       g_array_free(arr, TRUE);
+       val = g_variant_new("(ay)", builder);
 
-       if (error) {
-               BT_ERR("SetManufacturerData Fail: %s", error->message);
-               g_error_free(error);
+       result = g_dbus_proxy_call_sync(proxy,
+                               "SetManufacturerData",
+                               val,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+       g_variant_builder_unref(builder);
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Failed to SetManufacturerData (Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else {
+                       BT_ERR("Failed to SetManufacturerData");
+               }
                return BLUETOOTH_ERROR_INTERNAL;
        }
+       builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
+
+       for (i = 0; i < (m_data->data_len) + 2; i++) {
+               g_variant_builder_add(builder, "y", m_data->data[i]);
+       }
+
+       val = g_variant_new("(ay)", builder);
 
        _bt_send_event(BT_ADAPTER_EVENT,
                        BLUETOOTH_EVENT_MANUFACTURER_DATA_CHANGED,
-                       DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                       &m_data, m_data->data_len,
-                       DBUS_TYPE_INVALID);
+                       val);
 
        BT_INFO("Set manufacturer data");
 
+       g_variant_builder_unref(builder);
+       g_variant_unref(result);
+
        return BLUETOOTH_ERROR_NONE;
 }
+
index 8837461..7be41a8 100644 (file)
@@ -26,8 +26,9 @@
 #include <string.h>
 #include <malloc.h>
 #include <stacktrim.h>
+#include <syspopup_caller.h>
 #include <vconf.h>
-#include <package-manager.h>
+#include <bundle_internal.h>
 
 #ifdef TIZEN_NETWORK_TETHERING_ENABLE
 #include <tethering.h>
 #include "bt-service-device.h"
 #include "bt-service-audio.h"
 
-#if defined(LIBNOTIFY_SUPPORT)
-#include "bt-popup.h"
-#elif defined(LIBNOTIFICATION_SUPPORT)
-#include "bt-service-agent-notification.h"
-#else
-#include <syspopup_caller.h>
-#endif
-
 #define BT_APP_AUTHENTICATION_TIMEOUT          35
 #define BT_APP_AUTHORIZATION_TIMEOUT           15
 
 #define BT_PAN_MAX_CONNECTION 4
 extern guint nap_connected_device_count;
 
+#define G_VARIANT_UNREF(variant) \
+       g_variant_unref(variant); \
+       variant = NULL
+
 static int __bt_agent_is_auto_response(uint32_t dev_class, const gchar *address,
                                                        const gchar *name);
 static gboolean __bt_agent_is_hid_keyboard(uint32_t dev_class);
@@ -108,13 +105,7 @@ static gboolean __bt_agent_system_popup_timer_cb(gpointer user_data)
 
        ++retry_count;
 
-#if defined(LIBNOTIFY_SUPPORT)
-       ret = notify_launch(b);
-#elif defined(LIBNOTIFICATION_SUPPORT)
-       ret = notification_launch(b);
-#else
        ret = syspopup_launch("bt-syspopup", b);
-#endif
        if (ret < 0) {
                BT_ERR("Sorry! Can't launch popup, ret=%d, Re-try[%d] time..",
                                                        ret, retry_count);
@@ -134,18 +125,22 @@ static gboolean __bt_agent_system_popup_timer_cb(gpointer user_data)
 }
 
 #ifdef TIZEN_WEARABLE
-static void __bt_unbond_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                               gpointer user_data)
+static void __bt_unbond_cb(GDBusProxy *proxy,
+               GAsyncResult *res, gpointer user_data)
 {
        GError *err = NULL;
-
-       dbus_g_proxy_end_call(proxy, call, &err, G_TYPE_INVALID);
-       if (err != NULL) {
-               BT_ERR("Error occured in RemoveBonding [%s]\n", err->message);
-               g_error_free(err);
+       GVariant *value;
+
+       value = g_dbus_proxy_call_finish(proxy, res, &err);
+       if (value == NULL) {
+               BT_ERR("Error: Unbond Failed");
+               if (err) {
+                       BT_ERR("errCode[%x], message[%s]\n", err->code, err->message);
+                       g_clear_error(&err);
+               }
                return;
        }
-
+       g_variant_unref(value);
        BT_INFO("Unbonding is done");
        return;
 }
@@ -170,7 +165,7 @@ static gboolean __bt_unpair_device(void)
 
        no_of_device = device_list->len / sizeof(bluetooth_device_info_t);
        for (i = 0; i < no_of_device; i++) {
-               DBusGProxy *adapter_proxy;
+               GDBusProxy *adapter_proxy;
                bluetooth_device_info_t info;
                char addr[BT_ADDRESS_STRING_SIZE] = { 0 };
                char *device_path = NULL;
@@ -195,15 +190,11 @@ static gboolean __bt_unpair_device(void)
                        return FALSE;
                }
 
-               if (!dbus_g_proxy_begin_call(adapter_proxy, "UnpairDevice",
-                                       (DBusGProxyCallNotify)__bt_unbond_cb,
-                                       NULL, NULL,
-                                       DBUS_TYPE_G_OBJECT_PATH, device_path,
-                                       G_TYPE_INVALID)) {
-                       BT_ERR("RemoveBonding begin failed\n");
-                       g_array_free(device_list, TRUE);
-                       return FALSE;
-               }
+               g_dbus_proxy_call(adapter_proxy,
+                               "UnpairDevice", g_variant_new("o", device_path),
+                               G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+                               (GAsyncReadyCallback)__bt_unbond_cb, NULL);
+
                BT_INFO("unbonding %s is requested", addr);
 
                g_array_free(device_list, TRUE);
@@ -214,58 +205,61 @@ static gboolean __bt_unpair_device(void)
        return FALSE;
 }
 
-static DBusHandlerResult __bt_popup_event_filter(DBusConnection *conn,
-               DBusMessage *msg, void *data)
+static void __bt_popup_event_filter(GDBusConnection *connection,
+               const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal_name,
+               GVariant *parameters,
+               gpointer user_data)
 {
-       int response;
+       BT_DBG("Sender Name[%s] Object Path[%s] Interface[%s] Signal[%s]",
+                       sender_name, object_path, interface_name, signal_name);
 
-       BT_DBG("+");
-
-       if (msg == NULL)
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
-       if (!dbus_message_is_signal(msg, "User.Bluetooth.syspopup", "ResetResponse"))
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       if (g_strcmp0(interface_name, "User.Bluetooth.syspopup") == 0 &&
+                       g_strcmp0(signal_name, "ResetResponse") == 0) {
+               int response;
 
-       if (!dbus_message_get_args(msg, NULL,
-                               DBUS_TYPE_INT32, &response,
-                               DBUS_TYPE_INVALID)) {
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+               g_variant_get(parameters, "(i)", &response);
+               BT_DBG("response = %d", response);
        }
+}
 
-       BT_DBG("response = %d", response);
+int __bt_service_subscribe_popup(GDBusConnection *conn,
+               gboolean subscribe)
+{
+       static guint subs_interface_added_id = 0;
 
-       BT_DBG("-");
-       return DBUS_HANDLER_RESULT_HANDLED;
+       if (conn == NULL)
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+
+       if (subscribe) {
+               if (subs_interface_added_id == 0) {
+                       subs_interface_added_id = g_dbus_connection_signal_subscribe(conn,
+                                       NULL, "User.Bluetooth.syspopup", "ResetResponse", NULL, NULL, 0,
+                                       __bt_popup_event_filter, NULL, NULL);
+               }
+       } else {
+               if (subs_interface_added_id > 0) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_interface_added_id);
+                       subs_interface_added_id = 0;
+               }
+       }
+       return BLUETOOTH_ERROR_NONE;
 }
 
 static void  __bt_register_popup_event_signal(void)
 {
-       DBusError dbus_error;
-       DBusGConnection *gconn;
-       DBusConnection *conn;
+       GDBusConnection *conn;
 
        BT_DBG("+\n");
 
-       gconn = _bt_get_system_gconn();
-       if (gconn == NULL)
-               return;
-
-       conn = dbus_g_connection_get_connection(gconn);
+       conn = _bt_get_system_gconn();
        if (conn == NULL)
                return;
 
-       dbus_connection_add_filter(conn, __bt_popup_event_filter, NULL, NULL);
-
-       dbus_error_init(&dbus_error);
-       dbus_bus_add_match(conn,
-                       "type='signal',interface='User.Bluetooth.syspopup'"
-                       ",member='ResetResponse'", &dbus_error);
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Error: %s\n", dbus_error.message);
-               dbus_error_free(&dbus_error);
-               return;
-       }
+       __bt_service_subscribe_popup(conn, TRUE);
 
        BT_DBG("-\n");
        return;
@@ -346,6 +340,11 @@ int _bt_launch_system_popup(bt_agent_event_type_t event_type,
                                                sizeof(event_str));
                break;
 
+       case BT_AGENT_EVENT_PASSKEY_AUTO_ACCEPTED:
+               g_strlcpy(event_str, "passkey-auto-accepted",
+                                               sizeof(event_str));
+               break;
+
        case BT_AGENT_EVENT_PASSKEY_REQUEST:
                g_strlcpy(event_str, "passkey-request", sizeof(event_str));
                break;
@@ -410,9 +409,7 @@ int _bt_launch_system_popup(bt_agent_event_type_t event_type,
 
        bundle_add(b, "event-type", event_str);
 
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
        ret = syspopup_launch("bt-syspopup", b);
-#endif
        if (0 > ret) {
                BT_ERR("Popup launch failed...retry %d", ret);
 
@@ -426,53 +423,77 @@ int _bt_launch_system_popup(bt_agent_event_type_t event_type,
        return 0;
 }
 
-static gboolean __pincode_request(GapAgent *agent, DBusGProxy *device)
+static GVariant *__bt_service_getall(GDBusProxy *device, const char *interface)
+{
+       GError *error = NULL;
+       GVariant *reply;
+
+       reply = g_dbus_proxy_call_sync(device,
+                       "GetAll", g_variant_new("(s)", interface),
+                       G_DBUS_CALL_FLAGS_NONE, -1,
+                       NULL, &error);
+       if (reply == NULL) {
+               ERR("GetAll dBUS-RPC failed");
+               if (error) {
+                       ERR("D-Bus API failure: errCode[%x], message[%s]",
+                               error->code, error->message);
+                       g_clear_error(&error);
+               }
+               return NULL;
+       }
+
+       return reply;
+}
+
+static gboolean __pincode_request(GapAgentPrivate *agent, GDBusProxy *device)
 {
        uint32_t device_class;
-       GHashTable *hash = NULL;
-       GValue *value;
        const gchar *address;
        const gchar *name;
-       GError *error = NULL;
+       GVariant *reply = NULL;
+       GVariant *reply_temp = NULL;
+       GVariant *tmp_value;
 
-       BT_INFO("+");
+       BT_DBG("+");
 
-       dbus_g_proxy_call(device, "GetAll", &error,
-                               G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                               G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
-                               G_TYPE_VALUE), &hash, G_TYPE_INVALID);
-       if (error) {
-               BT_ERR("error in GetBasicProperties [%s]\n", error->message);
-               g_error_free(error);
+       reply_temp = __bt_service_getall(device, BT_DEVICE_INTERFACE);
+
+       if (reply_temp == NULL) {
                gap_agent_reply_pin_code(agent, GAP_AGENT_REJECT, "",
-                                            NULL);
+                               NULL);
                goto done;
        }
 
-       value = g_hash_table_lookup(hash, "Class");
-       device_class = value ? g_value_get_uint(value) : 0;
+       g_variant_get(reply_temp,"(@a{sv})", &reply); /* Format of reply a{sv}*/
 
-       value = g_hash_table_lookup(hash, "Address");
-       address = value ? g_value_get_string(value) : NULL;
+       tmp_value = g_variant_lookup_value(reply, "Class", G_VARIANT_TYPE_UINT32);
+       g_variant_get(tmp_value, "u", &device_class);
+       G_VARIANT_UNREF(tmp_value);
+
+       tmp_value = g_variant_lookup_value(reply, "Address", G_VARIANT_TYPE_STRING);
+       g_variant_get(tmp_value, "s", &address);
+       G_VARIANT_UNREF(tmp_value);
        if (!address) {
                gap_agent_reply_pin_code(agent, GAP_AGENT_REJECT, "", NULL);
                goto done;
        }
 
-       value = g_hash_table_lookup(hash, "Name");
-       name = value ? g_value_get_string(value) : NULL;
+       tmp_value = g_variant_lookup_value(reply, "Name", G_VARIANT_TYPE_STRING);
+       g_variant_get(tmp_value, "s", &name);
+       G_VARIANT_UNREF(tmp_value);
        if (!name)
                name = address;
 
        if (_bt_is_device_creating() == TRUE &&
                _bt_is_bonding_device_address(address) == TRUE &&
                __bt_agent_is_auto_response(device_class, address, name)) {
-               /* Use Fixed PIN "0000" for basic pairing*/
+               BT_DBG("0000 Auto Pair");
+               /* Use Fixed PIN "0000" for basic pairing */
                _bt_set_autopair_status_in_bonding_info(TRUE);
                gap_agent_reply_pin_code(agent, GAP_AGENT_ACCEPT, "0000",
                                                                        NULL);
        } else if (__bt_agent_is_hid_keyboard(device_class)) {
+               BT_DBG("HID Keyboard");
                char str_passkey[BT_PASSKEY_MAX_LENGTH + 1] = { 0 };
 
                if (__bt_agent_generate_passkey(str_passkey,
@@ -489,51 +510,50 @@ static gboolean __pincode_request(GapAgent *agent, DBusGProxy *device)
                                                name, str_passkey, NULL,
                                                _gap_agent_get_path(agent));
        } else {
+               BT_DBG("Show Pin entry");
                _bt_launch_system_popup(BT_AGENT_EVENT_PIN_REQUEST, name, NULL,
                                        NULL, _gap_agent_get_path(agent));
        }
 
 done:
-       g_hash_table_destroy(hash);
+       g_variant_unref(reply);
+       g_variant_unref(reply_temp);
        __bt_agent_release_memory();
-
        BT_DBG("-");
 
        return TRUE;
 }
 
-static gboolean __passkey_request(GapAgent *agent, DBusGProxy *device)
+static gboolean __passkey_request(GapAgentPrivate *agent, GDBusProxy *device)
 {
-       GHashTable *hash = NULL;
-       GValue *value;
        const gchar *address;
        const gchar *name;
-       GError *error = NULL;
-
+       GVariant *reply = NULL;
+       GVariant *reply_temp = NULL;
+       GVariant *tmp_value;
        BT_DBG("+");
 
-       dbus_g_proxy_call(device, "GetAll", &error,
-                               G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                               G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
-                               G_TYPE_VALUE), &hash, G_TYPE_INVALID);
-       if (error) {
-               BT_ERR("error in GetBasicProperties [%s]\n", error->message);
-               g_error_free(error);
+       reply_temp = __bt_service_getall(device, BT_DEVICE_INTERFACE);
+
+       if (reply_temp == NULL) {
                gap_agent_reply_pin_code(agent, GAP_AGENT_REJECT, "",
                                             NULL);
                goto done;
        }
 
-       value = g_hash_table_lookup(hash, "Address");
-       address = value ? g_value_get_string(value) : NULL;
+       g_variant_get(reply_temp,"(@a{sv})", &reply); /* Format of reply a{sv}*/
+
+       tmp_value = g_variant_lookup_value (reply, "Address", G_VARIANT_TYPE_STRING);
+       g_variant_get(tmp_value, "s", &address);
+       G_VARIANT_UNREF(tmp_value);
        if (!address) {
                gap_agent_reply_pin_code(agent, GAP_AGENT_REJECT, "", NULL);
                goto done;
        }
 
-       value = g_hash_table_lookup(hash, "Name");
-       name = value ? g_value_get_string(value) : NULL;
+       tmp_value = g_variant_lookup_value(reply, "Name", G_VARIANT_TYPE_STRING);
+       g_variant_get(tmp_value, "s", &name);
+       G_VARIANT_UNREF(tmp_value);
        if (!name)
                name = address;
 
@@ -541,47 +561,46 @@ static gboolean __passkey_request(GapAgent *agent, DBusGProxy *device)
                                                _gap_agent_get_path(agent));
 
 done:
+       g_variant_unref(reply);
+       g_variant_unref(reply_temp);
        __bt_agent_release_memory();
-       g_hash_table_destroy(hash);
-       BT_DBG("-");
 
+       BT_DBG("-");
        return TRUE;
 }
 
-static gboolean __display_request(GapAgent *agent, DBusGProxy *device,
+static gboolean __display_request(GapAgentPrivate *agent, GDBusProxy *device,
                                                                guint passkey)
 {
-       GHashTable *hash = NULL;
-       GValue *value;
        const gchar *address;
        const gchar *name;
-       GError *error = NULL;
        char *str_passkey;
+       GVariant *reply = NULL;
+       GVariant *reply_temp = NULL;
+       GVariant *tmp_value = NULL;
 
        BT_DBG("+");
 
-       dbus_g_proxy_call(device, "GetAll", &error,
-                               G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                               G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
-                               G_TYPE_VALUE), &hash, G_TYPE_INVALID);
-       if (error) {
-               BT_ERR("error in GetAll [%s]\n", error->message);
-               g_error_free(error);
+       reply_temp = __bt_service_getall(device, BT_DEVICE_INTERFACE);
+       if (reply_temp == NULL) {
                gap_agent_reply_pin_code(agent, GAP_AGENT_REJECT, "",
                                             NULL);
                goto done;
        }
 
-       value = g_hash_table_lookup(hash, "Address");
-       address = value ? g_value_get_string(value) : NULL;
+       g_variant_get(reply_temp,"(@a{sv})", &reply); /* Format of reply a{sv}*/
+
+       tmp_value = g_variant_lookup_value (reply, "Address", G_VARIANT_TYPE_STRING);
+       g_variant_get(tmp_value, "s", &address);
+       G_VARIANT_UNREF(tmp_value);
        if (!address) {
                gap_agent_reply_pin_code(agent, GAP_AGENT_REJECT, "", NULL);
                goto done;
        }
 
-       value = g_hash_table_lookup(hash, "Name");
-       name = value ? g_value_get_string(value) : NULL;
+       tmp_value = g_variant_lookup_value(reply, "Name", G_VARIANT_TYPE_STRING);
+       g_variant_get(tmp_value, "s", &name);
+       G_VARIANT_UNREF(tmp_value);
        if (!name)
                name = address;
 
@@ -594,50 +613,49 @@ static gboolean __display_request(GapAgent *agent, DBusGProxy *device,
        g_free(str_passkey);
 
 done:
+       g_variant_unref(reply);
+       g_variant_unref(reply_temp);
        __bt_agent_release_memory();
-       g_hash_table_destroy(hash);
-       BT_DBG("-");
 
+       BT_DBG("-");
        return TRUE;
 }
 
-static gboolean __confirm_request(GapAgent *agent, DBusGProxy *device,
+static gboolean __confirm_request(GapAgentPrivate *agent, GDBusProxy *device,
                                                                guint passkey)
 {
-       GHashTable *hash = NULL;
-       GValue *value;
        const gchar *address;
        const gchar *name;
-       GError *error = NULL;
        char str_passkey[7];
-
+       GVariant *reply_temp = NULL;
+       GVariant *reply = NULL;
+       GVariant *tmp_value;
        BT_DBG("+ passkey[%.6d]", passkey);
 
        snprintf(str_passkey, sizeof(str_passkey), "%.6d", passkey);
 
-       dbus_g_proxy_call(device, "GetAll", &error,
-                               G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                               G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
-                               G_TYPE_VALUE), &hash, G_TYPE_INVALID);
+       reply_temp = __bt_service_getall(device, BT_DEVICE_INTERFACE);
 
-       if (error) {
-               BT_ERR("error in GetAll [%s]", error->message);
-               g_error_free(error);
+       if (reply_temp == NULL) {
+               BT_ERR("Device doesn't exist");
                gap_agent_reply_pin_code(agent, GAP_AGENT_REJECT, "",
                                             NULL);
                goto done;
        }
 
-       value = g_hash_table_lookup(hash, "Address");
-       address = value ? g_value_get_string(value) : NULL;
+       g_variant_get(reply_temp,"(@a{sv})", &reply); /* Format of reply a{sv}*/
+
+       tmp_value = g_variant_lookup_value (reply, "Address", G_VARIANT_TYPE_STRING);
+       g_variant_get(tmp_value, "s", &address);
+       G_VARIANT_UNREF(tmp_value);
        if (!address) {
                gap_agent_reply_pin_code(agent, GAP_AGENT_REJECT, "", NULL);
                goto done;
        }
 
-       value = g_hash_table_lookup(hash, "Name");
-       name = value ? g_value_get_string(value) : NULL;
+       tmp_value = g_variant_lookup_value (reply, "Name", G_VARIANT_TYPE_STRING);
+       g_variant_get(tmp_value, "s", &name);
+       G_VARIANT_UNREF(tmp_value);
        if (!name)
                name = address;
 
@@ -645,10 +663,9 @@ static gboolean __confirm_request(GapAgent *agent, DBusGProxy *device,
        uint32_t device_class = 0x00;
        uint32_t major_class;
 
-       value = g_hash_table_lookup(hash, "Class");
-       device_class = value ? g_value_get_uint(value) : 0;
-
-       BT_INFO("COD : 0x%X", device_class);
+       tmp_value = g_variant_lookup_value(reply, "Class", G_VARIANT_TYPE_UINT32);
+       g_variant_get(tmp_value, "u", &device_class);
+       G_VARIANT_UNREF(tmp_value);
 
        major_class = (device_class & 0x1f00) >> 8;
 
@@ -665,31 +682,32 @@ static gboolean __confirm_request(GapAgent *agent, DBusGProxy *device,
                                NULL, NULL, _gap_agent_get_path(agent));
        } else {
                BT_INFO("Launch passkey pop-up");
-               _bt_launch_system_popup(BT_AGENT_EVENT_PASSKEY_CONFIRM_REQUEST, name,
+               _bt_launch_system_popup(BT_AGENT_EVENT_PASSKEY_AUTO_ACCEPTED, name,
                                str_passkey, NULL, _gap_agent_get_path(agent));
+
+               gap_agent_reply_confirmation(agent, GAP_AGENT_ACCEPT, NULL);
        }
 #else
+       BT_DBG("LAUNCH SYSPOPUP");
        _bt_launch_system_popup(BT_AGENT_EVENT_PASSKEY_CONFIRM_REQUEST, name,
                                                str_passkey, NULL,
                                                _gap_agent_get_path(agent));
 #endif
 
 done:
+       g_variant_unref(reply);
+       g_variant_unref(reply_temp);
        __bt_agent_release_memory();
-       g_hash_table_destroy(hash);
-
        BT_DBG("-");
 
        return TRUE;
 }
 
-static gboolean __pairing_cancel_request(GapAgent *agent, const char *address)
+static gboolean __pairing_cancel_request(GapAgentPrivate *agent, const char *address)
 {
        BT_DBG("On Going Pairing is cancelled by remote\n");
 
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
        syspopup_destroy_all();
-#endif
 
        __bt_agent_release_memory();
 
@@ -702,21 +720,20 @@ static gboolean __a2dp_authorize_request_check(void)
        return _bt_is_headset_type_connected(BT_AUDIO_A2DP, NULL);
 }
 
-static gboolean __authorize_request(GapAgent *agent, DBusGProxy *device,
+static gboolean __authorize_request(GapAgentPrivate *agent, GDBusProxy *device,
                                                        const char *uuid)
 {
-       GHashTable *hash = NULL;
-       GValue *value;
        const gchar *address;
        const gchar *name;
        gboolean trust;
        gboolean paired;
+       GVariant *reply = NULL;
+       GVariant *reply_temp = NULL;
+       GVariant *tmp_value;
 #ifdef TIZEN_NETWORK_TETHERING_ENABLE
        bool enabled;
        tethering_h tethering = NULL;
-       int ret = TETHERING_ERROR_NONE;
 #endif
-       GError *error = NULL;
        int result = BLUETOOTH_ERROR_NONE;
        int request_type = BT_AGENT_EVENT_AUTHORIZE_REQUEST;
 
@@ -798,55 +815,51 @@ fail:
 #endif
        }
 
-       dbus_g_proxy_call(device, "GetAll", &error,
-                               G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                               G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
-                               G_TYPE_VALUE), &hash, G_TYPE_INVALID);
-       if (error) {
-               BT_ERR("error in GetAll [%s]\n", error->message);
-               g_error_free(error);
+       reply_temp = __bt_service_getall(device, BT_DEVICE_INTERFACE);
+       if (reply_temp == NULL) {
                gap_agent_reply_pin_code(agent, GAP_AGENT_REJECT, "",
                                             NULL);
                goto done;
        }
 
-       value = g_hash_table_lookup(hash, "Address");
-       address = value ? g_value_get_string(value) : NULL;
+       g_variant_get(reply_temp,"(@a{sv})", &reply); /* Format of reply a{sv}*/
+
+       tmp_value = g_variant_lookup_value (reply, "Address", G_VARIANT_TYPE_STRING);
+       g_variant_get(tmp_value, "s", &address);
+       G_VARIANT_UNREF(tmp_value);
        if (!address) {
                gap_agent_reply_pin_code(agent, GAP_AGENT_REJECT, "", NULL);
                goto done;
        }
 
-       value = g_hash_table_lookup(hash, "Alias");
-       name = value ? g_value_get_string(value) : NULL;
+       tmp_value = g_variant_lookup_value(reply, "Alias", G_VARIANT_TYPE_STRING);
+       g_variant_get(tmp_value, "s", &name);
+       G_VARIANT_UNREF(tmp_value);
        if (!name)
                name = address;
 
-       value = g_hash_table_lookup(hash, "Trusted");
-       trust = value ? g_value_get_boolean(value) : 0;
+       tmp_value = g_variant_lookup_value(reply, "Trusted", G_VARIANT_TYPE_BOOLEAN);
+       g_variant_get(tmp_value, "b", &trust);
+       G_VARIANT_UNREF(tmp_value);
 
-       value = g_hash_table_lookup(hash, "Paired");
-       paired = value ? g_value_get_boolean(value) : 0;
+       tmp_value = g_variant_lookup_value(reply, "Paired", G_VARIANT_TYPE_BOOLEAN);
+       g_variant_get(tmp_value, "b", &paired);
+       G_VARIANT_UNREF(tmp_value);
        if ((paired == FALSE) && (trust == FALSE)) {
                BT_ERR("No paired & No trusted device");
                gap_agent_reply_authorize(agent,
-                                             GAP_AGENT_REJECT, NULL);
+                               GAP_AGENT_REJECT, NULL);
                goto done;
        }
 
-       BT_INFO("Authorization request for device [%s] Service:[%s]\n", address,
-                                                                       uuid);
+       BT_INFO("Authorization request for device [%s] Service:[%s]\n", address, uuid);
 
        if (strcasecmp(uuid, OPP_UUID) == 0 &&
             _gap_agent_exist_osp_server(agent, BT_OBEX_SERVER,
                                        NULL) == TRUE) {
                _bt_send_event(BT_OPP_SERVER_EVENT,
-                       BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &address,
-                       DBUS_TYPE_STRING, &name,
-                       DBUS_TYPE_INVALID);
+                               BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE,
+                               g_variant_new("iss", result, address, name));
 
                goto done;
        }
@@ -859,13 +872,8 @@ fail:
 
                _bt_send_event(BT_RFCOMM_SERVER_EVENT,
                        BLUETOOTH_EVENT_RFCOMM_AUTHORIZE,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &address,
-                       DBUS_TYPE_STRING, &uuid,
-                       DBUS_TYPE_STRING, &name,
-                       DBUS_TYPE_STRING, &osp_serv->path,
-                       DBUS_TYPE_INT16, &osp_serv->fd,
-                       DBUS_TYPE_INVALID);
+                       g_variant_new("issssn", result, address, uuid,
+                                       name, osp_serv->path, osp_serv->fd));
 
                goto done;
        }
@@ -887,24 +895,22 @@ fail:
        }
 
 done:
+       g_variant_unref(reply);
+       g_variant_unref(reply_temp);
        __bt_agent_release_memory();
-       g_hash_table_destroy(hash);
-
        BT_DBG("-");
 
        return TRUE;
 }
 
-static gboolean __authorization_cancel_request(GapAgent *agent,
+static gboolean __authorization_cancel_request(GapAgentPrivate *agent,
                                                        const char *address)
 {
        BT_DBG("On Going Authorization is cancelled by remote\n");
 
        gap_agent_reply_authorize(agent, GAP_AGENT_CANCEL, NULL);
 
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
        syspopup_destroy_all();
-#endif
 
        __bt_agent_release_memory();
 
@@ -916,16 +922,16 @@ void _bt_destroy_agent(void *agent)
        if (!agent)
                return;
 
-       _gap_agent_reset_dbus(agent);
+       _gap_agent_reset_dbus((GapAgentPrivate *)agent);
 
-       g_object_unref(agent);
+       g_free(agent);
 }
 
 void* _bt_create_agent(const char *path, gboolean adapter)
 {
        GAP_AGENT_FUNC_CB func_cb;
-       DBusGProxy *adapter_proxy;
-       GapAgentagent;
+       GDBusProxy *adapter_proxy;
+       GapAgentPrivate *agent;
 
        adapter_proxy = _bt_get_adapter_proxy();
        if (!adapter_proxy)
@@ -939,14 +945,15 @@ void* _bt_create_agent(const char *path, gboolean adapter)
        func_cb.pairing_cancel_func = __pairing_cancel_request;
        func_cb.authorization_cancel_func = __authorization_cancel_request;
 
-       agent = _gap_agent_new();
+       /* Allocate memory*/
+       agent = g_new0(GapAgentPrivate, 1);
 
-       _gap_agent_setup_dbus(agent, &func_cb, path);
+       _gap_agent_setup_dbus(agent, &func_cb, path, adapter_proxy);
 
        if (adapter) {
                if (!_gap_agent_register(agent)) {
                        _bt_destroy_agent(agent);
-                       return NULL;
+                       agent = NULL;
                }
        }
 
@@ -967,6 +974,7 @@ gboolean _bt_agent_register_osp_server(const gint type,
 gboolean _bt_agent_unregister_osp_server(const gint type, const char *uuid)
 {
        void *agent = _bt_get_adapter_agent();
+
        if (!agent)
                return FALSE;
 
@@ -1038,7 +1046,7 @@ static gboolean __bt_agent_find_device_by_address_exactname(char *buffer,
                                                        const char *address)
 {
        char *pch;
-       char *last = NULL;
+       char *last;
 
        pch = strtok_r(buffer, "= ,", &last);
 
@@ -1058,7 +1066,7 @@ static gboolean __bt_agent_find_device_by_partial_name(char *buffer,
                                                const char *partial_name)
 {
        char *pch;
-       char *last = NULL;
+       char *last;
 
        pch = strtok_r(buffer, "= ,", &last);
 
@@ -1104,6 +1112,12 @@ static gboolean __bt_agent_is_device_blacklist(const char *address,
        rewind(fp);
 
        buffer = g_malloc0(sizeof(char) * size);
+       /* Fix : NULL_RETURNS */
+       if (buffer == NULL) {
+               BT_ERR("Fail to allocate memory");
+               fclose(fp);
+               return FALSE;
+       }
        result = fread((char *)buffer, 1, size, fp);
        fclose(fp);
        if (result != size) {
index a85d4ed..1bf4b03 100644 (file)
  *
  */
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
+#include <gio/gio.h>
 #include <glib.h>
 #include <dlog.h>
 #include <string.h>
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
 #include <syspopup_caller.h>
-#endif
 
 #include "bluetooth-api.h"
 #include "bt-internal-types.h"
@@ -67,18 +64,17 @@ static void __bt_free_wait_data();
 static gboolean __bt_device_support_uuid(char *remote_address,
                                bt_audio_type_t type);
 
-static void __bt_hf_request_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+static void __bt_hf_request_cb(GDBusProxy *proxy, GAsyncResult *res,
                                    gpointer user_data)
 {
        GError *g_error = NULL;
-       GArray *out_param1 = NULL;
-       GArray *out_param2 = NULL;
+       GVariant *out_param1 = NULL;
+       GVariant *reply = NULL;
        int result = BLUETOOTH_ERROR_NONE;
        bt_function_data_t *func_data;
        request_info_t *req_info;
 
-       dbus_g_proxy_end_call(proxy, call, &g_error, G_TYPE_INVALID);
-
+       reply = g_dbus_proxy_call_finish(proxy, res, &g_error);
        g_object_unref(proxy);
 
        func_data = user_data;
@@ -95,34 +91,29 @@ static void __bt_hf_request_cb(DBusGProxy *proxy, DBusGProxyCall *call,
                goto done;
        }
 
-       if (g_error == NULL)
-               goto dbus_return;
-
-       BT_ERR("HFG request Dbus Call Error: %s\n", g_error->message);
-
-       result = BLUETOOTH_ERROR_INTERNAL;
+       if (reply == NULL) {
+               BT_ERR("HF Connect Dbus Call Error");
+               if (g_error) {
+                       BT_ERR("Error: %s\n", g_error->message);
+                       g_clear_error(&g_error);
+               }
+               result = BLUETOOTH_ERROR_INTERNAL;
+       } else {
+               g_variant_unref(reply);
+       }
 
-dbus_return:
        if (req_info->context == NULL)
                goto done;
 
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-       g_array_append_vals(out_param1, func_data->address,
-                               BT_ADDRESS_STR_LEN);
-       g_array_append_vals(out_param2, &result, sizeof(int));
-
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
+       out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+               func_data->address, BT_ADDRESS_STR_LEN, TRUE, NULL, NULL);
 
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
+       g_dbus_method_invocation_return_value(req_info->context,
+                       g_variant_new("(iv)", result, out_param1));
 
        _bt_delete_request_list(req_info->req_id);
-done:
-       if (g_error)
-               g_error_free(g_error);
 
+done:
        if (func_data) {
                g_free(func_data->address);
                g_free(func_data);
@@ -141,7 +132,6 @@ void _bt_audio_check_pending_connect()
 
                _bt_convert_addr_string_to_type(device_address.addr,
                                pdata->address);
-
                _bt_audio_connect(pdata->req_id,
                                BT_AUDIO_A2DP,
                                &device_address,
@@ -156,21 +146,19 @@ void _bt_audio_check_pending_connect()
        return;
 }
 
-static void __bt_audio_request_cb(DBusGProxy *proxy, DBusGProxyCall *call,
+static void __bt_audio_request_cb(GDBusProxy *proxy, GAsyncResult *res,
                                    gpointer user_data)
 {
        GError *g_error = NULL;
-       GArray *out_param1 = NULL;
-       GArray *out_param2 = NULL;
+       GVariant *out_param1 = NULL;
+       GVariant *reply = NULL;
        int result = BLUETOOTH_ERROR_NONE;
-
        bt_audio_function_data_t *func_data;
-
        request_info_t *req_info;
 
-       dbus_g_proxy_end_call(proxy, call, &g_error, G_TYPE_INVALID);
-
+       reply = g_dbus_proxy_call_finish(proxy, res, &g_error);
        g_object_unref(proxy);
+       g_variant_unref(reply);
 
        func_data = user_data;
 
@@ -250,22 +238,15 @@ dbus_return:
                goto done;
        }
 
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-       g_array_append_vals(out_param1, func_data->address,
-                       BT_ADDRESS_STR_LEN);
-       g_array_append_vals(out_param2, &result, sizeof(int));
-
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
+       out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+               func_data->address, BT_ADDRESS_STR_LEN, TRUE, NULL, NULL);
 
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
+       g_dbus_method_invocation_return_value(req_info->context,
+                       g_variant_new("(iv)", result, out_param1));
 
        _bt_delete_request_list(req_info->req_id);
 done:
-       if (g_error)
-               g_error_free(g_error);
+       g_clear_error(&g_error);
 
        if (func_data) {
                g_free(func_data->address);
@@ -273,78 +254,6 @@ done:
        }
 }
 
-static char *__bt_get_audio_path(bluetooth_device_address_t *address)
-{
-
-       char *object_path = NULL;
-       char addr_str[BT_ADDRESS_STRING_SIZE + 1] = { 0 };
-       DBusGProxy *audio_proxy;
-       DBusGProxy *adapter_proxy;
-       DBusGConnection *g_conn;
-
-       retv_if(address == NULL, NULL);
-
-       g_conn = _bt_get_system_gconn();
-       retv_if(g_conn == NULL, NULL);
-
-       adapter_proxy = _bt_get_adapter_proxy();
-       retv_if(adapter_proxy == NULL, NULL);
-
-       _bt_convert_addr_type_to_string(addr_str, address->addr);
-
-       object_path = _bt_get_device_object_path(addr_str);
-
-       retv_if(object_path == NULL, BLUETOOTH_ERROR_NOT_FOUND);
-
-       audio_proxy = dbus_g_proxy_new_for_name(g_conn,
-                                       BT_BLUEZ_NAME,
-                                       object_path,
-                                       BT_HFP_AGENT_INTERFACE);
-
-       retv_if(audio_proxy == NULL, NULL);
-
-       g_object_unref(audio_proxy);
-
-       return object_path;
-}
-
-static char *__bt_get_connected_audio_path(void)
-{
-       int i;
-       guint size;
-       char *audio_path = NULL;
-       GArray *device_list;
-       bluetooth_device_info_t info;
-
-       /* allocate the g_pointer_array */
-       device_list = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-       if (_bt_get_bonded_devices(&device_list)
-                       != BLUETOOTH_ERROR_NONE) {
-               g_array_free(device_list, TRUE);
-               return NULL;
-       }
-
-       size = device_list->len;
-       size = (device_list->len) / sizeof(bluetooth_device_info_t);
-
-       for (i = 0; i < size; i++) {
-
-               info = g_array_index(device_list,
-                               bluetooth_device_info_t, i);
-
-               if (info.connected == TRUE) {
-                       audio_path = __bt_get_audio_path(&info.device_address);
-                       if (audio_path)
-                               break;
-               }
-       }
-
-       g_array_free(device_list, TRUE);
-
-       return audio_path;
-}
-
 static void __bt_free_wait_data()
 {
        if (g_wait_data != NULL) {
@@ -357,8 +266,7 @@ static void __bt_free_wait_data()
 static void __bt_remove_device_from_wait_list()
 {
        /* Before deleting the request update the UI */
-       GArray *out_param_1 = NULL;
-       GArray *out_param_2 = NULL;
+       GVariant *out_param_1 = NULL;
        int result = BLUETOOTH_ERROR_INTERNAL;
        request_info_t *req_info;
 
@@ -368,15 +276,12 @@ static void __bt_remove_device_from_wait_list()
                return;
        }
 
-       out_param_1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param_2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       g_array_append_vals(out_param_1, g_wait_data->address,
-                       BT_ADDRESS_STR_LEN);
-       g_array_append_vals(out_param_2, &result, sizeof(int));
-       dbus_g_method_return(req_info->context,
-                       out_param_1, out_param_2);
-       g_array_free(out_param_1, TRUE);
-       g_array_free(out_param_2, TRUE);
+       out_param_1 = g_variant_new_from_data((const GVariantType *)"ay",
+               g_wait_data->address, BT_ADDRESS_STR_LEN, TRUE, NULL, NULL);
+
+       g_dbus_method_invocation_return_value(req_info->context,
+                       g_variant_new("(iv)", result, out_param_1));
+
        _bt_delete_request_list(g_wait_data->req_id);
 }
 
@@ -556,6 +461,12 @@ void _bt_add_headset_to_list(int type, int status, const char *address)
        }
 
        connected_device = g_malloc0(sizeof(bt_connected_headset_data_t));
+       /* Fix : NULL_RETURNS */
+       if (connected_device == NULL) {
+               BT_ERR("No memory allocated");
+               return;
+       }
+
        connected_device->device_state = status;
        if (status == BT_STATE_CONNECTED)
                connected_device->type |= type;
@@ -707,8 +618,8 @@ int _bt_audio_connect(int request_id, int type,
 {
        int result = BLUETOOTH_ERROR_NONE;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-       DBusGProxy *adapter_proxy;
-       DBusGConnection *g_conn;
+       GDBusProxy *adapter_proxy;
+       GDBusConnection *g_conn;
        int ret;
        char *uuid;
        int value = BLUETOOTH_ERROR_NONE;
@@ -725,6 +636,11 @@ int _bt_audio_connect(int request_id, int type,
        _bt_convert_addr_type_to_string(address, device_address->addr);
 
        func_data = g_malloc0(sizeof(bt_audio_function_data_t));
+       /* Fix : NULL_RETURNS */
+       if (func_data == NULL) {
+               result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
+               goto fail;
+       }
 
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
@@ -742,6 +658,9 @@ int _bt_audio_connect(int request_id, int type,
        case BT_AVRCP:
                uuid = AVRCP_TARGET_UUID;
                break;
+       case BT_AUDIO_A2DP_SOURCE:
+               uuid = A2DP_SOURCE_UUID;
+               break;
        case BT_AUDIO_ALL:
                if (__bt_device_support_uuid(address, BT_AUDIO_HSP)) {
                        uuid = HFP_HS_UUID;
@@ -797,8 +716,8 @@ int _bt_audio_disconnect(int request_id, int type,
        int result = BLUETOOTH_ERROR_NONE;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        bt_audio_function_data_t *func_data;
-       DBusGProxy *adapter_proxy;
-       DBusGConnection *g_conn;
+       GDBusProxy *adapter_proxy;
+       GDBusConnection *g_conn;
        GList *node;
        int ret;
        char *uuid;
@@ -831,6 +750,9 @@ int _bt_audio_disconnect(int request_id, int type,
        case BT_AVRCP:
                uuid = AVRCP_TARGET_UUID;
                break;
+       case BT_AUDIO_A2DP_SOURCE:
+               uuid = A2DP_SOURCE_UUID;
+               break;
        case BT_AUDIO_ALL:
                if (_bt_is_service_connected(address, BT_AUDIO_HSP)) {
                        uuid = HFP_HS_UUID;
@@ -911,13 +833,11 @@ int _bt_hf_connect(int request_id,
        int result = BLUETOOTH_ERROR_NONE;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        bt_function_data_t *func_data;
-       DBusGProxy *adapter_proxy;
-       DBusGConnection *g_conn;
-
+       GDBusProxy *adapter_proxy;
+       GDBusConnection *g_conn;
        int ret;
        char *uuid;
 
-
        BT_CHECK_PARAMETER(device_address, return);
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
@@ -935,6 +855,11 @@ int _bt_hf_connect(int request_id,
        }
 
        func_data = g_malloc0(sizeof(bt_function_data_t));
+       /* Fix : NULL_RETURNS */
+       if (func_data == NULL) {
+               result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
+               goto fail;
+       }
 
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
@@ -969,8 +894,8 @@ int _bt_hf_disconnect(int request_id,
        int result = BLUETOOTH_ERROR_NONE;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        bt_function_data_t *func_data;
-       DBusGProxy *adapter_proxy;
-       DBusGConnection *g_conn;
+       GDBusProxy *adapter_proxy;
+       GDBusConnection *g_conn;
 
        int ret;
        char *uuid;
@@ -992,6 +917,11 @@ int _bt_hf_disconnect(int request_id,
        }
 
        func_data = g_malloc0(sizeof(bt_function_data_t));
+       /* Fix : NULL_RETURNS */
+       if (func_data == NULL) {
+               result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
+               goto fail;
+       }
 
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
@@ -1018,126 +948,33 @@ fail:
        return result;
 }
 
-int _bt_audio_get_speaker_gain(unsigned int *gain)
-{
-       char *device_path = NULL;
-       DBusGProxy *adapter_proxy;
-       DBusGProxy *profile_proxy;
-       DBusGConnection *g_conn;
-       GHashTable *hash = NULL;
-       GValue *value;
-
-       adapter_proxy = _bt_get_adapter_proxy();
-       retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       g_conn = _bt_get_system_gconn();
-       retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       device_path = __bt_get_connected_audio_path();
-       retv_if(device_path == NULL, BLUETOOTH_ERROR_NOT_CONNECTED);
-
-       profile_proxy = dbus_g_proxy_new_for_name(g_conn, BT_BLUEZ_NAME,
-                                     device_path, BT_HEADSET_INTERFACE);
-
-       g_free(device_path);
-
-       retv_if(profile_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_g_proxy_call(profile_proxy, "GetProperties", NULL,
-                       G_TYPE_INVALID,
-                       dbus_g_type_get_map("GHashTable",
-                       G_TYPE_STRING, G_TYPE_VALUE),
-                       &hash, G_TYPE_INVALID);
-
-       g_object_unref(profile_proxy);
-
-       retv_if(hash == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       value = g_hash_table_lookup(hash, "SpeakerGain");
-       *gain = value ? g_value_get_uint(value) : 0;
-       g_hash_table_destroy(hash);
-       return BLUETOOTH_ERROR_NONE;
-}
-
-int _bt_audio_set_speaker_gain(unsigned int gain)
-{
-       char *device_path = NULL;
-       char *gain_str = "SpeakerGain";
-       char sig[2] = {DBUS_TYPE_UINT16, '\0'};
-       int ret = BLUETOOTH_ERROR_NONE;
-       DBusMessage *msg;
-       DBusMessageIter iter;
-       DBusMessageIter value;
-       DBusConnection *conn;
-
-       conn = _bt_get_system_conn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       device_path = __bt_get_connected_audio_path();
-       retv_if(device_path == NULL, BLUETOOTH_ERROR_NOT_CONNECTED);
-
-       msg = dbus_message_new_method_call(BT_BLUEZ_NAME,
-                       device_path, BT_HEADSET_INTERFACE,
-                       "SetProperty");
-
-       g_free(device_path);
-
-       retv_if(msg == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_message_iter_init_append(msg, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING,
-                       &gain_str);
-       dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
-                       sig, &value);
-       dbus_message_iter_append_basic(&value, DBUS_TYPE_UINT16,
-                       &gain);
-       dbus_message_iter_close_container(&iter, &value);
-
-       if (dbus_message_get_type(msg) == DBUS_MESSAGE_TYPE_METHOD_CALL)
-               dbus_message_set_no_reply(msg, TRUE);
-
-       if (!dbus_connection_send(conn, msg, NULL)) {
-               BT_ERR("Dbus sending failed\n");
-               ret = BLUETOOTH_ERROR_INTERNAL;
-       }
-       dbus_message_unref(msg);
-
-       return ret;
-}
-
 int _bt_audio_set_content_protect(gboolean status)
 {
-       DBusConnection *conn;
-       DBusMessage *signal;
+       GDBusConnection *conn;
+       GError *error = NULL;
 
        BT_DBG("+\n");
 
-       conn = _bt_get_system_conn();
+       conn = _bt_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       BT_DBG("Content Protection status = [%d] \n", status);
-
-       /*Emit Content protection Status change signal with value*/
-       signal = dbus_message_new_signal(BT_CONTENT_PROTECTION_PATH,
-                                       BT_CONTENT_PROTECTION_INTERFACE,
-                                       "ProtectionRequired");
-       if (!signal)
-               goto err;
-
-       if (!dbus_message_append_args(signal,
-                               DBUS_TYPE_BOOLEAN, &status,
-                               DBUS_TYPE_INVALID)) {
-               BT_ERR("Signal appending failed\n");
-               dbus_message_unref(signal);
-               goto err;
-       }
+       BT_DBG("Content Protection status = [%d]", status);
 
-       dbus_connection_send(conn, signal, NULL);
-       dbus_message_unref(signal);
+       g_dbus_connection_emit_signal(conn,
+                       NULL, BT_CONTENT_PROTECTION_PATH,
+                       BT_CONTENT_PROTECTION_INTERFACE,
+                       "ProtectionRequired",
+                       g_variant_new("(b)", status),
+                       &error);
 
-       BT_DBG("-\n");
-       return BLUETOOTH_ERROR_NONE;
+       if (error) {
+               /* dBUS gives error cause */
+               ERR("Could not Emit Signal: errCode[%x], message[%s]",
+                       error->code, error->message);
+               g_clear_error(&error);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
 
-err:
-       return BLUETOOTH_ERROR_INTERNAL;
+       BT_DBG("Emit Signal done = [ProtectionRequired]");
+       return BLUETOOTH_ERROR_NONE;
 }
diff --git a/bt-service/bt-service-avrcp-controller.c b/bt-service/bt-service-avrcp-controller.c
new file mode 100644 (file)
index 0000000..41a18b1
--- /dev/null
@@ -0,0 +1,659 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
+ *              Chanyeol Park <chanyeol.park@samsung.com>
+ *              Rakesh M K <rakesh.mk@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *             http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "bt-internal-types.h"
+#include "bt-service-common.h"
+#include "bt-service-avrcp-controller.h"
+#include "bt-service-audio.h"
+#include "bt-service-event.h"
+
+static bt_player_settinngs_t repeat_status[] = {
+       { REPEAT_INVALID, "" },
+       { REPEAT_MODE_OFF, "off" },
+       { REPEAT_SINGLE_TRACK, "singletrack" },
+       { REPEAT_ALL_TRACK, "alltracks" },
+       { REPEAT_GROUP, "group" },
+       { REPEAT_INVALID, "" }
+};
+
+static bt_player_settinngs_t equalizer_status[] = {
+       { EQUALIZER_INVALID, "" },
+       { EQUALIZER_OFF, "off" },
+       { EQUALIZER_ON, "on" },
+       { EQUALIZER_INVALID, "" },
+};
+
+static bt_player_settinngs_t scan_status[] = {
+       { SCAN_INVALID, "" },
+       { SCAN_MODE_OFF, "off" },
+       { SCAN_ALL_TRACK, "alltracks" },
+       { SCAN_GROUP, "group" },
+       { SCAN_INVALID, "" },
+};
+
+static bt_player_settinngs_t shuffle_settings[] = {
+       { SHUFFLE_INVALID, "" },
+       { SHUFFLE_MODE_OFF, "off" },
+       { SHUFFLE_ALL_TRACK, "alltracks" },
+       { SHUFFLE_GROUP, "group" },
+       { SHUFFLE_INVALID, "" }
+};
+
+static char *avrcp_control_path = NULL;
+
+void _bt_set_control_device_path(const char *path)
+{
+
+       ret_if(path == NULL);
+
+       g_free(avrcp_control_path);
+       BT_DBG("control_path = %s", path);
+       avrcp_control_path = g_strdup(path);
+}
+
+void _bt_remove_control_device_path(const char *path)
+{
+       ret_if(path == NULL);
+
+       if (avrcp_control_path &&
+                       !g_strcmp0(avrcp_control_path, path)) {
+               BT_DBG("control_path = %s", path);
+               g_free(avrcp_control_path);
+               avrcp_control_path = NULL;
+       }
+}
+
+static char *__bt_get_control_device_path(void)
+{
+       char *adapter_path;
+       char *control_path;
+       char connected_address[BT_ADDRESS_STRING_SIZE + 1];
+
+       BT_DBG("+");
+
+       retv_if(avrcp_control_path != NULL, avrcp_control_path);
+
+       retv_if(!_bt_is_headset_type_connected(BT_AVRCP,
+                       connected_address), NULL);
+
+       BT_DBG("device address = %s", connected_address);
+
+       adapter_path = _bt_get_device_object_path(connected_address);
+       retv_if(adapter_path == NULL, NULL);
+
+       control_path = g_strdup_printf(BT_MEDIA_CONTROL_PATH, adapter_path);
+       g_free(adapter_path);
+
+       avrcp_control_path = control_path;
+       BT_DBG("control_path = %s", control_path);
+       return control_path;
+}
+
+static int __bt_media_send_control_msg(const char *name)
+{
+       GVariant *reply = NULL;
+       GError *err = NULL;
+       GDBusConnection *conn = NULL;
+       GDBusProxy *proxy = NULL;
+       char *control_path = NULL;
+
+       retv_if(name == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       conn = _bt_get_system_conn();
+       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       control_path = __bt_get_control_device_path();
+       retv_if(control_path == NULL, BLUETOOTH_ERROR_NOT_CONNECTED);
+       BT_DBG("control_path %s", control_path);
+
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       BT_BLUEZ_NAME, control_path,
+                       BT_PLAYER_CONTROL_INTERFACE, NULL, &err);
+       if (proxy == NULL) {
+               BT_ERR("Unable to allocate new proxy \n");
+               if (err) {
+                       BT_ERR("%s", err->message);
+                       g_clear_error(&err);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       reply = g_dbus_proxy_call_sync(proxy, name, NULL,
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+
+       g_object_unref(proxy);
+
+       if (!reply) {
+               BT_ERR("Error returned in method call");
+               if (err) {
+                       BT_ERR("%s", err->message);
+                       g_clear_error(&err);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       g_variant_unref(reply);
+
+       BT_DBG("-");
+       return BLUETOOTH_ERROR_NONE;
+}
+
+int _bt_avrcp_control_cmd(int type)
+{
+       int ret = BLUETOOTH_ERROR_INTERNAL;
+       BT_DBG("+");
+
+       switch (type) {
+       case PLAY:
+               ret = __bt_media_send_control_msg("Play");
+               break;
+       case PAUSE:
+               ret = __bt_media_send_control_msg("Pause");
+               break;
+       case STOP:
+               ret = __bt_media_send_control_msg("Stop");
+               break;
+       case NEXT:
+               ret = __bt_media_send_control_msg("Next");
+               break;
+       case PREVIOUS:
+               ret = __bt_media_send_control_msg("Previous");
+               break;
+       case FAST_FORWARD:
+               ret = __bt_media_send_control_msg("FastForward");
+               break;
+       case REWIND:
+               ret = __bt_media_send_control_msg("Rewind");
+               break;
+       default:
+               BT_DBG("Invalid Type\n");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+       BT_DBG("-");
+       return ret;
+}
+
+GDBusProxy *__bt_get_control_properties_proxy(void)
+{
+       GDBusProxy *proxy = NULL;
+       GError *error = NULL;
+       char *control_path = NULL;
+       GDBusConnection *conn = NULL;
+
+       control_path = __bt_get_control_device_path();
+       retv_if(control_path == NULL, NULL);
+       BT_DBG("control_path = %s", control_path);
+
+       conn = _bt_get_system_conn();
+       retv_if(conn == NULL, NULL);
+
+       proxy = g_dbus_proxy_new_sync(conn,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       BT_BLUEZ_NAME, control_path,
+                       BT_PROPERTIES_INTERFACE, NULL, &error);
+       if (proxy == NULL) {
+               BT_ERR("Unable to allocate new proxy");
+               if (error) {
+                       BT_ERR("%s", error->message);
+                       g_clear_error(&error);
+               }
+               return NULL;
+       }
+
+       return proxy;
+}
+
+static int __bt_media_attr_to_event(const char *str)
+{
+       if (!strcasecmp(str, "Equalizer"))
+               return BLUETOOTH_EVENT_AVRCP_CONTROL_EQUALIZER_STATUS;
+       else if (!strcasecmp(str, "Repeat"))
+               return BLUETOOTH_EVENT_AVRCP_CONTROL_REPEAT_STATUS;
+       else if (!strcasecmp(str, "Shuffle"))
+               return BLUETOOTH_EVENT_AVRCP_CONTROL_SHUFFLE_STATUS;
+       else if (!strcasecmp(str, "Scan"))
+               return BLUETOOTH_EVENT_AVRCP_CONTROL_SCAN_STATUS;
+       else if (!strcasecmp(str, "Position"))
+               return BLUETOOTH_EVENT_AVRCP_SONG_POSITION_STATUS;
+       else if (!strcasecmp(str, "Track"))
+               return BLUETOOTH_EVENT_AVRCP_TRACK_CHANGED;
+       else if (!strcasecmp(str, "Status"))
+               return BLUETOOTH_EVENT_AVRCP_PLAY_STATUS_CHANGED;
+
+       return 0;
+}
+
+static int __bt_media_attr_to_type(const char *str)
+{
+       if (!strcasecmp(str, "Equalizer"))
+               return EQUALIZER;
+       else if (!strcasecmp(str, "Repeat"))
+               return REPEAT;
+       else if (!strcasecmp(str, "Shuffle"))
+               return SHUFFLE;
+       else if (!strcasecmp(str, "Scan"))
+               return SCAN;
+       else if (!strcasecmp(str, "Position"))
+               return POSITION;
+       else if (!strcasecmp(str, "Track"))
+               return METADATA;
+       else if (!strcasecmp(str, "Status"))
+               return STATUS;
+
+       return 0;
+}
+
+static const char *__bt_media_type_to_str(int type)
+{
+       switch (type) {
+       case EQUALIZER:
+               return "Equalizer";
+       case REPEAT:
+               return "Repeat";
+       case SHUFFLE:
+               return "Shuffle";
+       case SCAN:
+               return "Scan";
+       case POSITION:
+               return "Position";
+       case METADATA:
+               return "Track";
+       case STATUS:
+               return "Status";
+       }
+       return NULL;
+}
+
+static int __bt_media_attrval_to_val(int type, const char *value)
+{
+       int ret = 0;
+
+       switch (type) {
+       case EQUALIZER:
+               if (!strcmp(value, "off"))
+                       ret = EQUALIZER_OFF;
+               else if (!strcmp(value, "on"))
+                       ret = EQUALIZER_ON;
+               else
+                       ret = EQUALIZER_INVALID;
+               break;
+
+       case REPEAT:
+               if (!strcmp(value, "off"))
+                       ret = REPEAT_MODE_OFF;
+               else if (!strcmp(value, "singletrack"))
+                       ret = REPEAT_SINGLE_TRACK;
+               else if (!strcmp(value, "alltracks"))
+                       ret = REPEAT_ALL_TRACK;
+               else if (!strcmp(value, "group"))
+                       ret = REPEAT_GROUP;
+               else
+                       ret = REPEAT_INVALID;
+               break;
+
+       case SHUFFLE:
+               if (!strcmp(value, "off"))
+                       ret = SHUFFLE_MODE_OFF;
+               else if (!strcmp(value, "alltracks"))
+                       ret = SHUFFLE_ALL_TRACK;
+               else if (!strcmp(value, "group"))
+                       ret = SHUFFLE_GROUP;
+               else
+                       ret = SHUFFLE_INVALID;
+               break;
+
+       case SCAN:
+               if (!strcmp(value, "off"))
+                       ret = SCAN_MODE_OFF;
+               else if (!strcmp(value, "alltracks"))
+                       ret = SCAN_ALL_TRACK;
+               else if (!strcmp(value, "group"))
+                       ret = SCAN_GROUP;
+               else
+                       ret = SCAN_INVALID;
+               break;
+
+       case STATUS:
+               if (!strcmp(value, "stopped"))
+                       ret = STATUS_STOPPED;
+               else if (!strcmp(value, "playing"))
+                       ret = STATUS_PLAYING;
+               else if (!strcmp(value, "paused"))
+                       ret = STATUS_PAUSED;
+               else if (!strcmp(value, "forward-seek"))
+                       ret = STATUS_FORWARD_SEEK;
+               else if (!strcmp(value, "reverse-seek"))
+                       ret = STATUS_REVERSE_SEEK;
+               else if (!strcmp(value, "error"))
+                       ret = STATUS_ERROR;
+               else
+                       ret = STATUS_INVALID;
+       }
+       return ret;
+}
+
+int _bt_avrcp_control_get_property(int type, unsigned int *value)
+{
+       GDBusProxy *proxy = NULL;
+       char *name = NULL;
+       int ret = BLUETOOTH_ERROR_NONE;
+       GError *err = NULL;
+       GVariant *reply = NULL;
+
+       BT_CHECK_PARAMETER(value, return);
+
+       proxy = __bt_get_control_properties_proxy();
+       retv_if(proxy == NULL, BLUETOOTH_ERROR_NOT_CONNECTED);
+
+       reply = g_dbus_proxy_call_sync(proxy,
+                                       "Get", g_variant_new("ss", BT_PLAYER_CONTROL_INTERFACE, __bt_media_type_to_str(type)),
+                                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+
+       g_object_unref(proxy);
+
+       if (!reply) {
+               BT_ERR("Can't get managed objects");
+               if (err) {
+                       BT_ERR("%s", err->message);
+                       g_clear_error(&err);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       } else {
+                       switch (type) {
+                       case EQUALIZER:
+                       case REPEAT:
+                       case SHUFFLE:
+                       case SCAN:
+                       case STATUS:
+                               name =(char *)g_variant_get_string(reply, NULL);
+                               *value = __bt_media_attrval_to_val(type, name);
+                               BT_DBG("Type[%s] and Value[%s]", __bt_media_type_to_str(type), name);
+                               break;
+                       case POSITION:
+                               *value = g_variant_get_uint32(reply);
+                               break;
+                       default:
+                               BT_DBG("Invalid Type\n");
+                               ret =  BLUETOOTH_ERROR_INTERNAL;
+                       }
+               }
+       g_variant_unref(reply);
+       return ret;
+}
+
+int _bt_avrcp_control_set_property(int type, unsigned int value)
+{
+       GValue *attr_value = NULL;
+       GDBusProxy *proxy = NULL;
+       GError *error = NULL;
+       GVariant *reply, *param;
+
+       g_value_init(attr_value, G_TYPE_STRING);
+
+       switch (type) {
+       case EQUALIZER:
+               param = g_variant_new("s", equalizer_status[value].property);
+               BT_DBG("equalizer_status %s", equalizer_status[value].property);
+               break;
+       case REPEAT:
+               param = g_variant_new("s", repeat_status[value].property);
+               BT_DBG("repeat_status %s", repeat_status[value].property);
+               break;
+       case SHUFFLE:
+               param = g_variant_new("s", shuffle_settings[value].property);
+               BT_DBG("shuffle_settings %s", shuffle_settings[value].property);
+               break;
+       case SCAN:
+               param = g_variant_new("s", scan_status[value].property);
+               BT_DBG("scan_status %s", scan_status[value].property);
+               break;
+       default:
+               BT_ERR("Invalid property type: %d", type);
+               g_value_unset(attr_value);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       proxy = __bt_get_control_properties_proxy();
+       retv_if(proxy == NULL, BLUETOOTH_ERROR_NOT_CONNECTED);
+
+       reply = g_dbus_proxy_call_sync(proxy,
+                                       "Set", g_variant_new("ssv", BT_PLAYER_CONTROL_INTERFACE, __bt_media_type_to_str(type), param),
+                                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+       g_object_unref(proxy);
+       g_variant_unref(param);
+
+       if (!reply) {
+               BT_ERR("Can't get managed objects");
+               if (error) {
+                       BT_ERR("SetProperty Fail: %s", error->message);
+                       g_clear_error(&error);
+                       return BLUETOOTH_ERROR_INTERNAL;
+               }
+       }
+
+       g_variant_unref(reply);
+       g_value_unset(attr_value);
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+static int __bt_avrcp_control_parse_properties(
+                               media_metadata_attributes_t *metadata,
+                               GVariant *item)
+{
+       GVariant *value = NULL;
+       GVariantIter iter;
+       char *value_string = NULL;
+       unsigned int value_uint;
+       const char *key = NULL;
+
+       g_variant_iter_init(&iter, item);
+       while (g_variant_iter_loop(&iter, "{sv}", &key, &value)){
+               if (strcasecmp(key, "Title") == 0){
+                       value_string = (char *)g_variant_get_string(value, NULL);
+                       BT_DBG("Value : %s ", value_string);
+                       metadata->title = value_string;
+               } else if (strcasecmp(key, "Artist") == 0) {
+                       value_string =(char *)g_variant_get_string(value, NULL);
+                       BT_DBG("Value : %s ", value_string);
+                       metadata->artist = value_string;
+               } else if (strcasecmp(key, "Album") == 0) {
+                       value_string =(char *)g_variant_get_string(value, NULL);
+                       BT_DBG("Value : %s ", value_string);
+                       metadata->album = value_string;
+               } else if (strcasecmp(key, "Genre") == 0) {
+                       value_string =(char *)g_variant_get_string(value, NULL);
+                       BT_DBG("Value : %s ", value_string);
+                       metadata->genre = value_string;
+               } else if (strcasecmp(key, "Duration") == 0) {
+                       value_uint = g_variant_get_uint32(value);
+                       metadata->duration = value_uint;
+               } else if (strcasecmp(key, "NumberOfTracks") == 0) {
+                       value_uint = g_variant_get_uint32(value);
+                       metadata->total_tracks = value_uint;
+               } else if (strcasecmp(key, "TrackNumber") == 0) {
+                       value_uint = g_variant_get_uint32(value);
+                       metadata->number = value_uint;
+               } else
+                       BT_DBG("%s not supported, ignoring", key);
+       }
+
+       if (!metadata->title)
+               metadata->title = g_strdup("");
+       if (!metadata->artist)
+               metadata->artist = g_strdup("");
+       if (!metadata->album)
+               metadata->album = g_strdup("");
+       if (!metadata->genre)
+               metadata->genre = g_strdup("");
+
+       return BLUETOOTH_ERROR_NONE;
+
+}
+
+int _bt_avrcp_control_get_track_info(media_metadata_attributes_t *metadata)
+{
+       GDBusProxy *proxy = NULL;
+       GVariant *reply = NULL;
+       GVariant *item = NULL;
+       GError *err = NULL;
+       GDBusConnection *conn = NULL;
+       char *control_path = NULL;
+       char *interface_name = NULL;
+       char *property_name = NULL;
+       GVariant *parameters = NULL;
+       int ret = BLUETOOTH_ERROR_NONE;
+
+       retv_if(metadata == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       conn = _bt_get_system_conn();
+       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       control_path = __bt_get_control_device_path();
+       retv_if(control_path == NULL, BLUETOOTH_ERROR_NOT_CONNECTED);
+       BT_DBG("control_path %s", control_path);
+
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       BT_BLUEZ_NAME, control_path,
+                       BT_PROPERTIES_INTERFACE, NULL, &err);
+       if (proxy == NULL) {
+               BT_ERR("Unable to allocate new proxy \n");
+               if (err) {
+                       BT_ERR("%s", err->message);
+                       g_clear_error(&err);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       interface_name = g_strdup(BT_PLAYER_CONTROL_INTERFACE);
+       property_name = g_strdup("Track");
+
+       parameters = g_variant_new("(ss)", interface_name, property_name);
+
+       g_free(interface_name);
+       g_free(property_name);
+
+       reply = g_dbus_proxy_call_sync(proxy, "Get", parameters,
+                                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+
+       g_object_unref(proxy);
+
+       if (!reply) {
+               BT_ERR("Error returned in method call");
+               if (err) {
+                       BT_ERR("%s", err->message);
+                       g_clear_error(&err);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       g_variant_get(reply, "(v)", &item);
+
+       ret = __bt_avrcp_control_parse_properties(metadata, item);
+
+       g_variant_unref(reply);
+       BT_DBG("-");
+       return ret;
+}
+
+void _bt_handle_avrcp_control_event(GVariant *reply, const char *path)
+{
+       GVariant *param = NULL;
+       const char *property = NULL;
+
+       if (!reply) {
+               BT_ERR("Error returned in method call\n");
+               return;
+       }
+
+       GVariantIter iter;
+       GVariant *value = NULL;
+       g_variant_iter_init(&iter, reply);
+       while (g_variant_iter_loop(&iter, "{sv}", &property,
+                               &value)) {
+               if ((strcasecmp(property, "Equalizer") == 0) ||
+                       (strcasecmp(property, "Repeat") == 0) ||
+                       (strcasecmp(property, "Shuffle") == 0) ||
+                       (strcasecmp(property, "Scan") == 0) ||
+                       (strcasecmp(property, "Status") == 0)){
+                               const char *valstr;
+                               unsigned int type, val;
+
+                               valstr = g_variant_get_string(value, NULL);
+                               BT_DBG("Value : %s ", valstr);
+                               type = __bt_media_attr_to_type(property);
+                               val = __bt_media_attrval_to_val(type, valstr);
+
+                               /* Send event to application */
+                               param = g_variant_new("(u)", val);
+                               _bt_send_event(BT_AVRCP_CONTROL_EVENT,
+                                       __bt_media_attr_to_event(property), param);
+               } else if (strcasecmp(property, "Position") == 0) {
+                       unsigned int val;
+
+                       val = g_variant_get_uint32(value);
+                       BT_DBG("Value : %d ", val);
+
+                       /* Send event to application */
+                       param = g_variant_new("(u)", val);
+                       _bt_send_event(BT_AVRCP_CONTROL_EVENT,
+                               __bt_media_attr_to_event(property), param);
+               } else if (strcasecmp(property, "Track") == 0) {
+                       int ret = BLUETOOTH_ERROR_NONE;
+                       media_metadata_attributes_t metadata;
+
+                       memset(&metadata, 0x00, sizeof(media_metadata_attributes_t));
+
+                       ret = __bt_avrcp_control_parse_properties(
+                                                               &metadata, reply);
+                       if (BLUETOOTH_ERROR_NONE != ret){
+                               /* Free key and value because of break unless free not required */
+                               free((char *)property);
+                               g_variant_unref(value);
+                               break;
+                       }
+
+                               /* Send event to application */
+                       param = g_variant_new("(ssssuuu)",
+                                                       metadata.title,
+                                                       metadata.artist,
+                                                       metadata.album,
+                                                       metadata.genre,
+                                                       metadata.total_tracks,
+                                                       metadata.number,
+                                                       metadata.duration);
+                       _bt_send_event(BT_AVRCP_CONTROL_EVENT,
+                               BLUETOOTH_EVENT_AVRCP_TRACK_CHANGED, param);
+
+                       g_free((char *)metadata.title);
+                       g_free((char *)metadata.artist);
+                       g_free((char *)metadata.album);
+                       g_free((char *)metadata.genre);
+               } else {
+                       BT_DBG("Property not handled");
+               }
+       }
+
+       BT_DBG("-");
+}
index 434b312..f7c5367 100644 (file)
  *
  */
 
-#include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
+#include <gio/gio.h>
 #include <glib.h>
 #include <dlog.h>
 #include <string.h>
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
 #include <syspopup_caller.h>
-#endif
+#include <dbus/dbus.h>
 
 #include "bluetooth-api.h"
 #include "bt-internal-types.h"
-
 #include "bt-service-common.h"
 #include "bt-service-avrcp.h"
 #include "bt-service-event.h"
 #include "bt-service-util.h"
 #include "bt-service-audio.h"
 
-struct player_settinngs_t {
-       int key;
-       const char *property;
-};
-
-static struct player_settinngs_t loopstatus_settings[] = {
+static bt_player_settinngs_t loopstatus_settings[] = {
        { REPEAT_INVALID, "" },
        { REPEAT_MODE_OFF, "None" },
        { REPEAT_SINGLE_TRACK, "Track" },
@@ -53,8 +44,7 @@ static struct player_settinngs_t loopstatus_settings[] = {
        { REPEAT_INVALID, "" }
 };
 
-
-static struct player_settinngs_t shuffle_settings[] = {
+static bt_player_settinngs_t shuffle_settings[] = {
        { SHUFFLE_INVALID, "" },
        { SHUFFLE_MODE_OFF, "off" },
        { SHUFFLE_ALL_TRACK, "alltracks" },
@@ -62,7 +52,7 @@ static struct player_settinngs_t shuffle_settings[] = {
        { SHUFFLE_INVALID, "" }
 };
 
-static struct player_settinngs_t player_status[] = {
+static bt_player_settinngs_t player_status[] = {
        { STATUS_STOPPED, "stopped" },
        { STATUS_PLAYING, "playing" },
        { STATUS_PAUSED, "paused" },
@@ -72,76 +62,120 @@ static struct player_settinngs_t player_status[] = {
        { STATUS_INVALID, "" }
 };
 
-static struct player_settinngs_t repeat_status[] = {
-       { REPEAT_INVALID, "" },
-       { REPEAT_MODE_OFF, "off" },
-       { REPEAT_SINGLE_TRACK, "singletrack" },
-       { REPEAT_ALL_TRACK, "alltracks" },
-       { REPEAT_GROUP, "group" },
-       { REPEAT_INVALID, "" }
-};
+GDBusConnection *bt_gdbus_conn = NULL;
+static guint avrcp_reg_id = 0;
+static GDBusProxy *service_gproxy = NULL;
+
+/* Introspection data exposed from bt-service */
+static const gchar bt_avrcp_bluez_introspection_xml[] =
+"<node name='/'>"
+" <interface name='org.freedesktop.DBus.Properties'>"
+"     <method name='Set'>"
+"          <arg type='s' name='interface' direction='in'/>"
+"          <arg type='s' name='property' direction='in'/>"
+"          <arg type='v' name='value' direction='in'/>"
+"     </method>"
+" </interface>"
+"</node>";
+
+static gboolean __bt_media_emit_property_changed(GDBusConnection *connection,
+               const char *path, const char *interface, const char *name,
+               const GVariant *variant)
+{
+       GVariantBuilder *builder = NULL;
+       GError *error = NULL;
 
-static struct player_settinngs_t equalizer_status[] = {
-       { EQUALIZER_INVALID, "" },
-       { EQUALIZER_OFF, "off" },
-       { EQUALIZER_ON, "on" },
-       { EQUALIZER_INVALID, "" },
-};
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       g_variant_builder_add(builder, "{sv}", name, variant);
 
-static struct player_settinngs_t scan_status[] = {
-       { SCAN_INVALID, "" },
-       { SCAN_MODE_OFF, "off" },
-       { SCAN_ALL_TRACK, "alltracks" },
-       { SCAN_GROUP, "group" },
-       { SCAN_INVALID, "" },
-};
+       g_dbus_connection_emit_signal(connection, NULL, path,
+                               DBUS_INTERFACE_PROPERTIES,
+                               "PropertiesChanged",
+                               g_variant_new("(sa{sv})",
+                               interface, builder),
+                               &error);
+
+       g_variant_builder_unref(builder);
+       if (error) {
+               BT_ERR("Could not Emit PropertiesChanged Signal: errCode[%x], message[%s]",
+                       error->code, error->message);
+               g_clear_error(&error);
+               return FALSE;
+       }
+
+       return TRUE;
+}
+
+static GQuark __bt_avrcp_error_quark(void)
+{
+       static GQuark quark = 0;
+
+       if (!quark)
+               quark = g_quark_from_static_string("bt-avrcp");
 
-DBusConnection *g_bt_dbus_conn = NULL;
-static char *avrcp_control_path = NULL;
+       return quark;
+}
+
+static GError *__bt_avrcp_set_error(bt_avrcp_error_t error)
+{
+       BT_ERR("error[%d]\n", error);
+
+       switch (error) {
+       case BT_AVRCP_ERROR_INVALID_PARAM:
+               return g_error_new(BT_AVRCP_ERROR, error,
+                               BT_ERROR_INVALID_PARAM);
+       case BT_AVRCP_ERROR_INVALID_INTERFACE:
+               return g_error_new(BT_AVRCP_ERROR, error,
+                               BT_ERROR_INVALID_INTERFACE);
+       case BT_AVRCP_ERROR_INTERNAL:
+       default:
+               return g_error_new(BT_AVRCP_ERROR, error,
+                               BT_ERROR_INTERNAL);
+       }
+}
 
-static DBusHandlerResult _bt_avrcp_handle_set_property(DBusConnection *connection,
-                               DBusMessage *message, void *user_data)
+static void __bt_avrcp_agent_method(GDBusConnection *connection,
+               const gchar *sender,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *method_name,
+               GVariant *parameters,
+               GDBusMethodInvocation *invocation,
+               gpointer user_data)
 {
        BT_DBG("+");
-       const gchar *value;
-       unsigned int status;
+       BT_INFO("method %s", method_name);
+       BT_INFO("object_path %s", object_path);
+       int ret = BT_AVRCP_ERROR_NONE;
+       GError *err = NULL;
        gboolean shuffle_status;
-       DBusMessageIter args;
-       const char *property = NULL;
-       const char *interface = NULL;
-       DBusMessage *reply = NULL;
-       DBusHandlerResult result = DBUS_HANDLER_RESULT_HANDLED;
-       DBusMessageIter entry;
-       int type;
-
-
-       dbus_message_iter_init(message, &args);
-       dbus_message_iter_get_basic(&args, &interface);
-       dbus_message_iter_next(&args);
-
-       if (g_strcmp0(interface, BT_MEDIA_PLAYER_INTERFACE) != 0) {
-               result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-               goto finish;
+       guint32 status;
+       gchar *interface = NULL;
+       gchar *property = NULL;
+       gchar *loop_status = NULL;
+       GVariant *value;
+
+       if (g_strcmp0(method_name, "Set") == 0) {
+               g_variant_get(parameters, "(&s&sv)", &interface, &property,
+                               &value);
+
+               if (g_strcmp0(interface, BT_MEDIA_PLAYER_INTERFACE) != 0) {
+                       ret = BT_AVRCP_ERROR_INVALID_INTERFACE;
+                       goto fail;
+               }
        }
 
-       dbus_message_iter_get_basic(&args, &property);
-       dbus_message_iter_next(&args);
-       dbus_message_iter_recurse(&args, &entry);
-       type = dbus_message_iter_get_arg_type(&entry);
-
-       BT_DBG("property %s\n", property);
-
+       BT_DBG("Property: %s\n", property);
        if (g_strcmp0(property, "Shuffle") == 0) {
-               if (type != DBUS_TYPE_BOOLEAN) {
-                       BT_DBG("Error");
-                       reply = dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
-                                       "Invalid arguments");
-                       dbus_connection_send(connection, reply, NULL);
-                       result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-                       goto finish;
+
+               if (!g_variant_is_of_type(value, G_VARIANT_TYPE_BOOLEAN)) {
+                       BT_ERR("Error");
+                       ret = BT_AVRCP_ERROR_INVALID_PARAM;
+                       goto fail;
                }
-               dbus_message_iter_get_basic(&entry, &shuffle_status);
-               BT_DBG("value %d\n", shuffle_status);
+
+               shuffle_status = g_variant_get_boolean(value);
+               BT_DBG("Value: %s\n", shuffle_status ? "TRUE" : "FALSE");
                if (shuffle_status == TRUE)
                        status = SHUFFLE_ALL_TRACK;
                else
@@ -149,558 +183,358 @@ static DBusHandlerResult _bt_avrcp_handle_set_property(DBusConnection *connectio
 
                _bt_send_event(BT_AVRCP_EVENT,
                                BLUETOOTH_EVENT_AVRCP_SETTING_SHUFFLE_STATUS,
-                               DBUS_TYPE_UINT32, &status,
-                               DBUS_TYPE_INVALID);
-
+                               g_variant_new("(u)", status));
        } else if (g_strcmp0(property, "LoopStatus") == 0) {
-               if (type != DBUS_TYPE_STRING) {
-                       BT_DBG("Error");
-                       reply = dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
-                                       "Invalid arguments");
-                       dbus_connection_send(connection, reply, NULL);
-                       result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-                       goto finish;
+
+               if (!g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+                       BT_ERR("Error");
+                       ret = BT_AVRCP_ERROR_INVALID_PARAM;
+                       goto fail;
                }
-               dbus_message_iter_get_basic(&entry, &value);
-               BT_DBG("value %s\n", value);
 
-               if (g_strcmp0(value, "Track") == 0)
+               loop_status = (gchar *)g_variant_get_string(value, NULL);
+               BT_DBG("Value: %s\n", loop_status);
+
+               if (g_strcmp0(loop_status, "Track") == 0)
                        status = REPEAT_SINGLE_TRACK;
-               else if (g_strcmp0(value, "Playlist") == 0)
+               else if (g_strcmp0(loop_status, "Playlist") == 0)
                        status = REPEAT_ALL_TRACK;
-               else if (g_strcmp0(value, "None") == 0)
+               else if (g_strcmp0(loop_status, "None") == 0)
                        status = REPEAT_MODE_OFF;
                else
                        status = REPEAT_INVALID;
 
                _bt_send_event(BT_AVRCP_EVENT,
                                BLUETOOTH_EVENT_AVRCP_SETTING_REPEAT_STATUS,
-                               DBUS_TYPE_UINT32, &status,
-                               DBUS_TYPE_INVALID);
+                               g_variant_new("(u)", status));
        }
-finish:
-       if (reply)
-               dbus_message_unref(reply);
-
-       return result;
-}
-
-static DBusHandlerResult _bt_avrcp_message_handle(DBusConnection *conn, DBusMessage *msg, void *user_data)
-{
-       BT_DBG("+");
-
-       if (dbus_message_is_method_call(msg, DBUS_INTERFACE_PROPERTIES, "Set"))
-               return _bt_avrcp_handle_set_property(conn, msg, user_data);
 
        BT_DBG("-");
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       return;
+
+fail:
+       g_variant_unref(value);
+       err = __bt_avrcp_set_error(ret);
+       g_dbus_method_invocation_return_gerror(invocation, err);
+       g_clear_error(&err);
+       BT_INFO("-");
 }
 
-static DBusObjectPathVTable bt_object_table = {
-        .message_function       = _bt_avrcp_message_handle,
+static const GDBusInterfaceVTable method_table = {
+       __bt_avrcp_agent_method,
+       NULL,
+       NULL,
 };
 
-gboolean bt_dbus_register_object_path(DBusConnection *connection,
-                                               const char *path)
-{
-       if (!dbus_connection_register_object_path(connection, path,
-                               &bt_object_table, NULL))
-               return FALSE;
-       return TRUE;
-}
-
-void bt_dbus_unregister_object_path(DBusConnection *connection,
-                                               const char *path)
-{
-       dbus_connection_unregister_object_path(connection, path);
-}
-
-static void __bt_media_append_variant(DBusMessageIter *iter,
-                       int type, void *value)
+static GDBusNodeInfo *__bt_avrcp_create_method_node_info
+                               (const gchar *introspection_data)
 {
-       char sig[2] = { type, '\0'};
-       DBusMessageIter value_iter;
-
-       dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, sig,
-                                                       &value_iter);
-
-       dbus_message_iter_append_basic(&value_iter, type, value);
+       GError *err = NULL;
+       GDBusNodeInfo *node_info = NULL;
 
-       dbus_message_iter_close_container(iter, &value_iter);
-}
+       if (introspection_data == NULL)
+               return NULL;
 
-static void __bt_media_append_dict_entry(DBusMessageIter *iter,
-                       const char *key, int type, void *property)
-{
-       DBusMessageIter dict_entry;
-       const char *str_ptr;
+       node_info = g_dbus_node_info_new_for_xml(introspection_data, &err);
 
-       if (type == DBUS_TYPE_STRING) {
-               str_ptr = *((const char **)property);
-               ret_if(str_ptr == NULL);
+       if (err) {
+               BT_ERR("Unable to create node: %s", err->message);
+               g_clear_error(&err);
        }
 
-       dbus_message_iter_open_container(iter,
-                                       DBUS_TYPE_DICT_ENTRY,
-                                       NULL, &dict_entry);
-
-       dbus_message_iter_append_basic(&dict_entry, DBUS_TYPE_STRING, &key);
-
-       __bt_media_append_variant(&dict_entry, type, property);
-
-       dbus_message_iter_close_container(iter, &dict_entry);
-}
-
-static gboolean __bt_media_emit_property_changed(
-                                DBusConnection *connection,
-                                const char *path,
-                                const char *interface,
-                                const char *name,
-                                int type,
-                                void *property)
-{
-       DBusMessage *sig;
-       DBusMessageIter entry, dict;
-       gboolean ret;
-
-       sig = dbus_message_new_signal(path, DBUS_INTERFACE_PROPERTIES,
-                                               "PropertiesChanged");
-       retv_if(sig == NULL, FALSE);
-
-       dbus_message_iter_init_append(sig, &entry);
-       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &interface);
-       dbus_message_iter_open_container(&entry, DBUS_TYPE_ARRAY,
-                       DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
-                       DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
-                       DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
-
-       __bt_media_append_dict_entry(&dict,
-                                       name, type, property);
-
-       dbus_message_iter_close_container(&entry, &dict);
-
-       ret = dbus_connection_send(connection, sig, NULL);
-       dbus_message_unref(sig);
-
-       return ret;
-}
-
-void _bt_set_control_device_path(const char *path)
-{
-
-       ret_if(path == NULL);
-
-       g_free(avrcp_control_path);
-       BT_DBG("control_path = %s", path);
-       avrcp_control_path = g_strdup(path);
+       return node_info;
 }
 
-void _bt_remove_control_device_path(const char *path)
+static GDBusProxy *__bt_avrcp_gdbus_init_service_proxy(void)
 {
-       ret_if(path == NULL);
-
-       if (avrcp_control_path &&
-                       !g_strcmp0(avrcp_control_path, path)) {
-               BT_DBG("control_path = %s", path);
-               g_free(avrcp_control_path);
-               avrcp_control_path = NULL;
-       }
-}
-
-static char *__bt_get_control_device_path(void)
-{
-       char *adapter_path;
-       char *control_path;
-       char connected_address[BT_ADDRESS_STRING_SIZE + 1];
-
        BT_DBG("+");
+       GDBusProxy *proxy;
+       GError *err = NULL;
+       char *adapter_path;
 
-       retv_if(avrcp_control_path != NULL, avrcp_control_path);
-
-       retv_if(!_bt_is_headset_type_connected(BT_AVRCP,
-                       connected_address), NULL);
+       if (bt_gdbus_conn == NULL)
+               bt_gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
 
-       BT_DBG("device address = %s", connected_address);
+       if (!bt_gdbus_conn) {
+               if (err) {
+                       BT_ERR("Unable to connect to gdbus: %s", err->message);
+                       g_clear_error(&err);
+               }
+               return NULL;
+       }
 
-       adapter_path = _bt_get_device_object_path(connected_address);
+       adapter_path = _bt_get_adapter_path();
        retv_if(adapter_path == NULL, NULL);
 
-       control_path = g_strdup_printf(BT_MEDIA_CONTROL_PATH, adapter_path);
+       proxy =  g_dbus_proxy_new_sync(bt_gdbus_conn,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       BT_BLUEZ_NAME, adapter_path,
+                       BT_MEDIA_INTERFACE, NULL, &err);
        g_free(adapter_path);
 
-       avrcp_control_path = control_path;
-       BT_DBG("control_path = %s", control_path);
-       return control_path;
-}
-
-static int __bt_media_send_control_msg(const char *name)
-{
-       DBusMessage *msg;
-       DBusMessage *reply;
-       DBusError err;
-       DBusConnection *conn;
-       char *control_path;
-
-       retv_if(name == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       conn = _bt_get_system_conn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       control_path = __bt_get_control_device_path();
-       retv_if(control_path == NULL, BLUETOOTH_ERROR_NOT_CONNECTED);
-       BT_DBG("control_path %s", control_path);
-
-       msg = dbus_message_new_method_call(BT_BLUEZ_NAME, control_path,
-                               BT_PLAYER_CONTROL_INTERFACE, name);
-
-       retv_if(msg == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_error_init(&err);
-       reply = dbus_connection_send_with_reply_and_block(conn,
-                               msg, -1, &err);
-       dbus_message_unref(msg);
-
-       if (!reply) {
-               BT_ERR("Error in Sending Control Command");
-
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("%s", err.message);
-                       dbus_error_free(&err);
+       if (!proxy) {
+               BT_ERR("Unable to create proxy");
+               if (err) {
+                       BT_ERR("Error: %s", err->message);
+                       g_clear_error(&err);
                }
-               return BLUETOOTH_ERROR_INTERNAL;
+               return NULL;
        }
 
-       dbus_message_unref(reply);
-
-       BT_DBG("-");
-       return BLUETOOTH_ERROR_NONE;
+       BT_DBG("-");;
+       return proxy;
 }
 
+static GDBusProxy *__bt_avrcp_gdbus_get_service_proxy(void)
+{
+       return (service_gproxy) ? service_gproxy :
+                       __bt_avrcp_gdbus_init_service_proxy();
+}
 
 int _bt_register_media_player(void)
 {
        BT_DBG("+");
-       DBusMessage *msg;
-       DBusMessage *reply;
-       DBusMessageIter iter;
-       DBusMessageIter property_dict;
-       DBusError err;
-       char *object;
-       char *adapter_path;
-       DBusConnection *conn;
-       DBusGConnection *gconn;
+       gchar *adapter_path;
        gboolean shuffle_status;
+       gchar *path;
+       GDBusConnection *conn;
+       GDBusNodeInfo *node_info;
+       GDBusProxy *proxy;
+       GVariantBuilder *builder;
+       GVariant *ret;
+       GError *error = NULL;
 
        media_player_settings_t player_settings = {0,};
 
        player_settings.repeat  = REPEAT_MODE_OFF;
-
-       player_settings.shuffle = SHUFFLE_MODE_OFF;
        player_settings.status = STATUS_STOPPED;
        player_settings.position = 0;
+       shuffle_status = FALSE;
 
-
-       gconn = _bt_get_system_gconn();
-       retv_if(gconn  == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       conn = _bt_get_system_conn();
+       conn = _bt_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-       g_bt_dbus_conn = conn;
+       bt_gdbus_conn = conn;
+
+       node_info = __bt_avrcp_create_method_node_info(
+                               bt_avrcp_bluez_introspection_xml);
+       if (node_info == NULL)
+               return BLUETOOTH_ERROR_INTERNAL;
 
+       avrcp_reg_id = g_dbus_connection_register_object(bt_gdbus_conn,
+                                       BT_MEDIA_OBJECT_PATH,
+                                       node_info->interfaces[0],
+                                       &method_table,
+                                       NULL, NULL, &error);
+       g_dbus_node_info_unref(node_info);
 
-       if (!bt_dbus_register_object_path(conn, BT_MEDIA_OBJECT_PATH)){
-               BT_DBG("Could not register interface %s",
-                               BT_MEDIA_PLAYER_INTERFACE);
+       if (avrcp_reg_id == 0) {
+               BT_ERR("Failed to register: %s", error->message);
+               g_clear_error(&error);
+               return BLUETOOTH_ERROR_INTERNAL;
        }
 
        adapter_path = _bt_get_adapter_path();
        retv_if(adapter_path == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       msg = dbus_message_new_method_call(BT_BLUEZ_NAME, adapter_path,
-                               BT_MEDIA_INTERFACE, "RegisterPlayer");
-
+       proxy =  g_dbus_proxy_new_sync(conn,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       BT_BLUEZ_NAME, adapter_path,
+                       BT_MEDIA_INTERFACE, NULL, &error);
        g_free(adapter_path);
 
-       retv_if(msg == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       object = g_strdup(BT_MEDIA_OBJECT_PATH);
-
-       dbus_message_iter_init_append(msg, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &object);
-       g_free(object);
-
-       dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
-                       DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
-                       DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
-                       DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &property_dict);
-
-       __bt_media_append_dict_entry(&property_dict,
-               "LoopStatus",
-               DBUS_TYPE_STRING,
-               &loopstatus_settings[player_settings.repeat].property);
-
-       if (player_settings.shuffle == SHUFFLE_MODE_OFF)
-               shuffle_status = FALSE;
-       else
-               shuffle_status = TRUE;
-
-       __bt_media_append_dict_entry(&property_dict,
-               "Shuffle",
-               DBUS_TYPE_BOOLEAN,
-               &shuffle_status);
+       if (proxy == NULL) {
+               BT_ERR("Unable to create proxy");
+               if (error) {
+                       BT_ERR("Error: %s", error->message);
+                       g_clear_error(&error);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
 
-       __bt_media_append_dict_entry(&property_dict,
-               "PlaybackStatus",
-               DBUS_TYPE_STRING,
-               &player_status[player_settings.status].property);
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
 
+       g_variant_builder_add(builder, "{sv}", "LoopStatus",
+                       g_variant_new("s",
+                       loopstatus_settings[player_settings.repeat].property));
+       BT_ERR("LoopStatus: %s", loopstatus_settings[player_settings.repeat].property);
 
-       __bt_media_append_dict_entry(&property_dict,
-               "Position",
-               DBUS_TYPE_UINT32, &player_settings.position);
+       g_variant_builder_add(builder, "{sv}", "Shuffle",
+                       g_variant_new("b", shuffle_status));
 
-       dbus_message_iter_close_container(&iter, &property_dict);
+       g_variant_builder_add(builder, "{sv}", "PlaybackStatus",
+                       g_variant_new("s",
+                       player_status[player_settings.status].property));
+       BT_ERR("PlaybackStatus: %s", player_status[player_settings.status].property);
 
-       dbus_error_init(&err);
-       reply = dbus_connection_send_with_reply_and_block(conn,
-                               msg, -1, &err);
-       dbus_message_unref(msg);
+       g_variant_builder_add(builder, "{sv}", "Position",
+                       g_variant_new("u", player_settings.position));
 
-       if (!reply) {
-               BT_ERR("Error in registering the Music Player \n");
+       path = g_strdup(BT_MEDIA_OBJECT_PATH);
+       ret = g_dbus_proxy_call_sync(proxy, "RegisterPlayer",
+                       g_variant_new("(oa{sv})", path, builder),
+                       G_DBUS_CALL_FLAGS_NONE, -1,
+                       NULL, &error);
 
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("%s", err.message);
-                       dbus_error_free(&err);
-                       return BLUETOOTH_ERROR_INTERNAL;
+       g_object_unref(proxy);
+       g_free(path);
+       g_variant_builder_unref(builder);
+
+       if (ret == NULL) {
+               BT_ERR("Call RegisterPlayer Failed");
+               if (error) {
+                       BT_ERR("errCode[%x], message[%s]",
+                                       error->code, error->message);
+                       g_clear_error(&error);
                }
+               return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       if (reply)
-               dbus_message_unref(reply);
-
-       BT_DBG("-");
+       g_variant_unref(ret);
        return BLUETOOTH_ERROR_NONE;
 }
 
-int _bt_unregister_media_player(void)
+static void __bt_avrcp_unregister_object_path(void)
 {
-       BT_DBG("+");
-       DBusMessage *msg;
-       DBusMessage *reply;
-       DBusError err;
-       char *object;
-       char *adapter_path;
-       DBusConnection *conn;
-
-       conn = g_bt_dbus_conn;
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       adapter_path = _bt_get_adapter_path();
-       retv_if(adapter_path == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       msg = dbus_message_new_method_call(BT_BLUEZ_NAME, adapter_path,
-                               BT_MEDIA_INTERFACE, "UnregisterPlayer");
-
-
-       g_free(adapter_path);
-
-       retv_if(msg == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       object = g_strdup(BT_MEDIA_OBJECT_PATH);
-
-       dbus_message_append_args(msg,
-                               DBUS_TYPE_OBJECT_PATH, &object,
-                               DBUS_TYPE_INVALID);
-
-       g_free(object);
-
-       dbus_error_init(&err);
-       reply = dbus_connection_send_with_reply_and_block(conn,
-                               msg, -1, &err);
-       dbus_message_unref(msg);
-
-       if (!reply) {
-               BT_ERR("Error in unregistering the Music Player \n");
-
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("%s", err.message);
-                       dbus_error_free(&err);
-                       return BLUETOOTH_ERROR_INTERNAL;
-               }
-       } else {
-               dbus_message_unref(reply);
+       if (avrcp_reg_id > 0) {
+               g_dbus_connection_unregister_object(bt_gdbus_conn,
+                                                       avrcp_reg_id);
+               avrcp_reg_id = 0;
        }
-
-       bt_dbus_unregister_object_path(conn, BT_MEDIA_OBJECT_PATH);
-       g_bt_dbus_conn = NULL;
-
-       BT_DBG("-");
-       return BLUETOOTH_ERROR_NONE;
 }
 
-static void __bt_media_append_metadata_entry(DBusMessageIter *metadata,
-                       void *key_type, void *value, int type)
+int _bt_unregister_media_player(void)
 {
        BT_DBG("+");
-       DBusMessageIter string_entry;
-
-       dbus_message_iter_open_container(metadata,
-                               DBUS_TYPE_DICT_ENTRY,
-                               NULL, &string_entry);
-
-       dbus_message_iter_append_basic(&string_entry, DBUS_TYPE_STRING, key_type);
-
-       __bt_media_append_variant(&string_entry, type, value);
+       GDBusProxy *proxy;
+       GVariant *ret;
+       GError *error = NULL;
+       GDBusConnection *conn;
+       gchar *path;
 
-       dbus_message_iter_close_container(metadata, &string_entry);
-       BT_DBG("-");
-}
+       conn = bt_gdbus_conn;
+       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-static void __bt_media_append_metadata_array(DBusMessageIter *metadata,
-                       void *key_type, void *value, int type)
-{
-       BT_DBG("+");
-       DBusMessageIter string_entry, variant, array;
-       char array_sig[3] = { type, DBUS_TYPE_STRING, '\0' };
+       proxy = __bt_avrcp_gdbus_get_service_proxy();
+       if (proxy == NULL)
+               return BLUETOOTH_ERROR_INTERNAL;
 
-       dbus_message_iter_open_container(metadata,
-                               DBUS_TYPE_DICT_ENTRY,
-                               NULL, &string_entry);
-       dbus_message_iter_append_basic(&string_entry, DBUS_TYPE_STRING, key_type);
+       path = g_strdup(BT_MEDIA_OBJECT_PATH);
+       BT_DBG("path is [%s]", path);
+
+       ret = g_dbus_proxy_call_sync(proxy, "UnregisterPlayer",
+                       g_variant_new("(o)", path),
+                       G_DBUS_CALL_FLAGS_NONE, -1,
+                       NULL, &error);
+       g_free(path);
+
+       if (ret == NULL) {
+               BT_ERR("UnregisterPlayer failed");
+               if (error) {
+                       BT_ERR("D-Bus API failure: errCode[%x], message[%s]",
+                                       error->code, error->message);
+                       g_clear_error(&error);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
 
-       dbus_message_iter_open_container(&string_entry, DBUS_TYPE_VARIANT,
-                       array_sig, &variant);
+       __bt_avrcp_unregister_object_path();
 
-       dbus_message_iter_open_container(&variant, type,
-                               DBUS_TYPE_STRING_AS_STRING, &array);
-       dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING, value);
+       g_variant_unref(ret);
+       g_object_unref(bt_gdbus_conn);
+       bt_gdbus_conn = NULL;
 
-       dbus_message_iter_close_container(&variant, &array);
-       dbus_message_iter_close_container(&string_entry, &variant);
-       dbus_message_iter_close_container(metadata, &string_entry);
        BT_DBG("-");
+       return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_avrcp_set_track_info(media_metadata_attributes_t *meta_data)
 {
        BT_DBG("+");
-       DBusMessage *sig;
-       DBusMessageIter iter;
-       DBusMessageIter property_dict, metadata_dict, metadata_variant, metadata;
-       DBusConnection *conn;
        char *interface = BT_MEDIA_PLAYER_INTERFACE;
-       char * metadata_str = "Metadata";
-       const char *key_type;
+       GDBusConnection *conn;
+       GError *error = NULL;
+       GVariantBuilder *builder = NULL;
+       GVariantBuilder *inner_builder = NULL;
+       GVariant *children[1];
+       gboolean ret;
 
        retv_if(meta_data == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       conn = g_bt_dbus_conn;
+       conn = bt_gdbus_conn;
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       sig = dbus_message_new_signal(BT_MEDIA_OBJECT_PATH, DBUS_INTERFACE_PROPERTIES,
-                               "PropertiesChanged");
-       retv_if(sig == NULL, FALSE);
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+       inner_builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
 
-       dbus_message_iter_init_append(sig, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &interface);
+       g_variant_builder_add(inner_builder, "{sv}",
+               "xesam:title", g_variant_new_string(meta_data->title));
 
-       dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
-                               DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
-                               DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
-                               DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &property_dict);
+       children[0] = g_variant_new_string(meta_data->artist);
+       g_variant_builder_add(inner_builder, "{sv}",
+               "xesam:artist", g_variant_new_array(G_VARIANT_TYPE_STRING,
+               children, 1));
 
-       dbus_message_iter_open_container(&property_dict,
-                               DBUS_TYPE_DICT_ENTRY,
-                               NULL, &metadata_dict);
+       g_variant_builder_add(inner_builder, "{sv}",
+               "xesam:album", g_variant_new_string(meta_data->album));
 
-       dbus_message_iter_append_basic(&metadata_dict, DBUS_TYPE_STRING, &metadata_str);
+       children[0] = g_variant_new_string(meta_data->genre);
+       g_variant_builder_add(inner_builder, "{sv}",
+               "xesam:genre", g_variant_new_array(G_VARIANT_TYPE_STRING,
+               children, 1));
 
-       dbus_message_iter_open_container(&metadata_dict, DBUS_TYPE_VARIANT, "a{sv}",
-                               &metadata_variant);
+       g_variant_builder_add(inner_builder, "{sv}",
+               "xesam:totalTracks", g_variant_new_int32(meta_data->total_tracks));
 
-       dbus_message_iter_open_container(&metadata_variant, DBUS_TYPE_ARRAY,
-                               DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
-                               DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
-                               DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &metadata);
+       g_variant_builder_add(inner_builder, "{sv}",
+               "xesam:trackNumber", g_variant_new_int32(meta_data->number));
 
-       if (meta_data->title) {
-               key_type = "xesam:title";
-               __bt_media_append_metadata_entry(&metadata, &key_type,
-                               &meta_data->title, DBUS_TYPE_STRING);
-       }
-
-       if (meta_data->artist) {
-               key_type = "xesam:artist";
-               __bt_media_append_metadata_array(&metadata, &key_type,
-                               &meta_data->artist, DBUS_TYPE_ARRAY);
-       }
+       g_variant_builder_add(inner_builder, "{sv}",
+               "mpris:lenght", g_variant_new_int64(meta_data->duration));
 
-       if (meta_data->album) {
-               key_type = "xesam:album";
-               __bt_media_append_metadata_entry(&metadata, &key_type,
-                               &meta_data->album, DBUS_TYPE_STRING);
-       }
+       g_variant_builder_add(builder, "{sv}",
+               "Metadata", g_variant_new("a{sv}", inner_builder));
 
-       if (meta_data->genre) {
-               key_type = "xesam:genre";
-               __bt_media_append_metadata_array(&metadata, &key_type,
-                               &meta_data->genre, DBUS_TYPE_ARRAY);
-       }
+       ret = g_dbus_connection_emit_signal(conn, NULL, BT_MEDIA_OBJECT_PATH,
+                               DBUS_INTERFACE_PROPERTIES,
+                               "PropertiesChanged",
+                               g_variant_new("(sa{sv})",
+                               interface, builder),
+                               &error);
 
-       if (0 != meta_data->total_tracks) {
-               key_type = "xesam:totalTracks";
-               __bt_media_append_metadata_entry(&metadata, &key_type,
-                               &meta_data->total_tracks, DBUS_TYPE_INT32);
-       }
+       g_variant_builder_unref(inner_builder);
+       g_variant_builder_unref(builder);
 
-       if (0 != meta_data->number) {
-               key_type = "xesam:trackNumber";
-               __bt_media_append_metadata_entry(&metadata, &key_type,
-                               &meta_data->number, DBUS_TYPE_INT32);
-       }
-
-       if (0 != meta_data->duration) {
-               key_type = "mpris:length";
-               __bt_media_append_metadata_entry(&metadata, &key_type,
-                               &meta_data->duration, DBUS_TYPE_INT64);
+       if (!ret) {
+               if (error != NULL) {
+                       BT_ERR("D-Bus API failure: errCode[%x], message[%s]",
+                               error->code, error->message);
+                       g_clear_error(&error);
+               }
        }
 
-       dbus_message_iter_close_container(&metadata_variant, &metadata);
-       dbus_message_iter_close_container(&metadata_dict, &metadata_variant);
-       dbus_message_iter_close_container(&property_dict, &metadata_dict);
-       dbus_message_iter_close_container(&iter, &property_dict);
-
-       if (!dbus_connection_send(conn, sig, NULL))
-               BT_ERR("Unable to send TrackChanged signal\n");
-
-       dbus_message_unref(sig);
        BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
 
-
 int _bt_avrcp_set_interal_property(int type, media_player_settings_t *properties)
 {
        BT_DBG("+");
-       DBusConnection *conn;
+       GDBusConnection *conn;
        int value;
        media_metadata_attributes_t meta_data;
-       dbus_bool_t shuffle;
+       gboolean shuffle;
+       GVariantBuilder *builder = NULL;
+       GVariant *children[1];
 
-       conn = g_bt_dbus_conn;
+       conn = bt_gdbus_conn;
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        switch (type) {
        case REPEAT:
                value = properties->repeat;
-               if (!__bt_media_emit_property_changed(
-                       conn,
-                       BT_MEDIA_OBJECT_PATH,
-                       BT_MEDIA_PLAYER_INTERFACE,
-                       "LoopStatus",
-                       DBUS_TYPE_STRING,
-                       &loopstatus_settings[value].property)) {
+               if (!__bt_media_emit_property_changed(conn, BT_MEDIA_OBJECT_PATH,
+                               BT_MEDIA_PLAYER_INTERFACE, "LoopStatus",
+                               g_variant_new_string(loopstatus_settings[value].property))) {
                        BT_ERR("Error sending the PropertyChanged signal \n");
                        return BLUETOOTH_ERROR_INTERNAL;
                }
@@ -708,62 +542,75 @@ int _bt_avrcp_set_interal_property(int type, media_player_settings_t *properties
        case SHUFFLE:
                value = properties->shuffle;
                if (g_strcmp0(shuffle_settings[value].property, "off") == 0)
-                       shuffle = 0;
+                       shuffle = FALSE;
                else
-                       shuffle = 1;
-
-               if (!__bt_media_emit_property_changed(
-                       conn,
-                       BT_MEDIA_OBJECT_PATH,
-                       BT_MEDIA_PLAYER_INTERFACE,
-                       "Shuffle",
-                       DBUS_TYPE_BOOLEAN,
-                       &shuffle)) {
-                       BT_DBG("Error sending the PropertyChanged signal \n");
+                       shuffle = TRUE;
+
+               if (!__bt_media_emit_property_changed(conn, BT_MEDIA_OBJECT_PATH,
+                               BT_MEDIA_PLAYER_INTERFACE, "Shuffle",
+                               g_variant_new_boolean(shuffle))) {
+                       BT_ERR("Error sending the PropertyChanged signal \n");
                        return BLUETOOTH_ERROR_INTERNAL;
                }
                break;
        case STATUS:
                value = properties->status;
-               if (!__bt_media_emit_property_changed(
-                       conn,
-                       BT_MEDIA_OBJECT_PATH,
-                       BT_MEDIA_PLAYER_INTERFACE,
-                       "PlaybackStatus",
-                       DBUS_TYPE_STRING,
-                       &player_status[value].property)) {
-                       BT_DBG("Error sending the PropertyChanged signal \n");
+               if (!__bt_media_emit_property_changed(conn, BT_MEDIA_OBJECT_PATH,
+                               BT_MEDIA_PLAYER_INTERFACE, "PlaybackStatus",
+                               g_variant_new_string(player_status[value].property))) {
+                       BT_ERR("Error sending the PropertyChanged signal \n");
                        return BLUETOOTH_ERROR_INTERNAL;
                }
                break;
        case POSITION:
                value = properties->position;
-               if (!__bt_media_emit_property_changed(
-                       conn,
-                       BT_MEDIA_OBJECT_PATH,
-                       BT_MEDIA_PLAYER_INTERFACE,
-                       "Position",
-                       DBUS_TYPE_UINT32,
-                       &value)) {
-                       BT_DBG("Error sending the PropertyChanged signal \n");
+               if (!__bt_media_emit_property_changed(conn, BT_MEDIA_OBJECT_PATH,
+                               BT_MEDIA_PLAYER_INTERFACE, "Position",
+                               g_variant_new_uint32(value))) {
+                       BT_ERR("Error sending the PropertyChanged signal \n");
                        return BLUETOOTH_ERROR_INTERNAL;
                }
                break;
        case METADATA:
                meta_data = properties->metadata;
-               if (!__bt_media_emit_property_changed(
-                       conn,
-                       BT_MEDIA_OBJECT_PATH,
-                       BT_MEDIA_PLAYER_INTERFACE,
-                       "Metadata",
-                       DBUS_TYPE_ARRAY,
-                       &meta_data)) {
-                       BT_DBG("Error sending the PropertyChanged signal \n");
+
+               builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+               g_variant_builder_add(builder, "{sv}",
+                               "xesam:title", g_variant_new_string(meta_data.title));
+
+               children[0] = g_variant_new_string(meta_data.artist);
+               g_variant_builder_add(builder, "{sv}",
+                               "xesam:artist", g_variant_new_array(G_VARIANT_TYPE_STRING,
+                                               children, 1));
+
+               g_variant_builder_add(builder, "{sv}",
+                               "xesam:album", g_variant_new_string(meta_data.album));
+
+               children[0] = g_variant_new_string(meta_data.genre);
+               g_variant_builder_add(builder, "{sv}",
+                               "xesam:genre", g_variant_new_array(G_VARIANT_TYPE_STRING,
+                                               children, 1));
+
+               g_variant_builder_add(builder, "{sv}",
+                               "xesam:totalTracks", g_variant_new_int32(meta_data.total_tracks));
+
+               g_variant_builder_add(builder, "{sv}",
+                               "xesam:trackNumber", g_variant_new_int32(meta_data.number));
+
+               g_variant_builder_add(builder, "{sv}",
+                               "mpris:lenght", g_variant_new_int64(meta_data.duration));
+
+               if (!__bt_media_emit_property_changed(conn, BT_MEDIA_OBJECT_PATH,
+                               BT_MEDIA_PLAYER_INTERFACE, "Metadata",
+                               g_variant_new("a{sv}", builder))) {
+                       BT_ERR("Error sending the PropertyChanged signal \n");
+                       g_variant_builder_unref(builder);
                        return BLUETOOTH_ERROR_INTERNAL;
                }
+               g_variant_builder_unref(builder);
                break;
        default:
-               BT_DBG("Invalid Type\n");
+               BT_ERR("Invalid Type\n");
                return BLUETOOTH_ERROR_INTERNAL;
        }
        BT_DBG("-");
@@ -832,564 +679,3 @@ int _bt_avrcp_set_property(int type, unsigned int value)
 
        return BLUETOOTH_ERROR_NONE;
 }
-
-int _bt_avrcp_control_cmd(int type)
-{
-       int ret = BLUETOOTH_ERROR_INTERNAL;
-       BT_DBG("+");
-
-       switch (type) {
-       case PLAY:
-               ret = __bt_media_send_control_msg("Play");
-               break;
-       case PAUSE:
-               ret = __bt_media_send_control_msg("Pause");
-               break;
-       case STOP:
-               ret = __bt_media_send_control_msg("Stop");
-               break;
-       case NEXT:
-               ret = __bt_media_send_control_msg("Next");
-               break;
-       case PREVIOUS:
-               ret = __bt_media_send_control_msg("Previous");
-               break;
-       case FAST_FORWARD:
-               ret = __bt_media_send_control_msg("FastForward");
-               break;
-       case REWIND:
-               ret = __bt_media_send_control_msg("Rewind");
-               break;
-       default:
-               BT_DBG("Invalid Type\n");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-       BT_DBG("-");
-       return ret;
-}
-
-DBusGProxy *__bt_get_control_properties_proxy(void)
-{
-       DBusGProxy *proxy;
-       char *control_path;
-       DBusGConnection *conn;
-
-       control_path = __bt_get_control_device_path();
-       retv_if(control_path == NULL, NULL);
-       BT_DBG("control_path = %s", control_path);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, NULL);
-
-       proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               control_path, BT_PROPERTIES_INTERFACE);
-       return proxy;
-}
-
-static int __bt_media_attr_to_event(const char *str)
-{
-       if (!strcasecmp(str, "Equalizer"))
-               return BLUETOOTH_EVENT_AVRCP_CONTROL_EQUALIZER_STATUS;
-       else if (!strcasecmp(str, "Repeat"))
-               return BLUETOOTH_EVENT_AVRCP_CONTROL_REPEAT_STATUS;
-       else if (!strcasecmp(str, "Shuffle"))
-               return BLUETOOTH_EVENT_AVRCP_CONTROL_SHUFFLE_STATUS;
-       else if (!strcasecmp(str, "Scan"))
-               return BLUETOOTH_EVENT_AVRCP_CONTROL_SCAN_STATUS;
-       else if (!strcasecmp(str, "Position"))
-               return BLUETOOTH_EVENT_AVRCP_SONG_POSITION_STATUS;
-       else if (!strcasecmp(str, "Track"))
-               return BLUETOOTH_EVENT_AVRCP_TRACK_CHANGED;
-       else if (!strcasecmp(str, "Status"))
-               return BLUETOOTH_EVENT_AVRCP_PLAY_STATUS_CHANGED;
-
-       return 0;
-}
-
-static int __bt_media_attr_to_type(const char *str)
-{
-       if (!strcasecmp(str, "Equalizer"))
-               return EQUALIZER;
-       else if (!strcasecmp(str, "Repeat"))
-               return REPEAT;
-       else if (!strcasecmp(str, "Shuffle"))
-               return SHUFFLE;
-       else if (!strcasecmp(str, "Scan"))
-               return SCAN;
-       else if (!strcasecmp(str, "Position"))
-               return POSITION;
-       else if (!strcasecmp(str, "Track"))
-               return METADATA;
-       else if (!strcasecmp(str, "Status"))
-               return STATUS;
-
-       return 0;
-}
-
-static const char *__bt_media_type_to_str(int type)
-{
-       switch (type) {
-       case EQUALIZER:
-               return "Equalizer";
-       case REPEAT:
-               return "Repeat";
-       case SHUFFLE:
-               return "Shuffle";
-       case SCAN:
-               return "Scan";
-       case POSITION:
-               return "Position";
-       case METADATA:
-               return "Track";
-       case STATUS:
-               return "Status";
-       }
-       return NULL;
-}
-
-static int __bt_media_attrval_to_val(int type, const char *value)
-{
-       int ret = 0;
-
-       switch (type) {
-       case EQUALIZER:
-               if (!strcmp(value, "off"))
-                       ret = EQUALIZER_OFF;
-               else if (!strcmp(value, "on"))
-                       ret = EQUALIZER_ON;
-               else
-                       ret = EQUALIZER_INVALID;
-               break;
-
-       case REPEAT:
-               if (!strcmp(value, "off"))
-                       ret = REPEAT_MODE_OFF;
-               else if (!strcmp(value, "singletrack"))
-                       ret = REPEAT_SINGLE_TRACK;
-               else if (!strcmp(value, "alltracks"))
-                       ret = REPEAT_ALL_TRACK;
-               else if (!strcmp(value, "group"))
-                       ret = REPEAT_GROUP;
-               else
-                       ret = REPEAT_INVALID;
-               break;
-
-       case SHUFFLE:
-               if (!strcmp(value, "off"))
-                       ret = SHUFFLE_MODE_OFF;
-               else if (!strcmp(value, "alltracks"))
-                       ret = SHUFFLE_ALL_TRACK;
-               else if (!strcmp(value, "group"))
-                       ret = SHUFFLE_GROUP;
-               else
-                       ret = SHUFFLE_INVALID;
-               break;
-
-       case SCAN:
-               if (!strcmp(value, "off"))
-                       ret = SCAN_MODE_OFF;
-               else if (!strcmp(value, "alltracks"))
-                       ret = SCAN_ALL_TRACK;
-               else if (!strcmp(value, "group"))
-                       ret = SCAN_GROUP;
-               else
-                       ret = SCAN_INVALID;
-               break;
-
-       case STATUS:
-               if (!strcmp(value, "stopped"))
-                       ret = STATUS_STOPPED;
-               else if (!strcmp(value, "playing"))
-                       ret = STATUS_PLAYING;
-               else if (!strcmp(value, "paused"))
-                       ret = STATUS_PAUSED;
-               else if (!strcmp(value, "forward-seek"))
-                       ret = STATUS_FORWARD_SEEK;
-               else if (!strcmp(value, "reverse-seek"))
-                       ret = STATUS_REVERSE_SEEK;
-               else if (!strcmp(value, "error"))
-                       ret = STATUS_ERROR;
-               else
-                       ret = STATUS_INVALID;
-       }
-       return ret;
-}
-
-int _bt_avrcp_control_get_property(int type, unsigned int *value)
-{
-       DBusGProxy *proxy;
-       char *name = NULL;
-       int ret = BLUETOOTH_ERROR_NONE;
-       GError *err = NULL;
-       GValue attr_value = { 0 };
-
-       BT_CHECK_PARAMETER(value, return);
-
-       proxy = __bt_get_control_properties_proxy();
-       retv_if(proxy == NULL, BLUETOOTH_ERROR_NOT_CONNECTED);
-
-       if (!dbus_g_proxy_call(proxy, "Get", &err,
-                       G_TYPE_STRING, BT_PLAYER_CONTROL_INTERFACE,
-                       G_TYPE_STRING, __bt_media_type_to_str(type),
-                       G_TYPE_INVALID,
-                       G_TYPE_VALUE, &attr_value,
-                       G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("Getting property failed: [%s]\n", err->message);
-                       g_error_free(err);
-               }
-               g_object_unref(proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-       g_object_unref(proxy);
-
-       switch (type) {
-       case EQUALIZER:
-       case REPEAT:
-       case SHUFFLE:
-       case SCAN:
-       case STATUS:
-               name = (char *)g_value_get_string(&attr_value);
-               *value = __bt_media_attrval_to_val(type, name);
-               BT_DBG("Type[%s] and Value[%s]", __bt_media_type_to_str(type), name);
-               break;
-       case POSITION:
-               *value = g_value_get_uint(&attr_value);
-               break;
-       default:
-               BT_DBG("Invalid Type\n");
-               ret =  BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       return ret;
-}
-
-int _bt_avrcp_control_set_property(int type, unsigned int value)
-{
-       GValue attr_value = { 0 };
-       DBusGProxy *proxy;
-       GError *error = NULL;
-
-       proxy = __bt_get_control_properties_proxy();
-
-       retv_if(proxy == NULL, BLUETOOTH_ERROR_NOT_CONNECTED);
-       g_value_init(&attr_value, G_TYPE_STRING);
-
-       switch (type) {
-       case EQUALIZER:
-               g_value_set_string(&attr_value, equalizer_status[value].property);
-               BT_DBG("equalizer_status %s", equalizer_status[value].property);
-               break;
-       case REPEAT:
-               g_value_set_string(&attr_value, repeat_status[value].property);
-               BT_DBG("repeat_status %s", repeat_status[value].property);
-               break;
-       case SHUFFLE:
-               g_value_set_string(&attr_value, shuffle_settings[value].property);
-               BT_DBG("shuffle_settings %s", shuffle_settings[value].property);
-               break;
-       case SCAN:
-               g_value_set_string(&attr_value, scan_status[value].property);
-               BT_DBG("scan_status %s", scan_status[value].property);
-               break;
-       default:
-               BT_ERR("Invalid property type: %d", type);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_g_proxy_call(proxy, "Set", &error,
-                       G_TYPE_STRING, BT_PLAYER_CONTROL_INTERFACE,
-                       G_TYPE_STRING, __bt_media_type_to_str(type),
-                       G_TYPE_VALUE, &attr_value,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
-
-       g_value_unset(&attr_value);
-       g_object_unref(proxy);
-
-       if (error) {
-               BT_ERR("SetProperty Fail: %s", error->message);
-               g_error_free(error);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-static gboolean __bt_avrcp_control_parse_metadata(
-                                       char **value_string,
-                                       unsigned int *value_uint,
-                                       int type,
-                                       DBusMessageIter *iter)
-{
-       if (dbus_message_iter_get_arg_type(iter) != type)
-               return FALSE;
-
-       if (type == DBUS_TYPE_STRING) {
-               char *value;
-               dbus_message_iter_get_basic(iter, &value);
-               *value_string = g_strdup(value);
-       } else if (type == DBUS_TYPE_UINT32) {
-               int value;
-               dbus_message_iter_get_basic(iter, &value);
-               *value_uint = value;
-       } else
-               return FALSE;
-
-       return TRUE;
-}
-
-
-static int __bt_avrcp_control_parse_properties(
-                               media_metadata_attributes_t *metadata,
-                               DBusMessageIter *iter)
-{
-       DBusMessageIter dict;
-       DBusMessageIter var;
-       int ctype;
-       char *value_string;
-       unsigned int value_uint;
-
-       ctype = dbus_message_iter_get_arg_type(iter);
-       if (ctype != DBUS_TYPE_ARRAY) {
-               BT_ERR("ctype error %d", ctype);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_recurse(iter, &dict);
-
-       while ((ctype = dbus_message_iter_get_arg_type(&dict)) !=
-                                                       DBUS_TYPE_INVALID) {
-               DBusMessageIter entry;
-               const char *key;
-
-               if (ctype != DBUS_TYPE_DICT_ENTRY) {
-                       BT_ERR("ctype error %d", ctype);
-                       return BLUETOOTH_ERROR_INTERNAL;
-               }
-
-               dbus_message_iter_recurse(&dict, &entry);
-               if (dbus_message_iter_get_arg_type(&entry) !=
-                                                       DBUS_TYPE_STRING) {
-                       BT_ERR("ctype not DBUS_TYPE_STRING");
-                       return BLUETOOTH_ERROR_INTERNAL;
-               }
-
-               dbus_message_iter_get_basic(&entry, &key);
-               dbus_message_iter_next(&entry);
-
-               if (dbus_message_iter_get_arg_type(&entry) !=
-                                                       DBUS_TYPE_VARIANT) {
-                       BT_ERR("ctype not DBUS_TYPE_VARIANT");
-                       return FALSE;
-               }
-
-               dbus_message_iter_recurse(&entry, &var);
-
-               BT_ERR("Key value is %s", key);
-
-               if (strcasecmp(key, "Title") == 0) {
-                       if (!__bt_avrcp_control_parse_metadata(&value_string,
-                                       &value_uint, DBUS_TYPE_STRING, &var))
-                               return BLUETOOTH_ERROR_INTERNAL;
-                       BT_DBG("Value : %s ", value_string);
-                       metadata->title = value_string;
-               } else if (strcasecmp(key, "Artist") == 0) {
-                       if (!__bt_avrcp_control_parse_metadata(&value_string,
-                                       &value_uint, DBUS_TYPE_STRING, &var))
-                               return BLUETOOTH_ERROR_INTERNAL;
-                       BT_DBG("Value : %s ", value_string);
-                       metadata->artist = value_string;
-               } else if (strcasecmp(key, "Album") == 0) {
-                       if (!__bt_avrcp_control_parse_metadata(&value_string,
-                                       &value_uint, DBUS_TYPE_STRING, &var))
-                               return BLUETOOTH_ERROR_INTERNAL;
-                       BT_DBG("Value : %s ", value_string);
-                       metadata->album = value_string;
-               } else if (strcasecmp(key, "Genre") == 0) {
-                       if (!__bt_avrcp_control_parse_metadata(&value_string,
-                                       &value_uint, DBUS_TYPE_STRING, &var))
-                               return BLUETOOTH_ERROR_INTERNAL;
-                       BT_DBG("Value : %s ", value_string);
-                       metadata->genre = value_string;
-               } else if (strcasecmp(key, "Duration") == 0) {
-                       if (!__bt_avrcp_control_parse_metadata(&value_string,
-                                       &value_uint, DBUS_TYPE_UINT32, &var))
-                               return BLUETOOTH_ERROR_INTERNAL;
-                       metadata->duration = value_uint;
-               } else if (strcasecmp(key, "NumberOfTracks") == 0) {
-                       if (!__bt_avrcp_control_parse_metadata(&value_string,
-                                       &value_uint, DBUS_TYPE_UINT32, &var))
-                               return BLUETOOTH_ERROR_INTERNAL;
-                       metadata->total_tracks = value_uint;
-               } else if (strcasecmp(key, "TrackNumber") == 0) {
-                       if (!__bt_avrcp_control_parse_metadata(&value_string,
-                                       &value_uint, DBUS_TYPE_UINT32, &var))
-                               return BLUETOOTH_ERROR_INTERNAL;
-                       metadata->number = value_uint;
-               } else
-                       BT_DBG("%s not supported, ignoring", key);
-               dbus_message_iter_next(&dict);
-       }
-
-       if (!metadata->title)
-               metadata->title = g_strdup("");
-       if (!metadata->artist)
-               metadata->artist = g_strdup("");
-       if (!metadata->album)
-               metadata->album = g_strdup("");
-       if (!metadata->genre)
-               metadata->genre = g_strdup("");
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-int _bt_avrcp_control_get_track_info(media_metadata_attributes_t *metadata)
-{
-       DBusMessage *msg;
-       DBusMessage *reply;
-       DBusError err;
-       DBusConnection *conn;
-       char *control_path;
-       char *interface_name;
-       char *property_name;
-       DBusMessageIter arr, iter;
-       int ret = BLUETOOTH_ERROR_NONE;
-
-       retv_if(metadata == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       conn = _bt_get_system_conn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       control_path = __bt_get_control_device_path();
-       retv_if(control_path == NULL, BLUETOOTH_ERROR_NOT_CONNECTED);
-       BT_DBG("control_path %s", control_path);
-
-       msg = dbus_message_new_method_call(BT_BLUEZ_NAME, control_path,
-                               BT_PROPERTIES_INTERFACE, "Get");
-
-       retv_if(msg == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       interface_name = g_strdup(BT_PLAYER_CONTROL_INTERFACE);
-       property_name = g_strdup("Track");
-
-       dbus_message_append_args(msg,
-               DBUS_TYPE_STRING, &interface_name,
-               DBUS_TYPE_STRING, &property_name,
-               DBUS_TYPE_INVALID);
-
-       dbus_error_init(&err);
-       reply = dbus_connection_send_with_reply_and_block(conn,
-                               msg, -1, &err);
-
-       g_free(interface_name);
-       g_free(property_name);
-       dbus_message_unref(msg);
-
-       if (!reply) {
-               BT_ERR("Error in getting Metadata");
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("%s", err.message);
-                       dbus_error_free(&err);
-               }
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_init(reply, &iter);
-       dbus_message_iter_recurse(&iter, &arr);
-
-       ret = __bt_avrcp_control_parse_properties(metadata, &arr);
-       dbus_message_unref(reply);
-
-       BT_DBG("-");
-       return ret;
-}
-
-void _bt_handle_avrcp_control_event(DBusMessageIter *msg_iter, const char *path)
-{
-       DBusMessageIter value_iter;
-       DBusMessageIter dict_iter;
-       DBusMessageIter item_iter;
-       const char *property = NULL;
-
-       dbus_message_iter_recurse(msg_iter, &item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_DICT_ENTRY) {
-               BT_ERR("This is bad format dbus");
-               return;
-       }
-
-       dbus_message_iter_recurse(&item_iter, &dict_iter);
-
-       dbus_message_iter_get_basic(&dict_iter, &property);
-       ret_if(property == NULL);
-
-       BT_DBG("property : %s ", property);
-       ret_if(!dbus_message_iter_next(&dict_iter));
-
-       if ((strcasecmp(property, "Equalizer") == 0) ||
-               (strcasecmp(property, "Repeat") == 0) ||
-               (strcasecmp(property, "Shuffle") == 0) ||
-               (strcasecmp(property, "Scan") == 0) ||
-               (strcasecmp(property, "Status") == 0)) {
-
-               const char *valstr;
-               int type, value;
-
-               dbus_message_iter_recurse(&dict_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &valstr);
-               BT_DBG("Value : %s ", valstr);
-               type = __bt_media_attr_to_type(property);
-               value = __bt_media_attrval_to_val(type, valstr);
-
-                               /* Send event to application */
-               _bt_send_event(BT_AVRCP_CONTROL_EVENT,
-                       __bt_media_attr_to_event(property),
-                       DBUS_TYPE_UINT32, &value,
-                       DBUS_TYPE_INVALID);
-       } else if (strcasecmp(property, "Position") == 0) {
-               unsigned int value;
-
-               dbus_message_iter_recurse(&dict_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &value);
-               BT_DBG("Value : %d ", value);
-
-                               /* Send event to application */
-               _bt_send_event(BT_AVRCP_CONTROL_EVENT,
-                       __bt_media_attr_to_event(property),
-                       DBUS_TYPE_UINT32, &value,
-                       DBUS_TYPE_INVALID);
-       } else if (strcasecmp(property, "Track") == 0) {
-               int ret = BLUETOOTH_ERROR_NONE;
-               media_metadata_attributes_t metadata;
-
-               dbus_message_iter_recurse(&dict_iter, &value_iter);
-               memset(&metadata, 0x00, sizeof(media_metadata_attributes_t));
-
-               ret = __bt_avrcp_control_parse_properties(
-                                                       &metadata, &value_iter);
-               if (BLUETOOTH_ERROR_NONE != ret)
-                       return;
-
-                               /* Send event to application */
-               _bt_send_event(BT_AVRCP_CONTROL_EVENT,
-                       BLUETOOTH_EVENT_AVRCP_TRACK_CHANGED,
-                       DBUS_TYPE_STRING, &metadata.title,
-                       DBUS_TYPE_STRING, &metadata.artist,
-                       DBUS_TYPE_STRING, &metadata.album,
-                       DBUS_TYPE_STRING, &metadata.genre,
-                       DBUS_TYPE_UINT32, &metadata.total_tracks,
-                       DBUS_TYPE_UINT32, &metadata.number,
-                       DBUS_TYPE_UINT32, &metadata.duration,
-                       DBUS_TYPE_INVALID);
-
-               g_free(metadata.title);
-               g_free(metadata.artist);
-               g_free(metadata.album);
-               g_free(metadata.genre);
-       } else {
-               BT_DBG("Preprty not handled");
-       }
-
-       BT_DBG("-");
-}
index 4005434..71e4ec2 100644 (file)
 
 #include <stdio.h>
 #include <string.h>
+#include <glib.h>
+#include <dlog.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <termios.h>
+#include <net_connection.h>
 #include <dbus/dbus-glib-lowlevel.h>
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus.h>
 #include <errno.h>
 #include <termios.h>
 #include <net_connection.h>
+#include <bundle.h>
+#include <eventsystem.h>
+
+#include <bundle.h>
+#include <eventsystem.h>
+
 
 #include "bluetooth-api.h"
 #include "bt-service-common.h"
 #include "bt-service-agent.h"
 
-static DBusGConnection *system_conn;
-static DBusGConnection *session_conn;
-static DBusGProxy *manager_proxy;
-static DBusGProxy *adapter_proxy;
+static GDBusConnection *system_conn;
+static GDBusConnection *session_conn;
+static GDBusProxy *manager_proxy;
+static GDBusProxy *adapter_proxy;
 static void *net_conn;
 
-static DBusGProxy *adapter_properties_proxy;
+static GDBusProxy *adapter_properties_proxy;
+
+static GDBusConnection *system_gconn = NULL;
+
+GDBusConnection *_bt_gdbus_init_system_gconn(void)
+{
+       GError *error = NULL;
+
+       if (!g_thread_supported()) {
+               g_thread_init(NULL);
+       }
+
+//     dbus_g_thread_init();
+
+       g_type_init();
+
+       if (system_gconn != NULL)
+               return system_gconn;
+
+       system_gconn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+
+       if (!system_gconn) {
+               BT_ERR("Unable to connect to dbus: %s", error->message);
+               g_clear_error(&error);
+       }
+
+       return system_gconn;
+}
+
+GDBusConnection *_bt_gdbus_get_system_gconn(void)
+{
+       GDBusConnection *local_system_gconn = NULL;
+       GError *error = NULL;
+
+       if (system_gconn == NULL) {
+               system_gconn = _bt_gdbus_init_system_gconn();
+       } else if (g_dbus_connection_is_closed(system_gconn)){
+
+               local_system_gconn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+
+               if (!local_system_gconn) {
+                       BT_ERR("Unable to connect to dbus: %s", error->message);
+                       g_clear_error(&error);
+               }
+
+               system_gconn = local_system_gconn;
+       }
+
+       return system_gconn;
+}
 
-static DBusGProxy *__bt_init_manager_proxy(void)
+static GDBusProxy *__bt_init_manager_proxy(void)
 {
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
 
        g_type_init();
 
        if (system_conn == NULL) {
-               system_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
+               system_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
                retv_if(system_conn == NULL, NULL);
        }
 
-       proxy = dbus_g_proxy_new_for_name(system_conn, BT_BLUEZ_NAME,
-                       BT_MANAGER_PATH, BT_MANAGER_INTERFACE);
+       proxy = g_dbus_proxy_new_sync(system_conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL, BT_BLUEZ_NAME,
+                                                               BT_MANAGER_PATH, BT_MANAGER_INTERFACE,  NULL, NULL);
 
        retv_if(proxy == NULL, NULL);
 
@@ -66,21 +128,30 @@ static DBusGProxy *__bt_init_manager_proxy(void)
        return proxy;
 }
 
-static DBusGProxy *__bt_init_adapter_proxy(void)
+static GDBusProxy *__bt_init_adapter_proxy(void)
 {
-       DBusGProxy *manager_proxy;
-       DBusGProxy *proxy;
+       GDBusProxy *manager_proxy;
+       GDBusProxy *proxy;
+       char *adapter_path = NULL;
+
+       g_type_init();
 
        if (system_conn == NULL) {
-               system_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
+               system_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
                retv_if(system_conn == NULL, NULL);
        }
 
        manager_proxy = _bt_get_manager_proxy();
        retv_if(manager_proxy == NULL, NULL);
 
-       proxy = dbus_g_proxy_new_for_name(system_conn, BT_BLUEZ_NAME,
-                               BT_BLUEZ_HCI_PATH, BT_ADAPTER_INTERFACE);
+       adapter_path = _bt_get_adapter_path();
+       retv_if(adapter_path == NULL, NULL);
+
+       proxy = g_dbus_proxy_new_sync(system_conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL, BT_BLUEZ_NAME,
+                                                               adapter_path, BT_ADAPTER_INTERFACE,  NULL, NULL);
+
+       g_free(adapter_path);
 
        retv_if(proxy == NULL, NULL);
 
@@ -89,23 +160,30 @@ static DBusGProxy *__bt_init_adapter_proxy(void)
        return proxy;
 }
 
-static DBusGProxy *__bt_init_adapter_properties_proxy(void)
+static GDBusProxy *__bt_init_adapter_properties_proxy(void)
 {
-       DBusGProxy *manager_proxy;
-       DBusGProxy *proxy;
+       GDBusProxy *manager_proxy;
+       GDBusProxy *proxy;
+       char *adapter_path = NULL;
 
        g_type_init();
 
        if (system_conn == NULL) {
-               system_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
+               system_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
                retv_if(system_conn == NULL, NULL);
        }
 
        manager_proxy = _bt_get_manager_proxy();
        retv_if(manager_proxy == NULL, NULL);
 
-       proxy = dbus_g_proxy_new_for_name(system_conn, BT_BLUEZ_NAME,
-                       BT_BLUEZ_HCI_PATH, BT_PROPERTIES_INTERFACE);
+       adapter_path = _bt_get_adapter_path();
+       retv_if(adapter_path == NULL, NULL);
+
+       proxy = g_dbus_proxy_new_sync(system_conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                                       NULL, BT_BLUEZ_NAME,
+                                                                       adapter_path, BT_PROPERTIES_INTERFACE,  NULL, NULL);
+
+       g_free(adapter_path);
 
        retv_if(proxy == NULL, NULL);
 
@@ -114,37 +192,37 @@ static DBusGProxy *__bt_init_adapter_properties_proxy(void)
        return proxy;
 }
 
-DBusGConnection *__bt_init_system_gconn(void)
+GDBusConnection *__bt_init_system_gconn(void)
 {
        g_type_init();
 
        if (system_conn == NULL)
-               system_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);
+               system_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
 
        return system_conn;
 }
 
-DBusGConnection *__bt_init_session_conn(void)
+GDBusConnection *__bt_init_session_conn(void)
 {
        if (session_conn == NULL)
-               session_conn = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
+               session_conn =g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
 
        return session_conn;
 }
 
-DBusGConnection *_bt_get_session_gconn(void)
+GDBusConnection *_bt_get_session_gconn(void)
 {
        return (session_conn) ? session_conn : __bt_init_session_conn();
 }
 
-DBusGConnection *_bt_get_system_gconn(void)
+GDBusConnection *_bt_get_system_gconn(void)
 {
        return (system_conn) ? system_conn : __bt_init_system_gconn();
 }
 
-DBusConnection *_bt_get_system_conn(void)
+GDBusConnection *_bt_get_system_conn(void)
 {
-       DBusGConnection *g_conn;
+       GDBusConnection *g_conn;
 
        if (system_conn == NULL) {
                g_conn = __bt_init_system_gconn();
@@ -154,13 +232,13 @@ DBusConnection *_bt_get_system_conn(void)
 
        retv_if(g_conn == NULL, NULL);
 
-       return dbus_g_connection_get_connection(g_conn);
+       return g_conn;
 }
 
-DBusGProxy *_bt_get_manager_proxy(void)
+GDBusProxy *_bt_get_manager_proxy(void)
 {
        if (manager_proxy) {
-               const char *path =  dbus_g_proxy_get_path(manager_proxy);
+               const gchar *path =  g_dbus_proxy_get_object_path(manager_proxy);
                if (path == NULL) {
                        BT_ERR("Already proxy released hence creating new proxy");
                        return  __bt_init_manager_proxy();
@@ -194,41 +272,10 @@ void *_bt_get_net_conn(void)
        return (net_conn) ? net_conn : __bt_init_net_conn();
 }
 
-gboolean _bt_get_adapter_power(void)
-{
-       DBusGProxy *proxy = NULL;
-       gboolean powered;
-       GValue powered_v = { 0 };
-       GError *err = NULL;
-
-       BT_DBG("_bt_check_adapter 4");
-       proxy = _bt_get_adapter_properties_proxy();
-       retv_if(proxy == NULL, FALSE);
-
-       if (!dbus_g_proxy_call(proxy, "Get", &err,
-                       G_TYPE_STRING, BT_ADAPTER_INTERFACE,
-                       G_TYPE_STRING, "Powered",
-                       G_TYPE_INVALID,
-                       G_TYPE_VALUE, &powered_v,
-                       G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("Getting property failed \n: [%s]\n", err->message);
-                       g_error_free(err);
-               }
-               return FALSE;
-       }
-
-       powered = (gboolean)g_value_get_boolean(&powered_v);
-
-       BT_DBG("powered = %d", powered);
-
-       return powered;
-}
-
-DBusGProxy *_bt_get_adapter_proxy(void)
+GDBusProxy *_bt_get_adapter_proxy(void)
 {
        if (adapter_proxy) {
-               const char *path =  dbus_g_proxy_get_path(adapter_proxy);
+               const char *path =  g_dbus_proxy_get_object_path(adapter_proxy);
                if (path == NULL) {
                        BT_ERR("Already proxy released hence creating new proxy");
                        return  __bt_init_adapter_proxy();
@@ -240,119 +287,72 @@ DBusGProxy *_bt_get_adapter_proxy(void)
 
 }
 
-DBusGProxy *_bt_get_adapter_properties_proxy(void)
+GDBusProxy *_bt_get_adapter_properties_proxy(void)
 {
        return (adapter_properties_proxy) ? adapter_properties_proxy :
                                        __bt_init_adapter_properties_proxy();
 }
 
-static char *__bt_extract_adapter_path(DBusMessageIter *msg_iter)
+static char *__bt_extract_adapter_path(GVariantIter *iter)
 {
        char *object_path = NULL;
-       DBusMessageIter value_iter;
-
-       /* Parse the signature:  oa{sa{sv}}} */
-       retv_if(dbus_message_iter_get_arg_type(msg_iter) !=
-                               DBUS_TYPE_OBJECT_PATH, NULL);
-
-       dbus_message_iter_get_basic(msg_iter, &object_path);
-       retv_if(object_path == NULL, NULL);
-
-       /* object array (oa) */
-       retv_if(dbus_message_iter_next(msg_iter) == FALSE, NULL);
-       retv_if(dbus_message_iter_get_arg_type(msg_iter) !=
-                               DBUS_TYPE_ARRAY, NULL);
-
-       dbus_message_iter_recurse(msg_iter, &value_iter);
-
-       /* string array (sa) */
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                                       DBUS_TYPE_DICT_ENTRY) {
-               char *interface_name = NULL;
-               DBusMessageIter interface_iter;
-
-               dbus_message_iter_recurse(&value_iter, &interface_iter);
-
-               retv_if(dbus_message_iter_get_arg_type(&interface_iter) !=
-                       DBUS_TYPE_STRING, NULL);
-
-               dbus_message_iter_get_basic(&interface_iter, &interface_name);
-
-               if (g_strcmp0(interface_name, "org.bluez.Adapter1") == 0) {
-                       /* Tizen don't allow the multi-adapter */
-                       BT_DBG("Found an adapter: %s", object_path);
+       GVariantIter *interface_iter;
+       GVariantIter *svc_iter;
+       char *interface_str = NULL;
+
+       /* Parse the signature: oa{sa{sv}}} */
+       while (g_variant_iter_loop(iter, "{&oa{sa{sv}}}", &object_path,
+                       &interface_iter)) {
+
+               if (object_path == NULL)
+                       continue;
+
+               while (g_variant_iter_loop(interface_iter, "{sa{sv}}",
+                               &interface_str, &svc_iter)) {
+                       if (g_strcmp0(interface_str, "org.bluez.Adapter1") != 0)
+                               continue;
+
+                       BT_DBG("Object Path: %s", object_path);
+                       g_free(interface_str);
+                       g_variant_iter_free(svc_iter);
+                       g_variant_iter_free(interface_iter);
                        return g_strdup(object_path);
                }
-
-               dbus_message_iter_next(&value_iter);
        }
-
-       BT_DBG("There is no adapter");
-
        return NULL;
 }
 
 char *_bt_get_adapter_path(void)
 {
-       DBusMessage *msg;
-       DBusMessage *reply;
-       DBusMessageIter reply_iter;
-       DBusMessageIter value_iter;
-       DBusError err;
-       DBusConnection *conn;
+       GDBusConnection *conn;
+       GDBusProxy *manager_proxy;
+       GVariant *result = NULL;
+       GVariantIter *iter = NULL;
        char *adapter_path = NULL;
 
        conn = _bt_get_system_conn();
        retv_if(conn == NULL, NULL);
 
-       msg = dbus_message_new_method_call(BT_BLUEZ_NAME, BT_MANAGER_PATH,
-                                               BT_MANAGER_INTERFACE,
-                                               "GetManagedObjects");
-
-       retv_if(msg == NULL, NULL);
-
-       /* Synchronous call */
-       dbus_error_init(&err);
-       reply = dbus_connection_send_with_reply_and_block(
-                                       conn, msg,
-                                       -1, &err);
-       dbus_message_unref(msg);
+       manager_proxy = _bt_get_manager_proxy();
+       retv_if(manager_proxy == NULL, NULL);
 
-       if (!reply) {
+       result = g_dbus_proxy_call_sync(manager_proxy, "GetManagedObjects",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               NULL);
+       if (!result) {
                BT_ERR("Can't get managed objects");
-
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("%s", err.message);
-                       dbus_error_free(&err);
-               }
-               return NULL;
-       }
-
-       if (dbus_message_iter_init(reply, &reply_iter) == FALSE) {
-               BT_ERR("Fail to iterate the reply");
-               dbus_message_unref(reply);
                return NULL;
        }
 
-       dbus_message_iter_recurse(&reply_iter, &value_iter);
-
        /* signature of GetManagedObjects:  a{oa{sa{sv}}} */
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                                               DBUS_TYPE_DICT_ENTRY) {
-               DBusMessageIter msg_iter;
-
-               dbus_message_iter_recurse(&value_iter, &msg_iter);
-
-               adapter_path = __bt_extract_adapter_path(&msg_iter);
-               if (adapter_path != NULL) {
-                       BT_DBG("Found the adapter path");
-                       break;
-               }
-
-               dbus_message_iter_next(&value_iter);
-       }
-       dbus_message_unref(reply);
+       g_variant_get(result, "(a{oa{sa{sv}}})", &iter);
 
+       adapter_path = __bt_extract_adapter_path(iter);
+       g_variant_iter_free(iter);
+       g_variant_unref(result);
        return adapter_path;
 }
 
@@ -379,12 +379,12 @@ void _bt_deinit_proxys(void)
        _bt_deinit_bluez_proxy();
 
        if (system_conn) {
-               dbus_g_connection_unref(system_conn);
+               g_object_unref(system_conn);
                system_conn = NULL;
        }
 
        if (session_conn) {
-               dbus_g_connection_unref(session_conn);
+               g_object_unref(session_conn);
                session_conn = NULL;
        }
 
@@ -484,7 +484,7 @@ void _bt_free_device_info(bt_remote_dev_info_t *dev_info)
        g_free(dev_info->manufacturer_data);
 
        if (dev_info->uuids) {
-               for (i = 0; dev_info->uuids[i] != NULL; i++)
+               for (i = 0; i < dev_info->uuid_count && dev_info->uuids[i]; i++)
                        g_free(dev_info->uuids[i]);
 
                g_free(dev_info->uuids);
@@ -553,6 +553,7 @@ gboolean _bt_utf8_validate(char *name)
 
 int _bt_register_osp_server_in_agent(int type, char *uuid, char *path, int fd)
 {
+       BT_DBG("+");
        if (!_bt_agent_register_osp_server( type, uuid, path, fd))
                return BLUETOOTH_ERROR_INTERNAL;
 
@@ -561,6 +562,7 @@ int _bt_register_osp_server_in_agent(int type, char *uuid, char *path, int fd)
 
 int _bt_unregister_osp_server_in_agent(int type, char *uuid)
 {
+       BT_DBG("+");
        if (!_bt_agent_unregister_osp_server( type, uuid))
                return BLUETOOTH_ERROR_INTERNAL;
 
@@ -610,88 +612,53 @@ int _bt_set_non_blocking_tty(int sk)
        return BLUETOOTH_ERROR_NONE;
 }
 
-static char *__bt_extract_device_path(DBusMessageIter *msg_iter, char *address)
+static char *__bt_extract_device_path(GVariantIter *iter, char *address)
 {
        char *object_path = NULL;
        char device_address[BT_ADDRESS_STRING_SIZE] = { 0 };
 
-       /* Parse the signature:  oa{sa{sv}}} */
-       retv_if(dbus_message_iter_get_arg_type(msg_iter) !=
-                               DBUS_TYPE_OBJECT_PATH, NULL);
-
-       dbus_message_iter_get_basic(msg_iter, &object_path);
-       retv_if(object_path == NULL, NULL);
-
-       _bt_convert_device_path_to_address(object_path, device_address);
-
-       if (g_strcmp0(address, device_address) == 0) {
-               return g_strdup(object_path);
+       /* Parse the signature: oa{sa{sv}}} */
+       while (g_variant_iter_loop(iter, "{&oa{sa{sv}}}", &object_path,
+                       NULL)) {
+               retv_if(object_path == NULL, NULL);
+               _bt_convert_device_path_to_address(object_path, device_address);
+               if (g_strcmp0(address, device_address) == 0) {
+                       return g_strdup(object_path);
+               }
        }
-
        return NULL;
 }
 
 char *_bt_get_device_object_path(char *address)
 {
-       DBusMessage *msg;
-       DBusMessage *reply;
-       DBusMessageIter reply_iter;
-       DBusMessageIter value_iter;
-       DBusError err;
-       DBusConnection *conn;
        char *object_path = NULL;
+       GDBusConnection *conn;
+       GDBusProxy *manager_proxy;
+       GVariant *result = NULL;
+       GVariantIter *iter = NULL;
 
        conn = _bt_get_system_conn();
        retv_if(conn == NULL, NULL);
 
-       msg = dbus_message_new_method_call(BT_BLUEZ_NAME, BT_MANAGER_PATH,
-                                               BT_MANAGER_INTERFACE,
-                                               "GetManagedObjects");
-
-       retv_if(msg == NULL, NULL);
-
-       /* Synchronous call */
-       dbus_error_init(&err);
-       reply = dbus_connection_send_with_reply_and_block(
-                                       conn, msg,
-                                       -1, &err);
-       dbus_message_unref(msg);
+       manager_proxy = _bt_get_manager_proxy();
+       retv_if(manager_proxy == NULL, NULL);
 
-       if (!reply) {
+       result = g_dbus_proxy_call_sync(manager_proxy, "GetManagedObjects",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               NULL);
+       if (!result) {
                BT_ERR("Can't get managed objects");
-
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("%s", err.message);
-                       dbus_error_free(&err);
-               }
-               return NULL;
-       }
-
-       if (dbus_message_iter_init(reply, &reply_iter) == FALSE) {
-               BT_ERR("Fail to iterate the reply");
-               dbus_message_unref(reply);
                return NULL;
        }
 
-       dbus_message_iter_recurse(&reply_iter, &value_iter);
-
        /* signature of GetManagedObjects:  a{oa{sa{sv}}} */
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                                               DBUS_TYPE_DICT_ENTRY) {
-               DBusMessageIter msg_iter;
-
-               dbus_message_iter_recurse(&value_iter, &msg_iter);
-
-               object_path = __bt_extract_device_path(&msg_iter, address);
-               if (object_path != NULL) {
-                       BT_DBG("Found the device path");
-                       break;
-               }
-
-               dbus_message_iter_next(&value_iter);
-       }
-       dbus_message_unref(reply);
-
+       g_variant_get(result, "(a{oa{sa{sv}}})", &iter);
+       object_path = __bt_extract_device_path(iter, address);
+       g_variant_iter_free(iter);
+       g_variant_unref(result);
        return object_path;
 }
 
@@ -702,6 +669,8 @@ char *_bt_get_profile_uuid128(bt_profile_type_t profile_type)
                return strdup(RFCOMM_UUID_STR);
        case BT_PROFILE_CONN_A2DP:
                return strdup(A2DP_SINK_UUID);
+       case BT_PROFILE_CONN_A2DP_SINK:
+               return strdup(A2DP_SOURCE_UUID);
        case BT_PROFILE_CONN_HSP:
                return strdup(HFP_HS_UUID);
        case BT_PROFILE_CONN_HID:
@@ -836,3 +805,64 @@ void _bt_logging_connection(gboolean connect, int addr_type)
                        le_conn, le_disc, edr_conn, edr_disc);
 }
 
+int _bt_eventsystem_set_value(const char *event, const char *key, const char *value)
+{
+       int ret;
+       bundle *b = NULL;
+
+       b = bundle_create();
+
+       bundle_add_str(b, key, value);
+
+       ret = eventsystem_request_sending_system_event(event, b);
+
+       BT_DBG("request_sending_system_event result: %d", ret);
+
+       bundle_free(b);
+
+       return ret;
+}
+
+void _bt_swap_byte_ordering(char *data, int data_len)
+{
+       char temp;
+       int i, j;
+
+       ret_if(data == NULL);
+       /* Swap to opposite endian */
+       for (i = 0, j = data_len - 1; i < data_len; i++, j--) {
+               temp = data[i];
+               data[i] = data[j];
+               data[j] = temp;
+               }
+}
+
+int _bt_byte_arr_cmp(const char *data1, const char *data2, int data_len)
+{
+       int i;
+
+       retv_if(data1 == NULL, -1);
+       retv_if(data2 == NULL, -1);
+       for (i = 0; i < data_len; i++) {
+               if (data1[i] != data2[i])
+                       return data1[i] - data2[i];
+               }
+       return 0;
+}
+int _bt_byte_arr_cmp_with_mask(const char *data1, const char *data2,
+       const char *mask, int data_len)
+{
+       int i;
+       char a, b;
+
+       retv_if(data1 == NULL, -1);
+       retv_if(data2 == NULL, -1);
+       retv_if(mask == NULL, -1);
+       for (i = 0; i < data_len; i++) {
+               a = data1[i] & mask[i];
+               b = data2[i] & mask[i];
+               if (a != b)
+                       return (int)(a - b);
+               }
+       return 0;
+}
index 94cd20a..f292b21 100644 (file)
  *
  */
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
 #include <glib.h>
+#include <gio/gio.h>
 #include <dlog.h>
 #include <string.h>
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
 #include <syspopup_caller.h>
-#endif
 
 #include "bluetooth-api.h"
 #include "bt-internal-types.h"
@@ -50,6 +47,7 @@
 #define BT_LE_CONN_INTERVAL_MAX 4000 /* msec */
 #define BT_LE_CONN_SUPER_TO_MIN 100 /* msec */
 #define BT_LE_CONN_SUPER_TO_MAX 32000 /* msec */
+#define BT_LE_CONN_SLAVE_LATENCY_MAX 499
 #define BT_LE_CONN_INTERVAL_SPLIT 1.25 /* msec */
 #define BT_LE_CONN_TO_SPLIT 10 /* msec */
 
@@ -58,8 +56,8 @@ typedef struct {
        int result;
        char *addr;
        gboolean is_autopair;
-       DBusGProxy *device_proxy;
-       DBusGProxy *adapter_proxy;
+       GDBusProxy *device_proxy;
+       GDBusProxy *adapter_proxy;
        void *agent;
        unsigned short conn_type;
 } bt_funcion_data_t;
@@ -71,19 +69,21 @@ bt_funcion_data_t *searching_info;
 /* This HID Mouse does not support pairing precedure. need to skip it. */
 #define SMB_MOUSE_LAP_ADDR "00:12:A1"
 
-static void __bt_bond_device_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                                                    gpointer user_data);
+static void __bt_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res,
+                                       gpointer user_data);
 
 static int __bt_retry_bond(void);
 
 
-static void __bt_decline_pair_request()
+/*static void __bt_decline_pair_request()
 {
-       GArray *out_param1;
-       GArray *out_param2;
+       GVariant *out_param1;
+       GVariant *out_param2;
        request_info_t *req_info;
        bluetooth_device_info_t dev_info;
        bt_remote_dev_info_t *remote_dev_info;
+       GVariant *uuid_list, *manufacture_data;
+       GVariant *param;
 
        BT_DBG("+");
        if (bonding_info) {
@@ -99,26 +99,33 @@ static void __bt_decline_pair_request()
                return;
        }
 
+       uuid_list =  g_variant_new_from_data((const GVariantType *)"as",
+                                               remote_dev_info->uuids, remote_dev_info->uuid_count,
+                                               TRUE, NULL, NULL);
 
+       manufacture_data = g_variant_new_from_data((const GVariantType *)"ay",
+                                               remote_dev_info->manufacturer_data, remote_dev_info->manufacturer_data_len,
+                                               TRUE, NULL, NULL);
 
-       /* Send the event to application */
+       param = g_variant_new("isunsbuba{s}na{y})",
+                       bonding_info->result,
+                       bonding_info->addr,
+                       remote_dev_info->class,
+                       remote_dev_info->rssi,
+                       remote_dev_info->name,
+                       remote_dev_info->paired,
+                       remote_dev_info->connected,
+                       remote_dev_info->trust,
+                       uuid_list,
+                       remote_dev_info->manufacturer_data_len,
+                       manufacture_data);
+
+
+       //Send the event to application
        if (remote_dev_info != NULL) {
                _bt_send_event(BT_ADAPTER_EVENT,
                        BLUETOOTH_EVENT_BONDING_FINISHED,
-                       DBUS_TYPE_INT32, &bonding_info->result,
-                       DBUS_TYPE_STRING, &bonding_info->addr,
-                       DBUS_TYPE_UINT32, &remote_dev_info->class,
-                       DBUS_TYPE_INT16, &remote_dev_info->rssi,
-                       DBUS_TYPE_STRING, &remote_dev_info->name,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->paired,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->connected,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->trust,
-                       DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
-                       &remote_dev_info->uuids, remote_dev_info->uuid_count,
-                       DBUS_TYPE_INT16, &remote_dev_info->manufacturer_data_len,
-                       DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                       &remote_dev_info->manufacturer_data, remote_dev_info->manufacturer_data_len,
-                       DBUS_TYPE_INVALID);
+                       param);
 
                _bt_free_device_info(remote_dev_info);
        }
@@ -126,21 +133,20 @@ static void __bt_decline_pair_request()
        if (req_info->context == NULL)
                goto done;
 
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
        memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
        _bt_convert_addr_string_to_type(dev_info.device_address.addr,
                                        bonding_info->addr);
 
-       g_array_append_vals(out_param1, &dev_info,
-                               sizeof(bluetooth_device_info_t));
-       g_array_append_vals(out_param2, &bonding_info->result, sizeof(int));
+       out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+               &dev_info, sizeof(bluetooth_device_info_t), TRUE, NULL, NULL);
+
+       out_param2 = g_variant_new_from_data((const GVariantType *)"i",
+               &bonding_info->result, sizeof(int), TRUE, NULL, NULL);
 
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
 
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
+       g_dbus_method_invocation_return_value(req_info->context,
+                       g_variant_new("@ayi", out_param1, out_param2));
+
 
        _bt_delete_request_list(req_info->req_id);
 done:
@@ -150,7 +156,7 @@ done:
        bonding_info = NULL;
 
        BT_DBG("-");
-}
+} */
 
 #ifdef TIZEN_WEARABLE
 static gboolean __bt_syspopup_timer_cb(gpointer user_data)
@@ -161,9 +167,7 @@ static gboolean __bt_syspopup_timer_cb(gpointer user_data)
 
        b = (bundle *)user_data;
 
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
        ret = syspopup_launch("bt-syspopup", b);
-#endif
        if (ret < 0) {
                BT_ERR("Sorry!! Cannot launch popup return = %d, Retrying...", ret);
        } else {
@@ -178,7 +182,7 @@ static gboolean __bt_launch_unable_to_pairing_syspopup(int result)
        BT_DBG("+");
        int ret = 0;
        bundle *b = NULL;
-       DBusGConnection *conn;
+       GDBusConnection *conn;
 
        conn = _bt_get_system_gconn();
        if (conn == NULL)
@@ -197,9 +201,7 @@ static gboolean __bt_launch_unable_to_pairing_syspopup(int result)
        else
                bundle_add(b, "error", "error");
 
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
        ret = syspopup_launch("bt-syspopup", b);
-#endif
        if (0 > ret) {
                BT_ERR("Popup launch failed...retry %d \n", ret);
                g_timeout_add(200, (GSourceFunc) __bt_syspopup_timer_cb,
@@ -266,8 +268,7 @@ void __bt_cancel_search_service_done(void)
        int result = BLUETOOTH_ERROR_CANCEL_BY_USER;
        request_info_t *req_info;
        bluetooth_device_info_t dev_info;
-       GArray *out_param1;
-       GArray *out_param2;
+       GVariant *out_param1;
 
        ret_if(searching_info == NULL);
 
@@ -280,21 +281,16 @@ void __bt_cancel_search_service_done(void)
        if (req_info->context == NULL)
                goto done;
 
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
        memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
        _bt_convert_addr_string_to_type(dev_info.device_address.addr,
                                        searching_info->addr);
 
-       g_array_append_vals(out_param1, &dev_info,
-                               sizeof(bluetooth_device_info_t));
-       g_array_append_vals(out_param2, &result, sizeof(int));
+       out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+               &dev_info, sizeof(bluetooth_device_info_t), TRUE, NULL, NULL);
 
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
 
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
+       g_dbus_method_invocation_return_value(req_info->context,
+                       g_variant_new("(iv)", result, out_param1));
 
        _bt_delete_request_list(req_info->req_id);
 
@@ -305,50 +301,35 @@ done:
        searching_info = NULL;
 }
 
-static void __bt_get_uuids(GValue *value, bt_remote_dev_info_t *info)
+static void __bt_get_uuids(GVariant *value, bt_remote_dev_info_t *info)
 {
-       int i = 0;
-       char **uuid_value;
-
        ret_if(value == NULL);
        ret_if(info == NULL);
 
-       info->uuid_count = 0;
-
-       uuid_value = g_value_get_boxed(value);
-       ret_if(uuid_value == NULL);
-
-       while (uuid_value[i]) {
-               i++;
-       }
-       ret_if(i == 0);
-
-       info->uuid_count = i;
-
-       info->uuids = g_new0(char *, info->uuid_count + 1);
-
-       for (i = 0; uuid_value[i] != NULL; i++) {
-               info->uuids[i] = g_strdup(uuid_value[i]);
-       }
+       info->uuid_count = g_variant_get_size(value);
+       info->uuids = g_variant_dup_strv(value, &info->uuid_count);
 }
 
 bt_remote_dev_info_t *_bt_get_remote_device_info(char *address)
 {
        bt_remote_dev_info_t *dev_info;
        char *object_path = NULL;
-       DBusGProxy *adapter_proxy;
-       DBusGProxy *device_proxy;
-       GHashTable *hash = NULL;
-       GValue *value;
-       const gchar *name;
-       GByteArray *manufacturer_data = NULL;
-       DBusGConnection *conn;
+       GDBusProxy *adapter_proxy;
+       GDBusProxy *device_proxy;
+       GVariant *value;
+       GVariant *tmp_value;
+       gchar *name;
+       gchar *manufacturer_data = NULL;
+       GDBusConnection *conn;
+       GError *error = NULL;
+       GVariant *result = NULL;
 
        retv_if(address == NULL, NULL);
 
        adapter_proxy = _bt_get_adapter_proxy();
        retv_if(adapter_proxy == NULL, NULL);
 
+
        object_path = _bt_get_device_object_path(address);
 
        retv_if(object_path == NULL, NULL);
@@ -360,78 +341,94 @@ bt_remote_dev_info_t *_bt_get_remote_device_info(char *address)
                return NULL;
        }
 
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               object_path, BT_PROPERTIES_INTERFACE);
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL, BT_BLUEZ_NAME,
+                                                               object_path, BT_PROPERTIES_INTERFACE,  NULL, NULL);
+
        g_free(object_path);
        retv_if(device_proxy == NULL, NULL);
 
-       dbus_g_proxy_call(device_proxy, "GetAll", NULL,
-                               G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                               G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
-                               G_TYPE_VALUE), &hash, G_TYPE_INVALID);
+       result = g_dbus_proxy_call_sync(device_proxy, "GetAll",
+                               g_variant_new("(s)", BT_DEVICE_INTERFACE),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
 
        g_object_unref(device_proxy);
 
        dev_info = g_malloc0(sizeof(bt_remote_dev_info_t));
 
-       if (hash != NULL) {
-               value = g_hash_table_lookup(hash, "Alias");
-               name = value ? g_value_get_string(value) : NULL;
+       if (result != NULL) {
+               g_variant_get(result , "(@a{sv})", &value);
+               g_variant_unref(result);
 
+               tmp_value = g_variant_lookup_value (value, "Alias", G_VARIANT_TYPE_STRING);
+
+               g_variant_get(tmp_value, "s", &name);
+               g_variant_unref(tmp_value);
                if (name != NULL)
                        DBG_SECURE("Alias Name [%s]", name);
                else {
-                       value = g_hash_table_lookup(hash, "Name");
-                       name = value ? g_value_get_string(value) : NULL;
+                       tmp_value = g_variant_lookup_value(value, "Name", G_VARIANT_TYPE_STRING);
+                       g_variant_get(tmp_value, "s", &name);
+                       g_variant_unref(tmp_value);
                }
 
-               value = g_hash_table_lookup(hash, "Class");
-               dev_info->class = value ? g_value_get_uint(value) : 0;
+               tmp_value = g_variant_lookup_value(value, "Class", G_VARIANT_TYPE_UINT32);
+               dev_info->class = tmp_value ? g_variant_get_uint32(tmp_value) : 0;
+               g_variant_unref(tmp_value);
 
-               value = g_hash_table_lookup(hash, "Connected");
-               dev_info->connected = value ? g_value_get_boolean(value) : FALSE;
+               tmp_value = g_variant_lookup_value(value, "Connected",  G_VARIANT_TYPE_BOOLEAN);
+               dev_info->connected = tmp_value ? g_variant_get_boolean(tmp_value) : BLUETOOTH_CONNECTED_LINK_NONE;
+               g_variant_unref(tmp_value);
 
-               value = g_hash_table_lookup(hash, "Trusted");
-               dev_info->trust = value ? g_value_get_boolean(value) : FALSE;
+               tmp_value = g_variant_lookup_value(value, "Trusted",  G_VARIANT_TYPE_BOOLEAN);
+               dev_info->trust = tmp_value ? g_variant_get_boolean(tmp_value) : FALSE;
+               g_variant_unref(tmp_value);
 
-               value = g_hash_table_lookup(hash, "Paired");
-               dev_info->paired = value ? g_value_get_boolean(value) : FALSE;
+               tmp_value = g_variant_lookup_value(value, "Paired",  G_VARIANT_TYPE_BOOLEAN);
+               dev_info->paired = tmp_value ? g_variant_get_boolean(tmp_value) : FALSE;
+               g_variant_unref(tmp_value);
 
                BT_DBG("Paired %d", dev_info->paired );
 
-               value = g_hash_table_lookup(hash, "RSSI");
-               dev_info->rssi = value ? g_value_get_int(value) : 0;
+               tmp_value = g_variant_lookup_value(value, "RSSI", G_VARIANT_TYPE_INT32);
+               dev_info->rssi = tmp_value ? g_variant_get_int32(tmp_value) : 0;
+               g_variant_unref(tmp_value);
 
-               value = g_hash_table_lookup(hash, "LastAddrType");
-               dev_info->addr_type = value ? g_value_get_uchar(value) : 0;
+               tmp_value = g_variant_lookup_value(value, "LastAddrType", G_VARIANT_TYPE_UINT32);
+               dev_info->addr_type = tmp_value ? g_variant_get_uint32(tmp_value) : 0;
+               g_variant_unref(tmp_value);
 
-               value = g_hash_table_lookup(hash, "UUIDs");
-               __bt_get_uuids(value, dev_info);
+               tmp_value = g_variant_lookup_value(value, "UUIDs", G_VARIANT_TYPE_STRING_ARRAY);
+               __bt_get_uuids(tmp_value, dev_info);
+               g_variant_unref(tmp_value);
 
-               value = g_hash_table_lookup(hash, "ManufacturerDataLen");
-               dev_info->manufacturer_data_len = value ? g_value_get_uint(value) : 0;
+               tmp_value = g_variant_lookup_value(value, "ManufacturerDataLen", G_VARIANT_TYPE_UINT32);
+               dev_info->manufacturer_data_len = tmp_value ? g_variant_get_uint32(tmp_value) : 0;
                if (dev_info->manufacturer_data_len > BLUETOOTH_MANUFACTURER_DATA_LENGTH_MAX) {
                        BT_ERR("manufacturer_data_len is too long(len = %d)", dev_info->manufacturer_data_len);
                        dev_info->manufacturer_data_len = BLUETOOTH_MANUFACTURER_DATA_LENGTH_MAX;
                }
+               g_variant_unref(tmp_value);
 
-               value = g_hash_table_lookup(hash, "ManufacturerData");
-               manufacturer_data = value ? g_value_get_boxed(value) : NULL;
+               tmp_value = g_variant_lookup_value(value, "ManufacturerData", G_VARIANT_TYPE_BYTESTRING);
+               manufacturer_data = value ? (gchar *)g_variant_get_bytestring(tmp_value) : NULL;
                if (manufacturer_data) {
                        if (dev_info->manufacturer_data_len > 0) {
-                               BT_DBG("manufacturer_data_len  = %d", dev_info->manufacturer_data_len);
                                dev_info->manufacturer_data = g_malloc0(dev_info->manufacturer_data_len);
-                               memcpy(dev_info->manufacturer_data, manufacturer_data->data, dev_info->manufacturer_data_len);
+                               memcpy(dev_info->manufacturer_data, manufacturer_data, dev_info->manufacturer_data_len);
                        }
                }
+               g_variant_unref(tmp_value);
 
                dev_info->address = g_strdup(address);
                dev_info->name = g_strdup(name);
-
-               g_hash_table_destroy(hash);
+               g_free(name);
+               g_variant_unref(value);
        } else {
-               BT_ERR("Hash is NULL\n");
+               BT_ERR("result  is NULL\n");
                g_free(dev_info);
                dev_info = NULL;
        }
@@ -439,6 +436,22 @@ bt_remote_dev_info_t *_bt_get_remote_device_info(char *address)
        return dev_info;
 }
 
+char *_bt_get_bonded_device_name(char *address)
+{
+       bluetooth_device_address_t device_address = { {0} };
+       bluetooth_device_info_t dev_info;
+
+       retv_if(address == NULL, strdup(""));
+
+       _bt_convert_addr_string_to_type(device_address.addr, address);
+
+       memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
+
+       _bt_get_bonded_device_info(&device_address, &dev_info);
+
+       return g_strdup(dev_info.device_name.name);
+}
+
 static gboolean __ignore_auto_pairing_request(const char *address)
 {
        gchar *buffer;
@@ -478,6 +491,12 @@ static gboolean __ignore_auto_pairing_request(const char *address)
        }
 
        buffer = g_malloc0(sizeof(char) * size);
+       /* Fix : NULL_RETURNS */
+       if (buffer == NULL) {
+               BT_ERR("Memory allocation error\n");
+               fclose(fp);
+               return FALSE;
+       }
        result = fread((char *)buffer, 1, size, fp);
        fclose(fp);
        if (result != size) {
@@ -504,6 +523,8 @@ static gboolean __ignore_auto_pairing_request(const char *address)
        }
        buffer = g_strjoinv(BT_AGENT_NEW_LINE, lines);
        g_strfreev(lines);
+       /* Fix : NULL_RETURNS */
+       retv_if(buffer == NULL, FALSE);
 
        fp = fopen(BT_AGENT_AUTO_PAIR_BLACKLIST_FILE, "w");
 
@@ -529,32 +550,22 @@ static int __bt_retry_bond(void)
        BT_CHECK_PARAMETER(bonding_info, return);
        BT_CHECK_PARAMETER(bonding_info->addr, return);
 
-       if (!dbus_g_proxy_begin_call_with_timeout(bonding_info->device_proxy,
-                               "Pair",
-                               (DBusGProxyCallNotify) __bt_bond_device_cb,
-                               NULL, NULL, BT_MAX_DBUS_TIMEOUT,
-                               G_TYPE_UCHAR, bonding_info->conn_type,
-                               G_TYPE_INVALID)) {
-               BT_ERR("RePair call fail");
-
-               g_object_unref(bonding_info->device_proxy);
-               goto fail;
-       }
-
+       g_dbus_proxy_call(bonding_info->device_proxy, "Pair",
+                               g_variant_new("(y)", bonding_info->conn_type),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               BT_MAX_DBUS_TIMEOUT,
+                               NULL,
+                               (GAsyncReadyCallback)__bt_bond_device_cb,
+                               NULL);
 
        return BLUETOOTH_ERROR_NONE;
-
-fail:
-       __bt_decline_pair_request();
-       is_device_creating = FALSE;
-
-       return BLUETOOTH_ERROR_INTERNAL;
 }
 
 
 static int __bt_remove_and_bond(void)
 {
-       DBusGProxy *adapter_proxy;
+       GDBusProxy *adapter_proxy;
+       GVariant *result = NULL;
        GError *err = NULL;
        char *device_path = NULL;
 
@@ -564,18 +575,27 @@ static int __bt_remove_and_bond(void)
        adapter_proxy = _bt_get_adapter_proxy();
        retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call(adapter_proxy, "FindDevice", NULL,
-                         G_TYPE_STRING, bonding_info->addr,
-                         G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH,
-                         &device_path,
-                         G_TYPE_INVALID);
+       result = g_dbus_proxy_call_sync(adapter_proxy, "FindDevice",
+                               g_variant_new("(s)", bonding_info->addr),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               NULL);
+       if (result == NULL)
+               return BLUETOOTH_ERROR_INTERNAL;
+
+       g_variant_get(result , "(&o)", &device_path);
+       g_variant_unref(result);
 
        retv_if(device_path == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call(adapter_proxy, "UnpairDevice",
-                         &err, DBUS_TYPE_G_OBJECT_PATH, device_path,
-                         G_TYPE_INVALID, G_TYPE_INVALID);
-       g_free(device_path);
+       result = g_dbus_proxy_call_sync(adapter_proxy, "UnpairDevice",
+                               g_variant_new("(o)", device_path),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &err);
+
        if (err != NULL) {
                BT_ERR("UnpairDevice Fail: %s", err->message);
                g_error_free(err);
@@ -599,25 +619,22 @@ static int __bt_cancel_and_bond(void)
 }
 
 
-static void __bt_bond_device_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                                                    gpointer user_data)
+static void __bt_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res,
+                                       gpointer user_data)
 {
        int result = BLUETOOTH_ERROR_NONE;
        GError *err = NULL;
-       GArray *out_param1;
-       GArray *out_param2;
+       GVariant *out_param1;
        request_info_t *req_info;
        bluetooth_device_info_t dev_info;
        bt_remote_dev_info_t *remote_dev_info;
+       GVariant *manufacture_data;
+       GVariant *param;
 
        /* Terminate ALL system popup */
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
-       //syspopup_destroy_all();
-#endif
+       syspopup_destroy_all();
 
-       dbus_g_proxy_end_call(proxy, call, &err, G_TYPE_INVALID);
-
-       g_object_unref(proxy);
+        g_dbus_proxy_call_finish(proxy, res, &err);
 
        is_device_creating = FALSE;
 
@@ -629,8 +646,6 @@ static void __bt_bond_device_cb(DBusGProxy *proxy, DBusGProxyCall *call,
                return;
        }
 
-       bonding_info->device_proxy = NULL;
-
        req_info = _bt_get_request_info(bonding_info->req_id);
        if (req_info == NULL) {
                BT_ERR("req_info == NULL");
@@ -638,17 +653,19 @@ static void __bt_bond_device_cb(DBusGProxy *proxy, DBusGProxyCall *call,
        }
 
        if (err != NULL) {
-               BT_ERR("Error occured in Pair [%s]", err->message);
+               BT_ERR("Error occured in CreateBonding [%s]", err->message);
 
                if (!strcmp(err->message, "Already Exists")) {
                        BT_INFO("Existing Bond, remove and retry");
                        ret_if(__bt_remove_and_bond() == BLUETOOTH_ERROR_NONE);
 
                        result = BLUETOOTH_ERROR_PARING_FAILED;
-//             } else if (_bt_agent_is_canceled() ||
-//                     !strcmp(err->message, "Authentication Canceled")) {
-//                     result = BLUETOOTH_ERROR_CANCEL_BY_USER;
+               } else if (_bt_agent_is_canceled() ||
+                       !strcmp(err->message, "Authentication Canceled")) {
+                       BT_INFO("Cancelled by USER");
+                       result = BLUETOOTH_ERROR_CANCEL_BY_USER;
                } else if (!strcmp(err->message, "Authentication Rejected")) {
+                       BT_INFO("REJECTED");
                        result = BLUETOOTH_ERROR_ACCESS_DENIED;
                } else if (!strcmp(err->message, "In Progress")) {
                        BT_INFO("Bond in progress, cancel and retry");
@@ -656,12 +673,14 @@ static void __bt_bond_device_cb(DBusGProxy *proxy, DBusGProxyCall *call,
 
                        result = BLUETOOTH_ERROR_PARING_FAILED;
                } else if (!strcmp(err->message, "Authentication Failed")) {
+                       BT_INFO("Authentication Failed");
                        if (bonding_info->is_autopair == TRUE) {
                                _bt_set_autopair_status_in_bonding_info(FALSE);
                                __ignore_auto_pairing_request(bonding_info->addr);
                        }
                        result = BLUETOOTH_ERROR_AUTHENTICATION_FAILED;
                } else if (!strcmp(err->message, "Page Timeout")) {
+                       BT_INFO("Page Timeout");
                        /* This is the special case
                             As soon as call bluetooth_bond_device, try to cancel bonding.
                             In this case, before completing to call 'CreatePairedDevice' method
@@ -669,13 +688,15 @@ static void __bt_bond_device_cb(DBusGProxy *proxy, DBusGProxyCall *call,
                        */
                        result = BLUETOOTH_ERROR_HOST_DOWN;
                } else if (!strcmp(err->message, BT_TIMEOUT_MESSAGE)) {
-                       dbus_g_proxy_call(proxy, "CancelDeviceCreation", NULL,
-                                          G_TYPE_STRING, bonding_info->addr,
-                                          G_TYPE_INVALID, G_TYPE_INVALID);
+                       g_dbus_proxy_call_sync(proxy, "CancelDeviceCreation",
+                                               g_variant_new("(s)", bonding_info->addr),
+                                               G_DBUS_CALL_FLAGS_NONE,
+                                               -1,
+                                               NULL,
+                                               NULL);
 
                        result = BLUETOOTH_ERROR_INTERNAL;
                } else if (!strcmp(err->message, "Connection Timeout")) {
-                       BT_INFO("pairing request timeout");
                        /* Pairing request timeout */
                        result = BLUETOOTH_ERROR_TIMEOUT;
                } else if (!strcmp(err->message, "Authentication Timeout")) {
@@ -686,14 +707,12 @@ static void __bt_bond_device_cb(DBusGProxy *proxy, DBusGProxyCall *call,
                        result = BLUETOOTH_ERROR_PARING_FAILED;
                }
        }
-#if 0
+
        if (result == BLUETOOTH_ERROR_PARING_FAILED ||
                        result == BLUETOOTH_ERROR_AUTHENTICATION_FAILED ||
                        result == BLUETOOTH_ERROR_TIMEOUT ||
                        result == BLUETOOTH_ERROR_HOST_DOWN) {
-
-                       BT_INFO("result error %d", result);
-                       bonding_info->result = result;
+               bonding_info->result = result;
 #ifdef TIZEN_WEARABLE
                __bt_launch_unable_to_pairing_syspopup(result);
 #endif
@@ -701,69 +720,77 @@ static void __bt_bond_device_cb(DBusGProxy *proxy, DBusGProxyCall *call,
 
        g_object_unref(proxy);
        bonding_info->device_proxy = NULL;
-#endif
+
        if (result != BLUETOOTH_ERROR_NONE)
                goto dbus_return;
 
        remote_dev_info = _bt_get_remote_device_info(bonding_info->addr);
 
+       GVariant *uuids = NULL;
+       GVariantBuilder *builder = NULL;
+       int i = 0;
+       builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
+       for (i=0; i < remote_dev_info->uuid_count; i++) {
+               g_variant_builder_add(builder, "s",
+                       remote_dev_info->uuids[i]);
+       }
+       uuids = g_variant_new("as", builder);
+       g_variant_builder_unref(builder);
+       manufacture_data = g_variant_new_from_data((const GVariantType *)"ay",
+                                               remote_dev_info->manufacturer_data, remote_dev_info->manufacturer_data_len,
+                                               TRUE, NULL, NULL);
+
+       param = g_variant_new("(isunsbub@asn@ay)",
+                       result,
+                       bonding_info->addr,
+                       remote_dev_info->class,
+                       remote_dev_info->rssi,
+                       remote_dev_info->name,
+                       remote_dev_info->paired,
+                       remote_dev_info->connected,
+                       remote_dev_info->trust,
+                       uuids,
+                       remote_dev_info->manufacturer_data_len,
+                       manufacture_data);
+
+
        /* Send the event to application */
        if (remote_dev_info != NULL) {
+
                _bt_send_event(BT_ADAPTER_EVENT,
                        BLUETOOTH_EVENT_BONDING_FINISHED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &bonding_info->addr,
-                       DBUS_TYPE_UINT32, &remote_dev_info->class,
-                       DBUS_TYPE_INT16, &remote_dev_info->rssi,
-                       DBUS_TYPE_STRING, &remote_dev_info->name,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->paired,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->connected,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->trust,
-                       DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
-                       &remote_dev_info->uuids, remote_dev_info->uuid_count,
-                       DBUS_TYPE_INT16, &remote_dev_info->manufacturer_data_len,
-                       DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                       &remote_dev_info->manufacturer_data, remote_dev_info->manufacturer_data_len,
-                       DBUS_TYPE_INVALID);
+                       param);
 
                _bt_free_device_info(remote_dev_info);
        }
 
 dbus_return:
-
        if (req_info->context == NULL)
                goto done;
 
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
        memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
        _bt_convert_addr_string_to_type(dev_info.device_address.addr,
                                        bonding_info->addr);
 
-#if 0
        if (_bt_adapter_get_status() != BT_ACTIVATED)
                result = BLUETOOTH_ERROR_NOT_IN_OPERATION;
-#endif
 
-       g_array_append_vals(out_param1, &dev_info,
-                               sizeof(bluetooth_device_info_t));
-       g_array_append_vals(out_param2, &result, sizeof(int));
+       out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+               &dev_info, sizeof(bluetooth_device_info_t), TRUE, NULL, NULL);
 
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
+       g_dbus_method_invocation_return_value(req_info->context,
+                       g_variant_new("(iv)", result, out_param1));
 
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
+       g_variant_unref(out_param1);
+//     g_variant_unref(out_param2);
 
        _bt_delete_request_list(req_info->req_id);
-
 done:
        if (err)
                g_error_free(err);
 
-#if 0
        _bt_agent_set_canceled(FALSE);
-#endif
+
 
        g_free(bonding_info->addr);
        g_free(bonding_info);
@@ -774,13 +801,13 @@ int _bt_bond_device(int request_id,
                bluetooth_device_address_t *device_address,
                unsigned short conn_type, GArray **out_param1)
 {
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        bluetooth_device_info_t dev_info;
 
-       DBusGConnection *conn;
+       GDBusConnection *conn;
        char *device_path = NULL;
-       DBusGProxy *adapter_proxy;
+       GDBusProxy *adapter_proxy;
        GError *error = NULL;
 
        BT_CHECK_PARAMETER(device_address, return);
@@ -807,19 +834,23 @@ int _bt_bond_device(int request_id,
 
        if (device_path == NULL) {
                BT_ERR("No searched device");
-
+               GVariant *ret = NULL;
                adapter_proxy = _bt_get_adapter_proxy();
                retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-               dbus_g_proxy_call(adapter_proxy, "CreateDevice", &error,
-                       G_TYPE_STRING, address,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
+               ret = g_dbus_proxy_call_sync(adapter_proxy, "CreateDevice",
+                                       g_variant_new("(s)", address),
+                                       G_DBUS_CALL_FLAGS_NONE,
+                                       -1,
+                                       NULL,
+                                       &error);
 
                if (error != NULL) {
                        BT_ERR("CreateDevice Fail: %s", error->message);
-                       g_error_free(error);
+                       g_clear_error(&error);
                }
-
+               if (ret)
+                       g_variant_unref(ret);
                device_path = _bt_get_device_object_path(address);
                if (device_path == NULL) {
                        memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
@@ -835,8 +866,9 @@ int _bt_bond_device(int request_id,
                }
        }
 
-       proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               device_path, BT_DEVICE_INTERFACE);
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL, BT_BLUEZ_NAME,
+                                                               device_path, BT_DEVICE_INTERFACE,  NULL, NULL);
 
        g_free(device_path);
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
@@ -850,20 +882,18 @@ int _bt_bond_device(int request_id,
 
        is_device_creating = TRUE;
 
-       if (!dbus_g_proxy_begin_call_with_timeout(proxy, "Pair",
-                               (DBusGProxyCallNotify) __bt_bond_device_cb,
-                               NULL, NULL, BT_MAX_DBUS_TIMEOUT,
-                               G_TYPE_UCHAR, conn_type,
-                               G_TYPE_INVALID)) {
-               BT_ERR("Pair call fail");
-               g_object_unref(proxy);
-               bonding_info->device_proxy = NULL;
-               goto fail;
-       }
+       g_dbus_proxy_call(proxy, "Pair",
+                               g_variant_new("(y)", conn_type),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               BT_MAX_DBUS_TIMEOUT,
+                               NULL,
+                               (GAsyncReadyCallback)__bt_bond_device_cb,
+                               NULL);
+
 /* TODO: We need to check if we can pair the specific device using 'pair' API of bluez 5.x */
 
        return BLUETOOTH_ERROR_NONE;
-fail:
+/*fail:
        memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
        _bt_convert_addr_string_to_type(dev_info.device_address.addr,
                                        bonding_info->addr);
@@ -877,7 +907,7 @@ fail:
        g_free(bonding_info);
        bonding_info = NULL;
 
-       return BLUETOOTH_ERROR_INTERNAL;
+       return BLUETOOTH_ERROR_INTERNAL;*/
 }
 
 int _bt_cancel_bonding(void)
@@ -897,18 +927,17 @@ int _bt_cancel_bonding(void)
        return BLUETOOTH_ERROR_NONE;
 }
 
-static void __bt_unbond_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                               gpointer user_data)
+static void __bt_unbond_cb(GDBusProxy *proxy, GAsyncResult *res,
+                                       gpointer user_data)
 {
        GError *err = NULL;
-       GArray *out_param1;
-       GArray *out_param2;
+       GVariant *out_param1;
        int result = BLUETOOTH_ERROR_NONE;
        bt_funcion_data_t *unbonding_info;
        bluetooth_device_info_t dev_info;
        request_info_t *req_info;
 
-       dbus_g_proxy_end_call(proxy, call, &err, G_TYPE_INVALID);
+       g_dbus_proxy_call_finish(proxy, res, &err);
 
        unbonding_info = user_data;
 
@@ -932,23 +961,18 @@ static void __bt_unbond_cb(DBusGProxy *proxy, DBusGProxyCall *call,
        if (req_info->context == NULL)
                goto done;
 
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
        memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
        _bt_convert_addr_string_to_type(dev_info.device_address.addr,
                                        unbonding_info->addr);
 
-       g_array_append_vals(out_param1, &dev_info,
-                               sizeof(bluetooth_device_info_t));
-       g_array_append_vals(out_param2, &result, sizeof(int));
+       out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+               &dev_info, sizeof(bluetooth_device_info_t), TRUE, NULL, NULL);
 
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
+       g_dbus_method_invocation_return_value(req_info->context,
+                       g_variant_new("(iv)", result, out_param1));
 
-       _bt_delete_request_list(req_info->req_id);
 
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
+       _bt_delete_request_list(req_info->req_id);
 
 done:
        if (err)
@@ -966,13 +990,13 @@ int _bt_unbond_device(int request_id,
 {
        char *device_path = NULL;
        bt_funcion_data_t *unbonding_info;
-       DBusGProxy *adapter_proxy = NULL;
-       DBusGProxy *device_proxy = NULL;
-       DBusGConnection *conn;
+       GDBusProxy *adapter_proxy = NULL;
+       GDBusProxy *device_proxy = NULL;
+       GDBusConnection *conn;
        int result = BLUETOOTH_ERROR_INTERNAL;
        bluetooth_device_info_t dev_info;
-       GValue paired = { 0 };
        GError *error = NULL;
+       GVariant *ret = NULL;
 
        BT_CHECK_PARAMETER(device_address, return);
 
@@ -981,6 +1005,12 @@ int _bt_unbond_device(int request_id,
 
        /* allocate user data so that it can be retrieved in callback */
        unbonding_info = g_malloc0(sizeof(bt_funcion_data_t));
+       /* Fix : NULL_RETURNS */
+       if (unbonding_info == NULL) {
+               BT_ERR("Memory not allocated !");
+               return BLUETOOTH_ERROR_MEMORY_ALLOCATION;
+       }
+
        unbonding_info->addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
        unbonding_info->req_id = request_id;
 
@@ -1002,38 +1032,43 @@ int _bt_unbond_device(int request_id,
                goto fail;
        }
 
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               device_path, BT_PROPERTIES_INTERFACE);
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL, BT_BLUEZ_NAME,
+                                                               device_path, BT_PROPERTIES_INTERFACE,  NULL, NULL);
+
        if (device_proxy != NULL) {
-               if (!dbus_g_proxy_call(device_proxy, "Get", &error,
-                               G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                               G_TYPE_STRING, "Paired",
-                               G_TYPE_INVALID,
-                               G_TYPE_VALUE, &paired,
-                               G_TYPE_INVALID)) {
-                       if (error != NULL) {
-                               BT_ERR("Getting property failed: [%s]\n", error->message);
-                               g_error_free(error);
-                       }
+
+               ret = g_dbus_proxy_call_sync(device_proxy, "Get",
+                                       g_variant_new("(ss)", BT_DEVICE_INTERFACE, "Paired"),
+                                       G_DBUS_CALL_FLAGS_NONE,
+                                       -1,
+                                       NULL,
+                                       &error);
+               if (error) {
+                       BT_ERR("Getting property failed: [%s]\n", error->message);
+                       g_error_free(error);
+                       result = BLUETOOTH_ERROR_NOT_PAIRED;
+                       goto fail;
                } else {
-                       if (g_value_get_boolean(&paired) == FALSE) {
+                       if (!ret) {
                                BT_ERR("No paired device");
                                g_object_unref(device_proxy);
                                result = BLUETOOTH_ERROR_NOT_PAIRED;
                                goto fail;
                        }
+                       g_variant_unref(ret);
                }
                g_object_unref(device_proxy);
        }
 
-       if (!dbus_g_proxy_begin_call(adapter_proxy, "UnpairDevice",
-                               (DBusGProxyCallNotify) __bt_unbond_cb,
-                               (gpointer)unbonding_info, NULL,
-                               DBUS_TYPE_G_OBJECT_PATH, device_path,
-                               G_TYPE_INVALID)) {
-               BT_ERR("RemoveBonding begin failed\n");
-               goto fail;
-       }
+       g_dbus_proxy_call(adapter_proxy, "UnpairDevice",
+                               g_variant_new("(o)", device_path),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               BT_MAX_DBUS_TIMEOUT,
+                               NULL,
+                               (GAsyncReadyCallback)__bt_unbond_cb,
+                               NULL);
+
        g_free(device_path);
        return BLUETOOTH_ERROR_NONE;
 
@@ -1050,21 +1085,21 @@ fail:
        return result;
 }
 
-static void __bt_discover_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                               gpointer user_data)
+static void __bt_discover_cb(GDBusProxy *proxy, GAsyncResult *res,
+                                       gpointer user_data)
 {
        GError *err = NULL;
-       GHashTable *hash = NULL;
-       GArray *out_param1;
-       GArray *out_param2;
+       GVariant *out_param1;
        int result = BLUETOOTH_ERROR_NONE;
        bluetooth_device_info_t dev_info;
        bt_remote_dev_info_t *remote_dev_info;
        request_info_t *req_info;
+       GVariant *uuid_list, *manufacture_data;
+       GVariant *param;
+       GVariantBuilder *builder = NULL;
+       int i = 0;
 
-       dbus_g_proxy_end_call(proxy, call, &err,
-                             dbus_g_type_get_map("GHashTable", G_TYPE_UINT, G_TYPE_STRING), &hash,
-                             G_TYPE_INVALID);
+       g_dbus_proxy_call_finish(proxy, res, &err);
 
        g_object_unref(proxy);
 
@@ -1109,24 +1144,37 @@ static void __bt_discover_cb(DBusGProxy *proxy, DBusGProxyCall *call,
        remote_dev_info = _bt_get_remote_device_info(searching_info->addr);
 
 event:
+       builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
+       for (i=0; i < remote_dev_info->uuid_count; i++) {
+               g_variant_builder_add(builder, "s",
+                       remote_dev_info->uuids[i]);
+       }
+       uuid_list = g_variant_new("as", builder);
+       g_variant_builder_unref(builder);
+       manufacture_data = g_variant_new_from_data((const GVariantType *)"ay",
+                                               remote_dev_info->manufacturer_data, remote_dev_info->manufacturer_data_len,
+                                               TRUE, NULL, NULL);
+
+       param = g_variant_new("(isunsbub@asn@ay)",
+                       result,
+                       searching_info->addr,
+                       remote_dev_info->class,
+                       remote_dev_info->rssi,
+                       remote_dev_info->name,
+                       remote_dev_info->paired,
+                       remote_dev_info->connected,
+                       remote_dev_info->trust,
+                       uuid_list,
+                       remote_dev_info->manufacturer_data_len,
+                       manufacture_data);
+
+
        /* Send the event to application */
        if (remote_dev_info != NULL) {
+
                _bt_send_event(BT_ADAPTER_EVENT,
                        BLUETOOTH_EVENT_SERVICE_SEARCHED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &searching_info->addr,
-                       DBUS_TYPE_UINT32, &remote_dev_info->class,
-                       DBUS_TYPE_INT16, &remote_dev_info->rssi,
-                       DBUS_TYPE_STRING, &remote_dev_info->name,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->paired,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->connected,
-                       DBUS_TYPE_BOOLEAN, &remote_dev_info->trust,
-                       DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
-                       &remote_dev_info->uuids, remote_dev_info->uuid_count,
-                       DBUS_TYPE_INT16, &remote_dev_info->manufacturer_data_len,
-                       DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                       &remote_dev_info->manufacturer_data, remote_dev_info->manufacturer_data_len,
-                       DBUS_TYPE_INVALID);
+                       param);
 
                _bt_free_device_info(remote_dev_info);
        }
@@ -1135,29 +1183,22 @@ dbus_return:
        if (req_info->context == NULL)
                goto done;
 
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
        memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
        _bt_convert_addr_string_to_type(dev_info.device_address.addr,
                                        searching_info->addr);
 
-       g_array_append_vals(out_param1, &dev_info,
-                               sizeof(bluetooth_device_info_t));
-       g_array_append_vals(out_param2, &result, sizeof(int));
+       out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+               &dev_info, sizeof(bluetooth_device_info_t), TRUE, NULL, NULL);
 
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
+       g_dbus_method_invocation_return_value(req_info->context,
+                       g_variant_new("(iv)", result, out_param1));
 
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
 
        _bt_delete_request_list(req_info->req_id);
 done:
        if (err)
                g_error_free(err);
 
-       g_hash_table_destroy(hash);
-
        if (searching_info) {
                g_free(searching_info->addr);
                g_free(searching_info);
@@ -1169,14 +1210,19 @@ int _bt_search_device(int request_id,
                        bluetooth_device_address_t *device_address)
 {
        char *device_path = NULL;
-       DBusGProxy *device_proxy = NULL;
-       DBusGConnection *conn;
+       GDBusProxy *device_proxy = NULL;
+       GDBusConnection *conn;
 
-       DBusGProxy *adapter_proxy;
+       GDBusProxy *adapter_proxy;
        int result = BLUETOOTH_ERROR_INTERNAL;
 
        BT_CHECK_PARAMETER(device_address, return);
 
+       if (bonding_info) {
+               BT_ERR("Bonding in progress");
+               return BLUETOOTH_ERROR_DEVICE_BUSY;
+       }
+
        if (searching_info) {
                BT_ERR("Service searching in progress");
                return BLUETOOTH_ERROR_DEVICE_BUSY;
@@ -1205,23 +1251,22 @@ int _bt_search_device(int request_id,
                goto fail;
        }
 
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                                     device_path, BT_PROPERTIES_INTERFACE);
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL, BT_BLUEZ_NAME,
+                                                               device_path, BT_DEVICE_INTERFACE,  NULL, NULL);
        g_free(device_path);
        if (device_proxy == NULL) {
                result = BLUETOOTH_ERROR_INTERNAL;
                goto fail;
        }
 
-       if (!dbus_g_proxy_begin_call(device_proxy, "Get",
-                       (DBusGProxyCallNotify)__bt_discover_cb,
-                       (gpointer)searching_info, NULL,
-                       G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                       G_TYPE_STRING, "UUIDs",
-                       G_TYPE_INVALID)) {
-               BT_ERR("DiscoverServices failed");
-               goto fail;
-       }
+       g_dbus_proxy_call(device_proxy, "DiscoverServices",
+                       g_variant_new("(s)", ""),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       BT_MAX_DBUS_TIMEOUT,
+                       NULL,
+                       (GAsyncReadyCallback)__bt_discover_cb,
+                       searching_info);
 
        searching_info->device_proxy = device_proxy;
 
@@ -1243,10 +1288,12 @@ int _bt_cancel_search_device(void)
        retv_if(searching_info == NULL, BLUETOOTH_ERROR_NOT_IN_OPERATION);
 
        if (searching_info->device_proxy) {
-               dbus_g_proxy_call(searching_info->device_proxy,
-                               "CancelDiscovery",
-                               &err,
-                               G_TYPE_INVALID, G_TYPE_INVALID);
+               g_dbus_proxy_call_sync(searching_info->device_proxy, "CancelDiscovery",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &err);
        }
        __bt_cancel_search_service_done();
 
@@ -1258,11 +1305,10 @@ int _bt_set_alias(bluetooth_device_address_t *device_address,
 {
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        gchar *device_path = NULL;
-       DBusGProxy *adapter_proxy;
-       DBusGProxy *device_proxy;
+       GDBusProxy *adapter_proxy;
+       GDBusProxy *device_proxy;
        GError *error = NULL;
-       GValue name = { 0 };
-       DBusGConnection *conn;
+       GDBusConnection *conn;
 
        BT_CHECK_PARAMETER(device_address, return);
        BT_CHECK_PARAMETER(alias, return);
@@ -1282,24 +1328,22 @@ int _bt_set_alias(bluetooth_device_address_t *device_address,
                return BLUETOOTH_ERROR_NOT_PAIRED;
        }
 
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               device_path, BT_PROPERTIES_INTERFACE);
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL, BT_BLUEZ_NAME,
+                                                               device_path, BT_PROPERTIES_INTERFACE,  NULL, NULL);
 
        g_free(device_path);
        retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-       g_value_init(&name, G_TYPE_STRING);
-       g_value_set_string(&name, alias);
 
-       dbus_g_proxy_call(device_proxy, "Set", &error,
-                       G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                       G_TYPE_STRING, "Alias",
-                       G_TYPE_VALUE, &name,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
+       g_dbus_proxy_call_sync(device_proxy, "Set",
+                               g_variant_new("(ssv)", BT_DEVICE_INTERFACE,  "Alias", g_variant_new("s", alias)),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
 
        g_object_unref(device_proxy);
 
-       g_value_unset(&name);
-
        if (error) {
                 BT_ERR("SetProperty error: [%s]", error->message);
                 g_error_free(error);
@@ -1314,12 +1358,11 @@ int _bt_set_authorization(bluetooth_device_address_t *device_address,
 {
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        gchar *device_path = NULL;
-       DBusGProxy *device_proxy;
+       GDBusProxy *device_proxy;
        gboolean previous_value;
        GError *error = NULL;
-       GValue trusted = { 0 };
-       GValue trusted_v = { 0 };
-       DBusGConnection *conn;
+       GDBusConnection *conn;
+       GVariant *result = NULL;
        int ret = BLUETOOTH_ERROR_NONE;
 
        BT_CHECK_PARAMETER(device_address, return);
@@ -1336,27 +1379,28 @@ int _bt_set_authorization(bluetooth_device_address_t *device_address,
                return BLUETOOTH_ERROR_NOT_PAIRED;
        }
 
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               device_path, BT_PROPERTIES_INTERFACE);
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL, BT_BLUEZ_NAME,
+                                                               device_path, BT_PROPERTIES_INTERFACE,  NULL, NULL);
+
        g_free(device_path);
        retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       if (!dbus_g_proxy_call(device_proxy, "Get", &error,
-                       G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                       G_TYPE_STRING, "Trusted",
-                       G_TYPE_INVALID,
-                       G_TYPE_VALUE, &trusted_v,
-                       G_TYPE_INVALID)) {
-               if (error != NULL) {
-                       BT_ERR("Getting property failed: [%s]\n", error->message);
-                       g_error_free(error);
-               }
+       result = g_dbus_proxy_call_sync(device_proxy, "Get",
+                               g_variant_new("(ss)", BT_DEVICE_INTERFACE, "Trusted" ),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+       if (error != NULL) {
+               BT_ERR("Getting property failed: [%s]\n", error->message);
+               g_error_free(error);
                g_object_unref(device_proxy);
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       previous_value = g_value_get_boolean(&trusted_v);
-
+       previous_value = g_variant_get_boolean(result);
+       g_variant_unref(result);
        /* If the input is same with previous value, return error. */
        if (previous_value == authorize) {
                BT_ERR("Same value: %d", previous_value);
@@ -1365,18 +1409,14 @@ int _bt_set_authorization(bluetooth_device_address_t *device_address,
                goto done;
        }
 
-       g_value_init(&trusted, G_TYPE_BOOLEAN);
-       g_value_set_boolean(&trusted, authorize);
-
-       dbus_g_proxy_call(device_proxy, "Set", &error,
-                       G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                       G_TYPE_STRING, "Trusted",
-                       G_TYPE_VALUE, &trusted,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
+       g_dbus_proxy_call_sync(device_proxy, "Set",
+                                g_variant_new("(ssv)", BT_DEVICE_INTERFACE, "Trusted", g_variant_new("b",authorize)),
+                                G_DBUS_CALL_FLAGS_NONE,
+                                -1,
+                                NULL,
+                                &error);
 
        g_object_unref(device_proxy);
-       g_value_unset(&trusted);
-
        if (error) {
                 BT_ERR("SetProperty error: [%s]", error->message);
                 g_error_free(error);
@@ -1392,11 +1432,12 @@ int _bt_is_gatt_connected(bluetooth_device_address_t *device_address,
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        char *object_path = NULL;
 
-       DBusGProxy *device_proxy;
+       GDBusProxy *device_proxy;
        GError *error = NULL;
-       GValue *value;
-       GHashTable *hash = NULL;
-       DBusGConnection *conn;
+       GVariant *value;
+       GVariant *tmp_value;
+       GDBusConnection *conn;
+       GVariant *result = NULL;
        int ret = BLUETOOTH_ERROR_NONE;
 
        BT_CHECK_PARAMETER(device_address, return);
@@ -1409,35 +1450,39 @@ int _bt_is_gatt_connected(bluetooth_device_address_t *device_address,
        object_path = _bt_get_device_object_path(address);
        retv_if(object_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
 
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               object_path, BT_PROPERTIES_INTERFACE);
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL, BT_BLUEZ_NAME,
+                                                               object_path, BT_PROPERTIES_INTERFACE,  NULL, NULL);
        g_free(object_path);
        retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call(device_proxy, "GetAll", &error,
-                       G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                       G_TYPE_INVALID,
-                       dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
-                       G_TYPE_VALUE), &hash, G_TYPE_INVALID);
+       result = g_dbus_proxy_call_sync(device_proxy, "GetAll",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
 
-       if (error != NULL) {
+       if (error != NULL || result == NULL) {
                BT_ERR("Error occured in Proxy call [%s]\n", error->message);
                g_error_free(error);
                g_object_unref(device_proxy);
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       if (hash == NULL) {
+       g_variant_get(result , "(@a{sv})", &value);
+       g_variant_unref(result);
+
+       tmp_value = g_variant_lookup_value (value, "GattConnected", G_VARIANT_TYPE_BOOLEAN);
+       if (tmp_value != NULL) {
                g_object_unref(device_proxy);
                return BLUETOOTH_ERROR_INTERNAL;
        }
-
-       value = g_hash_table_lookup(hash, "GattConnected");
-       *is_connected = g_value_get_boolean(value);
+       *is_connected = g_variant_get_boolean (tmp_value);
 
        BT_DBG("gatt is connected : %d", *is_connected);
-
-       g_hash_table_destroy(hash);
+       g_variant_unref(tmp_value);
+       g_variant_unref(value);
        g_object_unref(device_proxy);
 
        return ret;
@@ -1448,21 +1493,20 @@ int _bt_is_device_connected(bluetooth_device_address_t *device_address,
 {
        char *object_path = NULL;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-       DBusGProxy *device_proxy = NULL;
-       DBusGProxy *adapter_proxy = NULL;
-       DBusGConnection *conn;
+       GDBusProxy *device_proxy = NULL;
+       GDBusProxy *adapter_proxy = NULL;
+       GDBusConnection *conn;
        GError *error = NULL;
-       GHashTable *hash = NULL;
-       GValue *value = NULL;
-
-       dbus_bool_t val = FALSE;
-       char *uuid;
+       GVariant *tmp_value = NULL;
+       GVariant *value = NULL;
+       GVariant *result = NULL;
+       char *uuid = NULL;
 
        retv_if(device_address == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
        retv_if(is_connected == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
 
        *is_connected = FALSE;
-
+       BT_DBG("connection_type: %d", connection_type);
        if (connection_type == BLUETOOTH_RFCOMM_SERVICE)
                return _bt_rfcomm_is_device_connected(device_address,
                                                is_connected);
@@ -1479,24 +1523,43 @@ int _bt_is_device_connected(bluetooth_device_address_t *device_address,
 
        if(connection_type == BLUETOOTH_NAP_SERVER_SERVICE)     {
                object_path = _bt_get_adapter_path();
-               device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                                               object_path, BT_NETWORK_SERVER_INTERFACE);
+               device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                                       NULL, BT_BLUEZ_NAME,
+                                                                       object_path, BT_NETWORK_SERVER_INTERFACE,  NULL, NULL);
                g_free(object_path);
                if (device_proxy == NULL) {
                        BT_DBG("Device don't have this service");
                        return BLUETOOTH_ERROR_INTERNAL;
                }
-               dbus_g_proxy_call(device_proxy, "GetProperties", NULL,
-                                       G_TYPE_STRING, address,
-                                       G_TYPE_INVALID,
-                                       dbus_g_type_get_map("GHashTable",
-                                       G_TYPE_STRING, G_TYPE_VALUE),
-                                       &hash, G_TYPE_INVALID);
-               if (hash != NULL) {
-                       value = g_hash_table_lookup(hash, "Connected");
-                       *is_connected = value ? g_value_get_boolean(value) : FALSE;
-                       g_hash_table_destroy(hash);
+
+               result = g_dbus_proxy_call_sync(device_proxy, "GetProperties",
+                                       g_variant_new("(s)", address),
+                                       G_DBUS_CALL_FLAGS_NONE,
+                                       -1,
+                                       NULL,
+                                       &error);
+
+               if (result == NULL) {
+                       BT_ERR("Error occured in Proxy call");
+                       if (error) {
+                               BT_ERR("Error occured in Proxy call [%s]\n", error->message);
+                               g_error_free(error);
+                       }
+                       g_object_unref(device_proxy);
+                       return BLUETOOTH_ERROR_INTERNAL;
+               }
+               g_variant_get(result , "(@a{sv})", &value);
+               g_variant_unref(result);
+
+
+               tmp_value = g_variant_lookup_value (value, "Connected", G_VARIANT_TYPE_BOOLEAN);
+               if (tmp_value != NULL) {
+                       g_object_unref(device_proxy);
+                       return BLUETOOTH_ERROR_INTERNAL;
                }
+               *is_connected = g_variant_get_boolean (tmp_value);
+               g_variant_unref(tmp_value);
+               g_variant_unref(value);
        } else if(connection_type == BLUETOOTH_NAP_SERVICE) {
                return _bt_is_network_connected(_bt_get_net_conn(),
                                                device_address->addr, is_connected);
@@ -1511,42 +1574,115 @@ int _bt_is_device_connected(bluetooth_device_address_t *device_address,
 
                object_path = _bt_get_device_object_path(address);
                retv_if(object_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
-
-               device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                                               object_path, BT_DEVICE_INTERFACE);
+               BT_DBG("object_path: %s", object_path);
+               device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                                       NULL, BT_BLUEZ_NAME,
+                                                                       object_path, BT_DEVICE_INTERFACE,  NULL, NULL);
                g_free(object_path);
                if (device_proxy == NULL) {
                        BT_DBG("Device don't have this service");
                        g_free(uuid);
                        return BLUETOOTH_ERROR_INTERNAL;
                }
-               dbus_g_proxy_call(device_proxy, "IsConnectedProfile", &error,
-                                       G_TYPE_STRING, uuid,
-                                       G_TYPE_INVALID,
-                                       G_TYPE_BOOLEAN, &val,
-                                       G_TYPE_INVALID);
 
-               if (error != NULL) {
-                       BT_ERR("Failed to get properties: %s\n", error->message);
-                       g_error_free(error);
+               result = g_dbus_proxy_call_sync(device_proxy, "IsConnectedProfile",
+                                       g_variant_new("(s)", uuid),
+                                       G_DBUS_CALL_FLAGS_NONE,
+                                       -1,
+                                       NULL,
+                                       &error);
+
+               if (result == NULL) {
+                       BT_ERR("Error occured in Proxy call");
+                       if (error) {
+                               BT_ERR("Error occured in Proxy call [%s]\n", error->message);
+                               g_error_free(error);
+                       }
+                       g_object_unref(device_proxy);
+                       return BLUETOOTH_ERROR_INTERNAL;
                }
-
-               *is_connected = val;
+               g_variant_get(result, "(b)", is_connected);
                g_free(uuid);
+               g_variant_unref(result);
        }
 
        g_object_unref(device_proxy);
        return BLUETOOTH_ERROR_NONE;
 }
 
+int _bt_get_connected_link(bluetooth_device_address_t *device_address,
+                       bluetooth_connected_link_t *connected)
+{
+       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+       char *object_path = NULL;
+
+       GDBusProxy *device_proxy;
+       GError *error = NULL;
+       GDBusConnection *conn;
+       GVariant *tmp_value = NULL;
+       GVariant *value = NULL;
+       GVariant *result = NULL;
+
+       int ret = BLUETOOTH_ERROR_NONE;
+
+       BT_CHECK_PARAMETER(device_address, return);
+
+       conn = _bt_get_system_gconn();
+       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       _bt_convert_addr_type_to_string(address, device_address->addr);
+
+       object_path = _bt_get_device_object_path(address);
+       retv_if(object_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
+
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL, BT_BLUEZ_NAME,
+                                                               object_path, BT_PROPERTIES_INTERFACE,  NULL, NULL);
+       g_free(object_path);
+       if (device_proxy == NULL) {
+               *connected = BLUETOOTH_CONNECTED_LINK_NONE;
+               return BLUETOOTH_ERROR_NONE;
+       }
+
+       result = g_dbus_proxy_call_sync(device_proxy, "GetAll",
+                                       g_variant_new("(s)", BT_DEVICE_INTERFACE),
+                                       G_DBUS_CALL_FLAGS_NONE,
+                                       -1,
+                                       NULL,
+                                       &error);
+
+       if (error != NULL) {
+               BT_ERR("Error occured in Proxy call [%s]\n", error->message);
+               g_error_free(error);
+               g_object_unref(device_proxy);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       g_variant_get(result , "(@a{sv})", &value);
+       g_variant_unref(result);
+
+       tmp_value = g_variant_lookup_value (value, "Connected", G_VARIANT_TYPE_BOOLEAN);
+       if (tmp_value != NULL) {
+               g_object_unref(device_proxy);
+               g_variant_unref(value);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+       *connected = g_variant_get_boolean (tmp_value);
+       g_variant_unref(tmp_value);
+       g_variant_unref(value);
+       g_object_unref(device_proxy);
+
+       return ret;
+}
+
 int _bt_connect_le_device(const bluetooth_device_address_t *bd_addr, gboolean auto_connect)
 {
        char device_address[BT_ADDRESS_STRING_SIZE] = { 0 };
        gchar *device_path = NULL;
        GError *error = NULL;
-       DBusGProxy *device_proxy = NULL;
-       DBusGProxy *adapter_proxy;
-       DBusGConnection *conn;
+       GDBusProxy *device_proxy = NULL;
+       GDBusProxy *adapter_proxy;
+       GDBusConnection *conn;
        int ret = BLUETOOTH_ERROR_NONE;
 
        BT_CHECK_PARAMETER(bd_addr, return);
@@ -1569,14 +1705,19 @@ int _bt_connect_le_device(const bluetooth_device_address_t *bd_addr, gboolean au
 
        retv_if(device_path == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               device_path, BT_DEVICE_INTERFACE);
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL, BT_BLUEZ_NAME,
+                                                               device_path, BT_DEVICE_INTERFACE,  NULL, NULL);
        g_free(device_path);
        retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call(device_proxy, "ConnectLE", &error,
-                       G_TYPE_BOOLEAN, auto_connect, G_TYPE_INVALID,
-                       G_TYPE_INVALID);
+       g_dbus_proxy_call_sync(device_proxy, "ConnectLE",
+                                g_variant_new("(b)", auto_connect),
+                                G_DBUS_CALL_FLAGS_NONE,
+                                -1,
+                                NULL,
+                                &error);
+
        if (error) {
                BT_ERR("ConnectLE Call Error %s[%s]", error->message, device_address);
                g_error_free(error);
@@ -1594,9 +1735,9 @@ int _bt_disconnect_le_device(const bluetooth_device_address_t *bd_addr)
        char device_address[BT_ADDRESS_STRING_SIZE] = { 0 };
        gchar *device_path = NULL;
        GError *error = NULL;
-       DBusGProxy *device_proxy = NULL;
-       DBusGProxy *adapter_proxy;
-       DBusGConnection *conn;
+       GDBusProxy *device_proxy = NULL;
+       GDBusProxy *adapter_proxy;
+       GDBusConnection *conn;
        int ret = BLUETOOTH_ERROR_NONE;
 
        BT_CHECK_PARAMETER(bd_addr, return);
@@ -1619,12 +1760,18 @@ int _bt_disconnect_le_device(const bluetooth_device_address_t *bd_addr)
 
        retv_if(device_path == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               device_path, BT_DEVICE_INTERFACE);
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL, BT_BLUEZ_NAME,
+                                                               device_path, BT_DEVICE_INTERFACE,  NULL, NULL);
        g_free(device_path);
        retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call(device_proxy, "DisconnectLE", &error, G_TYPE_INVALID, G_TYPE_INVALID);
+       g_dbus_proxy_call_sync(device_proxy, "DisconnectLE",
+                               NULL,
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
        if (error) {
                BT_ERR("DisconnectLE Call Error %s[%s]", error->message, device_address);
                g_error_free(error);
@@ -1641,9 +1788,9 @@ int _bt_connect_profile(char *address, char *uuid,
                                                void *cb, gpointer func_data)
 {
        char *object_path;
-       DBusGProxy *proxy;
-       DBusGConnection *conn;
-       DBusGProxy *adapter_proxy;
+       GDBusProxy *proxy;
+       GDBusConnection *conn;
+       GDBusProxy *adapter_proxy;
        GError *error = NULL;
 
        conn = _bt_get_system_gconn();
@@ -1656,9 +1803,12 @@ int _bt_connect_profile(char *address, char *uuid,
                adapter_proxy = _bt_get_adapter_proxy();
                retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-               dbus_g_proxy_call(adapter_proxy, "CreateDevice", &error,
-                       G_TYPE_STRING, address,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
+               g_dbus_proxy_call_sync(adapter_proxy, "CreateDevice",
+                                        g_variant_new("(s)", address),
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
 
                if (error != NULL) {
                        BT_ERR("CreateDevice Fail: %s", error->message);
@@ -1669,20 +1819,20 @@ int _bt_connect_profile(char *address, char *uuid,
        }
        retv_if(object_path == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               object_path, BT_DEVICE_INTERFACE);
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL, BT_BLUEZ_NAME,
+                                                               object_path, BT_DEVICE_INTERFACE,  NULL, NULL);
        g_free(object_path);
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       if (!dbus_g_proxy_begin_call(proxy, "ConnectProfile",
-                       (DBusGProxyCallNotify)cb,
-                       func_data, NULL,
-                       G_TYPE_STRING, uuid,
-                       G_TYPE_INVALID)) {
-               BT_ERR("Connect Dbus Call Error");
-               g_object_unref(proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+       g_dbus_proxy_call(proxy, "ConnectProfile",
+                               g_variant_new("(s)", uuid),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               BT_MAX_DBUS_TIMEOUT,
+                               NULL,
+                               (GAsyncReadyCallback)cb,
+                               func_data);
+
        return BLUETOOTH_ERROR_NONE;
 }
 
@@ -1690,8 +1840,8 @@ int _bt_disconnect_profile(char *address, char *uuid,
                                                void *cb, gpointer func_data)
 {
        char *object_path;
-       DBusGProxy *proxy;
-       DBusGConnection *conn;
+       GDBusProxy *proxy;
+       GDBusConnection *conn;
 
        conn = _bt_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
@@ -1699,20 +1849,20 @@ int _bt_disconnect_profile(char *address, char *uuid,
        object_path = _bt_get_device_object_path(address);
        retv_if(object_path == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               object_path, BT_DEVICE_INTERFACE);
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL, BT_BLUEZ_NAME,
+                                                               object_path, BT_DEVICE_INTERFACE,  NULL, NULL);
        g_free(object_path);
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       if (!dbus_g_proxy_begin_call(proxy, "DisconnectProfile",
-                       (DBusGProxyCallNotify)cb,
-                       func_data, NULL,
-                       G_TYPE_STRING, uuid,
-                       G_TYPE_INVALID)) {
-               BT_ERR("Connect Dbus Call Error");
-               g_object_unref(proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+       g_dbus_proxy_call(proxy, "DisconnectProfile",
+                                       g_variant_new("(s)", uuid),
+                                       G_DBUS_CALL_FLAGS_NONE,
+                                       BT_MAX_DBUS_TIMEOUT,
+                                       NULL,
+                                       (GAsyncReadyCallback)cb,
+                                       func_data);
+
        return BLUETOOTH_ERROR_NONE;
 }
 
@@ -1720,7 +1870,7 @@ int _bt_enable_rssi(bluetooth_device_address_t *bd_addr, int link_type,
                int low_threshold, int in_range_threshold, int high_threshold)
 {
        int ret = BLUETOOTH_ERROR_NONE;
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        GError *error = NULL;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
 
@@ -1738,22 +1888,17 @@ int _bt_enable_rssi(bluetooth_device_address_t *bd_addr, int link_type,
        proxy = _bt_get_adapter_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       if (!dbus_g_proxy_call(proxy, "EnableRssi", &error,
-                               G_TYPE_STRING, address,
-                               G_TYPE_INT, link_type,
-                               G_TYPE_INT, low_threshold,
-                               G_TYPE_INT, in_range_threshold,
-                               G_TYPE_INT, high_threshold,
-                               G_TYPE_INVALID, G_TYPE_INVALID)) {
-               BT_ERR("Failed to Enable RSSI");
-               ret = BLUETOOTH_ERROR_INTERNAL;
-               if (error != NULL) {
-                               BT_ERR("Dbus Call Error:[%s]", error->message);
-                               g_error_free(error);
-                               ret = BLUETOOTH_ERROR_INTERNAL;
-               }
+       g_dbus_proxy_call_sync(proxy, "EnableRssi",
+                               g_variant_new("(siiii)", address, link_type, low_threshold, in_range_threshold, high_threshold),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
+       if (error != NULL) {
+                       BT_ERR("Dbus Call Error:[%s]", error->message);
+                       g_error_free(error);
+                       ret = BLUETOOTH_ERROR_INTERNAL;
        }
-
        return ret;
 }
 
@@ -1761,7 +1906,7 @@ int _bt_get_rssi_strength(bluetooth_device_address_t *bd_addr,
                                        int link_type)
 {
        int ret = BLUETOOTH_ERROR_NONE;
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        GError *error = NULL;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
 
@@ -1777,19 +1922,18 @@ int _bt_get_rssi_strength(bluetooth_device_address_t *bd_addr,
        proxy = _bt_get_adapter_proxy();
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       if (!dbus_g_proxy_call(proxy, "GetRssiStrength", &error,
-                               G_TYPE_STRING, address,
-                               G_TYPE_INT, link_type,
-                               G_TYPE_INVALID, G_TYPE_INVALID)) {
-               BT_ERR("Failed to get Raw RSSI");
-               ret = BLUETOOTH_ERROR_INTERNAL;
-               if (error != NULL) {
-                               BT_ERR("Dbus Call Error:[%s]", error->message);
-                               g_error_free(error);
-                               ret = BLUETOOTH_ERROR_INTERNAL;
-               }
-       }
+       g_dbus_proxy_call_sync(proxy, "GetRssiStrength",
+                               g_variant_new("(si)", address, link_type),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
 
+       if (error != NULL) {
+                       BT_ERR("Dbus Call Error:[%s]", error->message);
+                       g_error_free(error);
+                       ret = BLUETOOTH_ERROR_INTERNAL;
+       }
        return ret;
 }
 
@@ -1800,9 +1944,11 @@ int _bt_le_conn_update(unsigned char *device_address,
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        gchar *device_path = NULL;
        GError *error = NULL;
-       DBusGProxy *device_proxy = NULL;
-       DBusGConnection *conn;
+       GDBusProxy *device_proxy = NULL;
+       GDBusConnection *conn;
+       GVariant *reply;
        guint32 min, max, to;
+       guint32 min_supervision_to;
        int ret = BLUETOOTH_ERROR_NONE;
 
        BT_DBG("+");
@@ -1819,18 +1965,24 @@ int _bt_le_conn_update(unsigned char *device_address,
                goto fail;
        }
 
-       min = interval_min / BT_LE_CONN_INTERVAL_SPLIT;
-       max = interval_max / BT_LE_CONN_INTERVAL_SPLIT;
-
        if (time_out < BT_LE_CONN_SUPER_TO_MIN ||
                        time_out > BT_LE_CONN_SUPER_TO_MAX) {
                ret = BLUETOOTH_ERROR_INVALID_PARAM;
                goto fail;
        }
 
-       to = time_out / BT_LE_CONN_TO_SPLIT;
+       if (latency > BT_LE_CONN_SLAVE_LATENCY_MAX) {
+               ret = BLUETOOTH_ERROR_INVALID_PARAM;
+               goto fail;
+       }
 
-       if (latency > ((to / max) - 1)) {
+       /*
+        * The Supervision_Timeout in milliseconds shall be larger than
+        * (1 + Conn_Latency) * Conn_Interval_Max * 2,
+        * where Conn_Interval_Max is given in milliseconds.
+        */
+       min_supervision_to = (1 + latency) * interval_max * 2;
+       if (time_out <= min_supervision_to) {
                ret = BLUETOOTH_ERROR_INVALID_PARAM;
                goto fail;
        }
@@ -1854,26 +2006,34 @@ int _bt_le_conn_update(unsigned char *device_address,
                goto fail;
        }
 
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               device_path, BT_DEVICE_INTERFACE);
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL, BT_BLUEZ_NAME,
+                                                               device_path, BT_DEVICE_INTERFACE,  NULL, NULL);
+
        g_free(device_path);
        retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call(device_proxy, "LeConnUpdate", &error,
-                       G_TYPE_UINT, min,
-                       G_TYPE_UINT, max,
-                       G_TYPE_UINT, latency,
-                       G_TYPE_UINT, to,
-                       G_TYPE_INVALID, G_TYPE_INVALID);
-       if (error) {
-               BT_ERR("LeConnUpdate Call Error %s[%s]",
-                               error->message, address);
-               g_error_free(error);
-               g_object_unref(device_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+       min = interval_min / BT_LE_CONN_INTERVAL_SPLIT;
+       max = interval_max / BT_LE_CONN_INTERVAL_SPLIT;
+       to = time_out / BT_LE_CONN_TO_SPLIT;
+
+       reply = g_dbus_proxy_call_sync(device_proxy, "LeConnUpdate",
+                               g_variant_new("(uuuu)", min, max, latency, to),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               &error);
 
        g_object_unref(device_proxy);
+       BT_ERR("LeConnUpdate Call Error for %s", address);
+       if (reply == NULL) {
+               if (error) {
+                       BT_ERR("Error %s[%s]", error->message, address);
+                       g_error_free(error);
+                       return BLUETOOTH_ERROR_INTERNAL;
+               }
+       }
+       g_variant_unref(reply);
        BT_DBG("-");
 
 fail:
index 82efdb6..69555b5 100644 (file)
  *
  */
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus.h>
 #include <glib.h>
 #include <string.h>
 #include <dlog.h>
 #include <vconf.h>
 #include <vconf-internal-bt-keys.h>
-#if 0
 #include <journal/device.h>
-#endif
 
 #include "bluetooth-api.h"
 #include "bt-internal-types.h"
 #include "bt-service-agent.h"
 #include "bt-service-pbap.h"
 #include "bt-service-headset-connection.h"
+#include "bt-service-avrcp-controller.h"
+
 #include "bt-service-opp-client.h"
 
-static DBusGConnection *manager_conn = NULL;
-static DBusGConnection *obexd_conn = NULL;
-static GList *p_cache_list = NULL;
-static DBusGConnection *opc_obexd_conn = NULL;
+#define DBUS_TIMEOUT 20 * 1000 /* 20 Sec */
+static GDBusConnection *manager_conn;
+static GDBusConnection *obexd_conn;
+static GDBusConnection *opc_obexd_conn;
 
+static GList *p_cache_list = NULL;
 
 static guint event_id;
 guint nap_connected_device_count = 0;
@@ -63,12 +61,6 @@ static guint hid_connected_device_count = 0;
 static GList *p_adv_ind_list;
 
 typedef struct {
-       char *addr;
-       int data_len;
-       char *data;
-} bt_le_adv_info_t;
-
-typedef struct {
        bt_remote_dev_info_t *dev_info;
 } bt_cache_info_t;
 
@@ -86,11 +78,15 @@ typedef enum {
        OBEX_MAS = (1 << 8),
 } bluetooth_obex_connection_type_t;
 
-void _bt_handle_property_changed_event(DBusMessage *msg);
-void _bt_opc_property_changed_event(DBusMessage *msg);
-int _bt_register_service_event(DBusGConnection *g_conn, int event_type);
-void _bt_unregister_service_event(DBusGConnection *g_conn, int event_type);
+void _bt_handle_property_changed_event(GVariant *msg, const char *object_path);
+void _bt_opc_property_changed_event(GVariant *msg, char *path);
+int _bt_register_service_event(GDBusConnection *g_conn, int event_type);
+void _bt_unregister_service_event(GDBusConnection *g_conn, int event_type);
 void _bt_opp_client_event_deinit(void);
+void _bt_handle_network_client_event(GVariant *msg_iter,
+                               const char *path);
+void __bt_gatt_char_property_changed_event(GVariant *msg_iter,
+                               const char *path);
 
 static void __bt_free_bt_le_adv_info_t(bt_le_adv_info_t *adv_info)
 {
@@ -143,309 +139,135 @@ static void __bt_del_adv_ind_info(char *addr)
 static void __bt_free_cache_info(bt_cache_info_t *cache_info)
 {
        ret_if(cache_info == NULL);
-
        _bt_free_device_info(cache_info->dev_info);
        g_free(cache_info);
 }
 
-static gboolean __bt_parse_device_properties(DBusMessageIter *item_iter,
+static gboolean __bt_parse_device_properties(GVariant *item,
                                                bt_remote_dev_info_t *dev_info)
 {
-       BT_DBG("+");
-       DBusMessageIter value_iter;
-       char *value;
-
-       dbus_message_iter_recurse(item_iter, &value_iter);
-
-       if (dbus_message_iter_get_arg_type(&value_iter) != DBUS_TYPE_DICT_ENTRY) {
-               BT_DBG("No entry");
+       GVariantIter iter;
+       gchar *key;
+       GVariant *val;
+       gsize len = 0;
+       if (item == NULL)
                return FALSE;
-       }
-
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                                               DBUS_TYPE_DICT_ENTRY) {
-               char *key;
-               DBusMessageIter dict_entry;
-               DBusMessageIter iter_dict_val;
-
-               dbus_message_iter_recurse(&value_iter, &dict_entry);
-
-               dbus_message_iter_get_basic(&dict_entry, &key);
-
-               if (key == NULL) {
-                       dbus_message_iter_next(&value_iter);
-                       continue;
-               }
-
-               if (!dbus_message_iter_next(&dict_entry)) {
-                       dbus_message_iter_next(&value_iter);
-                       continue;
-               }
-               dbus_message_iter_recurse(&dict_entry, &iter_dict_val);
-
-               if (dev_info) {
-                       if (strcasecmp(key, "Address") == 0) {
-                               const char *address = NULL;
-                               dbus_message_iter_get_basic(&iter_dict_val, &address);
-                               dev_info->address = g_strdup(address);
-                       } else if (strcasecmp(key, "Class") == 0) {
-                               dbus_message_iter_get_basic(&iter_dict_val, &dev_info->class);
-                       } else if (strcasecmp(key, "Name") == 0) {
-                               dbus_message_iter_get_basic(&iter_dict_val, &value);
-                               if (dev_info->name == NULL)
-                                       dev_info->name = g_strdup(value);
-                       } else if (strcasecmp(key, "Connected") == 0) {
-                               dbus_message_iter_get_basic(&iter_dict_val,
-                                               &dev_info->connected);
-                       } else if (strcasecmp(key, "Paired") == 0) {
-                               dbus_message_iter_get_basic(&iter_dict_val,
-                                               &dev_info->paired);
-                       } else if (strcasecmp(key, "Trusted") == 0) {
-                               dbus_message_iter_get_basic(&iter_dict_val,
-                                               &dev_info->trust);
-                       } else if (strcasecmp(key, "RSSI") == 0) {
-                               dbus_message_iter_get_basic(&iter_dict_val,
-                                               &dev_info->rssi);
-                       } else if (strcasecmp(key, "LastAddrType") == 0) {
-                               dbus_message_iter_get_basic(&iter_dict_val,
-                                               &dev_info->addr_type);
-                       } else if (strcasecmp(key, "UUIDs") == 0) {
-                               DBusMessageIter uuid_iter;
-                               DBusMessageIter tmp_iter;
-                               int i = 0;
-
-                               dbus_message_iter_recurse(&iter_dict_val, &uuid_iter);
-
-                               tmp_iter = uuid_iter;
-
-                               /* Store the uuid count */
-                               while (dbus_message_iter_get_arg_type(&tmp_iter) != DBUS_TYPE_INVALID) {
-                                       dbus_message_iter_get_basic(&tmp_iter,
-                                                       &value);
 
+       g_variant_iter_init(&iter, item);
+       while (g_variant_iter_loop(&iter, "{sv}", &key, &val)) {
+               if (strcasecmp(key, "Address") == 0)  {
+                       dev_info->address = g_variant_dup_string(val, &len);
+               } else if (strcasecmp(key, "Class") == 0) {
+                       dev_info->class = g_variant_get_uint32(val);
+               } else if (strcasecmp(key, "name") == 0) {
+                       if (dev_info->name == NULL)
+                               dev_info->name = g_variant_dup_string(val, &len);
+               } else if (strcasecmp(key, "Connected") == 0) {
+                       dev_info->connected = g_variant_get_uint32(val);
+               } else if (strcasecmp(key, "paired") == 0) {
+                       dev_info->paired = g_variant_get_boolean(val);
+               } else if (strcasecmp(key, "Trusted") == 0) {
+                       dev_info->trust = g_variant_get_boolean(val);
+               } else if (strcasecmp(key, "RSSI") == 0) {
+                       dev_info->rssi = g_variant_get_int16(val);
+               } else if (strcasecmp(key, "LastAddrType") == 0) {
+                       dev_info->addr_type = g_variant_get_byte(val);
+               } else if (strcasecmp(key, "UUIDs") == 0) {
+                       char **uuid_value;
+                       gsize size = 0;
+                       int i =0;
+                       size = g_variant_get_size(val);
+
+                       if (size > 0) {
+                               uuid_value = (char **)g_variant_get_strv(val, &size);
+                               if (dev_info->uuids == NULL)
+                                       dev_info->uuids = g_malloc0(sizeof(char *) * size);
+
+                               for (i = 0; uuid_value[i] != NULL; i++) {
                                        dev_info->uuid_count++;
-                                       if (!dbus_message_iter_next(&tmp_iter))
-                                               break;
-                               }
-
-                               /* Store the uuids */
-                               if (dev_info->uuid_count > 0) {
-                                       dev_info->uuids = g_new0(char *,
-                                                       dev_info->uuid_count + 1);
-                               } else {
-                                       dbus_message_iter_next(&value_iter);
-                                       continue;
-                               }
-
-                               while (dbus_message_iter_get_arg_type(&uuid_iter) != DBUS_TYPE_INVALID) {
-                                       dbus_message_iter_get_basic(&uuid_iter,
-                                                       &value);
-                                       dev_info->uuids[i] = g_strdup(value);
-                                       i++;
-                                       if (!dbus_message_iter_next(&uuid_iter)) {
-                                               break;
-                                       }
-                               }
-                       } else if (strcasecmp(key, "ManufacturerDataLen") == 0) {
-                               dbus_message_iter_get_basic(&iter_dict_val,
-                                                                       &dev_info->manufacturer_data_len);
-
-                               if (dev_info->manufacturer_data_len > BLUETOOTH_MANUFACTURER_DATA_LENGTH_MAX) {
-                                       BT_ERR("manufacturer_data_len is too long(len = %d)", dev_info->manufacturer_data_len);
-                                       dev_info->manufacturer_data_len = BLUETOOTH_MANUFACTURER_DATA_LENGTH_MAX;
+                                       dev_info->uuids[i] = g_strdup(uuid_value[i]);
                                }
+                               g_free(uuid_value);
+                       }
+               } else if (strcasecmp(key, "ManufacturerDataLen") == 0) {
+                       g_variant_get(val, "(i)", &dev_info->manufacturer_data_len);
+                       if (dev_info->manufacturer_data_len > BLUETOOTH_MANUFACTURER_DATA_LENGTH_MAX) {
+                               BT_ERR("manufacturer_data_len is too long(len = %d)", dev_info->manufacturer_data_len);
+                               dev_info->manufacturer_data_len = BLUETOOTH_MANUFACTURER_DATA_LENGTH_MAX;
+                       }
 
-                               if (dev_info->manufacturer_data_len == 0)
-                                       dev_info->manufacturer_data = g_strdup("");
-                       } else if (strcasecmp(key, "ManufacturerData") == 0) {
-                               DBusMessageIter manufacturer_iter;
-                               int i = 0;
-                               int len = 0;
-                               char *manufacturer_data = NULL;
-                               char byte = 0;
-
-                               dbus_message_iter_recurse(&iter_dict_val, &manufacturer_iter);
-                               len = dbus_message_iter_get_array_len(&manufacturer_iter);
-
+                       if (dev_info->manufacturer_data_len == 0)
+                               dev_info->manufacturer_data = g_strdup("");
+               } else if (strcasecmp(key, "ManufacturerData") == 0) {
+                       int len = 0;
+                       GVariant *manufacturer_var;
+                       g_variant_get(val, "@ay", &manufacturer_var);
+                       len = g_variant_get_size(manufacturer_var);
+                       if (len > 0) {
+                               char *manufacturer_data = (char *)g_variant_get_data(manufacturer_var);
                                dev_info->manufacturer_data = g_malloc0(len);
-                               manufacturer_data = dev_info->manufacturer_data;
-
-                               while (dbus_message_iter_get_arg_type(&manufacturer_iter) == DBUS_TYPE_BYTE) {
-                                       dbus_message_iter_get_basic(&manufacturer_iter, &byte);
-                                       manufacturer_data[i] = byte;
-                                       i++;
-                                       dbus_message_iter_next(&manufacturer_iter);
-                               }
+                               memcpy(dev_info->manufacturer_data, manufacturer_data,
+                                       len);
                        }
+                       g_variant_unref(manufacturer_var);
                }
-
-               dbus_message_iter_next(&value_iter);
        }
 
        BT_DBG("-");
        return TRUE;
 }
 
-static gboolean __bt_parse_interface(DBusMessage *msg,
+static gboolean __bt_parse_interface(GVariant *msg,
                                        bt_remote_dev_info_t *dev_info)
 {
-       BT_DBG("+");
-
-       DBusMessageIter msg_iter;
-       DBusMessageIter value_iter;
-       char *object_path = NULL;
-
-       retv_if(dbus_message_iter_init(msg, &msg_iter) == FALSE, FALSE);
-
-       dbus_message_iter_get_basic(&msg_iter, &object_path);
-       retv_if(object_path == NULL, FALSE);
-
-       /* object array (oa) */
-       retv_if(dbus_message_iter_next(&msg_iter) == FALSE, FALSE);
-       retv_if(dbus_message_iter_get_arg_type(&msg_iter) !=
-                               DBUS_TYPE_ARRAY, FALSE);
-
-       dbus_message_iter_recurse(&msg_iter, &value_iter);
-
-       /* string array (sa) */
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                                       DBUS_TYPE_DICT_ENTRY) {
-               char *interface_name = NULL;
-               DBusMessageIter interface_iter;
-
-               dbus_message_iter_recurse(&value_iter, &interface_iter);
-
-               retv_if(dbus_message_iter_get_arg_type(&interface_iter) !=
-                       DBUS_TYPE_STRING, FALSE);
-
-               dbus_message_iter_get_basic(&interface_iter, &interface_name);
-
-               retv_if(dbus_message_iter_next(&interface_iter) == FALSE, FALSE);
-
-               retv_if(dbus_message_iter_get_arg_type(&interface_iter) !=
-                       DBUS_TYPE_ARRAY, FALSE);
-
-               BT_DBG("interface: %s", interface_name);
-
-               if (g_strcmp0(interface_name, "org.bluez.Device1") == 0) {
-                       BT_DBG("Found a device: %s", object_path);
-
-                       if (__bt_parse_device_properties(&interface_iter,
-                                       dev_info) == FALSE) {
+       char *path = NULL;
+       GVariant *optional_param;
+       GVariantIter iter;
+       GVariant *child;
+       char *interface_name= NULL;
+       GVariant *inner_iter = NULL;
+       g_variant_get(msg, "(&o@a{sa{sv}})",
+                                       &path, &optional_param);
+       g_variant_iter_init(&iter, optional_param);
+
+       while ((child = g_variant_iter_next_value(&iter))) {
+               g_variant_get(child,"{&s@a{sv}}", &interface_name, &inner_iter);
+               if (g_strcmp0(interface_name, BT_DEVICE_INTERFACE) == 0) {
+                       BT_DBG("Found a device: %s", path);
+                       if (__bt_parse_device_properties(inner_iter,
+                               dev_info) == FALSE) {
+                               g_variant_unref(inner_iter);
+                               g_variant_unref(child);
+                               g_variant_unref(optional_param);
                                BT_ERR("Fail to parse the properies");
                                return FALSE;
                        } else {
+                               g_variant_unref(inner_iter);
+                               g_variant_unref(child);
+                               g_variant_unref(optional_param);
                                return TRUE;
                        }
                }
-
-               dbus_message_iter_next(&value_iter);
+               g_variant_unref(inner_iter);
+       g_variant_unref(child);
        }
-
-       BT_DBG("-");
+       if (optional_param)
+               g_variant_unref(optional_param);
 
        return FALSE;
 }
 
-char *__bt_get_headset_name(char *address)
-{
-       bluetooth_device_address_t device_address = { {0} };
-       bluetooth_device_info_t dev_info;
-
-       retv_if(address == NULL, strdup(""));
-
-       _bt_convert_addr_string_to_type(device_address.addr, address);
-
-       memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
-
-       _bt_get_bonded_device_info(&device_address, &dev_info);
-
-       return g_strdup(dev_info.device_name.name);
-}
-
-static int __bt_get_owner_info(DBusMessage *msg, char **name,
+static int __bt_get_owner_info(GVariant *msg, char **name,
                                char **previous, char **current)
 {
-       DBusMessageIter item_iter;
-
-       dbus_message_iter_init(msg, &item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, name);
-
-       retv_if(*name == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_message_iter_next(&item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, previous);
-
-       retv_if(*previous == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_message_iter_next(&item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, current);
-
-       retv_if(*current == NULL, BLUETOOTH_ERROR_INTERNAL);
-
+       g_variant_get(msg, "(sss)", name, previous, current);
        return BLUETOOTH_ERROR_NONE;
 }
 
-static int __bt_get_agent_signal_info(DBusMessage *msg, char **address,
+static int __bt_get_agent_signal_info(GVariant *msg, char **address,
                                char **name, char **uuid)
 {
-       BT_DBG("+");
-
-       DBusMessageIter item_iter;
-
-       dbus_message_iter_init(msg, &item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, address);
-
-       dbus_message_iter_next(&item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, name);
-
-       dbus_message_iter_next(&item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, uuid);
-
-       BT_DBG("-");
-
+       g_variant_get(msg, "(sss)", address, name, uuid);
        return BLUETOOTH_ERROR_NONE;
 }
 
@@ -471,7 +293,7 @@ gboolean _bt_discovery_finished_cb(gpointer user_data)
 {
        int result = BLUETOOTH_ERROR_NONE;
        event_id = 0;
-
+       GVariant *param = NULL;
        if (_bt_get_discovering_property(DISCOVERY_ROLE_BREDR) == FALSE) {
                if (_bt_get_cancel_by_user() == TRUE) {
                        result = BLUETOOTH_ERROR_CANCEL_BY_USER;
@@ -479,59 +301,31 @@ gboolean _bt_discovery_finished_cb(gpointer user_data)
 
                _bt_set_cancel_by_user(FALSE);
                _bt_set_discovery_status(FALSE);
+               param = g_variant_new("(i)", result);
                _bt_send_event(BT_ADAPTER_EVENT,
                        BLUETOOTH_EVENT_DISCOVERY_FINISHED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_INVALID);
+                       param);
        }
 
        return FALSE;
 }
 
-gboolean _bt_stop_discovery_timeout_cb(gpointer user_data)
-{
-       DBusGProxy *adapter_proxy;
-
-       event_id = 0;
-
-       adapter_proxy = _bt_get_adapter_proxy();
-       retv_if(adapter_proxy == NULL, FALSE);
-
-       /* Need to stop searching */
-       dbus_g_proxy_call(adapter_proxy,
-                               "StopDiscovery",
-                               NULL,
-                               G_TYPE_INVALID,
-                               G_TYPE_INVALID);
-
-       return FALSE;
-}
-
-void _bt_stop_discovery_timeout(void)
-{
-       if (event_id > 0)
-               return;
-
-       event_id = g_timeout_add(BT_STOP_DISCOVERY_TIMEOUT,
-               (GSourceFunc)_bt_stop_discovery_timeout_cb, NULL);
-}
-
 static gboolean __bt_le_discovery_finished_cb(gpointer user_data)
 {
        int result = BLUETOOTH_ERROR_NONE;
        event_id = 0;
-
+       GVariant *param = NULL;
        if (_bt_get_discovering_property(DISCOVERY_ROLE_LE) == FALSE) {
                if (_bt_get_cancel_by_user() == TRUE) {
                        result = BLUETOOTH_ERROR_CANCEL_BY_USER;
                }
 
                _bt_set_cancel_by_user(FALSE);
-               _bt_set_le_discovery_status(FALSE);
+               _bt_set_le_scan_status(FALSE);
+               param = g_variant_new("(i)", result);
                _bt_send_event(BT_LE_ADAPTER_EVENT,
                        BLUETOOTH_EVENT_LE_DISCOVERY_FINISHED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_INVALID);
+                       param);
        }
 
        return FALSE;
@@ -578,7 +372,7 @@ static void __bt_device_remote_connected_properties(
 {
        int result = BLUETOOTH_ERROR_NONE;
        int i;
-
+       GVariant *param = NULL;
        BT_DBG("+");
 
        if (remote_dev_info->uuid_count > 0 ) {
@@ -590,11 +384,10 @@ static void __bt_device_remote_connected_properties(
                                event = (connected == TRUE) ?
                                        BLUETOOTH_HID_CONNECTED :
                                        BLUETOOTH_HID_DISCONNECTED;
-
+                               param = g_variant_new("(is)", result,
+                                                       address);
                                _bt_send_event(BT_HID_EVENT, event,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &address,
-                                       DBUS_TYPE_INVALID);
+                                       param);
                                break;
                        }
                }
@@ -603,18 +396,16 @@ static void __bt_device_remote_connected_properties(
        BT_DBG("-");
 }
 
-void _bt_handle_adapter_event(DBusMessage *msg)
+void _bt_handle_adapter_event(GVariant *msg, const char *member)
 {
        BT_DBG("+");
 
        int result = BLUETOOTH_ERROR_NONE;
-       DBusMessageIter item_iter;
-       const char *member = dbus_message_get_member(msg);
-
+       GVariant *param = NULL;
        ret_if(member == NULL);
 
        if (strcasecmp(member, "DeviceCreated") == 0) {
-               const char *object_path = NULL;
+               char *object_path = NULL;
                char *address;
                bt_remote_dev_info_t *remote_dev_info;
 
@@ -623,11 +414,8 @@ void _bt_handle_adapter_event(DBusMessage *msg)
                /* Bonding from remote device */
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
 
-               dbus_message_iter_init(msg, &item_iter);
-               dbus_message_iter_get_basic(&item_iter, &object_path);
-               dbus_message_iter_next(&item_iter);
-
-               _bt_convert_device_path_to_address(object_path, address);
+               g_variant_get(msg, "(&o)", &object_path);
+               _bt_convert_device_path_to_address((const char*)object_path, address);
 
                remote_dev_info = _bt_get_remote_device_info(address);
                if (remote_dev_info == NULL) {
@@ -638,7 +426,7 @@ void _bt_handle_adapter_event(DBusMessage *msg)
                _bt_free_device_info(remote_dev_info);
                g_free(address);
        } else if (strcasecmp(member, "InterfacesRemoved") == 0) {
-               const char *object_path = NULL;
+               char *object_path = NULL;
                char *address;
                bt_cache_info_t *cache_info;
                bt_remote_dev_info_t *dev_info;
@@ -646,18 +434,13 @@ void _bt_handle_adapter_event(DBusMessage *msg)
 
                /* Bonding from remote device */
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
+               g_variant_get(msg, "(&o)", &object_path);
 
-               dbus_message_iter_init(msg, &item_iter);
-               dbus_message_iter_get_basic(&item_iter, &object_path);
-               dbus_message_iter_next(&item_iter);
-
-               _bt_convert_device_path_to_address(object_path, address);
+               /* Fix : NULL_RETURNS */
+               if (address == NULL)
+                       return;
 
-               _bt_send_event(BT_ADAPTER_EVENT,
-                       BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &address,
-                       DBUS_TYPE_INVALID);
+               _bt_convert_device_path_to_address((const char *)object_path, address);
 
                node = g_list_first(p_cache_list);
 
@@ -679,19 +462,16 @@ void _bt_handle_adapter_event(DBusMessage *msg)
                        }
                        node = g_list_next(node);
                }
-
                g_free(address);
        } else if (strcasecmp(member, "AdvertisingEnabled") == 0) {
                BT_DBG("Advertising Enabled");
                int slot_id;
                const char *sender;
+               int event;
+               int adv_handle;
                gboolean status = FALSE;
 
-               dbus_message_iter_init(msg, &item_iter);
-
-               dbus_message_iter_get_basic(&item_iter, &slot_id);
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_get_basic(&item_iter, &status);
+               g_variant_get(msg, "(ib)", &slot_id, &status);
 
                BT_DBG("Advertising Enabled : slot_id [%d]  status [%d]", slot_id, status);
 
@@ -699,93 +479,65 @@ void _bt_handle_adapter_event(DBusMessage *msg)
                _bt_set_advertising_status(slot_id, status);
 
                sender = _bt_get_adv_slot_owner(slot_id);
-               if (status) {
-                       bluetooth_advertising_params_t adv_params = {0, };
-
-                       _bt_get_advertising_params(&adv_params);
-                       _bt_send_event_to_dest(sender, BT_ADAPTER_EVENT,
-                                       BLUETOOTH_EVENT_ADVERTISING_STARTED,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_DOUBLE, &adv_params.interval_min,
-                                       DBUS_TYPE_DOUBLE, &adv_params.interval_max,
-                                       DBUS_TYPE_INVALID);
-               } else {
-                       _bt_send_event_to_dest(sender, BT_ADAPTER_EVENT,
-                                       BLUETOOTH_EVENT_ADVERTISING_STOPPED,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_INVALID);
-               }
+               adv_handle = _bt_get_adv_slot_adv_handle(slot_id);
+
+               if (status)
+                       event = BLUETOOTH_EVENT_ADVERTISING_STARTED;
+               else
+                       event = BLUETOOTH_EVENT_ADVERTISING_STOPPED;
+               param = g_variant_new("(ii)", result,
+                                       adv_handle);
+               _bt_send_event_to_dest(sender, BT_ADAPTER_EVENT,
+                               event,
+                               param);
+
+               if (event == BLUETOOTH_EVENT_ADVERTISING_STOPPED)
+                       __bt_unregister_adv_slot_owner(slot_id);
        } else if (strcasecmp(member, "RssiEnabled") == 0) {
                BT_DBG("RSSI Enabled");
                gboolean status = FALSE;
                char *address = NULL;
                int link_type;
-
-               dbus_message_iter_init(msg, &item_iter);
-               dbus_message_iter_get_basic(&item_iter, &address);
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_get_basic(&item_iter, &link_type);
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_get_basic(&item_iter, &status);
+               g_variant_get(msg,"(sib)", &address, &link_type, &status);
 
                BT_DBG("RSSI Enabled [%s %d]", address, status);
+               param = g_variant_new("(isib)", result,
+                                       address, link_type, status);
                _bt_send_event(BT_DEVICE_EVENT,
                                BLUETOOTH_EVENT_RSSI_ENABLED,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &address,
-                               DBUS_TYPE_INT32, &link_type,
-                               DBUS_TYPE_BOOLEAN, &status,
-                               DBUS_TYPE_INVALID);
+                               param);
+               g_free(address);
        } else if (strcasecmp(member, "RssiAlert") == 0) {
                BT_DBG("RSSI Alert");
                int alert_type;
                int rssi_dbm;
                int link_type;
                char *address = NULL;
-
-               dbus_message_iter_init(msg, &item_iter);
-               dbus_message_iter_get_basic(&item_iter, &address);
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_get_basic(&item_iter, &link_type);
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_get_basic(&item_iter, &alert_type);
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_get_basic(&item_iter, &rssi_dbm);
+               g_variant_get(msg,"(siii)", &address, &link_type, &alert_type, &rssi_dbm);
 
                BT_DBG("RSSI Alert: [Address %s LinkType %d] [Type %d DBM %d]",
                                address, alert_type, rssi_dbm);
-
+               param = g_variant_new("(isiii)", result,
+                                       address, link_type, alert_type, rssi_dbm);
                _bt_send_event(BT_DEVICE_EVENT,
                                BLUETOOTH_EVENT_RSSI_ALERT,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &address,
-                               DBUS_TYPE_INT32, &link_type,
-                               DBUS_TYPE_INT32, &alert_type,
-                               DBUS_TYPE_INT32, &rssi_dbm,
-                               DBUS_TYPE_INVALID);
+                               param);
+               g_free(address);
        } else if (strcasecmp(member, "RawRssi") == 0) {
                BT_DBG("RSSI Raw");
                int rssi_dbm;
                int link_type;
                char *address = NULL;
-
-               dbus_message_iter_init(msg, &item_iter);
-               dbus_message_iter_get_basic(&item_iter, &address);
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_get_basic(&item_iter, &link_type);
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_get_basic(&item_iter, &rssi_dbm);
+               g_variant_get(msg,"(sii)", &address, &link_type, &rssi_dbm);
 
                BT_DBG("Raw RSSI: [Address %s] [Link Type %d][RSSI DBM %d]",
                                address, link_type, rssi_dbm);
-
+               param = g_variant_new("(isii)", result,
+                                       address, link_type, rssi_dbm);
                _bt_send_event(BT_DEVICE_EVENT,
                                BLUETOOTH_EVENT_RAW_RSSI,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &address,
-                               DBUS_TYPE_INT32, &link_type,
-                               DBUS_TYPE_INT32, &rssi_dbm,
-                               DBUS_TYPE_INVALID);
+                               param);
+               g_free(address);
        } else if (strcasecmp(member, BT_HARDWARE_ERROR) == 0) {
                BT_ERR_C("Hardware error received from BLUEZ");
                _bt_recover_adapter();
@@ -796,65 +548,62 @@ void _bt_handle_adapter_event(DBusMessage *msg)
        BT_DBG("-");
 }
 
-static void __bt_adapter_property_changed_event(DBusMessageIter *msg_iter, const char *path)
+static void __bt_adapter_property_changed_event(GVariant *msg, const char *path)
 {
-       DBusGProxy *adapter_proxy;
+       GDBusProxy *adapter_proxy;
        int mode = 0;
        int result = BLUETOOTH_ERROR_NONE;
-       DBusMessageIter value_iter;
-       DBusMessageIter dict_iter;
-       DBusMessageIter item_iter;
-       GValue timeout = { 0 };
-       const char *property = NULL;
-
-       dbus_message_iter_recurse(msg_iter, &item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_DICT_ENTRY) {
-               BT_ERR("This is bad format dbus");
-               return;
-       }
-
-       do {
-               dbus_message_iter_recurse(&item_iter, &dict_iter);
-
-               dbus_message_iter_get_basic(&dict_iter, &property);
-               ret_if(property == NULL);
-
-               ret_if(!dbus_message_iter_next(&dict_iter));
+       GVariantIter value_iter;
+       GVariant *val = NULL;
+       GError *err = NULL;
+       char *property = NULL;
+       GVariant *param = NULL;
+       g_variant_iter_init (&value_iter, msg);
+       while ((g_variant_iter_loop (&value_iter,"{sv}", &property, &val))) {
+               BT_INFO("Property %s", property);
 
                if (strcasecmp(property, "Discovering") == 0) {
                        gboolean discovering = FALSE;
-
-                       dbus_message_iter_recurse(&dict_iter, &value_iter);
-                       dbus_message_iter_get_basic(&value_iter, &discovering);
-
+                       g_variant_get(val, "b", &discovering);
                        /* Send event to application */
+                       BT_DBG("Discovering %d", discovering);
                        if (discovering == TRUE) {
                                _bt_set_discovery_status(TRUE);
+                               param = g_variant_new("(i)", result);
                                _bt_send_event(BT_ADAPTER_EVENT,
                                        BLUETOOTH_EVENT_DISCOVERY_STARTED,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_INVALID);
+                                       param);
                        } else {
-                               if (event_id > 0){
-                                       g_source_remove(event_id);
-                                       event_id = 0;
+                               ret_if(event_id > 0);
+
+                               adapter_proxy = _bt_get_adapter_proxy();
+                               ret_if(adapter_proxy == NULL);
+
+                               /* Need to stop searching */
+                               g_dbus_proxy_call_sync(adapter_proxy, "StopDiscovery",
+                                       NULL,
+                                       G_DBUS_CALL_FLAGS_NONE,
+                                       DBUS_TIMEOUT, NULL,
+                                       &err);
+                               if (err) {
+                                       BT_ERR("Dbus Error : %s", err->message);
+                                       g_clear_error(&err);
                                }
+
+                               event_id = g_timeout_add(BT_DISCOVERY_FINISHED_DELAY,
+                                 (GSourceFunc)_bt_discovery_finished_cb, NULL);
                        }
                } else if (strcasecmp(property, "LEDiscovering") == 0) {
                        gboolean le_discovering = FALSE;
 
-                       dbus_message_iter_recurse(&dict_iter, &value_iter);
-                       dbus_message_iter_get_basic(&value_iter, &le_discovering);
-
+                       g_variant_get(val, "b", &le_discovering);
                        /* Send event to application */
                        if (le_discovering == TRUE) {
-                               _bt_set_le_discovery_status(TRUE);
+                               _bt_set_le_scan_status(TRUE);
+                               param = g_variant_new("(i)", result);
                                _bt_send_event(BT_LE_ADAPTER_EVENT,
-                                       BLUETOOTH_EVENT_LE_DISCOVERY_STARTED,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_INVALID);
+                               BLUETOOTH_EVENT_LE_DISCOVERY_STARTED,
+                               param);
                        } else {
                                ret_if(event_id > 0);
 
@@ -862,214 +611,221 @@ static void __bt_adapter_property_changed_event(DBusMessageIter *msg_iter, const
                                ret_if(adapter_proxy == NULL);
 
                                /* Need to stop searching */
-                               dbus_g_proxy_call(adapter_proxy,
-                                                       "LEStopDiscovery",
-                                                       NULL,
-                                                       G_TYPE_INVALID,
-                                                       G_TYPE_INVALID);
+                               g_dbus_proxy_call_sync(adapter_proxy, "StopLEDiscovery",
+                                       NULL,
+                                       G_DBUS_CALL_FLAGS_NONE,
+                                       DBUS_TIMEOUT, NULL,
+                                       &err);
+                               if (err) {
+                                       BT_ERR("Dbus Error %s", err->message);
+                                       g_clear_error(&err);
+                               }
 
                                event_id = g_timeout_add(BT_DISCOVERY_FINISHED_DELAY,
-                                                 (GSourceFunc)__bt_le_discovery_finished_cb, NULL);
-                       }
+                                               (GSourceFunc)__bt_le_discovery_finished_cb, NULL);
+                               }
                } else if (strcasecmp(property, "Name") == 0) {
                        char *name = NULL;
-
-                       dbus_message_iter_recurse(&dict_iter, &value_iter);
-                       dbus_message_iter_get_basic(&value_iter, &name);
-
+                       g_variant_get(val, "s", &name);
+                       param = g_variant_new("(is)", result, name);
                        /* Send event to application */
                        _bt_send_event(BT_ADAPTER_EVENT,
-                                       BLUETOOTH_EVENT_LOCAL_NAME_CHANGED,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &name,
-                                       DBUS_TYPE_INVALID);
+                               BLUETOOTH_EVENT_LOCAL_NAME_CHANGED,
+                               param);
+                       g_free(name);
                } else if (strcasecmp(property, "Alias") == 0) {
                        char *alias = NULL;
-
-                       dbus_message_iter_recurse(&dict_iter, &value_iter);
-                       dbus_message_iter_get_basic(&value_iter, &alias);
-
+                       g_variant_get(val, "s", &alias);
+                       param = g_variant_new("(is)", result, alias);
                        /* Send event to application */
                        _bt_send_event(BT_ADAPTER_EVENT,
-                                       BLUETOOTH_EVENT_LOCAL_NAME_CHANGED,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &alias,
-                                       DBUS_TYPE_INVALID);
+                               BLUETOOTH_EVENT_LOCAL_NAME_CHANGED,
+                               param);
+                       g_free(alias);
                } else if (strcasecmp(property, "Discoverable") == 0) {
                        gboolean discoverable = FALSE;
 
-                       dbus_message_iter_recurse(&dict_iter, &value_iter);
-                       dbus_message_iter_get_basic(&value_iter, &discoverable);
+                       g_variant_get(val, "b", &discoverable);
+                       BT_DBG("discoverable %d", discoverable);
 
                        if (discoverable == FALSE) {
                                if (_bt_get_discoverable_timeout_property() > 0) {
-                                       g_value_init(&timeout, G_TYPE_UINT);
-                                       g_value_set_uint(&timeout, 0);
-
+                                       int time = 0;
                                        adapter_proxy = _bt_get_adapter_properties_proxy();
                                        ret_if(adapter_proxy == NULL);
-
-                                       dbus_g_proxy_call_no_reply(adapter_proxy, "Set",
-                                                       G_TYPE_STRING, BT_ADAPTER_INTERFACE,
-                                                       G_TYPE_STRING, "DiscoverableTimeout",
-                                                       G_TYPE_VALUE, &timeout,
-                                                       G_TYPE_INVALID);
-
-                                       g_value_unset(&timeout);
+                                       g_dbus_proxy_call_sync(adapter_proxy, "Set",
+                                       g_variant_new("(ssv)", BT_ADAPTER_INTERFACE,
+                                               "DiscoverableTimeout",
+                                               g_variant_new("i", time)),
+                                       G_DBUS_CALL_FLAGS_NONE,
+                                       DBUS_TIMEOUT, NULL,
+                                       &err);
+
+                                       if (err != NULL) {
+                                               BT_ERR("StopLEDiscovery Failed: %s", err->message);
+                                               g_error_free(err);
+                                       }
                                }
 
                                mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
 
                                /* Send event to application */
                                BT_INFO("[Connectable]");
+                               param = g_variant_new("(in)", result, mode);
                                _bt_send_event(BT_ADAPTER_EVENT,
-                                               BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED,
-                                               DBUS_TYPE_INT32, &result,
-                                               DBUS_TYPE_INT16, &mode,
-                                               DBUS_TYPE_INVALID);
+                                       BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED,
+                                       param);
                        } else {
                                _bt_get_discoverable_mode(&mode);
 
                                /* Event will be sent by "DiscoverableTimeout" signal */
-                               if (mode != BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE)
+                               if (mode != BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE) {
+                                       g_free(property);
+                                       g_variant_unref(val);
                                        return;
+                               }
 
                                /* Send event to application */
                                BT_INFO("[General Discoverable]");
+                               param = g_variant_new("(in)", result, mode);
                                _bt_send_event(BT_ADAPTER_EVENT,
-                                               BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED,
-                                               DBUS_TYPE_INT32, &result,
-                                               DBUS_TYPE_INT16, &mode,
-                                               DBUS_TYPE_INVALID);
+                                       BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED,
+                                       param);
                        }
                } else if (strcasecmp(property, "DiscoverableTimeout") == 0) {
                        _bt_get_discoverable_mode(&mode);
 
                        /* Event was already sent by "Discoverable" signal */
                        if (mode == BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE ||
-                               mode == BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE)
+                               mode == BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE) {
+                               g_free(property);
+                               g_variant_unref(val);
                                return;
+                       }
 
                        /* Send event to application */
                        BT_INFO("[Limited Discoverable (Timeout %u secs)]",
-                                       _bt_get_discoverable_timeout_property());
-
+                       _bt_get_discoverable_timeout_property());
+                       param = g_variant_new("(in)", result, mode);
                        _bt_send_event(BT_ADAPTER_EVENT,
-                                       BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_INT16, &mode,
-                                       DBUS_TYPE_INVALID);
+                               BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED,
+                               param);
                } else if (strcasecmp(property, "Powered") == 0) {
-       /* TODO: Need to check this operation!! */
+                       /* TODO: Need to check this operation!! */
                        gboolean powered = FALSE;
                        int bt_state;
-                       dbus_message_iter_recurse(&dict_iter, &value_iter);
-                       dbus_message_iter_get_basic(&value_iter, &powered);
-                       BT_DBG("Powered = %d", powered);
 
-                       if (powered == TRUE) {
-                               BT_ERR("calling _bt_handle_adapter_added ...........");
-                               _bt_handle_adapter_added();
-                       }
-                       else {
-                               _bt_set_disabled(BLUETOOTH_ERROR_NONE);
-                       }
-#if 0
+                       g_variant_get(val, "b" ,&powered);
+                       BT_DBG("Powered = %d", powered);
+                       if (powered == FALSE) {
+                               if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_state) == 0 &&
+                               bt_state != VCONFKEY_BT_STATUS_OFF) {
+                                       _bt_disable_adapter();
+                               }
                                if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_state) == 0 &&
                                        bt_state != VCONFKEY_BT_LE_STATUS_OFF) {
                                        _bt_set_le_disabled(BLUETOOTH_ERROR_NONE);
                                }
-#endif
+                       }
                } else if (strcasecmp(property, "Connectable") == 0) {
                        gboolean connectable = FALSE;
 
-                       dbus_message_iter_recurse(&dict_iter, &value_iter);
-                       dbus_message_iter_get_basic(&value_iter, &connectable);
+                       g_variant_get(val, "b", &connectable);
 
                        BT_DBG("Connectable property is changed : %d", connectable);
-
+                       param = g_variant_new("(b)", connectable);
                        _bt_send_event(BT_ADAPTER_EVENT,
-                                       BLUETOOTH_EVENT_CONNECTABLE_CHANGED,
-                                       DBUS_TYPE_BOOLEAN, &connectable,
-                                       DBUS_TYPE_INVALID);
-
+                               BLUETOOTH_EVENT_CONNECTABLE_CHANGED,
+                               param);
                        if (_bt_adapter_get_status() == BT_DEACTIVATING &&
-                               _bt_adapter_get_le_status() == BT_LE_ACTIVATED &&
-                               connectable == 0)
-                                       _bt_set_disabled(BLUETOOTH_ERROR_NONE);
+                       _bt_adapter_get_le_status() == BT_LE_ACTIVATED &&
+                       connectable == 0)
+                       _bt_set_disabled(BLUETOOTH_ERROR_NONE);
                } else if (strcasecmp(property, "SupportedLEFeatures") == 0) {
                        char *name = NULL;
-                       char *val = NULL;
-                       DBusMessageIter array_iter;
-
-                       dbus_message_iter_recurse(&dict_iter, &value_iter);
+                       char *value = NULL;
+                       GVariantIter *iter = NULL;
+                       g_variant_get(val, "as", &iter);
+                       while (g_variant_iter_loop(iter, "s", &name)) {
+                               BT_DBG("name = %s", name);
+                               g_variant_iter_loop(iter, "s", &value);
+                               BT_DBG("Value = %s", value);
+                               if (FALSE == _bt_update_le_feature_support(name, value))
+                                       BT_INFO("Fail to update LE feature info");
+                       }
+                       if (iter)
+                               g_variant_iter_free(iter);
+               } else {
+                       BT_DBG("property : [%s]", property);
+               }
+       }
+}
 
-                       if(dbus_message_iter_get_arg_type(&value_iter) == DBUS_TYPE_ARRAY) {
-                               dbus_message_iter_recurse(&value_iter, &array_iter);
+static void __bt_obex_property_changed_event(GVariant *msg, const char *path)
+{
+       BT_DBG("+");
 
-                               while (dbus_message_iter_get_arg_type(&array_iter) !=
-                                                       DBUS_TYPE_INVALID) {
-                                       dbus_message_iter_get_basic(&array_iter, &name);
-                                       if (!dbus_message_iter_next(&array_iter))
-                                               break;
+       GVariantIter value_iter;
+       GVariant *child = NULL, *val = NULL;
+       char *property = NULL;
+       g_variant_iter_init (&value_iter, msg);
+       while ((child = g_variant_iter_next_value (&value_iter))) {
+               g_variant_get(child, "{sv}", &property, &val);
 
-                                       dbus_message_iter_get_basic(&array_iter, &val);
+               ret_if(property == NULL);
 
-                                       BT_DBG("name[%s] value[%s]", name, val);
+               BT_DBG("property :%s", property);
 
-                                       if (FALSE == _bt_update_le_feature_support(name, val))
-                                               BT_INFO("Fail to update LE feature info");
+               if (strcasecmp(property, "Status") == 0) {
+                       char  *status;
+                       g_variant_get(val, "s", &status);
 
-                                       if (!dbus_message_iter_next(&array_iter))
-                                               break;
-                               }
+                       if (strcasecmp(status, "active") == 0){
+                               _bt_obex_transfer_started(path);
+                       } else if (strcasecmp(status, "complete") == 0) {
+                               _bt_obex_transfer_completed(path, TRUE);
+                               _bt_pbap_obex_transfer_completed(path, TRUE);
+                       } else if (strcasecmp(status, "error") == 0){
+                               _bt_obex_transfer_completed(path, FALSE);
+                               _bt_pbap_obex_transfer_completed(path, FALSE);
                        }
-               } else {
-                       BT_DBG("property : [%s]", property);
+                       g_free(status);
+               } else if (strcasecmp(property, "Transferred") == 0) {
+                       static int transferred  = 0;
+                       g_variant_get(val, "t", &transferred);
+
+                       _bt_obex_transfer_progress(path,transferred);
                }
-       } while(dbus_message_iter_next(&item_iter));
+               g_free(property);
+               g_variant_unref(val);
+               g_variant_unref(child);
+       }
+       BT_DBG("-");
 }
 
-static void __bt_device_property_changed_event(DBusMessageIter *msg_iter, const char *path)
+static void __bt_device_property_changed_event(GVariant *msg, const char *path)
 {
        BT_DBG("+");
 
        int event;
        int result = BLUETOOTH_ERROR_NONE;
-       DBusMessageIter value_iter;
-       DBusMessageIter dict_iter;
-       DBusMessageIter item_iter;
-       const char *property = NULL;
+       GVariantIter value_iter;
+       GVariant *val;
+       char *property = NULL;
        char *address;
+       GVariant *param = NULL;
        bt_remote_dev_info_t *remote_dev_info;
-
-
-       dbus_message_iter_recurse(msg_iter, &item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_DICT_ENTRY) {
-               BT_ERR("This is bad format dbus");
-               return;
-       }
-
-       do {
-               dbus_message_iter_recurse(&item_iter, &dict_iter);
-
-               dbus_message_iter_get_basic(&dict_iter, &property);
-               ret_if(property == NULL);
-
-               ret_if(!dbus_message_iter_next(&dict_iter));
-
-               BT_ERR(" device property changed \n %s" , property);
-
+       g_variant_iter_init (&value_iter, msg);
+       while ((g_variant_iter_loop(&value_iter, "{sv}", &property, &val))) {
+               BT_DBG("Property %s", property);
                if (strcasecmp(property, "Connected") == 0) {
-                       gboolean connected = FALSE;
+                       guint connected = 0;
 
-                       dbus_message_iter_recurse(&dict_iter, &value_iter);
-                       dbus_message_iter_get_basic(&value_iter, &connected);
+                       g_variant_get(val, "i", &connected);
 
-                       event = connected ? BLUETOOTH_EVENT_DEVICE_CONNECTED :
-                                       BLUETOOTH_EVENT_DEVICE_DISCONNECTED;
+                       event = (connected != BLUETOOTH_CONNECTED_LINK_NONE) ?
+                               BLUETOOTH_EVENT_DEVICE_CONNECTED :
+                               BLUETOOTH_EVENT_DEVICE_DISCONNECTED;
 
                        address = g_malloc0(BT_ADDRESS_STRING_SIZE);
 
@@ -1082,17 +838,16 @@ static void __bt_device_property_changed_event(DBusMessageIter *msg_iter, const
 
                        if (remote_dev_info != NULL) {
                                __bt_device_remote_connected_properties(
-                               remote_dev_info, address, connected);
+                                               remote_dev_info, address,
+                                               connected != BLUETOOTH_CONNECTED_LINK_NONE ?
+                                               TRUE : FALSE);
                                _bt_free_device_info(remote_dev_info);
                        }
-
+                       param = g_variant_new("(is)", result, address);
                        /* Send event to application */
                        _bt_send_event(BT_DEVICE_EVENT,
                                        event,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &address,
-                                       DBUS_TYPE_INVALID);
-
+                                       param);
                        g_free(address);
                } else if (strcasecmp(property, "RSSI") == 0) {
                        bt_remote_dev_info_t *remote_dev_info;
@@ -1104,6 +859,8 @@ static void __bt_device_property_changed_event(DBusMessageIter *msg_iter, const
 
                        remote_dev_info = _bt_get_remote_device_info(address);
                        if (remote_dev_info == NULL) {
+                               g_free(property);
+                               g_variant_unref(val);
                                g_free(address);
                                return;
                        }
@@ -1112,30 +869,44 @@ static void __bt_device_property_changed_event(DBusMessageIter *msg_iter, const
                        if (remote_dev_info && remote_dev_info->addr_type == 0) {
                                BT_DBG("Name %s", remote_dev_info->name);
 
+                               GVariant *uuids = NULL;
+                               GVariantBuilder *builder = NULL;
+                               int i = 0;
+                               builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
+                               for (i=0; i < remote_dev_info->uuid_count; i++) {
+                                       g_variant_builder_add(builder, "s",
+                                               remote_dev_info->uuids[i]);
+                               }
+                               uuids = g_variant_new("as", builder);
+                               g_variant_builder_unref(builder);
+                               GVariant *manufacturer_data =  NULL;
+                               manufacturer_data = g_variant_new_from_data(G_VARIANT_TYPE_BYTESTRING,
+                                                                       remote_dev_info->manufacturer_data,
+                                                                       remote_dev_info->manufacturer_data_len,
+                                                                       TRUE,
+                                                                       NULL, NULL);
+                               param = g_variant_new("(isunsbub@asn@ay)", result,
+                                                       remote_dev_info->address,
+                                                       remote_dev_info->class,
+                                                       remote_dev_info->rssi,
+                                                       remote_dev_info->name,
+                                                       remote_dev_info->paired,
+                                                       remote_dev_info->connected,
+                                                       remote_dev_info->trust,
+                                                       uuids,
+                                                       remote_dev_info->manufacturer_data_len,
+                                                       manufacturer_data);
+
                                _bt_send_event(BT_ADAPTER_EVENT,
-                               BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &remote_dev_info->address,
-                               DBUS_TYPE_UINT32, &remote_dev_info->class,
-                               DBUS_TYPE_INT16, &remote_dev_info->rssi,
-                               DBUS_TYPE_STRING, &remote_dev_info->name,
-                               DBUS_TYPE_BOOLEAN, &remote_dev_info->paired,
-                               DBUS_TYPE_BOOLEAN, &remote_dev_info->connected,
-                               DBUS_TYPE_BOOLEAN, &remote_dev_info->trust,
-                               DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
-                               &remote_dev_info->uuids, remote_dev_info->uuid_count,
-                               DBUS_TYPE_INT16, &remote_dev_info->manufacturer_data_len,
-                               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                               &remote_dev_info->manufacturer_data, remote_dev_info->manufacturer_data_len,
-                               DBUS_TYPE_INVALID);
+                                       BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND,
+                                       param);
+                               g_free(address);
                        }
                        _bt_free_device_info(remote_dev_info);
-                       g_free(address);
                } else if (strcasecmp(property, "GattConnected") == 0) {
                        gboolean gatt_connected = FALSE;
 
-                       dbus_message_iter_recurse(&dict_iter, &value_iter);
-                       dbus_message_iter_get_basic(&value_iter, &gatt_connected);
+                       g_variant_get(val, "b", &gatt_connected);
 
                        event = gatt_connected ? BLUETOOTH_EVENT_GATT_CONNECTED :
                                        BLUETOOTH_EVENT_GATT_DISCONNECTED;
@@ -1146,28 +917,24 @@ static void __bt_device_property_changed_event(DBusMessageIter *msg_iter, const
 
                        BT_DBG("gatt_connected: %d", gatt_connected);
                        BT_DBG("address: %s", address);
-
+                       param = g_variant_new("(is)", result, address);
                        /* Send event to application */
                        _bt_send_event(BT_DEVICE_EVENT,
                                        event,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &address,
-                                       DBUS_TYPE_INVALID);
-
+                                       param);
                        g_free(address);
                } else if (strcasecmp(property, "Paired") == 0) {
                        gboolean paired = FALSE;
                        bt_remote_dev_info_t *remote_dev_info;
-
-                       dbus_message_iter_recurse(&dict_iter, &value_iter);
-                       dbus_message_iter_get_basic(&value_iter, &paired);
-
+                       g_variant_get(val, "b", &paired);
                        _bt_agent_set_canceled(FALSE);
                        /* BlueZ sends paired signal for each paired device */
                        /* during activation, We should ignore this, otherwise*/
                        /* application thinks that a new device got paired */
                        if (_bt_adapter_get_status() != BT_ACTIVATED) {
                                BT_DBG("BT is not activated, so ignore this");
+                               g_free(property);
+                               g_variant_unref(val);
                                return;
                        }
 
@@ -1177,6 +944,8 @@ static void __bt_device_property_changed_event(DBusMessageIter *msg_iter, const
 
                        remote_dev_info = _bt_get_remote_device_info(address);
                        if (remote_dev_info == NULL) {
+                               g_free(property);
+                               g_variant_unref(val);
                                g_free(address);
                                return;
                        }
@@ -1184,39 +953,52 @@ static void __bt_device_property_changed_event(DBusMessageIter *msg_iter, const
                        if(paired == FALSE) {
                                BT_INFO("Unpaired: %s", address);
                                __bt_update_remote_cache_devinfo(address, FALSE);
+                               param = g_variant_new("(is)", result, address);
                                _bt_send_event(BT_ADAPTER_EVENT,
                                        BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &address,
-                                       DBUS_TYPE_INVALID);
+                                       param);
                        } else {
                                BT_INFO("Paired: %s", address);
                                __bt_update_remote_cache_devinfo(address, TRUE);
 
-#if 0
                                if (_bt_is_device_creating() == TRUE) {
                                        BT_DBG("Try to Pair by me");
                                        _bt_free_device_info(remote_dev_info);
                                        g_free(address);
+                                       g_free(property);
+                                       g_variant_unref(val);
                                        return;
                                }
-#endif
+                               GVariant *uuids = NULL;
+                               GVariantBuilder *builder = NULL;
+                               int i = 0;
+                               builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
+                               for (i=0; i < remote_dev_info->uuid_count; i++) {
+                                       g_variant_builder_add(builder, "s",
+                                               remote_dev_info->uuids[i]);
+                               }
+                               uuids = g_variant_new("as", builder);
+                               g_variant_builder_unref(builder);
+                               GVariant *manufacturer_data =  NULL;
+                               manufacturer_data = g_variant_new_from_data(G_VARIANT_TYPE_BYTESTRING,
+                                                                       remote_dev_info->manufacturer_data,
+                                                                       remote_dev_info->manufacturer_data_len,
+                                                                       TRUE,
+                                                                       NULL, NULL);
+
+                               param = g_variant_new("(isunsbub@asn@ay)", result,
+                                                       address, remote_dev_info->class,
+                                                       remote_dev_info->rssi,
+                                                       remote_dev_info->name,
+                                                       remote_dev_info->paired,
+                                                       remote_dev_info->connected,
+                                                       remote_dev_info->trust,
+                                                       uuids,
+                                                       remote_dev_info->manufacturer_data_len,
+                                                       manufacturer_data);
                                _bt_send_event(BT_ADAPTER_EVENT,
                                        BLUETOOTH_EVENT_BONDING_FINISHED,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &address,
-                                       DBUS_TYPE_UINT32, &remote_dev_info->class,
-                                       DBUS_TYPE_INT16, &remote_dev_info->rssi,
-                                       DBUS_TYPE_STRING, &remote_dev_info->name,
-                                       DBUS_TYPE_BOOLEAN, &remote_dev_info->paired,
-                                       DBUS_TYPE_BOOLEAN, &remote_dev_info->connected,
-                                       DBUS_TYPE_BOOLEAN, &remote_dev_info->trust,
-                                       DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
-                                       &remote_dev_info->uuids, remote_dev_info->uuid_count,
-                                       DBUS_TYPE_INT16, &remote_dev_info->manufacturer_data_len,
-                                       DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                                       &remote_dev_info->manufacturer_data, remote_dev_info->manufacturer_data_len,
-                                       DBUS_TYPE_INVALID);
+                                       param);
                        }
                        _bt_free_device_info(remote_dev_info);
                        g_free(address);
@@ -1226,11 +1008,12 @@ static void __bt_device_property_changed_event(DBusMessageIter *msg_iter, const
 
                        if (_bt_adapter_get_status() != BT_ACTIVATED) {
                                BT_DBG("BT is not activated, so ignore this");
+                               g_free(property);
+                               g_variant_unref(val);
                                return;
                        }
 
-                       dbus_message_iter_recurse(&dict_iter, &value_iter);
-                       dbus_message_iter_get_basic(&value_iter, &paired);
+                       g_variant_get(val, "b", &paired);
                        address = g_malloc0(BT_ADDRESS_STRING_SIZE);
                        BT_DBG("LegacyPaired: %d", paired);
                        _bt_convert_device_path_to_address(path, address);
@@ -1238,6 +1021,8 @@ static void __bt_device_property_changed_event(DBusMessageIter *msg_iter, const
                        remote_dev_info = _bt_get_remote_device_info(address);
                        if (remote_dev_info == NULL) {
                                g_free(address);
+                               g_free(property);
+                               g_variant_unref(val);
                                return;
                        }
 
@@ -1251,8 +1036,7 @@ static void __bt_device_property_changed_event(DBusMessageIter *msg_iter, const
                } else if (strcasecmp(property, "Trusted") == 0) {
                        gboolean trusted = FALSE;
 
-                       dbus_message_iter_recurse(&dict_iter, &value_iter);
-                       dbus_message_iter_get_basic(&value_iter, &trusted);
+                       g_variant_get(val, "b", &trusted);
 
                        event = trusted ? BLUETOOTH_EVENT_DEVICE_AUTHORIZED :
                                        BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED;
@@ -1263,438 +1047,389 @@ static void __bt_device_property_changed_event(DBusMessageIter *msg_iter, const
 
                        BT_DBG("trusted: %d", trusted);
                        BT_DBG("address: %s", address);
-
-                       remote_dev_info = _bt_get_remote_device_info(address);
-
+                       param = g_variant_new("(is)", result, address);
                        /* Send event to application */
                        _bt_send_event(BT_DEVICE_EVENT,
                                        event,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &address,
-                                       DBUS_TYPE_INVALID);
-
+                                       param);
                        g_free(address);
                }
-               dbus_message_iter_next(&item_iter);
-       } while (dbus_message_iter_get_arg_type(&item_iter) ==
-                       DBUS_TYPE_DICT_ENTRY);
+       }
        BT_DBG("-");
 }
 
-static void __bt_media_control_changed_event(DBusMessageIter *msg_iter, const char *path)
+static void __bt_media_control_changed_event(GVariant *msg, const char *path)
 {
        int event;
        int result = BLUETOOTH_ERROR_NONE;
-       DBusMessageIter value_iter;
-       DBusMessageIter dict_iter;
-       DBusMessageIter item_iter;
-       const char *property = NULL;
+       GVariantIter value_iter;
+       char *property = NULL;
        char *address;
+       GVariant *val = NULL;
+       GVariant *child = NULL;
        bt_remote_dev_info_t *remote_dev_info;
+       GVariant *param = NULL;
+       g_variant_iter_init (&value_iter, msg);
+       while ((child = g_variant_iter_next_value (&value_iter))) {
+               g_variant_get(child, "{sv}", &property, &val);
+               BT_INFO("Property %s", property);
+               if (strcasecmp(property, "Connected") == 0) {
+                       gboolean connected = FALSE;
 
-       dbus_message_iter_recurse(msg_iter, &item_iter);
+                       g_variant_get(val, "b", &connected);
 
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_DICT_ENTRY) {
-               BT_ERR("This is bad format dbus");
-               return;
-       }
-
-       dbus_message_iter_recurse(&item_iter, &dict_iter);
-
-       dbus_message_iter_get_basic(&dict_iter, &property);
-       ret_if(property == NULL);
-
-       ret_if(!dbus_message_iter_next(&dict_iter));
-
-       if (strcasecmp(property, "Connected") == 0) {
-               gboolean connected = FALSE;
+                       event = connected ? BLUETOOTH_EVENT_AVRCP_CONNECTED :
+                                       BLUETOOTH_EVENT_AVRCP_DISCONNECTED;
 
-               dbus_message_iter_recurse(&dict_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &connected);
-
-               event = connected ? BLUETOOTH_EVENT_AVRCP_CONNECTED :
-                               BLUETOOTH_EVENT_AVRCP_DISCONNECTED;
-
-               address = g_malloc0(BT_ADDRESS_STRING_SIZE);
+                       address = g_malloc0(BT_ADDRESS_STRING_SIZE);
 
-               _bt_convert_device_path_to_address(path, address);
+                       _bt_convert_device_path_to_address(path, address);
 
-               BT_DBG("connected: %d", connected);
-               BT_DBG("address: %s", address);
+                       BT_DBG("connected: %d", connected);
+                       BT_DBG("address: %s", address);
 
-               remote_dev_info = _bt_get_remote_device_info(address);
+                       remote_dev_info = _bt_get_remote_device_info(address);
 
-               if (remote_dev_info != NULL) {
-                       __bt_device_remote_connected_properties(
-                       remote_dev_info, address, connected);
-                       _bt_free_device_info(remote_dev_info);
+                       if (remote_dev_info != NULL) {
+                               __bt_device_remote_connected_properties(
+                               remote_dev_info, address, connected);
+                               _bt_free_device_info(remote_dev_info);
+                       }
+                       param = g_variant_new("(is)", result, address);
+                       /* Send event to application */
+                       _bt_send_event(BT_AVRCP_EVENT,
+                               event,
+                               param);
+                       g_free(address);
                }
-
-               /* Send event to application */
-               _bt_send_event(BT_AVRCP_EVENT,
-                       event,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &address,
-                       DBUS_TYPE_INVALID);
-               g_free(address);
+               g_free(property);
+               g_variant_unref(child);
+               g_variant_unref(val);
        }
-
        BT_DBG("-");
 }
 
-static void __bt_obex_property_changed_event(DBusMessageIter *msg_iter, const char *path)
+void _bt_handle_property_changed_event(GVariant *msg, const char *object_path)
 {
-       BT_DBG("+");
-
-       DBusMessageIter value_iter;
-       DBusMessageIter dict_iter;
-       DBusMessageIter item_iter;
-       const char *property = NULL;
+       char *interface_name = NULL;
+       GVariant *val = NULL;
 
-       dbus_message_iter_recurse(msg_iter, &item_iter);
+       g_variant_get(msg, "(&s@a{sv}@as)", &interface_name, &val,NULL);
 
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_DICT_ENTRY) {
-               BT_ERR("This is bad format dbus");
-               return;
+       if (strcasecmp(interface_name, BT_ADAPTER_INTERFACE) == 0) {
+               __bt_adapter_property_changed_event(val,
+                                       object_path);
+       } else if (strcasecmp(interface_name, BT_DEVICE_INTERFACE) == 0) {
+               __bt_device_property_changed_event(val,object_path);
+       } else if (strcasecmp(interface_name, BT_OBEX_TRANSFER_INTERFACE) == 0) {
+               BT_DBG("BT_OBEX_TRANSFER_INTERFACE");
+               __bt_obex_property_changed_event(val,
+                                       object_path);
+       } else if (strcasecmp(interface_name, BT_MEDIA_CONTROL_INTERFACE) == 0) {
+               __bt_media_control_changed_event(val,
+                                       object_path);
+       } else if (strcasecmp(interface_name, BT_PLAYER_CONTROL_INTERFACE) == 0) {
+               _bt_handle_avrcp_control_event(val,
+                                       object_path);
+       } else if (strcasecmp(interface_name, BT_NETWORK_CLIENT_INTERFACE) == 0) {
+               BT_DBG("BT_NETWORK_CLIENT_INTERFACE");
+               _bt_handle_network_client_event(val,
+                                       object_path);
+       } else if (strcasecmp(interface_name, BT_GATT_CHAR_INTERFACE) == 0) {
+               __bt_gatt_char_property_changed_event(val,
+                                       object_path);
        }
+       g_variant_unref(val);
+}
 
-       do {
-               dbus_message_iter_recurse(&item_iter, &dict_iter);
-
-               dbus_message_iter_get_basic(&dict_iter, &property);
+void __bt_opc_property_changed_event(GVariant *msg,
+                                               const char *path)
+{
+       GVariantIter value_iter;
+       char *property = NULL;
+       GVariant *val = NULL;
+       GVariant *child = NULL;
+
+       g_variant_iter_init (&value_iter, msg);
+       while ((child = g_variant_iter_next_value (&value_iter))) {
+               g_variant_get(child, "{sv}", &property, &val);
                ret_if(property == NULL);
 
-               ret_if(!dbus_message_iter_next(&dict_iter));
-
-               BT_DBG("property :%s", property);
-
                if (strcasecmp(property, "Status") == 0) {
-                       const char      *status;
-                       dbus_message_iter_recurse(&dict_iter, &value_iter);
-                       dbus_message_iter_get_basic(&value_iter, &status);
-
-                       if (strcasecmp(status, "active") == 0){
-                               _bt_obex_transfer_started(path);
-                       } else if (strcasecmp(status, "complete") == 0) {
-                               _bt_obex_transfer_completed(path, TRUE);
-                               _bt_pbap_obex_transfer_completed(path, TRUE);
-                       } else if (strcasecmp(status, "error") == 0){
-                               _bt_obex_transfer_completed(path, FALSE);
-                               _bt_pbap_obex_transfer_completed(path, FALSE);
+                       char *status = NULL;
+                       g_variant_get(val, "s", &status);
+                       BT_DBG("Status is %s", status);
+
+                       if(strcasecmp(status, "active") == 0){
+                               _bt_obex_client_started(path);
+                       }else if (strcasecmp(status, "complete") == 0) {
+                               _bt_obex_client_completed(path, TRUE);
+                       }else if (strcasecmp(status, "error") == 0){
+                               _bt_obex_client_completed(path, FALSE);
                        }
+                       g_free(status);
                } else if (strcasecmp(property, "Transferred") == 0) {
-                       static int transferred  = 0;
-                       dbus_message_iter_recurse(&dict_iter, &value_iter);
-                       dbus_message_iter_get_basic(&value_iter, &transferred);
+                       static int transferred  = 0;
+                       g_variant_get(val, "t", &transferred);
 
-                       _bt_obex_transfer_progress(path,transferred);
+                       _bt_obex_client_progress(path, transferred);
+               } else {
+                       BT_DBG("property : [%s]", property);
                }
-
-               dbus_message_iter_next(&item_iter);
-       } while (dbus_message_iter_get_arg_type(&item_iter) ==
-                       DBUS_TYPE_DICT_ENTRY);
-
-       BT_DBG("-");
+               g_free(property);
+               g_variant_unref(child);
+               g_variant_unref(val);
+       }
 }
 
-
-void _bt_handle_property_changed_event(DBusMessage *msg)
+void _bt_opc_property_changed_event(GVariant *msg, char *path)
 {
-       DBusMessageIter item_iter;
-       const char *member = dbus_message_get_member(msg);
-       const char *interface_name = NULL;
-
-       ret_if(member == NULL);
-
-       dbus_message_iter_init(msg, &item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus");
-               return;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, &interface_name);
-
-       ret_if(interface_name == NULL);
-
-       ret_if(dbus_message_iter_next(&item_iter) == FALSE);
-
-       ret_if(dbus_message_iter_get_arg_type(&item_iter) != DBUS_TYPE_ARRAY);
-
-       if (strcasecmp(interface_name, BT_ADAPTER_INTERFACE) == 0) {
-               __bt_adapter_property_changed_event(&item_iter,
-                                       dbus_message_get_path(msg));
-       } else if (strcasecmp(interface_name, BT_DEVICE_INTERFACE) == 0) {
-               __bt_device_property_changed_event(&item_iter,
-                                       dbus_message_get_path(msg));
-
-       } else if (strcasecmp(interface_name, BT_OBEX_TRANSFER_INTERFACE) == 0) {
-               BT_DBG("BT_OBEX_TRANSFER_INTERFACE");
-               __bt_obex_property_changed_event(&item_iter,
-                                       dbus_message_get_path(msg));
-       } else if (strcasecmp(interface_name, BT_MEDIA_CONTROL_INTERFACE) == 0) {
-               __bt_media_control_changed_event(&item_iter,
-                                       dbus_message_get_path(msg));
-       } else if (strcasecmp(interface_name, BT_PLAYER_CONTROL_INTERFACE) == 0) {
-               _bt_handle_avrcp_control_event(&item_iter,
-                                       dbus_message_get_path(msg));
-       } else if (strcasecmp(interface_name, BT_NETWORK_CLIENT_INTERFACE) == 0) {
-               BT_DBG("BT_NETWORK_CLIENT_INTERFACE");
-               _bt_handle_network_client_event(&item_iter,
-                                       dbus_message_get_path(msg));
+       char *interface_name = NULL;
+       GVariant *value = NULL;
+       g_variant_get(msg, "(&s@a{sv}@as)", &interface_name, &value, NULL);
+       BT_INFO("interface_name = %s", interface_name);
+       if (strcasecmp(interface_name, BT_OBEX_TRANSFER_INTERFACE) == 0) {
+               __bt_opc_property_changed_event(value,
+                                       path);
+       } else {
+               BT_DBG("interface_name : [%s]", interface_name);
        }
+       g_variant_unref(value);
 }
 
-void _bt_handle_input_event(DBusMessage *msg)
+
+void _bt_handle_input_event(GVariant *msg, const char *path)
 {
        int result = BLUETOOTH_ERROR_NONE;
-       DBusMessageIter item_iter;
-       DBusMessageIter value_iter;
        gboolean property_flag = FALSE;
-       const char *member = dbus_message_get_member(msg);
-       const char *path = dbus_message_get_path(msg);
-       const char *property = NULL;
+       GVariantIter value_iter;
+       char *property = NULL;
+       GVariant *child = NULL, *val = NULL;
        bt_remote_dev_info_t *remote_dev_info;
+       GVariant *param = NULL;
+       g_variant_iter_init (&value_iter, msg);
+       while ((child = g_variant_iter_next_value (&value_iter))) {
+               g_variant_get(child, "{sv}", &property, &val);
 
-       ret_if(member == NULL);
-
-       dbus_message_iter_init(msg, &item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus");
-               return;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, &property);
-
-       ret_if(property == NULL);
-
-       if (strcasecmp(property, "Connected") == 0) {
-               int event = BLUETOOTH_EVENT_NONE;
-               char *address;
-
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_recurse(&item_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &property_flag);
-
-               address = g_malloc0(BT_ADDRESS_STRING_SIZE);
+               ret_if(property == NULL);
 
-               _bt_convert_device_path_to_address(path, address);
+               if (strcasecmp(property, "Connected") == 0) {
+                       int event = BLUETOOTH_EVENT_NONE;
+                       char *address;
+                       g_variant_get(val, "b", &property_flag);
 
-               event = (property_flag == TRUE) ?
-                               BLUETOOTH_HID_CONNECTED :
-                               BLUETOOTH_HID_DISCONNECTED;
+                       address = g_malloc0(BT_ADDRESS_STRING_SIZE);
 
-               _bt_send_event(BT_HID_EVENT, event,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &address,
-                       DBUS_TYPE_INVALID);
+                       _bt_convert_device_path_to_address(path, address);
 
-               /* Check HID connection type (Keyboard or Mouse) and update the status */
-               remote_dev_info = _bt_get_remote_device_info(address);
+                       event = (property_flag == TRUE) ?
+                                       BLUETOOTH_HID_CONNECTED :
+                                       BLUETOOTH_HID_DISCONNECTED;
+                       param = g_variant_new("(is)", result, address);
+                       _bt_send_event(BT_HID_EVENT, event,
+                               param);
+                       /* Check HID connection type (Keyboard or Mouse) and update the status */
+                       remote_dev_info = _bt_get_remote_device_info(address);
 
-               if (property_flag == TRUE) {
-                       hid_connected_device_count++;
-                       __bt_set_device_values(TRUE,
-                                       VCONFKEY_BT_DEVICE_HID_CONNECTED);
-               } else {
-                       hid_connected_device_count--;
-                       if (hid_connected_device_count == 0)
-                               __bt_set_device_values(FALSE,
+                       if (property_flag == TRUE) {
+                               hid_connected_device_count++;
+                               __bt_set_device_values(TRUE,
                                                VCONFKEY_BT_DEVICE_HID_CONNECTED);
-               }
+                       } else {
+                               hid_connected_device_count--;
+                               if (hid_connected_device_count == 0)
+                                       __bt_set_device_values(FALSE,
+                                                       VCONFKEY_BT_DEVICE_HID_CONNECTED);
+                       }
 
-               if (remote_dev_info != NULL) {
-                       BT_DBG("HID device class [%x]", remote_dev_info->class);
-                       if (remote_dev_info->class &
+                       if (remote_dev_info != NULL) {
+                               BT_DBG("HID device class [%x]", remote_dev_info->class);
+                               if (remote_dev_info->class &
                                        BLUETOOTH_DEVICE_MINOR_CLASS_KEY_BOARD) {
-#if 0
-                               __bt_set_device_values(property_flag,
+                                       __bt_set_device_values(property_flag,
                                                VCONFKEY_BT_DEVICE_HID_KEYBOARD_CONNECTED);
-#endif
-                       }
-                       if (remote_dev_info->class &
-                                       BLUETOOTH_DEVICE_MINOR_CLASS_POINTING_DEVICE)
-                       {
-#if 0
-                               __bt_set_device_values(property_flag,
-                                               VCONFKEY_BT_DEVICE_HID_MOUSE_CONNECTED);
-#endif
+
+                               }
+
+                               if (remote_dev_info->class &
+                                               BLUETOOTH_DEVICE_MINOR_CLASS_POINTING_DEVICE) {
+                                       __bt_set_device_values(property_flag,
+                                                       VCONFKEY_BT_DEVICE_HID_MOUSE_CONNECTED);
+                               }
+                               _bt_free_device_info(remote_dev_info);
                        }
-                       _bt_free_device_info(remote_dev_info);
+                       g_free(address);
                }
+               g_free(property);
+               g_variant_unref(val);
+               g_variant_unref(child);
+        }
+}
 
-               g_free(address);
-       }
- }
-
-void _bt_handle_network_server_event(DBusMessage *msg)
+void _bt_handle_network_server_event(GVariant *msg, const char *member)
 {
        int result = BLUETOOTH_ERROR_NONE;
        char *address = NULL;
        char *device = NULL;
-       const char *member = dbus_message_get_member(msg);
-
+       GVariant *param = NULL;
        ret_if(member == NULL);
-
        if (strcasecmp(member, "PeerConnected") == 0) {
-               if (!dbus_message_get_args(msg, NULL,
-                       DBUS_TYPE_STRING, &device,
-                       DBUS_TYPE_STRING, &address,
-                       DBUS_TYPE_INVALID)) {
-                       BT_ERR("Unexpected parameters in signal");
-                       return;
-               }
+               g_variant_get(msg, "(ss)", &device, &address);
 
                __bt_set_device_values(TRUE,
                                VCONFKEY_BT_DEVICE_PAN_CONNECTED);
-
+               param = g_variant_new("(iss)", result, device, address);
                _bt_send_event(BT_NETWORK_EVENT, BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &device,
-                       DBUS_TYPE_STRING, &address,
-                       DBUS_TYPE_INVALID);
+                       param);
+               g_free(device);
+               g_free(address);
                 nap_connected_device_count++;
        } else if (strcasecmp(member, "PeerDisconnected") == 0) {
-               if (!dbus_message_get_args(msg, NULL,
-                       DBUS_TYPE_STRING, &device,
-                       DBUS_TYPE_STRING, &address,
-                       DBUS_TYPE_INVALID)) {
-                       BT_ERR("Unexpected parameters in signal");
-                       return;
-               }
+               g_variant_get(msg, "(ss)", &device, &address);
                nap_connected_device_count--;
                if (nap_connected_device_count == 0)
                        __bt_set_device_values(FALSE,
                                VCONFKEY_BT_DEVICE_PAN_CONNECTED);
-
+               param = g_variant_new("(iss)", result, device, address);
                _bt_send_event(BT_NETWORK_EVENT, BLUETOOTH_EVENT_NETWORK_SERVER_DISCONNECTED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &device,
-                       DBUS_TYPE_STRING, &address,
-                       DBUS_TYPE_INVALID);
+                       param);
+               g_free(device);
+               g_free(address);
        }
 }
 
-void _bt_handle_network_client_event(DBusMessageIter *msg_iter,
+void _bt_handle_network_client_event(GVariant *msg,
                                const char *path)
 {
        BT_DBG("+");
 
        int result = BLUETOOTH_ERROR_NONE;
-       DBusMessageIter item_iter;
-       DBusMessageIter dict_iter;
-       DBusMessageIter value_iter;
        gboolean property_flag = FALSE;
-       const char *property = NULL;
-
-       dbus_message_iter_recurse(msg_iter, &item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_DICT_ENTRY) {
-               BT_ERR("This is bad format dbus");
-               return;
-       }
+       char *property = NULL;
+       GVariant *val = NULL;
+       GVariantIter value_iter;
+       GVariant *param = NULL;
+       g_variant_iter_init (&value_iter, msg);
+       while ((g_variant_iter_loop(&value_iter, "{sv}", &property, &val))) {
+               if (strcasecmp(property, "Connected") == 0) {
+                       int event = BLUETOOTH_EVENT_NONE;
+                       char *address;
 
-       dbus_message_iter_recurse(&item_iter, &dict_iter);
-       dbus_message_iter_get_basic(&dict_iter, &property);
+                       g_variant_get(val, "b", &property_flag);
+                       address = g_malloc0(BT_ADDRESS_STRING_SIZE);
 
-       ret_if(property == NULL);
-       ret_if(!dbus_message_iter_next(&dict_iter));
+                       _bt_convert_device_path_to_address(path, address);
 
-       if (strcasecmp(property, "Connected") == 0) {
-               int event = BLUETOOTH_EVENT_NONE;
-               char *address;
+                       BT_DBG("property_flag %d", property_flag);
+                       if (property_flag == TRUE) {
+                               event = BLUETOOTH_EVENT_NETWORK_CONNECTED;
+                               nap_connected_device_count++;
+                               __bt_set_device_values(TRUE,
+                                       VCONFKEY_BT_DEVICE_PAN_CONNECTED);
+                       } else {
+                               event = BLUETOOTH_EVENT_NETWORK_DISCONNECTED;
+                               nap_connected_device_count--;
+                               if (nap_connected_device_count == 0)
+                                       __bt_set_device_values(FALSE,
+                                               VCONFKEY_BT_DEVICE_PAN_CONNECTED);
+                       }
+                       param = g_variant_new("(is)", result, address);
+                       _bt_send_event(BT_NETWORK_EVENT, event,
+                               param);
 
-               dbus_message_iter_recurse(&dict_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &property_flag);
+                       g_free(address);
+               }
+       }
+       BT_DBG("-");
+}
 
-               address = g_malloc0(BT_ADDRESS_STRING_SIZE);
+void __bt_gatt_char_property_changed_event(GVariant *msg,
+                               const char *path)
+{
+       GVariantIter value_iter;
+       char *property = NULL;
+       char * char_handle = NULL;
+       GVariant *val = NULL;
+       int result = BLUETOOTH_ERROR_NONE;
+       GVariant *param = NULL;
+       g_variant_iter_init (&value_iter, msg);
+       char_handle = g_strdup(path);
+       while ((g_variant_iter_loop(&value_iter, "{sv}", &property, &val))) {
+               BT_INFO("Property %s", property);
 
-               _bt_convert_device_path_to_address(path, address);
+               ret_if(property == NULL);
 
-               BT_DBG("property_flag %d", property_flag);
-               if (property_flag == TRUE) {
-                       event = BLUETOOTH_EVENT_NETWORK_CONNECTED;
-                       nap_connected_device_count++;
-                       __bt_set_device_values(TRUE,
-                               VCONFKEY_BT_DEVICE_PAN_CONNECTED);
-               } else {
-                       event = BLUETOOTH_EVENT_NETWORK_DISCONNECTED;
-                       nap_connected_device_count--;
-                       if (nap_connected_device_count == 0)
-                               __bt_set_device_values(FALSE,
-                                       VCONFKEY_BT_DEVICE_PAN_CONNECTED);
+               if (strcasecmp(property, "Notifying") == 0) {
+                       gboolean property_flag = FALSE;
+                       g_variant_get(val, "b", &property_flag);
+                       if (property_flag == TRUE)
+                               BT_DBG("notifying is enabled");
+                       else
+                               BT_DBG("notifying is disabled");
+               } else if (strcasecmp(property, "ChangedValue") == 0) {
+                       int len = 0;
+                       GByteArray *gp_byte_array = NULL;
+                       BT_INFO("Type '%s'\n", g_variant_get_type_string (val));
+
+                       if (val) {
+                               gp_byte_array = g_byte_array_new();
+                               len = g_variant_get_size(val);
+                               BT_DBG("Len = %d", len);
+                               g_byte_array_append (gp_byte_array,
+                                       (const guint8 *) g_variant_get_data(val), len);
+                               if (gp_byte_array->len != 0) {
+                                       GVariant *byte_array = NULL;
+                                       byte_array = g_variant_new_from_data(
+                                                               G_VARIANT_TYPE_BYTESTRING,
+                                                               gp_byte_array->data,
+                                                               gp_byte_array->len,
+                                                               TRUE, NULL, NULL);
+                                       param = g_variant_new("(is@ay)", result, char_handle,
+                                                               byte_array);
+                                       _bt_send_event(BT_DEVICE_EVENT,
+                                               BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED,
+                                               param);
+                               }
+                               g_byte_array_free(gp_byte_array, TRUE);
+                       }
                }
-
-               _bt_send_event(BT_NETWORK_EVENT, event,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &address,
-                       DBUS_TYPE_INVALID);
-
-               g_free(address);
        }
-       BT_DBG("-");
+       g_free(char_handle);
 }
-
-void _bt_handle_device_event(DBusMessage *msg)
+void _bt_handle_device_event(GVariant *msg, const char *member,const char *path)
 {
        int event;
        int result = BLUETOOTH_ERROR_NONE;
-       DBusMessageIter item_iter;
-       DBusMessageIter value_iter;
        char *address;
-       const char *member = dbus_message_get_member(msg);
-       const char *path = dbus_message_get_path(msg);
+       char *dev_name;
        const char *property = NULL;
-
+       GVariant *param = NULL;
        ret_if(path == NULL);
-       ret_if(member == NULL);
 
        if (strcasecmp(member, "PropertyChanged") == 0) {
-               dbus_message_iter_init(msg, &item_iter);
-
-               if (dbus_message_iter_get_arg_type(&item_iter)
-                                               != DBUS_TYPE_STRING) {
-                       BT_ERR("This is bad format dbus");
-                       return;
-               }
 
-               dbus_message_iter_get_basic(&item_iter, &property);
+               g_variant_get(msg, "(s)", &property);
 
                ret_if(property == NULL);
 
                if (strcasecmp(property, "GattConnected") == 0) {
                        gboolean connected = FALSE;
                        char *address;
-
                        address = g_malloc0(BT_ADDRESS_STRING_SIZE);
                        _bt_convert_device_path_to_address(path, address);
-
-                       dbus_message_iter_next(&item_iter);
-                       dbus_message_iter_recurse(&item_iter, &value_iter);
-                       dbus_message_iter_get_basic(&value_iter, &connected);
+                       g_variant_get(msg, "(b)", &connected);
 
                        event = connected ? BLUETOOTH_EVENT_GATT_CONNECTED :
                                        BLUETOOTH_EVENT_GATT_DISCONNECTED;
-
+                       param = g_variant_new("(is)", result, address);
                        _bt_send_event(BT_DEVICE_EVENT,
                                        event,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &address,
-                                       DBUS_TYPE_INVALID);
-
+                                       param);
                        g_free(address);
                } else if (strcasecmp(property, "Paired") == 0) {
                        gboolean paired = FALSE;
                        bt_remote_dev_info_t *remote_dev_info;
-                       dbus_message_iter_next(&item_iter);
-                       dbus_message_iter_recurse(&item_iter, &value_iter);
-                       dbus_message_iter_get_basic(&value_iter, &paired);
+                       g_variant_get(msg, "(b)", &paired);
 
                        ret_if(paired == FALSE);
 
@@ -1720,24 +1455,36 @@ void _bt_handle_device_event(DBusMessage *msg)
                                g_free(address);
                                return;
                        }
-
+                       GVariant *uuids = NULL;
+                       GVariantBuilder *builder = NULL;
+                       int i = 0;
+                       builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
+                       for (i=0; i < remote_dev_info->uuid_count; i++) {
+                               g_variant_builder_add(builder, "s",
+                                       remote_dev_info->uuids[i]);
+                       }
+                       uuids = g_variant_new("as", builder);
+                       g_variant_builder_unref(builder);
+                       GVariant *manufacturer_data = NULL;
+                       manufacturer_data = g_variant_new_from_data(
+                                               G_VARIANT_TYPE_BYTESTRING,
+                                               remote_dev_info->manufacturer_data,
+                                               remote_dev_info->manufacturer_data_len,
+                                               TRUE, NULL, NULL);
+                       param = g_variant_new("(isunsbub@asn@ay)", result,
+                                               address,
+                                               remote_dev_info->class,
+                                               remote_dev_info->rssi,
+                                               remote_dev_info->name,
+                                               remote_dev_info->paired,
+                                               remote_dev_info->connected,
+                                               remote_dev_info->trust,
+                                               uuids,
+                                               remote_dev_info->manufacturer_data_len,
+                                               manufacturer_data);
                        _bt_send_event(BT_ADAPTER_EVENT,
                                BLUETOOTH_EVENT_BONDING_FINISHED,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &address,
-                               DBUS_TYPE_UINT32, &remote_dev_info->class,
-                               DBUS_TYPE_INT16, &remote_dev_info->rssi,
-                               DBUS_TYPE_STRING, &remote_dev_info->name,
-                               DBUS_TYPE_BOOLEAN, &remote_dev_info->paired,
-                               DBUS_TYPE_BOOLEAN, &remote_dev_info->connected,
-                               DBUS_TYPE_BOOLEAN, &remote_dev_info->trust,
-                               DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
-                               &remote_dev_info->uuids, remote_dev_info->uuid_count,
-                               DBUS_TYPE_INT16, &remote_dev_info->manufacturer_data_len,
-                               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                               &remote_dev_info->manufacturer_data, remote_dev_info->manufacturer_data_len,
-                               DBUS_TYPE_INVALID);
-
+                               param);
                        _bt_free_device_info(remote_dev_info);
                        g_free(address);
 
@@ -1760,20 +1507,35 @@ void _bt_handle_device_event(DBusMessage *msg)
                        }
 
                        BT_DBG("UUID's count = %d", remote_dev_info->uuid_count);
-                       if (remote_dev_info->paired && remote_dev_info->uuid_count)
+                       if (remote_dev_info->paired && remote_dev_info->uuid_count) {
+                               GVariant *uuids = NULL;
+                               GVariantBuilder *builder = NULL;
+                               int i = 0;
+                               builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
+                               for (i=0; i < remote_dev_info->uuid_count; i++) {
+                                       g_variant_builder_add(builder, "s",
+                                               remote_dev_info->uuids[i]);
+                               }
+                               uuids = g_variant_new("as", builder);
+                               g_variant_builder_unref(builder);
+                               GVariant *manufacture_data = g_variant_new_from_data((const GVariantType *)"ay",
+                                               remote_dev_info->manufacturer_data, remote_dev_info->manufacturer_data_len,
+                                               TRUE, NULL, NULL);
+
+                               param = g_variant_new("(isunsbub@asn@ay)", result,
+                                                       address, remote_dev_info->class,
+                                                       remote_dev_info->rssi,
+                                                       remote_dev_info->name,
+                                                       remote_dev_info->paired,
+                                                       remote_dev_info->connected,
+                                                       remote_dev_info->trust,
+                                                       uuids,
+                                                       remote_dev_info->manufacturer_data_len,
+                                                       manufacture_data);
                                _bt_send_event(BT_ADAPTER_EVENT,
                                        BLUETOOTH_EVENT_SERVICE_SEARCHED,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &address,
-                                       DBUS_TYPE_UINT32, &remote_dev_info->class,
-                                       DBUS_TYPE_INT16, &remote_dev_info->rssi,
-                                       DBUS_TYPE_STRING, &remote_dev_info->name,
-                                       DBUS_TYPE_BOOLEAN, &remote_dev_info->paired,
-                                       DBUS_TYPE_BOOLEAN, &remote_dev_info->connected,
-                                       DBUS_TYPE_BOOLEAN, &remote_dev_info->trust,
-                                       DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
-                                       &remote_dev_info->uuids, remote_dev_info->uuid_count,
-                                       DBUS_TYPE_INVALID);
+                                       param);
+                       }
 
                        _bt_free_device_info(remote_dev_info);
                        g_free(address);
@@ -1781,56 +1543,49 @@ void _bt_handle_device_event(DBusMessage *msg)
        } else if (strcasecmp(member, "DeviceConnected") == 0) {
                unsigned char addr_type = 0;
 
-               dbus_message_iter_init(msg, &item_iter);
-               dbus_message_iter_get_basic(&item_iter, &addr_type);
+               g_variant_get(msg, "(y)", &addr_type);
 
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
 
                _bt_convert_device_path_to_address(path, address);
+               dev_name = _bt_get_bonded_device_name(address);
 
                BT_INFO("Address : %s Type : %d", address, addr_type);
-               BT_ERR_C("Connected [%s]", !addr_type ? "BREDR" : "LE");
+               BT_ERR_C("Connected [%s] [%s]", !addr_type ? "BREDR" : "LE",
+                               !addr_type ? dev_name : address);
+               g_free(dev_name);
 
                _bt_logging_connection(TRUE, addr_type);
-#if 0
                journal_bt_connected();
-#endif
-
+               param = g_variant_new("(isy)", result, address, addr_type);
                /*Send event to application*/
                _bt_send_event(BT_DEVICE_EVENT,
                                        BLUETOOTH_EVENT_DEVICE_CONNECTED,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &address,
-                                       DBUS_TYPE_BYTE, &addr_type,
-                                       DBUS_TYPE_INVALID);
-
+                                       param);
                g_free(address);
        } else if (strcasecmp(member, "Disconnected") == 0) {
                unsigned char disc_reason = 0;
                unsigned char addr_type = 0;
                gboolean sending = FALSE;
 
-               if (!dbus_message_get_args(msg, NULL,
-                               DBUS_TYPE_BYTE, &addr_type,
-                               DBUS_TYPE_BYTE, &disc_reason,
-                               DBUS_TYPE_INVALID))
-                       return;
+               g_variant_get(msg, "(yy)", &addr_type, &disc_reason);
 
                result = disc_reason;
 
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
 
                _bt_convert_device_path_to_address(path, address);
-#if 0
+               dev_name = _bt_get_bonded_device_name(address);
                journal_bt_disconnected();
-#endif
 
                /* 0x00 BDADDR_BRDER
                      0x01 BDADDR_LE_PUBLIC
                      0x02 BDADDR_LE_RANDOM */
                BT_INFO("Address : %s Type : %d", address, addr_type);
-               BT_ERR_C("Disconnected [%s] [%d : %s]", !addr_type ? "BREDR" : "LE",
-                               disc_reason, _bt_convert_disc_reason_to_string(disc_reason));
+               BT_ERR_C("Disconnected [%s] [%d : %s] [%s]", !addr_type ? "BREDR" : "LE",
+                               disc_reason, _bt_convert_disc_reason_to_string(disc_reason),
+                               !addr_type ? dev_name : address);
+               g_free(dev_name);
 
                _bt_headset_set_local_connection(FALSE);
                _bt_logging_connection(FALSE, addr_type);
@@ -1842,26 +1597,18 @@ void _bt_handle_device_event(DBusMessage *msg)
                _bt_opp_client_is_sending(&sending);
                if(sending == TRUE)
                        _bt_opp_client_check_pending_transfer(address);
-
+               param = g_variant_new("(isy)", result, address, addr_type);
                _bt_send_event(BT_DEVICE_EVENT,
                                        BLUETOOTH_EVENT_DEVICE_DISCONNECTED,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &address,
-                                       DBUS_TYPE_BYTE, &addr_type,
-                                       DBUS_TYPE_INVALID);
-
+                                       param);
                g_free(address);
        } else if (strcasecmp(member, "ProfileStateChanged") == 0) {
                int state = 0;
                char *profile_uuid = NULL;
                bt_headset_wait_t *wait_list;
 
-               if (!dbus_message_get_args(msg, NULL,
-                               DBUS_TYPE_STRING, &profile_uuid,
-                               DBUS_TYPE_INT32, &state,
-                               DBUS_TYPE_INVALID)) {
-                       return;
-               }
+               g_variant_get(msg, "(si)", &profile_uuid, &state);
+
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
 
                _bt_convert_device_path_to_address(path, address);
@@ -1891,12 +1638,9 @@ void _bt_handle_device_event(DBusMessage *msg)
                                 * intiate connection for pending profile */
                                _bt_headset_set_local_connection(FALSE);
                        }
-
+                       param = g_variant_new("(is)", result, address);
                        _bt_send_event(BT_HEADSET_EVENT, event,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &address,
-                               DBUS_TYPE_INVALID);
-
+                               param);
                        connected = _bt_is_headset_type_connected(BT_AUDIO_A2DP,
                                                connected_address);
                        if (connected) {
@@ -1924,6 +1668,7 @@ void _bt_handle_device_event(DBusMessage *msg)
 
                        if (!_bt_is_service_connected(address, BT_AUDIO_A2DP)) {
                                g_free(address);
+                               g_free(profile_uuid);
                                return;
                        }
 
@@ -1931,18 +1676,16 @@ void _bt_handle_device_event(DBusMessage *msg)
                                VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED);
 
                        __bt_connection_manager_set_state(address, event);
-
+                       param = g_variant_new("(is)", result, address);
                        _bt_send_event(BT_HEADSET_EVENT, event,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &address,
-                               DBUS_TYPE_INVALID);
-
+                               param);
                        /* Remove data from the connected list */
                        _bt_remove_headset_from_list(BT_AUDIO_A2DP, address);
                        wait_list = _bt_get_audio_wait_data();
 
                        if (wait_list == NULL) {
                                g_free(address);
+                               g_free(profile_uuid);
                                return;
                        }
 
@@ -1967,11 +1710,9 @@ void _bt_handle_device_event(DBusMessage *msg)
                                char connected_address[BT_ADDRESS_STRING_SIZE + 1];
                                bluetooth_device_address_t device_address;
                                gboolean connected;
-
+                               param = g_variant_new("(is)", result, address);
                                _bt_send_event(BT_AVRCP_CONTROL_EVENT, event,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &address,
-                                       DBUS_TYPE_INVALID);
+                                       param);
                                connected = _bt_is_headset_type_connected(
                                                        BT_AVRCP,
                                                        connected_address);
@@ -1991,14 +1732,23 @@ void _bt_handle_device_event(DBusMessage *msg)
                                                BT_STATE_CONNECTED, address);
                        } else if (state == BT_PROFILE_STATE_DISCONNECTED) {
                                int event = BLUETOOTH_EVENT_AVRCP_CONTROL_DISCONNECTED;
-
+                               param = g_variant_new("(is)", result, address);
                                _bt_send_event(BT_AVRCP_CONTROL_EVENT, event,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &address,
-                                       DBUS_TYPE_INVALID);
-
+                                       param);
                                /* Remove data from the connected list */
                                _bt_remove_headset_from_list(BT_AVRCP, address);
+                               }
+               } else if (strcasecmp(profile_uuid, A2DP_SOURCE_UUID) == 0) {
+                       if (state == BT_PROFILE_STATE_CONNECTED) {
+                               int event = BLUETOOTH_EVENT_AV_SOURCE_CONNECTED;
+                               BT_INFO("A2DP Source is connected");
+                               _bt_send_event(BT_A2DP_SOURCE_EVENT, event,
+                                       g_variant_new("(is)", result, address));
+                       } else if (state == BT_PROFILE_STATE_DISCONNECTED) {
+                               int event = BLUETOOTH_EVENT_AV_SOURCE_DISCONNECTED;
+                               BT_INFO("A2DP Source Disconnected");
+                               _bt_send_event(BT_A2DP_SOURCE_EVENT, event,
+                                               g_variant_new("(is)", result, address));
                        }
                } else if ((strcmp(profile_uuid, HID_UUID) == 0) &&
                        ((state == BT_PROFILE_STATE_CONNECTED) ||
@@ -2008,54 +1758,46 @@ void _bt_handle_device_event(DBusMessage *msg)
                                event = BLUETOOTH_HID_CONNECTED;
                        else
                                event = BLUETOOTH_HID_DISCONNECTED;
-
+                       param = g_variant_new("(is)", result, address);
                        _bt_send_event(BT_HID_EVENT, event,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &address,
-                               DBUS_TYPE_INVALID);
+                               param);
+
+                       if (state == BT_PROFILE_STATE_CONNECTED)
+                               __bt_set_device_values(TRUE,
+                                       VCONFKEY_BT_DEVICE_HID_CONNECTED);
+                       else
+                               __bt_set_device_values(FALSE,
+                                       VCONFKEY_BT_DEVICE_HID_CONNECTED);
                }
                g_free(address);
+               g_free(profile_uuid);
        } else if (strcasecmp(member, "AdvReport") == 0) {
 
                bt_remote_le_dev_info_t *le_dev_info = NULL;
                char *buffer = NULL;
                int buffer_len = 0;
                bt_le_adv_info_t *adv_info = NULL;
-
-               ret_if(_bt_is_le_discovering() == FALSE);
+               GVariant *value = NULL;
+               ret_if(_bt_is_le_scanning() == FALSE);
 
                le_dev_info = g_malloc0(sizeof(bt_remote_le_dev_info_t));
 
-               if (!dbus_message_get_args(msg, NULL,
-                               DBUS_TYPE_STRING, &le_dev_info->address,
-                               DBUS_TYPE_BYTE, &le_dev_info->addr_type,
-                               DBUS_TYPE_BYTE, &le_dev_info->adv_type,
-                               DBUS_TYPE_INT32, &le_dev_info->rssi,
-                               DBUS_TYPE_INT32, &le_dev_info->adv_data_len,
-                               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &buffer, &buffer_len,
-                               DBUS_TYPE_INVALID)) {
-                       g_free(le_dev_info);
-                       return;
-               }
+               g_variant_get(msg, "(syyii@ay)", &le_dev_info->address,
+                                               &le_dev_info->addr_type,
+                                               &le_dev_info->adv_type,
+                                               &le_dev_info->rssi,
+                                               &le_dev_info->adv_data_len,
+                                               &value);
+               buffer_len = g_variant_get_size(value);
+               if (buffer_len > 0)
+                       buffer = (char *)g_variant_get_data(value);
 
                le_dev_info->adv_data = g_memdup(buffer, buffer_len);
 
-               if (_bt_get_le_discovery_type() == BT_LE_PASSIVE_SCAN) {
-                               int len = 0;
-                               _bt_send_event(BT_LE_ADAPTER_EVENT,
-                                               BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND,
-                                               DBUS_TYPE_INT32, &result,
-                                               DBUS_TYPE_STRING, &le_dev_info->address,
-                                               DBUS_TYPE_INT16, &le_dev_info->addr_type,
-                                               DBUS_TYPE_INT16, &le_dev_info->rssi,
-                                               DBUS_TYPE_INT16, &le_dev_info->adv_data_len,
-                                               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                                               &le_dev_info->adv_data, le_dev_info->adv_data_len,
-                                               DBUS_TYPE_INT16, &len,
-                                               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                                               &le_dev_info->adv_data, len,
-                                               DBUS_TYPE_INVALID);
+               if (_bt_get_le_scan_type() == BT_LE_PASSIVE_SCAN) {
+                       _bt_send_scan_result_event(le_dev_info, NULL);
                        _bt_free_le_device_info(le_dev_info);
+                       g_variant_unref(value);
                        return;
                }
 
@@ -2072,24 +1814,14 @@ void _bt_handle_device_event(DBusMessage *msg)
                } else {     /* SCAN_RSP */
                        adv_info = __bt_get_adv_ind_info(le_dev_info->address);
                        if (adv_info) {
-                               _bt_send_event(BT_LE_ADAPTER_EVENT,
-                                               BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND,
-                                               DBUS_TYPE_INT32, &result,
-                                               DBUS_TYPE_STRING, &le_dev_info->address,
-                                               DBUS_TYPE_INT16, &le_dev_info->addr_type,
-                                               DBUS_TYPE_INT16, &le_dev_info->rssi,
-                                               DBUS_TYPE_INT16, &adv_info->data_len,
-                                               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                                               &adv_info->data, adv_info->data_len,
-                                               DBUS_TYPE_INT16, &le_dev_info->adv_data_len,
-                                               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                                               &le_dev_info->adv_data, le_dev_info->adv_data_len,
-                                               DBUS_TYPE_INVALID);
+                               _bt_send_scan_result_event(le_dev_info, adv_info);
                                __bt_del_adv_ind_info(le_dev_info->address);
                        }
                }
                _bt_free_le_device_info(le_dev_info);
+               g_variant_unref(value);
        }
+
 }
 
 void __bt_set_audio_values(gboolean connected, char *address)
@@ -2099,7 +1831,7 @@ void __bt_set_audio_values(gboolean connected, char *address)
 
        /*  Set the headset name */
        if (connected == TRUE) {
-               name = __bt_get_headset_name(address);
+               name = _bt_get_bonded_device_name(address);
        } else {
                name = g_strdup("");
        }
@@ -2139,44 +1871,31 @@ void __bt_set_audio_values(gboolean connected, char *address)
        }
 }
 
-void _bt_handle_headset_event(DBusMessage *msg)
+void _bt_handle_headset_event(GVariant *msg, const char *path)
 {
        int result = BLUETOOTH_ERROR_NONE;
-       DBusMessageIter item_iter;
-       DBusMessageIter value_iter;
        gboolean property_flag = FALSE;
-       const char *member = dbus_message_get_member(msg);
-       const char *path = dbus_message_get_path(msg);
-       const char *property = NULL;
-
-       ret_if(member == NULL);
-
-       dbus_message_iter_init(msg, &item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus");
-               return;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, &property);
+       char *property = NULL;
+       GVariant *value = NULL;
+       GVariant *param = NULL;
+       g_variant_get(msg, "(sv)", &property, &value);
 
        ret_if(property == NULL);
 
        BT_DBG("Property = %s \n", property);
-
        /* We allow only 1 headset connection (HSP or HFP)*/
        if (strcasecmp(property, "Connected") == 0) {
                int event = BLUETOOTH_EVENT_NONE;
                bt_headset_wait_t *wait_list;
                char *address;
-
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_recurse(&item_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &property_flag);
+               g_variant_get(value, "b", &property_flag);
 
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
 
+               /* Fix : NULL_RETURNS */
+               if (address == NULL)
+                       return;
+
                _bt_convert_device_path_to_address(path, address);
 
                if (property_flag == TRUE) {
@@ -2197,11 +1916,9 @@ void _bt_handle_headset_event(DBusMessage *msg)
                /* Set the State machine here */
                __bt_connection_manager_set_state(address, event);
                __bt_set_audio_values(property_flag, address);
-
+               param = g_variant_new("(is)", result, address);
                _bt_send_event(BT_HEADSET_EVENT, event,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &address,
-                       DBUS_TYPE_INVALID);
+                       param);
 
                if (event == BLUETOOTH_EVENT_AG_DISCONNECTED) {
                        /* Remove data from the connected list */
@@ -2239,9 +1956,7 @@ void _bt_handle_headset_event(DBusMessage *msg)
        } else if (strcasecmp(property, "State") == 0) {
                char *state = NULL;
 
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_recurse(&item_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &state);
+               g_variant_get(value, "s", &state);
 
                /* This code assumes we support only 1 headset connection */
                /* Need to use the headset list, if we support multi-headsets */
@@ -2252,8 +1967,10 @@ void _bt_handle_headset_event(DBusMessage *msg)
                        BT_DBG("connected/disconnected: Sco Disconnected");
                } else {
                        BT_ERR("Not handled state - %s", state);
+                       g_free(state);
                        return;
                }
+               g_free(state);
        } else if (strcasecmp(property, "SpeakerGain") == 0) {
                guint16 spkr_gain;
                char *address;
@@ -2262,15 +1979,10 @@ void _bt_handle_headset_event(DBusMessage *msg)
 
                _bt_convert_device_path_to_address(path, address);
 
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_recurse(&item_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &spkr_gain);
-
+               g_variant_get(value, "i", &spkr_gain);
+               param = g_variant_new("(isq)", result, address, spkr_gain);
                _bt_send_event(BT_HEADSET_EVENT, BLUETOOTH_EVENT_AG_SPEAKER_GAIN,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &address,
-                       DBUS_TYPE_UINT16, &spkr_gain,
-                       DBUS_TYPE_INVALID);
+                       param);
 
                g_free(address);
        } else if (strcasecmp(property, "MicrophoneGain") == 0) {
@@ -2281,158 +1993,148 @@ void _bt_handle_headset_event(DBusMessage *msg)
 
                _bt_convert_device_path_to_address(path, address);
 
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_recurse(&item_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &mic_gain);
-
+               g_variant_get(value, "i", &mic_gain);
+               param = g_variant_new("(isq)", result, address, mic_gain);
                _bt_send_event(BT_HEADSET_EVENT, BLUETOOTH_EVENT_AG_MIC_GAIN,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &address,
-                       DBUS_TYPE_UINT16, &mic_gain,
-                       DBUS_TYPE_INVALID);
-
+                       param);
                g_free(address);
        }
-}
 
-void _bt_handle_sink_event(DBusMessage *msg)
+       if (property)
+               g_free(property);
+       g_variant_unref(value);
+ }
+
+void _bt_handle_sink_event(GVariant *msg, const char *path)
 {
-       int result = BLUETOOTH_ERROR_NONE;
-       DBusMessageIter item_iter;
-       DBusMessageIter value_iter;
-       const char *member = dbus_message_get_member(msg);
-       const char *path = dbus_message_get_path(msg);
-       const char *property = NULL;
+       GVariantIter value_iter;
+       char *property = NULL;
 
        bt_headset_wait_t *wait_list;
 
-       ret_if(member == NULL);
+       GVariant *child = NULL;
+       GVariant *val = NULL;
+       GVariant *param = NULL;
+       g_variant_iter_init (&value_iter, msg);
+       while ((child = g_variant_iter_next_value (&value_iter))) {
 
-       dbus_message_iter_init(msg, &item_iter);
+               g_variant_get(child, "{sv}", &property, &val);
 
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus");
-               return;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, &property);
+               ret_if(property == NULL);
 
-       ret_if(property == NULL);
+               BT_DBG("Property = %s \n", property);
 
-       BT_DBG("Property: %s", property);
 
-       if (strcasecmp(property, "State") == 0) {
+               if (strcasecmp(property, "State") == 0) {
+                       int result = BLUETOOTH_ERROR_NONE;
+                       char *value;
 
-               const char *value;
+                       g_variant_get(val, "s", &value);
+                       BT_DBG("value: %s", value);
 
-               dbus_message_iter_next(&item_iter);
-               dbus_message_iter_recurse(&item_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &value);
+                       if (g_strcmp0(value, "disconnected") == 0) {
+                               char *address;
 
-               BT_DBG("value: %s", value);
+                               address = g_malloc0(BT_ADDRESS_STRING_SIZE);
 
-               if (g_strcmp0(value, "disconnected") == 0) {
-                       char *address;
+                               _bt_convert_device_path_to_address(path, address);
 
-                       address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-
-                       _bt_convert_device_path_to_address(path, address);
+                               __bt_set_device_values(FALSE,
+                                       VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED);
+                               param = g_variant_new("(is)", result, address);
+                               _bt_send_event(BT_HEADSET_EVENT,
+                                       BLUETOOTH_EVENT_AV_DISCONNECTED,
+                                       param);
 
-                       __bt_set_device_values(FALSE,
-                               VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED);
+                               /* Remove data from the connected list */
+                               _bt_remove_headset_from_list(BT_AUDIO_A2DP, address);
+                               wait_list = _bt_get_audio_wait_data();
+                               if (wait_list == NULL) {
+                                       g_free(value);
+                                       g_free(property);
+                                       g_variant_unref(val);
+                                       g_variant_unref(child);
+                                       g_free(address);
+                                       return;
+                               }
 
-                       _bt_send_event(BT_HEADSET_EVENT,
-                               BLUETOOTH_EVENT_AV_DISCONNECTED,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &address,
-                               DBUS_TYPE_INVALID);
+                               if (((wait_list->type == BT_AUDIO_ALL) &&
+                                       (wait_list->ag_flag == TRUE)) ||
+                                       (wait_list->type == BT_AUDIO_A2DP) ||
+                                       (wait_list->disconnection_type == BT_AUDIO_A2DP)) {
+                                       bluetooth_device_address_t device_address;
+                                       _bt_convert_addr_string_to_type(
+                                                               device_address.addr,
+                                                               wait_list->address);
 
-                       /* Remove data from the connected list */
-                       _bt_remove_headset_from_list(BT_AUDIO_A2DP, address);
-                       wait_list = _bt_get_audio_wait_data();
-                       if (wait_list == NULL) {
+                                       _bt_audio_connect(wait_list->req_id,
+                                                               wait_list->type,
+                                                               &device_address,
+                                                               wait_list->out_param1);
+                               }
                                g_free(address);
-                               return;
-                       }
-
-                       if (((wait_list->type == BT_AUDIO_ALL) &&
-                               (wait_list->ag_flag == TRUE)) ||
-                               (wait_list->type == BT_AUDIO_A2DP) ||
-                               (wait_list->disconnection_type == BT_AUDIO_A2DP)) {
+                       }else if (strcasecmp(value, "Connected") == 0) {
+                               char *address;
+                               char connected_address[BT_ADDRESS_STRING_SIZE + 1];
                                bluetooth_device_address_t device_address;
-                               _bt_convert_addr_string_to_type(
-                                                       device_address.addr,
-                                                       wait_list->address);
-
-                               _bt_audio_connect(wait_list->req_id,
-                                                       wait_list->type,
-                                                       &device_address,
-                                                       wait_list->out_param1);
-                       }
-                       g_free(address);
-               }else if (strcasecmp(value, "Connected") == 0) {
-                       char *address;
-                       char connected_address[BT_ADDRESS_STRING_SIZE + 1];
-                       bluetooth_device_address_t device_address;
-                       gboolean connected;
+                               gboolean connected;
 
-                       address = g_malloc0(BT_ADDRESS_STRING_SIZE);
+                               address = g_malloc0(BT_ADDRESS_STRING_SIZE);
 
-                       _bt_convert_device_path_to_address(path, address);
-
-                       __bt_set_device_values(TRUE,
-                                       VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED);
+                               _bt_convert_device_path_to_address(path, address);
 
-                       _bt_send_event(BT_HEADSET_EVENT,
-                               BLUETOOTH_EVENT_AV_CONNECTED,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &address,
-                               DBUS_TYPE_INVALID);
-
-                       /* Check for existing Media device to disconnect */
-                       connected = _bt_is_headset_type_connected(BT_AUDIO_A2DP,
+                               __bt_set_device_values(TRUE,
+                                               VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED);
+                               param = g_variant_new("(is)", result, address);
+                               _bt_send_event(BT_HEADSET_EVENT,
+                                       BLUETOOTH_EVENT_AV_CONNECTED,
+                                       param);
+                               /* Check for existing Media device to disconnect */
+                               connected = _bt_is_headset_type_connected(BT_AUDIO_A2DP,
+                                                                       connected_address);
+                               if (connected) {
+                                       /* Match connected device address */
+                                       if (g_strcmp0(connected_address, address) != 0) {
+                                               /* Convert BD adress from string type */
+                                               _bt_convert_addr_string_to_type(
+                                                               device_address.addr,
                                                                connected_address);
-                       if (connected) {
-                               /* Match connected device address */
-                               if (g_strcmp0(connected_address, address) != 0) {
-                                       /* Convert BD adress from string type */
-                                       _bt_convert_addr_string_to_type(
-                                                       device_address.addr,
-                                                       connected_address);
-                                       _bt_audio_disconnect(0, BT_AUDIO_A2DP,
-                                                       &device_address, NULL);
+                                               _bt_audio_disconnect(0, BT_AUDIO_A2DP,
+                                                               &device_address, NULL);
+                                       }
                                }
-                       }
 
-                       /* Add data to the connected list */
-                       _bt_add_headset_to_list(BT_AUDIO_A2DP,
-                                       BT_STATE_CONNECTED, address);
+                               /* Add data to the connected list */
+                               _bt_add_headset_to_list(BT_AUDIO_A2DP,
+                                               BT_STATE_CONNECTED, address);
 
-                       g_free(address);
+                               g_free(address);
+                       }
+                       g_free(value);
                }
+               g_free(property);
+               g_variant_unref(val);
+               g_variant_unref(child);
        }
 }
 
-void _bt_handle_agent_event(DBusMessage *msg)
+void _bt_handle_agent_event(GVariant *msg, const char *member)
 {
-       const char *member = dbus_message_get_member(msg);
        int result = BLUETOOTH_ERROR_NONE;
        char *address = NULL;
        char *name = NULL;
        char *uuid = NULL;
-
+       GVariant *param = NULL;
        ret_if(member == NULL);
 
        if (strcasecmp(member, "ObexAuthorize") == 0) {
                __bt_get_agent_signal_info(msg, &address, &name, &uuid);
-
+               param = g_variant_new("(iss)", result, address, name);
                _bt_send_event(BT_OPP_SERVER_EVENT,
                        BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &address,
-                       DBUS_TYPE_STRING, &name,
-                       DBUS_TYPE_INVALID);
+                       param);
+               g_free(address);
+               g_free(name);
        } else if (strcasecmp(member, "RfcommAuthorize") == 0) {
                bt_rfcomm_server_info_t *server_info;
 
@@ -2441,193 +2143,114 @@ void _bt_handle_agent_event(DBusMessage *msg)
                server_info = _bt_rfcomm_get_server_info_using_uuid(uuid);
                ret_if(server_info == NULL);
                ret_if(server_info->server_type != BT_CUSTOM_SERVER);
-
+               param = g_variant_new("(isssn)", result, address, uuid, name,
+                                       server_info->control_fd);
                _bt_send_event(BT_RFCOMM_SERVER_EVENT,
                        BLUETOOTH_EVENT_RFCOMM_AUTHORIZE,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &address,
-                       DBUS_TYPE_STRING, &uuid,
-                       DBUS_TYPE_STRING, &name,
-                       DBUS_TYPE_INT16, &server_info->control_fd,
-                       DBUS_TYPE_INVALID);
+                       param);
+               g_free(address);
+               g_free(uuid);
+               g_free(name);
        }
 }
 
-static int __bt_get_object_path(DBusMessage *msg, char **path)
+static int __bt_get_object_path(GVariant *msg, char **path)
 {
-       DBusMessageIter item_iter;
-
-       dbus_message_iter_init(msg, &item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_OBJECT_PATH) {
-               BT_ERR("This is bad format dbus");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_get_basic(&item_iter, path);
-
+       g_variant_get(msg, "(o*)", path, NULL);
        if (*path == NULL)
                return BLUETOOTH_ERROR_INTERNAL;
 
        return BLUETOOTH_ERROR_NONE;
 }
 
-static int __bt_parse_event(DBusMessage *msg)
+static void __bt_devices_list_free(void)
 {
-       DBusMessageIter msg_iter;
-       DBusMessageIter value_iter;
-
-       retv_if(dbus_message_iter_init(msg, &msg_iter) == FALSE, 0);
-
-       /* object array (oa) */
-       retv_if(dbus_message_iter_next(&msg_iter) == FALSE, 0);
-       retv_if(dbus_message_iter_get_arg_type(&msg_iter) !=
-                                       DBUS_TYPE_ARRAY, 0);
-
-       dbus_message_iter_recurse(&msg_iter, &value_iter);
-
-       /* string array (sa) */
-       while (dbus_message_iter_get_arg_type(&value_iter) ==
-                                       DBUS_TYPE_DICT_ENTRY) {
-               char *interface_name = NULL;
-               DBusMessageIter interface_iter;
-
-               dbus_message_iter_recurse(&value_iter, &interface_iter);
+       bt_cache_info_t *cache_info;
+       GList *node;
 
-               retv_if(dbus_message_iter_get_arg_type(&interface_iter) !=
-                                               DBUS_TYPE_STRING, 0);
+       node = g_list_first(p_cache_list);
 
-               dbus_message_iter_get_basic(&interface_iter,
-                                               &interface_name);
+       while (node != NULL){
+               cache_info = (bt_cache_info_t *)node->data;
+               p_cache_list = g_list_remove(p_cache_list, cache_info);
+               __bt_free_cache_info(cache_info);
 
-                retv_if(dbus_message_iter_next(&interface_iter) == FALSE,
-                                                               0);
+               node = g_list_next(node);
+       }
+}
 
-               retv_if(dbus_message_iter_get_arg_type(&interface_iter) !=
-                                       DBUS_TYPE_ARRAY, 0);
+static int __bt_parse_event(GVariant *msg)
+{
+       GVariantIter iter;
+       GVariant *child;
+       char *interface_name= NULL;
+       GVariant *inner_iter = NULL;
 
-               BT_DBG("interface: %s", interface_name);
+       g_variant_iter_init(&iter, msg);
 
+       while ((child = g_variant_iter_next_value(&iter))) {
+               g_variant_get(child,"{&s@a{sv}}", &interface_name, &inner_iter);
                if (g_strcmp0(interface_name,
                                BT_DEVICE_INTERFACE) == 0) {
+                       g_variant_unref(inner_iter);
+                       g_variant_unref(child);
                        return BT_DEVICE_EVENT;
                } else if (g_strcmp0(interface_name,
                                BT_MEDIATRANSPORT_INTERFACE) == 0) {
+                       g_variant_unref(inner_iter);
+                       g_variant_unref(child);
                        return BT_MEDIA_TRANSFER_EVENT;
-       #if 0
                } else if (g_strcmp0(interface_name,
                                BT_PLAYER_CONTROL_INTERFACE) == 0) {
+                       g_variant_unref(inner_iter);
+                       g_variant_unref(child);
                        return BT_AVRCP_CONTROL_EVENT;
-#endif
                }
-               dbus_message_iter_next(&value_iter);
+               g_variant_unref(inner_iter);
+               g_variant_unref(child);
        }
 
        return 0;
 }
 
-static int __bt_parse_remove_event(DBusMessage *msg)
+static  void __bt_manager_event_filter(GDBusConnection *connection,
+                                       const gchar *sender_name,
+                                       const gchar *object_path,
+                                       const gchar *interface_name,
+                                       const gchar *signal_name,
+                                       GVariant *parameters,
+                                       gpointer user_data)
 {
-       DBusMessageIter msg_iter;
-       DBusMessageIter value_iter;
-
-       retv_if(dbus_message_iter_init(msg, &msg_iter) ==
-                                       FALSE, 0);
-
-       retv_if(dbus_message_iter_next(&msg_iter) == FALSE,
-                                               0);
-       retv_if(dbus_message_iter_get_arg_type(&msg_iter) !=
-                                       DBUS_TYPE_ARRAY, 0);
-
-       dbus_message_iter_recurse(&msg_iter, &value_iter);
-
-       while (dbus_message_iter_get_arg_type(&value_iter)
-                                       != DBUS_TYPE_INVALID) {
-               char *key;
-
-               dbus_message_iter_get_basic(&value_iter, &key);
-
-               if (key == NULL) {
-                       dbus_message_iter_next(&value_iter);
-                       continue;
-               }
-
-               BT_DBG("key = %s", key);
-
-               if (g_strcmp0(key, BT_MEDIATRANSPORT_INTERFACE) == 0) {
-                       return BT_MEDIA_TRANSFER_EVENT;
-               } else if (g_strcmp0(key, BT_DEVICE_INTERFACE) == 0) {
-                       return BT_DEVICE_EVENT;
-               } else if (g_strcmp0(key, BT_PLAYER_CONTROL_INTERFACE) == 0) {
-                       return BT_AVRCP_CONTROL_EVENT;
-               }
-               dbus_message_iter_next(&value_iter);
-       }
-
-       return 0;
-}
-
-static void __bt_devices_list_free(void)
-{
-       bt_cache_info_t *cache_info;
-       GList *node;
-
-       node = g_list_first(p_cache_list);
-
-       while (node != NULL){
-               cache_info = (bt_cache_info_t *)node->data;
-
-               p_cache_list = g_list_remove(p_cache_list, cache_info);
-               __bt_free_cache_info(cache_info);
-
-               node = g_list_next(node);
-       }
-}
-
-static DBusHandlerResult __bt_manager_event_filter(DBusConnection *conn,
-                                          DBusMessage *msg, void *data)
-{
-       const char *member = dbus_message_get_member(msg);
-       bt_event_type_t bt_event;
+       bt_event_type_t bt_event = 0x00;
        int result = BLUETOOTH_ERROR_NONE;
+       GVariant *value;
+       char *obj_path = NULL;
+       GVariant *param = NULL;
+       if (signal_name == NULL)
+               return;
+       if (strcasecmp(signal_name, "InterfacesAdded") == 0) {
+               g_variant_get(parameters, "(&o@a{sa{sv}})", &obj_path, &value);
 
-       if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL)
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
-       retv_if(member == NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
-
-       if (strcasecmp(member, "InterfacesAdded") == 0) {
-
-               char *object_path = NULL;
-
-               BT_DBG("InterfacesAdded");
-
-               if (__bt_get_object_path(msg, &object_path)) {
-                       BT_ERR("Fail to get the path");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-               }
-
-               if (strcasecmp(object_path, BT_BLUEZ_HCI_PATH) == 0) {
+               if (strcasecmp(obj_path, BT_BLUEZ_HCI_PATH) == 0)
                        _bt_handle_adapter_added();
-               else {
-                       bt_event = __bt_parse_event(msg);
+               else {
+                       bt_event = __bt_parse_event(value);
                        if (bt_event == BT_DEVICE_EVENT) {
                                bt_cache_info_t *cache_info;
                                bt_remote_dev_info_t *dev_info;
 
-                               retv_if(_bt_is_discovering() == FALSE &&
-                                               _bt_is_le_discovering() == FALSE,
-                                                       DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
+                               ret_if(_bt_is_discovering() == FALSE &&
+                                               _bt_is_le_scanning() == FALSE);
 
                                cache_info = g_malloc0(sizeof(bt_cache_info_t));
                                dev_info = g_malloc0(sizeof(bt_remote_dev_info_t));
                                cache_info->dev_info = dev_info;
 
-                               if (__bt_parse_interface(msg, dev_info) == FALSE) {
+                               if (__bt_parse_interface(parameters, dev_info) == FALSE) {
                                        BT_ERR("Fail to parse the properies");
                                        __bt_free_cache_info(cache_info);
-                                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+                                       g_variant_unref(value);
+                                       return;
                                }
 
                                if (dev_info->addr_type != BDADDR_BREDR) {
@@ -2635,7 +2258,8 @@ static DBusHandlerResult __bt_manager_event_filter(DBusConnection *conn,
                                                some property doesn't reach to bt-service.
                                                So LE device is handled as AdvReport signal */
                                        __bt_free_cache_info(cache_info);
-                                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+                                       g_variant_unref(value);
+                                       return;
                                }
 
                                if (dev_info->name == NULL)
@@ -2644,48 +2268,78 @@ static DBusHandlerResult __bt_manager_event_filter(DBusConnection *conn,
                                         */
                                        dev_info->name = g_strdup(dev_info->address);
 
+                               GVariant *uuids = NULL;
+                               GVariantBuilder *builder = NULL;
+                               int i = 0;
+                               builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
+                               for (i=0; i < dev_info->uuid_count; i++) {
+                                       g_variant_builder_add(builder, "s",
+                                               dev_info->uuids[i]);
+                               }
+                               uuids = g_variant_new("as", builder);
+                               g_variant_builder_unref(builder);
+                               GVariant *manufacturer_data = NULL;
+                               manufacturer_data = g_variant_new_from_data(
+                                                       G_VARIANT_TYPE_BYTESTRING,
+                                                       dev_info->manufacturer_data,
+                                                       dev_info->manufacturer_data_len,
+                                                       TRUE, NULL, NULL);
+                               param = g_variant_new("(isunsbub@asn@ay)", result,
+                                                       dev_info->address,
+                                                       dev_info->class,
+                                                       dev_info->rssi,
+                                                       dev_info->name,
+                                                       dev_info->paired,
+                                                       dev_info->connected,
+                                                       dev_info->trust,
+                                                       uuids,
+                                                       dev_info->manufacturer_data_len,
+                                                       manufacturer_data);
                                _bt_send_event(BT_ADAPTER_EVENT,
                                        BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &dev_info->address,
-                                       DBUS_TYPE_UINT32, &dev_info->class,
-                                       DBUS_TYPE_INT16, &dev_info->rssi,
-                                       DBUS_TYPE_STRING, &dev_info->name,
-                                       DBUS_TYPE_BOOLEAN, &dev_info->paired,
-                                       DBUS_TYPE_BOOLEAN, &dev_info->connected,
-                                       DBUS_TYPE_BOOLEAN, &dev_info->trust,
-                                       DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
-                                       &dev_info->uuids, dev_info->uuid_count,
-                                       DBUS_TYPE_INT16, &dev_info->manufacturer_data_len,
-                                       DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                                       &dev_info->manufacturer_data, dev_info->manufacturer_data_len,
-                                       DBUS_TYPE_INVALID);
-
+                                        param);
                                p_cache_list = g_list_append(p_cache_list, cache_info);
+                       } else if (bt_event == BT_AVRCP_CONTROL_EVENT) {
+                               BT_DBG("Device path : %s ", obj_path);
+                               _bt_set_control_device_path(obj_path);
                        }
                }
-       } else if (strcasecmp(member, "InterfacesRemoved") == 0) {
-
-               bt_event = __bt_parse_remove_event(msg);
-
-               if ((bt_event != 0) && (bt_event != BT_MEDIA_TRANSFER_EVENT))
-                       _bt_handle_adapter_event(msg);
-
-       } else if (strcasecmp(member, "NameOwnerChanged") == 0) {
+               g_variant_unref(value);
+       } else if (strcasecmp(signal_name, "InterfacesRemoved") == 0) {
+               if (g_strcmp0(interface_name, BT_MEDIATRANSPORT_INTERFACE) == 0) {
+                       bt_event = BT_MEDIA_TRANSFER_EVENT;
+               } else if (g_strcmp0(interface_name, BT_DEVICE_INTERFACE) == 0) {
+                       bt_event = BT_DEVICE_EVENT;
+               } else if (g_strcmp0(interface_name, BT_PLAYER_CONTROL_INTERFACE) == 0) {
+                       bt_event = BT_AVRCP_CONTROL_EVENT;
+               }
+               if ((bt_event != 0) && (bt_event != BT_MEDIA_TRANSFER_EVENT)) {
+                       _bt_handle_adapter_event(parameters, signal_name);
+                       if (bt_event == BT_AVRCP_CONTROL_EVENT) {
+                               BT_INFO("Object Path %s", obj_path);
+                               _bt_remove_control_device_path(obj_path);
+                       }
+               }
+       } else if (strcasecmp(signal_name, "NameOwnerChanged") == 0) {
                gboolean value;
                char *name = NULL;
                char *previous = NULL;
                char *current = NULL;
 
-               BT_DBG("NameOwnerChanged");
-
-               if (__bt_get_owner_info(msg, &name, &previous, &current)) {
+               if (__bt_get_owner_info(parameters, &name, &previous, &current)) {
                        BT_ERR("Fail to get the owner info");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+                       return;
                }
 
-               if (*current != '\0')
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+               if (*current != '\0') {
+                       if (name)
+                               g_free(name);
+                       if (previous)
+                               g_free(previous);
+                       if (current)
+                               g_free(current);
+                       return;
+               }
 
                if (strcasecmp(name, BT_BLUEZ_NAME) == 0) {
                        BT_DBG("Bluetoothd is terminated");
@@ -2709,66 +2363,50 @@ static DBusHandlerResult __bt_manager_event_filter(DBusConnection *conn,
                        /* The obex server was terminated abnormally */
                        _bt_rfcomm_server_check_termination(name);
                }
-       } else  if (dbus_message_has_interface(msg, BT_PROPERTIES_INTERFACE)) {
-               const char *path = dbus_message_get_path(msg);
+
+               /* Stop advertising started by terminated process */
+               _bt_stop_advertising_by_terminated_process(name);
+               /* Stop LE Scan */
+               _bt_stop_le_scan(name);
+               g_free(name);
+               g_free(previous);
+               g_free(current);
+       } else if (g_strcmp0(interface_name, BT_PROPERTIES_INTERFACE) == 0) {
+               const char *path = object_path;
 
                if (strncmp(path, BT_MEDIA_OBJECT_PATH,
                                strlen(BT_MEDIA_OBJECT_PATH)) == 0)
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
-               _bt_handle_property_changed_event(msg);
-       } else  if (dbus_message_has_interface(msg, BT_ADAPTER_INTERFACE)) {
-               _bt_handle_adapter_event(msg);
-       } else  if (dbus_message_has_interface(msg, BT_INPUT_INTERFACE)) {
-               _bt_handle_input_event(msg);
-       } else  if (dbus_message_has_interface(msg, BT_NETWORK_SERVER_INTERFACE)) {
-               _bt_handle_network_server_event(msg);
-       } else  if (dbus_message_has_interface(msg, BT_HEADSET_INTERFACE)) {
-               _bt_handle_headset_event(msg);
-       } else  if (dbus_message_has_interface(msg, BT_SINK_INTERFACE)) {
-               _bt_handle_sink_event(msg);
-       } else  if (dbus_message_has_interface(msg, BT_AGENT_INTERFACE)) {
-               _bt_handle_agent_event(msg);
-       } else  if (dbus_message_has_interface(msg, BT_DEVICE_INTERFACE)) {
-               _bt_handle_device_event(msg);
-       }
+                       return;
 
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+               _bt_handle_property_changed_event(parameters, object_path);
+       } else if (g_strcmp0(interface_name, BT_ADAPTER_INTERFACE) == 0) {
+               _bt_handle_adapter_event(parameters, signal_name);
+       } else if (g_strcmp0(interface_name, BT_INPUT_INTERFACE) == 0) {
+               _bt_handle_input_event(parameters, object_path);
+       } else if (g_strcmp0(interface_name, BT_NETWORK_SERVER_INTERFACE) == 0) {
+               _bt_handle_network_server_event(parameters, signal_name);
+       } else if (g_strcmp0(interface_name, BT_HEADSET_INTERFACE) == 0) {
+               _bt_handle_headset_event(parameters, object_path);
+       } else if (g_strcmp0(interface_name, BT_SINK_INTERFACE) == 0) {
+               _bt_handle_sink_event(parameters, object_path);
+       } else if (g_strcmp0(interface_name, BT_AGENT_INTERFACE) == 0) {
+               _bt_handle_agent_event(parameters, signal_name);
+       } else if (g_strcmp0(interface_name, BT_DEVICE_INTERFACE) == 0) {
+               _bt_handle_device_event(parameters, signal_name, object_path);
+       }
+
+       return;
 }
 
-static gboolean __bt_is_obexd_event(DBusMessage *msg)
+static gboolean __bt_is_obexd_event(GVariant *msg, const char *interface)
 {
-       const char *member = dbus_message_get_member(msg);
-
-       if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL)
-               return FALSE;
-
-       retv_if(member == NULL, FALSE);
-
-       if (dbus_message_has_interface(msg, BT_PROPERTIES_INTERFACE)) {
-
-               DBusMessageIter item_iter;
-               const char *interface_name = NULL;
 
-               dbus_message_iter_init(msg, &item_iter);
-
-               if (dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_STRING) {
-                       BT_ERR("This is bad format dbus");
-                       return FALSE;
-                }
-
-               dbus_message_iter_get_basic(&item_iter, &interface_name);
+       if (g_strcmp0(interface, BT_PROPERTIES_INTERFACE) == 0) {
+               char *interface_name = NULL;
 
+               g_variant_get(msg,"(&s@a{sv}@as)", &interface_name, NULL, NULL);
                retv_if(interface_name == NULL, FALSE);
 
-               BT_DBG("interface: %s", interface_name);
-
-               retv_if(dbus_message_iter_next(&item_iter) == FALSE, FALSE);
-
-               retv_if(dbus_message_iter_get_arg_type(&item_iter) != DBUS_TYPE_ARRAY,
-                                                                       FALSE);
-
                if (strcasecmp(interface_name, BT_OBEX_TRANSFER_INTERFACE) == 0) {
                        BT_DBG("BT_OBEX_TRANSFER_INTERFACE");
                        return TRUE;
@@ -2778,123 +2416,90 @@ static gboolean __bt_is_obexd_event(DBusMessage *msg)
        return FALSE;
 }
 
-void __bt_opc_property_changed_event(DBusMessageIter *msg_iter,
-                                               const char *path)
-{
-       DBusMessageIter value_iter;
-       DBusMessageIter dict_iter;
-       DBusMessageIter item_iter;
-       const char *property = NULL;
-
-       dbus_message_iter_recurse(msg_iter, &item_iter);
-
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                               != DBUS_TYPE_DICT_ENTRY) {
-               BT_ERR("This is bad format dbus");
-               return;
-       }
-
-       dbus_message_iter_recurse(&item_iter, &dict_iter);
-
-       dbus_message_iter_get_basic(&dict_iter, &property);
-       ret_if(property == NULL);
-
-       ret_if(!dbus_message_iter_next(&dict_iter));
-
-       if (strcasecmp(property, "Status") == 0) {
-               const char *status = NULL;
-               dbus_message_iter_recurse(&dict_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &status);
-
-               BT_INFO("Status is %s", status);
-
-               if(strcasecmp(status, "active") == 0){
-                       _bt_obex_client_started(path);
-               }else if (strcasecmp(status, "complete") == 0) {
-                       _bt_obex_client_completed(path, TRUE);
-               }else if (strcasecmp(status, "error") == 0){
-                       _bt_obex_client_completed(path, FALSE);
-               }
-       } else if (strcasecmp(property, "Transferred") == 0) {
-               static int transferred  = 0;
-               dbus_message_iter_recurse(&dict_iter, &value_iter);
-               dbus_message_iter_get_basic(&value_iter, &transferred);
-
-               _bt_obex_client_progress(path, transferred);
-       } else {
-               BT_DBG("property : [%s]", property);
-       }
-}
-
-void _bt_opc_property_changed_event(DBusMessage *msg)
+static  void __bt_obexd_event_filter(GDBusConnection *connection,
+                                       const gchar *sender_name,
+                                       const gchar *object_path,
+                                       const gchar *interface_name,
+                                       const gchar *signal_name,
+                                       GVariant *parameters,
+                                       gpointer user_data)
 {
-       DBusMessageIter item_iter;
-       const char *member = dbus_message_get_member(msg);
-       const char *interface_name = NULL;
-
+       const char *member = signal_name;
+       char *obj_path = NULL;
        ret_if(member == NULL);
 
-       dbus_message_iter_init(msg, &item_iter);
+       if (strcasecmp(member, "InterfacesAdded") == 0) {
+               if (__bt_get_object_path(parameters, &obj_path)) {
+                       BT_ERR("Fail to get the path");
+                       return;
+               }
+               BT_INFO("object_path = [%s]", object_path);
 
-       if (dbus_message_iter_get_arg_type(&item_iter)
-                               != DBUS_TYPE_STRING) {
-               BT_ERR("This is bad format dbus");
-               return;
-       }
+               /*Handle OPP_SERVER_CONNECTED_EVENT here */
+               if (strncmp(obj_path, BT_SESSION_BASEPATH_SERVER,
+                               strlen(BT_SESSION_BASEPATH_SERVER)) != 0) {
+                       g_free(obj_path);
+                       return;
+               }
 
-       dbus_message_iter_get_basic(&item_iter, &interface_name);
+               if (g_strrstr(obj_path, "session") && g_strrstr(obj_path, "transfer")) {
+                       BT_DBG("Obex_Server_Session_Transfer connected");
+                       _bt_obex_transfer_connected();
+               }
+               g_free(obj_path);
+       } else if (strcasecmp(member, "InterfacesRemoved") == 0) {
+               /*Handle OPP_SERVER_DISCONNECTED_EVENT here */
+               if (__bt_get_object_path(parameters, &obj_path)) {
+                       BT_ERR("Fail to get the path");
+                       return;
+               }
+               BT_INFO("object_path = [%s]", object_path);
 
-       ret_if(interface_name == NULL);
+               if (strncmp(obj_path, BT_SESSION_BASEPATH_CLIENT,
+                               strlen(BT_SESSION_BASEPATH_CLIENT)) == 0) {
+                       BT_DBG("Call PBAP Disconnected");
+                       _bt_obex_pbap_client_disconnect(obj_path);
+               }
 
-       BT_DBG("interface: %s", interface_name);
+               if (strncmp(obj_path, BT_SESSION_BASEPATH_SERVER,
+                               strlen(BT_SESSION_BASEPATH_SERVER)) != 0) {
+                       g_free(obj_path);
+                       return;
+               }
 
-       ret_if(dbus_message_iter_next(&item_iter) == FALSE);
+               if (g_strrstr(obj_path, "session") && g_strrstr(obj_path, "transfer")) {
+                       BT_DBG("Obex_Server_Session_Transfer disconnected");
+                       _bt_obex_transfer_disconnected();
+               }
+               g_free(obj_path);
+       } else if (__bt_is_obexd_event(parameters, interface_name) == TRUE) {
+               const char *path = object_path;
 
-       ret_if(dbus_message_iter_get_arg_type(&item_iter) != DBUS_TYPE_ARRAY);
+               if (strncmp(path, BT_SESSION_BASEPATH_SERVER,
+                               strlen(BT_SESSION_BASEPATH_SERVER)) != 0 &&
+                       strncmp(path, BT_SESSION_BASEPATH_CLIENT,
+                               strlen(BT_SESSION_BASEPATH_CLIENT)) != 0) {
+                       BT_DBG("DBUS_HANDLER_RESULT_NOT_YET_HANDLED");
+                       return;
+               }
 
-       if (strcasecmp(interface_name, BT_OBEX_TRANSFER_INTERFACE) == 0) {
-               __bt_opc_property_changed_event(&item_iter,
-                                       dbus_message_get_path(msg));
-       } else {
-               BT_DBG("interface_name : [%s]", interface_name);
+               _bt_handle_property_changed_event(parameters, path);
        }
+       BT_DBG("-");
+       return;
 }
 
-static gboolean __bt_is_obexd_client_event(DBusMessage *msg)
+static gboolean __bt_is_obexd_client_event(GVariant *msg, const char *interface)
 {
        BT_DBG("+");
 
-       const char *member = dbus_message_get_member(msg);
-
-       if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL)
-               return FALSE;
-
-       retv_if(member == NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
-
-       if (dbus_message_has_interface(msg, BT_PROPERTIES_INTERFACE)) {
-               DBusMessageIter item_iter;
-               const char *interface_name = NULL;
-
-               dbus_message_iter_init(msg, &item_iter);
-
-               if (dbus_message_iter_get_arg_type(&item_iter)
-                                               != DBUS_TYPE_STRING) {
-                       BT_ERR("This is bad format dbus");
-                       return FALSE;
-               }
+       if (g_strcmp0(interface, BT_PROPERTIES_INTERFACE) == 0) {
+               char *interface_name = NULL;
 
-               dbus_message_iter_get_basic(&item_iter, &interface_name);
+               g_variant_get(msg,"(&s@a{sv}@as)", &interface_name, NULL, NULL);
 
                retv_if(interface_name == NULL, FALSE);
 
-               BT_DBG("interface: %s", interface_name);
-
-               retv_if(dbus_message_iter_next(&item_iter) == FALSE,
-                                                               FALSE);
-
-               retv_if(dbus_message_iter_get_arg_type(&item_iter)
-                                       != DBUS_TYPE_ARRAY, FALSE);
-
                if (strcasecmp(interface_name,
                                        BT_OBEX_TRANSFER_INTERFACE) == 0) {
                        BT_DBG("-");
@@ -2907,307 +2512,512 @@ static gboolean __bt_is_obexd_client_event(DBusMessage *msg)
        return FALSE;
 }
 
-static DBusHandlerResult __bt_opc_event_filter(DBusConnection *conn,
-                                               DBusMessage *msg, void *data)
+static  void __bt_opc_event_filter(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 *member = dbus_message_get_member(msg);
-
-       if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL)
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
-       retv_if(member == NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
-
+       const char *member = signal_name;
+       char *obj_path = NULL;
        if (strcasecmp(member, "InterfacesAdded") == 0) {
                BT_DBG("InterfacesAdded");
        }else if (strcasecmp(member, "InterfacesRemoved") == 0) {
-               char *object_path = NULL;
-
-               BT_DBG("InterfacesRemoved");
 
-               if (__bt_get_object_path(msg, &object_path)) {
+               if (__bt_get_object_path(parameters, &obj_path)) {
                        BT_ERR("Fail to get the path");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+                       return;
                }
 
-               BT_DBG("object_path =%s",object_path);
+               BT_DBG("object_path =%s",obj_path);
 
-               if (strncmp(object_path, BT_SESSION_BASEPATH_CLIENT,
+               if (strncmp(obj_path, BT_SESSION_BASEPATH_CLIENT,
                                strlen(BT_SESSION_BASEPATH_CLIENT)) != 0
-                               || strstr(object_path, "transfer") == NULL)
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-               else if (strncmp(object_path, BT_SESSION_BASEPATH_CLIENT,
+                               || strstr(obj_path, "transfer") == NULL) {
+                       g_free(obj_path);
+                       return;
+               }
+               else if (strncmp(obj_path, BT_SESSION_BASEPATH_CLIENT,
                                strlen(BT_SESSION_BASEPATH_CLIENT)) == 0) {
                        BT_DBG("Going to call opc disconnected");
-                       _bt_opc_disconnected(object_path);
+                       _bt_opc_disconnected(obj_path);
                }
 
                _bt_sending_files();
-
-       }else if (__bt_is_obexd_client_event(msg) == TRUE){
-               const char *path = dbus_message_get_path(msg);
-
+               g_free(obj_path);
+       }else if (__bt_is_obexd_client_event(parameters, interface_name) == TRUE){
+               char *path = (char *)object_path;
+               BT_INFO("object_path %s", path);
                if (strncmp(path, BT_SESSION_BASEPATH_CLIENT,
                        strlen(BT_SESSION_BASEPATH_CLIENT)) != 0) {
                        BT_DBG("NOT BT_SESSION_BASEPATH_CLIENT");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+                       return;
                }
 
-               _bt_opc_property_changed_event(msg);
+               _bt_opc_property_changed_event(parameters, path);
        }
 
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       return;
 }
 
-static DBusHandlerResult __bt_obexd_event_filter(DBusConnection *conn,
-                                               DBusMessage *msg, void *data)
+int _bt_opp_client_event_init(void)
 {
-       const char *member = dbus_message_get_member(msg);
-       char *object_path = NULL;
+       GError *error = NULL;
 
-       if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL)
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       if (opc_obexd_conn == NULL) {
+               opc_obexd_conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
 
-       retv_if(member == NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
+               if (!opc_obexd_conn) {
+                       if (error) {
+                               BT_ERR("Unable to connect to dbus: %s", error->message);
+                               g_clear_error(&error);
+                       }
+               return BLUETOOTH_ERROR_INTERNAL;
+               }
+       }
 
-       if (strcasecmp(member, "InterfacesAdded") == 0) {
-               BT_DBG("InterfacesAdded");
-               if (__bt_get_object_path(msg, &object_path)) {
-                       BT_ERR("Fail to get the path");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       if (_bt_register_service_event(opc_obexd_conn,
+                       BT_OPP_CLIENT_EVENT) != BLUETOOTH_ERROR_NONE) {
+                       g_object_unref(opc_obexd_conn);
+                       opc_obexd_conn = NULL;
+                       return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
+void _bt_opp_client_event_deinit(void)
+{
+       if (opc_obexd_conn) {
+               _bt_unregister_service_event(opc_obexd_conn,
+                                               BT_OPP_CLIENT_EVENT);
+                g_object_unref(opc_obexd_conn);
+                opc_obexd_conn = NULL;
+       }
+}
+
+int _bt_register_manager_subscribe_signal(GDBusConnection *conn,
+               int subscribe)
+{
+       if (conn == NULL)
+               return -1;
+
+       static int subs_interface_added_id = -1;
+       static int subs_interface_removed_id = -1;
+       static int subs_name_owner_id = -1;
+       static int subs_property_id = -1;
+       static int subs_adapter_id = -1;
+
+       if (subscribe) {
+               if (subs_interface_added_id == -1) {
+                       subs_interface_added_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_MANAGER_INTERFACE,
+                               BT_INTERFACES_ADDED, NULL, NULL, 0,
+                               __bt_manager_event_filter,
+                               NULL, NULL);
+               }
+               if (subs_interface_removed_id == -1) {
+                       subs_interface_removed_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_MANAGER_INTERFACE,
+                               BT_INTERFACES_REMOVED, NULL, NULL, 0,
+                               __bt_manager_event_filter,
+                               NULL, NULL);
+               }
+               if (subs_name_owner_id == -1) {
+                       subs_name_owner_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_FREEDESKTOP_INTERFACE,
+                               BT_NAME_OWNER_CHANGED, NULL, NULL, 0,
+                               __bt_manager_event_filter,
+                               NULL, NULL);
                }
+               if (subs_property_id == -1) {
+                       subs_property_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_PROPERTIES_INTERFACE,
+                               BT_PROPERTIES_CHANGED, NULL, NULL, 0,
+                               __bt_manager_event_filter,
+                               NULL, NULL);
+               }
+               if (subs_adapter_id == -1) {
+                       subs_adapter_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_ADAPTER_INTERFACE,
+                               NULL, NULL, NULL, 0,
+                               __bt_manager_event_filter,
+                               NULL, NULL);
+               }
+       } else {
+               if (subs_interface_added_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_interface_added_id);
+                       subs_interface_added_id = -1;
+               }
+               if (subs_interface_removed_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_interface_removed_id);
+                       subs_interface_removed_id = -1;
+               }
+               if (subs_name_owner_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_name_owner_id);
+                       subs_name_owner_id = -1;
+               }
+               if (subs_property_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_property_id);
+                       subs_property_id = -1;
+               }
+               if (subs_adapter_id == -1) {
+                       g_dbus_connection_signal_unsubscribe(conn, subs_adapter_id);
+                       subs_adapter_id = -1;
+               }
+       }
+       return 0;
+}
 
-               BT_INFO("object_path = [%s]", object_path);
+int _bt_register_device_subscribe_signal(GDBusConnection *conn,
+               int subscribe)
+{
+       if (conn == NULL)
+               return -1;
+
+       static int subs_device_id = -1;
+
+       if (subscribe) {
+               if (subs_device_id == -1) {
+                       subs_device_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_DEVICE_INTERFACE,
+                               NULL, NULL, NULL, 0,
+                               __bt_manager_event_filter,
+                               NULL, NULL);
+               }
+       } else {
+               if (subs_device_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_device_id);
+                       subs_device_id = -1;
+               }
+       }
+       return 0;
+}
 
-               /*Handle OPP_SERVER_CONNECTED_EVENT here */
-               if (strncmp(object_path, BT_SESSION_BASEPATH_SERVER,
-                               strlen(BT_SESSION_BASEPATH_SERVER)) != 0)
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+int _bt_register_input_subscribe_signal(GDBusConnection *conn,
+               int subscribe)
+{
+       if (conn == NULL)
+               return -1;
+
+       static int subs_input_id = -1;
+
+       if (subscribe) {
+               if (subs_input_id == -1) {
+                       subs_input_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_INPUT_INTERFACE,
+                               NULL, NULL, NULL, 0,
+                               __bt_manager_event_filter,
+                               NULL, NULL);
+               }
+       } else {
+               if (subs_input_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_input_id);
+                       subs_input_id = -1;
+               }
+       }
+       return 0;
+}
 
-               if (g_strrstr(object_path, "session") && g_strrstr(object_path, "transfer")) {
-                       BT_DBG("Obex_Server_Session_Transfer connected");
-                       _bt_obex_transfer_connected();
+int _bt_register_network_subscribe_signal(GDBusConnection *conn,
+               int subscribe)
+{
+       if (conn == NULL)
+               return -1;
+
+       static int subs_serv_id = -1;
+       static int subs_client_id = -1;
+
+       if (subscribe) {
+               if (subs_serv_id == -1) {
+                       subs_serv_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_NETWORK_SERVER_INTERFACE,
+                               NULL, NULL, NULL, 0,
+                               __bt_manager_event_filter,
+                               NULL, NULL);
                }
-       } else if (strcasecmp(member, "InterfacesRemoved") == 0) {
-               /*Handle OPP_SERVER_DISCONNECTED_EVENT here */
-               BT_DBG("InterfacesRemoved");
-               if (__bt_get_object_path(msg, &object_path)) {
-                       BT_ERR("Fail to get the path");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+               if (subs_client_id == -1) {
+                       subs_client_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_NETWORK_CLIENT_INTERFACE,
+                               NULL, NULL, NULL, 0,
+                               __bt_manager_event_filter,
+                               NULL, NULL);
+               }
+       } else {
+               if (subs_serv_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_serv_id);
+                       subs_serv_id = -1;
                }
+               if (subs_client_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_client_id);
+                       subs_client_id = -1;
+               }
+       }
+       return 0;
+}
 
-               BT_INFO("object_path = [%s]", object_path);
+int _bt_register_audio_subscribe_signal(GDBusConnection *conn,
+               int subscribe)
+{
+       if (conn == NULL)
+               return -1;
+
+       static int subs_headset_id = -1;
+       static int subs_sink_id = -1;
+
+       if (subscribe) {
+               if (subs_headset_id == -1) {
+                       subs_headset_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_HEADSET_INTERFACE,
+                               NULL, NULL, NULL, 0,
+                               __bt_manager_event_filter,
+                               NULL, NULL);
+               }
+               if (subs_sink_id == -1) {
+                       subs_sink_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_SINK_INTERFACE,
+                               NULL, NULL, NULL, 0,
+                               __bt_manager_event_filter,
+                               NULL, NULL);
+               }
+       } else {
+               if (subs_headset_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_headset_id);
+                       subs_headset_id = -1;
+               }
+               if (subs_sink_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_sink_id);
+                       subs_sink_id = -1;
+               }
+       }
+       return 0;
+}
 
-               if (strncmp(object_path, BT_SESSION_BASEPATH_SERVER,
-                               strlen(BT_SESSION_BASEPATH_SERVER)) != 0)
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+int _bt_register_opp_server_subscribe_signal(GDBusConnection *conn,
+               int subscribe)
+{
+       if (conn == NULL)
+               return -1;
 
-               if (g_strrstr(object_path, "session") && g_strrstr(object_path, "transfer")) {
-                       BT_DBG("Obex_Server_Session_Transfer disconnected");
-                       _bt_obex_transfer_disconnected();
+       static int subs_opp_server_interface_added_id = -1;
+       static int subs_opp_server_interface_removed_id = -1;
+       static int subs_opp_server_property_id = -1;
+
+
+       if (subscribe) {
+               if (subs_opp_server_interface_added_id == -1) {
+                       subs_opp_server_interface_added_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_MANAGER_INTERFACE,
+                               BT_INTERFACES_ADDED, NULL, NULL, 0,
+                               __bt_obexd_event_filter,
+                               NULL, NULL);
+               }
+               if (subs_opp_server_interface_removed_id == -1) {
+                       subs_opp_server_interface_removed_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_MANAGER_INTERFACE,
+                               BT_INTERFACES_REMOVED, NULL, NULL, 0,
+                               __bt_obexd_event_filter,
+                               NULL, NULL);
+               }
+               if (subs_opp_server_property_id == -1) {
+                       subs_opp_server_property_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_PROPERTIES_INTERFACE,
+                               BT_PROPERTIES_CHANGED, NULL, NULL, 0,
+                               __bt_obexd_event_filter,
+                               NULL, NULL);
                }
-       } else if (__bt_is_obexd_event(msg) == TRUE) {
-               const char *path = dbus_message_get_path(msg);
+       } else {
+               if (subs_opp_server_interface_added_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_opp_server_interface_added_id);
+                       subs_opp_server_interface_added_id = -1;
+               }
+               if (subs_opp_server_interface_removed_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_opp_server_interface_removed_id);
+                       subs_opp_server_interface_removed_id = -1;
+               }
+               if (subs_opp_server_property_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_opp_server_property_id);
+                       subs_opp_server_property_id = -1;
+               }
+       }
+       return 0;
+}
 
-               if (strncmp(path, BT_SESSION_BASEPATH_SERVER,
-                               strlen(BT_SESSION_BASEPATH_SERVER)) != 0 &&
-                       strncmp(path, BT_SESSION_BASEPATH_CLIENT,
-                               strlen(BT_SESSION_BASEPATH_CLIENT)) != 0) {
-                       BT_DBG("DBUS_HANDLER_RESULT_NOT_YET_HANDLED");
-                       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+int _bt_register_opp_client_subscribe_signal(GDBusConnection *conn,
+               int subscribe)
+{
+       if (conn == NULL)
+               return -1;
+
+       static int subs_opp_client_interface_added_id = -1;
+       static int subs_opp_client_interface_removed_id = -1;
+       static int subs_opp_client_property_id = -1;
+
+
+       if (subscribe) {
+               if (subs_opp_client_interface_added_id == -1) {
+                       subs_opp_client_interface_added_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_MANAGER_INTERFACE,
+                               BT_INTERFACES_ADDED, NULL, NULL, 0,
+                               __bt_opc_event_filter,
+                               NULL, NULL);
+               }
+               if (subs_opp_client_interface_removed_id == -1) {
+                       subs_opp_client_interface_removed_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_MANAGER_INTERFACE,
+                               BT_INTERFACES_REMOVED, NULL, NULL, 0,
+                               __bt_opc_event_filter,
+                               NULL, NULL);
+               }
+               if (subs_opp_client_property_id == -1) {
+                       subs_opp_client_property_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_PROPERTIES_INTERFACE,
+                               BT_PROPERTIES_CHANGED, NULL, NULL, 0,
+                               __bt_opc_event_filter,
+                               NULL, NULL);
+               }
+       } else {
+               if (subs_opp_client_interface_added_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_opp_client_interface_added_id);
+                       subs_opp_client_interface_added_id = -1;
+               }
+               if (subs_opp_client_interface_removed_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_opp_client_interface_removed_id);
+                       subs_opp_client_interface_removed_id = -1;
                }
+               if (subs_opp_client_property_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_opp_client_property_id);
+                       subs_opp_client_property_id = -1;
+               }
+       }
+       return 0;
+}
 
-               _bt_handle_property_changed_event(msg);
+int _bt_register_a2dp_subscribe_signal(GDBusConnection *conn,
+               int subscribe)
+{
+       if (conn == NULL)
+               return -1;
+
+       static int subs_a2dp_source_id = -1;
+       static int subs_a2dp_sink_id = -1;
+
+       if (subscribe) {
+               if (subs_a2dp_source_id == -1) {
+                       subs_a2dp_source_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_A2DP_SOURCE_INTERFACE,
+                               NULL, NULL, NULL, 0,
+                               __bt_opc_event_filter,
+                               NULL, NULL);
+               }
+               if (subs_a2dp_sink_id == -1) {
+                       subs_a2dp_sink_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_SINK_INTERFACE,
+                               NULL, NULL, NULL, 0,
+                               __bt_opc_event_filter,
+                               NULL, NULL);
+               }
+       } else {
+               if (subs_a2dp_source_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_a2dp_source_id);
+                       subs_a2dp_source_id = -1;
+               }
+               if (subs_a2dp_sink_id != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_a2dp_sink_id);
+                       subs_a2dp_sink_id = -1;
+               }
        }
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       return 0;
 }
 
-int _bt_register_service_event(DBusGConnection *g_conn, int event_type)
+int _bt_register_service_event(GDBusConnection *g_conn, int event_type)
 {
        BT_DBG("+");
 
-       DBusError dbus_error;
-       char *match1 = NULL;
-       char *match2 = NULL;
-       char *match3 = NULL;
-       char *match4 = NULL;
-       DBusConnection *conn;
-       DBusHandleMessageFunction event_func = NULL;
-
        retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       conn = dbus_g_connection_get_connection(g_conn);
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
        switch (event_type) {
        case BT_MANAGER_EVENT:
-               BT_ERR("BT_MANAGER_EVENT_REC:  \n register service event");
-               event_func = __bt_manager_event_filter;
-               match1 = g_strdup_printf(MANAGER_EVENT_MATCH_RULE,
-                                       BT_MANAGER_INTERFACE,
-                                       BT_INTERFACES_ADDED);
-
-               match2 = g_strdup_printf(MANAGER_EVENT_MATCH_RULE,
-                                       BT_MANAGER_INTERFACE,
-                                       BT_INTERFACES_REMOVED);
-
-               match3 = g_strdup_printf(MANAGER_EVENT_MATCH_RULE,
-                                       BT_FREEDESKTOP_INTERFACE,
-                                       BT_NAME_OWNER_CHANGED);
-
-               match4 = g_strdup_printf(MANAGER_EVENT_MATCH_RULE,
-                                       BT_PROPERTIES_INTERFACE,
-                                       BT_PROPERTIES_CHANGED);
+               _bt_register_manager_subscribe_signal(g_conn, TRUE);
                break;
        case BT_DEVICE_EVENT:
-               match1 = g_strdup_printf(EVENT_MATCH_RULE,
-                                       BT_DEVICE_INTERFACE);
+               _bt_register_device_subscribe_signal(g_conn, TRUE);
                break;
        case BT_HID_EVENT:
-               match1 = g_strdup_printf(EVENT_MATCH_RULE,
-                                       BT_INPUT_INTERFACE);
+               _bt_register_input_subscribe_signal(g_conn, TRUE);
                break;
        case BT_NETWORK_EVENT:
-               match1 = g_strdup_printf(EVENT_MATCH_RULE,
-                                       BT_NETWORK_SERVER_INTERFACE);
-
-               match2 = g_strdup_printf(EVENT_MATCH_RULE,
-                                       BT_NETWORK_CLIENT_INTERFACE);
+               _bt_register_network_subscribe_signal(g_conn, TRUE);
                break;
        case BT_HEADSET_EVENT:
-               match1 = g_strdup_printf(EVENT_MATCH_RULE,
-                                       BT_HFP_AGENT_INTERFACE);
-
-               match2 = g_strdup_printf(EVENT_MATCH_RULE,
-                                       BT_SINK_INTERFACE);
+               _bt_register_audio_subscribe_signal(g_conn, TRUE);
                break;
+
        case BT_OPP_SERVER_EVENT:
                BT_ERR("BT_OPP_SERVER_EVENT: register service event");
-               event_func = __bt_obexd_event_filter;
-               match1 = g_strdup_printf(MANAGER_EVENT_MATCH_RULE,
-                                       BT_PROPERTIES_INTERFACE,
-                                       BT_PROPERTIES_CHANGED);
-
-               match2 = g_strdup_printf(MANAGER_EVENT_MATCH_RULE,
-                                       BT_MANAGER_INTERFACE,
-                                       BT_INTERFACES_ADDED);
-
-               match3 = g_strdup_printf(MANAGER_EVENT_MATCH_RULE,
-                                       BT_MANAGER_INTERFACE,
-                                       BT_INTERFACES_REMOVED);
+               _bt_register_opp_server_subscribe_signal(g_conn, TRUE);
                break;
        case BT_OPP_CLIENT_EVENT:
                BT_ERR("BT_OPP_CLIENT_EVENT: register service event");
-               event_func = __bt_opc_event_filter;
-               match1 = g_strdup_printf(MANAGER_EVENT_MATCH_RULE,
-                                       BT_PROPERTIES_INTERFACE,
-                                       BT_PROPERTIES_CHANGED);
-
-               match2 = g_strdup_printf(MANAGER_EVENT_MATCH_RULE,
-                                       BT_MANAGER_INTERFACE,
-                                       BT_INTERFACES_ADDED);
-
-               match3 = g_strdup_printf(MANAGER_EVENT_MATCH_RULE,
-                                       BT_MANAGER_INTERFACE,
-                                       BT_INTERFACES_REMOVED);
+               _bt_register_opp_client_subscribe_signal(g_conn, TRUE);
+               break;
+       case BT_A2DP_SOURCE_EVENT:
+               BT_INFO("A2dp Source event");
+               _bt_register_a2dp_subscribe_signal(g_conn, TRUE);
                break;
        default:
                BT_ERR("Unknown event");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       if (event_func) {
-               if (!dbus_connection_add_filter(conn, event_func,
-                                               NULL, NULL)) {
-                       BT_ERR("Fail to add filter");
-                       goto fail;
-               }
-       }
-
-       dbus_error_init(&dbus_error);
-
-       if (match1)
-               dbus_bus_add_match(conn, match1, &dbus_error);
-
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add match: %s\n", dbus_error.message);
-               dbus_error_free(&dbus_error);
-               goto fail;
-       }
-
-       if (match2)
-               dbus_bus_add_match(conn, match2, &dbus_error);
-
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add match: %s\n", dbus_error.message);
-               dbus_error_free(&dbus_error);
-               goto fail;
-       }
-
-       if (match3)
-               dbus_bus_add_match(conn, match3, &dbus_error);
-
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add match: %s\n", dbus_error.message);
-               dbus_error_free(&dbus_error);
-               goto fail;
-       }
-
-       if (match4)
-               dbus_bus_add_match(conn, match4, &dbus_error);
-
-       if (dbus_error_is_set(&dbus_error)) {
-               BT_ERR("Fail to add match: %s\n", dbus_error.message);
-               dbus_error_free(&dbus_error);
-               goto fail;
-       }
-
-       g_free(match3);
-       g_free(match4);
-
-       g_free(match1);
-       g_free(match2);
-
        return BLUETOOTH_ERROR_NONE;
-fail:
-       g_free(match1);
-       g_free(match2);
-
-       g_free(match3);
-       g_free(match4);
-
-       BT_DBG("-");
-
-       return BLUETOOTH_ERROR_INTERNAL;
 }
 
-void _bt_unregister_service_event(DBusGConnection *g_conn, int event_type)
+void _bt_unregister_service_event(GDBusConnection *g_conn, int event_type)
 {
        BT_DBG("+");
 
-       DBusConnection *conn;
-       DBusHandleMessageFunction event_func;
-
        ret_if(g_conn == NULL);
-       conn = dbus_g_connection_get_connection(g_conn);
 
        switch (event_type) {
        case BT_MANAGER_EVENT:
-               event_func = __bt_manager_event_filter;
+               _bt_register_manager_subscribe_signal(g_conn, FALSE);
+               _bt_register_device_subscribe_signal(g_conn, FALSE);
+               _bt_register_input_subscribe_signal(g_conn, FALSE);
+               _bt_register_network_subscribe_signal(g_conn, FALSE);
+               _bt_register_audio_subscribe_signal(g_conn, FALSE);
                break;
        case BT_OPP_SERVER_EVENT:
-               event_func = __bt_obexd_event_filter;
+               _bt_register_opp_server_subscribe_signal(g_conn, FALSE);
                break;
        case BT_OPP_CLIENT_EVENT:
-               event_func = __bt_opc_event_filter;
+               _bt_register_opp_client_subscribe_signal(g_conn, FALSE);
                break;
        default:
                BT_ERR("Unknown event");
                return;
        }
 
-       ret_if(conn == NULL);
-
-       dbus_connection_remove_filter(conn, event_func, NULL);
        BT_DBG("-");
 }
 
@@ -3218,10 +3028,10 @@ static int __bt_init_manager_receiver(void)
        GError *error = NULL;
 
        if (manager_conn == NULL) {
-               manager_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+               manager_conn =  g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
                if (error != NULL) {
                        BT_ERR("ERROR: Can't get on system bus [%s]", error->message);
-                       g_error_free(error);
+                       g_clear_error(&error);
                }
                retv_if(manager_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
        }
@@ -3229,7 +3039,6 @@ static int __bt_init_manager_receiver(void)
        if (_bt_register_service_event(manager_conn,
                                BT_MANAGER_EVENT) != BLUETOOTH_ERROR_NONE)
                goto fail;
-
        if (_bt_register_service_event(manager_conn,
                                BT_DEVICE_EVENT) != BLUETOOTH_ERROR_NONE)
                goto fail;
@@ -3245,15 +3054,14 @@ static int __bt_init_manager_receiver(void)
        if (_bt_register_service_event(manager_conn,
                                BT_NETWORK_EVENT) != BLUETOOTH_ERROR_NONE)
                goto fail;
-
        return BLUETOOTH_ERROR_NONE;
 fail:
        if (manager_conn) {
-               dbus_g_connection_unref(manager_conn);
+               g_object_unref(manager_conn);
                manager_conn = NULL;
        }
 
-       BT_DBG("REGISTER successfull");
+       BT_DBG("-");
 
        return BLUETOOTH_ERROR_INTERNAL;
 }
@@ -3264,17 +3072,18 @@ static int __bt_init_obexd_receiver(void)
        GError *error = NULL;
 
        if (obexd_conn == NULL) {
-               obexd_conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+               obexd_conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
                if (error != NULL) {
                        BT_ERR("ERROR: Can't get on session bus [%s]", error->message);
-                       g_error_free(error);
+                       g_clear_error(&error);
                }
                retv_if(obexd_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
        }
 
        if (_bt_register_service_event(obexd_conn,
                                BT_OPP_SERVER_EVENT) != BLUETOOTH_ERROR_NONE) {
-               dbus_g_connection_unref(obexd_conn);
+               BT_ERR("Error while registering service event");
+               g_object_unref(obexd_conn);
                obexd_conn = NULL;
                return BLUETOOTH_ERROR_INTERNAL;
        }
@@ -3312,12 +3121,12 @@ void _bt_deinit_service_event_receiver(void)
        _bt_unregister_service_event(obexd_conn, BT_OPP_SERVER_EVENT);
 
        if (manager_conn) {
-               dbus_g_connection_unref(manager_conn);
+               g_object_unref(manager_conn);
                manager_conn = NULL;
        }
 
        if (obexd_conn) {
-               dbus_g_connection_unref(obexd_conn);
+               g_object_unref(obexd_conn);
                obexd_conn = NULL;
        }
 
@@ -3326,39 +3135,3 @@ void _bt_deinit_service_event_receiver(void)
 
        BT_DBG("-");
 }
-
-int _bt_opp_client_event_init(void)
-{
-       GError *error = NULL;
-
-       if (opc_obexd_conn == NULL) {
-               opc_obexd_conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
-               if (error != NULL) {
-                       BT_ERR("ERROR: Can't get on session bus [%s]",
-                                                        error->message);
-                       g_error_free(error);
-                       return BLUETOOTH_ERROR_INTERNAL;
-               }
-
-               retv_if(opc_obexd_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-       }
-
-       if (_bt_register_service_event(opc_obexd_conn,
-                       BT_OPP_CLIENT_EVENT) != BLUETOOTH_ERROR_NONE) {
-               dbus_g_connection_unref(opc_obexd_conn);
-               opc_obexd_conn = NULL;
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-void _bt_opp_client_event_deinit(void)
-{
-       if (opc_obexd_conn) {
-               _bt_unregister_service_event(opc_obexd_conn,
-                                               BT_OPP_CLIENT_EVENT);
-               dbus_g_connection_unref(opc_obexd_conn);
-               opc_obexd_conn = NULL;
-       }
-}
index f78ecbe..9c1b9f4 100644 (file)
  *
  */
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
 #include <glib.h>
 #include <dlog.h>
-
+#include <gio/gio.h>
 #include "bluetooth-api.h"
 #include "bt-internal-types.h"
 
 #include "bt-service-common.h"
 #include "bt-service-event.h"
 
-static DBusConnection *event_conn;
-static DBusConnection *hf_local_term_event_conn;
+static GDBusConnection *event_conn;
+static GDBusConnection *hf_local_term_event_conn;
 
-int _bt_send_event(int event_type, int event, int type, ...)
+int _bt_send_event(int event_type, int event, GVariant *param)
 {
        BT_DBG("+");
-
-       DBusMessage *msg;
        char *path;
        char *signal;
-       va_list arguments;
+       GDBusMessage *msg1 = NULL;
 
        retv_if(event_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
@@ -88,6 +84,9 @@ int _bt_send_event(int event_type, int event, int type, ...)
        case BT_RFCOMM_SERVER_EVENT:
                path = BT_RFCOMM_SERVER_PATH;
                break;
+        case BT_A2DP_SOURCE_EVENT:
+                path = BT_A2DP_SOURCE_PATH;
+                break;
        default:
                BT_ERR("Unknown event");
                return BLUETOOTH_ERROR_INTERNAL;
@@ -124,9 +123,6 @@ int _bt_send_event(int event_type, int event, int type, ...)
        case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
                signal = BT_DEVICE_FOUND;
                break;
-       case BLUETOOTH_EVENT_REMOTE_DEVICE_DISAPPEARED:
-               signal = BT_DEVICE_DISAPPEARED;
-               break;
        case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
                signal = BT_DISCOVERY_FINISHED;
                break;
@@ -190,6 +186,10 @@ int _bt_send_event(int event_type, int event, int type, ...)
                signal = BT_PBAP_CONNECTED;
                BT_INFO_C("Connected [PBAP Client]");
                break;
+       case BLUETOOTH_PBAP_DISCONNECTED:
+               signal = BT_PBAP_DISCONNECTED;
+               BT_INFO_C("Disconnected [PBAP Client]");
+               break;
        case BLUETOOTH_PBAP_PHONEBOOK_SIZE:
                signal = BT_PBAP_PHONEBOOK_SIZE;
                break;
@@ -302,6 +302,14 @@ int _bt_send_event(int event_type, int event, int type, ...)
        case BLUETOOTH_EVENT_DEVICE_DISCONNECTED:
                signal = BT_DEVICE_DISCONNECTED;
                break;
+       case BLUETOOTH_EVENT_AV_SOURCE_CONNECTED:
+               signal = BT_A2DP_SOURCE_CONNECTED;
+               BT_INFO_C("Connected [A2DP Source]");
+               break;
+        case BLUETOOTH_EVENT_AV_SOURCE_DISCONNECTED:
+                signal = BT_A2DP_SOURCE_DISCONNECTED;
+                BT_INFO_C("Disconnected [A2DP Source]");
+                break;
        case BLUETOOTH_EVENT_AVRCP_CONNECTED:
        case BLUETOOTH_EVENT_AVRCP_CONTROL_CONNECTED:
                signal = BT_AVRCP_CONNECTED;
@@ -343,6 +351,9 @@ int _bt_send_event(int event_type, int event, int type, ...)
        case BLUETOOTH_EVENT_GATT_DISCONNECTED:
                signal = BT_GATT_DISCONNECTED;
                break;
+       case BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED:
+               signal = BT_GATT_CHAR_VAL_CHANGED;
+               break;
        default:
                BT_ERR("Unknown event");
                return BLUETOOTH_ERROR_INTERNAL;
@@ -351,49 +362,24 @@ int _bt_send_event(int event_type, int event, int type, ...)
        BT_DBG("Path : %s", path);
        BT_INFO_C("Signal : %s", signal);
 
-       msg = dbus_message_new_signal(path, BT_EVENT_SERVICE,
-                               signal);
-
-       if (msg == NULL) {
-               BT_ERR("Message is NULL");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       if (type) {
-               /* Set the arguments of the dbus message */
-               va_start(arguments, type);
-
-               if (!dbus_message_append_args_valist(msg, type, arguments)) {
-                       dbus_message_unref(msg);
-                       va_end(arguments);
-                       return BLUETOOTH_ERROR_INTERNAL;
-               }
-
-               va_end(arguments);
-       }
-
-       if (!dbus_connection_send(event_conn, msg, NULL)) {
-               BT_ERR("send failed");
-               dbus_message_unref(msg);
-               return BLUETOOTH_ERROR_INTERNAL;
+       msg1 = g_dbus_message_new_signal(path, BT_EVENT_SERVICE, signal);
+       g_dbus_message_set_body(msg1, param);
+       if (!g_dbus_connection_send_message(event_conn, msg1,G_DBUS_SEND_MESSAGE_FLAGS_NONE, 0, NULL)) {
+               BT_ERR("Error while sending");
        }
 
-       dbus_connection_flush(event_conn);
-       dbus_message_unref(msg);
-
+       g_object_unref(msg1);
        BT_DBG("-");
-
        return BLUETOOTH_ERROR_NONE;
 }
 
-int _bt_send_event_to_dest(const char* dest, int event_type, int event, int type, ...)
+int _bt_send_event_to_dest(const char* dest, int event_type,
+               int event, GVariant *param)
 {
        BT_DBG("+");
-
-       DBusMessage *msg;
        char *path;
        char *signal;
-       va_list arguments;
+       GError *error = NULL;
 
        retv_if(event_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
@@ -403,6 +389,9 @@ int _bt_send_event_to_dest(const char* dest, int event_type, int event, int type
        case BT_ADAPTER_EVENT:
                path = BT_ADAPTER_PATH;
                break;
+       case BT_LE_ADAPTER_EVENT:
+               path = BT_LE_ADAPTER_PATH;
+               break;
        default:
                BT_ERR("Unknown event");
                return BLUETOOTH_ERROR_INTERNAL;
@@ -415,6 +404,15 @@ int _bt_send_event_to_dest(const char* dest, int event_type, int event, int type
        case BLUETOOTH_EVENT_ADVERTISING_STOPPED:
                signal = BT_ADVERTISING_STOPPED;
                break;
+       case BLUETOOTH_EVENT_LE_DISCOVERY_STARTED:
+               signal = BT_LE_DISCOVERY_STARTED;
+               break;
+       case BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND:
+               signal = BT_LE_DEVICE_FOUND;
+               break;
+       case BLUETOOTH_EVENT_LE_DISCOVERY_FINISHED:
+               signal = BT_LE_DISCOVERY_FINISHED;
+               break;
        default:
                BT_ERR("Unknown event");
                return BLUETOOTH_ERROR_INTERNAL;
@@ -423,137 +421,98 @@ int _bt_send_event_to_dest(const char* dest, int event_type, int event, int type
        BT_DBG("Path : %s", path);
        BT_INFO_C("Signal : %s", signal);
 
-       msg = dbus_message_new_signal(path, BT_EVENT_SERVICE,
-                               signal);
-
-       if (msg == NULL) {
-               BT_ERR("Message is NULL");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       if (dbus_message_set_destination(msg, dest) == FALSE)
-               BT_ERR("Setting destination is failed");
-
-       if (type) {
-               /* Set the arguments of the dbus message */
-               va_start(arguments, type);
-
-               if (!dbus_message_append_args_valist(msg, type, arguments)) {
-                       dbus_message_unref(msg);
-                       va_end(arguments);
-                       return BLUETOOTH_ERROR_INTERNAL;
+       if (!g_dbus_connection_emit_signal(event_conn, dest, path, BT_EVENT_SERVICE,
+                       signal, param, &error)) {
+               BT_ERR("Error while sending Signal: %s", signal);
+               if (error) {
+                       BT_ERR("Error Code [%d], Error Message [%s]",
+                                       error->code, error->message);
+                       g_clear_error(&error);
                }
-
-               va_end(arguments);
        }
 
-       if (!dbus_connection_send(event_conn, msg, NULL)) {
-               BT_ERR("send failed");
-               dbus_message_unref(msg);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_connection_flush(event_conn);
-       dbus_message_unref(msg);
-
        BT_DBG("-");
-
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_send_hf_local_term_event(char *address)
 {
-       DBusMessage *msg;
-       char *signal = BT_HF_LOCAL_TERM;
+       GError *error = NULL;
 
        retv_if(hf_local_term_event_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       msg = dbus_message_new_signal(BT_HF_LOCAL_TERM_EVENT_PATH,
-                       BT_HF_LOCAL_TERM_EVENT_INTERFACE, signal);
-       if (msg == NULL) {
-               BT_ERR("Message is NULL\n");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_message_append_args(msg, DBUS_TYPE_STRING, &address, DBUS_TYPE_INVALID);
-
-       if (!dbus_connection_send(hf_local_term_event_conn, msg, NULL)) {
-               BT_ERR("send failed\n");
-               dbus_message_unref(msg);
-               return BLUETOOTH_ERROR_INTERNAL;
+       if (!g_dbus_connection_emit_signal(hf_local_term_event_conn, NULL,
+                       BT_HF_LOCAL_TERM_EVENT_PATH,
+                       BT_HF_LOCAL_TERM_EVENT_INTERFACE,
+                       BT_HF_LOCAL_TERM, g_variant_new("s", address),
+                       &error)) {
+               BT_ERR("Error while sending Signal: %s", signal);
+               if (error) {
+                       BT_ERR("Error Code [%d], Error Message [%s]",
+                                       error->code, error->message);
+                       g_clear_error(&error);
+               }
        }
 
-       dbus_connection_flush(hf_local_term_event_conn);
-       dbus_message_unref(msg);
-
        return BLUETOOTH_ERROR_NONE;
 }
 
 /* To send the event from service daemon to application*/
 int _bt_init_service_event_sender(void)
 {
-       DBusConnection *conn;
-       DBusError err;
-       int ret;
+       GDBusConnection *conn;
+       GError *err = NULL;
 
        if (event_conn) {
                BT_ERR("Event handler is already exist");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, NULL);
+       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_error_init(&err);
-
-       ret = dbus_bus_request_name(conn, BT_EVENT_SERVICE,
-                               DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
-
-       if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
-               if (dbus_error_is_set(&err) == TRUE) {
-                       BT_ERR(" Sudha 112 Event init failed \n \n, %s", err.message);
-                       dbus_error_free(&err);
+       if (conn == NULL) {
+               BT_ERR("conn == NULL");
+               if (err) {
+                       BT_ERR("Code[%d], Message[%s]",
+                                       err->code, err->message);
+                       g_clear_error(&err);
                }
+
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
        event_conn = conn;
-
        return BLUETOOTH_ERROR_NONE;
 }
 
 void _bt_deinit_service_event_sender(void)
 {
        if (event_conn) {
-               dbus_connection_close(event_conn);
+               g_object_unref(event_conn);
                event_conn = NULL;
        }
 }
 
 int _bt_init_hf_local_term_event_sender(void)
 {
-       DBusConnection *conn;
-       DBusError err;
-       int ret;
+       GDBusConnection *conn;
+       GError *err = NULL;
 
        if (hf_local_term_event_conn) {
-               BT_ERR(" Sudha Event handler is already exist");
+               BT_ERR("Event handler is already exist");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, NULL);
+       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_error_init(&err);
-
-       ret = dbus_bus_request_name(conn, BT_HF_LOCAL_TERM_EVENT_INTERFACE,
-                               DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
-
-       if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
-               if (dbus_error_is_set(&err) == TRUE) {
-                       BT_ERR("Sudha Event init failed \n, %s ", err.message);
-                       dbus_error_free(&err);
+       if (conn == NULL) {
+               BT_ERR("conn == NULL");
+               if (err) {
+                       BT_ERR("Code[%d], Message[%s]",
+                                       err->code, err->message);
+                       g_clear_error(&err);
                }
+
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
@@ -565,7 +524,7 @@ int _bt_init_hf_local_term_event_sender(void)
 void _bt_deinit_hf_local_term_event_sender(void)
 {
        if (hf_local_term_event_conn) {
-               dbus_connection_close(hf_local_term_event_conn);
+               g_object_unref(hf_local_term_event_conn);
                hf_local_term_event_conn = NULL;
        }
 }
index 89d73c7..0578822 100644 (file)
 #include "bt-service-adapter.h"
 #include "bt-service-device.h"
 
-static DBusGConnection *connection = NULL;
-
-typedef enum {
-       GAP_AGENT_EXEC_NO_OPERATION,
-       GAP_AGENT_EXEC_PAIRING,
-       GAP_AGENT_EXEC_AUTHORZATION,
-       GAP_AGENT_EXEC_CONFIRM_MODE,
-} GapAgentExecType;
-
-typedef struct _GapAgentPrivate GapAgentPrivate;
-
-struct _GapAgentPrivate {
-       gchar *busname;
-       gchar *path;
-       DBusGProxy *adapter;
-
-       DBusGProxy *agent_manager;
-
-       DBusGProxy *dbus_proxy;
-
-       GapAgentExecType exec_type;
-       DBusGMethodInvocation *reply_context;
-
-       char pairing_addr[18];
-       char authorize_addr[18];
-
-       GSList *osp_servers;
-
-       GAP_AGENT_FUNC_CB cb;
-       gboolean canceled;
-};
-
-G_DEFINE_TYPE(GapAgent, gap_agent, G_TYPE_OBJECT);
-
-static gboolean gap_agent_request_pin_code(GapAgent *agent,
-                                               const char *path,
-                                               DBusGMethodInvocation *context);
-
-static gboolean gap_agent_request_passkey(GapAgent *agent, const char *path,
-                                               DBusGMethodInvocation *context);
-
-static gboolean gap_agent_display_passkey(GapAgent *agent, const char *path,
-                                               guint passkey, guint16 entered,
-                                               DBusGMethodInvocation *context);
-
-static gboolean gap_agent_request_confirmation(GapAgent *agent,
-                                               const char *path,
-                                               guint passkey,
-                                               DBusGMethodInvocation *context);
-
-static gboolean gap_agent_authorize_service(GapAgent *agent, const char *path,
-                                               const char *uuid,
-                                               DBusGMethodInvocation *context);
-
-static gboolean gap_agent_request_authorization(GapAgent *agent,
-                                               const char *path,
-                                               DBusGMethodInvocation *context);
-
-static gboolean gap_agent_cancel(GapAgent *agent,
-                                               DBusGMethodInvocation *context);
-
-static gboolean gap_agent_release(GapAgent *agent,
-                                               DBusGMethodInvocation *context);
-
-static gboolean gap_agent_confirm_mode_change(GapAgent *agent,
-                                               const char *mode,
-                                               DBusGMethodInvocation *context);
-
-static gboolean gap_agent_get_discoverable_timeout(GapAgent *agent,
-                                               DBusGMethodInvocation *context);
-
-#include "bt-gap-agent-method.h"
+static GDBusConnection *connection = NULL;
 
 typedef enum {
        GAP_AGENT_ERROR_REJECT,
@@ -126,484 +55,7 @@ static GQuark gap_agent_error_quark(void)
 
 #define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
 
-static GError *gap_agent_error(GapAgentError error, const char *err_msg)
-{
-       return g_error_new(GAP_AGENT_ERROR, error, err_msg, NULL);
-}
-
-static void gap_agent_init(GapAgent *agent)
-{
-       BT_DBG("agent %p", agent);
-}
-
-static void gap_agent_finalize(GObject *agent)
-{
-       BT_DBG("Free agent %p", agent);
-
-       G_OBJECT_CLASS(gap_agent_parent_class)->finalize(agent);
-}
-
-static void gap_agent_class_init(GapAgentClass *klass)
-{
-       GObjectClass *object_class = (GObjectClass *) klass;
-       GError *error = NULL;
-
-       BT_DBG("class %p", klass);
-
-       g_type_class_add_private(klass, sizeof(GapAgentPrivate));
-
-       object_class->finalize = gap_agent_finalize;
-
-       connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
-
-       if (error != NULL) {
-               g_printerr("Connecting to system bus failed: %s",
-                                                               error->message);
-               g_error_free(error);
-       }
-
-       dbus_g_object_type_install_info(GAP_TYPE_AGENT,
-                                       &dbus_glib_gap_agent_object_info);
-}
-
-GapAgent *_gap_agent_new(void)
-{
-       GapAgent *agent;
-
-       agent = GAP_GET_AGENT(g_object_new(GAP_TYPE_AGENT, NULL));
-
-       BT_DBG("agent %p", agent);
-
-       return agent;
-}
-
-static gboolean gap_agent_request_pin_code(GapAgent *agent,
-                                               const char *path,
-                                               DBusGMethodInvocation *context)
-{
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
-       char *sender = dbus_g_method_get_sender(context);
-       DBusGProxy *device;
-       gboolean result;
-       char *addr;
-
-       DBusGConnection *conn;
-
-       if (sender == NULL)
-               return FALSE;
-
-       BT_INFO("Request pin code, Device Path :%s", path);
-
-       if (g_strcmp0(sender, priv->busname) != 0) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       if (!priv->cb.passkey_func) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       conn = _bt_get_system_gconn();
-       if (conn == NULL) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       device = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               path, BT_PROPERTIES_INTERFACE);
-       if (device == NULL) {
-               GError *error = gap_agent_error(GAP_AGENT_ERROR_REJECT,
-                                                       "No proxy for device");
-               BT_ERR("Fail to make device proxy");
-               dbus_g_method_return_error(context, error);
-               g_error_free(error);
-               g_free(sender);
-               return FALSE;
-       }
-
-       priv->exec_type = GAP_AGENT_EXEC_PAIRING;
-       priv->reply_context = context;
-
-       addr = strstr(path, "dev_");
-       if (addr != NULL) {
-               char *pos = NULL;
-               addr += 4;
-               g_strlcpy(priv->pairing_addr, addr, sizeof(priv->pairing_addr));
-
-               while ((pos = strchr(priv->pairing_addr, '_')) != NULL) {
-                       *pos = ':';
-               }
-       }
-
-       result = priv->cb.pincode_func(agent, device);
-
-       g_object_unref(device);
-
-       g_free(sender);
-       return result;
-}
-
-static gboolean gap_agent_request_passkey(GapAgent *agent, const char *path,
-                                               DBusGMethodInvocation *context)
-{
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
-       char *sender = dbus_g_method_get_sender(context);
-       DBusGProxy *device;
-       gboolean result;
-       char *addr;
-       DBusGConnection *conn;
-
-       if (sender == NULL)
-               return FALSE;
-
-       BT_INFO("Request passkey : agent %p sender %s priv->busname %s Device Path :%s", agent,
-           sender, priv->busname, path);
-
-       if (g_strcmp0(sender, priv->busname) != 0) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       if (!priv->cb.passkey_func) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       conn = _bt_get_system_gconn();
-       if (conn == NULL) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       device = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               path, BT_PROPERTIES_INTERFACE);
-
-       if (device == NULL) {
-               GError *error = gap_agent_error(GAP_AGENT_ERROR_REJECT,
-                                                       "No proxy for device");
-               BT_ERR("Fail to make device proxy");
-               dbus_g_method_return_error(context, error);
-               g_error_free(error);
-               g_free(sender);
-               return FALSE;
-       }
-
-       priv->exec_type = GAP_AGENT_EXEC_PAIRING;
-       priv->reply_context = context;
-
-       addr = strstr(path, "dev_");
-       if (addr != NULL) {
-               char *pos = NULL;
-               addr += 4;
-               g_strlcpy(priv->pairing_addr, addr, sizeof(priv->pairing_addr));
-
-               while ((pos = strchr(priv->pairing_addr, '_')) != NULL) {
-                       *pos = ':';
-               }
-       }
-
-       result = priv->cb.passkey_func(agent, device);
-
-       g_object_unref(device);
-
-       g_free(sender);
-       return result;
-
-}
-
-static gboolean gap_agent_display_passkey(GapAgent *agent, const char *path,
-                                               guint passkey, guint16 entered,
-                                               DBusGMethodInvocation *context)
-{
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
-       char *sender = dbus_g_method_get_sender(context);
-       DBusGProxy *device;
-       gboolean result;
-       DBusGConnection *conn;
-
-       if (sender == NULL)
-               return FALSE;
-
-       /* Do not show popup for Key event while typing*/
-       if (entered) {
-               g_free(sender);
-               return FALSE;
-       }
-       BT_INFO("Request passkey display : agent %p sender %s priv->busname %s Device Path :%s\n",
-                       agent, sender, priv->busname, path);
-
-       if (g_strcmp0(sender, priv->busname) != 0) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       if (!priv->cb.display_func) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       conn = _bt_get_system_gconn();
-       if (conn == NULL) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       device = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               path, BT_PROPERTIES_INTERFACE);
-
-       if (device == NULL) {
-               GError *error = gap_agent_error(GAP_AGENT_ERROR_REJECT,
-                                                       "No proxy for device");
-               BT_ERR("Fail to make device proxy");
-               dbus_g_method_return_error(context, error);
-               g_error_free(error);
-               g_free(sender);
-               return FALSE;
-       }
-
-       dbus_g_method_return(context);
-
-       result = priv->cb.display_func(agent, device, passkey);
-
-       g_object_unref(device);
-
-       g_free(sender);
-       return result;
-}
-
-static gboolean gap_agent_request_confirmation(GapAgent *agent,
-                                               const char *path,
-                                               guint passkey,
-                                               DBusGMethodInvocation *context)
-{
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
-       char *sender = dbus_g_method_get_sender(context);
-       DBusGProxy *device;
-       gboolean result;
-       char *addr;
-       DBusGConnection *conn;
-
-       if (sender == NULL)
-               return FALSE;
-
-       BT_INFO("Request passkey confirmation, Device Path :%s", path);
-
-       if (g_strcmp0(sender, priv->busname) != 0) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       if (!priv->cb.confirm_func) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       conn = _bt_get_system_gconn();
-       if (conn == NULL) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       device = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               path, BT_PROPERTIES_INTERFACE);
-       if (device == NULL) {
-               GError *error = gap_agent_error(GAP_AGENT_ERROR_REJECT,
-                                                       "No proxy for device");
-               BT_ERR("Fail to make device proxy");
-               dbus_g_method_return_error(context, error);
-               g_error_free(error);
-               g_free(sender);
-               return FALSE;
-       }
-
-       priv->exec_type = GAP_AGENT_EXEC_PAIRING;
-       priv->reply_context = context;
-
-       addr = strstr(path, "dev_");
-       if (addr != NULL) {
-               char *pos = NULL;
-               addr += 4;
-               g_strlcpy(priv->pairing_addr, addr, sizeof(priv->pairing_addr));
-
-               while ((pos = strchr(priv->pairing_addr, '_')) != NULL) {
-                       *pos = ':';
-               }
-       }
-
-       result = priv->cb.confirm_func(agent, device, passkey);
-
-       g_object_unref(device);
-
-       g_free(sender);
-       return result;
-}
-
-static gboolean gap_agent_authorize_service(GapAgent *agent, const char *path,
-                                               const char *uuid,
-                                               DBusGMethodInvocation *context)
-{
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
-       char *sender = dbus_g_method_get_sender(context);
-       DBusGProxy *device;
-       DBusGConnection *conn;
-       gboolean result;
-       char *addr;
-
-       if (sender == NULL)
-               return FALSE;
-
-       BT_DBG("Request authorization : agent %p sender %s priv->busname %s Device Path :%s", agent,
-           sender, priv->busname, path);
-
-       if (g_strcmp0(sender, priv->busname) != 0) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       if (!priv->cb.authorize_func) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       conn = _bt_get_system_gconn();
-       if (conn == NULL) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       device = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               path, BT_PROPERTIES_INTERFACE);
-
-       if (device == NULL) {
-               GError *error = gap_agent_error(GAP_AGENT_ERROR_REJECT,
-                                                       "No proxy for device");
-               BT_DBG("Fail to make device proxy\n");
-               dbus_g_method_return_error(context, error);
-               g_error_free(error);
-               g_free(sender);
-               return FALSE;
-       }
-
-       priv->exec_type = GAP_AGENT_EXEC_AUTHORZATION;
-       priv->reply_context = context;
-
-       addr = strstr(path, "dev_");
-       if (addr != NULL) {
-               char *pos = NULL;
-               addr += 4;
-               g_strlcpy(priv->authorize_addr, addr,
-                                               sizeof(priv->authorize_addr));
-
-               while ((pos = strchr(priv->authorize_addr, '_')) != NULL) {
-                       *pos = ':';
-               }
-       }
-
-       result = priv->cb.authorize_func(agent, device, uuid);
-
-       g_object_unref(device);
-
-       g_free(sender);
-       return result;
-}
-
-static gboolean gap_agent_request_authorization(GapAgent *agent,
-                                               const char *path,
-                                               DBusGMethodInvocation *context)
-{
-       dbus_g_method_return(context);
-       return TRUE;
-}
-
-
-static gboolean gap_agent_confirm_mode_change(GapAgent *agent,
-                                               const char *mode,
-                                               DBusGMethodInvocation *context)
-{
-       BT_DBG("");
-
-       dbus_g_method_return(context);
-       return TRUE;
-}
-
-static gboolean gap_agent_cancel(GapAgent *agent,
-                                               DBusGMethodInvocation *context)
-{
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
-       char *sender = dbus_g_method_get_sender(context);
-       gboolean result = FALSE;
-
-       if (sender == NULL)
-               return FALSE;
-
-       BT_DBG("Cancelled : agent %p sender %s", agent, sender);
-
-       if (g_strcmp0(sender, priv->busname) != 0) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       if (priv->cb.authorization_cancel_func &&
-                       priv->exec_type == GAP_AGENT_EXEC_AUTHORZATION) {
-               result = priv->cb.authorization_cancel_func(agent,
-                                                       priv->authorize_addr);
-               memset(priv->authorize_addr, 0x00,
-                                               sizeof(priv->authorize_addr));
-       } else if (priv->cb.pairing_cancel_func &&
-                               priv->exec_type == GAP_AGENT_EXEC_PAIRING) {
-               result = priv->cb.pairing_cancel_func(agent,
-                                                       priv->pairing_addr);
-               memset(priv->pairing_addr, 0x00, sizeof(priv->pairing_addr));
-       }
-
-       if (priv->exec_type != GAP_AGENT_EXEC_CONFIRM_MODE &&
-                       priv->exec_type != GAP_AGENT_EXEC_NO_OPERATION &&
-                                               priv->reply_context != NULL) {
-               GError *error = gap_agent_error(GAP_AGENT_ERROR_REJECT,
-                                               "Rejected by remote cancel");
-               dbus_g_method_return_error(priv->reply_context, error);
-               g_error_free(error);
-       }
-
-       /* Canceled flag is set when user cancels pairing request
-        * Since here bluez has cancelled pairing request, we set the flag to false
-        */
-       priv->canceled = FALSE;
-       priv->exec_type = GAP_AGENT_EXEC_NO_OPERATION;
-       priv->reply_context = NULL;
-
-       g_free(sender);
-       return result;
-}
-
-static gboolean gap_agent_release(GapAgent *agent,
-                                               DBusGMethodInvocation *context)
-{
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
-       char *sender = dbus_g_method_get_sender(context);
-
-       if (sender == NULL)
-               return FALSE;
-
-       BT_DBG("Released : agent %p sender %s\n", agent, sender);
-
-       if (g_strcmp0(sender, priv->busname) != 0) {
-               g_free(sender);
-               return FALSE;
-       }
-
-       dbus_g_method_return(context);
-
-       priv->exec_type = GAP_AGENT_EXEC_NO_OPERATION;
-       priv->reply_context = NULL;
-
-       memset(priv->pairing_addr, 0x00, sizeof(priv->pairing_addr));
-       memset(priv->authorize_addr, 0x00, sizeof(priv->authorize_addr));
-
-       g_free(sender);
-       return TRUE;
-}
+static gint gap_agent_id = -1;
 
 static bt_agent_osp_server_t *__gap_agent_find_server(GSList *servers,
                                                        int type,
@@ -646,7 +98,7 @@ static void __gap_agent_remove_osp_servers(GSList *osp_servers)
        }
 }
 
-gboolean _gap_agent_register_osp_server(GapAgent *agent,
+gboolean _gap_agent_register_osp_server(GapAgentPrivate *agent,
                                        const gint type,
                                        const char *uuid,
                                        const char *path,
@@ -656,7 +108,7 @@ gboolean _gap_agent_register_osp_server(GapAgent *agent,
 
        BT_DBG("+");
 
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
+       GapAgentPrivate *priv = agent;
 
        if (priv == NULL)
                return FALSE;
@@ -667,6 +119,9 @@ gboolean _gap_agent_register_osp_server(GapAgent *agent,
 
        server = g_malloc0(sizeof(bt_agent_osp_server_t));
 
+       /* Fix : NULL_RETURNS */
+       retv_if(server == NULL, FALSE);
+
        server->type = type;
        if (type == BT_RFCOMM_SERVER) {
                server->uuid = g_strdup(uuid);
@@ -681,7 +136,7 @@ gboolean _gap_agent_register_osp_server(GapAgent *agent,
        return TRUE;
 }
 
-gboolean _gap_agent_unregister_osp_server(GapAgent *agent,
+gboolean _gap_agent_unregister_osp_server(GapAgentPrivate *agent,
                                                const gint type,
                                                const char *uuid)
 {
@@ -689,7 +144,7 @@ gboolean _gap_agent_unregister_osp_server(GapAgent *agent,
 
        BT_DBG("+");
 
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
+       GapAgentPrivate *priv = agent;
 
        if (priv == NULL)
                return FALSE;
@@ -713,37 +168,40 @@ gboolean _gap_agent_unregister_osp_server(GapAgent *agent,
        return TRUE;
 }
 
-gboolean gap_agent_reply_pin_code(GapAgent *agent, const guint accept,
+gboolean gap_agent_reply_pin_code(GapAgentPrivate *agent, const guint accept,
                                                const char *pin_code,
-                                               DBusGMethodInvocation *context)
+                                               GDBusMethodInvocation *context)
 {
        BT_DBG("+");
 
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
+       GapAgentPrivate *priv = agent;
+
+       /* Fix : NULL_RETURNS */
+       retv_if(priv == NULL, FALSE);
 
        if (priv->exec_type != GAP_AGENT_EXEC_NO_OPERATION &&
                                                priv->reply_context != NULL) {
                if (accept == GAP_AGENT_ACCEPT) {
-                       dbus_g_method_return(priv->reply_context, pin_code);
+                       g_dbus_method_invocation_return_value(priv->reply_context,
+                                       g_variant_new("(s)", pin_code));
                        priv->canceled = FALSE;
                } else {
-                       GError *error = NULL;
                        switch (accept) {
                        case GAP_AGENT_CANCEL:
-                               error = gap_agent_error(GAP_AGENT_ERROR_CANCEL,
-                                                               "CanceledbyUser");
+                               g_dbus_method_invocation_return_error(priv->reply_context,
+                                               GAP_AGENT_ERROR, GAP_AGENT_ERROR_CANCEL,
+                                               "CanceledbyUser");
                                priv->canceled = TRUE;
                                break;
                        case GAP_AGENT_TIMEOUT:
                        case GAP_AGENT_REJECT:
                        default:
-                               error = gap_agent_error(GAP_AGENT_ERROR_REJECT,
-                                                               "Pairing request rejected");
+                               g_dbus_method_invocation_return_error(priv->reply_context,
+                                               GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
+                                               "Pairing request rejected");
                                priv->canceled = FALSE;
                                break;
                        }
-                       dbus_g_method_return_error(priv->reply_context, error);
-                       g_error_free(error);
                }
        }
 
@@ -756,38 +214,41 @@ gboolean gap_agent_reply_pin_code(GapAgent *agent, const guint accept,
        return TRUE;
 }
 
-gboolean gap_agent_reply_passkey(GapAgent *agent, const guint accept,
+gboolean gap_agent_reply_passkey(GapAgentPrivate *agent, const guint accept,
                                                const char *passkey,
-                                               DBusGMethodInvocation *context)
+                                               GDBusMethodInvocation *context)
 {
        BT_DBG("+");
 
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
+       GapAgentPrivate *priv = agent;
+
+       /* Fix : NULL_RETURNS */
+       retv_if(priv == NULL, FALSE);
 
        if (priv->exec_type != GAP_AGENT_EXEC_NO_OPERATION &&
                                                priv->reply_context != NULL) {
                if (accept == GAP_AGENT_ACCEPT) {
                        guint pass_key = atoi(passkey);
-                       dbus_g_method_return(priv->reply_context, pass_key);
+                       g_dbus_method_invocation_return_value(priv->reply_context,
+                                       g_variant_new("(u)", pass_key));
                        priv->canceled = FALSE;
                } else {
-                       GError *error = NULL;
                        switch (accept) {
                        case GAP_AGENT_CANCEL:
-                               error = gap_agent_error(GAP_AGENT_ERROR_CANCEL,
-                                                               "CanceledbyUser");
+                               g_dbus_method_invocation_return_error(priv->reply_context,
+                                               GAP_AGENT_ERROR, GAP_AGENT_ERROR_CANCEL,
+                                               "CanceledbyUser");
                                priv->canceled = TRUE;
                                break;
                        case GAP_AGENT_TIMEOUT:
                        case GAP_AGENT_REJECT:
                        default:
-                               error = gap_agent_error(GAP_AGENT_ERROR_REJECT,
-                                                               "Passkey request rejected");
+                               g_dbus_method_invocation_return_error(priv->reply_context,
+                                               GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
+                                               "Passkey request rejected");
                                priv->canceled = FALSE;
                                break;
                        }
-                       dbus_g_method_return_error(priv->reply_context, error);
-                       g_error_free(error);
                }
        }
 
@@ -800,36 +261,38 @@ gboolean gap_agent_reply_passkey(GapAgent *agent, const guint accept,
        return TRUE;
 }
 
-gboolean gap_agent_reply_confirmation(GapAgent *agent, const guint accept,
-                                         DBusGMethodInvocation *context)
+gboolean gap_agent_reply_confirmation(GapAgentPrivate *agent, const guint accept,
+               GDBusMethodInvocation *context)
 {
        BT_DBG("+");
 
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
+       GapAgentPrivate *priv = agent;
+
+       /* Fix : NULL_RETURNS */
+       retv_if(priv == NULL, FALSE);
 
        if (priv->exec_type != GAP_AGENT_EXEC_NO_OPERATION &&
                                                priv->reply_context != NULL) {
                if (accept == GAP_AGENT_ACCEPT) {
-                       dbus_g_method_return(priv->reply_context);
+                       g_dbus_method_invocation_return_value(priv->reply_context, NULL);
                        priv->canceled = FALSE;
                } else {
-                       GError *error = NULL;
                        switch (accept) {
                        case GAP_AGENT_CANCEL:
-                               error = gap_agent_error(GAP_AGENT_ERROR_CANCEL,
-                                                               "CanceledbyUser");
+                               g_dbus_method_invocation_return_error(priv->reply_context,
+                                               GAP_AGENT_ERROR, GAP_AGENT_ERROR_CANCEL,
+                                               "CanceledbyUser");
                                priv->canceled = TRUE;
                                break;
                        case GAP_AGENT_TIMEOUT:
                        case GAP_AGENT_REJECT:
                        default:
-                               error = gap_agent_error(GAP_AGENT_ERROR_REJECT,
-                                                               "Confirmation request rejected");
+                               g_dbus_method_invocation_return_error(priv->reply_context,
+                                               GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
+                                               "Confirmation request rejected");
                                priv->canceled = FALSE;
                                break;
                        }
-                       dbus_g_method_return_error(priv->reply_context, error);
-                       g_error_free(error);
                }
        }
 
@@ -842,19 +305,22 @@ gboolean gap_agent_reply_confirmation(GapAgent *agent, const guint accept,
        return TRUE;
 }
 
-gboolean gap_agent_reply_authorize(GapAgent *agent, const guint accept,
-                                      DBusGMethodInvocation *context)
+gboolean gap_agent_reply_authorize(GapAgentPrivate *agent, const guint accept,
+               GDBusMethodInvocation *context)
 {
        gboolean ret = TRUE;
 
        BT_DBG("+");
 
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
+       GapAgentPrivate *priv = agent;
+
+       /* Fix : NULL_RETURNS */
+       retv_if(priv == NULL, FALSE);
 
        if (priv->exec_type != GAP_AGENT_EXEC_NO_OPERATION &&
                                                priv->reply_context != NULL) {
                if (accept == GAP_AGENT_ACCEPT) {
-                       dbus_g_method_return(priv->reply_context);
+                       g_dbus_method_invocation_return_value(priv->reply_context, NULL);
                } else if (accept == GAP_AGENT_ACCEPT_ALWAYS) {
                        bluetooth_device_address_t addr = {{0,}};
                        int result;
@@ -867,36 +333,33 @@ gboolean gap_agent_reply_authorize(GapAgent *agent, const guint accept,
                                BT_INFO("[%s] Device added to trusted", priv->authorize_addr);
                        }
 
-                       dbus_g_method_return(priv->reply_context);
+                       g_dbus_method_invocation_return_value(priv->reply_context, NULL);
                } else {
-                       GError *error = NULL;
                        switch (accept) {
                        case GAP_AGENT_CANCEL:
-                               error = gap_agent_error(GAP_AGENT_ERROR_CANCEL,
-                                                               "CanceledbyUser");
+                               g_dbus_method_invocation_return_error(priv->reply_context,
+                                               GAP_AGENT_ERROR, GAP_AGENT_ERROR_CANCEL,
+                                               "CanceledbyUser");
                                break;
                        case GAP_AGENT_TIMEOUT:
                        case GAP_AGENT_REJECT:
                        default:
-                               error = gap_agent_error(GAP_AGENT_ERROR_REJECT,
-                                                               "Authorization request rejected");
+                               g_dbus_method_invocation_return_error(priv->reply_context,
+                                               GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
+                                               "Authorization request rejected");
                                break;
                        }
-                       dbus_g_method_return_error(priv->reply_context, error);
-                       g_error_free(error);
                }
 
                if (context)
-                       dbus_g_method_return(context);
+                       g_dbus_method_invocation_return_value(context, NULL);
        } else {
-               GError *error = gap_agent_error(GAP_AGENT_ERROR_REJECT,
-                                                       "No context");
                BT_ERR("No context");
 
                if (context)
-                       dbus_g_method_return_error(context, error);
-
-               g_error_free(error);
+                       g_dbus_method_invocation_return_error(context,
+                                       GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
+                                       "No context");
                ret = FALSE;
        }
 
@@ -909,129 +372,708 @@ gboolean gap_agent_reply_authorize(GapAgent *agent, const guint accept,
        return ret;
 }
 
-static gboolean gap_agent_get_discoverable_timeout(GapAgent *agent,
-                                               DBusGMethodInvocation *context)
-{
-       BT_DBG("+");
-
-       int timeout;
-
-       _bt_get_timeout_value(&timeout);
-
-       dbus_g_method_return(context, timeout);
-
-       BT_DBG("-");
-
-       return TRUE;
-}
-
-gboolean _gap_agent_register(GapAgent *agent)
+gboolean _gap_agent_register(GapAgentPrivate *agent)
 {
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
-       DBusGProxy *agent_manager;
+       GapAgentPrivate *priv = agent;
+       GDBusProxy *agent_manager;
        GError *error = NULL;
+       GVariant *reply;
 
        retv_if(priv == NULL, FALSE);
        retv_if(connection == NULL, FALSE);
 
        if (priv->agent_manager == NULL) {
-               agent_manager = dbus_g_proxy_new_for_name(connection,
-                                       BT_BLUEZ_NAME, BT_BLUEZ_PATH,
-                                       BT_AGENT_MANAGER_INTERFACE);
-
-               retv_if(agent_manager == NULL, FALSE);
+               agent_manager = g_dbus_proxy_new_sync(connection,
+                               G_DBUS_PROXY_FLAGS_NONE, NULL,
+                               BT_BLUEZ_NAME, BT_BLUEZ_PATH,
+                               BT_AGENT_MANAGER_INTERFACE, NULL, &error);
+               if (!agent_manager) {
+                       if (error) {
+                               ERR("Unable to create proxy: %s", error->message);
+                               g_clear_error(&error);
+                       }
+                       return FALSE;
+               }
        } else {
                agent_manager = priv->agent_manager;
        }
 
-#ifdef __TIZEN_MOBILE_
-       dbus_g_proxy_call(agent_manager, "RegisterAgent", &error,
-                               DBUS_TYPE_G_OBJECT_PATH, priv->path,
-                               G_TYPE_STRING, "DisplayYesNo", G_TYPE_INVALID,
-                               G_TYPE_INVALID);
-else
-       dbus_g_proxy_call(agent_manager, "RegisterAgent", &error,
-                       DBUS_TYPE_G_OBJECT_PATH, priv->path,
-                       G_TYPE_STRING, "NoInputNoOutput", G_TYPE_INVALID,
-                       G_TYPE_INVALID);
-#endif
-       if (error != NULL) {
-               BT_DBG("Agent registration failed: %s\n", error->message);
-               g_error_free(error);
+       reply = g_dbus_proxy_call_sync(agent_manager, "RegisterAgent",
+                       g_variant_new("(os)", priv->path, "DisplayYesNo"),
+                               G_DBUS_CALL_FLAGS_NONE, -1,
+                               NULL, &error);
+       if (reply == NULL) {
+               BT_ERR("Agent registration failed");
+               if (error) {
+                       BT_ERR("Agent registration failed: errCode[%x], message[%s]",
+                               error->code, error->message);
+                       g_clear_error(&error);
+               }
                g_object_unref(agent_manager);
                priv->agent_manager = NULL;
                return FALSE;
        }
+       g_variant_unref(reply);
+       reply = NULL;
 
        /* Set the defalut agent */
-       dbus_g_proxy_call(agent_manager, "RequestDefaultAgent", &error,
-                               DBUS_TYPE_G_OBJECT_PATH, priv->path,
-                               G_TYPE_INVALID, G_TYPE_INVALID);
-
-       if (error != NULL) {
-               BT_DBG("Request agent failed: %s\n", error->message);
-               g_error_free(error);
+       BT_DBG("agent_manager[%p] priv->path[%s]", agent_manager, priv->path);
+       reply = g_dbus_proxy_call_sync(agent_manager, "RequestDefaultAgent",
+                       g_variant_new("(o)", priv->path),
+                       G_DBUS_CALL_FLAGS_NONE, -1,
+                       NULL, &error);
+       if (reply == NULL) {
+               ERR("Request Default Agent failed");
+               if (error) {
+                       ERR("Request Default Agent failed: errCode[%x], message[%s]",
+                               error->code, error->message);
+                       g_clear_error(&error);
+               }
                g_object_unref(agent_manager);
                priv->agent_manager = NULL;
                return FALSE;
        }
+       g_variant_unref(reply);
 
        priv->agent_manager = agent_manager;
 
        return TRUE;
 }
 
-static gboolean __gap_agent_unregister(GapAgent *agent)
+static gboolean __gap_agent_unregister(GapAgentPrivate *agent)
 {
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
-       DBusGProxy *agent_manager;
+       GapAgentPrivate *priv = agent;
+       GDBusProxy *agent_manager;
        GError *error = NULL;
+       GVariant *reply;
 
        retv_if(priv == NULL, FALSE);
        retv_if(priv->path == NULL, FALSE);
        retv_if(connection == NULL, FALSE);
 
        if (priv->agent_manager == NULL) {
-               agent_manager = dbus_g_proxy_new_for_name(connection,
-                                       BT_BLUEZ_NAME, BT_BLUEZ_PATH,
-                                       BT_AGENT_MANAGER_INTERFACE);
-
-               retv_if(agent_manager == NULL, FALSE);
+               agent_manager = g_dbus_proxy_new_sync(connection,
+                               G_DBUS_PROXY_FLAGS_NONE, NULL,
+                               BT_BLUEZ_NAME, BT_BLUEZ_PATH,
+                               BT_AGENT_MANAGER_INTERFACE, NULL, &error);
+               if (!agent_manager) {
+                       if (error) {
+                               ERR("Unable to create proxy: %s", error->message);
+                               g_clear_error(&error);
+                       }
+                       return FALSE;
+               }
        } else {
                agent_manager = priv->agent_manager;
        }
 
-       dbus_g_proxy_call(agent_manager, "UnregisterAgent", &error,
-                               DBUS_TYPE_G_OBJECT_PATH, priv->path,
-                               G_TYPE_INVALID, G_TYPE_INVALID);
-
+       reply = g_dbus_proxy_call_sync(agent_manager, "UnregisterAgent",
+                       g_variant_new("o", priv->path),
+                       G_DBUS_CALL_FLAGS_NONE, -1,
+                       NULL, &error);
        g_object_unref(agent_manager);
        priv->agent_manager = NULL;
 
-       if (error != NULL) {
-               BT_DBG("Agent unregistration failed: %s\n", error->message);
-               g_error_free(error);
+       if (reply == NULL) {
+               ERR("Agent unregistration failed");
+               if (error) {
+                       ERR("Agent unregistration failed: errCode[%x], message[%s]",
+                               error->code, error->message);
+                       g_clear_error(&error);
+               }
                return FALSE;
        }
+       g_variant_unref(reply);
 
        return TRUE;
 }
 
-void _gap_agent_setup_dbus(GapAgent *agent, GAP_AGENT_FUNC_CB *func_cb,
-                                                       const char *path)
+static const gchar gap_agent_bluez_introspection_xml[] =
+"<node name='/'>"
+"  <interface name='org.bluez.Agent1'>"
+"    <method name='RequestPinCode'>"
+"      <arg type='o' name='device' direction='in'/>"
+"      <arg type='s' name='pincode' direction='out'/>"
+"    </method>"
+"    <method name='RequestPasskey'>"
+"      <arg type='o' name='device' direction='in'/>"
+"      <arg type='u' name='passkey' direction='out'/>"
+"    </method>"
+"    <method name='DisplayPasskey'>"
+"      <arg type='o' name='device' direction='in'/>"
+"      <arg type='u' name='passkey' direction='in'/>"
+"      <arg type='q' name='entered' direction='in'/>"
+"    </method>"
+"    <method name='RequestConfirmation'>"
+"      <arg type='o' name='device' direction='in'/>"
+"      <arg type='u' name='passkey' direction='in'/>"
+"    </method>"
+"    <method name='RequestAuthorization'>"
+"      <arg type='o' name='device' direction='in'/>"
+"    </method>"
+"    <method name='AuthorizeService'>"
+"      <arg type='o' name='device' direction='in'/>"
+"      <arg type='s' name='uuid' direction='in'/>"
+"    </method>"
+"    <method name='Cancel'>"
+"    </method>"
+"    <method name='Release'>"
+"    </method>"
+"    <method name='ReplyPinCode'>"
+"      <arg type='u' name='accept' direction='in'/>"
+"      <arg type='s' name='pincode' direction='in'/>"
+"    </method>"
+"    <method name='ReplyPasskey'>"
+"      <arg type='u' name='accept' direction='in'/>"
+"      <arg type='s' name='passkey' direction='in'/>"
+"    </method>"
+"    <method name='ReplyConfirmation'>"
+"      <arg type='u' name='accept' direction='in'/>"
+"    </method>"
+"    <method name='ReplyAuthorize'>"
+"      <arg type='u' name='accept' direction='in'/>"
+"    </method>"
+"    <method name='ConfirmModeChange'>"
+"      <arg type='s' name='mode' direction='in'/>"
+"    </method>"
+"    <method name='GetDiscoverableTimeout'>"
+"      <arg type='u' name='timeout' direction='out'/>"
+"    </method>"
+"  </interface>"
+"</node>";
+
+static GDBusNodeInfo *__bt_service_create_method_node_info
+                                       (const gchar *introspection_data)
+{
+       GError *err = NULL;
+       GDBusNodeInfo *node_info = NULL;
+
+       if (introspection_data == NULL)
+               return NULL;
+
+       node_info = g_dbus_node_info_new_for_xml(introspection_data, &err);
+
+       if (err) {
+               ERR("Unable to create node: %s", err->message);
+               g_clear_error(&err);
+       }
+       return node_info;
+}
+
+static void __bt_gap_agent_method(GDBusConnection *connection,
+                       const gchar *sender,
+                       const gchar *object_path,
+                       const gchar *interface_name,
+                       const gchar *method_name,
+                       GVariant *parameters,
+                       GDBusMethodInvocation *invocation,
+                       gpointer user_data)
+{
+       FN_START;
+
+       BT_DBG("Method[%s] Object Path[%s] Interface Name[%s]",
+                       method_name, object_path, interface_name);
+
+       GError *err = NULL;
+
+       if (g_strcmp0(method_name, "RequestPinCode") == 0) {
+               GapAgentPrivate *agent = user_data;
+               char *sender = (char *)g_dbus_method_invocation_get_sender(invocation);
+               GDBusProxy *device;
+               char *addr;
+               char *path;
+               GDBusConnection *conn;
+
+               if (sender == NULL)
+                       return;
+
+               g_variant_get(parameters, "(&o)", &path);
+               BT_INFO("Request pin code, Device Path :%s", path);
+
+               /* Need to check
+               if (g_strcmp0(sender, agent->busname) != 0)
+                       return;
+               */
+
+               if (!agent->cb.passkey_func)
+                       return;
+
+               conn = _bt_get_system_gconn();
+               if (conn == NULL)
+                       return;
+
+               device = g_dbus_proxy_new_sync(conn,
+                               G_DBUS_PROXY_FLAGS_NONE, NULL,
+                               BT_BLUEZ_NAME, path,
+                               BT_PROPERTIES_INTERFACE, NULL, &err);
+
+               if (!device) {
+                       BT_ERR("Fail to make device proxy");
+
+                       g_dbus_method_invocation_return_error(invocation,
+                                       GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
+                                       "No proxy for device");
+
+                       if (err) {
+                               ERR("Unable to create proxy: %s", err->message);
+                               g_clear_error(&err);
+                       }
+
+                       return;
+               }
+
+               agent->exec_type = GAP_AGENT_EXEC_PAIRING;
+               agent->reply_context = invocation;
+
+               addr = strstr(path, "dev_");
+               if (addr != NULL) {
+                       char *pos = NULL;
+                       addr += 4;
+                       g_strlcpy(agent->pairing_addr, addr, sizeof(agent->pairing_addr));
+
+                       while ((pos = strchr(agent->pairing_addr, '_')) != NULL) {
+                               *pos = ':';
+                       }
+               }
+
+               agent->cb.pincode_func(agent, device);
+
+               g_object_unref(device);
+               return;
+
+       } else if (g_strcmp0(method_name, "RequestPasskey") == 0) {
+               GapAgentPrivate *priv = user_data;
+               char *sender = (char *)g_dbus_method_invocation_get_sender(invocation);
+               GDBusProxy *device;
+               char *addr;
+               char *path;
+               GDBusConnection *conn;
+
+               if (sender == NULL)
+                       return;
+
+               g_variant_get(parameters, "(&o)", &path);
+               BT_INFO("Request passkey : sender %s priv->busname %s Device Path :%s",
+                               sender, priv->busname, path);
+
+               /* Need to check
+               if (g_strcmp0(sender, agent->busname) != 0)
+                       return;
+               */
+
+               if (!priv->cb.passkey_func)
+                       return;
+
+               conn = _bt_get_system_gconn();
+               if (conn == NULL)
+                       return;
+
+               device = g_dbus_proxy_new_sync(conn,
+                               G_DBUS_PROXY_FLAGS_NONE, NULL,
+                               BT_BLUEZ_NAME, path,
+                               BT_PROPERTIES_INTERFACE, NULL, &err);
+
+               if (!device) {
+                       BT_ERR("Fail to make device proxy");
+
+                       g_dbus_method_invocation_return_error(invocation,
+                                       GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
+                                       "No proxy for device");
+
+                       if (err) {
+                               ERR("Unable to create proxy: %s", err->message);
+                               g_clear_error(&err);
+                       }
+
+                       return;
+               }
+
+               priv->exec_type = GAP_AGENT_EXEC_PAIRING;
+               priv->reply_context = invocation;
+
+               addr = strstr(path, "dev_");
+               if (addr != NULL) {
+                       char *pos = NULL;
+                       addr += 4;
+                       g_strlcpy(priv->pairing_addr, addr, sizeof(priv->pairing_addr));
+
+                       while ((pos = strchr(priv->pairing_addr, '_')) != NULL) {
+                               *pos = ':';
+                       }
+               }
+
+               priv->cb.passkey_func(priv, device);
+
+               g_object_unref(device);
+               return;
+
+       } else if (g_strcmp0(method_name, "DisplayPasskey") == 0) {
+               GapAgentPrivate *priv = user_data;
+               char *sender = (char *)g_dbus_method_invocation_get_sender(invocation);
+               GDBusProxy *device;
+               guint passkey;
+               guint16 entered;
+               char *path;
+               GDBusConnection *conn;
+
+               if (sender == NULL)
+                       return;
+
+               g_variant_get(parameters, "(&ouq)", &path, &passkey, &entered);
+               BT_INFO("Request passkey display :sender %s priv->busname %s"
+                               " Device Path :%s, Passkey: %d, Entered: %d",
+                               sender, priv->busname, path, passkey, entered);
+
+               /* Do not show popup for Key event while typing*/
+               if (entered)
+                       return;
+
+               /* Need to check
+               if (g_strcmp0(sender, agent->busname) != 0)
+                       return;
+               */
+
+               if (!priv->cb.display_func)
+                       return;
+
+               conn = _bt_get_system_gconn();
+               if (conn == NULL)
+                       return;
+
+               device = g_dbus_proxy_new_sync(conn,
+                               G_DBUS_PROXY_FLAGS_NONE, NULL,
+                               BT_BLUEZ_NAME, path,
+                               BT_PROPERTIES_INTERFACE, NULL, &err);
+
+               if (!device) {
+                       BT_ERR("Fail to make device proxy");
+
+                       g_dbus_method_invocation_return_error(invocation,
+                                       GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
+                                       "No proxy for device");
+
+                       if (err) {
+                               ERR("Unable to create proxy: %s", err->message);
+                               g_clear_error(&err);
+                       }
+
+                       return;
+               }
+
+               g_dbus_method_invocation_return_value(invocation, NULL);
+
+               priv->cb.display_func(priv, device, passkey);
+
+               g_object_unref(device);
+               return;
+
+       } else if (g_strcmp0(method_name, "RequestConfirmation") == 0) {
+               GapAgentPrivate *priv = user_data;
+               char *sender = (char *)g_dbus_method_invocation_get_sender(invocation);
+               GDBusProxy *device;
+               guint passkey;
+               char *path;
+               char *addr;
+               GDBusConnection *conn;
+
+               if (sender == NULL)
+                       return;
+
+               g_variant_get(parameters, "(&ou)", &path, &passkey);
+               BT_INFO("Request passkey confirmation, Device Path :%s, Passkey: %d",
+                               path, passkey);
+
+               BT_DBG("Sender: [%s] priv->busname: [%s]", sender, priv->busname);
+               /* Need to check
+               if (g_strcmp0(sender, agent->busname) != 0)
+                       return;
+               */
+
+               BT_DBG("priv->cb.confirm_func [%p]", priv->cb.confirm_func);
+               if (!priv->cb.confirm_func)
+                       return;
+
+               conn = _bt_get_system_gconn();
+               if (conn == NULL)
+                       return;
+
+               device = g_dbus_proxy_new_sync(conn,
+                               G_DBUS_PROXY_FLAGS_NONE, NULL,
+                               BT_BLUEZ_NAME, path,
+                               BT_PROPERTIES_INTERFACE, NULL, &err);
+
+               if (!device) {
+                       BT_ERR("Fail to make device proxy");
+
+                       g_dbus_method_invocation_return_error(invocation,
+                                       GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
+                                       "No proxy for device");
+
+                       if (err) {
+                               ERR("Unable to create proxy: %s", err->message);
+                               g_clear_error(&err);
+                       }
+
+                       return;
+               }
+
+               priv->exec_type = GAP_AGENT_EXEC_PAIRING;
+               priv->reply_context = invocation;
+
+               addr = strstr(path, "dev_");
+               if (addr != NULL) {
+                       char *pos = NULL;
+                       addr += 4;
+                       g_strlcpy(priv->pairing_addr, addr, sizeof(priv->pairing_addr));
+
+                       while ((pos = strchr(priv->pairing_addr, '_')) != NULL) {
+                               *pos = ':';
+                       }
+               }
+
+               priv->cb.confirm_func(priv, device, passkey);
+
+               g_object_unref(device);
+               return;
+
+       } else if (g_strcmp0(method_name, "AuthorizeService") == 0) {
+               GapAgentPrivate *priv = user_data;
+               char *sender = (char *)g_dbus_method_invocation_get_sender(invocation);
+               GDBusProxy *device;
+               GDBusConnection *conn;
+               char *addr;
+               char *path;
+               char *uuid;
+
+               if (sender == NULL)
+                       return;
+
+               g_variant_get(parameters, "(&o&s)", &path, &uuid);
+               BT_DBG("Request authorization :sender %s priv->busname %s "
+                               "Device Path :%s UUID: %s",
+                               sender, priv->busname, path, uuid);
+
+               /* Need to check
+               if (g_strcmp0(sender, agent->busname) != 0)
+                       return;
+               */
+
+               if (!priv->cb.authorize_func)
+                       return;
+
+               conn = _bt_get_system_gconn();
+               if (conn == NULL)
+                       return;
+
+               device = g_dbus_proxy_new_sync(conn,
+                               G_DBUS_PROXY_FLAGS_NONE, NULL,
+                               BT_BLUEZ_NAME, path,
+                               BT_PROPERTIES_INTERFACE, NULL, &err);
+
+               if (!device) {
+                       BT_ERR("Fail to make device proxy");
+
+                       g_dbus_method_invocation_return_error(invocation,
+                                       GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
+                                       "No proxy for device");
+
+                       if (err) {
+                               ERR("Unable to create proxy: %s", err->message);
+                               g_clear_error(&err);
+                       }
+
+                       return;
+               }
+
+               priv->exec_type = GAP_AGENT_EXEC_AUTHORZATION;
+               priv->reply_context = invocation;
+
+               addr = strstr(path, "dev_");
+               if (addr != NULL) {
+                       char *pos = NULL;
+                       addr += 4;
+                       g_strlcpy(priv->authorize_addr, addr,
+                                                       sizeof(priv->authorize_addr));
+
+                       while ((pos = strchr(priv->authorize_addr, '_')) != NULL) {
+                               *pos = ':';
+                       }
+               }
+
+               priv->cb.authorize_func(priv, device, uuid);
+
+               g_object_unref(device);
+               return;
+
+       } else if (g_strcmp0(method_name, "RequestAuthorization") == 0) {
+               g_dbus_method_invocation_return_value(invocation, NULL);
+       } else if (g_strcmp0(method_name, "ConfirmModeChange") == 0) {
+               g_dbus_method_invocation_return_value(invocation, NULL);
+       } else if (g_strcmp0(method_name, "Cancel") == 0) {
+               GapAgentPrivate *priv = user_data;
+               char *sender = (char *)g_dbus_method_invocation_get_sender(invocation);
+
+               if (sender == NULL)
+                       return;
+
+               BT_DBG("Cancelled : agent %p sender %s", sender);
+
+               /* Need to check
+               if (g_strcmp0(sender, agent->busname) != 0)
+                       return;
+               */
+
+               if (priv->cb.authorization_cancel_func &&
+                               priv->exec_type == GAP_AGENT_EXEC_AUTHORZATION) {
+                       priv->cb.authorization_cancel_func(priv,
+                                                               priv->authorize_addr);
+                       memset(priv->authorize_addr, 0x00,
+                                                       sizeof(priv->authorize_addr));
+               } else if (priv->cb.pairing_cancel_func &&
+                                       priv->exec_type == GAP_AGENT_EXEC_PAIRING) {
+                       priv->cb.pairing_cancel_func(priv,
+                                                               priv->pairing_addr);
+                       memset(priv->pairing_addr, 0x00, sizeof(priv->pairing_addr));
+               }
+
+               if (priv->exec_type != GAP_AGENT_EXEC_CONFIRM_MODE &&
+                               priv->exec_type != GAP_AGENT_EXEC_NO_OPERATION &&
+                               priv->reply_context != NULL) {
+
+                       g_dbus_method_invocation_return_error(priv->reply_context,
+                                       GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
+                                       "Rejected by remote cancel");
+               }
+
+               /* Canceled flag is set when user cancels pairing request
+                * Since here bluez has cancelled pairing request, we set the flag to false
+                */
+               priv->canceled = FALSE;
+               priv->exec_type = GAP_AGENT_EXEC_NO_OPERATION;
+               priv->reply_context = NULL;
+
+               return;
+       } else if (g_strcmp0(method_name, "Release") == 0) {
+               GapAgentPrivate *priv = user_data;
+               char *sender = (char *)g_dbus_method_invocation_get_sender(invocation);
+
+               if (sender == NULL)
+                       return;
+
+               BT_DBG("Released : sender %s\n", sender);
+
+               /* Need to check
+               if (g_strcmp0(sender, agent->busname) != 0)
+                       return;
+               */
+
+               g_dbus_method_invocation_return_value(invocation, NULL);
+
+               priv->exec_type = GAP_AGENT_EXEC_NO_OPERATION;
+               priv->reply_context = NULL;
+
+               memset(priv->pairing_addr, 0x00, sizeof(priv->pairing_addr));
+               memset(priv->authorize_addr, 0x00, sizeof(priv->authorize_addr));
+
+               return;
+       } else if (g_strcmp0(method_name, "GetDiscoverableTimeout") == 0) {
+               BT_DBG("+");
+
+               int timeout;
+
+               _bt_get_timeout_value(&timeout);
+
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", timeout));
+
+               BT_DBG("-");
+
+               return;
+       } else if (g_strcmp0(method_name, "ReplyPinCode") == 0) {
+               GapAgentPrivate *priv = user_data;
+               const char *pin_code;
+               const guint accept;
+
+               g_variant_get(parameters, "(u&s)", &accept, &pin_code);
+               BT_DBG("Accept: %d PinCode: %s", accept, pin_code);
+               gap_agent_reply_pin_code(priv, accept, pin_code, invocation);
+       } else if (g_strcmp0(method_name, "ReplyPasskey") == 0) {
+               GapAgentPrivate *priv = user_data;
+               const char *passkey;
+               const guint accept;
+
+               g_variant_get(parameters, "(u&s)", &accept, &passkey);
+               BT_DBG("Accept: %d PinCode: %s", accept, passkey);
+               gap_agent_reply_passkey(priv, accept, passkey, invocation);
+       } else if (g_strcmp0(method_name, "ReplyConfirmation") == 0) {
+               GapAgentPrivate *priv = user_data;
+               const guint accept;
+
+               g_variant_get(parameters, "(u)", &accept);
+               BT_DBG("Accept: %d", accept);
+               gap_agent_reply_confirmation(priv, accept, invocation);
+       } else if (g_strcmp0(method_name, "ReplyAuthorize") == 0) {
+               GapAgentPrivate *priv = user_data;
+               const guint accept;
+
+               g_variant_get(parameters, "(u)", &accept);
+               BT_DBG("Accept: %d", accept);
+               gap_agent_reply_authorize(priv, accept, invocation);
+       }
+}
+
+static const GDBusInterfaceVTable method_table = {
+       __bt_gap_agent_method,
+       NULL,
+       NULL,
+};
+
+void _gap_agent_setup_dbus(GapAgentPrivate *agent, GAP_AGENT_FUNC_CB *func_cb,
+                                                       const char *path,
+                                                       GDBusProxy *adapter)
 {
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
-       GObject *object;
-       DBusGProxy *proxy;
+       GapAgentPrivate *priv = agent;
+       GDBusProxy *proxy;
+       GDBusNodeInfo *node_info;
+       GError *error = NULL;
+
 
        priv->path = g_strdup(path);
 
-       object = dbus_g_connection_lookup_g_object(connection, priv->path);
-       if (object != NULL)
-               g_object_unref(object);
 
-       dbus_g_connection_register_g_object(connection, priv->path,
-                                                       G_OBJECT(agent));
+       node_info = __bt_service_create_method_node_info(
+                               gap_agent_bluez_introspection_xml);
+       if (node_info == NULL)
+               return;
+
+       BT_DBG("path is [%s]", path);
+
+       connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (!connection) {
+               if (error) {
+                       ERR("Unable to connect to gdbus: %s", error->message);
+                       g_clear_error(&error);
+               }
+               return;
+       }
+
+       if (gap_agent_id == -1) {
+       gap_agent_id = g_dbus_connection_register_object(connection, path,
+                                       node_info->interfaces[0],
+                                       &method_table, priv,
+                                       NULL, &error);
+       }
+
+       g_dbus_node_info_unref(node_info);
+
+       if (gap_agent_id == 0) {
+               BT_ERR("Failed to register for Path: %s", path);
+               if (error) {
+                       BT_ERR("Failed to register: %s", error->message);
+                       g_clear_error(&error);
+               }
+               return;
+       }
 
        memcpy(&priv->cb, func_cb, sizeof(GAP_AGENT_FUNC_CB));
 
@@ -1040,28 +1082,43 @@ void _gap_agent_setup_dbus(GapAgent *agent, GAP_AGENT_FUNC_CB *func_cb,
        memset(priv->authorize_addr, 0x00, sizeof(priv->authorize_addr));
        priv->reply_context = NULL;
 
-       BT_DBG("patt: %s", path);
+       BT_DBG("path: %s", path);
 
-       proxy = dbus_g_proxy_new_for_name_owner(connection,
-                               BT_BLUEZ_NAME,
-                               path,
-                               BT_AGENT_INTERFACE,
-                               NULL);
-       if (proxy != NULL) {
-               priv->busname = g_strdup(dbus_g_proxy_get_bus_name(proxy));
-               g_object_unref(proxy);
-       } else {
+       proxy =  g_dbus_proxy_new_sync(connection,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       BT_BLUEZ_NAME, path,
+                       BT_AGENT_INTERFACE, NULL, &error);
+
+       if (!proxy) {
+               ERR("Unable to create proxy");
+               if (error) {
+                       ERR("Error: %s", error->message);
+                       g_clear_error(&error);
+               }
                priv->busname = NULL;
+       } else {
+               priv->busname = g_strdup(g_dbus_proxy_get_name(proxy));
+               g_object_unref(proxy);
+               BT_DBG("Busname: %s", priv->busname);
        }
+
 }
 
-void _gap_agent_reset_dbus(GapAgent *agent)
+void _gap_agent_reset_dbus(GapAgentPrivate *agent)
 {
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
+       GapAgentPrivate *priv = agent;
+
+       /* Fix : NULL_RETURNS */
+       if (priv == NULL)
+               return ;
 
        __gap_agent_unregister(agent);
 
-       dbus_g_connection_unregister_g_object(connection, G_OBJECT(agent));
+       if (gap_agent_id > 0) {
+               g_dbus_connection_unregister_object(connection,
+                               gap_agent_id);
+               gap_agent_id = 0;
+       }
 
        if (priv->osp_servers) {
                __gap_agent_remove_osp_servers(priv->osp_servers);
@@ -1069,10 +1126,8 @@ void _gap_agent_reset_dbus(GapAgent *agent)
                priv->osp_servers = NULL;
        }
 
-       if (priv->adapter) {
-               g_object_unref(priv->adapter);
-               priv->adapter = NULL;
-       }
+       g_object_ref(priv->adapter);
+       priv->adapter = NULL;
 
        g_free(priv->path);
        priv->path = NULL;
@@ -1081,12 +1136,12 @@ void _gap_agent_reset_dbus(GapAgent *agent)
        priv->busname = NULL;
 }
 
-gboolean _gap_agent_exist_osp_server(GapAgent *agent, int type, char *uuid)
+gboolean _gap_agent_exist_osp_server(GapAgentPrivate *agent, int type, char *uuid)
 {
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
+       GapAgentPrivate *priv = agent;
 
-       if (priv == NULL)
-               return FALSE;
+       /* Fix : NULL_RETURNS */
+       retv_if(priv == NULL, FALSE);
 
        if (__gap_agent_find_server(priv->osp_servers,
                                type, uuid) != NULL) {
@@ -1096,10 +1151,10 @@ gboolean _gap_agent_exist_osp_server(GapAgent *agent, int type, char *uuid)
        return FALSE;
 }
 
-bt_agent_osp_server_t *_gap_agent_get_osp_server(GapAgent *agent, int type,
+bt_agent_osp_server_t *_gap_agent_get_osp_server(GapAgentPrivate *agent, int type,
                                        char *uuid)
 {
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
+       GapAgentPrivate *priv = agent;
        bt_agent_osp_server_t *osp_serv = NULL;
        if (priv == NULL)
                return NULL;
@@ -1113,23 +1168,34 @@ bt_agent_osp_server_t *_gap_agent_get_osp_server(GapAgent *agent, int type,
        return osp_serv;
 }
 
-gchar* _gap_agent_get_path(GapAgent *agent)
+gchar* _gap_agent_get_path(GapAgentPrivate *agent)
 {
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
+       GapAgentPrivate *priv = agent;
+
+       /* Fix : NULL_RETURNS */
+       if (priv == NULL)
+               return NULL;
 
        return priv->path;
 }
 
-gboolean _gap_agent_is_canceled(GapAgent *agent)
+gboolean _gap_agent_is_canceled(GapAgentPrivate *agent)
 {
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
+       GapAgentPrivate *priv = agent;
+
+       /* Fix : NULL_RETURNS */
+       retv_if(priv == NULL, FALSE);
 
        return priv->canceled;
 }
 
-void _gap_agent_set_canceled(GapAgent *agent, gboolean value)
+void _gap_agent_set_canceled(GapAgentPrivate *agent, gboolean value)
 {
-       GapAgentPrivate *priv = GAP_AGENT_GET_PRIVATE(agent);
+       GapAgentPrivate *priv = agent;
+
+       /* Fix : NULL_RETURNS */
+       if (priv == NULL)
+               return;
 
        priv->canceled = value;
 }
index ca79727..f3438cb 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 
 <node name="/">
-  <interface name="org.bluez.Agent1">
+  <interface name="org.bluez.Agent">
     <method name="RequestPinCode">
       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
       <arg type="o" name="device"/>
       <arg type="u" name="passkey"/>
     </method>
 
-    <method name="RequestAuthorization">
-      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
-      <arg type="o" name="device"/>
-    </method>
-
-    <method name="AuthorizeService">
+    <method name="Authorize">
       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
       <arg type="o" name="device"/>
       <arg type="s" name="uuid"/>
index 422f9ba..7c19782 100644 (file)
@@ -21,9 +21,6 @@
  *
  */
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus.h>
 #include <glib.h>
 #include <string.h>
 #include <dlog.h>
index cde8fa2..c6f251a 100644 (file)
  *
  */
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
 #include <glib.h>
+#include <gio/gio.h>
 #include <dlog.h>
 #include <string.h>
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
 #include <syspopup_caller.h>
-#endif
 #include "bluetooth-api.h"
 
 #include "bt-service-common.h"
 #include "bt-service-event.h"
 #include "bt-service-util.h"
 
-static void __bt_hid_connect_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                                   gpointer user_data)
+static void __bt_hid_connect_cb(GDBusProxy *proxy, GAsyncResult *res,
+                                       gpointer user_data)
 {
        GError *g_error = NULL;
-       GArray *out_param1 = NULL;
-       GArray *out_param2 = NULL;
+       GVariant *out_param1 = NULL;
+       GVariant *reply = NULL;
        bluetooth_device_address_t device_addr = { {0} };
        int result = BLUETOOTH_ERROR_NONE;
        bt_function_data_t *func_data;
        request_info_t *req_info;
 
-       dbus_g_proxy_end_call(proxy, call, &g_error, G_TYPE_INVALID);
+       BT_DBG("+");
+       func_data = user_data;
 
+       reply = g_dbus_proxy_call_finish(proxy, res, &g_error);
        g_object_unref(proxy);
+       if (reply == NULL) {
+               BT_ERR("Hid Connect Dbus Call Error");
+               if (g_error) {
+                       BT_ERR("Error: %s\n", g_error->message);
+                       g_clear_error(&g_error);
+               }
+               result = BLUETOOTH_ERROR_INTERNAL;
+       }
+       g_variant_unref(reply);
 
-       func_data = user_data;
 
        if (func_data == NULL) {
                /* Send reply */
@@ -66,58 +73,53 @@ static void __bt_hid_connect_cb(DBusGProxy *proxy, DBusGProxyCall *call,
                goto done;
        }
 
-       if (g_error != NULL) {
-               BT_ERR("Hidh Connect Dbus Call Error: %s\n", g_error->message);
-               result = BLUETOOTH_ERROR_INTERNAL;
-       }
-
        if (req_info->context == NULL)
                goto done;
-
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
+       BT_DBG("Address: %s", func_data->address);
        _bt_convert_addr_string_to_type(device_addr.addr,
                                        func_data->address);
 
-       g_array_append_vals(out_param1, &device_addr,
-                               sizeof(bluetooth_device_address_t));
-       g_array_append_vals(out_param2, &result, sizeof(int));
+       out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+                       &device_addr, sizeof(bluetooth_device_address_t), TRUE, NULL, NULL);
 
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
-
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
+       g_dbus_method_invocation_return_value(req_info->context,
+                       g_variant_new("iv", result, out_param1));
 
        _bt_delete_request_list(req_info->req_id);
        BT_DBG("HID Connected..");
-done:
-       if (g_error)
-               g_error_free(g_error);
 
+done:
        if (func_data) {
                g_free(func_data->address);
                g_free(func_data);
        }
 }
 
-static void __bt_hid_disconnect_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                                   gpointer user_data)
+static void __bt_hid_disconnect_cb(GDBusProxy *proxy,GAsyncResult *res,
+                                       gpointer user_data)
 {
        GError *g_error = NULL;
-       GArray *out_param1 = NULL;
-       GArray *out_param2 = NULL;
+       GVariant *out_param1 = NULL;
+       GVariant *reply;
        bluetooth_device_address_t device_addr = { {0} };
        int result = BLUETOOTH_ERROR_NONE;
        bt_function_data_t *func_data;
        request_info_t *req_info;
 
-       dbus_g_proxy_end_call(proxy, call, &g_error, G_TYPE_INVALID);
-
+       reply = g_dbus_proxy_call_finish(proxy, res, &g_error);
        g_object_unref(proxy);
 
-       func_data = user_data;
+       if (reply == NULL) {
+               BT_ERR("Hid Disconnect Dbus Call Error");
+               if (g_error) {
+                       BT_ERR("Error: %s\n", g_error->message);
+                       g_clear_error(&g_error);
+               }
+               result = BLUETOOTH_ERROR_INTERNAL;
+       }
+       g_variant_unref(reply);
 
+       func_data = user_data;
        if (func_data == NULL) {
                /* Send reply */
                BT_ERR("func_data == NULL");
@@ -130,34 +132,22 @@ static void __bt_hid_disconnect_cb(DBusGProxy *proxy, DBusGProxyCall *call,
                goto done;
        }
 
-       if (g_error != NULL) {
-               BT_ERR("Hidh Connect Dbus Call Error: %s\n", g_error->message);
-               result = BLUETOOTH_ERROR_INTERNAL;
-       }
-
        if (req_info->context == NULL)
                goto done;
-
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
+       BT_DBG("Address: %s", func_data->address);
        _bt_convert_addr_string_to_type(device_addr.addr,
                                        func_data->address);
 
-       g_array_append_vals(out_param1, &device_addr,
-                               sizeof(bluetooth_device_address_t));
-       g_array_append_vals(out_param2, &result, sizeof(int));
-
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
+       out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+                                                       &device_addr, sizeof(bluetooth_device_address_t), TRUE, NULL, NULL);
 
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
+       g_dbus_method_invocation_return_value(req_info->context,
+                       g_variant_new("iv", result, out_param1));
 
        _bt_delete_request_list(req_info->req_id);
-done:
-       if (g_error)
-               g_error_free(g_error);
+       BT_DBG("HID Disconnected..");
 
+done:
        if (func_data) {
                g_free(func_data->address);
                g_free(func_data);
@@ -174,23 +164,26 @@ int _bt_hid_connect(int request_id,
 {
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        bt_function_data_t *func_data;
-       DBusGProxy *adapter_proxy;
-       DBusGConnection *conn;
+       /* GDBusProxy *adapter_proxy; */
+       GDBusConnection *conn;
 
        int ret;
        char *uuid;
 
        BT_CHECK_PARAMETER(device_address, return);
 
+       /* Unused adapter proxy
        adapter_proxy = _bt_get_adapter_proxy();
        retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
+       */
        conn = _bt_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
 
        func_data = g_malloc0(sizeof(bt_function_data_t));
+       /* Fix : NULL_RETURNS */
+       retv_if(func_data == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
 
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
@@ -211,22 +204,25 @@ int _bt_hid_disconnect(int request_id,
 {
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        bt_function_data_t *func_data;
-       DBusGProxy *adapter_proxy;
-       DBusGConnection *conn;
+       /* GDBusProxy *adapter_proxy; */
+       GDBusConnection *conn;
 
        int ret;
 
        BT_CHECK_PARAMETER(device_address, return);
 
+       /* Unused adapter proxy
        adapter_proxy = _bt_get_adapter_proxy();
        retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
+       */
        conn = _bt_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
 
        func_data = g_malloc0(sizeof(bt_function_data_t));
+       /* Fix : NULL_RETURNS */
+       retv_if(func_data == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
 
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
index 794d14d..5b7da77 100644 (file)
  *
  */
 
-#include <dbus/dbus-glib.h>
+//#include <dbus/dbus-glib.h>
 #include <glib.h>
 #include <dlog.h>
 #include <string.h>
 #include <vconf.h>
 
+#ifndef TIZEN_WEARABLE
+#include <privilege-control.h>
+#endif
+#include <bundle.h>
+#include <eventsystem.h>
+
 #include "bt-internal-types.h"
 #include "bt-service-common.h"
 #include "bt-service-event.h"
@@ -34,6 +40,7 @@
 #include "bt-service-util.h"
 #include "bt-request-handler.h"
 #include "bt-service-adapter.h"
+#include "bt-service-adapter-le.h"
 
 static GMainLoop *main_loop;
 static gboolean terminated = FALSE;
@@ -42,6 +49,7 @@ static void __bt_release_service(void)
 {
        _bt_service_unregister_vconf_handler();
 
+       _bt_service_adapter_le_deinit();
        _bt_deinit_service_event_sender();
        _bt_deinit_hf_local_term_event_sender();
        _bt_deinit_service_event_receiver();
@@ -52,16 +60,20 @@ static void __bt_release_service(void)
 
        _bt_clear_request_list();
 
-       _bt_service_cynara_deinit();
-
        BT_DBG("Terminating the bt-service daemon");
 }
 
-static void __bt_sigterm_handler(int signo)
+static void __bt_sigterm_handler(int signo, siginfo_t *info, void *data)
 {
-       BT_DBG("Get the signal: %d", signo);
+       int ret;
 
-       _bt_terminate_service(NULL);
+       BT_INFO("signal [%d] is sent by [%d]", signo, info->si_pid);
+
+       ret = _bt_recover_adapter();
+       if (ret != BLUETOOTH_ERROR_NONE)
+               BT_ERR("_bt_recover_adapter is failed : %d", ret);
+
+       return;
 }
 
 gboolean _bt_terminate_service(gpointer user_data)
@@ -75,10 +87,13 @@ gboolean _bt_terminate_service(gpointer user_data)
                        if(vconf_set_int(VCONFKEY_BT_STATUS,
                                        VCONFKEY_BT_STATUS_OFF) != 0)
                                BT_ERR("Set vconf failed\n");
+
+                       if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_STATE,
+                                                       EVT_VAL_BT_OFF) != ES_R_OK)
+                               BT_ERR("Fail to set value");
                }
        }
 
-#ifdef ENABLE_TIZEN_2_4
        if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_status) < 0) {
                BT_ERR("no bluetooth device info, so BT was disabled at previous session");
        } else {
@@ -86,9 +101,11 @@ gboolean _bt_terminate_service(gpointer user_data)
                        if(vconf_set_int(VCONFKEY_BT_LE_STATUS,
                                        VCONFKEY_BT_LE_STATUS_OFF) != 0)
                                BT_ERR("Set vconf failed\n");
+                       if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_LE_STATE,
+                                                       EVT_VAL_BT_LE_OFF) != ES_R_OK)
+                               BT_ERR("Fail to set value");
                }
        }
-#endif
 
        if (main_loop != NULL) {
                g_main_loop_quit(main_loop);
@@ -112,6 +129,7 @@ gboolean _bt_reliable_terminate_service(gpointer user_data)
 
        _bt_set_disabled(BLUETOOTH_ERROR_NONE);
 
+       _bt_service_adapter_le_deinit();
        _bt_deinit_service_event_sender();
        _bt_deinit_hf_local_term_event_sender();
 
@@ -133,14 +151,11 @@ gboolean _bt_reliable_terminate_service(gpointer user_data)
 static gboolean __bt_check_bt_service(void *data)
 {
        int bt_status = VCONFKEY_BT_STATUS_OFF;
-       int bt_le_status = 0;
+       int bt_le_status = VCONFKEY_BT_LE_STATUS_OFF;
        bt_status_t status = BT_DEACTIVATED;
        bt_le_status_t le_status = BT_LE_DEACTIVATED;
        int flight_mode_deactivation = 0;
        int bt_off_due_to_timeout = 0;
-       _bt_enable_adapter();
-       return FALSE;
-
 #if 0
        int ps_mode_deactivation = 0;
 #endif
@@ -153,11 +168,9 @@ static gboolean __bt_check_bt_service(void *data)
                BT_DBG("no bluetooth device info, so BT was disabled at previous session");
        }
 
-#ifdef ENABLE_TIZEN_2_4
        if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status) < 0) {
                BT_ERR("no bluetooth le info, so BT LE was disabled at previous session");
        }
-#endif
 
        if (vconf_get_int(BT_OFF_DUE_TO_FLIGHT_MODE, &flight_mode_deactivation) != 0)
                BT_ERR("Fail to get the flight_mode_deactivation value");
@@ -170,8 +183,8 @@ static gboolean __bt_check_bt_service(void *data)
        if (vconf_get_int(BT_OFF_DUE_TO_TIMEOUT, &bt_off_due_to_timeout) != 0)
                BT_ERR("Fail to get BT_OFF_DUE_TO_TIMEOUT");
 
-       if ((bt_status != VCONFKEY_BT_STATUS_OFF || bt_off_due_to_timeout)
-               && (status == BT_DEACTIVATED)) {
+       if ((bt_status != VCONFKEY_BT_STATUS_OFF || bt_off_due_to_timeout) &&
+               (status == BT_DEACTIVATED)) {
                BT_DBG("Previous session was enabled.");
 
                /* Enable the BT */
@@ -180,7 +193,7 @@ static gboolean __bt_check_bt_service(void *data)
                _bt_enable_core();
        }
 
-       if ((bt_le_status == 1) && (le_status == BT_LE_DEACTIVATED)) {
+       if ((bt_le_status == VCONFKEY_BT_LE_STATUS_ON) && (le_status == BT_LE_DEACTIVATED)) {
                BT_DBG("Previous session was le enabled. Turn BT LE on automatically.");
 
                /* Enable the BT LE */
@@ -192,9 +205,7 @@ static gboolean __bt_check_bt_service(void *data)
 
                if ((status != BT_ACTIVATING && status != BT_ACTIVATED) &&
                                (le_status != BT_LE_ACTIVATING && le_status != BT_LE_ACTIVATED)){
-#ifndef USB_BLUETOOTH
                        _bt_terminate_service(NULL);
-#endif
                }
        }
 
@@ -207,18 +218,17 @@ int main(void)
        BT_INFO_C("Starting the bt-service daemon");
 
        memset(&sa, 0, sizeof(sa));
-       sa.sa_handler = __bt_sigterm_handler;
+       sa.sa_sigaction = __bt_sigterm_handler;
+       sa.sa_flags = SA_SIGINFO;
        sigaction(SIGINT, &sa, NULL);
        sigaction(SIGTERM, &sa, NULL);
 
        g_type_init();
-
-       /* Security Initialization */
-       if (_bt_service_cynara_init() != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Fail to init cynara");
-               return EXIT_FAILURE;
-       }
-
+#ifndef TIZEN_WEARABLE
+       if (perm_app_set_privilege("bluetooth-frwk-service", NULL, NULL) !=
+               PC_OPERATION_SUCCESS)
+               BT_ERR("Failed to set app privilege");
+#endif
        /* Event reciever Init */
        if (_bt_init_service_event_receiver() != BLUETOOTH_ERROR_NONE) {
                BT_ERR("Fail to init event reciever");
@@ -227,20 +237,25 @@ int main(void)
 
        /* Event sender Init */
        if (_bt_init_service_event_sender() != BLUETOOTH_ERROR_NONE) {
-               BT_ERR(" Sudha 13 Fail to init event sender");
+               BT_ERR("Fail to init event sender");
                return 0;
        }
-/*
+
        if (_bt_init_hf_local_term_event_sender() != BLUETOOTH_ERROR_NONE) {
                BT_ERR("Fail to init core event sender");
                return 0;
        }
-*/
+
        if (_bt_service_register() != BLUETOOTH_ERROR_NONE) {
                BT_ERR("Fail to register service");
                return 0;
        }
 
+       if (_bt_service_adapter_le_init() != BLUETOOTH_ERROR_NONE) {
+               BT_ERR("Fail to init le");
+               return 0;
+       }
+
        _bt_init_request_id();
 
        _bt_init_request_list();
diff --git a/bt-service/bt-service-mdm.c b/bt-service/bt-service-mdm.c
deleted file mode 100644 (file)
index 20af6a9..0000000
+++ /dev/null
@@ -1,652 +0,0 @@
-/*
- * Bluetooth-frwk
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
- *              Girishashok Joshi <girish.joshi@samsung.com>
- *              Chanyeol Park <chanyeol.park@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *             http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifdef TIZEN_MDM_ENABLE
-#include <syspopup_caller.h>
-
-#include "bt-internal-types.h"
-#include "bt-service-common.h"
-#include "bt-service-main.h"
-#include "bt-service-mdm.h"
-#include "bt-service-opp-client.h"
-#include "bt-service-obex-server.h"
-#include "bt-service-rfcomm-client.h"
-#include "bt-service-rfcomm-server.h"
-#include "bt-service-adapter.h"
-#include "bt-service-device.h"
-#include "bt-service-network.h"
-#include "bt-service-pbap.h"
-
-policy_receiver_handle mdm_handle;
-
-static int __bt_mdm_is_profile_connected(bluetooth_device_address_t *device_address,
-               char *profile_uuid, gboolean *is_connected)
-{
-       char *object_path = NULL;
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-       DBusGProxy *device_proxy = NULL;
-       DBusGProxy *adapter_proxy = NULL;
-       DBusGConnection *conn;
-       GError *error = NULL;
-       GHashTable *hash = NULL;
-       GValue *value = NULL;
-       dbus_bool_t val = FALSE;
-
-       retv_if(device_address == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
-       retv_if(profile_uuid == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
-       retv_if(is_connected == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
-
-       *is_connected = FALSE;
-
-       if (g_strcmp0(profile_uuid, RFCOMM_UUID_STR) == 0)
-               return _bt_rfcomm_is_device_connected(device_address,
-                                                     is_connected);
-       else if (g_strcmp0(profile_uuid, GATT_UUID) == 0)
-               return _bt_is_gatt_connected(device_address, is_connected);
-
-       adapter_proxy = _bt_get_adapter_proxy();
-       retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       _bt_convert_addr_type_to_string(address, device_address->addr);
-
-       if (g_strcmp0(profile_uuid, NAP_UUID) == 0) {
-               object_path = _bt_get_adapter_path();
-               device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               object_path, BT_NETWORK_SERVER_INTERFACE);
-               g_free(object_path);
-               if (device_proxy == NULL) {
-                       BT_DBG("Device don't have this service");
-                       return BLUETOOTH_ERROR_INTERNAL;
-               }
-               dbus_g_proxy_call(device_proxy, "GetProperties", NULL,
-                               G_TYPE_STRING, address,
-                               G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable",
-                                       G_TYPE_STRING, G_TYPE_VALUE),
-                               &hash, G_TYPE_INVALID);
-               if (hash != NULL) {
-                       value = g_hash_table_lookup(hash, "Connected");
-                       *is_connected = value ? g_value_get_boolean(value) : FALSE;
-                       g_hash_table_destroy(hash);
-               }
-       } else if (g_strcmp0(profile_uuid, PANU_UUID) == 0)
-               return _bt_is_network_connected(_bt_get_net_conn(),
-                               device_address->addr, is_connected);
-       else {
-               object_path = _bt_get_device_object_path(address);
-               retv_if(object_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
-
-               device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                               object_path, BT_DEVICE_INTERFACE);
-               g_free(object_path);
-               if (device_proxy == NULL) {
-                       BT_DBG("Device don't have this service");
-                       return BLUETOOTH_ERROR_INTERNAL;
-               }
-               dbus_g_proxy_call(device_proxy, "IsConnectedProfile", &error,
-                               G_TYPE_STRING, profile_uuid,
-                               G_TYPE_INVALID,
-                               G_TYPE_BOOLEAN, &val,
-                               G_TYPE_INVALID);
-               if (error != NULL) {
-                       BT_ERR("Failed to get properties: %s\n", error->message);
-                       g_error_free(error);
-               }
-
-               *is_connected = val;
-       }
-
-       if (device_proxy)
-               g_object_unref(device_proxy);
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-static int __bt_mdm_get_connected_profile_address(char *address, char *UUID)
-{
-       int err;
-       int ret = FALSE;
-       int i;
-       gboolean is_connected = FALSE;
-       GArray *device_list = NULL;
-       bluetooth_device_info_t info;
-       guint size;
-
-       device_list = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-       if (_bt_get_bonded_devices(&device_list)
-                                       != BLUETOOTH_ERROR_NONE) {
-               g_array_free(device_list, TRUE);
-               return ret;
-       }
-
-       size = (device_list->len) / sizeof(bluetooth_device_info_t);
-       BT_DBG("g arrary size : [%d]", size);
-
-       for (i = 0; i < size; i++) {
-
-               info = g_array_index(device_list,
-                               bluetooth_device_info_t, i);
-
-               if (info.connected == TRUE) {
-                       BT_DBG("Found Connected device[%s]", info.device_name.name);
-                       err = __bt_mdm_is_profile_connected(&info.device_address,
-                               UUID, &is_connected);
-
-                       if (err == BLUETOOTH_ERROR_NONE) {
-                               if (is_connected) {
-                                       BT_DBG("connected device name : %s", info.device_name.name);
-                                       _bt_convert_addr_type_to_string(address, (unsigned char *)info.device_address.addr);
-                                       ret = TRUE;
-                                       break;
-                               }
-                       }
-
-               }
-       }
-       g_array_free(device_list, TRUE);
-
-       return ret;
-}
-
-static void __bt_mdm_mode_changed(int mode)
-{
-       int visible = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
-
-       BT_DBG("allow mode: %d", mode);
-
-       switch (mode) {
-       case MDM_BT_ALLOWED:
-               BT_DBG("MDM_BT_ALLOWED");
-               /* Nothing to do */
-               break;
-       case MDM_BT_HANDSFREE_ONLY:
-               BT_DBG("MDM_BT_HANDSFREE_ONLY");
-
-               _bt_get_discoverable_mode(&visible);
-               ret_if(visible == BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE);
-
-               _bt_set_discoverable_mode(BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE, 0);
-
-               _bt_opp_client_cancel_all_transfers();
-
-               _bt_obex_server_cancel_all_transfers();
-
-               _bt_rfcomm_client_disconnect_all();
-
-               _bt_rfcomm_server_disconnect_all_connection();
-
-               _bt_launch_mdm_popup("MDM_POLICY_DISABLE_BT_HANDSFREE");
-
-               break;
-       case MDM_BT_RESTRICTED:
-               BT_DBG("MDM_BT_RESTRICTED");
-
-               _bt_launch_mdm_popup("MDM_POLICY_DISABLE_BT");
-
-               /* deactivate BT */
-               _bt_disable_adapter();
-               break;
-       default:
-               BT_DBG("Unknown mode");
-               break;
-       }
-
-       BT_DBG("-");
-}
-
-static void __bt_mdm_discoverable_state_changed(int state)
-{
-       int visible = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
-
-       BT_DBG("state: %d", state);
-
-       switch (state) {
-       case MDM_ALLOWED:
-               BT_DBG("MDM_ALLOWED");
-               /* Nothing to do */
-               break;
-       case MDM_RESTRICTED:
-               BT_DBG("MDM_RESTRICTED");
-
-               _bt_get_discoverable_mode(&visible);
-               ret_if(visible == BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE);
-
-               _bt_set_discoverable_mode(BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE, 0);
-               break;
-       default:
-               BT_DBG("Unknown mode");
-               break;
-       }
-}
-
-static void __bt_mdm_limited_discoverable_state_changed(int state)
-{
-       int visible = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
-       int timeout = 0;
-
-       BT_DBG("state: %d", state);
-
-       switch (state) {
-       case MDM_ALLOWED:
-               BT_DBG("MDM_ALLOWED");
-               if (vconf_get_int(BT_FILE_VISIBLE_TIME, &timeout) != 0)
-                       BT_ERR("Fail to get the timeout value");
-               else {
-                       if (timeout != -1) {
-                               BT_DBG("_bt_set_discoverable_mode");
-                               if (_bt_set_discoverable_mode(
-                                       BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE,
-                                       timeout) != BLUETOOTH_ERROR_NONE) {
-                                       if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
-                                               BT_ERR("Set vconf failed");
-                               }
-                       }
-               }
-
-               break;
-       case MDM_RESTRICTED:
-               BT_DBG("MDM_RESTRICTED");
-
-               _bt_get_discoverable_mode(&visible);
-               ret_if(visible == BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE);
-
-               _bt_set_discoverable_mode(BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE,
-                               0);
-               break;
-       default:
-               BT_DBG("Unknown mode");
-               break;
-       }
-}
-
-static int __bt_mdm_idle_cb(void *data)
-{
-       int *status = data;
-       int mode;
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-
-       retv_if(status == NULL, FALSE);
-
-       BT_DBG("policy: %d", *status);
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS) return BT_MDM_NO_SERVICE;
-
-       switch (*status) {
-       case MDM_BT_MODE_CHANGED:
-               mode = mdm_get_allow_bluetooth_mode();
-               __bt_mdm_mode_changed(mode);
-               break;
-       case MDM_BT_OUTGOING_CALL_CHANGED:
-               BT_DBG("MDM_BT_OUTGOING_CALL_CHANGED");
-               break;
-       case MDM_BT_A2DP_PROFILE_CHANGED:
-               BT_DBG("MDM_BT_A2DP_PROFILE_CHANGED");
-#ifdef MDM_PHASE_2
-               if (mdm_get_bluetooth_profile_state(BLUETOOTH_A2DP_PROFILE)
-                       == MDM_RESTRICTED) {
-                       if (__bt_mdm_get_connected_profile_address(address,
-                                                       A2DP_SINK_UUID))
-                               _bt_disconnect_profile(address, A2DP_SINK_UUID,
-                                                               NULL, NULL);
-               }
-#endif
-               break;
-       case MDM_BT_AVRCP_PROFILE_CHANGED:
-               BT_DBG("MDM_BT_AVRCP_PROFILE_CHANGED");
-#ifdef MDM_PHASE_2
-               if (mdm_get_bluetooth_profile_state(BLUETOOTH_AVRCP_PROFILE)
-                       == MDM_RESTRICTED) {
-                       if (__bt_mdm_get_connected_profile_address(address,
-                                                       AVRCP_REMOTE_UUID))
-                               _bt_disconnect_profile(address, AVRCP_REMOTE_UUID,
-                                                               NULL, NULL);
-               }
-#endif
-               break;
-       case MDM_BT_BPP_PROFILE_CHANGED:
-               BT_DBG("MDM_BT_BPP_PROFILE_CHANGED");
-               break;
-       case MDM_BT_DUN_PROFILE_CHANGED:
-               BT_DBG("MDM_BT_DUN_PROFILE_CHANGED");
-               break;
-       case MDM_BT_FTP_PROFILE_CHANGED:
-               BT_DBG("MDM_BT_FTP_PROFILE_CHANGED");
-               break;
-       case MDM_BT_HFP_PROFILE_CHANGED:
-               BT_DBG("MDM_BT_HFP_PROFILE_CHANGED");
-#ifdef MDM_PHASE_2
-               if (mdm_get_bluetooth_profile_state(BLUETOOTH_HFP_PROFILE)
-                       == MDM_RESTRICTED) {
-                       if (__bt_mdm_get_connected_profile_address(address,
-                                                       HFP_HS_UUID))
-                               _bt_disconnect_profile(address, HFP_HS_UUID,
-                                                               NULL, NULL);
-               }
-#endif
-               break;
-       case MDM_BT_HSP_PROFILE_CHANGED:
-               BT_DBG("MDM_BT_HSP_PROFILE_CHANGED");
-#ifdef MDM_PHASE_2
-               if (mdm_get_bluetooth_profile_state(BLUETOOTH_HSP_PROFILE)
-                       == MDM_RESTRICTED) {
-                       if (__bt_mdm_get_connected_profile_address(address,
-                                                       HSP_HS_UUID))
-                               _bt_disconnect_profile(address, HSP_HS_UUID,
-                                                               NULL, NULL);
-               }
-#endif
-               break;
-       case MDM_BT_PBAP_PROFILE_CHANGED:
-               BT_DBG("MDM_BT_PBAP_PROFILE_CHANGED");
-#ifdef MDM_PHASE_2
-               if (mdm_get_bluetooth_profile_state(BLUETOOTH_PBAP_PROFILE)
-                       == MDM_RESTRICTED) {
-                       if (__bt_mdm_get_connected_profile_address(address,
-                                               OBEX_PSE_UUID)) {
-                               bluetooth_device_address_t addr;
-                               _bt_convert_addr_string_to_type(addr.addr,
-                                               address);
-                               _bt_pbap_disconnect(&addr);
-                       }
-               }
-#endif
-               break;
-       case MDM_BT_SAP_PROFILE_CHANGED:
-               BT_DBG("MDM_BT_SAP_PROFILE_CHANGED");
-               break;
-       case MDM_BT_SPP_PROFILE_CHANGED:
-               BT_DBG("MDM_BT_SPP_PROFILE_CHANGED");
-               break;
-       case MDM_BT_DESKTOP_CONNECTIVITY_STATE_CHANGED:
-               BT_DBG("MDM_BT_DESKTOP_CONNECTIVITY_STATE_CHANGED");
-               break;
-       case MDM_BT_DISCOVERABLE_STATE_CHANGED:
-               BT_DBG("MDM_BT_DISCOVERABLE_STATE_CHANGED");
-#ifdef MDM_PHASE_2
-               mode = mdm_get_bluetooth_discoverable_state();
-               __bt_mdm_discoverable_state_changed(mode);
-#endif
-               break;
-       case MDM_BT_PARINIG_STATE_CHANGED:
-               BT_DBG("MDM_BT_PARINIG_STATE_CHANGED");
-               break;
-       case MDM_BT_LIMITED_DISCOVERABLE_STATE_CHANGED:
-               BT_DBG("MDM_BT_LIMITED_DISCOVERABLE_STATE_CHANGED");
-#ifdef MDM_PHASE_2
-               mode = mdm_get_bluetooth_limited_discoverable_state();
-               __bt_mdm_limited_discoverable_state_changed(mode);
-#endif
-               break;
-       case MDM_BT_DATA_TRANSFER_CHANGED:
-               BT_DBG("MDM_BT_DATA_TRANSFER_CHANGED");
-#ifdef MDM_PHASE_2
-               mode = mdm_get_bluetooth_data_transfer_state();
-               if (mode == MDM_RESTRICTED) {
-                       _bt_opp_client_cancel_all_transfers();
-                       _bt_obex_server_cancel_all_transfers();
-               }
-#endif
-               break;
-       default:
-               BT_DBG("Unknown mode");
-               break;
-       }
-
-       g_free(status);
-
-       mdm_release_service();
-
-       BT_DBG("-");
-       return FALSE;
-}
-
-static void __bt_mdm_policy_changed_cb(int status, void *data)
-{
-       int *mdm_status;
-
-       BT_DBG("policy: %d", status);
-
-       mdm_status = g_malloc0(sizeof(int));
-
-       *mdm_status = status;
-
-       g_idle_add((GSourceFunc)__bt_mdm_idle_cb, mdm_status);
-}
-
-void _bt_init_mdm_handle(void)
-{
-       mdm_handle = mdm_register_policy_receiver(MDM_POLICY_ON_BT,
-                                               NULL,
-                                               __bt_mdm_policy_changed_cb);
-       if (mdm_handle == (policy_receiver_handle)NULL)
-               BT_ERR("MDM register failed\n");
-}
-
-void _bt_deinit_mdm_handle(void)
-{
-       if(mdm_handle != (policy_receiver_handle)NULL) {
-               mdm_deregister_policy_receiver(mdm_handle);
-               mdm_handle = (policy_receiver_handle)NULL;
-       }
-
-       mdm_release_service();
-}
-
-int _bt_launch_mdm_popup(char *mode)
-{
-       int ret = 0;
-       bundle *b;
-
-       b = bundle_create();
-       retv_if(b == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       bundle_add(b, "mode", mode);
-
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
-       ret = syspopup_launch(BT_MDM_SYSPOPUP, b);
-#endif
-
-       if (ret < 0)
-               BT_DBG("Popup launch failed: %d\n", ret);
-
-       bundle_free(b);
-
-       return ret;
-}
-
-bt_mdm_status_e _bt_check_mdm_allow_restriction(void)
-{
-       mdm_bt_allow_t mode;
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS) return BT_MDM_NO_SERVICE;
-
-       mode = mdm_get_allow_bluetooth_mode();
-       mdm_release_service();
-
-       return (mode == MDM_BT_RESTRICTED) ? BT_MDM_RESTRICTED : BT_MDM_ALLOWED;
-}
-
-#ifdef MDM_PHASE_2
-bt_mdm_status_e _bt_check_mdm_desktop_connectivity_restriction(void)
-{
-       bt_mdm_status_e mdm_status = BT_MDM_ALLOWED;
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS)
-               return BT_MDM_NO_SERVICE;
-
-       if (mdm_get_bluetooth_desktop_connectivity_state() == MDM_RESTRICTED) {
-               /* Not allow to visible on */
-               BT_ERR("Desktop connection is restricted");
-               mdm_status = BT_MDM_RESTRICTED;
-       }
-       mdm_release_service();
-
-       return mdm_status;
-}
-
-bt_mdm_status_e _bt_check_mdm_visible_restriction(void)
-{
-       bt_mdm_status_e mdm_status = BT_MDM_ALLOWED;
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS) return BT_MDM_NO_SERVICE;
-
-       if (mdm_get_bluetooth_discoverable_state() == MDM_RESTRICTED ||
-            mdm_get_allow_bluetooth_mode() == MDM_BT_HANDSFREE_ONLY) {
-               /* Not allow to visible on */
-               BT_ERR("Restricted to set visible mode");
-               mdm_status = BT_MDM_RESTRICTED;
-       }
-       mdm_release_service();
-
-       return mdm_status;
-}
-
-bt_mdm_status_e _bt_check_mdm_limited_discoverable_mode(void)
-{
-       bt_mdm_status_e mdm_status = BT_MDM_ALLOWED;
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS) return BT_MDM_NO_SERVICE;
-
-       if (mdm_get_bluetooth_limited_discoverable_state() == MDM_RESTRICTED) {
-               BT_ERR("limited discoverable mode");
-               mdm_status = BT_MDM_RESTRICTED;
-       }
-       mdm_release_service();
-
-       return mdm_status;
-}
-
-bt_mdm_status_e _bt_check_mdm_blacklist_devices(bluetooth_device_address_t *address)
-{
-       mdm_data_t *lp_data;
-       GList *blacklist;
-       char *device_name;
-       bluetooth_device_info_t dev_info;
-       bt_mdm_status_e mdm_status = BT_MDM_ALLOWED;
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS) return BT_MDM_NO_SERVICE;
-
-       memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
-
-       if (_bt_get_bonded_device_info(address,
-                               &dev_info) != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Not paired device");
-               goto release;
-       }
-
-       lp_data = mdm_get_bluetooth_devices_from_blacklist();
-       if (lp_data == NULL) {
-               BT_ERR("No blacklist");
-               goto release;
-       }
-
-       for (blacklist = (GList *)lp_data->data; blacklist; blacklist = blacklist->next) {
-               device_name = blacklist->data;
-
-               DBG_SECURE("blacklist name: %s", device_name);
-
-               if (g_strcmp0(dev_info.device_name.name,
-                                       device_name) == 0) {
-                       mdm_status = BT_MDM_RESTRICTED;
-                       break;
-               }
-       }
-
-       mdm_free_data(lp_data);
-release :
-       mdm_release_service();
-       return mdm_status;
-}
-
-mdm_bt_profile_t convert_uuid_string_to_type(const char* uuid)
-{
-       retv_if (uuid == NULL, MDM_BT_PROFILE_NONE);
-
-       if (!strcasecmp(uuid, BT_A2DP_UUID))
-               return BLUETOOTH_A2DP_PROFILE;
-       else if (!strcasecmp(uuid, BT_AVRCP_TARGET_UUID))
-               return BLUETOOTH_AVRCP_PROFILE;
-       else if (!strcasecmp(uuid, BT_FTP_UUID))
-               return BLUETOOTH_FTP_PROFILE;
-       else if (!strcasecmp(uuid, BT_HFP_AUDIO_GATEWAY_UUID))
-               return BLUETOOTH_HFP_PROFILE;
-       else if (!strcasecmp(uuid, HSP_AG_UUID))
-               return BLUETOOTH_HSP_PROFILE;
-       else if (!strcasecmp(uuid, OBEX_PSE_UUID))
-               return BLUETOOTH_PBAP_PROFILE;
-       else if (!strcasecmp(uuid, BT_SPP_UUID))
-               return BLUETOOTH_SPP_PROFILE;
-
-       return MDM_BT_PROFILE_NONE;
-}
-
-bt_mdm_status_e _bt_check_mdm_blacklist_uuid(char *uuid)
-{
-       mdm_data_t *lp_data;
-       GList *blacklist;
-       char *blacklist_uuid;
-       bt_mdm_status_e mdm_status = BT_MDM_ALLOWED;
-
-       retv_if (uuid == NULL, mdm_status);
-
-       if (mdm_get_service() != MDM_RESULT_SUCCESS) return BT_MDM_NO_SERVICE;
-
-       lp_data = mdm_get_bluetooth_uuids_from_blacklist();
-       if (lp_data == NULL) {
-               BT_ERR("No blacklist");
-               goto release;
-       }
-
-       for (blacklist = (GList *)lp_data->data; blacklist; blacklist = blacklist->next) {
-               blacklist_uuid = blacklist->data;
-
-               BT_DBG("blacklist_uuid: %s", blacklist_uuid);
-
-               if (g_strcmp0(blacklist_uuid, uuid) == 0) {
-                       mdm_status = BT_MDM_RESTRICTED;
-                       break;
-               }
-       }
-
-       if (mdm_status == BT_MDM_ALLOWED) {
-               mdm_bt_profile_t profile;
-               profile = convert_uuid_string_to_type(uuid);
-               if (mdm_get_bluetooth_profile_state(profile) == MDM_RESTRICTED) {
-                       BT_ERR("Restricted UUID");
-                       mdm_status = BT_MDM_RESTRICTED;
-               }
-       }
-
-       mdm_free_data(lp_data);
-
-release :
-       mdm_release_service();
-       return mdm_status;
-}
-#endif
-#endif
-
index 30e02fd..7f24a64 100644 (file)
  *
  */
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
 #include <glib.h>
+#include <gio/gio.h>
 #include <dlog.h>
 #include <string.h>
 #include <stdio.h>
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
 #include <syspopup_caller.h>
-#endif
 #include <net_connection.h>
 
 #include "bluetooth-api.h"
@@ -136,93 +133,96 @@ int _bt_is_network_connected(void *connection, unsigned char *address,
        return BLUETOOTH_ERROR_NONE;
 }
 
-static void __bt_network_connect_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                                   gpointer user_data)
+static void __bt_network_connect_cb(GDBusProxy *proxy, GAsyncResult *res,
+                                       gpointer user_data)
 {
        GError *g_error = NULL;
-       char *device = NULL;
-       GArray *out_param1 = NULL;
-       GArray *out_param2 = NULL;
+       GVariant *out_param1 = NULL;
+       GVariant *reply = NULL;
        bluetooth_device_address_t device_addr = { {0} };
        int result = BLUETOOTH_ERROR_NONE;
        bt_function_data_t *func_data;
        request_info_t *req_info;
 
-       dbus_g_proxy_end_call(proxy, call, &g_error, G_TYPE_STRING, &device, G_TYPE_INVALID);
-
+       reply = g_dbus_proxy_call_finish(proxy, res, &g_error);
        g_object_unref(proxy);
 
-       func_data = user_data;
+       if (reply == NULL) {
+               BT_ERR("Network Connect Dbus Call Error");
+               if (g_error) {
+                       BT_ERR("Error: %s\n", g_error->message);
+                       g_clear_error(&g_error);
+               }
+               result = BLUETOOTH_ERROR_INTERNAL;
+       }
+       g_variant_unref(reply);
 
+       func_data = user_data;
        if (func_data == NULL) {
                /* Send reply */
                BT_ERR("func_data == NULL");
                goto done;
        }
 
+       BT_ERR("func_data->req_id: %d", func_data->req_id);
        req_info = _bt_get_request_info(func_data->req_id);
        if (req_info == NULL) {
                BT_ERR("req_info == NULL");
                goto done;
        }
 
-       if (g_error != NULL) {
-               BT_ERR("Network Connect Dbus Call Error: %s\n", g_error->message);
-               result = BLUETOOTH_ERROR_INTERNAL;
-       }
-
        if (req_info->context == NULL)
                goto done;
 
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
        _bt_convert_addr_string_to_type(device_addr.addr,
                                        func_data->address);
 
-       g_array_append_vals(out_param1, &device_addr,
-                               sizeof(bluetooth_device_address_t));
-       g_array_append_vals(out_param2, &result, sizeof(int));
-
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
+       out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+                                                       &device_addr, sizeof(bluetooth_device_address_t), TRUE, NULL, NULL);
 
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
+       g_dbus_method_invocation_return_value(req_info->context,
+                       g_variant_new("iv", result, out_param1));
 
        _bt_delete_request_list(req_info->req_id);
-done:
-       if (g_error)
-               g_error_free(g_error);
 
+done:
        if (func_data) {
                g_free(func_data->address);
                g_free(func_data);
        }
 }
 
-static void __bt_network_disconnect_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                                   gpointer user_data)
+static void __bt_network_disconnect_cb(GDBusProxy *proxy, GAsyncResult *res,
+                                       gpointer user_data)
 {
        GError *g_error = NULL;
-       GArray *out_param1 = NULL;
-       GArray *out_param2 = NULL;
+       GVariant *out_param1 = NULL;
+       GVariant *reply = NULL;
        bluetooth_device_address_t device_addr = { {0} };
        int result = BLUETOOTH_ERROR_NONE;
        bt_function_data_t *func_data;
        request_info_t *req_info;
 
-       dbus_g_proxy_end_call(proxy, call, &g_error, G_TYPE_INVALID);
-
+       g_dbus_proxy_call_finish(proxy, res, &g_error);
        g_object_unref(proxy);
 
-       func_data = user_data;
+       if (reply == NULL) {
+               BT_ERR("Network Disconnect Dbus Call Error");
+               if (g_error) {
+                       BT_ERR("Error: %s\n", g_error->message);
+                       g_clear_error(&g_error);
+               }
+               result = BLUETOOTH_ERROR_INTERNAL;
+       }
+       g_variant_unref(reply);
 
+       func_data = user_data;
        if (func_data == NULL) {
                /* Send reply */
                BT_ERR("func_data == NULL");
                goto done;
        }
-
+       BT_ERR("func_data->req_id: %d", func_data->req_id);
        req_info = _bt_get_request_info(func_data->req_id);
        if (req_info == NULL) {
                BT_ERR("req_info == NULL");
@@ -237,26 +237,15 @@ static void __bt_network_disconnect_cb(DBusGProxy *proxy, DBusGProxyCall *call,
        if (req_info->context == NULL)
                goto done;
 
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-       _bt_convert_addr_string_to_type(device_addr.addr,
-                                       func_data->address);
-
-       g_array_append_vals(out_param1, &device_addr,
-                               sizeof(bluetooth_device_address_t));
-       g_array_append_vals(out_param2, &result, sizeof(int));
+       out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+                                                       &device_addr, sizeof(bluetooth_device_address_t), TRUE, NULL, NULL);
 
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
-
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
+       g_dbus_method_invocation_return_value(req_info->context,
+                       g_variant_new("iv", result, out_param1));
 
        _bt_delete_request_list(req_info->req_id);
-done:
-       if (g_error)
-               g_error_free(g_error);
 
+done:
        if (func_data) {
                g_free(func_data->address);
                g_free(func_data);
@@ -268,8 +257,8 @@ int _bt_network_activate(void)
        int ret = BLUETOOTH_ERROR_NONE;
        char *adapter_path;
        GError *err = NULL;
-       DBusGConnection *conn;
-       DBusGProxy *server_proxy;
+       GDBusConnection *conn;
+       GDBusProxy *server_proxy;
 
        conn = _bt_get_system_gconn();
        retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
@@ -277,9 +266,9 @@ int _bt_network_activate(void)
        adapter_path = _bt_get_adapter_path();
        retv_if(adapter_path == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       server_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                            adapter_path, BT_NETWORK_SERVER_INTERFACE);
-
+       server_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                       NULL, BT_BLUEZ_NAME,
+                       adapter_path, BT_NETWORK_SERVER_INTERFACE,  NULL, NULL);
        g_free(adapter_path);
 
        if (server_proxy == NULL) {
@@ -287,21 +276,21 @@ int _bt_network_activate(void)
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       if (!dbus_g_proxy_call(server_proxy, "Register", &err,
-                       G_TYPE_STRING, NAP_UUID_NAME,
-                       G_TYPE_STRING, NET_BRIDGE_INTERFACE,
-                       G_TYPE_INVALID, G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("Network server register Error: %s\n", err->message);
-                       if (g_strcmp0(err->message, "Already Exists") == 0) {
-                               ret = BLUETOOTH_ERROR_ALREADY_INITIALIZED;
-                       } else {
-                               ret = BLUETOOTH_ERROR_INTERNAL;
-                       }
-                       g_error_free(err);
+       g_dbus_proxy_call_sync(server_proxy, "Register",
+                                g_variant_new("(ss)", NAP_UUID_NAME, NET_BRIDGE_INTERFACE),
+                                G_DBUS_CALL_FLAGS_NONE,
+                                -1,
+                                NULL,
+                                &err);
+       if (err != NULL) {
+               BT_ERR("Network server register Error: %s\n", err->message);
+               if (g_strcmp0(err->message, "Already Exists") == 0) {
+                       ret = BLUETOOTH_ERROR_ALREADY_INITIALIZED;
+               } else {
+                       ret = BLUETOOTH_ERROR_INTERNAL;
                }
+               g_error_free(err);
        }
-
        g_object_unref(server_proxy);
 
        return ret;
@@ -311,8 +300,8 @@ int _bt_network_deactivate(void)
 {
        char *adapter_path;
        GError *err = NULL;
-       DBusGConnection *conn;
-       DBusGProxy *server_proxy;
+       GDBusConnection *conn;
+       GDBusProxy *server_proxy;
        int ret = BLUETOOTH_ERROR_NONE;
 
        conn = _bt_get_system_gconn();
@@ -321,9 +310,9 @@ int _bt_network_deactivate(void)
        adapter_path = _bt_get_adapter_path();
        retv_if(adapter_path == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       server_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                            adapter_path, BT_NETWORK_SERVER_INTERFACE);
-
+       server_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL, BT_BLUEZ_NAME,
+                                                               adapter_path, BT_NETWORK_SERVER_INTERFACE,  NULL, NULL);
        g_free(adapter_path);
 
        if (server_proxy == NULL) {
@@ -331,21 +320,22 @@ int _bt_network_deactivate(void)
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       if (!dbus_g_proxy_call(server_proxy, "Unregister", &err,
-                       G_TYPE_STRING, NAP_UUID_NAME,
-                       G_TYPE_INVALID, G_TYPE_INVALID)) {
-               if (err != NULL) {
-                       BT_ERR("Network server unregister Error: %s\n", err->message);
-                       if (g_strcmp0(err->message,
-                                       "Operation currently not available") == 0) {
-                               ret = BLUETOOTH_ERROR_ALREADY_DEACTIVATED;
-                       } else {
-                               ret = BLUETOOTH_ERROR_INTERNAL;
-                       }
-                       g_error_free(err);
+       g_dbus_proxy_call_sync(server_proxy, "Unregister",
+                                g_variant_new("(s)", NAP_UUID_NAME),
+                                G_DBUS_CALL_FLAGS_NONE,
+                                -1,
+                                NULL,
+                                &err);
+       if (err != NULL) {
+               BT_ERR("Network server unregister Error: %s\n", err->message);
+               if (g_strcmp0(err->message,
+                               "Operation currently not available") == 0) {
+                       ret = BLUETOOTH_ERROR_ALREADY_DEACTIVATED;
+               } else {
+                       ret = BLUETOOTH_ERROR_INTERNAL;
                }
+               g_error_free(err);
        }
-
        g_object_unref(server_proxy);
 
        return ret;
@@ -354,13 +344,15 @@ int _bt_network_deactivate(void)
 int _bt_network_connect(int request_id, int role,
                bluetooth_device_address_t *device_address)
 {
-       gchar *device_path = NULL;
+       const gchar *device_path = NULL;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        char remote_role[BLUETOOTH_UUID_STRING_MAX] = { 0 };
        bt_function_data_t *func_data;
-       DBusGProxy *adapter_proxy;
-       DBusGProxy *profile_proxy;
-       DBusGConnection *conn;
+       GDBusProxy *adapter_proxy;
+       GDBusProxy *profile_proxy;
+       GDBusConnection *conn;
+       GVariant *result = NULL;
+       GError*err = NULL;
 
        BT_CHECK_PARAMETER(device_address, return);
 
@@ -389,33 +381,44 @@ int _bt_network_connect(int request_id, int role,
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
 
-       dbus_g_proxy_call(adapter_proxy, "FindDevice", NULL,
-                         G_TYPE_STRING, address, G_TYPE_INVALID,
-                         DBUS_TYPE_G_OBJECT_PATH, &device_path, G_TYPE_INVALID);
+       result = g_dbus_proxy_call_sync(adapter_proxy, "FindDevice",
+                       g_variant_new("(s)", address),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       -1, NULL, &err);
+       if (result == NULL) {
+               BT_ERR("Error occurred in call to FindDevice");
+               if (err) {
+                       BT_ERR("Error: %s", err->message);
+                       g_clear_error(&err);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
 
+       device_path =  g_variant_get_string(result, NULL);
        if (device_path == NULL) {
                BT_ERR("No paired device");
+               g_variant_unref(result);
                return BLUETOOTH_ERROR_NOT_PAIRED;
        }
 
-       profile_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                                     device_path, BT_NETWORK_CLIENT_INTERFACE);
-       g_free(device_path);
+       profile_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                       NULL, BT_BLUEZ_NAME,
+                       device_path, BT_NETWORK_CLIENT_INTERFACE,  NULL, NULL);
+
+       g_variant_unref(result);
        retv_if(profile_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
        func_data = g_malloc0(sizeof(bt_function_data_t));
 
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
 
-       if (!dbus_g_proxy_begin_call(profile_proxy, "Connect",
-                       (DBusGProxyCallNotify)__bt_network_connect_cb,
-                       func_data, NULL,
-                       G_TYPE_STRING, remote_role,
-                       G_TYPE_INVALID)) {
-               BT_ERR("network connect Dbus Call Error");
-               g_object_unref(profile_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+       g_dbus_proxy_call(profile_proxy, "Connect",
+                               g_variant_new("(s)", remote_role),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               BT_MAX_DBUS_TIMEOUT,
+                               NULL,
+                               (GAsyncReadyCallback)__bt_network_connect_cb,
+                               func_data);
 
        return BLUETOOTH_ERROR_NONE;
 }
@@ -423,12 +426,14 @@ int _bt_network_connect(int request_id, int role,
 int _bt_network_disconnect(int request_id,
                bluetooth_device_address_t *device_address)
 {
-       gchar *device_path = NULL;
+       const gchar *device_path = NULL;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        bt_function_data_t *func_data;
-       DBusGProxy *adapter_proxy;
-       DBusGProxy *profile_proxy;
-       DBusGConnection *conn;
+       GDBusProxy *adapter_proxy;
+       GDBusProxy *profile_proxy;
+       GDBusConnection *conn;
+       GVariant *result = NULL;
+       GError*err = NULL;
 
        BT_CHECK_PARAMETER(device_address, return);
 
@@ -440,31 +445,43 @@ int _bt_network_disconnect(int request_id,
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
 
-       dbus_g_proxy_call(adapter_proxy, "FindDevice", NULL,
-                         G_TYPE_STRING, address, G_TYPE_INVALID,
-                         DBUS_TYPE_G_OBJECT_PATH, &device_path, G_TYPE_INVALID);
+       result = g_dbus_proxy_call_sync(adapter_proxy, "FindDevice",
+                                g_variant_new("(s)", address),
+                                G_DBUS_CALL_FLAGS_NONE,
+                                -1, NULL, &err);
+       if (result == NULL) {
+               BT_ERR("Error occurred in call to FindDevice");
+               if (err) {
+                       BT_ERR("Error: %s", err->message);
+                       g_clear_error(&err);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
 
+       device_path =  g_variant_get_string(result, NULL);
        if (device_path == NULL) {
                BT_ERR("No paired device");
                return BLUETOOTH_ERROR_NOT_PAIRED;
        }
 
-       profile_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                                     device_path, BT_NETWORK_CLIENT_INTERFACE);
-       g_free(device_path);
+       profile_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                       NULL, BT_BLUEZ_NAME,
+                       device_path, BT_NETWORK_CLIENT_INTERFACE,  NULL, NULL);
+
+       g_variant_unref(result);
        retv_if(profile_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
        func_data = g_malloc0(sizeof(bt_function_data_t));
 
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
 
-       if (!dbus_g_proxy_begin_call(profile_proxy, "Disconnect",
-                       (DBusGProxyCallNotify)__bt_network_disconnect_cb,
-                       func_data, NULL, G_TYPE_INVALID)) {
-               BT_ERR("network disconnect Dbus Call Error");
-               g_object_unref(profile_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+       g_dbus_proxy_call(profile_proxy, "Disconnect",
+                       NULL,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       BT_MAX_DBUS_TIMEOUT,
+                       NULL,
+                       (GAsyncReadyCallback)__bt_network_disconnect_cb,
+                       func_data);
 
        return BLUETOOTH_ERROR_NONE;
 }
@@ -475,8 +492,8 @@ int _bt_network_server_disconnect(int request_id,
        gchar *adapter_path = NULL;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        bt_function_data_t *func_data;
-       DBusGProxy *profile_proxy;
-       DBusGConnection *conn;
+       GDBusProxy *profile_proxy;
+       GDBusConnection *conn;
 
        BT_CHECK_PARAMETER(device_address, return);
 
@@ -491,8 +508,9 @@ int _bt_network_server_disconnect(int request_id,
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
 
-       profile_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                                     adapter_path, BT_NETWORK_SERVER_INTERFACE);
+       profile_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                       NULL, BT_BLUEZ_NAME,
+                       adapter_path, BT_NETWORK_SERVER_INTERFACE, NULL, NULL);
        g_free(adapter_path);
        retv_if(profile_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
        func_data = g_malloc0(sizeof(bt_function_data_t));
@@ -500,16 +518,16 @@ int _bt_network_server_disconnect(int request_id,
        func_data->address = g_strdup(address);
        func_data->req_id = request_id;
 
-       if (!dbus_g_proxy_begin_call(profile_proxy, "Disconnect",
-                       (DBusGProxyCallNotify)__bt_network_disconnect_cb,
-                       func_data, NULL, G_TYPE_STRING, address,
-                       G_TYPE_INVALID)) {
-               BT_ERR("network server disconnect Dbus Call Error");
-               g_free(func_data->address);
-               g_free(func_data);
-               g_object_unref(profile_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+       g_dbus_proxy_call(profile_proxy, "Disconnect",
+                                g_variant_new("(s)", address),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               BT_MAX_DBUS_TIMEOUT,
+                               NULL,
+                               (GAsyncReadyCallback)__bt_network_disconnect_cb,
+                               func_data);
+
+       g_free(func_data->address);
+       g_free(func_data);
 
        return BLUETOOTH_ERROR_NONE;
 }
index f6f28d6..6a988b3 100644 (file)
  * limitations under the License.
  *
  */
-#include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
+
 #include <glib.h>
 #include <dlog.h>
 #include <string.h>
+#include <gio/gio.h>
 
 #include "bluetooth-api.h"
 #include "bt-service-common.h"
 #include "bt-service-util.h"
 #include "bt-service-obex-agent.h"
 #include "marshal.h"
-#include "bt-obex-agent-method.h"
 
-static DBusGConnection *obex_conn = NULL;
+static GDBusConnection *conn = NULL;
+static GSList *obex_agent_list = NULL;
 
 typedef struct {
        gchar *name;
        gchar *path;
 
+       int openobex_id;
+       int obex_agent_id;
+
        /* callback data */
        gpointer authorize_data;
        gpointer release_data;
@@ -58,408 +60,491 @@ typedef struct {
        bt_obex_error_cb error_cb;
 } bt_obex_agent_info;
 
-#define BT_OBEX_AGENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
-                                       BT_OBEX_TYPE_AGENT, bt_obex_agent_info))
-
-G_DEFINE_TYPE(BtObexAgent, bt_obex_agent, G_TYPE_OBJECT)
-
-
-gboolean bt_obex_agent_authorize_push(BtObexAgent *agent, const char *path,
-                            DBusGMethodInvocation *context)
+static void __new_connection_method(GDBusConnection *connection,
+                                           const gchar *sender,
+                                           const gchar *object_path,
+                                           const gchar *interface_name,
+                                           const gchar *method_name,
+                                           GVariant *parameters,
+                                           GDBusMethodInvocation *invocation,
+                                           gpointer user_data);
+static const GDBusInterfaceVTable method_table = {
+       __new_connection_method,
+       NULL,
+       NULL,
+};
+
+static const gchar obex_service_agent_xml1[] =
+"<node name='/'>"
+"  <interface name='org.openobex.Agent'>"
+"    <method name='Request'>"
+"      <annotation name='org.freedesktop.DBus.GLib.Async' value=''/>"
+"      <arg type='o' name='transfer'/>"
+"     <arg type='s' name='name' direction='out'/>"
+"    </method>"
+"    <method name='Progress'>"
+"      <annotation name='org.freedesktop.DBus.GLib.Async' value=''/>"
+"      <arg type='o' name='transfer'/>"
+"      <arg type='t' name='transferred'/>"
+"    </method>"
+"    <method name='Complete'>"
+"      <annotation name='org.freedesktop.DBus.GLib.Async' value=''/>"
+"      <arg type='o' name='transfer'/>"
+ "   </method>"
+"    <method name='Release'>"
+"      <annotation name='org.freedesktop.DBus.GLib.Async' value=''/>"
+"    </method>"
+"    <method name='Error'>"
+"      <annotation name='org.freedesktop.DBus.GLib.Async' value=''/>"
+"      <arg type='o' name='transfer'/>"
+"      <arg type='s' name='message'/>"
+"    </method>"
+"    <method name='Authorize'>"
+"      <annotation name='org.freedesktop.DBus.GLib.Async' value=''/>"
+"              <arg type='o' name='objpath'/>"
+"              <arg type='s' name='bdaddress'/>"
+"              <arg type='s' name='name'/>"
+"              <arg type='s' name='type'/>"
+"              <arg type='i' name='length'/>"
+"              <arg type='i' name='time'/>"
+"              <arg type='s' name='filepath' direction='out'/>"
+"      </method>"
+"  </interface>"
+"</node>";
+
+static const gchar obex_service_agent_xml2[] =
+"<node name='/'>"
+"  <interface name='org.bluez.obex.Agent1'>"
+"    <method name='AuthorizePush'>"
+"    <annotation name='org.freedesktop.DBus.GLib.Async' value=''/>"
+"        <arg type='o' name='objpath'/>"
+"        <arg type='s' name='filepath' direction='out'/>"
+"    </method>"
+"  </interface>"
+"</node>";
+
+static bt_obex_agent_info *__find_obex_agent_info(char *path)
 {
-       bt_obex_agent_info *info;
-       gboolean result;
-
-       info = BT_OBEX_AGENT_GET_PRIVATE(agent);
-
-       if (info == NULL)
-               goto fail;
+       GSList *l;
 
-       if (info->authorize_cb == NULL)
-               goto fail;
+       for (l = obex_agent_list; l != NULL; l = l->next) {
+               bt_obex_agent_info *info = l->data;
 
-       result = info->authorize_cb(context, path,
-                               info->authorize_data);
+               if (g_strcmp0(info->path, path) == 0)
+                       return info;
+       }
 
-       return result;
-fail:
-       dbus_g_method_return(context, "");
-       return FALSE;
+       return NULL;
 }
 
-gboolean bt_obex_agent_authorize(BtObexAgent *agent, const char *path,
-                       const char *bdaddress, const char *name,
-                       const char *type, gint length, gint time,
-                            DBusGMethodInvocation *context)
-{
-       bt_obex_agent_info *info;
-
-       info = BT_OBEX_AGENT_GET_PRIVATE(agent);
-
-       if (info == NULL)
-               goto fail;
-
-       if (info->authorize_cb == NULL)
-               goto fail;
 
-       return TRUE;
-fail:
-       dbus_g_method_return(context, "");
-       return FALSE;
-}
-
-gboolean bt_obex_agent_request(BtObexAgent *agent, const char *path,
-                                  DBusGMethodInvocation *context)
+static void __new_connection_method(GDBusConnection *connection,
+                                           const gchar *sender,
+                                           const gchar *object_path,
+                                           const gchar *interface_name,
+                                           const gchar *method_name,
+                                           GVariant *parameters,
+                                           GDBusMethodInvocation *invocation,
+                                           gpointer user_data)
 {
-       char *sender;
-       bt_obex_agent_info *info;
-       DBusGProxy *proxy;
-       gboolean result;
-
-       info = BT_OBEX_AGENT_GET_PRIVATE(agent);
-
-       if (info == NULL)
-               goto fail;
-
-       if (obex_conn == NULL)
-               goto fail;
+       BT_DBG("method_name %s", method_name);
+       if (g_strcmp0(method_name, "AuthorizePush") == 0) {
+               bt_obex_agent_info *info;
+               char *path = NULL;
+               info = __find_obex_agent_info((char *)object_path);
 
-       sender = dbus_g_method_get_sender(context);
-
-       BT_DBG("sender %s", sender);
-
-       if (info->name == NULL) {
-               info->name = sender;
-       } else {
-               if (g_strcmp0(sender, info->name) != 0) {
-                       g_free(sender);
+               if (info == NULL)
                        goto fail;
-               }
-               g_free(sender);
-       }
-
-       if (info->request_cb == NULL)
-               goto fail;
-
-       proxy = dbus_g_proxy_new_for_name(obex_conn, BT_OBEX_SERVICE_NAME,
-                                         path, BT_OBEX_TRANSFER_INTERFACE);
 
-       result = info->request_cb(context, proxy, info->request_data);
-       g_object_unref(proxy);
+               if (info->authorize_cb == NULL)
+                       goto fail;
 
-       return result;
-fail:
-       BT_ERR("Fail case");
-       dbus_g_method_return(context, "");
-       return FALSE;
-}
+               g_variant_get(parameters, "(&o)", &path);
 
-gboolean bt_obex_agent_progress(BtObexAgent *agent, const char *path,
-                   guint64 transferred, DBusGMethodInvocation *context)
-{
-       BT_DBG("+");
+               info->authorize_cb(invocation, path,
+                               info->authorize_data);
 
-       bt_obex_agent_info *info;
-       char *sender;
-       gboolean result;
-       DBusGProxy *proxy;
+               return;
+       } else if (g_strcmp0(method_name, "Authorize") == 0) {
+               g_dbus_method_invocation_return_value(invocation, NULL);
+       } else if (g_strcmp0(method_name, "Request") == 0) {
+               char *sender;
+               bt_obex_agent_info *info;
+               GDBusProxy *proxy;
+               char *path = NULL;
+               char *name = NULL;
+               GError *err = NULL;
 
-       info = BT_OBEX_AGENT_GET_PRIVATE(agent);
+               info = __find_obex_agent_info((char *)object_path);
 
-       if (info == NULL)
-               goto fail;
+               if (info == NULL)
+                       goto fail;
 
-       if (obex_conn == NULL)
-               goto fail;
+               if (conn == NULL)
+                       goto fail;
 
-       sender = dbus_g_method_get_sender(context);
+               sender = (char *)g_dbus_method_invocation_get_sender(invocation);
 
-       if (g_strcmp0(sender, info->name) != 0) {
-               g_free(sender);
-               goto fail;
-       }
+               if (info->name == NULL) {
+                       info->name = sender;
+               } else {
+                       if (g_strcmp0(sender, info->name) != 0) {
+                               goto fail;
+                       }
+               }
 
-       g_free(sender);
+               if (info->request_cb == NULL)
+                       goto fail;
 
-       if (info->progress_cb == NULL)
-               goto fail;
+               g_variant_get(parameters, "(&o&s)", &path, &name);
+               proxy = g_dbus_proxy_new_sync(conn, G_DBUS_CALL_FLAGS_NONE,
+                                       NULL,
+                                       BT_OBEX_SERVICE_NAME,
+                                       path,
+                                       BT_OBEX_TRANSFER_INTERFACE,
+                                       NULL, &err);
+
+               if (err) {
+                       BT_ERR("Dbus Err: %s", err->message);
+                       g_clear_error(&err);
+                       goto fail;
+               }
 
-       proxy = dbus_g_proxy_new_for_name(obex_conn, BT_OBEX_SERVICE_NAME,
-                                         path, BT_OBEX_TRANSFER_INTERFACE);
+               info->request_cb(invocation, proxy, info->request_data);
+               g_object_unref(proxy);
+               return;
 
-       result = info->progress_cb(context, proxy, transferred, info->progress_data);
+       } else if (g_strcmp0(method_name, "Progress") == 0) {
+               BT_DBG("+");
 
-       g_object_unref(proxy);
+               bt_obex_agent_info *info;
+               char *sender;
+               char *path = NULL;
+               gint64 transferred;
+               GDBusProxy *proxy;
+               GError *err = NULL;
 
-       BT_DBG("-");
+               info = __find_obex_agent_info((char *)object_path);
 
-       return result;
-fail:
-       BT_ERR("Fail case");
-       dbus_g_method_return(context, "");
-       BT_DBG("-");
-       return FALSE;
-}
+               if (info == NULL)
+                       goto fail;
 
-gboolean bt_obex_agent_error(BtObexAgent *agent, const char *path,
-                        const char *message, DBusGMethodInvocation *context)
-{
-       bt_obex_agent_info *info;
-       char *sender;
-       DBusGProxy *proxy;
-       gboolean result;
+               if (conn == NULL)
+                       goto fail;
 
-       info = BT_OBEX_AGENT_GET_PRIVATE(agent);
+               sender = (char *)g_dbus_method_invocation_get_sender(invocation);
 
-       if (info == NULL)
-               goto fail;
+               if (g_strcmp0(sender, info->name) != 0) {
+                       goto fail;
+               }
 
-       if (obex_conn == NULL)
-               goto fail;
+               if (info->progress_cb == NULL)
+                       goto fail;
 
-       sender = dbus_g_method_get_sender(context);
+               g_variant_get(parameters, "(&ot)", &path, &transferred);
+               proxy = g_dbus_proxy_new_sync(conn, G_DBUS_CALL_FLAGS_NONE,
+                                       NULL,
+                                       BT_OBEX_SERVICE_NAME,
+                                       path,
+                                       BT_OBEX_TRANSFER_INTERFACE,
+                                       NULL, &err);
+
+               if (err) {
+                       BT_ERR("Dbus Err: %s", err->message);
+                       g_clear_error(&err);
+                       goto fail;
+               }
 
-       if (g_strcmp0(sender, info->name) != 0) {
-               g_free(sender);
-               goto fail;
-       }
+               info->progress_cb(invocation, proxy, transferred, info->progress_data);
 
-       g_free(sender);
+               g_object_unref(proxy);
 
-       if (info->error_cb == NULL)
-               goto fail;
+               BT_DBG("-");
 
-       proxy = dbus_g_proxy_new_for_name(obex_conn, BT_OBEX_SERVICE_NAME,
-                                         path, BT_OBEX_TRANSFER_INTERFACE);
+               return;
+       } else if (g_strcmp0(method_name, "Error") == 0) {
+               bt_obex_agent_info *info;
+               char *sender;
+               GDBusProxy *proxy;
+               char *path, *message;
+               GError *err = NULL;
 
-       result = info->error_cb(context, proxy, message, info->progress_data);
+               info = __find_obex_agent_info((char *)object_path);
 
-       g_object_unref(proxy);
+               if (info == NULL)
+                       goto fail;
 
-       return result;
-fail:
-       BT_ERR("Fail case");
-       dbus_g_method_return(context, "");
-       return FALSE;
-}
+               if (conn == NULL)
+                       goto fail;
 
-gboolean bt_obex_agent_complete(BtObexAgent *agent, const char *path,
-                                   DBusGMethodInvocation *context)
-{
-       bt_obex_agent_info *info;
-       char *sender;
-       DBusGProxy *proxy;
-       gboolean result;
+               sender = (char *)g_dbus_method_invocation_get_sender(invocation);
 
-       info = BT_OBEX_AGENT_GET_PRIVATE(agent);
+               if (g_strcmp0(sender, info->name) != 0) {
+                       goto fail;
+               }
 
-       if (info == NULL)
-               goto fail;
+               if (info->error_cb == NULL)
+                       goto fail;
+               g_variant_get(parameters, "(&o&s)", &path, &message);
+               proxy = g_dbus_proxy_new_sync(conn, G_DBUS_CALL_FLAGS_NONE,
+                                       NULL,
+                                       BT_OBEX_SERVICE_NAME,
+                                       path,
+                                       BT_OBEX_TRANSFER_INTERFACE,
+                                       NULL, &err);
+               if (err) {
+                       BT_ERR("Dbus Err: %s", err->message);
+                       g_clear_error(&err);
+                       goto fail;
+               }
+               info->error_cb(invocation, proxy, message, info->progress_data);
 
-       if (obex_conn == NULL)
-               goto fail;
+               g_object_unref(proxy);
 
-       sender = dbus_g_method_get_sender(context);
+               return;
+       } else if (g_strcmp0(method_name, "Complete") == 0) {
+               bt_obex_agent_info *info;
+               char *sender;
+               GDBusProxy *proxy;
+               char *path = NULL;
+               GError *err = NULL;
 
-       if (g_strcmp0(sender, info->name) != 0) {
-               g_free(sender);
-               goto fail;
-       }
+               info = __find_obex_agent_info((char *)object_path);
 
-       g_free(sender);
+               if (info == NULL)
+                       goto fail;
 
-       if (info->complete_cb == NULL)
-               goto fail;
+               if (conn == NULL)
+                       goto fail;
 
-       proxy = dbus_g_proxy_new_for_name(obex_conn, BT_OBEX_SERVICE_NAME,
-                                         path, BT_OBEX_TRANSFER_INTERFACE);
+               sender = (char *)g_dbus_method_invocation_get_sender(invocation);
 
-       result = info->complete_cb(context, proxy, info->complete_data);
+               if (g_strcmp0(sender, info->name) != 0) {
+                       goto fail;
+               }
 
-       g_object_unref(proxy);
+               if (info->complete_cb == NULL)
+                       goto fail;
 
-       return result;
-fail:
-       BT_ERR("Fail case");
-       dbus_g_method_return(context, "");
-       return FALSE;
-}
+               g_variant_get(parameters, "(&o)", &path);
+               proxy = g_dbus_proxy_new_sync(conn, G_DBUS_CALL_FLAGS_NONE,
+                                       NULL,
+                                       BT_OBEX_SERVICE_NAME,
+                                       path,
+                                       BT_OBEX_TRANSFER_INTERFACE,
+                                       NULL, &err);
+               if (err) {
+                       BT_ERR("Dbus Err: %s", err->message);
+                       g_clear_error(&err);
+                       goto fail;
+               }
 
-gboolean bt_obex_agent_release(BtObexAgent *agent, DBusGMethodInvocation *context)
-{
-       bt_obex_agent_info *info;
-       char *sender;
-       gboolean result;
+               info->complete_cb(invocation, proxy, info->complete_data);
 
-       info = BT_OBEX_AGENT_GET_PRIVATE(agent);
+               g_object_unref(proxy);
 
-       if (info == NULL)
-               goto fail;
+               return;
+       } else if (g_strcmp0(method_name, "Release") == 0) {
+               bt_obex_agent_info *info;
+               char *sender;
 
-       sender = dbus_g_method_get_sender(context);
+               info = __find_obex_agent_info((char *)object_path);
 
-       if (info->name) {
-               /*In H2 if user denies auth,release will come without request and hence
-               info->name will be NULL */
-               if (g_strcmp0(sender, info->name) != 0) {
-                       g_free(sender);
+               if (info == NULL)
                        goto fail;
-               }
-       }
-       g_free(sender);
 
-       if (info->release_cb == NULL)
-               goto fail;
+               sender = (char *)g_dbus_method_invocation_get_sender(invocation);
 
-       result = info->release_cb(context, info->release_data);
-
-       return result;
-fail:
-       BT_ERR("Fail case");
-       dbus_g_method_return(context, "");
-       return FALSE;
-}
-
-static void bt_obex_agent_init(BtObexAgent *agent)
-{
-       BT_DBG("agent %p", agent);
-}
+               if (info->name) {
+                       /*In H2 if user denies auth,release will come without request and hence
+                       info->name will be NULL */
+                       if (g_strcmp0(sender, info->name) != 0) {
+                               goto fail;
+                       }
+               }
 
-static void bt_obex_agent_finalize(GObject *agent)
-{
-       bt_obex_agent_info *info;
+               if (info->release_cb == NULL)
+                       goto fail;
 
-       info = BT_OBEX_AGENT_GET_PRIVATE(agent);
+               info->release_cb(invocation, info->release_data);
 
-       if (info) {
-               g_free(info->path);
-               g_free(info->name);
+               return;
        }
-
-       G_OBJECT_CLASS(bt_obex_agent_parent_class)->finalize(agent);
+fail:
+               BT_ERR("Fail case");
+               g_dbus_method_invocation_return_value(invocation, NULL);
 }
 
-static void bt_obex_agent_class_init(BtObexAgentClass *agent_class)
+void _bt_obex_agent_new(char *path)
 {
-       GObjectClass *object_class;
+       bt_obex_agent_info *info = NULL;
        GError *error = NULL;
 
-       object_class = (GObjectClass *)agent_class;
-
-       g_type_class_add_private(agent_class, sizeof(bt_obex_agent_info));
-
-       object_class->finalize = bt_obex_agent_finalize;
-
-       obex_conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
-
-       if (error != NULL) {
-               BT_ERR("Fail to get dbus: %s", error->message);
-               g_error_free(error);
+       if (conn == NULL) {
+               conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
+               if (error != NULL) {
+                       BT_ERR("Fail to get dbus: %s", error->message);
+                       g_error_free(error);
+                       return;
+               }
        }
-
-       dbus_g_object_type_install_info(BT_OBEX_TYPE_AGENT,
-                               &dbus_glib_bt_obex_agent_object_info);
+       info = (bt_obex_agent_info *)malloc (sizeof(bt_obex_agent_info));
+       memset(info, 0, sizeof(bt_obex_agent_info));
+       info->path = g_strdup(path);
+       obex_agent_list = g_slist_append(obex_agent_list, info);
 }
 
-BtObexAgent *_bt_obex_agent_new(void)
+void _bt_obex_agent_destroy(char *path)
 {
-       BtObexAgent *agent;
-
-       agent = BT_OBEX_AGENT(g_object_new(BT_OBEX_TYPE_AGENT, NULL));
-
-       return agent;
+       bt_obex_agent_info *info = NULL;
+       info = __find_obex_agent_info(path);
+       if (info == NULL) {
+               BT_ERR("obex agent info not found on path %s", path);
+               return;
+       }
+       obex_agent_list = g_slist_remove(obex_agent_list, info);
+       if (info->path)
+               g_free(info->path);
+       if (info->name)
+               g_free(info->name);
+       if (info->openobex_id)
+               g_dbus_connection_unregister_object(conn,
+                       info->openobex_id);
+       if (info->obex_agent_id)
+               g_dbus_connection_unregister_object(conn,
+                       info->obex_agent_id);
+
+       g_free(info);
 }
-
-gboolean _bt_obex_setup(BtObexAgent *agent, const char *path)
+gboolean _bt_obex_setup(const char *path)
 {
        bt_obex_agent_info *info;
-       DBusGProxy *proxy;
-       GObject *object;
+       GDBusProxy *proxy;
+       GDBusNodeInfo *new_conn_node;
+       GError *err = NULL;
 
-       info = BT_OBEX_AGENT_GET_PRIVATE(agent);
+       info = __find_obex_agent_info((char *)path);
 
-       retv_if(obex_conn == NULL, FALSE);
        retv_if(info == NULL, FALSE);
-       retv_if(info->path != NULL, FALSE);
 
-       info->path = g_strdup(path);
+       proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION,
+                               G_DBUS_PROXY_FLAGS_NONE,
+                               NULL,
+                               BT_OBEX_SERVICE_NAME,
+                               BT_OBEX_CLIENT_PATH,
+                               BT_OBEX_AGENT_INTERFACE,
+                               NULL,
+                               &err);
 
-       proxy = dbus_g_proxy_new_for_name_owner(obex_conn, BT_OBEX_SERVICE_NAME,
-                                               BT_OBEX_CLIENT_PATH,
-                                               BT_OBEX_AGENT_INTERFACE, NULL);
        g_free(info->name);
 
        if (proxy != NULL) {
-               info->name = g_strdup(dbus_g_proxy_get_bus_name(proxy));
+               info->name = g_strdup(g_dbus_proxy_get_name(proxy));
                g_object_unref(proxy);
        } else {
                info->name = NULL;
        }
 
-       object = dbus_g_connection_lookup_g_object(obex_conn, info->path);
-       if (object != NULL)
-               g_object_unref(object);
-
-       dbus_g_connection_register_g_object(obex_conn, info->path, G_OBJECT(agent));
-
-       dbus_g_object_register_marshaller(marshal_VOID__OBJECT_BOOLEAN,
-                                         G_TYPE_NONE, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_BOOLEAN,
-                                         G_TYPE_INVALID);
-
-       dbus_g_object_register_marshaller(marshal_VOID__INT_INT,
-                                         G_TYPE_NONE, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID);
+       new_conn_node = g_dbus_node_info_new_for_xml(obex_service_agent_xml1, NULL);
+
+       info->openobex_id = g_dbus_connection_register_object(conn, info->path,
+                                               new_conn_node->interfaces[0],
+                                               &method_table,
+                                               NULL, NULL, &err);
+       g_dbus_node_info_unref(new_conn_node);
+       if (err) {
+               BT_INFO("Dbus Err: %s", err->message);
+               g_clear_error(&err);
+               return FALSE;
+       }
+       if (info->openobex_id == 0)
+               BT_ERR("Error while registering object");
+       new_conn_node = g_dbus_node_info_new_for_xml(obex_service_agent_xml2, NULL);
+
+       info->obex_agent_id = g_dbus_connection_register_object(conn, info->path,
+                                               new_conn_node->interfaces[0],
+                                               &method_table,
+                                               NULL, NULL, &err);
+       g_dbus_node_info_unref(new_conn_node);
+       if (info->obex_agent_id == 0)
+               BT_ERR("Error while registering object");
+       if (err) {
+               BT_INFO("Dbus Err: %s", err->message);
+               g_clear_error(&err);
+               return FALSE;
+       }
        return TRUE;
 }
 
-void _bt_obex_set_authorize_cb(BtObexAgent *agent,
+void _bt_obex_set_authorize_cb(char *object_path,
                         bt_obex_authorize_cb func, gpointer data)
 {
-       bt_obex_agent_info *info = BT_OBEX_AGENT_GET_PRIVATE(agent);
+       bt_obex_agent_info *info = __find_obex_agent_info(object_path);;
 
        info->authorize_cb = func;
        info->authorize_data = data;
 }
 
-void _bt_obex_set_release_cb(BtObexAgent *agent,
+void _bt_obex_set_release_cb(char *object_path,
                       bt_obex_release_cb func, gpointer data)
 {
-       bt_obex_agent_info *info = BT_OBEX_AGENT_GET_PRIVATE(agent);
+       bt_obex_agent_info *info = __find_obex_agent_info(object_path);;
+
+       /* Fix : NULL_RETURNS */
+       if (info == NULL)
+               return;
 
        info->release_cb = func;
        info->release_data = data;
 }
 
-void _bt_obex_set_request_cb(BtObexAgent *agent,
+void _bt_obex_set_request_cb(char *object_path,
                       bt_obex_request_cb func, gpointer data)
 {
-       bt_obex_agent_info *info = BT_OBEX_AGENT_GET_PRIVATE(agent);
+       bt_obex_agent_info *info = __find_obex_agent_info(object_path);;
+
+       /* Fix : NULL_RETURNS */
+       if (info == NULL)
+               return;
 
        info->request_cb = func;
        info->request_data = data;
 }
 
-void _bt_obex_set_progress_cb(BtObexAgent *agent,
+void _bt_obex_set_progress_cb(char *object_path,
                        bt_obex_progress_cb func, gpointer data)
 {
-       bt_obex_agent_info *info = BT_OBEX_AGENT_GET_PRIVATE(agent);
+       bt_obex_agent_info *info = __find_obex_agent_info(object_path);;
+
+       /* Fix : NULL_RETURNS */
+       if (info == NULL)
+               return;
 
        info->progress_cb = func;
        info->progress_data = data;
 }
 
-void _bt_obex_set_complete_cb(BtObexAgent *agent,
+void _bt_obex_set_complete_cb(char *object_path,
                        bt_obex_complete_cb func, gpointer data)
 {
-       bt_obex_agent_info *info = BT_OBEX_AGENT_GET_PRIVATE(agent);
+       bt_obex_agent_info *info =__find_obex_agent_info(object_path);;
+
+       /* Fix : NULL_RETURNS */
+       if (info == NULL)
+               return;
 
        info->complete_cb = func;
        info->complete_data = data;
 }
 
-void _bt_obex_set_error_cb(BtObexAgent *agent,
+void _bt_obex_set_error_cb(char *object_path,
                        bt_obex_error_cb func, gpointer data)
 {
-       bt_obex_agent_info *info = BT_OBEX_AGENT_GET_PRIVATE(agent);
+       bt_obex_agent_info *info = __find_obex_agent_info(object_path);;
+
+       /* Fix : NULL_RETURNS */
+       if (info == NULL)
+               return;
 
        info->error_cb = func;
        info->error_data = data;
index 76672cc..6971a31 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 
 <node name="/">
-  <interface name="org.bluez.obex.Agent1">
+  <interface name="org.openobex.Agent">
     <method name="Request">
       <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
       <arg type="o" name="transfer"/>
index 296d1c6..8b89771 100644 (file)
  *
  */
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
 #include <stdio.h>
 #include <glib.h>
 #include <dlog.h>
 #include <string.h>
 #include <dirent.h>
+#ifdef TIZEN_MDM_ENABLE
+#include <bt-service-mdm.h>
+#endif
 #include <vconf.h>
 
+#include <gio/gio.h>
+
 #include "bluetooth-api.h"
 #include "bt-internal-types.h"
 
@@ -40,6 +43,7 @@
 #include "bt-service-obex-server.h"
 #include "bt-service-agent.h"
 
+#define DBUS_TIMEOUT 20 * 1000 /* 20 Seconds */
 #define BT_OBEX_SERVER_AGENT_PATH "/org/obex/server_agent"
 
 #define BT_OBEX_SERVICE "org.bluez.obex"
@@ -59,8 +63,8 @@ typedef struct {
 } bt_transfer_info_t;
 
 typedef struct {
-       DBusGMethodInvocation *reply_context;
-       gint64 file_size;
+       GDBusMethodInvocation *reply_context;
+       guint64 file_size;
        char *filename;
        char *file_path;
        char *device_name;
@@ -75,8 +79,7 @@ typedef struct {
 } bt_server_info_t;
 
 typedef struct {
-       BtObexAgent *obex_agent;
-       DBusGProxy *proxy;
+       GDBusProxy *proxy;
        int server_type;
        int accept_id;
        bt_auth_info_t *auth_info;
@@ -191,21 +194,21 @@ static void __bt_free_transfer_info(bt_transfer_info_t *transfer_info)
 void _bt_obex_check_pending_transfer(const char *address)
 {
        BT_DBG("+");
+       GVariant *param = NULL;
        bt_transfer_info_t *transfer_info = __bt_find_transfer_by_address(address);
        if (transfer_info != NULL) {
                int result = BLUETOOTH_ERROR_CANCEL;
+               param = g_variant_new("(isssstii)", result,
+                                       transfer_info->filename,
+                                       transfer_info->type,
+                                       transfer_info->device_name,
+                                       transfer_info->file_path,
+                                       transfer_info->file_size,
+                                       transfer_info->transfer_id,
+                                       agent_info.server_type);
                _bt_send_event(BT_OPP_SERVER_EVENT,
                        BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &transfer_info->filename,
-                       DBUS_TYPE_STRING, &transfer_info->type,
-                       DBUS_TYPE_STRING, &transfer_info->device_name,
-                       DBUS_TYPE_STRING, &transfer_info->file_path,
-                       DBUS_TYPE_UINT64, &transfer_info->file_size,
-                       DBUS_TYPE_INT32, &transfer_info->transfer_id,
-                       DBUS_TYPE_INT32, &agent_info.server_type,
-                       DBUS_TYPE_INVALID);
-
+                       param);
                transfers = g_slist_remove(transfers, transfer_info);
                __bt_free_transfer_info(transfer_info);
        }
@@ -216,41 +219,54 @@ static char *__bt_get_remote_device_name(const char *bdaddress)
 {
        char *device_path = NULL;
        char *name = NULL;
-       GHashTable *hash = NULL;
-       GValue *value;
-       DBusGProxy *device_proxy;
-       DBusGProxy *adapter_proxy;
-       DBusGConnection *conn;
+       GVariant *value;
+       GVariant *result = NULL;
+       GError *err = NULL;
+       GDBusProxy *device_proxy;
+       GDBusConnection *conn;
 
        retv_if(bdaddress == NULL, NULL);
 
-       adapter_proxy = _bt_get_adapter_proxy();
-       retv_if(adapter_proxy == NULL, NULL);
-
        device_path = _bt_get_device_object_path((char *)bdaddress);
        retv_if(device_path == NULL, NULL);
 
-       conn = _bt_get_system_gconn();
+       conn = _bt_get_session_gconn();
        retv_if(conn == NULL, NULL);
-
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                                       device_path, BT_PROPERTIES_INTERFACE);
+       BT_INFO("Device_path %s", device_path);
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                               NULL, BT_BLUEZ_NAME,
+                                               device_path,
+                                               BT_PROPERTIES_INTERFACE,
+                                               NULL, &err);
 
        g_free(device_path);
        retv_if(device_proxy == NULL, NULL);
 
-       dbus_g_proxy_call(device_proxy, "GetAll", NULL,
-                               G_TYPE_STRING, BT_DEVICE_INTERFACE,
-                               G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
-                               G_TYPE_VALUE), &hash, G_TYPE_INVALID);
+       result = g_dbus_proxy_call_sync(device_proxy, "GetAll",
+                       g_variant_new("(s)", BT_DEVICE_INTERFACE),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       DBUS_TIMEOUT, NULL,
+                       &err);
+       if (err) {
+               BT_ERR("DBus Error : %s", err->message);
+               g_clear_error(&err);
+               return NULL;
+       }
+       if (result == NULL) {
+               BT_ERR("g_dbus_proxy_call_sync function return NULL");
+               return NULL;
+       }
+       g_variant_get(result, "(@a{sv})", &value);
+       g_variant_unref(result);
 
        g_object_unref(device_proxy);
-
-       if (hash != NULL) {
-               value = g_hash_table_lookup(hash, "Alias");
-               name = value ? g_value_dup_string(value) : NULL;
-               g_hash_table_destroy(hash);
+       if (value) {
+               GVariant *temp_value = g_variant_lookup_value(value, "Alias",
+                       G_VARIANT_TYPE_STRING);
+               g_variant_get(temp_value, "(s)", &name);
+               if (temp_value)
+                       g_variant_unref(temp_value);
+               BT_INFO("Alias Name: %s", name);
        }
 
        return name;
@@ -268,46 +284,59 @@ static int __bt_get_transfer_id(const char *path)
        return atoi(tmp);
 }
 
-static DBusGProxy *__bt_get_transfer_proxy(const char *transfer_path)
+static GDBusProxy *__bt_get_transfer_proxy(const char *transfer_path)
 {
-       DBusGConnection *conn;
-       DBusGProxy *proxy;
+       GDBusConnection *conn;
+       GDBusProxy *proxy;
+       GError *err = NULL;
 
        conn = _bt_get_session_gconn();
        retv_if(conn == NULL, NULL);
 
-       proxy = dbus_g_proxy_new_for_name(conn,
-                                       BT_OBEX_SERVICE_NAME,
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                       NULL, BT_OBEX_SERVICE_NAME,
                                        transfer_path,
-                                       BT_OBEX_TRANSFER_INTERFACE);
+                                       BT_OBEX_TRANSFER_INTERFACE,
+                                       NULL, &err);
+
+       if (err) {
+               BT_ERR("Error : %s", err->message);
+               g_clear_error(&err);
+               return NULL;
+       }
 
        return proxy;
 }
 
-static DBusGProxy *__bt_get_transfer_properties_proxy(const char *transfer_path)
+static GDBusProxy *__bt_get_transfer_properties_proxy(const char *transfer_path)
 {
-       DBusGConnection *conn;
-       DBusGProxy *proxy;
-
+       GDBusConnection *conn;
+       GDBusProxy *proxy;
+       GError *err = NULL;
        conn = _bt_get_session_gconn();
        retv_if(conn == NULL, NULL);
 
-       proxy = dbus_g_proxy_new_for_name(conn,
-                                       BT_OBEX_SERVICE_NAME,
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                                       NULL,BT_OBEX_SERVICE_NAME,
                                        transfer_path,
-                                       BT_PROPERTIES_INTERFACE);
-
+                                       BT_PROPERTIES_INTERFACE,
+                                       NULL, &err);
+       if (err) {
+               BT_ERR("Error : %s", err->message);
+               g_clear_error(&err);
+               return NULL;
+       }
        return proxy;
 }
 
 static int __bt_get_transfer_properties(bt_transfer_info_t *transfer_info,
                                        const char *transfer_path)
 {
-       GHashTable *hash = NULL;
-       GValue *value;
-       DBusGProxy *transfer_proxy;
-       char *bdaddress;
-
+       GDBusProxy *transfer_proxy;
+       char *bdaddress = NULL;
+       GVariant *result = NULL;
+       GError *err = NULL;
+       GVariantIter *iter = NULL;
        BT_CHECK_PARAMETER(transfer_info, return);
        BT_CHECK_PARAMETER(transfer_path, return);
 
@@ -315,69 +344,78 @@ static int __bt_get_transfer_properties(bt_transfer_info_t *transfer_info,
 
        retv_if(transfer_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call(transfer_proxy, "GetAll", NULL,
-                               G_TYPE_STRING, BT_OBEX_TRANSFER_INTERFACE,
-                               G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
-                               G_TYPE_VALUE), &hash, G_TYPE_INVALID);
+       result = g_dbus_proxy_call_sync(transfer_proxy, "GetAll",
+                       g_variant_new("(s)", BT_OBEX_TRANSFER_INTERFACE),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       DBUS_TIMEOUT, NULL,
+                       &err);
 
-       if (hash == NULL) {
-               g_object_unref(transfer_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       value = g_hash_table_lookup(hash, "Operation");
-       transfer_info->type = value ? g_strdup(g_value_get_string(value)) : NULL;
-       if (!transfer_info->type)
+       if (err) {
+               BT_ERR("DBus Error : %s", err->message);
+               g_clear_error(&err);
                goto fail;
-
-       value = g_hash_table_lookup(hash, "Name");
-
-       transfer_info->filename = value ? g_strdup(g_value_get_string(value)) : NULL;
-       if (!transfer_info->filename)
+       }
+       if (result == NULL) {
+               BT_ERR("g_dbus_proxy_call_sync function return NULL");
                goto fail;
+       }
 
-       value = g_hash_table_lookup(hash, "Size");
-       transfer_info->file_size  = value ? g_value_get_uint64(value) : 0;
-
-       transfer_info->path = g_strdup(transfer_path);
-       transfer_info->transfer_id = __bt_get_transfer_id(transfer_path);
-
-       value = g_hash_table_lookup(hash, "Address");
-       bdaddress = value ? (char *)g_value_get_string(value) : NULL;
-       if (!bdaddress)
-               goto fail;
-       transfer_info->address = g_strdup(bdaddress);
+       g_variant_get(result, "(a{sv})", &iter);
+       g_variant_unref(result);
+       if (iter) {
+               const gchar *key;
+               GVariant *val;
+               gsize len = 0;
+               while (g_variant_iter_loop(iter, "{sv}", &key, &val)) {
+                       if (g_strcmp0(key, "Operation") == 0) {
+                               transfer_info->type = g_variant_dup_string(val, &len);
+                       } else if (g_strcmp0(key, "Name") == 0) {
+                               transfer_info->filename = g_variant_dup_string(val, &len);
+                       } else if (g_strcmp0(key, "Size") == 0) {
+                               transfer_info->file_size = g_variant_get_uint64(val);
+                       } else if (g_strcmp0(key, "Address") == 0) {
+                               transfer_info->address = g_variant_dup_string(val, &len);
+                               BT_INFO("addressss %s", transfer_info->address);
+                       } else if (g_strcmp0(key, "Filename") == 0) {
+                               transfer_info->file_path = g_variant_dup_string(val, &len);
+                               if (!transfer_info->file_path)
+                                       transfer_info->file_path = g_strdup(transfer_info->filename);
+                       }
+               }
+               g_variant_iter_free(iter);
+               if (transfer_info->type == NULL)
+                       goto fail;
+               if (transfer_info->address == NULL)
+                       goto fail;
 
-       value = g_hash_table_lookup(hash, "Filename");
-       transfer_info->file_path = value ? g_strdup(g_value_get_string(value)) : NULL;
-       if (!transfer_info->file_path)
-               transfer_info->file_path = g_strdup(transfer_info->filename);
+               transfer_info->device_name = __bt_get_remote_device_name(transfer_info->address);
 
-       transfer_info->device_name = __bt_get_remote_device_name(bdaddress);
-       if (!transfer_info->device_name)
-               transfer_info->device_name = g_strdup(bdaddress);
+               if (!transfer_info->device_name)
+                       transfer_info->device_name = g_strdup(bdaddress);
+               transfer_info->path = g_strdup(transfer_path);
+               transfer_info->transfer_id = __bt_get_transfer_id(transfer_path);
+       }
 
-       g_hash_table_destroy(hash);
        g_object_unref(transfer_proxy);
        return BLUETOOTH_ERROR_NONE;
 
 fail:
-       g_hash_table_destroy(hash);
        g_object_unref(transfer_proxy);
        return BLUETOOTH_ERROR_INTERNAL;
 }
 
-static gboolean __bt_authorize_cb(DBusGMethodInvocation *context,
+static gboolean __bt_authorize_cb(GDBusMethodInvocation *context,
                                        const char *path,
                                        gpointer user_data)
 {
        char *device_name = NULL;
        int result = BLUETOOTH_ERROR_NONE;
-       DBusGProxy *transfer_properties_proxy;
-       GHashTable *hash = NULL;
-       GValue *value;
+       GDBusProxy *transfer_properties_proxy;
        char * bdaddress = NULL;
+       GVariant *ret;
+       GVariantIter *iter;
+       GVariant *param = NULL;
+       GError *err = NULL;
 
        BT_DBG(" path [%s] \n", path);
 
@@ -385,34 +423,56 @@ static gboolean __bt_authorize_cb(DBusGMethodInvocation *context,
 
        retv_if(transfer_properties_proxy == NULL, FALSE);
 
-       dbus_g_proxy_call(transfer_properties_proxy, "GetAll", NULL,
-                               G_TYPE_STRING, BT_OBEX_TRANSFER_INTERFACE,
-                               G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
-                               G_TYPE_VALUE), &hash, G_TYPE_INVALID);
-
-       if (hash == NULL) {
+       ret = g_dbus_proxy_call_sync(transfer_properties_proxy, "GetAll",
+                       g_variant_new("(s)", BT_OBEX_TRANSFER_INTERFACE),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       DBUS_TIMEOUT, NULL,
+                       &err);
+       if (err) {
+               BT_ERR("DBus Error : %s", err->message);
+               g_clear_error(&err);
+               return FALSE;
+       }
+       if (ret == NULL) {
+               BT_ERR("g_dbus_proxy_call_sync function return NULL");
+               return FALSE;
+       }
+       g_variant_get(ret, "(a{sv})", &iter);
+       g_variant_unref(ret);
+       if (iter == NULL) {
                g_object_unref(transfer_properties_proxy);
                return FALSE;
        }
 
+#ifdef TIZEN_MDM_ENABLE
+       mdm_bt_allow_t mode = MDM_BT_ALLOWED;
+#endif
+
        __bt_free_auth_info(agent_info.auth_info);
 
        agent_info.auth_info = g_malloc(sizeof(bt_auth_info_t));
 
+       memset(agent_info.auth_info, 0, sizeof(bt_auth_info_t));
+
        agent_info.auth_info->reply_context = context;
 
        agent_info.auth_info->transfer_path = g_strdup(path);
 
-       value = g_hash_table_lookup(hash, "Name");
-       agent_info.auth_info->filename = value ? g_strdup(g_value_get_string(value)) : NULL;
-
-       value = g_hash_table_lookup(hash, "Size");
-       agent_info.auth_info->file_size  = value ? g_value_get_uint64(value) : 0;
-
-       value = g_hash_table_lookup(hash, "Address");
-       bdaddress = value ? (char *)g_value_get_string(value) : NULL;
-       agent_info.auth_info->address = g_strdup(bdaddress);
+       if (iter) {
+               const gchar *key;
+               GVariant *val;
+               gsize len = 0;
+               while (g_variant_iter_loop(iter, "{sv}", &key, &val)) {
+                       if (g_strcmp0(key, "Name") == 0) {
+                               agent_info.auth_info->filename = g_variant_dup_string(val,&len);
+                       } else if (g_strcmp0(key, "Address") == 0) {
+                               bdaddress = g_variant_dup_string(val, &len);
+                       } else if (g_strcmp0(key, "Size") == 0) {
+                               agent_info.auth_info->file_size = g_variant_get_uint64(val);
+                       }
+               }
+               g_variant_iter_free(iter);
+       }
 
        device_name = __bt_get_remote_device_name(bdaddress);
 
@@ -421,7 +481,6 @@ static gboolean __bt_authorize_cb(DBusGMethodInvocation *context,
 
        agent_info.auth_info->device_name = device_name;
 
-       g_hash_table_destroy(hash);
        g_object_unref(transfer_properties_proxy);
 
        if (agent_info.server_type == BT_CUSTOM_SERVER) {
@@ -429,13 +488,12 @@ static gboolean __bt_authorize_cb(DBusGMethodInvocation *context,
                _bt_obex_server_accept_authorize(agent_info.auth_info->filename, FALSE);
                return TRUE;
        }
-
+       param = g_variant_new("(ist)", result,
+                               agent_info.auth_info->filename,
+                               agent_info.auth_info->file_size);
        _bt_send_event(BT_OPP_SERVER_EVENT,
                BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_STRING, &agent_info.auth_info->filename,
-               DBUS_TYPE_UINT64, &agent_info.auth_info->file_size,
-               DBUS_TYPE_INVALID);
+               param);
 
        return TRUE;
 }
@@ -444,8 +502,8 @@ void _bt_obex_transfer_started(const char *transfer_path)
 {
        bt_transfer_info_t *transfer_info;
        request_info_t *req_info;
-       GArray *out_param1 = NULL;
-       GArray *out_param2 = NULL;
+       GVariant *out_param1 = NULL;
+       GVariant *param = NULL;
        int result = BLUETOOTH_ERROR_NONE;
 
        BT_DBG("%s", transfer_path);
@@ -490,33 +548,32 @@ void _bt_obex_transfer_started(const char *transfer_path)
 
                agent_info.accept_id = 0;
                result = BLUETOOTH_ERROR_NONE;
+               GArray *g_out_param1 = NULL;
+               g_out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
+               if (out_param1 == NULL) {
+                       out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+                                       g_out_param1->data, g_out_param1->len,
+                                       TRUE, NULL, NULL);
+               }
 
-               out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-               out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-               g_array_append_vals(out_param2, &result, sizeof(int));
-
-               dbus_g_method_return(req_info->context, out_param1, out_param2);
-
-               g_array_free(out_param1, TRUE);
-               g_array_free(out_param2, TRUE);
-
+               g_dbus_method_invocation_return_value(req_info->context,
+                               g_variant_new("(iv)", result, out_param1));
+               g_array_free(g_out_param1, TRUE);
                _bt_delete_request_list(req_info->req_id);
        }
 done:
        transfers = g_slist_append(transfers, transfer_info);
 
        BT_DBG("Transfer id %d\n", transfer_info->transfer_id);
-
+       param = g_variant_new("(isstii)", result,
+                               transfer_info->filename,
+                               transfer_info->type,
+                               transfer_info->file_size,
+                               transfer_info->transfer_id,
+                               agent_info.server_type);
        _bt_send_event(BT_OPP_SERVER_EVENT,
                BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_STRING, &transfer_info->filename,
-               DBUS_TYPE_STRING, &transfer_info->type,
-               DBUS_TYPE_UINT64, &transfer_info->file_size,
-               DBUS_TYPE_INT32, &transfer_info->transfer_id,
-               DBUS_TYPE_INT32, &agent_info.server_type,
-               DBUS_TYPE_INVALID);
+               param);
 }
 
 void _bt_obex_transfer_progress(const char *transfer_path,
@@ -525,6 +582,7 @@ void _bt_obex_transfer_progress(const char *transfer_path,
        BT_DBG("+");
        bt_transfer_info_t *transfer_info;
        int progress = 0;
+       GVariant *param = NULL;
        int result = BLUETOOTH_ERROR_NONE;
 
        transfer_info = __bt_find_transfer_by_path(transfer_path);
@@ -533,24 +591,23 @@ void _bt_obex_transfer_progress(const char *transfer_path,
        progress = (int)(((gdouble)transferred /
                        (gdouble)transfer_info->file_size) * 100);
 
+       param = g_variant_new("(isstiii)", result,
+                               transfer_info->filename,
+                               transfer_info->type,
+                               transfer_info->file_size,
+                               transfer_info->transfer_id,
+                               progress,
+                               agent_info.server_type);
        _bt_send_event(BT_OPP_SERVER_EVENT,
                BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_STRING, &transfer_info->filename,
-               DBUS_TYPE_STRING, &transfer_info->type,
-               DBUS_TYPE_UINT64, &transfer_info->file_size,
-               DBUS_TYPE_INT32, &transfer_info->transfer_id,
-               DBUS_TYPE_INT32, &progress,
-               DBUS_TYPE_INT32, &agent_info.server_type,
-               DBUS_TYPE_INVALID);
-
+               param);
        BT_DBG("-");
 }
 
 void _bt_obex_transfer_completed(const char *transfer_path, gboolean success)
 {
        bt_transfer_info_t *transfer_info;
-
+       GVariant *param = NULL;
        int result;
        BT_DBG("Transfer [%s] Success [%d] \n", transfer_path, success);
 
@@ -578,29 +635,27 @@ void _bt_obex_transfer_completed(const char *transfer_path, gboolean success)
                transfer_info->transfer_id = __bt_get_transfer_id(transfer_path);
                transfer_info->file_path = agent_info.auth_info->file_path;
 
+               param = g_variant_new("(isstii)", result,
+                                       transfer_info->filename,
+                                       transfer_info->type,
+                                       transfer_info->file_size,
+                                       transfer_info->transfer_id,
+                                       agent_info.server_type);
                _bt_send_event(BT_OPP_SERVER_EVENT,
                        BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &transfer_info->filename,
-                       DBUS_TYPE_STRING, &transfer_info->type,
-                       DBUS_TYPE_UINT64, &transfer_info->file_size,
-                       DBUS_TYPE_INT32, &transfer_info->transfer_id,
-                       DBUS_TYPE_INT32, &agent_info.server_type,
-                       DBUS_TYPE_INVALID);
+                       param);
        }
-
+       param = g_variant_new("(isssstii)", result,
+                               transfer_info->filename,
+                               transfer_info->type,
+                               transfer_info->device_name,
+                               transfer_info->file_path,
+                               transfer_info->file_size,
+                               transfer_info->transfer_id,
+                               agent_info.server_type);
        _bt_send_event(BT_OPP_SERVER_EVENT,
                BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_STRING, &transfer_info->filename,
-               DBUS_TYPE_STRING, &transfer_info->type,
-               DBUS_TYPE_STRING, &transfer_info->device_name,
-               DBUS_TYPE_STRING, &transfer_info->file_path,
-               DBUS_TYPE_UINT64, &transfer_info->file_size,
-               DBUS_TYPE_INT32, &transfer_info->transfer_id,
-               DBUS_TYPE_INT32, &agent_info.server_type,
-               DBUS_TYPE_INVALID);
-
+               param);
        transfers = g_slist_remove(transfers, transfer_info);
        __bt_free_transfer_info(transfer_info);
 }
@@ -610,12 +665,13 @@ void _bt_obex_transfer_connected()
        BT_DBG("+");
 
        int result = BLUETOOTH_ERROR_NONE;
+       GVariant *param = NULL;
+
+       param = g_variant_new("(i)", result);
 
        _bt_send_event(BT_OPP_SERVER_EVENT,
                BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_INVALID);
-
+               param);
        BT_DBG("-");
 }
 
@@ -624,52 +680,50 @@ void _bt_obex_transfer_disconnected()
        BT_DBG("+");
 
        int result = BLUETOOTH_ERROR_NONE;
+       GVariant *param = NULL;
 
+       param = g_variant_new("(i)", result);
        _bt_send_event(BT_OPP_SERVER_EVENT,
                BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_DISCONNECTED,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_INVALID);
-
+               param);
        BT_DBG("-");
 }
 
 int _bt_register_obex_server(void)
 {
-       DBusGConnection *g_conn;
-       DBusGProxy *manager_proxy;
+       GDBusConnection *g_conn;
+       GDBusProxy *manager_proxy;
        GError *g_error = NULL;
 
        /* Get the session bus. */
        g_conn = _bt_get_session_gconn();
        retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       if (!agent_info.obex_agent) {
-               agent_info.obex_agent = _bt_obex_agent_new();
-
-               retv_if(agent_info.obex_agent == NULL, BLUETOOTH_ERROR_INTERNAL);
+       _bt_obex_agent_new(BT_OBEX_SERVER_AGENT_PATH);
 
-               _bt_obex_setup(agent_info.obex_agent, BT_OBEX_SERVER_AGENT_PATH);
+       _bt_obex_setup(BT_OBEX_SERVER_AGENT_PATH);
 
-               _bt_obex_set_authorize_cb(agent_info.obex_agent,
+       _bt_obex_set_authorize_cb(BT_OBEX_SERVER_AGENT_PATH,
                                        __bt_authorize_cb, NULL);
-       }
 
-       manager_proxy = dbus_g_proxy_new_for_name(g_conn, BT_OBEX_SERVICE,
-                                               BT_OBEX_PATH, BT_OBEX_MANAGER);
+       manager_proxy = g_dbus_proxy_new_sync(g_conn, G_DBUS_PROXY_FLAGS_NONE,
+                                               NULL, BT_OBEX_SERVICE,
+                                               BT_OBEX_PATH,
+                                               BT_OBEX_MANAGER,
+                                               NULL, &g_error);
 
        if (manager_proxy == NULL) {
-               g_object_unref(agent_info.obex_agent);
-               agent_info.obex_agent = NULL;
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       dbus_g_proxy_call(manager_proxy, "RegisterAgent", &g_error,
-                         DBUS_TYPE_G_OBJECT_PATH, BT_OBEX_SERVER_AGENT_PATH,
-                         G_TYPE_INVALID, G_TYPE_INVALID);
+       g_dbus_proxy_call_sync(manager_proxy, "RegisterAgent",
+                               g_variant_new("(o)", BT_OBEX_SERVER_AGENT_PATH),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               DBUS_TIMEOUT, NULL,
+                               &g_error);
+
        if (g_error != NULL) {
                BT_ERR("Agent registration failed: %s\n", g_error->message);
-               g_object_unref(agent_info.obex_agent);
-               agent_info.obex_agent = NULL;
                g_object_unref(manager_proxy);
                g_error_free(g_error);
                return BLUETOOTH_ERROR_INTERNAL;
@@ -684,26 +738,22 @@ int _bt_unregister_obex_server(void)
 {
        GError *g_error = NULL;
 
-       retv_if(agent_info.obex_agent == NULL,
-                               BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST);
-
        retv_if(agent_info.proxy == NULL,
                                BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call(agent_info.proxy, "UnregisterAgent", &g_error,
-                         DBUS_TYPE_G_OBJECT_PATH, BT_OBEX_SERVER_AGENT_PATH,
-                         G_TYPE_INVALID, G_TYPE_INVALID);
+       g_dbus_proxy_call_sync(agent_info.proxy, "UnregisterAgent",
+                               g_variant_new("(o)", BT_OBEX_SERVER_AGENT_PATH),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               DBUS_TIMEOUT, NULL,
+                               &g_error);
        if (g_error != NULL) {
                BT_ERR("Agent unregistration failed: %s", g_error->message);
                g_error_free(g_error);
        }
-
+       _bt_obex_agent_destroy(BT_OBEX_SERVER_AGENT_PATH);
        g_object_unref(agent_info.proxy);
        agent_info.proxy = NULL;
 
-       g_object_unref(agent_info.obex_agent);
-       agent_info.obex_agent = NULL;
-
        return BLUETOOTH_ERROR_NONE;
 }
 
@@ -727,6 +777,7 @@ gboolean __bt_check_folder_path(const char *dest_path)
 
 int _bt_obex_server_allocate(char *sender, const char *dest_path, int app_pid, gboolean is_native)
 {
+       BT_DBG("+");
        if (__bt_check_folder_path(dest_path) == FALSE)
                return BLUETOOTH_ERROR_INVALID_PARAM;
 
@@ -753,7 +804,7 @@ int _bt_obex_server_allocate(char *sender, const char *dest_path, int app_pid, g
                agent_info.server_type = BT_CUSTOM_SERVER;
                _bt_register_osp_server_in_agent(BT_OBEX_SERVER, NULL, NULL, -1);
        }
-
+       BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
 
@@ -820,9 +871,8 @@ int _bt_obex_server_accept_authorize(const char *filename, gboolean is_native)
        else
                snprintf(file_path, sizeof(file_path), "%s", filename);
 
-       dbus_g_method_return(agent_info.auth_info->reply_context,
-                               file_path);
-
+       g_dbus_method_invocation_return_value(agent_info.auth_info->reply_context,
+               g_variant_new("(s)",&file_path));
        agent_info.auth_info->reply_context = NULL;
        agent_info.auth_info->file_path = g_strdup(file_path);
 
@@ -840,8 +890,8 @@ int _bt_obex_server_reject_authorize(void)
                        BT_OBEX_AGENT_ERROR_CANCEL,
                        "CancelledByUser");
 
-       dbus_g_method_return_error(agent_info.auth_info->reply_context,
-                               g_error);
+       g_dbus_method_invocation_return_gerror(agent_info.auth_info->reply_context,
+                       g_error);
        g_error_free(g_error);
 
        __bt_free_auth_info(agent_info.auth_info);
@@ -885,7 +935,8 @@ int _bt_obex_server_set_destination_path(const char *dest_path,
 int _bt_obex_server_set_root(const char *root)
 {
        GError *g_error = NULL;
-       GValue folder = { 0 };
+       GVariant *folder = NULL;
+       char *string = "Root";
        DIR *dp = NULL;
 
        BT_CHECK_PARAMETER(root, return);
@@ -902,14 +953,12 @@ int _bt_obex_server_set_root(const char *root)
 
        closedir(dp);
 
-       g_value_init(&folder, G_TYPE_STRING);
-       g_value_set_string(&folder, root);
-
-       dbus_g_proxy_call(agent_info.proxy, "SetProperty",
-                       &g_error, G_TYPE_STRING, "Root",
-                       G_TYPE_VALUE, &folder, G_TYPE_INVALID, G_TYPE_INVALID);
-
-       g_value_unset(&folder);
+       folder = g_variant_new_string(root);
+       g_dbus_proxy_call_sync(agent_info.proxy, "SetProperty",
+                       g_variant_new("(sv)", string, folder),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       DBUS_TIMEOUT, NULL,
+                       &g_error);
 
        if (g_error) {
                BT_ERR("SetProperty Fail: %s", g_error->message);
@@ -923,17 +972,23 @@ int _bt_obex_server_set_root(const char *root)
 int _bt_obex_server_cancel_transfer(int transfer_id)
 {
        bt_transfer_info_t *transfer = NULL;
-       DBusGProxy *proxy;
-
+       GDBusProxy *proxy;
+       GError *err = NULL;
+       BT_DBG("+");
        transfer = __bt_find_transfer_by_id(transfer_id);
-       retv_if(transfer == NULL, BLUETOOTH_ERROR_NOT_FOUND);
 
+       retv_if(transfer == NULL, BLUETOOTH_ERROR_NOT_FOUND);
        proxy = __bt_get_transfer_proxy(transfer->path);
 
        retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       dbus_g_proxy_call_no_reply(proxy, "Cancel", G_TYPE_INVALID, G_TYPE_INVALID);
-
+       g_dbus_proxy_call_sync(proxy, "Cancel", NULL,
+               G_DBUS_CALL_FLAGS_NONE,
+               DBUS_TIMEOUT, NULL, &err);
+       if (err) {
+               BT_ERR("Dbus Err: %s", err->message);
+               g_clear_error(&err);
+       }
        g_object_unref(proxy);
 
        return BLUETOOTH_ERROR_NONE;
@@ -1019,8 +1074,7 @@ int _bt_obex_server_is_receiving(gboolean *receiving)
 gboolean __bt_obex_server_accept_timeout_cb(gpointer user_data)
 {
        request_info_t *req_info;
-       GArray *out_param1;
-       GArray *out_param2;
+       GVariant *out_param1 = NULL;
        int result = BLUETOOTH_ERROR_TIMEOUT;
 
        /* Already reply in _bt_obex_transfer_started */
@@ -1033,17 +1087,17 @@ gboolean __bt_obex_server_accept_timeout_cb(gpointer user_data)
        }
 
        agent_info.accept_id = 0;
+       GArray *g_out_param1 = NULL;
+       g_out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
+       if (out_param1 == NULL) {
+               out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+                               g_out_param1->data, g_out_param1->len,
+                               TRUE, NULL, NULL);
+       }
 
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-       g_array_append_vals(out_param2, &result, sizeof(int));
-
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
-
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
-
+       g_dbus_method_invocation_return_value(req_info->context,
+                       g_variant_new("(iv)", result, out_param1));
+       g_array_free(g_out_param1, TRUE);
        _bt_delete_request_list(req_info->req_id);
 
        return FALSE;
index d436b5d..b9e9d11 100644 (file)
  *
  */
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
 #include <glib.h>
 #include <dlog.h>
 #include <string.h>
+#include <gio/gio.h>
 
 #include "bluetooth-api.h"
 #include "bt-service-common.h"
 
 int _bt_oob_read_local_data(bt_oob_data_t *local_oob_data)
 {
-       DBusMessage *msg;
-       DBusMessage *reply;
-       DBusError err;
+       GDBusProxy *proxy;
+       GVariant *reply;
+       GError *err = NULL;
        char *adapter_path;
        unsigned char *local_hash = NULL;
        unsigned char *local_randomizer = NULL;
-       DBusConnection *conn;
+       GDBusConnection *conn;
+       GVariant *hash = NULL;
+       GVariant *randomizer = NULL;
 
        BT_CHECK_PARAMETER(local_oob_data, return);
 
@@ -50,46 +51,67 @@ int _bt_oob_read_local_data(bt_oob_data_t *local_oob_data)
        adapter_path = _bt_get_adapter_path();
        retv_if(adapter_path == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       msg = dbus_message_new_method_call(BT_BLUEZ_NAME, adapter_path,
-                                       BT_OOB_INTERFACE, "ReadLocalData");
 
+       proxy =  g_dbus_proxy_new_sync(conn,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       BT_BLUEZ_NAME, adapter_path,
+                       BT_OOB_INTERFACE, NULL, &err);
        g_free(adapter_path);
+       if (!proxy) {
+               BT_ERR("Unable to create proxy");
+               if (err) {
+                       BT_ERR("Error: %s", err->message);
+                       g_clear_error(&err);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
 
-       retv_if(msg == NULL, BLUETOOTH_ERROR_INTERNAL);
+       reply = g_dbus_proxy_call_sync(proxy, "ReadLocalData",
+                       NULL,
+                       G_DBUS_CALL_FLAGS_NONE, -1,
+                       NULL, &err);
+       g_object_unref(proxy);
+
+       if (reply == NULL) {
+               BT_ERR("ReadLocalData dBUS-RPC is failed");
+               if (err != NULL) {
+                       BT_ERR("D-Bus API failure: errCode[%x], message[%s]",
+                                       err->code, err->message);
+                       g_clear_error(&err);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
 
-       dbus_error_init(&err);
-       reply = dbus_connection_send_with_reply_and_block(conn,
-                                       msg, -1, &err);
+       g_variant_get(reply ,"@ay@ay", &hash, &randomizer);
+       g_variant_unref(reply);
 
-       dbus_message_unref(msg);
-       if (!reply) {
-               BT_ERR("Error in ReadLocalData \n");
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("%s", err.message);
-                       dbus_error_free(&err);
-               }
+       if(hash != NULL){
+               local_oob_data->hash_len = (unsigned int)g_variant_get_size(hash);
+               local_hash = (unsigned char *)g_variant_get_data(hash);
+       } else {
+               BT_ERR("hash is NULL");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       if (!dbus_message_get_args(reply, NULL,
-                       DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                       &local_hash, &local_oob_data->hash_len,
-                       DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-                       &local_randomizer, &local_oob_data->randomizer_len,
-                       DBUS_TYPE_INVALID)) {
-               BT_ERR("Error in reading arguments\n");
-               dbus_message_unref(reply);
-               return BLUETOOTH_ERROR_INVALID_DATA;
+       g_variant_unref(hash);
+
+       if(randomizer != NULL){
+               local_oob_data->randomizer_len = (unsigned int)g_variant_get_size(randomizer);
+               local_randomizer = (unsigned char *)g_variant_get_data(randomizer);
+       } else {
+               BT_ERR("randomizer is NULL");
+               return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       if (NULL != local_hash)
+       g_variant_unref(randomizer);
+
+       if (local_oob_data->hash_len > 0)
                memcpy(local_oob_data->hash, local_hash, local_oob_data->hash_len);
 
-       if (NULL != local_randomizer)
+       if (local_oob_data->randomizer_len > 0)
                memcpy(local_oob_data->randomizer, local_randomizer,
-                                       local_oob_data->randomizer_len);
+                               local_oob_data->randomizer_len);
 
-       dbus_message_unref(reply);
 
        return BLUETOOTH_ERROR_NONE;
 }
@@ -98,15 +120,19 @@ int _bt_oob_add_remote_data(
                        bluetooth_device_address_t *remote_device_address,
                        bt_oob_data_t *remote_oob_data)
 {
-       DBusMessage *msg;
-       DBusMessage *reply;
-       DBusError err;
+       GDBusProxy *proxy;
+       GVariant *reply;
+       GError *err = NULL;
        char *dev_addr;
        char *adapter_path;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        unsigned char *remote_hash;
        unsigned char *remote_randomizer;
-       DBusConnection *conn;
+       GDBusConnection *conn;
+       GArray *in_param1 = NULL;
+       GArray *in_param2 = NULL;
+       GVariant *hash;
+       GVariant *randomizer;
 
        BT_CHECK_PARAMETER(remote_device_address, return);
        BT_CHECK_PARAMETER(remote_oob_data, return);
@@ -120,60 +146,79 @@ int _bt_oob_add_remote_data(
        _bt_convert_addr_type_to_string(address,
                remote_device_address->addr);
 
-       msg = dbus_message_new_method_call(BT_BLUEZ_NAME, adapter_path,
-                               BT_OOB_INTERFACE, "AddRemoteData");
-
+       proxy =  g_dbus_proxy_new_sync(conn,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       BT_BLUEZ_NAME, adapter_path,
+                       BT_OOB_INTERFACE, NULL, &err);
        g_free(adapter_path);
-
-       retv_if(msg == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       BT_DBG("remote hash len = [%d] and remote random len = [%d]\n",
-               remote_oob_data->hash_len, remote_oob_data->randomizer_len);
+       if (!proxy) {
+               BT_ERR("Unable to create proxy");
+               if (err) {
+                       BT_ERR("Error: %s", err->message);
+                       g_clear_error(&err);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
 
        remote_hash = remote_oob_data->hash;
        remote_randomizer = remote_oob_data->randomizer;
-
        dev_addr = g_strdup(address);
 
-       dbus_message_append_args(msg,
-               DBUS_TYPE_STRING, &dev_addr,
-               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-               &remote_hash, remote_oob_data->hash_len,
-               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-               &remote_randomizer, remote_oob_data->randomizer_len,
-               DBUS_TYPE_INVALID);
-
-       dbus_error_init(&err);
-       reply = dbus_connection_send_with_reply_and_block(conn,
-                                       msg, -1, &err);
-
-       dbus_message_unref(msg);
-       if (!reply) {
-               BT_ERR("Error in AddRemoteData \n");
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("%s", err.message);
-                       dbus_error_free(&err);
-                       g_free(dev_addr);
-                       return BLUETOOTH_ERROR_INTERNAL;
+       BT_DBG("remote hash len = [%d] and remote random len = [%d]\n",
+               remote_oob_data->hash_len, remote_oob_data->randomizer_len);
+       /*Create array of bytes variant*/
+       in_param1 = g_array_new(TRUE, TRUE, sizeof(gchar));
+       in_param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+       g_array_append_vals(in_param1, remote_hash,
+                       remote_oob_data->hash_len);
+       g_array_append_vals(in_param2, remote_randomizer,
+                       remote_oob_data->randomizer_len);
+
+       hash = g_variant_new_from_data((const GVariantType *)"ay",
+                       in_param1->data, in_param1->len,
+                       TRUE, NULL, NULL);
+
+       randomizer = g_variant_new_from_data((const GVariantType *)"ay",
+                       in_param2->data, in_param2->len,
+                       TRUE, NULL, NULL);
+
+       g_array_free(in_param1, TRUE);
+       g_array_free(in_param2, TRUE);
+
+       /* Call AddRemoteData Method*/
+       reply = g_dbus_proxy_call_sync(proxy, "AddRemoteData",
+                       g_variant_new("s@ay@ay", dev_addr, hash, randomizer),
+                       G_DBUS_CALL_FLAGS_NONE, -1,
+                       NULL, &err);
+       g_object_unref(proxy);
+       g_free(dev_addr);
+
+       /* Check the reply*/
+       if (reply == NULL) {
+               BT_ERR("AddRemoteData dBUS-RPC is failed");
+               if (err != NULL) {
+                       BT_ERR("D-Bus API failure: errCode[%x], message[%s]",
+                                       err->code, err->message);
+                       g_clear_error(&err);
                }
+               return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       g_free(dev_addr);
-       dbus_message_unref(reply);
-
+       g_variant_unref(reply);
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_oob_remove_remote_data(
                        bluetooth_device_address_t *remote_device_address)
 {
-       DBusMessage *msg;
-       DBusMessage *reply;
-       DBusError err;
+       GDBusProxy *proxy;
+       GVariant *reply;
+       GError *err = NULL;
        char *dev_addr;
        char *adapter_path;
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-       DBusConnection *conn;
+       GDBusConnection *conn;
 
        BT_CHECK_PARAMETER(remote_device_address, return);
 
@@ -186,36 +231,42 @@ int _bt_oob_remove_remote_data(
        _bt_convert_addr_type_to_string(address,
                remote_device_address->addr);
 
-       msg = dbus_message_new_method_call(BT_BLUEZ_NAME, adapter_path,
-                               BT_OOB_INTERFACE, "RemoveRemoteData");
-
+       proxy =  g_dbus_proxy_new_sync(conn,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       BT_BLUEZ_NAME, adapter_path,
+                       BT_OOB_INTERFACE, NULL, &err);
        g_free(adapter_path);
-
-       retv_if(msg == NULL, BLUETOOTH_ERROR_INTERNAL);
+       if (!proxy) {
+               BT_ERR("Unable to create proxy");
+               if (err) {
+                       BT_ERR("Error: %s", err->message);
+                       g_clear_error(&err);
+               }
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
 
        dev_addr = g_strdup(address);
 
-       dbus_message_append_args(msg, DBUS_TYPE_STRING,
-               &dev_addr, DBUS_TYPE_INVALID);
-
-       dbus_error_init(&err);
-       reply = dbus_connection_send_with_reply_and_block(conn,
-                                       msg, -1, &err);
-
-       dbus_message_unref(msg);
-       if (!reply) {
-               BT_ERR("Error in RemoveRemoteData \n");
-               if (dbus_error_is_set(&err)) {
-                       BT_ERR("%s", err.message);
-                       dbus_error_free(&err);
-                       g_free(dev_addr);
-                       return BLUETOOTH_ERROR_INTERNAL;
+       /* Call RemoveRemoteData Method*/
+       reply = g_dbus_proxy_call_sync(proxy, "RemoveRemoteData",
+                       g_variant_new("s", dev_addr),
+                       G_DBUS_CALL_FLAGS_NONE, -1,
+                       NULL, &err);
+       g_object_unref(proxy);
+       g_free(dev_addr);
+
+       /* Check the reply*/
+       if (reply == NULL) {
+               BT_ERR("RemoveRemoteData dBUS-RPC is failed");
+               if (err != NULL) {
+                       BT_ERR("D-Bus API failure: errCode[%x], message[%s]",
+                                       err->code, err->message);
+                       g_clear_error(&err);
                }
+               return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       g_free(dev_addr);
-       dbus_message_unref(reply);
-
+       g_variant_unref(reply);
        return BLUETOOTH_ERROR_NONE;
 }
 
index 2adf5e6..74b1829 100644 (file)
  *
  */
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
 #include <glib.h>
 #include <dlog.h>
 #include <string.h>
 #include <mime_type.h>
 
+#include <glib.h>
+#include <gio/gio.h>
+
 #include "bluetooth-api.h"
 #include "bt-internal-types.h"
 
 #include "bt-service-obex-agent.h"
 
 static GSList *transfer_list = NULL;
-
 bt_sending_info_t *sending_info;
 static int file_offset = 0;
 
+#define DBUS_TIEMOUT 20 * 1000  /* 20 Seconds */
 static gboolean __bt_sending_release();
 static void _bt_remove_session();
 
@@ -86,29 +87,22 @@ static void __bt_free_sending_info(bt_sending_info_t *info)
        g_free(info);
 }
 
-static void __bt_value_free(GValue *value)
-{
-       g_value_unset(value);
-       g_free(value);
-}
-
 static gboolean __bt_cancel_push_cb(gpointer data)
 {
        BT_DBG("+");
 
        int result = BLUETOOTH_ERROR_CANCEL_BY_USER;
-
+       GVariant *param = NULL;
        retv_if(sending_info == NULL, FALSE);
        sending_info->result = result;
 
+       param = g_variant_new("(isi)", result,
+                               sending_info->address,
+                               sending_info->request_id);
        /* Send the event in only error none case */
        _bt_send_event(BT_OPP_CLIENT_EVENT,
                        BLUETOOTH_EVENT_OPC_CONNECTED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &sending_info->address,
-                       DBUS_TYPE_INT32, &sending_info->request_id,
-                       DBUS_TYPE_INVALID);
-
+                       param);
        __bt_free_sending_info(sending_info);
        sending_info = NULL;
 
@@ -145,7 +139,7 @@ gboolean _bt_obex_client_progress(const char *transfer_path, int transferred)
        int percentage_progress;
        gint64 size;
        int result = BLUETOOTH_ERROR_NONE;
-
+       GVariant *param = NULL;
        retv_if(sending_info == NULL, TRUE);
        retv_if(sending_info->transfer_info == NULL, TRUE);
 
@@ -167,15 +161,14 @@ gboolean _bt_obex_client_progress(const char *transfer_path, int transferred)
        sending_info->result = result;
 
        /* Send the event in only error none case */
+       param = g_variant_new("(istii)", result,
+                               sending_info->transfer_info->file_name,
+                               sending_info->transfer_info->size,
+                               percentage_progress,
+                               sending_info->request_id);
        _bt_send_event(BT_OPP_CLIENT_EVENT,
                        BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &sending_info->transfer_info->file_name,
-                       DBUS_TYPE_UINT64, &sending_info->transfer_info->size,
-                       DBUS_TYPE_INT32, &percentage_progress,
-                       DBUS_TYPE_INT32, &sending_info->request_id,
-                       DBUS_TYPE_INVALID);
-
+                       param);
        BT_DBG("-");
 
        return TRUE;
@@ -186,7 +179,7 @@ gboolean _bt_obex_client_completed(const char *transfer_path, gboolean success)
        BT_DBG("+");
 
        int result = BLUETOOTH_ERROR_NONE;
-
+       GVariant *param = NULL;
        retv_if(sending_info == NULL, TRUE);
        retv_if(sending_info->transfer_info == NULL, TRUE);
 
@@ -196,8 +189,7 @@ gboolean _bt_obex_client_completed(const char *transfer_path, gboolean success)
                return FALSE;
        }
 
-       result = (success == TRUE) ? BLUETOOTH_ERROR_NONE
-                               : BLUETOOTH_ERROR_CANCEL;
+       result = (success == TRUE) ? BLUETOOTH_ERROR_NONE : BLUETOOTH_ERROR_CANCEL;
 
        sending_info->transfer_info->transfer_status = BT_TRANSFER_STATUS_COMPLETED;
        sending_info->result = result;
@@ -205,27 +197,24 @@ gboolean _bt_obex_client_completed(const char *transfer_path, gboolean success)
        if (!success) { /*In case of remote device reject, we need to send BLUETOOTH_EVENT_OPC_DISCONNECTED */
                BT_DBG("completed with error");
                if (!sending_info->is_canceled) {
+                       param = g_variant_new("(isti)", result,
+                                               sending_info->transfer_info->file_name,
+                                               sending_info->transfer_info->size,
+                                               sending_info->request_id);
                        _bt_send_event(BT_OPP_CLIENT_EVENT,
                                        BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &sending_info->transfer_info->file_name,
-                                       DBUS_TYPE_UINT64, &sending_info->transfer_info->size,
-                                       DBUS_TYPE_INT32, &sending_info->request_id,
-                                       DBUS_TYPE_INVALID);
-
+                                       param);
                   __bt_free_transfer_info(sending_info->transfer_info);
                   sending_info->transfer_info = NULL;
                   /* Reset the file offset as we will cancelled remaining files also */
                   file_offset = 0;
                }
-
+               param = g_variant_new("(isi)", sending_info->result,
+                                       sending_info->address,
+                                       sending_info->request_id);
                _bt_send_event(BT_OPP_CLIENT_EVENT,
                                BLUETOOTH_EVENT_OPC_DISCONNECTED,
-                               DBUS_TYPE_INT32, &sending_info->result,
-                               DBUS_TYPE_STRING, &sending_info->address,
-                               DBUS_TYPE_INT32, &sending_info->request_id,
-                               DBUS_TYPE_INVALID);
-
+                               param);
                __bt_sending_release();
                /* Sending info should not freed after sending_release it's
                 * already freed in that API and if any pending request is
@@ -236,14 +225,13 @@ gboolean _bt_obex_client_completed(const char *transfer_path, gboolean success)
        } else {
                BT_DBG("complete success");
                /* Send the event in only error none case */
+               param = g_variant_new("(isti)", result,
+                                       sending_info->transfer_info->file_name,
+                                       sending_info->transfer_info->size,
+                                       sending_info->request_id);
                _bt_send_event(BT_OPP_CLIENT_EVENT,
                                BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &sending_info->transfer_info->file_name,
-                               DBUS_TYPE_UINT64, &sending_info->transfer_info->size,
-                               DBUS_TYPE_INT32, &sending_info->request_id,
-                               DBUS_TYPE_INVALID);
-
+                               param);
           __bt_free_transfer_info(sending_info->transfer_info);
           sending_info->transfer_info = NULL;
        }
@@ -255,15 +243,14 @@ gboolean _bt_obex_client_completed(const char *transfer_path, gboolean success)
 
 gboolean _bt_obex_client_started(const char *transfer_path)
 {
-       GValue *value;
-       const char *transfer_name;
-       const char *file_name;
-       int size;
+       BT_DBG("+");
+
        int result = BLUETOOTH_ERROR_NONE;
-       GHashTable *hash = NULL;
-       GError *error;
-       DBusGConnection *g_conn;
-       DBusGProxy *transfer_proxy;
+       GError *error = NULL;
+       GVariant *param = NULL;
+       GDBusConnection *g_conn;
+       GDBusProxy *properties_proxy;
+       GDBusProxy *transfer_proxy;
 
        if (sending_info == NULL || sending_info->is_canceled == TRUE) {
                result = BLUETOOTH_ERROR_CANCEL_BY_USER;
@@ -272,53 +259,36 @@ gboolean _bt_obex_client_started(const char *transfer_path)
 
        /* Get the session bus. */
        g_conn = _bt_get_session_gconn();
-       retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+       retv_if(g_conn == NULL, FALSE);
+       properties_proxy = g_dbus_proxy_new_sync(g_conn, G_DBUS_PROXY_FLAGS_NONE,
+                                               NULL,BT_OBEXD_DBUS_NAME,
+                                               transfer_path, BT_PROPERTIES_INTERFACE,
+                                               NULL, &error);
 
-       __bt_free_transfer_info(sending_info->transfer_info);
+       retv_if(properties_proxy == NULL, FALSE);
 
-       sending_info->transfer_info = g_malloc0(sizeof(bt_transfer_info_t));
+       sending_info->transfer_info->properties_proxy = properties_proxy;
 
-       transfer_proxy = dbus_g_proxy_new_for_name(g_conn, BT_OBEXD_DBUS_NAME,
-                               transfer_path, BT_PROPERTIES_INTERFACE);
+       transfer_proxy = g_dbus_proxy_new_sync(g_conn, G_DBUS_PROXY_FLAGS_NONE,
+                                               NULL, BT_OBEXD_DBUS_NAME,
+                                               transfer_path, BT_OBEX_TRANSFER_INTERFACE,
+                                               NULL, &error);
 
        retv_if(transfer_proxy == NULL, FALSE);
 
        sending_info->transfer_info->proxy = transfer_proxy;
 
-       if (!dbus_g_proxy_call(transfer_proxy, "GetAll", NULL,
-                               G_TYPE_STRING, BT_OBEX_TRANSFER_INTERFACE,
-                               G_TYPE_INVALID,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
-                               G_TYPE_VALUE), &hash, G_TYPE_INVALID))
-               goto fail;
-
-       if (hash == NULL)
-               goto fail;
-
-       value = g_hash_table_lookup(hash, "Name");
-       transfer_name = value ? g_value_get_string(value) : NULL;
-
-       value = g_hash_table_lookup(hash, "Filename");
-       file_name = value ? g_value_get_string(value) : NULL;
-
-       value = g_hash_table_lookup(hash, "Size");
-       size = value ? g_value_get_uint64(value) : 0;
-
-       sending_info->transfer_info->transfer_name = g_strdup(transfer_name);
-       sending_info->transfer_info->file_name = g_strdup(file_name);
-       sending_info->transfer_info->size = size;
-       sending_info->result = BLUETOOTH_ERROR_NONE;
-
-       g_hash_table_destroy(hash);
-
+       sending_info->transfer_info->transfer_status = BT_TRANSFER_STATUS_STARTED;
+       sending_info->result = result;
+       param = g_variant_new("(isti)", result,
+                               sending_info->transfer_info->file_name,
+                               sending_info->transfer_info->size,
+                               sending_info->request_id);
        _bt_send_event(BT_OPP_CLIENT_EVENT,
                        BLUETOOTH_EVENT_OPC_TRANSFER_STARTED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &sending_info->transfer_info->file_name,
-                       DBUS_TYPE_UINT64, &sending_info->transfer_info->size,
-                       DBUS_TYPE_INT32, &sending_info->request_id,
-                       DBUS_TYPE_INVALID);
+                       param);
 
+       BT_DBG("-");
        return TRUE;
 canceled:
        error = g_error_new(__bt_opc_error_quark(), BT_OBEX_AGENT_ERROR_CANCEL,
@@ -326,24 +296,8 @@ canceled:
 
        g_error_free(error);
 
+       BT_DBG("-");
        return FALSE;
-fail:
-       result = BLUETOOTH_ERROR_INTERNAL;
-
-       /* Send the event in only error none case */
-       _bt_send_event(BT_OPP_CLIENT_EVENT,
-                       BLUETOOTH_EVENT_OPC_DISCONNECTED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &sending_info->address,
-                       DBUS_TYPE_INT32, &sending_info->request_id,
-                       DBUS_TYPE_INVALID);
-
-       __bt_free_sending_info(sending_info);
-       sending_info = NULL;
-
-       _bt_opp_client_event_deinit();
-
-       return TRUE;
 }
 
 static void __bt_free_sending_data(gpointer data)
@@ -364,19 +318,20 @@ static void __bt_free_sending_data(gpointer data)
        g_free(info);
 }
 
-
-
-static void __bt_sending_release_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                                       void *user_data)
+static void __bt_sending_release_cb(GDBusProxy *proxy,
+                               GAsyncResult *res, gpointer user_data)
 {
        BT_DBG("+");
        ret_if(sending_info == NULL);
 
        GError *error = NULL;
        int result = BLUETOOTH_ERROR_NONE;
+       GVariant *param = NULL;
+       g_dbus_proxy_call_finish(proxy, res, &error);
+       if (proxy)
+               g_object_unref(proxy);
 
-       if (dbus_g_proxy_end_call(proxy, call, &error,
-                                               G_TYPE_INVALID) == FALSE) {
+       if (error) {
                BT_ERR("%s", error->message);
                g_error_free(error);
 
@@ -387,13 +342,13 @@ static void __bt_sending_release_cb(DBusGProxy *proxy, DBusGProxyCall *call,
        }
 
        sending_info->result = result;
+       param = g_variant_new("(isi)", sending_info->result,
+                               sending_info->address,
+                               sending_info->request_id);
        /* Send the event in only error none case */
        _bt_send_event(BT_OPP_CLIENT_EVENT,
                        BLUETOOTH_EVENT_OPC_DISCONNECTED,
-                       DBUS_TYPE_INT32, &sending_info->result,
-                       DBUS_TYPE_STRING, &sending_info->address,
-                       DBUS_TYPE_INT32, &sending_info->request_id,
-                       DBUS_TYPE_INVALID);
+                       param);
 
        __bt_free_sending_info(sending_info);
        sending_info = NULL;
@@ -432,27 +387,28 @@ fail:
 
 static void _bt_remove_session()
 {
-       DBusGConnection *g_conn;
-       DBusGProxy *session_proxy;
-       DBusGProxyCall *proxy_call;
+       GDBusConnection *g_conn;
+       GDBusProxy *session_proxy;
+       GError *err = NULL;
 
        g_conn = _bt_get_session_gconn();
        ret_if(g_conn == NULL);
+       ret_if(sending_info->session_path == NULL);
 
-       session_proxy =  dbus_g_proxy_new_for_name(g_conn, BT_OBEXD_DBUS_NAME,
+       session_proxy = g_dbus_proxy_new_sync(g_conn, G_DBUS_PROXY_FLAGS_NONE,
+                                               NULL, BT_OBEXD_DBUS_NAME,
                                                BT_OBEX_CLIENT_PATH,
-                                               BT_OBEX_CLIENT_INTERFACE);
+                                               BT_OBEX_CLIENT_INTERFACE,
+                                               NULL, &err);
 
        ret_if(session_proxy == NULL);
 
-       proxy_call = dbus_g_proxy_begin_call(session_proxy, "RemoveSession",
-               __bt_sending_release_cb, NULL, NULL,
-               DBUS_TYPE_G_OBJECT_PATH, sending_info->session_path,
-               G_TYPE_INVALID);
-       if (proxy_call == NULL) {
-               BT_ERR("Fail to Remove session");
-               g_object_unref(session_proxy);
-       }
+       g_dbus_proxy_call(session_proxy, "RemoveSession",
+               g_variant_new("(o)", sending_info->session_path),
+               G_DBUS_CALL_FLAGS_NONE,
+               DBUS_TIEMOUT, NULL,
+               (GAsyncReadyCallback)__bt_sending_release_cb,
+               NULL);
 
 }
 
@@ -470,7 +426,7 @@ static gboolean __bt_sending_release()
 void _bt_opc_disconnected(const char *session_path)
 {
        BT_DBG("+");
-
+       GVariant *param = NULL;
        ret_if(sending_info == NULL);
 
        if (g_strcmp0(sending_info->session_path,
@@ -480,29 +436,25 @@ void _bt_opc_disconnected(const char *session_path)
        }
 
        if (sending_info->transfer_info) {
-               BT_INFO("sending_info is not NULL");
                if (sending_info->transfer_info->transfer_status == BT_TRANSFER_STATUS_PROGRESS ||
                                sending_info->transfer_info->transfer_status == BT_TRANSFER_STATUS_STARTED) {
                        BT_INFO("Abnormal termination");
-
+                       param = g_variant_new("(isti)", sending_info->result,
+                                               sending_info->transfer_info->file_name,
+                                               sending_info->transfer_info->size,
+                                               sending_info->request_id);
                        _bt_send_event(BT_OPP_CLIENT_EVENT,
                                        BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE,
-                                       DBUS_TYPE_INT32, &sending_info->result,
-                                       DBUS_TYPE_STRING, &sending_info->transfer_info->file_name,
-                                       DBUS_TYPE_UINT64, &sending_info->transfer_info->size,
-                                       DBUS_TYPE_INT32, &sending_info->request_id,
-                                       DBUS_TYPE_INVALID);
+                                       param);
                        __bt_free_transfer_info(sending_info->transfer_info);
                }
        }
-
+       param = g_variant_new("(isi)", sending_info->result,
+                               sending_info->address,
+                               sending_info->request_id);
        _bt_send_event(BT_OPP_CLIENT_EVENT,
                        BLUETOOTH_EVENT_OPC_DISCONNECTED,
-                       DBUS_TYPE_INT32, &sending_info->result,
-                       DBUS_TYPE_STRING, &sending_info->address,
-                       DBUS_TYPE_INT32, &sending_info->request_id,
-                       DBUS_TYPE_INVALID);
-
+                       param);
 
        __bt_free_sending_info(sending_info);
        sending_info = NULL;
@@ -510,87 +462,107 @@ void _bt_opc_disconnected(const char *session_path)
        BT_DBG("-");
 }
 
+static void __bt_send_file_cb(GDBusProxy *proxy,
+                               GAsyncResult *res, gpointer user_data)
+{
+       BT_DBG("+");
+       GVariant *value = NULL;
+       GError *error = NULL;
+       char *session_path = NULL;
+       const char *transfer_name = NULL;
+       const char *file_name = NULL;
+       int size = 0;
+       GVariantIter *iter;
+       value = g_dbus_proxy_call_finish(proxy, res, &error);
+       if (error) {
+               BT_ERR("%s", error->message);
+               g_error_free(error);
+               if (proxy)
+                       g_object_unref(proxy);
+               return;
+       }
+       if (proxy)
+               g_object_unref(proxy);
+
+       if (value) {
+               g_variant_get(value, "(oa{sv})", &session_path, &iter);
+               g_variant_unref(value);
+       }
+
+       __bt_free_transfer_info(sending_info->transfer_info);
+
+       sending_info->transfer_info = g_malloc0(sizeof(bt_transfer_info_t));
+
+       if (iter) {
+               const gchar *key;
+               GVariant *val;
+               gsize len = 0;
+               while (g_variant_iter_loop(iter, "{sv}", &key, &val)) {
+                       if (g_strcmp0(key, "Name") == 0) {
+                               transfer_name = g_variant_dup_string(val,&len);
+                       } else if (g_strcmp0(key, "Filename") == 0) {
+                               file_name = g_variant_dup_string(val, &len);
+                       } else if (g_strcmp0(key, "Size") == 0) {
+                               size = g_variant_get_uint64(val);
+                       }
+               }
+               g_variant_iter_free(iter);
+       }
+
+       sending_info->transfer_info->transfer_name = g_strdup(transfer_name);
+       sending_info->transfer_info->file_name = g_strdup(file_name);
+       sending_info->transfer_info->size = size;
+       sending_info->transfer_info->transfer_path = session_path;
+       sending_info->transfer_info->transfer_status = BT_TRANSFER_STATUS_QUEUED;
+       sending_info->result = BLUETOOTH_ERROR_NONE;
+       file_offset++;
+
+}
+
 void _bt_sending_files(void)
 {
        BT_DBG("+");
 
-       DBusGConnection *g_conn;
-       DBusGProxy *client_proxy;
        GError *err = NULL;
-       char *path = NULL;
-       GHashTable *hash = NULL;
-       GValue *value = NULL;
-       const char *transfer_name;
-       const char *file_name;
-       int size;
+       GDBusConnection *g_conn;
+       GDBusProxy *client_proxy;
        char *mimetype = NULL;
        char *ext = NULL;
 
-
        if (sending_info == NULL)
                return;
-
        if (file_offset < sending_info->file_count){
                /* Get the session bus. */
                g_conn = _bt_get_session_gconn();
                ret_if(g_conn == NULL);
 
-               client_proxy =  dbus_g_proxy_new_for_name(g_conn,
-                                               BT_OBEXD_DBUS_NAME,
+               client_proxy = g_dbus_proxy_new_sync(g_conn, G_DBUS_PROXY_FLAGS_NONE,
+                                               NULL, BT_OBEXD_DBUS_NAME,
                                                sending_info->session_path,
-                                               BT_OBEX_OBJECT_PUSH_INTERFACE);
-
+                                               BT_OBEX_OBJECT_PUSH_INTERFACE,
+                                               NULL, &err);
                ret_if(client_proxy == NULL);
 
                BT_DBG("Calling SendFile");
                ext = strrchr(sending_info->file_name_array[file_offset], '.');
 
-               if(!strcmp(ext+1, "imy"))
+               if (ext != NULL && (!strcmp(ext, ".imy")))
                        mimetype = g_strdup("audio/imelody");
-
-               if (!dbus_g_proxy_call(client_proxy, "SendFile", &err,
-                               G_TYPE_STRING,
-                               sending_info->file_name_array[file_offset],
-                               G_TYPE_STRING, mimetype,
-                               G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, &path,
-                               dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                               &hash, G_TYPE_INVALID)) {
-                       if (err != NULL) {
-                               BT_ERR("Calling SendFile failed: [%s]\n", err->message);
-                               g_error_free(err);
-                       }
+               g_dbus_proxy_call(client_proxy, "SendFile",
+                               g_variant_new("(ss)", sending_info->file_name_array[file_offset],
+                                                               mimetype),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               DBUS_TIEMOUT, NULL,
+                               (GAsyncReadyCallback)__bt_send_file_cb,
+                               sending_info);
+               if (err != NULL) {
+                       BT_ERR("Calling SendFile failed: [%s]\n", err->message);
+                       g_clear_error(&err);
                        g_free(mimetype);
                        return;
                }
 
                g_free(mimetype);
-
-               if (hash == NULL)
-                       return;
-
-               __bt_free_transfer_info(sending_info->transfer_info);
-
-               sending_info->transfer_info = g_malloc0(sizeof(bt_transfer_info_t));
-
-               value = g_hash_table_lookup(hash, "Name");
-               transfer_name = value ? g_value_get_string(value) : NULL;
-
-               value = g_hash_table_lookup(hash, "Filename");
-               file_name = value ? g_value_get_string(value) : NULL;
-
-               value = g_hash_table_lookup(hash, "Size");
-               size = value ? g_value_get_uint64(value) : 0;
-
-               sending_info->transfer_info->transfer_name = g_strdup(transfer_name);
-               sending_info->transfer_info->file_name = g_strdup(file_name);
-               sending_info->transfer_info->size = size;
-               sending_info->transfer_info->transfer_path = path;
-               sending_info->transfer_info->transfer_status = BT_TRANSFER_STATUS_QUEUED;
-               sending_info->result = BLUETOOTH_ERROR_NONE;
-
-               g_hash_table_destroy(hash);
-
-               file_offset++;
        }else{
                file_offset = 0;
                __bt_sending_release();
@@ -599,41 +571,47 @@ void _bt_sending_files(void)
        BT_DBG("-");
 }
 
-static void __bt_create_session_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                                       void *user_data)
+static void __bt_create_session_cb(GDBusProxy *proxy,
+                               GAsyncResult *res, gpointer user_data)
 {
        BT_DBG("+");
 
        GError *error = NULL;
+       GVariant *value;
        int result = BLUETOOTH_ERROR_NONE;
        char *session_path = NULL;
+       GVariant *param = NULL;
+
+       value = g_dbus_proxy_call_finish(proxy, res, &error);
+       if (proxy)
+               g_object_unref(proxy);
 
-       if (dbus_g_proxy_end_call(proxy, call, &error,
-               DBUS_TYPE_G_OBJECT_PATH, &session_path, G_TYPE_INVALID) == FALSE) {
+       if (value) {
+               g_variant_get(value, "(o)", &session_path);
+               g_variant_unref(value);
+       }
+       if (error) {
 
                BT_ERR("%s", error->message);
-               g_error_free(error);
+               g_clear_error(&error);
 
                result = BLUETOOTH_ERROR_INTERNAL;
        }else{
                BT_DBG("Session created");
                if(sending_info != NULL)
                        sending_info->session_path = g_strdup(session_path);
-}
+       }
        g_free(session_path);
-       g_object_unref(proxy);
        ret_if(sending_info == NULL);
 
-       sending_info->sending_proxy = NULL;
        sending_info->result = result;
-
+       param = g_variant_new("(isi)", result,
+                               sending_info->address,
+                               sending_info->request_id);
        /* Send the event in only error none case */
        _bt_send_event(BT_OPP_CLIENT_EVENT,
                        BLUETOOTH_EVENT_OPC_CONNECTED,
-                       DBUS_TYPE_INT32, &result,
-                       DBUS_TYPE_STRING, &sending_info->address,
-                       DBUS_TYPE_INT32, &sending_info->request_id,
-                       DBUS_TYPE_INVALID);
+                       param);
 
        if (result != BLUETOOTH_ERROR_NONE) {
                BT_ERR("Calling __bt_sending_release");
@@ -652,15 +630,12 @@ static void __bt_create_session_cb(DBusGProxy *proxy, DBusGProxyCall *call,
 static int __bt_opp_client_start_sending(int request_id, char *address,
                                        char **file_name_array, int file_count)
 {
-       BT_DBG("+");
-
-       GHashTable *hash;
-       GValue *value;
-       DBusGConnection *g_conn;
-       DBusGProxy *client_proxy;
-       DBusGProxyCall *proxy_call;
-
+       GVariantBuilder *builder;
        int i;
+       GDBusConnection *g_conn;
+       GDBusProxy *client_proxy;
+       GError *error = NULL;
+       BT_DBG("+");
 
        BT_CHECK_PARAMETER(address, return);
        BT_CHECK_PARAMETER(file_name_array, return);
@@ -669,22 +644,24 @@ static int __bt_opp_client_start_sending(int request_id, char *address,
        g_conn = _bt_get_session_gconn();
        retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       client_proxy =  dbus_g_proxy_new_for_name(g_conn, BT_OBEX_SERVICE_NAME,
-                                       BT_OBEX_CLIENT_PATH, BT_OBEX_CLIENT_INTERFACE);
-
-       retv_if(client_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+       client_proxy =  g_dbus_proxy_new_sync(g_conn, G_DBUS_PROXY_FLAGS_NONE,
+                                       NULL, BT_OBEX_SERVICE_NAME,
+                                       BT_OBEX_CLIENT_PATH,
+                                       BT_OBEX_CLIENT_INTERFACE,
+                                       NULL, &error);
 
-       BT_DBG("client_proxy is not NULL");
+       if (error) {
+               BT_ERR("Unable to create client proxy: %s", error->message);
+               g_clear_error(&error);
+       }
 
-       hash = g_hash_table_new_full(g_str_hash, g_str_equal,
-                                    NULL, (GDestroyNotify)__bt_value_free);
+       retv_if(client_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
 
-       value = g_new0(GValue, 1);
-       g_value_init(value, G_TYPE_STRING);
+       builder = g_variant_builder_new(
+                               G_VARIANT_TYPE("a{sv}"));
 
-       g_value_set_string(value, "OPP");
-       g_hash_table_insert(hash, "Target", value);
-       BT_DBG("Hash Table success");
+       g_variant_builder_add(builder, "{sv}", "Target",
+               g_variant_new_string("OPP"));
 
        __bt_free_sending_info(sending_info);
 
@@ -707,34 +684,20 @@ static int __bt_opp_client_start_sending(int request_id, char *address,
 
        BT_DBG("Going to call CreateSession");
 
-       proxy_call = dbus_g_proxy_begin_call(client_proxy, "CreateSession",
-                       __bt_create_session_cb, NULL, NULL,
-                       G_TYPE_STRING, address,
-                       dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                       hash, G_TYPE_INVALID);
-
-       if (proxy_call == NULL) {
-                       BT_ERR("Fail to Send files");
-                       g_hash_table_destroy(hash);
-                       g_object_unref(client_proxy);
-                       __bt_free_sending_info(sending_info);
-                       _bt_opp_client_event_deinit();
-                       sending_info = NULL;
-                       return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       BT_DBG("After CreateSession");
-
-       sending_info->sending_proxy = proxy_call;
-       g_hash_table_destroy(hash);
+       g_dbus_proxy_call(client_proxy, "CreateSession",
+                                               g_variant_new("(sa{sv})", address, builder),
+                                               G_DBUS_CALL_FLAGS_NONE,
+                                               DBUS_TIEMOUT, NULL,
+                                               (GAsyncReadyCallback)__bt_create_session_cb,
+                                               NULL);
+       g_variant_builder_unref(builder);
 
        BT_DBG("-");
 
        return BLUETOOTH_ERROR_NONE;
 }
 
-
-int _bt_opp_client_push_files(int request_id, DBusGMethodInvocation *context,
+int _bt_opp_client_push_files(int request_id, GDBusMethodInvocation *context,
                                bluetooth_device_address_t *remote_address,
                                char **file_path, int file_count)
 {
@@ -742,8 +705,7 @@ int _bt_opp_client_push_files(int request_id, DBusGMethodInvocation *context,
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
        bt_sending_data_t *data;
 
-       GArray *out_param1 = NULL;
-       GArray *out_param2 = NULL;
+       GVariant *out_param1 = NULL;
 
        int result = BLUETOOTH_ERROR_NONE;
        int i;
@@ -762,6 +724,10 @@ int _bt_opp_client_push_files(int request_id, DBusGMethodInvocation *context,
        } else {
                /* Insert data in the queue */
                data = g_malloc0(sizeof(bt_sending_data_t));
+               /* Fix : NULL_RETURNS */
+               if (data == NULL)
+                       return BLUETOOTH_ERROR_MEMORY_ALLOCATION;
+
                data->file_path = g_new0(char *, file_count + 1);
                data->address = g_strdup(address);
                data->file_count = file_count;
@@ -775,17 +741,13 @@ int _bt_opp_client_push_files(int request_id, DBusGMethodInvocation *context,
                transfer_list = g_slist_append(transfer_list, data);
        }
 
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
+       out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
+                                                       &request_id, sizeof(int),
+                                                       TRUE, NULL, NULL);
 
-       g_array_append_vals(out_param1, &request_id,
-                               sizeof(int));
-       g_array_append_vals(out_param2, &result, sizeof(int));
 
-       dbus_g_method_return(context, out_param1, out_param2);
-
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
+       g_dbus_method_invocation_return_value(context,
+                       g_variant_new("(iv)", result, out_param1));
 
        BT_DBG("-");
 
@@ -796,48 +758,35 @@ int _bt_opp_client_cancel_push(void)
 {
        BT_DBG("+");
 
-       DBusGConnection *g_conn;
-       DBusGProxy *client_proxy;
+       GError *err = NULL;
        int result = BLUETOOTH_ERROR_CANCEL_BY_USER;
-
+       GVariant *param = NULL;
        retv_if(sending_info == NULL, BLUETOOTH_ERROR_NOT_IN_OPERATION);
 
        sending_info->is_canceled = TRUE;
        sending_info->result = result;
 
        if (sending_info->transfer_info) {
-               BT_DBG("calling cancel in Bluez");
-               dbus_g_proxy_call_no_reply(sending_info->transfer_info->proxy,
-                                       "Cancel", G_TYPE_INVALID,
-                                       G_TYPE_INVALID);
 
+               g_dbus_proxy_call_sync(sending_info->transfer_info->proxy,
+                                       "Cancel", NULL,
+                                       G_DBUS_CALL_FLAGS_NONE, -1,
+                                       NULL, &err);
+               param = g_variant_new("(isti)", result,
+                                       sending_info->transfer_info->file_name,
+                                       sending_info->transfer_info->size,
+                                       sending_info->request_id);
                _bt_send_event(BT_OPP_CLIENT_EVENT,
                                BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &sending_info->transfer_info->file_name,
-                               DBUS_TYPE_UINT64, &sending_info->transfer_info->size,
-                               DBUS_TYPE_INT32, &sending_info->request_id,
-                               DBUS_TYPE_INVALID);
+                               param);
 
                if (result == BLUETOOTH_ERROR_CANCEL_BY_USER) {
                        BT_ERR("result is not BLUETOOTH_ERROR_NONE");
                        __bt_sending_release();
                        file_offset = 0;
                }
-       } else {
-               retv_if(sending_info->sending_proxy == NULL,
-                                       BLUETOOTH_ERROR_INTERNAL);
-
-               g_conn = _bt_get_session_gconn();
-               retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-               client_proxy =  dbus_g_proxy_new_for_name(g_conn, BT_OBEX_SERVICE_NAME,
-                                               BT_OBEX_CLIENT_PATH, BT_OBEX_CLIENT_INTERFACE);
-               retv_if(client_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-               dbus_g_proxy_cancel_call(client_proxy,
-                                       sending_info->sending_proxy);
 
+       } else {
                g_idle_add(__bt_cancel_push_cb, NULL);
        }
 
@@ -875,7 +824,7 @@ void _bt_opp_client_check_pending_transfer(const char *address)
        BT_DBG("+");
 
        int result = BLUETOOTH_ERROR_CANCEL;
-
+       GVariant *param = NULL;
        ret_if(sending_info == NULL);
        ret_if(sending_info->transfer_info == NULL);
 
@@ -885,26 +834,24 @@ void _bt_opp_client_check_pending_transfer(const char *address)
                sending_info->result = result;
 
                if (!sending_info->is_canceled) {
+                       param = g_variant_new("(isti)", result,
+                                               sending_info->transfer_info->file_name,
+                                               sending_info->transfer_info->size,
+                                               sending_info->request_id);
                        _bt_send_event(BT_OPP_CLIENT_EVENT,
                                        BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &sending_info->transfer_info->file_name,
-                                       DBUS_TYPE_UINT64, &sending_info->transfer_info->size,
-                                       DBUS_TYPE_INT32, &sending_info->request_id,
-                                       DBUS_TYPE_INVALID);
-
+                                       param);
                        __bt_free_transfer_info(sending_info->transfer_info);
                        sending_info->transfer_info = NULL;
                        /* Reset the file offset as we will cancelled remaining files also */
                        file_offset = 0;
                }
-
+               param = g_variant_new("(isi)", sending_info->result,
+                                       sending_info->address,
+                                       sending_info->request_id);
                _bt_send_event(BT_OPP_CLIENT_EVENT,
                                BLUETOOTH_EVENT_OPC_DISCONNECTED,
-                               DBUS_TYPE_INT32, &sending_info->result,
-                               DBUS_TYPE_STRING, &sending_info->address,
-                               DBUS_TYPE_INT32, &sending_info->request_id,
-                               DBUS_TYPE_INVALID);
+                               param);
 
                __bt_sending_release();
        }
index adf3102..9fc626d 100644 (file)
 #include <string.h>
 #include <malloc.h>
 #include <stacktrim.h>
-#if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
 #include <syspopup_caller.h>
-#endif
 #include <vconf.h>
 
 #include "bt-internal-types.h"
 #include "bt-service-common.h"
-//#include "bt-service-agent.h"
-//#include "bt-service-gap-agent.h"
-//#include "bt-service-adapter.h"
 #include "bt-service-event.h"
-//#include "bt-service-rfcomm-server.h"
-//#include "bt-service-device.h"
-//#include "bt-service-audio.h"
 #include "bt-service-pbap.h"
 #include <glib.h>
 #include <gio/gio.h>
@@ -118,8 +110,9 @@ char *SEARCH_FIELD[] = {
 };
 
 static char *g_pbap_session_path = NULL;
-static DBusGConnection *dbus_connection = NULL;
-static DBusGProxy *g_pbap_proxy = NULL;
+static char *g_pbap_server_address = NULL;
+static GDBusConnection *dbus_connection = NULL;
+static GDBusProxy *g_pbap_proxy = NULL;
 
 static struct {
        int type;
@@ -150,11 +143,11 @@ typedef struct {
 
 static GSList *transfers;
 
-int __bt_pbap_call_get_phonebook_size(DBusGProxy *proxy, bt_pbap_data_t *pbap_data);
-int __bt_pbap_call_get_phonebook(DBusGProxy *proxy, bt_pbap_data_t *pbap_data);
-int __bt_pbap_call_get_vcards_list(DBusGProxy *proxy, bt_pbap_data_t *pbap_data);
-int __bt_pbap_call_get_vcard(DBusGProxy *proxy, bt_pbap_data_t *pbap_data);
-int __bt_pbap_call_search_phonebook(DBusGProxy *proxy, bt_pbap_data_t *pbap_data);
+int __bt_pbap_call_get_phonebook_size(GDBusProxy *proxy, bt_pbap_data_t *pbap_data);
+int __bt_pbap_call_get_phonebook(GDBusProxy *proxy, bt_pbap_data_t *pbap_data);
+int __bt_pbap_call_get_vcards_list(GDBusProxy *proxy, bt_pbap_data_t *pbap_data);
+int __bt_pbap_call_get_vcard(GDBusProxy *proxy, bt_pbap_data_t *pbap_data);
+int __bt_pbap_call_search_phonebook(GDBusProxy *proxy, bt_pbap_data_t *pbap_data);
 
 static void __bt_pbap_free_data(bt_pbap_data_t *pbap_data)
 {
@@ -198,10 +191,11 @@ void _bt_pbap_obex_transfer_completed(const char *transfer_path, gboolean transf
        bt_pbap_transfer_info_t *transfer_info;
        int result = 0;
        int success = transfer_status;
+       GVariant *signal = NULL;
        BT_DBG("Transfer [%s] Success [%d] \n", transfer_path, success);
 
        result = (success == TRUE) ? BLUETOOTH_ERROR_NONE
-                               : BLUETOOTH_ERROR_CANCEL;
+                               : BLUETOOTH_ERROR_INTERNAL;
 
        transfer_info = __bt_find_transfer_by_path(transfer_path);
        ret_if(transfer_info == NULL);
@@ -210,25 +204,20 @@ void _bt_pbap_obex_transfer_completed(const char *transfer_path, gboolean transf
                        transfer_info->remote_device, transfer_info->filename,
                        transfer_info->operation);
 
+       signal = g_variant_new("(issi)", result,
+                       transfer_info->remote_device,
+                       transfer_info->filename, success);
        switch(transfer_info->operation) {
        case PULL_ALL: {
                _bt_send_event(BT_PBAP_CLIENT_EVENT,
                                        BLUETOOTH_PBAP_PHONEBOOK_PULL,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &transfer_info->remote_device,
-                                       DBUS_TYPE_STRING, &transfer_info->filename,
-                                       DBUS_TYPE_INT32, &success,
-                                       DBUS_TYPE_INVALID);
+                                       signal);
                break;
                }
        case GET_VCARD: {
                _bt_send_event(BT_PBAP_CLIENT_EVENT,
                                        BLUETOOTH_PBAP_VCARD_PULL,
-                                       DBUS_TYPE_INT32, &result,
-                                       DBUS_TYPE_STRING, &transfer_info->remote_device,
-                                       DBUS_TYPE_STRING, &transfer_info->filename,
-                                       DBUS_TYPE_INT32, &success,
-                                       DBUS_TYPE_INVALID);
+                                       signal);
                break;
                }
        default:
@@ -236,52 +225,86 @@ void _bt_pbap_obex_transfer_completed(const char *transfer_path, gboolean transf
                break;
 
        }
+
        transfers = g_slist_remove(transfers, transfer_info);
        __bt_free_transfer_info(transfer_info);
 }
 
-void __bt_pbap_connect_cb(DBusGProxy *proxy,
-               DBusGProxyCall *call, void *user_data)
+void _bt_obex_pbap_client_disconnect(char *path)
+{
+       if (g_strcmp0(g_pbap_session_path, path) == 0) {
+               int result = BLUETOOTH_ERROR_NONE;
+               GVariant *signal = g_variant_new("(is)", result,
+                               g_pbap_server_address);
+
+               _bt_send_event(BT_PBAP_CLIENT_EVENT,
+                                       BLUETOOTH_PBAP_DISCONNECTED,
+                                       signal);
+
+               g_free(g_pbap_session_path);
+               g_pbap_session_path = NULL;
+
+               g_free(g_pbap_server_address);
+               g_pbap_server_address = NULL;
+
+               g_object_unref(g_pbap_proxy);
+               g_pbap_proxy = NULL;
+
+               selected_path.folder = -1;
+               selected_path.type = -1;
+       }
+       BT_DBG("-");
+}
+
+void __bt_pbap_connect_cb(GDBusProxy *proxy,
+               GAsyncResult *res, gpointer user_data)
 {
        char *session_path = NULL;
        char *address_string = user_data;
-       GError *g_error = NULL;
-       int connected = -1;
-       int result = BLUETOOTH_ERROR_CANCEL;
+       GError *error = NULL;
+       GVariant *value;
+       GVariant *signal = NULL;
+       int result = BLUETOOTH_ERROR_INTERNAL;
 
+       value = g_dbus_proxy_call_finish(proxy, res, &error);
        BT_DBG("Address = %s", address_string);
-       if (!dbus_g_proxy_end_call(proxy, call, &g_error,
-                                       DBUS_TYPE_G_OBJECT_PATH, &session_path,
-                                       G_TYPE_INVALID)) {
-               BT_ERR("Error Code[%d]: Message %s \n", g_error->code, g_error->message);
-               g_error_free(g_error);
+
+       if (value == NULL) {
+               BT_ERR("g_dbus_proxy_call_finish failed");
+               if (error) {
+                       BT_ERR("errCode[%x], message[%s]\n",
+                                       error->code, error->message);
+                       g_clear_error(&error);
+               }
+               g_object_unref(g_pbap_proxy);
+               g_pbap_proxy = NULL;
        } else {
+               g_variant_get(value, "(&o)", &session_path);
+
                g_pbap_session_path = g_strdup(session_path);
                BT_DBG("Session Path = %s\n", g_pbap_session_path);
                result = BLUETOOTH_ERROR_NONE;
-               connected = 1;
+               g_pbap_server_address = g_strdup(address_string);
        }
 
+       signal = g_variant_new("(is)", result, address_string);
+
        _bt_send_event(BT_PBAP_CLIENT_EVENT,
                                BLUETOOTH_PBAP_CONNECTED,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &address_string,
-                               DBUS_TYPE_INT32, &connected,
-                               DBUS_TYPE_INVALID);
+                               signal);
 
        g_free(address_string);
-       g_free(session_path);
        BT_DBG("-");
 }
 
 int _bt_pbap_connect(const bluetooth_device_address_t *address)
 {
        BT_DBG("+");
-       GHashTable *hash;
-       GValue *tgt_value;
        GError *error = NULL;
        char address_string[18] = { 0, };
        char *ptr = NULL;
+       GVariantBuilder builder;
+       GVariant *args;
 
        BT_CHECK_PARAMETER(address, return);
 
@@ -296,79 +319,85 @@ int _bt_pbap_connect(const bluetooth_device_address_t *address)
 
        _bt_convert_addr_type_to_string(address_string, (unsigned char *)address->addr);
        BT_DBG("Address String: %s", address_string);
-       dbus_connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
-       if (error != NULL) {
-                       BT_ERR("Couldn't connect to system bus[%s]\n", error->message);
-                       g_error_free(error);
+       dbus_connection = _bt_get_session_gconn();
+       if (dbus_connection == NULL) {
+                       BT_ERR("Couldn't connect to system bus");
                        return EXIT_FAILURE;
        }
-       BT_DBG("#2");
-       g_pbap_proxy = dbus_g_proxy_new_for_name(dbus_connection,
-                       PBAP_OBEX_CLIENT_SERVICE,
-                       PBAP_OBEX_CLIENT_PATH,
-                       PBAP_OBEX_CLIENT_INTERFACE);
+
+       g_pbap_proxy =  g_dbus_proxy_new_sync(dbus_connection,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       PBAP_OBEX_CLIENT_SERVICE, PBAP_OBEX_CLIENT_PATH,
+                       PBAP_OBEX_CLIENT_INTERFACE, NULL, &error);
        if (!g_pbap_proxy) {
                BT_ERR("Failed to get a proxy for D-Bus\n");
+               if (error) {
+                       ERR("Unable to create proxy: %s", error->message);
+                       g_clear_error(&error);
+               }
                return -1;
        }
-       BT_DBG("#3");
-       hash = g_hash_table_new_full(g_str_hash, g_str_equal,
-                       NULL, (GDestroyNotify)g_free);
-       BT_DBG("#4");
-       tgt_value = g_new0(GValue, 1);
-       g_value_init(tgt_value, G_TYPE_STRING);
-       g_value_set_string(tgt_value, "pbap");
-       g_hash_table_insert(hash, "Target", tgt_value);
-       BT_DBG("#5");
+
+       /* Create Hash*/
+       g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
+       g_variant_builder_add(&builder, "{sv}", "Target",
+                                       g_variant_new("s", "pbap"));
+       args = g_variant_builder_end(&builder);
 
        ptr = g_strdup(address_string);
-       if (!dbus_g_proxy_begin_call(g_pbap_proxy, "CreateSession",
-                       (DBusGProxyCallNotify)__bt_pbap_connect_cb,
-                       ptr, NULL,
-                       G_TYPE_STRING, ptr,
-                       dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                       hash, G_TYPE_INVALID)) {
-               BT_ERR("Connect Dbus Call Error");
-               g_free(ptr);
-               g_object_unref(g_pbap_proxy);
-               g_hash_table_destroy(hash);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
 
-       g_hash_table_destroy(hash);
+       GVariant *temp = g_variant_new("(s@a{sv})", ptr, args);
+
+       g_dbus_proxy_call(g_pbap_proxy, "CreateSession",
+                       temp,
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+                       (GAsyncReadyCallback)__bt_pbap_connect_cb, ptr);
+       g_free(ptr);
 
        BT_DBG("-");
        return 0;
 }
 
-void __bt_pbap_disconnect_cb(DBusGProxy *proxy,
-               DBusGProxyCall *call, void *user_data)
+void __bt_pbap_disconnect_cb(GDBusProxy *proxy,
+               GAsyncResult *res, gpointer user_data)
 {
        char *address_string = user_data;
-       GError *g_error = NULL;
-       int connected = -1;
+       GError *error = NULL;
+       GVariant *value;
+       GVariant *signal = NULL;
        int result = BLUETOOTH_ERROR_INTERNAL ;
 
        BT_DBG("Address = %s", address_string);
-       if (!dbus_g_proxy_end_call(proxy, call, &g_error, G_TYPE_INVALID)) {
-               BT_ERR("Error Code[%d]: Message %s \n", g_error->code, g_error->message);
-               g_error_free(g_error);
+
+       value = g_dbus_proxy_call_finish(proxy, res, &error);
+       BT_DBG("Address = %s", address_string);
+
+       if (value == NULL) {
+               BT_ERR("g_dbus_proxy_call_finish failed");
+               if (error) {
+                       BT_ERR("errCode[%x], message[%s]\n",
+                                       error->code, error->message);
+                       g_clear_error(&error);
+               }
        } else {
+               g_object_unref(g_pbap_proxy);
+               g_pbap_proxy = NULL;
+
                g_free(g_pbap_session_path);
                g_pbap_session_path = NULL;
+
+               g_free(g_pbap_server_address);
+               g_pbap_server_address = NULL;
+
                result = BLUETOOTH_ERROR_NONE;
                selected_path.folder = -1;
                selected_path.type = -1;
-               connected = 0;
        }
 
-       g_object_unref(proxy);
+       signal = g_variant_new("(is)", result, address_string);
        _bt_send_event(BT_PBAP_CLIENT_EVENT,
-                               BLUETOOTH_PBAP_CONNECTED,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &address_string,
-                               DBUS_TYPE_INT32, &connected,
-                               DBUS_TYPE_INVALID);
+                       BLUETOOTH_PBAP_DISCONNECTED,
+                       signal);
 
        g_free(address_string);
        BT_DBG("-");
@@ -395,122 +424,144 @@ int _bt_pbap_disconnect(const bluetooth_device_address_t *address)
        BT_DBG("Session Path: %s", g_pbap_session_path);
 
        ptr = g_strdup(address_string);
-       if (!dbus_g_proxy_begin_call(g_pbap_proxy, "RemoveSession",
-                       (DBusGProxyCallNotify)__bt_pbap_disconnect_cb,
-                       ptr, NULL,
-                       DBUS_TYPE_G_OBJECT_PATH, g_pbap_session_path,
-                       G_TYPE_INVALID)) {
-               g_free(ptr);
-               BT_ERR("Disconnect Dbus Call Error");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+
+       g_dbus_proxy_call(g_pbap_proxy, "RemoveSession",
+                       g_variant_new("(o)", g_pbap_session_path),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+                       (GAsyncReadyCallback)__bt_pbap_disconnect_cb, ptr);
 
        return 0;
 }
 
-void __bt_pbap_select_cb(DBusGProxy *proxy,
-               DBusGProxyCall *call, void *user_data)
+void __bt_pbap_select_cb(GDBusProxy *proxy,
+               GAsyncResult *res, gpointer user_data)
 {
        BT_DBG("+");
-       GError *g_error = NULL;
+       GError *error = NULL;
+       GVariant *value;
        bt_pbap_data_t *pbap_data = user_data;
        char *address_string = pbap_data->data;
 
        BT_DBG("Address = %s", address_string);
-       if (dbus_g_proxy_end_call(proxy, call, &g_error, G_TYPE_INVALID)) {
-               switch (pbap_data->operation) {
-               case GET_SIZE: {
-                       __bt_pbap_call_get_phonebook_size(proxy, pbap_data);
-                       break;
-               }
-               case PULL_ALL: {
-                       __bt_pbap_call_get_phonebook(proxy, pbap_data);
-                       break;
-               }
-               case GET_LIST: {
-                       __bt_pbap_call_get_vcards_list(proxy, pbap_data);
-                       break;
-               }
-               case GET_VCARD: {
-                       __bt_pbap_call_get_vcard(proxy, pbap_data);
-                       break;
-               }
-               case PB_SEARCH: {
-                       __bt_pbap_call_search_phonebook(proxy, pbap_data);
-                       break;
-               }
-               default: {
-                       g_object_unref(proxy);
-                       __bt_pbap_free_data(pbap_data);
+
+       value = g_dbus_proxy_call_finish(proxy, res, &error);
+       if (value == NULL) {
+               BT_ERR("g_dbus_proxy_call_finish failed");
+               if (error) {
+                       BT_ERR("errCode[%x], message[%s]\n",
+                                       error->code, error->message);
+                       g_clear_error(&error);
                }
-               } // End of Case
-       } else {
+
+               selected_path.folder = -1;
+               selected_path.type = -1;
+
+               g_object_unref(proxy);
+               __bt_pbap_free_data(pbap_data);
+               return;
+       }
+
+       switch (pbap_data->operation) {
+       case GET_SIZE: {
+               __bt_pbap_call_get_phonebook_size(proxy, pbap_data);
+               break;
+       }
+       case PULL_ALL: {
+               __bt_pbap_call_get_phonebook(proxy, pbap_data);
+               break;
+       }
+       case GET_LIST: {
+               __bt_pbap_call_get_vcards_list(proxy, pbap_data);
+               break;
+       }
+       case GET_VCARD: {
+               __bt_pbap_call_get_vcard(proxy, pbap_data);
+               break;
+       }
+       case PB_SEARCH: {
+               __bt_pbap_call_search_phonebook(proxy, pbap_data);
+               break;
+       }
+       default: {
+               selected_path.folder = -1;
+               selected_path.type = -1;
                g_object_unref(proxy);
                __bt_pbap_free_data(pbap_data);
        }
+       } // End of Case
 
+       g_variant_unref(value);
        BT_DBG("-");
 }
 
 
-void __bt_pbap_get_phonebook_size_cb(DBusGProxy *proxy,
-               DBusGProxyCall *call, void *user_data)
+void __bt_pbap_get_phonebook_size_cb(GDBusProxy *proxy,
+               GAsyncResult *res, gpointer user_data)
 {
        BT_DBG("+");
-       GError *g_error = NULL;
+       GError *error = NULL;
        int result = BLUETOOTH_ERROR_INTERNAL;
        bt_pbap_data_t *pbap_data = user_data;
        char *address_string = pbap_data->data;
-       unsigned int size = 0;
+       unsigned short int size = 0;
+       GVariant *value;
+       GVariant *signal = NULL;
 
        BT_DBG("Address = %s", address_string);
-       if (!dbus_g_proxy_end_call(proxy, call, &g_error,
-                       G_TYPE_UINT, &size,
-                       G_TYPE_INVALID)) {
-               BT_ERR("Error Code[%d]: Message %s \n", g_error->code, g_error->message);
-               g_error_free(g_error);
+       value = g_dbus_proxy_call_finish(proxy, res, &error);
+
+       if (value == NULL) {
+               BT_ERR("g_dbus_proxy_call_finish failed");
+               if (error) {
+                       BT_ERR("errCode[%x], message[%s]\n",
+                                       error->code, error->message);
+                       g_clear_error(&error);
+               }
        } else {
-               BT_ERR("Success");
+               g_variant_get(value, "(q)", &size);
                result = BLUETOOTH_ERROR_NONE;
        }
+
        BT_DBG("Size of Phonebook: %d", size);
+
+       signal = g_variant_new("(isi)", result, address_string, size);
        _bt_send_event(BT_PBAP_CLIENT_EVENT,
                                BLUETOOTH_PBAP_PHONEBOOK_SIZE,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &address_string,
-                               DBUS_TYPE_INT32, &size,
-                               DBUS_TYPE_INVALID);
+                               signal);
+
+       g_variant_unref(value);
        g_object_unref(proxy);
        __bt_pbap_free_data(pbap_data);
        BT_DBG("-");
 }
 
-void __bt_pbap_get_phonebook_cb(DBusGProxy *proxy,
-               DBusGProxyCall *call, void *user_data)
+void __bt_pbap_get_phonebook_cb(GDBusProxy *proxy,
+               GAsyncResult *res, gpointer user_data)
 {
        BT_DBG("+");
-       GError *g_error = NULL;
+       GError *error = NULL;
        bt_pbap_data_t *pbap_data = user_data;
        char *address_string = pbap_data->data;
-       GHashTable *properties;
-       GValue *value = { 0 };
        bt_pbap_transfer_info_t *transfer_info;
        char *transfer = NULL;
        const gchar *filename =  NULL;
+       GVariant *value;
+       GVariant *properties;
 
        BT_DBG("Address = %s", address_string);
-       if (!dbus_g_proxy_end_call(proxy, call, &g_error,
-                       DBUS_TYPE_G_OBJECT_PATH, &transfer,
-                       dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                       &properties,
-                       G_TYPE_INVALID)) {
-               BT_ERR("Error Code[%d]: Message %s \n", g_error->code, g_error->message);
-               g_error_free(g_error);
-       } else {
-               if (properties != NULL) {
-                       value = g_hash_table_lookup(properties, "Filename");
-                       filename = value ? g_value_get_string(value) : NULL;
+       value = g_dbus_proxy_call_finish(proxy, res, &error);
+       if (value == NULL) {
+               BT_ERR("g_dbus_proxy_call_finish failed");
+               if (error) {
+                       BT_ERR("errCode[%x], message[%s]\n",
+                                       error->code, error->message);
+                       g_clear_error(&error);
                }
+       } else {
+               g_variant_get(value, "(o@a{sv})", &transfer, &properties);
+
+               if (g_variant_lookup(properties, "Filename", "s", &filename) == FALSE)
+                       filename = NULL;
 
                BT_DBG("Transfer Path: %s", transfer);
                BT_DBG("File Name: %s", filename);
@@ -527,90 +578,102 @@ void __bt_pbap_get_phonebook_cb(DBusGProxy *proxy,
        BT_DBG("-");
 }
 
-void __bt_pbap_get_vcard_list_cb(DBusGProxy *proxy,
-               DBusGProxyCall *call, void *user_data)
+void __bt_pbap_get_vcard_list_cb(GDBusProxy *proxy,
+               GAsyncResult *res, gpointer user_data)
 {
        BT_DBG("+");
-       GError *g_error = NULL;
+       GError *error = NULL;
        int i;
        int result = BLUETOOTH_ERROR_INTERNAL;
-       GPtrArray *vcardlist = NULL;
        bt_pbap_data_t *pbap_data = user_data;
        char *address_string = pbap_data->data;
        char **vcard_list = NULL;
        char list_entry[PBAP_VCARDLIST_MAXLENGTH] = { 0, };
        int length = 0;
-
-       BT_DBG("Address = %s", address_string);
-       if (!dbus_g_proxy_end_call(proxy, call, &g_error,
-                       dbus_g_type_get_collection("GPtrArray", dbus_g_type_get_struct("GValueArray",
-                                       G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID)),
-                               &vcardlist, G_TYPE_INVALID)) {
-               BT_ERR("Error Code[%d]: Message %s \n", g_error->code, g_error->message);
-               g_error_free(g_error);
-               vcard_list = g_new0(char *, length + 1);
+       GVariant *value;
+       GVariant *signal = NULL;
+
+       value = g_dbus_proxy_call_finish(proxy, res, &error);
+       if (value == NULL) {
+               BT_ERR("g_dbus_proxy_call_finish failed");
+               if (error) {
+                       BT_ERR("errCode[%x], message[%s]\n",
+                                       error->code, error->message);
+                       g_clear_error(&error);
+               }
        } else {
-               BT_DBG("vcardlist len %d", vcardlist->len);
-               length = vcardlist->len;
                result = BLUETOOTH_ERROR_NONE;
+               gchar *elname, *elval;
 
-               vcard_list = g_new0(char *, length + 1);
+               GVariantIter iter;
+               GVariant *child = NULL;
+               GVariant *value1 = NULL;
 
-               GValue *v = g_new0(GValue, 1);//g_ptr_array_index(vcardlist, 0);
-               gchar *elname, *elval;
-               g_value_init(v, dbus_g_type_get_struct ("GValueArray", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID));
-               for (i = 0; i < length; i++) {
-                       g_value_set_boxed(v, g_ptr_array_index(vcardlist, i));
-                       if (dbus_g_type_struct_get (v, 0, &elname, 1, &elval, G_MAXUINT)) {
-                               memset(list_entry, 0, PBAP_VCARDLIST_MAXLENGTH);
-                               g_snprintf (list_entry, PBAP_VCARDLIST_MAXLENGTH - 1,
-                                               "<card handle = \"%s\" name = \"%s\"/>", elname, elval);
-                               //If possible send as Array of <STRING, STRING>
-                               BT_DBG("%s", list_entry);
-                               vcard_list[i] = g_strdup(list_entry);
-                       }
+               g_variant_get(value ,"(@a(ss))", &value1); /* Format for value1 a(ss)*/
+               gsize items = g_variant_iter_init (&iter, value1);
+               vcard_list = g_new0(char *, items + 1);
+
+               for (i = 0; (child = g_variant_iter_next_value (&iter)) != NULL; i++) {
+                       g_variant_get(child ,"(&s&s)", &elname, &elval);
+
+                       memset(list_entry, 0, PBAP_VCARDLIST_MAXLENGTH);
+                       g_snprintf (list_entry, PBAP_VCARDLIST_MAXLENGTH - 1,
+                                       "<card handle = \"%s\" name = \"%s\"/>", elname, elval);
+                       //If possible send as Array of <STRING, STRING>
+                       BT_DBG("%s", list_entry);
+                       vcard_list[i] = g_strdup(list_entry);
+                       g_variant_unref(child);
                }
+
+               length = i;
+               g_variant_unref(value1);
+               g_variant_unref(value);
        }
 
+       BT_DBG("Address = %s", address_string);
+       GVariant *temp = g_variant_new_strv((const gchar * const*)vcard_list, length);
+       signal = g_variant_new("(isv)", result, address_string, temp);
+
        _bt_send_event(BT_PBAP_CLIENT_EVENT,
-                               BLUETOOTH_PBAP_VCARD_LIST,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &address_string,
-                               DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
-                               &vcard_list, length,
-                               DBUS_TYPE_INVALID);
+                       BLUETOOTH_PBAP_VCARD_LIST,
+                       signal);
 
+       for (i = 0; i < length; i++)
+               g_free(vcard_list[i]);
+
+       g_free(vcard_list);
        g_object_unref(proxy);
        __bt_pbap_free_data(pbap_data);
        BT_DBG("-");
 }
 
-void __bt_pbap_get_vcard_cb(DBusGProxy *proxy,
-               DBusGProxyCall *call, void *user_data)
+void __bt_pbap_get_vcard_cb(GDBusProxy *proxy,
+               GAsyncResult *res, gpointer user_data)
 {
        BT_DBG("+");
-       GError *g_error = NULL;
+       GError *error = NULL;
        bt_pbap_data_t *pbap_data = user_data;
        char *address_string = pbap_data->data;
-       GHashTable *properties;
-       GValue *value = { 0 };
        bt_pbap_transfer_info_t *transfer_info;
        char *transfer = NULL;
        const gchar *filename =  NULL;
+       GVariant *value;
+       GVariant *properties;
 
        BT_DBG("Address = %s", address_string);
-       if (!dbus_g_proxy_end_call(proxy, call, &g_error,
-                       DBUS_TYPE_G_OBJECT_PATH, &transfer,
-                       dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                       &properties,
-                       G_TYPE_INVALID)) {
-               BT_ERR("Error Code[%d]: Message %s \n", g_error->code, g_error->message);
-               g_error_free(g_error);
-       } else {
-               if (properties != NULL) {
-                       value = g_hash_table_lookup(properties, "Filename");
-                       filename = value ? g_value_get_string(value) : NULL;
+       value = g_dbus_proxy_call_finish(proxy, res, &error);
+       if (value == NULL) {
+               BT_ERR("g_dbus_proxy_call_finish failed");
+               if (error) {
+                       BT_ERR("errCode[%x], message[%s]\n",
+                                       error->code, error->message);
+                       g_clear_error(&error);
                }
+       } else {
+               g_variant_get(value, "(o@a{sv})", &transfer, &properties);
+
+               if (g_variant_lookup (properties, "Filename", "s", &filename) == FALSE)
+                       filename = NULL;
 
                BT_DBG("Transfer Path: %s", transfer);
                BT_DBG("File Name: %s", filename);
@@ -620,6 +683,9 @@ void __bt_pbap_get_vcard_cb(DBusGProxy *proxy,
                transfer_info->filename = (char *)filename;
                transfer_info->operation = GET_VCARD;
                transfers = g_slist_append(transfers, transfer_info);
+
+               g_variant_unref(properties);
+               g_variant_unref(value);
        }
 
        g_object_unref(proxy);
@@ -627,227 +693,217 @@ void __bt_pbap_get_vcard_cb(DBusGProxy *proxy,
        BT_DBG("-");
 }
 
-void __bt_pbap_search_phonebook_cb(DBusGProxy *proxy,
-               DBusGProxyCall *call, void *user_data)
+void __bt_pbap_search_phonebook_cb(GDBusProxy *proxy,
+               GAsyncResult *res, gpointer user_data)
 {
        BT_DBG("+");
-       GError *g_error = NULL;
+       GError *error = NULL;
        int i;
-       GPtrArray *vcardlist = NULL;
        bt_pbap_data_t *pbap_data = user_data;
        char *address_string = pbap_data->data;
        char **vcard_list = NULL;
        char list_entry[PBAP_VCARDLIST_MAXLENGTH] = { 0, };
        int length = 0;
        int result = BLUETOOTH_ERROR_INTERNAL;
-
-       BT_DBG("Address = %s", address_string);
-       if (!dbus_g_proxy_end_call(proxy, call, &g_error,
-                       dbus_g_type_get_collection("GPtrArray", dbus_g_type_get_struct("GValueArray",
-                                       G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID)),
-                               &vcardlist, G_TYPE_INVALID)) {
-               BT_ERR("Error Code[%d]: Message %s \n", g_error->code, g_error->message);
-               g_error_free(g_error);
+       GVariant *value;
+       GVariant *signal = NULL;
+
+       value = g_dbus_proxy_call_finish(proxy, res, &error);
+       if (value == NULL) {
+               BT_ERR("g_dbus_proxy_call_finish failed");
+               if (error) {
+                       BT_ERR("errCode[%x], message[%s]\n",
+                                       error->code, error->message);
+                       g_clear_error(&error);
+               }
        } else {
-               BT_DBG("vcardlist len %d", vcardlist->len);
-               length = vcardlist->len;
                result = BLUETOOTH_ERROR_NONE;
+               gchar *elname, *elval;
 
-               vcard_list = g_new0(char *, length + 1);
+               GVariantIter iter;
+               GVariant *child = NULL;
+               GVariant *value1 = NULL;
 
-               GValue *v = g_new0(GValue, 1);//g_ptr_array_index(vcardlist, 0);
-               gchar *elname, *elval;
-               g_value_init(v, dbus_g_type_get_struct ("GValueArray", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID));
-               for (i = 0; i < length; i++) {
-                       g_value_set_boxed(v, g_ptr_array_index(vcardlist, i));
-                       if (dbus_g_type_struct_get (v, 0, &elname, 1, &elval, G_MAXUINT)) {
-                               memset(list_entry, 0, PBAP_VCARDLIST_MAXLENGTH);
-                               g_snprintf (list_entry, PBAP_VCARDLIST_MAXLENGTH - 1,
-                                               "<card handle = \"%s\" name = \"%s\"/>", elname, elval);
-                               //If possible send as Array of <STRING, STRING>
-                               BT_DBG("%s", list_entry);
-                               vcard_list[i] = g_strdup(list_entry);
-                       }
+               g_variant_get(value ,"(@a(ss))", &value1);
+               gsize items = g_variant_iter_init (&iter, value1);
+               vcard_list = g_new0(char *, items + 1);
+
+               for (i = 0; (child = g_variant_iter_next_value (&iter)) != NULL; i++) {
+                       g_variant_get(child, "(&s&s)", &elname, &elval);
+
+                       memset(list_entry, 0, PBAP_VCARDLIST_MAXLENGTH);
+                       g_snprintf (list_entry, PBAP_VCARDLIST_MAXLENGTH - 1,
+                                       "<card handle = \"%s\" name = \"%s\"/>", elname, elval);
+                       //If possible send as Array of <STRING, STRING>
+                       BT_DBG("%s", list_entry);
+                       vcard_list[i] = g_strdup(list_entry);
+
+                       g_variant_unref(child);
                }
+               length = i;
+               g_variant_unref(value1);
+               g_variant_unref(value);
        }
 
+       BT_DBG("Address = %s", address_string);
+
+       signal = g_variant_new("(is@as)", result, address_string,
+                       g_variant_new_strv((const gchar * const*)vcard_list, length));
+
        _bt_send_event(BT_PBAP_CLIENT_EVENT,
                                BLUETOOTH_PBAP_PHONEBOOK_SEARCH,
-                               DBUS_TYPE_INT32, &result,
-                               DBUS_TYPE_STRING, &address_string,
-                               DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
-                               &vcard_list, length,
-                               DBUS_TYPE_INVALID);
+                               signal);
+
+       for (i = 0; i < length; i++)
+               g_free(vcard_list[i]);
+
+       g_free(vcard_list);
        g_object_unref(proxy);
        __bt_pbap_free_data(pbap_data);
        BT_DBG("-");
 }
 
-int __bt_pbap_call_get_phonebook_size(DBusGProxy *proxy, bt_pbap_data_t *pbap_data)
+int __bt_pbap_call_get_phonebook_size(GDBusProxy *proxy, bt_pbap_data_t *pbap_data)
 {
        BT_DBG("+");
-       if (!dbus_g_proxy_begin_call(proxy, "GetSize",
-                       (DBusGProxyCallNotify)__bt_pbap_get_phonebook_size_cb,
-                       pbap_data, NULL,
-                       G_TYPE_INVALID)) {
-               BT_ERR("GetSize Dbus Call Error");
-               __bt_pbap_free_data(pbap_data);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+
+       g_dbus_proxy_call(proxy, "GetSize",
+                       NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+                       (GAsyncReadyCallback)__bt_pbap_get_phonebook_size_cb,
+                       pbap_data);
 
        return BLUETOOTH_ERROR_NONE;
        BT_DBG("-");
 }
 
-int __bt_pbap_call_get_phonebook(DBusGProxy *proxy, bt_pbap_data_t *pbap_data)
+int __bt_pbap_call_get_phonebook(GDBusProxy *proxy, bt_pbap_data_t *pbap_data)
 {
        BT_DBG("+");
-       GHashTable *filters;
-       GValue *max_count;
-       GValue *format;
-       GValue *order;
-       GValue *offset;
+
        char *format_str = NULL;
        char *order_str = NULL;
        char *target_file = "/opt/usr/media/Downloads/pb.vcf";
        bt_pbap_pull_parameters_t *app_param = pbap_data->app_param;
+       GVariantBuilder builder;
+       GVariant *filters;
 
-       filters = g_hash_table_new_full(g_str_hash, g_str_equal,
-                               NULL, (GDestroyNotify)g_free);
+       g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
 
-       /* Add Format Filter only if other than vCard 2.1 (default)*/
-       if (app_param->format > 0) {
-               format_str = g_strdup(FORMAT[app_param->format]);
-               format = g_new0(GValue, 1);
-               g_value_init(format, G_TYPE_STRING);
-               g_value_set_string(format, format_str);
-               g_hash_table_insert(filters, "Format", format);
-               g_free(format_str);
-       }
+       /* Add MaxlistCount*/
+       g_variant_builder_add(&builder, "{sv}", "MaxCount",
+                                       g_variant_new("u",app_param->maxlist));
 
        /* Add Order Filter only if other than Indexed (default)*/
        if (app_param->order > 0) {
                order_str = g_strdup(ORDER[app_param->order]);
-               order = g_new0(GValue, 1);
-               g_value_init(order, G_TYPE_STRING);
-               g_value_set_string(order, order_str);
-               g_hash_table_insert(filters, "Order", order);
-               g_free(order_str);
+               g_variant_builder_add(&builder, "{sv}", "Order",
+                               g_variant_new("s",order_str));
        }
 
-       max_count = g_new0(GValue, 1);
-       g_value_init(max_count, G_TYPE_UINT);
-       g_value_set_uint(max_count, app_param->maxlist);
-       g_hash_table_insert(filters, "MaxCount", max_count);
-
        /* Add Offset Filter only if other than 0 (default)*/
        if (app_param->offset > 0) {
-               offset = g_new0(GValue, 1);
-               g_value_init(offset, G_TYPE_UINT);
-               g_value_set_uint(offset, app_param->offset);
-               g_hash_table_insert(filters, "Offset", offset);
+               g_variant_builder_add(&builder, "{sv}", "Offset",
+                                               g_variant_new("u",app_param->offset));
+       }
+
+       /* Add Format Filter only if other than vCard 2.1 (default)*/
+       if (app_param->format > 0) {
+               format_str = g_strdup(FORMAT[app_param->format]);
+               g_variant_builder_add(&builder, "{sv}", "Format",
+                                                       g_variant_new("s", format_str));
        }
 
+       filters = g_variant_builder_end(&builder);
+
 //****************************
 // Add code for Fields
 //
 //****************************
 
-       if (!dbus_g_proxy_begin_call(proxy, "PullAll",
-                       (DBusGProxyCallNotify)__bt_pbap_get_phonebook_cb,
-                       pbap_data, NULL,
-                       G_TYPE_STRING, target_file,
-                       dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                       filters,
-                       G_TYPE_INVALID)) {
-               BT_ERR("GetSize Dbus Call Error");
-               g_hash_table_destroy(filters);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+       g_dbus_proxy_call(proxy, "PullAll",
+                       g_variant_new("(s@a{sv})", target_file, filters),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+                       (GAsyncReadyCallback)__bt_pbap_get_phonebook_cb,
+                       pbap_data);
+
+       g_free(format_str);
+       g_free(order_str);
        g_hash_table_destroy(filters);
 
-       return BLUETOOTH_ERROR_NONE;
        BT_DBG("-");
+       return BLUETOOTH_ERROR_NONE;
 }
 
-int __bt_pbap_call_get_vcards_list(DBusGProxy *proxy, bt_pbap_data_t *pbap_data)
+int __bt_pbap_call_get_vcards_list(GDBusProxy *proxy, bt_pbap_data_t *pbap_data)
 {
        BT_DBG("+");
-       GHashTable *filters;
-       GValue *max_count;
-       GValue *order;
-       GValue *offset;
        char *order_str = NULL;
+       char *folder = NULL;
+       GVariantBuilder builder;
+       GVariant *filters;
+
        bt_pbap_list_parameters_t *app_param = pbap_data->app_param;
 
-       filters = g_hash_table_new_full(g_str_hash, g_str_equal,
-                               NULL, (GDestroyNotify)g_free);
+       g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
+
+       /* Add MaxlistCount*/
+       g_variant_builder_add(&builder, "{sv}", "MaxCount",
+                                       g_variant_new("u",app_param->maxlist));
 
        /* Add Order Filter only if other than Indexed (default)*/
        if (app_param->order > 0) {
                order_str = g_strdup(ORDER[app_param->order]);
-               order = g_new0(GValue, 1);
-               g_value_init(order, G_TYPE_STRING);
-               g_value_set_string(order, order_str);
-               g_hash_table_insert(filters, "Order", order);
-               g_free(order_str);
+               g_variant_builder_add(&builder, "{sv}", "Order",
+                               g_variant_new("s",order_str));
        }
 
-       max_count = g_new0(GValue, 1);
-       g_value_init(max_count, G_TYPE_UINT);
-       g_value_set_uint(max_count, app_param->maxlist);
-       g_hash_table_insert(filters, "MaxCount", max_count);
-
        /* Add Offset Filter only if other than 0 (default)*/
        if (app_param->offset > 0) {
-               offset = g_new0(GValue, 1);
-               g_value_init(offset, G_TYPE_UINT);
-               g_value_set_uint(offset, app_param->offset);
-               g_hash_table_insert(filters, "Offset", offset);
+               g_variant_builder_add(&builder, "{sv}", "Offset",
+                                               g_variant_new("u",app_param->offset));
        }
 
-       if (!dbus_g_proxy_begin_call(proxy, "List",
-                       (DBusGProxyCallNotify)__bt_pbap_get_vcard_list_cb,
-                       pbap_data, NULL,
-                       dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                       filters,
-                       G_TYPE_INVALID)) {
-               BT_ERR("List Dbus Call Error");
-               g_hash_table_destroy(filters);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+       filters = g_variant_builder_end(&builder);
 
-       g_hash_table_destroy(filters);
+       folder = g_strdup(TYPE[selected_path.type]);
+       BT_DBG("Folder: %s", folder);
+
+
+       g_dbus_proxy_call(proxy, "List",
+                       g_variant_new("(s@a{sv})", folder, filters),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+                       (GAsyncReadyCallback)__bt_pbap_get_vcard_list_cb,
+                       pbap_data);
+
+       g_free(folder);
+       g_free(order_str);
+       g_hash_table_unref(filters);
 
-       return BLUETOOTH_ERROR_NONE;
        BT_DBG("-");
+       return BLUETOOTH_ERROR_NONE;
 }
 
-int __bt_pbap_call_get_vcard(DBusGProxy *proxy, bt_pbap_data_t *pbap_data)
+int __bt_pbap_call_get_vcard(GDBusProxy *proxy, bt_pbap_data_t *pbap_data)
 {
        BT_DBG("+");
-       GHashTable *filters;
-       GValue *format;
+
        char *format_str = NULL;
        char *target_file = "/opt/usr/media/Downloads/pb.vcf";
        char *vcard_handle = NULL;
        char vcard[10] = { 0, };
-
+       GVariantBuilder builder;
+       GVariant *filters;
        bt_pbap_pull_vcard_parameters_t *app_param = pbap_data->app_param;
 
-       filters = g_hash_table_new_full(g_str_hash, g_str_equal,
-                               NULL, (GDestroyNotify)g_free);
+       g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
 
        /* Add Format Filter only if other than vCard 2.1 (default)*/
-       if (app_param->format > 0) {
+//     if (app_param->format > 0) {
                format_str = g_strdup(FORMAT[app_param->format]);
-               format = g_new0(GValue, 1);
-               g_value_init(format, G_TYPE_STRING);
-               g_value_set_string(format, format_str);
-               g_hash_table_insert(filters, "Format", format);
-               g_free(format_str);
-       }
-
+               g_variant_builder_add(&builder, "{sv}", "Format",
+                                                       g_variant_new("s", format_str));
+//     }
+       filters = g_variant_builder_end(&builder);
 
 //****************************
 // Add code for Fields
@@ -857,100 +913,82 @@ int __bt_pbap_call_get_vcard(DBusGProxy *proxy, bt_pbap_data_t *pbap_data)
        sprintf(vcard, "%d.vcf", app_param->index);
        BT_DBG("Handle: %s", vcard);
        vcard_handle = g_strdup(vcard);
+       BT_DBG("vcard_handle: %s", vcard_handle);
+       GVariant *temp = g_variant_new("(ss@a{sv})", vcard_handle, target_file, filters);
 
-       if (!dbus_g_proxy_begin_call(proxy, "Pull",
-                       (DBusGProxyCallNotify)__bt_pbap_get_vcard_cb,
-                       pbap_data, NULL,
-                       G_TYPE_STRING, vcard_handle,
-                       G_TYPE_STRING, target_file,
-                       dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                       filters,
-                       G_TYPE_INVALID)) {
-               BT_ERR("GetSize Dbus Call Error");
-               g_hash_table_destroy(filters);
-               g_free(vcard_handle);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+       g_dbus_proxy_call(proxy, "Pull",
+                       temp,
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+                       (GAsyncReadyCallback)__bt_pbap_get_vcard_cb,
+                       pbap_data);
 
-       g_hash_table_destroy(filters);
+       g_free(format_str);
        g_free(vcard_handle);
+       g_hash_table_destroy(filters);
 
-       return BLUETOOTH_ERROR_NONE;
        BT_DBG("-");
-
+       return BLUETOOTH_ERROR_NONE;
 }
 
-int __bt_pbap_call_search_phonebook(DBusGProxy *proxy, bt_pbap_data_t *pbap_data)
+int __bt_pbap_call_search_phonebook(GDBusProxy *proxy, bt_pbap_data_t *pbap_data)
 {
        BT_DBG("+");
-       GHashTable *filters;
-       GValue *max_count;
-       GValue *order;
-       GValue *offset;
+
        char *order_str = NULL;
        char *field = NULL;
        char *value = NULL;
        bt_pbap_search_parameters_t *app_param = pbap_data->app_param;
+       GVariantBuilder builder;
+       GVariant *filters;
+
+       g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
 
-       filters = g_hash_table_new_full(g_str_hash, g_str_equal,
-                               NULL, (GDestroyNotify)g_free);
+       /* Add MaxlistCount*/
+       g_variant_builder_add(&builder, "{sv}", "MaxCount",
+                                       g_variant_new("u",app_param->maxlist));
 
        /* Add Order Filter only if other than Indexed (default)*/
        if (app_param->order > 0) {
                order_str = g_strdup(ORDER[app_param->order]);
-               order = g_new0(GValue, 1);
-               g_value_init(order, G_TYPE_STRING);
-               g_value_set_string(order, order_str);
-               g_hash_table_insert(filters, "Order", order);
-               g_free(order_str);
+               g_variant_builder_add(&builder, "{sv}", "Order",
+                               g_variant_new("s",order_str));
        }
 
-       max_count = g_new0(GValue, 1);
-       g_value_init(max_count, G_TYPE_UINT);
-       g_value_set_uint(max_count, app_param->maxlist);
-       g_hash_table_insert(filters, "MaxCount", max_count);
-
        /* Add Offset Filter only if other than 0 (default)*/
        if (app_param->offset > 0) {
-               offset = g_new0(GValue, 1);
-               g_value_init(offset, G_TYPE_UINT);
-               g_value_set_uint(offset, app_param->offset);
-               g_hash_table_insert(filters, "Offset", offset);
+               g_variant_builder_add(&builder, "{sv}", "Offset",
+                                               g_variant_new("u",app_param->offset));
        }
 
+       filters = g_variant_builder_end(&builder);
+
        field = g_strdup(SEARCH_FIELD[app_param->search_attribute]);
        value = g_strdup(app_param->search_value);
-       if (!dbus_g_proxy_begin_call(proxy, "Search",
-                       (DBusGProxyCallNotify)__bt_pbap_search_phonebook_cb,
-                       pbap_data, NULL,
-                       G_TYPE_STRING, field,
-                       G_TYPE_STRING, value,
-                       dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
-                       filters,
-                       G_TYPE_INVALID)) {
-               BT_ERR("List Dbus Call Error");
-               g_hash_table_destroy(filters);
-               g_free(field);
-               g_free(value);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
 
-       g_hash_table_destroy(filters);
-       g_free(field);
+       g_dbus_proxy_call(proxy, "Search",
+                       g_variant_new("(ss@a{sv})", field, value, filters),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+                       (GAsyncReadyCallback)__bt_pbap_search_phonebook_cb,
+                       pbap_data);
+
        g_free(value);
+       g_free(order_str);
+       g_free(field);
+       g_hash_table_destroy(filters);
 
-       return BLUETOOTH_ERROR_NONE;
        BT_DBG("-");
+       return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_pbap_get_phonebook_size(const bluetooth_device_address_t *address,
                int source, int type)
 {
        BT_DBG("+");
-       DBusGProxy *g_pbap_session_proxy = NULL;
+       GDBusProxy *g_pbap_session_proxy = NULL;
        char address_string[18] = { 0, };
        char *source_string = NULL;
        char *type_string = NULL;
+       GError *err = NULL;
        bt_pbap_data_t *pbap_data = NULL;
 
        BT_CHECK_PARAMETER(address, return);
@@ -968,49 +1006,53 @@ int _bt_pbap_get_phonebook_size(const bluetooth_device_address_t *address,
 
        _bt_convert_addr_type_to_string(address_string, (unsigned char *)address->addr);
                        BT_DBG("Address String: %s", address_string);
+       source_string = g_strdup(SOURCE[source]);
+       type_string = g_strdup(TYPE[type]);
+
+       BT_DBG("Address[%s] Source[%s] Type[%s]",
+                       address_string, source_string, type_string);
        BT_DBG("Session Path = %s\n", g_pbap_session_path);
-       g_pbap_session_proxy = dbus_g_proxy_new_for_name(dbus_connection,
-                       PBAP_SESSION_SERVICE,
-                       g_pbap_session_path,
-                       PBAP_SESSION_INTERFACE);
+       g_pbap_session_proxy =  g_dbus_proxy_new_sync(dbus_connection,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       PBAP_SESSION_SERVICE, g_pbap_session_path,
+                       PBAP_SESSION_INTERFACE, NULL, &err);
+
        if (!g_pbap_session_proxy) {
                BT_ERR("Failed to get a proxy for D-Bus\n");
+               if (err) {
+                       ERR("Unable to create proxy: %s", err->message);
+                       g_clear_error(&err);
+               }
+               g_free(source_string);
+               g_free(type_string);
                return -1;
        }
 
+       BT_DBG("Prepare PBAP data");
        pbap_data = g_new0(bt_pbap_data_t, 1);
        pbap_data->operation = GET_SIZE;
        pbap_data->data = g_strdup(address_string);
 
        if (source ==  selected_path.folder && type == selected_path.type) {
-               return __bt_pbap_call_get_phonebook_size(g_pbap_session_proxy, pbap_data);
-       }
-
-       source_string = g_strdup(SOURCE[source]);
-       type_string = g_strdup(TYPE[type]);
-
-       BT_DBG("Address[%s] Source[%s] Type[%s]",
-               address_string, source_string, type_string);
-
-       if (!dbus_g_proxy_begin_call(g_pbap_session_proxy, "Select",
-                       (DBusGProxyCallNotify)__bt_pbap_select_cb,
-                       pbap_data, NULL,
-                       G_TYPE_STRING, source_string,
-                       G_TYPE_STRING, type_string,
-                       G_TYPE_INVALID)) {
-               BT_ERR("Select Dbus Call Error");
+               BT_DBG("Call get_phonebook_size directly");
                g_free(source_string);
                g_free(type_string);
-               g_object_unref(g_pbap_session_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return __bt_pbap_call_get_phonebook_size(g_pbap_session_proxy, pbap_data);
        }
 
+       BT_DBG("Call SELECT");
+       g_dbus_proxy_call(g_pbap_session_proxy, "Select",
+                       g_variant_new("(ss)", source_string, type_string),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+                       (GAsyncReadyCallback)__bt_pbap_select_cb,
+                       pbap_data);
+
+       BT_DBG("Set Folders");
        selected_path.folder = source;
        selected_path.type = type;
 
        g_free(source_string);
        g_free(type_string);
-
        return 0;
 }
 
@@ -1018,10 +1060,11 @@ int _bt_pbap_get_phonebook(const bluetooth_device_address_t *address,
                int source, int type, bt_pbap_pull_parameters_t *app_param)
 {
        BT_DBG("+");
-       DBusGProxy *g_pbap_session_proxy = NULL;
+       GDBusProxy *g_pbap_session_proxy = NULL;
        char address_string[18] = { 0, };
        char *source_string = NULL;
        char *type_string = NULL;
+       GError *err = NULL;
 
        bt_pbap_data_t *pbap_data = NULL;
        bt_pbap_pull_parameters_t *param = NULL;
@@ -1042,13 +1085,26 @@ int _bt_pbap_get_phonebook(const bluetooth_device_address_t *address,
        _bt_convert_addr_type_to_string(address_string, (unsigned char *)address->addr);
                BT_DBG("Address String: %s", address_string);
 
+       source_string = g_strdup(SOURCE[source]);
+       type_string = g_strdup(TYPE[type]);
+
+       BT_DBG("Address[%s] Source[%s] Type[%s]",
+                       address_string, source_string, type_string);
+
        BT_DBG("Session Path = %s\n", g_pbap_session_path);
-       g_pbap_session_proxy = dbus_g_proxy_new_for_name(dbus_connection,
-                       PBAP_SESSION_SERVICE,
-                       g_pbap_session_path,
-                       PBAP_SESSION_INTERFACE);
+       g_pbap_session_proxy =  g_dbus_proxy_new_sync(dbus_connection,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       PBAP_SESSION_SERVICE, g_pbap_session_path,
+                       PBAP_SESSION_INTERFACE, NULL, &err);
+
        if (!g_pbap_session_proxy) {
                BT_ERR("Failed to get a proxy for D-Bus\n");
+               if (err) {
+                       ERR("Unable to create proxy: %s", err->message);
+                       g_clear_error(&err);
+               }
+               g_free(source_string);
+               g_free(type_string);
                return -1;
        }
 
@@ -1063,28 +1119,14 @@ int _bt_pbap_get_phonebook(const bluetooth_device_address_t *address,
                return __bt_pbap_call_get_phonebook(g_pbap_session_proxy, pbap_data);
        }
 
-       source_string = g_strdup(SOURCE[source]);
-       type_string = g_strdup(TYPE[type]);
-
-       BT_DBG("Address[%s] Source[%s] Type[%s]",
-                       address_string, source_string, type_string);
-
-       if (!dbus_g_proxy_begin_call(g_pbap_session_proxy, "Select",
-                       (DBusGProxyCallNotify)__bt_pbap_select_cb,
-                       pbap_data, NULL,
-                       G_TYPE_STRING, source_string,
-                       G_TYPE_STRING, type_string,
-                       G_TYPE_INVALID)) {
-               BT_ERR("Select Dbus Call Error");
-               g_free(source_string);
-               g_free(type_string);
-               g_object_unref(g_pbap_session_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+       g_dbus_proxy_call(g_pbap_session_proxy, "Select",
+                       g_variant_new("(ss)", source_string, type_string),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+                       (GAsyncReadyCallback)__bt_pbap_select_cb,
+                       pbap_data);
 
        selected_path.folder = source;
        selected_path.type = type;
-
        g_free(source_string);
        g_free(type_string);
 
@@ -1095,10 +1137,11 @@ int _bt_pbap_get_list(const bluetooth_device_address_t *address, int source,
                int type,  bt_pbap_list_parameters_t *app_param)
 {
        BT_DBG("+");
-       DBusGProxy *g_pbap_session_proxy = NULL;
+       GDBusProxy *g_pbap_session_proxy = NULL;
        char address_string[18] = { 0, };
        char *source_string = NULL;
        char *type_string = NULL;
+       GError *err = NULL;
 
        bt_pbap_data_t *pbap_data = NULL;
        bt_pbap_list_parameters_t *param = NULL;
@@ -1119,16 +1162,30 @@ int _bt_pbap_get_list(const bluetooth_device_address_t *address, int source,
        _bt_convert_addr_type_to_string(address_string, (unsigned char *)address->addr);
                BT_DBG("Address String: %s", address_string);
 
+       source_string = g_strdup(SOURCE[source]);
+       type_string = g_strdup("nil");
+
+       BT_DBG("Address[%s] Source[%s] Type[%s]",
+                       address_string, source_string, type_string);
+
        BT_DBG("Session Path = %s\n", g_pbap_session_path);
-       g_pbap_session_proxy = dbus_g_proxy_new_for_name(dbus_connection,
-                       PBAP_SESSION_SERVICE,
-                       g_pbap_session_path,
-                       PBAP_SESSION_INTERFACE);
+       g_pbap_session_proxy =  g_dbus_proxy_new_sync(dbus_connection,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       PBAP_SESSION_SERVICE, g_pbap_session_path,
+                       PBAP_SESSION_INTERFACE, NULL, &err);
+
        if (!g_pbap_session_proxy) {
                BT_ERR("Failed to get a proxy for D-Bus\n");
+               if (err) {
+                       ERR("Unable to create proxy: %s", err->message);
+                       g_clear_error(&err);
+               }
+               g_free(source_string);
+               g_free(type_string);
                return -1;
        }
 
+       BT_DBG("Set PBAP Data");
        pbap_data = g_new0(bt_pbap_data_t, 1);
        pbap_data->operation = GET_LIST;
        pbap_data->data = g_strdup(address_string);
@@ -1136,32 +1193,20 @@ int _bt_pbap_get_list(const bluetooth_device_address_t *address, int source,
        memcpy(param, app_param, sizeof(bt_pbap_list_parameters_t));
        pbap_data->app_param = param;
 
+       /* Always Call Select for vCardListing
        if (source ==  selected_path.folder && type == selected_path.type) {
+               BT_DBG("Call Directly");
                return __bt_pbap_call_get_vcards_list(g_pbap_session_proxy, pbap_data);
-       }
-
-       source_string = g_strdup(SOURCE[source]);
-       type_string = g_strdup(TYPE[type]);
-
-       BT_DBG("Address[%s] Source[%s] Type[%s]",
-                       address_string, source_string, type_string);
-
-       if (!dbus_g_proxy_begin_call(g_pbap_session_proxy, "Select",
-                       (DBusGProxyCallNotify)__bt_pbap_select_cb,
-                       pbap_data, NULL,
-                       G_TYPE_STRING, source_string,
-                       G_TYPE_STRING, type_string,
-                       G_TYPE_INVALID)) {
-               BT_ERR("Select Dbus Call Error");
-               g_free(source_string);
-               g_free(type_string);
-               g_object_unref(g_pbap_session_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
+       } */
+       BT_DBG("Call SELECT");
+       g_dbus_proxy_call(g_pbap_session_proxy, "Select",
+                       g_variant_new("(ss)", source_string, type_string),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+                       (GAsyncReadyCallback)__bt_pbap_select_cb,
+                       pbap_data);
+       BT_DBG("Set Folders");
        selected_path.folder = source;
        selected_path.type = type;
-
        g_free(source_string);
        g_free(type_string);
 
@@ -1173,12 +1218,13 @@ int _bt_pbap_pull_vcard(const bluetooth_device_address_t *address,
                int source, int type, bt_pbap_pull_vcard_parameters_t *app_param)
 {
        BT_DBG("+");
-       DBusGProxy *g_pbap_session_proxy = NULL;
+       GDBusProxy *g_pbap_session_proxy = NULL;
        char address_string[18] = { 0, };
        char *source_string = NULL;
        char *type_string = NULL;
        bt_pbap_data_t *pbap_data = NULL;
        bt_pbap_pull_vcard_parameters_t *param = NULL;
+       GError *err = NULL;
 
        BT_CHECK_PARAMETER(address, return);
 
@@ -1196,13 +1242,24 @@ int _bt_pbap_pull_vcard(const bluetooth_device_address_t *address,
        _bt_convert_addr_type_to_string(address_string, (unsigned char *)address->addr);
                BT_DBG("Address String: %s", address_string);
 
+       source_string = g_strdup(SOURCE[source]);
+       type_string = g_strdup(TYPE[type]);
+
+       BT_DBG("Address[%s] Source[%s] Type[%s]",
+                       address_string, source_string, type_string);
+
        BT_DBG("Session Path = %s\n", g_pbap_session_path);
-       g_pbap_session_proxy = dbus_g_proxy_new_for_name(dbus_connection,
-                       PBAP_SESSION_SERVICE,
-                       g_pbap_session_path,
-                       PBAP_SESSION_INTERFACE);
+       g_pbap_session_proxy =  g_dbus_proxy_new_sync(dbus_connection,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       PBAP_SESSION_SERVICE, g_pbap_session_path,
+                       PBAP_SESSION_INTERFACE, NULL, &err);
+
        if (!g_pbap_session_proxy) {
                BT_ERR("Failed to get a proxy for D-Bus\n");
+               if (err) {
+                       ERR("Unable to create proxy: %s", err->message);
+                       g_clear_error(&err);
+               }
                return -1;
        }
 
@@ -1217,28 +1274,14 @@ int _bt_pbap_pull_vcard(const bluetooth_device_address_t *address,
                return __bt_pbap_call_get_vcard(g_pbap_session_proxy, pbap_data);
        }
 
-       source_string = g_strdup(SOURCE[source]);
-       type_string = g_strdup(TYPE[type]);
-
-       BT_DBG("Address[%s] Source[%s] Type[%s]",
-                       address_string, source_string, type_string);
-
-       if (!dbus_g_proxy_begin_call(g_pbap_session_proxy, "Select",
-                       (DBusGProxyCallNotify)__bt_pbap_select_cb,
-                       pbap_data, NULL,
-                       G_TYPE_STRING, source_string,
-                       G_TYPE_STRING, type_string,
-                       G_TYPE_INVALID)) {
-               BT_ERR("Select Dbus Call Error");
-               g_free(source_string);
-               g_free(type_string);
-               g_object_unref(g_pbap_session_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+       g_dbus_proxy_call(g_pbap_session_proxy, "Select",
+                       g_variant_new("(ss)", source_string, type_string),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+                       (GAsyncReadyCallback)__bt_pbap_select_cb,
+                       pbap_data);
 
        selected_path.folder = source;
        selected_path.type = type;
-
        g_free(source_string);
        g_free(type_string);
 
@@ -1249,12 +1292,13 @@ int _bt_pbap_phonebook_search(const bluetooth_device_address_t *address,
                int source, int type, bt_pbap_search_parameters_t *app_param)
 {
        BT_DBG("+");
-       DBusGProxy *g_pbap_session_proxy = NULL;
+       GDBusProxy *g_pbap_session_proxy = NULL;
        char address_string[18] = { 0, };
        char *source_string = NULL;
        char *type_string = NULL;
        bt_pbap_data_t *pbap_data = NULL;
        bt_pbap_search_parameters_t *param = NULL;
+       GError *err = NULL;
 
        BT_CHECK_PARAMETER(address, return);
 
@@ -1272,13 +1316,27 @@ int _bt_pbap_phonebook_search(const bluetooth_device_address_t *address,
        _bt_convert_addr_type_to_string(address_string, (unsigned char *)address->addr);
                BT_DBG("Address String: %s", address_string);
 
+       source_string = g_strdup(SOURCE[source]);
+       type_string = g_strdup("nil");
+
+       BT_DBG("Address[%s] Source[%s] Type[%s]",
+                       address_string, source_string, type_string);
+
        BT_DBG("Session Path = %s\n", g_pbap_session_path);
-       g_pbap_session_proxy = dbus_g_proxy_new_for_name(dbus_connection,
-                       PBAP_SESSION_SERVICE,
-                       g_pbap_session_path,
-                       PBAP_SESSION_INTERFACE);
+
+       g_pbap_session_proxy =  g_dbus_proxy_new_sync(dbus_connection,
+                       G_DBUS_PROXY_FLAGS_NONE, NULL,
+                       PBAP_SESSION_SERVICE, g_pbap_session_path,
+                       PBAP_SESSION_INTERFACE, NULL, &err);
+
        if (!g_pbap_session_proxy) {
                BT_ERR("Failed to get a proxy for D-Bus\n");
+               if (err) {
+                       ERR("Unable to create proxy: %s", err->message);
+                       g_clear_error(&err);
+               }
+               g_free(source_string);
+               g_free(type_string);
                return -1;
        }
 
@@ -1289,28 +1347,16 @@ int _bt_pbap_phonebook_search(const bluetooth_device_address_t *address,
        memcpy(param, app_param, sizeof(bt_pbap_search_parameters_t));
        pbap_data->app_param = param;
 
+       /* Call Select for vCardListing
        if (source ==  selected_path.folder && type == selected_path.type) {
                return __bt_pbap_call_search_phonebook(g_pbap_session_proxy, pbap_data);
-       }
-
-       source_string = g_strdup(SOURCE[source]);
-       type_string = g_strdup(TYPE[type]);
-
-       BT_DBG("Address[%s] Source[%s] Type[%s]",
-                       address_string, source_string, type_string);
+       }*/
 
-       if (!dbus_g_proxy_begin_call(g_pbap_session_proxy, "Select",
-                       (DBusGProxyCallNotify)__bt_pbap_select_cb,
-                       pbap_data, NULL,
-                       G_TYPE_STRING, source_string,
-                       G_TYPE_STRING, type_string,
-                       G_TYPE_INVALID)) {
-               BT_ERR("Select Dbus Call Error");
-               g_object_unref(g_pbap_session_proxy);
-               g_free(source_string);
-               g_free(type_string);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
+       g_dbus_proxy_call(g_pbap_session_proxy, "Select",
+                       g_variant_new("(ss)", source_string, type_string),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL,
+                       (GAsyncReadyCallback)__bt_pbap_select_cb,
+                       pbap_data);
 
        selected_path.folder = source;
        selected_path.type = type;
index 06bf862..e1e6a99 100644 (file)
  *
  */
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
+//#include <dbus/dbus-glib.h>
+//#include <dbus/dbus.h>
 #include <glib.h>
 #include <dlog.h>
 #include <string.h>
 #include <fcntl.h>
-#include <errno.h>
 
+#include <gio/gio.h>
 #include "bluetooth-api.h"
 #include "bt-internal-types.h"
 
@@ -43,537 +43,22 @@ typedef struct {
        char *channel;
        char *address;
        char *uuid;
-       DBusGProxy *rfcomm_proxy;
+       GDBusProxy *rfcomm_proxy;
 } rfcomm_function_data_t;
 
 rfcomm_function_data_t *rfcomm_info;
 GSList *client_list;
 
-static bt_rfcomm_info_t *__bt_rfcomm_get_client_info(int socket_fd)
-{
-       GSList *l;
-       bt_rfcomm_info_t *client_info;
-
-       for (l = client_list; l != NULL; l = l->next) {
-               client_info = l->data;
-
-               if (client_info == NULL)
-                       continue;
-
-               if (socket_fd == client_info->fd)
-                       return client_info;
-       }
-
-       return NULL;
-}
-
-static int __bt_rfcomm_open_socket(char *dev_node)
-{
-       int socket_fd;
-
-       socket_fd = open(dev_node, O_RDWR | O_NOCTTY);
-
-       if (socket_fd < 0) {
-               BT_ERR("Can't open TTY : %s(%d)", dev_node, socket_fd);
-               return socket_fd;
-       }
-
-       BT_DBG("/dev/rfcomm fd = %d", socket_fd);
-
-       if (_bt_set_non_blocking_tty(socket_fd) < 0) {
-               /* Even if setting the tty fails we will continue */
-               BT_ERR("Unable to set /dev/rfcomm fd = %d", socket_fd);
-       }
-
-       return socket_fd;
-}
-
-static int __bt_rfcomm_disconnect_request(int socket_fd)
-{
-       DBusGConnection *conn;
-       DBusGProxy *adapter_proxy;
-       DBusGProxy *rfcomm_proxy;
-       GError *error = NULL;
-       bt_rfcomm_info_t *client_info;
-       gchar *device_path = NULL;
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-
-       retv_if(address == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
-
-       adapter_proxy = _bt_get_adapter_proxy();
-       retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       client_info = __bt_rfcomm_get_client_info(socket_fd);
-       retv_if(client_info == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_g_proxy_call(adapter_proxy, "FindDevice", NULL,
-                         G_TYPE_STRING, client_info->address, G_TYPE_INVALID,
-                         DBUS_TYPE_G_OBJECT_PATH, &device_path, G_TYPE_INVALID);
-
-       retv_if(device_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
-
-       rfcomm_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                                     device_path, BT_SERIAL_INTERFACE);
-
-       BT_DBG("device path: %s", device_path);
-       g_free(device_path);
-
-       retv_if(rfcomm_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       BT_DBG("device node: %s", client_info->dev_node);
-       if (!dbus_g_proxy_call(rfcomm_proxy, "Disconnect",
-                       &error,
-                       G_TYPE_STRING, client_info->dev_node,
-                       G_TYPE_INVALID, G_TYPE_INVALID)) {
-               if (error) {
-                       BT_ERR("Disconnect Call Error, %s", error->message);
-                       g_error_free(error);
-               }
-               g_object_unref(rfcomm_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-       g_object_unref(rfcomm_proxy);
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-static int __bt_rfcomm_disconnect_cb(void *data)
-{
-       int result = BLUETOOTH_ERROR_NONE;
-       bt_rfcomm_info_t *client_info = data;
-
-       retv_if(client_info == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       _bt_send_event(BT_RFCOMM_CLIENT_EVENT,
-               BLUETOOTH_EVENT_RFCOMM_DISCONNECTED,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_STRING, &client_info->address,
-               DBUS_TYPE_STRING, &client_info->uuid,
-               DBUS_TYPE_INT16, &client_info->fd,
-               DBUS_TYPE_INVALID);
-
-       client_list = g_slist_remove(client_list, client_info);
-
-       g_source_remove(client_info->io_event);
-       close(client_info->fd);
-       g_free(client_info->dev_node);
-       g_free(client_info->address);
-       g_free(client_info->uuid);
-       g_free(client_info);
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-static int __bt_rfcomm_cancel_connect_cb(void *data)
-{
-       int result = BLUETOOTH_ERROR_CANCEL_BY_USER;
-       bluetooth_rfcomm_connection_t conn_info;
-       request_info_t *req_info;
-       GArray *out_param1;
-       GArray *out_param2;
-
-       retv_if(rfcomm_info == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       req_info = _bt_get_request_info(rfcomm_info->req_id);
-
-       retv_if(req_info == NULL, BLUETOOTH_ERROR_INTERNAL);
-       retv_if(req_info->context == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       memset(&conn_info, 0x00, sizeof(bluetooth_rfcomm_connection_t));
-       conn_info.device_role = RFCOMM_ROLE_CLIENT;
-       g_strlcpy(conn_info.uuid, rfcomm_info->uuid,
-                               BLUETOOTH_UUID_STRING_MAX);
-       conn_info.socket_fd = -1;
-       _bt_convert_addr_string_to_type(conn_info.device_addr.addr,
-                                       rfcomm_info->address);
-
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-       g_array_append_vals(out_param1, &conn_info,
-                                       sizeof(bluetooth_rfcomm_connection_t));
-       g_array_append_vals(out_param2, &result, sizeof(int));
-
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
-
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
-
-       _bt_delete_request_list(req_info->req_id);
-
-       g_object_unref(rfcomm_info->rfcomm_proxy);
-       g_free(rfcomm_info->address);
-       g_free(rfcomm_info->uuid);
-       g_free(rfcomm_info->channel);
-       g_free(rfcomm_info);
-       rfcomm_info = NULL;
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
 static int __bt_rfcomm_terminate_client(int socket_fd)
 {
-       BT_DBG("+");
-
-       int result;
-       bt_rfcomm_info_t *client_info;
-
-       client_info = __bt_rfcomm_get_client_info(socket_fd);
-       retv_if(client_info == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
-
-       result = __bt_rfcomm_disconnect_request(socket_fd);
-
-       if (result != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Fail to disconnect socket");
-               return result;
-       }
-
-       /* Send the disconnected event after return the function */
-       g_idle_add((GSourceFunc)__bt_rfcomm_disconnect_cb, client_info);
-
        return BLUETOOTH_ERROR_NONE;
 }
 
-static gboolean __bt_rfcomm_client_data_received_cb(GIOChannel *chan,
-                                                       GIOCondition cond,
-                                                       gpointer data)
-{
-       char *buffer = NULL;
-       gsize len;
-       int result = BLUETOOTH_ERROR_NONE;
-       bt_rfcomm_info_t *client_info = data;
-
-       BT_DBG("condition: %d", cond);
-
-       retv_if(client_info == NULL, FALSE);
-
-       if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
-               BT_ERR("Unix client disconnected (fd=%d)\n", client_info->fd);
-               __bt_rfcomm_terminate_client(client_info->fd);
-               return FALSE;
-       }
-
-       buffer = g_malloc0(BT_RFCOMM_BUFFER_MAX + 1);
-
-       if (g_io_channel_read_chars(chan, buffer, BT_RFCOMM_BUFFER_MAX,
-                               &len, NULL) == G_IO_STATUS_ERROR) {
-               BT_ERR("IO Channel read error client");
-               g_free(buffer);
-               __bt_rfcomm_terminate_client(client_info->fd);
-               return FALSE;
-       }
-
-       if (len == 0) {
-               BT_ERR("Read failed len=%d, fd=%d\n", len, client_info->fd);
-               g_free(buffer);
-               __bt_rfcomm_terminate_client(client_info->fd);
-               return FALSE;
-       }
-
-       BT_DBG("%s  -  clientfd = %d", buffer, client_info->fd);
-
-       _bt_send_event(BT_RFCOMM_CLIENT_EVENT,
-               BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_INT16, &client_info->fd,
-               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-               &buffer, len,
-               DBUS_TYPE_INVALID);
-
-       g_free(buffer);
-
-       return TRUE;
-}
-
-static void __bt_rfcomm_connected_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                                      gpointer user_data)
-{
-       BT_DBG("+\n");
-       GError *err = NULL;
-       gchar *rfcomm_device_node;
-       int socket_fd = -1;
-       int result = BLUETOOTH_ERROR_NONE;
-       bt_rfcomm_info_t *client_info = NULL;
-       request_info_t *req_info;
-       bluetooth_rfcomm_connection_t conn_info;
-       GArray *out_param1;
-       GArray *out_param2;
-
-       dbus_g_proxy_end_call(proxy, call, &err,
-                       G_TYPE_STRING, &rfcomm_device_node, G_TYPE_INVALID);
-
-       g_object_unref(proxy);
-
-       if (rfcomm_info == NULL) {
-               BT_ERR("rfcomm_info == NULL");
-               goto done;
-       }
-
-       if (err != NULL) {
-               BT_ERR("Error occured in connecting port [%s]", err->message);
-
-               if (!strcmp("Host is down", err->message))
-                       result = BLUETOOTH_ERROR_HOST_DOWN;
-               else
-                       result = BLUETOOTH_ERROR_CONNECTION_ERROR;
-
-               goto dbus_return;
-       }
-
-       BT_DBG("Success Connect REMOTE Device RFCOMM Node[%s]", rfcomm_device_node);
-
-       socket_fd = __bt_rfcomm_open_socket(rfcomm_device_node);
-
-       if (socket_fd < 0) {
-               int retry_count = 10;
-               do {
-                       BT_ERR("Fail to open socket[%d] retry_count[%d]", socket_fd, retry_count);
-                       usleep(10*1000);                /* 10 ms */
-                       socket_fd = __bt_rfcomm_open_socket(rfcomm_device_node);
-               } while (socket_fd < 0 && retry_count-- > 0);
-
-               if (socket_fd < 0) {
-                       BT_ERR("Fail to open socket: %d", socket_fd);
-                       goto dbus_return;
-               }
-       }
-
-       client_info = g_malloc0(sizeof(bt_rfcomm_info_t));
-
-       client_info->fd = socket_fd;
-       client_info->dev_node = g_strdup(rfcomm_device_node);
-       client_info->address = g_strdup(rfcomm_info->address);
-       client_info->uuid = g_strdup(rfcomm_info->uuid);
-       client_info->io_channel = g_io_channel_unix_new(socket_fd);
-       g_io_channel_set_encoding(client_info->io_channel, NULL, NULL);
-       client_info->io_event = g_io_add_watch(client_info->io_channel,
-                               G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
-                               __bt_rfcomm_client_data_received_cb,
-                               client_info);
-
-       g_io_channel_set_close_on_unref(client_info->io_channel, TRUE);
-       g_io_channel_set_flags(client_info->io_channel,
-                               G_IO_FLAG_NONBLOCK, NULL);
-
-       client_list = g_slist_append(client_list, client_info);
-
-       _bt_send_event(BT_RFCOMM_CLIENT_EVENT,
-               BLUETOOTH_EVENT_RFCOMM_CONNECTED,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_STRING, &rfcomm_info->address,
-               DBUS_TYPE_STRING, &rfcomm_info->uuid,
-               DBUS_TYPE_INT16, &socket_fd,
-               DBUS_TYPE_INVALID);
-
-dbus_return:
-       req_info = _bt_get_request_info(rfcomm_info->req_id);
-
-       if (req_info == NULL || req_info->context == NULL)
-               goto done;
-
-       memset(&conn_info, 0x00, sizeof(bluetooth_rfcomm_connection_t));
-       conn_info.device_role = RFCOMM_ROLE_CLIENT;
-       g_strlcpy(conn_info.uuid, rfcomm_info->uuid,
-                               BLUETOOTH_UUID_STRING_MAX);
-
-       if (client_info)
-               conn_info.socket_fd = client_info->fd;
-       else
-               conn_info.socket_fd = -1;
-
-       _bt_convert_addr_string_to_type(conn_info.device_addr.addr,
-                                       rfcomm_info->address);
-
-       out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-       out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-       g_array_append_vals(out_param1, &conn_info,
-                                       sizeof(bluetooth_rfcomm_connection_t));
-       g_array_append_vals(out_param2, &result, sizeof(int));
-       dbus_g_method_return(req_info->context, out_param1, out_param2);
-
-       g_array_free(out_param1, TRUE);
-       g_array_free(out_param2, TRUE);
-       _bt_delete_request_list(req_info->req_id);
-done:
-       if (err)
-               g_error_free(err);
-
-       ret_if(rfcomm_info == NULL);
-
-       g_free(rfcomm_info->address);
-       g_free(rfcomm_info->uuid);
-       g_free(rfcomm_info->channel);
-       g_free(rfcomm_info);
-       rfcomm_info = NULL;
-}
-
-static void __bt_rfcomm_discover_services_cb(DBusGProxy *proxy, DBusGProxyCall *call,
-                                                   gpointer user_data)
-{
-       GError *err = NULL;
-       GHashTable *hash = NULL;
-       const char *dev_path = NULL;
-       DBusGConnection *conn;
-       DBusGProxy *rfcomm_proxy;
-       int result = BLUETOOTH_ERROR_NONE;
-       GArray *out_param1;
-       GArray *out_param2;
-       request_info_t *req_info;
-       bluetooth_rfcomm_connection_t conn_info;
-
-       dbus_g_proxy_end_call(proxy, call, &err,
-                       dbus_g_type_get_map("GHashTable",
-                       G_TYPE_UINT, G_TYPE_STRING),
-                       &hash, G_TYPE_INVALID);
-
-       if (err != NULL) {
-               BT_ERR("Error occured in Proxy call [%s]\n", err->message);
-               result = BLUETOOTH_ERROR_CONNECTION_ERROR;
-               g_error_free(err);
-               goto fail;
-       }
-
-       g_hash_table_destroy(hash);
-
-       if (rfcomm_info == NULL) {
-               result = BLUETOOTH_ERROR_INTERNAL;
-               goto fail;
-       }
-
-       conn = _bt_get_system_gconn();
-       if (conn == NULL) {
-               BT_ERR("ERROR: Can't get on system bus");
-               result = BLUETOOTH_ERROR_INTERNAL;
-               goto fail;
-       }
-
-       dev_path = dbus_g_proxy_get_path(proxy);
-
-       rfcomm_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                                               dev_path,
-                                               BT_SERIAL_INTERFACE);
-
-       g_object_unref(proxy);
-       proxy = NULL;
-
-       if (rfcomm_proxy == NULL) {
-               BT_ERR("Failed to get the rfcomm proxy\n");
-               result = BLUETOOTH_ERROR_SERVICE_NOT_FOUND;
-               goto fail;
-       }
-
-       rfcomm_info->rfcomm_proxy = rfcomm_proxy;
-
-       if (!dbus_g_proxy_begin_call(rfcomm_proxy, "Connect",
-                       (DBusGProxyCallNotify)__bt_rfcomm_connected_cb,
-                       NULL,   /*user_data*/
-                       NULL,   /*destroy*/
-                       G_TYPE_STRING, rfcomm_info->uuid,
-                       G_TYPE_INVALID)) {
-               BT_ERR("RFCOMM connect Dbus Call Error");
-               g_object_unref(rfcomm_proxy);
-               result = BLUETOOTH_ERROR_INTERNAL;
-               goto fail;
-       }
-
-       BT_DBG("-\n");
-
-       return;
-fail:
-       if (proxy)
-               g_object_unref(proxy);
-
-       ret_if(rfcomm_info == NULL);
-
-       req_info = _bt_get_request_info(rfcomm_info->req_id);
-
-       if (req_info && req_info->context) {
-               memset(&conn_info, 0x00, sizeof(bluetooth_rfcomm_connection_t));
-
-               conn_info.device_role = RFCOMM_ROLE_CLIENT;
-               g_strlcpy(conn_info.uuid, rfcomm_info->uuid,
-                                       BLUETOOTH_UUID_STRING_MAX);
-
-               conn_info.socket_fd = -1;
-               _bt_convert_addr_string_to_type(conn_info.device_addr.addr,
-                                               rfcomm_info->address);
-
-               out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-               out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-               g_array_append_vals(out_param1, &conn_info,
-                                               sizeof(bluetooth_rfcomm_connection_t));
-               g_array_append_vals(out_param2, &result, sizeof(int));
-
-               dbus_g_method_return(req_info->context, out_param1, out_param2);
-
-               g_array_free(out_param1, TRUE);
-               g_array_free(out_param2, TRUE);
-               _bt_delete_request_list(req_info->req_id);
-       }
-
-       g_free(rfcomm_info->address);
-       g_free(rfcomm_info->uuid);
-       g_free(rfcomm_info);
-       rfcomm_info = NULL;
-}
 
 int _bt_rfcomm_connect_using_uuid(int request_id,
                        bluetooth_device_address_t *device_address,
                        char *remote_uuid)
 {
-       DBusGConnection *conn;
-       DBusGProxy *adapter_proxy;
-       DBusGProxy *device_proxy;
-       gchar *device_path = NULL;
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-
-       BT_CHECK_PARAMETER(address, return);
-       BT_CHECK_PARAMETER(remote_uuid, return);
-       retv_if(rfcomm_info != NULL, BLUETOOTH_ERROR_DEVICE_BUSY);
-
-       adapter_proxy = _bt_get_adapter_proxy();
-       retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       _bt_convert_addr_type_to_string(address, device_address->addr);
-
-       dbus_g_proxy_call(adapter_proxy, "FindDevice", NULL,
-                         G_TYPE_STRING, address, G_TYPE_INVALID,
-                         DBUS_TYPE_G_OBJECT_PATH, &device_path, G_TYPE_INVALID);
-
-       retv_if(device_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
-
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                                     device_path, BT_DEVICE_INTERFACE);
-       g_free(device_path);
-       retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       rfcomm_info = g_malloc0(sizeof(rfcomm_function_data_t));
-       rfcomm_info->address = g_strdup(address);
-       rfcomm_info->uuid = g_strdup(remote_uuid);
-       rfcomm_info->req_id = request_id;
-
-       if (!dbus_g_proxy_begin_call(device_proxy, "DiscoverServices",
-                       (DBusGProxyCallNotify)__bt_rfcomm_discover_services_cb,
-                       NULL, NULL,
-                       G_TYPE_STRING, rfcomm_info->uuid,
-                       G_TYPE_INVALID)) {
-               BT_ERR("Could not call dbus proxy\n");
-               g_object_unref(device_proxy);
-               g_free(rfcomm_info->address);
-               g_free(rfcomm_info->uuid);
-               g_free(rfcomm_info);
-               rfcomm_info = NULL;
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
        return BLUETOOTH_ERROR_NONE;
 }
 
@@ -582,130 +67,23 @@ int _bt_rfcomm_connect_using_channel(int request_id,
                        bluetooth_device_address_t *device_address,
                        char *channel)
 {
-       DBusGConnection *conn;
-       DBusGProxy *adapter_proxy;
-       DBusGProxy *device_proxy;
-       gchar *device_path = NULL;
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-
-       BT_CHECK_PARAMETER(address, return);
-       retv_if(rfcomm_info != NULL, BLUETOOTH_ERROR_DEVICE_BUSY);
-
-       adapter_proxy = _bt_get_adapter_proxy();
-       retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       conn = _bt_get_system_gconn();
-       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       _bt_convert_addr_type_to_string(address, device_address->addr);
-
-       dbus_g_proxy_call(adapter_proxy, "FindDevice", NULL,
-                         G_TYPE_STRING, address, G_TYPE_INVALID,
-                         DBUS_TYPE_G_OBJECT_PATH, &device_path, G_TYPE_INVALID);
-
-       retv_if(device_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
-
-       device_proxy = dbus_g_proxy_new_for_name(conn, BT_BLUEZ_NAME,
-                                               device_path,
-                                               BT_SERIAL_INTERFACE);
-       g_free(device_path);
-       retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       rfcomm_info = g_malloc0(sizeof(rfcomm_function_data_t));
-       rfcomm_info->address = g_strdup(address);
-       rfcomm_info->channel = g_strdup(channel);
-       rfcomm_info->req_id = request_id;
-       rfcomm_info->rfcomm_proxy = device_proxy;
-
-       if (!dbus_g_proxy_begin_call(device_proxy, "Connect",
-                       (DBusGProxyCallNotify)__bt_rfcomm_connected_cb,
-                       NULL,   /*user_data*/
-                       NULL,   /*destroy*/
-                       G_TYPE_STRING, channel,
-                       G_TYPE_INVALID)) {
-               BT_ERR("RFCOMM connect Dbus Call Error");
-               g_object_unref(device_proxy);
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       BT_DBG("-\n");
-
        return BLUETOOTH_ERROR_NONE;
 }
 
 /* Be used in RFCOMM client /server */
 int _bt_rfcomm_disconnect(int socket_fd)
 {
-       bt_rfcomm_info_t *socket_info;
-
-       socket_info = __bt_rfcomm_get_client_info(socket_fd);
-       if (socket_info == NULL)
-               return _bt_rfcomm_server_disconnect(socket_fd);
-
        return __bt_rfcomm_terminate_client(socket_fd);
 }
 
 /* Be used in RFCOMM client /server */
 int _bt_rfcomm_write(int socket_fd, char *buf, int length)
 {
-       int wbytes = 0;
-       int written;
-
-       retv_if(buf == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
-
-       /* Sometimes user may send huge data */
-       while (wbytes < length) {
-               written = write(socket_fd, buf + wbytes, length - wbytes);
-               if (written <= 0) {
-                       BT_ERR("write failed..\n");
-                       return BLUETOOTH_ERROR_NOT_IN_OPERATION;
-               }
-
-               /* Synchronize the sending buffer */
-               sync();
-               fsync(socket_fd);
-
-               wbytes += written;
-       }
-
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_rfcomm_cancel_connect(void)
 {
-       GError *error = NULL;
-       char *input_param;
-
-       BT_DBG("+");
-
-       retv_if(rfcomm_info == NULL, BLUETOOTH_ERROR_NOT_IN_OPERATION);
-       retv_if(rfcomm_info->rfcomm_proxy == NULL,
-                               BLUETOOTH_ERROR_INTERNAL);
-
-       if (rfcomm_info->uuid)
-               input_param = rfcomm_info->uuid;
-       else
-               input_param = rfcomm_info->channel;
-
-       retv_if(input_param == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       if (!dbus_g_proxy_call(rfcomm_info->rfcomm_proxy,
-                       "Disconnect",
-                       &error,
-                       G_TYPE_STRING, input_param,
-                       G_TYPE_INVALID, G_TYPE_INVALID)) {
-               if (error) {
-                       BT_ERR("Disconnect Dbus Call Error, %s", error->message);
-                       g_error_free(error);
-               }
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       /* Send the connected event after return the function */
-       g_idle_add((GSourceFunc) __bt_rfcomm_cancel_connect_cb, NULL);
-
-       BT_DBG("-");
-
        return BLUETOOTH_ERROR_NONE;
 }
 
index a879cd2..1710da6 100644 (file)
@@ -21,8 +21,8 @@
  *
  */
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
+//#include <dbus/dbus-glib.h>
+//#include <dbus/dbus.h>
 #include <glib.h>
 #include <dlog.h>
 #include <string.h>
@@ -52,81 +52,12 @@ typedef struct {
 } bt_rfcomm_event_info_t;
 
 GSList *server_list;
-static int latest_id = -1;
-static gboolean server_id_used[BT_RFCOMM_SERVER_ID_MAX];
-
-int __bt_rfcomm_assign_server_id(void)
-{
-       int index;
-
-       BT_DBG("latest_id: %d", latest_id);
-
-       index = latest_id + 1;
-
-       if (index >= BT_RFCOMM_SERVER_ID_MAX)
-               index = 0;
-
-       BT_DBG("index: %d", index);
-
-       while (server_id_used[index] == TRUE) {
-               if (index == latest_id) {
-                       /* No available ID */
-                       BT_ERR("All request ID is used");
-                       return -1;
-               }
-
-               index++;
-
-               if (index >= BT_RFCOMM_SERVER_ID_MAX)
-                       index = 0;
-       }
-
-       latest_id = index;
-       server_id_used[index] = TRUE;
-
-       BT_DBG("Assigned Id: %d", latest_id);
-
-       return latest_id;
-}
-
-void __bt_rfcomm_delete_server_id(int server_id)
-{
-       ret_if(server_id >= BT_RFCOMM_SERVER_ID_MAX);
-       ret_if(server_id < 0);
-
-       server_id_used[server_id] = FALSE;
-
-       /* Next server will use this ID */
-       latest_id = server_id - 1;
-}
-
-
-static bt_rfcomm_server_info_t *__bt_rfcomm_get_server_info(int control_fd)
-{
-       GSList *l;
-       bt_rfcomm_server_info_t *server_info;
-
-       retv_if(control_fd <= 0, NULL);
-
-       for (l = server_list; l != NULL; l = l->next) {
-               server_info = l->data;
-
-               if (server_info == NULL)
-                       continue;
-
-               if (control_fd == server_info->control_fd)
-                       return server_info;
-       }
-
-       return NULL;
-}
-
-static bt_rfcomm_server_info_t *__bt_rfcomm_get_server_info_using_data_fd(int data_fd)
+bt_rfcomm_server_info_t *_bt_rfcomm_get_server_info_using_uuid(char *uuid)
 {
        GSList *l;
        bt_rfcomm_server_info_t *server_info;
 
-       retv_if(data_fd <= 0, NULL);
+       retv_if(uuid == NULL, NULL);
 
        for (l = server_list; l != NULL; l = l->next) {
                server_info = l->data;
@@ -134,657 +65,41 @@ static bt_rfcomm_server_info_t *__bt_rfcomm_get_server_info_using_data_fd(int da
                if (server_info == NULL)
                        continue;
 
-               if (data_fd == server_info->data_fd)
+               if (g_strcmp0(server_info->uuid, uuid) == 0)
                        return server_info;
        }
 
        return NULL;
 }
 
-static DBusGProxy *__bt_rfcomm_get_serial_manager_proxy(void)
-{
-       DBusGProxy *proxy;
-       DBusGConnection *g_conn;
-       char *adapter_path;
-
-       BT_DBG("+");
-
-       g_conn = _bt_get_system_gconn();
-       retv_if(g_conn == NULL, NULL);
-
-       adapter_path = _bt_get_adapter_path();
-       retv_if(adapter_path == NULL, NULL);
-
-       proxy = dbus_g_proxy_new_for_name(g_conn, BT_BLUEZ_NAME,
-                       adapter_path, BT_SERIAL_MANAGER_INTERFACE);
-
-       g_free(adapter_path);
-
-       BT_DBG("-");
-
-       return proxy;
-}
-
-static DBusGProxy *__bt_get_serial_proxy(char *serial_path)
-{
-       DBusGProxy *proxy;
-       DBusGConnection *g_conn;
-
-       g_conn = _bt_get_system_gconn();
-       retv_if(g_conn == NULL, NULL);
-
-       proxy = dbus_g_proxy_new_for_name(g_conn, BT_BLUEZ_NAME,
-                       serial_path, BT_SERIAL_PROXY_INTERFACE);
-
-       return proxy;
-}
-
-static char *__bt_rfcomm_get_proxy_address(int server_id)
-{
-       BT_DBG("+");
-
-       return g_strdup_printf("%s%d",
-                               BT_RFCOMM_PROXY_ADDRESS,
-                               server_id);
-}
-
-int __bt_rfcomm_get_socket(int server_id)
-{
-       int result;
-       int socket_fd;
-       char *socket_address = NULL;
-       struct sockaddr_un server_addr;
-
-       retv_if(server_id < 0, -1);
-
-       socket_fd = socket(AF_UNIX, SOCK_STREAM, 0);
-       retv_if(socket_fd < 0, -1);
-
-       memset(&server_addr, 0, sizeof(server_addr));
-       server_addr.sun_family = PF_UNIX;
-
-       socket_address = g_strdup_printf("%s%d",
-                               BT_RFCOMM_SOCKET_ADDRESS,
-                               server_id);
-
-       BT_DBG("socket_address: %s", socket_address);
-
-       g_strlcpy(server_addr.sun_path + 1, socket_address,
-                                       sizeof(server_addr.sun_path));
-
-       if (bind(socket_fd, (struct sockaddr *)&server_addr,
-                                       sizeof(server_addr)) < 0) {
-               BT_ERR("Can't Bind Sock");
-               goto fail;
-       }
-
-       BT_DBG("socket_fd = %d", socket_fd);
-
-       result = _bt_set_socket_non_blocking(socket_fd);
-
-       if (result != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Cannot set the tty");
-               goto fail;
-       }
-
-       g_free(socket_address);
-       return socket_fd;
-fail:
-       g_free(socket_address);
-       close(socket_fd);
-       return -1;
-}
-
 int _bt_rfcomm_create_socket(char *sender, char *uuid)
 {
-       DBusGProxy *serial_manager = NULL;
-       DBusGProxy *serial_proxy = NULL;
-       GError *error = NULL;
-       char *proxy_address = NULL;
-       char *serial_path = NULL;
-       int server_id;
-       int socket_fd;
-       bt_rfcomm_server_info_t *server_info;
-
-       BT_CHECK_PARAMETER(uuid, return);
-
-       server_id = __bt_rfcomm_assign_server_id();
-       retv_if(server_id < 0, BLUETOOTH_ERROR_INTERNAL);
-
-       serial_manager = __bt_rfcomm_get_serial_manager_proxy();
-       if (serial_manager == NULL)
-               goto fail;
-
-       proxy_address = __bt_rfcomm_get_proxy_address(server_id);
-       if (proxy_address == NULL)
-               goto fail;
-
-       dbus_g_proxy_call(serial_manager, "CreateProxy", NULL,
-                       G_TYPE_STRING, uuid,
-                       G_TYPE_STRING, proxy_address,
-                       G_TYPE_INVALID,
-                       G_TYPE_STRING, &serial_path,
-                       G_TYPE_INVALID);
-
-       if (serial_path == NULL)
-               goto fail;
-
-       BT_DBG("serial_path: %s", serial_path);
-
-       serial_proxy = __bt_get_serial_proxy(serial_path);
-       if (serial_proxy == NULL)
-               goto fail;
-
-       if (!dbus_g_proxy_call(serial_proxy, "Enable", &error,
-                       G_TYPE_INVALID, G_TYPE_INVALID)) {
-               if (error != NULL) {
-                       BT_ERR("Enable Error: %s\n", error->message);
-                       g_error_free(error);
-               }
-               goto fail;
-       }
-
-       socket_fd = __bt_rfcomm_get_socket(server_id);
-       if (socket_fd < 0) {
-               BT_ERR("Can't get socket");
-               goto fail;
-       }
-
-       server_info = g_malloc0(sizeof(bt_rfcomm_server_info_t));
-       server_info->server_id = server_id;
-       server_info->serial_proxy = serial_proxy;
-       server_info->manager_proxy = serial_manager;
-       server_info->serial_path = g_strdup(serial_path);
-       server_info->uuid = g_strdup(uuid);
-       server_info->sender = g_strdup(sender);
-       server_info->control_fd = socket_fd;
-
-       server_list = g_slist_append(server_list, server_info);
-
-       g_free(proxy_address);
-
-       return socket_fd;
-fail:
-       __bt_rfcomm_delete_server_id(server_id);
-       g_free(proxy_address);
-
-       if (serial_manager) {
-               if (serial_path) {
-                       dbus_g_proxy_call(serial_manager, "RemoveProxy", NULL,
-                                       G_TYPE_STRING, serial_path,
-                                       G_TYPE_INVALID,
-                                       G_TYPE_INVALID);
-               }
-               g_object_unref(serial_manager);
-       }
-
-       if (serial_proxy)
-               g_object_unref(serial_proxy);
-
        return BLUETOOTH_ERROR_INTERNAL;
 }
 
-static gboolean __bt_rfcomm_server_data_received_cb(GIOChannel *chan,
-                                               GIOCondition cond,
-                                               gpointer data)
-{
-       char *buffer = NULL;
-       gsize len;
-       int result = BLUETOOTH_ERROR_NONE;
-       bt_rfcomm_server_info_t *server_info = data;
-
-       retv_if(server_info == NULL, FALSE);
-
-       if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) {
-               BT_ERR("Unix server  disconnected: %d", server_info->data_fd);
-               _bt_rfcomm_server_disconnect(server_info->data_fd);
-               return FALSE;
-       }
-
-       buffer = g_malloc0(BT_RFCOMM_BUFFER_MAX + 1);
-
-       if (g_io_channel_read_chars(chan, buffer, BT_RFCOMM_BUFFER_MAX, &len, NULL) ==
-                                                       G_IO_STATUS_ERROR) {
-               BT_ERR("IO Channel read error server");
-               g_free(buffer);
-               _bt_rfcomm_server_disconnect(server_info->data_fd);
-               return FALSE;
-       }
-
-       if (len == 0) {
-               BT_ERR("Read failed len=%d, fd=%d\n",
-                               len, server_info->data_fd);
-               g_free(buffer);
-               _bt_rfcomm_server_disconnect(server_info->data_fd);
-               return FALSE;
-       }
-
-       _bt_send_event(BT_RFCOMM_SERVER_EVENT,
-               BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_INT16, &server_info->data_fd,
-               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
-               &buffer, len,
-               DBUS_TYPE_INVALID);
-
-       g_free(buffer);
-
-       return TRUE;
-}
-
 int __bt_rfcomm_server_get_address(bt_rfcomm_server_info_t *server_info)
 {
-       DBusMessage *msg;
-       DBusMessage *reply;
-       DBusError error;
-       DBusMessageIter reply_iter;
-       DBusMessageIter reply_iter_entry;
-       DBusConnection *conn;
-       const char *property;
-
-       BT_CHECK_PARAMETER(server_info, return);
-
-       /* GetInfo Proxy Part */
-       msg = dbus_message_new_method_call(BT_BLUEZ_NAME,
-                                       server_info->serial_path,
-                                       BT_SERIAL_PROXY_INTERFACE,
-                                       "GetInfo");
-
-       retv_if(msg == NULL, BLUETOOTH_ERROR_INTERNAL);
-
-       dbus_error_init(&error);
-
-       conn = _bt_get_system_conn();
-
-       reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &error);
-       dbus_message_unref(msg);
-
-       if (reply == NULL) {
-               BT_ERR("Can't Call GetInfo Proxy");
-               if (dbus_error_is_set(&error)) {
-                       BT_ERR("%s", error.message);
-                       dbus_error_free(&error);
-               }
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       dbus_message_iter_init(reply, &reply_iter);
-
-       if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_ARRAY) {
-               BT_ERR("Can't get reply arguments - DBUS_TYPE_ARRAY");
-               goto fail;
-       }
-
-       dbus_message_iter_recurse(&reply_iter, &reply_iter_entry);
-
-       /*Parse the dict */
-       while (dbus_message_iter_get_arg_type(&reply_iter_entry) ==
-                                               DBUS_TYPE_DICT_ENTRY) {
-               DBusMessageIter dict_entry;
-               DBusMessageIter dict_entry_val;
-
-               dbus_message_iter_recurse(&reply_iter_entry, &dict_entry);
-
-               dbus_message_iter_get_basic(&dict_entry, &property);
-
-               if (g_strcmp0("connected", property) == 0) {
-                       dbus_bool_t value;
-
-                       dbus_message_iter_next(&dict_entry);
-                       dbus_message_iter_recurse(&dict_entry, &dict_entry_val);
-                       dbus_message_iter_get_basic(&dict_entry_val, &value);
-
-                       if (value == FALSE)
-                               goto fail;
-
-                       /*Parsing the address */
-                       dbus_message_iter_next(&reply_iter_entry);
-                       dbus_message_iter_recurse(&reply_iter_entry, &dict_entry);
-                       dbus_message_iter_get_basic(&dict_entry, &property);
-                       BT_DBG("String received...... = %s", property);
-
-                       if (g_strcmp0("address", property) == 0) {
-                               if (!dbus_message_iter_next(&dict_entry)) {
-                                       BT_ERR("Failed getting next dict entry\n");
-                                       goto fail;
-                               }
-
-                               if (dbus_message_iter_get_arg_type(&dict_entry) !=
-                                                               DBUS_TYPE_VARIANT) {
-                                       BT_ERR("Failed get arg type varient\n");
-                                       goto fail;
-                               }
-
-                               /*Getting the value of the varient*/
-                               dbus_message_iter_recurse(&dict_entry,
-                                                         &dict_entry_val);
-
-                               if (dbus_message_iter_get_arg_type(&dict_entry_val) !=
-                                                                       DBUS_TYPE_STRING) {
-                                       BT_ERR("Failed get arg type string\n");
-                                       goto fail;
-                               }
-
-                               /*get  value string address*/
-                               dbus_message_iter_get_basic(&dict_entry_val, &property);
-
-                               BT_DBG("Address = %s\n", property);
-
-                               g_free(server_info->remote_address);
-                               server_info->remote_address = g_strdup(property);
-                       }
-
-               }
-
-               dbus_message_iter_next(&reply_iter_entry);
-       }
-
-       dbus_message_unref(reply);
-
        return BLUETOOTH_ERROR_NONE;
-
-fail:
-       dbus_message_unref(reply);
-       return BLUETOOTH_ERROR_INTERNAL;
-}
-
-static gboolean __bt_rfcomm_server_connected_cb(GIOChannel *chan,
-                                                       GIOCondition cond,
-                                                       gpointer data)
-{
-       bt_rfcomm_server_info_t *server_info;
-       request_info_t *req_info;
-       int client_sock;
-       int addr_len;
-       struct sockaddr_un sock_addr;
-       int result = BLUETOOTH_ERROR_NONE;
-
-       BT_DBG("rfcomm_server.server_io_channel has %d", cond);
-
-       server_info = data;
-       retv_if(server_info == NULL, FALSE);
-
-       if (cond & G_IO_NVAL)
-               return FALSE;
-
-       if (cond & (G_IO_HUP | G_IO_ERR)) {
-               _bt_rfcomm_remove_socket(server_info->control_fd);
-               return FALSE;
-       }
-
-       memset(&sock_addr, 0, sizeof(struct sockaddr_un));
-       addr_len = sizeof(struct sockaddr_un);
-
-       client_sock = accept(server_info->control_fd,
-                            (struct sockaddr *)&sock_addr,
-                            (socklen_t *)&addr_len);
-
-       if (client_sock < 0) {
-               BT_ERR("Server Accept Error");
-               return TRUE;
-
-       } else {
-               BT_DBG("Accept Client Sock.(%d)\n", client_sock);
-
-       }
-
-       if (_bt_set_non_blocking_tty(client_sock) < 0) {
-               /* Even if setting the tty fails we will continue */
-               BT_ERR("Setting the tty properties failed(%d)\n", client_sock);
-       }
-
-       server_info->data_fd = client_sock;
-       server_info->data_io = g_io_channel_unix_new(client_sock);
-
-       g_io_channel_set_encoding(server_info->data_io, NULL, NULL);
-       g_io_channel_set_flags(server_info->data_io, G_IO_FLAG_NONBLOCK, NULL);
-       g_io_channel_set_close_on_unref(server_info->data_io, TRUE);
-
-       server_info->data_id =
-           g_io_add_watch(server_info->data_io,
-                          G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
-                          __bt_rfcomm_server_data_received_cb, server_info);
-
-       g_io_channel_unref(server_info->data_io);
-
-       __bt_rfcomm_server_get_address(server_info);
-
-       if (server_info->remote_address == NULL)
-               server_info->remote_address = g_strdup("");
-
-       if (server_info->server_type == BT_CUSTOM_SERVER) {
-               int result;
-               GArray *out_param1;
-               GArray *out_param2;
-
-               req_info = _bt_get_request_info(server_info->accept_id);
-               if (req_info == NULL || req_info->context == NULL) {
-                       BT_ERR("info is NULL");
-                       goto done;
-               }
-
-               server_info->accept_id = 0;
-               result = BLUETOOTH_ERROR_NONE;
-
-               out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
-               out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
-
-               g_array_append_vals(out_param1, &server_info->data_fd,
-                                       sizeof(int));
-               g_array_append_vals(out_param2, &result, sizeof(int));
-
-               dbus_g_method_return(req_info->context, out_param1, out_param2);
-
-               g_array_free(out_param1, TRUE);
-               g_array_free(out_param2, TRUE);
-
-               _bt_delete_request_list(req_info->req_id);
-       }
-
-done:
-       _bt_send_event(BT_RFCOMM_SERVER_EVENT,
-               BLUETOOTH_EVENT_RFCOMM_CONNECTED,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_STRING, &server_info->remote_address,
-               DBUS_TYPE_STRING, &server_info->uuid,
-               DBUS_TYPE_INT16, &server_info->data_fd,
-               DBUS_TYPE_INVALID);
-
-       BT_DBG("-");
-       return TRUE;
 }
 
-
 int _bt_rfcomm_listen(int socket_fd, int max_pending, gboolean is_native)
 {
-       int io_id;
-       bt_rfcomm_server_info_t *server_info;
-       GIOChannel *io_channel;
-
-       server_info = __bt_rfcomm_get_server_info(socket_fd);
-       retv_if(server_info == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
-       retv_if(server_info->control_io != NULL, BLUETOOTH_ERROR_DEVICE_BUSY);
-
-       if (listen(socket_fd, max_pending) != 0) {
-               BT_ERR("Fail to listen");
-               return BLUETOOTH_ERROR_INTERNAL;
-       }
-
-       io_channel = g_io_channel_unix_new(socket_fd);
-       server_info->control_io = io_channel;
-
-       g_io_channel_set_close_on_unref(io_channel, TRUE);
-       g_io_channel_set_encoding(io_channel, NULL, NULL);
-       g_io_channel_set_flags(io_channel, G_IO_FLAG_NONBLOCK, NULL);
-
-       io_id = g_io_add_watch(io_channel,
-                          G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
-                          __bt_rfcomm_server_connected_cb,
-                          server_info);
-
-       server_info->control_id = io_id;
-       g_io_channel_unref(io_channel);
-
-       /* BT_CUSTOM_SERVER / BT_NATIVE_SERVER*/
-       if (is_native) {
-               server_info->server_type = BT_NATIVE_SERVER;
-       } else {
-               server_info->server_type = BT_CUSTOM_SERVER;
-               _bt_register_osp_server_in_agent(BT_RFCOMM_SERVER,
-                                               server_info->uuid, NULL, -1);
-       }
-
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_rfcomm_remove_socket(int socket_fd)
 {
-       bt_rfcomm_server_info_t *server_info;
-       int result = BLUETOOTH_ERROR_NONE;
-
-       BT_DBG("+");
-
-       server_info = __bt_rfcomm_get_server_info(socket_fd);
-       retv_if(server_info == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
-
-       if (server_info->serial_proxy) {
-               if (!dbus_g_proxy_call(server_info->serial_proxy, "Disable",
-                                       NULL,
-                                       G_TYPE_INVALID,
-                                       G_TYPE_INVALID)) {
-                       BT_ERR("Fail to disable");
-               }
-       }
-
-       if (server_info->manager_proxy && server_info->serial_path) {
-               if (!dbus_g_proxy_call(server_info->manager_proxy,
-                               "RemoveProxy", NULL,
-                               G_TYPE_STRING, server_info->serial_path,
-                               G_TYPE_INVALID,
-                               G_TYPE_INVALID)) {
-                       BT_ERR("Fail to remove proxy");
-               }
-       }
-
-       if (server_info->server_type == BT_CUSTOM_SERVER) {
-               _bt_unregister_osp_server_in_agent(BT_RFCOMM_SERVER,
-                                               server_info->uuid);
-       }
-
-       _bt_send_event(BT_RFCOMM_SERVER_EVENT,
-               BLUETOOTH_EVENT_RFCOMM_SERVER_REMOVED,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_INT16, &server_info->data_fd,
-               DBUS_TYPE_INVALID);
-
-       _bt_rfcomm_server_disconnect(server_info->data_fd);
-
-       if (server_info->control_id > 0)
-               g_source_remove(server_info->control_id);
-
-       if (server_info->control_fd > 0)
-               close(server_info->control_fd);
-
-       server_list = g_slist_remove(server_list, server_info);
-
-       __bt_rfcomm_delete_server_id(server_info->server_id);
-
-       g_free(server_info->serial_path);
-       g_free(server_info->uuid);
-       g_free(server_info->sender);
-       g_free(server_info);
-
-       BT_DBG("-");
-
-       return BLUETOOTH_ERROR_NONE;
-}
-
-static int __bt_rfcomm_server_disconnect_cb(void *data)
-{
-       bt_rfcomm_event_info_t *event_info = data;
-       int result = BLUETOOTH_ERROR_NONE;
-
-       retv_if(event_info == NULL, BLUETOOTH_ERROR_NONE);
-       retv_if(event_info->uuid == NULL, BLUETOOTH_ERROR_NONE);
-
-       if (event_info->remote_address == NULL)
-               event_info->remote_address = g_strdup("");
-
-       _bt_send_event(BT_RFCOMM_SERVER_EVENT,
-               BLUETOOTH_EVENT_RFCOMM_DISCONNECTED,
-               DBUS_TYPE_INT32, &result,
-               DBUS_TYPE_STRING, &event_info->remote_address,
-               DBUS_TYPE_STRING, &event_info->uuid,
-               DBUS_TYPE_INT16, &event_info->data_fd,
-               DBUS_TYPE_INVALID);
-
-       g_free(event_info->uuid);
-       g_free(event_info->remote_address);
-       g_free(event_info);
-
        return BLUETOOTH_ERROR_NONE;
 }
 
 int _bt_rfcomm_server_disconnect(int data_fd)
 {
-       bt_rfcomm_server_info_t *server_info;
-       bt_rfcomm_event_info_t *event_info;
-
-       BT_DBG("+");
-
-       retv_if(data_fd <= 0, BLUETOOTH_ERROR_INVALID_PARAM);
-
-       server_info = __bt_rfcomm_get_server_info_using_data_fd(data_fd);
-       retv_if(server_info == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
-
-       if (server_info->data_id > 0)
-               g_source_remove(server_info->data_id);
-
-       if (server_info->data_fd > 0)
-               close(server_info->data_fd);
-
-       event_info = g_malloc0(sizeof(bt_rfcomm_event_info_t));
-       event_info->data_fd = server_info->data_fd;
-       event_info->remote_address = g_strdup(server_info->remote_address);
-       event_info->uuid = g_strdup(server_info->uuid);
-
-       /* Send the disconnected event after return the function */
-       g_idle_add((GSourceFunc)__bt_rfcomm_server_disconnect_cb, event_info);
-
-       g_free(server_info->remote_address);
-       server_info->remote_address = NULL;
-       server_info->data_fd = -1;
-       server_info->data_id = 0;
-       server_info->data_io = NULL;
-
-       BT_DBG("-");
-
        return BLUETOOTH_ERROR_NONE;
 }
 
 /* To support the BOT  */
 int _bt_rfcomm_is_uuid_available(char *uuid, gboolean *available)
 {
-       GSList *l;
-       bt_rfcomm_server_info_t *server_info;
-
-       BT_CHECK_PARAMETER(uuid, return);
-       BT_CHECK_PARAMETER(available, return);
-
-       *available = FALSE;
-
-       for (l = server_list; l != NULL; l = l->next) {
-               server_info = l->data;
-
-               if (server_info == NULL)
-                       continue;
-
-               if (g_ascii_strcasecmp(uuid, server_info->uuid) == 0) {
-                       *available = TRUE;
-                       return BLUETOOTH_ERROR_NONE;
-               }
-       }
-
        return BLUETOOTH_ERROR_NONE;
 }
 
@@ -810,26 +125,6 @@ int _bt_rfcomm_reject_connection(void)
        return BLUETOOTH_ERROR_NONE;
 }
 
-bt_rfcomm_server_info_t *_bt_rfcomm_get_server_info_using_uuid(char *uuid)
-{
-       GSList *l;
-       bt_rfcomm_server_info_t *server_info;
-
-       retv_if(uuid == NULL, NULL);
-
-       for (l = server_list; l != NULL; l = l->next) {
-               server_info = l->data;
-
-               if (server_info == NULL)
-                       continue;
-
-               if (g_strcmp0(server_info->uuid, uuid) == 0)
-                       return server_info;
-       }
-
-       return NULL;
-}
-
 int _bt_rfcomm_server_disconnect_all_connection(void)
 {
        GSList *l;
index 7a2b94f..b1aab41 100644 (file)
  */
 
 #include <string.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
 #include <glib.h>
 #include <dlog.h>
+#include <gio/gio.h>
 
 #include "bluetooth-api.h"
 #include "bt-service-common.h"
@@ -88,11 +87,13 @@ void _bt_init_request_list(void)
 
 /* insert request next to head */
 int _bt_insert_request_list(int req_id, int service_function,
-                       char *name, DBusGMethodInvocation *context)
+                       char *name, GDBusMethodInvocation *context)
 {
        request_info_t *info;
 
        info = g_malloc0(sizeof(request_info_t));
+       /* Fix : NULL_RETURNS */
+       retv_if(info == NULL, BLUETOOTH_ERROR_MEMORY_ALLOCATION);
 
        info->req_id = req_id;
        info->service_function = service_function;
index e29a80e..ab5fae2 100644 (file)
@@ -26,7 +26,6 @@
 #define _BT_REQUEST_HANDLER_H_
 
 #include <sys/types.h>
-#include <dbus/dbus-glib.h>
 #include <glib.h>
 #include <glib-object.h>
 
@@ -39,39 +38,10 @@ extern "C" {
 #define BT_SERVICE_NAME "org.projectx.bt"
 #define BT_SERVICE_PATH "/org/projectx/bt_service"
 
-#define BT_SERVICE_TYPE (bt_service_get_type())
-
-typedef struct _BtService
-{
-    GObject object;
-} BtService;
-
-typedef struct _BtServiceClass
-{
-    GObjectClass object_class;
-} BtServiceClass;
-
-gboolean bt_service_request(
-               BtService *service,
-               int service_type,
-               int service_function,
-               int request_type,
-               GArray* in_param1,
-               GArray* in_param2,
-               GArray* in_param3,
-               GArray* in_param4,
-               GArray* in_param5,
-               DBusGMethodInvocation *context);
-
 int _bt_service_register(void);
 
 void _bt_service_unregister(void);
 
-int _bt_service_cynara_init(void);
-
-void _bt_service_cynara_deinit(void);
-
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 6102f45..04f61b2 100644 (file)
 extern "C" {
 #endif
 
+#define BT_LE_SCAN_INTERVAL_MIN 2.5
+#define BT_LE_SCAN_INTERVAL_MAX 10240
+#define BT_LE_SCAN_WINDOW_MIN 2.5
+#define BT_LE_SCAN_WINDOW_MAX 10240
+
+typedef enum {
+       BT_LE_AD_TYPE_INCOMP_LIST_16_BIT_SERVICE_CLASS_UUIDS = 0x02,
+       BT_LE_AD_TYPE_COMP_LIST_16_BIT_SERVICE_CLASS_UUIDS = 0x03,
+       BT_LE_AD_TYPE_INCOMP_LIST_128_BIT_SERVICE_CLASS_UUIDS = 0x06,
+       BT_LE_AD_TYPE_COMP_LIST_128_BIT_SERVICE_CLASS_UUIDS = 0x07,
+       BT_LE_AD_TYPE_SHORTENED_LOCAL_NAME = 0x08,
+       BT_LE_AD_TYPE_COMPLETE_LOCAL_NAME = 0x09,
+       BT_LE_AD_TYPE_LIST_16_BIT_SERVICE_SOLICITATION_UUIDS = 0x14,
+       BT_LE_AD_TYPE_LIST_128_BIT_SERVICE_SOLICITATION_UUIDS = 0x15,
+       BT_LE_AD_TYPE_SERVICE_DATA = 0x16,
+       BT_LE_AD_TYPE_MANUFACTURER_SPECIFIC_DATA = 0xFF,
+} bt_le_advertising_data_type_e;
+
+typedef enum {
+       BT_LE_PASSIVE_SCAN = 0x00,
+       BT_LE_ACTIVE_SCAN
+} bt_le_scan_type_t;
+
+typedef struct {
+       char *addr;
+       int data_len;
+       char *data;
+} bt_le_adv_info_t;
+
 int _bt_service_adapter_le_init(void);
 
 void _bt_service_adapter_le_deinit(void);
@@ -41,26 +70,48 @@ gboolean _bt_update_le_feature_support(const char *item, const char *value);
 
 const char* _bt_get_adv_slot_owner(int slot_id);
 
+int _bt_get_adv_slot_adv_handle(int slot_id);
+
 void _bt_set_advertising_status(int slot_id, gboolean mode);
 
 gboolean _bt_is_advertising(void);
 
 void _bt_stop_advertising_by_terminated_process(const char* terminated_name);
 
-int _bt_set_advertising(gboolean enable, const char *sender, gboolean use_reserved_slot);
+int _bt_set_advertising(const char *sender, int adv_handle, gboolean enable, gboolean use_reserved_slot);
 
-int _bt_set_custom_advertising(gboolean enable, bluetooth_advertising_params_t *params, const char *sender, gboolean use_reserved_slot);
+int _bt_set_custom_advertising(const char *sender, int adv_handle, gboolean enable, bluetooth_advertising_params_t *params, gboolean use_reserved_slot);
 
 int _bt_get_advertising_data(bluetooth_advertising_data_t *adv, int *length);
 
-int _bt_set_advertising_data(bluetooth_advertising_data_t *data, int length, const char *sender, gboolean use_reserved_slot);
+int _bt_set_advertising_data(const char *sender, int adv_handle, bluetooth_advertising_data_t *data, int length, gboolean use_reserved_slot);
 
 int _bt_get_scan_response_data(bluetooth_scan_resp_data_t *response, int *length);
 
-int _bt_set_scan_response_data(bluetooth_scan_resp_data_t *response, int length, const char *sender, gboolean use_reserved_slot);
+int _bt_set_scan_response_data(const char *sender, int adv_handle, bluetooth_scan_resp_data_t *response, int length, gboolean use_reserved_slot);
 
 int _bt_set_scan_parameters(bluetooth_le_scan_params_t *params);
 
+int _bt_register_scan_filter(const char *sender, bluetooth_le_scan_filter_t *filter, int *slot_id);
+
+int _bt_unregister_scan_filter(const char *sender, int slot_id);
+
+int _bt_unregister_all_scan_filters(const char *sender);
+
+int _bt_start_le_scan(const char *sender);
+
+int _bt_stop_le_scan(const char *sender);
+
+void _bt_set_le_scan_status(gboolean mode);
+
+gboolean _bt_is_le_scanning(void);
+
+void _bt_set_le_scan_type(bt_le_scan_type_t type);
+
+bt_le_scan_type_t _bt_get_le_scan_type(void);
+
+void _bt_send_scan_result_event(const bt_remote_le_dev_info_t *le_dev_info, const bt_le_adv_info_t *adv_info);
+
 int _bt_add_white_list(bluetooth_device_address_t *device_address, bluetooth_device_address_type_t address_type);
 
 int _bt_remove_white_list(bluetooth_device_address_t *device_address, bluetooth_device_address_type_t address_type);
index b68c649..03c0c4d 100644 (file)
 extern "C" {
 #endif
 
-#define BT_LE_SCAN_INTERVAL_MIN 2.5
-#define BT_LE_SCAN_INTERVAL_MAX 10240
-#define BT_LE_SCAN_WINDOW_MIN 2.5
-#define BT_LE_SCAN_WINDOW_MAX 10240
-
 typedef enum {
        BT_DEACTIVATED,
        BT_ACTIVATED,
@@ -52,11 +47,6 @@ typedef enum {
        BT_LE_DEACTIVATING,
 } bt_le_status_t;
 
-typedef enum {
-       BT_LE_PASSIVE_SCAN = 0x00,
-       BT_LE_ACTIVE_SCAN
-} bt_le_discovery_type_t;
-
 int _bt_enable_adapter(void);
 
 int _bt_disable_adapter(void);
@@ -85,12 +75,6 @@ void _bt_service_unregister_vconf_handler(void);
 
 void _bt_set_discovery_status(gboolean mode);
 
-void _bt_set_le_discovery_status(gboolean mode);
-
-void _bt_set_le_discovery_type(bt_le_discovery_type_t type);
-
-bt_le_discovery_type_t _bt_get_le_discovery_type(void);
-
 int _bt_get_local_address(bluetooth_device_address_t *local_address);
 
 int _bt_get_local_version(bluetooth_version_t *local_version);
@@ -115,10 +99,6 @@ int _bt_start_custom_discovery(bt_discovery_role_type_t role);
 
 int _bt_cancel_discovery(void);
 
-int _bt_start_le_discovery(void);
-
-int _bt_stop_le_discovery(void);
-
 int _bt_get_bonded_devices(GArray **dev_list);
 
 int _bt_get_bonded_device_info(bluetooth_device_address_t *device_address,
@@ -128,8 +108,6 @@ int _bt_get_timeout_value(int *timeout);
 
 gboolean _bt_is_discovering(void);
 
-gboolean _bt_is_le_discovering(void);
-
 int _bt_enable_rssi(bluetooth_device_address_t *bd_addr, int link_type,
                int low_threshold, int in_range_threshold, int high_threshold);
 
@@ -150,10 +128,6 @@ void _bt_adapter_set_status(bt_status_t status);
 
 bt_status_t _bt_adapter_get_status(void);
 
-void _bt_handle_flight_mode_noti(void);
-
-int _bt_get_remote_found_devices(GArray **dev_list);
-
 void _bt_adapter_set_le_status(bt_le_status_t status);
 
 bt_le_status_t _bt_adapter_get_le_status(void);
@@ -170,6 +144,8 @@ int _bt_set_le_privacy(gboolean set_privacy);
 
 int _bt_set_manufacturer_data(bluetooth_manufacturer_data_t *m_data);
 
+int __bt_disable_cb(void);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 8b9040e..336a672 100644 (file)
 
 #include <stdint.h>
 #include <glib.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
 #include <unistd.h>
 #include <dlog.h>
-
 #include <stdio.h>
 
-#include <dbus/dbus-glib.h>
-
 #undef LOG_TAG
 #define LOG_TAG        "BLUETOOTH_FRWK_SERVICE"
 #define ERR(fmt, args...) SLOGE(fmt, ##args)
 
-#define BT_AGENT_PADDING_SIZE 4096
-#define BT_MAX_SERVICES_FOR_DEVICE     20     /**< This specifies maximum number of services a
-                                               device can support */
 #define BT_MAX_EVENT_STR_LENGTH        50
-#define BT_AGENT_ADDR_SIZE     18
-
-/* Define Error type */
-#define BT_AGENT_FAIL -1
-#define BT_AGENT_ERROR_NONE 0
 
 #ifndef TIZEN_WEARABLE
 #define BT_FILE_VISIBLE_TIME "file/private/libug-setting-bluetooth-efl/visibility_time"
@@ -65,49 +51,25 @@ typedef enum {
 } bt_agent_service_uuid_list_t;
 
 typedef enum {
-       BT_AGENT_EVENT_PIN_REQUEST = 0x0001,
-       BT_AGENT_EVENT_PASSKEY_CONFIRM_REQUEST = 0x0002,
-       BT_AGENT_EVENT_PASSKEY_REQUEST = 0x0004,
-       BT_AGENT_EVENT_PASSKEY_DISPLAY_REQUEST = 0x0008,
-       BT_AGENT_EVENT_AUTHORIZE_REQUEST = 0x0010,
-       BT_AGENT_EVENT_CONFIRM_MODE_REQUEST = 0x0020,
-       BT_AGENT_EVENT_APP_CONFIRM_REQUEST = 0x0040,
-       BT_AGENT_EVENT_FILE_RECEIVED = 0x0080,
-       BT_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST = 0x0100,
-       BT_AGENT_EVENT_SECURITY = 0x0200,
-       BT_AGENT_EVENT_TERMINATE = 0x0400,
-       BT_AGENT_EVENT_EXCHANGE_REQUEST = 0x0800,
-       BT_AGENT_EVENT_PBAP_REQUEST = 0x1000,
-       BT_AGENT_EVENT_MAP_REQUEST = 0x2000,
-       BT_AGENT_EVENT_SYSTEM_RESET_REQUEST = 0x4000,
-       BT_AGENT_EVENT_LEGACY_PAIR_FAILED_FROM_REMOTE = 0x8000,
+       BT_AGENT_EVENT_PIN_REQUEST,
+       BT_AGENT_EVENT_PASSKEY_CONFIRM_REQUEST,
+       BT_AGENT_EVENT_PASSKEY_AUTO_ACCEPTED,
+       BT_AGENT_EVENT_PASSKEY_REQUEST,
+       BT_AGENT_EVENT_PASSKEY_DISPLAY_REQUEST,
+       BT_AGENT_EVENT_AUTHORIZE_REQUEST,
+       BT_AGENT_EVENT_CONFIRM_MODE_REQUEST,
+       BT_AGENT_EVENT_APP_CONFIRM_REQUEST,
+       BT_AGENT_EVENT_FILE_RECEIVED,
+       BT_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST,
+       BT_AGENT_EVENT_SECURITY,
+       BT_AGENT_EVENT_TERMINATE,
+       BT_AGENT_EVENT_EXCHANGE_REQUEST,
+       BT_AGENT_EVENT_PBAP_REQUEST,
+       BT_AGENT_EVENT_MAP_REQUEST,
+       BT_AGENT_EVENT_SYSTEM_RESET_REQUEST,
+       BT_AGENT_EVENT_LEGACY_PAIR_FAILED_FROM_REMOTE,
 } bt_agent_event_type_t;
 
-typedef enum {
-       BT_AGENT_CHANGED_MODE_ENABLE,
-       BT_AGENT_CHANGED_MODE_DISABLE,
-} bt_agent_changed_mode_type_t;
-
-typedef enum {
-       BT_AGENT_RUN_STATUS_NO_CHANGE = 0x00,   /* No Change BT status*/
-       BT_AGENT_RUN_STATUS_ACTIVATE = 0x01,    /* BT Activate*/
-       BT_AGENT_RUN_STATUS_DEACTIVATE = 0x02,  /* BT Deactivate*/
-       BT_AGENT_RUN_STATUS_SEARCH_TEST = 0x03, /* BT Search Test*/
-       BT_AGENT_RUN_STATUS_TERMINATE = 0x04,   /* BT Terminate*/
-       BT_AGENT_RUN_STATUS_MAX = 0x05, /* Max val*/
-} bt_agent_run_status_t;
-
-typedef enum {
-       BT_AGENT_ON_CURRENTVIEW = 0x00, /* Run BT on current view*/
-       BT_AGENT_ON_FOREGROUND = 0x01,  /* Run BT on foreground*/
-       BT_AGENT_ON_BACKGROUND = 0x02,  /* Run BT on background*/
-} bt_agent_on_t;
-
-typedef enum {
-       BT_AGENT_OBEX_SERVER = 0x00,
-       BT_AGENT_RFCOMM_SERVER = 0x01,
-} bt_agent_osp_server_type_t;
-
 typedef struct {
        int type;
        char *uuid;
@@ -115,11 +77,6 @@ typedef struct {
        int fd;
 } bt_agent_osp_server_t;
 
-typedef struct {
-       unsigned int service_list_array[BT_MAX_SERVICES_FOR_DEVICE];
-       int service_index;
-} bt_agent_sdp_info_t;
-
 void* _bt_create_agent(const char *path, gboolean adapter);
 
 void _bt_destroy_agent(void *agent);
index a2ad749..6d24e83 100644 (file)
@@ -42,6 +42,11 @@ typedef struct {
        GArray **out_param1;
 } bt_headset_wait_t;
 
+typedef struct {
+       int key;
+       const char *property;
+} bt_player_settinngs_t;
+
 typedef enum {
        BT_PENDING_NONE = 0x00,
        BT_PENDING_CONNECT,
@@ -60,7 +65,8 @@ typedef enum {
        BT_AUDIO_HSP = 0x01,
        BT_AUDIO_A2DP,
        BT_AUDIO_ALL,
-       BT_AVRCP
+       BT_AVRCP,
+       BT_AUDIO_A2DP_SOURCE
 } bt_audio_type_t;
 
 typedef enum {
similarity index 51%
rename from bt-service/include/bt-service-mdm.h
rename to bt-service/include/bt-service-avrcp-controller.h
index 94c9c77..aa04cba 100644 (file)
@@ -1,11 +1,11 @@
 /*
  * Bluetooth-frwk
  *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
- *              Girishashok Joshi <girish.joshi@samsung.com>
  *              Chanyeol Park <chanyeol.park@samsung.com>
+  *             Rakesh M K<rakesh.mk@samsung.com>
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 
 
-#ifndef _BT_SERVICE_MDM_H_
-#define _BT_SERVICE_MDM_H_
+#ifndef _BT_SERVICE_AVRCP_CONTROLLER_H_
+#define _BT_SERVICE_AVRCP_CONTROLLER_H_
 
-#include <sys/types.h>
 #include <glib.h>
-
-#include <mdm.h>
+#include <sys/types.h>
+#include <gio/gio.h>
 
 #include "bluetooth-api.h"
+#include "bluetooth-media-control.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-typedef enum {
-       BT_MDM_NO_SERVICE,
-       BT_MDM_ALLOWED,
-       BT_MDM_RESTRICTED
-} bt_mdm_status_e;
 
-void _bt_init_mdm_handle(void);
+#define BT_MEDIA_CONTROL_PATH "%s/player0"
 
-void _bt_deinit_mdm_handle(void);
+int _bt_avrcp_control_cmd(int type);
 
-int _bt_launch_mdm_popup(char *mode);
+int _bt_avrcp_control_set_property(int type, unsigned int value);
 
-bt_mdm_status_e _bt_check_mdm_allow_restriction(void);
+int _bt_avrcp_control_get_property(int type, unsigned int *value);
 
-#ifdef MDM_PHASE_2
-bt_mdm_status_e _bt_check_mdm_desktop_connectivity_restriction(void);
+int _bt_avrcp_control_get_track_info(media_metadata_attributes_t *metadata);
 
-bt_mdm_status_e _bt_check_mdm_visible_restriction(void);
+void _bt_handle_avrcp_control_event(GVariant *reply, const char *path);
 
-bt_mdm_status_e _bt_check_mdm_limited_discoverable_mode(void);
+void _bt_set_control_device_path(const char *path);
 
-bt_mdm_status_e _bt_check_mdm_blacklist_devices(bluetooth_device_address_t *address);
-
-bt_mdm_status_e _bt_check_mdm_blacklist_uuid(char *uuid);
-#endif
+void _bt_remove_control_device_path(const char *path);
 
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
-#endif /*_BT_SERVICE_MDM_H_*/
+#endif /*_BT_SERVICE_AVRCP_CONTROLLER_H_*/
+
 
index fafc575..7540465 100644 (file)
@@ -27,8 +27,6 @@
 
 #include <glib.h>
 #include <sys/types.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
 
 #include "bluetooth-api.h"
 #include "bluetooth-media-control.h"
 extern "C" {
 #endif
 
-#define BLUEZ_MEDIA_PLAYER_INTERFACE   "org.bluez.MediaPlayer"
 #define BT_MEDIA_OBJECT_PATH "/Musicplayer"
 
-#define BT_MEDIA_CONTROL_PATH "%s/player0"
+#define BT_AVRCP_ERROR (__bt_avrcp_error_quark())
+
+#define BT_ERROR_INTERNAL "InternalError"
+#define BT_ERROR_INVALID_PARAM "InvalidParameters"
+#define BT_ERROR_INVALID_INTERFACE "InvalidInterface"
+
+typedef enum {
+       BT_AVRCP_ERROR_NONE,
+       BT_AVRCP_ERROR_INTERNAL,
+       BT_AVRCP_ERROR_INVALID_PARAM,
+       BT_AVRCP_ERROR_NOT_SUPPORTED,
+       BT_AVRCP_ERROR_INVALID_INTERFACE
+} bt_avrcp_error_t;
 
 int _bt_register_media_player(void);
 
@@ -52,16 +61,6 @@ int _bt_avrcp_set_properties(media_player_settings_t *properties);
 
 int _bt_avrcp_set_property(int type, unsigned int value);
 
-int _bt_avrcp_control_cmd(int type);
-
-int _bt_avrcp_control_set_property(int type, unsigned int value);
-
-int _bt_avrcp_control_get_property(int type, unsigned int *value);
-
-int _bt_avrcp_control_get_track_info(media_metadata_attributes_t *metadata);
-
-void _bt_handle_avrcp_control_event(DBusMessageIter *msg_iter, const char *path);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 5715cca..874b5df 100644 (file)
@@ -27,8 +27,8 @@
 
 #include <sys/types.h>
 #include <dlog.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
+#include <glib.h>
+#include <gio/gio.h>
 
 #include "bluetooth-api.h"
 
@@ -89,12 +89,12 @@ extern "C" {
        do { \
                if (arg == NULL) \
                { \
-                       BT_ERR("INVALID PARAMETER"); \
+                       BT_ERR("%s is NULL", #arg); \
                        func BLUETOOTH_ERROR_INVALID_PARAM; \
                } \
        } while (0)
 
-#define BT_CHANNEL_LENGTH_MAX 5
+
 #define BT_ADDRESS_LENGTH_MAX 6
 #define BT_ADDRESS_STRING_SIZE 18
 #define BT_RFCOMM_BUFFER_MAX 1024
@@ -128,7 +128,6 @@ extern "C" {
 
 #define BT_BLUEZ_PATH "/org/bluez"
 #define BT_BLUEZ_HCI_PATH "/org/bluez/hci0"
-#define BT_BLUEZ_HCI_DEV_PATH "/org/bluez/hci0/dev"
 #define BT_AGENT_NAME "org.bluez.frwk_agent"
 #define BT_AGENT_PATH "/org/bluez/agent/frwk_agent"
 #define BT_DEVICE_AGENT_PATH "/org/tizen/device_agent"
@@ -147,26 +146,26 @@ extern "C" {
 #define BT_MEDIATRANSPORT_INTERFACE "org.bluez.MediaTransport1"
 #define BT_MEDIA_CONTROL_INTERFACE "org.bluez.MediaControl1"
 #define BT_PLAYER_CONTROL_INTERFACE "org.bluez.MediaPlayer1"
+#define BT_GATT_CHAR_INTERFACE "org.bluez.GattCharacteristic1"
 
-#define BT_INPUT_INTERFACE "org.bluez.Input"
+#define BT_INPUT_INTERFACE "org.bluez.Input1"
 #define BT_NETWORK_INTERFACE "org.bluez.Network"
 #define BT_NETWORK_CLIENT_INTERFACE "org.bluez.Network1"
 #define BT_SERIAL_INTERFACE "org.bluez.Serial"
 #define BT_SERIAL_MANAGER_INTERFACE "org.bluez.SerialProxyManager"
 #define BT_SERIAL_PROXY_INTERFACE "org.bluez.SerialProxy"
-#define BT_HFP_AGENT_INTERFACE "Org.Hfp.App.Interface"
 #define BT_SINK_INTERFACE "org.bluez.AudioSink"
 #define BT_AUDIO_INTERFACE "org.bluez.Audio"
 #define BT_HEADSET_INTERFACE "org.bluez.Headset"
 #define BT_OOB_INTERFACE "org.bluez.OutOfBand"
 #define BT_HANDSFREE_GATEWAY_INTERFACE "org.bluez.HandsfreeGateway"
-#define BT_OBEXD_DBUS_NAME "org.bluez.obex"
-#define BT_OBEXD_MANAGER_INTERFACE "org.bluez.obex.AgentManager1"
-#define BT_OBEXD_TRANSFER_INTERFACE "org.bluez.obex.Transfer1"
+#define BT_OBEXD_INTERFACE "org.openobex"
+#define BT_OBEXD_MANAGER_INTERFACE "org.openobex.Manager"
+#define BT_OBEXD_TRANSFER_INTERFACE "org.openobex.Transfer"
+#define BT_A2DP_SOURCE_INTERFACE "org.bluez.AudioSource"
 
 #define BT_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
 
-#define MPRIS_PLAYER_INTERFACE "org.mpris.MediaPlayer2.Player"
 
 #define BT_OBEX_SERVICE_NAME "org.bluez.obex"
 #define BT_OBEX_CLIENT_PATH "/org/bluez/obex"
@@ -191,7 +190,6 @@ extern "C" {
 #define BT_INTERFACES_REMOVED "InterfacesRemoved"
 #define BT_NAME_OWNER_CHANGED "NameOwnerChanged"
 #define BT_PROPERTIES_CHANGED "PropertiesChanged"
-#define DBUS_INTERFACE_OBJECT_MANAGER "/"
 
 
 
@@ -203,6 +201,8 @@ extern "C" {
 /* UUID */
 #define GENERIC_AUDIO_UUID      "00001203-0000-1000-8000-00805f9b34fb"
 
+#define OBEX_OPP_UUID          "00001105-0000-1000-8000-00805f9b34fb"
+
 #define HSP_HS_UUID             "00001108-0000-1000-8000-00805f9b34fb"
 #define HSP_AG_UUID             "00001112-0000-1000-8000-00805f9b34fb"
 
@@ -226,8 +226,8 @@ extern "C" {
 #define GATT_UUID              "00001801-0000-1000-8000-00805f9b34fb"
 
 /* Privilege */
-#define BT_PRIVILEGE_PUBLIC "http://tizen.org/privilege/bluetooth"
-#define BT_PRIVILEGE_PLATFORM "http://tizen.org/privilege/bluetooth.admin"
+#define BT_PRIVILEGE_PUBLIC "bt-service::public"
+#define BT_PRIVILEGE_PLATFORM "bt-service::platform"
 
 /* BD Address type */
 #define BDADDR_BREDR           0x00
@@ -241,8 +241,6 @@ extern "C" {
 #define BT_LE_ADV_NONCONN_IND  0x03
 #define BT_LE_ADV_SCAN_RSP             0x04
 
-#define BT_STOP_DISCOVERY_TIMEOUT 1000*15
-
 /* Profile states matched to btd_service_state_t of bluez service.h */
 typedef enum {
        BT_PROFILE_STATE_UNAVAILABLE,
@@ -265,7 +263,9 @@ typedef enum {
        BT_PROFILE_CONN_NAP= 0x10,
        BT_PROFILE_CONN_HFG= 0x20,
        BT_PROFILE_CONN_GATT= 0x40,
-       BT_PROFILE_CONN_ALL= 0x80,
+       BT_PROGILE_CONN_NAP = 0x80,
+       BT_PROFILE_CONN_A2DP_SINK= 0x100,
+       BT_PROFILE_CONN_ALL= 0xffffffff,
 } bt_profile_type_t;
 
 typedef struct {
@@ -284,9 +284,9 @@ typedef struct {
        char *address;
        char *name;
        char **uuids;
-       int uuid_count;
+       unsigned int uuid_count;
        gboolean paired;
-       gboolean connected;
+       bluetooth_connected_link_t connected;
        gboolean trust;
        char *manufacturer_data;
        int manufacturer_data_len;
@@ -311,19 +311,19 @@ typedef struct {
        char *address;
 } bt_function_data_t;
 
-DBusConnection *_bt_get_system_conn(void);
+GDBusConnection *_bt_get_system_conn(void);
 
-DBusGConnection *_bt_get_system_gconn(void);
+GDBusConnection *_bt_get_system_gconn(void);
 
-DBusGConnection *_bt_get_session_gconn(void);
+GDBusConnection *_bt_get_session_gconn(void);
 
 void *_bt_get_net_conn(void);
 
-DBusGProxy *_bt_get_manager_proxy(void);
+GDBusProxy *_bt_get_manager_proxy(void);
 
-DBusGProxy *_bt_get_adapter_proxy(void);
+GDBusProxy *_bt_get_adapter_proxy(void);
 
-DBusGProxy *_bt_get_adapter_properties_proxy(void);
+GDBusProxy *_bt_get_adapter_properties_proxy(void);
 
 char *_bt_get_device_object_path(char *address);
 
@@ -337,8 +337,6 @@ void _bt_logging_connection(gboolean connect, int addr_type);
 
 char *_bt_get_adapter_path(void);
 
-gboolean _bt_get_adapter_power(void);
-
 void _bt_deinit_proxys(void);
 
 void _bt_convert_device_path_to_address(const char *device_path,
@@ -350,6 +348,13 @@ void _bt_convert_addr_string_to_type(unsigned char *addr,
 void _bt_convert_addr_type_to_string(char *address,
                                unsigned char *addr);
 
+void _bt_swap_byte_ordering(char *data, int data_len);
+
+int _bt_byte_arr_cmp(const char *data1, const char *data2, int data_len);
+
+int _bt_byte_arr_cmp_with_mask(const char *data1, const char *data2,
+                               const char *mask, int data_len);
+
 void _bt_print_device_address_t(const bluetooth_device_address_t *addr);
 
 void _bt_divide_device_class(bluetooth_device_class_t *device_class,
@@ -371,12 +376,10 @@ int _bt_set_socket_non_blocking(int socket_fd);
 
 int _bt_set_non_blocking_tty(int sk);
 
-gboolean _bt_is_headset_class(int dev_class);
-
-char *_bt_get_device_object_path(char *address);
-
 void _bt_deinit_bluez_proxy(void);
 
+int _bt_eventsystem_set_value(const char *event, const char *key, const char *value);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 7642a19..738da3a 100644 (file)
@@ -60,12 +60,17 @@ int _bt_is_gatt_connected(bluetooth_device_address_t *device_address,
 int _bt_is_device_connected(bluetooth_device_address_t *device_address,
                        int connection_type, gboolean *is_connected);
 
+int _bt_get_connected_link(bluetooth_device_address_t *device_address,
+                       bluetooth_connected_link_t *connected);
+
 gboolean _bt_is_device_creating(void);
 
 void _bt_set_autopair_status_in_bonding_info(gboolean is_autopair);
 
 bt_remote_dev_info_t *_bt_get_remote_device_info(char *address);
 
+char *_bt_get_bonded_device_name(char *address);
+
 gboolean _bt_is_bonding_device_address(const char *address);
 
 int _bt_connect_le_device(const bluetooth_device_address_t *bd_addr, gboolean auto_connect);
index ef526b0..fcb715f 100644 (file)
@@ -31,7 +31,9 @@
 extern "C" {
 #endif
 
-int _bt_send_event(int event_type, int event, int type, ...);
+int _bt_send_event(int event_type, int event, GVariant *param);
+
+int _bt_send_event_to_dest(const char* dest, int event_type, int event, GVariant *param);
 
 int _bt_init_service_event_sender(void);
 void _bt_deinit_service_event_sender(void);
@@ -42,10 +44,6 @@ void _bt_deinit_service_event_receiver(void);
 int _bt_opp_client_event_init(void);
 void _bt_opp_client_event_deinit(void);
 
-void _bt_get_temp_remote_devinfo(void);
-
-void _bt_stop_discovery_timeout(void);
-
 int _bt_send_hf_local_term_event(char *address);
 int _bt_init_hf_local_term_event_sender(void);
 void _bt_deinit_hf_local_term_event_sender(void);
index 9ce169b..bec881e 100644 (file)
 
 #include <stdint.h>
 #include <glib.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <gio/gio.h>
 
 #define BLUEZ_DEVICE_INTERFACE "org.bluez.Device"
 
-#define GAP_TYPE_AGENT (gap_agent_get_type())
-#define GAP_GET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GAP_TYPE_AGENT, GapAgent))
-#define GAP_IS_AGENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GAP_TYPE_AGENT))
-
-#define GAP_AGENT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST((class), GAP_TYPE_AGENT, \
-                                                                               GapAgentClass))
-#define GAP_GET_AGENT_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GAP_TYPE_AGENT, \
-                                                                               GapAgentClass))
-#define GAP_IS_AGENT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE((class), GAP_TYPE_AGENT))
-
-#define GAP_AGENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), GAP_TYPE_AGENT, \
-                                                                       GapAgentPrivate))
+typedef enum {
+       GAP_AGENT_EXEC_NO_OPERATION,
+       GAP_AGENT_EXEC_PAIRING,
+       GAP_AGENT_EXEC_AUTHORZATION,
+       GAP_AGENT_EXEC_CONFIRM_MODE,
+} GapAgentExecType;
 
-typedef struct _GapAgent GapAgent;
-typedef struct _GapAgentClass GapAgentClass;
+typedef struct _GapAgentPrivate GapAgentPrivate;
 
-typedef gboolean(*GapAgentPasskeyFunc) (GapAgent *agent,
-                                                       DBusGProxy *device);
-typedef gboolean(*GapAgentDisplayFunc) (GapAgent *agent, DBusGProxy *device,
+typedef gboolean(*GapAgentPasskeyFunc) (GapAgentPrivate *agent,
+                                               GDBusProxy *device);
+typedef gboolean(*GapAgentDisplayFunc) (GapAgentPrivate *agent, GDBusProxy *device,
                                                                guint passkey);
-typedef gboolean(*GapAgentConfirmFunc) (GapAgent *agent, DBusGProxy *device,
+typedef gboolean(*GapAgentConfirmFunc) (GapAgentPrivate *agent, GDBusProxy *device,
                                                                guint passkey);
-typedef gboolean(*GapAgentAuthorizeFunc) (GapAgent *agent,
-                                               DBusGProxy *device,
-                                               const char *uuid);
-typedef gboolean(*GapAgentConfirmModeFunc) (GapAgent *agent,
+typedef gboolean(*GapAgentAuthorizeFunc) (GapAgentPrivate *agent,
+                                       GDBusProxy *device, const char *uuid);
+typedef gboolean(*GapAgentConfirmModeFunc) (GapAgentPrivate *agent,
                                        const char *mode, const char *sender,
                                        gboolean need_popup, void *data);
-typedef gboolean(*GapAgentCancelFunc) (GapAgent *agent,
+typedef gboolean(*GapAgentCancelFunc) (GapAgentPrivate *agent,
                                                        const char *address);
 typedef gboolean(*GapAgentIgnoreAutoPairingFunc) (const char *address);
 typedef uint8_t bool_t;
@@ -82,49 +73,61 @@ typedef enum {
        GAP_AGENT_ACCEPT_ALWAYS,
 } GAP_AGENT_ACCEPT_TYPE_T;
 
-struct _GapAgent {
-       GObject parent;
-};
+struct _GapAgentPrivate {
+       gchar *busname;
+       gchar *path;
+       GDBusProxy *adapter;
+
+       GDBusProxy *agent_manager;
+
+       GDBusProxy *dbus_proxy;
+
+       GapAgentExecType exec_type;
+       GDBusMethodInvocation *reply_context;
+
+       char pairing_addr[18];
+       char authorize_addr[18];
+
+       GSList *osp_servers;
 
-struct _GapAgentClass {
-       GObjectClass parent_class;
+       GAP_AGENT_FUNC_CB cb;
+       gboolean canceled;
 };
 
-GapAgent *_gap_agent_new(void);
-void _gap_agent_setup_dbus(GapAgent *agent, GAP_AGENT_FUNC_CB *func_cb,
-                                       const char *path);
-gboolean _gap_agent_register(GapAgent *agent);
-void _gap_agent_reset_dbus(GapAgent *agent);
+void _gap_agent_setup_dbus(GapAgentPrivate *agent, GAP_AGENT_FUNC_CB *func_cb,
+                                       const char *path, GDBusProxy *adapter);
+gboolean _gap_agent_register(GapAgentPrivate *agent);
+void _gap_agent_reset_dbus(GapAgentPrivate *agent);
 
-gboolean gap_agent_reply_pin_code(GapAgent *agent, const guint accept,
+gboolean gap_agent_reply_pin_code(GapAgentPrivate *agent, const guint accept,
                                                const char *pin_code,
-                                               DBusGMethodInvocation *context);
-gboolean gap_agent_reply_passkey(GapAgent *agent, const guint accept,
+                                               GDBusMethodInvocation *context);
+gboolean gap_agent_reply_passkey(GapAgentPrivate *agent, const guint accept,
                                                const char *passkey,
-                                               DBusGMethodInvocation *context);
-gboolean gap_agent_reply_confirmation(GapAgent *agent, const guint accept,
-                                         DBusGMethodInvocation *context);
-gboolean gap_agent_reply_authorize(GapAgent *agent, const guint accept,
-                                      DBusGMethodInvocation *context);
+                                               GDBusMethodInvocation *context);
+gboolean gap_agent_reply_confirmation(GapAgentPrivate *agent, const guint accept,
+               GDBusMethodInvocation *context);
+gboolean gap_agent_reply_authorize(GapAgentPrivate *agent, const guint accept,
+               GDBusMethodInvocation *context);
 
-gboolean _gap_agent_exist_osp_server(GapAgent *agent, int type, char *uuid);
+gboolean _gap_agent_exist_osp_server(GapAgentPrivate *agent, int type, char *uuid);
 
-bt_agent_osp_server_t *_gap_agent_get_osp_server(GapAgent *agent, int type,
+bt_agent_osp_server_t *_gap_agent_get_osp_server(GapAgentPrivate *agent, int type,
                                        char *uuid);
 
-gchar* _gap_agent_get_path(GapAgent *agent);
+gchar* _gap_agent_get_path(GapAgentPrivate *agent);
 
-gboolean _gap_agent_is_canceled(GapAgent *agent);
+gboolean _gap_agent_is_canceled(GapAgentPrivate *agent);
 
-void _gap_agent_set_canceled(GapAgent *agent, gboolean value);
+void _gap_agent_set_canceled(GapAgentPrivate *agent, gboolean value);
 
-gboolean _gap_agent_register_osp_server(GapAgent *agent,
+gboolean _gap_agent_register_osp_server(GapAgentPrivate *agent,
                                                const gint type,
                                                const char *uuid,
                                                const char *path,
                                                int fd);
 
-gboolean _gap_agent_unregister_osp_server(GapAgent *agent,
+gboolean _gap_agent_unregister_osp_server(GapAgentPrivate *agent,
                                                const gint type,
                                                const char *uuid);
 
index 36dc0f6..b6fe016 100644 (file)
@@ -25,7 +25,6 @@
 #define __BT_SERVICE_OBEX_AGENT_H
 
 #include <glib-object.h>
-#include <dbus/dbus-glib.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -53,83 +52,62 @@ GType bt_obex_agent_get_type(void);
 #define BT_OBEX_AGENT_CLASS(agent_class) (G_TYPE_CHECK_CLASS_CAST((agent_class), BT_OBEX_TYPE_AGENT, BtObexAgentClass))
 #define BT_OBEX_GET_AGENT_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), BT_OBEX_TYPE_AGENT, BtObexAgentClass))
 
-typedef gboolean(*bt_obex_authorize_cb)(DBusGMethodInvocation *context,
+typedef gboolean(*bt_obex_authorize_cb)(GDBusMethodInvocation *context,
                                           const char *path,
                                           gpointer data);
 
-typedef gboolean(*bt_obex_request_cb)(DBusGMethodInvocation *context,
-                               DBusGProxy *transfer,
+typedef gboolean(*bt_obex_request_cb)(GDBusMethodInvocation *context,
+                               GDBusProxy *transfer,
                                gpointer data);
 
-typedef gboolean(*bt_obex_progress_cb)(DBusGMethodInvocation *context,
-                               DBusGProxy *transfer,
+typedef gboolean(*bt_obex_progress_cb)(GDBusMethodInvocation *context,
+                               GDBusProxy *transfer,
                                guint64 transferred,
                                gpointer data);
 
-typedef gboolean(*bt_obex_error_cb)(DBusGMethodInvocation *context,
-                               DBusGProxy *transfer,
+typedef gboolean(*bt_obex_error_cb)(GDBusMethodInvocation *context,
+                               GDBusProxy *transfer,
                                const char *message,
                                gpointer data);
 
-typedef gboolean(*bt_obex_complete_cb)(DBusGMethodInvocation *context,
-                               DBusGProxy *transfer,
+typedef gboolean(*bt_obex_complete_cb)(GDBusMethodInvocation *context,
+                               GDBusProxy *transfer,
                                gpointer data);
 
-typedef gboolean(*bt_obex_release_cb)(DBusGMethodInvocation *context,
+typedef gboolean(*bt_obex_release_cb)(GDBusMethodInvocation *context,
                                gpointer data);
 
 G_END_DECLS
 
-void _bt_obex_set_authorize_cb(BtObexAgent *agent,
+void _bt_obex_set_authorize_cb(char *object_path,
                         bt_obex_authorize_cb func,
                         gpointer data);
 
-void _bt_obex_set_request_cb(BtObexAgent *agent,
+void _bt_obex_set_request_cb(char *object_path,
                       bt_obex_request_cb func,
                       gpointer data);
 
-void _bt_obex_set_progress_cb(BtObexAgent *agent,
+void _bt_obex_set_progress_cb(char *object_path,
                        bt_obex_progress_cb func,
                        gpointer data);
 
-void _bt_obex_set_error_cb(BtObexAgent *agent,
+void _bt_obex_set_error_cb(char *object_path,
                        bt_obex_error_cb func,
                        gpointer data);
 
-void _bt_obex_set_complete_cb(BtObexAgent *agent,
+void _bt_obex_set_complete_cb(char *object_path,
                        bt_obex_complete_cb func,
                        gpointer data);
 
-void _bt_obex_set_release_cb(BtObexAgent *agent,
+void _bt_obex_set_release_cb(char *object_path,
                       bt_obex_release_cb func,
                       gpointer data);
 
-BtObexAgent *_bt_obex_agent_new(void);
+void _bt_obex_agent_new(char *path);
 
-gboolean _bt_obex_setup(BtObexAgent *agent, const char *path);
-
-gboolean bt_obex_agent_request(BtObexAgent *agent, const char *path,
-                                  DBusGMethodInvocation *context);
-
-gboolean bt_obex_agent_authorize_push(BtObexAgent *agent, const char *path,
-                            DBusGMethodInvocation *context);
-
-gboolean bt_obex_agent_authorize(BtObexAgent *agent, const char *path,
-                       const char *bdaddress, const char *name,
-                       const char *type, gint length, gint time,
-                            DBusGMethodInvocation *context);
-
-gboolean bt_obex_agent_progress(BtObexAgent *agent, const char *path,
-                   guint64 transferred, DBusGMethodInvocation *context);
-
-gboolean bt_obex_agent_complete(BtObexAgent *agent, const char *path,
-                                   DBusGMethodInvocation *context);
-
-gboolean bt_obex_agent_release(BtObexAgent *agent, DBusGMethodInvocation *context);
-
-gboolean bt_obex_agent_error(BtObexAgent *agent, const char *path,
-                        const char *message, DBusGMethodInvocation *context);
+void _bt_obex_agent_destroy(char *path);
 
+gboolean _bt_obex_setup(const char *path);
 
 #ifdef __cplusplus
 }
index 0205240..5f3f8e4 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <glib.h>
 #include <sys/types.h>
+#include <gio/gio.h>
 #include "bluetooth-api.h"
 #include "bt-internal-types.h"
 
@@ -48,8 +49,8 @@ typedef struct {
 } bt_file_path_t;
 
 typedef struct {
-       DBusGProxy *proxy;
-       DBusGProxy *properties_proxy;
+       GDBusProxy *proxy;
+       GDBusProxy *properties_proxy;
        char *transfer_name;
        char *file_name;
        char *transfer_path;
@@ -68,7 +69,6 @@ typedef struct {
 
        char *address;
        gboolean is_canceled;
-       DBusGProxyCall *sending_proxy;
        bt_transfer_info_t *transfer_info;
 } bt_sending_info_t;
 
@@ -80,7 +80,7 @@ typedef struct {
 } bt_sending_data_t;
 
 
-int _bt_opp_client_push_files(int request_id, DBusGMethodInvocation *context,
+int _bt_opp_client_push_files(int request_id, GDBusMethodInvocation *context,
                                bluetooth_device_address_t *remote_address,
                                char **file_path, int file_count);
 
index 3880972..ec3645e 100644 (file)
 
 #include <stdint.h>
 #include <glib.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
 #include <unistd.h>
 #include <dlog.h>
-
 #include <stdio.h>
 
-#include <dbus/dbus-glib.h>
-
 #undef LOG_TAG
 #define LOG_TAG        "BLUETOOTH_FRWK_SERVICE"
 #define ERR(fmt, args...) SLOGE(fmt, ##args)
@@ -60,4 +54,6 @@ int _bt_pbap_phonebook_search(const bluetooth_device_address_t *address,
                int source, int type, bt_pbap_search_parameters_t *app_param);
 
 void _bt_pbap_obex_transfer_completed(const char *transfer_path, gboolean transfer_status);
+
+void _bt_obex_pbap_client_disconnect(char *path);
 #endif
index c238e43..a71e9a4 100644 (file)
@@ -52,8 +52,8 @@ typedef struct {
        char *remote_address;
        GIOChannel *control_io;
        GIOChannel *data_io;
-       DBusGProxy *serial_proxy;
-       DBusGProxy *manager_proxy;
+//     DBusGProxy *serial_proxy;
+//     DBusGProxy *manager_proxy;
 } bt_rfcomm_server_info_t;
 
 int _bt_rfcomm_create_socket(char *sender, char *uuid);
index d1984bd..0b9cea7 100644 (file)
@@ -26,7 +26,7 @@
 #define _BT_SERVICE_UTIL_H_
 
 #include <sys/types.h>
-#include <dbus/dbus-glib.h>
+#include <gio/gio.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -38,7 +38,7 @@ typedef struct {
        int req_id;
        int service_function;
        char name[BT_NODE_NAME_LEN];
-       DBusGMethodInvocation *context;
+       GDBusMethodInvocation *context;
 } request_info_t;
 
 
@@ -52,7 +52,7 @@ void _bt_delete_request_id(int request_id);
 void _bt_init_request_list(void);
 
 int _bt_insert_request_list(int req_id, int service_function,
-                       char *name, DBusGMethodInvocation *context);
+                       char *name, GDBusMethodInvocation *context);
 
 int _bt_delete_request_list(int req_id);
 
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/bt-service/org.projectx.bt.service.in b/bt-service/org.projectx.bt.service.in
deleted file mode 100644 (file)
index bf43821..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-[D-BUS Service]
-Name=org.projectx.bt
-Exec=/bin/sh -c 'export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID/dbus/user_bus_socket; exec /usr/bin/bt-service'
-User=@TZ_SYS_DEFAULT_USER@
old mode 100755 (executable)
new mode 100644 (file)
index f23273a..e1576bb 100644 (file)
@@ -268,6 +268,7 @@ typedef enum {
        BLUETOOTH_HFG_SERVICE = 0x20,
        BLUETOOTH_GATT_SERVICE = 0x40,
        BLUETOOTH_NAP_SERVER_SERVICE = 0x80,
+       BLUETOOTH_A2DP_SINK_SERVICE = 0x100,
 } bluetooth_service_type_t;
 
 /**
@@ -401,7 +402,7 @@ typedef struct {
 
 #define BLUETOOTH_EVENT_AUDIO_BASE ((int)(BLUETOOTH_EVENT_GATT_BASE + 0x0020))
                                                                /**< Base ID for Audio events */
-#define BLUETOOTH_EVENT_HID_BASE ((int)(BLUETOOTH_EVENT_AUDIO_BASE + 0x0020))
+#define BLUETOOTH_EVENT_HID_BASE ((int)(BLUETOOTH_EVENT_AUDIO_BASE + 0x0030))
                                                                /**< Base ID for HID events */
 #define BLUETOOTH_EVENT_ADVERTISING_BASE ((int)(BLUETOOTH_EVENT_HID_BASE + 0x0020))
                                                                /**< Base ID for Advertising events */
@@ -439,7 +440,6 @@ typedef enum {
        BLUETOOTH_EVENT_DEVICE_AUTHORIZED,          /**< Bluetooth event authorize device */
        BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED,        /**< Bluetooth event unauthorize device */
        BLUETOOTH_EVENT_DISCOVERABLE_TIMEOUT_CHANGED,  /**< Bluetooth event mode changed */
-               BLUETOOTH_EVENT_REMOTE_DEVICE_DISAPPEARED, /**< Bluetooth event remote device disappeared*/
        BLUETOOTH_EVENT_CONNECTABLE_CHANGED,        /**< Bluetooth event connectable changed */
 
        BLUETOOTH_EVENT_RSSI_ENABLED,           /**< Bluetooth event RSSI monitoring enabled */
@@ -505,6 +505,7 @@ typedef enum {
        BLUETOOTH_EVENT_GATT_CONNECTED,/**<Gatt connected event */
        BLUETOOTH_EVENT_GATT_DISCONNECTED, /**<Gatt Disconnected event */
        BLUETOOTH_EVENT_GATT_SERVER_CHARACTERISTIC_VALUE_CHANGED, /**<Gatt Char write callback event */
+       BLUETOOTH_EVENT_GATT_SERVER_READ_REQUESTED, /** <GATT Characteristic/Descriptor Read Request event */
 
        BLUETOOTH_EVENT_AG_CONNECTED = BLUETOOTH_EVENT_AUDIO_BASE, /**<AG service connected event*/
        BLUETOOTH_EVENT_AG_DISCONNECTED, /**<AG service disconnected event*/
@@ -514,6 +515,8 @@ typedef enum {
        BLUETOOTH_EVENT_AG_AUDIO_DISCONNECTED,  /**<AV & AG service disconnected event*/
        BLUETOOTH_EVENT_AV_CONNECTED, /**<AV service connected event*/
        BLUETOOTH_EVENT_AV_DISCONNECTED, /**<AV service disconnected event*/
+       BLUETOOTH_EVENT_AV_SOURCE_CONNECTED, /**<AV Source device connected event */
+       BLUETOOTH_EVENT_AV_SOURCE_DISCONNECTED, /**<AV Source device disconnected event */
        BLUETOOTH_EVENT_AVRCP_CONNECTED, /**<AVRCP service connected event*/
        BLUETOOTH_EVENT_AVRCP_DISCONNECTED, /**<AVRCP service disconnected event*/
        BLUETOOTH_EVENT_AVRCP_SETTING_SHUFFLE_STATUS, /**<AVRCP service player suffle  status event*/
@@ -540,6 +543,9 @@ typedef enum {
 
        BLUETOOTH_HID_CONNECTED = BLUETOOTH_EVENT_HID_BASE, /**< Input connectd event*/
        BLUETOOTH_HID_DISCONNECTED, /**< Input disconnectd event*/
+       BLUETOOTH_HID_DEVICE_CONNECTED, /**< HID Device connected event*/
+       BLUETOOTH_HID_DEVICE_DISCONNECTED, /**< HID Device disconnected event*/
+       BLUETOOTH_HID_DEVICE_DATA_RECEIVED, /**< HID Device data received event*/
 
        BLUETOOTH_EVENT_ADVERTISING_STARTED = BLUETOOTH_EVENT_ADVERTISING_BASE, /**< Advertising started event */
        BLUETOOTH_EVENT_ADVERTISING_STOPPED, /**< Advertising stopped event */
@@ -550,7 +556,8 @@ typedef enum {
        BLUETOOTH_EVENT_TX_TIMEOUT_ERROR, /** TX Timeout Error*/
        BLUETOOTH_EVENT_MAX, /**< Bluetooth event Max value */
 
-       BLUETOOTH_PBAP_CONNECTED = BLUETOOTH_EVENT_PBAP_CLIENT_BASE, /**< PBAP connected/disconnectd event*/
+       BLUETOOTH_PBAP_CONNECTED = BLUETOOTH_EVENT_PBAP_CLIENT_BASE, /**< PBAP connected event*/
+       BLUETOOTH_PBAP_DISCONNECTED, /**< PBAP disconnectd event*/
        BLUETOOTH_PBAP_PHONEBOOK_SIZE, /**< PBAP Phonebook Size event*/
        BLUETOOTH_PBAP_PHONEBOOK_PULL, /**< PBAP Phonebook Pull event*/
        BLUETOOTH_PBAP_VCARD_LIST, /**< PBAP vCard List event*/
@@ -815,6 +822,28 @@ typedef enum {
 } bt_discovery_role_type_t;
 
 /**
+ * Connected state types
+ */
+typedef enum {
+       BLUETOOTH_CONNECTED_LINK_NONE = 0x00,
+       BLUETOOTH_CONNECTED_LINK_BREDR = 0x01,
+       BLUETOOTH_CONNECTED_LINK_LE = 0x02,
+       BLUETOOTH_CONNECTED_LINK_BREDR_LE = 0x03,
+} bluetooth_connected_link_t;
+
+/**
+* Scan filter entry
+*/
+typedef enum {
+       BLUETOOTH_LE_SCAN_FILTER_FEATURE_DEVICE_ADDRESS = 0x01,                 /**< device address */
+       BLUETOOTH_LE_SCAN_FILTER_FEATURE_SERVICE_UUID = 0x04,                   /**< service uuid */
+       BLUETOOTH_LE_SCAN_FILTER_FEATURE_SERVICE_SOLICITATION_UUID = 0x08,      /**< service solicitation uuid */
+       BLUETOOTH_LE_SCAN_FILTER_FEATURE_DEVICE_NAME = 0x10,                    /**< device name */
+       BLUETOOTH_LE_SCAN_FILTER_FEATURE_MANUFACTURER_DATA = 0x20,              /**< manufacturer data */
+       BLUETOOTH_LE_SCAN_FILTER_FEATURE_SERVICE_DATA = 0x40,                   /**< service data */
+} bluetooth_le_scan_filter_feature_t;
+
+/**
 * structure to hold the device information
 */
 typedef struct {
@@ -824,10 +853,10 @@ typedef struct {
        char uuids[BLUETOOTH_MAX_SERVICES_FOR_DEVICE][BLUETOOTH_UUID_STRING_MAX];
        unsigned int service_list_array[BLUETOOTH_MAX_SERVICES_FOR_DEVICE]; /**< Use enum values in bt_service_uuid_list_t */
        int service_index;
-       int rssi;                       /**< received strength signal*/
-       gboolean paired;                /**< paired flag */
-       gboolean connected;     /**< connected flag */
-       gboolean trust;         /**< connected flag */
+       int rssi;                               /**< received strength signal*/
+       gboolean paired;                        /**< paired flag */
+       bluetooth_connected_link_t connected;   /**< connected link type */
+       gboolean trust;                         /**< trust flag */
        bluetooth_manufacturer_data_t manufacturer_data;        /**< manafacturer specific class */
 } bluetooth_device_info_t;
 
@@ -847,6 +876,22 @@ typedef struct {
        bluetooth_le_advertising_data_t scan_resp_data;
 } bluetooth_le_device_info_t;
 
+typedef struct {
+       int slot_id;
+       bluetooth_le_scan_filter_feature_t added_features;              /**< added features */
+       bluetooth_device_address_t device_address;                      /**< device address */
+       char device_name[BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX];        /**< device name */
+       bluetooth_le_advertising_data_t service_uuid;                   /**< service uuid */
+       bluetooth_le_advertising_data_t service_uuid_mask;              /**< service uuid mask */
+       bluetooth_le_advertising_data_t service_solicitation_uuid;      /**< service solicitation uuid */
+       bluetooth_le_advertising_data_t service_solicitation_uuid_mask; /**< service solicitation uuid mask */
+       bluetooth_le_advertising_data_t service_data;                   /**< service data */
+       bluetooth_le_advertising_data_t service_data_mask;              /**< service data mask */
+       int manufacturer_id;                                            /**< manufacturer ID */
+       bluetooth_le_advertising_data_t manufacturer_data;              /**< manufacturer data */
+       bluetooth_le_advertising_data_t manufacturer_data_mask;         /**< manufacturer data mask */
+} bluetooth_le_scan_filter_t;
+
 /**
  * structure to hold the paired device information
  */
@@ -915,13 +960,49 @@ typedef struct {
 } bluetooth_rfcomm_received_data_t;
 
 /**
+ * HID Header type
+ */
+typedef enum {
+       HTYPE_TRANS_HANDSHAKE,
+       HTYPE_TRANS_HID_CONTROL,
+       HTYPE_TRANS_GET_REPORT,
+       HTYPE_TRANS_SET_REPORT,
+       HTYPE_TRANS_GET_PROTOCOL,
+       HTYPE_TRANS_SET_PROTOCOL,
+       HTYPE_TRANS_DATA,
+       HTYPE_TRANS_UNKNOWN
+}bt_hid_header_type_t;
+
+/**
+ * HID Param type
+ */
+typedef enum {
+       PTYPE_DATA_RTYPE_INPUT,
+       PTYPE_DATA_RTYPE_OUTPUT
+}bt_hid_param_type_t;
+
+/**
+ * Stucture to hid receive data
+ */
+typedef struct {
+       const char *address;
+       bt_hid_header_type_t type;
+               /**< Header type containing */
+       bt_hid_param_type_t param;
+               /**< Param type in header like INPUT Report or OutPut Report */
+       int buffer_size;/**< the length of the receive buffer */
+       char *buffer;
+               /**< the receive data buffer */
+} bluetooth_hid_received_data_t;
+
+/**
 * Stucture to rfcomm connection
 */
 
 typedef struct {
-       int socket_fd;
-               /**< the socket fd */
-       int device_role;/** < Device role - RFCOMM_ROLE_SERVER or RFCOMM_ROLE_CLIENT */
+       int socket_fd; /**< the socket fd */
+       int server_id; /* Server id */
+       int device_role; /** < Device role - RFCOMM_ROLE_SERVER or RFCOMM_ROLE_CLIENT */
        bluetooth_device_address_t device_addr;
                                              /**< device address */
        char uuid[BLUETOOTH_UUID_STRING_MAX];
@@ -946,6 +1027,13 @@ typedef struct {
                                              /**< device address */
 } bluetooth_rfcomm_connection_request_t;
 
+typedef struct {
+       int socket_fd;
+               /**< the socket fd */
+       bluetooth_device_address_t device_addr;
+                                             /**< device address */
+} bluetooth_hid_request_t;
+
 /**
  * HDP QOS types
  */
@@ -1061,7 +1149,7 @@ typedef struct {
        char *uuid;
        char *handle;
        gboolean primary;
-       bt_gatt_handle_info_t handle_info;
+       bt_gatt_handle_info_t include_handles;
        bt_gatt_handle_info_t char_handle;
 } bt_gatt_service_property_t;
 
@@ -1124,6 +1212,16 @@ typedef struct {
        guint32 val_len;
 } bt_gatt_char_value_t;
 
+/**
+ * Structure to GATT Read Request
+ */
+typedef struct {
+       char *char_handle;
+       char *service_handle;
+       char *address;
+       guint16 offset;
+       guint8 req_id;
+} bt_gatt_read_req_t;
 
 /**
  * Structure to RSSI Signal Strength Alert
@@ -1794,6 +1892,33 @@ int bluetooth_is_device_connected(const bluetooth_device_address_t *device_addre
                                gboolean *is_connected);
 
 /**
+ * @fn int bluetooth_get_connected_link_type(const bluetooth_device_address_t *device_address, bluetooth_connected_link_t *connected_link)
+ * @brief Gets device's connected link type
+ *
+ * This function is used to get device's connected link type
+ *
+ * This function is a synchronous call.
+ *
+ * @param[in]  device_address  a device address of remote bluetooth device
+ * @param[out] connected_link  a device's connected link type
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
+ *             BLUETOOTH_ERROR_INVALID_PARAM - Bluetooth name parameter is incorrect \n
+ *             BLUETOOTH_ERROR_INTERNAL - The dbus method call is fail \n
+ *
+ * @remark      None
+ *
+@code
+bluetooth_connected_link_t *connected_link = BLUETOOTH_CONNECTED_LINK_NONE;
+bluetooth_device_address_t device_address={{0x00,0x0D,0xFD,0x24,0x5E,0xFF}};
+ret = bluetooth_get_connected_link(&device_address, &connected_link);
+@endcode
+ */
+int bluetooth_get_connected_link_type(const bluetooth_device_address_t *device_address,
+                               bluetooth_connected_link_t *connected_link);
+
+/**
  * @fn int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t *discoverable_mode_ptr)
  * @brief Get the visibility mode
  *
@@ -2303,6 +2428,76 @@ ret = bluetooth_is_le_discovering ();
 int bluetooth_is_le_discovering(void);
 
 /**
+ * @fn int bluetooth_is_le_scanning(void)
+ * @brief Check for the device LE scan is in-progress or not.
+ *
+ * This API is used to check the current status of the LE Scan operation.If discovery is in\
+ * progress normally other operations are not allowed.
+ *
+ * This function checks whether the device  LE Scan is started or not.
+ *
+ * This function is a synchronous call.
+ *
+ * @return   TRUE  - LE Scan in progress \n
+ *              FALSE - LE Scan is not in progress \n
+ *
+ * @remark      None
+
+@code
+gboolean is_le_scanning = 0;
+is_le_scanning = bluetooth_is_le_scanning ();
+@endcode
+ */
+gboolean bluetooth_is_le_scanning(void);
+
+/**
+ * @fn int bluetooth_register_scan_filter(bluetooth_le_scan_filter_t *filter, int *slot_id)
+ * @brief Register scan filter.
+ *
+ * This function registers the scan filter.
+ *
+ * This function is a synchronous call.
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *
+ * @param[in]   filter   scan filter to register
+ * @param[out]  slot_id  the slot ID of scan filter
+ *
+ * @remark      None
+ */
+int bluetooth_register_scan_filter(bluetooth_le_scan_filter_t *filter, int *slot_id);
+
+/**
+ * @fn int bluetooth_unregister_scan_filter(int slot_id)
+ * @brief Register scan filter.
+ *
+ * This function unregisters the scan filter.
+ *
+ * This function is a synchronous call.
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *
+ * @param[in]   slot_id  the slot ID of scan filter
+ *
+ * @remark      None
+ */
+int bluetooth_unregister_scan_filter(int slot_id);
+
+/**
+ * @fn int bluetooth_unregister_all_scan_filters(void)
+ * @brief Register scan filter.
+ *
+ * This function usregisters all scan filters.
+ *
+ * This function is a synchronous call.
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *
+ * @remark      None
+ */
+int bluetooth_unregister_all_scan_filters(void);
+
+/**
  * @fn int bluetooth_enable_rssi(const bluetooth_device_address_t *remote_address,
                int link_type, bt_rssi_threshold_t rssi_threshold)
  * @brief Enable RSSI monitoring
@@ -2876,6 +3071,39 @@ int bluetooth_cancel_service_search(void);
 int bluetooth_rfcomm_create_socket(const char *uuid);
 
 /**
+ * @fn int bluetooth_rfcomm_create_socket_ex(const char *uuid, const char *bus_name, const char *path)
+ * @brief Register rfcomm socket with a specific uuid
+ *
+ *
+ * This API register rfcomm socket with the given UUID. The return value of this API is the socket
+ * descriptor of the server.
+ * This is the first API which is called to create the server. Once we created the server socket,
+ * we will listen on that return socket.
+ * So a bluetooth_rfcomm_listen_and_accept_ex should follow this API call. This is a synchronous call.
+ *
+ *
+ * @return  socket FD on Success \n
+ *              BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
+ *              BLUETOOTH_ERROR_INTERNAL - Internal error\n
+ *              BLUETOOTH_ERROR_MAX_CONNECTION - Maximum connection reached\n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ * @param[in]   UUID (128 bits)
+ * @param[in]   bus_name (const char)
+ * @param[in]   path (const char)
+ *
+ * @remark      None
+ * @see       bluetooth_rfcomm_listen_and_accept_ex, bluetooth_rfcomm_remove_socket
+ *
+ @code
+
+  const char *rfcomm_test_uuid="00001101-0000-1000-8000-00805F9B34FB";
+  fd  = bluetooth_rfcomm_create_socket_ex(rfcomm_test_uuid, bus_name, path);
+
+ @endcode
+ */
+int bluetooth_rfcomm_create_socket_ex(const char *uuid, const char *bus_name, const char *path);
+
+/**
  * @fn int bluetooth_rfcomm_remove_socket(int socket_fd, const char *uuid)
  * @brief De-register the rfcomm socket
  *
@@ -2922,6 +3150,52 @@ int bluetooth_rfcomm_create_socket(const char *uuid);
 int bluetooth_rfcomm_remove_socket(int socket_fd);
 
 /**
+ * @fn int bluetooth_rfcomm_remove_socket(const char *uuid)
+ * @brief De-register the rfcomm socket
+ *
+ *
+ * This API deregister rfcomm socket with the given socket UUID. If the remote device is
+ * already connected then we will receive the BLUETOOTH_EVENT_RFCOMM_DISCONNECTED with socket
+ * descriptor else no event will come. We will call this API only after the
+ * bluetooth_rfcomm_listen_and_accept_ex.
+ * This is a synchronous call.
+ *
+ * @return   BLUETOOTH_ERROR_NONE - Success \n
+ *               BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
+ *               BLUETOOTH_ERROR_NOT_FOUND - Cannot find the proxy\n
+ *               BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ * @param[in]   UUID (128 bits)
+ *
+ * @remark      None
+ * @see       bluetooth_rfcomm_create_socket_ex, bluetooth_rfcomm_listen_and_accept_ex
+ *
+ @code
+ void bt_event_callback(int event, bluetooth_event_param_t *param)
+ {
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED:
+               {
+                       bluetooth_rfcomm_connection_t *discon_ind =
+                                       (bluetooth_rfcomm_connection_t *)param->param_data;
+
+                       printf("\nDisconnected from FD %d",  discon_ind->socket_fd);
+               }
+       }
+ }
+
+ ...
+
+ int ret = 0;
+ fd  = bluetooth_rfcomm_create_socket_ex(rfcomm_test_uuid, path, bus_name);
+ ret = bluetooth_rfcomm_listen_and_accept_ex(rfcomm_test_uuid, 1, bus_name, path);
+ ....
+ ret = bluetooth_rfcomm_remove_socket_ex(rfcomm_test_uuid);
+ @endcode
+ */
+int bluetooth_rfcomm_remove_socket_ex(const char *uuid);
+
+/**
  * @fn int bluetooth_rfcomm_server_disconnect(int socket_fd)
  * @brief Disconnect rfcomm connection
  *
@@ -2997,6 +3271,56 @@ int bluetooth_rfcomm_server_disconnect(int socket_fd);
 int bluetooth_rfcomm_listen_and_accept(int socket_fd, int max_pending_connection);
 
 /**
+ * @fn int bluetooth_rfcomm_listen_and_accept_ex(const char *uuid, int max_pending_connection, const char *bus_name, const char *path)
+ * @brief Rfcomm socket listen
+ *
+ *
+ * This API make rfcomm socket listen and accept with socket. We will call this API immediatly
+ * after the bluetooth_rfcomm_create_socket API.
+ * This API listen for the incomming connection and once it receives a connection, it will give
+ * BLUETOOTH_EVENT_RFCOMM_CONNECTED
+ * event to the application. This is an Asynchronous API call.
+ *
+ *
+ * @return  BLUETOOTH_ERROR_NONE - Success \n
+ *              BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              BLUETOOTH_ERROR_CONNECTION_ERROR - Listen failed \n
+
+ * @param[in]  int socket_fd
+ * @param[in]  max pending connection.
+ * @param[in]  name
+ * @param[in]  path
+ *
+ * @remark      None
+ * @see       bluetooth_rfcomm_create_socket_ex
+ *
+  @code
+  void bt_event_callback(int event, bluetooth_event_param_t* param)
+ {
+       switch(event)
+       {
+               case BLUETOOTH_EVENT_RFCOMM_CONNECTED:
+               {
+                       bluetooth_rfcomm_connection_t *conn_ind =
+                                               (bluetooth_rfcomm_connection_t *)param->param_data;
+
+                       printf("\nConnected from FD %d",  conn_ind->socket_fd);
+               }
+       }
+ }
+
+ ...
+
+ int ret = 0;
+ fd  = bluetooth_rfcomm_create_socket_ex(rfcomm_test_uuid);
+ ret = bluetooth_rfcomm_listen_and_accept_ex(rfcomm_test_uuid, 1, bus_name, path);
+
+ @endcode
+ */
+
+int bluetooth_rfcomm_listen_and_accept_ex(const char *uuid, int max_pending_connection, const char *bus_name, const char *path);
+
+/**
  * @fn int bluetooth_rfcomm_listen(int socket_fd,int max_pending_connection)
  * @brief Rfcomm socket listen
  *
@@ -3061,7 +3385,7 @@ int bluetooth_rfcomm_listen(int socket_fd, int max_pending_connection);
  * @remark       None
  * @see          bluetooth_rfcomm_reject_connection
  */
-int bluetooth_rfcomm_accept_connection(int server_fd, int *client_fd);
+int bluetooth_rfcomm_accept_connection(int server_fd);
 
 /**
  * @fn int bluetooth_rfcomm_reject_connection()
@@ -3256,8 +3580,8 @@ int bluetooth_rfcomm_write(int fd, const char *buf, int length);
  * @remark       None
  */
 gboolean bluetooth_rfcomm_is_client_connected(void);
-int bluetooth_rfcomm_client_is_connected(bluetooth_device_address_t *device_address, gboolean *connected);
-int bluetooth_rfcomm_server_is_connected(bluetooth_device_address_t *device_address, gboolean *connected);
+int bluetooth_rfcomm_client_is_connected(const bluetooth_device_address_t *device_address, gboolean *connected);
+int bluetooth_rfcomm_server_is_connected(const bluetooth_device_address_t *device_address, gboolean *connected);
 
 /**
  * @fn int bluetooth_network_activate_server(void)
@@ -4147,6 +4471,33 @@ int bluetooth_gatt_set_characteristics_value(const char *char_handle,
                                                const guint8 *value, int length);
 
 /**
+ * @fn int bluetooth_gatt_set_characteristics_value_by_type(const char *char_handle,
+ *                             const guint8 *value, int length, guint8 write_type)
+ *
+ * @brief Set characteristic value by write type.
+ *
+ * This function is a synchronous call if write type is "write without resonse"
+ * and it is an asynchronous call if write type is "write with response"
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *             BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ *             BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
+ *
+ * @exception  None
+ * @param[in]  char_handle - Handle for Characteristic property.
+ * @param[in]  value - New value to set for characteristic property.
+ * @param[in]  length - Length of the value to be set.
+ * @param[in]  write_type - Type of write.
+ *
+ * @remark     None
+ * @see                None
+ */
+int bluetooth_gatt_set_characteristics_value_by_type(const char *char_handle,
+                               const guint8 *value, int length, guint8 write_type);
+
+
+/**
  * @fn int bluetooth_gatt_set_characteristics_value_request(const char *char_handle,
  *                                             const guint8 *value, int length)
  *
@@ -4601,6 +4952,35 @@ int bluetooth_gatt_register_service(const char *svc_path);
 */
 int bluetooth_gatt_unregister_service(const char *svc_path);
 
+/* @fn int bluetooth_gatt_send_response(int request_id,
+*                              int offset, char *value, int value_length)
+*
+* @brief Updates the attribute value in local attribute list.
+*
+* This function is a synchronous call.
+*
+* @return      BLUETOOTH_ERROR_NONE    - Success \n
+*       BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+*       BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
+*       BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
+*
+* @exception    None
+* @param[in] request_id The identification of a read request
+* @param[in] offset The offset from where a value is read
+* @param[in] value The value to be sent. It will be sent from @a offset.
+*              If it is NULL, a requested GATT handle's value will be sent from @a offset.
+* @param[in] value_length Value Length.
+*
+* @remark  Adapter should be enabled
+* @see bluetooth_gatt_add_service()
+* @see bluetooth_gatt_add_characteristics()
+* @see bluetooth_gatt_add_descriptor()
+* @see bluetooth_gatt_register_service()
+*/
+int bluetooth_gatt_send_response(int request_id,
+                               int offset, char *value, int value_length);
+
+
 /* @fn int bluetooth_gatt_delete_services(void)
 *
 * @brief deletes (unregisters) all services from the gatt server database..
@@ -4647,7 +5027,7 @@ int bluetooth_gatt_update_characteristic(const char *char_path,
                const char* char_value, int value_length);
 
 /**
- * @fn int bluetooth_set_advertising(gboolean enable);
+ * @fn int bluetooth_set_advertising(int handle, gboolean enable);
  *
  * @brief Set advertising status.
  *
@@ -4666,11 +5046,10 @@ int bluetooth_gatt_update_characteristic(const char *char_path,
  * @remark     None
  * @see                bluetooth_set_advertising_data
  */
-int bluetooth_set_advertising(gboolean enable);
+int bluetooth_set_advertising(int handle, gboolean enable);
 
 /**
- * @fn int bluetooth_set_custom_advertising(gboolean enable, float interval_min, float interval_max,
- *                                     guint8 filter_policy);
+ * @fn int bluetooth_set_custom_advertising(int handle, gboolean enable, bluetooth_advertising_params_t *params);
  *
  * @brief Set advertising status along with interval value.
  *
@@ -4693,7 +5072,7 @@ int bluetooth_set_advertising(gboolean enable);
  * @remark     None
  * @see                bluetooth_set_advertising_data
  */
-int bluetooth_set_custom_advertising(gboolean enable,
+int bluetooth_set_custom_advertising(int handle, gboolean enable,
                                        bluetooth_advertising_params_t *params);
 
 /**
@@ -4724,7 +5103,7 @@ ret = bluetooth_get_advertising_data(&value, &length);
 int bluetooth_get_advertising_data(bluetooth_advertising_data_t *value, int *length);
 
 /**
- * @fn int bluetooth_set_advertising_data(const bluetooth_advertising_data_t *value, int length);
+ * @fn int bluetooth_set_advertising_data(int handle, const bluetooth_advertising_data_t *value, int length);
  *
  * @brief Set advertising data with value
  *
@@ -4742,7 +5121,23 @@ int bluetooth_get_advertising_data(bluetooth_advertising_data_t *value, int *len
  *
  * @remark     None
  */
-int bluetooth_set_advertising_data(const bluetooth_advertising_data_t *value, int length);
+int bluetooth_set_advertising_data(int handle, const bluetooth_advertising_data_t *value, int length);
+
+/**
+ * @fn int bluetooth_check_privilege_advertising_parameter(void);
+ *
+ * @brief Check the privilege for advertising parameter setting
+ *
+ * This function is a synchronous call.
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_PERMISSION_DEINED - Permission deined \n
+ *
+ * @exception  None
+ *
+ * @remark     None
+ */
+int bluetooth_check_privilege_advertising_parameter(void);
 
 /**
  * @fn int bluetooth_get_scan_response_data(bluetooth_scan_resp_data_t *value, int *length);
@@ -4772,7 +5167,7 @@ ret = bluetooth_get_scan_response_data(&value, &length);
 int bluetooth_get_scan_response_data(bluetooth_scan_resp_data_t *value, int *length);
 
 /**
- * @fn int bluetooth_set_scan_response_data(const bluetooth_scan_resp_data_t *value, int length);
+ * @fn int bluetooth_set_scan_response_data(int handle, const bluetooth_scan_resp_data_t *value, int length);
  *
  * @brief Set scan response data with value
  *
@@ -4789,7 +5184,7 @@ int bluetooth_get_scan_response_data(bluetooth_scan_resp_data_t *value, int *len
  *
  * @remark     None
  */
-int bluetooth_set_scan_response_data(const bluetooth_scan_resp_data_t *value, int length);
+int bluetooth_set_scan_response_data(int handle, const bluetooth_scan_resp_data_t *value, int length);
 
 /**
  * @fn int bluetooth_set_scan_parameters(bluetooth_le_scan_params_t *params);
index 72d7df2..6d46f83 100644 (file)
@@ -158,6 +158,16 @@ int bluetooth_ag_disconnect(bluetooth_device_address_t *remote_address);
 int bluetooth_av_connect(bluetooth_device_address_t *remote_address);
 
 /**
+ * @brief      The function bluetooth_av_source_connect is called to establish an AV Source
+ *     connection with  the specified device.
+ *
+ * @param[in]  remote_address  Bluetooth device address.
+ * @return     int     Zero on Success or reason for error if any.
+ *
+ */
+int bluetooth_av_source_connect(bluetooth_device_address_t *remote_address);
+
+/**
  * @brief      The function bluetooth_av_disconnect is called to disconnect an
  *     existing AV connection with the specified device.
  *
@@ -168,6 +178,16 @@ int bluetooth_av_connect(bluetooth_device_address_t *remote_address);
 int bluetooth_av_disconnect(bluetooth_device_address_t *remote_address);
 
 /**
+ * @brief      The function bluetooth_av_source_disconnect is called to disconnect an
+ *     existing AV connection with the specified device.
+ *
+ * @param[in]  remote_address  Bluetooth device address.
+ * @return     int     Zero on Success or reason for error if any.
+ *
+ */
+int bluetooth_av_source_disconnect(bluetooth_device_address_t *remote_address);
+
+/**
  * @brief      The function bluetooth_ag_get_headset_volume is called to get
  *     the changed Volume on AG.
  *
@@ -239,7 +259,7 @@ int bluetooth_hf_get_codec(unsigned int *codec_id);
 
 int bluetooth_hf_get_audio_connected(unsigned int *audio_connected);
 
-int bluetooth_hf_is_hf_connected(gboolean *hf_connected);
+int bluetooth_hf_is_connected(gboolean *hf_connected);
 
 #ifdef __cplusplus
 }
index fbffc40..7391ce9 100644 (file)
@@ -49,6 +49,22 @@ typedef struct {
        void *user_data;
 } hid_event_param_t;
 
+typedef struct {
+       unsigned char btcode;
+       unsigned char rep_id;
+       unsigned char button;
+       signed char axis_x;
+       signed char axis_y;
+       signed char axis_z;
+} hid_send_mouse_event_t;
+
+typedef struct {
+       unsigned char   btcode;
+       unsigned char   rep_id;
+       unsigned char   modify;
+       unsigned char   key[8];
+} hid_send_key_event_t;
+
 typedef void (*hid_cb_func_ptr)(int, hid_event_param_t *, void *);
 
 typedef struct {
@@ -133,6 +149,174 @@ int bluetooth_hid_connect(hid_device_address_t *device_address);
  */
 int bluetooth_hid_disconnect(hid_device_address_t *device_address);
 
+/**
+ * @fn int bluetooth_hid_device_init(hid_cb_func_ptr callback_ptr, void *user_data)
+ * @brief Initialize HID Device service and register the callback
+ *
+ * This function is a synchronous call.
+ *
+ * @return  HID_ERROR_NONE  - Success \n
+ *              HID_ERROR_ALREADY_INITIALIZED - Aready Initialized \n
+ *              HID_ERROR_INTERNAL - Internal Error \n
+ *              HID_ERROR_NOT_ENABLED - Not enabled \n
+ *
+ * @remark      None
+ *
+ */
+int bluetooth_hid_device_init(hid_cb_func_ptr callback, void *user_data);
+
+/**
+ * @fn int bluetooth_hid_device_deinit(void)
+ * @brief Initialize HID service and register the callback
+ *
+ * This function is a synchronous call.
+ *
+ * @return  HID_ERROR_NONE  - Success \n
+ *              HID_ERROR_NOT_INITIALIZED - Not Initialiezed \n
+ *
+ * @remark      None
+ *
+ */
+int bluetooth_hid_device_deinit();
+
+/**
+ * @fn int bluetooth_hid_device_activate()
+ *
+ * @brief Register the HID Device UUID with bluez with RegisterProfile.
+ *
+ * This function is a asynchronous call.
+ *
+ * @return  HID_ERROR_NONE  - Success \n
+ *              HID_ERROR_NOT_INITIALIZED - Internal Error \n
+ *              HID_ERROR_NOT_ENABLED - Not enabled \n
+ *              HID_ERROR_INTERNAL - Not enabled \n
+ *
+ * @exception   None
+ * @remark      None
+ */
+int bluetooth_hid_device_activate(void);
+
+/**
+ * @fn int bluetooth_hid_device_deactivate()
+ *
+ * @brief Unregister the HID Device UUID with bluez with UnRegisterProfile.
+ *
+ * This function is a asynchronous call.
+ *
+ * @return  HID_ERROR_NONE  - Success \n
+ *              HID_ERROR_NOT_INITIALIZED - Internal Error \n
+ *              HID_ERROR_NOT_ENABLED - Not enabled \n
+ *              HID_ERROR_INTERNAL - Not enabled \n
+ *
+ * @exception   None
+ * @remark      None
+ */
+int bluetooth_hid_device_deactivate(void);
+
+/**
+ * @fn int bluetooth_hid_device_connect(const char *remote_addr)
+ *
+ * @brief Initiate the connection for HID device role with remote device
+ * address specified as parameter.
+ *
+ * This function is a asynchronous call.
+ *
+ * @return  HID_ERROR_NONE  - Success \n
+ *
+ * @exception   None
+ * @param[in]  remote_addr   device address of remote device.
+ * @remark      None
+ */
+int bluetooth_hid_device_connect(const char *remote_addr);
+/**
+ * @fn int bluetooth_hid_device_disconnect()
+ *
+ * @brief Terminate the connection with HID host device with DisconnectProfile.
+ *
+ * This function is a asynchronous call.
+ *
+ * @return  HID_ERROR_NONE  - Success \n
+ *              HID_ERROR_NOT_INITIALIZED - Internal Error \n
+ *              HID_ERROR_NOT_ENABLED - Not enabled \n
+ *              HID_ERROR_INTERNAL - Not enabled \n
+ *
+ * @exception   None
+ * @param[in]  remote_addr   device address of remote device.
+ * @remark      None
+ */
+
+int bluetooth_hid_device_disconnect(const char *remote_addr);
+
+/**
+ * @fn int bluetooth_hid_send_mouse_event(hid_send_mouse_event_t send_event)
+ *
+ * @brief write the event data on the socket.
+ *
+ * This function is a asynchronous call.
+ *
+ * @return  HID_ERROR_NONE  - Success \n
+ *              HID_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              HID_ERROR_NOT_INITIALIZED - Internal Error \n
+ *              HID_ERROR_NOT_ENABLED - Not enabled \n
+ *              HID_ERROR_INTERNAL - Not enabled \n
+ *
+ * @exception   None
+ * @param[in]  remote_addr   device address of remote device.
+ * @param[in]  send_event   This indicates the event data to send to remote device.
+ * @remark      None
+ */
+int bluetooth_hid_device_send_mouse_event(const char *remote_addr,
+               hid_send_mouse_event_t send_event);
+
+/**
+ * @fn int bluetooth_hid_device_send_key_event(hid_send_key_event_t send_event)
+ *
+ * @brief write the event data on the socket.
+ *
+ * This function is a asynchronous call.
+ *
+ * @return  HID_ERROR_NONE  - Success \n
+ *              HID_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              HID_ERROR_NOT_INITIALIZED - Internal Error \n
+ *              HID_ERROR_NOT_ENABLED - Not enabled \n
+ *              HID_ERROR_INTERNAL - Not enabled \n
+ *
+ * @exception   None
+ * @param[in]  remote_addr   device address of remote device.
+ * @param[in]  send_event   This indicates the event data to send to remote device.
+ * @remark      None
+ */
+int bluetooth_hid_device_send_key_event(const char *remote_addr,
+               hid_send_key_event_t send_event);
+
+/**
+ * @fn int bluetooth_hid_device_reply_to_report(const char *remote_addr,
+ *                     bt_hid_header_type_t htype,
+ *                     bt_hid_param_type_t ptype,
+ *                     char *buffer)
+ *
+ * @brief write the event data on the socket.
+ *
+ * This function is a asynchronous call.
+ *
+ * @return  HID_ERROR_NONE  - Success \n
+ *              HID_ERROR_INVALID_PARAM - Invalid parameter \n
+ *              HID_ERROR_NOT_INITIALIZED - Internal Error \n
+ *              HID_ERROR_NOT_ENABLED - Not enabled \n
+ *              HID_ERROR_INTERNAL - Not enabled \n
+ *
+ * @exception   None
+ * @param[in]  remote_addr   device address of remote device.
+ * @param[in]  htype   header type to be present in response
+ * @param[in]  ptype   Parameter type to be present in response.
+ * @param[in]  buffer   Data need to be send in reponse payload.
+ * @remark      None
+ */
+int bluetooth_hid_device_reply_to_report(const char *remote_addr,
+               bt_hid_header_type_t htype,
+               bt_hid_param_type_t ptype,
+               const char *data,
+               unsigned int data_len);
 
 #ifdef __cplusplus
 }
index f0a0195..1e69798 100644 (file)
@@ -61,23 +61,12 @@ typedef enum {
 } media_player_repeat_status;
 
 typedef enum {
-       STATUS_STOPPED = 0x00,
-       STATUS_PLAYING,
-       STATUS_PAUSED,
-       STATUS_FORWARD_SEEK,
-       STATUS_REVERSE_SEEK,
-       STATUS_ERROR,
-       STATUS_INVALID
-} media_player_status;
-
-typedef enum {
        SHUFFLE_MODE_OFF = 0x01,
        SHUFFLE_ALL_TRACK,
        SHUFFLE_GROUP,
        SHUFFLE_INVALID,
 } media_player_shuffle_status;
 
-/* bluez 4.101 */
 typedef enum {
        SCAN_MODE_OFF = 0x01,
        SCAN_ALL_TRACK,
@@ -86,6 +75,16 @@ typedef enum {
 } media_player_scan_status;
 
 typedef enum {
+       STATUS_STOPPED = 0x00,
+       STATUS_PLAYING,
+       STATUS_PAUSED,
+       STATUS_FORWARD_SEEK,
+       STATUS_REVERSE_SEEK,
+       STATUS_ERROR,
+       STATUS_INVALID
+} media_player_status;
+
+typedef enum {
        PLAY = 0x01,
        PAUSE,
        STOP,
index b8e76f1..a41d8cf 100644 (file)
@@ -363,6 +363,15 @@ int bluetooth_telephony_get_headset_volume(unsigned int *speaker_gain);
  */
 int bluetooth_telephony_set_speaker_gain(unsigned short speaker_gain);
 
+/**
+ * @brief      The function bluetooth_telephony_is_connected is called to get
+ *     the connection state on AG.
+ *
+ * @param[in]  ag_connnected   Connection state.
+ * @return     int     Zero on Success or reason for error if any.
+ *
+ */
+int bluetooth_telephony_is_connected(gboolean *ag_connected);
 
 #ifdef __cplusplus
 }
index 69e2e54..da69648 100644 (file)
@@ -67,6 +67,8 @@ typedef enum {
        BT_MEDIA_TRANSFER_EVENT,
        BT_HF_AGENT_EVENT,
        BT_AVRCP_CONTROL_EVENT,
+       BT_A2DP_SOURCE_EVENT,
+       BT_HID_DEVICE_EVENT,
        /* Will be added */
 } bt_event_type_t;
 
@@ -158,6 +160,7 @@ typedef enum {
        BT_RESET_ADAPTER,
        BT_SET_ADVERTISING,
        BT_SET_CUSTOM_ADVERTISING,
+       BT_SET_ADVERTISING_PARAMETERS,
        BT_GET_ADVERTISING_DATA,
        BT_SET_ADVERTISING_DATA,
        BT_SET_SCAN_PARAMETERS,
@@ -169,6 +172,9 @@ typedef enum {
        BT_ADD_WHITE_LIST,
        BT_REMOVE_WHITE_LIST,
        BT_CLEAR_WHITE_LIST,
+       BT_REGISTER_SCAN_FILTER,
+       BT_UNREGISTER_SCAN_FILTER,
+       BT_UNREGISTER_ALL_SCAN_FILTERS,
        BT_BOND_DEVICE = BT_FUNC_DEVICE_BASE,
        BT_BOND_DEVICE_BY_TYPE,
        BT_CANCEL_BONDING,
@@ -180,8 +186,16 @@ typedef enum {
        BT_SET_AUTHORIZATION,
        BT_UNSET_AUTHORIZATION,
        BT_IS_DEVICE_CONNECTED,
+       BT_GET_CONNECTED_LINK_TYPE,
        BT_HID_CONNECT = BT_FUNC_HID_BASE,
        BT_HID_DISCONNECT,
+       BT_HID_DEVICE_ACTIVATE,
+       BT_HID_DEVICE_DEACTIVATE,
+       BT_HID_DEVICE_CONNECT,
+       BT_HID_DEVICE_DISCONNECT,
+       BT_HID_DEVICE_SEND_MOUSE_EVENT,
+       BT_HID_DEVICE_SEND_KEY_EVENT,
+       BT_HID_DEVICE_SEND_REPLY_TO_REPORT,
        BT_NETWORK_ACTIVATE = BT_FUNC_NETWORK_BASE,
        BT_NETWORK_DEACTIVATE,
        BT_NETWORK_CONNECT,
@@ -193,6 +207,8 @@ typedef enum {
        BT_AG_DISCONNECT,
        BT_AV_CONNECT,
        BT_AV_DISCONNECT,
+       BT_AV_SOURCE_CONNECT,
+       BT_AV_SOURCE_DISCONNECT,
        BT_HF_CONNECT,
        BT_HF_DISCONNECT,
        BT_GET_SPEAKER_GAIN,
@@ -236,6 +252,8 @@ typedef enum {
        BT_RFCOMM_IS_UUID_AVAILABLE,
        BT_RFCOMM_ACCEPT_CONNECTION,
        BT_RFCOMM_REJECT_CONNECTION,
+       BT_RFCOMM_CREATE_SOCKET_EX,
+       BT_RFCOMM_REMOVE_SOCKET_EX,
        BT_PBAP_CONNECT = BT_FUNC_PBAP_BASE,
        BT_PBAP_DISCONNECT,
        BT_PBAP_GET_PHONEBOOK_SIZE,
@@ -305,6 +323,8 @@ typedef struct {
 #define BT_CORE_EVENT_PATH "/org/projectx/bt/bt_core"
 #define BT_HF_LOCAL_TERM_EVENT_PATH "/org/projectx/bt/hf_local_term"
 #define BT_AVRCP_CONTROL_PATH "/org/projectx/bt/avrcp_control"
+#define BT_A2DP_SOURCE_PATH "/org/projectx/bt/a2dp_source"
+#define BT_HID_DEVICE_PATH "/org/projectx/bt/hid_device"
 
 #define BT_ENABLED "Enabled"
 #define BT_DISABLED "Disabled"
@@ -317,7 +337,6 @@ typedef struct {
 #define BT_DISCOVERY_STARTED "DiscoveryStarted"
 #define BT_DISCOVERY_FINISHED "DiscoveryFinished"
 #define BT_DEVICE_FOUND "DeviceFound"
-#define BT_DEVICE_DISAPPEARED "DeviceDisappeared"
 #define BT_LE_DISCOVERY_STARTED "LEDiscoveryStarted"
 #define BT_LE_DISCOVERY_FINISHED "LEDiscoveryFinished"
 #define BT_LE_DEVICE_FOUND "LEDeviceFound"
@@ -340,6 +359,7 @@ typedef struct {
 #define BT_INPUT_CONNECTED "InputConnected"
 #define BT_INPUT_DISCONNECTED "InputDisconnected"
 #define BT_PBAP_CONNECTED "PbapConnected"
+#define BT_PBAP_DISCONNECTED "PbapDisconnected"
 #define BT_PBAP_PHONEBOOK_SIZE "PbapPhonebookSize"
 #define BT_PBAP_PHONEBOOK_PULL "PbapPhonebookPull"
 #define BT_PBAP_VCARD_LIST "PbapvCardList"
@@ -349,6 +369,8 @@ typedef struct {
 #define BT_HEADSET_DISCONNECTED "HeadsetDisconnected"
 #define BT_STEREO_HEADSET_CONNECTED "StereoHeadsetConnected"
 #define BT_STEREO_HEADSET_DISCONNECTED "StereoHeadsetDisconnected"
+#define BT_A2DP_SOURCE_CONNECTED "A2DPSourceConnected"
+#define BT_A2DP_SOURCE_DISCONNECTED "A2DPSourceDisconnected"
 #define BT_SCO_CONNECTED "ScoConnected"
 #define BT_SCO_DISCONNECTED "ScoDisconnected"
 #define BT_SPEAKER_GAIN "SpeakerGain"
@@ -386,9 +408,12 @@ typedef struct {
 #define BT_NAME_OWNER_CHANGED "NameOwnerChanged"
 #define BT_GATT_CONNECTED "GattConnected"
 #define BT_GATT_DISCONNECTED "GattDisconnected"
+#define BT_GATT_CHAR_VAL_CHANGED "GattCharValueChanged"
 #define BT_HARDWARE_ERROR "HardwareError"
 #define BT_TX_TIMEOUT_ERROR "TxTimeoutError"
 #define BT_HF_LOCAL_TERM "HandsfreeLocalTermination"
+#define BT_HID_DEVICE_CONNECTED "HIDConnected"
+#define BT_HID_DEVICE_DISCONNECTED "HIDDisconnected"
 
 #ifdef __cplusplus
 }
index 09010da..abcbb44 100644 (file)
@@ -4,6 +4,9 @@ After=dbus.socket dbus.service
 Requires=dbus.socket
 
 [Service]
+User=system
+Group=system
+SmackProcessLabel=bt-service
 Type=dbus
 BusName=org.projectx.bt
 ExecStart=/usr/bin/bt-service
diff --git a/packaging/bluetooth-frwk.manifest b/packaging/bluetooth-frwk.manifest
deleted file mode 100644 (file)
index 017d22d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
- <request>
-    <domain name="_"/>
- </request>
-</manifest>
index d6b3e67..254ea55 100644 (file)
@@ -1,63 +1,44 @@
-%bcond_with x
 %define _dumpdir /opt/etc/dump.d/module.d
 %define _varlibdir /opt/var/lib
 
 Name:       bluetooth-frwk
 Summary:    Bluetooth framework for BlueZ and Obexd. This package is Bluetooth framework based on BlueZ and Obexd stack.
-Version:    0.2.146
-Release:    0
-Group:      Network & Connectivity/Bluetooth
+Version:    0.2.148
+Release:    1
+Group:      TO_BE/FILLED_IN
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
-Source1001: bluetooth-frwk.manifest
-Source1002: bt-icon.png
-URL:        https://review.tizen.org/git/?p=platform/core/connectivity/bluetooth-frwk.git;a=summary
+
+Requires: sys-assert
 Requires: dbus
 Requires: syspopup
-%if "%{?profile}" != "mobile"
-Requires: bluetooth-tools
-%endif
-
 BuildRequires:  pkgconfig(aul)
 BuildRequires:  pkgconfig(dbus-glib-1)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(gio-2.0)
 BuildRequires:  pkgconfig(gio-unix-2.0)
-%if %{with bluetooth_frwk_libnotify}
-BuildRequires:  pkgconfig(libnotify)
-BuildRequires:  pkgconfig(gdk-pixbuf-2.0)
-BuildRequires:  pkgconfig(gtk+-3.0)
-%elif %{without bluetooth_frwk_libnotification}
 BuildRequires:  pkgconfig(syspopup-caller)
-Requires:       syspopup
-%else
-BuildRequires:  pkgconfig(syspopup-caller)
-%endif
 BuildRequires:  pkgconfig(vconf)
 BuildRequires:  pkgconfig(libxml-2.0)
 BuildRequires:  pkgconfig(dbus-1)
-%if %{with x}
 BuildRequires:  pkgconfig(utilX)
-%endif
 BuildRequires:  pkgconfig(capi-network-connection)
-
-BuildRequires:  pkgconfig(libprivilege-control)
-BuildRequires:  pkgconfig(status)
 BuildRequires:  pkgconfig(alarm-service)
-BuildRequires:  pkgconfig(notification)
+BuildRequires:  pkgconfig(security-server)
 BuildRequires:  pkgconfig(capi-content-mime-type)
 BuildRequires:  pkgconfig(appcore-efl)
 BuildRequires:  pkgconfig(pkgmgr)
-#BuildRequires:  pkgconfig(journal)
+BuildRequires:  pkgconfig(journal)
+BuildRequires:  pkgconfig(eventsystem)
+%if "%{?tizen_profile_name}" == "mobile"
+BuildRequires:  pkgconfig(capi-network-tethering)
+%endif
+
 BuildRequires:  cmake
-BuildRequires:  pkgconfig(libtzplatform-config)
-BuildRequires:  pkgconfig(cynara-client)
-BuildRequires:  pkgconfig(cynara-creds-dbus)
 
-Requires(post): /usr/bin/vconftool
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
+Requires(post): vconf
+Requires(postun): eglibc
 Requires: psmisc
 
 %description
@@ -67,7 +48,7 @@ Bluetooth framework for BlueZ and Obexd. This package is Bluetooth framework bas
 
 %package devel
 Summary:    Bluetooth framework for BlueZ and Obexd
-Group:      Development/Libraries
+Group:      TO_BE/FILLED
 Requires:   %{name} = %{version}-%{release}
 
 %description devel
@@ -76,7 +57,7 @@ This package contains API set for BT GAP, BT SDP, and BT RFCOMM.
 
 %package service
 Summary:    Bluetooth Service daemon
-Group:      Network & Connectivity/Bluetooth
+Group:      TO_BE/FILLED
 Requires:   %{name} = %{version}-%{release}
 
 %description service
@@ -84,16 +65,15 @@ This package is Bluetooth Service daemon to manage BT services.
 
 %package core
 Summary:    Bluetooth Core daemon
-Group:      Network & Connectivity/Bluetooth
+Group:      TO_BE/FILLED
 Requires:   %{name} = %{version}-%{release}
-Requires:   connman
 
 %description core
 This package is Bluetooth core daemon to manage activation / deactivation.
 
 %package test
 Summary:    Bluetooth test application
-Group:      Network & Connectivity/Bluetooth
+Group:      TO_BE/FILLED
 Requires:   %{name} = %{version}-%{release}
 
 %description test
@@ -101,7 +81,6 @@ This package is Bluetooth test application.
 
 %prep
 %setup -q
-cp %{SOURCE1001} .
 
 
 %build
@@ -109,40 +88,35 @@ export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
 export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
 export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
 
-%ifarch x86_64
-export CFLAGS+=" -Wall -g -fvisibility=hidden -fPIC -DRFCOMM_DIRECT "
-export LDFLAGS+=" -Wl,--rpath=%{_libdir} -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs"
-%else
-export CFLAGS+=" -fpie -DRFCOMM_DIRECT "
-export LDFLAGS+=" -Wl,--rpath=/usr/lib -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs -pie"
-%endif
-
-%ifarch aarch64
-export CFLAGS="${CFLAGS} -D__TIZEN_MOBILE__ -DTIZEN_TELEPHONY_ENABLED"
+%if "%{?tizen_profile_name}" == "mobile"
+export CFLAGS="$CFLAGS -DTIZEN_NETWORK_TETHERING_ENABLE"
 %endif
 
-%cmake . \
--DTZ_SYS_USER_GROUP=%TZ_SYS_USER_GROUP \
--DTZ_SYS_DEFAULT_USER=%TZ_SYS_DEFAULT_USER \
-%if %{with bluetooth_frwk_libnotify}
- -DLIBNOTIFY_SUPPORT=On \
+%if "%{?tizen_profile_name}" == "wearable"
+export CFLAGS="$CFLAGS -DTIZEN_WEARABLE"
+%define _servicefile packaging/bluetooth-frwk-wearable.service
+%define _servicedir multi-user.target.wants
 %else
- -DLIBNOTIFY_SUPPORT=Off \
+%define _servicefile packaging/bluetooth-frwk-mobile.service
+%define _servicedir graphical.target.wants
 %endif
-%if %{with bluetooth_frwk_libnotification}
- -DLIBNOTIFICATION_SUPPORT=On
-%else
- -DLIBNOTIFICATION_SUPPORT=Off
+%define _servicedir multi-user.target.wants
+
+%if "%{?tizen_profile_name}" == "mobile"
+export CFLAGS="$CFLAGS -DTIZEN_BT_FLIGHTMODE_ENABLED"
 %endif
 
+export LDFLAGS+=" -Wl,--rpath=/usr/lib -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs -pie"
+
+export CFLAGS+=" -fpie -DRFCOMM_DIRECT "
+cmake . -DCMAKE_INSTALL_PREFIX=/usr
+
+make
+
 %cmake \
 %if "%{?tizen_profile_name}" == "wearable"
        -DTIZEN_WEARABLE=YES \
-%endif
-%if "%{?tizen_profile_name}" == "mobile"
-       -DTIZEN_WEARABLE=NO \
-%endif
-%if "%{?tizen_profile_name}" == "common"
+%else
        -DTIZEN_WEARABLE=NO \
 %endif
 
@@ -154,53 +128,39 @@ install -D -m 0644 LICENSE %{buildroot}%{_datadir}/license/bluetooth-frwk
 install -D -m 0644 LICENSE %{buildroot}%{_datadir}/license/bluetooth-frwk-service
 install -D -m 0644 LICENSE %{buildroot}%{_datadir}/license/bluetooth-frwk-devel
 
-mkdir -p %{buildroot}%{_unitdir_user}
-install -m 0644 bt-service/bluetooth-frwk-service.service %{buildroot}%{_unitdir_user}
+mkdir -p %{buildroot}%{_libdir}/systemd/system/%{_servicedir}
+install -m 0644 %{_servicefile} %{buildroot}%{_libdir}/systemd/system/bluetooth-frwk.service
+ln -s ../bluetooth-frwk.service %{buildroot}%{_libdir}/systemd/system/%{_servicedir}/bluetooth-frwk.service
 
-%if %{with bluetooth_frwk_libnotify} || %{with bluetooth_frwk_libnotification}
-mkdir -p %{buildroot}%{_datadir}/icons/default
-install -m 0644 %{SOURCE1002} %{buildroot}%{_datadir}/icons/default/bt-icon.png
-%endif
-
-# On IVI bt-service needs to be run as 'app' even if there is a 'guest' user.
-%if "%{profile}"=="ivi"
-sed -i 's/%TZ_SYS_DEFAULT_USER/app/' %{buildroot}%{_datadir}/dbus-1/system-services/org.projectx.bt.service
-%endif
+mkdir -p %{buildroot}%{_dumpdir}
+install -m 0755 bluetooth_log_dump.sh %{buildroot}%{_dumpdir}
 
 %post
-/sbin/ldconfig
 %if "%{?tizen_profile_name}" == "wearable"
-vconftool set -f -t int db/bluetooth/status "1" -g 6520
-%endif
-%if "%{?tizen_profile_name}" == "mobile"
-vconftool set -f -t int db/bluetooth/status "0" -g 6520
-%endif
-%if "%{?tizen_profile_name}" == "common"
-vconftool set -f -t int db/bluetooth/status "0" -g 6520
+vconftool set -tf int db/bluetooth/status "1" -g 5000 -s tizen::vconf::public::r::platform::rw
+%else
+vconftool set -tf int db/bluetooth/status "0" -g 5000 -s tizen::vconf::public::r::platform::rw
 %endif
+#vconftool set -tf int db/bluetooth/lestatus "0" -g 5000 -s tizen::vconf::public::r::platform::rw
+#vconftool set -tf int file/private/bt-core/flight_mode_deactivated "0" -g 5000 -i -s tizen::vconf::platform::rw
+#vconftool set -tf int file/private/bt-core/powersaving_mode_deactivated "0" -g 5000 -i -s tizen::vconf::platform::rw
+#vconftool set -tf int file/private/bt-service/bt_off_due_to_timeout "0" -g 5000 -i -s tizen::vconf::platform::rw
+#vconftool set -tf string memory/bluetooth/sco_headset_name "" -g 5000 -i -s tizen::vconf::platform::rw
+#vconftool set -tf int memory/bluetooth/device "0" -g 5000 -i -s tizen::vconf::platform::rw
+#vconftool set -tf bool memory/bluetooth/dutmode "0" -g 5000 -i -s tizen::vconf::platform::rw
 
-
-vconftool set -f -t int db/bluetooth/status "0" -s User
-vconftool set -f -t int db/bluetooth/lestatus "0" -s User
-vconftool set -f -t int file/private/bt-core/flight_mode_deactivated "0" -s User
-vconftool set -f -t int file/private/bt-core/powersaving_mode_deactivated "0" -s User
-vconftool set -f -t int file/private/bt-service/bt_off_due_to_timeout "0" -s User
-vconftool set -f -t string memory/bluetooth/sco_headset_name "" -g 6520 -i
-vconftool set -f -t int memory/bluetooth/device "0" -g 6520 -i
-vconftool set -f -t bool memory/bluetooth/btsco "0" -g 6520 -i
-vconftool set -f -t bool memory/bluetooth/dutmode "0" -g 6520 -i
-
-#%post service
-#mkdir -p %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
-#ln -sf %{_libdir}/systemd/system/bluetooth-frwk.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+%post service
+mkdir -p %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+ln -sf %{_libdir}/systemd/system/bluetooth-frwk.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
 
 %postun -p /sbin/ldconfig
 
 %files
-%manifest %{name}.manifest
 %defattr(-, root, root)
 %{_libdir}/libbluetooth-api.so.*
 %{_datadir}/license/bluetooth-frwk
+%{_libdir}/systemd/system/%{_servicedir}/bluetooth-frwk.service
+%{_libdir}/systemd/system/bluetooth-frwk.service
 
 %files devel
 %defattr(-, root, root)
@@ -215,33 +175,30 @@ vconftool set -f -t bool memory/bluetooth/dutmode "0" -g 6520 -i
 %{_datadir}/license/bluetooth-frwk-devel
 
 %files service
-%manifest %{name}.manifest
+%manifest bluetooth-frwk.manifest
 %defattr(-, root, root)
+%{_sysconfdir}/rc.d/init.d/bluetooth-frwk-service
 %{_datadir}/dbus-1/system-services/org.projectx.bt.service
-
 %{_bindir}/bt-service
-%{_unitdir_user}/bluetooth-frwk-service.service
-%{_sysconfdir}/dbus-1/system.d/bluetooth-frwk-service.conf
 %{_bindir}/bluetooth-frwk-test
-#%{_bindir}/bluetooth-gatt-test
-#%{_bindir}/bluetooth-advertising-test
+%{_bindir}/bluetooth-gatt-test
+%{_bindir}/bluetooth-advertising-test
 %{_varlibdir}/bluetooth
 %{_prefix}/etc/bluetooth
+%attr(0666,-,-) %{_varlibdir}/bluetooth/auto-pair-blacklist
+%attr(0666,-,-) %{_prefix}/etc/bluetooth/stack_info
+%{_dumpdir}/bluetooth_log_dump.sh
 %{_datadir}/license/bluetooth-frwk-service
-%if %{with bluetooth_frwk_libnotify} || %{with bluetooth_frwk_libnotification}
-%{_datadir}/icons/default/bt-icon.png
-%endif
 
 %files core
-%manifest %{name}.manifest
+%manifest bluetooth-frwk-core.manifest
 %defattr(-, root, root)
 %{_datadir}/dbus-1/system-services/org.projectx.bt_core.service
 %{_bindir}/bt-core
-%{_sysconfdir}/dbus-1/system.d/bluetooth-frwk-core.conf
 
 %files test
-%manifest %{name}.manifest
+%manifest bluetooth-frwk-test.manifest
 %defattr(-, root, root)
 %{_bindir}/bluetooth-frwk-test
-#%{_bindir}/bluetooth-gatt-test
-#%{_bindir}/bluetooth-advertising-test
+%{_bindir}/bluetooth-gatt-test
+%{_bindir}/bluetooth-advertising-test
diff --git a/packaging/bt-icon.png b/packaging/bt-icon.png
deleted file mode 100644 (file)
index 9d2483e..0000000
Binary files a/packaging/bt-icon.png and /dev/null differ
index 7cf3104..4c628e3 100644 (file)
@@ -36,6 +36,6 @@ INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
 
 #ADD_SUBDIRECTORY(media-control)
 #ADD_SUBDIRECTORY(telephony)
-#ADD_SUBDIRECTORY(gatt-test)
+ADD_SUBDIRECTORY(gatt-test)
 #ADD_SUBDIRECTORY(handsfree)
-#ADD_SUBDIRECTORY(le-adv)
+ADD_SUBDIRECTORY(le-adv)
index 97b7706..146086c 100644 (file)
@@ -68,7 +68,6 @@ const char * rfcomm_test_uuid_custom ="26b2831b-2c2d-4f9c-914a-c0ab142351b7";
 
 
 GMainLoop *main_loop = NULL;
-static int timeout_status = 0;
 
 int current_transfer_id = 0;
 
@@ -261,17 +260,29 @@ void tc_usage_print(void)
        }
 }
 
-int test_input_callback(void *data)
+int find_tc_number(int input)
 {
-       int ret = 0;
        int i = 0;
-       int test_id = (int)data;
 
-       while(tc_table[i].tc_code != test_id) {
+       while (tc_table[i].tc_code != 0x0000)
+       {
+               if (tc_table[i].tc_code == input)
+                       return i;
                i++;
        }
-       TC_PRT("TC : %s", tc_table[i].tc_name);
-       switch (test_id)
+
+       return -1;
+}
+
+int test_input_callback(void *data)
+{
+       int ret = 0;
+       int test_id;
+
+       test_id = find_tc_number((int)data);
+       TC_PRT("TC : %s[%d]", tc_table[test_id ].tc_name, tc_table[test_id ].tc_code);
+
+       switch (tc_table[test_id ].tc_code)
        {
                case 0x00ff:
                        TC_PRT("Finished");
@@ -282,8 +293,8 @@ int test_input_callback(void *data)
                        bluetooth_register_callback(bt_event_callback, NULL);
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
-                               tc_result(TC_FAIL, i);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[0].tc_name, ret);
+                               tc_result(TC_FAIL, 1);
                        }
                        break;
 
@@ -291,8 +302,8 @@ int test_input_callback(void *data)
                        bluetooth_unregister_callback();
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
-                               tc_result(TC_FAIL, i);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[1].tc_name, ret);
+                               tc_result(TC_FAIL, 1);
                        }
                        break;
 
@@ -300,8 +311,8 @@ int test_input_callback(void *data)
                        ret = bluetooth_enable_adapter();
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
-                               tc_result(TC_FAIL, i);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[2].tc_name, ret);
+                               tc_result(TC_FAIL, 1);
                        }
                        break;
 
@@ -309,8 +320,8 @@ int test_input_callback(void *data)
                        ret = bluetooth_disable_adapter();
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
-                               tc_result(TC_FAIL, i);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[3].tc_name, ret);
+                               tc_result(TC_FAIL, 2);
                        }
                        break;
 
@@ -327,7 +338,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_get_local_address(&address);
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[5].tc_name, ret);
                        } else {
                                TC_PRT("dev [%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X]", \
                                        address.addr[0], address.addr[1], address.addr[2], \
@@ -343,7 +354,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_get_local_name(&local_name);
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[6].tc_name, ret);
                        } else {
                                TC_PRT("name: %s", local_name.name);
                        }
@@ -359,7 +370,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_set_local_name(&local_name);
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[7].tc_name, ret);
                        }
                        break;
                }
@@ -372,7 +383,7 @@ int test_input_callback(void *data)
 
                        ret = bluetooth_get_local_version(&local_version);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[89].tc_name, ret);
                        else
                                TC_PRT("version: %s", local_version.version);
                        break;
@@ -385,7 +396,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_is_service_used(rfcomm_test_uuid_spp, &used);
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[8].tc_name, ret);
                        } else {
                                TC_PRT("used: %d", used);
                        }
@@ -398,7 +409,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_get_discoverable_mode(&mode);
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[9].tc_name, ret);
                        }
                        else
                        {
@@ -413,7 +424,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_set_discoverable_mode(mode, 0);
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[10].tc_name, ret);
                        }
                        else
                        {
@@ -428,7 +439,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_set_discoverable_mode(mode, 0);
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[11].tc_name, ret);
                        }
                        else
                        {
@@ -443,7 +454,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_set_discoverable_mode(mode, 5);
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[12].tc_name, ret);
                        }
                        else
                        {
@@ -456,7 +467,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_start_discovery(0,0,0);
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[13].tc_name, ret);
                        }
                        break;
 
@@ -464,7 +475,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_cancel_discovery();
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[14].tc_name, ret);
                        }
                        break;
 
@@ -473,7 +484,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_is_discovering();
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[15].tc_name, ret);
                        }
                        else
                        {
@@ -491,7 +502,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_get_bonded_device_list(&devinfo);
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[16].tc_name, ret);
                        }
                        else
                        {
@@ -523,7 +534,6 @@ int test_input_callback(void *data)
                        /* Apple wireless keyboard */
                        //bluetooth_device_address_t device_address={{0xE8,0x06,0x88,0x3B,0x18,0xBA}};
                        //bluetooth_device_address_t device_address={{0x00,0x19,0x0E,0x01,0x61,0x17}}; /* DO-DH79-PYUN04 */
-                       //bluetooth_device_address_t device_address={{0xF4,0x7B,0x5E,0x7D,0xD9,0xBC}}; /* SoundShare */
                        //bluetooth_device_address_t device_address={{0x00,0x16,0x38,0xC3,0x1F,0xD2}}; /* DO-DH79-PYUN03 */
                        //bluetooth_device_address_t device_address={{0x58,0x17,0x0C,0xEC,0x6A,0xF3}}; /* MW600 */
                        bluetooth_device_address_t device_address={{0x00,0x0D,0xFD,0x24,0x5E,0xFF}}; /* Motorola S9 */
@@ -535,7 +545,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_bond_device(&device_address);
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[17].tc_name, ret);
                        }
                        break;
                }
@@ -546,7 +556,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_cancel_bonding();
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[18].tc_name, ret);
                        }
 
                        break;
@@ -556,11 +566,10 @@ int test_input_callback(void *data)
                {
                        bluetooth_device_address_t device_address={{0x00,0x19,0x0E,0x01,0x61,0x17}}; /* DO-DH79-PYUN04 */
                        //bluetooth_device_address_t device_address={{0x00,0x16,0x38,0xC3,0x1F,0xD2}};
-                       //bluetooth_device_address_t device_address={{0xF4,0x7B,0x5E,0x7D,0xD9,0xBC}}; /* SoundShare */
                        ret = bluetooth_unbond_device(&device_address);
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[19].tc_name, ret);
                        }
 
                        break;
@@ -569,7 +578,6 @@ int test_input_callback(void *data)
                case 21: /*Get paired device */
                {
                        bluetooth_device_info_t devinfo;
-                       //bluetooth_device_address_t device_address={{0xF4,0x7B,0x5E,0x7D,0xD9,0xBC}}; /* SoundShare */
                        bluetooth_device_address_t device_address={{0x00,0x16,0x38,0xC3,0x1F,0xD2}};
 
                        memset(&devinfo, 0x00, sizeof(bluetooth_device_info_t));
@@ -597,7 +605,7 @@ int test_input_callback(void *data)
 
                        ret = bluetooth_set_alias(&device_address, "Renamed device");
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[21].tc_name, ret);
                        break;
                }
 
@@ -607,7 +615,7 @@ int test_input_callback(void *data)
 
                        ret = bluetooth_authorize_device(&device_address, TRUE);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[22].tc_name, ret);
                        break;
                }
                case 24:
@@ -616,7 +624,7 @@ int test_input_callback(void *data)
 
                        ret = bluetooth_authorize_device(&device_address, FALSE);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[23].tc_name, ret);
                        break;
                }
                case 25:
@@ -625,14 +633,14 @@ int test_input_callback(void *data)
 
                        ret = bluetooth_search_service(&device_address);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[24].tc_name, ret);
                        break;
                }
                case 26:
                {
                        ret = bluetooth_cancel_service_search();
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[24].tc_name, ret);
                        break;
                }
                case 27:
@@ -642,7 +650,7 @@ int test_input_callback(void *data)
 
                        ret = bluetooth_is_device_connected(&device_address, BLUETOOTH_A2DP_SERVICE, &connected);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[24].tc_name, ret);
 
                        TC_PRT("connected : %d", connected);
                        break;
@@ -651,7 +659,7 @@ int test_input_callback(void *data)
                {
                        ret = bluetooth_reset_adapter();
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[27].tc_name, ret);
                        break;
                }
                case 91:
@@ -665,45 +673,43 @@ int test_input_callback(void *data)
                        m_data.data_len = sizeof(data) - 2;
                        ret = bluetooth_set_manufacturer_data(&m_data);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[90].tc_name, ret);
                        break;
                }
                case 29:
                {
                        ret = bluetooth_audio_init(bt_audio_event_callback, NULL);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[28].tc_name, ret);
                        break;
                }
                case 30:
                {
                        ret = bluetooth_audio_deinit();
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[29].tc_name, ret);
                        break;
                }
                case 31:
                {
                        /* MW600 */
                        //bluetooth_device_address_t device_address={{0x58,0x17,0x0C,0xEC,0x6A,0xF3}};
-                       //bluetooth_device_address_t device_address={{0xF4,0x7B,0x5E,0x7D,0xD9,0xBC}}; /* SoundShare */
                        bluetooth_device_address_t device_address={{0x00,0x0D,0xFD,0x24,0x5E,0xFF}}; /* Motorola S9 */
 
                        ret = bluetooth_audio_connect(&device_address);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[30].tc_name, ret);
                        break;
                }
                case 32:
                {
                        /* MW600 */
                        //bluetooth_device_address_t device_address={{0x58,0x17,0x0C,0xEC,0x6A,0xF3}};
-                       //bluetooth_device_address_t device_address={{0xF4,0x7B,0x5E,0x7D,0xD9,0xBC}}; /* SoundShare */
                        bluetooth_device_address_t device_address={{0x00,0x0D,0xFD,0x24,0x5E,0xFF}}; /* Motorola S9 */
 
                        ret = bluetooth_audio_disconnect(&device_address);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[31].tc_name, ret);
                        break;
                }
                case 33:
@@ -713,7 +719,7 @@ int test_input_callback(void *data)
 
                        ret = bluetooth_ag_connect(&device_address);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[32].tc_name, ret);
                        break;
                }
                case 34:
@@ -723,29 +729,27 @@ int test_input_callback(void *data)
 
                        ret = bluetooth_ag_disconnect(&device_address);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[33].tc_name, ret);
                        break;
                }
                case 35:
                {
                        /* MW600 */
                        bluetooth_device_address_t device_address={{0x58,0x17,0x0C,0xEC,0x6A,0xF3}};
-                       //bluetooth_device_address_t device_address={{0xF4,0x7B,0x5E,0x7D,0xD9,0xBC}}; /* SoundShare */
 
                        ret = bluetooth_av_connect(&device_address);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[34].tc_name, ret);
                        break;
                }
                case 36:
                {
                        /* MW600 */
                        bluetooth_device_address_t device_address={{0x58,0x17,0x0C,0xEC,0x6A,0xF3}};
-                       //bluetooth_device_address_t device_address={{0xF4,0x7B,0x5E,0x7D,0xD9,0xBC}}; /* SoundShare */
 
                        ret = bluetooth_av_disconnect(&device_address);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("%s failed with [0x%04x]", tc_table[35].tc_name, ret);
                        break;
                }
                case 37:
@@ -756,7 +760,7 @@ int test_input_callback(void *data)
                        if (ret < 0)
                                TC_PRT("failed with [0x%04x]", ret);
 
-                       TC_PRT("volume: %u", volume);
+                       TC_PRT("volume: %d", volume);
                        break;
                }
                case 38:
@@ -969,14 +973,14 @@ int test_input_callback(void *data)
                {
                        ret = bluetooth_hid_init(bt_hid_event_callback, NULL);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("Failed with [0x%04x]", ret);
                        break;
                }
                case 66:
                {
                        ret = bluetooth_hid_deinit();
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("Failed with [0x%04x]", ret);
                        break;
                }
                case 67:
@@ -986,7 +990,7 @@ int test_input_callback(void *data)
 
                        ret = bluetooth_hid_connect(&device_address);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("Failed with [0x%04x]", ret);
                        break;
                }
                case 68:
@@ -996,7 +1000,7 @@ int test_input_callback(void *data)
 
                        ret = bluetooth_hid_disconnect(&device_address);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("Failed with [0x%04x]", ret);
                        break;
                }
 
@@ -1008,7 +1012,7 @@ int test_input_callback(void *data)
                        //ret = bluetooth_rfcomm_connect(&device_address, "1");
 
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("Failed with [0x%04x]", ret);
                        break;
                }
                case 71:
@@ -1016,7 +1020,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_rfcomm_disconnect(-1);
 
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("Failed with [0x%04x]", ret);
                        break;
                }
                case 72:
@@ -1024,7 +1028,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_rfcomm_disconnect(g_ret_client_fd1);
 
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("Failed with [0x%04x]", ret);
                        break;
                }
                case 73:
@@ -1033,7 +1037,7 @@ int test_input_callback(void *data)
                        ret = bluetooth_rfcomm_write(g_ret_client_fd1, rd_data, sizeof(rd_data));
 
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("Failed with [0x%04x]", ret);
                        break;
                }
                case 74:
@@ -1049,7 +1053,7 @@ int test_input_callback(void *data)
                {
                        ret = bluetooth_rfcomm_create_socket(rfcomm_test_uuid_spp);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("Failed with [0x%04x]", ret);
 
                        TC_PRT("Returned FD = %d", ret);
                        server_fd = ret;
@@ -1059,7 +1063,7 @@ int test_input_callback(void *data)
                {
                        ret = bluetooth_rfcomm_create_socket(rfcomm_test_uuid_custom);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("Failed with [0x%04x]", ret);
 
                        TC_PRT("Returned FD = %d", ret);
                        server_fd = ret;
@@ -1069,7 +1073,7 @@ int test_input_callback(void *data)
                {
                        ret = bluetooth_rfcomm_remove_socket(server_fd);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("Failed with [0x%04x]", ret);
                        break;
                }
                case 83: /*Listen and accept */
@@ -1077,7 +1081,7 @@ int test_input_callback(void *data)
 
                        ret = bluetooth_rfcomm_listen_and_accept(server_fd, 1);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("Failed with [0x%04x]", ret);
 
                        TC_PRT("result = %d", ret);
                        break;
@@ -1087,7 +1091,7 @@ int test_input_callback(void *data)
 
                        ret = bluetooth_rfcomm_listen(server_fd, 1);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("Failed with [0x%04x]", ret);
 
                        TC_PRT("result = %d", ret);
                        break;
@@ -1096,7 +1100,7 @@ int test_input_callback(void *data)
                {
                        ret = bluetooth_rfcomm_server_disconnect(client_fd);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("Failed with [0x%04x]", ret);
                        break;
                }
                case 86:
@@ -1110,9 +1114,9 @@ int test_input_callback(void *data)
                }
                case 87:
                {
-                       ret = bluetooth_rfcomm_accept_connection(server_fd, &client_fd);
+                       ret = bluetooth_rfcomm_accept_connection(server_fd);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("Failed with [0x%04x]", ret);
                        TC_PRT("client fd: %d", client_fd);
                        break;
                }
@@ -1120,7 +1124,7 @@ int test_input_callback(void *data)
                {
                        ret = bluetooth_rfcomm_reject_connection(server_fd);
                        if (ret < 0)
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("Failed with [0x%04x]", ret);
                        break;
                }
                case 89:
@@ -1128,7 +1132,7 @@ int test_input_callback(void *data)
                                                                        0,0,0);
                        if (ret < 0)
                        {
-                               TC_PRT("%s failed with [0x%04x]", tc_table[i].tc_name, ret);
+                               TC_PRT("failed with [0x%04x]", ret);
                        }
                        break;
                case 92: {
@@ -1152,7 +1156,6 @@ int test_input_callback(void *data)
 
                        ret = bluetooth_gatt_add_service(service_uuid,
                                &svc_obj_path);
-                       g_free(service_uuid);
 
                        TC_PRT("service obj_path is %s", svc_obj_path);
                        }
@@ -1169,7 +1172,6 @@ int test_input_callback(void *data)
                        ret = bluetooth_gatt_add_new_characteristic(
                                svc_obj_path, char_uuid,
                                props, &char_obj_path);
-                       g_free(char_uuid);
 
                        TC_PRT("characteristic obj_path is %s", char_obj_path);
 
@@ -1183,7 +1185,6 @@ int test_input_callback(void *data)
                                desc_uuid, &desc_obj_path);
 
                        TC_PRT("add descriptor error is %d", ret);
-                       g_free(desc_uuid);
 
                        break;
                }
@@ -1249,17 +1250,6 @@ void cleanup()
        }
 }
 
-int timeout_callback(void *data)
-{
-       TC_PRT("timeout callback");
-       timeout_status = -1;
-
-       g_main_loop_quit(main_loop);
-
-       return FALSE;
-}
-
-
 void bt_hid_event_callback(int event, hid_event_param_t* param, void *user_data)
 {
        TC_PRT(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
@@ -1297,12 +1287,12 @@ void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_dat
                        if (param->result == BLUETOOTH_ERROR_NONE)
                        {
                                bluetooth_device_name_t *local_name = (bluetooth_device_name_t *)param->param_data;
-                               tc_result(TC_PASS, 7);
+                               tc_result(TC_PASS, 6);
                                TC_PRT("Changed Name : [%s]", local_name->name);
                        }
                        else
                        {
-                               tc_result(TC_FAIL, 7);
+                               tc_result(TC_FAIL, 6);
                        }
                        break;
 
@@ -1380,7 +1370,7 @@ void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_dat
                        if (param->result >= BLUETOOTH_ERROR_NONE)
                        {
                                bluetooth_device_info_t *device_info = NULL;
-                               tc_result(TC_PASS, 18);
+                               tc_result(TC_PASS, 12);
                                device_info  = (bluetooth_device_info_t *)param->param_data;
                                if (device_info == NULL)
                                        break;
@@ -1392,7 +1382,7 @@ void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_dat
                        }
                        else
                        {
-                               tc_result(TC_FAIL, 18);
+                               tc_result(TC_FAIL, 12);
                        }
                        break;
                }
@@ -1435,7 +1425,7 @@ void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_dat
                        TC_PRT("BLUETOOTH_EVENT_SERVICE_SEARCHED, result [0x%04x]", param->result);
                        if (param->result >= BLUETOOTH_ERROR_NONE)
                        {
-                               tc_result(TC_PASS, 25);
+                               tc_result(TC_PASS, 18);
                                bt_sdp_info_t * bt_sdp_info=param->param_data;
 
                                TC_PRT("Dev add = %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
@@ -1449,7 +1439,7 @@ void bt_event_callback(int event, bluetooth_event_param_t* param, void *user_dat
                        }
                        else
                        {
-                               tc_result(TC_FAIL, 25);
+                               tc_result(TC_FAIL, 18);
                        }
                        break;
                }
diff --git a/test/gatt-test/TFXF4E2.tmp b/test/gatt-test/TFXF4E2.tmp
deleted file mode 100755 (executable)
index e69de29..0000000
index 29d72f7..deb822f 100644 (file)
@@ -120,6 +120,11 @@ char * get_bd_from_file(char *filename)
        }
 
        buf = g_malloc0(20);
+       /* Fix : NULL_RETURNS */
+       if (buf == NULL) {
+               close(fd);
+               return NULL;
+       }
 
        if (read(fd, buf, 17) < 17) {
                perror("Can't load firmware");
@@ -146,7 +151,10 @@ static void __accept_bdaddress(bluetooth_device_address_t *device_address)
        }
 
        TC_PRT("Enter bd address: ");
-       scanf("%s", str_address);
+       int ret = 0;
+       ret = scanf("%s", str_address);
+       if (ret < 0)
+               TC_PRT("Some read error");
        TC_PRT("You have entered bd address %s\n", str_address);
        convert_addr_string_to_addr_type(device_address, str_address);
 }
@@ -154,8 +162,11 @@ static void __accept_bdaddress(bluetooth_device_address_t *device_address)
 static void __accept_alert_level()
 {
        TC_PRT("Enter alert level \n 0 - no alert 1 - mild alert 2 - High alert : ");
-       scanf("%u", &g_alert_level);
-       TC_PRT("You have selected alert level %u ", g_alert_level);
+       int ret = 0;
+       ret = scanf("%c", &g_alert_level);
+       if (ret < 0)
+               TC_PRT("Some read error");
+       TC_PRT("You have selected alert level %hu ", g_alert_level);
 }
 
 int test_input_callback(void *data)
@@ -297,8 +308,8 @@ static gboolean key_event_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
        unsigned int len = 0;
        int test_id;
 
-       if (g_io_channel_read(chan, buf, sizeof(buf), &len) !=
-                                                       G_IO_ERROR_NONE) {
+       if (g_io_channel_read_chars(chan, buf, sizeof(buf), 
+                       &len, NULL) ==  G_IO_STATUS_ERROR) {
                printf("IO Channel read error");
                return FALSE;
        }
index ce21548..e57dd57 100644 (file)
@@ -458,7 +458,7 @@ int test_input_callback(void *data)
                case 24:
                {
                        gboolean hf_connected;
-                       bluetooth_hf_is_hf_connected(&hf_connected);
+                       bluetooth_hf_is_connected(&hf_connected);
                        if (hf_connected == BLUETOOTH_HF_AUDIO_CONNECTED)
                                TC_PRT("HF is connected");
                        else
index c54bc9a..459c7a0 100644 (file)
@@ -111,11 +111,11 @@ int test_input_callback(void *data)
                break;
        case 1:
                TC_PRT("SetAdvertising ON");
-               ret = bluetooth_set_advertising(TRUE);
+               ret = bluetooth_set_advertising(0, TRUE);
                break;
        case 2:
                TC_PRT("SetAdvertising OFF");
-               ret = bluetooth_set_advertising(FALSE);
+               ret = bluetooth_set_advertising(0, FALSE);
                break;
        case 3:
                TC_PRT("SetCustomAdvertising ON, Filter 0x03");
@@ -123,7 +123,7 @@ int test_input_callback(void *data)
                params.interval_max = 1280;
                params.filter_policy = 0x03;
                params.type = 0x00;
-               ret = bluetooth_set_custom_advertising(TRUE, &params);
+               ret = bluetooth_set_custom_advertising(0, TRUE, &params);
                break;
        case 4:
                TC_PRT("SetCustomAdvertising ON, Filter 0x00");
@@ -131,7 +131,7 @@ int test_input_callback(void *data)
                params.interval_max = 1280;
                params.filter_policy = 0x00;
                params.type = 0x00;
-               ret = bluetooth_set_custom_advertising(TRUE, &params);
+               ret = bluetooth_set_custom_advertising(0, TRUE, &params);
                break;
        case 5: {
                TC_PRT("SetAdvertisingData");
@@ -141,7 +141,7 @@ int test_input_callback(void *data)
                TC_PRT("%x %x %x %x %x %x", data[0], data[1], data[2], data[3],
                                data[4], data[5]);
                memcpy(adv.data, data, sizeof(data));
-               ret = bluetooth_set_advertising_data(&adv, sizeof(data));
+               ret = bluetooth_set_advertising_data(0, &adv, sizeof(data));
                break;
        }
        case 6:
@@ -156,7 +156,7 @@ int test_input_callback(void *data)
                TC_PRT("%x %x %x %x %x %x %x", data[0], data[1], data[2],
                                data[3], data[4], data[5], data[6]);
                memcpy(rsp.data, data, sizeof(data));
-               ret = bluetooth_set_scan_response_data(&rsp, sizeof(data));
+               ret = bluetooth_set_scan_response_data(0, &rsp, sizeof(data));
                break;
        }
        case 8:
@@ -336,8 +336,8 @@ static gboolean key_event_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
        unsigned int len = 0;
        int test_id;
 
-       if (g_io_channel_read(chan, buf, sizeof(buf), &len) !=
-                                                       G_IO_ERROR_NONE) {
+       if (g_io_channel_read_chars(chan, buf, sizeof(buf), 
+                       &len, NULL) ==  G_IO_STATUS_ERROR) {
                printf("IO Channel read error");
                return FALSE;
        }