return IN_PROGRESS error when pbap connection is on progress 36/206936/1
authorDeokhyun Kim <dukan.kim@samsung.com>
Wed, 29 May 2019 07:31:13 +0000 (16:31 +0900)
committerDeokhyun Kim <dukan.kim@samsung.com>
Wed, 29 May 2019 07:31:35 +0000 (16:31 +0900)
Change-Id: Iaf91555a3d486e7f40997fc10a0c65bf76a6c1dc
Signed-off-by: Deokhyun Kim <dukan.kim@samsung.com>
bt-service/bt-service-pbap.c

index 296e136..9132225 100644 (file)
@@ -110,6 +110,7 @@ char *SEARCH_FIELD[] = {
 static char *g_pbap_session_path = NULL;
 static char *g_pbap_server_address = NULL;
 static GDBusProxy *g_pbap_proxy = NULL;
+static gboolean g_is_pbap_connecting;
 
 static struct {
        int type;
@@ -316,6 +317,8 @@ void __bt_pbap_connect_cb(GDBusProxy *proxy,
 
        g_free(address_string);
        BT_DBG("-");
+
+       g_is_pbap_connecting = FALSE;
 }
 
 int _bt_pbap_connect(const bluetooth_device_address_t *address)
@@ -334,6 +337,9 @@ int _bt_pbap_connect(const bluetooth_device_address_t *address)
        if (g_pbap_session_path)
                return BLUETOOTH_ERROR_ALREADY_CONNECT;
 
+       if (g_is_pbap_connecting == TRUE)
+               return BLUETOOTH_ERROR_IN_PROGRESS;
+
        BT_DBG("BD Address [%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X]",
                        address->addr[0], address->addr[1],
                        address->addr[2], address->addr[3],
@@ -344,7 +350,7 @@ int _bt_pbap_connect(const bluetooth_device_address_t *address)
        g_conn = _bt_gdbus_get_session_gconn();
        if (g_conn == NULL) {
                        BT_ERR("Couldn't connect to session bus");
-                       return EXIT_FAILURE;
+                       return BLUETOOTH_ERROR_INTERNAL;
        }
        g_pbap_proxy =  g_dbus_proxy_new_sync(g_conn,
                        G_DBUS_PROXY_FLAGS_NONE, NULL,
@@ -356,7 +362,7 @@ int _bt_pbap_connect(const bluetooth_device_address_t *address)
                        ERR("Unable to create proxy: %s", error->message);
                        g_clear_error(&error);
                }
-               return -1;
+               return BLUETOOTH_ERROR_INTERNAL;
        }
 
        /* Create Hash*/
@@ -369,13 +375,14 @@ int _bt_pbap_connect(const bluetooth_device_address_t *address)
 
        GVariant *temp = g_variant_new("(s@a{sv})", ptr, args);
 
+       g_is_pbap_connecting = TRUE;
        g_dbus_proxy_call(g_pbap_proxy, "CreateSession",
                        temp,
                        G_DBUS_CALL_FLAGS_NONE, -1, NULL,
                        (GAsyncReadyCallback)__bt_pbap_connect_cb, ptr);
 
        BT_DBG("-");
-       return 0;
+       return BLUETOOTH_ERROR_NONE;
 }
 
 void __bt_pbap_disconnect_cb(GDBusProxy *proxy,
@@ -456,7 +463,7 @@ int _bt_pbap_disconnect(const bluetooth_device_address_t *address)
                        G_DBUS_CALL_FLAGS_NONE, -1, NULL,
                        (GAsyncReadyCallback)__bt_pbap_disconnect_cb, ptr);
 
-       return 0;
+       return BLUETOOTH_ERROR_NONE;
 }
 
 void __bt_pbap_select_cb(GDBusProxy *proxy,