File indexing completed on 2024-05-12 05:17:15

0001 /*
0002     SPDX-FileCopyrightText: 2009 Andras Mantia <amantia@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "myrightsjob.h"
0008 
0009 #include <KLocalizedString>
0010 
0011 #include "acljobbase_p.h"
0012 #include "response_p.h"
0013 #include "rfccodecs.h"
0014 #include "session_p.h"
0015 
0016 namespace KIMAP
0017 {
0018 class MyRightsJobPrivate : public AclJobBasePrivate
0019 {
0020 public:
0021     MyRightsJobPrivate(Session *session, const QString &name)
0022         : AclJobBasePrivate(session, name)
0023         , myRights(Acl::None)
0024     {
0025     }
0026     ~MyRightsJobPrivate()
0027     {
0028     }
0029 
0030     Acl::Rights myRights;
0031 };
0032 }
0033 
0034 using namespace KIMAP;
0035 
0036 MyRightsJob::MyRightsJob(Session *session)
0037     : AclJobBase(*new MyRightsJobPrivate(session, i18n("MyRights")))
0038 {
0039 }
0040 
0041 MyRightsJob::~MyRightsJob()
0042 {
0043 }
0044 
0045 void MyRightsJob::doStart()
0046 {
0047     Q_D(MyRightsJob);
0048 
0049     d->tags << d->sessionInternal()->sendCommand("MYRIGHTS", '\"' + KIMAP::encodeImapFolderName(d->mailBox.toUtf8()) + '\"');
0050 }
0051 
0052 void MyRightsJob::handleResponse(const Response &response)
0053 {
0054     Q_D(MyRightsJob);
0055 
0056     if (handleErrorReplies(response) == NotHandled) {
0057         if (response.content.size() == 4 && response.content[1].toString() == "MYRIGHTS") {
0058             d->myRights = Acl::rightsFromString(response.content[3].toString());
0059         }
0060     }
0061 }
0062 
0063 bool MyRightsJob::hasRightEnabled(Acl::Right right)
0064 {
0065     Q_D(MyRightsJob);
0066     return d->myRights & right;
0067 }
0068 
0069 Acl::Rights MyRightsJob::rights()
0070 {
0071     Q_D(MyRightsJob);
0072     return d->myRights;
0073 }
0074 
0075 #include "moc_myrightsjob.cpp"