1 | /* |
2 | Copyright (c) 2008 Volker Krause <vkrause@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 "itemmovejob.h" |
21 | |
22 | #include "collection.h" |
23 | #include "item.h" |
24 | #include "job_p.h" |
25 | #include "protocolhelper_p.h" |
26 | #include <akonadi/private/imapparser_p.h> |
27 | #include "movejobimpl_p.h" |
28 | |
29 | using namespace Akonadi; |
30 | |
31 | class Akonadi::ItemMoveJobPrivate : public MoveJobImpl<Item, ItemMoveJob> |
32 | { |
33 | public: |
34 | ItemMoveJobPrivate(ItemMoveJob *parent) |
35 | : MoveJobImpl<Item, ItemMoveJob>(parent) |
36 | { |
37 | } |
38 | Q_DECLARE_PUBLIC(ItemMoveJob) |
39 | }; |
40 | |
41 | ItemMoveJob::ItemMoveJob(const Item &item, const Collection &destination, QObject *parent) |
42 | : Job(new ItemMoveJobPrivate(this), parent) |
43 | { |
44 | Q_D(ItemMoveJob); |
45 | d->destination = destination; |
46 | d->objectsToMove.append(item); |
47 | } |
48 | |
49 | ItemMoveJob::ItemMoveJob(const Item::List &items, const Collection &destination, QObject *parent) |
50 | : Job(new ItemMoveJobPrivate(this), parent) |
51 | { |
52 | Q_D(ItemMoveJob); |
53 | d->destination = destination; |
54 | d->objectsToMove = items; |
55 | } |
56 | |
57 | ItemMoveJob::ItemMoveJob(const Item::List &items, const Collection &source, const Collection &destination, QObject *parent) |
58 | : Job(new ItemMoveJobPrivate(this), parent) |
59 | { |
60 | Q_D(ItemMoveJob); |
61 | d->source = source; |
62 | d->destination = destination; |
63 | d->objectsToMove = items; |
64 | } |
65 | |
66 | |
67 | ItemMoveJob::~ItemMoveJob() |
68 | { |
69 | } |
70 | |
71 | void ItemMoveJob::doStart() |
72 | { |
73 | Q_D(ItemMoveJob); |
74 | d->sendCommand("MOVE" ); |
75 | } |
76 | |
77 | Collection ItemMoveJob::destinationCollection() const |
78 | { |
79 | Q_D(const ItemMoveJob); |
80 | return d->destination; |
81 | } |
82 | |
83 | QList<Item> ItemMoveJob::items() const |
84 | { |
85 | Q_D(const ItemMoveJob); |
86 | return d->objectsToMove; |
87 | } |
88 | |
89 | |