KDECore
BackendsManager.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "BackendsManager.h"
00021
00022 #include <QPluginLoader>
00023
00024 #ifndef KDE_USE_FINAL
00025 Q_IMPORT_PLUGIN(auth_backend)
00026 Q_IMPORT_PLUGIN(helper_proxy)
00027 #endif
00028 namespace KAuth
00029 {
00030
00031 AuthBackend *BackendsManager::auth = NULL;
00032 HelperProxy *BackendsManager::helper = NULL;
00033
00034 BackendsManager::BackendsManager()
00035 {
00036 }
00037
00038 void BackendsManager::init()
00039 {
00040 QObjectList l = QPluginLoader::staticInstances();
00041 foreach(QObject *o, l) {
00042 AuthBackend *a = qobject_cast<AuthBackend *>(o);
00043 if (a) {
00044 auth = a;
00045 }
00046 HelperProxy *h = qobject_cast<HelperProxy *>(o);
00047 if (h) {
00048 helper = h;
00049 }
00050 }
00051
00052 Q_ASSERT_X(auth, __FUNCTION__, "No AuthBackend found.");
00053 Q_ASSERT_X(helper, __FUNCTION__, "No HelperBackend found.");
00054 }
00055
00056 AuthBackend *BackendsManager::authBackend()
00057 {
00058 if (!auth) {
00059 init();
00060 }
00061
00062 return auth;
00063 }
00064
00065 HelperProxy *BackendsManager::helperProxy()
00066 {
00067 if (!helper) {
00068 init();
00069 }
00070
00071 return helper;
00072 }
00073
00074 }