Re: [PATCH 1/5] service: Add function to remove empty strings

2015-07-15 Thread Tomasz Bursztyka

Hi Jaakko,

Make the whole change it one loop. No need to check if there is, empty 
strings, at first.
It's greedy and, if there 1+ empty lines, you will anyway loop all over 
again.


Tomasz


This helper function takes in a heap-allocated buffer of heap-allocated
strings. If no strings should be removed, return the buffer. Else, free
all empty strings, place nonempty strings to a new container and return
it, freeing the old container.
---
  src/service.c | 32 
  1 file changed, 32 insertions(+)

diff --git a/src/service.c b/src/service.c
index 2d8245e..1723586 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2926,6 +2926,38 @@ static DBusMessage *get_properties(DBusConnection *conn,
return reply;
  }
  
+static char **remove_empty_strings(char **strv)

+{
+   int amount, length, index;
+   char **iter, **out;
+
+   amount = 0;
+   length = g_strv_length(strv);
+   iter = strv;
+
+   while (*iter)
+   if (strlen(*iter++))
+   amount++;
+
+   if (amount == length - 1)
+   return strv;
+
+   out = g_new0(char *, amount+1);
+   index = 0;
+   iter = strv;
+
+   while (*iter) {
+   if (strlen(*iter))
+   out[index++] = *iter;
+   else
+   g_free(*iter);
+   iter++;
+   }
+
+   g_free(strv);
+   return out;
+}
+
  static int update_proxy_configuration(struct connman_service *service,
DBusMessageIter *array)
  {


___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH 1/5] service: Add function to remove empty strings

2015-07-15 Thread Slava Monich

 Hi Jaakko,

 On ke, 2015-07-15 at 11:35 +0300, Jaakko Hannikainen wrote:
 This helper function takes in a heap-allocated buffer of heap-allocated
 strings. If no strings should be removed, return the buffer. Else, free
 all empty strings, place nonempty strings to a new container and return
 it, freeing the old container.
 ---
  src/service.c | 32 
  1 file changed, 32 insertions(+)

 diff --git a/src/service.c b/src/service.c
 index 2d8245e..1723586 100644
 --- a/src/service.c
 +++ b/src/service.c
 @@ -2926,6 +2926,38 @@ static DBusMessage *get_properties(DBusConnection 
 *conn,
  return reply;
  }
  
 +static char **remove_empty_strings(char **strv)
 +{
 +int amount, length, index;
 +char **iter, **out;
 +
 +amount = 0;
 +length = g_strv_length(strv);
 We could remove the call to g_strv_length() and calculate the max length
 in the while loop below.

 +iter = strv;
 +
 +while (*iter)
 +if (strlen(*iter++))
 +amount++;

And it's unnecessary to calculate the length of each string. Twice.

It would suffice to just check the first byte.

Regards,
-Slava
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH 3/5] service: Remove empty strings from Proxy

2015-07-15 Thread Jaakko Hannikainen
Same as previous commit, but for Proxy.Configuration.
---
 src/service.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/service.c b/src/service.c
index 37f8fb9..2bf64e8 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3071,9 +3071,12 @@ static int update_proxy_configuration(struct 
connman_service *service,
if (servers_str) {
g_strfreev(service-proxies);
 
-   if (servers_str-len  0)
-   service-proxies = g_strsplit_set(
+   if (servers_str-len  0) {
+   char **proxies = g_strsplit_set(
servers_str-str,  , 0);
+   proxies = remove_empty_strings(proxies);
+   service-proxies = proxies;
+   }
else
service-proxies = NULL;
}
@@ -3081,9 +3084,12 @@ static int update_proxy_configuration(struct 
connman_service *service,
if (excludes_str) {
g_strfreev(service-excludes);
 
-   if (excludes_str-len  0)
-   service-excludes = g_strsplit_set(
+   if (excludes_str-len  0) {
+   char **excludes = g_strsplit_set(
excludes_str-str,  , 0);
+   excludes = remove_empty_strings(excludes);
+   service-excludes = excludes;
+   }
else
service-excludes = NULL;
}
-- 
2.1.0

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH 3/5] service: Remove empty strings from Proxy

2015-07-15 Thread Jukka Rissanen
Hi Jaakko,

On ke, 2015-07-15 at 11:35 +0300, Jaakko Hannikainen wrote:
 Same as previous commit, but for Proxy.Configuration.

Proper commit message please.

 ---
  src/service.c | 14 ++
  1 file changed, 10 insertions(+), 4 deletions(-)
 
 diff --git a/src/service.c b/src/service.c
 index 37f8fb9..2bf64e8 100644
 --- a/src/service.c
 +++ b/src/service.c
 @@ -3071,9 +3071,12 @@ static int update_proxy_configuration(struct 
 connman_service *service,
   if (servers_str) {
   g_strfreev(service-proxies);
  
 - if (servers_str-len  0)
 - service-proxies = g_strsplit_set(
 + if (servers_str-len  0) {
 + char **proxies = g_strsplit_set(
   servers_str-str,  , 0);
 + proxies = remove_empty_strings(proxies);
 + service-proxies = proxies;
 + }
   else
   service-proxies = NULL;
   }
 @@ -3081,9 +3084,12 @@ static int update_proxy_configuration(struct 
 connman_service *service,
   if (excludes_str) {
   g_strfreev(service-excludes);
  
 - if (excludes_str-len  0)
 - service-excludes = g_strsplit_set(
 + if (excludes_str-len  0) {
 + char **excludes = g_strsplit_set(
   excludes_str-str,  , 0);
 + excludes = remove_empty_strings(excludes);
 + service-excludes = excludes;
 + }
   else
   service-excludes = NULL;
   }


Cheers,
Jukka


___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH 5/5] service: Remove empty strings from Timeservers

2015-07-15 Thread Jaakko Hannikainen
As both Domains and Nameserves' parsing uses GString to hold the
temporary server list, change Timeservers' parsing to use it too. While
parsing, remove empty strings.
---
 src/service.c | 34 +++---
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/src/service.c b/src/service.c
index be5f2f5..6768826 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3328,7 +3328,7 @@ static DBusMessage *set_property(DBusConnection *conn,
service_save(service);
} else if (g_str_equal(name, Timeservers.Configuration)) {
DBusMessageIter entry;
-   GSList *list = NULL;
+   GString *str;
int count = 0;
 
if (service-immutable)
@@ -3337,18 +3337,22 @@ static DBusMessage *set_property(DBusConnection *conn,
if (type != DBUS_TYPE_ARRAY)
return __connman_error_invalid_arguments(msg);
 
+   str = g_string_new(NULL);
+   if (!str)
+   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;
-   GSList *new_head;
-
dbus_message_iter_get_basic(entry, val);
+   dbus_message_iter_next(entry);
 
-   new_head = __connman_timeserver_add_list(list, val);
-   if (list != new_head) {
-   count++;
-   list = new_head;
+   if(val[0]) {
+   if (str-len  0)
+   g_string_append_printf(str,  %s, val);
+   else
+   g_string_append(str, val);
}
 
dbus_message_iter_next(entry);
@@ -3357,15 +3361,15 @@ static DBusMessage *set_property(DBusConnection *conn,
g_strfreev(service-timeservers_config);
service-timeservers_config = NULL;
 
-   if (list) {
-   service-timeservers_config = g_new0(char *, count+1);
-
-   while (list) {
-   count--;
-   service-timeservers_config[count] = list-data;
-   list = g_slist_delete_link(list, list);
-   };
+   if (str-len  0) {
+   char **timeservers = g_strsplit_set(str-str,  , 0);
+   timeservers = remove_empty_strings(timeservers);
+   service-timeservers_config = timeservers;
}
+   else
+   service-timeservers = NULL;
+
+   g_string_free(str, TRUE);
 
service_save(service);
timeservers_configuration_changed(service);
-- 
2.1.0

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH 4/5] service: Strip whitespace from Proxy URL

2015-07-15 Thread Jaakko Hannikainen
Call g_strstrip on the URL before setting Proxy.Configuration.URL.
---
 src/service.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/service.c b/src/service.c
index 2bf64e8..be5f2f5 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3102,7 +3102,7 @@ static int update_proxy_configuration(struct 
connman_service *service,
g_free(service-pac);
 
if (url  strlen(url)  0)
-   service-pac = g_strdup(url);
+   service-pac = g_strstrip(g_strdup(url));
else
service-pac = NULL;
 
-- 
2.1.0

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH 2/5] service: Remove empty strings from Domains

2015-07-15 Thread Jaakko Hannikainen
When parsing DBus messages to Domains.Configuration, remove all empty
strings from input. For example, sending
 example.com   foo.example.com  will result in
Domains.Configuration containing [ example.com, foo.example.com ],
rather than [ , example.com, , , foo.example.com, ].
---
 src/service.c | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/service.c b/src/service.c
index 1723586..37f8fb9 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3387,17 +3387,22 @@ static DBusMessage *set_property(DBusConnection *conn,
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);
+   if(!val[0]) {
+   if (str-len  0)
+   g_string_append_printf(str,  %s, val);
+   else
+   g_string_append(str, val);
+   }
}
 
searchdomain_remove_all(service);
g_strfreev(service-domains);
 
-   if (str-len  0)
-   service-domains = g_strsplit_set(str-str,  , 0);
+   if (str-len  0) {
+   char **domains = g_strsplit_set(str-str,  , 0);
+   domains = remove_empty_strings(domains);
+   service-domains = domains;
+   }
else
service-domains = NULL;
 
-- 
2.1.0

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH 1/5] service: Add function to remove empty strings

2015-07-15 Thread Jaakko Hannikainen
This helper function takes in a heap-allocated buffer of heap-allocated
strings. If no strings should be removed, return the buffer. Else, free
all empty strings, place nonempty strings to a new container and return
it, freeing the old container.
---
 src/service.c | 32 
 1 file changed, 32 insertions(+)

diff --git a/src/service.c b/src/service.c
index 2d8245e..1723586 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2926,6 +2926,38 @@ static DBusMessage *get_properties(DBusConnection *conn,
return reply;
 }
 
+static char **remove_empty_strings(char **strv)
+{
+   int amount, length, index;
+   char **iter, **out;
+
+   amount = 0;
+   length = g_strv_length(strv);
+   iter = strv;
+
+   while (*iter)
+   if (strlen(*iter++))
+   amount++;
+
+   if (amount == length - 1)
+   return strv;
+
+   out = g_new0(char *, amount+1);
+   index = 0;
+   iter = strv;
+
+   while (*iter) {
+   if (strlen(*iter))
+   out[index++] = *iter;
+   else
+   g_free(*iter);
+   iter++;
+   }
+
+   g_free(strv);
+   return out;
+}
+
 static int update_proxy_configuration(struct connman_service *service,
DBusMessageIter *array)
 {
-- 
2.1.0

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH 1/5] service: Add function to remove empty strings

2015-07-15 Thread Jukka Rissanen
Hi Jaakko,

On ke, 2015-07-15 at 11:35 +0300, Jaakko Hannikainen wrote:
 This helper function takes in a heap-allocated buffer of heap-allocated
 strings. If no strings should be removed, return the buffer. Else, free
 all empty strings, place nonempty strings to a new container and return
 it, freeing the old container.
 ---
  src/service.c | 32 
  1 file changed, 32 insertions(+)
 
 diff --git a/src/service.c b/src/service.c
 index 2d8245e..1723586 100644
 --- a/src/service.c
 +++ b/src/service.c
 @@ -2926,6 +2926,38 @@ static DBusMessage *get_properties(DBusConnection 
 *conn,
   return reply;
  }
  
 +static char **remove_empty_strings(char **strv)
 +{
 + int amount, length, index;
 + char **iter, **out;
 +
 + amount = 0;
 + length = g_strv_length(strv);

We could remove the call to g_strv_length() and calculate the max length
in the while loop below.

 + iter = strv;
 +
 + while (*iter)
 + if (strlen(*iter++))
 + amount++;
 +
 + if (amount == length - 1)
 + return strv;
 +
 + out = g_new0(char *, amount+1);
 + index = 0;
 + iter = strv;
 +
 + while (*iter) {
 + if (strlen(*iter))
 + out[index++] = *iter;
 + else
 + g_free(*iter);
 + iter++;
 + }
 +
 + g_free(strv);
 + return out;
 +}
 +
  static int update_proxy_configuration(struct connman_service *service,
   DBusMessageIter *array)
  {


Cheers,
Jukka


___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: connecting to an open wifi network with wps push button

2015-07-15 Thread Tomasz Bursztyka

Hi,

Is there any way to accomplish using connman?  I don't see a way to send a
WPS push button without first connecting to a service and having the user
agent request the WPS pin or push button.


That's the software WPS push button you want. There is no other way.

When the user physically press a real button: it means he wants to connect.
So here, that's exactly the same thing: he needs first to request a 
connection

and then connman (since it detects the service as WPS ready) asks you about
which method you want to use.

Note that WPS is usually badly implemented in AP side. So depending on 
those,

you may see connman no requesting you the method through the agent if the AP
does its job well, i.e.: advertizing properly it's running a WPS PBC 
sequence.

(thus connman detects it, and then do not ask the user about the method and
uses PBC automatically)

Tomasz
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH v2 2/6] service: Remove empty strings from Domains

2015-07-15 Thread Jaakko Hannikainen
When parsing DBus messages to Domains.Configuration, remove all empty
strings from input. For example, sending
 example.com   foo.example.com  will result in
Domains.Configuration containing [ example.com, foo.example.com ],
rather than [ , example.com, , , foo.example.com, ].
---
 src/service.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/service.c b/src/service.c
index 3cf49a8..b14ddf7 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3372,6 +3372,10 @@ static DBusMessage *set_property(DBusConnection *conn,
const char *val;
dbus_message_iter_get_basic(entry, val);
dbus_message_iter_next(entry);
+
+   if (!val[0])
+   continue;
+
if (str-len  0)
g_string_append_printf(str,  %s, val);
else
@@ -3381,9 +3385,11 @@ static DBusMessage *set_property(DBusConnection *conn,
searchdomain_remove_all(service);
g_strfreev(service-domains);
 
-   if (str-len  0)
-   service-domains = g_strsplit_set(str-str,  , 0);
-   else
+   if (str-len  0) {
+   char **domains = g_strsplit_set(str-str,  , 0);
+   domains = remove_empty_strings(domains);
+   service-domains = domains;
+   } else
service-domains = NULL;
 
g_string_free(str, TRUE);
-- 
2.1.0

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH v2 1/6] service: Add function to remove empty strings

2015-07-15 Thread Jaakko Hannikainen
This helper function takes in a heap-allocated buffer of heap-allocated
strings. It frees empty strings and moves other strings on top of them.
---
 src/service.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/src/service.c b/src/service.c
index 2d8245e..3cf49a8 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2926,6 +2926,23 @@ static DBusMessage *get_properties(DBusConnection *conn,
return reply;
 }
 
+static char **remove_empty_strings(char **strv)
+{
+   int index = 0;
+   char **iter = strv;
+
+   while (*iter) {
+   if (**iter)
+   strv[index++] = *iter;
+   else
+   g_free(*iter);
+   iter++;
+   }
+
+   strv[index] = NULL;
+   return strv;
+}
+
 static int update_proxy_configuration(struct connman_service *service,
DBusMessageIter *array)
 {
-- 
2.1.0

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH v2 4/6] service: Strip whitespace from Proxy URL

2015-07-15 Thread Jaakko Hannikainen
Call g_strstrip on the URL before setting Proxy.Configuration.URL.
---
 src/service.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/service.c b/src/service.c
index 7b9f8f3..7adcd4f 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3085,7 +3085,7 @@ static int update_proxy_configuration(struct 
connman_service *service,
g_free(service-pac);
 
if (url  strlen(url)  0)
-   service-pac = g_strdup(url);
+   service-pac = g_strstrip(g_strdup(url));
else
service-pac = NULL;
 
-- 
2.1.0

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH v2 6/6] service: Remove empty strings from Nameservers

2015-07-15 Thread Jaakko Hannikainen
When parsing DBus messages to Nameservers.Configuration, check all
space-separated strings, replace non-IPs with empty strings and
remove all empty strings from input.

Sending 123.123.123.123  invalid-ip 8.8.8.8  will result in
Nameservers.Configuration containing [ 123.123.123.123, 8.8.8.8 ],
rather than [ 123.123.123.123, , invalid-ip, 8.8.8.8, ].

Previously the function only checked that the string starts with a
correct IP and then split the string with spaces as delimiter, thus
accepting bad values.
---
 src/service.c | 26 ++
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/service.c b/src/service.c
index 8ea7c7c..76099f1 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3272,20 +3272,30 @@ static DBusMessage *set_property(DBusConnection *conn,
const char *val;
dbus_message_iter_get_basic(entry, val);
dbus_message_iter_next(entry);
-   if (connman_inet_check_ipaddress(val)  0) {
-   if (str-len  0)
-   g_string_append_printf(str,  %s, val);
-   else
-   g_string_append(str, val);
-   }
+
+   if (!val[0])
+   continue;
+
+   if (str-len  0)
+   g_string_append_printf(str,  %s, val);
+   else
+   g_string_append(str, val);
}
 
nameserver_remove_all(service, CONNMAN_IPCONFIG_TYPE_ALL);
g_strfreev(service-nameservers_config);
 
if (str-len  0) {
-   service-nameservers_config =
-   g_strsplit_set(str-str,  , 0);
+   char **nameservers, **iter;
+
+   nameservers = g_strsplit_set(str-str,  , 0);
+
+   for (iter = nameservers; *iter; iter++)
+   if (connman_inet_check_ipaddress(*iter) = 0)
+   *iter[0] = '\0';
+
+   nameservers = remove_empty_strings(nameservers);
+   service-nameservers_config = nameservers;
} else {
service-nameservers_config = NULL;
}
-- 
2.1.0

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH v2 0/6] Strip whitespace and empty strings from DBus input

2015-07-15 Thread Jaakko Hannikainen
Hello,

These patches remove empty strings and leading/trailing whitespace from DBus

input for Domains.Configuration, Proxy.Configuration, Timeservers.Configuration 

and Nameservers.Configuration.  



Previously, Nameservers.Configuration accepted invalid values such as   

192.0.2.1  invalid-ip 8.8.8.8  and then split them with space as delimiter,   

resulting in Nameservers.Configuration containing   

[192.0.2.1, , invalid-ip, 8.8.8.8, ] rather than the valid value

[192.0.2.1, 8.8.8.8].   



The v2 implements remove_empty_strings much more sensibly, fixes some style 

issues and adds a patch for Nameservers.Configuration.

Managed to fudge the cover letter first time around, sorry.

Jaakko Hannikainen (6):
  service: Add function to remove empty strings
  service: Remove empty strings from Domains
  service: Remove empty strings from Proxy
  service: Strip whitespace from Proxy URL
  service: Remove empty strings from Timeservers
  service: Remove empty strings from Nameservers

 src/service.c | 109 +++---
 1 file changed, 74 insertions(+), 35 deletions(-)

-- 
2.1.0

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH v2 3/6] service: Remove empty strings from Proxy

2015-07-15 Thread Jaakko Hannikainen
When parsing DBus messages to Proxy.Configuration, remove all empty
strings from input. For example, sending
 example.com   foo.example.com  will result in Proxy.Configuration containing
[ example.com, foo.example.com ], rather than
[ , example.com, , , foo.example.com, ].
---
 src/service.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/service.c b/src/service.c
index b14ddf7..7b9f8f3 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3056,20 +3056,24 @@ static int update_proxy_configuration(struct 
connman_service *service,
if (servers_str) {
g_strfreev(service-proxies);
 
-   if (servers_str-len  0)
-   service-proxies = g_strsplit_set(
+   if (servers_str-len  0) {
+   char **proxies = g_strsplit_set(
servers_str-str,  , 0);
-   else
+   proxies = remove_empty_strings(proxies);
+   service-proxies = proxies;
+   } else
service-proxies = NULL;
}
 
if (excludes_str) {
g_strfreev(service-excludes);
 
-   if (excludes_str-len  0)
-   service-excludes = g_strsplit_set(
+   if (excludes_str-len  0) {
+   char **excludes = g_strsplit_set(
excludes_str-str,  , 0);
-   else
+   excludes = remove_empty_strings(excludes);
+   service-excludes = excludes;
+   } else
service-excludes = NULL;
}
 
-- 
2.1.0

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH v2 5/6] service: Remove empty strings from Timeservers

2015-07-15 Thread Jaakko Hannikainen
As both Domains and Nameserves' parsing uses GString to hold the
temporary server list, change Timeservers' parsing to use it too. While
parsing, remove empty strings.
---
 src/service.c | 36 +++-
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/src/service.c b/src/service.c
index 7adcd4f..8ea7c7c 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3311,7 +3311,7 @@ static DBusMessage *set_property(DBusConnection *conn,
service_save(service);
} else if (g_str_equal(name, Timeservers.Configuration)) {
DBusMessageIter entry;
-   GSList *list = NULL;
+   GString *str;
int count = 0;
 
if (service-immutable)
@@ -3320,35 +3320,37 @@ static DBusMessage *set_property(DBusConnection *conn,
if (type != DBUS_TYPE_ARRAY)
return __connman_error_invalid_arguments(msg);
 
+   str = g_string_new(NULL);
+   if (!str)
+   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;
-   GSList *new_head;
-
dbus_message_iter_get_basic(entry, val);
+   dbus_message_iter_next(entry);
 
-   new_head = __connman_timeserver_add_list(list, val);
-   if (list != new_head) {
-   count++;
-   list = new_head;
-   }
+   if (!val[0])
+   continue;
 
-   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-timeservers_config);
service-timeservers_config = NULL;
 
-   if (list) {
-   service-timeservers_config = g_new0(char *, count+1);
+   if (str-len  0) {
+   char **timeservers = g_strsplit_set(str-str,  , 0);
+   timeservers = remove_empty_strings(timeservers);
+   service-timeservers_config = timeservers;
+   } else
+   service-timeservers = NULL;
 
-   while (list) {
-   count--;
-   service-timeservers_config[count] = list-data;
-   list = g_slist_delete_link(list, list);
-   };
-   }
+   g_string_free(str, TRUE);
 
service_save(service);
timeservers_configuration_changed(service);
-- 
2.1.0

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: connecting to an open wifi network with wps push button

2015-07-15 Thread James Zipperer
I don't think it's exactly the same thing, please correct me if I am wrong.

The WPS PBC can be initiated by either the AP or the device.  It does not
need to be started on the AP side.  If you cannot initiate the button press
without first selecting a service to connect to, there is no way to start
the WPS sequence from device side because you have already chosen which AP
you want to connect to.  You must be able to have the device advertising
the WPS PBC before you select the AP to connect to.  That way the AP can
see the advertisements.

wpa_supplicant / wpa_cli allow the button to be pressed before choosing the
network to connect to.

Thanks!



On Tue, Jul 14, 2015 at 11:52 PM, Tomasz Bursztyka 
tomasz.burszt...@linux.intel.com wrote:

 Hi,

 Is there any way to accomplish using connman?  I don't see a way to send a
 WPS push button without first connecting to a service and having the user
 agent request the WPS pin or push button.


 That's the software WPS push button you want. There is no other way.

 When the user physically press a real button: it means he wants to connect.
 So here, that's exactly the same thing: he needs first to request a
 connection
 and then connman (since it detects the service as WPS ready) asks you about
 which method you want to use.

 Note that WPS is usually badly implemented in AP side. So depending on
 those,
 you may see connman no requesting you the method through the agent if the
 AP
 does its job well, i.e.: advertizing properly it's running a WPS PBC
 sequence.
 (thus connman detects it, and then do not ask the user about the method and
 uses PBC automatically)

 Tomasz
 ___
 connman mailing list
 connman@connman.net
 https://lists.connman.net/mailman/listinfo/connman




-- 

*James Zipperer*
Software Engineer
Synapse Product Development

mail 1511 6th Ave Suite 400, Seattle, WA 98101
direct 206-832-1269,3614 | office 206-381-0898 | mobile 206-399-6228
james.zippe...@synapse.com | http://www.synapse.com

This email and any files transmitted with it are confidential. Unauthorized
publication, use or dissemination of this email is prohibited.
Please consider the environment before printing.
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] doc/technology-api.txt: Fix typo

2015-07-15 Thread Marko Sulejic
---
 doc/technology-api.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/technology-api.txt b/doc/technology-api.txt
index f97eac0..f3703c0 100644
--- a/doc/technology-api.txt
+++ b/doc/technology-api.txt
@@ -56,7 +56,7 @@ Propertiesboolean Powered [readwrite]
 
Boolean representing if a technology is connected.
 
-   This is just a convience property for allowing the
+   This is just a convenience property for allowing the
UI to easily show if this technology has an active
connection or not.
 
-- 
2.1.0

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH v2 0/6] Strip whitespace and empty strings from DBus input

2015-07-15 Thread Jukka Rissanen
Hi Jaakko,

On ke, 2015-07-15 at 15:26 +0300, Jaakko Hannikainen wrote:
 Hello,
 
 These patches remove empty strings and leading/trailing whitespace from DBus  
   
 input for Domains.Configuration, Proxy.Configuration, 
 Timeservers.Configuration 
 and Nameservers.Configuration.
   
   
   
 Previously, Nameservers.Configuration accepted invalid values such as 
   
 192.0.2.1  invalid-ip 8.8.8.8  and then split them with space as delimiter, 
   
 resulting in Nameservers.Configuration containing 
   
 [192.0.2.1, , invalid-ip, 8.8.8.8, ] rather than the valid value  
   
 [192.0.2.1, 8.8.8.8]. 
   
   
   
 The v2 implements remove_empty_strings much more sensibly, fixes some style   
   
 issues and adds a patch for Nameservers.Configuration.
 
 Managed to fudge the cover letter first time around, sorry.

looks good so ACK from me.

Cheers,
Jukka



___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman