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

akonadi

  • akonadi
searchresultjob.cpp
1 /*
2  Copyright (c) 2013 Daniel Vrátil <dvratil@redhat.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 "searchresultjob_p.h"
21 #include "job_p.h"
22 #include "protocolhelper_p.h"
23 
24 #include <akonadi/private/protocol_p.h>
25 
26 
27 
28 namespace Akonadi {
29 
30 class SearchResultJobPrivate: public Akonadi::JobPrivate
31 {
32  public:
33  SearchResultJobPrivate( SearchResultJob *parent );
34 
35  QByteArray searchId;
36  Collection collection;
37  ImapSet uid;
38  QVector<QByteArray> rid;
39 };
40 
41 SearchResultJobPrivate::SearchResultJobPrivate( SearchResultJob *parent)
42  : JobPrivate( parent )
43 {
44 }
45 
46 }
47 
48 
49 using namespace Akonadi;
50 
51 SearchResultJob::SearchResultJob( const QByteArray &searchId, const Collection &collection, QObject *parent )
52  : Job(new SearchResultJobPrivate( this ), parent )
53 {
54  Q_D( SearchResultJob );
55  Q_ASSERT( collection.isValid() );
56 
57  d->searchId = searchId;
58  d->collection = collection;
59 }
60 
61 SearchResultJob::~SearchResultJob()
62 {
63 }
64 
65 void SearchResultJob::setSearchId( const QByteArray &searchId )
66 {
67  Q_D( SearchResultJob );
68  d->searchId = searchId;
69 }
70 
71 QByteArray SearchResultJob::searchId() const
72 {
73  return d_func()->searchId;
74 }
75 
76 void SearchResultJob::setResult( const ImapSet &set )
77 {
78  Q_D( SearchResultJob );
79  d->rid.clear();
80  d->uid = set;
81 }
82 
83 void SearchResultJob::setResult( const QVector<qint64> &ids )
84 {
85  Q_D( SearchResultJob );
86  d->rid.clear();
87  d->uid = ImapSet();
88  d->uid.add( ids );
89 }
90 
91 void SearchResultJob::setResult( const QVector<QByteArray> &remoteIds )
92 {
93  Q_D( SearchResultJob );
94  d->uid = ImapSet();
95  d->rid = remoteIds;
96 }
97 
98 void SearchResultJob::doStart()
99 {
100  Q_D( SearchResultJob );
101 
102  QByteArray command = d->newTag() + ' ';
103 
104  if ( !d->rid.isEmpty() ) {
105  command += AKONADI_CMD_RID;
106  } else {
107  command += AKONADI_CMD_UID;
108  }
109 
110  command += " SEARCH_RESULT " + d->searchId + " " + QByteArray::number( d->collection.id() ) + " (";
111 
112  if ( !d->rid.isEmpty() ) {
113  command += ImapParser::join( d->rid.toList(), " " );
114  } else if ( !d->uid.isEmpty() ) {
115  command += d->uid.toImapSequenceSet();
116  }
117 
118  command += ")";
119 
120  d->writeData( command );
121 }
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
Akonadi::Job
Base class for all actions in the Akonadi storage.
Definition: job.h:86
Akonadi::JobPrivate
Definition: job_p.h:31
Akonadi::Entity::isValid
bool isValid() const
Returns whether the entity is valid.
Definition: entity.cpp:97
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Mon Jul 21 2014 08:03:55 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