Modify the hid agent for gtest
[platform/core/connectivity/bluetooth-agent.git] / hid-agent / bluetooth-hid-agent.c
index 031d16a..f1790c1 100644 (file)
@@ -23,6 +23,7 @@
 #include <aul.h>
 
 #include "bluetooth-hid-agent.h"
+#include "bluetooth-hid-manager.h"
 
 static GMainLoop *gmain_loop;
 static char *g_obj_path;
@@ -152,11 +153,13 @@ static void __bt_hid_name_owner_changed_cb(GDBusConnection *connection,
 
                ret = _bt_hid_register_application(FALSE, name_owner);
                if (ret == BT_HID_AGENT_ERROR_NONE) {
-                       is_hid_connectable = FALSE;
-                       if (name_owner_sig_id > 0) {
-                               g_dbus_connection_signal_unsubscribe(gdbus_conn,
-                                                       name_owner_sig_id);
-                               name_owner_sig_id = 0;
+                       if (_bt_hid_get_sender_list() == NULL) {
+                               is_hid_connectable = FALSE;
+                               if (name_owner_sig_id > 0) {
+                                       g_dbus_connection_signal_unsubscribe(gdbus_conn,
+                                                               name_owner_sig_id);
+                                       name_owner_sig_id = 0;
+                               }
                        }
                }
        }
@@ -196,11 +199,13 @@ static void __hid_agent_method(GDBusConnection *connection,
 
                ret = _bt_hid_register_application(FALSE, sender);
                if (ret == BT_HID_AGENT_ERROR_NONE) {
-                       is_hid_connectable = FALSE;
-                       if (name_owner_sig_id > 0) {
-                               g_dbus_connection_signal_unsubscribe(gdbus_conn,
-                                                       name_owner_sig_id);
-                               name_owner_sig_id = 0;
+                       if (_bt_hid_get_sender_list() == NULL) {
+                               is_hid_connectable = FALSE;
+                               if (name_owner_sig_id > 0) {
+                                       g_dbus_connection_signal_unsubscribe(gdbus_conn,
+                                                               name_owner_sig_id);
+                                       name_owner_sig_id = 0;
+                               }
                        }
                } else {
                        goto fail;
@@ -602,29 +607,6 @@ static void __bt_hid_agent_filter_cb(GDBusConnection *connection,
        FN_END;
 }
 
-void _bt_convert_device_path_to_address(const char *device_path,
-                                               char *device_address)
-{
-       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
-       char *dev_addr;
-
-       ret_if(device_path == NULL);
-       ret_if(device_address == NULL);
-
-       dev_addr = strstr(device_path, "dev_");
-       if (dev_addr != NULL) {
-               char *pos = NULL;
-               dev_addr += 4;
-               g_strlcpy(address, dev_addr, sizeof(address));
-
-               while ((pos = strchr(address, '_')) != NULL) {
-                       *pos = ':';
-               }
-
-               g_strlcpy(device_address, address, BT_ADDRESS_STRING_SIZE);
-       }
-}
-
 static void __bt_hid_device_filter_cb(GDBusConnection *connection,
                                        const gchar *sender_name,
                                        const gchar *object_path,
@@ -739,9 +721,8 @@ static void __bt_hid_agent_dbus_init(void)
                return;
        }
 
-       if (!__bt_hid_agent_get_adapter_path(conn, NULL)) {
+       if (!__bt_hid_agent_get_adapter_path(conn, NULL))
                __bt_hid_agent_register();
-       }
 
        interface_added_sig_id = g_dbus_connection_signal_subscribe(conn,
                                NULL, BT_MANAGER_INTERFACE, BT_INTERFACES_ADDED, NULL, NULL, 0,
@@ -798,7 +779,7 @@ static void __bt_hid_agent_dbus_deinit(void)
 
 
 
-bt_hid_agent_error_t __bt_hid_disconnect_profile(void)
+bt_hid_agent_error_t _bt_hid_disconnect_profile(void)
 {
        FN_START;
        GDBusProxy *proxy;