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
29 pageHeader.title: qsTr(
"Incoming Server: %1").arg(SettingsStore.selectedAccount.name)
31 property AccountConfig incoming: account.incoming
33 readonly
property bool isIMAP: incoming ? incoming.serviceType === AccountConfig.IMAP :
false
34 readonly
property bool isPOP: incoming ? incoming.serviceType === AccountConfig.POP3 :
false
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)
53 Log.logInfo(
"IncomingServerGroup::determineIfSettingsChanged",
"Settings have changed")
56 Log.logInfo(
"IncomingServerGroup::determineIfSettingsChanged",
"No changes")
63 type: SettingsKeys.saveCurrentGroup
65 Log.logInfo(
"IncomingServerGroup::saveCurrentGroup",
"Saving group settings")
66 if (!settingsChanged()) {
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
77 Log.logInfo(
"IncomingServerGroup::saveCurrentGroup",
"Saving IMAP properties")
78 incoming.saslMechanism = authentication.selectedMethod
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
88 Log.logInfo(
"IncomingServerGroup::saveCurrentGroup",
"Saving POP3 properties")
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
96 SettingsStore.settingsChanged =
true
97 Log.logInfo(
"IncomingServerGroup::saveCurrentGroup",
"Saved group settings")
105 objectName:
"serverInputField"
106 title: qsTr(
"Hostname")
107 placeholderText:
"imap.example.org"
108 inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhEmailCharactersOnly
109 text: incoming ? incoming.server :
""
114 objectName:
"portInputField"
116 placeholderText:
"993"
117 inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhDigitsOnly
118 text: incoming ? incoming.port :
""
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 :
""
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 :
""
142 objectName:
"showPwdCheckBox"
143 text: qsTr(
"Show password")
144 textColor: Suru.secondaryForegroundColor
149 text: qsTr(
"Security settings")
158 Component.onCompleted: {
160 setEncryptionType(incoming.encryption)
171 visible: incoming.serviceType !== AccountConfig.POP3
173 Component.onCompleted: {
174 if (visible && incoming) {
175 console.log(
"incomigauth", incoming.saslMechanism)
176 setAuthType(incoming.saslMechanism)
182 id: allowUntrustedSwitch
183 checked: incoming ? incoming.acceptUntrustedCertificates :
false
184 text: qsTr(
"Allow untrusted certificates")
189 text: qsTr(
"Server settings")
194 text: qsTr(
"Check for new mail on start")
200 text: qsTr(
"Enable IMAP IDLE")
201 visible: incoming ? (isIMAP && incoming.canIDLE) :
false
202 checked: incoming ? incoming.idleEnabled :
false
207 title: qsTr(
"Check interval (minutes), set 0 to disable auto checks")
208 text: incoming ? incoming.checkInterval : 5
209 inputMethodHints: Qt.ImhDigitsOnly
214 text: qsTr(
"Check when roaming")
215 checked: incoming ? incoming.checkWhenRoaming :
false
220 title: qsTr(
"Maximum mail size (MB)")
221 text: incoming ? incoming.maxMailSize :
""
226 text: qsTr(
"No maximum mail size")
227 textColor: Suru.secondaryForegroundColor
228 checked: incoming ? incoming.isAutoDownload :
false
232 id: autoDownloadAttachments
234 text: qsTr(
"Automatically download attachments")
235 checked: incoming ? incoming.downloadAttachments :
false
240 text: qsTr(
"Allowed to delete mail")
241 checked: incoming ? incoming.canDeleteMail :
false