• 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.14
  • 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  KDateTime internalDate;
40  QByteArray content;
41  qint64 uid;
42  };
43 }
44 
45 using namespace KIMAP;
46 
47 AppendJob::AppendJob( Session *session )
48  : Job( *new AppendJobPrivate( session, i18n( "Append" ) ) )
49 {
50 }
51 
52 AppendJob::~AppendJob()
53 {
54 }
55 
56 void AppendJob::setMailBox( const QString &mailBox )
57 {
58  Q_D( AppendJob );
59  d->mailBox = mailBox;
60 }
61 
62 QString AppendJob::mailBox() const
63 {
64  Q_D( const AppendJob );
65  return d->mailBox;
66 }
67 
68 void AppendJob::setFlags( const QList<QByteArray> &flags)
69 {
70  Q_D( AppendJob );
71  d->flags = flags;
72 }
73 
74 QList<QByteArray> AppendJob::flags() const
75 {
76  Q_D( const AppendJob );
77  return d->flags;
78 }
79 
80 void AppendJob::setInternalDate( const KDateTime &internalDate )
81 {
82  Q_D( AppendJob );
83  d->internalDate = internalDate;
84 }
85 
86 KDateTime AppendJob::internalDate() const
87 {
88  Q_D( const AppendJob );
89  return d->internalDate;
90 }
91 
92 void AppendJob::setContent( const QByteArray &content )
93 {
94  Q_D( AppendJob );
95  d->content = content;
96 }
97 
98 QByteArray AppendJob::content() const
99 {
100  Q_D( const AppendJob );
101  return d->content;
102 }
103 
104 qint64 AppendJob::uid() const
105 {
106  Q_D( const AppendJob );
107  return d->uid;
108 }
109 
110 void AppendJob::doStart()
111 {
112  Q_D( AppendJob );
113 
114  QByteArray parameters = '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"';
115 
116  if ( !d->flags.isEmpty() ) {
117  parameters += " (";
118  foreach ( const QByteArray &flag, d->flags ) {
119  parameters+= flag + ' ';
120  }
121  parameters.chop( 1 );
122  parameters += ')';
123  }
124 
125  if ( !d->internalDate.isNull() ) {
126  parameters += " \"" + d->internalDate.toString( QString::fromAscii( "%d-%:b-%Y %H:%M:%S %z" ) ).toLatin1() + '\"';
127  }
128 
129  parameters += " {" + QByteArray::number( d->content.size() ) + '}';
130 
131  d->tags << d->sessionInternal()->sendCommand( "APPEND", parameters );
132 }
133 
134 void AppendJob::handleResponse( const Message &response )
135 {
136  Q_D( AppendJob );
137 
138  for ( QList<Message::Part>::ConstIterator it = response.responseCode.begin();
139  it != response.responseCode.end(); ++it ) {
140  if ( it->toString() == "APPENDUID" ) {
141  it = it + 2;
142  if ( it != response.responseCode.end() ) {
143  d->uid = it->toString().toLongLong();
144  }
145  break;
146  }
147  }
148 
149  if ( handleErrorReplies( response ) == NotHandled ) {
150  if ( !response.content.isEmpty() && response.content[0].toString() == "+" ) {
151  d->sessionInternal()->sendData( d->content );
152  }
153  }
154 }
QString::fromAscii
QString fromAscii(const char *str, int size)
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:68
QByteArray
KIMAP::AppendJob::uid
qint64 uid() const
The UID of the new message.
Definition: appendjob.cpp:104
QByteArray::chop
void chop(int n)
KIMAP::AppendJob::setContent
void setContent(const QByteArray &content)
The content of the message.
Definition: appendjob.cpp:92
KIMAP::AppendJob::setMailBox
void setMailBox(const QString &mailBox)
Set the mailbox to append the message to.
Definition: appendjob.cpp:56
KIMAP::AppendJob::content
QByteArray content() const
The content that the message will have.
Definition: appendjob.cpp:98
QByteArray::number
QByteArray number(int n, int base)
KIMAP::AppendJob::mailBox
QString mailBox() const
The mailbox that the message will be appended to.
Definition: appendjob.cpp:62
QString
QList< QByteArray >
KIMAP::AppendJob::internalDate
KDateTime internalDate() const
The internal date that will be set on the appended message.
Definition: appendjob.cpp:86
KIMAP::AppendJob::flags
QList< QByteArray > flags() const
The flags that will be set on the appended message.
Definition: appendjob.cpp:74
KIMAP::AppendJob
Appends a message to a mailbox.
Definition: appendjob.h:43
KIMAP::AppendJob::setInternalDate
void setInternalDate(const KDateTime &internalDate)
Set the internal date that should be applied to the appended message.
Definition: appendjob.cpp:80
QList::begin
iterator begin()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:37:03 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
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

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