Akonadi

collectionidentificationattribute.cpp
1 /*
2  Copyright (c) 2014 Christian Mollekopf <[email protected]>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "collectionidentificationattribute.h"
21 
22 #include <private/imapparser_p.h>
23 
24 #include <QByteArray>
25 #include <QList>
26 
27 using namespace Akonadi;
28 
29 class Q_DECL_HIDDEN CollectionIdentificationAttribute::Private
30 {
31 public:
32  Private()
33  {
34  }
35  QByteArray mFolderNamespace;
36  QByteArray mIdentifier;
37  QByteArray mName;
38  QByteArray mOrganizationUnit;
39  QByteArray mMail;
40 };
41 
42 CollectionIdentificationAttribute::CollectionIdentificationAttribute(const QByteArray &identifier, const QByteArray &folderNamespace,
43  const QByteArray &name, const QByteArray &organizationUnit, const QByteArray &mail)
44  : d(new Private)
45 {
46  d->mIdentifier = identifier;
47  d->mFolderNamespace = folderNamespace;
48  d->mName = name;
49  d->mOrganizationUnit = organizationUnit;
50  d->mMail = mail;
51 }
52 
53 CollectionIdentificationAttribute::~CollectionIdentificationAttribute()
54 {
55  delete d;
56 }
57 
59 {
60  d->mIdentifier = identifier;
61 }
62 
63 QByteArray CollectionIdentificationAttribute::identifier() const
64 {
65  return d->mIdentifier;
66 }
67 
68 void CollectionIdentificationAttribute::setMail(const QByteArray &mail)
69 {
70  d->mMail = mail;
71 }
72 
73 QByteArray CollectionIdentificationAttribute::mail() const
74 {
75  return d->mMail;
76 }
77 
78 void CollectionIdentificationAttribute::setOu(const QByteArray &ou)
79 {
80  d->mOrganizationUnit = ou;
81 }
82 
83 QByteArray CollectionIdentificationAttribute::ou() const
84 {
85  return d->mOrganizationUnit;
86 }
87 
88 void CollectionIdentificationAttribute::setName(const QByteArray &name)
89 {
90  d->mName = name;
91 }
92 
93 QByteArray CollectionIdentificationAttribute::name() const
94 {
95  return d->mName;
96 }
97 
99 {
100  d->mFolderNamespace = ns;
101 }
102 
103 QByteArray CollectionIdentificationAttribute::collectionNamespace() const
104 {
105  return d->mFolderNamespace;
106 }
107 
109 {
110  return QByteArrayLiteral("collectionidentification");
111 }
112 
114 {
115  return new CollectionIdentificationAttribute(d->mIdentifier, d->mFolderNamespace, d->mName, d->mOrganizationUnit, d->mMail);
116 }
117 
119 {
121  l << Akonadi::ImapParser::quote(d->mIdentifier);
122  l << Akonadi::ImapParser::quote(d->mFolderNamespace);
123  l << Akonadi::ImapParser::quote(d->mName);
124  l << Akonadi::ImapParser::quote(d->mOrganizationUnit);
125  l << Akonadi::ImapParser::quote(d->mMail);
126  return '(' + Akonadi::ImapParser::join(l, " ") + ')';
127 }
128 
130 {
132  Akonadi::ImapParser::parseParenthesizedList(data, l);
133  const int size = l.size();
134  Q_ASSERT(size >= 2);
135  if (size < 2) {
136  return;
137  }
138  d->mIdentifier = l[0];
139  d->mFolderNamespace = l[1];
140 
141  if (size == 5) {
142  d->mName = l[2];
143  d->mOrganizationUnit = l[3];
144  d->mMail = l[4];
145  }
146 }
147 
void setCollectionNamespace(const QByteArray &ns)
Sets a namespace the collection is in.
Provides interface for custom attributes for Entity.
Definition: attribute.h:139
int size() const const
void deserialize(const QByteArray &data) override
Sets the data of this attribute, using the same encoding as returned by toByteArray().
Attribute that stores additional information on a collection that can be used for searching...
void setIdentifier(const QByteArray &identifier)
Sets an identifier for the collection.
Attribute * clone() const override
Creates a copy of this attribute.
QByteArray type() const override
Returns the type of the attribute.
Helper integration between Akonadi and Qt.
QByteArray serialized() const override
Returns a QByteArray representation of the attribute which will be storaged.
virtual QVariant data(const QModelIndex &index, int role) const const override
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jun 5 2020 23:08:54 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.