Debian Codegraph @

Dekko/backend/accounts/AccountValidator.h

raw symbols SCIP
1 /* Copyright (C) 2016 - 2017 Dan Chapman <[email protected]>
2
3 This file is part of Dekko email client for Ubuntu devices
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
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 /** @ingroup group_accounts */
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(); // qml one
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; // store it locally
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 // ACCOUNTVALIDATOR_H