KIMAP Library
copyjob.cpp
00001 /* 00002 Copyright (c) 2009 Andras Mantia <amantia@kde.org> 00003 00004 This library is free software; you can redistribute it and/or modify it 00005 under the terms of the GNU Library General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or (at your 00007 option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to the 00016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301, USA. 00018 */ 00019 00020 #include "copyjob.h" 00021 00022 #include <KDE/KLocale> 00023 #include <KDE/KDebug> 00024 00025 #include "job_p.h" 00026 #include "message_p.h" 00027 #include "session_p.h" 00028 #include "rfccodecs.h" 00029 00030 //TODO: when custom error codes are introduced, handle the NO [TRYCREATE] response 00031 00032 namespace KIMAP 00033 { 00034 class CopyJobPrivate : public JobPrivate 00035 { 00036 public: 00037 CopyJobPrivate( Session *session, const QString& name ) : JobPrivate(session, name) { } 00038 ~CopyJobPrivate() { } 00039 00040 QString mailBox; 00041 ImapSet set; 00042 bool uidBased; 00043 ImapSet resultingUids; 00044 }; 00045 } 00046 00047 using namespace KIMAP; 00048 00049 CopyJob::CopyJob( Session *session ) 00050 : Job( *new CopyJobPrivate(session, i18n("Copy")) ) 00051 { 00052 Q_D(CopyJob); 00053 d->uidBased = false; 00054 } 00055 00056 CopyJob::~CopyJob() 00057 { 00058 } 00059 00060 void CopyJob::setMailBox( const QString &mailBox ) 00061 { 00062 Q_D(CopyJob); 00063 d->mailBox = mailBox; 00064 } 00065 00066 QString CopyJob::mailBox() const 00067 { 00068 Q_D(const CopyJob); 00069 return d->mailBox; 00070 } 00071 00072 void CopyJob::setSequenceSet( const ImapSet &set ) 00073 { 00074 Q_D(CopyJob); 00075 d->set = set; 00076 } 00077 00078 ImapSet CopyJob::sequenceSet() const 00079 { 00080 Q_D(const CopyJob); 00081 return d->set; 00082 } 00083 00084 00085 void CopyJob::setUidBased( bool uidBased ) 00086 { 00087 Q_D(CopyJob); 00088 d->uidBased = uidBased; 00089 } 00090 00091 bool CopyJob::isUidBased() const 00092 { 00093 Q_D(const CopyJob); 00094 return d->uidBased; 00095 } 00096 00097 ImapSet CopyJob::resultingUids() const 00098 { 00099 Q_D(const CopyJob); 00100 return d->resultingUids; 00101 } 00102 00103 void CopyJob::doStart() 00104 { 00105 Q_D(CopyJob); 00106 00107 QByteArray parameters = d->set.toImapSequenceSet()+' '; 00108 parameters+= '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"'; 00109 00110 QByteArray command = "COPY"; 00111 if ( d->uidBased ) { 00112 command = "UID "+command; 00113 } 00114 00115 d->tags << d->sessionInternal()->sendCommand( command, parameters ); 00116 } 00117 00118 void CopyJob::handleResponse( const Message &response ) 00119 { 00120 Q_D(CopyJob); 00121 00122 for ( QList<Message::Part>::ConstIterator it = response.responseCode.begin(); 00123 it != response.responseCode.end(); ++it ) { 00124 if ( it->toString()=="COPYUID" ) { 00125 it = it + 3; 00126 if ( it < response.responseCode.end() ) { 00127 d->resultingUids = ImapSet::fromImapSequenceSet( it->toString() ); 00128 } 00129 break; 00130 } 00131 } 00132 00133 handleErrorReplies( response ); 00134 } 00135 00136 #include "copyjob.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:08:13 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:08:13 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.