8#include "listeneradapter_p.h"
10#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
11#include <polkitagent/polkitagent.h>
19class ListenerAdapterHelper
22 ListenerAdapterHelper() : q(nullptr) {}
23 ~ListenerAdapterHelper() {
29Q_GLOBAL_STATIC(ListenerAdapterHelper, s_globalListenerAdapter)
31ListenerAdapter *ListenerAdapter::instance()
33 if (!s_globalListenerAdapter()->q) {
34 new ListenerAdapter();
37 return s_globalListenerAdapter()->q;
40ListenerAdapter::ListenerAdapter(
QObject *parent)
43 Q_ASSERT(!s_globalListenerAdapter()->q);
44 s_globalListenerAdapter()->q =
this;
47Listener* ListenerAdapter::findListener(PolkitAgentListener *listener)
51 Q_FOREACH(listItem, m_listeners) {
54 if (listItem->listener() == listener) {
62void ListenerAdapter::polkit_qt_listener_initiate_authentication(PolkitAgentListener *listener,
63 const gchar *action_id,
65 const gchar *icon_name,
66 PolkitDetails *details,
69 GCancellable *cancellable,
70 GSimpleAsyncResult *result)
72 qDebug() <<
"polkit_qt_listener_initiate_authentication callback for " << listener;
77 Listener *
list = findListener(listener);
79 for (GList *identity = g_list_first(identities); identity !=
nullptr; identity = g_list_next(identity)) {
89 new AsyncResult(result));
92gboolean ListenerAdapter::polkit_qt_listener_initiate_authentication_finish(PolkitAgentListener *listener,
96 qDebug() <<
"polkit_qt_listener_initiate_authentication_finish callback for " << listener;
98 GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT(res);
99 if (g_simple_async_result_propagate_error(simple, error)) {
105void ListenerAdapter::cancelled_cb(PolkitAgentListener *listener)
107 qDebug() <<
"cancelled_cb for " << listener;
109 Listener *
list = findListener(listener);
111 list->cancelAuthentication();
114void ListenerAdapter::addListener(Listener *listener)
116 qDebug() <<
"Adding new listener " << listener <<
"for " << listener->listener();
118 m_listeners.
append(listener);
121void ListenerAdapter::removeListener(Listener *listener)
123 qDebug() <<
"Removing listener " << listener;
126 m_listeners.removeOne(listener);
Class used for passing details around.
Abstract class representing identities.
KIOCORE_EXPORT QStringList list(const QString &fileClass)
void append(QList< T > &&value)
QString fromUtf8(QByteArrayView str)