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

KIMAP Library

  • sources
  • kde-4.12
  • kdepimlibs
  • kimap
appendjob.cpp
1 /*
2  Copyright (c) 2009 Kevin Ottens <ervin@kde.org>
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 "appendjob.h"
21 
22 #include <KDE/KLocalizedString>
23 
24 #include "job_p.h"
25 #include "message_p.h"
26 #include "session_p.h"
27 #include "rfccodecs.h"
28 
29 namespace KIMAP
30 {
31  class AppendJobPrivate : public JobPrivate
32  {
33  public:
34  AppendJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ), uid( 0 ) { }
35  ~AppendJobPrivate() { }
36 
37  QString mailBox;
38  QList<QByteArray> flags;
39  QByteArray content;
40  qint64 uid;
41  };
42 }
43 
44 using namespace KIMAP;
45 
46 AppendJob::AppendJob( Session *session )
47  : Job( *new AppendJobPrivate( session, i18n( "Append" ) ) )
48 {
49 }
50 
51 AppendJob::~AppendJob()
52 {
53 }
54 
55 void AppendJob::setMailBox( const QString &mailBox )
56 {
57  Q_D( AppendJob );
58  d->mailBox = mailBox;
59 }
60 
61 QString AppendJob::mailBox() const
62 {
63  Q_D( const AppendJob );
64  return d->mailBox;
65 }
66 
67 void AppendJob::setFlags( const QList<QByteArray> &flags)
68 {
69  Q_D( AppendJob );
70  d->flags = flags;
71 }
72 
73 QList<QByteArray> AppendJob::flags() const
74 {
75  Q_D( const AppendJob );
76  return d->flags;
77 }
78 
79 void AppendJob::setContent( const QByteArray &content )
80 {
81  Q_D( AppendJob );
82  d->content = content;
83 }
84 
85 QByteArray AppendJob::content() const
86 {
87  Q_D( const AppendJob );
88  return d->content;
89 }
90 
91 qint64 AppendJob::uid() const
92 {
93  Q_D( const AppendJob );
94  return d->uid;
95 }
96 
97 void AppendJob::doStart()
98 {
99  Q_D( AppendJob );
100 
101  QByteArray parameters = '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"';
102 
103  if ( !d->flags.isEmpty() ) {
104  parameters += " (";
105  foreach ( const QByteArray &flag, d->flags ) {
106  parameters+= flag + ' ';
107  }
108  parameters.chop( 1 );
109  parameters += ')';
110  }
111 
112  parameters += " {" + QByteArray::number( d->content.size() ) + '}';
113 
114  d->tags << d->sessionInternal()->sendCommand( "APPEND", parameters );
115 }
116 
117 void AppendJob::handleResponse( const Message &response )
118 {
119  Q_D( AppendJob );
120 
121  for ( QList<Message::Part>::ConstIterator it = response.responseCode.begin();
122  it != response.responseCode.end(); ++it ) {
123  if ( it->toString() == "APPENDUID" ) {
124  it = it + 2;
125  if ( it != response.responseCode.end() ) {
126  d->uid = it->toString().toLongLong();
127  }
128  break;
129  }
130  }
131 
132  if ( handleErrorReplies( response ) == NotHandled ) {
133  if ( response.content[0].toString() == "+" ) {
134  d->sessionInternal()->sendData( d->content );
135  }
136  }
137 }
rfccodecs.h
This file is part of the IMAP support library and defines the RfcCodecs class.
KIMAP::AppendJob::setFlags
void setFlags(const QList< QByteArray > &flags)
Set the flags that should be applied to the appended message.
Definition: appendjob.cpp:67
KIMAP::AppendJob::uid
qint64 uid() const
The UID of the new message.
Definition: appendjob.cpp:91
KIMAP::AppendJob::setContent
void setContent(const QByteArray &content)
The content of the message.
Definition: appendjob.cpp:79
KIMAP::AppendJob::setMailBox
void setMailBox(const QString &mailBox)
Set the mailbox to append the message to.
Definition: appendjob.cpp:55
KIMAP::AppendJob::content
QByteArray content() const
The content that the message will have.
Definition: appendjob.cpp:85
KIMAP::AppendJob::mailBox
QString mailBox() const
The mailbox that the message will be appended to.
Definition: appendjob.cpp:61
KIMAP::AppendJob::flags
QList< QByteArray > flags() const
The flags that will be set on the appended message.
Definition: appendjob.cpp:73
KIMAP::AppendJob
Appends a message to a mailbox.
Definition: appendjob.h:42
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIMAP Library

Skip menu "KIMAP Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • 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