PBAP: seperate a PBAP connect error cause in detail 52/187252/1
authorDeokhyun Kim <dukan.kim@samsung.com>
Tue, 21 Aug 2018 08:23:45 +0000 (17:23 +0900)
committerDeokhyun Kim <dukan.kim@samsung.com>
Tue, 21 Aug 2018 08:23:45 +0000 (17:23 +0900)
Change-Id: I45c97b3c5a79103c0ab8af8abf2ccc65016714fa
Signed-off-by: Deokhyun Kim <dukan.kim@samsung.com>
bt-service/bt-service-pbap.c

index d69b66a..296e136 100644 (file)
@@ -253,6 +253,26 @@ void _bt_obex_pbap_client_disconnect(char *path)
        BT_DBG("-");
 }
 
+static int __bt_pbap_get_error(const char *error_message)
+{
+       if (error_message == NULL) {
+               BT_ERR("Error message NULL");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       BT_ERR("Error message = %s", error_message);
+       if (g_strcmp0(error_message, "Unable to find service record") == 0)
+               return BLUETOOTH_ERROR_SERVICE_NOT_FOUND;
+       else if (g_strcmp0(error_message, "Transport got disconnected") == 0)
+               return BLUETOOTH_ERROR_AUTHORIZATION_REJECTED;
+       else if (g_str_has_prefix(error_message, "Connection refused") == 0)
+               return BLUETOOTH_ERROR_AUTHENTICATION_REJECTED;
+       else if (g_strcmp0(error_message, "Timed out waiting for response") == 0)
+               return BLUETOOTH_ERROR_TIMEOUT;
+       else
+               return BLUETOOTH_ERROR_INTERNAL;
+}
+
 void __bt_pbap_connect_cb(GDBusProxy *proxy,
                GAsyncResult *res, gpointer user_data)
 {
@@ -269,9 +289,11 @@ void __bt_pbap_connect_cb(GDBusProxy *proxy,
        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_dbus_error_strip_remote_error(error);
+                       result = __bt_pbap_get_error(error->message);
+                       BT_ERR("Failed to coonect with error[0x%x][%s]",
+                                       result, error->message);
+                       g_error_free(error);
                }
                g_object_unref(g_pbap_proxy);
                g_pbap_proxy = NULL;