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

akonadi

  • akonadi
tagmodifyjob.cpp
1 /*
2  Copyright (c) 2014 Christian Mollekopf <mollekopf@kolabsys.com>
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 "tagmodifyjob.h"
21 #include "job_p.h"
22 #include "tag.h"
23 #include "protocolhelper_p.h"
24 #include "changemediator_p.h"
25 
26 using namespace Akonadi;
27 
28 struct Akonadi::TagModifyJobPrivate : public JobPrivate
29 {
30  TagModifyJobPrivate(TagModifyJob *parent)
31  : JobPrivate(parent)
32  {
33  }
34 
35  Tag mTag;
36 };
37 
38 TagModifyJob::TagModifyJob(const Akonadi::Tag& tag, QObject* parent)
39  :Job(new TagModifyJobPrivate(this), parent)
40 {
41  Q_D(TagModifyJob);
42  d->mTag = tag;
43 }
44 
45 void TagModifyJob::doStart()
46 {
47  Q_D(TagModifyJob);
48 
49  QList<QByteArray> list;
50  if (!d->mTag.remoteId().isEmpty()) {
51  list << "RID";
52  list << ImapParser::quote(d->mTag.remoteId());
53  }
54  if (d->mTag.parent().isValid() && !d->mTag.isImmutable()) {
55  list << "PARENT";
56  list << QString::number(d->mTag.parent().id()).toLatin1();
57  }
58 
59  QByteArray command = d->newTag();
60  try {
61  command += ProtocolHelper::tagSetToByteArray(Tag::List() << d->mTag, "TAGSTORE");
62  } catch ( const std::exception &e ) {
63  setError(Unknown);
64  setErrorText( QString::fromUtf8(e.what()));
65  emitResult();
66  return;
67  }
68  command += " (";
69  command += ImapParser::join(list, " ");
70  command += " ";
71 
72  if ( !d->mTag.attributes().isEmpty() ) {
73  command += ProtocolHelper::attributesToByteArray(d->mTag, false);
74  }
75  if ( !d->mTag.removedAttributes().isEmpty() ) {
76  QList<QByteArray> l;
77  Q_FOREACH ( const QByteArray &attr, d->mTag.removedAttributes()) {
78  l << '-' + attr;
79  }
80  command += ImapParser::join( l, " " );
81  }
82 
83  command += ")";
84 
85  d->writeData( command );
86 }
87 
88 void TagModifyJob::doHandleResponse( const QByteArray &tag, const QByteArray &data )
89 {
90  Q_D(TagModifyJob);
91  Q_UNUSED(tag);
92 
93  if ( data.startsWith( "OK" ) ) { //krazy:exclude=strings
94  ChangeMediator::invalidateTag(d->mTag);
95  }
96 
97  emitResult();
98  return;
99 }
Akonadi::TagModifyJob::doHandleResponse
virtual void doHandleResponse(const QByteArray &tag, const QByteArray &data)
This method should be reimplemented in the concrete jobs in case you want to handle incoming data...
Definition: tagmodifyjob.cpp:88
Akonadi::Job::Unknown
Unknown error.
Definition: job.h:109
Akonadi::ProtocolHelper::attributesToByteArray
static QByteArray attributesToByteArray(const Entity &entity, bool ns=false)
Convert attributes to their protocol representation.
Definition: protocolhelper.cpp:206
Akonadi::TagModifyJob::TagModifyJob
TagModifyJob(const Tag &tag, QObject *parent=0)
Creates a new tag modify job.
Definition: tagmodifyjob.cpp:38
Akonadi::Job
Base class for all actions in the Akonadi storage.
Definition: job.h:86
Akonadi::TagModifyJob::doStart
virtual void doStart()
This method must be reimplemented in the concrete jobs.
Definition: tagmodifyjob.cpp:45
Akonadi::TagModifyJob
Job that modifies a tag in the Akonadi storage.
Definition: tagmodifyjob.h:34
Akonadi::JobPrivate
Definition: job_p.h:31
Akonadi::Tag
An Akonadi Tag.
Definition: tag.h:44
Akonadi::TagModifyJob::tag
Tag tag() const
Returns the modified tag.
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Mon Jul 21 2014 08:03:56 by doxygen 1.8.6 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.13.3 API Reference

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