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

KIMAP Library

  • kimap
copyjob.cpp
1 /*
2  Copyright (c) 2009 Andras Mantia <amantia@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 "copyjob.h"
21 
22 #include <KDE/KLocale>
23 #include <KDE/KDebug>
24 
25 #include "job_p.h"
26 #include "message_p.h"
27 #include "session_p.h"
28 #include "rfccodecs.h"
29 
30 //TODO: when custom error codes are introduced, handle the NO [TRYCREATE] response
31 
32 namespace KIMAP
33 {
34  class CopyJobPrivate : public JobPrivate
35  {
36  public:
37  CopyJobPrivate( Session *session, const QString& name ) : JobPrivate( session, name ) { }
38  ~CopyJobPrivate() { }
39 
40  QString mailBox;
41  ImapSet set;
42  bool uidBased;
43  ImapSet resultingUids;
44  };
45 }
46 
47 using namespace KIMAP;
48 
49 CopyJob::CopyJob( Session *session )
50  : Job( *new CopyJobPrivate( session, i18n( "Copy" ) ) )
51 {
52  Q_D( CopyJob );
53  d->uidBased = false;
54 }
55 
56 CopyJob::~CopyJob()
57 {
58 }
59 
60 void CopyJob::setMailBox( const QString &mailBox )
61 {
62  Q_D( CopyJob );
63  d->mailBox = mailBox;
64 }
65 
66 QString CopyJob::mailBox() const
67 {
68  Q_D( const CopyJob );
69  return d->mailBox;
70 }
71 
72 void CopyJob::setSequenceSet( const ImapSet &set )
73 {
74  Q_D( CopyJob );
75  d->set = set;
76 }
77 
78 ImapSet CopyJob::sequenceSet() const
79 {
80  Q_D( const CopyJob );
81  return d->set;
82 }
83 
84 
85 void CopyJob::setUidBased( bool uidBased )
86 {
87  Q_D( CopyJob );
88  d->uidBased = uidBased;
89 }
90 
91 bool CopyJob::isUidBased() const
92 {
93  Q_D( const CopyJob );
94  return d->uidBased;
95 }
96 
97 ImapSet CopyJob::resultingUids() const
98 {
99  Q_D( const CopyJob );
100  return d->resultingUids;
101 }
102 
103 void CopyJob::doStart()
104 {
105  Q_D( CopyJob );
106 
107  QByteArray parameters = d->set.toImapSequenceSet()+' ';
108  parameters += '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"';
109 
110  QByteArray command = "COPY";
111  if ( d->uidBased ) {
112  command = "UID "+command;
113  }
114 
115  d->tags << d->sessionInternal()->sendCommand( command, parameters );
116 }
117 
118 void CopyJob::handleResponse( const Message &response )
119 {
120  Q_D( CopyJob );
121 
122  for ( QList<Message::Part>::ConstIterator it = response.responseCode.begin();
123  it != response.responseCode.end(); ++it ) {
124  if ( it->toString() == "COPYUID" ) {
125  it = it + 3;
126  if ( it < response.responseCode.end() ) {
127  d->resultingUids = ImapSet::fromImapSequenceSet( it->toString() );
128  }
129  break;
130  }
131  }
132 
133  handleErrorReplies( response );
134 }
135 
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:25:16 by doxygen 1.8.3.1 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-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 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
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