From: Patrik Flykt Date: Thu, 5 Apr 2012 19:38:44 +0000 (+0300) Subject: service: Function for checking and updating service ordering X-Git-Tag: 2.0_alpha~445 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2f03c0fb45f3e2f51c028a671d74e9fa9c90101a;p=framework%2Fconnectivity%2Fconnman.git service: Function for checking and updating service ordering 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. --- diff --git a/src/service.c b/src/service.c index bf1eb26..911b6bb 100644 --- a/src/service.c +++ b/src/service.c @@ -4296,6 +4296,36 @@ static void downgrade_connected_services(void) } } +static int service_update_preferred_order(struct connman_service *default_service, + struct connman_service *new_service, + enum connman_service_state new_state) +{ + unsigned int *tech_array; + int i; + + if (default_service == NULL || default_service == new_service || + default_service->state != new_state ) + return 0; + + tech_array = connman_setting_get_uint_list("PreferredTechnologies"); + if (tech_array != NULL) { + + for (i = 0; tech_array[i] != 0; i += 1) { + if (default_service->type == tech_array[i]) + return -EALREADY; + + if (new_service->type == tech_array[i]) { + 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;