Hi Patrik,

On 03/30/2012 11:24 AM, [email protected] wrote:
From: Patrik Flykt<[email protected]>

Update the service order checking with a lookup of preferred
technologies. If the new service is found to be preferred,
switch the order of the current default and the new service.

Do the same checks for the default service as currently in
online state default service checking; if the current default
service stays as default, return -EALREADY.

When neither service was found to be preferred, return -EAGAIN.
---
  src/service.c |   33 +++++++++++++++++++++++++++++++++
  1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/src/service.c b/src/service.c
index c9ee233..e2c0a0e 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4173,6 +4173,39 @@ static void downgrade_connected_services(void)
        }
  }

+static int service_update_order(struct connman_service *default_service,
+               struct connman_service *new_service,
+               enum connman_service_state new_state)
+{

Perhaps the function name could be changed as we have already __connman_service_update_ordering() function in service.c


+       char **tech_array;
+       int i;
+       enum connman_service_type type;
+
+       if (default_service == NULL || default_service == new_service ||
+                       default_service->state != new_state )
+               return 0;
+
+       tech_array = connman_setting_get_string_list("PreferredTechnologies");
+       if (tech_array != NULL) {

What about
        if (tech_array == NULL)
                return -EALREADY;

so we don't have to indent the rest of the func.

+
+               for (i = 0; tech_array[i] != NULL; i += 1) {
+                       type = __connman_service_string2type(tech_array[i]);
+
+                       if (default_service->type == type)
+                               return -EALREADY;
+
+                       if (new_service->type == type) {
+                               switch_default_service(new_service,
+                                               default_service);
+                               return 0;
+                       }
+               }
+               return -EAGAIN;
+       }
+
+       return -EALREADY;
+}
+
  static int service_indicate_state(struct connman_service *service)
  {
        enum connman_service_state old_state, new_state;


Cheers,
Jukka

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to