find_element, data);
service = __connman_element_get_service(data->element);
- if (service != NULL)
- data->order = __connman_service_get_order(service);
+ data->order = __connman_service_get_order(service);
gateway_list = g_slist_append(gateway_list, data);
static struct gateway_data *find_default_gateway(void)
{
struct gateway_data *found = NULL;
+ unsigned int order = 0;
GSList *list;
for (list = gateway_list; list; list = list->next) {
struct gateway_data *data = list->data;
- /* just return the last one for now */
- found = data;
+
+ if (found == NULL || data->order > order) {
+ found = data;
+ order = data->order;
+ }
}
return found;
struct connman_service *service;
service = __connman_element_get_service(data->element);
-
data->order = __connman_service_get_order(service);
}
}
unsigned int __connman_service_get_order(struct connman_service *service)
{
+ GSequenceIter *iter;
+
if (service == NULL)
return 0;
+ if (service->favorite == FALSE)
+ return 0;
+
+ iter = g_hash_table_lookup(service_hash, service->identifier);
+ if (iter != NULL) {
+ if (g_sequence_iter_get_position(iter) == 0)
+ return 1;
+ }
+
return service->order;
}