summaryrefslogtreecommitdiff
path: root/clients/cli/polkit-agent.c
diff options
context:
space:
mode:
Diffstat (limited to 'clients/cli/polkit-agent.c')
-rw-r--r--clients/cli/polkit-agent.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/clients/cli/polkit-agent.c b/clients/cli/polkit-agent.c
index ce11a68635..338f0b15e9 100644
--- a/clients/cli/polkit-agent.c
+++ b/clients/cli/polkit-agent.c
@@ -31,7 +31,8 @@
#if WITH_POLKIT_AGENT
static char *
-polkit_request (const char *request,
+polkit_request (NMPolkitListener *listener,
+ const char *request,
const char *action_id,
const char *message,
const char *icon_name,
@@ -60,19 +61,25 @@ polkit_request (const char *request,
}
static void
-polkit_show_info (const char *text)
+polkit_show_info (NMPolkitListener *listener,
+ const char *text,
+ gpointer user_data)
{
g_print (_("Authentication message: %s\n"), text);
}
static void
-polkit_show_error (const char *text)
+polkit_show_error (NMPolkitListener *listener,
+ const char *text,
+ gpointer user_data)
{
g_print (_("Authentication error: %s\n"), text);
}
static void
-polkit_completed (gboolean gained_authorization)
+polkit_completed (NMPolkitListener *listener,
+ gboolean gained_authorization,
+ gpointer user_data)
{
/* We don't print anything here. The outcome will be evident from
* the operation result anyway. */
@@ -83,7 +90,13 @@ gboolean
nmc_polkit_agent_init (NmCli* nmc, gboolean for_session, GError **error)
{
#if WITH_POLKIT_AGENT
- PolkitAgentListener *listener;
+ static const NMPolkitListenVtable vtable = {
+ .on_request = polkit_request,
+ .on_show_info = polkit_show_info,
+ .on_show_error = polkit_show_error,
+ .on_completed = polkit_completed,
+ };
+ NMPolkitListener *listener;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -91,12 +104,9 @@ nmc_polkit_agent_init (NmCli* nmc, gboolean for_session, GError **error)
if (!listener)
return FALSE;
- nm_polkit_listener_set_request_callback (NM_POLKIT_LISTENER (listener), polkit_request, nmc);
- nm_polkit_listener_set_show_info_callback (NM_POLKIT_LISTENER (listener), polkit_show_info);
- nm_polkit_listener_set_show_error_callback (NM_POLKIT_LISTENER (listener), polkit_show_error);
- nm_polkit_listener_set_completed_callback (NM_POLKIT_LISTENER (listener), polkit_completed);
+ nm_polkit_listener_set_vtable (listener, &vtable, nmc);
- nmc->pk_listener = NM_POLKIT_LISTENER (listener);
+ nmc->pk_listener = listener;
#endif
return TRUE;
}
@@ -105,7 +115,10 @@ void
nmc_polkit_agent_fini (NmCli* nmc)
{
#if WITH_POLKIT_AGENT
- g_clear_object (&nmc->pk_listener);
+ if (nmc->pk_listener) {
+ nm_polkit_listener_set_vtable (nmc->pk_listener, NULL, NULL);
+ g_clear_object (&nmc->pk_listener);
+ }
#endif
}