1/*
2 * \copyright Copyright (c) 2015-2021 Governikus GmbH & Co. KG, Germany
3 */
4
5import QtQuick 2.12
6
7import Governikus.EnterPasswordView 1.0
8import Governikus.Global 1.0
9import Governikus.Style 1.0
10import Governikus.TitleBar 1.0
11import Governikus.ProgressView 1.0
12import Governikus.ResultView 1.0
13import Governikus.SelfAuthenticationView 1.0
14import Governikus.WhiteListClient 1.0
15import Governikus.View 1.0
16import Governikus.Workflow 1.0
17import Governikus.Type.ApplicationModel 1.0
18import Governikus.Type.SettingsModel 1.0
19import Governikus.Type.AuthModel 1.0
20import Governikus.Type.NumberModel 1.0
21import Governikus.Type.ChangePinModel 1.0
22import Governikus.Type.ConnectivityManager 1.0
23
24
25SectionPage
26{
27	id: identifyEditChatView
28	navigationAction: NavigationAction {
29		state: "back"
30		onClicked: appWindow.close()
31	}
32	//: LABEL ANDROID IOS
33	title: qsTr("Identify")
34
35	content: SelfAuthenticationView {
36		width: identifyEditChatView.width
37		height: identifyEditChatView.height
38	}
39
40	IdentifyController {
41		id: identifyController
42	}
43
44	EditRights {
45		id: editRights
46		visible: false
47	}
48
49	SelfAuthenticationData {
50		id: selfAuthenticationData
51		visible: false
52
53		onDone: {
54			firePop()
55			AuthModel.continueWorkflow()
56		}
57	}
58
59	WhiteListSurveyView {
60		id: whiteListSurveyView
61		visible: false
62
63		onDone: {
64			SettingsModel.setDeviceSurveyPending(pUserAccepted)
65			firePop()
66			AuthModel.continueWorkflow()
67		}
68	}
69
70	GeneralWorkflow {
71		id: identifyWorkflow
72		visible: false
73
74		controller: identifyController
75		workflowModel: AuthModel
76		//: LABEL ANDROID IOS
77		workflowTitle: qsTr("Identify")
78	}
79
80	Component {
81		id: transportPinReminder
82
83		TransportPinReminderView {}
84	}
85
86	EnterPasswordView {
87		id: enterPinView
88
89		visible: false
90
91		navigationAction: NavigationAction { state: "cancel"; onClicked: { firePop(); AuthModel.cancelWorkflow() } }
92		//: LABEL ANDROID IOS
93		title: qsTr("Identify")
94		enableTransportPinLink: state === "PIN"
95
96		onPasswordEntered: {
97			firePop()
98			AuthModel.continueWorkflow()
99		}
100
101		onChangePinLength: {
102			firePop()
103			AuthModel.requestTransportPinChange()
104		}
105	}
106
107	ProgressView {
108		id: identifyAbortedProgressView
109
110		visible: false
111
112		navigationAction: NavigationAction { state: "cancel"; onClicked: AuthModel.cancelWorkflow() }
113		//: INFO DESKTOP_QML The user aborted the authentication process, according to TR we need to inform the service provider
114		text: qsTr("Aborting process and informing the service provider")
115		subText: {
116			if (ConnectivityManager.networkInterfaceActive) {
117				//: INFO DESKTOP_QML Information message about cancellation process with present network connectivity
118				return qsTr("Please wait a moment.")
119			}
120			//: INFO DESKTOP_QML Information message about cancellation process without working network connectivity
121			return qsTr("Network problems detected, trying to reach server within 30 seconds.")
122		}
123		progressBarVisible: false
124		subTextColor: !ConnectivityManager.networkInterfaceActive ? Style.color.warning_text : Style.color.secondary_text
125	}
126
127	ProgressView {
128		id: identifyProgressView
129
130		readonly property bool inProgress: identifyController.workflowState !== IdentifyController.WorkflowStates.Initial
131
132		navigationAction: NavigationAction {
133			state: AuthModel.isBasicReader || identifyController.workflowProgressVisible ? "cancel" : ""
134			onClicked: AuthModel.cancelWorkflow()
135		}
136		//: LABEL ANDROID IOS
137		title: qsTr("Identify")
138		visible: false
139		//: LABEL ANDROID IOS
140		text: (AuthModel.error ? qsTr("Cancel authentication process") :
141				//: INFO ANDROID IOS Header of the progress status message during the authentication process.
142				!inProgress ? qsTr("Acquiring provider certificate") :
143				//: INFO ANDROID IOS Header of the progress status message during the authentication process.
144				qsTr("Authentication in progress"))
145		subText: {
146			if (!visible) {
147				return ""
148			}
149			//: INFO DESKTOP_QML Generic progress status message while no card communication is active.
150			if (!inProgress || AuthModel.error) {
151				return qsTr("Please wait a moment.")
152			}
153			if (AuthModel.isBasicReader) {
154				//: INFO ANDROID IOS Second line text if a basic card reader is used and background communication with the card/server is running. Is not actually visible since the basic reader password handling is done by EnterPasswordView.
155				return qsTr("Please do not move the ID card.")
156			}
157			if (!!NumberModel.inputError) {
158				return NumberModel.inputError
159			}
160			if (NumberModel.pinDeactivated) {
161				//: INFO ANDROID IOS The online authentication feature of the ID card is disabled and needs to be actived the be authorities.
162				return qsTr("The online identification function of your ID card is not activated. Please contact your responsible authority to activate the online identification function.")
163			}
164			if (identifyController.workflowState === IdentifyController.WorkflowStates.Update || identifyController.workflowState === IdentifyController.WorkflowStates.Pin) {
165				//: INFO ANDROID IOS The card reader requests the user's attention.
166				return qsTr("Please observe the display of your card reader.")
167			}
168			if (identifyController.workflowState === IdentifyController.WorkflowStates.Can) {
169				//: INFO ANDROID IOS The PIN was entered wrongfully two times, the third attempts requires additional CAN verification, hint where the CAN is found.
170				return qsTr("A wrong PIN has been entered twice on your ID card. For a third attempt, please first enter the six-digit Card Access Number (CAN). You can find your Card Access Number (CAN) in the bottom right on the front of your ID card.")
171			}
172
173			//: INFO ANDROID IOS Generic status message during the authentication process.
174			return qsTr("Please wait a moment.")
175		}
176		subTextColor: !AuthModel.isBasicReader && (NumberModel.inputError
177												   || NumberModel.pinDeactivated
178												   || identifyController.workflowState === IdentifyController.WorkflowStates.Can)
179					  ? Style.color.warning_text : Style.color.secondary_text
180		progressValue: AuthModel.progressValue
181		progressText: AuthModel.progressMessage
182		progressBarVisible: identifyController.workflowProgressVisible
183	}
184
185	ProgressView {
186		id: checkConnectivityView
187		navigationAction: NavigationAction { state: "cancel"; onClicked: AuthModel.cancelWorkflow() }
188		//: LABEL ANDROID IOS
189		title: qsTr("Identify")
190		visible: false
191		//: LABEL ANDROID IOS
192		text: qsTr("No network connectivity")
193		//: INFO ANDROID IOS No network connection, the user needs to active the network interface or abort the procedure.
194		subText: qsTr("Please establish an internet connection.")
195		subTextColor: Style.color.warning_text
196	}
197
198	ResultView {
199		id: cardPositionView
200		navigationAction: NavigationAction { state: "cancel"; onClicked: AuthModel.cancelWorkflow() }
201		//: LABEL ANDROID IOS
202		title: qsTr("Identify")
203		resultType: ResultView.Type.IsInfo
204		//: LABEL ANDROID IOS
205		buttonText: qsTr("Retry")
206		//: INFO ANDROID IOS The NFC signal is weak, by repositioning the card the signal might improve.
207		text: qsTr("Weak NFC signal. Please\n- change the card position\n- remove the mobile phone case (if present)\n- connect the smartphone with a charging cable")
208		onClicked: {
209			firePop()
210			AuthModel.continueWorkflow()
211		}
212		visible: false
213	}
214
215	ResultView {
216		id: identifyResult
217		//: LABEL ANDROID IOS
218		title: qsTr("Identify")
219		resultType: AuthModel.resultString ? ResultView.Type.IsError : ResultView.Type.IsSuccess
220		showMailButton: AuthModel.errorIsMasked
221		header: AuthModel.errorHeader
222		errorCode: AuthModel.statusCode
223		errorDescription: AuthModel.errorText
224		text: AuthModel.resultString
225		onClicked: {
226			AuthModel.continueWorkflow()
227			firePopAll()
228			if (ApplicationModel.currentWorkflow === "authentication") {
229				appWindow.close()
230			}
231			navBar.lockedAndHidden = false
232		}
233		visible: false
234	}
235}
236