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

akonadi

  • 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 
39 
40 
41 EntityDeletedAttribute::EntityDeletedAttribute()
42  : d_ptr( new EntityDeletedAttributePrivate() )
43 {
44 
45 }
46 
47 EntityDeletedAttribute::~EntityDeletedAttribute()
48 {
49  delete d_ptr;
50 }
51 
52 void EntityDeletedAttribute::setRestoreCollection( const Akonadi::Collection &collection )
53 {
54  Q_D( EntityDeletedAttribute );
55  if ( !collection.isValid() ) {
56  kWarning() << "invalid collection" << collection;
57  }
58  Q_ASSERT( collection.isValid() );
59  d->restoreCollection = collection;
60  if ( collection.resource().isEmpty() ) {
61  kWarning() << "no resource set";
62  }
63  d->restoreResource = collection.resource();
64 }
65 
66 Collection EntityDeletedAttribute::restoreCollection() const
67 {
68  Q_D( const EntityDeletedAttribute );
69  return d->restoreCollection;
70 }
71 
72 QString EntityDeletedAttribute::restoreResource() const
73 {
74  Q_D( const EntityDeletedAttribute );
75  return d->restoreResource;
76 }
77 
78 QByteArray Akonadi::EntityDeletedAttribute::type() const
79 {
80  return "DELETED";
81 }
82 
83 EntityDeletedAttribute * EntityDeletedAttribute::clone() const
84 {
85  const Q_D( EntityDeletedAttribute );
86  EntityDeletedAttribute *attr = new EntityDeletedAttribute();
87  attr->d_ptr->restoreCollection = d->restoreCollection;
88  attr->d_ptr->restoreResource = d->restoreResource;
89  return attr;
90 }
91 
92 QByteArray EntityDeletedAttribute::serialized() const
93 {
94  const Q_D( EntityDeletedAttribute );
95 
96  QList<QByteArray> l;
97  l << ImapParser::quote( d->restoreResource.toUtf8() );
98  QList<QByteArray> components;
99  components << QByteArray::number( d->restoreCollection.id() );
100 
101  l << '(' + ImapParser::join( components, " " ) + ')';
102  return '(' + ImapParser::join( l, " " ) + ')';
103 }
104 
105 void EntityDeletedAttribute::deserialize( const QByteArray &data )
106 {
107  Q_D( EntityDeletedAttribute );
108 
109  QList<QByteArray> l;
110  ImapParser::parseParenthesizedList( data, l );
111  if ( l.size() != 2 ) {
112  kWarning() << "invalid size";
113  return;
114  }
115  d->restoreResource = QString::fromUtf8( l[0] );
116 
117  if ( !l[1].isEmpty() ) {
118  QList<QByteArray> componentData;
119  ImapParser::parseParenthesizedList( l[1], componentData );
120  if ( componentData.size() != 1 ) {
121  return;
122  }
123  QList<int> components;
124  bool ok;
125  for ( int i = 0; i < 1; ++i ) {
126  components << componentData.at( i ).toInt( &ok );
127  if ( !ok ) {
128  return;
129  }
130  }
131  d->restoreCollection = Collection( components.at( 0 ) );
132  }
133 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:27:35 by doxygen 1.8.3.1 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-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 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
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