1
0
mirror of https://github.com/QRouland/UTPass.git synced 2026-01-09 19:16:57 +00:00

Foramtting

This commit is contained in:
2026-01-06 15:42:10 +01:00
parent 083750f429
commit fbfd276b00
15 changed files with 185 additions and 186 deletions

View File

@@ -22,7 +22,8 @@ enum class GitCloneErrorCode {
* @param error A pointer to the git_error structure * @param error A pointer to the git_error structure
* @return Corresponding GitCloneErrorCode integer value * @return Corresponding GitCloneErrorCode integer value
*/ */
inline GitCloneErrorCode gitErrorToGitCloneErrorCode(const git_error* error) { inline GitCloneErrorCode gitErrorToGitCloneErrorCode(const git_error* error)
{
if (error == nullptr) { if (error == nullptr) {
return GitCloneErrorCode::Successful; ///< Default error if null return GitCloneErrorCode::Successful; ///< Default error if null
} }

View File

@@ -15,7 +15,7 @@ extern "C" {
Git::Git(): Git::Git():
m_sem(std::unique_ptr<QSemaphore>(new QSemaphore(1))), m_sem(std::unique_ptr<QSemaphore>(new QSemaphore(1))),
m_ssh_homedir (QStandardPaths::writableLocation( m_ssh_homedir (QStandardPaths::writableLocation(
QStandardPaths::AppDataLocation).append("/.ssh")) QStandardPaths::AppDataLocation).append("/.ssh"))
{ {
qDebug() << "[Git] SSH Home is " << m_ssh_homedir.absolutePath(); qDebug() << "[Git] SSH Home is " << m_ssh_homedir.absolutePath();
QDir m_ssh_homedir(this->m_ssh_homedir); QDir m_ssh_homedir(this->m_ssh_homedir);
@@ -83,7 +83,8 @@ void Git::cloneResult(const int err_code, const QString message)
this->m_sem->release(); this->m_sem->release();
} }
bool Git::importSshKey(QUrl source_path, bool is_private){ bool Git::importSshKey(QUrl source_path, bool is_private)
{
auto destination_path = is_private ? this->privKeyPath() : this->pubKeyPath(); auto destination_path = is_private ? this->privKeyPath() : this->pubKeyPath();
QFile source_file(source_path.toLocalFile()); QFile source_file(source_path.toLocalFile());

View File

@@ -62,14 +62,16 @@ bool CloneJob::moveToDestination(QDir tmp_dir, const QString& path)
qDebug() << "[CloneJob] Moving cloned content to destination dir"; qDebug() << "[CloneJob] Moving cloned content to destination dir";
if (!QDir().rename(tmp_dir.absolutePath(), destination_dir.absolutePath())) { if (!QDir().rename(tmp_dir.absolutePath(), destination_dir.absolutePath())) {
qWarning() << "[CloneJob] Failed to move directory from" << tmp_dir.absolutePath() << "to" << destination_dir.absolutePath(); qWarning() << "[CloneJob] Failed to move directory from" << tmp_dir.absolutePath() << "to" <<
destination_dir.absolutePath();
return false; return false;
} }
return true; return true;
} }
const QPair<GitCloneErrorCode, QString> CloneJob::clone(QString url, QString path, cred_type cred, git_cred_acquire_cb cb) const QPair<GitCloneErrorCode, QString> CloneJob::clone(QString url, QString path, cred_type cred,
git_cred_acquire_cb cb)
{ {
git_repository *repo = nullptr; // Use nullptr for type safety git_repository *repo = nullptr; // Use nullptr for type safety
git_clone_options opts = GIT_CLONE_OPTIONS_INIT; git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
@@ -82,11 +84,11 @@ const QPair<GitCloneErrorCode, QString> CloneJob::clone(QString url, QString pat
// Map the application specific cb errors if any // Map the application specific cb errors if any
if (ret == GIT_EUSER) { if (ret == GIT_EUSER) {
if(payload.err == ErrorCodeCB::NoUsername) if (payload.err == ErrorCodeCB::NoUsername)
return {GitCloneErrorCode::NoUsername, "no username provided in URL"}; return {GitCloneErrorCode::NoUsername, "no username provided in URL"};
if(payload.err == ErrorCodeCB::InvalidCreds) if (payload.err == ErrorCodeCB::InvalidCreds)
return {GitCloneErrorCode::AuthentificationError, "authentification error"}; return {GitCloneErrorCode::AuthentificationError, "authentification error"};
if(payload.err == ErrorCodeCB::UrlTypeDoNotMatchCreds) if (payload.err == ErrorCodeCB::UrlTypeDoNotMatchCreds)
return {GitCloneErrorCode::UrlTypeDoNotMatchCreds, "invalid creds types for provided url"}; return {GitCloneErrorCode::UrlTypeDoNotMatchCreds, "invalid creds types for provided url"};
return {GitCloneErrorCode::UnexpectedError, "unexcepted error occured"}; return {GitCloneErrorCode::UnexpectedError, "unexcepted error occured"};
} }

View File

@@ -27,12 +27,12 @@ class CloneJob : public GitJob
signals: signals:
/** /**
* @brief Signal emitted when the cloning operation is complete. * @brief Signal emitted when the cloning operation is complete.
* *
* This signal is emitted once the cloning operation finishes. * This signal is emitted once the cloning operation finishes.
* *
* @param err A Git error. * @param err A Git error.
*/ */
void resultReady(const int err_code, const QString message); void resultReady(const int err_code, const QString message);
private: private:

View File

@@ -57,7 +57,7 @@ int GitJob::credentialsCB(git_cred **out, const char *url, const char *username_
} }
return git_cred_userpass_plaintext_new(out, username_from_url, x.pass.toLocal8Bit().constData()); return git_cred_userpass_plaintext_new(out, username_from_url, x.pass.toLocal8Bit().constData());
}, },
[allowed_types, &out, &username_from_url , &p](const SSHKey & x) [allowed_types, &out, &username_from_url, &p](const SSHKey & x)
{ {
qDebug() << "[GitJob] credentialsCB : SSHKey "; qDebug() << "[GitJob] credentialsCB : SSHKey ";
if (!(allowed_types & GIT_CREDTYPE_SSH_KEY)) { if (!(allowed_types & GIT_CREDTYPE_SSH_KEY)) {

View File

@@ -39,8 +39,7 @@ enum class ErrorCodeCB {
}; };
struct PayloadCB struct PayloadCB {
{
bool called; bool called;
cred_type creds; cred_type creds;
ErrorCodeCB err; ErrorCodeCB err;

View File

@@ -24,7 +24,8 @@ enum class ErrorCodeShow {
* @param rnpErrorCode The RNP error code * @param rnpErrorCode The RNP error code
* @return Corresponding ErrorCodeShow integer value * @return Corresponding ErrorCodeShow integer value
*/ */
inline ErrorCodeShow rnpErrorToErrorCodeShow(int rnpErrorCode) { inline ErrorCodeShow rnpErrorToErrorCodeShow(int rnpErrorCode)
{
switch (rnpErrorCode) { switch (rnpErrorCode) {
case RNP_ERROR_BAD_PASSWORD: case RNP_ERROR_BAD_PASSWORD:
return ErrorCodeShow::BadPassphrase; ///< Bad passphrase error return ErrorCodeShow::BadPassphrase; ///< Bad passphrase error
@@ -49,7 +50,8 @@ enum class ErrorCodeImportKeyFile {
* @param rnpErrorCode The RNP error code * @param rnpErrorCode The RNP error code
* @return Corresponding ErrorCodeImportKeyFile integer value * @return Corresponding ErrorCodeImportKeyFile integer value
*/ */
inline ErrorCodeImportKeyFile rnpErrorToErrorCodeImportKeyFile(int rnpErrorCode) { inline ErrorCodeImportKeyFile rnpErrorToErrorCodeImportKeyFile(int rnpErrorCode)
{
switch (rnpErrorCode) { switch (rnpErrorCode) {
case RNP_ERROR_BAD_FORMAT: case RNP_ERROR_BAD_FORMAT:
return ErrorCodeImportKeyFile::BadFormat; ///< Bad format error return ErrorCodeImportKeyFile::BadFormat; ///< Bad format error

View File

@@ -1,18 +1,16 @@
import Git 1.0 import Git 1.0
import Lomiri.Components 1.3 import Lomiri.Components 1.3
import Pass 1.0 import Pass 1.0
import Utils 1.0
import QtQuick 2.4 import QtQuick 2.4
import Utils 1.0
Column { Column {
property alias importSshPrivKeyButton: repoImportPrivKeyButton
property alias importSshPubKeyButton: repoImportPubKeyButton
property alias importSshPrivKeyButton : repoImportPrivKeyButton property alias deleteSshPrivKeyButton: repoDeletePrivKeyButton
property alias importSshPubKeyButton : repoImportPubKeyButton property alias deleteSshPubKeyButton: repoDeletePubKeyButton
property alias deleteSshPrivKeyButton : repoDeletePrivKeyButton property bool __sshPrivKeyAvailable: false
property alias deleteSshPubKeyButton : repoDeletePubKeyButton property bool __sshPubKeyAvailable: false
property bool __sshPrivKeyAvailable : false
property bool __sshPubKeyAvailable : false
signal repoUrlChanged(string url) signal repoUrlChanged(string url)
@@ -28,7 +26,6 @@ Column {
Component.onCompleted: { Component.onCompleted: {
update(); update();
} }
anchors.top: parent.fill anchors.top: parent.fill
spacing: units.gu(1) spacing: units.gu(1)
@@ -108,7 +105,6 @@ Column {
visible: !__sshPrivKeyAvailable visible: !__sshPrivKeyAvailable
} }
Text { Text {
id: repoPassphraseLabel id: repoPassphraseLabel

View File

@@ -10,15 +10,15 @@ Page {
id: importKeyFilePage id: importKeyFilePage
property var activeTransfer property var activeTransfer
property alias contentPicker : contentPicker property alias contentPicker: contentPicker
property string headerTitle: i18n.tr("Import succeeded !")
property string headerTitle : i18n.tr("Import succeeded !") property string dialogErrorTxt: i18n.tr("Import failed !")
property string dialogErrorTxt : i18n.tr("Import failed !") property string dialogErrorDescriptionTxt: null
property string dialogErrorDescriptionTxt : null property string dialogSuccessTxt: i18n.tr("File Imported")
property string dialogSuccessTxt : i18n.tr("File Imported")
ContentPeerPicker { ContentPeerPicker {
id: contentPicker id: contentPicker
anchors.top: importKeyHeader.bottom anchors.top: importKeyHeader.bottom
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.topMargin: importKeyFilePage.header.height anchors.topMargin: importKeyFilePage.header.height
@@ -39,7 +39,6 @@ Page {
activeTransfer: importKeyFilePage.activeTransfer activeTransfer: importKeyFilePage.activeTransfer
} }
header: StackHeader { header: StackHeader {
id: importKeyHeader id: importKeyHeader

View File

@@ -6,12 +6,12 @@ Dialog {
id: dialog id: dialog
property string textError property string textError
property string textErrorDescription : null property string textErrorDescription: null
signal dialogClosed() signal dialogClosed()
title: i18n.tr("Error !") title: i18n.tr("Error !")
text: textErrorDescription ? (textError + "<br>" + textErrorDescription) : textError text: textErrorDescription ? (textError + "<br>" + textErrorDescription) : textError
Button { Button {
text: i18n.tr("Close") text: i18n.tr("Close")

View File

@@ -51,22 +51,26 @@ Page {
}); });
Pass.onShowFailed.connect(function(code, message) { Pass.onShowFailed.connect(function(code, message) {
switch (code) { switch (code) {
case 1: // UnexceptedError -> use the default (not translate) rnp error case 1:
__text_error_description = message; // UnexceptedError -> use the default (not translate) rnp error
break; __text_error_description = message;
case 2: // BadPassphrase break;
__text_error_description = i18n.tr("Bad passphrase"); case 2:
break; // BadPassphrase
case 3: // NoKeyFound __text_error_description = i18n.tr("Bad passphrase");
__text_error_description = i18n.tr("No valid key found"); break;
break; case 3:
case 3: // DecryptFailed // NoKeyFound
__text_error_description = i18n.tr("Decryption failed"); __text_error_description = i18n.tr("No valid key found");
break; break;
default: case 3:
console.warn("Unhandled error code"); // DecryptFailed
__text_error_description = message; __text_error_description = i18n.tr("Decryption failed");
break; break;
default:
console.warn("Unhandled error code");
__text_error_description = message;
break;
} }
PopupUtils.open(passwordPageDecryptError); PopupUtils.open(passwordPageDecryptError);
}); });
@@ -195,10 +199,9 @@ Page {
textError: i18n.tr("Decryption failed !") textError: i18n.tr("Decryption failed !")
textErrorDescription: __text_error_description textErrorDescription: __text_error_description
} }
} }
Timer { Timer {
id: searchTimer id: searchTimer

View File

@@ -9,34 +9,35 @@ import Lomiri.Components.Popups 1.3
import Pass 1.0 import Pass 1.0
import QtQuick 2.4 import QtQuick 2.4
import Utils 1.0 import Utils 1.0
Page {
id: importGitClonePage
property int __gitModeHTTP : 0 Page {
property int __gitModeHTTP_AUTH : 1
// property int __gitModeSSH_KEY : 2 // property int __gitModeSSH_KEY : 2
property int __gitCloneErrorCodeSuccessful : 0 id: importGitClonePage
property int __gitCloneErrorCodeUnexpectedError : 1
property int __gitCloneErrorCodeInvalidUrl : 2
property int __gitCloneErrorCodeNoUsername : 3
property int __gitCloneErrorCodeAuthentificationError : 4
property int __gitCloneErrorCodeUrlTypeDoNotMatchCreds : 5
property int __gitModeHTTP: 0
property int __gitModeHTTP_AUTH: 1
property int __gitCloneErrorCodeSuccessful: 0
property int __gitCloneErrorCodeUnexpectedError: 1
property int __gitCloneErrorCodeInvalidUrl: 2
property int __gitCloneErrorCodeNoUsername: 3
property int __gitCloneErrorCodeAuthentificationError: 4
property int __gitCloneErrorCodeUrlTypeDoNotMatchCreds: 5
property string __repoUrl property string __repoUrl
property string __err_message : null property string __err_message: null
function __loadForm() { function __loadForm() {
// case __gitModeSSH_KEY:
// importGitCloneForm.source = Qt.resolvedUrl("../../components/GitCloneSshKey.qml");
// break;
switch (combo.selectedIndex) { switch (combo.selectedIndex) {
case __gitModeHTTP: case __gitModeHTTP:
importGitCloneForm.source = Qt.resolvedUrl("../../components/GitCloneHttp.qml"); importGitCloneForm.source = Qt.resolvedUrl("../../components/GitCloneHttp.qml");
break; break;
case __gitModeHTTP_AUTH: case __gitModeHTTP_AUTH:
importGitCloneForm.source = Qt.resolvedUrl("../../components/GitCloneHttpAuth.qml"); importGitCloneForm.source = Qt.resolvedUrl("../../components/GitCloneHttpAuth.qml");
break; break;
// case __gitModeSSH_KEY:
// importGitCloneForm.source = Qt.resolvedUrl("../../components/GitCloneSshKey.qml");
// break;
} }
} }
@@ -44,7 +45,8 @@ Page {
Git.cloneSucceed.connect(function() { Git.cloneSucceed.connect(function() {
GitSettings.type = combo.selectedIndex; GitSettings.type = combo.selectedIndex;
GitSettings.repoUrl = importGitClonePage.__repoUrl; GitSettings.repoUrl = importGitClonePage.__repoUrl;
if(GitSettings.type != __gitModeSSH_KEY) { // ensure there no ssh key is kept if swicthing to another git mode if (GitSettings.type != __gitModeSSH_KEY) {
// ensure there no ssh key is kept if swicthing to another git mode
Utils.rmFile(Git.privKey); Utils.rmFile(Git.privKey);
Utils.rmFile(Git.pubKey); Utils.rmFile(Git.pubKey);
} }
@@ -52,24 +54,24 @@ Page {
}); });
Git.cloneFailed.connect(function(err_code, msg) { Git.cloneFailed.connect(function(err_code, msg) {
switch (err_code) { switch (err_code) {
case __gitCloneErrorCodeUnexpectedError: case __gitCloneErrorCodeUnexpectedError:
__err_message = i18n.tr("An error occurred during the clone operation."); __err_message = i18n.tr("An error occurred during the clone operation.");
break; break;
case __gitCloneErrorCodeInvalidUrl: case __gitCloneErrorCodeInvalidUrl:
__err_message = i18n.tr("Invalid URL for the current clone operation."); __err_message = i18n.tr("Invalid URL for the current clone operation.");
break; break;
case __gitCloneErrorCodeNoUsername: case __gitCloneErrorCodeNoUsername:
__err_message = i18n.tr("Username is missing in the URL."); __err_message = i18n.tr("Username is missing in the URL.");
break; break;
case __gitCloneErrorCodeAuthentificationError: case __gitCloneErrorCodeAuthentificationError:
__err_message = i18n.tr("Authentication error, credentials may be invalid."); __err_message = i18n.tr("Authentication error, credentials may be invalid.");
break; break;
case __gitCloneErrorCodeUrlTypeDoNotMatchCreds: case __gitCloneErrorCodeUrlTypeDoNotMatchCreds:
__err_message = i18n.tr("Credentials type does not match the URL for the current clone operation."); __err_message = i18n.tr("Credentials type does not match the URL for the current clone operation.");
break; break;
default: default:
__err_message = msg; __err_message = msg;
break; break;
} }
PopupUtils.open(dialogGitCloneError, importGitClonePage); PopupUtils.open(dialogGitCloneError, importGitClonePage);
}); });
@@ -103,7 +105,7 @@ Page {
id: combo id: combo
width: parent.width width: parent.width
model: ["HTTP", "HTTP AUTH" ] //, "SSH KEY"] model: ["HTTP", "HTTP AUTH"] //, "SSH KEY"]
onDelegateClicked: function(i) { onDelegateClicked: function(i) {
timer.setTimeout(function() { timer.setTimeout(function() {
__loadForm(); __loadForm();
@@ -133,28 +135,28 @@ Page {
width: parent.width width: parent.width
onLoaded: { onLoaded: {
// case __gitModeSSH_KEY:
// importGitCloneForm.item.importSshPrivKeyButton.clicked.connect(function() {
// pageStack.push(Qt.resolvedUrl("ImportSSHkey.qml"), {
// "isPrivateKey": true
// });
// });
// importGitCloneForm.item.importSshPubKeyButton.clicked.connect(function() {
// pageStack.push(Qt.resolvedUrl("ImportSSHkey.qml"), {
// "isPrivateKey": false
// });
// });
// break;
importGitCloneForm.item.repoUrlChanged.connect(function(url) { importGitCloneForm.item.repoUrlChanged.connect(function(url) {
importGitClonePage.__repoUrl = url; importGitClonePage.__repoUrl = url;
}); });
importGitCloneForm.item.setRepoUrl(importGitClonePage.__repoUrl); importGitCloneForm.item.setRepoUrl(importGitClonePage.__repoUrl);
switch (combo.selectedIndex) { switch (combo.selectedIndex) {
case __gitModeHTTP: case __gitModeHTTP:
break; break;
case __gitModeHTTP_AUTH: case __gitModeHTTP_AUTH:
break; break;
// case __gitModeSSH_KEY:
// importGitCloneForm.item.importSshPrivKeyButton.clicked.connect(function() {
// pageStack.push(Qt.resolvedUrl("ImportSSHkey.qml"), {
// "isPrivateKey": true
// });
// });
// importGitCloneForm.item.importSshPubKeyButton.clicked.connect(function() {
// pageStack.push(Qt.resolvedUrl("ImportSSHkey.qml"), {
// "isPrivateKey": false
// });
// });
// break;
} }
} }
} }

View File

@@ -7,19 +7,16 @@ import Pass 1.0
import QtQuick 2.4 import QtQuick 2.4
import Utils 1.0 import Utils 1.0
Page { Page {
id: importKeyFilePage id: importKeyFilePage
property var activeTransfer property var activeTransfer
property alias contentPicker : contentPicker property alias contentPicker: contentPicker
property string __text_error_description: null
property string __text_error_description : null
ContentPeerPicker { ContentPeerPicker {
id: contentPicker id: contentPicker
anchors.top: importKeyHeader.bottom anchors.top: importKeyHeader.bottom
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.topMargin: importKeyFilePage.header.height anchors.topMargin: importKeyFilePage.header.height
@@ -28,43 +25,43 @@ Page {
showTitle: false showTitle: false
contentType: ContentType.Text contentType: ContentType.Text
handler: ContentHandler.Source handler: ContentHandler.Source
onPeerSelected: { onPeerSelected: {
{ {
importKeyFilePage.contentPicker.peer.selectionType = ContentTransfer.Single; importKeyFilePage.contentPicker.peer.selectionType = ContentTransfer.Single;
importKeyFilePage.activeTransfer = importKeyFilePage.contentPicker.peer.request(); importKeyFilePage.activeTransfer = importKeyFilePage.contentPicker.peer.request();
importKeyFilePage.activeTransfer.stateChanged.connect(function() { importKeyFilePage.activeTransfer.stateChanged.connect(function() {
if (importKeyFilePage.activeTransfer.state === ContentTransfer.Charged) { if (importKeyFilePage.activeTransfer.state === ContentTransfer.Charged) {
console.log("Charged"); console.log("Charged");
console.log(importKeyFilePage.activeTransfer.items[0].url); console.log(importKeyFilePage.activeTransfer.items[0].url);
Pass.importGPGKey(importKeyFilePage.activeTransfer.items[0].url); Pass.importGPGKey(importKeyFilePage.activeTransfer.items[0].url);
Pass.importGPGKeySucceed.connect(function() { Pass.importGPGKeySucceed.connect(function() {
Utils.rmFile(importKeyFilePage.activeTransfer.items[0].url); Utils.rmFile(importKeyFilePage.activeTransfer.items[0].url);
importKeyFilePage.activeTransfer = null; importKeyFilePage.activeTransfer = null;
PopupUtils.open(dialogImportKeyPageSucess); PopupUtils.open(dialogImportKeyPageSucess);
}); });
Pass.importGPGKeyFailed.connect(function(err, message) { Pass.importGPGKeyFailed.connect(function(err, message) {
Utils.rmFile(importKeyFilePage.activeTransfer.items[0].url); Utils.rmFile(importKeyFilePage.activeTransfer.items[0].url);
importKeyFilePage.activeTransfer = null; importKeyFilePage.activeTransfer = null;
switch (code) { switch (code) {
case 1: // UnexceptedError -> use the default (not translate) rnp error case 1:
__text_error_description = message; // UnexceptedError -> use the default (not translate) rnp error
break; __text_error_description = message;
case 2: // BadFormat break;
__text_error_description = i18n.tr("The file is not in a valid key format"); case 2:
break; // BadFormat
default: __text_error_description = i18n.tr("The file is not in a valid key format");
console.warn("Unhandled error code"); break;
__text_error_description = message; default:
break; console.warn("Unhandled error code");
} __text_error_description = message;
PopupUtils.open(dialogImportKeyPageError); break;
}); }
} PopupUtils.open(dialogImportKeyPageError);
}); });
} }
});
};
} }
onCancelPressed: { onCancelPressed: {
pageStack.pop(); pageStack.pop();
} }
@@ -77,13 +74,6 @@ Page {
activeTransfer: importKeyFilePage.activeTransfer activeTransfer: importKeyFilePage.activeTransfer
} }
header: StackHeader {
id: importKeyHeader
title: i18n.tr("GPG Key Import")
}
Component { Component {
id: dialogImportKeyPageError id: dialogImportKeyPageError
@@ -105,4 +95,11 @@ Page {
} }
} }
header: StackHeader {
id: importKeyHeader
title: i18n.tr("GPG Key Import")
}
} }

View File

@@ -1,10 +1,9 @@
import "../../components" import "../../components"
import Utils 1.0
import Git 1.0 import Git 1.0
import Lomiri.Components 1.3 import Lomiri.Components 1.3
import Lomiri.Components.Popups 1.3 import Lomiri.Components.Popups 1.3
import Lomiri.Content 1.3 import Lomiri.Content 1.3
import Utils 1.0
ImportFile { ImportFile {
id: importSSHKeyPage id: importSSHKeyPage
@@ -12,27 +11,25 @@ ImportFile {
property bool isPrivateKey property bool isPrivateKey
headerTitle: i18n.tr("SSH Key Import") headerTitle: i18n.tr("SSH Key Import")
dialogSuccessTxt : i18n.tr("SSH Key successfully imported !") dialogSuccessTxt: i18n.tr("SSH Key successfully imported !")
dialogErrorTxt : i18n.tr("SSH Key import failed !") dialogErrorTxt: i18n.tr("SSH Key import failed !")
contentPicker.onPeerSelected: { contentPicker.onPeerSelected: {
{ {
importSSHKeyPage.contentPicker.peer.selectionType = ContentTransfer.Single; importSSHKeyPage.contentPicker.peer.selectionType = ContentTransfer.Single;
importSSHKeyPage.activeTransfer = importSSHKeyPage.contentPicker.peer.request(); importSSHKeyPage.activeTransfer = importSSHKeyPage.contentPicker.peer.request();
importSSHKeyPage.activeTransfer.stateChanged.connect(function() { importSSHKeyPage.activeTransfer.stateChanged.connect(function() {
if (importSSHKeyPage.activeTransfer.state === ContentTransfer.Charged) { if (importSSHKeyPage.activeTransfer.state === ContentTransfer.Charged) {
console.log("Charged"); console.log("Charged");
console.log(importSSHKeyPage.activeTransfer.items[0].url); console.log(importSSHKeyPage.activeTransfer.items[0].url);
var ret = Git.importSshKey(importSSHKeyPage.activeTransfer.items[0].url, isPrivateKey); var ret = Git.importSshKey(importSSHKeyPage.activeTransfer.items[0].url, isPrivateKey);
Utils.rmFile(importSSHKeyPage.activeTransfer.items[0].url); Utils.rmFile(importSSHKeyPage.activeTransfer.items[0].url);
importSSHKeyPage.activeTransfer = null; importSSHKeyPage.activeTransfer = null;
if(ret) { if (ret)
PopupUtils.open(importSSHKeyPage.dialogImportKeyPageSucess); PopupUtils.open(importSSHKeyPage.dialogImportKeyPageSucess);
} else { else
PopupUtils.open(importSSHKeyPage.dialogImportKeyPageError); PopupUtils.open(importSSHKeyPage.dialogImportKeyPageError);
} }
} });
}); };
}
} }
} }