Commit f47f5178 authored by Albert Vaca Cintora's avatar Albert Vaca Cintora

Rename NetworkPackage -> NetworkPacket

Summary: KDE Connect, now with correct naming!

Test Plan: It still builds.

Reviewers: #kde_connect, apol, nicolasfella

Reviewed By: #kde_connect, apol, nicolasfella

Subscribers: nicolasfella

Differential Revision: https://phabricator.kde.org/D11036
parent d58f6cf2
......@@ -31,7 +31,7 @@ set(kdeconnectcore_SRCS
kdeconnectconfig.cpp
dbushelper.cpp
networkpackage.cpp
networkpacket.cpp
filetransferjob.cpp
daemon.cpp
device.cpp
......
......@@ -48,10 +48,10 @@ QString BluetoothDeviceLink::name()
return "BluetoothLink"; // Should be same in both android and kde version
}
bool BluetoothDeviceLink::sendPackage(NetworkPackage& np)
bool BluetoothDeviceLink::sendPacket(NetworkPacket& np)
{
if (np.hasPayload()) {
qCWarning(KDECONNECT_CORE) << "Sending packages with payload over bluetooth not yet supported";
qCWarning(KDECONNECT_CORE) << "Sending packets with payload over bluetooth not yet supported";
/*
BluetoothUploadJob* uploadJob = new BluetoothUploadJob(np.payload(), mBluetoothSocket->peerAddress(), this);
np.setPayloadTransferInfo(uploadJob->transferInfo());
......@@ -78,27 +78,27 @@ void BluetoothDeviceLink::dataReceived()
{
if (mSocketReader->bytesAvailable() == 0) return;
const QByteArray serializedPackage = mSocketReader->readLine();
const QByteArray serializedPacket = mSocketReader->readLine();
//qCDebug(KDECONNECT_CORE) << "BluetoothDeviceLink dataReceived" << package;
//qCDebug(KDECONNECT_CORE) << "BluetoothDeviceLink dataReceived" << packet;
NetworkPackage package(QString::null);
NetworkPackage::unserialize(serializedPackage, &package);
NetworkPacket packet(QString::null);
NetworkPacket::unserialize(serializedPacket, &packet);
if (package.type() == PACKAGE_TYPE_PAIR) {
if (packet.type() == PACKET_TYPE_PAIR) {
//TODO: Handle pair/unpair requests and forward them (to the pairing handler?)
mPairingHandler->packageReceived(package);
mPairingHandler->packetReceived(packet);
return;
}
if (package.hasPayloadTransferInfo()) {
if (packet.hasPayloadTransferInfo()) {
BluetoothDownloadJob* downloadJob = new BluetoothDownloadJob(mBluetoothSocket->peerAddress(),
package.payloadTransferInfo(), this);
packet.payloadTransferInfo(), this);
downloadJob->start();
package.setPayload(downloadJob->payload(), package.payloadSize());
packet.setPayload(downloadJob->payload(), packet.payloadSize());
}
Q_EMIT receivedPackage(package);
Q_EMIT receivedPacket(packet);
if (mSocketReader->bytesAvailable() > 0) {
QMetaObject::invokeMethod(this, "dataReceived", Qt::QueuedConnection);
......
......@@ -38,7 +38,7 @@ public:
BluetoothDeviceLink(const QString& deviceId, LinkProvider* parent, QBluetoothSocket* socket);
virtual QString name() override;
bool sendPackage(NetworkPackage& np) override;
bool sendPacket(NetworkPacket& np) override;
virtual void userRequestsPair() override;
virtual void userRequestsUnpair() override;
......
......@@ -172,27 +172,27 @@ void BluetoothLinkProvider::clientIdentityReceived()
disconnect(socket, SIGNAL(readyRead()), this, SLOT(clientIdentityReceived()));
NetworkPackage receivedPackage("");
bool success = NetworkPackage::unserialize(identityArray, &receivedPackage);
NetworkPacket receivedPacket("");
bool success = NetworkPacket::unserialize(identityArray, &receivedPacket);
if (!success || receivedPackage.type() != PACKAGE_TYPE_IDENTITY) {
qCWarning(KDECONNECT_CORE) << "Not an identity package";
if (!success || receivedPacket.type() != PACKET_TYPE_IDENTITY) {
qCWarning(KDECONNECT_CORE) << "Not an identity packet";
mSockets.remove(socket->peerAddress());
socket->close();
socket->deleteLater();
return;
}
qCDebug(KDECONNECT_CORE()) << "Received identity package from" << socket->peerAddress();
qCDebug(KDECONNECT_CORE()) << "Received identity packet from" << socket->peerAddress();
disconnect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(connectError()));
const QString& deviceId = receivedPackage.get<QString>("deviceId");
const QString& deviceId = receivedPacket.get<QString>("deviceId");
BluetoothDeviceLink* deviceLink = new BluetoothDeviceLink(deviceId, this, socket);
NetworkPackage np2("");
NetworkPackage::createIdentityPackage(&np2);
success = deviceLink->sendPackage(np2);
NetworkPacket np2("");
NetworkPacket::createIdentityPacket(&np2);
success = deviceLink->sendPacket(np2);
if (success) {
......@@ -201,7 +201,7 @@ void BluetoothLinkProvider::clientIdentityReceived()
connect(deviceLink, SIGNAL(destroyed(QObject*)),
this, SLOT(deviceLinkDestroyed(QObject*)));
Q_EMIT onConnectionReceived(receivedPackage, deviceLink);
Q_EMIT onConnectionReceived(receivedPacket, deviceLink);
//We kill any possible link from this same device
addLink(deviceLink, deviceId);
......@@ -232,16 +232,16 @@ void BluetoothLinkProvider::serverNewConnection()
connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(connectError()));
connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
NetworkPackage np2("");
NetworkPackage::createIdentityPackage(&np2);
NetworkPacket np2("");
NetworkPacket::createIdentityPacket(&np2);
socket->write(np2.serialize());
qCDebug(KDECONNECT_CORE()) << "Sent identity package to" << socket->peerAddress();
qCDebug(KDECONNECT_CORE()) << "Sent identity packet to" << socket->peerAddress();
mSockets.insert(socket->peerAddress(), socket);
}
//I'm the existing device and this is the answer to my identity package (data received)
//I'm the existing device and this is the answer to my identity packet (data received)
void BluetoothLinkProvider::serverDataReceived()
{
QBluetoothSocket* socket = qobject_cast<QBluetoothSocket*>(sender());
......@@ -255,26 +255,26 @@ void BluetoothLinkProvider::serverDataReceived()
disconnect(socket, SIGNAL(readyRead()), this, SLOT(serverDataReceived()));
disconnect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(connectError()));
NetworkPackage receivedPackage("");
bool success = NetworkPackage::unserialize(identityArray, &receivedPackage);
NetworkPacket receivedPacket("");
bool success = NetworkPacket::unserialize(identityArray, &receivedPacket);
if (!success || receivedPackage.type() != PACKAGE_TYPE_IDENTITY) {
qCWarning(KDECONNECT_CORE) << "Not an identity package.";
if (!success || receivedPacket.type() != PACKET_TYPE_IDENTITY) {
qCWarning(KDECONNECT_CORE) << "Not an identity packet.";
mSockets.remove(socket->peerAddress());
socket->close();
socket->deleteLater();
return;
}
qCDebug(KDECONNECT_CORE()) << "Received identity package from" << socket->peerAddress();
qCDebug(KDECONNECT_CORE()) << "Received identity packet from" << socket->peerAddress();
const QString& deviceId = receivedPackage.get<QString>("deviceId");
const QString& deviceId = receivedPacket.get<QString>("deviceId");
BluetoothDeviceLink* deviceLink = new BluetoothDeviceLink(deviceId, this, socket);
connect(deviceLink, SIGNAL(destroyed(QObject*)),
this, SLOT(deviceLinkDestroyed(QObject*)));
Q_EMIT onConnectionReceived(receivedPackage, deviceLink);
Q_EMIT onConnectionReceived(receivedPacket, deviceLink);
addLink(deviceLink, deviceId);
}
......
......@@ -24,7 +24,7 @@
#include "daemon.h"
#include "kdeconnectconfig.h"
#include "bluetoothpairinghandler.h"
#include "networkpackagetypes.h"
#include "networkpackettypes.h"
BluetoothPairingHandler::BluetoothPairingHandler(DeviceLink* deviceLink)
: PairingHandler(deviceLink)
......@@ -35,9 +35,9 @@ BluetoothPairingHandler::BluetoothPairingHandler(DeviceLink* deviceLink)
connect(&m_pairingTimeout, &QTimer::timeout, this, &BluetoothPairingHandler::pairingTimeout);
}
void BluetoothPairingHandler::packageReceived(const NetworkPackage& np)
void BluetoothPairingHandler::packetReceived(const NetworkPacket& np)
{
qCDebug(KDECONNECT_CORE) << "Pairing package received!" << np.serialize();
qCDebug(KDECONNECT_CORE) << "Pairing packet received!" << np.serialize();
m_pairingTimeout.stop();
......@@ -89,10 +89,10 @@ bool BluetoothPairingHandler::requestPairing()
;
}
NetworkPackage np(PACKAGE_TYPE_PAIR);
NetworkPacket np(PACKET_TYPE_PAIR);
np.set("pair", true);
bool success;
success = deviceLink()->sendPackage(np);
success = deviceLink()->sendPacket(np);
if (success) {
setInternalPairStatus(Requested);
m_pairingTimeout.start();
......@@ -104,9 +104,9 @@ bool BluetoothPairingHandler::acceptPairing()
{
qCDebug(KDECONNECT_CORE) << "User accepts pairing";
m_pairingTimeout.stop(); // Just in case it is started
NetworkPackage np(PACKAGE_TYPE_PAIR);
NetworkPacket np(PACKET_TYPE_PAIR);
np.set("pair", true);
bool success = deviceLink()->sendPackage(np);
bool success = deviceLink()->sendPacket(np);
if (success) {
setInternalPairStatus(Paired);
}
......@@ -116,24 +116,24 @@ bool BluetoothPairingHandler::acceptPairing()
void BluetoothPairingHandler::rejectPairing()
{
qCDebug(KDECONNECT_CORE) << "User rejects pairing";
NetworkPackage np(PACKAGE_TYPE_PAIR);
NetworkPacket np(PACKET_TYPE_PAIR);
np.set("pair", false);
deviceLink()->sendPackage(np);
deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired);
}
void BluetoothPairingHandler::unpair() {
NetworkPackage np(PACKAGE_TYPE_PAIR);
NetworkPacket np(PACKET_TYPE_PAIR);
np.set("pair", false);
deviceLink()->sendPackage(np);
deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired);
}
void BluetoothPairingHandler::pairingTimeout()
{
NetworkPackage np(PACKAGE_TYPE_PAIR);
NetworkPacket np(PACKET_TYPE_PAIR);
np.set("pair", false);
deviceLink()->sendPackage(np);
deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired); //Will emit the change as well
Q_EMIT pairingError(i18n("Timed out"));
}
......
......@@ -27,7 +27,7 @@
#include <QTimer>
// This class is used pairing related stuff. It has direct access to links and can directly send packages
// This class is used pairing related stuff. It has direct access to links and can directly send packets
class BluetoothPairingHandler
: public PairingHandler
{
......@@ -43,7 +43,7 @@ public:
BluetoothPairingHandler(DeviceLink* deviceLink);
virtual ~BluetoothPairingHandler() { }
virtual void packageReceived(const NetworkPackage& np) Q_DECL_OVERRIDE;
virtual void packetReceived(const NetworkPacket& np) Q_DECL_OVERRIDE;
virtual bool requestPairing() Q_DECL_OVERRIDE;
virtual bool acceptPairing() Q_DECL_OVERRIDE;
virtual void rejectPairing() Q_DECL_OVERRIDE;
......
......@@ -36,7 +36,7 @@ void DeviceLineReader::dataReceived()
while(m_device->canReadLine()) {
const QByteArray line = m_device->readLine();
if (line.length() > 1) {
m_packages.enqueue(line);//we don't want single \n
m_packets.enqueue(line);//we don't want single \n
}
}
......@@ -48,8 +48,8 @@ void DeviceLineReader::dataReceived()
return;
}
//If we have any packages, tell it to the world.
if (!m_packages.isEmpty()) {
//If we have any packets, tell it to the world.
if (!m_packets.isEmpty()) {
Q_EMIT readyRead();
}
}
......@@ -39,9 +39,9 @@ class DeviceLineReader
public:
DeviceLineReader(QIODevice* device, QObject* parent = 0);
QByteArray readLine() { return m_packages.dequeue(); }
QByteArray readLine() { return m_packets.dequeue(); }
qint64 write(const QByteArray& data) { return m_device->write(data); }
qint64 bytesAvailable() const { return m_packages.size(); }
qint64 bytesAvailable() const { return m_packets.size(); }
Q_SIGNALS:
void readyRead();
......@@ -53,7 +53,7 @@ private Q_SLOTS:
private:
QByteArray m_lastChunk;
QIODevice* m_device;
QQueue<QByteArray> m_packages;
QQueue<QByteArray> m_packets;
};
......
......@@ -24,10 +24,10 @@
#include <QObject>
#include <QtCrypto>
#include "core/networkpackage.h"
#include "core/networkpacket.h"
class PairingHandler;
class NetworkPackage;
class NetworkPacket;
class LinkProvider;
class Device;
......@@ -47,7 +47,7 @@ public:
const QString& deviceId() const { return m_deviceId; }
LinkProvider* provider() { return m_linkProvider; }
virtual bool sendPackage(NetworkPackage& np) = 0;
virtual bool sendPacket(NetworkPacket& np) = 0;
//user actions
virtual void userRequestsPair() = 0;
......@@ -64,7 +64,7 @@ Q_SIGNALS:
void pairingRequestExpired(PairingHandler* handler);
void pairStatusChanged(DeviceLink::PairStatus status);
void pairingError(const QString& error);
void receivedPackage(const NetworkPackage& np);
void receivedPacket(const NetworkPacket& np);
protected:
QCA::PrivateKey m_privateKey;
......
......@@ -82,7 +82,7 @@ QString LanDeviceLink::name()
return QStringLiteral("LanLink"); // Should be same in both android and kde version
}
bool LanDeviceLink::sendPackage(NetworkPackage& np)
bool LanDeviceLink::sendPacket(NetworkPacket& np)
{
if (np.hasPayload()) {
np.setPayloadTransferInfo(sendPayload(np)->transferInfo());
......@@ -90,13 +90,13 @@ bool LanDeviceLink::sendPackage(NetworkPackage& np)
int written = m_socketLineReader->write(np.serialize());
//Actually we can't detect if a package is received or not. We keep TCP
//Actually we can't detect if a packet is received or not. We keep TCP
//"ESTABLISHED" connections that look legit (return true when we use them),
//but that are actually broken (until keepalive detects that they are down).
return (written != -1);
}
UploadJob* LanDeviceLink::sendPayload(const NetworkPackage& np)
UploadJob* LanDeviceLink::sendPayload(const NetworkPacket& np)
{
UploadJob* job = new UploadJob(np.payload(), deviceId());
job->start();
......@@ -107,30 +107,30 @@ void LanDeviceLink::dataReceived()
{
if (m_socketLineReader->bytesAvailable() == 0) return;
const QByteArray serializedPackage = m_socketLineReader->readLine();
NetworkPackage package(QString::null);
NetworkPackage::unserialize(serializedPackage, &package);
const QByteArray serializedPacket = m_socketLineReader->readLine();
NetworkPacket packet(QString::null);
NetworkPacket::unserialize(serializedPacket, &packet);
//qCDebug(KDECONNECT_CORE) << "LanDeviceLink dataReceived" << serializedPackage;
//qCDebug(KDECONNECT_CORE) << "LanDeviceLink dataReceived" << serializedPacket;
if (package.type() == PACKAGE_TYPE_PAIR) {
if (packet.type() == PACKET_TYPE_PAIR) {
//TODO: Handle pair/unpair requests and forward them (to the pairing handler?)
qobject_cast<LanLinkProvider*>(provider())->incomingPairPackage(this, package);
qobject_cast<LanLinkProvider*>(provider())->incomingPairPacket(this, packet);
return;
}
if (package.hasPayloadTransferInfo()) {
if (packet.hasPayloadTransferInfo()) {
//qCDebug(KDECONNECT_CORE) << "HasPayloadTransferInfo";
QVariantMap transferInfo = package.payloadTransferInfo();
QVariantMap transferInfo = packet.payloadTransferInfo();
//FIXME: The next two lines shouldn't be needed! Why are they here?
transferInfo.insert(QStringLiteral("useSsl"), true);
transferInfo.insert(QStringLiteral("deviceId"), deviceId());
DownloadJob* job = new DownloadJob(m_socketLineReader->peerAddress(), transferInfo);
job->start();
package.setPayload(job->getPayload(), package.payloadSize());
packet.setPayload(job->getPayload(), packet.payloadSize());
}
Q_EMIT receivedPackage(package);
Q_EMIT receivedPacket(packet);
if (m_socketLineReader->bytesAvailable() > 0) {
QMetaObject::invokeMethod(this, "dataReceived", Qt::QueuedConnection);
......
......@@ -44,8 +44,8 @@ public:
void reset(QSslSocket* socket, ConnectionStarted connectionSource);
QString name() override;
bool sendPackage(NetworkPackage& np) override;
UploadJob* sendPayload(const NetworkPackage& np);
bool sendPacket(NetworkPacket& np) override;
UploadJob* sendPayload(const NetworkPacket& np);
void userRequestsPair() override;
void userRequestsUnpair() override;
......
This diff is collapsed.
......@@ -49,7 +49,7 @@ public:
void userRequestsPair(const QString& deviceId);
void userRequestsUnpair(const QString& deviceId);
void incomingPairPackage(DeviceLink* device, const NetworkPackage& np);
void incomingPairPacket(DeviceLink* device, const NetworkPacket& np);
static void configureSslSocket(QSslSocket* socket, const QString& deviceId, bool isDeviceTrusted);
static void configureSocket(QSslSocket* socket);
......@@ -78,7 +78,7 @@ private:
LanPairingHandler* createPairingHandler(DeviceLink* link);
void onNetworkConfigurationChanged(const QNetworkConfiguration& config);
void addLink(const QString& deviceId, QSslSocket* socket, NetworkPackage* receivedPackage, LanDeviceLink::ConnectionStarted connectionOrigin);
void addLink(const QString& deviceId, QSslSocket* socket, NetworkPacket* receivedPacket, LanDeviceLink::ConnectionStarted connectionOrigin);
Server* m_server;
QUdpSocket m_udpSocket;
......@@ -88,10 +88,10 @@ private:
QMap<QString, LanPairingHandler*> m_pairingHandlers;
struct PendingConnect {
NetworkPackage* np;
NetworkPacket* np;
QHostAddress sender;
};
QMap<QSslSocket*, PendingConnect> m_receivedIdentityPackages;
QMap<QSslSocket*, PendingConnect> m_receivedIdentityPackets;
QNetworkConfiguration m_lastConfig;
const bool m_testMode;
QTimer m_combineBroadcastsTimer;
......
......@@ -25,7 +25,7 @@
#include "kdeconnectconfig.h"
#include "landevicelink.h"
#include "lanpairinghandler.h"
#include "networkpackagetypes.h"
#include "networkpackettypes.h"
LanPairingHandler::LanPairingHandler(DeviceLink* deviceLink)
: PairingHandler(deviceLink)
......@@ -36,7 +36,7 @@ LanPairingHandler::LanPairingHandler(DeviceLink* deviceLink)
connect(&m_pairingTimeout, &QTimer::timeout, this, &LanPairingHandler::pairingTimeout);
}
void LanPairingHandler::packageReceived(const NetworkPackage& np)
void LanPairingHandler::packetReceived(const NetworkPacket& np)
{
bool wantsPair = np.get<bool>(QStringLiteral("pair"));
......@@ -80,8 +80,8 @@ bool LanPairingHandler::requestPairing()
return acceptPairing();
}
NetworkPackage np(PACKAGE_TYPE_PAIR, {{"pair", true}});
const bool success = deviceLink()->sendPackage(np);
NetworkPacket np(PACKET_TYPE_PAIR, {{"pair", true}});
const bool success = deviceLink()->sendPacket(np);
if (success) {
setInternalPairStatus(Requested);
}
......@@ -90,8 +90,8 @@ bool LanPairingHandler::requestPairing()
bool LanPairingHandler::acceptPairing()
{
NetworkPackage np(PACKAGE_TYPE_PAIR, {{"pair", true}});
bool success = deviceLink()->sendPackage(np);
NetworkPacket np(PACKET_TYPE_PAIR, {{"pair", true}});
bool success = deviceLink()->sendPacket(np);
if (success) {
setInternalPairStatus(Paired);
}
......@@ -100,21 +100,21 @@ bool LanPairingHandler::acceptPairing()
void LanPairingHandler::rejectPairing()
{
NetworkPackage np(PACKAGE_TYPE_PAIR, {{"pair", false}});
deviceLink()->sendPackage(np);
NetworkPacket np(PACKET_TYPE_PAIR, {{"pair", false}});
deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired);
}
void LanPairingHandler::unpair() {
NetworkPackage np(PACKAGE_TYPE_PAIR, {{"pair", false}});
deviceLink()->sendPackage(np);
NetworkPacket np(PACKET_TYPE_PAIR, {{"pair", false}});
deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired);
}
void LanPairingHandler::pairingTimeout()
{
NetworkPackage np(PACKAGE_TYPE_PAIR, {{"pair", false}});
deviceLink()->sendPackage(np);
NetworkPacket np(PACKET_TYPE_PAIR, {{"pair", false}});
deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired); //Will emit the change as well
Q_EMIT pairingError(i18n("Timed out"));
}
......
......@@ -28,7 +28,7 @@
#include "backends/devicelink.h"
#include "backends/pairinghandler.h"
// This class is used pairing related stuff. It has direct access to links and can directly send packages
// This class is used pairing related stuff. It has direct access to links and can directly send packets
class LanPairingHandler
: public PairingHandler
{
......@@ -46,7 +46,7 @@ public:
LanPairingHandler(DeviceLink* deviceLink);
~LanPairingHandler() override { }
void packageReceived(const NetworkPackage& np) override;
void packetReceived(const NetworkPacket& np) override;
bool requestPairing() override;
bool acceptPairing() override;
void rejectPairing() override;
......
......@@ -34,7 +34,7 @@ void SocketLineReader::dataReceived()
while (m_socket->canReadLine()) {
const QByteArray line = m_socket->readLine();
if (line.length() > 1) { //we don't want a single \n
m_packages.enqueue(line);
m_packets.enqueue(line);
}
}
......@@ -46,8 +46,8 @@ void SocketLineReader::dataReceived()
return;
}
//If we have any packages, tell it to the world.
if (!m_packages.isEmpty()) {
//If we have any packets, tell it to the world.
if (!m_packets.isEmpty()) {
Q_EMIT readyRead();
}
}
......@@ -40,11 +40,11 @@ class KDECONNECTCORE_EXPORT SocketLineReader
public:
explicit SocketLineReader(QSslSocket* socket, QObject* parent = nullptr);
QByteArray readLine() { return m_packages.dequeue(); }
QByteArray readLine() { return m_packets.dequeue(); }
qint64 write(const QByteArray& data) { return m_socket->write(data); }
QHostAddress peerAddress() const { return m_socket->peerAddress(); }
QSslCertificate peerCertificate() const { return m_socket->peerCertificate(); }
qint64 bytesAvailable() const { return m_packages.size(); }
qint64 bytesAvailable() const { return m_packets.size(); }
QSslSocket* m_socket;
......@@ -56,7 +56,7 @@ private Q_SLOTS:
private:
QByteArray m_lastChunk;
QQueue<QByteArray> m_packages;
QQueue<QByteArray> m_packets;
};
......
......@@ -23,7 +23,7 @@
#include <QObject>
#include "core/networkpackage.h"
#include "core/networkpacket.h"
#include "pairinghandler.h"
class DeviceLink;
......@@ -54,7 +54,7 @@ Q_SIGNALS:
//NOTE: The provider will destroy the DeviceLink when it's no longer accessible,
// and every user should listen to the destroyed signal to remove its references.
// That's the reason because there is no "onConnectionLost".
void onConnectionReceived(const NetworkPackage& identityPackage, DeviceLink*) const;
void onConnectionReceived(const NetworkPacket& identityPacket, DeviceLink*) const;
};
......
......@@ -33,10 +33,10 @@ QString LoopbackDeviceLink::name()
return QStringLiteral("LoopbackLink");
}
bool LoopbackDeviceLink::sendPackage(NetworkPackage& input)
bool LoopbackDeviceLink::sendPacket(NetworkPacket& input)
{
NetworkPackage output(QString::null);
NetworkPackage::unserialize(input.serialize(), &output);
NetworkPacket output(QString::null);
NetworkPacket::unserialize(input.serialize(), &output);
//LoopbackDeviceLink does not need deviceTransferInfo
if (input.hasPayload()) {
......@@ -45,7 +45,7 @@ bool LoopbackDeviceLink::sendPackage(NetworkPackage& input)
output.setPayload(input.payload(), input.payloadSize());
}
Q_EMIT receivedPackage(output);
Q_EMIT receivedPacket(output);
return true;
}
......
......@@ -33,7 +33,7 @@ public:
LoopbackDeviceLink(const QString& d, LoopbackLinkProvider* a);
QString name() override;
bool sendPackage(NetworkPackage& np) override;
bool sendPacket(NetworkPacket& np) override;
void userRequestsPair() override { setPairStatus(Paired); }
void userRequestsUnpair() override { setPairStatus(NotPaired); }
......
......@@ -23,9 +23,9 @@
#include "core_debug.h"
LoopbackLinkProvider::LoopbackLinkProvider()
: identityPackage(PACKAGE_TYPE_IDENTITY)
: identityPacket(PACKET_TYPE_IDENTITY)
{
NetworkPackage::createIdentityPackage(&identityPackage);
NetworkPacket::createIdentityPacket(&identityPacket);
}
LoopbackLinkProvider::~LoopbackLinkProvider()
......@@ -36,7 +36,7 @@ LoopbackLinkProvider::~LoopbackLinkProvider()
void LoopbackLinkProvider::onNetworkChange()
{
LoopbackDeviceLink* newLoopbackDeviceLink = new LoopbackDeviceLink(QStringLiteral("loopback"), this);
Q_EMIT onConnectionReceived(identityPackage, newLoopbackDeviceLink);
Q_EMIT onConnectionReceived(identityPacket, newLoopbackDeviceLink);
if (loopbackDeviceLink) {
delete loopbackDeviceLink;
......
......@@ -42,7 +42,7 @@ public:
private:
QPointer<LoopbackDeviceLink> loopbackDeviceLink;
NetworkPackage identityPackage;
NetworkPacket identityPacket;
};
......