summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>2016-02-10 16:20:34 +0000
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>2016-02-10 16:20:34 +0000
commitb6166f72a3d516396e366cab10aa6e8207ce9fec (patch)
tree0743288d552f830caaf81b9a68e5c53e9c7ca9ba
parent4546ebac129386cdd3dc96e17e1253d481ef7faf (diff)
downloadgeoclue-b6166f72a3d516396e366cab10aa6e8207ce9fec.tar.gz
service-client: Keep auth data around
Keep the finalized desktop ID and accuracy level around during the agent authorization process and use that.
-rw-r--r--src/gclue-service-client.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/src/gclue-service-client.c b/src/gclue-service-client.c
index 0cab947..68564c7 100644
--- a/src/gclue-service-client.c
+++ b/src/gclue-service-client.c
@@ -284,6 +284,8 @@ typedef struct
{
GClueServiceClient *client;
GDBusMethodInvocation *invocation;
+ char *desktop_id;
+ GClueAccuracyLevel accuracy_level;
} StartData;
static void
@@ -291,14 +293,15 @@ start_data_free (StartData *data)
{
g_object_unref (data->client);
g_object_unref (data->invocation);
+ g_free(data->desktop_id);
g_slice_free (StartData, data);
}
static void
-complete_start (StartData *data, GClueAccuracyLevel accuracy_level)
+complete_start (StartData *data)
{
GClueDBusClient *gdbus_client = GCLUE_DBUS_CLIENT (data->client);
- start_client (data->client, accuracy_level);
+ start_client (data->client, data->accuracy_level);
gclue_dbus_client_complete_start (gdbus_client,
data->invocation);
@@ -313,26 +316,20 @@ on_authorize_app_ready (GObject *source_object,
gpointer user_data)
{
StartData *data = (StartData *) user_data;
- GClueDBusClient *client = GCLUE_DBUS_CLIENT (data->client);
GClueServiceClientPrivate *priv = data->client->priv;
GError *error = NULL;
gboolean authorized = FALSE;
- GClueAccuracyLevel accuracy_level;
- accuracy_level = gclue_dbus_client_get_requested_accuracy_level
- (client);
if (!gclue_agent_call_authorize_app_finish (GCLUE_AGENT (source_object),
&authorized,
- &accuracy_level,
+ &data->accuracy_level,
res,
&error))
goto error_out;
if (!authorized) {
- const char *desktop_id;
guint32 uid;
- desktop_id = gclue_dbus_client_get_desktop_id (client);
uid = gclue_client_info_get_user_id (priv->client_info);
g_set_error (&error,
@@ -340,14 +337,14 @@ on_authorize_app_ready (GObject *source_object,
G_DBUS_ERROR_ACCESS_DENIED,
"Agent rejected '%s' for user '%u'. Please ensure "
"that '%s' has installed a valid %s.desktop file.",
- desktop_id,
+ data->desktop_id,
uid,
- desktop_id,
- desktop_id);
+ data->desktop_id,
+ data->desktop_id);
goto error_out;
}
- complete_start (data, accuracy_level);
+ complete_start (data);
return;
@@ -364,7 +361,7 @@ gclue_service_client_handle_start (GClueDBusClient *client,
GClueConfig *config;
StartData *data;
const char *desktop_id;
- GClueAccuracyLevel accuracy_level, max_accuracy;
+ GClueAccuracyLevel max_accuracy;
GClueAppPerm app_perm;
guint32 uid;
@@ -407,17 +404,18 @@ gclue_service_client_handle_start (GClueDBusClient *client,
data = g_slice_new (StartData);
data->client = g_object_ref (client);
data->invocation = g_object_ref (invocation);
+ data->desktop_id = g_strdup (desktop_id);
- accuracy_level = gclue_dbus_client_get_requested_accuracy_level (client);
- accuracy_level = CLAMP (accuracy_level,
- GCLUE_ACCURACY_LEVEL_COUNTRY,
- GCLUE_ACCURACY_LEVEL_EXACT);
+ data->accuracy_level = gclue_dbus_client_get_requested_accuracy_level (client);
+ data->accuracy_level = CLAMP (data->accuracy_level,
+ GCLUE_ACCURACY_LEVEL_COUNTRY,
+ GCLUE_ACCURACY_LEVEL_EXACT);
/* No agent == No authorization needed */
if (priv->agent_proxy == NULL ||
gclue_config_is_system_component (config, desktop_id) ||
app_perm == GCLUE_APP_PERM_ALLOWED) {
- complete_start (data, accuracy_level);
+ complete_start (data);
return TRUE;
}
@@ -439,12 +437,12 @@ gclue_service_client_handle_start (GClueDBusClient *client,
}
g_debug ("requested accuracy level: %u. "
"Max accuracy level allowed by agent: %u",
- accuracy_level, max_accuracy);
- accuracy_level = CLAMP (accuracy_level, 0, max_accuracy);
+ data->accuracy_level, max_accuracy);
+ data->accuracy_level = CLAMP (data->accuracy_level, 0, max_accuracy);
gclue_agent_call_authorize_app (priv->agent_proxy,
desktop_id,
- accuracy_level,
+ data->accuracy_level,
NULL,
on_authorize_app_ready,
data);