1
0
mirror of https://github.com/QRouland/UTPass.git synced 2025-01-24 15:46:40 +00:00

Fix delete gpg key

This commit is contained in:
Quentin Rouland 2025-01-20 11:23:40 +01:00
parent c0757da47b
commit 0eb8920856
13 changed files with 74 additions and 56 deletions

View File

@ -30,10 +30,10 @@ bool Git::clone(QString url, QString path, cred_type mode)
return false; return false;
} }
auto v = overload { auto v = overload {
[](const HTTP & x) { return "HTTP"; }, [](const HTTP & x) { return "HTTP"; },
[](const HTTPUserPass & x) { return "HTTPAuth"; }, [](const HTTPUserPass & x) { return "HTTPAuth"; },
[](const SSHPass & x) { return "SSHAuth"; }, [](const SSHPass & x) { return "SSHAuth"; },
[](const SSHKey & x) { return "SSHKey"; }, [](const SSHKey & x) { return "SSHKey"; },
}; };
qDebug() << "Creating clone Job " << url << " " << path << " " << std::visit(v, mode); qDebug() << "Creating clone Job " << url << " " << path << " " << std::visit(v, mode);
CloneJob *clone_job = new CloneJob(url, path, mode); CloneJob *clone_job = new CloneJob(url, path, mode);

View File

@ -19,7 +19,8 @@ CloneJob::CloneJob(QString url, QString path, cred_type cred):
} }
void CloneJob::run() { void CloneJob::run()
{
auto tmp_dir = this->cloneSetup(); auto tmp_dir = this->cloneSetup();
auto err = this->clone(this->m_url, tmp_dir.absolutePath(), this->m_cred, this->credentialsCB); auto err = this->clone(this->m_url, tmp_dir.absolutePath(), this->m_cred, this->credentialsCB);
if (err) { if (err) {

View File

@ -234,7 +234,7 @@ void Gpg::getKeysJobResultSlot(const GpgME::KeyListResult &result, const std::ve
const QString &auditLogAsHtml, const GpgME::Error &auditLogError) const QString &auditLogAsHtml, const GpgME::Error &auditLogError)
{ {
if (result.error()) { if (result.error()) {
qWarning() << "Something gone wrong on decrypt"; qWarning() << "Something gone wrong on getKeys";
qDebug() << "Code Error : " << result.error().code(); qDebug() << "Code Error : " << result.error().code();
qDebug() << "Error str : " << result.error().asString(); qDebug() << "Error str : " << result.error().asString();
} }
@ -287,14 +287,13 @@ Error Gpg::deleteKey(const Key key)
QObject::connect(job, &DeleteJob::result, QObject::connect(job, &DeleteJob::result,
this, &Gpg::deleteKeySlot); this, &Gpg::deleteKeySlot);
return openpgp()->deleteJob()->start(key, true); return job->start(key, true);
} }
void Gpg::deleteKeySlot(const GpgME::Error &error, const QString &auditLogAsHtml, const GpgME::Error &auditLogError) void Gpg::deleteKeySlot(const GpgME::Error &error, const QString &auditLogAsHtml, const GpgME::Error &auditLogError)
{ {
if (error) { if (error) {
qWarning() << "Something gone wrong on decrypt"; qWarning() << "Something gone wrong on deleteKey";
qDebug() << "Code Error : " << error.code(); qDebug() << "Code Error : " << error.code();
qDebug() << "Error str : " << error.asString(); qDebug() << "Error str : " << error.asString();
} }

View File

@ -43,7 +43,7 @@ bool Pass::show(QUrl url)
return false; return false;
} }
auto path = url.toLocalFile(); auto path = url.toLocalFile();
qInfo() << "Staring decrypting job for " << path; qInfo() << "Pass show " << path;
QFileInfo file_info(path); QFileInfo file_info(path);
this->m_show_filename = file_info.completeBaseName(); this->m_show_filename = file_info.completeBaseName();
return this->m_gpg->decryptFromFile(path); return this->m_gpg->decryptFromFile(path);
@ -51,36 +51,39 @@ bool Pass::show(QUrl url)
void Pass::showResult(Error err, QString plain_text) void Pass::showResult(Error err, QString plain_text)
{ {
qInfo() << "Result for decrypting job"; qDebug() << "Pass show Result";
if (err) { if (err) {
qInfo() << "Decrypt Failed"; qInfo() << "Pass show Failed";
emit showFailed(err.asString()); emit showFailed(err.asString());
} else if (err.isCanceled()){ } else if (err.isCanceled()) {
qInfo() << "Decrypt Cancelled"; qInfo() << "Pass show Cancelled";
emit showCancelled(); emit showCancelled();
} else { } else {
qInfo() << "Decrypt OK"; qInfo() << "Pass show Succeed";
emit showSucceed(this->m_show_filename, plain_text); emit showSucceed(this->m_show_filename, plain_text);
} }
this->m_show_filename = QString(); this->m_show_filename = QString();
this->m_sem->release(1); this->m_sem->release(1);
} }
bool Pass::deleteGPGKey(Key key) bool Pass::deleteGPGKey(PassKeyModel* key)
{ {
if (!this->m_sem->tryAcquire(1, 500)) { if (!this->m_sem->tryAcquire(1, 500)) {
return false; return false;
} }
qInfo() << "Deleting Key"; qInfo() << "Delete Key " << key->uid();
return this->m_gpg->deleteKey(key); return this->m_gpg->deleteKey(key->key());
} }
void Pass::deleteGPGKeyResult(Error err) void Pass::deleteGPGKeyResult(Error err)
{ {
qDebug() << "Delete Ke yResult";
if (err) { if (err) {
qInfo() << "Delete Key Failed";
emit deleteGPGKeyFailed(err.asString()); emit deleteGPGKeyFailed(err.asString());
} else { } else {
qInfo() << "Delete Key Succeed";
emit deleteGPGKeySucceed(); emit deleteGPGKeySucceed();
} }
this->m_sem->release(1); this->m_sem->release(1);
@ -91,15 +94,18 @@ bool Pass::importGPGKey(QUrl url)
if (!this->m_sem->tryAcquire(1, 500)) { if (!this->m_sem->tryAcquire(1, 500)) {
return false; return false;
} }
qInfo() << "Importing Key from " << url; qInfo() << "Import GPG Key from " << url;
return this->m_gpg->importKeysFromFile(url.toLocalFile()); return this->m_gpg->importKeysFromFile(url.toLocalFile());
} }
void Pass::importGPGKeyResult(Error err) void Pass::importGPGKeyResult(Error err)
{ {
qDebug() << "Import GPG Key Result";
if (err) { if (err) {
qInfo() << "Delete Key Failed";
emit importGPGKeyFailed(err.asString()); emit importGPGKeyFailed(err.asString());
} else { } else {
qInfo() << "Delete Key Succeed";
emit importGPGKeySucceed(); emit importGPGKeySucceed();
} }
this->m_sem->release(1); this->m_sem->release(1);
@ -110,15 +116,18 @@ bool Pass::getAllGPGKeys()
if (!this->m_sem->tryAcquire(1, 500)) { if (!this->m_sem->tryAcquire(1, 500)) {
return false; return false;
} }
qInfo() << "Getting all key form gpg "; qInfo() << "Get GPG keys";
return this->m_gpg->getAllKeys(); return this->m_gpg->getAllKeys();
} }
void Pass::getAllGPGKeysResult(Error err, std::vector<GpgME::Key> keys_info) void Pass::getAllGPGKeysResult(Error err, std::vector<GpgME::Key> keys_info)
{ {
qDebug() << "Get GPG keys Result";
if (err) { if (err) {
qInfo() << "Get GPG Failed";
emit getAllGPGKeysFailed(err.asString()); emit getAllGPGKeysFailed(err.asString());
} else { } else {
qInfo() << "Get GPG Succeed";
emit getAllGPGKeysSucceed(QVariant::fromValue(PassKeyModel::keysToPassKey(keys_info))); emit getAllGPGKeysSucceed(QVariant::fromValue(PassKeyModel::keysToPassKey(keys_info)));
} }
this->m_sem->release(1); this->m_sem->release(1);
@ -126,6 +135,6 @@ void Pass::getAllGPGKeysResult(Error err, std::vector<GpgME::Key> keys_info)
void Pass::responsePassphraseDialog(bool cancel, QString passphrase) void Pass::responsePassphraseDialog(bool cancel, QString passphrase)
{ {
qDebug() << "responsePassphraseDialog"; qDebug() << "Propagate responsePassphraseDialog";
emit responsePassphraseDialogPropagate(cancel, passphrase); emit responsePassphraseDialogPropagate(cancel, passphrase);
} }

View File

@ -79,8 +79,6 @@ signals:
*/ */
void getAllGPGKeysSucceed(QVariant keys_info); void getAllGPGKeysSucceed(QVariant keys_info);
/** /**
* @brief Emitted when retrieving GPG keys fails. * @brief Emitted when retrieving GPG keys fails.
* @param message The error message describing the failure. * @param message The error message describing the failure.
@ -144,10 +142,10 @@ public:
/** /**
* @brief Deletes the specified GPG key. * @brief Deletes the specified GPG key.
* @param key The GPG key to delete. * @param key The PassKeyModel to delete.
* @return True if the operation was successful, false otherwise. * @return True if the operation was successful, false otherwise.
*/ */
Q_INVOKABLE bool deleteGPGKey(Key key); Q_INVOKABLE bool deleteGPGKey(PassKeyModel* key);
/** /**
* @brief Imports a GPG key from the given URL. * @brief Imports a GPG key from the given URL.

View File

@ -59,7 +59,8 @@ bool Utils::rmDir(QUrl dir_url)
return dir.removeRecursively(); return dir.removeRecursively();
} }
QString Utils::manifestPath(){ QString Utils::manifestPath()
{
auto path = QDir(QDir::currentPath()).filePath("manifest_.json"); auto path = QDir(QDir::currentPath()).filePath("manifest_.json");
qDebug() << "Manifest path : " << path; qDebug() << "Manifest path : " << path;
return path; return path;

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: utpass.qrouland\n" "Project-Id-Version: utpass.qrouland\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-01-17 10:40+0100\n" "POT-Creation-Date: 2025-01-20 11:22+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -85,7 +85,7 @@ msgid ""
"a zip in the settings" "a zip in the settings"
msgstr "" msgstr ""
#: ../qml/pages/PasswordList.qml:71 ../qml/pages/settings/InfoKeys.qml:169 #: ../qml/pages/PasswordList.qml:71 ../qml/pages/settings/InfoKeys.qml:171
msgid "Decryption failed !" msgid "Decryption failed !"
msgstr "" msgstr ""
@ -124,7 +124,7 @@ msgid ""
msgstr "" msgstr ""
#: ../qml/pages/settings/ImportZip.qml:62 #: ../qml/pages/settings/ImportZip.qml:62
#: ../qml/pages/settings/InfoKeys.qml:131 #: ../qml/pages/settings/InfoKeys.qml:137
#: ../qml/pages/settings/git/ImportGitClone.qml:54 #: ../qml/pages/settings/git/ImportGitClone.qml:54
msgid "Yes" msgid "Yes"
msgstr "" msgstr ""
@ -142,31 +142,31 @@ msgstr ""
msgid "Zip Password Store Import" msgid "Zip Password Store Import"
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:48 #: ../qml/pages/settings/InfoKeys.qml:54
msgid "Key ID :" msgid "Key ID :"
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:82 #: ../qml/pages/settings/InfoKeys.qml:88
msgid "Users IDs : " msgid "Users IDs : "
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:108 #: ../qml/pages/settings/InfoKeys.qml:114
msgid "Delete this key" msgid "Delete this key"
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:130 #: ../qml/pages/settings/InfoKeys.qml:136
msgid "You're are about to delete<br>%1<br>Continue ?" msgid "You're are about to delete<br>%1<br>Continue ?"
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:148 #: ../qml/pages/settings/InfoKeys.qml:150
msgid "Key removal failed !" msgid "Key removal failed !"
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:157 #: ../qml/pages/settings/InfoKeys.qml:159
msgid "Key successfully deleted !" msgid "Key successfully deleted !"
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:177 #: ../qml/pages/settings/InfoKeys.qml:179
msgid "Info Keys" msgid "Info Keys"
msgstr "" msgstr ""

View File

@ -1,8 +1,8 @@
import "../components" import "../components"
import Lomiri.Components 1.3 import Lomiri.Components 1.3
import QtQuick 2.4 import QtQuick 2.4
import "headers"
import Utils 1.0 import Utils 1.0
import "headers"
Page { Page {
id: infoPage id: infoPage

View File

@ -9,7 +9,7 @@ import QtQuick 2.4
Page { Page {
id: infoKeysPage id: infoKeysPage
property string currentKey property QtObject currentKey
Component.onCompleted: { Component.onCompleted: {
Pass.onGetAllGPGKeysSucceed.connect(function(keys_info) { Pass.onGetAllGPGKeysSucceed.connect(function(keys_info) {
@ -18,6 +18,12 @@ Page {
Pass.getAllGPGKeysFailed.connect(function(message) { Pass.getAllGPGKeysFailed.connect(function(message) {
PopupUtils.open(infoKeysPageGetAllError); PopupUtils.open(infoKeysPageGetAllError);
}); });
Pass.deleteGPGKeySucceed.connect(function(keys_info) {
PopupUtils.open(infoKeysPageDeleteSuccess);
});
Pass.deleteGPGKeyFailed.connect(function(message) {
PopupUtils.open(infoKeysPageDeleteError);
});
Pass.getAllGPGKeys(); Pass.getAllGPGKeys();
} }
@ -108,7 +114,7 @@ Page {
text: i18n.tr("Delete this key") text: i18n.tr("Delete this key")
color: theme.palette.normal.negative color: theme.palette.normal.negative
onClicked: { onClicked: {
infoKeysPage.currentKey = model.modelData.uid; infoKeysPage.currentKey = model.modelData;
PopupUtils.open(infoKeysPageDeleteValidation, infoKeysPage); PopupUtils.open(infoKeysPageDeleteValidation, infoKeysPage);
} }
} }
@ -127,15 +133,11 @@ Page {
id: infoKeysPageDeleteValidation id: infoKeysPageDeleteValidation
SimpleValidationDialog { SimpleValidationDialog {
text: i18n.tr("You're are about to delete<br>%1<br>Continue ?").arg(infoKeysPage.currentKey) text: i18n.tr("You're are about to delete<br>%1<br>Continue ?").arg(infoKeysPage.currentKey.uid)
continueText: i18n.tr("Yes") continueText: i18n.tr("Yes")
continueColor: theme.palette.normal.negative continueColor: theme.palette.normal.negative
onValidated: { onValidated: {
var status = Pass.deleteGPGKey(infoKeysPage.currentKey); var status = Pass.deleteGPGKey(infoKeysPage.currentKey);
if (status)
PopupUtils.open(infoKeysPageDeleteSuccess);
else
PopupUtils.open(infoKeysPageDeleteError);
} }
} }

View File

@ -1,7 +1,7 @@
import QtQuick 2.4
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 QtQuick 2.4
Column { Column {
width: parent.width width: parent.width

View File

@ -1,7 +1,7 @@
import QtQuick 2.4
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 QtQuick 2.4
Column { Column {
anchors.top: parent.fill anchors.top: parent.fill

View File

@ -1,31 +1,38 @@
import QtQuick 2.4
import Git 1.0 import Git 1.0
import Lomiri.Components 1.3 import Lomiri.Components 1.3
import Lomiri.Components.Pickers 1.3 import Lomiri.Components.Pickers 1.3
import QtQuick 2.4
OptionSelector { OptionSelector {
id: combo id: combo
width : parent.width
width: parent.width
model: ["HTTP", "HTTP AUTH"] model: ["HTTP", "HTTP AUTH"]
onDelegateClicked: function(i) { onDelegateClicked: function(i) {
if(i===0) { if (i === 0)
timer.setTimeout(function(){importGitCloneForm.source = Qt.resolvedUrl("GitCloneHttp.qml") }, 500); timer.setTimeout(function() {
} else if (i===1) { importGitCloneForm.source = Qt.resolvedUrl("GitCloneHttp.qml");
timer.setTimeout( function(){importGitCloneForm.source = Qt.resolvedUrl("GitCloneHttpAuth.qml") }, 500); }, 500);
} else if (i === 1)
timer.setTimeout(function() {
importGitCloneForm.source = Qt.resolvedUrl("GitCloneHttpAuth.qml");
}, 500);
} }
Timer { Timer {
id: timer id: timer
function setTimeout(cb, delayTime) { function setTimeout(cb, delayTime) {
timer.interval = delayTime; timer.interval = delayTime;
timer.repeat = false; timer.repeat = false;
timer.triggered.connect(cb); timer.triggered.connect(cb);
timer.triggered.connect(function release () { timer.triggered.connect(function release() {
timer.triggered.disconnect(cb); // This is important timer.triggered.disconnect(cb); // This is important
timer.triggered.disconnect(release); // This is important as well timer.triggered.disconnect(release); // This is important as well
}); });
timer.start(); timer.start();
} }
} }
} }

View File

@ -18,7 +18,7 @@ Page {
PopupUtils.open(dialogGitCloneError); PopupUtils.open(dialogGitCloneError);
}); });
PopupUtils.open(importGitCloneValidation, importGitClonePage); PopupUtils.open(importGitCloneValidation, importGitClonePage);
importGitCloneForm.source = Qt.resolvedUrl("GitCloneHttp.qml") importGitCloneForm.source = Qt.resolvedUrl("GitCloneHttp.qml");
} }
Column { Column {
@ -44,6 +44,7 @@ Page {
width: parent.width width: parent.width
} }
} }
Component { Component {