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 "rfccodecs.h"
14 #include "session_p.h"
15 
16 namespace KIMAP
17 {
18 class MyRightsJobPrivate : public AclJobBasePrivate
19 {
20 public:
21  MyRightsJobPrivate(Session *session, const QString &name)
22  : AclJobBasePrivate(session, name)
23  , myRights(Acl::None)
24  {
25  }
26  ~MyRightsJobPrivate()
27  {
28  }
29 
30  Acl::Rights myRights;
31 };
32 }
33 
34 using namespace KIMAP;
35 
36 MyRightsJob::MyRightsJob(Session *session)
37  : AclJobBase(*new MyRightsJobPrivate(session, i18n("MyRights")))
38 {
39 }
40 
41 MyRightsJob::~MyRightsJob()
42 {
43 }
44 
45 void MyRightsJob::doStart()
46 {
48 
49  d->tags << d->sessionInternal()->sendCommand("MYRIGHTS", '\"' + KIMAP::encodeImapFolderName(d->mailBox.toUtf8()) + '\"');
50 }
51 
52 void MyRightsJob::handleResponse(const Response &response)
53 {
55 
56  if (handleErrorReplies(response) == NotHandled) {
57  if (response.content.size() == 4 && response.content[1].toString() == "MYRIGHTS") {
58  d->myRights = Acl::rightsFromString(response.content[3].toString());
59  }
60  }
61 }
62 
64 {
66  return d->myRights & right;
67 }
68 
70 {
72  return d->myRights;
73 }
74 
75 #include "moc_myrightsjob.cpp"
Right
Possible rights that can be held on a mailbox.
Definition: acl.h:23
Base class for jobs that operate on mailbox ACLs.
Definition: acljobbase.h:29
KIMAP_EXPORT Rights rightsFromString(const QByteArray &string)
Convert the text form of a set of rights into a Rights bitflag.
Definition: acl.cpp:55
QString i18n(const char *text, const TYPE &arg...)
Acl::Rights rights()
Get the rights for the current user on the mailbox.
Definition: myrightsjob.cpp:69
bool hasRightEnabled(Acl::Right right)
Check whether the current user has the a particular right on the mailbox.
Definition: myrightsjob.cpp:63
const char * name(StandardAction id)
Determine the rights the currently-logged-in user has on the current mailbox.
Definition: myrightsjob.h:42
Provides handlers for various RFC/MIME encodings.
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 03:51:44 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.