Dekko
Loading...
Searching...
No Matches
ManualInputUI.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 Lomiri.Components 1.3
20import QuickFlux 1.0
21import Dekko.Lomiri.Components 1.0
22import Dekko.Mail.API 1.0
23import Dekko.Mail.Stores.Accounts 1.0
25DekkoPage {
26 objectName: "manualInputUI"
27
28 pageHeader.title: qsTr("Server configuration")
29
31 id: flicker
33 text: qsTr("IMAP Server:")
34 textMargin: 0
35 visible: AccountSetup.isImap
36 }
37
39 id: imap
40 serviceType: "imap"
41 visible: AccountSetup.isImap
42 accountConfig: visible ? AccountSetup.account.incoming : null
43 }
44
46 text: qsTr("POP3 Server:")
47 textMargin: 0
48 visible: AccountSetup.isPop3
49 }
50
52 id: pop
53 serviceType: "pop3"
54 visible: AccountSetup.isPop3
55 accountConfig: visible ? AccountSetup.account.incoming : null
56 }
57
59 text: qsTr("SMTP Server:")
60 textMargin: 0
61 }
62
64 id: smtp
65 serviceType: "smtp"
66 accountConfig: visible ? AccountSetup.account.outgoing : null
67 }
68
70 previousAction: Action {
71 text: qsTr("Back")
72 onTriggered: WizardActions.wizardStepBack()
73 }
74 nextAction: Action {
75 text: qsTr("Next")
76 onTriggered: WizardActions.validateServerConfiguration()
77 }
78 }
79 }
80
81 AppListener {
82 Filter {
83 type: WizardKeys.validateServerConfiguration
84 onDispatched: {
85 if (AccountSetup.isImap) {
86 WizardActions.validateServer(imap.toMap())
87 } else if (AccountSetup.isPop3) {
88 WizardActions.validateServer(pop.toMap())
89 } else {
90 WizardActions.validateServer(smtp.toMap())
91 }
92 }
93 }
94
95 Filter {
96 type: WizardKeys.serverConfigValid
97 onDispatched: {
98 if (message.serviceType !== "smtp") {
99 WizardActions.validateServer(smtp.toMap())
100 } else {
101 console.log("CONFIG VALID")
102 if (AccountSetup.isImap) {
103 WizardActions.applyServerConfig(imap.toMap())
104 } else if (AccountSetup.isPop3) {
105 WizardActions.applyServerConfig(pop.toMap())
106 }
107 WizardActions.applyServerConfig(smtp.toMap())
108 WizardActions.wizardStepForward()
109 }
110 }
111 }
112
113 Filter {
114 type: WizardKeys.invalidServerConfig
115 onDispatched: {
116 flicker.positionAtBeginning()
117 var result = message.result
118 if (message.serviceType === "imap") {
119 imap.showInvalidFields(result)
120 } else if (message.serviceType === "pop3") {
121 pop.showInvalidFields(result)
122 } else if (message.serviceType === "smtp") {
123 smtp.showInvalidFields(result)
124 } else {
125 Log.logError("ManualInputUI::InvalidServerConfig", "Unknow service type " + result.serviceType)
126 }
127 }
128 }
129 }
130
131 AppScript {
132 runWhen: WizardKeys.noServerPasswordSet
133 script: {
134 Log.logWarning("ManualInputUI::noPasswordSet", "No password set, :-/ asking user if this is what they want")
135 PopupActions.showConfirmationDialog(PopupKeys.popupSetupWizard, "serverinputpwd", qsTr("Password empty"), qsTr("Would you like to continue?"))
136
137 once(PopupKeys.confirmationDialogConfirmed, function(message) {
138 if (message.id !== "serverinputpwd") {
139 return;
140 }
141 Log.logInfo("ManualInputUI::confirmationDialogConfirmed", "Seems they do! Setting validation to allow empty password")
142 WizardActions.setNoPasswordAllowed()
143 WizardActions.validateServerConfiguration()
144 })
145
146 // Disconnect all callbacks if the user steps back or forward
147 once(WizardKeys.wizardStepBack, exit.bind(this, 0))
148 once(WizardKeys.wizardStepForward, exit.bind(this, 0))
149 }
150 }
151}