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;
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)
{
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;
g_free(address_string);
BT_DBG("-");
+
+ g_is_pbap_connecting = FALSE;
}
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],
_bt_convert_addr_type_to_string(address_string, (unsigned char *)address->addr);
BT_DBG("Address String: %s", address_string);
- g_conn = _bt_gdbus_get_system_gconn();
+ 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,
ERR("Unable to create proxy: %s", error->message);
g_clear_error(&error);
}
- return -1;
+ return BLUETOOTH_ERROR_INTERNAL;
}
/* Create Hash*/
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,
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,
g_free(folder);
g_free(order_str);
-
+ g_hash_table_unref((GHashTable *)filters);
/* In _bt_pbap_get_list(), path(type) is set to "nil", but current type is not null.
The path should be reset here */
selected_path.type = -1;
//
//****************************
- snprintf(vcard, 20, "%d.vcf", app_param->index);
+ sprintf(vcard, "%d.vcf", app_param->index);
BT_DBG("Handle: %s", vcard);
vcard_handle = g_strdup(vcard);
BT_DBG("vcard_handle: %s", vcard_handle);
address_string, source_string, type_string);
BT_DBG("Session Path = %s\n", g_pbap_session_path);
- g_conn = _bt_gdbus_get_system_gconn();
+ g_conn = _bt_gdbus_get_session_gconn();
if (g_conn == NULL) {
BT_ERR("Couldn't connect to session bus");
g_free(source_string);
BT_DBG("Session Path = %s\n", g_pbap_session_path);
- g_conn = _bt_gdbus_get_system_gconn();
+ g_conn = _bt_gdbus_get_session_gconn();
if (g_conn == NULL) {
BT_ERR("Couldn't connect to session bus");
g_free(source_string);
BT_DBG("Session Path = %s\n", g_pbap_session_path);
- g_conn = _bt_gdbus_get_system_gconn();
+ g_conn = _bt_gdbus_get_session_gconn();
if (g_conn == NULL) {
BT_ERR("Couldn't connect to session bus");
g_free(source_string);
BT_DBG("Session Path = %s\n", g_pbap_session_path);
- g_conn = _bt_gdbus_get_system_gconn();
+ g_conn = _bt_gdbus_get_session_gconn();
if (g_conn == NULL) {
BT_ERR("Couldn't connect to session bus");
g_free(source_string);
BT_DBG("Session Path = %s\n", g_pbap_session_path);
- g_conn = _bt_gdbus_get_system_gconn();
+ g_conn = _bt_gdbus_get_session_gconn();
if (g_conn == NULL) {
BT_ERR("Couldn't connect to session bus");
g_free(source_string);