summaryrefslogtreecommitdiffstats
path: root/serial
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-08-13 18:06:48 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-08-13 18:06:48 +0000
commitd9b79bb83ad9255dfcf2102cb10c3da26c4e3155 (patch)
tree59fbe2b4a99e2f508d9aa013fed394e663a09e5b /serial
parent7a085c5eeb65bbde0fee0561de9e0ee283c50566 (diff)
serial: handle already enabled error for Proxy.Enable and not enabled error for Proxy.Disable
Diffstat (limited to 'serial')
-rw-r--r--serial/manager.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/serial/manager.c b/serial/manager.c
index a6c6fe94..cd83bfe2 100644
--- a/serial/manager.c
+++ b/serial/manager.c
@@ -1173,6 +1173,9 @@ static DBusHandlerResult proxy_enable(DBusConnection *conn,
sdp_buf_t buf;
int sk;
+ if (prx->listen_watch)
+ return err_failed(conn, msg, "Already enabled");
+
/* Listen */
/* FIXME: missing options */
sk = rfcomm_listen(&prx->src, &prx->channel, 0);
@@ -1242,19 +1245,13 @@ static DBusHandlerResult proxy_disable(DBusConnection *conn,
{
struct proxy *prx = data;
- /* Unregister the record */
- if (prx->record_id) {
- remove_proxy_record(conn, prx->record_id);
- prx->record_id = 0;
- }
-
- /* Stop listen */
- if (prx->listen_watch) {
- g_source_remove(prx->listen_watch);
- prx->listen_watch = 0;
- }
+ if (!prx->listen_watch)
+ return err_failed(conn, msg, "Not enabled");
/* Remove watches */
+ g_source_remove(prx->listen_watch);
+ prx->listen_watch = 0;
+
if (prx->rfcomm_watch) {
g_source_remove(prx->rfcomm_watch);
prx->rfcomm_watch = 0;
@@ -1265,6 +1262,10 @@ static DBusHandlerResult proxy_disable(DBusConnection *conn,
prx->tty_watch = 0;
}
+ /* Unregister the record */
+ remove_proxy_record(conn, prx->record_id);
+ prx->record_id = 0;
+
return send_message_and_unref(conn,
dbus_message_new_method_return(msg));
}