Port polkit agent to GTask
This commit is contained in:
parent
bf0be6ef12
commit
8b4249ef26
@ -201,7 +201,7 @@ struct _AuthRequest {
|
|||||||
gchar *cookie;
|
gchar *cookie;
|
||||||
GList *identities;
|
GList *identities;
|
||||||
|
|
||||||
GSimpleAsyncResult *simple;
|
GTask *simple;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -338,30 +338,28 @@ auth_request_complete (AuthRequest *request,
|
|||||||
gboolean dismissed)
|
gboolean dismissed)
|
||||||
{
|
{
|
||||||
ShellPolkitAuthenticationAgent *agent = request->agent;
|
ShellPolkitAuthenticationAgent *agent = request->agent;
|
||||||
|
gboolean is_current = agent->current_request == request;
|
||||||
|
|
||||||
|
print_debug ("COMPLETING %s %s cookie %s", is_current ? "CURRENT" : "SCHEDULED",
|
||||||
|
request->action_id, request->cookie);
|
||||||
|
|
||||||
|
if (!is_current)
|
||||||
|
agent->scheduled_requests = g_list_remove (agent->scheduled_requests, request);
|
||||||
|
|
||||||
if (dismissed)
|
if (dismissed)
|
||||||
g_simple_async_result_set_error (request->simple,
|
g_task_return_new_error (request->simple,
|
||||||
POLKIT_ERROR,
|
POLKIT_ERROR,
|
||||||
POLKIT_ERROR_CANCELLED,
|
POLKIT_ERROR_CANCELLED,
|
||||||
_("Authentication dialog was dismissed by the user"));
|
_("Authentication dialog was dismissed by the user"));
|
||||||
|
|
||||||
if (agent->current_request == request)
|
|
||||||
{
|
|
||||||
print_debug ("COMPLETING CURRENT %s cookie %s", request->action_id, request->cookie);
|
|
||||||
|
|
||||||
g_simple_async_result_complete_in_idle (request->simple);
|
|
||||||
auth_request_free (request);
|
|
||||||
|
|
||||||
agent->current_request = NULL;
|
|
||||||
|
|
||||||
maybe_process_next_request (agent);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
g_task_return_boolean (request->simple, TRUE);
|
||||||
|
|
||||||
|
auth_request_free (request);
|
||||||
|
|
||||||
|
if (is_current)
|
||||||
{
|
{
|
||||||
print_debug ("COMPLETING SCHEDULED %s cookie %s", request->action_id, request->cookie);
|
agent->current_request = NULL;
|
||||||
agent->scheduled_requests = g_list_remove (agent->scheduled_requests, request);
|
maybe_process_next_request (agent);
|
||||||
g_simple_async_result_complete_in_idle (request->simple);
|
|
||||||
auth_request_free (request);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,10 +406,7 @@ initiate_authentication (PolkitAgentListener *listener,
|
|||||||
request->cookie = g_strdup (cookie);
|
request->cookie = g_strdup (cookie);
|
||||||
request->identities = g_list_copy (identities);
|
request->identities = g_list_copy (identities);
|
||||||
g_list_foreach (request->identities, (GFunc) g_object_ref, NULL);
|
g_list_foreach (request->identities, (GFunc) g_object_ref, NULL);
|
||||||
request->simple = g_simple_async_result_new (G_OBJECT (listener),
|
request->simple = g_task_new (listener, NULL, callback, user_data);
|
||||||
callback,
|
|
||||||
user_data,
|
|
||||||
initiate_authentication);
|
|
||||||
request->cancellable = cancellable;
|
request->cancellable = cancellable;
|
||||||
request->handler_id = g_cancellable_connect (request->cancellable,
|
request->handler_id = g_cancellable_connect (request->cancellable,
|
||||||
G_CALLBACK (on_request_cancelled),
|
G_CALLBACK (on_request_cancelled),
|
||||||
@ -429,11 +424,7 @@ initiate_authentication_finish (PolkitAgentListener *listener,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
|
return g_task_propagate_boolean (G_TASK (res), error);
|
||||||
if (g_simple_async_result_propagate_error (simple, error))
|
|
||||||
return FALSE;
|
|
||||||
else
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user