diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-03-28 14:35:28 +0000 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-03-28 14:35:28 +0000 |
commit | 44f1d3a1a09a29afd84496a1d6b49d08caf3dbe2 (patch) | |
tree | 881368662900d285f325703c29059bb16ecb21b9 /network/server.c | |
parent | 45bddf6307e9a6f017a313d2b3e16ef6ce8db376 (diff) |
network: added Server.Disable
Diffstat (limited to 'network/server.c')
-rw-r--r-- | network/server.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/network/server.c b/network/server.c index 0dd29d0d..e70e13ab 100644 --- a/network/server.c +++ b/network/server.c @@ -642,10 +642,30 @@ static DBusHandlerResult enable(DBusConnection *conn, return send_message_and_unref(conn, reply); } -static DBusHandlerResult disable(DBusConnection *conn, DBusMessage *msg, - void *data) +static DBusHandlerResult disable(DBusConnection *conn, + DBusMessage *msg, void *data) { - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + struct network_server *ns = data; + DBusMessage *reply; + + reply = dbus_message_new_method_return(msg); + if (!reply) + return DBUS_HANDLER_RESULT_NEED_MEMORY; + + if (!ns->io) + return err_failed(conn, msg, "Not enabled"); + + /* Remove the service record */ + if (ns->record_id) { + remove_server_record(conn, ns->record_id); + ns->record_id = 0; + } + + g_io_channel_unref(ns->io); + g_io_channel_close(ns->io); + ns->io = NULL; + + return send_message_and_unref(conn, reply); } static DBusHandlerResult set_name(DBusConnection *conn, @@ -843,8 +863,10 @@ static void server_free(struct network_server *ns) if (ns->conn) dbus_connection_unref(ns->conn); - if (ns->io) + if (ns->io) { g_io_channel_unref(ns->io); + g_io_channel_close(ns->io); + } g_free(ns); } |