diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-05-14 15:05:20 +0000 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-05-14 15:05:20 +0000 |
commit | 39d74106f6bbb9f998387dd27529fc077773a182 (patch) | |
tree | 22b68a0090b04e4d602d0f3882fb3e1cfd067d3d | |
parent | 396c3c819743ae85089d358c882b9657554a6452 (diff) |
Add CancelConnect to Connection interface.
-rw-r--r-- | network/connection.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/network/connection.c b/network/connection.c index 9062c419..4f57e93a 100644 --- a/network/connection.c +++ b/network/connection.c @@ -176,9 +176,11 @@ static gboolean bnep_connect_cb(GIOChannel *chan, GIOCondition cond, (GIOFunc) bnep_watchdog_cb, nc); return FALSE; failed: - nc->state = DISCONNECTED; - err_connection_failed(nc->conn, nc->msg, "bnep failed"); - g_io_channel_close(chan); + if (nc->state != DISCONNECTED) { + nc->state = DISCONNECTED; + err_connection_failed(nc->conn, nc->msg, "bnep failed"); + g_io_channel_close(chan); + } return FALSE; } @@ -465,7 +467,7 @@ static DBusHandlerResult connection_connect(DBusConnection *conn, } nc->msg = dbus_message_ref(msg); - if(l2cap_connect(nc)) { + if (l2cap_connect(nc) < 0) { error("Connect failed. %s(%d)", strerror(errno), errno); goto fail; } @@ -481,6 +483,25 @@ fail: return DBUS_HANDLER_RESULT_HANDLED; } +static DBusHandlerResult connection_cancel(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct network_conn *nc = data; + DBusMessage *reply; + + if (nc->state != CONNECTING) { + err_failed(conn, msg, "Device has no pending connect"); + return DBUS_HANDLER_RESULT_HANDLED; + } + + close(nc->sk); + nc->state = DISCONNECTED; + + reply = dbus_message_new_method_return(msg); + + return send_message_and_unref(conn, reply); +} + static DBusHandlerResult connection_disconnect(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -598,6 +619,7 @@ static DBusMethodVTable connection_methods[] = { { "GetDescription", get_description, "", "s" }, { "GetInterface", get_interface, "", "s" }, { "Connect", connection_connect, "", "s" }, + { "CancelConnect", connection_cancel, "", "" }, { "Disconnect", connection_disconnect, "", "" }, { "IsConnected", is_connected, "", "b" }, { "GetInfo", get_info, "", "{sv}", }, |