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
|
|
|
|
2023-06-27 12:10:59 +01:00
|
|
|
#include "kdeconnectconfig.h"
|
2013-09-09 17:35:56 +01:00
|
|
|
#include "loopbacklinkprovider.h"
|
2013-07-03 02:52:44 +01:00
|
|
|
|
2023-06-27 12:10:59 +01:00
|
|
|
LoopbackDeviceLink::LoopbackDeviceLink(LoopbackLinkProvider *parent)
|
|
|
|
: DeviceLink(KdeConnectConfig::instance().deviceId(), parent)
|
2013-07-03 02:52:44 +01:00
|
|
|
{
|
|
|
|
}
|
2013-08-30 18:07:08 +01:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
bool LoopbackDeviceLink::sendPacket(NetworkPacket &input)
|
2013-08-30 18:07:08 +01:00
|
|
|
{
|
2023-06-27 12:15:11 +01:00
|
|
|
NetworkPacket output;
|
2018-03-04 19:48:51 +00:00
|
|
|
NetworkPacket::unserialize(input.serialize(), &output);
|
2013-08-30 18:07:08 +01:00
|
|
|
|
2022-09-10 22:23:52 +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;
|
|
|
|
}
|
2023-06-27 12:10:59 +01:00
|
|
|
|
|
|
|
DeviceInfo LoopbackDeviceLink::deviceInfo() const
|
|
|
|
{
|
|
|
|
return KdeConnectConfig::instance().deviceInfo();
|
|
|
|
}
|