22
22
#include <QtCore/QObject>
23
23
#include <QtCore/QHash>
24
#include <QtCore/QSettings>
25
26
#include <Accounts/Account>
27
28
#include "dbustypes.h"
29
30
class SyncEvolutionSessionProxy;
30
33
class SyncAccount : public QObject
35
38
static const QString GoogleContactService;
37
40
enum AccountState {
45
SyncAccount(Accounts::Account *account, QObject *parent=0);
47
SyncAccount(Accounts::Account *account,
50
virtual ~SyncAccount();
53
void cancel(const QString &serviceName = QString());
54
void sync(const QString &serviceName = QString());
52
56
void status() const;
53
57
AccountState state() const;
54
QDateTime lastSyncDate() const;
55
58
bool enabled() const;
56
59
QString displayName() const;
61
QString iconName(const QString &serviceName) const;
62
virtual QStringList availableServices() const;
63
QStringList enabledServices() const;
64
uint lastError() const;
66
static QString statusDescription(const QString &status);
60
69
void stateChanged(AccountState newState);
64
void enableChanged(bool enable);
70
void syncStarted(const QString &serviceName, bool firstSync);
71
void syncFinished(const QString &serviceName, bool firstSync, const QString &status);
72
void syncError(const QString &serviceName, int errorCode);
73
void enableChanged(const QString &serviceName, bool enable);
74
void configured(const QString &serviceName);
77
void onAccountConfigured();
78
void onAccountConfigureError();
68
80
void onAccountEnabledChanged(const QString &serviceName, bool enabled);
69
81
void onSessionStatusChanged(const QString &newStatus);
70
82
void onSessionProgressChanged(int progress);
74
86
Accounts::Account *m_account;
75
87
SyncEvolutionSessionProxy *m_currentSession;
88
QSettings *m_settings;
77
QString m_sessionName;
78
QStringMap m_syncOperation;
90
QMap<QString, bool> m_availabeServices;
79
91
AccountState m_state;
80
92
QList<QMetaObject::Connection> m_sessionConnections;
83
void continueConfigure();
93
QList<SyncConfigure*> m_pendingConfigs;
96
// current sync information
98
QString m_syncServiceName;
101
void configure(const QString &serviceName);
86
102
void setState(AccountState state);
103
void continueSync(const QString &serviceName);
88
104
void attachSession(SyncEvolutionSessionProxy *session);
89
105
void releaseSession();
90
QStringMap lastReport() const;
91
QString lastSyncStatus() const;
106
QStringMap lastReport(const QString &serviceName) const;
107
QString syncMode(const QString &serviceName, bool *firstSync) const;
108
QString lastSyncStatus(const QString &serviceName) const;
109
bool syncService(const QString &serviceName);
110
void setupServices();
111
QString sessionName(const QString &serviceName) const;
112
void dumpReport(const QStringMap &report) const;