mirror of
https://github.com/QuasarApp/Patronum.git
synced 2025-04-27 08:04:32 +00:00
fix test on Linux
This commit is contained in:
parent
61bce748e4
commit
680a77c010
@ -70,7 +70,10 @@ QDataStream &operator<<(QDataStream &stream, const Feature &obj) {
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &stream, Feature &obj) {
|
||||
stream >> obj._cmd >> obj._arg;
|
||||
decltype (obj._cmd) cmd;
|
||||
stream >> cmd >> obj._arg;
|
||||
obj.setCmd(cmd);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
@ -50,12 +50,7 @@ bool ControllerPrivate::sendFeaturesRequest() {
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray responce;
|
||||
QDataStream stream(&responce, QIODevice::WriteOnly);
|
||||
|
||||
stream << static_cast<quint8>(Command::FeaturesRequest);
|
||||
|
||||
return _socket->send(responce);
|
||||
return _socket->send(_parser->createPackage(Command::FeaturesRequest));
|
||||
}
|
||||
|
||||
bool ControllerPrivate::sendCmd(const QSet<Feature> &result) {
|
||||
@ -67,13 +62,7 @@ bool ControllerPrivate::sendCmd(const QSet<Feature> &result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray request;
|
||||
QDataStream stream(&request, QIODevice::WriteOnly);
|
||||
|
||||
stream << static_cast<quint8>(Command::Feature);
|
||||
stream << result;
|
||||
|
||||
if (_socket->send(request)) {
|
||||
if (_socket->send(_parser->createPackage(Command::Feature, result))) {
|
||||
_responce = false;
|
||||
return true;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ signals:
|
||||
void sigListFeatures(QList<Feature>);
|
||||
|
||||
private:
|
||||
|
||||
LocalSocket *_socket = nullptr;
|
||||
IController *_controller = nullptr;
|
||||
bool _responce = false;
|
||||
|
@ -22,10 +22,12 @@ bool Package::isValid() const {
|
||||
}
|
||||
|
||||
void Package::reset() {
|
||||
|
||||
m_hdr = {0, 0};
|
||||
m_data.clear();
|
||||
}
|
||||
|
||||
Package::Package() {
|
||||
reset();
|
||||
}
|
||||
|
||||
bool Header::isValid() const {
|
||||
|
@ -32,6 +32,7 @@ enum class Command: quint8 {
|
||||
/// This is response of the execute of command
|
||||
FeatureResponce,
|
||||
/// This command is finished command for the terminal. after receive this command terminal will closse connection.
|
||||
/// @note For Devs This commnad should be last in the enum. This commnad uses in te validation of header.
|
||||
CloseConnection
|
||||
};
|
||||
|
||||
|
@ -2,10 +2,7 @@
|
||||
#include <quasarapp.h>
|
||||
namespace Patronum {
|
||||
|
||||
Parser::Parser()
|
||||
{
|
||||
|
||||
}
|
||||
Parser::Parser() { }
|
||||
|
||||
bool Parser::parse(const QByteArray &array,
|
||||
QList<Package> &result) {
|
||||
|
@ -22,14 +22,14 @@ public:
|
||||
*/
|
||||
bool parse(const QByteArray& array, QList<Package>& result);
|
||||
|
||||
template<class DATA>
|
||||
template<class DATA = QByteArray>
|
||||
/**
|
||||
* @brief createPackage This method create a custom package with @a cmd and @a data
|
||||
* @param cmd This is package command.
|
||||
* @param data This is data object.
|
||||
* @return bytes arra of the package.
|
||||
*/
|
||||
QByteArray createPackage(Command cmd, const DATA &data) {
|
||||
QByteArray createPackage(Command cmd, const DATA &data = {}) {
|
||||
QByteArray result;
|
||||
QDataStream stream(&result, QIODevice::WriteOnly);
|
||||
|
||||
|
@ -51,12 +51,7 @@ bool ServicePrivate::sendCloseConnection() {
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray responce;
|
||||
QDataStream stream(&responce, QIODevice::WriteOnly);
|
||||
|
||||
stream << static_cast<quint8>(Command::CloseConnection);
|
||||
|
||||
return _socket->send(responce);
|
||||
return _socket->send(_parser->createPackage(Command::CloseConnection));
|
||||
}
|
||||
|
||||
void ServicePrivate::listen() const {
|
||||
@ -121,14 +116,8 @@ void ServicePrivate::handleReceve(QByteArray data) {
|
||||
|
||||
case Command::FeaturesRequest: {
|
||||
|
||||
QSet<Feature> features = _service->supportedFeatures();
|
||||
QByteArray sendData;
|
||||
QDataStream stream(&sendData, QIODevice::WriteOnly);
|
||||
|
||||
stream << static_cast<quint8>(Command::Features);
|
||||
stream << features;
|
||||
|
||||
if (!_socket->send(sendData)) {
|
||||
if (!_socket->send(_parser->createPackage(Command::Features,
|
||||
_service->supportedFeatures()))) {
|
||||
QuasarAppUtils::Params::log("Fail to send ",
|
||||
QuasarAppUtils::Error);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user