diff --git a/CMakeLists.txt b/CMakeLists.txt index 88f60b5..5209d1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,6 @@ set(SECRETSERVICE_VERSION "0.${GIT_COMMIT_COUNT}.${GIT_COMMIT_HASH}") set(SECRETSERVICE_PACKAGE_ID "quasarapp.core.secretservice") option(SECRETSERVICE_TESTS "This option disables or enables tests of the ${PROJECT_NAME} project" ON) -option(SECRETSERVICE_EXAMPLE "This option disables or enables example app of the ${PROJECT_NAME} project" ON) if (ANDROID OR IOS OR QA_WASM32) set(SECRETSERVICE_TESTS OFF CACHE BOOL "This option force disbled for ANDROID IOS QA_WASM32 and Not Qt projects" FORCE) @@ -56,13 +55,8 @@ add_subdirectory(src/db) add_subdirectory(src/core) set(PATRONUM_TESTS OFF) -add_subdirectory(submodules/Patronum) add_subdirectory(src/service) -if (DEFINED SECRETSERVICE_EXAMPLE) - add_subdirectory(src/example) -endif() - if (SECRETSERVICE_TESTS) add_subdirectory(tests) else() diff --git a/src/db/src/private/secretdatabase.cpp b/src/db/src/private/secretdatabase.cpp index f042845..9b8c619 100644 --- a/src/db/src/private/secretdatabase.cpp +++ b/src/db/src/private/secretdatabase.cpp @@ -27,11 +27,7 @@ SecretDataBase::SecretDataBase() { } QVariantMap SecretDataBase::defaultDbParams() const { - return { - {QH_DB_DRIVER, "QSQLITE"}, - {QH_DB_FILE_PATH, QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/QASecret.sqlite" }, - {QH_DB_BACKUP_PATH, QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/QASecretBackUps"} - }; + return QH::DataBase::defaultDbParams(); } QSharedPointer diff --git a/src/example/CMakeLists.txt b/src/example/CMakeLists.txt deleted file mode 100644 index b12392e..0000000 --- a/src/example/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -# -# Copyright (C) 2024-2024 QuasarApp. -# Distributed under the GPLv3 software license, see the accompanying -# Everyone is permitted to copy and distribute verbatim copies -# of this license document, but changing it is not allowed. -# - -cmake_minimum_required(VERSION 3.19) - -get_filename_component(CURRENT_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR} NAME) - -set(CURRENT_PROJECT "${PROJECT_NAME}_${CURRENT_PROJECT_DIR}") -option(SIGN_APP "This option enable od disabled sign apk and aab files" ON) - -file(GLOB_RECURSE SOURCE_CPP - "*.cpp" "*.h" -) - -file(GLOB_RECURSE SOURCE_QRC - "*.qrc" -) - -set(ALL_SOURCES ${SOURCE_CPP} ${SOURCE_QRC}) - -set(PUBLIC_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") - -set(PRIVATE_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/private") - -updateGitVars() - -qt_add_executable(${CURRENT_PROJECT} ${ALL_SOURCES}) - -target_link_libraries(${CURRENT_PROJECT} PUBLIC ${PROJECT_NAME}) - -target_include_directories(${CURRENT_PROJECT} PUBLIC ${PUBLIC_INCUDE_DIR}) -target_include_directories(${CURRENT_PROJECT} PRIVATE ${PRIVATE_INCUDE_DIR}) - -SET(TARGET_DIR "${CMAKE_SOURCE_DIR}/Distro") -file(MAKE_DIRECTORY ${TARGET_DIR}) - - - diff --git a/src/example/main.cpp b/src/example/main.cpp deleted file mode 100644 index 5283c4b..0000000 --- a/src/example/main.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//# -//# Copyright (C) 2024-2024 QuasarApp. -//# Distributed under the GPLv3 software license, see the accompanying -//# Everyone is permitted to copy and distribute verbatim copies -//# of this license document, but changing it is not allowed. -//# - -#include "params.h" -#include -#include -#include -#include - - -int main(int argc, char * argv[]) { - - QCoreApplication app(argc, argv); - QASecret::init(); - - auto service = QASecret::KeyStorage::instance(); - - QTimer::singleShot(0, nullptr, [service]() { - auto hash = service->add("val"); - auto val = service->get(hash); - - if (val == "val") { - QuasarAppUtils::Params::log("All is fine!", QuasarAppUtils::Info); - } - - QCoreApplication::quit(); - }); - - - return app.exec(); -} diff --git a/src/service/CMakeLists.txt b/src/service/CMakeLists.txt index 16924fb..4170a67 100644 --- a/src/service/CMakeLists.txt +++ b/src/service/CMakeLists.txt @@ -30,7 +30,7 @@ updateGitVars() qt_add_executable(${CURRENT_PROJECT} ${ALL_SOURCES}) -target_link_libraries(${CURRENT_PROJECT} PUBLIC ${PROJECT_NAME} Patronum) +target_link_libraries(${CURRENT_PROJECT} PUBLIC ${PROJECT_NAME}) target_include_directories(${CURRENT_PROJECT} PUBLIC ${PUBLIC_INCUDE_DIR}) target_include_directories(${CURRENT_PROJECT} PRIVATE ${PRIVATE_INCUDE_DIR}) diff --git a/src/service/languages/de.ts b/src/service/languages/de.ts index 0423b36..9f3d6d4 100644 --- a/src/service/languages/de.ts +++ b/src/service/languages/de.ts @@ -2,21 +2,9 @@ - QuasarAppUtils::Locales + QObject - This bot is still under development. - - - - We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - - - - Thank you for your wait. - - - - Service is stoped. Please use the start command. + Service is not initialized. @@ -31,44 +19,27 @@ You forget a data. please use the next command add -data yourDataString + + You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + + You forget a hash key of alias of removable data. Please use the next command remove -hash yourHash or remove -alias yourAlias + + + QuasarAppUtils::Locales - This is description of the ping command + This bot is still under development. - Returns state + We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - Adds new value into seret storage, and return a hash key after adding. - - - - Remove data from storage by hash key or alias. - - - - return secret from database - - - - Alias name - - - - Data that will be saved - - - - Hash kay of data - - - - You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + Thank you for your wait. diff --git a/src/service/languages/en.ts b/src/service/languages/en.ts index 0423b36..9f3d6d4 100644 --- a/src/service/languages/en.ts +++ b/src/service/languages/en.ts @@ -2,21 +2,9 @@ - QuasarAppUtils::Locales + QObject - This bot is still under development. - - - - We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - - - - Thank you for your wait. - - - - Service is stoped. Please use the start command. + Service is not initialized. @@ -31,44 +19,27 @@ You forget a data. please use the next command add -data yourDataString + + You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + + You forget a hash key of alias of removable data. Please use the next command remove -hash yourHash or remove -alias yourAlias + + + QuasarAppUtils::Locales - This is description of the ping command + This bot is still under development. - Returns state + We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - Adds new value into seret storage, and return a hash key after adding. - - - - Remove data from storage by hash key or alias. - - - - return secret from database - - - - Alias name - - - - Data that will be saved - - - - Hash kay of data - - - - You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + Thank you for your wait. diff --git a/src/service/languages/es.ts b/src/service/languages/es.ts index 0423b36..9f3d6d4 100644 --- a/src/service/languages/es.ts +++ b/src/service/languages/es.ts @@ -2,21 +2,9 @@ - QuasarAppUtils::Locales + QObject - This bot is still under development. - - - - We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - - - - Thank you for your wait. - - - - Service is stoped. Please use the start command. + Service is not initialized. @@ -31,44 +19,27 @@ You forget a data. please use the next command add -data yourDataString + + You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + + You forget a hash key of alias of removable data. Please use the next command remove -hash yourHash or remove -alias yourAlias + + + QuasarAppUtils::Locales - This is description of the ping command + This bot is still under development. - Returns state + We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - Adds new value into seret storage, and return a hash key after adding. - - - - Remove data from storage by hash key or alias. - - - - return secret from database - - - - Alias name - - - - Data that will be saved - - - - Hash kay of data - - - - You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + Thank you for your wait. diff --git a/src/service/languages/fr.ts b/src/service/languages/fr.ts index 0423b36..9f3d6d4 100644 --- a/src/service/languages/fr.ts +++ b/src/service/languages/fr.ts @@ -2,21 +2,9 @@ - QuasarAppUtils::Locales + QObject - This bot is still under development. - - - - We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - - - - Thank you for your wait. - - - - Service is stoped. Please use the start command. + Service is not initialized. @@ -31,44 +19,27 @@ You forget a data. please use the next command add -data yourDataString + + You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + + You forget a hash key of alias of removable data. Please use the next command remove -hash yourHash or remove -alias yourAlias + + + QuasarAppUtils::Locales - This is description of the ping command + This bot is still under development. - Returns state + We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - Adds new value into seret storage, and return a hash key after adding. - - - - Remove data from storage by hash key or alias. - - - - return secret from database - - - - Alias name - - - - Data that will be saved - - - - Hash kay of data - - - - You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + Thank you for your wait. diff --git a/src/service/languages/ja.ts b/src/service/languages/ja.ts index 0423b36..9f3d6d4 100644 --- a/src/service/languages/ja.ts +++ b/src/service/languages/ja.ts @@ -2,21 +2,9 @@ - QuasarAppUtils::Locales + QObject - This bot is still under development. - - - - We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - - - - Thank you for your wait. - - - - Service is stoped. Please use the start command. + Service is not initialized. @@ -31,44 +19,27 @@ You forget a data. please use the next command add -data yourDataString + + You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + + You forget a hash key of alias of removable data. Please use the next command remove -hash yourHash or remove -alias yourAlias + + + QuasarAppUtils::Locales - This is description of the ping command + This bot is still under development. - Returns state + We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - Adds new value into seret storage, and return a hash key after adding. - - - - Remove data from storage by hash key or alias. - - - - return secret from database - - - - Alias name - - - - Data that will be saved - - - - Hash kay of data - - - - You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + Thank you for your wait. diff --git a/src/service/languages/pl.ts b/src/service/languages/pl.ts index 0423b36..9f3d6d4 100644 --- a/src/service/languages/pl.ts +++ b/src/service/languages/pl.ts @@ -2,21 +2,9 @@ - QuasarAppUtils::Locales + QObject - This bot is still under development. - - - - We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - - - - Thank you for your wait. - - - - Service is stoped. Please use the start command. + Service is not initialized. @@ -31,44 +19,27 @@ You forget a data. please use the next command add -data yourDataString + + You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + + You forget a hash key of alias of removable data. Please use the next command remove -hash yourHash or remove -alias yourAlias + + + QuasarAppUtils::Locales - This is description of the ping command + This bot is still under development. - Returns state + We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - Adds new value into seret storage, and return a hash key after adding. - - - - Remove data from storage by hash key or alias. - - - - return secret from database - - - - Alias name - - - - Data that will be saved - - - - Hash kay of data - - - - You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + Thank you for your wait. diff --git a/src/service/languages/ru.ts b/src/service/languages/ru.ts index 0423b36..9f3d6d4 100644 --- a/src/service/languages/ru.ts +++ b/src/service/languages/ru.ts @@ -2,21 +2,9 @@ - QuasarAppUtils::Locales + QObject - This bot is still under development. - - - - We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - - - - Thank you for your wait. - - - - Service is stoped. Please use the start command. + Service is not initialized. @@ -31,44 +19,27 @@ You forget a data. please use the next command add -data yourDataString + + You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + + You forget a hash key of alias of removable data. Please use the next command remove -hash yourHash or remove -alias yourAlias + + + QuasarAppUtils::Locales - This is description of the ping command + This bot is still under development. - Returns state + We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - Adds new value into seret storage, and return a hash key after adding. - - - - Remove data from storage by hash key or alias. - - - - return secret from database - - - - Alias name - - - - Data that will be saved - - - - Hash kay of data - - - - You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + Thank you for your wait. diff --git a/src/service/languages/tr.ts b/src/service/languages/tr.ts index 0423b36..9f3d6d4 100644 --- a/src/service/languages/tr.ts +++ b/src/service/languages/tr.ts @@ -2,21 +2,9 @@ - QuasarAppUtils::Locales + QObject - This bot is still under development. - - - - We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - - - - Thank you for your wait. - - - - Service is stoped. Please use the start command. + Service is not initialized. @@ -31,44 +19,27 @@ You forget a data. please use the next command add -data yourDataString + + You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + + You forget a hash key of alias of removable data. Please use the next command remove -hash yourHash or remove -alias yourAlias + + + QuasarAppUtils::Locales - This is description of the ping command + This bot is still under development. - Returns state + We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - Adds new value into seret storage, and return a hash key after adding. - - - - Remove data from storage by hash key or alias. - - - - return secret from database - - - - Alias name - - - - Data that will be saved - - - - Hash kay of data - - - - You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + Thank you for your wait. diff --git a/src/service/languages/uk.ts b/src/service/languages/uk.ts index 0423b36..9f3d6d4 100644 --- a/src/service/languages/uk.ts +++ b/src/service/languages/uk.ts @@ -2,21 +2,9 @@ - QuasarAppUtils::Locales + QObject - This bot is still under development. - - - - We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - - - - Thank you for your wait. - - - - Service is stoped. Please use the start command. + Service is not initialized. @@ -31,44 +19,27 @@ You forget a data. please use the next command add -data yourDataString + + You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + + You forget a hash key of alias of removable data. Please use the next command remove -hash yourHash or remove -alias yourAlias + + + QuasarAppUtils::Locales - This is description of the ping command + This bot is still under development. - Returns state + We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - Adds new value into seret storage, and return a hash key after adding. - - - - Remove data from storage by hash key or alias. - - - - return secret from database - - - - Alias name - - - - Data that will be saved - - - - Hash kay of data - - - - You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + Thank you for your wait. diff --git a/src/service/languages/zh.ts b/src/service/languages/zh.ts index 0423b36..9f3d6d4 100644 --- a/src/service/languages/zh.ts +++ b/src/service/languages/zh.ts @@ -2,21 +2,9 @@ - QuasarAppUtils::Locales + QObject - This bot is still under development. - - - - We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - - - - Thank you for your wait. - - - - Service is stoped. Please use the start command. + Service is not initialized. @@ -31,44 +19,27 @@ You forget a data. please use the next command add -data yourDataString + + You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + + You forget a hash key of alias of removable data. Please use the next command remove -hash yourHash or remove -alias yourAlias + + + QuasarAppUtils::Locales - This is description of the ping command + This bot is still under development. - Returns state + We are working very hard on our new delivery service to make it as easy as possible for you to be with us wherever you are. - Adds new value into seret storage, and return a hash key after adding. - - - - Remove data from storage by hash key or alias. - - - - return secret from database - - - - Alias name - - - - Data that will be saved - - - - Hash kay of data - - - - You forget a hash key of alias of getting data. Please use the next command get -hash yourHash or get -alias yourAlias + Thank you for your wait. diff --git a/src/service/main.cpp b/src/service/main.cpp index 65e8476..41f73fc 100644 --- a/src/service/main.cpp +++ b/src/service/main.cpp @@ -5,14 +5,111 @@ //# of this license document, but changing it is not allowed. //# -#include +#include +#include +#include +#include +#include "params.h" + +bool processRequest() { + auto storage = QASecret::KeyStorage::instance(); + + if (!storage) { + QuasarAppUtils::Params::log(QObject::tr("Service is not initialized.")); + return false; + } + + bool fAdd = QuasarAppUtils::Params::isEndable("add"); + bool fRemove = QuasarAppUtils::Params::isEndable("remove"); + bool fGet = QuasarAppUtils::Params::isEndable("get"); + + int actionsCount = fAdd + fRemove + fGet; + if (actionsCount > 1) { + QuasarAppUtils::Params::log(QObject::tr("You are try to run multiple commands. please choose some of pleas choose one."), + QuasarAppUtils::Error); + return false; + } else if (!actionsCount) { + QuasarAppUtils::Params::log(QObject::tr("please choose one of available actions add/remove/get"), + QuasarAppUtils::Error); + return false; + }; + + if (fAdd) { + const auto&& dataVal = QuasarAppUtils::Params::getArg("data"); + const auto&& aliasVal = QuasarAppUtils::Params::getArg("alias"); + + if (dataVal.isEmpty()) { + QuasarAppUtils::Params::log(QObject::tr("You forget a data. please use the next command add -data yourDataString"), + QuasarAppUtils::Error); + return false; + } + + QuasarAppUtils::Params::log(storage->add(dataVal.toLatin1(), aliasVal), + QuasarAppUtils::VerboseLvl::Info); + + } else if ( fGet) { + + const auto&& hashVal = QuasarAppUtils::Params::getArg("hash"); + const auto&& aliasVal = QuasarAppUtils::Params::getArg("alias"); + + if (hashVal.isEmpty() && aliasVal.isEmpty()) { + QuasarAppUtils::Params::log(QObject::tr("You forget a hash key of alias of getting data. " + "Please use the next command get -hash yourHash or " + "get -alias yourAlias"), QuasarAppUtils::Error); + return false; + } + + if (hashVal.size()) { + QuasarAppUtils::Params::log(storage->get(hashVal.toLatin1()), + QuasarAppUtils::VerboseLvl::Info); + } else if (aliasVal.size()) { + QuasarAppUtils::Params::log(storage->get(aliasVal), + QuasarAppUtils::VerboseLvl::Info); + } + + } else if (fRemove) { + + const auto&& hashVal = QuasarAppUtils::Params::getArg("hash"); + const auto&& aliasVal = QuasarAppUtils::Params::getArg("alias"); + + if (hashVal.isEmpty() && aliasVal.isEmpty()) { + QuasarAppUtils::Params::log(QObject::tr("You forget a hash key of alias of removable data. " + "Please use the next command remove -hash yourHash or " + "remove -alias yourAlias"), QuasarAppUtils::Error); + return false; + } + + if (hashVal.size()) { + storage->remove(hashVal.toLatin1()); + } else if (aliasVal.size()) { + storage->remove(aliasVal); + } + + } + + return true; +} + int main(int argc, char *argv[]) { QCoreApplication::setApplicationName("QASecret"); QCoreApplication::setOrganizationName("QuasarApp"); - SecretService service(argc, argv); + QuasarAppUtils::Params::parseParams(argc, argv); + QCoreApplication app(argc, argv); + QASecret::init(); - return service.exec(); + QTimer::singleShot(0, nullptr, []() { + + if (!processRequest()) { + QCoreApplication::exit(1); + return; + } + + QCoreApplication::quit(); + }); + + + return app.exec(); } diff --git a/src/service/secretservice.cpp b/src/service/secretservice.cpp deleted file mode 100644 index 4ff7ce5..0000000 --- a/src/service/secretservice.cpp +++ /dev/null @@ -1,143 +0,0 @@ -//# -//# Copyright (C) 2024-2024 QuasarApp. -//# Distributed under the GPLv3 software license, see the accompanying -//# Everyone is permitted to copy and distribute verbatim copies -//# of this license document, but changing it is not allowed. -//# - -#include "secretservice.h" -#include -#include -#include - -SecretService::SecretService(int argc, char **argv): - Patronum::Service(argc, argv) { - -} - -bool SecretService::onStart() { - // call on server started - QASecret::init(); - - return true; -} - -void SecretService::onStop() { - // call on server stoped - QASecret::KeyStorage::deinitService(); - -} - -void SecretService::handleReceiveData(const QHash &data) { - auto storage = QASecret::KeyStorage::instance(); - - if (!storage) { - sendResuylt(QuasarAppUtils::Locales::tr("Service is stoped. Please use the start command.")); - return; - } - - bool fAdd = data.contains("add"); - bool fRemove = data.contains("remove"); - bool fGet = data.contains("get"); - - int actionsCount = fAdd + fRemove + fGet; - if (actionsCount > 1) { - sendResuylt(QuasarAppUtils::Locales::tr("You are try to run multiple commands. please choose some of pleas choose one.")); - return; - } else if (data.isEmpty()) { - sendResuylt(QuasarAppUtils::Locales::tr("please choose one of available actions add/remove/get")); - return; - }; - - if (fAdd) { - const auto&& dataVal = data.value("data").arg(); - const auto&& aliasVal = data.value("alias").arg(); - - if (dataVal.isEmpty()) { - sendResuylt(QuasarAppUtils::Locales::tr("You forget a data. please use the next command add -data yourDataString")); - return; - } - - sendRawResuylt(storage->add(dataVal.toLatin1(), aliasVal)); - - } else if ( fGet) { - - const auto&& hashVal = data.value("hash").arg(); - const auto&& aliasVal = data.value("alias").arg(); - - if (hashVal.isEmpty() && aliasVal.isEmpty()) { - sendResuylt(QuasarAppUtils::Locales::tr("You forget a hash key of alias of getting data. " - "Please use the next command get -hash yourHash or " - "get -alias yourAlias")); - return; - } - - if (hashVal.size()) { - sendRawResuylt(storage->get(hashVal.toLatin1())); - } else if (aliasVal.size()) { - sendRawResuylt(storage->get(aliasVal)); - } - - } else if (fRemove) { - - const auto&& hashVal = data.value("hash").arg(); - const auto&& aliasVal = data.value("alias").arg(); - - if (hashVal.isEmpty() && aliasVal.isEmpty()) { - sendResuylt(QuasarAppUtils::Locales::tr("You forget a hash key of alias of removable data. " - "Please use the next command remove -hash yourHash or " - "remove -alias yourAlias")); - return; - } - - if (hashVal.size()) { - storage->remove(hashVal.toLatin1()); - } else if (aliasVal.size()) { - storage->remove(aliasVal); - } - - } else { - Patronum::Service::handleReceiveData(data); - } -} - -bool SecretService::handleReceive(const Patronum::Feature &data) { - - if (data.cmd() == "ping") { - sendResuylt("Pong"); - } else if (data.cmd() == "state") { - auto storage = QASecret::KeyStorage::instance(); - - if (storage) { - sendResuylt("application status: Active"); - } else { - sendResuylt("application status: Stoped"); - } - } - - return true; -} - -QSet SecretService::supportedFeatures() { - QSet data; - - data << Patronum::Feature("ping", {}, QuasarAppUtils::Locales::tr("This is description of the ping command")); - data << Patronum::Feature("state", {}, QuasarAppUtils::Locales::tr("Returns state")); - data << Patronum::Feature("add", - {}, - QuasarAppUtils::Locales::tr("Adds new value into seret storage, and return a hash key after adding."), - "QASecret add -data mysecretString -alias myCustomKey "); - data << Patronum::Feature("remove", - {}, - QuasarAppUtils::Locales::tr("Remove data from storage by hash key or alias."), - "QASecret remove -hash hashKey or QASecret remove -alias myCustomKey"); - data << Patronum::Feature("get", - {}, - QuasarAppUtils::Locales::tr("return secret from database"), - "QASecret get -hash hashKey or QASecret get -alias myCustomKey "); - data << Patronum::Feature("-alias", {"aliasName"}, QuasarAppUtils::Locales::tr("Alias name")); - data << Patronum::Feature("-data", {"data"}, QuasarAppUtils::Locales::tr("Data that will be saved")); - data << Patronum::Feature("-hash", {"hash"}, QuasarAppUtils::Locales::tr("Hash kay of data")); - - return data; -} diff --git a/src/service/secretservice.h b/src/service/secretservice.h deleted file mode 100644 index e82f278..0000000 --- a/src/service/secretservice.h +++ /dev/null @@ -1,32 +0,0 @@ -//# -//# Copyright (C) 2024-2024 QuasarApp. -//# Distributed under the GPLv3 software license, see the accompanying -//# Everyone is permitted to copy and distribute verbatim copies -//# of this license document, but changing it is not allowed. -//# - -#ifndef SECRETSERVICE_H -#define SECRETSERVICE_H - -#include - -/** - * @brief The SecretService class main class - */ -class SecretService: public Patronum::Service -{ - -public: - SecretService(int argc, char **argv); - - bool onStart() override; - - void onStop() override; - - void handleReceiveData(const QHash &data) override; - bool handleReceive(const Patronum::Feature &data) override; - QSet supportedFeatures() override; - -}; - -#endif // SECRETSERVICE_H