-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest.cpp
More file actions
56 lines (44 loc) · 874 Bytes
/
Copy pathrequest.cpp
File metadata and controls
56 lines (44 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "request.h"
#include "eros.pb.h"
Request::Request(Eros *parent, const QString &command)
: QObject(parent)
{
this->command_ = command;
this->eros_ = parent;
this->data_ = nullptr;
}
Request::~Request()
{
}
void Request::requestSent()
{
}
bool Request::processError(int code, const QByteArray &data)
{
emit error(this, code);
return true;
}
QBuffer *Request::serializeMessageToBuffer(::google::protobuf::Message *message)
{
QByteArray data;
data.resize(message->ByteSize());
if (message->SerializeToArray(data.data(), data.size()))
{
QBuffer *buffer = new QBuffer();
buffer->open(QIODevice::ReadWrite);
buffer->write(data);
buffer->seek(0);
buffer->close();
return buffer;
} else {
return nullptr;
}
}
const QString &Request::command() const
{
return this->command_;
}
QIODevice* Request::data() const
{
return this->data_;
}