Commit 72535ecf authored by Jean Vincent's avatar Jean Vincent Committed by Albert Vaca Cintora

Make member variable names, & placement and * placement more coherent

Summary:
Change all member variables to the form m_fooBar because it is the preferred form in Qt (it was half and half between this and mFooBar, and a minority didn't have anything).
Place all references and pointers on the side of the type since it is the majority.

Basically:
 - mFoo -> m_foo
 - foo -> m_foo (if it is a member variable)
 - Type &ref -> Type& ref
 - Type *ptr -> Type* ptr

Reviewers: #kde_connect, nicolasfella, albertvaka

Reviewed By: #kde_connect, nicolasfella, albertvaka

Subscribers: albertvaka, #kde_connect

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D7312
parent 5d4821fb
......@@ -23,7 +23,7 @@
#include <KAboutData>
#include <KLocalizedString>
int main(int argc, char *argv[])
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
KAboutData aboutData(QStringLiteral("kdeconnect.app"), i18n("KDE Connect App"), QStringLiteral("1.0"), i18n("KDE Connect App"), KAboutLicense::GPL, i18n("(c) 2015, Aleix Pol Gonzalez"));
......
......@@ -11,7 +11,6 @@ Name[el]=Εφαρμογή KDE Connect
Name[en_GB]=KDE Connect Application
Name[es]=Aplicación KDE Connect
Name[et]=KDE Connecti rakendus
Name[eu]=KDE Connect aplikazioa
Name[fi]=KDE Connect -sovellus
Name[fr]=Application KDE Connect
Name[gl]=Aplicativo de KDE Connect
......@@ -48,7 +47,6 @@ GenericName[el]=Συγχρονισμός συσκευών
GenericName[en_GB]=Device Synchronisation
GenericName[es]=Sincronización de dispositivos
GenericName[et]=Seadmete sünkroonimine
GenericName[eu]=Galuak sinkronizatzea
GenericName[fi]=Laitteiden synkronointi
GenericName[fr]=Synchronisation de périphériques
GenericName[gl]=Sincronización de dispositivos
......@@ -86,7 +84,6 @@ Comment[el]=Όλες οι συσκευές σας σε μία
Comment[en_GB]=Make all your devices one
Comment[es]=Convertir todos sus dispositivos en uno
Comment[et]=Kõigi seadmete ühendamine
Comment[eu]=Bat egin zure gailu guztiak
Comment[fi]=Yhdistä kaikki laitteesi toisiinsa
Comment[fr]=Unifiez vos périphériques
Comment[gl]=Unifique os seus dispositivos.
......
......@@ -152,7 +152,7 @@ int main(int argc, char** argv)
QTextStream(stderr) << i18n("waiting for device...") << endl;
blockOnReply(iface.acquireDiscoveryMode(id));
QObject::connect(&iface, &DaemonDbusInterface::deviceAdded, [&](const QString &deviceAddedId) {
QObject::connect(&iface, &DaemonDbusInterface::deviceAdded, [&](const QString& deviceAddedId) {
if (device == deviceAddedId) {
wait.quit();
}
......
......@@ -20,7 +20,7 @@
#include "bluetoothdownloadjob.h"
BluetoothDownloadJob::BluetoothDownloadJob(const QBluetoothAddress &remoteAddress, const QVariantMap &transferInfo, QObject *parent)
BluetoothDownloadJob::BluetoothDownloadJob(const QBluetoothAddress& remoteAddress, const QVariantMap& transferInfo, QObject* parent)
: QObject(parent)
, mRemoteAddress(remoteAddress)
, mTransferUuid(QBluetoothUuid(transferInfo.value("uuid").toString()))
......
......@@ -34,7 +34,7 @@ class BluetoothDownloadJob
{
Q_OBJECT
public:
explicit BluetoothDownloadJob(const QBluetoothAddress &remoteAddress, const QVariantMap &transferInfo, QObject* parent = 0);
explicit BluetoothDownloadJob(const QBluetoothAddress& remoteAddress, const QVariantMap& transferInfo, QObject* parent = 0);
QSharedPointer<QIODevice> payload() const;
void start();
......
......@@ -24,7 +24,7 @@
#include "core_debug.h"
#include <QCoreApplication>
BluetoothUploadJob::BluetoothUploadJob(const QSharedPointer<QIODevice> &data, const QBluetoothAddress &remoteAddress, QObject *parent)
BluetoothUploadJob::BluetoothUploadJob(const QSharedPointer<QIODevice>& data, const QBluetoothAddress& remoteAddress, QObject* parent)
: QObject(parent)
, mData(data)
, mRemoteAddress(remoteAddress)
......
......@@ -34,7 +34,7 @@ class BluetoothUploadJob
{
Q_OBJECT
public:
explicit BluetoothUploadJob(const QSharedPointer<QIODevice> &data, const QBluetoothAddress &remoteAddress, QObject* parent = 0);
explicit BluetoothUploadJob(const QSharedPointer<QIODevice>& data, const QBluetoothAddress& remoteAddress, QObject* parent = 0);
QVariantMap transferInfo() const;
void start();
......
......@@ -23,33 +23,33 @@
DeviceLineReader::DeviceLineReader(QIODevice* device, QObject* parent)
: QObject(parent)
, mDevice(device)
, m_device(device)
{
connect(mDevice, SIGNAL(readyRead()),
connect(m_device, SIGNAL(readyRead()),
this, SLOT(dataReceived()));
connect(mDevice, SIGNAL(disconnected()),
connect(m_device, SIGNAL(disconnected()),
this, SIGNAL(disconnected()));
}
void DeviceLineReader::dataReceived()
{
while(mDevice->canReadLine()) {
const QByteArray line = mDevice->readLine();
while(m_device->canReadLine()) {
const QByteArray line = m_device->readLine();
if (line.length() > 1) {
mPackages.enqueue(line);//we don't want single \n
m_packages.enqueue(line);//we don't want single \n
}
}
//If we still have things to read from the device, call dataReceived again
//We do this manually because we do not trust readyRead to be emitted again
//So we call this method again just in case.
if (mDevice->bytesAvailable() > 0) {
if (m_device->bytesAvailable() > 0) {
QMetaObject::invokeMethod(this, "dataReceived", Qt::QueuedConnection);
return;
}
//If we have any packages, tell it to the world.
if (!mPackages.isEmpty()) {
if (!m_packages.isEmpty()) {
Q_EMIT readyRead();
}
}
......@@ -39,9 +39,9 @@ class DeviceLineReader
public:
DeviceLineReader(QIODevice* device, QObject* parent = 0);
QByteArray readLine() { return mPackages.dequeue(); }
qint64 write(const QByteArray& data) { return mDevice->write(data); }
qint64 bytesAvailable() const { return mPackages.size(); }
QByteArray readLine() { return m_packages.dequeue(); }
qint64 write(const QByteArray& data) { return m_device->write(data); }
qint64 bytesAvailable() const { return m_packages.size(); }
Q_SIGNALS:
void readyRead();
......@@ -51,9 +51,9 @@ private Q_SLOTS:
void dataReceived();
private:
QByteArray lastChunk;
QIODevice* mDevice;
QQueue<QByteArray> mPackages;
QByteArray m_lastChunk;
QIODevice* m_device;
QQueue<QByteArray> m_packages;
};
......
......@@ -24,10 +24,10 @@
DeviceLink::DeviceLink(const QString& deviceId, LinkProvider* parent)
: QObject(parent)
, mPrivateKey(KdeConnectConfig::instance()->privateKey())
, mDeviceId(deviceId)
, mLinkProvider(parent)
, mPairStatus(NotPaired)
, m_privateKey(KdeConnectConfig::instance()->privateKey())
, m_deviceId(deviceId)
, m_linkProvider(parent)
, m_pairStatus(NotPaired)
{
Q_ASSERT(!deviceId.isEmpty());
......@@ -36,8 +36,8 @@ DeviceLink::DeviceLink(const QString& deviceId, LinkProvider* parent)
void DeviceLink::setPairStatus(DeviceLink::PairStatus status)
{
if (mPairStatus != status) {
mPairStatus = status;
if (m_pairStatus != status) {
m_pairStatus = status;
Q_EMIT pairStatusChanged(status);
}
}
......
......@@ -44,8 +44,8 @@ public:
virtual QString name() = 0;
const QString& deviceId() const { return mDeviceId; }
LinkProvider* provider() { return mLinkProvider; }
const QString& deviceId() const { return m_deviceId; }
LinkProvider* provider() { return m_linkProvider; }
virtual bool sendPackage(NetworkPackage& np) = 0;
......@@ -53,7 +53,7 @@ public:
virtual void userRequestsPair() = 0;
virtual void userRequestsUnpair() = 0;
PairStatus pairStatus() const { return mPairStatus; }
PairStatus pairStatus() const { return m_pairStatus; }
virtual void setPairStatus(PairStatus status);
//The daemon will periodically destroy unpaired links if this returns false
......@@ -63,16 +63,16 @@ Q_SIGNALS:
void pairingRequest(PairingHandler* handler);
void pairingRequestExpired(PairingHandler* handler);
void pairStatusChanged(DeviceLink::PairStatus status);
void pairingError(const QString &error);
void pairingError(const QString& error);
void receivedPackage(const NetworkPackage& np);
protected:
QCA::PrivateKey mPrivateKey;
QCA::PrivateKey m_privateKey;
private:
const QString mDeviceId;
LinkProvider* mLinkProvider;
PairStatus mPairStatus;
const QString m_deviceId;
LinkProvider* m_linkProvider;
PairStatus m_pairStatus;
};
......
......@@ -31,16 +31,16 @@
#include "lanlinkprovider.h"
#include "core/core_debug.h"
DownloadJob::DownloadJob(const QHostAddress &address, const QVariantMap &transferInfo)
DownloadJob::DownloadJob(const QHostAddress& address, const QVariantMap& transferInfo)
: KJob()
, mAddress(address)
, mPort(transferInfo[QStringLiteral("port")].toInt())
, mSocket(new QSslSocket)
, mBuffer(new QBuffer)
, m_address(address)
, m_port(transferInfo[QStringLiteral("port")].toInt())
, m_socket(new QSslSocket)
, m_buffer(new QBuffer)
{
LanLinkProvider::configureSslSocket(mSocket.data(), transferInfo.value(QStringLiteral("deviceId")).toString(), true);
LanLinkProvider::configureSslSocket(m_socket.data(), transferInfo.value(QStringLiteral("deviceId")).toString(), true);
connect(mSocket.data(), SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketFailed(QAbstractSocket::SocketError)));
connect(m_socket.data(), SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketFailed(QAbstractSocket::SocketError)));
// connect(mSocket.data(), &QAbstractSocket::stateChanged, [](QAbstractSocket::SocketState state){ qDebug() << "statechange" << state; });
}
......@@ -53,27 +53,27 @@ void DownloadJob::start()
{
//TODO: Timeout?
// Cannot use read only, might be due to ssl handshake, getting QIODevice::ReadOnly error and no connection
mSocket->connectToHostEncrypted(mAddress.toString(), mPort, QIODevice::ReadWrite);
m_socket->connectToHostEncrypted(m_address.toString(), m_port, QIODevice::ReadWrite);
bool b = mBuffer->open(QBuffer::ReadWrite);
bool b = m_buffer->open(QBuffer::ReadWrite);
Q_ASSERT(b);
}
void DownloadJob::socketFailed(QAbstractSocket::SocketError error)
{
if (error != QAbstractSocket::RemoteHostClosedError) { //remote host closes when finishes
qWarning(KDECONNECT_CORE) << "error..." << mSocket->errorString();
qWarning(KDECONNECT_CORE) << "error..." << m_socket->errorString();
setError(error + 1);
setErrorText(mSocket->errorString());
setErrorText(m_socket->errorString());
} else {
auto ba = mSocket->readAll();
mBuffer->write(ba);
mBuffer->seek(0);
auto ba = m_socket->readAll();
m_buffer->write(ba);
m_buffer->seek(0);
}
emitResult();
}
QSharedPointer<QIODevice> DownloadJob::getPayload()
{
return mBuffer.staticCast<QIODevice>();
return m_buffer.staticCast<QIODevice>();
}
......@@ -38,16 +38,16 @@ class KDECONNECTCORE_EXPORT DownloadJob
{
Q_OBJECT
public:
DownloadJob(const QHostAddress &address, const QVariantMap &transferInfo);
DownloadJob(const QHostAddress& address, const QVariantMap& transferInfo);
~DownloadJob() override;
void start() override;
QSharedPointer<QIODevice> getPayload();
private:
QHostAddress mAddress;
qint16 mPort;
QSharedPointer<QSslSocket> mSocket;
QSharedPointer<QBuffer> mBuffer;
QHostAddress m_address;
qint16 m_port;
QSharedPointer<QSslSocket> m_socket;
QSharedPointer<QBuffer> m_buffer;
private Q_SLOTS:
void socketFailed(QAbstractSocket::SocketError error);
......
......@@ -31,30 +31,30 @@
LanDeviceLink::LanDeviceLink(const QString& deviceId, LinkProvider* parent, QSslSocket* socket, ConnectionStarted connectionSource)
: DeviceLink(deviceId, parent)
, mSocketLineReader(nullptr)
, m_socketLineReader(nullptr)
{
reset(socket, connectionSource);
}
void LanDeviceLink::reset(QSslSocket* socket, ConnectionStarted connectionSource)
{
if (mSocketLineReader) {
disconnect(mSocketLineReader->mSocket, &QAbstractSocket::disconnected, this, &QObject::deleteLater);
delete mSocketLineReader;
if (m_socketLineReader) {
disconnect(m_socketLineReader->m_socket, &QAbstractSocket::disconnected, this, &QObject::deleteLater);
delete m_socketLineReader;
}
mSocketLineReader = new SocketLineReader(socket, this);
m_socketLineReader = new SocketLineReader(socket, this);
connect(socket, &QAbstractSocket::disconnected, this, &QObject::deleteLater);
connect(mSocketLineReader, &SocketLineReader::readyRead, this, &LanDeviceLink::dataReceived);
connect(m_socketLineReader, &SocketLineReader::readyRead, this, &LanDeviceLink::dataReceived);
//We take ownership of the socket.
//When the link provider destroys us,
//the socket (and the reader) will be
//destroyed as well
socket->setParent(mSocketLineReader);
socket->setParent(m_socketLineReader);
mConnectionSource = connectionSource;
m_connectionSource = connectionSource;
QString certString = KdeConnectConfig::instance()->getDeviceProperty(deviceId(), QStringLiteral("certificate"));
DeviceLink::setPairStatus(certString.isEmpty()? PairStatus::NotPaired : PairStatus::Paired);
......@@ -62,10 +62,10 @@ void LanDeviceLink::reset(QSslSocket* socket, ConnectionStarted connectionSource
QHostAddress LanDeviceLink::hostAddress() const
{
if (!mSocketLineReader) {
if (!m_socketLineReader) {
return QHostAddress::Null;
}
QHostAddress addr = mSocketLineReader->mSocket->peerAddress();
QHostAddress addr = m_socketLineReader->m_socket->peerAddress();
if (addr.protocol() == QAbstractSocket::IPv6Protocol) {
bool success;
QHostAddress convertedAddr = QHostAddress(addr.toIPv4Address(&success));
......@@ -88,7 +88,7 @@ bool LanDeviceLink::sendPackage(NetworkPackage& np)
np.setPayloadTransferInfo(sendPayload(np)->transferInfo());
}
int written = mSocketLineReader->write(np.serialize());
int written = m_socketLineReader->write(np.serialize());
//Actually we can't detect if a package is received or not. We keep TCP
//"ESTABLISHED" connections that look legit (return true when we use them),
......@@ -105,9 +105,9 @@ UploadJob* LanDeviceLink::sendPayload(const NetworkPackage& np)
void LanDeviceLink::dataReceived()
{
if (mSocketLineReader->bytesAvailable() == 0) return;
if (m_socketLineReader->bytesAvailable() == 0) return;
const QByteArray serializedPackage = mSocketLineReader->readLine();
const QByteArray serializedPackage = m_socketLineReader->readLine();
NetworkPackage package(QString::null);
NetworkPackage::unserialize(serializedPackage, &package);
......@@ -125,14 +125,14 @@ void LanDeviceLink::dataReceived()
//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(mSocketLineReader->peerAddress(), transferInfo);
DownloadJob* job = new DownloadJob(m_socketLineReader->peerAddress(), transferInfo);
job->start();
package.setPayload(job->getPayload(), package.payloadSize());
}
Q_EMIT receivedPackage(package);
if (mSocketLineReader->bytesAvailable() > 0) {
if (m_socketLineReader->bytesAvailable() > 0) {
QMetaObject::invokeMethod(this, "dataReceived", Qt::QueuedConnection);
}
......@@ -140,7 +140,7 @@ void LanDeviceLink::dataReceived()
void LanDeviceLink::userRequestsPair()
{
if (mSocketLineReader->peerCertificate().isNull()) {
if (m_socketLineReader->peerCertificate().isNull()) {
Q_EMIT pairingError(i18n("This device cannot be paired because it is running an old version of KDE Connect."));
} else {
qobject_cast<LanLinkProvider*>(provider())->userRequestsPair(deviceId());
......@@ -154,7 +154,7 @@ void LanDeviceLink::userRequestsUnpair()
void LanDeviceLink::setPairStatus(PairStatus status)
{
if (status == Paired && mSocketLineReader->peerCertificate().isNull()) {
if (status == Paired && m_socketLineReader->peerCertificate().isNull()) {
Q_EMIT pairingError(i18n("This device cannot be paired because it is running an old version of KDE Connect."));
return;
}
......@@ -162,8 +162,8 @@ void LanDeviceLink::setPairStatus(PairStatus status)
DeviceLink::setPairStatus(status);
if (status == Paired) {
Q_ASSERT(KdeConnectConfig::instance()->trustedDevices().contains(deviceId()));
Q_ASSERT(!mSocketLineReader->peerCertificate().isNull());
KdeConnectConfig::instance()->setDeviceProperty(deviceId(), QStringLiteral("certificate"), mSocketLineReader->peerCertificate().toPem());
Q_ASSERT(!m_socketLineReader->peerCertificate().isNull());
KdeConnectConfig::instance()->setDeviceProperty(deviceId(), QStringLiteral("certificate"), m_socketLineReader->peerCertificate().toPem());
}
}
......
......@@ -60,9 +60,9 @@ private Q_SLOTS:
void dataReceived();
private:
SocketLineReader* mSocketLineReader;
ConnectionStarted mConnectionSource;
QHostAddress mHostAddress;
SocketLineReader* m_socketLineReader;
ConnectionStarted m_connectionSource;
QHostAddress m_hostAddress;
};
#endif
......@@ -45,21 +45,21 @@
#define MIN_VERSION_WITH_SSL_SUPPORT 6
LanLinkProvider::LanLinkProvider(bool testMode)
: mTestMode(testMode)
: m_testMode(testMode)
{
mTcpPort = 0;
m_tcpPort = 0;
combineBroadcastsTimer.setInterval(0); // increase this if waiting a single event-loop iteration is not enough
combineBroadcastsTimer.setSingleShot(true);
connect(&combineBroadcastsTimer, &QTimer::timeout, this, &LanLinkProvider::broadcastToNetwork);
m_combineBroadcastsTimer.setInterval(0); // increase this if waiting a single event-loop iteration is not enough
m_combineBroadcastsTimer.setSingleShot(true);
connect(&m_combineBroadcastsTimer, &QTimer::timeout, this, &LanLinkProvider::broadcastToNetwork);
connect(&mUdpSocket, &QIODevice::readyRead, this, &LanLinkProvider::newUdpConnection);
connect(&m_udpSocket, &QIODevice::readyRead, this, &LanLinkProvider::newUdpConnection);
mServer = new Server(this);
mServer->setProxy(QNetworkProxy::NoProxy);
connect(mServer,&QTcpServer::newConnection,this, &LanLinkProvider::newConnection);
m_server = new Server(this);
m_server->setProxy(QNetworkProxy::NoProxy);
connect(m_server,&QTcpServer::newConnection,this, &LanLinkProvider::newConnection);
mUdpSocket.setProxy(QNetworkProxy::NoProxy);
m_udpSocket.setProxy(QNetworkProxy::NoProxy);
//Detect when a network interface changes status, so we announce ourelves in the new network
QNetworkConfigurationManager* networkManager = new QNetworkConfigurationManager(this);
......@@ -67,7 +67,7 @@ LanLinkProvider::LanLinkProvider(bool testMode)
}
void LanLinkProvider::onNetworkConfigurationChanged(const QNetworkConfiguration &config)
void LanLinkProvider::onNetworkConfigurationChanged(const QNetworkConfiguration& config)
{
if (m_lastConfig != config && config.state() == QNetworkConfiguration::Active) {
m_lastConfig = config;
......@@ -81,19 +81,19 @@ LanLinkProvider::~LanLinkProvider()
void LanLinkProvider::onStart()
{
const QHostAddress bindAddress = mTestMode? QHostAddress::LocalHost : QHostAddress::Any;
const QHostAddress bindAddress = m_testMode? QHostAddress::LocalHost : QHostAddress::Any;
bool success = mUdpSocket.bind(bindAddress, UDP_PORT, QUdpSocket::ShareAddress);
bool success = m_udpSocket.bind(bindAddress, UDP_PORT, QUdpSocket::ShareAddress);
Q_ASSERT(success);
qCDebug(KDECONNECT_CORE) << "onStart";
mTcpPort = MIN_TCP_PORT;
while (!mServer->listen(bindAddress, mTcpPort)) {
mTcpPort++;
if (mTcpPort > MAX_TCP_PORT) { //No ports available?
m_tcpPort = MIN_TCP_PORT;
while (!m_server->listen(bindAddress, m_tcpPort)) {
m_tcpPort++;
if (m_tcpPort > MAX_TCP_PORT) { //No ports available?
qCritical(KDECONNECT_CORE) << "Error opening a port in range" << MIN_TCP_PORT << "-" << MAX_TCP_PORT;
mTcpPort = 0;
m_tcpPort = 0;
return;
}
}
......@@ -104,47 +104,47 @@ void LanLinkProvider::onStart()
void LanLinkProvider::onStop()
{
qCDebug(KDECONNECT_CORE) << "onStop";
mUdpSocket.close();
mServer->close();
m_udpSocket.close();
m_server->close();
}
void LanLinkProvider::onNetworkChange()
{
if (combineBroadcastsTimer.isActive()) {
if (m_combineBroadcastsTimer.isActive()) {
qCDebug(KDECONNECT_CORE()) << "Preventing duplicate broadcasts";
return;
}
combineBroadcastsTimer.start();
m_combineBroadcastsTimer.start();
}
//I'm in a new network, let's be polite and introduce myself
void LanLinkProvider::broadcastToNetwork()
{
if (!mServer->isListening()) {
if (!m_server->isListening()) {
//Not started
return;
}
Q_ASSERT(mTcpPort != 0);
Q_ASSERT(m_tcpPort != 0);
qCDebug(KDECONNECT_CORE()) << "Broadcasting identity packet";
QHostAddress destAddress = mTestMode? QHostAddress::LocalHost : QHostAddress(QStringLiteral("255.255.255.255"));
QHostAddress destAddress = m_testMode? QHostAddress::LocalHost : QHostAddress(QStringLiteral("255.255.255.255"));
NetworkPackage np(QLatin1String(""));
NetworkPackage::createIdentityPackage(&np);
np.set(QStringLiteral("tcpPort"), mTcpPort);
np.set(QStringLiteral("tcpPort"), m_tcpPort);
#ifdef Q_OS_WIN
//On Windows we need to broadcast from every local IP address to reach all networks
QUdpSocket sendSocket;
sendSocket.setProxy(QNetworkProxy::NoProxy);
for (const QNetworkInterface &iface : QNetworkInterface::allInterfaces()) {
for (const QNetworkInterface& iface : QNetworkInterface::allInterfaces()) {
if ( (iface.flags() & QNetworkInterface::IsUp)
&& (iface.flags() & QNetworkInterface::IsRunning)
&& (iface.flags() & QNetworkInterface::CanBroadcast)) {
for (const QNetworkAddressEntry &ifaceAddress : iface.addressEntries()) {
for (const QNetworkAddressEntry& ifaceAddress : iface.addressEntries()) {
QHostAddress sourceAddress = ifaceAddress.ip();
if (sourceAddress.protocol() == QAbstractSocket::IPv4Protocol && sourceAddress != QHostAddress::LocalHost) {
qCDebug(KDECONNECT_CORE()) << "Broadcasting as" << sourceAddress;
......@@ -156,7 +156,7 @@ void LanLinkProvider::broadcastToNetwork()
}
}
#else
mUdpSocket.writeDatagram(np.serialize(), destAddress, UDP_PORT);
m_udpSocket.writeDatagram(np.serialize(), destAddress, UDP_PORT);
#endif
}
......@@ -165,15 +165,15 @@ void LanLinkProvider::broadcastToNetwork()
//I will create a TcpSocket and try to connect. This can result in either connected() or connectError().
void LanLinkProvider::newUdpConnection() //udpBroadcastReceived
{
while (mUdpSocket.hasPendingDatagrams()) {
while (m_udpSocket.hasPendingDatagrams()) {
QByteArray datagram;
datagram.resize(mUdpSocket.pendingDatagramSize());
datagram.resize(m_udpSocket.pendingDatagramSize());
QHostAddress sender;
mUdpSocket.readDatagram(datagram.data(), datagram.size(), &sender);
m_udpSocket.readDatagram(datagram.data(), datagram.size(), &sender);
if (sender.isLoopback() && !mTestMode)
if (sender.isLoopback() && !m_testMode)
continue;
NetworkPackage* receivedPackage = new NetworkPackage(QLatin1String(""));
......@@ -200,8 +200,8 @@ void LanLinkProvider::newUdpConnection() //udpBroadcastReceived
QSslSocket* socket = new QSslSocket(this);
socket->setProxy(QNetworkProxy::NoProxy);
receivedIdentityPackages[socket].np = receivedPackage;
receivedIdentityPackages[socket].sender = sender;
m_receivedIdentityPackages[socket].np = receivedPackage;
m_receivedIdentityPackages[socket].sender = sender;
connect(socket, &QAbstractSocket::connected, this, &LanLinkProvider::connected);
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectError()));
socket->connectToHost(sender, tcpPort);
......@@ -218,12 +218,12 @@ void LanLinkProvider::connectError()
qCDebug(KDECONNECT_CORE) << "Fallback (1), try reverse connection (send udp packet)" << socket->errorString();
NetworkPackage np(QLatin1String(""));
NetworkPackage::createIdentityPackage(&np);
np.set(QStringLiteral("tcpPort"), mTcpPort);
mUdpSocket.writeDatagram(np.serialize(), receivedIdentityPackages[socket].sender, UDP_PORT);
np.set(QStringLiteral("tcpPort"), m_tcpPort);
m_udpSocket.writeDatagram(np.serialize(), m_receivedIdentityPackages[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 receivedIdentityPackages.take(socket).np;
delete m_receivedIdentityPackages.take(socket).np;
delete socket;
}
......@@ -241,7 +241,7 @@ void LanLinkProvider::connected()
// If socket disconnects due to any reason after connection, link on ssl faliure
connect(socket, &QAbstractSocket::disconnected, socket, &QObject::deleteLater);
NetworkPackage* receivedPackage = receivedIdentityPackages[socket].np;
NetworkPackage* receivedPackage = m_receivedIdentityPackages[socket].np;
const QString& deviceId = receivedPackage->get<QString>(QStringLiteral("deviceId"));
//qCDebug(KDECONNECT_CORE) << "Connected" << socket->isWritable();
......@@ -281,10 +281,10 @@ void LanLinkProvider::connected()
//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)";
mUdpSocket.writeDatagram(np2.serialize(), receivedIdentityPackages[socket].sender, UDP_PORT);
m_udpSocket.writeDatagram(np2.serialize(), m_receivedIdentityPackages[socket].sender, UDP_PORT);
}
delete receivedIdentityPackages.take(socket).np;
delete m_receivedIdentityPackages.take(socket).np;
//We don't delete the socket because now it's owned by the LanDeviceLink
}
......@@ -300,13 +300,13 @@ void LanLinkProvider::encrypted()
Q_ASSERT(socket->mode() != QSslSocket::UnencryptedMode);
LanDeviceLink::ConnectionStarted connectionOrigin = (socket->mode() == QSslSocket::SslClientMode)? LanDeviceLink::Locally : LanDeviceLink::Remotely;
NetworkPackage* receivedPackage = receivedIdentityPackages[socket].np;
NetworkPackage* receivedPackage = m_receivedIdentityPackages[socket].np;