| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#ifndef ACCOUNTVALIDATOR_H |
| 19 |
#define ACCOUNTVALIDATOR_H |
| 20 |
|
| 21 |
#include <QLoggingCategory> |
| 22 |
#include <QObject> |
| 23 |
#include <QPointer> |
| 24 |
#include <QTimer> |
| 25 |
#include <qmailserviceaction.h> |
| 26 |
#include "Account.h" |
| 27 |
|
| 28 |
Q_DECLARE_LOGGING_CATEGORY(D_ACCOUNTS_VALIDATOR) |
| 29 |
|
| 30 |
|
| 31 |
class AccountValidator: public QObject |
| 32 |
{ |
| 33 |
Q_OBJECT |
| 34 |
Q_PROPERTY(bool inProgress READ inProgress NOTIFY inProgressChanged) |
| 35 |
Q_ENUMS(FailureReason) |
| 36 |
Q_ENUMS(State) |
| 37 |
public: |
| 38 |
explicit AccountValidator(QObject *parent = 0); |
| 39 |
|
| 40 |
enum FailureReason { |
| 41 |
AccountInvalid, |
| 42 |
ConfigInvalid, |
| 43 |
ConnectionError, |
| 44 |
DiskFull, |
| 45 |
ExternalError, |
| 46 |
FailedLogin, |
| 47 |
InternalError, |
| 48 |
Timeout, |
| 49 |
UntrustedCertificates, |
| 50 |
ValidationAlreadyInProgress |
| 51 |
}; |
| 52 |
|
| 53 |
enum State { |
| 54 |
None, |
| 55 |
RetrieveFolderList, |
| 56 |
CreateStandardFolders, |
| 57 |
TransmitMessage |
| 58 |
}; |
| 59 |
bool inProgress() const { return m_inProgress; } |
| 60 |
|
| 61 |
signals: |
| 62 |
void success(); |
| 63 |
void failed(AccountConfiguration::ServiceType service, FailureReason reason); |
| 64 |
void failedActionStatus(QMailServiceAction::Status::ErrorCode errorCode); |
| 65 |
void validationFailed(); |
| 66 |
void inProgressChanged(); |
| 67 |
|
| 68 |
public slots: |
| 69 |
void validateAccount(Account *account); |
| 70 |
|
| 71 |
private slots: |
| 72 |
void handleAccountActivity(QMailServiceAction::Activity activity); |
| 73 |
|
| 74 |
void createStandardFolders(); |
| 75 |
void testTransmission(); |
| 76 |
|
| 77 |
private: |
| 78 |
QPointer<Account> m_account; |
| 79 |
QPointer<QMailRetrievalAction> m_retrievelAction; |
| 80 |
QPointer<QMailTransmitAction> m_transmitAction; |
| 81 |
bool m_inProgress; |
| 82 |
State m_state; |
| 83 |
QTimer *m_timer; |
| 84 |
|
| 85 |
void testFailed(AccountConfiguration::ServiceType serviceType, QMailServiceAction::Status status); |
| 86 |
void init(); |
| 87 |
void cleanUp(); |
| 88 |
void setInProgress(const bool inProgress) { |
| 89 |
m_inProgress = inProgress; |
| 90 |
emit inProgressChanged(); |
| 91 |
} |
| 92 |
}; |
| 93 |
|
| 94 |
#endif |