Dekko
Loading...
Searching...
No Matches
ServerDetails.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 QtQuick.Controls.Suru 2.2
20import Lomiri.Components 1.3
21import QuickFlux 1.0
22import Dekko.Lomiri.Components 1.0
23import "../../components"
24
25Item {
26
27 height: col.height
28 anchors {
29 left: parent.left
30 right: parent.right
31 }
32
33 property string serviceType: "imap"
34 property QtObject accountConfig: null
35
36 // rather than using more property bindings here just return a map that can be
37 // used for validation and saving to the account object.
38 function toMap() {
39 var s = {
40 "servicetype" : serviceType,
41 "hostname" : server.text,
42 "port": port.text,
43 "encryption": encryption.selectedMethod,
44 "username": username.text,
45 "password": password.text,
46 "authentication": authentication.selectedMethod,
47 "allowUntrusted": allowUntrustedSwitch.checked
48 }
49 return s
50 }
51
52 function showInvalidFields(result) {
53 server.requiredField = result.indexOf("hostname") > -1
54 port.requiredField = result.indexOf("port") > -1
55 username.requiredField = result.indexOf("username") > -1
56 }
57
58 Column {
59 id: col
60 anchors {
61 left: parent.left
62 top: parent.top
63 right: parent.right
64 }
65 spacing: units.gu(1)
66
68 id: server
69 objectName: "serverInputField"
70 title: qsTr("Hostname")
71 placeholderText: serviceType+".example.org"
72 inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhEmailCharactersOnly
73 text: accountConfig ? accountConfig.server : ""
74 }
75
77 id: port
78 objectName: "portInputField"
79 title: qsTr("Port")
80 placeholderText: "993"
81 inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhDigitsOnly
82 text: accountConfig ? accountConfig.port : ""
83 }
84
86 id: encryption
87 anchors {
88 left: parent.left
89 right: parent.right
90 }
91 Component.onCompleted: {
92 if (accountConfig) {
93 setEncryptionType(accountConfig.encryption)
94 }
95 }
96 }
97
99 id: username
100 objectName: "usernameInputField"
101 title: qsTr("Username")
102 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText | Qt.ImhEmailCharactersOnly
103 placeholderText: "user@example.org"
104 text: accountConfig ? ((serviceType === "smtp") ? accountConfig.username : accountConfig.email) : ""
105 }
106
108 id: password
109 objectName: "userInputPasswordField"
110 title: qsTr("Password")
111 inputMethodHints: Qt.ImhHiddenText | Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
112 echoMode: showPassword.checked ? TextInput.Normal : TextInput.Password
113 placeholderText: qsTr("Password")
114 text: accountConfig ? accountConfig.password : ""
115 }
116
118 id: showPassword
119 objectName: "showPwdCheckBox"
120 text: qsTr("Show password")
121 textColor: Suru.secondaryForegroundColor
122 }
123
125 id: authentication
126 anchors {
127 left: parent.left
128 right: parent.right
129 }
130 visible: serviceType !== "pop3"
131 Component.onCompleted: {
132 if (visible && accountConfig) {
133 setAuthType(accountConfig.saslMechanism)
134 }
135 }
136 }
137
139 id: allowUntrustedSwitch
140 checked: accountConfig ? accountConfig.acceptUntrustedCertificates : false
141 text: qsTr("Allow untrusted certificates")
142 }
143 }
144}