mirror of
https://github.com/QuasarApp/SecretService.git
synced 2025-04-26 22:04:33 +00:00
final (tested) implementation
This commit is contained in:
parent
af1db8ba64
commit
cc61a93b69
@ -6,13 +6,14 @@
|
|||||||
//#
|
//#
|
||||||
|
|
||||||
#include "SecretDB.h"
|
#include "SecretDB.h"
|
||||||
|
#include <heart.h>
|
||||||
#include <secretdatabase.h>
|
#include <secretdatabase.h>
|
||||||
|
|
||||||
|
|
||||||
namespace DBSecret {
|
namespace DBSecret {
|
||||||
|
|
||||||
bool init() {
|
bool init() {
|
||||||
|
QH::init();
|
||||||
initSecretDBResources();
|
initSecretDBResources();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -38,85 +38,5 @@ target_include_directories(${CURRENT_PROJECT} PRIVATE ${PRIVATE_INCUDE_DIR})
|
|||||||
SET(TARGET_DIR "${CMAKE_SOURCE_DIR}/Distro")
|
SET(TARGET_DIR "${CMAKE_SOURCE_DIR}/Distro")
|
||||||
file(MAKE_DIRECTORY ${TARGET_DIR})
|
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}")
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,31 @@
|
|||||||
//# of this license document, but changing it is not allowed.
|
//# 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[]) {
|
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();
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,14 @@
|
|||||||
//# of this license document, but changing it is not allowed.
|
//# of this license document, but changing it is not allowed.
|
||||||
//#
|
//#
|
||||||
|
|
||||||
|
#include <secretservice.h>
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
return 0;
|
|
||||||
|
QCoreApplication::setApplicationName("QASecret");
|
||||||
|
QCoreApplication::setOrganizationName("QuasarApp");
|
||||||
|
|
||||||
|
SecretService service(argc, argv);
|
||||||
|
|
||||||
|
return service.exec();
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,11 @@
|
|||||||
SecretService::SecretService(int argc, char **argv):
|
SecretService::SecretService(int argc, char **argv):
|
||||||
Patronum::Service<QCoreApplication>(argc, argv) {
|
Patronum::Service<QCoreApplication>(argc, argv) {
|
||||||
|
|
||||||
QASecret::init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SecretService::onStart() {
|
bool SecretService::onStart() {
|
||||||
// call on server started
|
// call on server started
|
||||||
|
QASecret::init();
|
||||||
QASecret::KeyStorage::initService(std::make_unique<QASecret::KeyStorage>(DBSecret::database()));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -52,36 +50,20 @@ void SecretService::handleReceiveData(const QHash<QString, Patronum::Feature> &d
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (fAdd) {
|
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()) {
|
if (dataVal.isEmpty()) {
|
||||||
sendResuylt(QuasarAppUtils::Locales::tr("You forget a data. please use the next command add -data yourDataString"));
|
sendResuylt(QuasarAppUtils::Locales::tr("You forget a data. please use the next command add -data yourDataString"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendResuylt(storage->add(dataVal.toLatin1()));
|
sendRawResuylt(storage->add(dataVal.toLatin1(), 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()) {
|
|
||||||
sendResuylt(storage->get(hashVal.toLatin1()));
|
|
||||||
} else if (aliasVal.size()) {
|
|
||||||
sendResuylt(storage->get(aliasVal));
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if ( fGet) {
|
} else if ( fGet) {
|
||||||
|
|
||||||
const auto&& hashVal = data.value("-hash").arg();
|
const auto&& hashVal = data.value("hash").arg();
|
||||||
const auto&& aliasVal = data.value("-alias").arg();
|
const auto&& aliasVal = data.value("alias").arg();
|
||||||
|
|
||||||
if (hashVal.isEmpty() && aliasVal.isEmpty()) {
|
if (hashVal.isEmpty() && aliasVal.isEmpty()) {
|
||||||
sendResuylt(QuasarAppUtils::Locales::tr("You forget a hash key of alias of getting data. "
|
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;
|
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()) {
|
if (hashVal.size()) {
|
||||||
storage->remove(hashVal.toLatin1());
|
storage->remove(hashVal.toLatin1());
|
||||||
} else if (aliasVal.size()) {
|
} else if (aliasVal.size()) {
|
||||||
@ -97,7 +97,7 @@ void SecretService::handleReceiveData(const QHash<QString, Patronum::Feature> &d
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
handleReceiveData(data);
|
Patronum::Service<QCoreApplication>::handleReceiveData(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit d05de3b235f0f1c726fc8ca5fffcc7d4bc7758f1
|
Subproject commit 7c440c2a3137f2cefdf9ed054327e96f05d13879
|
Loading…
x
Reference in New Issue
Block a user