10#include "polkitqtlistener_p.h"
15#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
17using namespace PolkitQt1::Agent;
22struct _PolkitQtListener {
23 PolkitAgentListener parent_instance;
29struct _PolkitQtListenerClass {
30 PolkitAgentListenerClass parent_class;
33static void polkit_qt_listener_initiate_authentication(PolkitAgentListener *listener,
34 const gchar *action_id,
36 const gchar *icon_name,
37 PolkitDetails *details,
40 GCancellable *cancellable,
41 GAsyncReadyCallback callback,
44static gboolean polkit_qt_listener_initiate_authentication_finish(PolkitAgentListener *listener,
48G_DEFINE_TYPE(PolkitQtListener, polkit_qt_listener, POLKIT_AGENT_TYPE_LISTENER)
50static void polkit_qt_listener_init(PolkitQtListener *listener)
54static void polkit_qt_listener_finalize(GObject *
object)
56 PolkitQtListener *listener;
58 listener = POLKIT_QT_LISTENER(
object);
60 if (G_OBJECT_CLASS(polkit_qt_listener_parent_class)->finalize !=
nullptr) {
61 G_OBJECT_CLASS(polkit_qt_listener_parent_class)->finalize(
object);
65static void polkit_qt_listener_class_init(PolkitQtListenerClass *klass)
67 GObjectClass *gobject_class;
68 PolkitAgentListenerClass *listener_class;
70 gobject_class = G_OBJECT_CLASS(klass);
71 listener_class = POLKIT_AGENT_LISTENER_CLASS(klass);
73 gobject_class->finalize = polkit_qt_listener_finalize;
75 listener_class->initiate_authentication = polkit_qt_listener_initiate_authentication;
76 listener_class->initiate_authentication_finish = polkit_qt_listener_initiate_authentication_finish;
79PolkitAgentListener *polkit_qt_listener_new(
void)
81 return POLKIT_AGENT_LISTENER(g_object_new(POLKIT_QT_TYPE_LISTENER,
nullptr));
84static void cancelled_cb(GCancellable *cancellable, gpointer user_data)
86 ListenerAdapter::instance()->cancelled_cb((PolkitAgentListener *)user_data);
89static void polkit_qt_listener_initiate_authentication(PolkitAgentListener *agent_listener,
90 const gchar *action_id,
92 const gchar *icon_name,
93 PolkitDetails *details,
96 GCancellable *cancellable,
97 GAsyncReadyCallback callback,
100 qDebug() <<
"Listener adapter polkit_qt_listener_initiate_authentication";
101 PolkitQtListener *listener = POLKIT_QT_LISTENER(agent_listener);
103 if (cancellable !=
nullptr) {
104 g_cancellable_connect(cancellable,
105 G_CALLBACK(cancelled_cb),
111 GSimpleAsyncResult *result = g_simple_async_result_new((GObject *) listener, callback, user_data, agent_listener);
112 qDebug() <<
"GSimpleAsyncResult:" << result;
114 ListenerAdapter::instance()->polkit_qt_listener_initiate_authentication(agent_listener,
126static gboolean polkit_qt_listener_initiate_authentication_finish(PolkitAgentListener *listener,
130 qDebug() <<
"Listener adapter polkit_qt_listener_initiate_authentication_finish";
131 return ListenerAdapter::instance()->polkit_qt_listener_initiate_authentication_finish(listener,