client: Use helper functions for setting domains, nameservers and timeservers
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 27 Mar 2013 11:54:05 +0000 (13:54 +0200)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Thu, 4 Apr 2013 07:27:26 +0000 (10:27 +0300)
client/commands.c

index 2cdf4b37ec3753a517ac82f4062ae1994faee69e..731a7b27b0e5728250e1d6d1b3f05efcf5f2ed7e 100644 (file)
@@ -522,6 +522,24 @@ static void config_append_ipv6(DBusMessageIter *iter, void *user_data)
                                &opts[0]);
 }
 
+static void config_append_str(DBusMessageIter *iter, void *user_data)
+{
+       struct config_append *append = user_data;
+       char **opts = append->opts;
+       int i = 0;
+
+       if (opts == NULL)
+               return;
+
+       while (opts[i] != NULL) {
+               dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
+                               &opts[i]);
+               i++;
+       }
+
+       append->values = i;
+}
+
 static int cmd_config(char *args[], int num, struct option *options)
 {
        int result = 0, res = 0, index = 2, oldindex = 0;
@@ -595,23 +613,35 @@ static int cmd_config(char *args[], int num, struct option *options)
                        break;
 
                case 'n':
-                       res = set_service_property(connection, message,
-                                       service_name,
+                       res = __connmanctl_dbus_set_property_array(connection,
+                                       path, "net.connman.Service",
+                                       config_return, g_strdup(service_name),
                                        "Nameservers.Configuration",
-                                       NULL, opt_start, 0);
+                                       DBUS_TYPE_STRING, config_append_str,
+                                       &append);
+                       index += append.values;
                        break;
+
                case 't':
-                       res = set_service_property(connection, message,
-                                       service_name,
+                       res = __connmanctl_dbus_set_property_array(connection,
+                                       path, "net.connman.Service",
+                                       config_return, g_strdup(service_name),
                                        "Timeservers.Configuration",
-                                       NULL, opt_start, 0);
+                                       DBUS_TYPE_STRING, config_append_str,
+                                       &append);
+                       index += append.values;
                        break;
+
                case 'd':
-                       res = set_service_property(connection, message,
-                                       service_name,
+                       res = __connmanctl_dbus_set_property_array(connection,
+                                       path, "net.connman.Service",
+                                       config_return, g_strdup(service_name),
                                        "Domains.Configuration",
-                                       NULL, opt_start, 0);
+                                       DBUS_TYPE_STRING, config_append_str,
+                                       &append);
+                       index += append.values;
                        break;
+
                case 'x':
                        if (*opt_start == NULL) {
                                res = -EINVAL;