Debian Codegraph @

Dekko/backend/autoconfig/autodiscover.h

raw symbols SCIP
1 /* Copyright (C) 2015 Dan Chapman <[email protected]>
2
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License as
5 published by the Free Software Foundation; either version 2 of
6 the License or (at your option) version 3
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 #ifndef AUTODISCOVER_H
17 #define AUTODISCOVER_H
18
19 #include <QObject>
20 #include <QPointer>
21 #include <QScopedPointer>
22 #include "autoconfig.h"
23 #include "emailvalidator.h"
24 #include "srvlookup.h"
25 #include "emailprovider.h"
26
27 class AutoDiscover : public QObject
28 {
29 Q_OBJECT
30 Q_PROPERTY(bool inProgress READ inProgress NOTIFY progressChanged)
31 Q_PROPERTY(QString domain MEMBER m_domain CONSTANT)
32 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
33 Q_ENUMS(Status)
34 public:
35 explicit AutoDiscover(QObject *parent = 0);
36
37 enum Status {
38 INVALID,
39 NEW_REQUEST,
40 REQUEST_LOCAL,
41 REQUEST_AUTOCONFIG_V12, // dekko v1.2
42 REQUEST_AUTOCONFIG_V11, // tbird v1.1
43 REQUEST_AUTOCONFIG_WELLKNOWN_V12, // dekko v1.2
44 REQUEST_AUTOCONFIG_WELLKNOWN_V11, // tbird v1.1
45 REQUEST_AUTOCONFIG_ISPDB, // autoconfig.thunderbird.net
46 // REQUEST_SRV,
47 // REQUEST_WEBFINGER, // Is this possible?? it should be!
48 REQUEST_FAILED,
49 REQUEST_SUCCEEDED,
50 BUILDING_RESULT
51 };
52
53 Q_INVOKABLE bool isValidMailAddress(const QString &address);
54 bool inProgress() const;
55 Status status() const;
56
57 signals:
58 void invalidMailAddress(QString address);
59 void success();
60 void failed();
61 void progressChanged();
62 void statusChanged();
63 void noNetworkAvailable();
64
65 public slots:
66 void lookUp(const QString &mailAddress);
67
68 private:
69 void buildNextRequest();
70 void handleRequestFailed();
71 void setStatus(Status status);
72
73 private slots:
74 void handleRequestSucceeded(EmailProvider *config);
75
76 private:
77 QPointer<EmailProvider> m_serverConfig;
78 QPointer<AutoConfig> m_autoConfig;
79 QPointer<SrvLookup> m_srvLookup;
80
81 QString m_domain;
82 Status m_status;
83 bool m_inProgress;
84
85 // For UNIT TESTS
86 Q_PROPERTY(bool testMode MEMBER m_testMode)
87 Q_PROPERTY(EmailProvider *_serverConf MEMBER m_serverConfig)
88 bool m_testMode;
89
90 };
91
92 #endif // AUTODISCOVER_H