summaryrefslogtreecommitdiffstats
path: root/network
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-03-22 15:24:51 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-03-22 15:24:51 +0000
commit9cefcf43f42f48d59804c1832e8e5fc9a5abe26e (patch)
treed26a427df9245196b783726b62b6f0380328d9d6 /network
parent04b559087e7a2a593822ca933e3f7aca3700fa43 (diff)
network: Added Server.SetName
Diffstat (limited to 'network')
-rw-r--r--network/error.c8
-rw-r--r--network/error.h7
-rw-r--r--network/server.c28
3 files changed, 37 insertions, 6 deletions
diff --git a/network/error.c b/network/error.c
index 28bd54ae..ec3f9298 100644
--- a/network/error.c
+++ b/network/error.c
@@ -60,3 +60,11 @@ DBusHandlerResult err_failed(DBusConnection *conn, DBusMessage *msg,
dbus_message_new_error(msg,
NETWORK_ERROR_INTERFACE ".Failed", str));
}
+
+DBusHandlerResult err_invalid_args(DBusConnection *conn,
+ DBusMessage *msg, const char *str)
+{
+ return send_message_and_unref(conn,
+ dbus_message_new_error(msg,
+ NETWORK_ERROR_INTERFACE ".InvalidArguments", str));
+}
diff --git a/network/error.h b/network/error.h
index 63f6ffde..e28002e7 100644
--- a/network/error.h
+++ b/network/error.h
@@ -27,8 +27,9 @@ DBusHandlerResult err_unknown_connection(DBusConnection *conn,
DBusMessage *msg);
DBusHandlerResult err_generic(DBusConnection *conn, DBusMessage *msg,
const char *name, const char *str);
-DBusHandlerResult err_does_not_exist(DBusConnection *conn, DBusMessage *msg,
- const char *str);
+DBusHandlerResult err_does_not_exist(DBusConnection *conn,
+ DBusMessage *msg, const char *str);
DBusHandlerResult err_failed(DBusConnection *conn, DBusMessage *msg,
const char *str);
-
+DBusHandlerResult err_invalid_args(DBusConnection *conn,
+ DBusMessage *msg, const char *str);
diff --git a/network/server.c b/network/server.c
index bf1e45fc..98eb83b3 100644
--- a/network/server.c
+++ b/network/server.c
@@ -75,10 +75,32 @@ static DBusHandlerResult disable(DBusConnection *conn, DBusMessage *msg,
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-static DBusHandlerResult set_name(DBusConnection *conn, DBusMessage *msg,
- void *data)
+static DBusHandlerResult set_name(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ struct network_server *ns = data;
+ DBusMessage *reply;
+ const char *name;
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+ if (!dbus_message_get_args(msg, NULL,
+ DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_INVALID))
+ return err_invalid_args(conn, msg, "Invalid name");
+
+ if (!name || (strlen(name) == 0))
+ return err_invalid_args(conn, msg, "Invalid name");
+
+ if (ns->name)
+ g_free(ns->name);
+ ns->name = g_strdup(name);
+
+ /* FIXME: Update the service record attribute */
+
+ return send_message_and_unref(conn, reply);
}
static DBusHandlerResult get_name(DBusConnection *conn,