1 /*
2    SPDX-FileCopyrightText: 2013-2021 Laurent Montel <montel@kde.org>
3 
4    SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "libsieveeditor_private_export.h"
10 #include "sieveeditorutil.h"
11 #include <QWidget>
12 
13 namespace Ui
14 {
15 class ServerSieveSettings;
16 }
17 namespace MailTransport
18 {
19 class ServerTest;
20 }
21 class QComboBox;
22 class LIBSIEVEEDITOR_TESTS_EXPORT ServerSieveSettings : public QWidget
23 {
24     Q_OBJECT
25 
26 public:
27     explicit ServerSieveSettings(QWidget *parent = nullptr);
28     ~ServerSieveSettings() override;
29 
30     Q_REQUIRED_RESULT QString serverName() const;
31     void setServerName(const QString &name);
32 
33     Q_REQUIRED_RESULT int port() const;
34     void setPort(int value);
35 
36     Q_REQUIRED_RESULT QString userName() const;
37     void setUserName(const QString &name);
38 
39     Q_REQUIRED_RESULT QString password() const;
40     void setPassword(const QString &pass);
41 
42     void setServerSieveConfig(const SieveEditorUtil::SieveServerConfig &conf);
43     Q_REQUIRED_RESULT SieveEditorUtil::SieveServerConfig serverSieveConfig() const;
44 
45     Q_REQUIRED_RESULT QString imapServerName() const;
46     void setImapServerName(const QString &name);
47 
48     Q_REQUIRED_RESULT int imapPort() const;
49     void setImapPort(int value);
50 
51     Q_REQUIRED_RESULT QString imapUserName() const;
52     void setImapUserName(const QString &name);
53 
54     Q_REQUIRED_RESULT QString imapPassword() const;
55     void setImapPassword(const QString &pass);
56 
57     void setAuthenticationType(KSieveUi::SieveImapAccountSettings::AuthenticationMode type);
58     Q_REQUIRED_RESULT KSieveUi::SieveImapAccountSettings::AuthenticationMode authenticationType() const;
59 Q_SIGNALS:
60     void enableOkButton(bool enabled);
61 
62 private:
63     void slotUserServerNameChanged();
64     void slotTest();
65 
66     void slotFinished(const QVector<int> &testResult);
67     void slotEncryptionRadioChanged();
68 
69 private:
70     void populateDefaultAuthenticationOptions(QComboBox *combobox);
71     void slotSafetyChanged();
72     void populateDefaultComboBoxAuthenticationOptions();
73     Ui::ServerSieveSettings *const ui;
74     MailTransport::ServerTest *mServerTest = nullptr;
75 };
76 
77