KIMAP

myrightsjob.cpp
1 /*
2  SPDX-FileCopyrightText: 2009 Andras Mantia <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "myrightsjob.h"
8 
9 #include <KLocalizedString>
10 
11 #include "acljobbase_p.h"
12 #include "response_p.h"
13 #include "session_p.h"
14 #include "rfccodecs.h"
15 
16 namespace KIMAP
17 {
18 class MyRightsJobPrivate : public AclJobBasePrivate
19 {
20 public:
21  MyRightsJobPrivate(Session *session, const QString &name) : AclJobBasePrivate(session, name), myRights(Acl::None) {}
22  ~MyRightsJobPrivate() { }
23 
24  Acl::Rights myRights;
25 };
26 }
27 
28 using namespace KIMAP;
29 
30 MyRightsJob::MyRightsJob(Session *session)
31  : AclJobBase(*new MyRightsJobPrivate(session, i18n("MyRights")))
32 {
33 }
34 
35 MyRightsJob::~MyRightsJob()
36 {
37 }
38 
39 void MyRightsJob::doStart()
40 {
41  Q_D(MyRightsJob);
42 
43  d->tags << d->sessionInternal()->sendCommand("MYRIGHTS", '\"' + KIMAP::encodeImapFolderName(d->mailBox.toUtf8()) + '\"');
44 }
45 
46 void MyRightsJob::handleResponse(const Response &response)
47 {
48  Q_D(MyRightsJob);
49 
50  if (handleErrorReplies(response) == NotHandled) {
51  if (response.content.size() == 4 &&
52  response.content[1].toString() == "MYRIGHTS") {
53  d->myRights = Acl::rightsFromString(response.content[3].toString());
54  }
55  }
56 }
57 
59 {
60  Q_D(MyRightsJob);
61  return d->myRights & right;
62 }
63 
65 {
66  Q_D(MyRightsJob);
67  return d->myRights;
68 }
This file is part of the IMAP support library and defines the RfcCodecs class.
bool hasRightEnabled(Acl::Right right)
Check whether the current user has the a particular right on the mailbox.
Definition: myrightsjob.cpp:58
Acl::Rights rights()
Get the rights for the current user on the mailbox.
Definition: myrightsjob.cpp:64
Right
Possible rights that can be held on a mailbox.
Definition: acl.h:26
Determine the rights the currently-logged-in user has on the current mailbox.
Definition: myrightsjob.h:44
QString i18n(const char *text, const TYPE &arg...)
KIMAP_EXPORT Rights rightsFromString(const QByteArray &string)
Convert the text form of a set of rights into a Rights bitflag.
Definition: acl.cpp:56
Definition: acl.cpp:12
Base class for jobs that operate on mailbox ACLs.
Definition: acljobbase.h:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Oct 24 2020 23:16:51 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.