final (tested) implementation

This commit is contained in:
Andrei Yankovich 2024-01-14 15:01:24 +01:00
parent af1db8ba64
commit cc61a93b69
6 changed files with 65 additions and 111 deletions

View File

@ -6,13 +6,14 @@
//#
#include "SecretDB.h"
#include <heart.h>
#include <secretdatabase.h>
namespace DBSecret {
bool init() {
QH::init();
initSecretDBResources();
return true;
}

View File

@ -38,85 +38,5 @@ target_include_directories(${CURRENT_PROJECT} PRIVATE ${PRIVATE_INCUDE_DIR})
SET(TARGET_DIR "${CMAKE_SOURCE_DIR}/Distro")
file(MAKE_DIRECTORY ${TARGET_DIR})
if (ANDROID)
set(ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/android CACHE INTERNAL "")
set(ENV{ANDROID_API_VERSION} 31)
set(ANDROID_API_VERSION $ENV{ANDROID_API_VERSION})
set(OPENSSL_ROOT_PATH "$ENV{OPENSSL_ROOT_DIR}")
set(SecretService_EXTRA_LIBS
${PROJECT_NAME}Library
# libName
)
if (SIGN_APP)
message("SIGN_APP")
addDeploySignedAPK(${CURRENT_PROJECT}
"${CMAKE_CURRENT_LIST_DIR}/android"
"QuasarAppProject"
"${SIGPATH}/quasarapp.keystore"
"${SIGPASS_QUASARAPP}"
"${TARGET_DIR}"
"${SecretService_EXTRA_LIBS}")
else()
message("NO_SIGN_APP")
addDeployAPK(${CURRENT_PROJECT}
"${CMAKE_CURRENT_LIST_DIR}/android"
"${TARGET_DIR}"
"${SecretService_EXTRA_LIBS}")
endif()
set(manifest_file "${CMAKE_CURRENT_SOURCE_DIR}/android/AndroidManifest.xml")
configure_file("${manifest_file}.in" ${manifest_file} @ONLY)
set(gradle_file "${CMAKE_CURRENT_SOURCE_DIR}/android/build.gradle")
configure_file("${gradle_file}.in" ${gradle_file} @ONLY)
file(GLOB java_files
"android/src/com/quasarapp/androidtools/*.java"
"android/*.xml"
"android/*.gradle"
"android/gradlew"
"android/gradle.*"
)
add_custom_target(${name}Android
SOURCES ${java_files}
)
elseif(IOS)
# set_xcode_property(${CURRENT_PROJECT} PRODUCT_BUNDLE_IDENTIFIER ${CHEATCARD_PACKAGE_ID} All)
set_target_properties(${CURRENT_PROJECT} PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER ${SECRETSERVICE_PACKAGE_ID}
MACOSX_BUNDLE_BUNDLE_VERSION ${SECRETSERVICE_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${SECRETSERVICE_VERSION}
)
else()
# Desctop deploying
message(GIT_COMMIT_COUNT = ${GIT_COMMIT_COUNT})
configure_file_in(${CURRENT_PROJECT} "${CMAKE_CURRENT_SOURCE_DIR}/deploy/SecretService.json")
addDeployFromCustomFile(${CURRENT_PROJECT} "${CMAKE_CURRENT_SOURCE_DIR}/deploy/SecretService.json")
endif()
set(LANGS ${CMAKE_CURRENT_SOURCE_DIR}/languages/en.ts
${CMAKE_CURRENT_SOURCE_DIR}/languages/ru.ts
${CMAKE_CURRENT_SOURCE_DIR}/languages/uk.ts
${CMAKE_CURRENT_SOURCE_DIR}/languages/ja.ts
${CMAKE_CURRENT_SOURCE_DIR}/languages/tr.ts
${CMAKE_CURRENT_SOURCE_DIR}/languages/zh.ts
${CMAKE_CURRENT_SOURCE_DIR}/languages/de.ts
${CMAKE_CURRENT_SOURCE_DIR}/languages/fr.ts
${CMAKE_CURRENT_SOURCE_DIR}/languages/es.ts
${CMAKE_CURRENT_SOURCE_DIR}/languages/pl.ts)
prepareQM(${CURRENT_PROJECT} ${CMAKE_CURRENT_SOURCE_DIR}/../ "${LANGS}")

View File

@ -5,6 +5,31 @@
//# of this license document, but changing it is not allowed.
//#
#include "params.h"
#include <QASecret.h>
#include <QCoreApplication>
#include <QTimer>
#include <QASecret/keystorage.h>
int main(int argc, char * argv[]) {
return 0;
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();
}

View File

@ -5,6 +5,14 @@
//# of this license document, but changing it is not allowed.
//#
#include <secretservice.h>
int main(int argc, char *argv[]) {
return 0;
QCoreApplication::setApplicationName("QASecret");
QCoreApplication::setOrganizationName("QuasarApp");
SecretService service(argc, argv);
return service.exec();
}

View File

@ -13,13 +13,11 @@
SecretService::SecretService(int argc, char **argv):
Patronum::Service<QCoreApplication>(argc, argv) {
QASecret::init();
}
bool SecretService::onStart() {
// call on server started
QASecret::KeyStorage::initService(std::make_unique<QASecret::KeyStorage>(DBSecret::database()));
QASecret::init();
return true;
}
@ -52,36 +50,20 @@ void SecretService::handleReceiveData(const QHash<QString, Patronum::Feature> &d
};
if (fAdd) {
const auto&& dataVal = data.value("-data").arg();
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;
}
sendResuylt(storage->add(dataVal.toLatin1()));
} 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()) {
sendResuylt(storage->get(hashVal.toLatin1()));
} else if (aliasVal.size()) {
sendResuylt(storage->get(aliasVal));
}
sendRawResuylt(storage->add(dataVal.toLatin1(), aliasVal));
} else if ( fGet) {
const auto&& hashVal = data.value("-hash").arg();
const auto&& aliasVal = data.value("-alias").arg();
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. "
@ -90,6 +72,24 @@ void SecretService::handleReceiveData(const QHash<QString, Patronum::Feature> &d
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()) {
@ -97,7 +97,7 @@ void SecretService::handleReceiveData(const QHash<QString, Patronum::Feature> &d
}
} else {
handleReceiveData(data);
Patronum::Service<QCoreApplication>::handleReceiveData(data);
}
}

@ -1 +1 @@
Subproject commit d05de3b235f0f1c726fc8ca5fffcc7d4bc7758f1
Subproject commit 7c440c2a3137f2cefdf9ed054327e96f05d13879