File indexing completed on 2024-12-22 05:01:15
0001 /* 0002 SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "kmailsieveimapinstanceinterface.h" 0008 #include <Akonadi/AgentInstance> 0009 #include <Akonadi/AgentManager> 0010 #include <KSieveCore/SieveImapInstance> 0011 0012 KMailSieveImapInstanceInterface::KMailSieveImapInstanceInterface() = default; 0013 0014 QList<KSieveCore::SieveImapInstance> KMailSieveImapInstanceInterface::sieveImapInstances() 0015 { 0016 QList<KSieveCore::SieveImapInstance> listInstance; 0017 0018 const Akonadi::AgentInstance::List allInstances = Akonadi::AgentManager::self()->instances(); 0019 listInstance.reserve(allInstances.count()); 0020 for (const Akonadi::AgentInstance &instance : allInstances) { 0021 KSieveCore::SieveImapInstance sieveInstance; 0022 sieveInstance.setCapabilities(instance.type().capabilities()); 0023 sieveInstance.setIdentifier(instance.identifier()); 0024 sieveInstance.setMimeTypes(instance.type().mimeTypes()); 0025 sieveInstance.setName(instance.name()); 0026 switch (instance.status()) { 0027 case Akonadi::AgentInstance::Idle: 0028 sieveInstance.setStatus(KSieveCore::SieveImapInstance::Idle); 0029 break; 0030 case Akonadi::AgentInstance::Running: 0031 sieveInstance.setStatus(KSieveCore::SieveImapInstance::Running); 0032 break; 0033 case Akonadi::AgentInstance::Broken: 0034 sieveInstance.setStatus(KSieveCore::SieveImapInstance::Broken); 0035 break; 0036 case Akonadi::AgentInstance::NotConfigured: 0037 sieveInstance.setStatus(KSieveCore::SieveImapInstance::NotConfigured); 0038 break; 0039 } 0040 listInstance.append(sieveInstance); 0041 } 0042 return listInstance; 0043 }