| 1 |
#ifndef CACHEMANAGERPLUGIN_H |
| 2 |
#define CACHEMANAGERPLUGIN_H |
| 3 |
|
| 4 |
#include <QObject> |
| 5 |
#include <QDBusPendingCallWatcher> |
| 6 |
#include <PluginInfo.h> |
| 7 |
#include <PluginLoader.h> |
| 8 |
#include <QScopedPointer> |
| 9 |
#include <qmailmessagekey.h> |
| 10 |
#include <qmailmessage.h> |
| 11 |
|
| 12 |
class CacheManagerService : public ServicePlugin |
| 13 |
{ |
| 14 |
Q_OBJECT |
| 15 |
public: |
| 16 |
explicit CacheManagerService(QObject *parent = 0); |
| 17 |
|
| 18 |
enum Period { |
| 19 |
WEEK = 0, |
| 20 |
FORTNIGHT = 1, |
| 21 |
MONTH = 2, |
| 22 |
THREE_MONTH = 3, |
| 23 |
SIX_MONTH = 4, |
| 24 |
ALL = 5 |
| 25 |
}; |
| 26 |
|
| 27 |
|
| 28 |
public: |
| 29 |
virtual QString pluginId() const override; |
| 30 |
virtual QString location() const override; |
| 31 |
virtual QString i18n() const override; |
| 32 |
virtual QVariantMap documentation() const override; |
| 33 |
|
| 34 |
|
| 35 |
public: |
| 36 |
virtual void start(); |
| 37 |
virtual void stop(); |
| 38 |
|
| 39 |
virtual void messageReceived(const QString &key, const QVariant &value); |
| 40 |
|
| 41 |
protected: |
| 42 |
|
| 43 |
void buildQuery(const QMailAccountId &id, const Period &period); |
| 44 |
|
| 45 |
void queryMessages(const QMailMessageKey &key); |
| 46 |
|
| 47 |
private slots: |
| 48 |
void sendQueries(); |
| 49 |
void removePending(); |
| 50 |
void handleQueryResponse(QDBusPendingCallWatcher *call); |
| 51 |
|
| 52 |
private: |
| 53 |
QList<QMailMessageKey> m_queries; |
| 54 |
QMailMessageIdList m_toRemove; |
| 55 |
}; |
| 56 |
|
| 57 |
class CacheManagerPlugin : public QObject, public PluginInterface |
| 58 |
{ |
| 59 |
Q_OBJECT |
| 60 |
Q_INTERFACES(PluginInterface) |
| 61 |
Q_PLUGIN_METADATA(IID "org.dekkoproject.cache-manager") |
| 62 |
|
| 63 |
|
| 64 |
public: |
| 65 |
virtual QString name() const; |
| 66 |
virtual QString description() const; |
| 67 |
virtual PluginInfo *create(QObject *parent) const; |
| 68 |
}; |
| 69 |
|
| 70 |
|
| 71 |
#endif |