File indexing completed on 2024-05-12 04:58:53

0001 /**
0002  * SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #include "loopbackdevicelink.h"
0008 
0009 #include "kdeconnectconfig.h"
0010 #include "loopbacklinkprovider.h"
0011 
0012 LoopbackDeviceLink::LoopbackDeviceLink(LoopbackLinkProvider *parent)
0013     : DeviceLink(KdeConnectConfig::instance().deviceId(), parent)
0014 {
0015 }
0016 
0017 bool LoopbackDeviceLink::sendPacket(NetworkPacket &input)
0018 {
0019     NetworkPacket output;
0020     NetworkPacket::unserialize(input.serialize(), &output);
0021 
0022     // LoopbackDeviceLink does not need deviceTransferInfo
0023     if (input.hasPayload()) {
0024         bool b = input.payload()->open(QIODevice::ReadOnly);
0025         Q_ASSERT(b);
0026         output.setPayload(input.payload(), input.payloadSize());
0027     }
0028 
0029     Q_EMIT receivedPacket(output);
0030 
0031     return true;
0032 }
0033 
0034 DeviceInfo LoopbackDeviceLink::deviceInfo() const
0035 {
0036     return KdeConnectConfig::instance().deviceInfo();
0037 }
0038 
0039 #include "moc_loopbackdevicelink.cpp"