1 /*
2     SPDX-FileCopyrightText: 2009 Andras Mantia <amantia@kde.org>
3 
4     SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "setacljob.h"
8 
9 #include <KLocalizedString>
10 
11 #include "acljobbase_p.h"
12 #include "response_p.h"
13 #include "rfccodecs.h"
14 #include "session_p.h"
15 
16 namespace KIMAP
17 {
18 class SetAclJobPrivate : public AclJobBasePrivate
19 {
20 public:
SetAclJobPrivate(Session * session,const QString & name)21     SetAclJobPrivate(Session *session, const QString &name)
22         : AclJobBasePrivate(session, name)
23     {
24     }
~SetAclJobPrivate()25     ~SetAclJobPrivate()
26     {
27     }
28 };
29 }
30 
31 using namespace KIMAP;
32 
SetAclJob(Session * session)33 SetAclJob::SetAclJob(Session *session)
34     : AclJobBase(*new SetAclJobPrivate(session, i18n("SetAcl")))
35 {
36 }
37 
~SetAclJob()38 SetAclJob::~SetAclJob()
39 {
40 }
41 
doStart()42 void SetAclJob::doStart()
43 {
44     Q_D(SetAclJob);
45     QByteArray r = Acl::rightsToString(d->rightList);
46     if (d->modifier == Add) {
47         r.prepend('+');
48     } else if (d->modifier == Remove) {
49         r.prepend('-');
50     }
51     d->tags << d->sessionInternal()->sendCommand("SETACL", '\"' + KIMAP::encodeImapFolderName(d->mailBox.toUtf8()) + "\" \"" + d->id + "\" \"" + r + '\"');
52 }
53 
setRights(AclModifier modifier,Acl::Rights rights)54 void SetAclJob::setRights(AclModifier modifier, Acl::Rights rights)
55 {
56     Q_D(SetAclJob);
57     d->setRights(modifier, rights);
58 }
59 
setIdentifier(const QByteArray & identifier)60 void SetAclJob::setIdentifier(const QByteArray &identifier)
61 {
62     Q_D(SetAclJob);
63     d->setIdentifier(identifier);
64 }
65 
identifier()66 QByteArray SetAclJob::identifier()
67 {
68     Q_D(SetAclJob);
69     return d->identifier();
70 }
71