summaryrefslogtreecommitdiff
path: root/vpn
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2013-02-19 08:45:05 (GMT)
committerPatrik Flykt <patrik.flykt@linux.intel.com>2013-02-19 12:29:39 (GMT)
commit4115c1071718019c38c76f27e17d7161012551de (patch)
tree53b39428db15473d68b1591b095a92be4e7a4bda /vpn
parentce3ebabc5b922c883e17b775211dfdfc3430d527 (diff)
downloadconnman-4115c1071718019c38c76f27e17d7161012551de.zip
connman-4115c1071718019c38c76f27e17d7161012551de.tar.gz
connman-4115c1071718019c38c76f27e17d7161012551de.tar.bz2
vpn-provider: Add GetProperties method implementation
Diffstat (limited to 'vpn')
-rw-r--r--vpn/vpn-provider.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index 6a77c1e..9d4de01 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -84,6 +84,9 @@ struct vpn_provider {
char *config_entry;
};
+static void append_properties(DBusMessageIter *iter,
+ struct vpn_provider *provider);
+
static void free_route(gpointer data)
{
struct vpn_route *route = data;
@@ -373,6 +376,26 @@ static void provider_schedule_changed(struct vpn_provider *provider)
provider);
}
+static DBusMessage *get_properties(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct vpn_provider *provider = data;
+ DBusMessage *reply;
+ DBusMessageIter array;
+
+ DBG("provider %p", provider);
+
+ reply = dbus_message_new_method_return(msg);
+ if (reply == NULL)
+ return NULL;
+
+ dbus_message_iter_init_append(reply, &array);
+
+ append_properties(&array, provider);
+
+ return reply;
+}
+
static DBusMessage *set_property(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -475,6 +498,9 @@ static DBusMessage *do_disconnect(DBusConnection *conn, DBusMessage *msg,
}
static const GDBusMethodTable connection_methods[] = {
+ { GDBUS_METHOD("GetProperties",
+ NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
+ get_properties) },
{ GDBUS_METHOD("SetProperty",
GDBUS_ARGS({ "name", "s" }, { "value", "v" }),
NULL, set_property) },
@@ -1284,6 +1310,8 @@ static void append_properties(DBusMessageIter *iter,
struct vpn_provider *provider)
{
DBusMessageIter dict;
+ GHashTableIter hash;
+ gpointer value, key;
connman_dbus_dict_open(iter, &dict);
@@ -1325,6 +1353,20 @@ static void append_properties(DBusMessageIter *iter,
DBUS_TYPE_DICT_ENTRY, append_routes,
provider->routes);
+ if (provider->setting_strings != NULL) {
+ g_hash_table_iter_init(&hash, provider->setting_strings);
+
+ while (g_hash_table_iter_next(&hash, &key, &value) == TRUE) {
+ struct vpn_setting *setting = value;
+
+ if (setting->hide_value == FALSE &&
+ setting->value != NULL)
+ connman_dbus_dict_append_basic(&dict, key,
+ DBUS_TYPE_STRING,
+ &setting->value);
+ }
+ }
+
connman_dbus_dict_close(iter, &dict);
}