mirror of
https://github.com/QRouland/UTPass.git
synced 2025-01-24 07:36:39 +00:00
Fix delete gpg key
This commit is contained in:
parent
c0757da47b
commit
0eb8920856
@ -30,10 +30,10 @@ bool Git::clone(QString url, QString path, cred_type mode)
|
||||
return false;
|
||||
}
|
||||
auto v = overload {
|
||||
[](const HTTP & x) { return "HTTP"; },
|
||||
[](const HTTP & x) { return "HTTP"; },
|
||||
[](const HTTPUserPass & x) { return "HTTPAuth"; },
|
||||
[](const SSHPass & x) { return "SSHAuth"; },
|
||||
[](const SSHKey & x) { return "SSHKey"; },
|
||||
[](const SSHPass & x) { return "SSHAuth"; },
|
||||
[](const SSHKey & x) { return "SSHKey"; },
|
||||
};
|
||||
qDebug() << "Creating clone Job " << url << " " << path << " " << std::visit(v, mode);
|
||||
CloneJob *clone_job = new CloneJob(url, path, mode);
|
||||
|
@ -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 err = this->clone(this->m_url, tmp_dir.absolutePath(), this->m_cred, this->credentialsCB);
|
||||
if (err) {
|
||||
|
@ -234,7 +234,7 @@ void Gpg::getKeysJobResultSlot(const GpgME::KeyListResult &result, const std::ve
|
||||
const QString &auditLogAsHtml, const GpgME::Error &auditLogError)
|
||||
{
|
||||
if (result.error()) {
|
||||
qWarning() << "Something gone wrong on decrypt";
|
||||
qWarning() << "Something gone wrong on getKeys";
|
||||
qDebug() << "Code Error : " << result.error().code();
|
||||
qDebug() << "Error str : " << result.error().asString();
|
||||
}
|
||||
@ -287,14 +287,13 @@ Error Gpg::deleteKey(const Key key)
|
||||
QObject::connect(job, &DeleteJob::result,
|
||||
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)
|
||||
{
|
||||
|
||||
if (error) {
|
||||
qWarning() << "Something gone wrong on decrypt";
|
||||
qWarning() << "Something gone wrong on deleteKey";
|
||||
qDebug() << "Code Error : " << error.code();
|
||||
qDebug() << "Error str : " << error.asString();
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ bool Pass::show(QUrl url)
|
||||
return false;
|
||||
}
|
||||
auto path = url.toLocalFile();
|
||||
qInfo() << "Staring decrypting job for " << path;
|
||||
qInfo() << "Pass show " << path;
|
||||
QFileInfo file_info(path);
|
||||
this->m_show_filename = file_info.completeBaseName();
|
||||
return this->m_gpg->decryptFromFile(path);
|
||||
@ -51,36 +51,39 @@ bool Pass::show(QUrl url)
|
||||
|
||||
void Pass::showResult(Error err, QString plain_text)
|
||||
{
|
||||
qInfo() << "Result for decrypting job";
|
||||
qDebug() << "Pass show Result";
|
||||
if (err) {
|
||||
qInfo() << "Decrypt Failed";
|
||||
qInfo() << "Pass show Failed";
|
||||
emit showFailed(err.asString());
|
||||
|
||||
} else if (err.isCanceled()){
|
||||
qInfo() << "Decrypt Cancelled";
|
||||
emit showCancelled();
|
||||
} else if (err.isCanceled()) {
|
||||
qInfo() << "Pass show Cancelled";
|
||||
emit showCancelled();
|
||||
} else {
|
||||
qInfo() << "Decrypt OK";
|
||||
qInfo() << "Pass show Succeed";
|
||||
emit showSucceed(this->m_show_filename, plain_text);
|
||||
}
|
||||
this->m_show_filename = QString();
|
||||
this->m_sem->release(1);
|
||||
}
|
||||
|
||||
bool Pass::deleteGPGKey(Key key)
|
||||
bool Pass::deleteGPGKey(PassKeyModel* key)
|
||||
{
|
||||
if (!this->m_sem->tryAcquire(1, 500)) {
|
||||
return false;
|
||||
}
|
||||
qInfo() << "Deleting Key";
|
||||
return this->m_gpg->deleteKey(key);
|
||||
qInfo() << "Delete Key " << key->uid();
|
||||
return this->m_gpg->deleteKey(key->key());
|
||||
}
|
||||
|
||||
void Pass::deleteGPGKeyResult(Error err)
|
||||
{
|
||||
qDebug() << "Delete Ke yResult";
|
||||
if (err) {
|
||||
qInfo() << "Delete Key Failed";
|
||||
emit deleteGPGKeyFailed(err.asString());
|
||||
} else {
|
||||
qInfo() << "Delete Key Succeed";
|
||||
emit deleteGPGKeySucceed();
|
||||
}
|
||||
this->m_sem->release(1);
|
||||
@ -91,15 +94,18 @@ bool Pass::importGPGKey(QUrl url)
|
||||
if (!this->m_sem->tryAcquire(1, 500)) {
|
||||
return false;
|
||||
}
|
||||
qInfo() << "Importing Key from " << url;
|
||||
qInfo() << "Import GPG Key from " << url;
|
||||
return this->m_gpg->importKeysFromFile(url.toLocalFile());
|
||||
}
|
||||
|
||||
void Pass::importGPGKeyResult(Error err)
|
||||
{
|
||||
qDebug() << "Import GPG Key Result";
|
||||
if (err) {
|
||||
qInfo() << "Delete Key Failed";
|
||||
emit importGPGKeyFailed(err.asString());
|
||||
} else {
|
||||
qInfo() << "Delete Key Succeed";
|
||||
emit importGPGKeySucceed();
|
||||
}
|
||||
this->m_sem->release(1);
|
||||
@ -110,15 +116,18 @@ bool Pass::getAllGPGKeys()
|
||||
if (!this->m_sem->tryAcquire(1, 500)) {
|
||||
return false;
|
||||
}
|
||||
qInfo() << "Getting all key form gpg ";
|
||||
qInfo() << "Get GPG keys";
|
||||
return this->m_gpg->getAllKeys();
|
||||
}
|
||||
|
||||
void Pass::getAllGPGKeysResult(Error err, std::vector<GpgME::Key> keys_info)
|
||||
{
|
||||
qDebug() << "Get GPG keys Result";
|
||||
if (err) {
|
||||
qInfo() << "Get GPG Failed";
|
||||
emit getAllGPGKeysFailed(err.asString());
|
||||
} else {
|
||||
qInfo() << "Get GPG Succeed";
|
||||
emit getAllGPGKeysSucceed(QVariant::fromValue(PassKeyModel::keysToPassKey(keys_info)));
|
||||
}
|
||||
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)
|
||||
{
|
||||
qDebug() << "responsePassphraseDialog";
|
||||
qDebug() << "Propagate responsePassphraseDialog";
|
||||
emit responsePassphraseDialogPropagate(cancel, passphrase);
|
||||
}
|
||||
|
@ -79,8 +79,6 @@ signals:
|
||||
*/
|
||||
void getAllGPGKeysSucceed(QVariant keys_info);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Emitted when retrieving GPG keys fails.
|
||||
* @param message The error message describing the failure.
|
||||
@ -144,10 +142,10 @@ public:
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
Q_INVOKABLE bool deleteGPGKey(Key key);
|
||||
Q_INVOKABLE bool deleteGPGKey(PassKeyModel* key);
|
||||
|
||||
/**
|
||||
* @brief Imports a GPG key from the given URL.
|
||||
|
@ -59,7 +59,8 @@ bool Utils::rmDir(QUrl dir_url)
|
||||
return dir.removeRecursively();
|
||||
}
|
||||
|
||||
QString Utils::manifestPath(){
|
||||
QString Utils::manifestPath()
|
||||
{
|
||||
auto path = QDir(QDir::currentPath()).filePath("manifest_.json");
|
||||
qDebug() << "Manifest path : " << path;
|
||||
return path;
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: utpass.qrouland\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"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -85,7 +85,7 @@ msgid ""
|
||||
"a zip in the settings"
|
||||
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 !"
|
||||
msgstr ""
|
||||
|
||||
@ -124,7 +124,7 @@ msgid ""
|
||||
msgstr ""
|
||||
|
||||
#: ../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
|
||||
msgid "Yes"
|
||||
msgstr ""
|
||||
@ -142,31 +142,31 @@ msgstr ""
|
||||
msgid "Zip Password Store Import"
|
||||
msgstr ""
|
||||
|
||||
#: ../qml/pages/settings/InfoKeys.qml:48
|
||||
#: ../qml/pages/settings/InfoKeys.qml:54
|
||||
msgid "Key ID :"
|
||||
msgstr ""
|
||||
|
||||
#: ../qml/pages/settings/InfoKeys.qml:82
|
||||
#: ../qml/pages/settings/InfoKeys.qml:88
|
||||
msgid "Users IDs : "
|
||||
msgstr ""
|
||||
|
||||
#: ../qml/pages/settings/InfoKeys.qml:108
|
||||
#: ../qml/pages/settings/InfoKeys.qml:114
|
||||
msgid "Delete this key"
|
||||
msgstr ""
|
||||
|
||||
#: ../qml/pages/settings/InfoKeys.qml:130
|
||||
#: ../qml/pages/settings/InfoKeys.qml:136
|
||||
msgid "You're are about to delete<br>%1<br>Continue ?"
|
||||
msgstr ""
|
||||
|
||||
#: ../qml/pages/settings/InfoKeys.qml:148
|
||||
#: ../qml/pages/settings/InfoKeys.qml:150
|
||||
msgid "Key removal failed !"
|
||||
msgstr ""
|
||||
|
||||
#: ../qml/pages/settings/InfoKeys.qml:157
|
||||
#: ../qml/pages/settings/InfoKeys.qml:159
|
||||
msgid "Key successfully deleted !"
|
||||
msgstr ""
|
||||
|
||||
#: ../qml/pages/settings/InfoKeys.qml:177
|
||||
#: ../qml/pages/settings/InfoKeys.qml:179
|
||||
msgid "Info Keys"
|
||||
msgstr ""
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import "../components"
|
||||
import Lomiri.Components 1.3
|
||||
import QtQuick 2.4
|
||||
import "headers"
|
||||
import Utils 1.0
|
||||
import "headers"
|
||||
|
||||
Page {
|
||||
id: infoPage
|
||||
|
@ -9,7 +9,7 @@ import QtQuick 2.4
|
||||
Page {
|
||||
id: infoKeysPage
|
||||
|
||||
property string currentKey
|
||||
property QtObject currentKey
|
||||
|
||||
Component.onCompleted: {
|
||||
Pass.onGetAllGPGKeysSucceed.connect(function(keys_info) {
|
||||
@ -18,6 +18,12 @@ Page {
|
||||
Pass.getAllGPGKeysFailed.connect(function(message) {
|
||||
PopupUtils.open(infoKeysPageGetAllError);
|
||||
});
|
||||
Pass.deleteGPGKeySucceed.connect(function(keys_info) {
|
||||
PopupUtils.open(infoKeysPageDeleteSuccess);
|
||||
});
|
||||
Pass.deleteGPGKeyFailed.connect(function(message) {
|
||||
PopupUtils.open(infoKeysPageDeleteError);
|
||||
});
|
||||
Pass.getAllGPGKeys();
|
||||
}
|
||||
|
||||
@ -108,7 +114,7 @@ Page {
|
||||
text: i18n.tr("Delete this key")
|
||||
color: theme.palette.normal.negative
|
||||
onClicked: {
|
||||
infoKeysPage.currentKey = model.modelData.uid;
|
||||
infoKeysPage.currentKey = model.modelData;
|
||||
PopupUtils.open(infoKeysPageDeleteValidation, infoKeysPage);
|
||||
}
|
||||
}
|
||||
@ -127,15 +133,11 @@ Page {
|
||||
id: infoKeysPageDeleteValidation
|
||||
|
||||
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")
|
||||
continueColor: theme.palette.normal.negative
|
||||
onValidated: {
|
||||
var status = Pass.deleteGPGKey(infoKeysPage.currentKey);
|
||||
if (status)
|
||||
PopupUtils.open(infoKeysPageDeleteSuccess);
|
||||
else
|
||||
PopupUtils.open(infoKeysPageDeleteError);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import QtQuick 2.4
|
||||
import Git 1.0
|
||||
import Lomiri.Components 1.3
|
||||
import Pass 1.0
|
||||
import QtQuick 2.4
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
|
@ -1,7 +1,7 @@
|
||||
import QtQuick 2.4
|
||||
import Git 1.0
|
||||
import Lomiri.Components 1.3
|
||||
import Pass 1.0
|
||||
import QtQuick 2.4
|
||||
|
||||
Column {
|
||||
anchors.top: parent.fill
|
||||
|
@ -1,31 +1,38 @@
|
||||
import QtQuick 2.4
|
||||
import Git 1.0
|
||||
import Lomiri.Components 1.3
|
||||
import Lomiri.Components.Pickers 1.3
|
||||
import QtQuick 2.4
|
||||
|
||||
OptionSelector {
|
||||
OptionSelector {
|
||||
id: combo
|
||||
width : parent.width
|
||||
|
||||
width: parent.width
|
||||
model: ["HTTP", "HTTP AUTH"]
|
||||
onDelegateClicked: function(i) {
|
||||
if(i===0) {
|
||||
timer.setTimeout(function(){importGitCloneForm.source = Qt.resolvedUrl("GitCloneHttp.qml") }, 500);
|
||||
} else if (i===1) {
|
||||
timer.setTimeout( function(){importGitCloneForm.source = Qt.resolvedUrl("GitCloneHttpAuth.qml") }, 500);
|
||||
}
|
||||
if (i === 0)
|
||||
timer.setTimeout(function() {
|
||||
importGitCloneForm.source = Qt.resolvedUrl("GitCloneHttp.qml");
|
||||
}, 500);
|
||||
else if (i === 1)
|
||||
timer.setTimeout(function() {
|
||||
importGitCloneForm.source = Qt.resolvedUrl("GitCloneHttpAuth.qml");
|
||||
}, 500);
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: timer
|
||||
|
||||
function setTimeout(cb, delayTime) {
|
||||
timer.interval = delayTime;
|
||||
timer.repeat = false;
|
||||
timer.triggered.connect(cb);
|
||||
timer.triggered.connect(function release () {
|
||||
timer.triggered.connect(function release() {
|
||||
timer.triggered.disconnect(cb); // This is important
|
||||
timer.triggered.disconnect(release); // This is important as well
|
||||
});
|
||||
timer.start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ Page {
|
||||
PopupUtils.open(dialogGitCloneError);
|
||||
});
|
||||
PopupUtils.open(importGitCloneValidation, importGitClonePage);
|
||||
importGitCloneForm.source = Qt.resolvedUrl("GitCloneHttp.qml")
|
||||
importGitCloneForm.source = Qt.resolvedUrl("GitCloneHttp.qml");
|
||||
}
|
||||
|
||||
Column {
|
||||
@ -44,6 +44,7 @@ Page {
|
||||
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Component {
|
||||
|
Loading…
x
Reference in New Issue
Block a user