1/*
2 Copyright (c) 2009 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#ifndef AKONADI_RESOURCESELECTJOB_P_H
21#define AKONADI_RESOURCESELECTJOB_P_H
22
23#include "akonadiprivate_export.h"
24
25#include <akonadi/job.h>
26
27namespace Akonadi {
28
29class ResourceSelectJobPrivate;
30
31/**
32 * @internal
33 *
34 * @short Job that selects a resource context for remote identifier based operations.
35 *
36 * This job selects a resource context that is used whenever remote identifier
37 * based operations ( e.g. fetch items or collections by remote identifier ) are
38 * executed.
39 *
40 * Example:
41 *
42 * @code
43 *
44 * using namespace Akonadi;
45 *
46 * // Find out the akonadi id of the item with the remote id 'd1627013c6d5a2e7bb58c12560c27047'
47 * // that is stored in the resource with identifier 'my_mail_resource'
48 *
49 * Session *m_resourceSession = new Session( "resourceSession" );
50 *
51 * ResourceSelectJob *job = new ResourceSelectJob( "my_mail_resource", resourceSession );
52 *
53 * connect( job, SIGNAL(result(KJob*)), SLOT(resourceSelected(KJob*)) );
54 * ...
55 *
56 * void resourceSelected( KJob *job )
57 * {
58 * if ( job->error() )
59 * return;
60 *
61 * Item item;
62 * item.setRemoteIdentifier( "d1627013c6d5a2e7bb58c12560c27047" );
63 *
64 * ItemFetchJob *fetchJob = new ItemFetchJob( item, m_resourceSession );
65 * connect( fetchJob, SIGNAL(result(KJob*)), SLOT(itemFetched(KJob*)) );
66 * }
67 *
68 * void itemFetched( KJob *job )
69 * {
70 * if ( job->error() )
71 * return;
72 *
73 * const Item item = job->items().first();
74 *
75 * qDebug() << "Remote id" << item.remoteId() << "has akonadi id" << item.id();
76 * }
77 *
78 * @endcode
79 *
80 * @author Volker Krause <vkrause@kde.org>
81 */
82class AKONADI_TESTS_EXPORT ResourceSelectJob : public Job
83{
84 Q_OBJECT
85public:
86 /**
87 * Selects the specified resource for all following remote identifier
88 * based operations in the same session.
89 *
90 * @param identifier The resource identifier, or any empty string to reset
91 * the selection.
92 * @param parent The parent object.
93 */
94 explicit ResourceSelectJob(const QString &identifier, QObject *parent = 0);
95
96protected:
97 void doStart();
98
99private:
100 //@cond PRIVATE
101 Q_DECLARE_PRIVATE(ResourceSelectJob)
102 //@endcond PRIVATE
103};
104
105}
106
107#endif
108