diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-09-28 18:24:10 -0300 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2011-09-29 09:11:34 -0500 |
commit | 06544a4c4d6a20fdfe6618a39d539f55f47e7986 (patch) | |
tree | 0ed3f490a02d9f4aea074b2093308f8a5ccb9886 /plugins/sap.c | |
parent | 02a6d7b3a9037c2ad407d95ad54e2477f68e4c4d (diff) | |
download | ofono-06544a4c4d6a20fdfe6618a39d539f55f47e7986.tar.bz2 |
sap: remove connect callback if enable fails
Diffstat (limited to 'plugins/sap.c')
-rw-r--r-- | plugins/sap.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/plugins/sap.c b/plugins/sap.c index 1c0d9ce4..28b07e7a 100644 --- a/plugins/sap.c +++ b/plugins/sap.c @@ -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; } |