1
0
mirror of https://github.com/QRouland/UTPass.git synced 2025-02-11 15:07:16 +00:00

Complete rewrite from gpgme to rnp

This commit is contained in:
Quentin Rouland 2025-02-03 21:46:21 +01:00
parent e56c16f27b
commit ba52ddac5c
20 changed files with 333 additions and 171 deletions

View File

@ -7,11 +7,12 @@ set(
pass.cpp pass.cpp
passkeyringmodel.h passkeyringmodel.h
passphraseprovider.h passphraseprovider.h
jobs/rmjob.cpp jobs/decryptjob.cpp
jobs/rnpjob.cpp jobs/deletekeyjob.cpp
jobs/getkeysjob.cpp jobs/getkeysjob.cpp
jobs/importkeyjob.cpp jobs/importkeyjob.cpp
jobs/decryptjob.cpp jobs/rmjob.cpp
jobs/rnpjob.cpp
) )
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)

View File

@ -16,12 +16,13 @@ DecryptJob::DecryptJob(QDir rnp_homedir, QString path):
void DecryptJob::run() void DecryptJob::run()
{ {
qDebug() << "[DecryptJob] Starting"; qDebug() << "[DecryptJob] Starting";
this->load_sec_keyring(NULL); this->loadFullKeyring(NULL);
rnp_input_t input = NULL; rnp_input_t input = NULL;
rnp_output_t output = NULL; rnp_output_t output = NULL;
uint8_t *buf = NULL; uint8_t *buf = NULL;
size_t buf_len = 0; size_t buf_len = 0;
QString data = QString::Null();
auto ret = rnp_input_from_path(&input, this->m_encrypted_file_path.toLocal8Bit().data()); auto ret = rnp_input_from_path(&input, this->m_encrypted_file_path.toLocal8Bit().data());
if (ret == RNP_SUCCESS) { if (ret == RNP_SUCCESS) {
@ -34,14 +35,13 @@ void DecryptJob::run()
ret = rnp_output_memory_get_buf(output, &buf, &buf_len, false); ret = rnp_output_memory_get_buf(output, &buf, &buf_len, false);
} }
if (ret == RNP_SUCCESS) { if (ret == RNP_SUCCESS) {
emit resultSuccess(this->m_encrypted_file_path, QString::fromUtf8((char*)buf)); data = QString::fromUtf8((char*)buf);
} }
rnp_input_destroy(input); rnp_input_destroy(input);
rnp_output_destroy(output); rnp_output_destroy(output);
terminateOnError(ret); terminateOnError(ret);
emit resultSuccess(this->m_encrypted_file_path, data);
emit resultSuccess(this->m_encrypted_file_path, QString::fromUtf8((char*)buf));
qDebug() << "[DecryptJob] Finished Successfully "; qDebug() << "[DecryptJob] Finished Successfully ";
} }

View File

@ -18,8 +18,7 @@ class DecryptJob : public RnpJob
* @brief Executes the decryption operation. * @brief Executes the decryption operation.
* *
* This method performs the actual decryption of the encrypted file specified during * This method performs the actual decryption of the encrypted file specified during
* object construction. The operation is carried out in a separate background thread * object construction.
* to prevent blocking the main application thread.
*/ */
void run() override; void run() override;

View File

@ -0,0 +1,42 @@
#include <QDebug>
#include <QString>
#include <QJsonDocument>
#include "deletekeyjob.h"
extern "C" {
#include <rnp/rnp.h>
#include <rnp/rnp_err.h>
}
DeleteKeyJob::DeleteKeyJob(QDir rnp_homedir, QString fingerprint):
RnpJob(rnp_homedir),
m_fingerprint(fingerprint)
{
this->setObjectName("ImportKeyJob");
}
void DeleteKeyJob::run()
{
qDebug() << "[DeleteKeyJob] Starting";
// Loading keyring
this->loadFullKeyring(NULL);
// Delete key
rnp_key_handle_t key = NULL;
auto ret = rnp_locate_key(this->m_ffi, "fingerprint", this->m_fingerprint.toLocal8Bit().data(), &key);
if (ret == RNP_SUCCESS) {
ret = rnp_key_remove(key, RNP_KEY_REMOVE_PUBLIC | RNP_KEY_REMOVE_SECRET | RNP_KEY_REMOVE_SUBKEYS);
};
rnp_key_handle_destroy(key);
// Save resulting keyring
this->saveFullKeyring();
// Emit result
terminateOnError(ret);
emit resultSuccess();
qDebug() << "[DeleteKeyJob] Finished Successfully ";
}

View File

@ -0,0 +1,46 @@
#ifndef DELETEKEYJOB_H
#define DELETEKEYJOB_H
#include "rnpjob.h"
/**
* @class DeleteKeyJob
* @brief A job to handle the deletion of a key in a separate thread.
*
*/
class DeleteKeyJob : public RnpJob
{
Q_OBJECT
/**
* @brief Executes the key deletion operation.
*
* This function performs the actual process of deleting the GPG key from the keyring.
*/
void run() override;
signals:
/**
* @brief Emitted when the key deletion operation is successful.
*
* This signal is emitted when the key is successfully deleted from the keyring..
*/
void resultSuccess();
private:
QString m_fingerprint; /**< The fingerprint of the key to delete. */
public:
/**
* @brief Constructs a DeleteKeyJob object with the specified fingerprint and keyring directory.
*
* This constructor initializes the DeleteKeyJob instance with the directory containing
* the keyrings and the fingerprint of the GPG key to delete.
*
* @param rnp_homedir The directory containing the keyrings where the key will be deleted.
* @param fingerprint The fingerprint of the key to delete.
*/
DeleteKeyJob(QDir rnp_homedir, QString fingerprint);
};
#endif // DELETEKEYJOB_H

View File

@ -30,7 +30,7 @@ void GetKeysJob::run()
// Loading keyring // Loading keyring
QSet<QString> fingerprints = QSet<QString>(); QSet<QString> fingerprints = QSet<QString>();
this->load_full_keyring(&fingerprints); this->loadFullKeyring(&fingerprints);
//Get infos keys //Get infos keys
auto key_infos = QList<QJsonDocument>(); auto key_infos = QList<QJsonDocument>();

View File

@ -16,8 +16,7 @@ class GetKeysJob : public RnpJob
/** /**
* @brief Executes the process of fetching all GPG keys. * @brief Executes the process of fetching all GPG keys.
* *
* This function performs the task of retrieving all keys from the keyrings. It is executed * This function performs the task of retrieving all keys from the keyrings.
* in a separate thread to avoid blocking the main application thread.
*/ */
void run() override; void run() override;

View File

@ -19,6 +19,11 @@ ImportKeyJob::ImportKeyJob(QDir rnp_homedir, QString key_file_path):
void ImportKeyJob::run() void ImportKeyJob::run()
{ {
qDebug() << "[ImportKeyJob] Starting"; qDebug() << "[ImportKeyJob] Starting";
// Loading keyring
this->loadFullKeyring(NULL);
// Import new key
rnp_input_t input = NULL; rnp_input_t input = NULL;
auto ret = rnp_input_from_path(&input, this->m_key_file_path.toLocal8Bit().constData()); auto ret = rnp_input_from_path(&input, this->m_key_file_path.toLocal8Bit().constData());
if (ret == RNP_SUCCESS) { if (ret == RNP_SUCCESS) {
@ -35,29 +40,33 @@ void ImportKeyJob::run()
rnp_input_destroy(input); rnp_input_destroy(input);
terminateOnError(ret); terminateOnError(ret);
rnp_output_t output = NULL; // Save resulting keyring
qDebug() << "[ImportKeyJob] Writing pubring to " << this->pubringPath(); this->saveFullKeyring();
ret = rnp_output_to_file(&output, this->pubringPath().toLocal8Bit().constData(), RNP_OUTPUT_FILE_OVERWRITE); // rnp_output_t output = NULL;
if (ret == RNP_SUCCESS) { // qDebug() << "[ImportKeyJob] Writing pubring to " << this->pubringPath();
qDebug() << "[ImportKeyJob] Saving key pubring "; // ret = rnp_output_to_file(&output, this->pubringPath().toLocal8Bit().constData(), RNP_OUTPUT_FILE_OVERWRITE);
ret = rnp_save_keys(this->m_ffi, RNP_KEYSTORE_GPG, output, RNP_LOAD_SAVE_PUBLIC_KEYS); // if (ret == RNP_SUCCESS) {
// qDebug() << "[ImportKeyJob] Saving key pubring ";
// ret = rnp_save_keys(this->m_ffi, RNP_KEYSTORE_GPG, output, RNP_LOAD_SAVE_PUBLIC_KEYS);
} // }
if (ret == RNP_SUCCESS) { // if (ret == RNP_SUCCESS) {
ret = rnp_output_finish(output); // ret = rnp_output_finish(output);
} // }
rnp_output_destroy(output); // rnp_output_destroy(output);
terminateOnError(ret); // terminateOnError(ret);
qDebug() << "[ImportKeyJob] Writing secring to " << this->secringPath(); // qDebug() << "[ImportKeyJob] Writing secring to " << this->secringPath();
ret = rnp_output_to_file(&output, this->secringPath().toLocal8Bit().constData(), RNP_OUTPUT_FILE_OVERWRITE); // ret = rnp_output_to_file(&output, this->secringPath().toLocal8Bit().constData(), RNP_OUTPUT_FILE_OVERWRITE);
if (ret == RNP_SUCCESS) { // if (ret == RNP_SUCCESS) {
qDebug() << "[ImportKeyJob] Saving key secring "; // qDebug() << "[ImportKeyJob] Saving key secring ";
ret = rnp_save_keys(this->m_ffi, RNP_KEYSTORE_GPG, output, RNP_LOAD_SAVE_SECRET_KEYS); // ret = rnp_save_keys(this->m_ffi, RNP_KEYSTORE_GPG, output, RNP_LOAD_SAVE_SECRET_KEYS);
} // }
rnp_output_destroy(output); // rnp_output_destroy(output);
terminateOnError(ret); // terminateOnError(ret);
// Emit result
emit resultSuccess(); emit resultSuccess();
qDebug() << "[ImportKeyJob] Finished Successfully "; qDebug() << "[ImportKeyJob] Finished Successfully ";
} }

View File

@ -16,8 +16,7 @@ class ImportKeyJob : public RnpJob
* @brief Executes the key import operation. * @brief Executes the key import operation.
* *
* This function handles the actual process of importing the GPG key file into the * This function handles the actual process of importing the GPG key file into the
* keyring. It is executed in a separate thread to prevent UI freezing or blocking * keyring.
* of the main application thread during the import.
*/ */
void run() override; void run() override;

View File

@ -17,8 +17,6 @@ class RmJob : public QThread
* @brief Executes the recursive remove operation. * @brief Executes the recursive remove operation.
* *
* This method performs the recursive removal of the specified target path. * This method performs the recursive removal of the specified target path.
* The operation is performed in the background to prevent blocking of the main
* application thread.
*/ */
void run() override; void run() override;

View File

@ -50,7 +50,7 @@ bool RnpJob::passProvider(rnp_ffi_t ffi,
} }
void RnpJob::load_key_file(QSet<QString> *result_fingerprints, const QString path, const uint32_t flags) void RnpJob::loadKeyFile(QSet<QString> *result_fingerprints, const QString path, const uint32_t flags)
{ {
qDebug() << "[RnpJob] Load keyring at" << path; qDebug() << "[RnpJob] Load keyring at" << path;
rnp_input_t input = NULL; rnp_input_t input = NULL;
@ -82,18 +82,53 @@ void RnpJob::load_key_file(QSet<QString> *result_fingerprints, const QString pat
} }
void RnpJob::load_pub_keyring(QSet<QString> *result_fingerprints = NULL) void RnpJob::loadPubKeyring(QSet<QString> *result_fingerprints = NULL)
{ {
this->load_key_file(result_fingerprints, this->pubringPath(), RNP_LOAD_SAVE_PUBLIC_KEYS); this->loadKeyFile(result_fingerprints, this->pubringPath(), RNP_LOAD_SAVE_PUBLIC_KEYS);
} }
void RnpJob::load_sec_keyring(QSet<QString> *result_fingerprints = NULL) void RnpJob::loadSecKeyring(QSet<QString> *result_fingerprints = NULL)
{ {
this->load_key_file(result_fingerprints, this->secringPath(), RNP_LOAD_SAVE_SECRET_KEYS); this->loadKeyFile(result_fingerprints, this->secringPath(), RNP_LOAD_SAVE_SECRET_KEYS);
} }
void RnpJob::load_full_keyring(QSet<QString> *result_fingerprints = NULL) void RnpJob::loadFullKeyring(QSet<QString> *result_fingerprints = NULL)
{ {
this->load_pub_keyring(result_fingerprints); this->loadPubKeyring(result_fingerprints);
this->load_sec_keyring(result_fingerprints); this->loadSecKeyring(result_fingerprints);
} }
void RnpJob::saveKeyFile(const QString path, const uint32_t flags)
{
qDebug() << "[RnpJob] Saving keyring at" << path;
rnp_output_t output = NULL;
auto ret = rnp_output_to_file(&output, path.toLocal8Bit().data(), RNP_OUTPUT_FILE_OVERWRITE);
if (ret == RNP_SUCCESS) {
qDebug() << "[ImportKeyJob] Saving key pubring ";
ret = rnp_save_keys(this->m_ffi, RNP_KEYSTORE_GPG, output, flags);
}
if (ret == RNP_SUCCESS) {
ret = rnp_output_finish(output);
}
rnp_output_destroy(output);
terminateOnError(ret);
}
void RnpJob::savePubKeyring()
{
this->saveKeyFile(this->pubringPath(), RNP_LOAD_SAVE_PUBLIC_KEYS);
}
void RnpJob::saveSecKeyring()
{
this->saveKeyFile(this->secringPath(), RNP_LOAD_SAVE_SECRET_KEYS);
}
void RnpJob::saveFullKeyring()
{
this->savePubKeyring();
this->saveSecKeyring();
}

View File

@ -73,7 +73,19 @@ private:
* @param path The path to the key file. * @param path The path to the key file.
* @param flags Flags specifying options for loading keys (e.g., overwrite, secret keys, etc.). * @param flags Flags specifying options for loading keys (e.g., overwrite, secret keys, etc.).
*/ */
void load_key_file(QSet<QString> *result_fingerprints, const QString path, const uint32_t flags); void loadKeyFile(QSet<QString> *result_fingerprints, const QString path, const uint32_t flags);
/**
* @brief Saves keys to the keyring file in the specified directory.
*
* This method saves a keyring to a file. It allows you to specify options such as overwriting
* existing files or including secret keys.
*
* @param path The path to the keyring file where the keys should be saved.
* @param flags Flags specifying options for saving the keys (e.g., overwrite, include secret keys, etc.).
*/
void saveKeyFile(const QString path, const uint32_t flags);
protected: protected:
rnp_ffi_t m_ffi; /**< RNP FFI (Foreign Function Interface) handle, used for interacting with the RNP library. */ rnp_ffi_t m_ffi; /**< RNP FFI (Foreign Function Interface) handle, used for interacting with the RNP library. */
@ -105,34 +117,43 @@ protected:
} }
/** /**
* @brief Loads the secret keyring into the RNP system. * @brief Loads the secret keyring into RNP.
*
* This method loads the secret keyring file (secring.pgp) into the system, adding keys
* to the keyring based on their fingerprints.
* *
* @param result_fingerprints A set that will hold the fingerprints of the loaded secret keys. * @param result_fingerprints A set that will hold the fingerprints of the loaded secret keys.
*/ */
void load_sec_keyring(QSet<QString> *result_fingerprints); void loadSecKeyring(QSet<QString> *result_fingerprints);
/** /**
* @brief Loads the public keyring into the RNP system. * @brief Loads the public keyring into RNP.
*
* This method loads the public keyring file (pubring.pgp) into the system, adding keys
* to the keyring based on their fingerprints.
* *
* @param result_fingerprints A set that will hold the fingerprints of the loaded public keys. * @param result_fingerprints A set that will hold the fingerprints of the loaded public keys.
*/ */
void load_pub_keyring(QSet<QString> *result_fingerprints); void loadPubKeyring(QSet<QString> *result_fingerprints);
/** /**
* @brief Loads both the public and secret keyrings into the RNP system. * @brief Loads both the public and secret keyrings into RNP.
*
* This method loads both the public and secret keyring files into the system, adding keys
* to the keyring based on their fingerprints. It is a combined operation for full keyring loading.
* *
* @param result_fingerprints A set that will hold the fingerprints of all loaded keys. * @param result_fingerprints A set that will hold the fingerprints of all loaded keys.
*/ */
void load_full_keyring(QSet<QString> *result_fingerprints); void loadFullKeyring(QSet<QString> *result_fingerprints);
/**
* @brief Saves the secret keyring to the RNP homedir.
*
*/
void saveSecKeyring();
/**
* @brief Saves the public keyring to the RNP homedir.
*
*/
void savePubKeyring();
/**
* @brief Saves both the public and secret keyrings to the RNP homedir.
*
*/
void saveFullKeyring();
public: public:
/** /**
@ -155,7 +176,8 @@ public:
~RnpJob(); ~RnpJob();
void setPassProvider(rnp_password_cb pass_provider_cb) { void setPassProvider(rnp_password_cb pass_provider_cb)
{
rnp_ffi_set_pass_provider(this->m_ffi, pass_provider_cb, NULL); rnp_ffi_set_pass_provider(this->m_ffi, pass_provider_cb, NULL);
} }
}; };

View File

@ -3,8 +3,10 @@
#include <QtCore/QDir> #include <QtCore/QDir>
#include "jobs/decryptjob.h" #include "jobs/decryptjob.h"
#include "jobs/deletekeyjob.h"
#include "jobs/getkeysjob.h" #include "jobs/getkeysjob.h"
#include "jobs/importkeyjob.h" #include "jobs/importkeyjob.h"
#include "jobs/rmjob.h"
#include "pass.h" #include "pass.h"
#include "passphraseprovider.h" #include "passphraseprovider.h"
@ -91,57 +93,62 @@ void Pass::slotShowSucceed(QString encrypted_file_path, QString plain_text)
this->m_sem->release(1); this->m_sem->release(1);
} }
// bool Pass::deletePasswordStore() bool Pass::deletePasswordStore()
// { {
// if (!this->m_sem->tryAcquire(1, 500)) { qInfo() << "[Pass] Delete Password Store at" << this->password_store();
// return false; if (!this->m_sem->tryAcquire(1, 500)) {
// } qInfo() << "[Pass] A command is already running";
// qInfo() << "Pass delete Password Store"; return false;
// auto job = new RmJob(this->password_store()); }
// qDebug() << "Delete Password Store at " << this->password_store(); auto job = new RmJob(this->password_store());
// connect(job, &RmJob::resultReady, this, &Pass::deletePasswordStoreResult); connect(job, &RmJob::resultReady, this, &Pass::slotDeletePasswordStoreResult);
// connect(job, &RmJob::finished, job, &QObject::deleteLater); connect(job, &RmJob::finished, job, &QObject::deleteLater);
// job->start(); job->start();
// return true; return true;
// } }
// void Pass::deletePasswordStoreResult(bool err) void Pass::slotDeletePasswordStoreResult(bool err)
// { {
if (err) {
// qDebug() << "Pass delete Password StoreResult"; qInfo() << "[Pass] delete Password Store Failed";
// if (err) { //dir.removeRecursively()) { emit deletePasswordStoreFailed("failed to delete password store");
// qInfo() << "Pass delete Password Store Failed"; } else {
// emit deletePasswordStoreFailed("failed to delete password store"); qInfo() << "[Pass] Delete Password Store Succeed";
emit deletePasswordStoreSucceed();
// } else { }
// qInfo() << "Pass delete Password Store Succeed"; this->m_sem->release(1);
// emit deletePasswordStoreSucceed(); }
// }
// this->m_sem->release(1);
// }
// bool Pass::deleteGPGKey(PassKeyModel* key) bool Pass::deleteGPGKey(PassKeyModel* key)
// { {
// if (!this->m_sem->tryAcquire(1, 500)) { qInfo() << "[Pass] Delete GPG key fingerprint " << key->property("keyid").toString();
// return false; if (!this->m_sem->tryAcquire(1, 500)) {
// } qInfo() << "[Pass] A command is already running";
// qInfo() << "Delete Key " << key->uid(); return false;
// return this->m_gpg->deleteKey(key->key()); }
// } auto job = new DeleteKeyJob(this->m_gpg_home, key->property("fingerprint").toString());
QObject::connect(job, &DeleteKeyJob::resultError, this, &Pass::slotDeleteGPGKeyError);
QObject::connect(job, &DeleteKeyJob::resultSuccess, this, &Pass::slotDeleteGPGKeySucceed);
connect(job, &DeleteKeyJob::finished, job, &QObject::deleteLater);
job->start();
return true;
}
void Pass::slotDeleteGPGKeyError(rnp_result_t err)
{
qInfo() << "[Pass] Delete GPG key Failed";
emit deleteGPGKeyFailed(rnp_result_to_string(err));
this->m_sem->release(1);
}
void Pass::slotDeleteGPGKeySucceed()
{
qInfo() << "[Pass] Delete GPG key Succesfull";
emit deleteGPGKeySucceed();
this->m_sem->release(1);
}
// 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);
// }
bool Pass::importGPGKey(QUrl url) bool Pass::importGPGKey(QUrl url)
{ {
@ -206,6 +213,6 @@ void Pass::slotGetAllGPGKeysSucceed(QList<QJsonDocument> result)
void Pass::responsePassphraseDialog(bool cancel, QString passphrase) void Pass::responsePassphraseDialog(bool cancel, QString passphrase)
{ {
qDebug() << "Propagate responsePassphraseDialog"; qDebug() << "[Pass] Propagate responsePassphraseDialog to UTPassphraseProvider";
emit responsePassphraseDialogPropagate(cancel, passphrase); emit responsePassphraseDialogPropagate(cancel, passphrase);
} }

View File

@ -35,11 +35,9 @@ private slots:
void slotShowSucceed(QString encrypted_file_path, QString plain_text); void slotShowSucceed(QString encrypted_file_path, QString plain_text);
/** void slotDeleteGPGKeyError(rnp_result_t err);
* @brief Slot to handle the result of a GPG key deletion operation.
* @param err The error that occurred during the operation. void slotDeleteGPGKeySucceed();
*/
// void deleteGPGKeyResult(Error err);
/** /**
* @brief Slot to handle the error result of a GPG key import operation. * @brief Slot to handle the error result of a GPG key import operation.
@ -67,7 +65,7 @@ private slots:
* @brief Slot to handle the result of a delete Password Store operation. * @brief Slot to handle the result of a delete Password Store operation.
* @param err True if an error occurred during the operation. * @param err True if an error occurred during the operation.
*/ */
void deletePasswordStoreResult(bool err); void slotDeletePasswordStoreResult(bool err);
signals: signals:
// GPG-related signals // GPG-related signals
@ -146,7 +144,8 @@ signals:
private: private:
QString m_password_store; /**< The path to the password store. */ QString m_password_store; /**< The path to the password store. */
QString m_gpg_home; /**< The path to the gpg home. */ QString m_gpg_home; /**< The path to the gpg home. */
std::unique_ptr<PassKeyringModel> m_keyring_model; /**< Meta data on the keyring uid, name, secrecy ... of the availble keys. */ std::unique_ptr<PassKeyringModel>
m_keyring_model; /**< Meta data on the keyring uid, name, secrecy ... of the availble keys. */
rnp_password_cb m_passphrase_provider; /**< Pointer on passphrase povider for operations using secret keys. */ rnp_password_cb m_passphrase_provider; /**< Pointer on passphrase povider for operations using secret keys. */
std::unique_ptr<QSemaphore> m_sem; /**< Semaphore for managing concurrent operations. */ std::unique_ptr<QSemaphore> m_sem; /**< Semaphore for managing concurrent operations. */

View File

@ -39,10 +39,10 @@ public:
PassKeyModel(QJsonDocument key_info) PassKeyModel(QJsonDocument key_info)
{ {
this->m_fingerprint = key_info["fingerprint"].toString(); this->m_fingerprint = key_info["fingerprint"].toString();
qDebug() << "fingerprint : " << this->m_fingerprint; qDebug() << "[PassKeyModel] fingerprint : " << this->m_fingerprint;
this->m_keyid = key_info["keyid"].toString(); this->m_keyid = key_info["keyid"].toString();
qDebug() << "keyid : " << this->m_keyid; qDebug() << "[PassKeyModel] keyid : " << this->m_keyid;
auto user_ids_json_array = key_info["userids"].toArray(); auto user_ids_json_array = key_info["userids"].toArray();
auto userids = QList<QString>(); auto userids = QList<QString>();
@ -50,10 +50,10 @@ public:
userids.append((*i).toString()); userids.append((*i).toString());
} }
this->m_userids = QVariant(userids); this->m_userids = QVariant(userids);
qDebug() << "userids : " << this->m_userids; qDebug() << "[PassKeyModel] userids : " << this->m_userids;
this->m_hasSecret = key_info["secret key"]["present"].toBool(); this->m_hasSecret = key_info["secret key"]["present"].toBool();
qDebug() << "hasSecret : " << this->m_hasSecret; qDebug() << "[PassKeyModel] hasSecret : " << this->m_hasSecret;
} }
}; };
@ -92,13 +92,13 @@ public:
PassKeyringModel(QList<QJsonDocument> key_infos) PassKeyringModel(QList<QJsonDocument> key_infos)
{ {
for (auto i = key_infos.begin(), end = key_infos.end(); i != end; ++i) { for (auto i = key_infos.begin(), end = key_infos.end(); i != end; ++i) {
qDebug() << *i; qDebug() << "[PassKeyringModel]" << *i;
// Ignore subkeys and only add primary keys to the model. // Ignore subkeys and only add primary keys to the model.
if ((*i)["primary key grip"].isUndefined()) { if ((*i)["primary key grip"].isUndefined()) {
this->m_keys.append(new PassKeyModel(*i)); this->m_keys.append(new PassKeyModel(*i));
} else { } else {
qDebug() << "Subkey info " << (*i)["keyid"].toString() << "ignored"; qDebug() << "[PassKeyringModel] Subkey info " << (*i)["keyid"].toString() << "ignored";
} }
} }
} }

View File

@ -138,8 +138,7 @@ public:
return false; return false;
} }
if (!UTPassphraseProvider::instance().m_sem->tryAcquire(1, 500)) if (!UTPassphraseProvider::instance().m_sem->tryAcquire(1, 500)) {
{
qWarning() << "[UTPassphraseProvider] Aborting : Cannot acquire UTPassphraseProvider semaphore"; qWarning() << "[UTPassphraseProvider] Aborting : Cannot acquire UTPassphraseProvider semaphore";
return false; return false;
} }
@ -182,7 +181,8 @@ public:
* *
* @param window The window object to set. * @param window The window object to set.
*/ */
void setWindow(QObject* window){ void setWindow(QObject* window)
{
this->m_window = window; this->m_window = window;
} }
}; };

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-02-03 19:54+0100\n" "POT-Creation-Date: 2025-02-03 21:35+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"
@ -123,7 +123,7 @@ msgstr ""
#: ../qml/pages/settings/DeleteRepo.qml:56 #: ../qml/pages/settings/DeleteRepo.qml:56
#: ../qml/pages/settings/ImportZip.qml:64 #: ../qml/pages/settings/ImportZip.qml:64
#: ../qml/pages/settings/InfoKeys.qml:167 #: ../qml/pages/settings/InfoKeys.qml:170
#: ../qml/pages/settings/git/ImportGitClone.qml:56 #: ../qml/pages/settings/git/ImportGitClone.qml:56
msgid "Yes" msgid "Yes"
msgstr "" msgstr ""
@ -137,7 +137,7 @@ msgid "Password Store deleted !"
msgstr "" msgstr ""
#: ../qml/pages/settings/DeleteRepo.qml:90 #: ../qml/pages/settings/DeleteRepo.qml:90
#: ../qml/pages/settings/InfoKeys.qml:209 #: ../qml/pages/settings/InfoKeys.qml:212
msgid "Info Keys" msgid "Info Keys"
msgstr "" msgstr ""
@ -179,27 +179,27 @@ msgstr ""
msgid "Key ID :" msgid "Key ID :"
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:117 #: ../qml/pages/settings/InfoKeys.qml:120
msgid "Users IDs : " msgid "Users IDs : "
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:144 #: ../qml/pages/settings/InfoKeys.qml:147
msgid "Delete this key" msgid "Delete this key"
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:166 #: ../qml/pages/settings/InfoKeys.qml:169
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:180 #: ../qml/pages/settings/InfoKeys.qml:183
msgid "Key removal failed !" msgid "Key removal failed !"
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:189 #: ../qml/pages/settings/InfoKeys.qml:192
msgid "Key successfully deleted !" msgid "Key successfully deleted !"
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:201 #: ../qml/pages/settings/InfoKeys.qml:204
msgid "An Error occured getting GPG keys !" msgid "An Error occured getting GPG keys !"
msgstr "" msgstr ""

View File

@ -88,7 +88,13 @@ Page {
width: parent.width width: parent.width
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
text: model.modelData.keyid text: {
if (!model.modelData) {
"";
} else {
model.modelData.keyid;
}
}
color: theme.palette.normal.backgroundText color: theme.palette.normal.backgroundText
} }
@ -102,6 +108,7 @@ Page {
id: userIdsModel id: userIdsModel
Component.onCompleted: { Component.onCompleted: {
if (model.modelData) {
for (var i = 0; i < model.modelData.userids.length; ++i) { for (var i = 0; i < model.modelData.userids.length; ++i) {
userIdsModel.append({ userIdsModel.append({
"model": model.modelData.userids[i] "model": model.modelData.userids[i]
@ -109,6 +116,7 @@ Page {
} }
} }
} }
}
Text { Text {
width: parent.width width: parent.width
@ -125,7 +133,7 @@ Page {
width: parent.width width: parent.width
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
text: modelData.uid text: modelData
color: theme.palette.normal.backgroundText color: theme.palette.normal.backgroundText
} }
@ -163,7 +171,7 @@ Page {
id: infoKeysPageDeleteValidation id: infoKeysPageDeleteValidation
SimpleValidationDialog { SimpleValidationDialog {
text: i18n.tr("You're are about to delete<br>%1.<br>Continue ?").arg(infoKeysPage.__currentKey.uid) text: i18n.tr("You're are about to delete<br>%1.<br>Continue ?").arg(infoKeysPage.__currentKey.keyid)
continueText: i18n.tr("Yes") continueText: i18n.tr("Yes")
continueColor: theme.palette.normal.negative continueColor: theme.palette.normal.negative
onValidated: { onValidated: {

View File

@ -33,7 +33,8 @@ example_pass_provider(rnp_ffi_t ffi,
const char *pgp_context, const char *pgp_context,
char buf[], char buf[],
size_t buf_len) size_t buf_len)
{ strncpy(buf, "utpasspassphrase", buf_len); {
strncpy(buf, "utpasspassphrase", buf_len);
return true; return true;
} }
}; };

View File

@ -21,9 +21,8 @@ PassTestCase {
} }
function test_pass_show(data) { function test_pass_show(data) {
if (data.add_home_gpg_data === true) { if (data.add_home_gpg_data === true)
TestsUtils.copyFolder(Qt.resolvedUrl("../../assets/gpghome"), Qt.resolvedUrl(gpg_home)); TestsUtils.copyFolder(Qt.resolvedUrl("../../assets/gpghome"), Qt.resolvedUrl(gpg_home));
}
var fname, ctext; var fname, ctext;
Pass.showSucceed.connect(function(file_name, clear_text) { Pass.showSucceed.connect(function(file_name, clear_text) {
@ -34,15 +33,13 @@ PassTestCase {
Pass.showFailed.connect(function(err) { Pass.showFailed.connect(function(err) {
err_msg = err; err_msg = err;
}); });
Pass.show(Qt.resolvedUrl(data.file)); Pass.show(Qt.resolvedUrl(data.file));
data.spy.wait(); data.spy.wait();
if (data.err_msg) { if (data.err_msg)
verify(err_msg === data.err_msg, "Should return %1 but return %2".arg(data.err_msg).arg(err_msg)); verify(err_msg === data.err_msg, "Should return %1 but return %2".arg(data.err_msg).arg(err_msg));
} else { else
verify(false); verify(false);
} }
}
SignalSpy { SignalSpy {
id: showSucceed id: showSucceed