summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--src/service.c89
-rwxr-xr-xtest/list-services3
-rwxr-xr-xtest/monitor-services3
-rwxr-xr-xtest/set-domains20
5 files changed, 114 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am
index 8a7aca93..6be9e482 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -143,7 +143,7 @@ test_scripts = test/get-state test/list-profiles test/list-services \
test/test-manager test/test-connman test/monitor-connman \
test/connect-vpn test/disconnect-vpn test/list-providers \
test/monitor-manager test/test-counter test/set-ip-method \
- test/set-nameservers
+ test/set-nameservers test/set-domains
if TEST
testdir = $(pkglibdir)/test
diff --git a/src/service.c b/src/service.c
index d5105c30..386fe550 100644
--- a/src/service.c
+++ b/src/service.c
@@ -67,6 +67,7 @@ struct connman_service {
struct connman_network *network;
char **nameservers;
char *nameserver;
+ char **domains;
/* 802.1x settings from the config files */
char *eap;
char *identity;
@@ -592,6 +593,27 @@ static void append_dnsconfig(DBusMessageIter *iter, void *user_data)
DBUS_TYPE_STRING, &service->nameservers[i]);
}
+static void append_domain(DBusMessageIter *iter, void *user_data)
+{
+ struct connman_service *service = user_data;
+
+ if (is_connected(service) == FALSE)
+ return;
+}
+
+static void append_domainconfig(DBusMessageIter *iter, void *user_data)
+{
+ struct connman_service *service = user_data;
+ int i;
+
+ if (service->domains == NULL)
+ return;
+
+ for (i = 0; service->domains[i]; i++)
+ dbus_message_iter_append_basic(iter,
+ DBUS_TYPE_STRING, &service->domains[i]);
+}
+
static void append_proxy(DBusMessageIter *iter, void *user_data)
{
struct connman_service *service = user_data;
@@ -639,6 +661,14 @@ static void dns_configuration_changed(struct connman_service *service)
dns_changed(service);
}
+static void domain_configuration_changed(struct connman_service *service)
+{
+ connman_dbus_property_changed_array(service->path,
+ CONNMAN_SERVICE_INTERFACE,
+ "Domains.Configuration",
+ DBUS_TYPE_STRING, append_domainconfig, service);
+}
+
static DBusMessage *get_properties(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
@@ -790,6 +820,12 @@ static DBusMessage *get_properties(DBusConnection *conn,
connman_dbus_dict_append_array(&dict, "Nameservers.Configuration",
DBUS_TYPE_STRING, append_dnsconfig, service);
+ connman_dbus_dict_append_array(&dict, "Domains",
+ DBUS_TYPE_STRING, append_domain, service);
+
+ connman_dbus_dict_append_array(&dict, "Domains.Configuration",
+ DBUS_TYPE_STRING, append_domainconfig, service);
+
connman_dbus_dict_append_dict(&dict, "Proxy", append_proxy, service);
connman_dbus_dict_close(&array, &dict);
@@ -956,6 +992,42 @@ static DBusMessage *set_property(DBusConnection *conn,
dns_configuration_changed(service);
__connman_storage_save_service(service);
+ } else if (g_str_equal(name, "Domains.Configuration") == TRUE) {
+ DBusMessageIter entry;
+ GString *str;
+
+ if (type != DBUS_TYPE_ARRAY)
+ return __connman_error_invalid_arguments(msg);
+
+ str = g_string_new(NULL);
+ if (str == NULL)
+ return __connman_error_invalid_arguments(msg);
+
+ dbus_message_iter_recurse(&value, &entry);
+
+ while (dbus_message_iter_get_arg_type(&entry) == DBUS_TYPE_STRING) {
+ const char *val;
+ dbus_message_iter_get_basic(&entry, &val);
+ dbus_message_iter_next(&entry);
+ if (str->len > 0)
+ g_string_append_printf(str, " %s", val);
+ else
+ g_string_append(str, val);
+ }
+
+ g_strfreev(service->domains);
+
+ if (str->len > 0)
+ service->domains = g_strsplit_set(str->str, " ", 0);
+ else
+ service->domains = NULL;
+
+ g_string_free(str, TRUE);
+
+ //update_domains(service);
+ domain_configuration_changed(service);
+
+ __connman_storage_save_service(service);
} else if (g_str_equal(name, "IPv4.Configuration") == TRUE) {
int err;
@@ -2910,6 +2982,13 @@ static int service_load(struct connman_service *service)
service->nameservers = NULL;
}
+ service->domains = g_key_file_get_string_list(keyfile,
+ service->identifier, "Domains", &length, NULL);
+ if (service->domains != NULL && length == 0) {
+ g_strfreev(service->domains);
+ service->domains = NULL;
+ }
+
done:
g_key_file_free(keyfile);
@@ -3053,6 +3132,16 @@ update:
g_key_file_remove_key(keyfile, service->identifier,
"Nameservers", NULL);
+ if (service->domains != NULL) {
+ guint len = g_strv_length(service->domains);
+
+ g_key_file_set_string_list(keyfile, service->identifier,
+ "Domains",
+ (const gchar **) service->domains, len);
+ } else
+ g_key_file_remove_key(keyfile, service->identifier,
+ "Domains", NULL);
+
data = g_key_file_to_data(keyfile, &length, NULL);
if (g_file_set_contents(pathname, data, length, NULL) == FALSE)
diff --git a/test/list-services b/test/list-services
index e7476561..abe8420e 100755
--- a/test/list-services
+++ b/test/list-services
@@ -35,7 +35,8 @@ for path in properties["Services"]:
for key in properties.keys():
if key in ["IPv4", "IPv4.Configuration", "Proxy", "Ethernet"]:
val = extract_values(properties[key])
- elif key in ["Nameservers", "Nameservers.Configuration"]:
+ elif key in ["Nameservers", "Nameservers.Configuration",
+ "Domains", "Domains.Configuration"]:
val = extract_list(properties[key])
elif key in ["Favorite", "Immutable", "AutoConnect",
"SetupRequired", "PassphraseRequired"]:
diff --git a/test/monitor-services b/test/monitor-services
index 5657444c..93fd7581 100755
--- a/test/monitor-services
+++ b/test/monitor-services
@@ -30,7 +30,8 @@ def property_changed(name, value, path):
val = val + " ]"
elif name in ["IPv4", "IPv4.Configuration", "Proxy", "Ethernet"]:
val = extract_values(value)
- elif name in ["Nameservers", "Nameservers.Configuration"]:
+ elif name in ["Nameservers", "Nameservers.Configuration",
+ "Domains", "Domains.Configuration"]:
val = extract_list(value)
elif name in ["Strength", "Priority"]:
val = int(value)
diff --git a/test/set-domains b/test/set-domains
new file mode 100755
index 00000000..c45034c8
--- /dev/null
+++ b/test/set-domains
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+if (len(sys.argv) < 2):
+ print "Usage: %s <service> [domain*]" % (sys.argv[0])
+ sys.exit(1)
+
+bus = dbus.SystemBus()
+path = "/profile/default/" + sys.argv[1]
+service = dbus.Interface(bus.get_object('org.moblin.connman', path),
+ 'org.moblin.connman.Service')
+
+properties = service.GetProperties()
+
+print "Setting domains to %s" % (sys.argv[2:])
+
+service.SetProperty("Domains.Configuration",
+ dbus.Array(sys.argv[2:], signature=dbus.Signature('s')))