mirror of
https://github.com/QuasarApp/SecretService.git
synced 2025-04-26 05:44:32 +00:00
added database lirary
This commit is contained in:
parent
3e47703a4b
commit
a9416ebe3a
@ -51,6 +51,7 @@ endif()
|
||||
set(HEART_TESTS OFF)
|
||||
add_subdirectory(submodules/Heart)
|
||||
|
||||
add_subdirectory(src/db)
|
||||
add_subdirectory(src/core)
|
||||
|
||||
set(PATRONUM_TESTS OFF)
|
||||
|
@ -29,7 +29,7 @@ if (SECRETSERVICE_TESTS)
|
||||
target_link_libraries(${CURRENT_PROJECT} PUBLIC ${PROJECT_NAME}testcore)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${CURRENT_PROJECT} PUBLIC Qt${QT_VERSION_MAJOR}::Core Heart)
|
||||
target_link_libraries(${CURRENT_PROJECT} PUBLIC Qt${QT_VERSION_MAJOR}::Core "${PROJECT_NAME}DB")
|
||||
|
||||
target_include_directories(${CURRENT_PROJECT} PUBLIC ${PUBLIC_INCUDE_DIR})
|
||||
target_include_directories(${CURRENT_PROJECT} PRIVATE ${PRIVATE_INCUDE_DIR})
|
||||
|
65
src/core/src/private/keystorage.h
Normal file
65
src/core/src/private/keystorage.h
Normal file
@ -0,0 +1,65 @@
|
||||
//#
|
||||
//# Copyright (C) 2023-2023 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 KEYSTORAGE_H
|
||||
#define KEYSTORAGE_H
|
||||
|
||||
#include "qaservice.h"
|
||||
#include <QHash>
|
||||
|
||||
namespace QASecret {
|
||||
|
||||
/**
|
||||
* @brief The KeyStorage class the storage store seccrets values on the simple key - value table. Where value is secrete and key is a sha256(secret) hash.
|
||||
*/
|
||||
class KeyStorage: public QuasarAppUtils::Service<KeyStorage>
|
||||
{
|
||||
public:
|
||||
KeyStorage();
|
||||
|
||||
/**
|
||||
* @brief add adds to storage new value, and return access key.
|
||||
* @param value This is value to save.
|
||||
* @param alias This is simple alias for get key.
|
||||
* @return access key of @a value.
|
||||
*/
|
||||
QByteArray add(const QByteArray& value, const QString& alias = {});
|
||||
|
||||
/**
|
||||
* @brief remove This method remove secret from storage by key.
|
||||
* @param key This is sha256 key of secret
|
||||
*/
|
||||
void remove(const QByteArray& key);
|
||||
|
||||
/**
|
||||
* @brief remove This method remove seccret value by alias.
|
||||
* @param alias
|
||||
*/
|
||||
void remove(const QString& alias);
|
||||
|
||||
|
||||
/**
|
||||
* @brief get return value by access key.
|
||||
* @param key this is access key of value.
|
||||
* @return secret value
|
||||
*/
|
||||
QByteArray get(const QByteArray& key);
|
||||
|
||||
/**
|
||||
* @brief get return value by alias of key.
|
||||
* @param key this is access key of value.
|
||||
* @return secret value
|
||||
*/
|
||||
QByteArray get(const QString& alias);
|
||||
|
||||
private:
|
||||
QHash<QByteArray, QByteArray> _storage;
|
||||
QHash<QString, QByteArray> _aliases;
|
||||
|
||||
};
|
||||
}
|
||||
#endif // KEYSTORAGE_H
|
40
src/db/CMakeLists.txt
Normal file
40
src/db/CMakeLists.txt
Normal file
@ -0,0 +1,40 @@
|
||||
#
|
||||
# Copyright (C) 2020-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)
|
||||
|
||||
set(CURRENT_PROJECT "${PROJECT_NAME}DB")
|
||||
add_definitions(-DSECRETDB_LIBRARY)
|
||||
|
||||
|
||||
file(GLOB_RECURSE SOURCE_CPP
|
||||
"src/*.cpp"
|
||||
"src/*.h"
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE SOURCE_QRC
|
||||
"*.qrc"
|
||||
)
|
||||
|
||||
set(PUBLIC_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/public")
|
||||
set(PRIVATE_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/private")
|
||||
|
||||
add_library(${CURRENT_PROJECT} ${SOURCE_CPP} ${SOURCE_QRC})
|
||||
|
||||
|
||||
target_link_libraries(${CURRENT_PROJECT} PUBLIC Heart )
|
||||
|
||||
|
||||
target_include_directories(${CURRENT_PROJECT} PUBLIC ${PUBLIC_INCUDE_DIR})
|
||||
target_include_directories(${CURRENT_PROJECT} PRIVATE ${PRIVATE_INCUDE_DIR})
|
||||
|
||||
|
||||
prepareQM(${CURRENT_PROJECT} ${CMAKE_CURRENT_SOURCE_DIR} "${LANGS}")
|
||||
|
||||
set(QML_IMPORT_PATH ${QML_IMPORT_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/src" CACHE STRING "" FORCE)
|
||||
|
||||
configure_file_in(${CURRENT_PROJECT} "${CMAKE_CURRENT_SOURCE_DIR}/src/public/SecretDB/global.h")
|
8
src/db/SecretDB.qrc
Normal file
8
src/db/SecretDB.qrc
Normal file
@ -0,0 +1,8 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>src/sql/YourTimeDB_1.sql</file>
|
||||
<file>src/sql/YourTimeDB_2.sql</file>
|
||||
<file>src/sql/YourTimeDB_3.sql</file>
|
||||
</qresource>
|
||||
<qresource prefix="/YourTime/languages"/>
|
||||
</RCC>
|
19
src/db/languages/en.ts
Normal file
19
src/db/languages/en.ts
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="en_US">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
19
src/db/languages/ru.ts
Normal file
19
src/db/languages/ru.ts
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="ru_RU">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation>Этот бот все еще находится в разработке.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation>Мы очень усердно работаем над нашей новой службой доставки, чтобы вам было как можно проще быть с нами, где бы вы ни находились.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation>Спасибо за ожидание.</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
19
src/db/languages/sr.ts
Normal file
19
src/db/languages/sr.ts
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="sr_RS">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation>Ovaj bot je još uvek u razvoju.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation>Radimo veoma naporno na našoj novoj usluzi dostave kako bismo vam učinili što lakšim da budete sa nama gde god da se nalazite.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation>Hvala vam na čekanju.</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
19
src/db/languages/sr_ME.ts
Normal file
19
src/db/languages/sr_ME.ts
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="sr_ME">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation>Ovaj bot je još uvek u razvoju.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation>Radimo veoma naporno na našoj novoj usluzi dostave kako bismo vam učinili što lakšim da budete sa nama gde god da se nalazite.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation>Hvala vam na čekanju.</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
19
src/db/languages/uk.ts
Normal file
19
src/db/languages/uk.ts
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="uk_UA">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation>Цей бот ще в розробці.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation>Ми наполегливо працюємо над нашою новою службою доставки, щоб вам було якомога легше бути з нами, де б ви не були.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation>Дякуємо за очікування.</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
58
src/db/src/private/image.cpp
Normal file
58
src/db/src/private/image.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
//#
|
||||
//# Copyright (C) 2023-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 "image.h"
|
||||
|
||||
namespace QASecret {
|
||||
|
||||
Image::Image() {}
|
||||
|
||||
const QString &Image::getId() const {
|
||||
return _id;
|
||||
}
|
||||
|
||||
void Image::setId(const QString &id) {
|
||||
_id = id;
|
||||
}
|
||||
|
||||
const QByteArray &Image::getImage() const {
|
||||
return _image;
|
||||
}
|
||||
|
||||
void Image::setImage(const QByteArray &source) {
|
||||
_image = source;
|
||||
}
|
||||
|
||||
QH::PKG::DBObject* Image::createDBObject() const {
|
||||
return new Image();
|
||||
}
|
||||
|
||||
bool Image::fromSqlRecord(const QSqlRecord& q) {
|
||||
_id = q.value("id").toString();
|
||||
_image = q.value("data").toByteArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
QString Image::table() const {
|
||||
return "Images";
|
||||
}
|
||||
|
||||
QH::PKG::DBVariantMap Image::variantMap() const {
|
||||
return {
|
||||
{"id", {_id, QH::PKG::MemberType::PrimaryKey}},
|
||||
{"data", {_image, QH::PKG::MemberType::InsertUpdate}}
|
||||
};
|
||||
}
|
||||
|
||||
QString Image::primaryKey() const {
|
||||
return "id";
|
||||
}
|
||||
|
||||
QVariant Image::primaryValue() const {
|
||||
return _id;
|
||||
}
|
||||
}
|
49
src/db/src/private/image.h
Normal file
49
src/db/src/private/image.h
Normal file
@ -0,0 +1,49 @@
|
||||
//#
|
||||
//# Copyright (C) 2023-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 IMAGE_H
|
||||
#define IMAGE_H
|
||||
|
||||
#include "dbobject.h"
|
||||
#include <SecretDB/iimage.h>
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
namespace QASecret {
|
||||
|
||||
/**
|
||||
* @brief The Image class
|
||||
*/
|
||||
class Image : public QH::PKG::DBObject, public iImage
|
||||
{
|
||||
public:
|
||||
Image();
|
||||
|
||||
// iImage interface
|
||||
|
||||
const QString &getId() const override;
|
||||
void setId(const QString &id) override;
|
||||
const QByteArray &getImage() const override;
|
||||
void setImage(const QByteArray &source) override;
|
||||
|
||||
// DBObject interface
|
||||
QH::PKG::DBObject* createDBObject() const override;
|
||||
bool fromSqlRecord(const QSqlRecord& q) override;
|
||||
QString table() const override;
|
||||
QH::PKG::DBVariantMap variantMap() const override;
|
||||
|
||||
QString primaryKey() const override;
|
||||
QVariant primaryValue() const override;
|
||||
|
||||
private:
|
||||
QString _id;
|
||||
QByteArray _image;
|
||||
};
|
||||
}
|
||||
#endif // IMAGE_H
|
257
src/db/src/private/secretdatabase.cpp
Normal file
257
src/db/src/private/secretdatabase.cpp
Normal file
@ -0,0 +1,257 @@
|
||||
//#
|
||||
//# Copyright (C) 2023-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 "botdatabase.h"
|
||||
#include "image.h"
|
||||
#include "processedid.h"
|
||||
#include <QCryptographicHash>
|
||||
#include <dbobjectsrequest.h>
|
||||
#include <menuitem.h>
|
||||
#include <menuitem_v0.h>
|
||||
#include <order.h>
|
||||
#include <role.h>
|
||||
#include <sqldb.h>
|
||||
#include <user.h>
|
||||
|
||||
namespace QASecret {
|
||||
|
||||
BotDataBase::BotDataBase() {
|
||||
|
||||
addDBPatch({
|
||||
0,
|
||||
1,
|
||||
[](const QH::iObjectProvider* database) -> bool {
|
||||
return database->doSql(":/src/sql/YourTimeDB_1.sql");
|
||||
}
|
||||
});
|
||||
|
||||
addDBPatch({
|
||||
1,
|
||||
2,
|
||||
[](const QH::iObjectProvider* database) -> bool {
|
||||
return database->doSql(":/src/sql/YourTimeDB_2.sql");
|
||||
}
|
||||
});
|
||||
|
||||
addDBPatch({
|
||||
2,
|
||||
3,
|
||||
[this](QH::iObjectProvider* database) -> bool {
|
||||
if (!database->doSql(":/src/sql/YourTimeDB_3.sql")) {
|
||||
return false;
|
||||
}
|
||||
QH::PKG::DBObjectsRequest<MenuItem_v0>
|
||||
request("MenuV0");
|
||||
auto&& oldMenu = database->getObject(request);
|
||||
|
||||
for (const auto &oldMenuItem: oldMenu->data()) {
|
||||
auto&& menuItem = getMenuById(oldMenuItem->getId(), true);
|
||||
menuItem->setCategory(oldMenuItem->category());
|
||||
menuItem->setName(oldMenuItem->getName());
|
||||
menuItem->setDescription(oldMenuItem->getDescription());
|
||||
menuItem->setPrice(oldMenuItem->getPrice());
|
||||
menuItem->setTranslations(oldMenuItem->getTranslations());
|
||||
|
||||
const auto& image = oldMenuItem->getImage();
|
||||
if (image.size()) {
|
||||
auto&& imageId = QCryptographicHash::hash(image,
|
||||
QCryptographicHash::Sha256).
|
||||
toBase64(QByteArray::Base64UrlEncoding);
|
||||
|
||||
auto&& imageObj = getImageById(imageId, true);
|
||||
imageObj->setImage(image);
|
||||
|
||||
saveImage(imageObj);
|
||||
|
||||
menuItem->setImage(imageId);
|
||||
} else if (oldMenuItem->getImageSource().size()) {
|
||||
menuItem->setImage(oldMenuItem->getImageSource());
|
||||
}
|
||||
|
||||
saveMenuItem(menuItem);
|
||||
|
||||
}
|
||||
|
||||
return database->doQuery("DROP TABLE MenuV0");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QSet<unsigned long long> BotDataBase::getProcessedIds() {
|
||||
QSet<unsigned long long> result;
|
||||
QH::PKG::DBObjectsRequest<ProcessedId>
|
||||
request("ProcessedIds");
|
||||
|
||||
auto&& responce = db()->getObject(request);
|
||||
if (!responce)
|
||||
return result;
|
||||
|
||||
auto&& resp = responce->data();
|
||||
|
||||
for (const auto& val: resp) {
|
||||
result.insert(val->getId());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void BotDataBase::addProcessedId(unsigned long long id) {
|
||||
auto&& idObj = QSharedPointer<ProcessedId>::create();
|
||||
idObj->setId(id);
|
||||
|
||||
db()->insertObject(idObj);
|
||||
}
|
||||
|
||||
void BotDataBase::removeProcessedId(unsigned long long id) {
|
||||
auto&& idObj = QSharedPointer<ProcessedId>::create();
|
||||
idObj->setId(id);
|
||||
|
||||
db()->deleteObject(idObj);
|
||||
|
||||
}
|
||||
|
||||
void BotDataBase::setProcessedIds(const QSet<unsigned long long> &ids) {
|
||||
auto request = QSharedPointer<QH::PKG::DBObjectsRequest<ProcessedId>>::create(
|
||||
"ProcessedIds");
|
||||
|
||||
db()->deleteObject(request);
|
||||
|
||||
for (const auto& id : ids) {
|
||||
addProcessedId(id);
|
||||
}
|
||||
}
|
||||
|
||||
QSharedPointer<iUser> BotDataBase::getUserById(unsigned long long id, bool ifNotExistsCreate) {
|
||||
return getById<User>(id, &User::setId, ifNotExistsCreate);
|
||||
}
|
||||
|
||||
QList<QSharedPointer<iUser>> BotDataBase::getAllUsers(iRole::RoleName roleName) {
|
||||
QString condition;
|
||||
if (roleName != iRole::All) {
|
||||
condition = QString("role = %0").arg(roleName);
|
||||
condition = QString("id IN ( SELECT userId FROM Roles WHERE %0 )").arg(condition);
|
||||
}
|
||||
|
||||
auto&& data = getAll<User>("Users", condition);
|
||||
return {data.begin(), data.end()};
|
||||
}
|
||||
|
||||
void BotDataBase::saveUser(const QSharedPointer<iUser>& user) {
|
||||
saveObj(user.dynamicCast<User>());
|
||||
}
|
||||
|
||||
void BotDataBase::removeUser(unsigned long long id) {
|
||||
deleteById<User>(id, &User::setId);
|
||||
}
|
||||
|
||||
QSharedPointer<iRole> BotDataBase::getRoleByUserId(unsigned long long userId, bool ifNotExistsCreate) {
|
||||
return getById<Role>(userId, &Role::setUserId, ifNotExistsCreate);
|
||||
}
|
||||
|
||||
void BotDataBase::saveRole(const QSharedPointer<iRole>& role) {
|
||||
saveObj(role.dynamicCast<Role>());
|
||||
}
|
||||
|
||||
void BotDataBase::removeRole(unsigned long long userId) {
|
||||
deleteById<Role>(userId, &Role::setUserId);
|
||||
}
|
||||
|
||||
QSharedPointer<iMenuItem> BotDataBase::getMenuById(int id, bool ifNotExistsCreate) {
|
||||
return getById<MenuItem>(id, &MenuItem::setId, ifNotExistsCreate);
|
||||
}
|
||||
|
||||
QList<QSharedPointer<iMenuItem>> BotDataBase::getAllMenuItems() {
|
||||
auto&& data = getAll<MenuItem>("Menu");
|
||||
return {data.begin(), data.end()};
|
||||
}
|
||||
|
||||
void BotDataBase::saveMenuItem(const QSharedPointer<iMenuItem>& menuItem) {
|
||||
saveObj(menuItem.dynamicCast<MenuItem>());
|
||||
}
|
||||
|
||||
unsigned int BotDataBase::insertMenuItem(const QSharedPointer<iMenuItem> &menuItem) {
|
||||
auto&& resultId = QSharedPointer<unsigned int>::create();
|
||||
insertObj(menuItem.dynamicCast<MenuItem>(), resultId.toWeakRef());
|
||||
|
||||
return *resultId;
|
||||
}
|
||||
|
||||
void BotDataBase::removeMenuItem(int id) {
|
||||
deleteById<MenuItem>(id, &MenuItem::setId);
|
||||
}
|
||||
|
||||
void BotDataBase::clearMenuTable() const {
|
||||
db()->doQuery("DELETE FROM Menu", {}, true);
|
||||
}
|
||||
|
||||
QSharedPointer<iMenuItem> BotDataBase::makeMenuItem() {
|
||||
if (auto&& menuItem = QSharedPointer<MenuItem>::create()) {
|
||||
menuItem->setId(insertMenuItem(menuItem));
|
||||
return std::move(menuItem);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QSharedPointer<iOrder> BotDataBase::getOrderById(int id, bool ifNotExistsCreate) {
|
||||
return getById<Order>(id, &Order::setId, ifNotExistsCreate);
|
||||
}
|
||||
|
||||
QList<QSharedPointer<iOrder>> BotDataBase::getAllOrders(iOrder::State state) {
|
||||
|
||||
QString condition;
|
||||
if (state != iOrder::All) {
|
||||
condition = QString("state = %0").arg(state);
|
||||
}
|
||||
|
||||
auto&& data = getAll<Order>("Orders", condition);
|
||||
return {data.begin(), data.end()};
|
||||
}
|
||||
|
||||
void BotDataBase::saveOrder(const QSharedPointer<iOrder>& order) {
|
||||
saveObj(order.dynamicCast<Order>());
|
||||
}
|
||||
|
||||
unsigned int BotDataBase::insertOrder(const QSharedPointer<iOrder> &order) {
|
||||
auto&& resultId = QSharedPointer<unsigned int>::create();
|
||||
insertObj(order.dynamicCast<Order>(), resultId);
|
||||
|
||||
return *resultId;
|
||||
}
|
||||
|
||||
QSharedPointer<iOrder> BotDataBase::makeOrder() {
|
||||
if (auto&& newOrder = QSharedPointer<Order>::create()) {
|
||||
newOrder->setId(insertOrder(newOrder));
|
||||
return std::move(newOrder);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void BotDataBase::removeOrder(int id) {
|
||||
deleteById<Order>(id, &Order::setId);
|
||||
}
|
||||
|
||||
QList<QSharedPointer<iImage> > BotDataBase::getAllImages() {
|
||||
auto&& data = getAll<Image>("Images", "");
|
||||
return {data.begin(), data.end()};
|
||||
}
|
||||
|
||||
QSharedPointer<iImage> BotDataBase::getImageById(const QString &id, bool ifNotExistsCreate) {
|
||||
return getById<Image>(id, &Image::setId, ifNotExistsCreate);
|
||||
}
|
||||
|
||||
void BotDataBase::saveImage(const QSharedPointer<iImage> &image) {
|
||||
saveObj(image.dynamicCast<Image>());
|
||||
}
|
||||
|
||||
void BotDataBase::removeImage(const QString &id) {
|
||||
deleteById<Image>(id, &Image::setId);
|
||||
}
|
||||
|
||||
|
||||
}
|
64
src/db/src/private/secretdatabase.h
Normal file
64
src/db/src/private/secretdatabase.h
Normal file
@ -0,0 +1,64 @@
|
||||
//#
|
||||
//# Copyright (C) 2023-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 <YourTimeDeliviry/idatabase.h>
|
||||
|
||||
#include <database.h>
|
||||
|
||||
#ifndef BOTDATABASE_H
|
||||
#define BOTDATABASE_H
|
||||
|
||||
namespace QASecret {
|
||||
|
||||
class BotDataBase: public IDataBase, public QH::DataBase
|
||||
{
|
||||
public:
|
||||
BotDataBase();
|
||||
|
||||
// IDataBase interface
|
||||
public:
|
||||
QSet<unsigned long long> getProcessedIds() override;
|
||||
void addProcessedId(unsigned long long id) override;
|
||||
void removeProcessedId(unsigned long long id) override;
|
||||
void setProcessedIds(const QSet<unsigned long long> &ids) override;
|
||||
|
||||
QSharedPointer<iUser> getUserById(unsigned long long id, bool ifNotExistsCreate = false) override;
|
||||
QList<QSharedPointer<iUser> > getAllUsers(iRole::RoleName roleName = iRole::All) override;
|
||||
void saveUser(const QSharedPointer<iUser> &user) override;
|
||||
void removeUser(unsigned long long id) override;
|
||||
QSharedPointer<iRole> getRoleByUserId(unsigned long long userId, bool ifNotExistsCreate = false) override;
|
||||
|
||||
void saveRole(const QSharedPointer<iRole> &role) override;
|
||||
void removeRole(unsigned long long userId) override;
|
||||
|
||||
QSharedPointer<iMenuItem> getMenuById(int id, bool ifNotExistsCreate = false) override;
|
||||
QList<QSharedPointer<iMenuItem> > getAllMenuItems() override;
|
||||
void saveMenuItem(const QSharedPointer<iMenuItem> &menuItem) override;
|
||||
unsigned int insertMenuItem(const QSharedPointer<iMenuItem> &menuItem) override;
|
||||
|
||||
void removeMenuItem(int id) override;
|
||||
void clearMenuTable() const override;
|
||||
QSharedPointer<iMenuItem> makeMenuItem() override;
|
||||
|
||||
QSharedPointer<iOrder> getOrderById(int id, bool ifNotExistsCreate = false) override;
|
||||
QList<QSharedPointer<iOrder> > getAllOrders(iOrder::State state = iOrder::State::All) override;
|
||||
void saveOrder(const QSharedPointer<iOrder> &order) override;
|
||||
unsigned int insertOrder(const QSharedPointer<iOrder> &order) override;
|
||||
QSharedPointer<iOrder> makeOrder() override;
|
||||
|
||||
void removeOrder(int id) override;
|
||||
|
||||
QList<QSharedPointer<iImage> > getAllImages() override;
|
||||
QSharedPointer<iImage> getImageById(const QString &id, bool ifNotExistsCreate = false) override;
|
||||
|
||||
void saveImage(const QSharedPointer<iImage> &image) override;
|
||||
void removeImage(const QString &id) override;
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
#endif // BOTDATABASE_H
|
28
src/db/src/public/SecretDB.cpp
Normal file
28
src/db/src/public/SecretDB.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
//#
|
||||
//# Copyright (C) 2021-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 "SecretDB.h"
|
||||
|
||||
#include <botdatabase.h>
|
||||
|
||||
|
||||
namespace QASecret {
|
||||
|
||||
bool init() {
|
||||
initSecretDBResources();
|
||||
return true;
|
||||
}
|
||||
|
||||
QSharedPointer<IDataBase> database() {
|
||||
auto db = QSharedPointer<BotDataBase>::create();
|
||||
db->initSqlDb();
|
||||
|
||||
return db;
|
||||
}
|
||||
|
||||
|
||||
}
|
26
src/db/src/public/SecretDB.h
Normal file
26
src/db/src/public/SecretDB.h
Normal file
@ -0,0 +1,26 @@
|
||||
//#
|
||||
//# Copyright (C) 2021-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 "SecretDB/global.h"
|
||||
#include "SecretDB/idatabase.h"
|
||||
#include <QSharedPointer>
|
||||
#include <QString>
|
||||
|
||||
inline void initSecretDBResources() { Q_INIT_RESOURCE(SecretDB); }
|
||||
|
||||
namespace QASecret {
|
||||
|
||||
/**
|
||||
* @brief init main initialize method of The YourTimeDeliviry library
|
||||
* @return true if library initialized successfull
|
||||
*/
|
||||
bool SECRETDB_EXPORT init();
|
||||
|
||||
QSharedPointer<IDataBase> SECRETDB_EXPORT database();
|
||||
|
||||
|
||||
};
|
20
src/db/src/public/SecretDB/global.h.in
Normal file
20
src/db/src/public/SecretDB/global.h.in
Normal file
@ -0,0 +1,20 @@
|
||||
//#
|
||||
//# 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 SECRETDB_GLOBAL_H
|
||||
#define SECRETDB_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if defined(SECRETDB_LIBRARY)
|
||||
# define SECRETDB_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define SECRETDB_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif //SECRETDB_GLOBAL_H
|
||||
|
15
src/db/src/public/SecretDB/idatabase.cpp
Normal file
15
src/db/src/public/SecretDB/idatabase.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
//#
|
||||
//# Copyright (C) 2018-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 "idatabase.h"
|
||||
namespace QASecret {
|
||||
|
||||
IDataBase::IDataBase()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
191
src/db/src/public/SecretDB/idatabase.h
Normal file
191
src/db/src/public/SecretDB/idatabase.h
Normal file
@ -0,0 +1,191 @@
|
||||
//#
|
||||
//# 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 IDATABASE_H
|
||||
#define IDATABASE_H
|
||||
|
||||
#include <QSet>
|
||||
#include <QSharedPointer>
|
||||
#include "global.h"
|
||||
#include "irecord.h"
|
||||
|
||||
|
||||
namespace QASecret {
|
||||
/**
|
||||
* @brief The IDataBase class Main database
|
||||
*/
|
||||
class SECRETDB_EXPORT IDataBase
|
||||
{
|
||||
public:
|
||||
IDataBase();
|
||||
|
||||
/**
|
||||
* @brief Get a user by their ID.
|
||||
* @param id The ID of the user to retrieve.
|
||||
* @param ifNotExistsCreate - this option will create a new object if object with @a id is not existst into database. But object wil not save into database.
|
||||
* @return A QSharedPointer to the user object if found, nullptr otherwise.
|
||||
*/
|
||||
virtual QSharedPointer<iUser> getRecordByAlias(const QString& alias, bool ifNotExistsCreate = false) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get a list of all users in the database.
|
||||
* @return A list of QSharedPointer<iUser> objects.
|
||||
*/
|
||||
virtual QList<QSharedPointer<iUser>> getAllUsers(iRole::RoleName roleName = iRole::All) = 0;
|
||||
|
||||
/**
|
||||
* @brief Update old, or insert if not exists a new user to the database.
|
||||
* @param user The user object to add.
|
||||
*/
|
||||
virtual void saveUser(const QSharedPointer<iUser>& user) = 0;
|
||||
|
||||
/**
|
||||
* @brief Remove a user from the database by their ID.
|
||||
* @param id The ID of the user to remove.
|
||||
*/
|
||||
virtual void removeUser(unsigned long long id) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get a user's role by their ID.
|
||||
* @param userId The ID of the user.
|
||||
* @param ifNotExistsCreate - this option will create a new object if object with @a id is not existst into database. But object wil not save into database.
|
||||
* @return A QSharedPointer to the role object if found, nullptr otherwise.
|
||||
*/
|
||||
virtual QSharedPointer<iRole> getRoleByUserId(unsigned long long userId, bool ifNotExistsCreate = false) = 0;
|
||||
|
||||
/**
|
||||
* @brief Update old, or insert if not exists a new role to the database.
|
||||
* @param role The role object to add.
|
||||
*/
|
||||
virtual void saveRole(const QSharedPointer<iRole>& role) = 0;
|
||||
|
||||
/**
|
||||
* @brief Remove a role from the database by the user's ID.
|
||||
* @param userId The ID of the user whose role should be removed.
|
||||
*/
|
||||
virtual void removeRole(unsigned long long userId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get a menu item by its ID.
|
||||
* @param id The ID of the menu item to retrieve.
|
||||
* @param ifNotExistsCreate - this option will create a new object if object with @a id is not existst into database. But object wil not save into database.
|
||||
* @return A QSharedPointer to the menu item object if found, nullptr otherwise.
|
||||
*/
|
||||
virtual QSharedPointer<iMenuItem> getMenuById(int id, bool ifNotExistsCreate = false) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get a list of all menu items in the database.
|
||||
* @return A list of QSharedPointer<iMenu> objects.
|
||||
*/
|
||||
virtual QList<QSharedPointer<iMenuItem>> getAllMenuItems() = 0;
|
||||
|
||||
/**
|
||||
* @brief Update old, or insert if not exists a new menu item to the database.
|
||||
* @param menuItem The menu item object to add.
|
||||
*/
|
||||
virtual void saveMenuItem(const QSharedPointer<iMenuItem>& menuItem) = 0;
|
||||
|
||||
/**
|
||||
* @brief insertMenuItem This method create a new record of the menuItem and return them id
|
||||
* @param menuItem This is data to save.
|
||||
* @return id of the new record of the @a menuItem
|
||||
*/
|
||||
virtual unsigned int insertMenuItem(const QSharedPointer<iMenuItem> &menuItem) = 0;
|
||||
|
||||
/**
|
||||
* @brief Remove a menu item from the database by its ID.
|
||||
* @param id The ID of the menu item to remove.
|
||||
*/
|
||||
virtual void removeMenuItem(int id) = 0;
|
||||
|
||||
/**
|
||||
* @brief clearMenuTable This method remove all data from the menu table.
|
||||
*/
|
||||
virtual void clearMenuTable() const = 0;
|
||||
|
||||
/**
|
||||
* @brief makeMenuItem This method create a new record of the menu item in database.
|
||||
* @return new record of the menu item.
|
||||
*/
|
||||
virtual QSharedPointer<iMenuItem> makeMenuItem() = 0;
|
||||
|
||||
/**
|
||||
* @brief Get an order by its ID.
|
||||
* @param id The ID of the order to retrieve.\
|
||||
* @param ifNotExistsCreate - this option will create a new object if object with @a id is not existst into database. But object wil not save into database.
|
||||
* @return A QSharedPointer to the order object if found, nullptr otherwise.
|
||||
*/
|
||||
virtual QSharedPointer<iOrder> getOrderById(int id, bool ifNotExistsCreate = false) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get a list of all orders in the database.
|
||||
* @param state filter order by status. If you want to get all orders with all statuses use the iOrder::State:All
|
||||
* @return A list of QSharedPointer<iOrder> objects.
|
||||
*/
|
||||
virtual QList<QSharedPointer<iOrder>> getAllOrders(iOrder::State state = iOrder::State::All) = 0;
|
||||
|
||||
/**
|
||||
* @brief Update old, or insert if not exists a new order to the database.
|
||||
* @param order The order object to add.
|
||||
*/
|
||||
virtual void saveOrder(const QSharedPointer<iOrder>& order) = 0;
|
||||
|
||||
/**
|
||||
* @brief insertOrder This method create a new record of the order and return them id
|
||||
* @param order This is data to save.
|
||||
* @return id of the new record of the @a order
|
||||
*/
|
||||
virtual unsigned int insertOrder(const QSharedPointer<iOrder> &order) = 0;
|
||||
|
||||
/**
|
||||
* @brief makeOrder This method create a new record of the order into database.
|
||||
* @return new record of the order.
|
||||
*/
|
||||
virtual QSharedPointer<iOrder> makeOrder() = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Remove an order from the database by its ID.
|
||||
* @param id The ID of the order to remove.
|
||||
*/
|
||||
virtual void removeOrder(int id) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get a list of all images in the database.
|
||||
* @return A list of QSharedPointer<iImage> objects.
|
||||
*/
|
||||
virtual QList<QSharedPointer<iImage>> getAllImages() = 0;
|
||||
|
||||
/**
|
||||
* @brief Update old, or insert if not exists a new image to the database.
|
||||
* @param image The order object to add.
|
||||
*/
|
||||
virtual void saveImage(const QSharedPointer<iImage>& image) = 0;
|
||||
|
||||
/**
|
||||
* @brief Remove an image from the database by its ID.
|
||||
* @param id The ID of the image to remove.
|
||||
*/
|
||||
virtual void removeImage(const QString& id) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get an image by its ID.
|
||||
* @param id The ID of the image to retrieve.\
|
||||
* @param ifNotExistsCreate - this option will create a new object if object with @a id is not existst into database. But object wil not save into database.
|
||||
* @return A QSharedPointer to the image object if found, nullptr otherwise.
|
||||
*/
|
||||
virtual QSharedPointer<iImage> getImageById(const QString &id, bool ifNotExistsCreate = false) = 0;
|
||||
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif // IDATABASE_H
|
13
src/db/src/public/SecretDB/irecord.cpp
Normal file
13
src/db/src/public/SecretDB/irecord.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
//#
|
||||
//# 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 "irecord.h"
|
||||
namespace QASecret {
|
||||
|
||||
iRecord::iRecord() {}
|
||||
}
|
62
src/db/src/public/SecretDB/irecord.h
Normal file
62
src/db/src/public/SecretDB/irecord.h
Normal file
@ -0,0 +1,62 @@
|
||||
//#
|
||||
//# 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 IRECORD_H
|
||||
#define IRECORD_H
|
||||
|
||||
#include "global.h"
|
||||
|
||||
namespace QASecret {
|
||||
|
||||
/**
|
||||
* @brief The iRecord class This is main interface for all records of database
|
||||
*/
|
||||
class SECRETDB_EXPORT iRecord
|
||||
{
|
||||
public:
|
||||
iRecord();
|
||||
|
||||
/**
|
||||
* @brief getAlias returns alias of the record.
|
||||
* @return record alias.
|
||||
*/
|
||||
virtual const QString& getAlias() const = 0;
|
||||
|
||||
/**
|
||||
* @brief setAlias This method sets new alias for record.
|
||||
* @param alias is a new vlaue of record
|
||||
*/
|
||||
virtual void setAlias(const QString& alias) = 0;
|
||||
|
||||
/**
|
||||
* @brief getHash return hash of data
|
||||
* @return hash of record
|
||||
*/
|
||||
virtual const QByteArray& getHash() const = 0;
|
||||
|
||||
/**
|
||||
* @brief setHash This method sets new hash of record.
|
||||
* @param source is raw data sources of iamge.
|
||||
*/
|
||||
virtual void setHash(const QByteArray& source) = 0;
|
||||
|
||||
/**
|
||||
* @brief getData This method returns data of the record.
|
||||
* @return source secret data of record
|
||||
*/
|
||||
virtual const QByteArray& getData() const = 0;
|
||||
|
||||
/**
|
||||
* @brief setData This method sets new data of record.
|
||||
* @param newData this is new value of data.
|
||||
*/
|
||||
virtual void setData(const QByteArray& newData) = 0;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // IRECORD_H
|
32
src/db/src/sql/SecretDB_1.sql
Normal file
32
src/db/src/sql/SecretDB_1.sql
Normal file
@ -0,0 +1,32 @@
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "ProcessedIds" (
|
||||
"id" BIGINT NOT NULL UNIQUE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "Orders" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY,
|
||||
"time" INTEGER NOT NULL,
|
||||
"finishTime" INTEGER NOT NULL,
|
||||
"accepted" BOOLEAN NOT NULL DEFAULT false,
|
||||
"done" BOOLEAN NOT NULL DEFAULT false,
|
||||
"delivered" BOOLEAN NOT NULL DEFAULT false,
|
||||
"courier" INTEGER DEFAULT NULL,
|
||||
"receiver" INTEGER DEFAULT NULL,
|
||||
"manufacturer" INTEGER DEFAULT NULL,
|
||||
"data" BLOB NOT NULL,
|
||||
|
||||
FOREIGN KEY (courier) REFERENCES Users(id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE,
|
||||
|
||||
FOREIGN KEY (receiver) REFERENCES Users(id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE,
|
||||
|
||||
FOREIGN KEY (manufacturer) REFERENCES Users(id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
COMMIT;
|
67
src/db/yourtimebot.cpp
Normal file
67
src/db/yourtimebot.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
//#
|
||||
//# Copyright (C) 2023-2023 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 "yourtimebot.h"
|
||||
|
||||
#include <qTbot/messages/telegramupdate.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <locales.h>
|
||||
|
||||
YourTimeBot::YourTimeBot(const QSharedPointer<YourTimeDeliviry::IDataBase> &db) {
|
||||
_db = db;
|
||||
|
||||
connect(this, &YourTimeBot::sigReceiveUpdate, this, &YourTimeBot::handleIncomeNewUpdate);
|
||||
}
|
||||
|
||||
bool YourTimeBot::login(const QByteArray &token) {
|
||||
|
||||
if (!_db)
|
||||
return false;
|
||||
|
||||
setProcessed(_db->getProcessedIds());
|
||||
|
||||
|
||||
if(!QuasarAppUtils::Locales::init( {QLocale::English,
|
||||
QLocale::Russian,
|
||||
QLocale::Ukrainian,
|
||||
QLocale::Serbian}, {
|
||||
":/YourTime/languages/"
|
||||
}
|
||||
)){
|
||||
return false;
|
||||
}
|
||||
|
||||
return qTbot::TelegramRestBot::login(token);
|
||||
}
|
||||
|
||||
void YourTimeBot::handleIncomeNewUpdate(const QSharedPointer<qTbot::iUpdate> &update) {
|
||||
|
||||
if (auto&& tupdate = update.dynamicCast<qTbot::TelegramUpdate>()) {
|
||||
if (tupdate->contains(tupdate->MessageUpdate)) {
|
||||
auto mesg = tupdate->message();
|
||||
if (mesg->text() == "/start") {
|
||||
|
||||
sendMessage(mesg->chatId(), QuasarAppUtils::Locales::tr("This bot is still under development.",
|
||||
QLocale(mesg->languageCode())));
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
sendMessage(mesg->chatId(), QuasarAppUtils::Locales::tr("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.",
|
||||
QLocale(mesg->languageCode())));
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
|
||||
sendMessage(mesg->chatId(), QuasarAppUtils::Locales::tr("Thank you for your wait.",
|
||||
QLocale(mesg->languageCode())));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
markUpdateAsProcessed(update);
|
||||
_db->addProcessedId(update->updateId());
|
||||
}
|
32
src/db/yourtimebot.h
Normal file
32
src/db/yourtimebot.h
Normal file
@ -0,0 +1,32 @@
|
||||
//#
|
||||
//# Copyright (C) 2023-2023 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 YOURTIMEBOT_H
|
||||
#define YOURTIMEBOT_H
|
||||
|
||||
#include "YourTimeDeliviry/idatabase.h"
|
||||
#include <qTbot/telegramrestbot.h>
|
||||
|
||||
/**
|
||||
* @brief The YourTimeBot class
|
||||
*/
|
||||
class YourTimeBot: public qTbot::TelegramRestBot
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
YourTimeBot(const QSharedPointer<YourTimeDeliviry::IDataBase>& db);
|
||||
bool login(const QByteArray &token) override;
|
||||
// IBot interface
|
||||
protected:
|
||||
void handleIncomeNewUpdate(const QSharedPointer<qTbot::iUpdate> &update) override;
|
||||
|
||||
private:
|
||||
QSharedPointer<YourTimeDeliviry::IDataBase> _db;
|
||||
|
||||
};
|
||||
|
||||
#endif // YOURTIMEBOT_H
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>QuasarAppUtils::Locales</name>
|
||||
<message>
|
||||
<source>This bot is still under development.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>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.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Thank you for your wait.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
Loading…
x
Reference in New Issue
Block a user