2013-06-06 04:57:06 +01:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
|
2013-06-06 04:57:06 +01:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2013-06-06 04:57:06 +01:00
|
|
|
*/
|
|
|
|
|
2013-08-28 22:47:39 +01:00
|
|
|
#include "loopbackdevicelink.h"
|
2013-07-03 02:52:44 +01:00
|
|
|
|
2013-09-09 17:35:56 +01:00
|
|
|
#include "loopbacklinkprovider.h"
|
2013-07-03 02:52:44 +01:00
|
|
|
|
2013-08-28 22:47:39 +01:00
|
|
|
LoopbackDeviceLink::LoopbackDeviceLink(const QString& deviceId, LoopbackLinkProvider* provider)
|
2016-01-10 15:12:13 +00:00
|
|
|
: DeviceLink(deviceId, provider)
|
2013-07-03 02:52:44 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2013-08-30 18:07:08 +01:00
|
|
|
|
2015-07-25 12:45:19 +01:00
|
|
|
QString LoopbackDeviceLink::name()
|
|
|
|
{
|
2016-11-26 14:38:08 +00:00
|
|
|
return QStringLiteral("LoopbackLink");
|
2015-07-25 12:45:19 +01:00
|
|
|
}
|
|
|
|
|
2018-03-04 19:48:51 +00:00
|
|
|
bool LoopbackDeviceLink::sendPacket(NetworkPacket& input)
|
2013-08-30 18:07:08 +01:00
|
|
|
{
|
2019-02-03 01:00:36 +00:00
|
|
|
NetworkPacket output((QString()));
|
2018-03-04 19:48:51 +00:00
|
|
|
NetworkPacket::unserialize(input.serialize(), &output);
|
2013-08-30 18:07:08 +01:00
|
|
|
|
2013-09-09 21:50:27 +01:00
|
|
|
//LoopbackDeviceLink does not need deviceTransferInfo
|
2013-09-09 17:35:56 +01:00
|
|
|
if (input.hasPayload()) {
|
2015-09-07 13:54:33 +01:00
|
|
|
bool b = input.payload()->open(QIODevice::ReadOnly);
|
|
|
|
Q_ASSERT(b);
|
2013-09-24 13:13:02 +01:00
|
|
|
output.setPayload(input.payload(), input.payloadSize());
|
2013-09-09 17:35:56 +01:00
|
|
|
}
|
|
|
|
|
2018-03-04 19:48:51 +00:00
|
|
|
Q_EMIT receivedPacket(output);
|
2013-08-30 18:07:08 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2013-09-13 22:27:16 +01:00
|
|
|
|