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

akonadi

  • akonadi
collectionmodifyjob.cpp
1 /*
2  Copyright (c) 2006 Volker Krause <vkrause@kde.org>
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 "collectionmodifyjob.h"
21 
22 #include "changemediator_p.h"
23 #include "collection_p.h"
24 #include "collectionstatistics.h"
25 #include "imapparser_p.h"
26 #include "job_p.h"
27 #include "protocolhelper_p.h"
28 
29 #include <akonadi/private/protocol_p.h>
30 
31 #include <KLocale>
32 
33 using namespace Akonadi;
34 
35 class Akonadi::CollectionModifyJobPrivate : public JobPrivate
36 {
37  public:
38  CollectionModifyJobPrivate( CollectionModifyJob *parent )
39  : JobPrivate( parent )
40  {
41  }
42 
43  Collection mCollection;
44 };
45 
46 CollectionModifyJob::CollectionModifyJob( const Collection &collection, QObject * parent )
47  : Job( new CollectionModifyJobPrivate( this ), parent )
48 {
49  Q_D( CollectionModifyJob );
50  d->mCollection = collection;
51 }
52 
53 CollectionModifyJob::~CollectionModifyJob()
54 {
55 }
56 
57 void CollectionModifyJob::doStart()
58 {
59  Q_D( CollectionModifyJob );
60  QByteArray command = d->newTag();
61  try {
62  command += ProtocolHelper::entityIdToByteArray( d->mCollection, AKONADI_CMD_COLLECTIONMODIFY );
63  } catch ( const std::exception &e ) {
64  setError( Job::Unknown );
65  setErrorText( QString::fromUtf8( e.what() ) );
66  emitResult();
67  return;
68  }
69 
70  QByteArray changes;
71  if ( d->mCollection.d_func()->contentTypesChanged ) {
72  QList<QByteArray> bList;
73  foreach ( const QString &s, d->mCollection.contentMimeTypes() ) {
74  bList << s.toLatin1();
75  }
76  changes += " MIMETYPE (" + ImapParser::join( bList, " " ) + ')';
77  }
78  if ( d->mCollection.parentCollection().id() >= 0 ) {
79  changes += " PARENT " + QByteArray::number( d->mCollection.parentCollection().id() );
80  }
81  if ( !d->mCollection.name().isEmpty() ) {
82  changes += " NAME " + ImapParser::quote( d->mCollection.name().toUtf8() );
83  }
84  if ( !d->mCollection.remoteId().isNull() ) {
85  changes += " REMOTEID " + ImapParser::quote( d->mCollection.remoteId().toUtf8() );
86  }
87  if ( !d->mCollection.remoteRevision().isNull() ) {
88  changes += " REMOTEREVISION " + ImapParser::quote( d->mCollection.remoteRevision().toUtf8() );
89  }
90  if ( d->mCollection.d_func()->cachePolicyChanged ) {
91  changes += ' ' + ProtocolHelper::cachePolicyToByteArray( d->mCollection.cachePolicy() );
92  }
93  if ( d->mCollection.attributes().count() > 0 ) {
94  changes += ' ' + ProtocolHelper::attributesToByteArray( d->mCollection );
95  }
96  foreach ( const QByteArray &b, d->mCollection.d_func()->mDeletedAttributes ) {
97  changes += " -" + b;
98  }
99  if ( changes.isEmpty() ) {
100  emitResult();
101  return;
102  }
103  command += changes + '\n';
104  d->writeData( command );
105 
106  ChangeMediator::invalidateCollection( d->mCollection );
107 }
108 
109 Collection CollectionModifyJob::collection() const
110 {
111  const Q_D( CollectionModifyJob );
112  return d->mCollection;
113 }
114 
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:27:33 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