Akonadi

collectionidentificationattribute.cpp
1 /*
2  SPDX-FileCopyrightText: 2014 Christian Mollekopf <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "collectionidentificationattribute.h"
8 
9 #include <private/imapparser_p.h>
10 
11 #include <QByteArray>
12 #include <QList>
13 
14 using namespace Akonadi;
15 
16 class Akonadi::CollectionIdentificationAttributePrivate
17 {
18 public:
19  QByteArray mFolderNamespace;
20  QByteArray mIdentifier;
21  QByteArray mName;
22  QByteArray mOrganizationUnit;
23  QByteArray mMail;
24 };
25 
26 CollectionIdentificationAttribute::CollectionIdentificationAttribute(const QByteArray &identifier,
27  const QByteArray &folderNamespace,
28  const QByteArray &name,
29  const QByteArray &organizationUnit,
30  const QByteArray &mail)
31  : d(new CollectionIdentificationAttributePrivate())
32 {
33  d->mIdentifier = identifier;
34  d->mFolderNamespace = folderNamespace;
35  d->mName = name;
36  d->mOrganizationUnit = organizationUnit;
37  d->mMail = mail;
38 }
39 
40 CollectionIdentificationAttribute::~CollectionIdentificationAttribute() = default;
41 
43 {
44  d->mIdentifier = identifier;
45 }
46 
47 QByteArray CollectionIdentificationAttribute::identifier() const
48 {
49  return d->mIdentifier;
50 }
51 
52 void CollectionIdentificationAttribute::setMail(const QByteArray &mail)
53 {
54  d->mMail = mail;
55 }
56 
57 QByteArray CollectionIdentificationAttribute::mail() const
58 {
59  return d->mMail;
60 }
61 
62 void CollectionIdentificationAttribute::setOu(const QByteArray &ou)
63 {
64  d->mOrganizationUnit = ou;
65 }
66 
67 QByteArray CollectionIdentificationAttribute::ou() const
68 {
69  return d->mOrganizationUnit;
70 }
71 
72 void CollectionIdentificationAttribute::setName(const QByteArray &name)
73 {
74  d->mName = name;
75 }
76 
77 QByteArray CollectionIdentificationAttribute::name() const
78 {
79  return d->mName;
80 }
81 
83 {
84  d->mFolderNamespace = ns;
85 }
86 
87 QByteArray CollectionIdentificationAttribute::collectionNamespace() const
88 {
89  return d->mFolderNamespace;
90 }
91 
93 {
94  return QByteArrayLiteral("collectionidentification");
95 }
96 
98 {
99  return new CollectionIdentificationAttribute(d->mIdentifier, d->mFolderNamespace, d->mName, d->mOrganizationUnit, d->mMail);
100 }
101 
103 {
105  l << Akonadi::ImapParser::quote(d->mIdentifier);
106  l << Akonadi::ImapParser::quote(d->mFolderNamespace);
107  l << Akonadi::ImapParser::quote(d->mName);
108  l << Akonadi::ImapParser::quote(d->mOrganizationUnit);
109  l << Akonadi::ImapParser::quote(d->mMail);
110  return '(' + Akonadi::ImapParser::join(l, " ") + ')';
111 }
112 
114 {
116  Akonadi::ImapParser::parseParenthesizedList(data, l);
117  const int size = l.size();
118  Q_ASSERT(size >= 2);
119  if (size < 2) {
120  return;
121  }
122  d->mIdentifier = l[0];
123  d->mFolderNamespace = l[1];
124 
125  if (size == 5) {
126  d->mName = l[2];
127  d->mOrganizationUnit = l[3];
128  d->mMail = l[4];
129  }
130 }
void deserialize(const QByteArray &data) override
Sets the data of this attribute, using the same encoding as returned by toByteArray().
QByteArray type() const override
Returns the type of the attribute.
void setIdentifier(const QByteArray &identifier)
Sets an identifier for the collection.
QAction * mail(const QObject *recvr, const char *slot, QObject *parent)
Provides interface for custom attributes for Entity.
Definition: attribute.h:124
int size() const const
QByteArray serialized() const override
Returns a QByteArray representation of the attribute which will be storaged.
void setCollectionNamespace(const QByteArray &ns)
Sets a namespace the collection is in.
Attribute that stores additional information on a collection that can be used for searching.
QString name(StandardShortcut id)
Attribute * clone() const override
Creates a copy of this attribute.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jun 30 2022 03:51:45 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.