diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -31,7 +31,7 @@ kdeconnectconfig.cpp dbushelper.cpp - networkpackage.cpp + networkpacket.cpp filetransferjob.cpp daemon.cpp device.cpp diff --git a/core/backends/bluetooth/bluetoothdevicelink.h b/core/backends/bluetooth/bluetoothdevicelink.h --- a/core/backends/bluetooth/bluetoothdevicelink.h +++ b/core/backends/bluetooth/bluetoothdevicelink.h @@ -38,7 +38,7 @@ 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; diff --git a/core/backends/bluetooth/bluetoothdevicelink.cpp b/core/backends/bluetooth/bluetoothdevicelink.cpp --- a/core/backends/bluetooth/bluetoothdevicelink.cpp +++ b/core/backends/bluetooth/bluetoothdevicelink.cpp @@ -48,10 +48,10 @@ 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 @@ { 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); diff --git a/core/backends/bluetooth/bluetoothlinkprovider.cpp b/core/backends/bluetooth/bluetoothlinkprovider.cpp --- a/core/backends/bluetooth/bluetoothlinkprovider.cpp +++ b/core/backends/bluetooth/bluetoothlinkprovider.cpp @@ -172,36 +172,36 @@ 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("deviceId"); + const QString& deviceId = receivedPacket.get("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) { qCDebug(KDECONNECT_CORE) << "Handshaking done (I'm the new device)"; 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 @@ 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(sender()); @@ -255,26 +255,26 @@ 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("deviceId"); + const QString& deviceId = receivedPacket.get("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); } diff --git a/core/backends/bluetooth/bluetoothpairinghandler.h b/core/backends/bluetooth/bluetoothpairinghandler.h --- a/core/backends/bluetooth/bluetoothpairinghandler.h +++ b/core/backends/bluetooth/bluetoothpairinghandler.h @@ -27,7 +27,7 @@ #include -// 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 @@ 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; diff --git a/core/backends/bluetooth/bluetoothpairinghandler.cpp b/core/backends/bluetooth/bluetoothpairinghandler.cpp --- a/core/backends/bluetooth/bluetoothpairinghandler.cpp +++ b/core/backends/bluetooth/bluetoothpairinghandler.cpp @@ -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 @@ 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 @@ ; } - 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 @@ { 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 @@ 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")); } diff --git a/core/backends/devicelinereader.h b/core/backends/devicelinereader.h --- a/core/backends/devicelinereader.h +++ b/core/backends/devicelinereader.h @@ -39,9 +39,9 @@ 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: QByteArray m_lastChunk; QIODevice* m_device; - QQueue m_packages; + QQueue m_packets; }; diff --git a/core/backends/devicelinereader.cpp b/core/backends/devicelinereader.cpp --- a/core/backends/devicelinereader.cpp +++ b/core/backends/devicelinereader.cpp @@ -36,7 +36,7 @@ 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 @@ 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(); } } diff --git a/core/backends/devicelink.h b/core/backends/devicelink.h --- a/core/backends/devicelink.h +++ b/core/backends/devicelink.h @@ -24,10 +24,10 @@ #include #include -#include "core/networkpackage.h" +#include "core/networkpacket.h" class PairingHandler; -class NetworkPackage; +class NetworkPacket; class LinkProvider; class Device; @@ -47,7 +47,7 @@ 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 @@ 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; diff --git a/core/backends/lan/landevicelink.h b/core/backends/lan/landevicelink.h --- a/core/backends/lan/landevicelink.h +++ b/core/backends/lan/landevicelink.h @@ -44,8 +44,8 @@ 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; diff --git a/core/backends/lan/landevicelink.cpp b/core/backends/lan/landevicelink.cpp --- a/core/backends/lan/landevicelink.cpp +++ b/core/backends/lan/landevicelink.cpp @@ -82,21 +82,21 @@ 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()); } 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 @@ { 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(provider())->incomingPairPackage(this, package); + qobject_cast(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); diff --git a/core/backends/lan/lanlinkprovider.h b/core/backends/lan/lanlinkprovider.h --- a/core/backends/lan/lanlinkprovider.h +++ b/core/backends/lan/lanlinkprovider.h @@ -49,7 +49,7 @@ 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 @@ 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 @@ QMap m_pairingHandlers; struct PendingConnect { - NetworkPackage* np; + NetworkPacket* np; QHostAddress sender; }; - QMap m_receivedIdentityPackages; + QMap m_receivedIdentityPackets; QNetworkConfiguration m_lastConfig; const bool m_testMode; QTimer m_combineBroadcastsTimer; diff --git a/core/backends/lan/lanlinkprovider.cpp b/core/backends/lan/lanlinkprovider.cpp --- a/core/backends/lan/lanlinkprovider.cpp +++ b/core/backends/lan/lanlinkprovider.cpp @@ -132,8 +132,8 @@ QHostAddress destAddress = m_testMode? QHostAddress::LocalHost : QHostAddress(QStringLiteral("255.255.255.255")); - NetworkPackage np(QLatin1String("")); - NetworkPackage::createIdentityPackage(&np); + NetworkPacket np(QLatin1String("")); + NetworkPacket::createIdentityPacket(&np); np.set(QStringLiteral("tcpPort"), m_tcpPort); #ifdef Q_OS_WIN @@ -176,32 +176,32 @@ if (sender.isLoopback() && !m_testMode) continue; - NetworkPackage* receivedPackage = new NetworkPackage(QLatin1String("")); - bool success = NetworkPackage::unserialize(datagram, receivedPackage); + NetworkPacket* receivedPacket = new NetworkPacket(QLatin1String("")); + bool success = NetworkPacket::unserialize(datagram, receivedPacket); - //qCDebug(KDECONNECT_CORE) << "udp connection from " << receivedPackage->; + //qCDebug(KDECONNECT_CORE) << "udp connection from " << receivedPacket->; //qCDebug(KDECONNECT_CORE) << "Datagram " << datagram.data() ; - if (!success || receivedPackage->type() != PACKAGE_TYPE_IDENTITY) { - delete receivedPackage; + if (!success || receivedPacket->type() != PACKET_TYPE_IDENTITY) { + delete receivedPacket; continue; } - if (receivedPackage->get(QStringLiteral("deviceId")) == KdeConnectConfig::instance()->deviceId()) { + if (receivedPacket->get(QStringLiteral("deviceId")) == KdeConnectConfig::instance()->deviceId()) { //qCDebug(KDECONNECT_CORE) << "Ignoring my own broadcast"; - delete receivedPackage; + delete receivedPacket; continue; } - int tcpPort = receivedPackage->get(QStringLiteral("tcpPort")); + int tcpPort = receivedPacket->get(QStringLiteral("tcpPort")); - //qCDebug(KDECONNECT_CORE) << "Received Udp identity package from" << sender << " asking for a tcp connection on port " << tcpPort; + //qCDebug(KDECONNECT_CORE) << "Received Udp identity packet from" << sender << " asking for a tcp connection on port " << tcpPort; QSslSocket* socket = new QSslSocket(this); socket->setProxy(QNetworkProxy::NoProxy); - m_receivedIdentityPackages[socket].np = receivedPackage; - m_receivedIdentityPackages[socket].sender = sender; + m_receivedIdentityPackets[socket].np = receivedPacket; + m_receivedIdentityPackets[socket].sender = sender; connect(socket, &QAbstractSocket::connected, this, &LanLinkProvider::connected); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectError())); socket->connectToHost(sender, tcpPort); @@ -216,18 +216,18 @@ disconnect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectError())); qCDebug(KDECONNECT_CORE) << "Fallback (1), try reverse connection (send udp packet)" << socket->errorString(); - NetworkPackage np(QLatin1String("")); - NetworkPackage::createIdentityPackage(&np); + NetworkPacket np(QLatin1String("")); + NetworkPacket::createIdentityPacket(&np); np.set(QStringLiteral("tcpPort"), m_tcpPort); - m_udpSocket.writeDatagram(np.serialize(), m_receivedIdentityPackages[socket].sender, UDP_PORT); + m_udpSocket.writeDatagram(np.serialize(), m_receivedIdentityPackets[socket].sender, UDP_PORT); //The socket we created didn't work, and we didn't manage //to create a LanDeviceLink from it, deleting everything. - delete m_receivedIdentityPackages.take(socket).np; + delete m_receivedIdentityPackets.take(socket).np; delete socket; } -//We received a UDP package and answered by connecting to them by TCP. This gets called on a succesful connection. +//We received a UDP packet and answered by connecting to them by TCP. This gets called on a succesful connection. void LanLinkProvider::connected() { QSslSocket* socket = qobject_cast(sender()); @@ -241,22 +241,22 @@ // If socket disconnects due to any reason after connection, link on ssl failure connect(socket, &QAbstractSocket::disconnected, socket, &QObject::deleteLater); - NetworkPackage* receivedPackage = m_receivedIdentityPackages[socket].np; - const QString& deviceId = receivedPackage->get(QStringLiteral("deviceId")); + NetworkPacket* receivedPacket = m_receivedIdentityPackets[socket].np; + const QString& deviceId = receivedPacket->get(QStringLiteral("deviceId")); //qCDebug(KDECONNECT_CORE) << "Connected" << socket->isWritable(); // If network is on ssl, do not believe when they are connected, believe when handshake is completed - NetworkPackage np2(QLatin1String("")); - NetworkPackage::createIdentityPackage(&np2); + NetworkPacket np2(QLatin1String("")); + NetworkPacket::createIdentityPacket(&np2); socket->write(np2.serialize()); bool success = socket->waitForBytesWritten(); if (success) { qCDebug(KDECONNECT_CORE) << "TCP connection done (i'm the existing device)"; // if ssl supported - if (receivedPackage->get(QStringLiteral("protocolVersion")) >= MIN_VERSION_WITH_SSL_SUPPORT) { + if (receivedPacket->get(QStringLiteral("protocolVersion")) >= MIN_VERSION_WITH_SSL_SUPPORT) { bool isDeviceTrusted = KdeConnectConfig::instance()->trustedDevices().contains(deviceId); configureSslSocket(socket, deviceId, isDeviceTrusted); @@ -271,20 +271,20 @@ socket->startServerEncryption(); - return; // Return statement prevents from deleting received package, needed in slot "encrypted" + return; // Return statement prevents from deleting received packet, needed in slot "encrypted" } else { - qWarning() << receivedPackage->get(QStringLiteral("deviceName")) << "uses an old protocol version, this won't work"; - //addLink(deviceId, socket, receivedPackage, LanDeviceLink::Remotely); + qWarning() << receivedPacket->get(QStringLiteral("deviceName")) << "uses an old protocol version, this won't work"; + //addLink(deviceId, socket, receivedPacket, LanDeviceLink::Remotely); } } else { //I think this will never happen, but if it happens the deviceLink //(or the socket that is now inside it) might not be valid. Delete them. qCDebug(KDECONNECT_CORE) << "Fallback (2), try reverse connection (send udp packet)"; - m_udpSocket.writeDatagram(np2.serialize(), m_receivedIdentityPackages[socket].sender, UDP_PORT); + m_udpSocket.writeDatagram(np2.serialize(), m_receivedIdentityPackets[socket].sender, UDP_PORT); } - delete m_receivedIdentityPackages.take(socket).np; + delete m_receivedIdentityPackets.take(socket).np; //We don't delete the socket because now it's owned by the LanDeviceLink } @@ -300,13 +300,13 @@ Q_ASSERT(socket->mode() != QSslSocket::UnencryptedMode); LanDeviceLink::ConnectionStarted connectionOrigin = (socket->mode() == QSslSocket::SslClientMode)? LanDeviceLink::Locally : LanDeviceLink::Remotely; - NetworkPackage* receivedPackage = m_receivedIdentityPackages[socket].np; - const QString& deviceId = receivedPackage->get(QStringLiteral("deviceId")); + NetworkPacket* receivedPacket = m_receivedIdentityPackets[socket].np; + const QString& deviceId = receivedPacket->get(QStringLiteral("deviceId")); - addLink(deviceId, socket, receivedPackage, connectionOrigin); + addLink(deviceId, socket, receivedPacket, connectionOrigin); - // Copied from connected slot, now delete received package - delete m_receivedIdentityPackages.take(socket).np; + // Copied from connected slot, now delete received packet + delete m_receivedIdentityPackets.take(socket).np; } void LanLinkProvider::sslErrors(const QList& errors) @@ -323,11 +323,11 @@ device->unpair(); } - delete m_receivedIdentityPackages.take(socket).np; + delete m_receivedIdentityPackets.take(socket).np; // Socket disconnects itself on ssl error and will be deleted by deleteLater slot, no need to delete manually } -//I'm the new device and this is the answer to my UDP identity package (no data received yet). They are connecting to us through TCP, and they should send an identity. +//I'm the new device and this is the answer to my UDP identity packet (no data received yet). They are connecting to us through TCP, and they should send an identity. void LanLinkProvider::newConnection() { //qCDebug(KDECONNECT_CORE) << "LanLinkProvider newConnection"; @@ -346,31 +346,31 @@ } } -//I'm the new device and this is the answer to my UDP identity package (data received) +//I'm the new device and this is the answer to my UDP identity packet (data received) void LanLinkProvider::dataReceived() { QSslSocket* socket = qobject_cast(sender()); const QByteArray data = socket->readLine(); //qCDebug(KDECONNECT_CORE) << "LanLinkProvider received reply:" << data; - NetworkPackage* np = new NetworkPackage(QLatin1String("")); - bool success = NetworkPackage::unserialize(data, np); + NetworkPacket* np = new NetworkPacket(QLatin1String("")); + bool success = NetworkPacket::unserialize(data, np); if (!success) { delete np; return; } - if (np->type() != PACKAGE_TYPE_IDENTITY) { + if (np->type() != PACKET_TYPE_IDENTITY) { qCWarning(KDECONNECT_CORE) << "LanLinkProvider/newConnection: Expected identity, received " << np->type(); delete np; return; } // Needed in "encrypted" if ssl is used, similar to "connected" - m_receivedIdentityPackages[socket].np = np; + m_receivedIdentityPackets[socket].np = np; const QString& deviceId = np->get(QStringLiteral("deviceId")); //qCDebug(KDECONNECT_CORE) << "Handshaking done (i'm the new device)"; @@ -396,7 +396,7 @@ } else { qWarning() << np->get(QStringLiteral("deviceName")) << "uses an old protocol version, this won't work"; //addLink(deviceId, socket, np, LanDeviceLink::Locally); - delete m_receivedIdentityPackages.take(socket).np; + delete m_receivedIdentityPackets.take(socket).np; } } @@ -480,7 +480,7 @@ } -void LanLinkProvider::addLink(const QString& deviceId, QSslSocket* socket, NetworkPackage* receivedPackage, LanDeviceLink::ConnectionStarted connectionOrigin) +void LanLinkProvider::addLink(const QString& deviceId, QSslSocket* socket, NetworkPacket* receivedPacket, LanDeviceLink::ConnectionStarted connectionOrigin) { // Socket disconnection will now be handled by LanDeviceLink disconnect(socket, &QAbstractSocket::disconnected, socket, &QObject::deleteLater); @@ -503,7 +503,7 @@ m_pairingHandlers[deviceId]->setDeviceLink(deviceLink); } } - Q_EMIT onConnectionReceived(*receivedPackage, deviceLink); + Q_EMIT onConnectionReceived(*receivedPacket, deviceLink); } LanPairingHandler* LanLinkProvider::createPairingHandler(DeviceLink* link) @@ -530,9 +530,9 @@ ph->unpair(); } -void LanLinkProvider::incomingPairPackage(DeviceLink* deviceLink, const NetworkPackage& np) +void LanLinkProvider::incomingPairPacket(DeviceLink* deviceLink, const NetworkPacket& np) { LanPairingHandler* ph = createPairingHandler(deviceLink); - ph->packageReceived(np); + ph->packetReceived(np); } diff --git a/core/backends/lan/lanpairinghandler.h b/core/backends/lan/lanpairinghandler.h --- a/core/backends/lan/lanpairinghandler.h +++ b/core/backends/lan/lanpairinghandler.h @@ -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 @@ 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; diff --git a/core/backends/lan/lanpairinghandler.cpp b/core/backends/lan/lanpairinghandler.cpp --- a/core/backends/lan/lanpairinghandler.cpp +++ b/core/backends/lan/lanpairinghandler.cpp @@ -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 @@ connect(&m_pairingTimeout, &QTimer::timeout, this, &LanPairingHandler::pairingTimeout); } -void LanPairingHandler::packageReceived(const NetworkPackage& np) +void LanPairingHandler::packetReceived(const NetworkPacket& np) { bool wantsPair = np.get(QStringLiteral("pair")); @@ -80,41 +80,41 @@ 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); } return success; } 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); } return success; } 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")); } diff --git a/core/backends/lan/socketlinereader.h b/core/backends/lan/socketlinereader.h --- a/core/backends/lan/socketlinereader.h +++ b/core/backends/lan/socketlinereader.h @@ -40,11 +40,11 @@ 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: QByteArray m_lastChunk; - QQueue m_packages; + QQueue m_packets; }; diff --git a/core/backends/lan/socketlinereader.cpp b/core/backends/lan/socketlinereader.cpp --- a/core/backends/lan/socketlinereader.cpp +++ b/core/backends/lan/socketlinereader.cpp @@ -34,7 +34,7 @@ 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 @@ 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(); } } diff --git a/core/backends/linkprovider.h b/core/backends/linkprovider.h --- a/core/backends/linkprovider.h +++ b/core/backends/linkprovider.h @@ -23,7 +23,7 @@ #include -#include "core/networkpackage.h" +#include "core/networkpacket.h" #include "pairinghandler.h" class DeviceLink; @@ -54,7 +54,7 @@ //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; }; diff --git a/core/backends/loopback/loopbackdevicelink.h b/core/backends/loopback/loopbackdevicelink.h --- a/core/backends/loopback/loopbackdevicelink.h +++ b/core/backends/loopback/loopbackdevicelink.h @@ -33,7 +33,7 @@ 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); } diff --git a/core/backends/loopback/loopbackdevicelink.cpp b/core/backends/loopback/loopbackdevicelink.cpp --- a/core/backends/loopback/loopbackdevicelink.cpp +++ b/core/backends/loopback/loopbackdevicelink.cpp @@ -33,19 +33,19 @@ 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()) { bool b = input.payload()->open(QIODevice::ReadOnly); Q_ASSERT(b); output.setPayload(input.payload(), input.payloadSize()); } - Q_EMIT receivedPackage(output); + Q_EMIT receivedPacket(output); return true; } diff --git a/core/backends/loopback/loopbacklinkprovider.h b/core/backends/loopback/loopbacklinkprovider.h --- a/core/backends/loopback/loopbacklinkprovider.h +++ b/core/backends/loopback/loopbacklinkprovider.h @@ -42,7 +42,7 @@ private: QPointer loopbackDeviceLink; - NetworkPackage identityPackage; + NetworkPacket identityPacket; }; diff --git a/core/backends/loopback/loopbacklinkprovider.cpp b/core/backends/loopback/loopbacklinkprovider.cpp --- a/core/backends/loopback/loopbacklinkprovider.cpp +++ b/core/backends/loopback/loopbacklinkprovider.cpp @@ -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 @@ void LoopbackLinkProvider::onNetworkChange() { LoopbackDeviceLink* newLoopbackDeviceLink = new LoopbackDeviceLink(QStringLiteral("loopback"), this); - Q_EMIT onConnectionReceived(identityPackage, newLoopbackDeviceLink); + Q_EMIT onConnectionReceived(identityPacket, newLoopbackDeviceLink); if (loopbackDeviceLink) { delete loopbackDeviceLink; diff --git a/core/backends/pairinghandler.h b/core/backends/pairinghandler.h --- a/core/backends/pairinghandler.h +++ b/core/backends/pairinghandler.h @@ -21,7 +21,7 @@ #ifndef KDECONNECT_PAIRINGHANDLER_H #define KDECONNECT_PAIRINGHANDLER_H -#include "networkpackage.h" +#include "networkpacket.h" #include "devicelink.h" /* @@ -47,7 +47,7 @@ DeviceLink* deviceLink() const; void setDeviceLink(DeviceLink* dl); - virtual void packageReceived(const NetworkPackage& np) = 0; + virtual void packetReceived(const NetworkPacket& np) = 0; virtual void unpair() = 0; static int pairingTimeoutMsec() { return 30 * 1000; } // 30 seconds of timeout (default), subclasses that use different values should override diff --git a/core/daemon.h b/core/daemon.h --- a/core/daemon.h +++ b/core/daemon.h @@ -28,7 +28,7 @@ #include "kdeconnectcore_export.h" #include "device.h" -class NetworkPackage; +class NetworkPacket; class DeviceLink; class Device; class QNetworkAccessManager; @@ -81,7 +81,7 @@ Q_SCRIPTABLE void pairingRequestsChanged(); private Q_SLOTS: - void onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink* dl); + void onNewDeviceLink(const NetworkPacket& identityPacket, DeviceLink* dl); void onDeviceStatusChanged(); private: diff --git a/core/daemon.cpp b/core/daemon.cpp --- a/core/daemon.cpp +++ b/core/daemon.cpp @@ -27,7 +27,7 @@ #include "core_debug.h" #include "kdeconnectconfig.h" -#include "networkpackage.h" +#include "networkpacket.h" #ifdef KDECONNECT_BLUETOOTH #include "backends/bluetooth/bluetoothlinkprovider.h" @@ -168,23 +168,23 @@ return ret; } -void Daemon::onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink* dl) +void Daemon::onNewDeviceLink(const NetworkPacket& identityPacket, DeviceLink* dl) { - const QString& id = identityPackage.get(QStringLiteral("deviceId")); + const QString& id = identityPacket.get(QStringLiteral("deviceId")); //qCDebug(KDECONNECT_CORE) << "Device discovered" << id << "via" << dl->provider()->name(); if (d->m_devices.contains(id)) { - qCDebug(KDECONNECT_CORE) << "It is a known device" << identityPackage.get(QStringLiteral("deviceName")); + qCDebug(KDECONNECT_CORE) << "It is a known device" << identityPacket.get(QStringLiteral("deviceName")); Device* device = d->m_devices[id]; bool wasReachable = device->isReachable(); - device->addLink(identityPackage, dl); + device->addLink(identityPacket, dl); if (!wasReachable) { Q_EMIT deviceVisibilityChanged(id, true); } } else { - qCDebug(KDECONNECT_CORE) << "It is a new device" << identityPackage.get(QStringLiteral("deviceName")); - Device* device = new Device(this, identityPackage, dl); + qCDebug(KDECONNECT_CORE) << "It is a new device" << identityPacket.get(QStringLiteral("deviceName")); + Device* device = new Device(this, identityPacket, dl); //we discard the connections that we created but it's not paired. if (!isDiscoveringDevices() && !device->isTrusted() && !dl->linkShouldBeKeptAlive()) { diff --git a/core/device.h b/core/device.h --- a/core/device.h +++ b/core/device.h @@ -27,7 +27,7 @@ #include #include -#include "networkpackage.h" +#include "networkpacket.h" #include "backends/devicelink.h" class DeviceLink; @@ -69,7 +69,7 @@ * * We know everything but we don't trust it yet */ - Device(QObject* parent, const NetworkPackage& np, DeviceLink* dl); + Device(QObject* parent, const NetworkPacket& np, DeviceLink* dl); ~Device() override; @@ -82,7 +82,7 @@ Q_SCRIPTABLE QString encryptionInfo() const; //Add and remove links - void addLink(const NetworkPackage& identityPackage, DeviceLink*); + void addLink(const NetworkPacket& identityPacket, DeviceLink*); void removeLink(DeviceLink*); Q_SCRIPTABLE bool isTrusted() const; @@ -107,9 +107,9 @@ QHostAddress getLocalIpAddress() const; public Q_SLOTS: - ///sends a @p np package to the device + ///sends a @p np packet to the device ///virtual for testing purposes. - virtual bool sendPackage(NetworkPackage& np); + virtual bool sendPacket(NetworkPacket& np); //Dbus operations public Q_SLOTS: @@ -122,7 +122,7 @@ Q_SCRIPTABLE bool hasPairingRequests() const; private Q_SLOTS: - void privateReceivedPackage(const NetworkPackage& np); + void privateReceivedPacket(const NetworkPacket& np); void linkDestroyed(QObject* o); void pairStatusChanged(DeviceLink::PairStatus current); void addPairingRequest(PairingHandler* handler); diff --git a/core/device.cpp b/core/device.cpp --- a/core/device.cpp +++ b/core/device.cpp @@ -20,10 +20,6 @@ #include "device.h" -#ifdef interface // MSVC language extension, QDBusConnection uses this as a variable name -#undef interface -#endif - #include #include @@ -37,7 +33,7 @@ #include "backends/devicelink.h" #include "backends/lan/landevicelink.h" #include "backends/linkprovider.h" -#include "networkpackage.h" +#include "networkpacket.h" #include "kdeconnectconfig.h" #include "daemon.h" @@ -49,7 +45,7 @@ Device::Device(QObject* parent, const QString& id) : QObject(parent) , m_deviceId(id) - , m_protocolVersion(NetworkPackage::s_protocolVersion) //We don't know it yet + , m_protocolVersion(NetworkPacket::s_protocolVersion) //We don't know it yet { KdeConnectConfig::DeviceInfo info = KdeConnectConfig::instance()->getTrustedDevice(id); @@ -65,12 +61,12 @@ connect(this, &Device::pairingError, this, &warn); } -Device::Device(QObject* parent, const NetworkPackage& identityPackage, DeviceLink* dl) +Device::Device(QObject* parent, const NetworkPacket& identityPacket, DeviceLink* dl) : QObject(parent) - , m_deviceId(identityPackage.get(QStringLiteral("deviceId"))) - , m_deviceName(identityPackage.get(QStringLiteral("deviceName"))) + , m_deviceId(identityPacket.get(QStringLiteral("deviceId"))) + , m_deviceName(identityPacket.get(QStringLiteral("deviceName"))) { - addLink(identityPackage, dl); + addLink(identityPacket, dl); //Register in bus QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors); @@ -107,7 +103,7 @@ const KPluginMetaData service = loader->getPluginInfo(pluginName); const bool pluginEnabled = isPluginEnabled(pluginName); - const QSet incomingCapabilities = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-SupportedPackageType")).toSet(); + const QSet incomingCapabilities = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-SupportedPacketType")).toSet(); if (pluginEnabled) { KdeConnectPlugin* plugin = m_plugins.take(pluginName); @@ -206,19 +202,19 @@ return p1->provider()->priority() > p2->provider()->priority(); } -void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link) +void Device::addLink(const NetworkPacket& identityPacket, DeviceLink* link) { //qCDebug(KDECONNECT_CORE) << "Adding link to" << id() << "via" << link->provider(); - setName(identityPackage.get(QStringLiteral("deviceName"))); - m_deviceType = str2type(identityPackage.get(QStringLiteral("deviceType"))); + setName(identityPacket.get(QStringLiteral("deviceName"))); + m_deviceType = str2type(identityPacket.get(QStringLiteral("deviceType"))); if (m_deviceLinks.contains(link)) return; - m_protocolVersion = identityPackage.get(QStringLiteral("protocolVersion"), -1); - if (m_protocolVersion != NetworkPackage::s_protocolVersion) { - qCWarning(KDECONNECT_CORE) << m_deviceName << "- warning, device uses a different protocol version" << m_protocolVersion << "expected" << NetworkPackage::s_protocolVersion; + m_protocolVersion = identityPacket.get(QStringLiteral("protocolVersion"), -1); + if (m_protocolVersion != NetworkPacket::s_protocolVersion) { + qCWarning(KDECONNECT_CORE) << m_deviceName << "- warning, device uses a different protocol version" << m_protocolVersion << "expected" << NetworkPacket::s_protocolVersion; } connect(link, &QObject::destroyed, @@ -230,15 +226,15 @@ //the old one before this is called), so we do not have to worry about destroying old links. //-- Actually, we should not destroy them or the provider will store an invalid ref! - connect(link, &DeviceLink::receivedPackage, - this, &Device::privateReceivedPackage); + connect(link, &DeviceLink::receivedPacket, + this, &Device::privateReceivedPacket); std::sort(m_deviceLinks.begin(), m_deviceLinks.end(), lessThan); - const bool capabilitiesSupported = identityPackage.has(QStringLiteral("incomingCapabilities")) || identityPackage.has(QStringLiteral("outgoingCapabilities")); + const bool capabilitiesSupported = identityPacket.has(QStringLiteral("incomingCapabilities")) || identityPacket.has(QStringLiteral("outgoingCapabilities")); if (capabilitiesSupported) { - const QSet outgoingCapabilities = identityPackage.get(QStringLiteral("outgoingCapabilities")).toSet() - , incomingCapabilities = identityPackage.get(QStringLiteral("incomingCapabilities")).toSet(); + const QSet outgoingCapabilities = identityPacket.get(QStringLiteral("outgoingCapabilities")).toSet() + , incomingCapabilities = identityPacket.get(QStringLiteral("incomingCapabilities")).toSet(); m_supportedPlugins = PluginLoader::instance()->pluginsForCapabilities(incomingCapabilities, outgoingCapabilities); //qDebug() << "new plugins for" << m_deviceName << m_supportedPlugins << incomingCapabilities << outgoingCapabilities; @@ -320,32 +316,32 @@ } } -bool Device::sendPackage(NetworkPackage& np) +bool Device::sendPacket(NetworkPacket& np) { - Q_ASSERT(np.type() != PACKAGE_TYPE_PAIR); + Q_ASSERT(np.type() != PACKET_TYPE_PAIR); Q_ASSERT(isTrusted()); - //Maybe we could block here any package that is not an identity or a pairing package to prevent sending non encrypted data + //Maybe we could block here any packet that is not an identity or a pairing packet to prevent sending non encrypted data for (DeviceLink* dl : qAsConst(m_deviceLinks)) { - if (dl->sendPackage(np)) return true; + if (dl->sendPacket(np)) return true; } return false; } -void Device::privateReceivedPackage(const NetworkPackage& np) +void Device::privateReceivedPacket(const NetworkPacket& np) { - Q_ASSERT(np.type() != PACKAGE_TYPE_PAIR); + Q_ASSERT(np.type() != PACKET_TYPE_PAIR); if (isTrusted()) { const QList plugins = m_pluginsByIncomingCapability.values(np.type()); if (plugins.isEmpty()) { - qWarning() << "discarding unsupported package" << np.type() << "for" << name(); + qWarning() << "discarding unsupported packet" << np.type() << "for" << name(); } for (KdeConnectPlugin* plugin : plugins) { - plugin->receivePackage(np); + plugin->receivePacket(np); } } else { - qCDebug(KDECONNECT_CORE) << "device" << name() << "not paired, ignoring package" << np.type(); + qCDebug(KDECONNECT_CORE) << "device" << name() << "not paired, ignoring packet" << np.type(); unpair(); } diff --git a/core/kdeconnectconfig.cpp b/core/kdeconnectconfig.cpp --- a/core/kdeconnectconfig.cpp +++ b/core/kdeconnectconfig.cpp @@ -68,7 +68,7 @@ Daemon::instance()->reportError( i18n("KDE Connect failed to start"), i18n("Could not find support for RSA in your QCA installation. If your " - "distribution provides separate packages for QCA-ossl and QCA-gnupg, " + "distribution provides separate packets for QCA-ossl and QCA-gnupg, " "make sure you have them installed and try again.")); return; } diff --git a/core/kdeconnectplugin.h b/core/kdeconnectplugin.h --- a/core/kdeconnectplugin.h +++ b/core/kdeconnectplugin.h @@ -26,7 +26,7 @@ #include "kdeconnectcore_export.h" #include "kdeconnectpluginconfig.h" -#include "networkpackage.h" +#include "networkpacket.h" #include "device.h" struct KdeConnectPluginPrivate; @@ -43,18 +43,18 @@ const Device* device(); Device const* device() const; - bool sendPackage(NetworkPackage& np) const; + bool sendPacket(NetworkPacket& np) const; KdeConnectPluginConfig* config() const; virtual QString dbusPath() const; public Q_SLOTS: /** - * Returns true if it has handled the package in some way - * device.sendPackage can be used to send an answer back to the device + * Returns true if it has handled the packet in some way + * device.sendPacket can be used to send an answer back to the device */ - virtual bool receivePackage(const NetworkPackage& np) = 0; + virtual bool receivePacket(const NetworkPacket& np) = 0; /** * This method will be called when a device is connected to this computer. diff --git a/core/kdeconnectplugin.cpp b/core/kdeconnectplugin.cpp --- a/core/kdeconnectplugin.cpp +++ b/core/kdeconnectplugin.cpp @@ -66,14 +66,14 @@ return d->m_device; } -bool KdeConnectPlugin::sendPackage(NetworkPackage& np) const +bool KdeConnectPlugin::sendPacket(NetworkPacket& np) const { if(!d->m_outgoingCapabilties.contains(np.type())) { - qCWarning(KDECONNECT_CORE) << metaObject()->className() << "tried to send an unsupported package type" << np.type() << ". Supported:" << d->m_outgoingCapabilties; + qCWarning(KDECONNECT_CORE) << metaObject()->className() << "tried to send an unsupported packet type" << np.type() << ". Supported:" << d->m_outgoingCapabilties; return false; } // qCWarning(KDECONNECT_CORE) << metaObject()->className() << "sends" << np.type() << ". Supported:" << d->mOutgoingTypes; - return d->m_device->sendPackage(np); + return d->m_device->sendPacket(np); } QString KdeConnectPlugin::dbusPath() const diff --git a/core/networkpackage.h b/core/networkpacket.h rename from core/networkpackage.h rename to core/networkpacket.h --- a/core/networkpackage.h +++ b/core/networkpacket.h @@ -18,10 +18,10 @@ * along with this program. If not, see . */ -#ifndef NETWORKPACKAGE_H -#define NETWORKPACKAGE_H +#ifndef NETWORKPACKET_H +#define NETWORKPACKET_H -#include "networkpackagetypes.h" +#include "networkpackettypes.h" #include #include @@ -35,7 +35,7 @@ class FileTransferJob; -class KDECONNECTCORE_EXPORT NetworkPackage +class KDECONNECTCORE_EXPORT NetworkPacket { Q_GADGET Q_PROPERTY( QString id READ id WRITE setId ) @@ -49,12 +49,12 @@ //const static QCA::EncryptionAlgorithm EncryptionAlgorithm; const static int s_protocolVersion; - explicit NetworkPackage(const QString& type, const QVariantMap& body = {}); + explicit NetworkPacket(const QString& type, const QVariantMap& body = {}); - static void createIdentityPackage(NetworkPackage*); + static void createIdentityPacket(NetworkPacket*); QByteArray serialize() const; - static bool unserialize(const QByteArray& json, NetworkPackage* out); + static bool unserialize(const QByteArray& json, NetworkPacket* out); const QString& id() const { return m_id; } const QString& type() const { return m_type; } @@ -96,6 +96,6 @@ }; -KDECONNECTCORE_EXPORT QDebug operator<<(QDebug s, const NetworkPackage& pkg); +KDECONNECTCORE_EXPORT QDebug operator<<(QDebug s, const NetworkPacket& pkg); -#endif // NETWORKPACKAGE_H +#endif // NETWORKPACKET_H diff --git a/core/networkpackage.cpp b/core/networkpacket.cpp rename from core/networkpackage.cpp rename to core/networkpacket.cpp --- a/core/networkpackage.cpp +++ b/core/networkpacket.cpp @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -#include "networkpackage.h" +#include "networkpacket.h" #include "core_debug.h" #include @@ -34,42 +34,42 @@ #include "pluginloader.h" #include "kdeconnectconfig.h" -QDebug operator<<(QDebug s, const NetworkPackage& pkg) +QDebug operator<<(QDebug s, const NetworkPacket& pkg) { - s.nospace() << "NetworkPackage(" << pkg.type() << ':' << pkg.body(); + s.nospace() << "NetworkPacket(" << pkg.type() << ':' << pkg.body(); if (pkg.hasPayload()) { s.nospace() << ":withpayload"; } s.nospace() << ')'; return s.space(); } -const int NetworkPackage::s_protocolVersion = 7; +const int NetworkPacket::s_protocolVersion = 7; -NetworkPackage::NetworkPackage(const QString& type, const QVariantMap& body) +NetworkPacket::NetworkPacket(const QString& type, const QVariantMap& body) : m_id(QString::number(QDateTime::currentMSecsSinceEpoch())) , m_type(type) , m_body(body) , m_payload() , m_payloadSize(0) { } -void NetworkPackage::createIdentityPackage(NetworkPackage* np) +void NetworkPacket::createIdentityPacket(NetworkPacket* np) { KdeConnectConfig* config = KdeConnectConfig::instance(); np->m_id = QString::number(QDateTime::currentMSecsSinceEpoch()); - np->m_type = PACKAGE_TYPE_IDENTITY; + np->m_type = PACKET_TYPE_IDENTITY; np->m_payload = QSharedPointer(); np->m_payloadSize = 0; np->set(QStringLiteral("deviceId"), config->deviceId()); np->set(QStringLiteral("deviceName"), config->name()); np->set(QStringLiteral("deviceType"), config->deviceType()); - np->set(QStringLiteral("protocolVersion"), NetworkPackage::s_protocolVersion); + np->set(QStringLiteral("protocolVersion"), NetworkPacket::s_protocolVersion); np->set(QStringLiteral("incomingCapabilities"), PluginLoader::instance()->incomingCapabilities()); np->set(QStringLiteral("outgoingCapabilities"), PluginLoader::instance()->outgoingCapabilities()); - //qCDebug(KDECONNECT_CORE) << "createIdentityPackage" << np->serialize(); + //qCDebug(KDECONNECT_CORE) << "createIdentityPacket" << np->serialize(); } template @@ -85,7 +85,7 @@ return map; } -QByteArray NetworkPackage::serialize() const +QByteArray NetworkPacket::serialize() const { //Object -> QVariant //QVariantMap variant; @@ -107,7 +107,7 @@ qCDebug(KDECONNECT_CORE) << "Serialization error:"; } else { /*if (!isEncrypted()) { - //qCDebug(KDECONNECT_CORE) << "Serialized package:" << json; + //qCDebug(KDECONNECT_CORE) << "Serialized packet:" << json; }*/ json.append('\n'); } @@ -134,7 +134,7 @@ } } -bool NetworkPackage::unserialize(const QByteArray& a, NetworkPackage* np) +bool NetworkPacket::unserialize(const QByteArray& a, NetworkPacket* np) { //Json -> QVariant QJsonParseError parseError; @@ -165,7 +165,7 @@ } -FileTransferJob* NetworkPackage::createPayloadTransferJob(const QUrl& destination) const +FileTransferJob* NetworkPacket::createPayloadTransferJob(const QUrl& destination) const { return new FileTransferJob(payload(), payloadSize(), destination); } diff --git a/core/networkpackagetypes.h b/core/networkpackettypes.h rename from core/networkpackagetypes.h rename to core/networkpackettypes.h --- a/core/networkpackagetypes.h +++ b/core/networkpackettypes.h @@ -18,10 +18,10 @@ * along with this program. If not, see . */ -#ifndef NETWORKPACKAGETYPES_H -#define NETWORKPACKAGETYPES_H +#ifndef NETWORKPACKETTYPES_H +#define NETWORKPACKETTYPES_H -#define PACKAGE_TYPE_IDENTITY QStringLiteral("kdeconnect.identity") -#define PACKAGE_TYPE_PAIR QStringLiteral("kdeconnect.pair") +#define PACKET_TYPE_IDENTITY QStringLiteral("kdeconnect.identity") +#define PACKET_TYPE_PAIR QStringLiteral("kdeconnect.pair") -#endif // NETWORKPACKAGETYPES_H +#endif // NETWORKPACKETTYPES_H diff --git a/core/pluginloader.cpp b/core/pluginloader.cpp --- a/core/pluginloader.cpp +++ b/core/pluginloader.cpp @@ -69,7 +69,7 @@ return ret; } - const QStringList outgoingInterfaces = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-OutgoingPackageType")); + const QStringList outgoingInterfaces = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-OutgoingPacketType")); QVariant deviceVariant = QVariant::fromValue(device); @@ -87,16 +87,16 @@ { QSet ret; for (const KPluginMetaData& service : qAsConst(plugins)) { - ret += KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-SupportedPackageType")).toSet(); + ret += KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-SupportedPacketType")).toSet(); } return ret.toList(); } QStringList PluginLoader::outgoingCapabilities() const { QSet ret; for (const KPluginMetaData& service : qAsConst(plugins)) { - ret += KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-OutgoingPackageType")).toSet(); + ret += KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-OutgoingPacketType")).toSet(); } return ret.toList(); } @@ -106,8 +106,8 @@ QSet ret; for (const KPluginMetaData& service : qAsConst(plugins)) { - const QSet pluginIncomingCapabilities = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-SupportedPackageType")).toSet(); - const QSet pluginOutgoingCapabilities = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-OutgoingPackageType")).toSet(); + const QSet pluginIncomingCapabilities = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-SupportedPacketType")).toSet(); + const QSet pluginOutgoingCapabilities = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-OutgoingPacketType")).toSet(); bool capabilitiesEmpty = (pluginIncomingCapabilities.isEmpty() && pluginOutgoingCapabilities.isEmpty()); #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) diff --git a/interfaces/notificationsmodel.cpp b/interfaces/notificationsmodel.cpp --- a/interfaces/notificationsmodel.cpp +++ b/interfaces/notificationsmodel.cpp @@ -267,5 +267,6 @@ void NotificationsModel::notificationUpdated(const QString& id) { //TODO only emit the affected indices + Q_UNUSED(id); Q_EMIT dataChanged(index(0,0), index(m_notificationList.size() - 1, 0)); } diff --git a/plugins/README.txt b/plugins/README.txt --- a/plugins/README.txt +++ b/plugins/README.txt @@ -1,4 +1,4 @@ -Writting a plugin for KDE Connect +Writting a plugin for KDE Connect ================================= For the desktop client (this project): @@ -18,9 +18,9 @@ A. Replace "ping" with "findmyphone". B. Change name, description, icon, author, email, version, website, license info. C. Remove all the translations - D. Set X-KDEConnect-SupportedPackageType and X-KDEConnect-OutgoingPackageType to the package type your plugin will receive + D. Set X-KDEConnect-SupportedPacketType and X-KDEConnect-OutgoingPacketType to the packet type your plugin will receive and send, respectively. In this example this is "kdeconnect.findmyphone". Make sure that this matches what is defined in - the findmyplugin.h file (in the line "#define PACKAGE_TYPE_..."), and also in Android. + the findmyplugin.h file (in the line "#define PACKET_TYPE_..."), and also in Android. 10. Now you have an empty skeleton to implement your new plugin logic. For Android (project kdeconnect-android): @@ -37,6 +37,6 @@ 7. Open src/org/kde/kdeconnect/Plugins/PluginFactory.java. A. Copy "import … PingPlugin" line with replacing "PingPlugin" with "FindMyPhonePlugin". B. Copy "PluginFactory.registerPlugin(PingPlugin.class);" line with replacing "PingPlugin" with "FindMyPhonePlugin". -8. Open src/org/kde/kdeconnect/NetworkPackage.java. Copy a "public final static String PACKAGE_TYPE_PING = …" line - replacing "PING" with the package type you will be using (should match the desktop client). +8. Open src/org/kde/kdeconnect/NetworkPacket.java. Copy a "public final static String PACKET_TYPE_PING = …" line + replacing "PING" with the packet type you will be using (should match the desktop client). 9. Now you have an empty skeleton to implement your new plugin logic. diff --git a/plugins/battery/batteryplugin.h b/plugins/battery/batteryplugin.h --- a/plugins/battery/batteryplugin.h +++ b/plugins/battery/batteryplugin.h @@ -24,7 +24,7 @@ #include #include -#define PACKAGE_TYPE_BATTERY_REQUEST QStringLiteral("kdeconnect.battery.request") +#define PACKET_TYPE_BATTERY_REQUEST QStringLiteral("kdeconnect.battery.request") Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_PLUGIN_BATTERY) class BatteryDbusInterface; @@ -38,7 +38,7 @@ explicit BatteryPlugin(QObject* parent, const QVariantList& args); ~BatteryPlugin() override; - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; void connected() override; private: diff --git a/plugins/battery/batteryplugin.cpp b/plugins/battery/batteryplugin.cpp --- a/plugins/battery/batteryplugin.cpp +++ b/plugins/battery/batteryplugin.cpp @@ -43,8 +43,8 @@ void BatteryPlugin::connected() { - NetworkPackage np(PACKAGE_TYPE_BATTERY_REQUEST, {{"request",true}}); - sendPackage(np); + NetworkPacket np(PACKET_TYPE_BATTERY_REQUEST, {{"request",true}}); + sendPacket(np); } BatteryPlugin::~BatteryPlugin() @@ -58,7 +58,7 @@ //batteryDbusInterface->deleteLater(); } -bool BatteryPlugin::receivePackage(const NetworkPackage& np) +bool BatteryPlugin::receivePacket(const NetworkPacket& np) { bool isCharging = np.get(QStringLiteral("isCharging"), false); int currentCharge = np.get(QStringLiteral("currentCharge"), -1); diff --git a/plugins/battery/kdeconnect_battery.json b/plugins/battery/kdeconnect_battery.json --- a/plugins/battery/kdeconnect_battery.json +++ b/plugins/battery/kdeconnect_battery.json @@ -91,10 +91,10 @@ "Version": "0.1", "Website": "http://albertvaka.wordpress.com" }, - "X-KdeConnect-OutgoingPackageType": [ + "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.battery.request" ], - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.battery" ] } diff --git a/plugins/clipboard/clipboardplugin.h b/plugins/clipboard/clipboardplugin.h --- a/plugins/clipboard/clipboardplugin.h +++ b/plugins/clipboard/clipboardplugin.h @@ -27,7 +27,7 @@ #include Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_PLUGIN_CLIPBOARD) -#define PACKAGE_TYPE_CLIPBOARD QStringLiteral("kdeconnect.clipboard") +#define PACKET_TYPE_CLIPBOARD QStringLiteral("kdeconnect.clipboard") class ClipboardPlugin : public KdeConnectPlugin @@ -37,7 +37,7 @@ public: explicit ClipboardPlugin(QObject* parent, const QVariantList& args); - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; void connected() override { } private Q_SLOTS: diff --git a/plugins/clipboard/clipboardplugin.cpp b/plugins/clipboard/clipboardplugin.cpp --- a/plugins/clipboard/clipboardplugin.cpp +++ b/plugins/clipboard/clipboardplugin.cpp @@ -37,11 +37,11 @@ void ClipboardPlugin::propagateClipboard(const QString& content) { - NetworkPackage np(PACKAGE_TYPE_CLIPBOARD, {{"content", content}}); - sendPackage(np); + NetworkPacket np(PACKET_TYPE_CLIPBOARD, {{"content", content}}); + sendPacket(np); } -bool ClipboardPlugin::receivePackage(const NetworkPackage& np) +bool ClipboardPlugin::receivePacket(const NetworkPacket& np) { QString content = np.get(QStringLiteral("content")); ClipboardListener::instance()->setText(content); diff --git a/plugins/clipboard/kdeconnect_clipboard.json b/plugins/clipboard/kdeconnect_clipboard.json --- a/plugins/clipboard/kdeconnect_clipboard.json +++ b/plugins/clipboard/kdeconnect_clipboard.json @@ -91,10 +91,10 @@ "Version": "0.1", "Website": "http://albertvaka.wordpress.com" }, - "X-KdeConnect-OutgoingPackageType": [ + "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.clipboard" ], - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.clipboard" ] } diff --git a/plugins/findmyphone/findmyphoneplugin.h b/plugins/findmyphone/findmyphoneplugin.h --- a/plugins/findmyphone/findmyphoneplugin.h +++ b/plugins/findmyphone/findmyphoneplugin.h @@ -25,7 +25,7 @@ #include -#define PACKAGE_TYPE_FINDMYPHONE_REQUEST QStringLiteral("kdeconnect.findmyphone.request") +#define PACKET_TYPE_FINDMYPHONE_REQUEST QStringLiteral("kdeconnect.findmyphone.request") class FindMyPhonePlugin : public KdeConnectPlugin @@ -41,7 +41,7 @@ QString dbusPath() const override; void connected() override {} - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; }; #endif diff --git a/plugins/findmyphone/findmyphoneplugin.cpp b/plugins/findmyphone/findmyphoneplugin.cpp --- a/plugins/findmyphone/findmyphoneplugin.cpp +++ b/plugins/findmyphone/findmyphoneplugin.cpp @@ -36,16 +36,16 @@ { } -bool FindMyPhonePlugin::receivePackage(const NetworkPackage& np) +bool FindMyPhonePlugin::receivePacket(const NetworkPacket& np) { Q_UNUSED(np); return false; } void FindMyPhonePlugin::ring() { - NetworkPackage np(PACKAGE_TYPE_FINDMYPHONE_REQUEST); - sendPackage(np); + NetworkPacket np(PACKET_TYPE_FINDMYPHONE_REQUEST); + sendPacket(np); } QString FindMyPhonePlugin::dbusPath() const diff --git a/plugins/findmyphone/kdeconnect_findmyphone.json b/plugins/findmyphone/kdeconnect_findmyphone.json --- a/plugins/findmyphone/kdeconnect_findmyphone.json +++ b/plugins/findmyphone/kdeconnect_findmyphone.json @@ -97,7 +97,7 @@ "Version": "0.1", "Website": "http://kde.org" }, - "X-KdeConnect-OutgoingPackageType": [ + "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.findmyphone.request" ] } diff --git a/plugins/lockdevice/kdeconnect_lockdevice.json b/plugins/lockdevice/kdeconnect_lockdevice.json --- a/plugins/lockdevice/kdeconnect_lockdevice.json +++ b/plugins/lockdevice/kdeconnect_lockdevice.json @@ -85,11 +85,11 @@ "Version": "0.1", "Website": "https://kde.org" }, - "X-KdeConnect-OutgoingPackageType": [ + "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.lock.request", "kdeconnect.lock" ], - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.lock.request", "kdeconnect.lock" ] diff --git a/plugins/lockdevice/lockdeviceplugin.h b/plugins/lockdevice/lockdeviceplugin.h --- a/plugins/lockdevice/lockdeviceplugin.h +++ b/plugins/lockdevice/lockdeviceplugin.h @@ -27,8 +27,8 @@ class OrgFreedesktopScreenSaverInterface; -#define PACKAGE_TYPE_LOCK QStringLiteral("kdeconnect.lock") -#define PACKAGE_TYPE_LOCK_REQUEST QStringLiteral("kdeconnect.lock.request") +#define PACKET_TYPE_LOCK QStringLiteral("kdeconnect.lock") +#define PACKET_TYPE_LOCK_REQUEST QStringLiteral("kdeconnect.lock.request") class Q_DECL_EXPORT LockDevicePlugin : public KdeConnectPlugin @@ -46,7 +46,7 @@ QString dbusPath() const override; void connected() override; - bool receivePackage(const NetworkPackage & np) override; + bool receivePacket(const NetworkPacket & np) override; Q_SIGNALS: void lockedChanged(bool locked); diff --git a/plugins/lockdevice/lockdeviceplugin.cpp b/plugins/lockdevice/lockdeviceplugin.cpp --- a/plugins/lockdevice/lockdeviceplugin.cpp +++ b/plugins/lockdevice/lockdeviceplugin.cpp @@ -52,11 +52,11 @@ } void LockDevicePlugin::setLocked(bool locked) { - NetworkPackage np(PACKAGE_TYPE_LOCK_REQUEST, {{"setLocked", locked}}); - sendPackage(np); + NetworkPacket np(PACKET_TYPE_LOCK_REQUEST, {{"setLocked", locked}}); + sendPacket(np); } -bool LockDevicePlugin::receivePackage(const NetworkPackage & np) +bool LockDevicePlugin::receivePacket(const NetworkPacket & np) { if (np.has(QStringLiteral("isLocked"))) { bool locked = np.get(QStringLiteral("isLocked")); @@ -72,8 +72,8 @@ sendState = true; } if (sendState) { - NetworkPackage np(PACKAGE_TYPE_LOCK, QVariantMap {{"isLocked", QVariant::fromValue(iface()->GetActive())}}); - sendPackage(np); + NetworkPacket np(PACKET_TYPE_LOCK, QVariantMap {{"isLocked", QVariant::fromValue(iface()->GetActive())}}); + sendPacket(np); } return true; @@ -91,8 +91,8 @@ void LockDevicePlugin::connected() { - NetworkPackage np(PACKAGE_TYPE_LOCK_REQUEST, {{"requestLocked", QVariant()}}); - sendPackage(np); + NetworkPacket np(PACKET_TYPE_LOCK_REQUEST, {{"requestLocked", QVariant()}}); + sendPacket(np); } QString LockDevicePlugin::dbusPath() const diff --git a/plugins/mousepad/kdeconnect_mousepad.json b/plugins/mousepad/kdeconnect_mousepad.json --- a/plugins/mousepad/kdeconnect_mousepad.json +++ b/plugins/mousepad/kdeconnect_mousepad.json @@ -90,8 +90,8 @@ ], "Version": "0.1" }, - "X-KdeConnect-OutgoingPackageType": [], - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-OutgoingPacketType": [], + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.mousepad.request" ] } diff --git a/plugins/mousepad/mousepadplugin.h b/plugins/mousepad/mousepadplugin.h --- a/plugins/mousepad/mousepadplugin.h +++ b/plugins/mousepad/mousepadplugin.h @@ -46,16 +46,16 @@ explicit MousepadPlugin(QObject* parent, const QVariantList& args); ~MousepadPlugin() override; - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; void connected() override { } private: #if HAVE_X11 - bool handlePackageX11(const NetworkPackage& np); + bool handlePacketX11(const NetworkPacket& np); #endif #if HAVE_WAYLAND void setupWaylandIntegration(); - bool handPackageWayland(const NetworkPackage& np); + bool handPacketWayland(const NetworkPacket& np); #endif #if HAVE_X11 diff --git a/plugins/mousepad/mousepadplugin.cpp b/plugins/mousepad/mousepadplugin.cpp --- a/plugins/mousepad/mousepadplugin.cpp +++ b/plugins/mousepad/mousepadplugin.cpp @@ -118,20 +118,20 @@ #endif } -bool MousepadPlugin::receivePackage(const NetworkPackage& np) +bool MousepadPlugin::receivePacket(const NetworkPacket& np) { #if HAVE_X11 if (m_x11) { - return handlePackageX11(np); + return handlePacketX11(np); } #endif #if HAVE_WAYLAND if (m_waylandInput) { if (!m_waylandAuthenticationRequested) { m_waylandInput->authenticate(i18n("KDE Connect"), i18n("Use your phone as a touchpad and keyboard")); m_waylandAuthenticationRequested = true; } - handPackageWayland(np); + handPacketWayland(np); } #endif return false; @@ -153,7 +153,7 @@ #endif #if HAVE_X11 -bool MousepadPlugin::handlePackageX11(const NetworkPackage& np) +bool MousepadPlugin::handlePacketX11(const NetworkPacket& np) { //qDebug() << np.serialize(); @@ -289,7 +289,7 @@ registry->setup(); } -bool MousepadPlugin::handPackageWayland(const NetworkPackage& np) +bool MousepadPlugin::handPacketWayland(const NetworkPacket& np) { const float dx = np.get(QStringLiteral("dx"), 0); const float dy = np.get(QStringLiteral("dy"), 0); diff --git a/plugins/mousepad_windows/kdeconnect_mousepad.json b/plugins/mousepad_windows/kdeconnect_mousepad.json --- a/plugins/mousepad_windows/kdeconnect_mousepad.json +++ b/plugins/mousepad_windows/kdeconnect_mousepad.json @@ -90,8 +90,8 @@ ], "Version": "0.1" }, - "X-KdeConnect-OutgoingPackageType": [], - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-OutgoingPacketType": [], + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.mousepad.request" ] } diff --git a/plugins/mousepad_windows/mousepadplugin_windows.h b/plugins/mousepad_windows/mousepadplugin_windows.h --- a/plugins/mousepad_windows/mousepadplugin_windows.h +++ b/plugins/mousepad_windows/mousepadplugin_windows.h @@ -35,7 +35,7 @@ explicit MousepadPlugin(QObject* parent, const QVariantList &args); ~MousepadPlugin() override; - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; void connected() override { } }; diff --git a/plugins/mousepad_windows/mousepadplugin_windows.cpp b/plugins/mousepad_windows/mousepadplugin_windows.cpp --- a/plugins/mousepad_windows/mousepadplugin_windows.cpp +++ b/plugins/mousepad_windows/mousepadplugin_windows.cpp @@ -39,7 +39,7 @@ { } -bool MousepadPlugin::receivePackage(const NetworkPackage& np) +bool MousepadPlugin::receivePacket(const NetworkPacket& np) { float dx = np.get(QStringLiteral("dx"), 0); float dy = np.get(QStringLiteral("dy"), 0); diff --git a/plugins/mpriscontrol/kdeconnect_mpriscontrol.json b/plugins/mpriscontrol/kdeconnect_mpriscontrol.json --- a/plugins/mpriscontrol/kdeconnect_mpriscontrol.json +++ b/plugins/mpriscontrol/kdeconnect_mpriscontrol.json @@ -90,10 +90,10 @@ "Version": "0.1", "Website": "http://albertvaka.wordpress.com" }, - "X-KdeConnect-OutgoingPackageType": [ + "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.mpris" ], - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.mpris.request" ] } diff --git a/plugins/mpriscontrol/mpriscontrolplugin.h b/plugins/mpriscontrol/mpriscontrolplugin.h --- a/plugins/mpriscontrol/mpriscontrolplugin.h +++ b/plugins/mpriscontrol/mpriscontrolplugin.h @@ -28,7 +28,7 @@ #include -#define PACKAGE_TYPE_MPRIS QStringLiteral("kdeconnect.mpris") +#define PACKET_TYPE_MPRIS QStringLiteral("kdeconnect.mpris") Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_PLUGIN_MPRIS) @@ -40,7 +40,7 @@ public: explicit MprisControlPlugin(QObject* parent, const QVariantList& args); - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; void connected() override { } private Q_SLOTS: @@ -52,7 +52,7 @@ void addPlayer(const QString& ifaceName); void removePlayer(const QString& ifaceName); void sendPlayerList(); - void mprisPlayerMetadataToNetworkPackage(NetworkPackage& np, const QVariantMap& nowPlayingMap) const; + void mprisPlayerMetadataToNetworkPacket(NetworkPacket& np, const QVariantMap& nowPlayingMap) const; QHash playerList; int prevVolume; diff --git a/plugins/mpriscontrol/mpriscontrolplugin.cpp b/plugins/mpriscontrol/mpriscontrolplugin.cpp --- a/plugins/mpriscontrol/mpriscontrolplugin.cpp +++ b/plugins/mpriscontrol/mpriscontrolplugin.cpp @@ -104,18 +104,18 @@ const QString& service = interface->service(); const QString& player = playerList.key(service); - NetworkPackage np(PACKAGE_TYPE_MPRIS, { + NetworkPacket np(PACKET_TYPE_MPRIS, { {"pos", position/1000}, //Send milis instead of nanos {"player", player} }); - sendPackage(np); + sendPacket(np); } void MprisControlPlugin::propertiesChanged(const QString& propertyInterface, const QVariantMap& properties) { Q_UNUSED(propertyInterface); - NetworkPackage np(PACKAGE_TYPE_MPRIS); + NetworkPacket np(PACKET_TYPE_MPRIS); bool somethingToSend = false; if (properties.contains(QStringLiteral("Volume"))) { int volume = (int) (properties[QStringLiteral("Volume")].toDouble()*100); @@ -130,7 +130,7 @@ QVariantMap nowPlayingMap; bullshit >> nowPlayingMap; - mprisPlayerMetadataToNetworkPackage(np, nowPlayingMap); + mprisPlayerMetadataToNetworkPacket(np, nowPlayingMap); somethingToSend = true; } if (properties.contains(QStringLiteral("PlaybackStatus"))) { @@ -170,7 +170,7 @@ long long pos = mprisInterface.position(); np.set(QStringLiteral("pos"), pos/1000); //Send milis instead of nanos } - sendPackage(np); + sendPacket(np); } } @@ -182,7 +182,7 @@ sendPlayerList(); } -bool MprisControlPlugin::receivePackage (const NetworkPackage& np) +bool MprisControlPlugin::receivePacket (const NetworkPacket& np) { if (np.has(QStringLiteral("playerList"))) { return false; //Whoever sent this is an mpris client and not an mpris control! @@ -226,11 +226,11 @@ } //Send something read from the mpris interface - NetworkPackage answer(PACKAGE_TYPE_MPRIS); + NetworkPacket answer(PACKET_TYPE_MPRIS); bool somethingToSend = false; if (np.get(QStringLiteral("requestNowPlaying"))) { QVariantMap nowPlayingMap = mprisInterface.metadata(); - mprisPlayerMetadataToNetworkPackage(answer, nowPlayingMap); + mprisPlayerMetadataToNetworkPacket(answer, nowPlayingMap); qlonglong pos = mprisInterface.position(); answer.set(QStringLiteral("pos"), pos/1000); @@ -253,20 +253,20 @@ } if (somethingToSend) { answer.set(QStringLiteral("player"), player); - sendPackage(answer); + sendPacket(answer); } return true; } void MprisControlPlugin::sendPlayerList() { - NetworkPackage np(PACKAGE_TYPE_MPRIS); + NetworkPacket np(PACKET_TYPE_MPRIS); np.set(QStringLiteral("playerList"),playerList.keys()); - sendPackage(np); + sendPacket(np); } -void MprisControlPlugin::mprisPlayerMetadataToNetworkPackage(NetworkPackage& np, const QVariantMap& nowPlayingMap) const { +void MprisControlPlugin::mprisPlayerMetadataToNetworkPacket(NetworkPacket& np, const QVariantMap& nowPlayingMap) const { QString title = nowPlayingMap[QStringLiteral("xesam:title")].toString(); QString artist = nowPlayingMap[QStringLiteral("xesam:artist")].toString(); QString album = nowPlayingMap[QStringLiteral("xesam:album")].toString(); diff --git a/plugins/mprisremote/kdeconnect_mprisremote.json b/plugins/mprisremote/kdeconnect_mprisremote.json --- a/plugins/mprisremote/kdeconnect_mprisremote.json +++ b/plugins/mprisremote/kdeconnect_mprisremote.json @@ -70,10 +70,10 @@ "Version": "0.1", "Website": "https://kde.org" }, - "X-KdeConnect-OutgoingPackageType": [ + "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.mpris.request" ], - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.mpris" ] } diff --git a/plugins/mprisremote/mprisremoteplugin.h b/plugins/mprisremote/mprisremoteplugin.h --- a/plugins/mprisremote/mprisremoteplugin.h +++ b/plugins/mprisremote/mprisremoteplugin.h @@ -25,8 +25,8 @@ #include -#define PACKAGE_TYPE_MPRIS_REQUEST QStringLiteral("kdeconnect.mpris.request") -#define PACKAGE_TYPE_MPRIS QStringLiteral("kdeconnect.mpris") +#define PACKET_TYPE_MPRIS_REQUEST QStringLiteral("kdeconnect.mpris.request") +#define PACKET_TYPE_MPRIS QStringLiteral("kdeconnect.mpris") class Q_DECL_EXPORT MprisRemotePlugin : public KdeConnectPlugin @@ -57,7 +57,7 @@ void setPosition(int position); void setPlayer(const QString& player); - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; void connected() override {} QString dbusPath() const override; diff --git a/plugins/mprisremote/mprisremoteplugin.cpp b/plugins/mprisremote/mprisremoteplugin.cpp --- a/plugins/mprisremote/mprisremoteplugin.cpp +++ b/plugins/mprisremote/mprisremoteplugin.cpp @@ -50,9 +50,9 @@ { } -bool MprisRemotePlugin::receivePackage(const NetworkPackage& np) +bool MprisRemotePlugin::receivePacket(const NetworkPacket& np) { - if (np.type() != PACKAGE_TYPE_MPRIS) + if (np.type() != PACKET_TYPE_MPRIS) return false; if (np.has(QStringLiteral("nowPlaying")) || np.has(QStringLiteral("volume")) || np.has(QStringLiteral("isPlaying")) || np.has(QStringLiteral("length")) || np.has(QStringLiteral("pos"))) { @@ -92,53 +92,53 @@ void MprisRemotePlugin::requestPlayerStatus() { - NetworkPackage np(PACKAGE_TYPE_MPRIS_REQUEST, { + NetworkPacket np(PACKET_TYPE_MPRIS_REQUEST, { {"player", m_player}, {"requestNowPlaying", true}, {"requestVolume", true}} ); - sendPackage(np); + sendPacket(np); } void MprisRemotePlugin::requestPlayerList() { - NetworkPackage np(PACKAGE_TYPE_MPRIS_REQUEST, {{"requestPlayerList", true}}); - sendPackage(np); + NetworkPacket np(PACKET_TYPE_MPRIS_REQUEST, {{"requestPlayerList", true}}); + sendPacket(np); } void MprisRemotePlugin::sendAction(const QString& action) { - NetworkPackage np(PACKAGE_TYPE_MPRIS_REQUEST, { + NetworkPacket np(PACKET_TYPE_MPRIS_REQUEST, { {"player", m_player}, {"action", action} }); - sendPackage(np); + sendPacket(np); } void MprisRemotePlugin::seek(int offset) const { - NetworkPackage np(PACKAGE_TYPE_MPRIS_REQUEST, { + NetworkPacket np(PACKET_TYPE_MPRIS_REQUEST, { {"player", m_player}, {"Seek", offset}}); - sendPackage(np); + sendPacket(np); } void MprisRemotePlugin::setVolume(int volume) { - NetworkPackage np(PACKAGE_TYPE_MPRIS_REQUEST, { + NetworkPacket np(PACKET_TYPE_MPRIS_REQUEST, { {"player", m_player}, {"setVolume",volume} }); - sendPackage(np); + sendPacket(np); } void MprisRemotePlugin::setPosition(int position) { - NetworkPackage np(PACKAGE_TYPE_MPRIS_REQUEST, { + NetworkPacket np(PACKET_TYPE_MPRIS_REQUEST, { {"player", m_player}, {"SetPosition", position} }); - sendPackage(np); + sendPacket(np); m_lastPosition = position; m_lastPositionTime = QDateTime::currentMSecsSinceEpoch(); diff --git a/plugins/notifications/kdeconnect_notifications.json b/plugins/notifications/kdeconnect_notifications.json --- a/plugins/notifications/kdeconnect_notifications.json +++ b/plugins/notifications/kdeconnect_notifications.json @@ -88,11 +88,11 @@ "Version": "0.1", "Website": "http://albertvaka.wordpress.com" }, - "X-KdeConnect-OutgoingPackageType": [ + "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.notification.request", "kdeconnect.notification.reply" ], - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.notification" ] } diff --git a/plugins/notifications/notification.h b/plugins/notifications/notification.h --- a/plugins/notifications/notification.h +++ b/plugins/notifications/notification.h @@ -26,7 +26,7 @@ #include #include -#include +#include class Notification : public QObject @@ -45,7 +45,7 @@ Q_PROPERTY(QString replyId READ replyId) public: - Notification(const NetworkPackage& np, QObject* parent); + Notification(const NetworkPacket& np, QObject* parent); ~Notification() override; QString internalId() const { return m_internalId; } @@ -59,9 +59,9 @@ bool hasIcon() const { return m_hasIcon; } void show(); bool silent() const { return m_silent; } - void update(const NetworkPackage& np); + void update(const NetworkPacket& np); bool isReady() const { return m_ready; } - KNotification* createKNotification(bool update, const NetworkPackage& np); + KNotification* createKNotification(bool update, const NetworkPacket& np); public Q_SLOTS: Q_SCRIPTABLE void dismiss(); @@ -90,8 +90,8 @@ QString m_payloadHash; bool m_ready; - void parseNetworkPackage(const NetworkPackage& np); - void loadIcon(const NetworkPackage& np); + void parseNetworkPacket(const NetworkPacket& np); + void loadIcon(const NetworkPacket& np); void applyIcon(); void applyNoIcon(); }; diff --git a/plugins/notifications/notification.cpp b/plugins/notifications/notification.cpp --- a/plugins/notifications/notification.cpp +++ b/plugins/notifications/notification.cpp @@ -32,7 +32,7 @@ #include -Notification::Notification(const NetworkPackage& np, QObject* parent) +Notification::Notification(const NetworkPacket& np, QObject* parent) : QObject(parent) { //Make a own directory for each user so noone can see each others icons @@ -49,7 +49,7 @@ m_closed = false; m_ready = false; - parseNetworkPackage(np); + parseNetworkPacket(np); createKNotification(false, np); } @@ -74,13 +74,13 @@ } } -void Notification::update(const NetworkPackage& np) +void Notification::update(const NetworkPacket& np) { - parseNetworkPackage(np); + parseNetworkPacket(np); createKNotification(!m_closed, np); } -KNotification* Notification::createKNotification(bool update, const NetworkPackage& np) +KNotification* Notification::createKNotification(bool update, const NetworkPacket& np) { if (!update) { m_notification = new KNotification(QStringLiteral("notification"), KNotification::CloseOnTimeout, this); @@ -132,7 +132,7 @@ return m_notification; } -void Notification::loadIcon(const NetworkPackage& np) +void Notification::loadIcon(const NetworkPacket& np) { m_ready = false; FileTransferJob* job = np.createPayloadTransferJob(QUrl::fromLocalFile(m_iconPath)); @@ -172,7 +172,7 @@ m_closed = true; } -void Notification::parseNetworkPackage(const NetworkPackage& np) +void Notification::parseNetworkPacket(const NetworkPacket& np) { m_internalId = np.get(QStringLiteral("id")); m_appName = np.get(QStringLiteral("appName")); diff --git a/plugins/notifications/notificationsdbusinterface.h b/plugins/notifications/notificationsdbusinterface.h --- a/plugins/notifications/notificationsdbusinterface.h +++ b/plugins/notifications/notificationsdbusinterface.h @@ -43,7 +43,7 @@ explicit NotificationsDbusInterface(KdeConnectPlugin* plugin); ~NotificationsDbusInterface() override; - void processPackage(const NetworkPackage& np); + void processPacket(const NetworkPacket& np); void clearNotifications(); void dismissRequested(const QString& notification); void replyRequested(Notification* noti); diff --git a/plugins/notifications/notificationsdbusinterface.cpp b/plugins/notifications/notificationsdbusinterface.cpp --- a/plugins/notifications/notificationsdbusinterface.cpp +++ b/plugins/notifications/notificationsdbusinterface.cpp @@ -56,7 +56,7 @@ return m_notifications.keys(); } -void NotificationsDbusInterface::processPackage(const NetworkPackage& np) +void NotificationsDbusInterface::processPacket(const NetworkPacket& np) { if (np.get(QStringLiteral("isCancel"))) { QString id = np.get(QStringLiteral("id")); @@ -148,9 +148,9 @@ void NotificationsDbusInterface::dismissRequested(const QString& internalId) { - NetworkPackage np(PACKAGE_TYPE_NOTIFICATION_REQUEST); + NetworkPacket np(PACKET_TYPE_NOTIFICATION_REQUEST); np.set(QStringLiteral("cancel"), internalId); - m_plugin->sendPackage(np); + m_plugin->sendPacket(np); //Workaround: we erase notifications without waiting a repsonse from the //phone because we won't receive a response if we are out of sync and this @@ -172,10 +172,10 @@ void NotificationsDbusInterface::sendReply(const QString& replyId, const QString& message) { - NetworkPackage np(PACKAGE_TYPE_NOTIFICATION_REPLY); + NetworkPacket np(PACKET_TYPE_NOTIFICATION_REPLY); np.set(QStringLiteral("requestReplyId"), replyId); np.set(QStringLiteral("message"), message); - m_plugin->sendPackage(np); + m_plugin->sendPacket(np); } QString NotificationsDbusInterface::newId() diff --git a/plugins/notifications/notificationsplugin.h b/plugins/notifications/notificationsplugin.h --- a/plugins/notifications/notificationsplugin.h +++ b/plugins/notifications/notificationsplugin.h @@ -25,8 +25,8 @@ #include -#define PACKAGE_TYPE_NOTIFICATION_REQUEST QStringLiteral("kdeconnect.notification.request") -#define PACKAGE_TYPE_NOTIFICATION_REPLY QStringLiteral("kdeconnect.notification.reply") +#define PACKET_TYPE_NOTIFICATION_REQUEST QStringLiteral("kdeconnect.notification.request") +#define PACKET_TYPE_NOTIFICATION_REPLY QStringLiteral("kdeconnect.notification.reply") /* * This class is just a proxy for NotificationsDbusInterface @@ -45,7 +45,7 @@ explicit NotificationsPlugin(QObject* parent, const QVariantList& args); ~NotificationsPlugin() override; - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; void connected() override; protected: diff --git a/plugins/notifications/notificationsplugin.cpp b/plugins/notifications/notificationsplugin.cpp --- a/plugins/notifications/notificationsplugin.cpp +++ b/plugins/notifications/notificationsplugin.cpp @@ -37,8 +37,8 @@ void NotificationsPlugin::connected() { - NetworkPackage np(PACKAGE_TYPE_NOTIFICATION_REQUEST, {{"request", true}}); - sendPackage(np); + NetworkPacket np(PACKET_TYPE_NOTIFICATION_REQUEST, {{"request", true}}); + sendPacket(np); } NotificationsPlugin::~NotificationsPlugin() @@ -52,11 +52,11 @@ notificationsDbusInterface->clearNotifications(); } -bool NotificationsPlugin::receivePackage(const NetworkPackage& np) +bool NotificationsPlugin::receivePacket(const NetworkPacket& np) { if (np.get(QStringLiteral("request"))) return false; - notificationsDbusInterface->processPackage(np); + notificationsDbusInterface->processPacket(np); return true; } diff --git a/plugins/pausemusic/kdeconnect_pausemusic.json b/plugins/pausemusic/kdeconnect_pausemusic.json --- a/plugins/pausemusic/kdeconnect_pausemusic.json +++ b/plugins/pausemusic/kdeconnect_pausemusic.json @@ -90,7 +90,7 @@ "Version": "0.1", "Website": "http://albertvaka.wordpress.com" }, - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.telephony" ] } diff --git a/plugins/pausemusic/pausemusicplugin.h b/plugins/pausemusic/pausemusicplugin.h --- a/plugins/pausemusic/pausemusicplugin.h +++ b/plugins/pausemusic/pausemusicplugin.h @@ -39,7 +39,7 @@ public: explicit PauseMusicPlugin(QObject* parent, const QVariantList& args); - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; void connected() override { } private: diff --git a/plugins/pausemusic/pausemusicplugin.cpp b/plugins/pausemusic/pausemusicplugin.cpp --- a/plugins/pausemusic/pausemusicplugin.cpp +++ b/plugins/pausemusic/pausemusicplugin.cpp @@ -39,7 +39,7 @@ , muted(false) {} -bool PauseMusicPlugin::receivePackage(const NetworkPackage& np) +bool PauseMusicPlugin::receivePacket(const NetworkPacket& np) { bool pauseOnlyWhenTalking = config()->get(QStringLiteral("conditionTalking"), false); diff --git a/plugins/ping/kdeconnect_ping.json b/plugins/ping/kdeconnect_ping.json --- a/plugins/ping/kdeconnect_ping.json +++ b/plugins/ping/kdeconnect_ping.json @@ -69,10 +69,10 @@ "Version": "0.1", "Website": "http://albertvaka.wordpress.com" }, - "X-KdeConnect-OutgoingPackageType": [ + "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.ping" ], - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.ping" ] } diff --git a/plugins/ping/pingplugin.h b/plugins/ping/pingplugin.h --- a/plugins/ping/pingplugin.h +++ b/plugins/ping/pingplugin.h @@ -25,7 +25,7 @@ #include -#define PACKAGE_TYPE_PING QStringLiteral("kdeconnect.ping") +#define PACKET_TYPE_PING QStringLiteral("kdeconnect.ping") class Q_DECL_EXPORT PingPlugin : public KdeConnectPlugin @@ -40,7 +40,7 @@ Q_SCRIPTABLE void sendPing(); Q_SCRIPTABLE void sendPing(const QString& customMessage); - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; void connected() override {} QString dbusPath() const override; diff --git a/plugins/ping/pingplugin.cpp b/plugins/ping/pingplugin.cpp --- a/plugins/ping/pingplugin.cpp +++ b/plugins/ping/pingplugin.cpp @@ -45,7 +45,7 @@ // qCDebug(KDECONNECT_PLUGIN_PING) << "Ping plugin destructor for device" << device()->name(); } -bool PingPlugin::receivePackage(const NetworkPackage& np) +bool PingPlugin::receivePacket(const NetworkPacket& np) { KNotification* notification = new KNotification(QStringLiteral("pingReceived")); //KNotification::Persistent notification->setIconName(QStringLiteral("dialog-ok")); @@ -59,18 +59,18 @@ void PingPlugin::sendPing() { - NetworkPackage np(PACKAGE_TYPE_PING); - bool success = sendPackage(np); + NetworkPacket np(PACKET_TYPE_PING); + bool success = sendPacket(np); qCDebug(KDECONNECT_PLUGIN_PING) << "sendPing:" << success; } void PingPlugin::sendPing(const QString& customMessage) { - NetworkPackage np(PACKAGE_TYPE_PING); + NetworkPacket np(PACKET_TYPE_PING); if (!customMessage.isEmpty()) { np.set(QStringLiteral("message"), customMessage); } - bool success = sendPackage(np); + bool success = sendPacket(np); qCDebug(KDECONNECT_PLUGIN_PING) << "sendPing:" << success; } diff --git a/plugins/remotecommands/kdeconnect_remotecommands.json b/plugins/remotecommands/kdeconnect_remotecommands.json --- a/plugins/remotecommands/kdeconnect_remotecommands.json +++ b/plugins/remotecommands/kdeconnect_remotecommands.json @@ -85,10 +85,10 @@ ], "Version": "0.1" }, - "X-KdeConnect-OutgoingPackageType": [ + "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.runcommand.request" ], - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.runcommand" ] } diff --git a/plugins/remotecommands/remotecommandsplugin.h b/plugins/remotecommands/remotecommandsplugin.h --- a/plugins/remotecommands/remotecommandsplugin.h +++ b/plugins/remotecommands/remotecommandsplugin.h @@ -44,7 +44,7 @@ Q_SCRIPTABLE void triggerCommand(const QString& key); QByteArray commands() const { return m_commands; } - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; void connected() override; QString dbusPath() const override; diff --git a/plugins/remotecommands/remotecommandsplugin.cpp b/plugins/remotecommands/remotecommandsplugin.cpp --- a/plugins/remotecommands/remotecommandsplugin.cpp +++ b/plugins/remotecommands/remotecommandsplugin.cpp @@ -30,10 +30,10 @@ #include #include -#include +#include #include -#define PACKAGE_TYPE_RUNCOMMAND_REQUEST QLatin1String("kdeconnect.runcommand.request") +#define PACKET_TYPE_RUNCOMMAND_REQUEST QLatin1String("kdeconnect.runcommand.request") K_PLUGIN_FACTORY_WITH_JSON( KdeConnectPluginFactory, "kdeconnect_remotecommands.json", registerPlugin< RemoteCommandsPlugin >(); ) @@ -47,7 +47,7 @@ RemoteCommandsPlugin::~RemoteCommandsPlugin() = default; -bool RemoteCommandsPlugin::receivePackage(const NetworkPackage& np) +bool RemoteCommandsPlugin::receivePacket(const NetworkPacket& np) { if (np.has(QStringLiteral("commandList"))) { setCommands(np.get(QStringLiteral("commandList"))); @@ -59,8 +59,8 @@ void RemoteCommandsPlugin::connected() { - NetworkPackage np(PACKAGE_TYPE_RUNCOMMAND_REQUEST, {{"requestCommandList", true}}); - sendPackage(np); + NetworkPacket np(PACKET_TYPE_RUNCOMMAND_REQUEST, {{"requestCommandList", true}}); + sendPacket(np); } QString RemoteCommandsPlugin::dbusPath() const @@ -78,8 +78,8 @@ void RemoteCommandsPlugin::triggerCommand(const QString& key) { - NetworkPackage np(PACKAGE_TYPE_RUNCOMMAND_REQUEST, {{ "key", key }}); - sendPackage(np); + NetworkPacket np(PACKET_TYPE_RUNCOMMAND_REQUEST, {{ "key", key }}); + sendPacket(np); } #include "remotecommandsplugin.moc" diff --git a/plugins/remotecontrol/kdeconnect_remotecontrol.json b/plugins/remotecontrol/kdeconnect_remotecontrol.json --- a/plugins/remotecontrol/kdeconnect_remotecontrol.json +++ b/plugins/remotecontrol/kdeconnect_remotecontrol.json @@ -85,8 +85,8 @@ "Version": "0.1", "Website": "https://kde.org" }, - "X-KdeConnect-OutgoingPackageType": [ + "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.mousepad.request" ], - "X-KdeConnect-SupportedPackageType": [] + "X-KdeConnect-SupportedPacketType": [] } diff --git a/plugins/remotecontrol/remotecontrolplugin.h b/plugins/remotecontrol/remotecontrolplugin.h --- a/plugins/remotecontrol/remotecontrolplugin.h +++ b/plugins/remotecontrol/remotecontrolplugin.h @@ -25,7 +25,7 @@ #include -#define PACKAGE_TYPE_MOUSEPAD_REQUEST QStringLiteral("kdeconnect.mousepad.request") +#define PACKET_TYPE_MOUSEPAD_REQUEST QStringLiteral("kdeconnect.mousepad.request") class Q_DECL_EXPORT RemoteControlPlugin : public KdeConnectPlugin @@ -37,7 +37,7 @@ explicit RemoteControlPlugin(QObject* parent, const QVariantList &args); ~RemoteControlPlugin() override; - bool receivePackage(const NetworkPackage& /*np*/) override { return false; } + bool receivePacket(const NetworkPacket& /*np*/) override { return false; } void connected() override {} QString dbusPath() const override; diff --git a/plugins/remotecontrol/remotecontrolplugin.cpp b/plugins/remotecontrol/remotecontrolplugin.cpp --- a/plugins/remotecontrol/remotecontrolplugin.cpp +++ b/plugins/remotecontrol/remotecontrolplugin.cpp @@ -44,17 +44,17 @@ void RemoteControlPlugin::moveCursor(const QPoint &p) { - NetworkPackage np(PACKAGE_TYPE_MOUSEPAD_REQUEST, { + NetworkPacket np(PACKET_TYPE_MOUSEPAD_REQUEST, { {"dx", p.x()}, {"dy", p.y()} }); - sendPackage(np); + sendPacket(np); } void RemoteControlPlugin::sendCommand(const QString &name, bool val) { - NetworkPackage np(PACKAGE_TYPE_MOUSEPAD_REQUEST, {{name, val}}); - sendPackage(np); + NetworkPacket np(PACKET_TYPE_MOUSEPAD_REQUEST, {{name, val}}); + sendPacket(np); } QString RemoteControlPlugin::dbusPath() const diff --git a/plugins/remotekeyboard/kdeconnect_remotekeyboard.json b/plugins/remotekeyboard/kdeconnect_remotekeyboard.json --- a/plugins/remotekeyboard/kdeconnect_remotekeyboard.json +++ b/plugins/remotekeyboard/kdeconnect_remotekeyboard.json @@ -75,10 +75,10 @@ ], "Version": "0.1" }, - "X-KdeConnect-OutgoingPackageType": [ + "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.mousepad.request" ], - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.mousepad.echo", "kdeconnect.mousepad.keyboardstate" ] diff --git a/plugins/remotekeyboard/remotekeyboardplugin.h b/plugins/remotekeyboard/remotekeyboardplugin.h --- a/plugins/remotekeyboard/remotekeyboardplugin.h +++ b/plugins/remotekeyboard/remotekeyboardplugin.h @@ -30,9 +30,9 @@ Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_PLUGIN_REMOTEKEYBOARD); -#define PACKAGE_TYPE_MOUSEPAD_REQUEST QLatin1String("kdeconnect.mousepad.request") -#define PACKAGE_TYPE_MOUSEPAD_ECHO QLatin1String("kdeconnect.mousepad.echo") -#define PACKAGE_TYPE_MOUSEPAD_KEYBOARDSTATE QLatin1String("kdeconnect.mousepad.keyboardstate") +#define PACKET_TYPE_MOUSEPAD_REQUEST QLatin1String("kdeconnect.mousepad.request") +#define PACKET_TYPE_MOUSEPAD_ECHO QLatin1String("kdeconnect.mousepad.echo") +#define PACKET_TYPE_MOUSEPAD_KEYBOARDSTATE QLatin1String("kdeconnect.mousepad.keyboardstate") class RemoteKeyboardPlugin : public KdeConnectPlugin @@ -48,7 +48,7 @@ explicit RemoteKeyboardPlugin(QObject* parent, const QVariantList& args); ~RemoteKeyboardPlugin() override; - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; QString dbusPath() const override; void connected() override; diff --git a/plugins/remotekeyboard/remotekeyboardplugin.cpp b/plugins/remotekeyboard/remotekeyboardplugin.cpp --- a/plugins/remotekeyboard/remotekeyboardplugin.cpp +++ b/plugins/remotekeyboard/remotekeyboardplugin.cpp @@ -77,12 +77,12 @@ { } -bool RemoteKeyboardPlugin::receivePackage(const NetworkPackage& np) +bool RemoteKeyboardPlugin::receivePacket(const NetworkPacket& np) { - if (np.type() == PACKAGE_TYPE_MOUSEPAD_ECHO) { + if (np.type() == PACKET_TYPE_MOUSEPAD_ECHO) { if (!np.has("isAck") || !np.has("key")) { qCWarning(KDECONNECT_PLUGIN_REMOTEKEYBOARD) << "Invalid packet of type" - << PACKAGE_TYPE_MOUSEPAD_ECHO; + << PACKET_TYPE_MOUSEPAD_ECHO; return false; } // qCWarning(KDECONNECT_PLUGIN_REMOTEKEYBOARD) << "Received keypress" << np; @@ -92,7 +92,7 @@ np.get("ctrl", false), np.get("alt", false)); return true; - } else if (np.type() == PACKAGE_TYPE_MOUSEPAD_KEYBOARDSTATE) { + } else if (np.type() == PACKET_TYPE_MOUSEPAD_KEYBOARDSTATE) { // qCWarning(KDECONNECT_PLUGIN_REMOTEKEYBOARD) << "Received keyboardstate" << np; if (m_remoteState != np.get("state")) { m_remoteState = np.get("state"); @@ -107,15 +107,15 @@ bool shift, bool ctrl, bool alt, bool sendAck) const { - NetworkPackage np(PACKAGE_TYPE_MOUSEPAD_REQUEST, { + NetworkPacket np(PACKET_TYPE_MOUSEPAD_REQUEST, { {"key", key}, {"specialKey", specialKey}, {"shift", shift}, {"ctrl", ctrl}, {"alt", alt}, {"sendAck", sendAck} }); - sendPackage(np); + sendPacket(np); } void RemoteKeyboardPlugin::sendQKeyEvent(const QVariantMap& keyEvent, bool sendAck) const diff --git a/plugins/runcommand/kdeconnect_runcommand.json b/plugins/runcommand/kdeconnect_runcommand.json --- a/plugins/runcommand/kdeconnect_runcommand.json +++ b/plugins/runcommand/kdeconnect_runcommand.json @@ -98,10 +98,10 @@ "Version": "0.1", "Website": "http://albertvaka.wordpress.com" }, - "X-KdeConnect-OutgoingPackageType": [ + "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.runcommand" ], - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.runcommand.request" ] } diff --git a/plugins/runcommand/runcommandplugin.h b/plugins/runcommand/runcommandplugin.h --- a/plugins/runcommand/runcommandplugin.h +++ b/plugins/runcommand/runcommandplugin.h @@ -39,7 +39,7 @@ explicit RunCommandPlugin(QObject* parent, const QVariantList& args); ~RunCommandPlugin() override; - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; void connected() override; private Q_SLOTS: diff --git a/plugins/runcommand/runcommandplugin.cpp b/plugins/runcommand/runcommandplugin.cpp --- a/plugins/runcommand/runcommandplugin.cpp +++ b/plugins/runcommand/runcommandplugin.cpp @@ -30,10 +30,10 @@ #include #include -#include +#include #include -#define PACKAGE_TYPE_RUNCOMMAND QStringLiteral("kdeconnect.runcommand") +#define PACKET_TYPE_RUNCOMMAND QStringLiteral("kdeconnect.runcommand") K_PLUGIN_FACTORY_WITH_JSON( KdeConnectPluginFactory, "kdeconnect_runcommand.json", registerPlugin< RunCommandPlugin >(); ) @@ -49,7 +49,7 @@ { } -bool RunCommandPlugin::receivePackage(const NetworkPackage& np) +bool RunCommandPlugin::receivePacket(const NetworkPacket& np) { if (np.get(QStringLiteral("requestCommandList"), false)) { sendConfig(); @@ -82,8 +82,8 @@ void RunCommandPlugin::sendConfig() { QString commands = config()->get(QStringLiteral("commands"),QStringLiteral("{}")); - NetworkPackage np(PACKAGE_TYPE_RUNCOMMAND, {{"commandList", commands}}); - sendPackage(np); + NetworkPacket np(PACKET_TYPE_RUNCOMMAND, {{"commandList", commands}}); + sendPacket(np); } void RunCommandPlugin::configChanged() { diff --git a/plugins/screensaver-inhibit/screensaverinhibitplugin.h b/plugins/screensaver-inhibit/screensaverinhibitplugin.h --- a/plugins/screensaver-inhibit/screensaverinhibitplugin.h +++ b/plugins/screensaver-inhibit/screensaverinhibitplugin.h @@ -34,7 +34,7 @@ explicit ScreensaverInhibitPlugin(QObject* parent, const QVariantList& args); ~ScreensaverInhibitPlugin() override; - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; void connected() override; private: diff --git a/plugins/screensaver-inhibit/screensaverinhibitplugin.cpp b/plugins/screensaver-inhibit/screensaverinhibitplugin.cpp --- a/plugins/screensaver-inhibit/screensaverinhibitplugin.cpp +++ b/plugins/screensaver-inhibit/screensaverinhibitplugin.cpp @@ -76,7 +76,7 @@ } -bool ScreensaverInhibitPlugin::receivePackage(const NetworkPackage& np) +bool ScreensaverInhibitPlugin::receivePacket(const NetworkPacket& np) { Q_UNUSED(np); return false; diff --git a/plugins/sendnotifications/kdeconnect_sendnotifications.json b/plugins/sendnotifications/kdeconnect_sendnotifications.json --- a/plugins/sendnotifications/kdeconnect_sendnotifications.json +++ b/plugins/sendnotifications/kdeconnect_sendnotifications.json @@ -87,10 +87,10 @@ "Version": "0.1", "Website": "http://albertvaka.wordpress.com" }, - "X-KdeConnect-OutgoingPackageType": [ + "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.notification" ], - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.notification.request" ] } diff --git a/plugins/sendnotifications/notificationslistener.cpp b/plugins/sendnotifications/notificationslistener.cpp --- a/plugins/sendnotifications/notificationslistener.cpp +++ b/plugins/sendnotifications/notificationslistener.cpp @@ -237,7 +237,7 @@ return 0; //qCDebug(KDECONNECT_PLUGIN_SENDNOTIFICATION) << "Sending notification from" << appName << ":" < 0 ? replacesId : ++id)}, {"appName", appName}, {"ticker", ticker}, @@ -268,7 +268,7 @@ np.setPayload(iconSource, iconSource->size()); } - m_plugin->sendPackage(np); + m_plugin->sendPacket(np); return (replacesId > 0 ? replacesId : id); } diff --git a/plugins/sendnotifications/sendnotificationsplugin.h b/plugins/sendnotifications/sendnotificationsplugin.h --- a/plugins/sendnotifications/sendnotificationsplugin.h +++ b/plugins/sendnotifications/sendnotificationsplugin.h @@ -23,7 +23,7 @@ #include "core/kdeconnectplugin.h" -#define PACKAGE_TYPE_NOTIFICATION QStringLiteral("kdeconnect.notification") +#define PACKET_TYPE_NOTIFICATION QStringLiteral("kdeconnect.notification") /* * This class is just a proxy for NotificationsDbusInterface @@ -42,7 +42,7 @@ explicit SendNotificationsPlugin(QObject* parent, const QVariantList& args); ~SendNotificationsPlugin() override; - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; void connected() override; protected: diff --git a/plugins/sendnotifications/sendnotificationsplugin.cpp b/plugins/sendnotifications/sendnotificationsplugin.cpp --- a/plugins/sendnotifications/sendnotificationsplugin.cpp +++ b/plugins/sendnotifications/sendnotificationsplugin.cpp @@ -40,7 +40,7 @@ delete notificationsListener; } -bool SendNotificationsPlugin::receivePackage(const NetworkPackage& np) +bool SendNotificationsPlugin::receivePacket(const NetworkPacket& np) { Q_UNUSED(np); return true; diff --git a/plugins/sftp/kdeconnect_sftp.json b/plugins/sftp/kdeconnect_sftp.json --- a/plugins/sftp/kdeconnect_sftp.json +++ b/plugins/sftp/kdeconnect_sftp.json @@ -92,10 +92,10 @@ "Version": "0.1", "Website": "http://albertvaka.wordpress.com" }, - "X-KdeConnect-OutgoingPackageType": [ + "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.sftp.request" ], - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.sftp" ] } diff --git a/plugins/sftp/mounter.h b/plugins/sftp/mounter.h --- a/plugins/sftp/mounter.h +++ b/plugins/sftp/mounter.h @@ -46,7 +46,7 @@ void failed(const QString& message); private Q_SLOTS: - void onPakcageReceived(const NetworkPackage& np); + void onPakcageReceived(const NetworkPacket& np); void onStarted(); void onError(QProcess::ProcessError error); void onFinished(int exitCode, QProcess::ExitStatus exitStatus); diff --git a/plugins/sftp/mounter.cpp b/plugins/sftp/mounter.cpp --- a/plugins/sftp/mounter.cpp +++ b/plugins/sftp/mounter.cpp @@ -39,7 +39,7 @@ , m_started(false) { - connect(m_sftp, &SftpPlugin::packageReceived, this, &Mounter::onPakcageReceived); + connect(m_sftp, &SftpPlugin::packetReceived, this, &Mounter::onPakcageReceived); connect(&m_connectTimer, &QTimer::timeout, this, &Mounter::onMountTimeout); @@ -74,7 +74,7 @@ return loop.exec(); } -void Mounter::onPakcageReceived(const NetworkPackage& np) +void Mounter::onPakcageReceived(const NetworkPacket& np) { if (np.get(QStringLiteral("stop"), false)) { @@ -204,8 +204,8 @@ void Mounter::start() { - NetworkPackage np(PACKAGE_TYPE_SFTP_REQUEST, {{"startBrowsing", true}}); - m_sftp->sendPackage(np); + NetworkPacket np(PACKET_TYPE_SFTP_REQUEST, {{"startBrowsing", true}}); + m_sftp->sendPacket(np); m_connectTimer.start(); } diff --git a/plugins/sftp/sftpplugin.h b/plugins/sftp/sftpplugin.h --- a/plugins/sftp/sftpplugin.h +++ b/plugins/sftp/sftpplugin.h @@ -24,7 +24,7 @@ #include #include -#define PACKAGE_TYPE_SFTP_REQUEST QStringLiteral("kdeconnect.sftp.request") +#define PACKET_TYPE_SFTP_REQUEST QStringLiteral("kdeconnect.sftp.request") class KNotification; @@ -38,12 +38,12 @@ explicit SftpPlugin(QObject* parent, const QVariantList& args); ~SftpPlugin() override; - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; void connected() override {} QString dbusPath() const override { return "/modules/kdeconnect/devices/" + deviceId + "/sftp"; } Q_SIGNALS: - void packageReceived(const NetworkPackage& np); + void packetReceived(const NetworkPacket& np); Q_SCRIPTABLE void mounted(); Q_SCRIPTABLE void unmounted(); diff --git a/plugins/sftp/sftpplugin.cpp b/plugins/sftp/sftpplugin.cpp --- a/plugins/sftp/sftpplugin.cpp +++ b/plugins/sftp/sftpplugin.cpp @@ -125,14 +125,14 @@ return false; } -bool SftpPlugin::receivePackage(const NetworkPackage& np) +bool SftpPlugin::receivePacket(const NetworkPacket& np) { if (!(fields_c - np.body().keys().toSet()).isEmpty()) { - // package is invalid + // packet is invalid return false; } - Q_EMIT packageReceived(np); + Q_EMIT packetReceived(np); remoteDirectories.clear(); if (np.has(QStringLiteral("multiPaths"))) { diff --git a/plugins/share/kdeconnect_share.json b/plugins/share/kdeconnect_share.json --- a/plugins/share/kdeconnect_share.json +++ b/plugins/share/kdeconnect_share.json @@ -90,10 +90,10 @@ "Version": "0.1", "Website": "http://albertvaka.wordpress.com" }, - "X-KdeConnect-OutgoingPackageType": [ + "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.share.request" ], - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.share.request" ] } diff --git a/plugins/share/shareplugin.h b/plugins/share/shareplugin.h --- a/plugins/share/shareplugin.h +++ b/plugins/share/shareplugin.h @@ -26,7 +26,7 @@ #include -#define PACKAGE_TYPE_SHARE_REQUEST QStringLiteral("kdeconnect.share.request") +#define PACKET_TYPE_SHARE_REQUEST QStringLiteral("kdeconnect.share.request") class SharePlugin : public KdeConnectPlugin @@ -40,7 +40,7 @@ ///Helper method, QDBus won't recognize QUrl Q_SCRIPTABLE void shareUrl(const QString& url) { shareUrl(QUrl(url)); } - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; void connected() override {} QString dbusPath() const override; diff --git a/plugins/share/shareplugin.cpp b/plugins/share/shareplugin.cpp --- a/plugins/share/shareplugin.cpp +++ b/plugins/share/shareplugin.cpp @@ -69,21 +69,21 @@ return idx>=0 ? filename.mid(idx + 1) : filename; } -bool SharePlugin::receivePackage(const NetworkPackage& np) +bool SharePlugin::receivePacket(const NetworkPacket& np) { /* //TODO: Write a test like this - if (np.type() == PACKAGE_TYPE_PING) { + if (np.type() == PACKET_TYPE_PING) { qCDebug(KDECONNECT_PLUGIN_SHARE) << "sending file" << (QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/.bashrc"); - NetworkPackage out(PACKAGE_TYPE_SHARE_REQUEST); + NetworkPacket out(PACKET_TYPE_SHARE_REQUEST); out.set("filename", mDestinationDir + "itworks.txt"); AutoClosingQFile* file = new AutoClosingQFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/.bashrc"); //Test file to transfer out.setPayload(file, file->size()); - device()->sendPackage(out); + device()->sendPacket(out); return true; @@ -155,15 +155,15 @@ void SharePlugin::shareUrl(const QUrl& url) { - NetworkPackage package(PACKAGE_TYPE_SHARE_REQUEST); + NetworkPacket packet(PACKET_TYPE_SHARE_REQUEST); if(url.isLocalFile()) { QSharedPointer ioFile(new QFile(url.toLocalFile())); - package.setPayload(ioFile, ioFile->size()); - package.set(QStringLiteral("filename"), QUrl(url).fileName()); + packet.setPayload(ioFile, ioFile->size()); + packet.set(QStringLiteral("filename"), QUrl(url).fileName()); } else { - package.set(QStringLiteral("url"), url.toString()); + packet.set(QStringLiteral("url"), url.toString()); } - sendPackage(package); + sendPacket(packet); } QString SharePlugin::dbusPath() const diff --git a/plugins/telephony/kdeconnect_telephony.json b/plugins/telephony/kdeconnect_telephony.json --- a/plugins/telephony/kdeconnect_telephony.json +++ b/plugins/telephony/kdeconnect_telephony.json @@ -88,11 +88,11 @@ "Version": "0.1", "Website": "http://albertvaka.wordpress.com" }, - "X-KdeConnect-OutgoingPackageType": [ + "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.telephony.request", "kdeconnect.sms.request" ], - "X-KdeConnect-SupportedPackageType": [ + "X-KdeConnect-SupportedPacketType": [ "kdeconnect.telephony" ] } diff --git a/plugins/telephony/telephonyplugin.h b/plugins/telephony/telephonyplugin.h --- a/plugins/telephony/telephonyplugin.h +++ b/plugins/telephony/telephonyplugin.h @@ -28,8 +28,8 @@ #include -#define PACKAGE_TYPE_TELEPHONY_REQUEST QStringLiteral("kdeconnect.telephony.request") -#define PACKAGE_TYPE_SMS_REQUEST QStringLiteral("kdeconnect.sms.request") +#define PACKET_TYPE_TELEPHONY_REQUEST QStringLiteral("kdeconnect.telephony.request") +#define PACKET_TYPE_SMS_REQUEST QStringLiteral("kdeconnect.sms.request") Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_PLUGIN_TELEPHONY) @@ -42,19 +42,19 @@ public: explicit TelephonyPlugin(QObject* parent, const QVariantList& args); - bool receivePackage(const NetworkPackage& np) override; + bool receivePacket(const NetworkPacket& np) override; void connected() override {} QString dbusPath() const override; public Q_SLOTS: Q_SCRIPTABLE void sendSms(const QString& phoneNumber, const QString& messageBody); private Q_SLOTS: - void sendMutePackage(); + void sendMutePacket(); void showSendSmsDialog(); private: - KNotification* createNotification(const NetworkPackage& np); + KNotification* createNotification(const NetworkPacket& np); QDBusInterface m_telepathyInterface; }; diff --git a/plugins/telephony/telephonyplugin.cpp b/plugins/telephony/telephonyplugin.cpp --- a/plugins/telephony/telephonyplugin.cpp +++ b/plugins/telephony/telephonyplugin.cpp @@ -39,7 +39,7 @@ { } -KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np) +KNotification* TelephonyPlugin::createNotification(const NetworkPacket& np) { const QString event = np.get(QStringLiteral("event")); const QString phoneNumber = np.get(QStringLiteral("phoneNumber"), i18n("unknown number")); @@ -107,7 +107,7 @@ if (event == QLatin1String("ringing")) { notification->setActions( QStringList(i18n("Mute Call")) ); - connect(notification, &KNotification::action1Activated, this, &TelephonyPlugin::sendMutePackage); + connect(notification, &KNotification::action1Activated, this, &TelephonyPlugin::sendMutePacket); } else if (event == QLatin1String("sms")) { const QString messageBody = np.get(QStringLiteral("messageBody"),QLatin1String("")); notification->setActions( QStringList(i18n("Reply")) ); @@ -121,7 +121,7 @@ } -bool TelephonyPlugin::receivePackage(const NetworkPackage& np) +bool TelephonyPlugin::receivePacket(const NetworkPacket& np) { if (np.get(QStringLiteral("isCancel"))) { @@ -135,20 +135,20 @@ return true; } -void TelephonyPlugin::sendMutePackage() +void TelephonyPlugin::sendMutePacket() { - NetworkPackage package(PACKAGE_TYPE_TELEPHONY_REQUEST, {{"action", "mute"}}); - sendPackage(package); + NetworkPacket packet(PACKET_TYPE_TELEPHONY_REQUEST, {{"action", "mute"}}); + sendPacket(packet); } void TelephonyPlugin::sendSms(const QString& phoneNumber, const QString& messageBody) { - NetworkPackage np(PACKAGE_TYPE_SMS_REQUEST, { + NetworkPacket np(PACKET_TYPE_SMS_REQUEST, { {"sendSms", true}, {"phoneNumber", phoneNumber}, {"messageBody", messageBody} }); - sendPackage(np); + sendPacket(np); } void TelephonyPlugin::showSendSmsDialog() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -18,7 +18,7 @@ ecm_add_test(pluginloadtest.cpp LINK_LIBRARIES ${kdeconnect_libraries}) ecm_add_test(sendfiletest.cpp LINK_LIBRARIES ${kdeconnect_libraries}) -ecm_add_test(networkpackagetests.cpp LINK_LIBRARIES ${kdeconnect_libraries}) +ecm_add_test(networkpackettests.cpp LINK_LIBRARIES ${kdeconnect_libraries}) ecm_add_test(testsocketlinereader.cpp TEST_NAME testsocketlinereader LINK_LIBRARIES ${kdeconnect_libraries}) ecm_add_test(testsslsocketlinereader.cpp TEST_NAME testsslsocketlinereader LINK_LIBRARIES ${kdeconnect_libraries}) ecm_add_test(kdeconnectconfigtest.cpp TEST_NAME kdeconnectconfigtest LINK_LIBRARIES ${kdeconnect_libraries}) diff --git a/tests/devicetest.cpp b/tests/devicetest.cpp --- a/tests/devicetest.cpp +++ b/tests/devicetest.cpp @@ -42,18 +42,18 @@ QString deviceId; QString deviceName; QString deviceType; - NetworkPackage* identityPackage; + NetworkPacket* identityPacket; }; void DeviceTest::initTestCase() { deviceId = QStringLiteral("testdevice"); deviceName = QStringLiteral("Test Device"); deviceType = QStringLiteral("smartphone"); - QString stringPackage = QStringLiteral("{\"id\":1439365924847,\"type\":\"kdeconnect.identity\",\"body\":{\"deviceId\":\"testdevice\",\"deviceName\":\"Test Device\",\"protocolVersion\":6,\"deviceType\":\"phone\"}}"); - identityPackage = new NetworkPackage(QStringLiteral("kdeconnect.identity")); - NetworkPackage::unserialize(stringPackage.toLatin1(), identityPackage); + QString stringPacket = QStringLiteral("{\"id\":1439365924847,\"type\":\"kdeconnect.identity\",\"body\":{\"deviceId\":\"testdevice\",\"deviceName\":\"Test Device\",\"protocolVersion\":6,\"deviceType\":\"phone\"}}"); + identityPacket = new NetworkPacket(QStringLiteral("kdeconnect.identity")); + NetworkPacket::unserialize(stringPacket.toLatin1(), identityPacket); } void DeviceTest::testPairedDevice() @@ -76,7 +76,7 @@ LanLinkProvider linkProvider; QSslSocket socket; LanDeviceLink* link = new LanDeviceLink(deviceId, &linkProvider, &socket, LanDeviceLink::Locally); - device.addLink(*identityPackage, link); + device.addLink(*identityPacket, link); QCOMPARE(device.isReachable(), true); QCOMPARE(device.availableLinks().contains(linkProvider.name()), true); @@ -98,7 +98,7 @@ QSslSocket socket; LanDeviceLink* link = new LanDeviceLink(deviceId, &linkProvider, &socket, LanDeviceLink::Locally); - Device device(this, *identityPackage, link); + Device device(this, *identityPacket, link); QCOMPARE(device.id(), deviceId); QCOMPARE(device.name(), deviceName); @@ -118,7 +118,7 @@ void DeviceTest::cleanupTestCase() { - delete identityPackage; + delete identityPacket; } QTEST_GUILESS_MAIN(DeviceTest) diff --git a/tests/lanlinkprovidertest.cpp b/tests/lanlinkprovidertest.cpp --- a/tests/lanlinkprovidertest.cpp +++ b/tests/lanlinkprovidertest.cpp @@ -33,7 +33,7 @@ #include /* - * This class tests the working of LanLinkProvider under different conditions that when identity package is received over TCP, over UDP and same when the device is paired. + * This class tests the working of LanLinkProvider under different conditions that when identity packet is received over TCP, over UDP and same when the device is paired. * It depends on KdeConnectConfig since LanLinkProvider internally uses it. */ class LanLinkProviderTest : public QObject @@ -50,11 +50,11 @@ private Q_SLOTS: - void pairedDeviceTcpPackageReceived(); - void pairedDeviceUdpPackageReceived(); + void pairedDeviceTcpPacketReceived(); + void pairedDeviceUdpPacketReceived(); - void unpairedDeviceTcpPackageReceived(); - void unpairedDeviceUdpPackageReceived(); + void unpairedDeviceTcpPacketReceived(); + void unpairedDeviceUdpPacketReceived(); private: @@ -64,7 +64,7 @@ Server* m_server; SocketLineReader* m_reader; QUdpSocket* m_udpSocket; - QString m_identityPackage; + QString m_identityPacket; // Attributes for test device QString m_deviceId; @@ -76,7 +76,7 @@ void addTrustedDevice(); void removeTrustedDevice(); void setSocketAttributes(QSslSocket* socket); - void testIdentityPackage(QByteArray& identityPackage); + void testIdentityPacket(QByteArray& identityPacket); }; @@ -91,10 +91,10 @@ m_lanLinkProvider.onStart(); - m_identityPackage = QStringLiteral("{\"id\":1439365924847,\"type\":\"kdeconnect.identity\",\"body\":{\"deviceId\":\"testdevice\",\"deviceName\":\"Test Device\",\"protocolVersion\":6,\"deviceType\":\"phone\",\"tcpPort\":") + QString::number(TEST_PORT) + QStringLiteral("}}"); + m_identityPacket = QStringLiteral("{\"id\":1439365924847,\"type\":\"kdeconnect.identity\",\"body\":{\"deviceId\":\"testdevice\",\"deviceName\":\"Test Device\",\"protocolVersion\":6,\"deviceType\":\"phone\",\"tcpPort\":") + QString::number(TEST_PORT) + QStringLiteral("}}"); } -void LanLinkProviderTest::pairedDeviceTcpPackageReceived() +void LanLinkProviderTest::pairedDeviceTcpPacketReceived() { KdeConnectConfig* kcc = KdeConnectConfig::instance(); addTrustedDevice(); @@ -113,7 +113,7 @@ mUdpServer->readDatagram(datagram.data(), datagram.size(), &sender); - testIdentityPackage(datagram); + testIdentityPacket(datagram); QJsonDocument jsonDocument = QJsonDocument::fromJson(datagram); QJsonObject body = jsonDocument.object().value(QStringLiteral("body")).toObject(); @@ -127,7 +127,7 @@ QVERIFY2(socket.isOpen(), "Socket disconnected immediately"); - socket.write(m_identityPackage.toLatin1()); + socket.write(m_identityPacket.toLatin1()); socket.waitForBytesWritten(2000); QSignalSpy spy3(&socket, SIGNAL(encrypted())); @@ -149,7 +149,7 @@ delete mUdpServer; } -void LanLinkProviderTest::pairedDeviceUdpPackageReceived() +void LanLinkProviderTest::pairedDeviceUdpPacketReceived() { KdeConnectConfig* kcc = KdeConnectConfig::instance(); addTrustedDevice(); @@ -161,8 +161,8 @@ QSignalSpy spy(m_server, SIGNAL(newConnection())); - qint64 bytesWritten = m_udpSocket->writeDatagram(m_identityPackage.toLatin1(), QHostAddress::LocalHost, LanLinkProvider::UDP_PORT); // write an identity package to udp socket here, we do not broadcast it here - QCOMPARE(bytesWritten, m_identityPackage.size()); + qint64 bytesWritten = m_udpSocket->writeDatagram(m_identityPacket.toLatin1(), QHostAddress::LocalHost, LanLinkProvider::UDP_PORT); // write an identity packet to udp socket here, we do not broadcast it here + QCOMPARE(bytesWritten, m_identityPacket.size()); // We should have an incoming connection now, wait for incoming connection QVERIFY(!spy.isEmpty() || spy.wait()); @@ -176,9 +176,9 @@ QSignalSpy spy2(m_reader, SIGNAL(readyRead())); QVERIFY(spy2.wait()); - QByteArray receivedPackage = m_reader->readLine(); - testIdentityPackage(receivedPackage); - // Received identiy package from LanLinkProvider now start ssl + QByteArray receivedPacket = m_reader->readLine(); + testIdentityPacket(receivedPacket); + // Received identiy packet from LanLinkProvider now start ssl QSignalSpy spy3(serverSocket, SIGNAL(encrypted())); QVERIFY(connect(serverSocket, static_cast(&QSslSocket::error), @@ -205,7 +205,7 @@ delete m_udpSocket; } -void LanLinkProviderTest::unpairedDeviceTcpPackageReceived() +void LanLinkProviderTest::unpairedDeviceTcpPacketReceived() { QUdpSocket* mUdpServer = new QUdpSocket; bool b = mUdpServer->bind(QHostAddress::LocalHost, LanLinkProvider::UDP_PORT, QUdpSocket::ShareAddress); @@ -221,7 +221,7 @@ mUdpServer->readDatagram(datagram.data(), datagram.size(), &sender); - testIdentityPackage(datagram); + testIdentityPacket(datagram); QJsonDocument jsonDocument = QJsonDocument::fromJson(datagram); QJsonObject body = jsonDocument.object().value(QStringLiteral("body")).toObject(); @@ -235,7 +235,7 @@ QVERIFY2(socket.isOpen(), "Socket disconnected immediately"); - socket.write(m_identityPackage.toLatin1()); + socket.write(m_identityPacket.toLatin1()); socket.waitForBytesWritten(2000); QSignalSpy spy3(&socket, SIGNAL(encrypted())); @@ -255,16 +255,16 @@ delete mUdpServer; } -void LanLinkProviderTest::unpairedDeviceUdpPackageReceived() +void LanLinkProviderTest::unpairedDeviceUdpPacketReceived() { m_server = new Server(this); m_udpSocket = new QUdpSocket(this); m_server->listen(QHostAddress::LocalHost, TEST_PORT); QSignalSpy spy(m_server, &Server::newConnection); - qint64 bytesWritten = m_udpSocket->writeDatagram(m_identityPackage.toLatin1(), QHostAddress::LocalHost, LanLinkProvider::UDP_PORT); // write an identity package to udp socket here, we do not broadcast it here - QCOMPARE(bytesWritten, m_identityPackage.size()); + qint64 bytesWritten = m_udpSocket->writeDatagram(m_identityPacket.toLatin1(), QHostAddress::LocalHost, LanLinkProvider::UDP_PORT); // write an identity packet to udp socket here, we do not broadcast it here + QCOMPARE(bytesWritten, m_identityPacket.size()); QVERIFY(!spy.isEmpty() || spy.wait()); @@ -277,12 +277,12 @@ QSignalSpy spy2(m_reader, &SocketLineReader::readyRead); QVERIFY(spy2.wait()); - QByteArray receivedPackage = m_reader->readLine(); - QVERIFY2(!receivedPackage.isEmpty(), "Empty package received"); + QByteArray receivedPacket = m_reader->readLine(); + QVERIFY2(!receivedPacket.isEmpty(), "Empty packet received"); - testIdentityPackage(receivedPackage); + testIdentityPacket(receivedPacket); - // Received identity package from LanLinkProvider now start ssl + // Received identity packet from LanLinkProvider now start ssl QSignalSpy spy3(serverSocket, SIGNAL(encrypted())); @@ -299,17 +299,17 @@ delete m_udpSocket; } -void LanLinkProviderTest::testIdentityPackage(QByteArray& identityPackage) +void LanLinkProviderTest::testIdentityPacket(QByteArray& identityPacket) { - QJsonDocument jsonDocument = QJsonDocument::fromJson(identityPackage); + QJsonDocument jsonDocument = QJsonDocument::fromJson(identityPacket); QJsonObject jsonObject = jsonDocument.object(); QJsonObject body = jsonObject.value(QStringLiteral("body")).toObject(); QCOMPARE(jsonObject.value("type").toString(), QString("kdeconnect.identity")); - QVERIFY2(body.contains("deviceName"), "Device name not found in identity package"); - QVERIFY2(body.contains("deviceId"), "Device id not found in identity package"); - QVERIFY2(body.contains("protocolVersion"), "Protocol version not found in identity package"); - QVERIFY2(body.contains("deviceType"), "Device type not found in identity package"); + QVERIFY2(body.contains("deviceName"), "Device name not found in identity packet"); + QVERIFY2(body.contains("deviceId"), "Device id not found in identity packet"); + QVERIFY2(body.contains("protocolVersion"), "Protocol version not found in identity packet"); + QVERIFY2(body.contains("deviceType"), "Device type not found in identity packet"); } QSslCertificate LanLinkProviderTest::generateCertificate(QString& commonName, QCA::PrivateKey& privateKey) diff --git a/tests/networkpackagetests.h b/tests/networkpackettests.h rename from tests/networkpackagetests.h rename to tests/networkpackettests.h --- a/tests/networkpackagetests.h +++ b/tests/networkpackettests.h @@ -18,21 +18,21 @@ * along with this program. If not, see . */ -#ifndef NETWORKPACKAGETESTS_H -#define NETWORKPACKAGETESTS_H +#ifndef NETWORKPACKETTESTS_H +#define NETWORKPACKETTESTS_H #include -class NetworkPackageTests : public QObject +class NetworkPacketTests : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); - void networkPackageTest(); - void networkPackageIdentityTest(); - //void networkPackageEncryptionTest(); + void networkPacketTest(); + void networkPacketIdentityTest(); + //void networkPacketEncryptionTest(); void cleanupTestCase(); diff --git a/tests/networkpackagetests.cpp b/tests/networkpackettests.cpp rename from tests/networkpackagetests.cpp rename to tests/networkpackettests.cpp --- a/tests/networkpackagetests.cpp +++ b/tests/networkpackettests.cpp @@ -18,23 +18,23 @@ * along with this program. If not, see . */ -#include "networkpackagetests.h" +#include "networkpackettests.h" -#include "core/networkpackage.h" +#include "core/networkpacket.h" #include #include -QTEST_GUILESS_MAIN(NetworkPackageTests); +QTEST_GUILESS_MAIN(NetworkPacketTests); -void NetworkPackageTests::initTestCase() +void NetworkPacketTests::initTestCase() { // Called before the first testfunction is executed } -void NetworkPackageTests::networkPackageTest() +void NetworkPacketTests::networkPacketTest() { - NetworkPackage np(QStringLiteral("com.test")); + NetworkPacket np(QStringLiteral("com.test")); np.set(QStringLiteral("hello"),"hola"); QCOMPARE( (np.get("hello","bye")) , QString("hola") ); @@ -47,49 +47,49 @@ np.set(QStringLiteral("foo"), "bar"); QByteArray ba = np.serialize(); - //qDebug() << "Serialized package:" << ba; - NetworkPackage np2(QLatin1String("")); - NetworkPackage::unserialize(ba,&np2); + //qDebug() << "Serialized packet:" << ba; + NetworkPacket np2(QLatin1String("")); + NetworkPacket::unserialize(ba,&np2); QCOMPARE( np.id(), np2.id() ); QCOMPARE( np.type(), np2.type() ); QCOMPARE( np.body(), np2.body() ); QByteArray json("{\"id\":\"123\",\"type\":\"test\",\"body\":{\"testing\":true}}"); //qDebug() << json; - NetworkPackage::unserialize(json,&np2); + NetworkPacket::unserialize(json,&np2); QCOMPARE( np2.id(), QString("123") ); QCOMPARE( (np2.get("testing")), true ); QCOMPARE( (np2.get("not_testing")), false ); QCOMPARE( (np2.get("not_testing",true)), true ); - //NetworkPackage::unserialize("this is not json",&np2); + //NetworkPacket::unserialize("this is not json",&np2); //QtTest::ignoreMessage(QtSystemMsg, "json_parser - syntax error found, forcing abort, Line 1 Column 0"); //QtTest::ignoreMessage(QtDebugMsg, "Unserialization error: 1 \"syntax error, unexpected string\""); } -void NetworkPackageTests::networkPackageIdentityTest() +void NetworkPacketTests::networkPacketIdentityTest() { - NetworkPackage np(QLatin1String("")); - NetworkPackage::createIdentityPackage(&np); + NetworkPacket np(QLatin1String("")); + NetworkPacket::createIdentityPacket(&np); - QCOMPARE( np.get("protocolVersion", -1) , NetworkPackage::s_protocolVersion ); - QCOMPARE( np.type() , PACKAGE_TYPE_IDENTITY ); + QCOMPARE( np.get("protocolVersion", -1) , NetworkPacket::s_protocolVersion ); + QCOMPARE( np.type() , PACKET_TYPE_IDENTITY ); } -void NetworkPackageTests::cleanupTestCase() +void NetworkPacketTests::cleanupTestCase() { // Called after the last testfunction was executed } -void NetworkPackageTests::init() +void NetworkPacketTests::init() { // Called before each testfunction is executed } -void NetworkPackageTests::cleanup() +void NetworkPacketTests::cleanup() { // Called after every testfunction } diff --git a/tests/testnotificationlistener.cpp b/tests/testnotificationlistener.cpp --- a/tests/testnotificationlistener.cpp +++ b/tests/testnotificationlistener.cpp @@ -67,49 +67,49 @@ { Q_OBJECT private: - int sentPackages; - NetworkPackage* lastPackage; + int sentPackets; + NetworkPacket* lastPacket; public: explicit TestDevice(QObject* parent, const QString& id) : Device (parent, id) - , sentPackages(0) - , lastPackage(nullptr) + , sentPackets(0) + , lastPacket(nullptr) {} ~TestDevice() override { - delete lastPackage; + delete lastPacket; } - int getSentPackages() const + int getSentPackets() const { - return sentPackages; + return sentPackets; } - NetworkPackage* getLastPackage() + NetworkPacket* getLastPacket() { - return lastPackage; + return lastPacket; } - void deleteLastPackage() + void deleteLastPacket() { - delete lastPackage; - lastPackage = nullptr; + delete lastPacket; + lastPacket = nullptr; } public Q_SLOTS: - bool sendPackage(NetworkPackage& np) override + bool sendPacket(NetworkPacket& np) override { - ++sentPackages; - // copy package manually to allow for inspection (can't use copy-constructor) - deleteLastPackage(); - lastPackage = new NetworkPackage(np.type()); - Q_ASSERT(lastPackage); + ++sentPackets; + // copy packet manually to allow for inspection (can't use copy-constructor) + deleteLastPacket(); + lastPacket = new NetworkPacket(np.type()); + Q_ASSERT(lastPacket); for (QVariantMap::ConstIterator iter = np.body().constBegin(); iter != np.body().constEnd(); iter++) - lastPackage->set(iter.key(), iter.value()); - lastPackage->setPayload(np.payload(), np.payloadSize()); + lastPacket->set(iter.key(), iter.value()); + lastPacket->setPayload(np.payload(), np.payloadSize()); return true; } }; @@ -181,7 +181,7 @@ TestDevice* d = new TestDevice(nullptr, dId); int proxiedNotifications = 0; - QCOMPARE(proxiedNotifications, d->getSentPackages()); + QCOMPARE(proxiedNotifications, d->getSentPackets()); plugin = new TestNotificationsPlugin(this, QVariantList({ QVariant::fromValue(d), "notifications_plugin", @@ -222,14 +222,14 @@ retId = listener->Notify(appName, replacesId, icon, summary, body, {}, {{}}, 0); // ... should return replacesId, QCOMPARE(retId, replacesId); - // ... have triggered sending a package - QCOMPARE(++proxiedNotifications, d->getSentPackages()); + // ... have triggered sending a packet + QCOMPARE(++proxiedNotifications, d->getSentPackets()); // ... with our properties, - QCOMPARE(d->getLastPackage()->get("id"), replacesId); - QCOMPARE(d->getLastPackage()->get("appName"), appName); - QCOMPARE(d->getLastPackage()->get("ticker"), summary + ": " + body); - QCOMPARE(d->getLastPackage()->get("isClearable"), true); - QCOMPARE(d->getLastPackage()->hasPayload(), false); + QCOMPARE(d->getLastPacket()->get("id"), replacesId); + QCOMPARE(d->getLastPacket()->get("appName"), appName); + QCOMPARE(d->getLastPacket()->get("ticker"), summary + ": " + body); + QCOMPARE(d->getLastPacket()->get("isClearable"), true); + QCOMPARE(d->getLastPacket()->hasPayload(), false); // ... and create a new application internally that is initialized correctly: QCOMPARE(listener->getApplications().count(), 1); @@ -248,107 +248,107 @@ retId = listener->Notify(appName2, replacesId+1, icon2, summary2, body2, {}, {{"urgency", 2}}, 10); QCOMPARE(retId, replacesId+1); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); - QCOMPARE(d->getLastPackage()->get("id"), replacesId+1); - QCOMPARE(d->getLastPackage()->get("appName"), appName2); - QCOMPARE(d->getLastPackage()->get("ticker"), summary2 + ": " + body2); - QCOMPARE(d->getLastPackage()->get("isClearable"), false); // timeout != 0 - QCOMPARE(d->getLastPackage()->hasPayload(), false); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); + QCOMPARE(d->getLastPacket()->get("id"), replacesId+1); + QCOMPARE(d->getLastPacket()->get("appName"), appName2); + QCOMPARE(d->getLastPacket()->get("ticker"), summary2 + ": " + body2); + QCOMPARE(d->getLastPacket()->get("isClearable"), false); // timeout != 0 + QCOMPARE(d->getLastPacket()->hasPayload(), false); QCOMPARE(listener->getApplications().count(), 2); QVERIFY(listener->getApplications().contains(appName2)); QVERIFY(listener->getApplications().contains(appName)); // if persistent-only is set, timeouts > 0 are not synced: plugin->config()->set(QStringLiteral("generalPersistent"), true); retId = listener->Notify(appName, replacesId, icon, summary, body, {}, {{}}, 1); QCOMPARE(retId, 0U); - QCOMPARE(proxiedNotifications, d->getSentPackages()); + QCOMPARE(proxiedNotifications, d->getSentPackets()); retId = listener->Notify(appName2, replacesId, icon2, summary2, body2, {}, {{}}, 3); QCOMPARE(retId, 0U); - QCOMPARE(proxiedNotifications, d->getSentPackages()); + QCOMPARE(proxiedNotifications, d->getSentPackets()); // but timeout == 0 is retId = listener->Notify(appName, replacesId, icon, summary, body, {}, {{}}, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); plugin->config()->set(QStringLiteral("generalPersistent"), false); // if min-urgency is set, lower urgency levels are not synced: plugin->config()->set(QStringLiteral("generalUrgency"), 1); retId = listener->Notify(appName, replacesId, icon, summary, body, {}, {{"urgency", 0}}, 0); QCOMPARE(retId, 0U); - QCOMPARE(proxiedNotifications, d->getSentPackages()); + QCOMPARE(proxiedNotifications, d->getSentPackets()); // equal urgency is retId = listener->Notify(appName, replacesId, icon, summary, body, {}, {{"urgency", 1}}, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); // higher urgency as well retId = listener->Notify(appName, replacesId, icon, summary, body, {}, {{"urgency", 2}}, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); plugin->config()->set(QStringLiteral("generalUrgency"), 0); // notifications for a deactivated application are not synced: QVERIFY(listener->getApplications().contains(appName)); listener->getApplications()[appName].active = false; QVERIFY(!listener->getApplications()[appName].active); retId = listener->Notify(appName, replacesId, icon, summary, body, {}, {{"urgency", 0}}, 0); QCOMPARE(retId, 0U); - QCOMPARE(proxiedNotifications, d->getSentPackages()); + QCOMPARE(proxiedNotifications, d->getSentPackets()); // others are still: retId = listener->Notify(appName2, replacesId+1, icon2, summary2, body2, {}, {{}}, 0); QCOMPARE(retId, replacesId+1); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); // back to normal: listener->getApplications()[appName].active = true; QVERIFY(listener->getApplications()[appName].active); retId = listener->Notify(appName, replacesId, icon, summary, body, {}, {{}}, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); // notifications with blacklisted subjects are not synced: QVERIFY(listener->getApplications().contains(appName)); listener->getApplications()[appName].blacklistExpression.setPattern(QStringLiteral("black[12]|foo(bar|baz)")); retId = listener->Notify(appName, replacesId, icon, QStringLiteral("summary black1"), body, {}, {{}}, 0); QCOMPARE(retId, 0U); - QCOMPARE(proxiedNotifications, d->getSentPackages()); + QCOMPARE(proxiedNotifications, d->getSentPackets()); retId = listener->Notify(appName, replacesId, icon, QStringLiteral("summary foobar"), body, {}, {{}}, 0); QCOMPARE(retId, 0U); - QCOMPARE(proxiedNotifications, d->getSentPackages()); + QCOMPARE(proxiedNotifications, d->getSentPackets()); // other subjects are synced: retId = listener->Notify(appName, replacesId, icon, QStringLiteral("summary foo"), body, {}, {{}}, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); retId = listener->Notify(appName, replacesId, icon, QStringLiteral("summary black3"), body, {}, {{}}, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); // also body is checked by blacklist if requested: plugin->config()->set(QStringLiteral("generalIncludeBody"), true); retId = listener->Notify(appName, replacesId, icon, summary, QStringLiteral("body black1"), {}, {{}}, 0); QCOMPARE(retId, 0U); - QCOMPARE(proxiedNotifications, d->getSentPackages()); + QCOMPARE(proxiedNotifications, d->getSentPackets()); retId = listener->Notify(appName, replacesId, icon, summary, QStringLiteral("body foobaz"), {}, {{}}, 0); QCOMPARE(retId, 0U); - QCOMPARE(proxiedNotifications, d->getSentPackages()); + QCOMPARE(proxiedNotifications, d->getSentPackets()); // body does not matter if inclusion was not requested: plugin->config()->set(QStringLiteral("generalIncludeBody"), false); retId = listener->Notify(appName, replacesId, icon, summary, QStringLiteral("body black1"), {}, {{}}, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); // without body, also ticker value is different: - QCOMPARE(d->getLastPackage()->get("ticker"), summary); + QCOMPARE(d->getLastPacket()->get("ticker"), summary); retId = listener->Notify(appName, replacesId, icon, summary, QStringLiteral("body foobaz"), {}, {{}}, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); // back to normal: listener->getApplications()[appName].blacklistExpression.setPattern(QLatin1String("")); plugin->config()->set(QStringLiteral("generalIncludeBody"), true); retId = listener->Notify(appName, replacesId, icon, summary, body, {}, {{}}, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); retId = listener->Notify(appName2, replacesId, icon2, summary2, body2, {}, {{}}, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); // icon synchronization: QStringList iconPaths; @@ -367,51 +367,51 @@ QFileInfo fi(iconName); retId = listener->Notify(appName, replacesId, fi.baseName(), summary, body, {}, {{}}, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); - QVERIFY(d->getLastPackage()->hasPayload()); - QCOMPARE(d->getLastPackage()->payloadSize(), fi.size()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); + QVERIFY(d->getLastPacket()->hasPayload()); + QCOMPARE(d->getLastPacket()->payloadSize(), fi.size()); // works also with abolute paths retId = listener->Notify(appName, replacesId, iconName, summary, body, {}, {{}}, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); - QVERIFY(d->getLastPackage()->hasPayload()); - QCOMPARE(d->getLastPackage()->payloadSize(), fi.size()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); + QVERIFY(d->getLastPacket()->hasPayload()); + QCOMPARE(d->getLastPacket()->payloadSize(), fi.size()); // extensions other than png are not accepted: retId = listener->Notify(appName, replacesId, iconName + ".svg", summary, body, {}, {{}}, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); - QVERIFY(!d->getLastPackage()->hasPayload()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); + QVERIFY(!d->getLastPacket()->hasPayload()); // if sync not requested no payload: plugin->config()->set(QStringLiteral("generalSynchronizeIcons"), false); retId = listener->Notify(appName, replacesId, fi.baseName(), summary, body, {}, {{}}, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); - QVERIFY(!d->getLastPackage()->hasPayload()); - QCOMPARE(d->getLastPackage()->payloadSize(), 0); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); + QVERIFY(!d->getLastPacket()->hasPayload()); + QCOMPARE(d->getLastPacket()->payloadSize(), 0); } plugin->config()->set(QStringLiteral("generalSynchronizeIcons"), true); // image-path in hints if (iconPaths.size() > 0) { retId = listener->Notify(appName, replacesId, iconPaths.size() > 1 ? iconPaths[1] : icon, summary, body, {}, {{"image-path", iconPaths[0]}}, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); - QVERIFY(d->getLastPackage()->hasPayload()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); + QVERIFY(d->getLastPacket()->hasPayload()); QFileInfo hintsFi(iconPaths[0]); // image-path has priority over appIcon parameter: - QCOMPARE(d->getLastPackage()->payloadSize(), hintsFi.size()); + QCOMPARE(d->getLastPacket()->payloadSize(), hintsFi.size()); } // image_path in hints if (iconPaths.size() > 0) { retId = listener->Notify(appName, replacesId, iconPaths.size() > 1 ? iconPaths[1] : icon, summary, body, {}, {{"image_path", iconPaths[0]}}, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); - QVERIFY(d->getLastPackage()->hasPayload()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); + QVERIFY(d->getLastPacket()->hasPayload()); QFileInfo hintsFi(iconPaths[0]); // image_path has priority over appIcon parameter: - QCOMPARE(d->getLastPackage()->payloadSize(), hintsFi.size()); + QCOMPARE(d->getLastPacket()->payloadSize(), hintsFi.size()); } // image-data in hints @@ -440,10 +440,10 @@ hints.insert(QStringLiteral("image-path"), iconPaths[0]); retId = listener->Notify(appName, replacesId, icon, summary, body, {}, hints, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); - QVERIFY(d->getLastPackage()->hasPayload()); - buffer = dynamic_cast(d->getLastPackage()->payload().data()); - QCOMPARE(d->getLastPackage()->payloadSize(), buffer->size()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); + QVERIFY(d->getLastPacket()->hasPayload()); + buffer = dynamic_cast(d->getLastPacket()->payload().data()); + QCOMPARE(d->getLastPacket()->payloadSize(), buffer->size()); // image-data is attached as png data QVERIFY(image.loadFromData(reinterpret_cast(buffer->data().constData()), buffer->size(), "PNG")); // image-data has priority over image-path: @@ -461,10 +461,10 @@ hints.insert(QStringLiteral("image_path"), iconPaths[0]); retId = listener->Notify(appName, replacesId, icon, summary, body, {}, hints, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); - QVERIFY(d->getLastPackage()->hasPayload()); - buffer = dynamic_cast(d->getLastPackage()->payload().data()); - QCOMPARE(d->getLastPackage()->payloadSize(), buffer->size()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); + QVERIFY(d->getLastPacket()->hasPayload()); + buffer = dynamic_cast(d->getLastPacket()->payload().data()); + QCOMPARE(d->getLastPacket()->payloadSize(), buffer->size()); // image-data is attached as png data QVERIFY(image.loadFromData(reinterpret_cast(buffer->data().constData()), buffer->size(), "PNG")); // image_data has priority over image_path/image-path: @@ -480,10 +480,10 @@ hints.insert(QStringLiteral("icon_data"), imageData); retId = listener->Notify(appName, replacesId, QLatin1String(""), summary, body, {}, hints, 0); QCOMPARE(retId, replacesId); - QCOMPARE(++proxiedNotifications, d->getSentPackages()); - QVERIFY(d->getLastPackage()); - QVERIFY(d->getLastPackage()->hasPayload()); - buffer = dynamic_cast(d->getLastPackage()->payload().data()); + QCOMPARE(++proxiedNotifications, d->getSentPackets()); + QVERIFY(d->getLastPacket()); + QVERIFY(d->getLastPacket()->hasPayload()); + buffer = dynamic_cast(d->getLastPacket()->payload().data()); // image-data is attached as png data QVERIFY(image.loadFromData(reinterpret_cast(buffer->data().constData()), buffer->size(), "PNG")); QCOMPARE(image.byteCount(), rowStride*height); diff --git a/tests/testsocketlinereader.cpp b/tests/testsocketlinereader.cpp --- a/tests/testsocketlinereader.cpp +++ b/tests/testsocketlinereader.cpp @@ -30,15 +30,15 @@ Q_OBJECT public Q_SLOTS: void initTestCase(); - void newPackage(); + void newPacket(); private Q_SLOTS: void socketLineReader(); private: QTimer m_timer; QEventLoop m_loop; - QList m_packages; + QList m_packets; Server* m_server; QSslSocket* m_conn; SocketLineReader* m_reader; @@ -83,34 +83,34 @@ QVERIFY2(sock != nullptr, "Could not open a connection to the client"); m_reader = new SocketLineReader(sock, this); - connect(m_reader, &SocketLineReader::readyRead, this, &TestSocketLineReader::newPackage); + connect(m_reader, &SocketLineReader::readyRead, this, &TestSocketLineReader::newPacket); m_timer.start(); m_loop.exec(); /* remove the empty line before compare */ dataToSend.removeOne("\n"); - QCOMPARE(m_packages.count(), 5);//We expect 5 Packages + QCOMPARE(m_packets.count(), 5);//We expect 5 Packets for(int x = 0;x < 5; ++x) { - QCOMPARE(m_packages[x], dataToSend[x]); + QCOMPARE(m_packets[x], dataToSend[x]); } } -void TestSocketLineReader::newPackage() +void TestSocketLineReader::newPacket() { if (!m_reader->bytesAvailable()) { return; } int maxLoops = 5; while(m_reader->bytesAvailable() > 0 && maxLoops > 0) { --maxLoops; - const QByteArray package = m_reader->readLine(); - if (!package.isEmpty()) { - m_packages.append(package); + const QByteArray packet = m_reader->readLine(); + if (!packet.isEmpty()) { + m_packets.append(packet); } - if (m_packages.count() == 5) { + if (m_packets.count() == 5) { m_loop.exit(); } } diff --git a/tests/testsslsocketlinereader.cpp b/tests/testsslsocketlinereader.cpp --- a/tests/testsslsocketlinereader.cpp +++ b/tests/testsslsocketlinereader.cpp @@ -34,7 +34,7 @@ { Q_OBJECT public Q_SLOTS: - void newPackage(); + void newPacket(); private Q_SLOTS: @@ -53,7 +53,7 @@ QTimer m_timer; QCA::Initializer m_qcaInitializer; QEventLoop m_loop; - QList m_packages; + QList m_packets; Server* m_server; QSslSocket* m_clientSocket; SocketLineReader* m_reader; @@ -143,18 +143,18 @@ } m_clientSocket->flush(); - m_packages.clear(); + m_packets.clear(); m_reader = new SocketLineReader(serverSocket, this); - connect(m_reader, &SocketLineReader::readyRead, this,&TestSslSocketLineReader::newPackage); + connect(m_reader, &SocketLineReader::readyRead, this,&TestSslSocketLineReader::newPacket); m_loop.exec(); /* remove the empty line before compare */ dataToSend.removeOne("\n"); - QCOMPARE(m_packages.count(), 5);//We expect 5 Packages + QCOMPARE(m_packets.count(), 5);//We expect 5 Packets for(int x = 0;x < 5; ++x) { - QCOMPARE(m_packages[x], dataToSend[x]); + QCOMPARE(m_packets[x], dataToSend[x]); } delete m_reader; @@ -202,18 +202,18 @@ } m_clientSocket->flush(); - m_packages.clear(); + m_packets.clear(); m_reader = new SocketLineReader(serverSocket, this); - connect(m_reader, &SocketLineReader::readyRead, this, &TestSslSocketLineReader::newPackage); + connect(m_reader, &SocketLineReader::readyRead, this, &TestSslSocketLineReader::newPacket); m_loop.exec(); /* remove the empty line before compare */ dataToSend.removeOne("\n"); - QCOMPARE(m_packages.count(), 5);//We expect 5 Packages + QCOMPARE(m_packets.count(), 5);//We expect 5 Packets for(int x = 0;x < 5; ++x) { - QCOMPARE(m_packages[x], dataToSend[x]); + QCOMPARE(m_packets[x], dataToSend[x]); } delete m_reader; @@ -261,21 +261,21 @@ } -void TestSslSocketLineReader::newPackage() +void TestSslSocketLineReader::newPacket() { if (!m_reader->bytesAvailable()) { return; } int maxLoops = 5; while(m_reader->bytesAvailable() > 0 && maxLoops > 0) { --maxLoops; - const QByteArray package = m_reader->readLine(); - if (!package.isEmpty()) { - m_packages.append(package); + const QByteArray packet = m_reader->readLine(); + if (!packet.isEmpty()) { + m_packets.append(packet); } - if (m_packages.count() == 5) { + if (m_packets.count() == 5) { m_loop.exit(); } }