static void shell_polkit_authentication_agent_init (ShellPolkitAuthenticationAgent *agent) { gpointer handle; PolkitSubject *subject; GError *error; subject = NULL; error = NULL; subject = polkit_unix_session_new_for_process_sync (getpid (), NULL, /* GCancellable* */ &error); if (subject == NULL) { g_warning ("Error getting session for the process we are in: %s (%s %d)", error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); goto out; } handle = polkit_agent_listener_register (POLKIT_AGENT_LISTENER (agent), POLKIT_AGENT_REGISTER_FLAGS_NONE, subject, NULL, /* use default object path */ NULL, /* GCancellable */ &error); if (handle == NULL) { g_warning ("Error registering polkit authentication agent: %s (%s %d)", error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); goto out; } /* We don't need to register so skip saving handle */ out: if (subject != NULL) g_object_unref (subject); }
PolkitAgentListener * polkit_mate_listener_new (void) { return POLKIT_AGENT_LISTENER (g_object_new (POLKIT_MATE_TYPE_LISTENER, NULL)); }