File indexing completed on 2025-01-26 04:52:16
0001 /* 0002 * SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "ldapsearchclientreadconfigserverjob.h" 0008 #include "ldapclient.h" 0009 #include "ldapclient_debug.h" 0010 #include "ldapclientsearchconfigreadconfigjob.h" 0011 using namespace KLDAPCore; 0012 using namespace KLDAPWidgets; 0013 LdapSearchClientReadConfigServerJob::LdapSearchClientReadConfigServerJob(QObject *parent) 0014 : QObject(parent) 0015 { 0016 } 0017 0018 LdapSearchClientReadConfigServerJob::~LdapSearchClientReadConfigServerJob() = default; 0019 0020 void LdapSearchClientReadConfigServerJob::start() 0021 { 0022 if (!canStart()) { 0023 qCWarning(LDAPCLIENT_LOG) << " Impossible to start LdapSearchClientReadConfigServerJob"; 0024 deleteLater(); 0025 return; 0026 } 0027 auto job = new LdapClientSearchConfigReadConfigJob(this); 0028 connect(job, &LdapClientSearchConfigReadConfigJob::configLoaded, this, &LdapSearchClientReadConfigServerJob::slotConfigLoaded); 0029 job->setActive(mActive); 0030 job->setConfig(mConfig); 0031 job->setServerIndex(mCurrentIndex); 0032 job->start(); 0033 } 0034 0035 bool LdapSearchClientReadConfigServerJob::canStart() const 0036 { 0037 return mCurrentIndex != -1 && mConfig.isValid(); 0038 } 0039 0040 void LdapSearchClientReadConfigServerJob::slotConfigLoaded(const KLDAPCore::LdapServer &server) 0041 { 0042 mLdapClient->setServer(server); 0043 deleteLater(); 0044 } 0045 0046 LdapClient *LdapSearchClientReadConfigServerJob::ldapClient() const 0047 { 0048 return mLdapClient; 0049 } 0050 0051 void LdapSearchClientReadConfigServerJob::setLdapClient(LdapClient *ldapClient) 0052 { 0053 mLdapClient = ldapClient; 0054 } 0055 0056 int LdapSearchClientReadConfigServerJob::currentIndex() const 0057 { 0058 return mCurrentIndex; 0059 } 0060 0061 void LdapSearchClientReadConfigServerJob::setCurrentIndex(int currentIndex) 0062 { 0063 mCurrentIndex = currentIndex; 0064 } 0065 0066 bool LdapSearchClientReadConfigServerJob::active() const 0067 { 0068 return mActive; 0069 } 0070 0071 void LdapSearchClientReadConfigServerJob::setActive(bool active) 0072 { 0073 mActive = active; 0074 } 0075 0076 KConfigGroup LdapSearchClientReadConfigServerJob::config() const 0077 { 0078 return mConfig; 0079 } 0080 0081 void LdapSearchClientReadConfigServerJob::setConfig(const KConfigGroup &config) 0082 { 0083 mConfig = config; 0084 } 0085 0086 #include "moc_ldapsearchclientreadconfigserverjob.cpp"