Dekko
Loading...
Searching...
No Matches
IncomingServerGroup.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("Incoming Server: %1").arg(SettingsStore.selectedAccount.name)
30
31 property AccountConfig incoming: account.incoming
32
33 readonly property bool isIMAP: incoming ? incoming.serviceType === AccountConfig.IMAP : false
34 readonly property bool isPOP: incoming ? incoming.serviceType === AccountConfig.POP3 : false
35
36 function settingsChanged() {
37 if (incoming.name !== username.text
38 || incoming.email !== username.text
39 || incoming.password !== password.text
40 || incoming.server !== server.text
41 || incoming.port !== port.text
42 || incoming.encryption !== encryption.selectedMethod
43 || incoming.acceptUntrustedCertificates !== allowUntrustedSwitch.checked
44 || (isIMAP && incoming.saslMechanism !== authentication.selectedMethod)
45 || (isIMAP && incoming.idleEnabled !== idleEnabled.checked)
46 || (isIMAP && incoming.isAutoDownload !== noMaxMailSize.checked)
47 || (isIMAP && incoming.downloadAttachments !== autoDownloadAttachments.checked)
48 || incoming.checkInterval !== parseInt(checkInterval.text)
49 || incoming.checkWhenRoaming !== checkRoaming.checked
50 || incoming.maxMailSize !== parseInt(maxMailSize.text)
51 || incoming.canDeleteMail !== canDeleteMail.checked)
52 {
53 Log.logInfo("IncomingServerGroup::determineIfSettingsChanged", "Settings have changed")
54 return true
55 } else {
56 Log.logInfo("IncomingServerGroup::determineIfSettingsChanged", "No changes")
57 return false
58 }
59 }
60
61 AppListener {
62 Filter {
63 type: SettingsKeys.saveCurrentGroup
64 onDispatched: {
65 Log.logInfo("IncomingServerGroup::saveCurrentGroup", "Saving group settings")
66 if (!settingsChanged()) {
67 return
68 }
69 incoming.name = username.text
70 incoming.email = username.text
71 incoming.password = password.text
72 incoming.server = server.text
73 incoming.port = port.text
74 incoming.encryption = encryption.selectedMethod
75 incoming.acceptUntrustedCertificates = allowUntrustedSwitch.checked
76 if (isIMAP) {
77 Log.logInfo("IncomingServerGroup::saveCurrentGroup", "Saving IMAP properties")
78 incoming.saslMechanism = authentication.selectedMethod
79 // incoming.checkOnStart = checkOnStart.checked
80 incoming.idleEnabled = idleEnabled.checked
81 incoming.checkInterval = parseInt(checkInterval.text)
82 incoming.checkWhenRoaming = checkRoaming.checked
83 incoming.maxMailSize = parseInt(maxMailSize.text)
84 incoming.isAutoDownload = noMaxMailSize.checked
85 incoming.downloadAttachments = autoDownloadAttachments.checked
86 incoming.canDeleteMail = canDeleteMail.checked
87 } else if (isPOP) {
88 Log.logInfo("IncomingServerGroup::saveCurrentGroup", "Saving POP3 properties")
89 // incoming.checkOnStart = checkOnStart.checked
90 incoming.checkInterval = parseInt(checkInterval.text)
91 incoming.checkWhenRoaming = checkRoaming.checked
92 incoming.maxMailSize = parseInt(maxMailSize.text)
93 incoming.isAutoDownload = noMaxMailSize.checked
94 incoming.canDeleteMail = canDeleteMail.checked
95 }
96 SettingsStore.settingsChanged = true
97 Log.logInfo("IncomingServerGroup::saveCurrentGroup", "Saved group settings")
98 }
99 }
100 }
101
104 id: server
105 objectName: "serverInputField"
106 title: qsTr("Hostname")
107 placeholderText: "imap.example.org"
108 inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhEmailCharactersOnly
109 text: incoming ? incoming.server : ""
110 }
111
113 id: port
114 objectName: "portInputField"
115 title: qsTr("Port")
116 placeholderText: "993"
117 inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhDigitsOnly
118 text: incoming ? incoming.port : ""
119 }
120
122 id: username
123 objectName: "usernameInputField"
124 title: qsTr("Username")
125 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText | Qt.ImhEmailCharactersOnly
126 placeholderText: "user@example.org"
127 text: incoming ? incoming.email : ""
128 }
129
131 id: password
132 objectName: "userInputPasswordField"
133 title: qsTr("Password")
134 inputMethodHints: Qt.ImhHiddenText | Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
135 echoMode: showPassword.checked ? TextInput.Normal : TextInput.Password
136 placeholderText: qsTr("Password")
137 text: incoming ? incoming.password : ""
138 }
139
141 id: showPassword
142 objectName: "showPwdCheckBox"
143 text: qsTr("Show password")
144 textColor: Suru.secondaryForegroundColor
145 }
146
148 textMargin: 0
149 text: qsTr("Security settings")
150 }
151
153 id: encryption
154 anchors {
155 left: parent.left
156 right: parent.right
157 }
158 Component.onCompleted: {
159 if (incoming) {
160 setEncryptionType(incoming.encryption)
161 }
162 }
163 }
164
166 id: authentication
167 anchors {
168 left: parent.left
169 right: parent.right
170 }
171 visible: incoming.serviceType !== AccountConfig.POP3
172
173 Component.onCompleted: {
174 if (visible && incoming) {
175 console.log("incomigauth", incoming.saslMechanism)
176 setAuthType(incoming.saslMechanism)
177 }
178 }
179 }
180
182 id: allowUntrustedSwitch
183 checked: incoming ? incoming.acceptUntrustedCertificates : false
184 text: qsTr("Allow untrusted certificates")
185 }
186
188 textMargin: 0
189 text: qsTr("Server settings")
190 }
191
193 id: checkOnStart
194 text: qsTr("Check for new mail on start")
195 checked: true
196 }
197
199 id: idleEnabled
200 text: qsTr("Enable IMAP IDLE")
201 visible: incoming ? (isIMAP && incoming.canIDLE) : false
202 checked: incoming ? incoming.idleEnabled : false
203 }
204
206 id: checkInterval
207 title: qsTr("Check interval (minutes), set 0 to disable auto checks")
208 text: incoming ? incoming.checkInterval : 5
209 inputMethodHints: Qt.ImhDigitsOnly
210 }
211
213 id: checkRoaming
214 text: qsTr("Check when roaming")
215 checked: incoming ? incoming.checkWhenRoaming : false
216 }
217
219 id: maxMailSize
220 title: qsTr("Maximum mail size (MB)")
221 text: incoming ? incoming.maxMailSize : ""
222 }
223
225 id: noMaxMailSize
226 text: qsTr("No maximum mail size")
227 textColor: Suru.secondaryForegroundColor
228 checked: incoming ? incoming.isAutoDownload : false
229 }
230
232 id: autoDownloadAttachments
233 visible: isIMAP
234 text: qsTr("Automatically download attachments")
235 checked: incoming ? incoming.downloadAttachments : false
236 }
237
239 id: canDeleteMail
240 text: qsTr("Allowed to delete mail")
241 checked: incoming ? incoming.canDeleteMail : false
242 }
243 }
244}