added new interfaces and base implementations

This commit is contained in:
Andrei Yankovich 2023-08-30 19:25:28 +02:00
parent 353e06f1e4
commit 4456fd7c85
10 changed files with 224 additions and 10 deletions

View File

@ -24,7 +24,7 @@ if (ANDROID OR IOS)
set(BUILD_SHARED_LIBS ON)
endif()
find_package(Qt6 COMPONENTS Core REQUIRED)
find_package(Qt6 COMPONENTS Core Network REQUIRED)
find_package(Qt6 COMPONENTS Test QUIET)
include(submodules/CMake/QuasarApp.cmake)

View File

@ -4,11 +4,11 @@
"src/build/Debug/qTbotEaxample.exe"
],
"clear": true,
"binPrefix": "/media/D/builds/build-CMakeProject-Desktop_Qt_6_5_2_GCC_64bit-Debug",
"binPrefix": "/home/andrei/git/build-qTbot-Desktop_Qt_6_5_2_GCC_64bit-Debug",
"libDir": [
"/media/D/builds/CMakeProject",
"/home/andrei/git/qTbot",
"/home/andrei/Qt/6.5.2/gcc_64",
"/media/D/builds/build-CMakeProject-Desktop_Qt_6_5_2_GCC_64bit-Debug"
"/home/andrei/git/build-qTbot-Desktop_Qt_6_5_2_GCC_64bit-Debug"
],
"recursiveDepth": "10",
"deploySystem": false,
@ -17,11 +17,11 @@
"qif": true,
"zip": true,
"ignoreEnv": [
"/media/D/builds/CMakeProject/Distro"
"/home/andrei/git/qTbot/Distro"
],
"extraLib": "crypto",
"targetDir": "/media/D/builds/CMakeProject/Distro",
"deployVersion": "0.87.648a8dc",
"targetDir": "/home/andrei/git/qTbot/Distro",
"deployVersion": "0.2.353e06f",
}

View File

@ -23,9 +23,12 @@ file(GLOB_RECURSE SOURCE_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})
add_library(${CURRENT_PROJECT} ${SOURCE_CPP} ${SOURCE_QRC}
src/public/qTbot/itelegrambot.h src/public/qTbot/itelegrambot.cpp
src/public/qTbot/ibot.h src/public/qTbot/ibot.cpp
src/public/qTbot/imessage.h src/public/qTbot/imessage.cpp)
target_link_libraries(${CURRENT_PROJECT} PUBLIC Qt${QT_VERSION_MAJOR}::Core )
target_link_libraries(${CURRENT_PROJECT} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Network)
target_include_directories(${CURRENT_PROJECT} PUBLIC ${PUBLIC_INCUDE_DIR})
target_include_directories(${CURRENT_PROJECT} PRIVATE ${PRIVATE_INCUDE_DIR})

View File

@ -10,7 +10,7 @@
#include <QtCore/qglobal.h>
#define QTBOT_VERSION "0.87.648a8dc"
#define QTBOT_VERSION "0.2.353e06f"
#if defined(QTBOT_LIBRARY)
# define QTBOT_EXPORT Q_DECL_EXPORT

View File

@ -0,0 +1,25 @@
#include "ibot.h"
namespace qTbot {
IBot::IBot()
{
}
QByteArray &IBot::token() const {
return _token;
}
void IBot::setToken(const QByteArray &newToken) {
_token = newToken;
}
QString IBot::name() const {
return _name;
}
void IBot::setName(const QString &newName) {
_name = newName;
}
}

View File

@ -0,0 +1,70 @@
//#
//# Copyright (C) 2021-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 IBOT_H
#define IBOT_H
#include "qTbot/global.h"
#include "qTbot/imessage.h"
#include <QSharedPointer>
namespace qTbot {
/**
* @brief The IBot class Base interface for all chat-bots objcts.
*/
class QTBOT_EXPORT IBot
{
public:
IBot();
/**
* @brief sendMessage This method should be send message to the server.
* @param message This is data for sending.
* @return true if the message sent successful else false.
*/
virtual bool sendMessage(const QSharedPointer<iMessage>& message) = 0;
/**
* @brief token This is token value for authication on the remote server (bot)
* @return auth toke of the bot.
*/
QByteArray &token() const;
/**
* @brief setToken This is setter of the IBot::token value.
* @param newToken This is new value of the token.
*/
void setToken(const QByteArray &newToken);
/**
* @brief name This is name of the bot. usualy it fields will be received from the server after autication.
* @return
*/
QString name() const;
/**
* @brief setName This method sets new value for the IBot::name field.
* @param newName
*/
void setName(const QString &newName);
private:
QByteArray& _token;
QString _name;
signals:
/**
* @brief receiveMessage emit when but receive any updates from users.
*/
void receiveMessage(QSharedPointer<iMessage> );
};
}
#endif // IBOT_H

View File

@ -0,0 +1,21 @@
#include "imessage.h"
iMessage::iMessage() {
}
const QByteArray& iMessage::rawData() const {
return _rawData;
}
void iMessage::setRawData(const QByteArray &newRawData) {
_rawData = newRawData;
}
const QByteArray &iMessage::userId() const {
return _userId;
}
void iMessage::setUserId(const QByteArray &newUserId) {
_userId = newUserId;
}

View File

@ -0,0 +1,54 @@
//#
//# Copyright (C) 2021-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 IMESSAGE_H
#define IMESSAGE_H
#include "qTbot/global.h"
#include <QByteArray>
/**
* @brief The iMessage class - is main interface for all messages objects.
*/
class QTBOT_EXPORT iMessage
{
public:
iMessage();
/**
* @brief rawData returns raw data of the message.
* The raw data is not parsed value form the server.
* @return raw data from the server.
*/
const QByteArray &rawData() const;
/**
* @brief setRawData This method sets new raw data value.
* @param newRawData This is new value of the rawData.
*/
void setRawData(const QByteArray &newRawData);
/**
* @brief userId This is id of user that sent this message or must be receive this.
* @return user id.
*/
const QByteArray& userId() const;
/**
* @brief setUserId This method sets new value of the message user.
* @param newUserId This new value of user.
*/
void setUserId(const QByteArray &newUserId);
private:
QByteArray _rawData;
QByteArray _userId;
};
#endif // IMESSAGE_H

View File

@ -0,0 +1,6 @@
#include "itelegrambot.h"
iTelegramBot::iTelegramBot()
{
}

View File

@ -0,0 +1,35 @@
//#
//# Copyright (C) 2021-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 ITELEGRAMBOT_H
#define ITELEGRAMBOT_H
#include "qTbot/global.h"
#include "qTbot/imessage.h"
#include <QSharedPointer>
namespace qTbot {
struct TelegramMessage
{
};
class QTBOT_EXPORT iTelegramBot
{
public:
iTelegramBot();
virtual const QString& name() const;
virtual const QByteArray& token() const;
signals:
};
}
#endif // ITELEGRAMBOT_H