diff --git a/CMakeLists.txt b/CMakeLists.txt index 19b05fb..9aef5c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,19 +62,19 @@ file(GLOB_RECURSE I18N_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po qml/*.q list(APPEND I18N_SRC_FILES ${DESKTOP_FILE_NAME}.in.h) find_program(INTLTOOL_MERGE intltool-merge) -if(NOT INTLTOOL_MERGE) +if (NOT INTLTOOL_MERGE) message(FATAL_ERROR "Could not find intltool-merge, please install the intltool package") -endif() +endif () find_program(INTLTOOL_EXTRACT intltool-extract) -if(NOT INTLTOOL_EXTRACT) +if (NOT INTLTOOL_EXTRACT) message(FATAL_ERROR "Could not find intltool-extract, please install the intltool package") -endif() +endif () add_custom_target(${DESKTOP_FILE_NAME} ALL - COMMENT "Merging translations into ${DESKTOP_FILE_NAME}..." - COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${CMAKE_SOURCE_DIR}/po ${CMAKE_SOURCE_DIR}/${DESKTOP_FILE_NAME}.in ${DESKTOP_FILE_NAME} - COMMAND sed -i 's/${PROJECT_NAME}-//g' ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE_NAME} -) + COMMENT "Merging translations into ${DESKTOP_FILE_NAME}..." + COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${CMAKE_SOURCE_DIR}/po ${CMAKE_SOURCE_DIR}/${DESKTOP_FILE_NAME}.in ${DESKTOP_FILE_NAME} + COMMAND sed -i 's/${PROJECT_NAME}-//g' ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE_NAME} + ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE_NAME} DESTINATION ${DATA_DIR}) @@ -88,13 +88,13 @@ add_dependencies(${PROJECT_NAME} Gnupg) # We don't need to add plugin sources here as they get exposed # via the library target. file(GLOB_RECURSE PROJECT_SRC_FILES - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - qml/*.qml - qml/*.js - *.json - *.json.in - *.apparmor - *.desktop.in -) + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + qml/*.qml + qml/*.js + *.json + *.json.in + *.apparmor + *.desktop.in + ) -add_custom_target(${PROJECT_NAME}_FILES ALL SOURCES ${PROJECT_SRC_FILES} ) \ No newline at end of file +add_custom_target(${PROJECT_NAME}_FILES ALL SOURCES ${PROJECT_SRC_FILES}) \ No newline at end of file diff --git a/plugins/Gpg/CMakeLists.txt b/plugins/Gpg/CMakeLists.txt index 3aa139c..1509485 100644 --- a/plugins/Gpg/CMakeLists.txt +++ b/plugins/Gpg/CMakeLists.txt @@ -2,7 +2,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(PLUGIN "Gpg") set( - SRC + SRC plugin.cpp gpg.cpp ) @@ -37,9 +37,9 @@ set_property(TARGET QGpgme PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libq target_link_libraries(${PLUGIN} QGpgme Gpgmepp Gpgme GpgAssuan GpgError) execute_process( - COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH - OUTPUT_VARIABLE ARCH_TRIPLET - OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH + OUTPUT_VARIABLE ARCH_TRIPLET + OUTPUT_STRIP_TRAILING_WHITESPACE ) set(QT_IMPORTS_DIR "/lib/${ARCH_TRIPLET}") diff --git a/plugins/Gpg/gpg.cpp b/plugins/Gpg/gpg.cpp index 1d5ae41..eb55670 100644 --- a/plugins/Gpg/gpg.cpp +++ b/plugins/Gpg/gpg.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include "gpg.h" @@ -19,148 +18,147 @@ using namespace GpgME; using namespace QGpgME; Gpg::Gpg() { - auto error = initializeLibrary(OpenPGP); - if (error) { - qDebug() << "Code Error : " << error.code(); - qDebug() << "Error str : " << error.asString(); - qFatal("GpgME init fail"); - } + auto error = initializeLibrary(OpenPGP); + if (error) { + qDebug() << "Code Error : " << error.code(); + qDebug() << "Error str : " << error.asString(); + qFatal("GpgME init fail"); + } - QString gnuhome = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation).append("/gpghome"); - QDir dir(gnuhome); - if (!dir.exists()) dir.mkpath("."); - qputenv("GNUPGHOME", gnuhome.toStdString().c_str()); - qDebug() << "GNUPGHOME is :" << qgetenv("GNUPGHOME"); + QString gnuhome = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation).append("/gpghome"); + QDir dir(gnuhome); + if (!dir.exists()) + dir.mkpath("."); + qputenv("GNUPGHOME", gnuhome.toStdString().c_str()); + qDebug() << "GNUPGHOME is :" << qgetenv("GNUPGHOME"); - error = checkEngine(OpenPGP); - if (error) { - qDebug() << "Code Error : " << error.code(); - qDebug() << "Error str : " << error.asString(); - qFatal("Engine check Fail"); + error = checkEngine(OpenPGP); + if (error) { + qDebug() << "Code Error : " << error.code(); + qDebug() << "Error str : " << error.asString(); + qFatal("Engine check Fail"); - } - qDebug() << "GpgME Engine Version :" << engineInfo(OpenPGP).version(); + } + qDebug() << "GpgME Engine Version :" << engineInfo(OpenPGP).version(); } void Gpg::list_dir() { - qDebug() << "hello world!"; + qDebug() << "hello world!"; } QString Gpg::decrypt(const QByteArray cipherText) { - /*auto decJob = openpgp()->decryptJob(); - auto ctx = DecryptJob::context(decJob);*/ + /*auto decJob = openpgp()->decryptJob(); + auto ctx = DecryptJob::context(decJob);*/ - /* TODO - * TestPassphraseProvider provider; - ctx->setPassphraseProvider(&provider); - ctx->setPinentryMode(Context::PinentryLoopback);*/ + /* TODO + * TestPassphraseProvider provider; + ctx->setPassphraseProvider(&provider); + ctx->setPinentryMode(Context::PinentryLoopback);*/ - /*QByteArray plainText; - decJob->exec(cipherText, plainText); + /*QByteArray plainText; + decJob->exec(cipherText, plainText); - return QString::fromUtf8(plainText);*/ + return QString::fromUtf8(plainText);*/ } QString Gpg::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 this->decrypt(plainText);*/ + /*QFile file(path); + if (!file.open(QIODevice::ReadOnly)) { + qErrnoWarning("Can't open the File"); + return nullptr; + } + QByteArray plainText = file.readAll(); + return this->decrypt(plainText);*/ } QByteArray Gpg::encrypt(const QString str) { - /*auto listjob = openpgp()->keyListJob(false, false, false); - std::vector keys; - auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"), false, keys); + /*auto listjob = openpgp()->keyListJob(false, false, false); + std::vector keys; + auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"), false, keys); - auto job = openpgp() - ->encryptJob( - true, //ASCII Armor - true //Textmode - ); - QByteArray cipherText; - auto result = job->exec(keys, QStringLiteral("Hello World").toUtf8(), Context::AlwaysTrust, cipherText); - return cipherText;*/ + auto job = openpgp() + ->encryptJob( + true, //ASCII Armor + true //Textmode + ); + QByteArray cipherText; + auto result = job->exec(keys, QStringLiteral("Hello World").toUtf8(), Context::AlwaysTrust, cipherText); + return cipherText;*/ } bool Gpg::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;*/ + /*QFile file(path); + if (!file.open(QIODevice::WriteOnly)) { + qErrnoWarning("Can't open the File"); + return false; + } + file.write(Pass::encrypt(str)); + return true;*/ } - - QString Gpg::get_key_id(QString uid) { - qDebug() << "Getting the key id " << uid; - auto *job = openpgp()->keyListJob(false, false, false); - std::vector keys; - auto result = job->exec(QStringList() << uid, false, keys); - delete job; + qDebug() << "Getting the key id " << uid; + auto *job = openpgp()->keyListJob(false, false, false); + std::vector keys; + auto result = job->exec(QStringList() << uid, false, keys); + delete job; - if (keys.empty()) { - qDebug() << "No key found for" << uid; - return nullptr; - } - const QString kId = QLatin1String(keys.front().keyID()); - qDebug() << "Id key for " << uid << "is : " << kId; - return kId; + if (keys.empty()) { + qDebug() << "No key found for" << uid; + return nullptr; + } + const QString kId = QLatin1String(keys.front().keyID()); + qDebug() << "Id key for " << uid << "is : " << kId; + return kId; } QStringList Gpg::get_all_keys_id() { - qDebug() << "Show all available key"; - auto job = openpgp()->keyListJob(false, false, false); - std::vector keys; - auto result = job->exec(QStringList(""), false, keys); - delete job; + qDebug() << "Show all available key"; + auto job = openpgp()->keyListJob(false, false, false); + std::vector keys; + auto result = job->exec(QStringList(""), false, keys); + delete job; - if (keys.empty()) { - qDebug() << "No key found" ; - return QStringList(); - } + if (keys.empty()) { + qDebug() << "No key found"; + return QStringList(); + } - auto r = QStringList(); - for(const auto &key: keys) { - r.append(QLatin1String(key.keyID())); - qDebug() << "Key" << QLatin1String(key.keyID()); - } - return r; + auto r = QStringList(); + for (const auto &key: keys) { + r.append(QLatin1String(key.keyID())); + qDebug() << "Key" << QLatin1String(key.keyID()); + } + return r; } bool Gpg::import_key(QString path) { - qDebug() << "Importing the key file" << path; - QFile file(path); - if (!file.open(QIODevice::ReadOnly)) { - qWarning() << "Can't open the File"; - return false; - } + qDebug() << "Importing the key file" << path; + QFile file(path); + if (!file.open(QIODevice::ReadOnly)) { + qWarning() << "Can't open the File"; + return false; + } - auto job = openpgp()->importJob(); - auto result = job->exec(file.readAll()); + auto job = openpgp()->importJob(); + auto result = job->exec(file.readAll()); - delete job; - file.close(); + delete job; + file.close(); - if(result.error()) { - qWarning() << "Import go wrong"; - return false; - } + if (result.error()) { + qWarning() << "Import go wrong"; + return false; + } - qDebug() << "Key imported" << result.numImported(); - qDebug() << "Key not imported" << result.notImported(); - qDebug() << "Key unchanged" << result.numUnchanged(); - qDebug() << "Result null" << result.isNull(); - qDebug() << "newUserIDs" << result.newUserIDs(); + qDebug() << "Key imported" << result.numImported(); + qDebug() << "Key not imported" << result.notImported(); + qDebug() << "Key unchanged" << result.numUnchanged(); + qDebug() << "Result null" << result.isNull(); + qDebug() << "newUserIDs" << result.newUserIDs(); - for(const auto &key: result.imports()) - qDebug() << "Key" << key.fingerprint(); + for (const auto &key: result.imports()) + qDebug() << "Key" << key.fingerprint(); - return true; + return true; } \ No newline at end of file diff --git a/plugins/Gpg/gpg.h b/plugins/Gpg/gpg.h index 8714b78..f034eee 100644 --- a/plugins/Gpg/gpg.h +++ b/plugins/Gpg/gpg.h @@ -3,21 +3,21 @@ #include -class Gpg: public QObject { - Q_OBJECT +class Gpg : public QObject { + Q_OBJECT -public: - Gpg(); - ~Gpg() = default; + public: + Gpg(); + ~Gpg() = default; - Q_INVOKABLE void list_dir(); - Q_INVOKABLE QString get_key_id(QString uid); - Q_INVOKABLE QStringList get_all_keys_id(); - Q_INVOKABLE bool import_key(QString path); - 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); + Q_INVOKABLE void list_dir(); + Q_INVOKABLE QString get_key_id(QString uid); + Q_INVOKABLE QStringList get_all_keys_id(); + Q_INVOKABLE bool import_key(QString path); + 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 diff --git a/plugins/Gpg/plugin.cpp b/plugins/Gpg/plugin.cpp index 23ef464..520fd4d 100644 --- a/plugins/Gpg/plugin.cpp +++ b/plugins/Gpg/plugin.cpp @@ -1,10 +1,9 @@ #include -#include #include "plugin.h" #include "gpg.h" void FileSystemPlugin::registerTypes(const char *uri) { - //@uri Pass - qmlRegisterSingletonType(uri, 1, 0, "Gpg", [](QQmlEngine*, QJSEngine*) -> QObject* { return new Gpg; }); + //@uri Pass + qmlRegisterSingletonType(uri, 1, 0, "Gpg", [](QQmlEngine *, QJSEngine *) -> QObject * { return new Gpg; }); } diff --git a/plugins/Gpg/plugin.h b/plugins/Gpg/plugin.h index 5571fb7..131bde1 100644 --- a/plugins/Gpg/plugin.h +++ b/plugins/Gpg/plugin.h @@ -4,11 +4,12 @@ #include class FileSystemPlugin : public QQmlExtensionPlugin { - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_OBJECT + Q_PLUGIN_METADATA(IID + "org.qt-project.Qt.QQmlExtensionInterface") -public: - void registerTypes(const char *uri); + public: + void registerTypes(const char *uri); }; #endif diff --git a/plugins/Pass/CMakeLists.txt b/plugins/Pass/CMakeLists.txt index 5a05fcc..3ab033a 100644 --- a/plugins/Pass/CMakeLists.txt +++ b/plugins/Pass/CMakeLists.txt @@ -2,9 +2,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(PLUGIN "Pass") set( - SRC - plugin.cpp - pass.cpp + SRC + plugin.cpp + pass.cpp ) set(CMAKE_AUTOMOC ON) @@ -15,9 +15,9 @@ qt5_use_modules(${PLUGIN} Qml Quick DBus) execute_process( - COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH - OUTPUT_VARIABLE ARCH_TRIPLET - OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH + OUTPUT_VARIABLE ARCH_TRIPLET + OUTPUT_STRIP_TRAILING_WHITESPACE ) set(QT_IMPORTS_DIR "/lib/${ARCH_TRIPLET}") diff --git a/plugins/Pass/pass.cpp b/plugins/Pass/pass.cpp index 1e85c21..72f269f 100644 --- a/plugins/Pass/pass.cpp +++ b/plugins/Pass/pass.cpp @@ -3,13 +3,12 @@ #include "pass.h" - Pass::Pass() { } void Pass::speak() { - qDebug() << "Starting app from main.cpp"; + qDebug() << "Starting app from main.cpp"; } diff --git a/plugins/Pass/pass.h b/plugins/Pass/pass.h index 97afe17..1bc82d5 100644 --- a/plugins/Pass/pass.h +++ b/plugins/Pass/pass.h @@ -3,15 +3,15 @@ #include -class Pass: public QObject { - Q_OBJECT - QString gpgHome; +class Pass : public QObject { + Q_OBJECT + QString gpgHome; -public: - Pass(); - ~Pass() override = default; + public: + Pass(); + ~Pass() override = default; - Q_INVOKABLE void speak(); + Q_INVOKABLE void speak(); }; #endif diff --git a/plugins/Pass/plugin.cpp b/plugins/Pass/plugin.cpp index 0d21535..5c415bc 100644 --- a/plugins/Pass/plugin.cpp +++ b/plugins/Pass/plugin.cpp @@ -1,10 +1,9 @@ #include -#include #include "plugin.h" #include "pass.h" void PassPlugin::registerTypes(const char *uri) { - //@uri Pass - qmlRegisterSingletonType(uri, 1, 0, "Pass", [](QQmlEngine*, QJSEngine*) -> QObject* { return new Pass; }); + //@uri Pass + qmlRegisterSingletonType(uri, 1, 0, "Pass", [](QQmlEngine *, QJSEngine *) -> QObject * { return new Pass; }); } diff --git a/plugins/Pass/plugin.h b/plugins/Pass/plugin.h index c0988f5..8554993 100644 --- a/plugins/Pass/plugin.h +++ b/plugins/Pass/plugin.h @@ -4,11 +4,12 @@ #include class PassPlugin : public QQmlExtensionPlugin { - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_OBJECT + Q_PLUGIN_METADATA(IID + "org.qt-project.Qt.QQmlExtensionInterface") -public: - void registerTypes(const char *uri) override; + public: + void registerTypes(const char *uri) override; }; #endif diff --git a/po/utpass.qrouland.pot b/po/utpass.qrouland.pot index 18efdb7..199919c 100644 --- a/po/utpass.qrouland.pot +++ b/po/utpass.qrouland.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: utpass.qrouland\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-03-20 22:15+0000\n" +"POT-Creation-Date: 2019-03-20 22:31+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n"