mirror of
https://github.com/QRouland/UTPass.git
synced 2025-06-30 09:12:29 +00:00
Inital base for use GPG && GpgmE
This commit is contained in:
@ -13,28 +13,6 @@ add_library(${PLUGIN} MODULE ${SRC})
|
||||
set_target_properties(${PLUGIN} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PLUGIN})
|
||||
qt5_use_modules(${PLUGIN} Qml Quick DBus)
|
||||
|
||||
set(EXTERNAL_LIBS "${CMAKE_SOURCE_DIR}/local")
|
||||
set(THIRD_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
INCLUDE_DIRECTORIES(${EXTERNAL_LIBS}/include)
|
||||
add_dependencies(${PLUGIN} LibGpgme)
|
||||
|
||||
add_library(GpgError STATIC IMPORTED)
|
||||
set_property(TARGET GpgError PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libgpg-error.a")
|
||||
|
||||
add_library(GpgAssuan STATIC IMPORTED)
|
||||
set_property(TARGET GpgAssuan PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libassuan.a")
|
||||
|
||||
add_library(Gpgme STATIC IMPORTED)
|
||||
set_property(TARGET Gpgme PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libgpgme.a")
|
||||
|
||||
add_library(Gpgmepp STATIC IMPORTED)
|
||||
set_property(TARGET Gpgmepp PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libgpgmepp.a")
|
||||
|
||||
add_library(QGpgme STATIC IMPORTED)
|
||||
set_property(TARGET QGpgme PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libqgpgme.a")
|
||||
|
||||
target_link_libraries(${PLUGIN} QGpgme Gpgmepp Gpgme GpgAssuan GpgError)
|
||||
|
||||
execute_process(
|
||||
COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
|
||||
|
@ -1,71 +1,16 @@
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include "pass.h"
|
||||
#include "gpgme++/global.h"
|
||||
#include "gpgme++/engineinfo.h"
|
||||
#include "qgpgme/protocol.h"
|
||||
#include "qgpgme/encryptjob.h"
|
||||
|
||||
#include "pass.h"
|
||||
|
||||
|
||||
Pass::Pass() {
|
||||
qDebug() << "Initializing GpgMe";
|
||||
if(GpgME::initializeLibrary(GpgME::OpenPGP))
|
||||
qFatal("Fatal error when initializing GpgMe");
|
||||
qDebug() << "GpgME Engine Version :" << GpgME::engineInfo(GpgME::GpgEngine).version();
|
||||
|
||||
}
|
||||
|
||||
void Pass::speak() {
|
||||
qDebug() << "Starting app from main.cpp";
|
||||
}
|
||||
|
||||
QString Pass::decrypt(const QByteArray cipherText) {
|
||||
/*auto decJob = QGpgME::openpgp()->decryptJob();
|
||||
auto ctx = QGpgME::Job::context(decJob);
|
||||
|
||||
TestPassphraseProvider provider;
|
||||
ctx->setPassphraseProvider(&provider);
|
||||
ctx->setPinentryMode(Context::PinentryLoopback);
|
||||
|
||||
QByteArray plainText;
|
||||
decJob->exec(cipherText, plainText);
|
||||
|
||||
return QString::fromUtf8(plainText);*/
|
||||
}
|
||||
|
||||
QString Pass::decrypt_file(const QString path) {
|
||||
/*QFile file(path);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qErrnoWarning("Can't open the File");
|
||||
return nullptr;
|
||||
}
|
||||
QByteArray plainText = file.readAll();
|
||||
return Pass::decrypt(plainText);*/
|
||||
}
|
||||
|
||||
QByteArray Pass::encrypt(const QString str) {
|
||||
/*auto listjob = QGpgME::openpgp()->keyListJob(false, false, false);
|
||||
std::vector<GpgME::Key> keys;
|
||||
auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"), false, keys);
|
||||
|
||||
|
||||
|
||||
auto job = QGpgME::openpgp()
|
||||
->encryptJob(
|
||||
true, //ASCII Armor
|
||||
true //Textmode
|
||||
);
|
||||
QByteArray cipherText;
|
||||
auto result = job->exec(keys, QStringLiteral("Hello World").toUtf8(), GpgME::Context::AlwaysTrust, cipherText);
|
||||
return cipherText;*/
|
||||
}
|
||||
|
||||
bool Pass::encrypt_file(const QString str, const QString path) {
|
||||
/*QFile file(path);
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
qErrnoWarning("Can't open the File");
|
||||
return false;
|
||||
}
|
||||
file.write(Pass::encrypt(str));
|
||||
return true;*/
|
||||
}
|
||||
|
@ -12,10 +12,6 @@ public:
|
||||
~Pass() override = default;
|
||||
|
||||
Q_INVOKABLE void speak();
|
||||
Q_INVOKABLE QString decrypt(QByteArray plainText);
|
||||
Q_INVOKABLE QString decrypt_file(QString path);
|
||||
Q_INVOKABLE QByteArray encrypt(QString str);
|
||||
Q_INVOKABLE bool encrypt_file(QString str, QString path);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user