Commit 73628833 authored by Jussi Kukkonen's avatar Jussi Kukkonen

sort providers by accuracy in Master

parent df764fee
......@@ -99,8 +99,7 @@ gc_iface_master_client_set_requirements (GcMasterClient *client,
// TODO: should have a return value to indicate provider existence?
} else {
/* TODO select which provider/interface to use out of the possible ones
* Now using the first one */
/* choose the most accurate provider (first one) */
client->position_provider = providers->data;
g_signal_connect (G_OBJECT (client->position_provider),
......@@ -122,12 +121,11 @@ gc_iface_master_client_set_requirements (GcMasterClient *client,
// TODO: should have a return value to indicate provider existence?
} else {
/* TODO select which provider/interface to use out of the possible ones
* Now using the first one */
/* choose the most accurate provider (first one) */
client->address_provider = providers->data;
g_signal_connect (G_OBJECT (client->address_provider),
"position-changed",
"address-changed",
G_CALLBACK (address_changed),
client);
......
......@@ -820,7 +820,6 @@ gc_master_provider_network_status_changed (GcMasterProvider *provider,
provider_status_changed (priv->geoclue, status, provider);
/* update position cache */
/* FIXME what should happen when net is down:
* should position cache be updated ? */
if (status == GEOCLUE_STATUS_AVAILABLE) {
......@@ -828,3 +827,14 @@ gc_master_provider_network_status_changed (GcMasterProvider *provider,
}
}
}
/* GCompareFunc for sorting providers by accuracy */
gint
gc_master_provider_compare_by_accuracy (GcMasterProvider *a,
GcMasterProvider *b)
{
GcMasterProviderPrivate *priv_a = GET_PRIVATE (a);
GcMasterProviderPrivate *priv_b = GET_PRIVATE (b);
return priv_b->accuracy_level - priv_a->accuracy_level;
}
......@@ -44,6 +44,8 @@ GType gc_master_provider_get_type (void);
GcMasterProvider *gc_master_provider_new (const char *filename,
gboolean network_status_events);
gint gc_master_provider_compare_by_accuracy (GcMasterProvider *a, GcMasterProvider *b);
gboolean gc_master_provider_is_good (GcMasterProvider *provider,
GcInterfaceFlags iface_types,
GeoclueAccuracyLevel min_accuracy,
......
......@@ -114,7 +114,9 @@ gc_master_add_new_provider (GcMaster *master,
return;
}
providers = g_list_prepend (providers, provider);
providers = g_list_insert_sorted
(providers, provider,
(GCompareFunc)gc_master_provider_compare_by_accuracy);
}
/* Scan a directory for .provider files */
......@@ -231,8 +233,6 @@ gc_master_get_providers (GcInterfaceFlags iface_type,
return NULL;
}
/* we should probably return in some order?
* accuracy? */
for (l = providers; l; l = l->next) {
GcMasterProvider *provider = l->data;
......@@ -245,5 +245,6 @@ gc_master_get_providers (GcInterfaceFlags iface_type,
}
}
/* return most accurate first */
return g_list_reverse (p);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment