From 2390cc983b5936e81fbcebd3c48407b2997ce0bf Mon Sep 17 00:00:00 2001 From: Quentin Rouland Date: Fri, 22 Mar 2019 00:11:36 +0100 Subject: [PATCH] UP --- .gitignore | 2 +- CMakeLists.txt | 17 ----------------- README.md | 20 ++++++++++---------- clickable.json | 8 ++++---- gpghome/.gitkeep | 0 password-store/.gitKeep | 0 password-store/dir/pass.gpg | 0 password-store/pass.gpg | 0 password-store/public.key | 30 ------------------------------ plugins/Gpg/gpg.cpp | 12 ++++++------ plugins/Gpg/gpg.h | 14 +++++++------- plugins/Gpg/plugin.cpp | 2 +- plugins/Gpg/plugin.h | 6 +++--- plugins/Pass/pass.cpp | 15 +++++++++------ plugins/Pass/pass.h | 2 +- po/utpass.qrouland.pot | 26 +++++++++++++------------- qml/Main.qml | 4 ++-- tests/plugins/TestGpg.cpp | 17 ----------------- tests/plugins/TestPass.cpp | 17 ----------------- tests/unit/tst_gpg.qml | 10 ++++++++++ 20 files changed, 67 insertions(+), 135 deletions(-) delete mode 100644 gpghome/.gitkeep delete mode 100644 password-store/.gitKeep delete mode 100644 password-store/dir/pass.gpg delete mode 100644 password-store/pass.gpg delete mode 100644 password-store/public.key delete mode 100644 tests/plugins/TestGpg.cpp delete mode 100644 tests/plugins/TestPass.cpp create mode 100644 tests/unit/tst_gpg.qml diff --git a/.gitignore b/.gitignore index 4be93cc..6afa968 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ cmake-build-debug build +taglib-build .clickable .idea local - diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b47c39..61af248 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,8 +45,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json DESTINATION ${CMAKE_INST install(FILES ${PROJECT_NAME}.apparmor DESTINATION ${DATA_DIR}) install(DIRECTORY qml DESTINATION ${DATA_DIR}) install(DIRECTORY assets DESTINATION ${DATA_DIR}) -install(DIRECTORY password-store DESTINATION ${DATA_DIR}) -install(DIRECTORY gpghome DESTINATION ${DATA_DIR}) install(DIRECTORY local/bin DESTINATION ${DATA_DIR}) file(GLOB_RECURSE BIN_FILES "local/bin/*") @@ -97,18 +95,3 @@ file(GLOB_RECURSE PROJECT_SRC_FILES ) add_custom_target(${PROJECT_NAME}_FILES ALL SOURCES ${PROJECT_SRC_FILES}) - -# Tests -enable_testing(true) -set(CMAKE_INCLUDE_CURRENT_DIR ON) -include_directories(tests/plugins) - -find_package(Qt5Test) - -add_executable(TestGpg tests/plugins/TestGpg.cpp) -add_executable(TestPass tests/plugins/TestPass.cpp) -target_link_libraries(TestGpg Qt5::Test) -target_link_libraries(TestPass Qt5::Test) - -add_test(TestGpg TestGpg) -add_test(TestPass TestPass) diff --git a/README.md b/README.md index adf1e9c..7bd25b1 100644 --- a/README.md +++ b/README.md @@ -11,15 +11,15 @@ A password management app for Ubuntu Touch aiming to be compatible with [ZX2C4 For more options/details see the [clickable documentation](http://clickable.bhdouglass.com/en/latest/index.html) ## Custom clickable command -* ```clickable test ``` : run test for all plugins -* ```clickable test_gpg ``` : run test for gpg plugin -* ```clickable test_pass``` : run test for pass plugin -* ```clickable style ``` : reformat the code (Required : [astyle](astyle.sourceforge.ne) & [https://github.com/jesperhh/qmlfmt](https://github.com/jesperhh/qmlfmt)) +* ```clickable test ``` : build and run test for all plugins +* ```clickable test_gpg ``` : build and run test for gpg plugin +* ```clickable test_pass``` : build and run test for pass plugin +* ```clickable style ``` : reformat the code (Required : [astyle](astyle.sourceforge.ne) & [qmlfmt](https://github.com/jesperhh/qmlfmt)) # Contributing -Any contributions are welcome using the github issue & pull request system. -Please try to respect the code style format by runnning ```clickable style``` before committing. +Any contributions are welcome using the github issue & pull request system. +Please try to respect the code style format by running ```clickable style``` before committing. # Features @@ -37,7 +37,7 @@ The goal is to be closest possible of the features offer by [ZX2C4’s pass comm List passwords. - [x] UI allowing to navigate through the password store showing the available passwords --- -- [ ] pass find pass-names... +- [ ] pass find pass-names... List passwords that match pass-names - [ ] Search bar allowing searchs by pass-names --- @@ -80,7 +80,7 @@ List passwords that match pass-names --- - [ ] pass cp [--force,-f] old-path new-path Copies old-path to new-path, optionally forcefully, selectively reencrypting. - + - [ ] TBD --- - [ ] pass git git-command-args... @@ -90,7 +90,7 @@ List passwords that match pass-names --- - [ ] pass help Show this text. - + - [ ] TBD --- - [ ] pass version @@ -121,5 +121,5 @@ List passwords that match pass-names Some useful links related to UTpass development : * [Ubports](https://ubports.com/) : Ubuntu Touch Community * [ZX2C4’s pass command line application](https://www.passwordstore.org/) : the standard unix password manager. -* [Clickable](https://github.com/bhdouglass/clickable) : Compile, build, and deploy Ubuntu Touch click packages +* [Clickable](https://github.com/bhdouglass/clickable) : Compile, build, and deploy Ubuntu Touch click packages * [Gpgme](https://www.gnupg.org/software/gpgme/index.html) : GnuPG Made Easy (GPGME) is a library designed to make access to GnuPG easier for applications diff --git a/clickable.json b/clickable.json index 7c6a98f..9b9a38c 100644 --- a/clickable.json +++ b/clickable.json @@ -3,10 +3,10 @@ "kill": "UTPass", "scripts": { "clean": "third/clean.sh && rm -rf build", - "style": "astyle --options=.astylerc \"plugins/*.cpp,*.h\" && qmlfmt -w qml", - "test": "clickable run \"cd build && make test\"", - "test_gpg": "clickable run \"cd build && ./TestGpg\"", - "test_pass": "clickable run \"cd build && ./TestPass\"" + "style": "astyle --options=.astylerc \"plugins/*.cpp,*.h\" && astyle --options=.astylerc \"tests/*.cpp,*.h\" && qmlfmt -w qml", + "test": "clickable build --arch amd64 && clickable run \"cd build && make test\"", + "test_gpg": "clickable build --arch amd64 && clickable run \"cd build && ./TestGpg\"", + "test_pass": "clickable build --arch amd64 && clickable run \"cd build && ./TestPass\"" }, "dependencies_build": [ "texinfo", diff --git a/gpghome/.gitkeep b/gpghome/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/password-store/.gitKeep b/password-store/.gitKeep deleted file mode 100644 index e69de29..0000000 diff --git a/password-store/dir/pass.gpg b/password-store/dir/pass.gpg deleted file mode 100644 index e69de29..0000000 diff --git a/password-store/pass.gpg b/password-store/pass.gpg deleted file mode 100644 index e69de29..0000000 diff --git a/password-store/public.key b/password-store/public.key deleted file mode 100644 index 30d6554..0000000 --- a/password-store/public.key +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- - -mQENBFyNdOEBCADl2oWeYkmVBDWoWgZdkpbV5VRJJFATLsu5aHBuQO/C1mn2RlL2 -jIpIzI5mwviAw9RN0KnLdHvp3n3JkJPZ8tB3Sk9SD8qhr6ae2DbIpySMscYC9+Go -t0mrGyB3w+Y5etfZ/1dRNx6/vYaWYIG6bKfJettt/zLJcjpkIKcrN4OKyN2wXz3y -EiAiJvMntdgLslURl93RyNuVR6UaE4TchtDqRc2KvXAxrf6NUYd4KxvUgUd0TFPs -s3SRs+cAcRmTzxv/c40sBw3z0B9rBB7T7oPgGUA6NhErvBwpF9MLN+6ucZ1HHLLH -dmCd7q2OT7wZ9L6zILmKvJcK13V4FyO9zOALABEBAAG0I1Rlc3QgKFRlc3QgZ3Bn -IGtleSkgPHRlc3RAdGVzdC5vcmc+iQFOBBMBCAA4FiEE6JXydyCXAQnkfMmTuV1W -R67EDnIFAlyNdOECGwMFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQuV1WR67E -DnIchAgAvV5q4/Hktlu3RIgo8KkGksMOS5XhJrr6fZ8bUgqpwL3oEfZ3Se5aS7yN -5M7NT8foB2zK2moBICMYpxBxQoGjxFosv94FqX9+XMiRc2Di6MwLwKkWfu0HoPEi -e701iTo53r6K84TIKNrRsKyg6C/pRqNNwSp1YcvG11eUnG5teZMcb1xsMfx4O2/s -mcrySo0ZjAfYnh2poxf4yy9xTryPrDnaY/EFj+4uBMLH8jG3QQiAH1N6wHhi/vwj -FaaaBtRxcVU/obGDg2LHTVxItv81xzSbLf8JdIGOKjwFed+DjaoSlEzPnuaEZf/M -7mE6fiGbIhFgUlwEGomptZDC1fg3M7kBDQRcjXThAQgAmuSsbRoLfiSoij5CWiP4 -UUvhIEt5d4KkMRRvuWXkJo4FWs2tmNWIb1tiXuKhX+puLjP06LwfEyNT1jz75pgO -tSQ0Yz55Hn25CWOcyWF/iIoIjjw3WhQ0a59Ajk8tVdVrTEhlcQ+m7dH1igyMO1vv -iH1eTu+TXqWDF1+oYTZH0iTMYreCNbz2RcFHZQKdWK8GI1DE/qeKLHf+XYGTVQH4 -fRnGaX7T5DdnklHKVGi4iILOKn5aofTIg14roS9yfDMK6vmNr7BkzqAe9+WfYC0K -TU3hX1z5SrjnYnBb531MaaCotUEI3DbNeoNsuH3Hx0WLHR1Q55Hh+KAxhMUKTR4P -uwARAQABiQE2BBgBCAAgFiEE6JXydyCXAQnkfMmTuV1WR67EDnIFAlyNdOECGwwA -CgkQuV1WR67EDnKjKwgA3yexUAoTe9sDRKO710MSWhPAn3DZ8qMo8EqmNegG86PO -/mD6BPKo9503pqGGXYoFBcqsmFX07uvy0evCsqO15xuDWwOhNX5fm2LeSsNEkhhC -2wvJVQPdekj9KmOrRRRcr6DlR0Yl7+BJX1+zF8tYwtU4tiY+bCOVRoa1KvTXUwcy -sRTQ9xWguCP8Ai1GyZS0P8lEU0nCS2KrgU/XKQVW7o2OtBiywJbmVCDw15vIq3kN -akRrU5DvYCelUjjzgj+HC3MEE5fV4UsuFLKw3QMmekzFfa6OagRb/FYYZ5ZL+tGI -cf2W57AJOHpgYvxqrY5M1UfKLf8kCYPt3AG0XiD5mw== -=OHyE ------END PGP PUBLIC KEY BLOCK----- diff --git a/plugins/Gpg/gpg.cpp b/plugins/Gpg/gpg.cpp index a152a48..01dea9d 100644 --- a/plugins/Gpg/gpg.cpp +++ b/plugins/Gpg/gpg.cpp @@ -43,7 +43,7 @@ Gpg::Gpg() qDebug() << "GpgME Engine Version :" << engineInfo(OpenPGP).version(); } -void Gpg::list_dir() +void Gpg::listDir() { qDebug() << "hello world!"; } @@ -64,7 +64,7 @@ QString Gpg::decrypt(const QByteArray cipherText) return QString::fromUtf8(plainText);*/ } -QString Gpg::decrypt_file(const QString path) +QString Gpg::decryptFile(QString path) { /*QFile file(path); if (!file.open(QIODevice::ReadOnly)) { @@ -91,7 +91,7 @@ QByteArray Gpg::encrypt(const QString str) return cipherText;*/ } -bool Gpg::encrypt_file(const QString str, const QString path) +bool Gpg::encryptFile(QString str, QString path) { /*QFile file(path); if (!file.open(QIODevice::WriteOnly)) { @@ -102,7 +102,7 @@ bool Gpg::encrypt_file(const QString str, const QString path) return true;*/ } -QString Gpg::get_key_id(QString uid) +QString Gpg::getKeyId(QString uid) { qDebug() << "Getting the key id " << uid; auto *job = openpgp()->keyListJob(false, false, false); @@ -119,7 +119,7 @@ QString Gpg::get_key_id(QString uid) return kId; } -QStringList Gpg::get_all_keys_id() +QStringList Gpg::getAllKeysId() { qDebug() << "Show all available key"; auto job = openpgp()->keyListJob(false, false, false); @@ -140,7 +140,7 @@ QStringList Gpg::get_all_keys_id() return r; } -bool Gpg::import_key(QString path) +bool Gpg::importKey(QString path) { qDebug() << "Importing the key file" << path; QFile file(path); diff --git a/plugins/Gpg/gpg.h b/plugins/Gpg/gpg.h index 1708b05..b614212 100644 --- a/plugins/Gpg/gpg.h +++ b/plugins/Gpg/gpg.h @@ -9,16 +9,16 @@ class Gpg : public QObject public: Gpg(); - ~Gpg() = default; + ~Gpg() override = 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 void listDir(); + Q_INVOKABLE QString getKeyId(QString uid); + Q_INVOKABLE QStringList getAllKeysId(); + Q_INVOKABLE bool importKey(QString path); Q_INVOKABLE QString decrypt(QByteArray plainText); - Q_INVOKABLE QString decrypt_file(QString path); + Q_INVOKABLE QString decryptFile(QString path); Q_INVOKABLE QByteArray encrypt(QString str); - Q_INVOKABLE bool encrypt_file(QString str, QString path); + Q_INVOKABLE bool encryptFile(QString str, QString path); }; #endif diff --git a/plugins/Gpg/plugin.cpp b/plugins/Gpg/plugin.cpp index 2b044ce..936ce60 100644 --- a/plugins/Gpg/plugin.cpp +++ b/plugins/Gpg/plugin.cpp @@ -3,7 +3,7 @@ #include "plugin.h" #include "gpg.h" -void FileSystemPlugin::registerTypes(const char *uri) +void GpgPlugin::registerTypes(const char *uri) { //@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 ee4b9ec..a4d0ed6 100644 --- a/plugins/Gpg/plugin.h +++ b/plugins/Gpg/plugin.h @@ -1,9 +1,9 @@ -#ifndef PASSPLUGIN_H -#define PASSPLUGIN_H +#ifndef GPGPLUGIN_H +#define GPGPLUGIN_H #include -class FileSystemPlugin : public QQmlExtensionPlugin +class GpgPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID diff --git a/plugins/Pass/pass.cpp b/plugins/Pass/pass.cpp index 27ba7f4..424929f 100644 --- a/plugins/Pass/pass.cpp +++ b/plugins/Pass/pass.cpp @@ -1,17 +1,20 @@ #include #include +#include +#include #include "pass.h" -Pass::Pass() -{ - +Pass::Pass(){ + pass_store = QStandardPaths::writableLocation( + QStandardPaths::AppDataLocation).append("/.password-store"); + QDir dir(pass_store); + if (!dir.exists()) + dir.mkpath("."); + qDebug() << "Password Store is :" << pass_store; } void Pass::speak() { qDebug() << "Starting app from main.cpp"; } - - - diff --git a/plugins/Pass/pass.h b/plugins/Pass/pass.h index dd01164..5dd5732 100644 --- a/plugins/Pass/pass.h +++ b/plugins/Pass/pass.h @@ -6,7 +6,7 @@ class Pass : public QObject { Q_OBJECT - QString gpgHome; + QString pass_store; public: Pass(); diff --git a/po/utpass.qrouland.pot b/po/utpass.qrouland.pot index 138414e..62e2ffc 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-21 16:44+0000\n" +"POT-Creation-Date: 2019-03-21 21:15+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,10 +17,6 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: ../qml/pages/Settings.qml:8 ../qml/pages/headers/MainHeader.qml:49 -msgid "Settings" -msgstr "" - #: ../qml/pages/PasswordList.qml:16 msgid "Back" msgstr "" @@ -29,20 +25,24 @@ msgstr "" msgid "No password found in the current folder" msgstr "" -#: ../qml/pages/Info.qml:9 ../qml/pages/headers/MainHeader.qml:56 -msgid "Info" +#: ../qml/pages/Settings.qml:8 ../qml/pages/headers/MainHeader.qml:49 +msgid "Settings" msgstr "" -#: ../qml/pages/Info.qml:43 ../qml/pages/headers/MainHeader.qml:8 -#: ../qml/pages/headers/StackHeader.qml:8 UTPass.desktop.in.h:1 +#: ../qml/pages/headers/MainHeader.qml:8 ../qml/pages/headers/StackHeader.qml:8 +#: ../qml/pages/Info.qml:43 UTPass.desktop.in.h:1 msgid "UTPass" msgstr "" -#: ../qml/pages/Info.qml:53 -msgid "Suggest improvement(s) or report a bug(s)" -msgstr "" - #: ../qml/pages/headers/MainHeader.qml:23 #: ../qml/pages/headers/MainHeader.qml:38 msgid "Search" msgstr "" + +#: ../qml/pages/headers/MainHeader.qml:56 ../qml/pages/Info.qml:9 +msgid "Info" +msgstr "" + +#: ../qml/pages/Info.qml:53 +msgid "Suggest improvement(s) or report a bug(s)" +msgstr "" diff --git a/qml/Main.qml b/qml/Main.qml index 2bf79b1..5d24f0f 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -23,7 +23,7 @@ MainView { "pages/PasswordList.qml"))) } Component.onCompleted: { - Gpg.import_key("password-store/public.key") - Gpg.get_all_keys_id() + Gpg.importKey("password-store/public.key") + Gpg.getAllKeysId() } } diff --git a/tests/plugins/TestGpg.cpp b/tests/plugins/TestGpg.cpp deleted file mode 100644 index 3eaafcd..0000000 --- a/tests/plugins/TestGpg.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include - -class TestGpg: public QObject -{ -Q_OBJECT -private slots: - void toUpper(); -}; - -void TestGpg::toUpper() -{ - QString str = "Hello"; - QCOMPARE(str.toUpper(), QString("HELLO")); -} - -QTEST_MAIN(TestGpg) -#include "TestGpg.moc" \ No newline at end of file diff --git a/tests/plugins/TestPass.cpp b/tests/plugins/TestPass.cpp deleted file mode 100644 index 29803fe..0000000 --- a/tests/plugins/TestPass.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include - -class TestPass: public QObject -{ -Q_OBJECT -private slots: - void toUpper(); -}; - -void TestPass::toUpper() -{ - QString str = "Hello"; - QCOMPARE(str.toUpper(), QString("HELLO")); -} - -QTEST_MAIN(TestPass) -#include "TestPass.moc" \ No newline at end of file diff --git a/tests/unit/tst_gpg.qml b/tests/unit/tst_gpg.qml new file mode 100644 index 0000000..8f80ffd --- /dev/null +++ b/tests/unit/tst_gpg.qml @@ -0,0 +1,10 @@ +import QtTest 1.0 +import Ubuntu.Test 1.0 +import Gpg 1.0 + +UbuntuTestCase { + name: "GpgTests" + function test_empty_gnuhome() { + Gpg::getListIds().empty() + } +}