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

@@ -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;

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,12 +1,10 @@
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 importSshPrivKeyButton: repoImportPrivKeyButton
property alias importSshPubKeyButton: repoImportPubKeyButton property alias importSshPubKeyButton: repoImportPubKeyButton
property alias deleteSshPrivKeyButton: repoDeletePrivKeyButton property alias deleteSshPrivKeyButton: repoDeletePrivKeyButton
@@ -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

@@ -11,7 +11,6 @@ Page {
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
@@ -19,6 +18,7 @@ Page {
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

@@ -51,16 +51,20 @@ 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:
// UnexceptedError -> use the default (not translate) rnp error
__text_error_description = message; __text_error_description = message;
break; break;
case 2: // BadPassphrase case 2:
// BadPassphrase
__text_error_description = i18n.tr("Bad passphrase"); __text_error_description = i18n.tr("Bad passphrase");
break; break;
case 3: // NoKeyFound case 3:
// NoKeyFound
__text_error_description = i18n.tr("No valid key found"); __text_error_description = i18n.tr("No valid key found");
break; break;
case 3: // DecryptFailed case 3:
// DecryptFailed
__text_error_description = i18n.tr("Decryption failed"); __text_error_description = i18n.tr("Decryption failed");
break; break;
default: default:
@@ -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,24 +9,28 @@ 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 { Page {
// property int __gitModeSSH_KEY : 2
id: importGitClonePage id: importGitClonePage
property int __gitModeHTTP: 0 property int __gitModeHTTP: 0
property int __gitModeHTTP_AUTH: 1 property int __gitModeHTTP_AUTH: 1
// property int __gitModeSSH_KEY : 2
property int __gitCloneErrorCodeSuccessful: 0 property int __gitCloneErrorCodeSuccessful: 0
property int __gitCloneErrorCodeUnexpectedError: 1 property int __gitCloneErrorCodeUnexpectedError: 1
property int __gitCloneErrorCodeInvalidUrl: 2 property int __gitCloneErrorCodeInvalidUrl: 2
property int __gitCloneErrorCodeNoUsername: 3 property int __gitCloneErrorCodeNoUsername: 3
property int __gitCloneErrorCodeAuthentificationError: 4 property int __gitCloneErrorCodeAuthentificationError: 4
property int __gitCloneErrorCodeUrlTypeDoNotMatchCreds: 5 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");
@@ -34,9 +38,6 @@ Page {
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);
} }
@@ -133,16 +135,6 @@ Page {
width: parent.width width: parent.width
onLoaded: { 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: // case __gitModeSSH_KEY:
// importGitCloneForm.item.importSshPrivKeyButton.clicked.connect(function() { // importGitCloneForm.item.importSshPrivKeyButton.clicked.connect(function() {
// pageStack.push(Qt.resolvedUrl("ImportSSHkey.qml"), { // pageStack.push(Qt.resolvedUrl("ImportSSHkey.qml"), {
@@ -155,6 +147,16 @@ Page {
// }); // });
// }); // });
// break; // 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;
} }
} }
} }

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,7 +25,6 @@ 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;
@@ -47,10 +43,12 @@ Page {
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:
// UnexceptedError -> use the default (not translate) rnp error
__text_error_description = message; __text_error_description = message;
break; break;
case 2: // BadFormat case 2:
// BadFormat
__text_error_description = i18n.tr("The file is not in a valid key format"); __text_error_description = i18n.tr("The file is not in a valid key format");
break; break;
default: default:
@@ -62,9 +60,8 @@ Page {
}); });
} }
}); });
};
} }
}
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
@@ -14,7 +13,6 @@ ImportFile {
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;
@@ -26,13 +24,12 @@ ImportFile {
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);
} }
}
}); });
} };
} }
} }