On to, 2014-12-11 at 12:24 +0200, Tomasz Bursztyka wrote: > Hi, > > NACK. > > > From: Chengyi Zhao <[email protected]> > > > > --- > > 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 [email protected] https://lists.connman.net/mailman/listinfo/connman
