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

akonadi

  • sources
  • kde-4.12
  • kdepimlibs
  • akonadi
searchcreatejob.cpp
1 
2 /*
3  Copyright (c) 2007 Volker Krause <vkrause@kde.org>
4 
5  This library is free software; you can redistribute it and/or modify it
6  under the terms of the GNU Library General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or (at your
8  option) any later version.
9 
10  This library is distributed in the hope that it will be useful, but WITHOUT
11  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13  License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to the
17  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  02110-1301, USA.
19 */
20 
21 #include "searchcreatejob.h"
22 
23 #include "collection.h"
24 #include "imapparser_p.h"
25 #include "protocolhelper_p.h"
26 #include "job_p.h"
27 #include <akonadi/private/protocol_p.h>
28 
29 using namespace Akonadi;
30 
31 class Akonadi::SearchCreateJobPrivate : public JobPrivate
32 {
33  public:
34  SearchCreateJobPrivate( SearchCreateJob *parent )
35  : JobPrivate( parent )
36  {
37  }
38 
39  QString mName;
40  QString mQuery;
41  QString mQueryLanguage;
42  Collection mCreatedCollection;
43 };
44 
45 SearchCreateJob::SearchCreateJob( const QString & name, const QString & query, QObject * parent )
46  : Job( new SearchCreateJobPrivate( this ), parent )
47 {
48  Q_D( SearchCreateJob );
49 
50  d->mName = name;
51  d->mQuery = query;
52 }
53 
54 SearchCreateJob::~SearchCreateJob()
55 {
56 }
57 
58 void SearchCreateJob::setQueryLanguage(const QString& queryLanguage)
59 {
60  Q_D( SearchCreateJob );
61  d->mQueryLanguage = queryLanguage;
62 }
63 
64 void SearchCreateJob::doStart()
65 {
66  Q_D( SearchCreateJob );
67 
68  QByteArray command = d->newTag() + " SEARCH_STORE ";
69  command += ImapParser::quote( d->mName.toUtf8() );
70  command += ' ';
71  command += ImapParser::quote( d->mQuery.toUtf8() );
72  if ( !d->mQueryLanguage.isEmpty() ) {
73  command += " (" AKONADI_PARAM_PERSISTENTSEARCH_QUERYLANG " ";
74  command += ImapParser::quote( d->mQueryLanguage.toUtf8() );
75  command += ')';
76  }
77  command += '\n';
78  d->writeData( command );
79 }
80 
81 Akonadi::Collection SearchCreateJob::createdCollection() const
82 {
83  Q_D( const SearchCreateJob );
84  return d->mCreatedCollection;
85 }
86 
87 void SearchCreateJob::doHandleResponse( const QByteArray &tag, const QByteArray &data )
88 {
89  Q_D( SearchCreateJob );
90  if ( tag == "*" ) {
91  ProtocolHelper::parseCollection( data, d->mCreatedCollection );
92  return;
93  }
94  kDebug() << "Unhandled response: " << tag << data;
95 }
96 
Akonadi::SearchCreateJob::doStart
void doStart()
Reimplemented from Akonadi::Job.
Definition: searchcreatejob.cpp:64
Akonadi::SearchCreateJob::~SearchCreateJob
~SearchCreateJob()
Destroys the search create job.
Definition: searchcreatejob.cpp:54
Akonadi::SearchCreateJob
Job that creates a virtual/search collection in the Akonadi storage.
Definition: searchcreatejob.h:60
Akonadi::SearchCreateJob::createdCollection
Collection createdCollection() const
Returns the newly created search collection once the job finished successfully.
Definition: searchcreatejob.cpp:81
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::ProtocolHelper::parseCollection
static int parseCollection(const QByteArray &data, Collection &collection, int start=0)
Parse a collection description.
Definition: protocolhelper.cpp:129
Akonadi::SearchCreateJob::doHandleResponse
void doHandleResponse(const QByteArray &tag, const QByteArray &data)
Reimplemented from Akonadi::Job.
Definition: searchcreatejob.cpp:87
Akonadi::SearchCreateJob::SearchCreateJob
SearchCreateJob(const QString &name, const QString &query, QObject *parent=0)
Creates a search create job.
Definition: searchcreatejob.cpp:45
Akonadi::JobPrivate
Definition: job_p.h:31
Akonadi::SearchCreateJob::setQueryLanguage
void setQueryLanguage(const QString &queryLanguage)
Sets the query language.
Definition: searchcreatejob.cpp:58
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:27 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
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

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