summaryrefslogtreecommitdiffstats
path: root/network
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-10-02 17:39:07 -0300
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-10-02 17:39:07 -0300
commit357a15b5878b65edef89b00b2db5d128e85bd07e (patch)
treea6f6b9d30d271823fb809f22319f788750314034 /network
parentd6a4551d32bff4624e4a7f72aac25fea051f3c14 (diff)
Add property support for network interface.
Diffstat (limited to 'network')
-rw-r--r--network/connection.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/network/connection.c b/network/connection.c
index c17950bc..0f6f6c2d 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -40,6 +40,7 @@
#include "logging.h"
#include "glib-helper.h"
+#include "dbus-common.h"
#include "error.h"
#include "common.h"
@@ -412,6 +413,51 @@ static DBusMessage *is_connected(DBusConnection *conn,
DBUS_TYPE_INVALID);
}
+static DBusMessage *connection_get_properties(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct network_peer *peer = data;
+ struct network_conn *nc;
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusMessageIter dict;
+ dbus_bool_t connected;
+ const char *property;
+ GSList *l;
+
+ dbus_message_iter_init_append(reply, &iter);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+
+ /* Connected */
+ for (l = peer->connections; l; l = l->next) {
+ nc = l->data;
+
+ if (nc->state == CONNECTED)
+ break;
+ }
+ connected = (l != NULL);
+ dbus_message_iter_append_dict_entry(&dict, "Connected",
+ DBUS_TYPE_BOOLEAN, &connected);
+
+ /* Device */
+ property = connected ? nc->dev : "";
+ dbus_message_iter_append_dict_entry(&dict, "Device",
+ DBUS_TYPE_STRING, &property);
+
+ /* UUID */
+ property = connected ? bnep_uuid(nc->id) : "";
+ dbus_message_iter_append_dict_entry(&dict, "UUID",
+ DBUS_TYPE_STRING, &property);
+
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return reply;
+}
+
static void connection_free(struct network_conn *nc)
{
if (nc->state == CONNECTED) {
@@ -448,12 +494,14 @@ static GDBusMethodTable connection_methods[] = {
G_DBUS_METHOD_FLAG_ASYNC },
{ "Disconnect", "", "", connection_disconnect },
{ "IsConnected", "", "b", is_connected },
+ { "GetProperties", "", "a{sv}",connection_get_properties },
{ }
};
static GDBusSignalTable connection_signals[] = {
{ "Connected", "ss" },
{ "Disconnected", "s" },
+ { "PropertyChanged", "sv" },
{ }
};