| 
									
										
										
										
											2019-12-19 07:46:16 -04:00
										 |  |  | // SPDX-License-Identifier: LGPL-3.0-or-later
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-09 14:42:58 -04:00
										 |  |  | import QtQuick 2.12 | 
					
						
							|  |  |  | import Qt.labs.platform 1.1 | 
					
						
							|  |  |  | import "../Popups" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HFileDialogOpener { | 
					
						
							|  |  |  |     fill: false | 
					
						
							|  |  |  |     dialog.title: qsTr("Save decryption keys file as...") | 
					
						
							|  |  |  |     dialog.fileMode: FileDialog.SaveFile | 
					
						
							| 
									
										
										
										
											2019-11-06 08:55:47 -04:00
										 |  |  |     onFilePicked: { | 
					
						
							| 
									
										
										
										
											2019-09-09 14:42:58 -04:00
										 |  |  |         exportPasswordPopup.file = file | 
					
						
							|  |  |  |         exportPasswordPopup.open() | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-07 12:45:20 -04:00
										 |  |  |     // This is used for the SignOutPopup to know when the export is done
 | 
					
						
							| 
									
										
										
										
											2019-11-30 05:50:56 -04:00
										 |  |  |     // so it can close
 | 
					
						
							| 
									
										
										
										
											2019-09-09 14:49:54 -04:00
										 |  |  |     signal done() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-09 14:42:58 -04:00
										 |  |  |     property string userId: "" | 
					
						
							|  |  |  |     property bool exporting: false | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function exportKeys(file, passphrase) { | 
					
						
							|  |  |  |         exporting = true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-08 04:46:20 -04:00
										 |  |  |         const path = file.toString().replace(/^file:\/\//, "") | 
					
						
							| 
									
										
										
										
											2019-09-09 14:42:58 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |         py.callClientCoro(userId, "export_keys", [path, passphrase], () => { | 
					
						
							|  |  |  |             exporting = false | 
					
						
							| 
									
										
										
										
											2019-09-09 14:49:54 -04:00
										 |  |  |             done() | 
					
						
							| 
									
										
										
										
											2019-09-09 14:42:58 -04:00
										 |  |  |         }) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     PasswordPopup { | 
					
						
							|  |  |  |         id: exportPasswordPopup | 
					
						
							| 
									
										
										
										
											2020-03-17 13:40:58 -04:00
										 |  |  |         details.text: qsTr("Passphrase to protect this file:") | 
					
						
							| 
									
										
										
										
											2019-09-09 14:42:58 -04:00
										 |  |  |         okText: qsTr("Export") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         onAcceptedPasswordChanged: exportKeys(file, acceptedPassword) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         property url file: "" | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |