mirror of
https://github.com/QRouland/UTPass.git
synced 2025-07-02 10:12:28 +00:00
Fix delete gpg key
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user