• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • sources
  • kde-4.14
  • kdepimlibs
  • akonadi
entitydeletedattribute.cpp
1 /*
2  Copyright (c) 2011 Christian Mollekopf <chrigi_1@fastmail.fm>
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 "entitydeletedattribute.h"
21 
22 #include "imapparser_p.h"
23 
24 #include <QtCore/QByteArray>
25 #include <QtCore/QString>
26 
27 using namespace Akonadi;
28 
29 class EntityDeletedAttribute::EntityDeletedAttributePrivate
30 {
31 public:
32  EntityDeletedAttributePrivate() {};
33 
34  Collection restoreCollection;
35  QString restoreResource;
36 };
37 
38 EntityDeletedAttribute::EntityDeletedAttribute()
39  : d_ptr(new EntityDeletedAttributePrivate())
40 {
41 
42 }
43 
44 EntityDeletedAttribute::~EntityDeletedAttribute()
45 {
46  delete d_ptr;
47 }
48 
49 void EntityDeletedAttribute::setRestoreCollection(const Akonadi::Collection &collection)
50 {
51  Q_D(EntityDeletedAttribute);
52  if (!collection.isValid()) {
53  kWarning() << "invalid collection" << collection;
54  }
55  Q_ASSERT(collection.isValid());
56  d->restoreCollection = collection;
57  if (collection.resource().isEmpty()) {
58  kWarning() << "no resource set";
59  }
60  d->restoreResource = collection.resource();
61 }
62 
63 Collection EntityDeletedAttribute::restoreCollection() const
64 {
65  Q_D(const EntityDeletedAttribute);
66  return d->restoreCollection;
67 }
68 
69 QString EntityDeletedAttribute::restoreResource() const
70 {
71  Q_D(const EntityDeletedAttribute);
72  return d->restoreResource;
73 }
74 
75 QByteArray Akonadi::EntityDeletedAttribute::type() const
76 {
77  static const QByteArray sType( "DELETED" );
78  return sType;
79 }
80 
81 EntityDeletedAttribute *EntityDeletedAttribute::clone() const
82 {
83  const Q_D(EntityDeletedAttribute);
84  EntityDeletedAttribute *attr = new EntityDeletedAttribute();
85  attr->d_ptr->restoreCollection = d->restoreCollection;
86  attr->d_ptr->restoreResource = d->restoreResource;
87  return attr;
88 }
89 
90 QByteArray EntityDeletedAttribute::serialized() const
91 {
92  const Q_D(EntityDeletedAttribute);
93 
94  QList<QByteArray> l;
95  l << ImapParser::quote(d->restoreResource.toUtf8());
96  QList<QByteArray> components;
97  components << QByteArray::number(d->restoreCollection.id());
98 
99  l << '(' + ImapParser::join(components, " ") + ')';
100  return '(' + ImapParser::join(l, " ") + ')';
101 }
102 
103 void EntityDeletedAttribute::deserialize(const QByteArray &data)
104 {
105  Q_D(EntityDeletedAttribute);
106 
107  QList<QByteArray> l;
108  ImapParser::parseParenthesizedList(data, l);
109  if (l.size() != 2) {
110  kWarning() << "invalid size";
111  return;
112  }
113  d->restoreResource = QString::fromUtf8(l[0]);
114 
115  if (!l[1].isEmpty()) {
116  QList<QByteArray> componentData;
117  ImapParser::parseParenthesizedList(l[1], componentData);
118  if (componentData.size() != 1) {
119  return;
120  }
121  QList<int> components;
122  bool ok;
123  for (int i = 0; i < 1; ++i) {
124  components << componentData.at(i).toInt(&ok);
125  if (!ok) {
126  return;
127  }
128  }
129  d->restoreCollection = Collection(components.at(0));
130  }
131 }
Akonadi::EntityDeletedAttribute::EntityDeletedAttribute
EntityDeletedAttribute()
Creates a new entity deleted attribute.
Definition: entitydeletedattribute.cpp:38
Akonadi::EntityDeletedAttribute::restoreCollection
Collection restoreCollection() const
Returns the original collection of an item that has been moved to trash using a TrashJob.
Definition: entitydeletedattribute.cpp:63
QByteArray
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
QList::at
const T & at(int i) const
QList::size
int size() const
QString::fromUtf8
QString fromUtf8(const char *str, int size)
Akonadi::EntityDeletedAttribute::deserialize
void deserialize(const QByteArray &data)
Reimplemented from Attribute.
Definition: entitydeletedattribute.cpp:103
QString::isEmpty
bool isEmpty() const
QByteArray::number
QByteArray number(int n, int base)
Akonadi::EntityDeletedAttribute::type
QByteArray type() const
Reimplemented from Attribute.
Definition: entitydeletedattribute.cpp:75
QString
QList< QByteArray >
Akonadi::EntityDeletedAttribute::clone
EntityDeletedAttribute * clone() const
Reimplemented from Attribute.
Definition: entitydeletedattribute.cpp:81
Akonadi::EntityDeletedAttribute
An Attribute that marks that an entity was marked as deleted.
Definition: entitydeletedattribute.h:49
Akonadi::EntityDeletedAttribute::restoreResource
QString restoreResource() const
Returns the resource of the restoreCollection.
Definition: entitydeletedattribute.cpp:69
Akonadi::EntityDeletedAttribute::serialized
QByteArray serialized() const
Reimplemented from Attribute.
Definition: entitydeletedattribute.cpp:90
Akonadi::EntityDeletedAttribute::~EntityDeletedAttribute
~EntityDeletedAttribute()
Destroys the entity deleted attribute.
Definition: entitydeletedattribute.cpp:44
Akonadi::Collection::resource
QString resource() const
Returns the identifier of the resource owning the collection.
Definition: collection.cpp:207
Akonadi::Entity::isValid
bool isValid() const
Returns whether the entity is valid.
Definition: entity.cpp:97
Akonadi::EntityDeletedAttribute::setRestoreCollection
void setRestoreCollection(const Collection &col)
Sets the collection used to restore items which have been moved to trash using a TrashJob If the Reso...
Definition: entitydeletedattribute.cpp:49
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:03 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal