-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
testdevice.cpp
40 lines (34 loc) · 1023 Bytes
/
testdevice.cpp
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
/**
* SPDX-FileCopyrightText: 2015 Holger Kaelberer <[email protected]>
* SPDX-FileCopyrightText: 2019 Simon Redman <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "testdevice.h"
TestDevice::TestDevice(QObject *parent, const QString &id)
: Device(parent, id)
, sentPackets(0)
, lastPacket(nullptr)
{
}
TestDevice::~TestDevice()
{
delete lastPacket;
}
bool TestDevice::isReachable() const
{
return true;
}
bool TestDevice::sendPacket(NetworkPacket &np)
{
++sentPackets;
// copy packet manually to allow for inspection (can't use copy-constructor)
deleteLastPacket();
lastPacket = new NetworkPacket(np.type());
Q_ASSERT(lastPacket);
for (QVariantMap::ConstIterator iter = np.body().constBegin(); iter != np.body().constEnd(); iter++)
lastPacket->set(iter.key(), iter.value());
lastPacket->setPayload(np.payload(), np.payloadSize());
return true;
}
#include "moc_testdevice.cpp"