[PATCH] service: Send changed type signal

2014-12-11 Thread Chengyi Zhao
From: Chengyi Zhao chengyi1.z...@archermind.com

---
 src/service.c | 31 ++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/service.c b/src/service.c
index 9bba227..6c8b2a2 100644
--- a/src/service.c
+++ b/src/service.c
@@ -183,7 +183,7 @@ const char *__connman_service_type2string(enum 
connman_service_type type)
 {
switch (type) {
case CONNMAN_SERVICE_TYPE_UNKNOWN:
-   break;
+   return unknown;
case CONNMAN_SERVICE_TYPE_SYSTEM:
return system;
case CONNMAN_SERVICE_TYPE_ETHERNET:
@@ -1423,9 +1423,30 @@ bool __connman_service_index_is_default(int index)
return __connman_service_get_index(service) == index;
 }
 
+static void type_changed(struct connman_service *service)
+{
+   const char *str;
+
+   if (!service)
+   return;
+
+   if (!allow_property_changed(service))
+   return;
+
+   str = __connman_service_type2string(service-type);
+   if (!str)
+   return;
+
+   connman_dbus_property_changed_basic(service-path,
+   CONNMAN_SERVICE_INTERFACE, Type,
+   DBUS_TYPE_STRING, str);
+}
+
 static void default_changed(void)
 {
struct connman_service *service = __connman_service_get_default();
+   enum connman_service_type old_type = CONNMAN_SERVICE_TYPE_UNKNOWN;
+   enum connman_service_type new_type = CONNMAN_SERVICE_TYPE_UNKNOWN;
 
if (service == current_default)
return;
@@ -1436,6 +1457,11 @@ static void default_changed(void)
 
__connman_service_timeserver_changed(current_default, NULL);
 
+   if (current_default)
+   old_type = current_default-type;
+   if (service)
+   new_type = service-type;
+
current_default = service;
 
if (service) {
@@ -1448,6 +1474,9 @@ static void default_changed(void)
}
 
__connman_notifier_default_changed(service);
+
+   if (old_type != new_type)
+   type_changed(service);
 }
 
 static void state_changed(struct connman_service *service)
-- 
1.9.1

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


Re: [PATCH] service: Send changed type signal

2014-12-11 Thread Tomasz Bursztyka

Hi,

NACK.


From: Chengyi Zhao chengyi1.z...@archermind.com

---
  src/service.c | 31 ++-
  1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/service.c b/src/service.c
index 9bba227..6c8b2a2 100644
--- a/src/service.c
+++ b/src/service.c
@@ -183,7 +183,7 @@ const char *__connman_service_type2string(enum 
connman_service_type type)
  {
switch (type) {
case CONNMAN_SERVICE_TYPE_UNKNOWN:
-   break;
+   return unknown;


No, if a service type is unknown this functions returns NULL, and that's it.
You will never ever get a service through service list which owns a type 
unknown.

Or if it is, there will be serious bug around.


case CONNMAN_SERVICE_TYPE_SYSTEM:
return system;
case CONNMAN_SERVICE_TYPE_ETHERNET:
@@ -1423,9 +1423,30 @@ bool __connman_service_index_is_default(int index)
return __connman_service_get_index(service) == index;
  }
  
+static void type_changed(struct connman_service *service)

+{
+   const char *str;
+
+   if (!service)
+   return;
+
+   if (!allow_property_changed(service))
+   return;
+
+   str = __connman_service_type2string(service-type);
+   if (!str)
+   return;
+
+   connman_dbus_property_changed_basic(service-path,
+   CONNMAN_SERVICE_INTERFACE, Type,
+   DBUS_TYPE_STRING, str);
+}


The type of a service never changes, this signal is useless.


+
  static void default_changed(void)
  {
struct connman_service *service = __connman_service_get_default();
+   enum connman_service_type old_type = CONNMAN_SERVICE_TYPE_UNKNOWN;
+   enum connman_service_type new_type = CONNMAN_SERVICE_TYPE_UNKNOWN;
  
  	if (service == current_default)

return;
@@ -1436,6 +1457,11 @@ static void default_changed(void)
  
  	__connman_service_timeserver_changed(current_default, NULL);
  
+	if (current_default)

+   old_type = current_default-type;
+   if (service)
+   new_type = service-type;
+
current_default = service;
  
  	if (service) {

@@ -1448,6 +1474,9 @@ static void default_changed(void)
}
  
  	__connman_notifier_default_changed(service);

+
+   if (old_type != new_type)
+   type_changed(service);
  }


This does not make any sense.
The type of the previous default service or the new one has not changed.
Sure, the previous service could have a different type than the new one, 
but themselves

they haven't changed their type.


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


Re: [PATCH] service: Send changed type signal

2014-12-11 Thread Patrik Flykt
On Thu, 2014-12-11 at 17:54 +0800, Chengyi Zhao wrote:
 From: Chengyi Zhao chengyi1.z...@archermind.com
 
 ---

There is no commit message. NACK.

Patrik

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


Re: [PATCH] service: Send changed type signal

2014-12-11 Thread Jukka Rissanen
On to, 2014-12-11 at 12:24 +0200, Tomasz Bursztyka wrote:
 Hi,
 
 NACK.
 
  From: Chengyi Zhao chengyi1.z...@archermind.com
 
  ---
src/service.c | 31 ++-
1 file changed, 30 insertions(+), 1 deletion(-)
 
  diff --git a/src/service.c b/src/service.c
  index 9bba227..6c8b2a2 100644
  --- a/src/service.c
  +++ b/src/service.c
  @@ -183,7 +183,7 @@ const char *__connman_service_type2string(enum 
  connman_service_type type)
{
  switch (type) {
  case CONNMAN_SERVICE_TYPE_UNKNOWN:
  -   break;
  +   return unknown;
 
 No, if a service type is unknown this functions returns NULL, and that's it.
 You will never ever get a service through service list which owns a type 
 unknown.
 Or if it is, there will be serious bug around.
 
  case CONNMAN_SERVICE_TYPE_SYSTEM:
  return system;
  case CONNMAN_SERVICE_TYPE_ETHERNET:
  @@ -1423,9 +1423,30 @@ bool __connman_service_index_is_default(int index)
  return __connman_service_get_index(service) == index;
}

  +static void type_changed(struct connman_service *service)
  +{
  +   const char *str;
  +
  +   if (!service)
  +   return;
  +
  +   if (!allow_property_changed(service))
  +   return;
  +
  +   str = __connman_service_type2string(service-type);
  +   if (!str)
  +   return;
  +
  +   connman_dbus_property_changed_basic(service-path,
  +   CONNMAN_SERVICE_INTERFACE, Type,
  +   DBUS_TYPE_STRING, str);
  +}
 
 The type of a service never changes, this signal is useless.
 
  +
static void default_changed(void)
{
  struct connman_service *service = __connman_service_get_default();
  +   enum connman_service_type old_type = CONNMAN_SERVICE_TYPE_UNKNOWN;
  +   enum connman_service_type new_type = CONNMAN_SERVICE_TYPE_UNKNOWN;

  if (service == current_default)
  return;
  @@ -1436,6 +1457,11 @@ static void default_changed(void)

  __connman_service_timeserver_changed(current_default, NULL);

  +   if (current_default)
  +   old_type = current_default-type;
  +   if (service)
  +   new_type = service-type;
  +
  current_default = service;

  if (service) {
  @@ -1448,6 +1474,9 @@ static void default_changed(void)
  }

  __connman_notifier_default_changed(service);
  +
  +   if (old_type != new_type)
  +   type_changed(service);
}
 
 This does not make any sense.
 The type of the previous default service or the new one has not changed.
 Sure, the previous service could have a different type than the new one, 
 but themselves
 they haven't changed their type.

To Chengyi:

if you want to know what is the current type of default service, you can
get that information from service properties. You just need to listen
the service PropertyChanged signals and get the type from there.


Cheers,
Jukka


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


RE: [PATCH] service: Send changed type signal

2014-12-11 Thread Chengyi Zhao
Hi,

  
  This does not make any sense.
  The type of the previous default service or the new one has not changed.
  Sure, the previous service could have a different type than the new one, 
  but themselves
  they haven't changed their type.
Yes, this service type haven't been changed.
But, now users want to monitor the type changed signal of default service,I 
think ConnMan should send the signal when the type of default service has 
beenchanged.
So I suggest that manager module can add the property 'Type' to provider the 
type of current default service and send the type changed signal of default 
service.
 
 if you want to know what is the current type of default service, you can
 get that information from service properties. You just need to listen
 the service PropertyChanged signals and get the type from there.
Yes, I think so.
But, when received the service PropertyChanged('State' property) signals, I 
found out I can't get the correct default service, because 'service_list' 
sometimeshasn't been sorted. 
Thanks,
Chengyi
  
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


RE: [PATCH] service: Send changed type signal

2014-12-11 Thread Chengyi Zhao



Hi

 From: checkz...@hotmail.com
 To: connman@connman.net
 Subject: RE: [PATCH] service: Send changed type signal
 Date: Thu, 11 Dec 2014 13:34:08 +
 
 Hi,
 
   
   This does not make any sense.
   The type of the previous default service or the new one has not changed.
   Sure, the previous service could have a different type than the new one, 
   but themselves
   they haven't changed their type.
 Yes, this service type haven't been changed.
 But, now users want to monitor the type changed signal of default service,I 
 think ConnMan should send the signal when the type of default service has 
 been changed.
 So I suggest that manager module can add the property 'Type' to provider the 
 type  of current default service and send the type changed signal of default 
 service.
  
  if you want to know what is the current type of default service, you can
  get that information from service properties. You just need to listen
  the service PropertyChanged signals and get the type from there.
 Yes, I think so.
 But, when received the service PropertyChanged('State' property) signals,  I 
 found out I can't get the correct default service,  because 'service_list' 
 sometimes hasn't been sorted. 

To Jukka,
Users can listen the ServicesChanged signal of manager object, after received 
this signal, service_list has been sorted, and the first service is a default 
service, user can getthe first service type.
Thanks,Chengyi
  
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman