• 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
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/KLocalizedString>
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 void CopyJob::setUidBased( bool uidBased )
85 {
86  Q_D( CopyJob );
87  d->uidBased = uidBased;
88 }
89 
90 bool CopyJob::isUidBased() const
91 {
92  Q_D( const CopyJob );
93  return d->uidBased;
94 }
95 
96 ImapSet CopyJob::resultingUids() const
97 {
98  Q_D( const CopyJob );
99  return d->resultingUids;
100 }
101 
102 void CopyJob::doStart()
103 {
104  Q_D( CopyJob );
105 
106  QByteArray parameters = d->set.toImapSequenceSet()+' ';
107  parameters += '\"' + KIMAP::encodeImapFolderName( d->mailBox.toUtf8() ) + '\"';
108 
109  QByteArray command = "COPY";
110  if ( d->uidBased ) {
111  command = "UID "+command;
112  }
113 
114  d->tags << d->sessionInternal()->sendCommand( command, parameters );
115 }
116 
117 void CopyJob::handleResponse( const Message &response )
118 {
119  Q_D( CopyJob );
120 
121  for ( QList<Message::Part>::ConstIterator it = response.responseCode.begin();
122  it != response.responseCode.end(); ++it ) {
123  if ( it->toString() == "COPYUID" ) {
124  it = it + 3;
125  if ( it < response.responseCode.end() ) {
126  d->resultingUids = ImapSet::fromImapSequenceSet( it->toString() );
127  }
128  break;
129  }
130  }
131 
132  handleErrorReplies( response );
133 }
rfccodecs.h
This file is part of the IMAP support library and defines the RfcCodecs class.
KIMAP::CopyJob::setMailBox
void setMailBox(const QString &mailBox)
Sets the destination mailbox.
Definition: copyjob.cpp:60
KIMAP::CopyJob::sequenceSet
ImapSet sequenceSet() const
The messages that will be copied.
Definition: copyjob.cpp:78
KIMAP::CopyJob::setUidBased
void setUidBased(bool uidBased)
Set how the sequence set should be interpreted.
Definition: copyjob.cpp:84
KIMAP::CopyJob::setSequenceSet
void setSequenceSet(const ImapSet &set)
Sets the messages to be copied.
Definition: copyjob.cpp:72
KIMAP::CopyJob::mailBox
QString mailBox() const
The destination mailbox.
Definition: copyjob.cpp:66
KIMAP::CopyJob::isUidBased
bool isUidBased() const
How to interpret the sequence set.
Definition: copyjob.cpp:90
KIMAP::ImapSet
Represents a set of natural numbers (1-> ) in a as compact as possible form.
Definition: imapset.h:140
KIMAP::ImapSet::fromImapSequenceSet
static ImapSet fromImapSequenceSet(const QByteArray &sequence)
Return the set corresponding to the given IMAP-compatible QByteArray representation.
Definition: imapset.cpp:293
KIMAP::CopyJob::resultingUids
ImapSet resultingUids() const
The UIDs of the new copies of the messages.
Definition: copyjob.cpp:96
KIMAP::CopyJob
Copies one or more messages to another mailbox.
Definition: copyjob.h:46
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