akonadi
searchcreatejob.cpp
00001 00002 /* 00003 Copyright (c) 2007 Volker Krause <vkrause@kde.org> 00004 00005 This library is free software; you can redistribute it and/or modify it 00006 under the terms of the GNU Library General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or (at your 00008 option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, but WITHOUT 00011 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to the 00017 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00018 02110-1301, USA. 00019 */ 00020 00021 #include "searchcreatejob.h" 00022 00023 #include "collection.h" 00024 #include "imapparser_p.h" 00025 #include "protocolhelper_p.h" 00026 #include "job_p.h" 00027 #include <akonadi/private/protocol_p.h> 00028 00029 using namespace Akonadi; 00030 00031 class Akonadi::SearchCreateJobPrivate : public JobPrivate 00032 { 00033 public: 00034 SearchCreateJobPrivate( SearchCreateJob *parent ) 00035 : JobPrivate( parent ) 00036 { 00037 } 00038 00039 QString mName; 00040 QString mQuery; 00041 QString mQueryLanguage; 00042 Collection mCreatedCollection; 00043 }; 00044 00045 SearchCreateJob::SearchCreateJob( const QString & name, const QString & query, QObject * parent ) 00046 : Job( new SearchCreateJobPrivate( this ), parent ) 00047 { 00048 Q_D( SearchCreateJob ); 00049 00050 d->mName = name; 00051 d->mQuery = query; 00052 } 00053 00054 SearchCreateJob::~SearchCreateJob() 00055 { 00056 } 00057 00058 void SearchCreateJob::setQueryLanguage(const QString& queryLanguage) 00059 { 00060 Q_D( SearchCreateJob ); 00061 d->mQueryLanguage = queryLanguage; 00062 } 00063 00064 void SearchCreateJob::doStart() 00065 { 00066 Q_D( SearchCreateJob ); 00067 00068 QByteArray command = d->newTag() + " SEARCH_STORE "; 00069 command += ImapParser::quote( d->mName.toUtf8() ); 00070 command += ' '; 00071 command += ImapParser::quote( d->mQuery.toUtf8() ); 00072 if ( !d->mQueryLanguage.isEmpty() ) { 00073 command += " (" AKONADI_PARAM_PERSISTENTSEARCH_QUERYLANG " "; 00074 command += ImapParser::quote( d->mQueryLanguage.toUtf8() ); 00075 command += ')'; 00076 } 00077 command += '\n'; 00078 d->writeData( command ); 00079 } 00080 00081 Akonadi::Collection SearchCreateJob::createdCollection() const 00082 { 00083 Q_D( const SearchCreateJob ); 00084 return d->mCreatedCollection; 00085 } 00086 00087 void SearchCreateJob::doHandleResponse( const QByteArray &tag, const QByteArray &data ) 00088 { 00089 Q_D( SearchCreateJob ); 00090 if ( tag == "*" ) { 00091 ProtocolHelper::parseCollection( data, d->mCreatedCollection ); 00092 return; 00093 } 00094 kDebug() << "Unhandled response: " << tag << data; 00095 } 00096 00097 #include "searchcreatejob.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon May 14 2012 04:52:58 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon May 14 2012 04:52:58 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.