SVN_SILENT made messages (.desktop file) - always resolve ours
[trojita.git] / src / MSA / Account.h
blob395840a0409099f96b81d3e413af91e98dc47ae1
1 /* Copyright (C) 2014 Dan Chapman <dpniel@ubuntu.com>
2 Copyright (C) 2006 - 2016 Jan Kundrát <jkt@kde.org>
4 This file is part of the Trojita Qt IMAP e-mail client,
5 http://trojita.flaska.net/
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of
10 the License or (at your option) version 3 or any later version
11 accepted by the membership of KDE e.V. (or its successor approved
12 by the membership of KDE e.V.), which shall act as a proxy
13 defined in Section 14 of version 3 of the license.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef MSA_ACCOUNT_H
24 #define MSA_ACCOUNT_H
26 #include <QObject>
28 class QSettings;
30 namespace MSA {
32 class Account : public QObject
34 Q_OBJECT
36 Q_PROPERTY(QString server READ server WRITE setServer NOTIFY serverChanged)
37 Q_PROPERTY(int port READ port WRITE setPort NOTIFY portChanged)
38 Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged)
39 Q_PROPERTY(bool authenticateEnabled READ authenticateEnabled WRITE setAuthenticateEnabled NOTIFY authenticateEnabledChanged)
40 Q_PROPERTY(bool reuseImapAuthentication READ reuseImapAuthentication WRITE setReuseImapAuthentication NOTIFY reuseImapAuthenticationChanged)
41 Q_PROPERTY(QString pathToSendmail READ pathToSendmail WRITE setPathToSendmail NOTIFY pathToSendmailChanged)
42 Q_PROPERTY(bool saveToImap READ saveToImap WRITE setSaveToImap NOTIFY saveToImapChanged)
43 Q_PROPERTY(QString sentMailboxName READ sentMailboxName WRITE setSentMailboxName NOTIFY sentMailboxNameChanged)
44 Q_PROPERTY(bool useBurl READ useBurl WRITE setUseBurl NOTIFY useBurlChanged)
45 Q_PROPERTY(Method submissionMethod READ submissionMethod WRITE setSubmissionMethod NOTIFY submissionMethodChanged)
46 Q_ENUMS(Method)
48 public:
49 Account(QObject *parent, QSettings *settings, const QString &accountName);
51 enum class Method {
52 SMTP, /**< Non-encrypted connection over network */
53 SSMTP, /**< Encrypted network connection from the start */
54 SMTP_STARTTLS, /**< Starts with a non-encrypted network connection. Which gets upgraded using STARTTLS */
55 SENDMAIL, /**< Use a local Sendmail compatible transfer agent */
56 IMAP_SENDMAIL, /**< Uses the IMAP SENDMAIL Extension */
59 Method submissionMethod() const;
60 QString server() const;
61 int port() const;
62 QString username() const;
63 bool authenticateEnabled() const;
64 bool reuseImapAuthentication() const;
65 QString pathToSendmail() const;
66 bool saveToImap() const;
67 QString sentMailboxName() const;
68 bool useBurl() const;
70 static quint16 defaultPort(const Method method);
72 Q_INVOKABLE void saveSettings();
73 Q_INVOKABLE void restoreSettings();
75 signals:
76 void submissionMethodChanged();
77 void serverChanged();
78 void portChanged();
79 void usernameChanged();
80 void authenticateEnabledChanged();
81 void reuseImapAuthenticationChanged();
82 void pathToSendmailChanged();
83 void saveToImapChanged();
84 void sentMailboxNameChanged();
85 void useBurlChanged();
86 void showPortWarning(const QString &message);
87 void settingsSaved();
88 void settingsRestored();
90 public slots:
91 void setSubmissionMethod(const Method method);
92 void setServer(const QString &server);
93 void setPort(const quint16 port);
94 void setUsername(const QString &username);
95 void setAuthenticateEnabled(const bool auth);
96 void setReuseImapAuthentication(const bool reuseImapAuth);
97 void setPathToSendmail(const QString &pathToSendmail);
98 void setSaveToImap(const bool selected);
99 void setSentMailboxName(const QString &location);
100 void setUseBurl(const bool selected);
102 private slots:
103 void maybeShowPortWarning();
105 private:
106 QSettings *m_settings;
107 QString m_accountName;
108 QString m_server;
109 QString m_username;
110 quint16 m_port;
111 QString m_password;
112 bool m_authenticateEnabled;
113 bool m_reuseImapAuth;
114 QString m_pathToSendmail;
115 bool m_saveToImap;
116 QString m_sentMailboxName;
117 bool m_useBurl;
119 Method m_msaSubmissionMethod;
125 Q_DECLARE_METATYPE(MSA::Account::Method)
127 #endif // MSA_ACCOUNT_H