Commit b9313d03 authored by Jussi Kukkonen's avatar Jussi Kukkonen

reinit master client when requirements are set

parent 93358fa8
......@@ -52,10 +52,12 @@ typedef struct _GcMasterClientPrivate {
gboolean require_updates;
GeoclueResourceFlags allowed_resources;
gboolean position_started;
GcMasterProvider *position_provider;
GList *position_providers;
gboolean position_provider_choice_in_progress;
gboolean address_started;
GcMasterProvider *address_provider;
GList *address_providers;
gboolean address_provider_choice_in_progress;
......@@ -530,24 +532,6 @@ gc_master_client_choose_address_provider (GcMasterClient *client,
return TRUE;
}
static gboolean
gc_iface_master_client_set_requirements (GcMasterClient *client,
GeoclueAccuracyLevel min_accuracy,
int min_time,
gboolean require_updates,
GeoclueResourceFlags allowed_resources,
GError **error)
{
GcMasterClientPrivate *priv = GET_PRIVATE (client);
priv->min_accuracy = min_accuracy;
priv->min_time = min_time;
priv->require_updates = require_updates;
priv->allowed_resources = allowed_resources;
return TRUE;
}
static void
gc_master_provider_set_position_providers (GcMasterClient *client,
GList *providers)
......@@ -588,12 +572,79 @@ gc_master_provider_set_address_providers (GcMasterClient *client,
g_free (accuracy_data);
}
static void
gc_master_client_init_position_providers (GcMasterClient *client)
{
GcMasterClientPrivate *priv = GET_PRIVATE (client);
GList *providers;
if (!priv->position_started) {
return;
}
/* TODO: free priv->position_providers */
providers = gc_master_get_providers (GC_IFACE_POSITION,
priv->min_accuracy,
priv->require_updates,
priv->allowed_resources,
NULL);
g_debug ("client: %d position providers matching requirements found, now choosing current provider",
g_list_length (providers));
gc_master_provider_set_position_providers (client, providers);
gc_master_client_choose_position_provider (client, priv->position_providers);
}
static void
gc_master_client_init_address_providers (GcMasterClient *client)
{
GList *providers;
GcMasterClientPrivate *priv = GET_PRIVATE (client);
if (!priv->address_started) {
return;
}
/* TODO: free priv->address_providers */
providers = gc_master_get_providers (GC_IFACE_ADDRESS,
priv->min_accuracy,
priv->require_updates,
priv->allowed_resources,
NULL);
g_debug ("client: %d address providers matching requirements found, now choosing current provider",
g_list_length (providers));
gc_master_provider_set_address_providers (client, providers);
gc_master_client_choose_address_provider (client, priv->address_providers);
}
static gboolean
gc_iface_master_client_set_requirements (GcMasterClient *client,
GeoclueAccuracyLevel min_accuracy,
int min_time,
gboolean require_updates,
GeoclueResourceFlags allowed_resources,
GError **error)
{
GcMasterClientPrivate *priv = GET_PRIVATE (client);
priv->min_accuracy = min_accuracy;
priv->min_time = min_time;
priv->require_updates = require_updates;
priv->allowed_resources = allowed_resources;
gc_master_client_init_position_providers (client);
gc_master_client_init_address_providers (client);
return TRUE;
}
static gboolean
gc_iface_master_client_position_start (GcMasterClient *client,
GError **error)
{
GList *providers;
GcMasterClientPrivate *priv = GET_PRIVATE (client);
if (priv->position_providers) {
......@@ -605,16 +656,9 @@ gc_iface_master_client_position_start (GcMasterClient *client,
return FALSE;
}
providers = gc_master_get_providers (GC_IFACE_POSITION,
priv->min_accuracy,
priv->require_updates,
priv->allowed_resources,
NULL);
g_debug ("client: %d position providers matching requirements found, now choosing current provider",
g_list_length (providers));
priv->position_started = TRUE;
gc_master_provider_set_position_providers (client, providers);
gc_master_client_choose_position_provider (client, priv->position_providers);
gc_master_client_init_position_providers (client);
return TRUE;
}
......@@ -623,7 +667,6 @@ static gboolean
gc_iface_master_client_address_start (GcMasterClient *client,
GError **error)
{
GList *providers;
GcMasterClientPrivate *priv = GET_PRIVATE (client);
if (priv->address_providers) {
......@@ -635,16 +678,8 @@ gc_iface_master_client_address_start (GcMasterClient *client,
return FALSE;
}
providers = gc_master_get_providers (GC_IFACE_ADDRESS,
priv->min_accuracy,
priv->require_updates,
priv->allowed_resources,
NULL);
g_debug ("client: %d address providers matching requirements found, now choosing current provider",
g_list_length (providers));
gc_master_provider_set_address_providers (client, providers);
gc_master_client_choose_address_provider (client, priv->address_providers);
priv->address_started = TRUE;
gc_master_client_init_address_providers (client);
return TRUE;
}
......@@ -777,9 +812,11 @@ gc_master_client_init (GcMasterClient *client)
priv->position_provider_choice_in_progress = FALSE;
priv->address_provider_choice_in_progress = FALSE;
priv->position_started = FALSE;
priv->position_provider = NULL;
priv->position_providers = NULL;
priv->address_started = FALSE;
priv->address_provider = NULL;
priv->address_providers = NULL;
}
......
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