summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/manager.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/manager.c b/src/manager.c
index 043b3e31..6e9ecf17 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -29,7 +29,56 @@
#include "ofono.h"
+static void append_modem(struct ofono_modem *modem, void *userdata)
+{
+ DBusMessageIter *array = userdata;
+ const char *path = ofono_modem_get_path(modem);
+ DBusMessageIter entry, dict;
+
+ dbus_message_iter_open_container(array, DBUS_TYPE_STRUCT,
+ NULL, &entry);
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_OBJECT_PATH,
+ &path);
+ dbus_message_iter_open_container(&entry, DBUS_TYPE_ARRAY,
+ OFONO_PROPERTIES_ARRAY_SIGNATURE,
+ &dict);
+
+ __ofono_modem_append_properties(modem, &dict);
+ dbus_message_iter_close_container(&entry, &dict);
+ dbus_message_iter_close_container(array, &entry);
+}
+
+static DBusMessage *manager_get_modems(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusMessageIter array;
+
+ reply = dbus_message_new_method_return(msg);
+ if (reply == NULL)
+ return NULL;
+
+ dbus_message_iter_init_append(reply, &iter);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_OBJECT_PATH_AS_STRING
+ DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING
+ DBUS_STRUCT_END_CHAR_AS_STRING,
+ &array);
+ __ofono_modem_foreach(append_modem, &array);
+ dbus_message_iter_close_container(&iter, &array);
+
+ return reply;
+}
+
static GDBusMethodTable manager_methods[] = {
+ { "GetModems", "", "a(oa{sv})", manager_get_modems },
{ }
};