mirror of git://git.sysmocom.de/ofono
sap: remove connect callback if enable fails
This commit is contained in:
parent
02a6d7b3a9
commit
06544a4c4d
|
@ -54,6 +54,7 @@ static struct bluetooth_sap_driver *sap_hw_driver = NULL;
|
||||||
struct sap_data {
|
struct sap_data {
|
||||||
struct ofono_modem *hw_modem;
|
struct ofono_modem *hw_modem;
|
||||||
struct bluetooth_sap_driver *sap_driver;
|
struct bluetooth_sap_driver *sap_driver;
|
||||||
|
DBusPendingCall *call;
|
||||||
};
|
};
|
||||||
|
|
||||||
int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
|
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);
|
DBG("%p", modem);
|
||||||
|
|
||||||
|
if (data->call != NULL)
|
||||||
|
dbus_pending_call_cancel(data->call);
|
||||||
|
|
||||||
g_free(data);
|
g_free(data);
|
||||||
|
|
||||||
ofono_modem_set_data(modem, NULL);
|
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)
|
static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
|
||||||
{
|
{
|
||||||
struct ofono_modem *modem = user_data;
|
struct ofono_modem *modem = user_data;
|
||||||
|
struct sap_data *data = ofono_modem_get_data(modem);
|
||||||
DBusError derr;
|
DBusError derr;
|
||||||
DBusMessage *reply;
|
DBusMessage *reply;
|
||||||
|
|
||||||
|
@ -127,6 +132,8 @@ static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
|
||||||
|
|
||||||
reply = dbus_pending_call_steal_reply(call);
|
reply = dbus_pending_call_steal_reply(call);
|
||||||
|
|
||||||
|
data->call = NULL;
|
||||||
|
|
||||||
if (ofono_modem_get_powered(modem))
|
if (ofono_modem_get_powered(modem))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
@ -147,6 +154,8 @@ done:
|
||||||
/* power up hardware */
|
/* power up hardware */
|
||||||
static int sap_enable(struct ofono_modem *modem)
|
static int sap_enable(struct ofono_modem *modem)
|
||||||
{
|
{
|
||||||
|
struct sap_data *data = ofono_modem_get_data(modem);
|
||||||
|
DBusPendingCall *call;
|
||||||
int status;
|
int status;
|
||||||
const char *str = "sap";
|
const char *str = "sap";
|
||||||
const char *server_path = ofono_modem_get_string(modem, "ServerPath");
|
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);
|
DBG("%p", modem);
|
||||||
|
|
||||||
status = bluetooth_send_with_reply(server_path, BLUEZ_SERIAL_INTERFACE,
|
status = bluetooth_send_with_reply(server_path, BLUEZ_SERIAL_INTERFACE,
|
||||||
"ConnectFD", NULL, sap_connect_reply,
|
"ConnectFD", &call, sap_connect_reply,
|
||||||
modem, NULL, DBUS_TIMEOUT,
|
modem, NULL, DBUS_TIMEOUT,
|
||||||
DBUS_TYPE_STRING, &str,
|
DBUS_TYPE_STRING, &str,
|
||||||
DBUS_TYPE_INVALID);
|
DBUS_TYPE_INVALID);
|
||||||
|
@ -162,6 +171,8 @@ static int sap_enable(struct ofono_modem *modem)
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
data->call = call;
|
||||||
|
|
||||||
return -EINPROGRESS;
|
return -EINPROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue