KIMAP Library
appendjob.cpp
00001 /* 00002 Copyright (c) 2009 Kevin Ottens <ervin@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 "appendjob.h" 00021 00022 #include <KDE/KLocale> 00023 00024 #include "job_p.h" 00025 #include "message_p.h" 00026 #include "session_p.h" 00027 #include "rfccodecs.h" 00028 00029 namespace KIMAP 00030 { 00031 class AppendJobPrivate : public JobPrivate 00032 { 00033 public: 00034 AppendJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ), uid( 0 ) { } 00035 ~AppendJobPrivate() { } 00036 00037 QString mailBox; 00038 QList<QByteArray> flags; 00039 QByteArray content; 00040 qint64 uid; 00041 }; 00042 } 00043 00044 using namespace KIMAP; 00045 00046 AppendJob::AppendJob( Session *session ) 00047 : Job( *new AppendJobPrivate(session, i18n("Append")) ) 00048 { 00049 } 00050 00051 AppendJob::~AppendJob() 00052 { 00053 } 00054 00055 void AppendJob::setMailBox( const QString &mailBox ) 00056 { 00057 Q_D(AppendJob); 00058 d->mailBox = mailBox; 00059 } 00060 00061 QString AppendJob::mailBox() const 00062 { 00063 Q_D(const AppendJob); 00064 return d->mailBox; 00065 } 00066 00067 void AppendJob::setFlags( const QList<QByteArray> &flags) 00068 { 00069 Q_D(AppendJob); 00070 d->flags = flags; 00071 } 00072 00073 QList<QByteArray> AppendJob::flags() const 00074 { 00075 Q_D(const AppendJob); 00076 return d->flags; 00077 } 00078 00079 void AppendJob::setContent( const QByteArray &content ) 00080 { 00081 Q_D(AppendJob); 00082 d->content = content; 00083 } 00084 00085 QByteArray AppendJob::content() const 00086 { 00087 Q_D(const AppendJob); 00088 return d->content; 00089 } 00090 00091 qint64 AppendJob::uid() const 00092 { 00093 Q_D(const AppendJob); 00094 return d->uid; 00095 } 00096 00097 void AppendJob::doStart() 00098 { 00099 Q_D(AppendJob); 00100 00101 QByteArray parameters = '\"'+KIMAP::encodeImapFolderName( d->mailBox.toUtf8() )+'\"'; 00102 00103 if ( !d->flags.isEmpty() ) { 00104 parameters+=" ("; 00105 foreach ( const QByteArray &flag, d->flags ) { 00106 parameters+= flag+' '; 00107 } 00108 parameters.chop(1); 00109 parameters+=')'; 00110 } 00111 00112 parameters+=" {"+QByteArray::number(d->content.size())+'}'; 00113 00114 d->tags << d->sessionInternal()->sendCommand( "APPEND", parameters ); 00115 } 00116 00117 void AppendJob::handleResponse( const Message &response ) 00118 { 00119 Q_D(AppendJob); 00120 00121 for ( QList<Message::Part>::ConstIterator it = response.responseCode.begin(); 00122 it != response.responseCode.end(); ++it ) { 00123 if ( it->toString()=="APPENDUID" ) { 00124 it = it + 2; 00125 if ( it != response.responseCode.end() ) { 00126 d->uid = it->toString().toLongLong(); 00127 } 00128 break; 00129 } 00130 } 00131 00132 if (handleErrorReplies(response) == NotHandled ) { 00133 if ( response.content[0].toString() == "+" ) { 00134 d->sessionInternal()->sendData( d->content ); 00135 } 00136 } 00137 } 00138 00139 #include "appendjob.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:24:24 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:24:24 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.