File indexing completed on 2024-05-12 05:17:12
0001 /* 0002 SPDX-FileCopyrightText: 2009 Kevin Ottens <ervin@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "capabilitiesjob.h" 0008 0009 #include <KLocalizedString> 0010 0011 #include "job_p.h" 0012 #include "response_p.h" 0013 #include "session_p.h" 0014 0015 namespace KIMAP 0016 { 0017 class CapabilitiesJobPrivate : public JobPrivate 0018 { 0019 public: 0020 CapabilitiesJobPrivate(Session *session, const QString &name) 0021 : JobPrivate(session, name) 0022 { 0023 } 0024 ~CapabilitiesJobPrivate() 0025 { 0026 } 0027 0028 QStringList capabilities; 0029 }; 0030 } 0031 0032 using namespace KIMAP; 0033 0034 CapabilitiesJob::CapabilitiesJob(Session *session) 0035 : Job(*new CapabilitiesJobPrivate(session, i18n("Capabilities"))) 0036 { 0037 } 0038 0039 CapabilitiesJob::~CapabilitiesJob() 0040 { 0041 } 0042 0043 QStringList CapabilitiesJob::capabilities() const 0044 { 0045 Q_D(const CapabilitiesJob); 0046 return d->capabilities; 0047 } 0048 0049 void CapabilitiesJob::doStart() 0050 { 0051 Q_D(CapabilitiesJob); 0052 d->tags << d->sessionInternal()->sendCommand("CAPABILITY"); 0053 } 0054 0055 void CapabilitiesJob::handleResponse(const Response &response) 0056 { 0057 Q_D(CapabilitiesJob); 0058 if (handleErrorReplies(response) == NotHandled) { 0059 const int responseSize(response.content.size()); 0060 if (responseSize >= 2 && response.content[1].toString() == "CAPABILITY") { 0061 for (int i = 2; i < responseSize; ++i) { 0062 d->capabilities << QLatin1StringView(response.content[i].toString().toUpper()); 0063 } 0064 Q_EMIT capabilitiesReceived(d->capabilities); 0065 } 0066 } 0067 } 0068 0069 #include "moc_capabilitiesjob.cpp"