Dekko
Loading...
Searching...
No Matches
OutgoingServerGroup.qml
1/* Copyright (C) 2016 - 2017 Dan Chapman <dpniel@ubuntu.com>
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*/
18import QtQuick 2.4
19import QuickFlux 1.0
20import QtQuick.Controls.Suru 2.2
21import Lomiri.Components 1.3
22import Dekko.Mail.Accounts 1.0
23import Dekko.Mail.API 1.0
24import Dekko.Mail.Stores.Settings 1.0
25import Dekko.Lomiri.Components 1.0
26import "../components"
27
29 pageHeader.title: qsTr("Outgoing Server: %1").arg(SettingsStore.selectedAccount.name)
30
31 property SmtpAccountConfig outgoing: account.outgoing
32
33 function settingsChanged() {
34 if (outgoing.username !== username.text
35 || outgoing.password !== password.text
36 || outgoing.server !== server.text
37 || outgoing.port !== port.text
38 || outgoing.encryption !== encryption.selectedMethod
39 || outgoing.acceptUntrustedCertificates !== allowUntrustedSwitch.checked
40 || outgoing.saslMechanism !== authentication.selectedMethod
41 || outgoing.authFromCaps !== authFromCaps.checked)
42 {
43 Log.logInfo("OutgoingServerGroup::determineIfSettingsChanged", "Settings have changed")
44 return true
45 } else {
46 Log.logInfo("OutgoingServerGroup::determineIfSettingsChanged", "No changes")
47 return false
48 }
49 }
50
51 AppListener {
52 Filter {
53 type: SettingsKeys.saveCurrentGroup
54 onDispatched: {
55 Log.logInfo("OutgoingServerGroup::saveCurrentGroup", "Saving group settings")
56 if (!settingsChanged()) {
57 return
58 }
59 outgoing.username = username.text
60 outgoing.password = password.text
61 outgoing.server = server.text
62 outgoing.port = port.text
63 outgoing.encryption = encryption.selectedMethod
64 outgoing.saslMechanism = authentication.selectedMethod
65 outgoing.authFromCaps = authFromCaps.checked
66 outgoing.acceptUntrustedCertificates = allowUntrustedSwitch.checked
67 SettingsStore.settingsChanged = true
68 Log.logInfo("OutgoingServerGroup::saveCurrentGroup", "Saved group settings")
69 }
70 }
71 }
72
75 id: server
76 title: qsTr("Hostname")
77 placeholderText: "smtp.example.org"
78 inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhEmailCharactersOnly
79 text: outgoing ? outgoing.server : ""
80 }
81
83 id: port
84 title: qsTr("Port")
85 placeholderText: "465"
86 inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhDigitsOnly
87 text: outgoing ? outgoing.port : ""
88 }
89
91 id: username
92 objectName: "usernameInputField"
93 title: qsTr("Username")
94 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText | Qt.ImhEmailCharactersOnly
95 placeholderText: "user@example.org"
96 text: outgoing ? outgoing.username : ""
97 }
98
100 id: password
101 title: qsTr("Password")
102 inputMethodHints: Qt.ImhHiddenText | Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
103 echoMode: showPassword.checked ? TextInput.Normal : TextInput.Password
104 placeholderText: qsTr("Password")
105 text: outgoing ? outgoing.password : ""
106 }
107
109 id: showPassword
110 objectName: "showPwdCheckBox"
111 text: qsTr("Show password")
112 textColor: suru.secondaryForegroundColor
113 }
114
116 textMargin: 0
117 text: qsTr("Security settings")
118 }
119
121 id: encryption
122 anchors {
123 left: parent.left
124 right: parent.right
125 }
126 Component.onCompleted: {
127 if (outgoing) {
128 setEncryptionType(outgoing.encryption)
129 }
130 }
131 }
132
134 id: authentication
135 anchors {
136 left: parent.left
137 right: parent.right
138 }
139
140 Component.onCompleted: {
141 if (visible && outgoing) {
142 setAuthType(outgoing.saslMechanism)
143 }
144 }
145 }
146
148 id: authFromCaps
149 checked: outgoing ? outgoing.authFromCaps : false
150 text: qsTr("Authenticate from server capabilities")
151 }
152
154 id: allowUntrustedSwitch
155 checked: outgoing ? outgoing.acceptUntrustedCertificates : false
156 text: qsTr("Allow untrusted certificates")
157 }
158 }
159}