Debian Codegraph @

Dekko/backend/autoconfig/serverconfiguration.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 SERVERCONFIGURATION_H
17 #define SERVERCONFIGURATION_H
18
19 #include <QObject>
20 #include <QVariantMap>
21
22 class ServerConfiguration : public QObject
23 {
24 Q_OBJECT
25 Q_PROPERTY(QString imapHostName READ imapHost NOTIFY configChanged )
26 Q_PROPERTY(int imapPort READ imapPort NOTIFY configChanged )
27 Q_PROPERTY(NetworkMethod imapMethod READ imapMethod NOTIFY configChanged)
28 Q_PROPERTY(QString smtpHostName READ smtpHost NOTIFY configChanged )
29 Q_PROPERTY(int smtpPort READ smtpPort NOTIFY configChanged )
30 Q_PROPERTY(NetworkMethod smtpMethod READ smtpMethod NOTIFY configChanged )
31 Q_PROPERTY(bool isValid READ isValid NOTIFY configChanged)
32 Q_ENUMS(NetworkMethod)
33 Q_ENUMS(DefaultPorts)
34
35 public:
36 explicit ServerConfiguration(QObject *parent = 0);
37
38 enum NetworkMethod {
39 INVALID, /**< No configuration was provided */
40 CLEAR_TEXT, /**< Cleartext connection over network -- no encryption whatsoever */
41 STARTTLS, /**< Network connection which starts in plaintext and is upgraded via STARTTLS later on */
42 SSL_TLS, /**< Network connection over SSL/TLS encrypted from the very beginning */
43 };
44
45 enum DefaultPorts {
46 PORT_IMAP = 143,
47 PORT_IMAPS = 993,
48 PORT_SMTP = 587,
49 PORT_SSMTP = 465
50 };
51
52 // IMAP configs
53 QString imapHost() const;
54 void setImapHost(const QString &hostname);
55 int imapPort() const;
56 void setImapPort(const int &port);
57 NetworkMethod imapMethod() const;
58 void setImapMethod(const NetworkMethod &method);
59
60 //SMTP configs
61 QString smtpHost() const;
62 void setSmtpHost(const QString &hostname);
63 int smtpPort() const;
64 void setSmtpPort(const int &port);
65 NetworkMethod smtpMethod() const;
66 void setSmtpMethod(const NetworkMethod &method);
67
68 bool isValid() const;
69 Q_INVOKABLE QVariantMap toMap() const;
70
71 bool operator ==(const ServerConfiguration *config) const;
72
73 signals:
74 void configChanged();
75
76 private:
77 QString m_imapHost;
78 QString m_smtpHost;
79 int m_imapPort;
80 int m_smtpPort;
81 NetworkMethod m_imapMethod;
82 NetworkMethod m_smtpMethod;
83
84 };
85
86 #endif // SERVERCONFIGURATION_H