File indexing completed on 2024-05-12 05:11:12
0001 /* 0002 SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "akonadi-mime_export.h" 0010 #include "specialmailcollections.h" 0011 0012 #include <Akonadi/SpecialCollectionsRequestJob> 0013 0014 #include <memory> 0015 0016 namespace Akonadi 0017 { 0018 class SpecialMailCollectionsRequestJobPrivate; 0019 0020 /** 0021 * @short A job to request SpecialMailCollections. 0022 * 0023 * Use this job to request the SpecialMailCollections you need. You can request both 0024 * default SpecialMailCollections and SpecialMailCollections in a given resource. The default 0025 * SpecialMailCollections resource is created when the first default SpecialCollection is 0026 * requested, but if a SpecialCollection in a custom resource is requested, this 0027 * job expects that resource to exist already. 0028 * 0029 * If the folders you requested already exist, this job simply succeeds. 0030 * Otherwise, it creates the required collections and registers them with 0031 * SpecialMailCollections. 0032 * 0033 * Example: 0034 * 0035 * @code 0036 * 0037 * SpecialMailCollectionsRequestJob *job = new SpecialMailCollectionsRequestJob( this ); 0038 * job->requestDefaultCollection( SpecialMailCollections::Outbox ); 0039 * connect( job, SIGNAL(result(KJob*)), 0040 * this, SLOT(requestDone(KJob*)) ); 0041 * 0042 * ... 0043 * 0044 * MyClass::requestDone( KJob *job ) 0045 * { 0046 * if ( job->error() ) 0047 * return; 0048 * 0049 * SpecialMailCollectionsRequestJob *requestJob = qobject_cast<SpecialMailCollectionsRequestJob*>( job ); 0050 * 0051 * const Collection collection = requestJob->collection(); 0052 * ... 0053 * } 0054 * 0055 * @endcode 0056 * 0057 * @author Constantin Berzan <exit3219@gmail.com> 0058 * @since 4.4 0059 */ 0060 class AKONADI_MIME_EXPORT SpecialMailCollectionsRequestJob : public SpecialCollectionsRequestJob 0061 { 0062 Q_OBJECT 0063 0064 public: 0065 /** 0066 * Creates a new special mail collections request job. 0067 */ 0068 explicit SpecialMailCollectionsRequestJob(QObject *parent = nullptr); 0069 0070 /** 0071 * Destroys the special mail collections request job. 0072 */ 0073 ~SpecialMailCollectionsRequestJob() override; 0074 0075 /** 0076 * Requests a special mail collection of the given @p type in the default resource. 0077 */ 0078 void requestDefaultCollection(SpecialMailCollections::Type type); 0079 0080 /** 0081 * Requests a special mail collection of the given @p type in the given resource @p instance. 0082 */ 0083 void requestCollection(SpecialMailCollections::Type type, const AgentInstance &instance); 0084 0085 private: 0086 //@cond PRIVATE 0087 friend class SpecialMailCollectionsRequestJobPrivate; 0088 0089 std::unique_ptr<SpecialMailCollectionsRequestJobPrivate> const d; 0090 //@endcond 0091 }; 0092 } // namespace Akonadi