mirror of
https://github.com/QRouland/UTPass.git
synced 2025-07-05 11:22:29 +00:00
Some improvements
This commit is contained in:
@ -7,6 +7,7 @@ set(
|
||||
pass.cpp
|
||||
passkeyringmodel.h
|
||||
passphraseprovider.h
|
||||
error.h
|
||||
jobs/decryptjob.cpp
|
||||
jobs/deletekeyjob.cpp
|
||||
jobs/getkeysjob.cpp
|
||||
|
30
plugins/Pass/error.h
Normal file
30
plugins/Pass/error.h
Normal file
@ -0,0 +1,30 @@
|
||||
// error.h
|
||||
#ifndef ERROR_H
|
||||
#define ERROR_H
|
||||
|
||||
extern "C" {
|
||||
#include "rnp/rnp_err.h"
|
||||
}
|
||||
|
||||
enum ErrorCodeShow {
|
||||
UnexceptedError= 1,
|
||||
BadPassphrase,
|
||||
NoKeyFound,
|
||||
DecryptFailed
|
||||
};
|
||||
|
||||
ErrorCodeShow rnpErrorToErrorCodeShow(int rnpErrorCode) {
|
||||
switch (rnpErrorCode) {
|
||||
case RNP_ERROR_BAD_PASSWORD:
|
||||
return BadPassphrase;
|
||||
case RNP_ERROR_KEY_NOT_FOUND:
|
||||
case RNP_ERROR_NO_SUITABLE_KEY:
|
||||
return NoKeyFound;
|
||||
case RNP_ERROR_DECRYPT_FAILED:
|
||||
return DecryptFailed;
|
||||
default:
|
||||
return UnexceptedError;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ERROR_H
|
@ -3,6 +3,7 @@
|
||||
#include <QtCore/QDir>
|
||||
#include <QDirIterator>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
#include "error.h"
|
||||
#include "jobs/decryptjob.h"
|
||||
#include "jobs/deletekeyjob.h"
|
||||
#include "jobs/getkeysjob.h"
|
||||
@ -108,7 +109,7 @@ bool Pass::show(QUrl url)
|
||||
void Pass::slotShowError(rnp_result_t err)
|
||||
{
|
||||
qInfo() << "[Pass] Show Failed";
|
||||
emit showFailed(rnp_result_to_string(err));
|
||||
emit showFailed(rnpErrorToErrorCodeShow(err), rnp_result_to_string(err));
|
||||
this->m_sem->release(1);
|
||||
}
|
||||
|
||||
@ -136,13 +137,13 @@ bool Pass::deletePasswordStore()
|
||||
}
|
||||
|
||||
void Pass::slotDeletePasswordStoreResult(bool err)
|
||||
{
|
||||
this->initPasswordStore(); // reinit an empty password-store
|
||||
{
|
||||
if (err) {
|
||||
qInfo() << "[Pass] Delete Password Store Failed";
|
||||
emit deletePasswordStoreFailed("failed to delete password store");
|
||||
} else {
|
||||
qInfo() << "[Pass] Delete Password Store Succeed";
|
||||
this->initPasswordStore(); // reinit an empty password-store
|
||||
emit deletePasswordStoreSucceed();
|
||||
}
|
||||
this->m_sem->release(1);
|
||||
|
@ -125,7 +125,7 @@ signals:
|
||||
* @brief Emitted when showing a password fails.
|
||||
* @param message The error message describing the failure.
|
||||
*/
|
||||
void showFailed(QString message);
|
||||
void showFailed(int err, QString message);
|
||||
|
||||
/**
|
||||
* @brief Emitted hen showing a password cancelled.
|
||||
|
Reference in New Issue
Block a user