• 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
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 namespace Akonadi {
27 
28 class SearchResultJobPrivate : public Akonadi::JobPrivate
29 {
30 public:
31  SearchResultJobPrivate(SearchResultJob *parent);
32 
33  QByteArray searchId;
34  Collection collection;
35  ImapSet uid;
36  QVector<QByteArray> rid;
37 };
38 
39 SearchResultJobPrivate::SearchResultJobPrivate(SearchResultJob *parent)
40  : JobPrivate(parent)
41 {
42 }
43 
44 }
45 
46 using namespace Akonadi;
47 
48 SearchResultJob::SearchResultJob(const QByteArray &searchId, const Collection &collection, QObject *parent)
49  : Job(new SearchResultJobPrivate(this), parent)
50 {
51  Q_D(SearchResultJob);
52  Q_ASSERT(collection.isValid());
53 
54  d->searchId = searchId;
55  d->collection = collection;
56 }
57 
58 SearchResultJob::~SearchResultJob()
59 {
60 }
61 
62 void SearchResultJob::setSearchId(const QByteArray &searchId)
63 {
64  Q_D(SearchResultJob);
65  d->searchId = searchId;
66 }
67 
68 QByteArray SearchResultJob::searchId() const
69 {
70  return d_func()->searchId;
71 }
72 
73 void SearchResultJob::setResult(const ImapSet &set)
74 {
75  Q_D(SearchResultJob);
76  d->rid.clear();
77  d->uid = set;
78 }
79 
80 void SearchResultJob::setResult(const QVector<qint64> &ids)
81 {
82  Q_D(SearchResultJob);
83  d->rid.clear();
84  d->uid = ImapSet();
85  d->uid.add(ids);
86 }
87 
88 void SearchResultJob::setResult(const QVector<QByteArray> &remoteIds)
89 {
90  Q_D(SearchResultJob);
91  d->uid = ImapSet();
92  d->rid = remoteIds;
93 }
94 
95 void SearchResultJob::doStart()
96 {
97  Q_D(SearchResultJob);
98 
99  QByteArray command = d->newTag() + ' ';
100 
101  if (!d->rid.isEmpty()) {
102  command += AKONADI_CMD_RID;
103  } else {
104  command += AKONADI_CMD_UID;
105  }
106 
107  command += " SEARCH_RESULT " + d->searchId + " " + QByteArray::number(d->collection.id()) + " (";
108 
109  if (!d->rid.isEmpty()) {
110  command += ImapParser::join(d->rid.toList(), " ");
111  } else if (!d->uid.isEmpty()) {
112  command += d->uid.toImapSequenceSet();
113  }
114 
115  command += ")";
116 
117  d->writeData(command);
118 }
QByteArray
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
QObject
QByteArray::number
QByteArray number(int n, int base)
QVector< QByteArray >
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-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:03 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