Warning, file /frameworks/kauth/autotests/BackendsManager.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2012 Dario Freddi <drf@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #include "BackendsManager.h" 0008 0009 #include "BackendsConfig.h" 0010 0011 // Include backends directly 0012 #include "TestBackend.h" 0013 #include "backends/dbus/DBusHelperProxy.h" 0014 0015 #include <QDebug> 0016 #include <QDir> 0017 #include <QPluginLoader> 0018 #include <QThread> 0019 0020 namespace KAuth 0021 { 0022 AuthBackend *BackendsManager::auth = nullptr; 0023 QHash<QThread *, HelperProxy *> proxiesForThreads = QHash<QThread *, HelperProxy *>(); 0024 0025 BackendsManager::BackendsManager() 0026 { 0027 } 0028 0029 void BackendsManager::init() 0030 { 0031 if (!auth) { 0032 // Load the test backend 0033 auth = new TestBackend; 0034 } 0035 0036 if (!proxiesForThreads.contains(QThread::currentThread())) { 0037 // Load the test helper backend 0038 proxiesForThreads.insert(QThread::currentThread(), new DBusHelperProxy(QDBusConnection::sessionBus())); 0039 } 0040 } 0041 0042 AuthBackend *BackendsManager::authBackend() 0043 { 0044 if (!auth) { 0045 init(); 0046 } 0047 0048 return auth; 0049 } 0050 0051 HelperProxy *BackendsManager::helperProxy() 0052 { 0053 if (!proxiesForThreads.contains(QThread::currentThread())) { 0054 qDebug() << "Creating new proxy for thread" << QThread::currentThread(); 0055 init(); 0056 } 0057 0058 return proxiesForThreads[QThread::currentThread()]; 0059 } 0060 0061 void BackendsManager::setProxyForThread(QThread *thread, HelperProxy *proxy) 0062 { 0063 qDebug() << "Adding proxy for thread" << thread; 0064 0065 proxiesForThreads.insert(thread, proxy); 0066 } 0067 0068 } // namespace Auth