mirror of
https://github.com/QRouland/UTPass.git
synced 2026-01-09 03:06:58 +00:00
Foramtting
This commit is contained in:
@@ -22,7 +22,8 @@ enum class GitCloneErrorCode {
|
||||
* @param error A pointer to the git_error structure
|
||||
* @return Corresponding GitCloneErrorCode integer value
|
||||
*/
|
||||
inline GitCloneErrorCode gitErrorToGitCloneErrorCode(const git_error* error) {
|
||||
inline GitCloneErrorCode gitErrorToGitCloneErrorCode(const git_error* error)
|
||||
{
|
||||
if (error == nullptr) {
|
||||
return GitCloneErrorCode::Successful; ///< Default error if null
|
||||
}
|
||||
|
||||
@@ -83,7 +83,8 @@ void Git::cloneResult(const int err_code, const QString message)
|
||||
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();
|
||||
|
||||
QFile source_file(source_path.toLocalFile());
|
||||
|
||||
@@ -62,14 +62,16 @@ bool CloneJob::moveToDestination(QDir tmp_dir, const QString& path)
|
||||
qDebug() << "[CloneJob] Moving cloned content to destination dir";
|
||||
|
||||
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 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_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
|
||||
if (ret == GIT_EUSER) {
|
||||
if(payload.err == ErrorCodeCB::NoUsername)
|
||||
if (payload.err == ErrorCodeCB::NoUsername)
|
||||
return {GitCloneErrorCode::NoUsername, "no username provided in URL"};
|
||||
if(payload.err == ErrorCodeCB::InvalidCreds)
|
||||
if (payload.err == ErrorCodeCB::InvalidCreds)
|
||||
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::UnexpectedError, "unexcepted error occured"};
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
},
|
||||
[allowed_types, &out, &username_from_url , &p](const SSHKey & x)
|
||||
[allowed_types, &out, &username_from_url, &p](const SSHKey & x)
|
||||
{
|
||||
qDebug() << "[GitJob] credentialsCB : SSHKey ";
|
||||
if (!(allowed_types & GIT_CREDTYPE_SSH_KEY)) {
|
||||
|
||||
@@ -39,8 +39,7 @@ enum class ErrorCodeCB {
|
||||
};
|
||||
|
||||
|
||||
struct PayloadCB
|
||||
{
|
||||
struct PayloadCB {
|
||||
bool called;
|
||||
cred_type creds;
|
||||
ErrorCodeCB err;
|
||||
|
||||
@@ -24,7 +24,8 @@ enum class ErrorCodeShow {
|
||||
* @param rnpErrorCode The RNP error code
|
||||
* @return Corresponding ErrorCodeShow integer value
|
||||
*/
|
||||
inline ErrorCodeShow rnpErrorToErrorCodeShow(int rnpErrorCode) {
|
||||
inline ErrorCodeShow rnpErrorToErrorCodeShow(int rnpErrorCode)
|
||||
{
|
||||
switch (rnpErrorCode) {
|
||||
case RNP_ERROR_BAD_PASSWORD:
|
||||
return ErrorCodeShow::BadPassphrase; ///< Bad passphrase error
|
||||
@@ -49,7 +50,8 @@ enum class ErrorCodeImportKeyFile {
|
||||
* @param rnpErrorCode The RNP error code
|
||||
* @return Corresponding ErrorCodeImportKeyFile integer value
|
||||
*/
|
||||
inline ErrorCodeImportKeyFile rnpErrorToErrorCodeImportKeyFile(int rnpErrorCode) {
|
||||
inline ErrorCodeImportKeyFile rnpErrorToErrorCodeImportKeyFile(int rnpErrorCode)
|
||||
{
|
||||
switch (rnpErrorCode) {
|
||||
case RNP_ERROR_BAD_FORMAT:
|
||||
return ErrorCodeImportKeyFile::BadFormat; ///< Bad format error
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import Git 1.0
|
||||
import Lomiri.Components 1.3
|
||||
import Pass 1.0
|
||||
import Utils 1.0
|
||||
import QtQuick 2.4
|
||||
import Utils 1.0
|
||||
|
||||
Column {
|
||||
|
||||
|
||||
property alias importSshPrivKeyButton : repoImportPrivKeyButton
|
||||
property alias importSshPubKeyButton : repoImportPubKeyButton
|
||||
property alias deleteSshPrivKeyButton : repoDeletePrivKeyButton
|
||||
property alias deleteSshPubKeyButton : repoDeletePubKeyButton
|
||||
property bool __sshPrivKeyAvailable : false
|
||||
property bool __sshPubKeyAvailable : false
|
||||
property alias importSshPrivKeyButton: repoImportPrivKeyButton
|
||||
property alias importSshPubKeyButton: repoImportPubKeyButton
|
||||
property alias deleteSshPrivKeyButton: repoDeletePrivKeyButton
|
||||
property alias deleteSshPubKeyButton: repoDeletePubKeyButton
|
||||
property bool __sshPrivKeyAvailable: false
|
||||
property bool __sshPubKeyAvailable: false
|
||||
|
||||
signal repoUrlChanged(string url)
|
||||
|
||||
@@ -28,7 +26,6 @@ Column {
|
||||
Component.onCompleted: {
|
||||
update();
|
||||
}
|
||||
|
||||
anchors.top: parent.fill
|
||||
spacing: units.gu(1)
|
||||
|
||||
@@ -108,7 +105,6 @@ Column {
|
||||
visible: !__sshPrivKeyAvailable
|
||||
}
|
||||
|
||||
|
||||
Text {
|
||||
id: repoPassphraseLabel
|
||||
|
||||
|
||||
@@ -10,15 +10,15 @@ Page {
|
||||
id: importKeyFilePage
|
||||
|
||||
property var activeTransfer
|
||||
property alias contentPicker : contentPicker
|
||||
|
||||
property string headerTitle : i18n.tr("Import succeeded !")
|
||||
property string dialogErrorTxt : i18n.tr("Import failed !")
|
||||
property string dialogErrorDescriptionTxt : null
|
||||
property string dialogSuccessTxt : i18n.tr("File Imported")
|
||||
property alias contentPicker: contentPicker
|
||||
property string headerTitle: i18n.tr("Import succeeded !")
|
||||
property string dialogErrorTxt: i18n.tr("Import failed !")
|
||||
property string dialogErrorDescriptionTxt: null
|
||||
property string dialogSuccessTxt: i18n.tr("File Imported")
|
||||
|
||||
ContentPeerPicker {
|
||||
id: contentPicker
|
||||
|
||||
anchors.top: importKeyHeader.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.topMargin: importKeyFilePage.header.height
|
||||
@@ -39,7 +39,6 @@ Page {
|
||||
activeTransfer: importKeyFilePage.activeTransfer
|
||||
}
|
||||
|
||||
|
||||
header: StackHeader {
|
||||
id: importKeyHeader
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ Dialog {
|
||||
id: dialog
|
||||
|
||||
property string textError
|
||||
property string textErrorDescription : null
|
||||
property string textErrorDescription: null
|
||||
|
||||
signal dialogClosed()
|
||||
|
||||
|
||||
@@ -51,16 +51,20 @@ Page {
|
||||
});
|
||||
Pass.onShowFailed.connect(function(code, message) {
|
||||
switch (code) {
|
||||
case 1: // UnexceptedError -> use the default (not translate) rnp error
|
||||
case 1:
|
||||
// UnexceptedError -> use the default (not translate) rnp error
|
||||
__text_error_description = message;
|
||||
break;
|
||||
case 2: // BadPassphrase
|
||||
case 2:
|
||||
// BadPassphrase
|
||||
__text_error_description = i18n.tr("Bad passphrase");
|
||||
break;
|
||||
case 3: // NoKeyFound
|
||||
case 3:
|
||||
// NoKeyFound
|
||||
__text_error_description = i18n.tr("No valid key found");
|
||||
break;
|
||||
case 3: // DecryptFailed
|
||||
case 3:
|
||||
// DecryptFailed
|
||||
__text_error_description = i18n.tr("Decryption failed");
|
||||
break;
|
||||
default:
|
||||
@@ -195,10 +199,9 @@ Page {
|
||||
textError: i18n.tr("Decryption failed !")
|
||||
textErrorDescription: __text_error_description
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Timer {
|
||||
id: searchTimer
|
||||
|
||||
|
||||
@@ -9,24 +9,28 @@ import Lomiri.Components.Popups 1.3
|
||||
import Pass 1.0
|
||||
import QtQuick 2.4
|
||||
import Utils 1.0
|
||||
Page {
|
||||
id: importGitClonePage
|
||||
|
||||
property int __gitModeHTTP : 0
|
||||
property int __gitModeHTTP_AUTH : 1
|
||||
Page {
|
||||
// property int __gitModeSSH_KEY : 2
|
||||
|
||||
property int __gitCloneErrorCodeSuccessful : 0
|
||||
property int __gitCloneErrorCodeUnexpectedError : 1
|
||||
property int __gitCloneErrorCodeInvalidUrl : 2
|
||||
property int __gitCloneErrorCodeNoUsername : 3
|
||||
property int __gitCloneErrorCodeAuthentificationError : 4
|
||||
property int __gitCloneErrorCodeUrlTypeDoNotMatchCreds : 5
|
||||
id: importGitClonePage
|
||||
|
||||
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 __err_message : null
|
||||
property string __err_message: null
|
||||
|
||||
function __loadForm() {
|
||||
// case __gitModeSSH_KEY:
|
||||
// importGitCloneForm.source = Qt.resolvedUrl("../../components/GitCloneSshKey.qml");
|
||||
// break;
|
||||
|
||||
switch (combo.selectedIndex) {
|
||||
case __gitModeHTTP:
|
||||
importGitCloneForm.source = Qt.resolvedUrl("../../components/GitCloneHttp.qml");
|
||||
@@ -34,9 +38,6 @@ Page {
|
||||
case __gitModeHTTP_AUTH:
|
||||
importGitCloneForm.source = Qt.resolvedUrl("../../components/GitCloneHttpAuth.qml");
|
||||
break;
|
||||
// case __gitModeSSH_KEY:
|
||||
// importGitCloneForm.source = Qt.resolvedUrl("../../components/GitCloneSshKey.qml");
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +45,8 @@ Page {
|
||||
Git.cloneSucceed.connect(function() {
|
||||
GitSettings.type = combo.selectedIndex;
|
||||
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.pubKey);
|
||||
}
|
||||
@@ -103,7 +105,7 @@ Page {
|
||||
id: combo
|
||||
|
||||
width: parent.width
|
||||
model: ["HTTP", "HTTP AUTH" ] //, "SSH KEY"]
|
||||
model: ["HTTP", "HTTP AUTH"] //, "SSH KEY"]
|
||||
onDelegateClicked: function(i) {
|
||||
timer.setTimeout(function() {
|
||||
__loadForm();
|
||||
@@ -133,16 +135,6 @@ Page {
|
||||
|
||||
width: parent.width
|
||||
onLoaded: {
|
||||
importGitCloneForm.item.repoUrlChanged.connect(function(url) {
|
||||
importGitClonePage.__repoUrl = url;
|
||||
});
|
||||
importGitCloneForm.item.setRepoUrl(importGitClonePage.__repoUrl);
|
||||
|
||||
switch (combo.selectedIndex) {
|
||||
case __gitModeHTTP:
|
||||
break;
|
||||
case __gitModeHTTP_AUTH:
|
||||
break;
|
||||
// case __gitModeSSH_KEY:
|
||||
// importGitCloneForm.item.importSshPrivKeyButton.clicked.connect(function() {
|
||||
// pageStack.push(Qt.resolvedUrl("ImportSSHkey.qml"), {
|
||||
@@ -155,6 +147,16 @@ Page {
|
||||
// });
|
||||
// });
|
||||
// break;
|
||||
|
||||
importGitCloneForm.item.repoUrlChanged.connect(function(url) {
|
||||
importGitClonePage.__repoUrl = url;
|
||||
});
|
||||
importGitCloneForm.item.setRepoUrl(importGitClonePage.__repoUrl);
|
||||
switch (combo.selectedIndex) {
|
||||
case __gitModeHTTP:
|
||||
break;
|
||||
case __gitModeHTTP_AUTH:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,19 +7,16 @@ import Pass 1.0
|
||||
import QtQuick 2.4
|
||||
import Utils 1.0
|
||||
|
||||
|
||||
|
||||
Page {
|
||||
id: importKeyFilePage
|
||||
|
||||
property var activeTransfer
|
||||
property alias contentPicker : contentPicker
|
||||
|
||||
property string __text_error_description : null
|
||||
|
||||
property alias contentPicker: contentPicker
|
||||
property string __text_error_description: null
|
||||
|
||||
ContentPeerPicker {
|
||||
id: contentPicker
|
||||
|
||||
anchors.top: importKeyHeader.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.topMargin: importKeyFilePage.header.height
|
||||
@@ -28,7 +25,6 @@ Page {
|
||||
showTitle: false
|
||||
contentType: ContentType.Text
|
||||
handler: ContentHandler.Source
|
||||
|
||||
onPeerSelected: {
|
||||
{
|
||||
importKeyFilePage.contentPicker.peer.selectionType = ContentTransfer.Single;
|
||||
@@ -47,10 +43,12 @@ Page {
|
||||
Utils.rmFile(importKeyFilePage.activeTransfer.items[0].url);
|
||||
importKeyFilePage.activeTransfer = null;
|
||||
switch (code) {
|
||||
case 1: // UnexceptedError -> use the default (not translate) rnp error
|
||||
case 1:
|
||||
// UnexceptedError -> use the default (not translate) rnp error
|
||||
__text_error_description = message;
|
||||
break;
|
||||
case 2: // BadFormat
|
||||
case 2:
|
||||
// BadFormat
|
||||
__text_error_description = i18n.tr("The file is not in a valid key format");
|
||||
break;
|
||||
default:
|
||||
@@ -62,9 +60,8 @@ Page {
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
onCancelPressed: {
|
||||
pageStack.pop();
|
||||
}
|
||||
@@ -77,13 +74,6 @@ Page {
|
||||
activeTransfer: importKeyFilePage.activeTransfer
|
||||
}
|
||||
|
||||
|
||||
header: StackHeader {
|
||||
id: importKeyHeader
|
||||
|
||||
title: i18n.tr("GPG Key Import")
|
||||
}
|
||||
|
||||
Component {
|
||||
id: dialogImportKeyPageError
|
||||
|
||||
@@ -105,4 +95,11 @@ Page {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
header: StackHeader {
|
||||
id: importKeyHeader
|
||||
|
||||
title: i18n.tr("GPG Key Import")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import "../../components"
|
||||
import Utils 1.0
|
||||
import Git 1.0
|
||||
|
||||
import Lomiri.Components 1.3
|
||||
import Lomiri.Components.Popups 1.3
|
||||
import Lomiri.Content 1.3
|
||||
import Utils 1.0
|
||||
|
||||
ImportFile {
|
||||
id: importSSHKeyPage
|
||||
@@ -12,9 +11,8 @@ ImportFile {
|
||||
property bool isPrivateKey
|
||||
|
||||
headerTitle: i18n.tr("SSH Key Import")
|
||||
dialogSuccessTxt : i18n.tr("SSH Key successfully imported !")
|
||||
dialogErrorTxt : i18n.tr("SSH Key import failed !")
|
||||
|
||||
dialogSuccessTxt: i18n.tr("SSH Key successfully imported !")
|
||||
dialogErrorTxt: i18n.tr("SSH Key import failed !")
|
||||
contentPicker.onPeerSelected: {
|
||||
{
|
||||
importSSHKeyPage.contentPicker.peer.selectionType = ContentTransfer.Single;
|
||||
@@ -26,13 +24,12 @@ ImportFile {
|
||||
var ret = Git.importSshKey(importSSHKeyPage.activeTransfer.items[0].url, isPrivateKey);
|
||||
Utils.rmFile(importSSHKeyPage.activeTransfer.items[0].url);
|
||||
importSSHKeyPage.activeTransfer = null;
|
||||
if(ret) {
|
||||
if (ret)
|
||||
PopupUtils.open(importSSHKeyPage.dialogImportKeyPageSucess);
|
||||
} else {
|
||||
else
|
||||
PopupUtils.open(importSSHKeyPage.dialogImportKeyPageError);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user