summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-08-19 13:02:40 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-08-19 14:20:06 -0500
commit256e01c8c4949a43409cbd1c4c1e64c1016a9cad (patch)
tree3f7294b83c7b25622ad4869a4264ac8ee2ffc887 /src
parenta9a54c0933a9812b4628d82e50838b89a42e4d26 (diff)
downloadofono-256e01c8c4949a43409cbd1c4c1e64c1016a9cad.tar.bz2
gprs: Add support for GetContexts
Diffstat (limited to 'src')
-rw-r--r--src/gprs.c63
1 files changed, 58 insertions, 5 deletions
diff --git a/src/gprs.c b/src/gprs.c
index 3fe903d1..46e61e9f 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -1338,15 +1338,68 @@ static DBusMessage *gprs_deactivate_all(DBusConnection *conn,
return __ofono_error_not_implemented(msg);
}
+static DBusMessage *gprs_get_contexts(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_gprs *gprs = data;
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusMessageIter array;
+ DBusMessageIter entry, dict;
+ const char *path;
+ GSList *l;
+ struct pri_context *ctx;
+
+ 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);
+
+ for (l = gprs->contexts; l; l = l->next) {
+ ctx = l->data;
+
+ path = ctx->path;
+
+ 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);
+
+ append_context_properties(ctx, &dict);
+ dbus_message_iter_close_container(&entry, &dict);
+ dbus_message_iter_close_container(&array, &entry);
+ }
+
+ dbus_message_iter_close_container(&iter, &array);
+
+ return reply;
+}
+
static GDBusMethodTable manager_methods[] = {
- { "GetProperties", "", "a{sv}", gprs_get_properties },
- { "SetProperty", "sv", "", gprs_set_property },
- { "AddContext", "s", "o", gprs_add_context,
+ { "GetProperties", "", "a{sv}", gprs_get_properties },
+ { "SetProperty", "sv", "", gprs_set_property },
+ { "AddContext", "s", "o", gprs_add_context,
G_DBUS_METHOD_FLAG_ASYNC },
- { "RemoveContext", "o", "", gprs_remove_context,
+ { "RemoveContext", "o", "", gprs_remove_context,
G_DBUS_METHOD_FLAG_ASYNC },
- { "DeactivateAll", "", "", gprs_deactivate_all,
+ { "DeactivateAll", "", "", gprs_deactivate_all,
G_DBUS_METHOD_FLAG_ASYNC },
+ { "GetContexts", "", "a(oa{sv})", gprs_get_contexts },
{ }
};