kdeconnect-kde/core/backends/loopback/loopbackdevicelink.cpp
Albert Vaca Cintora db546e7608 Add DeviceInfo class
Equivalent to this Android MR (see description there): https://invent.kde.org/network/kdeconnect-android/-/merge_requests/374
2023-06-27 11:10:59 +00:00

37 lines
972 B
C++

/**
* SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "loopbackdevicelink.h"
#include "kdeconnectconfig.h"
#include "loopbacklinkprovider.h"
LoopbackDeviceLink::LoopbackDeviceLink(LoopbackLinkProvider *parent)
: DeviceLink(KdeConnectConfig::instance().deviceId(), parent)
{
}
bool LoopbackDeviceLink::sendPacket(NetworkPacket &input)
{
NetworkPacket output((QString()));
NetworkPacket::unserialize(input.serialize(), &output);
// LoopbackDeviceLink does not need deviceTransferInfo
if (input.hasPayload()) {
bool b = input.payload()->open(QIODevice::ReadOnly);
Q_ASSERT(b);
output.setPayload(input.payload(), input.payloadSize());
}
Q_EMIT receivedPacket(output);
return true;
}
DeviceInfo LoopbackDeviceLink::deviceInfo() const
{
return KdeConnectConfig::instance().deviceInfo();
}