sap: remove connect callback if enable fails

This commit is contained in:
Gustavo F. Padovan 2011-09-28 18:24:10 -03:00 committed by Denis Kenzior
parent 02a6d7b3a9
commit 06544a4c4d
1 changed files with 12 additions and 1 deletions

View File

@ -54,6 +54,7 @@ static struct bluetooth_sap_driver *sap_hw_driver = NULL;
struct sap_data {
struct ofono_modem *hw_modem;
struct bluetooth_sap_driver *sap_driver;
DBusPendingCall *call;
};
int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
@ -112,6 +113,9 @@ static void sap_remove(struct ofono_modem *modem)
DBG("%p", modem);
if (data->call != NULL)
dbus_pending_call_cancel(data->call);
g_free(data);
ofono_modem_set_data(modem, NULL);
@ -120,6 +124,7 @@ static void sap_remove(struct ofono_modem *modem)
static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
{
struct ofono_modem *modem = user_data;
struct sap_data *data = ofono_modem_get_data(modem);
DBusError derr;
DBusMessage *reply;
@ -127,6 +132,8 @@ static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
reply = dbus_pending_call_steal_reply(call);
data->call = NULL;
if (ofono_modem_get_powered(modem))
goto done;
@ -147,6 +154,8 @@ done:
/* power up hardware */
static int sap_enable(struct ofono_modem *modem)
{
struct sap_data *data = ofono_modem_get_data(modem);
DBusPendingCall *call;
int status;
const char *str = "sap";
const char *server_path = ofono_modem_get_string(modem, "ServerPath");
@ -154,7 +163,7 @@ static int sap_enable(struct ofono_modem *modem)
DBG("%p", modem);
status = bluetooth_send_with_reply(server_path, BLUEZ_SERIAL_INTERFACE,
"ConnectFD", NULL, sap_connect_reply,
"ConnectFD", &call, sap_connect_reply,
modem, NULL, DBUS_TIMEOUT,
DBUS_TYPE_STRING, &str,
DBUS_TYPE_INVALID);
@ -162,6 +171,8 @@ static int sap_enable(struct ofono_modem *modem)
if (status < 0)
return -EINVAL;
data->call = call;
return -EINPROGRESS;
}