• 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
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 using namespace Akonadi;
32 
33 class Akonadi::CollectionModifyJobPrivate : public JobPrivate
34 {
35 public:
36  CollectionModifyJobPrivate(CollectionModifyJob *parent)
37  : JobPrivate(parent)
38  {
39  }
40 
41  virtual QString jobDebuggingString() const
42  {
43  return QString::fromLatin1("Collection Id %1").arg(mCollection.id());
44  }
45 
46  Collection mCollection;
47 };
48 
49 CollectionModifyJob::CollectionModifyJob(const Collection &collection, QObject *parent)
50  : Job(new CollectionModifyJobPrivate(this), parent)
51 {
52  Q_D(CollectionModifyJob);
53  d->mCollection = collection;
54 }
55 
56 CollectionModifyJob::~CollectionModifyJob()
57 {
58 }
59 
60 void CollectionModifyJob::doStart()
61 {
62  Q_D(CollectionModifyJob);
63  QByteArray command = d->newTag();
64  try {
65  command += ProtocolHelper::entityIdToByteArray(d->mCollection, AKONADI_CMD_COLLECTIONMODIFY);
66  } catch (const std::exception &e) {
67  setError(Job::Unknown);
68  setErrorText(QString::fromUtf8(e.what()));
69  emitResult();
70  return;
71  }
72 
73  QByteArray changes;
74  if (d->mCollection.d_func()->contentTypesChanged) {
75  QList<QByteArray> bList;
76  foreach (const QString &s, d->mCollection.contentMimeTypes()) {
77  bList << s.toLatin1();
78  }
79  changes += " MIMETYPE (" + ImapParser::join(bList, " ") + ')';
80  }
81  if (d->mCollection.parentCollection().id() >= 0) {
82  changes += " PARENT " + QByteArray::number(d->mCollection.parentCollection().id());
83  }
84  if (!d->mCollection.name().isEmpty()) {
85  changes += " NAME " + ImapParser::quote(d->mCollection.name().toUtf8());
86  }
87  if (!d->mCollection.remoteId().isNull()) {
88  changes += " REMOTEID " + ImapParser::quote(d->mCollection.remoteId().toUtf8());
89  }
90  if (!d->mCollection.remoteRevision().isNull()) {
91  changes += " REMOTEREVISION " + ImapParser::quote(d->mCollection.remoteRevision().toUtf8());
92  }
93  if (d->mCollection.d_func()->cachePolicyChanged) {
94  changes += ' ' + ProtocolHelper::cachePolicyToByteArray(d->mCollection.cachePolicy());
95  }
96  if (d->mCollection.d_func()->enabledChanged) {
97  changes += ' ' + ProtocolHelper::enabled(d->mCollection.enabled());
98  }
99  if (d->mCollection.d_func()->listPreferenceChanged) {
100  changes += ' ' + ProtocolHelper::listPreference(Collection::ListDisplay, d->mCollection.localListPreference(Collection::ListDisplay));
101  changes += ' ' + ProtocolHelper::listPreference(Collection::ListSync, d->mCollection.localListPreference(Collection::ListSync));
102  changes += ' ' + ProtocolHelper::listPreference(Collection::ListIndex, d->mCollection.localListPreference(Collection::ListIndex));
103  }
104  if (d->mCollection.d_func()->referencedChanged) {
105  changes += ' ' + ProtocolHelper::referenced(d->mCollection.referenced());
106  }
107  if (d->mCollection.attributes().count() > 0) {
108  changes += ' ' + ProtocolHelper::attributesToByteArray(d->mCollection);
109  }
110  foreach (const QByteArray &b, d->mCollection.d_func()->mDeletedAttributes) {
111  changes += " -" + b;
112  }
113  if (changes.isEmpty()) {
114  emitResult();
115  return;
116  }
117  command += changes + '\n';
118  d->writeData(command);
119 
120  ChangeMediator::invalidateCollection(d->mCollection);
121 }
122 
123 Collection CollectionModifyJob::collection() const
124 {
125  const Q_D(CollectionModifyJob);
126  return d->mCollection;
127 }
Akonadi::CollectionModifyJob
Job that modifies a collection in the Akonadi storage.
Definition: collectionmodifyjob.h:82
QByteArray
Akonadi::Job::Unknown
Unknown error.
Definition: job.h:108
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
QByteArray::isEmpty
bool isEmpty() const
Akonadi::Collection::ListDisplay
Listing for display to the user.
Definition: collection.h:337
Akonadi::ProtocolHelper::attributesToByteArray
static QByteArray attributesToByteArray(const Entity &entity, bool ns=false)
Convert attributes to their protocol representation.
Definition: protocolhelper.cpp:232
Akonadi::Job
Base class for all actions in the Akonadi storage.
Definition: job.h:86
Akonadi::CollectionModifyJob::CollectionModifyJob
CollectionModifyJob(const Collection &collection, QObject *parent=0)
Creates a new collection modify job for the given collection.
Definition: collectionmodifyjob.cpp:49
Akonadi::Collection::ListIndex
Listing for indexing the content.
Definition: collection.h:338
QString::fromUtf8
QString fromUtf8(const char *str, int size)
Akonadi::CollectionModifyJob::collection
Collection collection() const
Returns the modified collection.
Definition: collectionmodifyjob.cpp:123
QObject
QByteArray::number
QByteArray number(int n, int base)
QString
QList< QByteArray >
Akonadi::CollectionModifyJob::doStart
virtual void doStart()
This method must be reimplemented in the concrete jobs.
Definition: collectionmodifyjob.cpp:60
QString::toLatin1
QByteArray toLatin1() const
Akonadi::CollectionModifyJob::~CollectionModifyJob
~CollectionModifyJob()
Destroys the collection modify job.
Definition: collectionmodifyjob.cpp:56
Akonadi::JobPrivate
Definition: job_p.h:31
QString::fromLatin1
QString fromLatin1(const char *str, int size)
Akonadi::ProtocolHelper::entityIdToByteArray
static QByteArray entityIdToByteArray(const T &object, const QByteArray &command)
Converts the given object identifier into a protocol representation.
Definition: protocolhelper_p.h:204
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Akonadi::Collection::ListSync
Listing for synchronization.
Definition: collection.h:336
Akonadi::ProtocolHelper::cachePolicyToByteArray
static QByteArray cachePolicyToByteArray(const CachePolicy &policy)
Convert a cache policy object into its protocol representation.
Definition: protocolhelper.cpp:71
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:02 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