• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 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/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
32namespace 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
47using namespace KIMAP;
48
49CopyJob::CopyJob( Session *session )
50 : Job( *new CopyJobPrivate( session, i18n( "Copy" ) ) )
51{
52 Q_D( CopyJob );
53 d->uidBased = false;
54}
55
56CopyJob::~CopyJob()
57{
58}
59
60void CopyJob::setMailBox( const QString &mailBox )
61{
62 Q_D( CopyJob );
63 d->mailBox = mailBox;
64}
65
66QString CopyJob::mailBox() const
67{
68 Q_D( const CopyJob );
69 return d->mailBox;
70}
71
72void CopyJob::setSequenceSet( const ImapSet &set )
73{
74 Q_D( CopyJob );
75 d->set = set;
76}
77
78ImapSet CopyJob::sequenceSet() const
79{
80 Q_D( const CopyJob );
81 return d->set;
82}
83
84void CopyJob::setUidBased( bool uidBased )
85{
86 Q_D( CopyJob );
87 d->uidBased = uidBased;
88}
89
90bool CopyJob::isUidBased() const
91{
92 Q_D( const CopyJob );
93 return d->uidBased;
94}
95
96ImapSet CopyJob::resultingUids() const
97{
98 Q_D( const CopyJob );
99 return d->resultingUids;
100}
101
102void 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
117void 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}
KIMAP::CopyJob
Copies one or more messages to another mailbox.
Definition: copyjob.h:47
KIMAP::CopyJob::setUidBased
void setUidBased(bool uidBased)
Set how the sequence set should be interpreted.
Definition: copyjob.cpp:84
KIMAP::CopyJob::mailBox
QString mailBox() const
The destination mailbox.
Definition: copyjob.cpp:66
KIMAP::CopyJob::setSequenceSet
void setSequenceSet(const ImapSet &set)
Sets the messages to be copied.
Definition: copyjob.cpp:72
KIMAP::CopyJob::isUidBased
bool isUidBased() const
How to interpret the sequence set.
Definition: copyjob.cpp:90
KIMAP::CopyJob::resultingUids
ImapSet resultingUids() const
The UIDs of the new copies of the messages.
Definition: copyjob.cpp:96
KIMAP::CopyJob::sequenceSet
ImapSet sequenceSet() const
The messages that will be copied.
Definition: copyjob.cpp:78
KIMAP::CopyJob::setMailBox
void setMailBox(const QString &mailBox)
Sets the destination mailbox.
Definition: copyjob.cpp:60
KIMAP::ImapSet
Represents a set of natural numbers (1-> ) in a as compact as possible form.
Definition: imapset.h:141
KIMAP::ImapSet::fromImapSequenceSet
static ImapSet fromImapSequenceSet(const QByteArray &sequence)
Return the set corresponding to the given IMAP-compatible QByteArray representation.
Definition: imapset.cpp:293
rfccodecs.h
This file is part of the IMAP support library and defines the RfcCodecs class.
KIMAP::encodeImapFolderName
QByteArray encodeImapFolderName(const QByteArray &src)
Converts an Unicode IMAP mailbox to a QByteArray which can be used in IMAP communication.
Definition: rfccodecs.cpp:198
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 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.14.10 API Reference

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