[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:29:27 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=2e4c376
The following commit has been merged in the master branch:
commit 2e4c3762e92f119880292d39ddb9292cbe13024f
Author: Albert Vaca <albertvaka at gmail.com>
Date: Thu Dec 10 17:11:48 2015 -0800
Re-use landevicelink objects instead of re-creating one each time
---
core/backends/lan/landevicelink.cpp | 19 ++++++++++++++-----
core/backends/lan/landevicelink.h | 1 +
core/backends/lan/lanlinkprovider.cpp | 24 +++++++++++-------------
core/backends/lan/lanlinkprovider.h | 2 +-
4 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/core/backends/lan/landevicelink.cpp b/core/backends/lan/landevicelink.cpp
index a0b14da..c172dbb 100644
--- a/core/backends/lan/landevicelink.cpp
+++ b/core/backends/lan/landevicelink.cpp
@@ -29,17 +29,26 @@
LanDeviceLink::LanDeviceLink(const QString& deviceId, LinkProvider* parent, QSslSocket* socket, ConnectionStarted connectionSource)
: DeviceLink(deviceId, parent, connectionSource)
- , mSocketLineReader(new SocketLineReader(socket))
+ , mSocketLineReader(nullptr)
{
- connect(mSocketLineReader, SIGNAL(readyRead()),
- this, SLOT(dataReceived()));
+ reset(socket, connectionSource);
+}
+void LanDeviceLink::reset(QSslSocket* socket, DeviceLink::ConnectionStarted connectionSource)
+{
//We take ownership of the socket.
//When the link provider destroys us,
//the socket (and the reader) will be
//destroyed as well
- connect(socket, SIGNAL(disconnected()),
- this, SLOT(deleteLater()));
+
+ if (mSocketLineReader) {
+ delete mSocketLineReader;
+ }
+
+ mSocketLineReader = new SocketLineReader(socket);
+
+ connect(socket, SIGNAL(disconnected()), this, SLOT(deleteLater()));
+ connect(mSocketLineReader, SIGNAL(readyRead()), this, SLOT(dataReceived()));
mSocketLineReader->setParent(this);
socket->setParent(this);
}
diff --git a/core/backends/lan/landevicelink.h b/core/backends/lan/landevicelink.h
index 48c379e..fa6667b 100644
--- a/core/backends/lan/landevicelink.h
+++ b/core/backends/lan/landevicelink.h
@@ -37,6 +37,7 @@ class LanDeviceLink
public:
LanDeviceLink(const QString& deviceId, LinkProvider* parent, QSslSocket* socket, ConnectionStarted connectionSource);
+ void reset(QSslSocket* socket, ConnectionStarted connectionSource);
virtual QString name() Q_DECL_OVERRIDE;
bool sendPackage(NetworkPackage& np) override;
diff --git a/core/backends/lan/lanlinkprovider.cpp b/core/backends/lan/lanlinkprovider.cpp
index 2eef152..07b39af 100644
--- a/core/backends/lan/lanlinkprovider.cpp
+++ b/core/backends/lan/lanlinkprovider.cpp
@@ -433,24 +433,22 @@ void LanLinkProvider::configureSocket(QSslSocket* socket)
void LanLinkProvider::addLink(const QString& deviceId, QSslSocket* socket, NetworkPackage* receivedPackage, DeviceLink::ConnectionStarted connectionOrigin)
{
-
- LanDeviceLink* deviceLink = new LanDeviceLink(deviceId, this, socket, connectionOrigin);
- connect(deviceLink, SIGNAL(destroyed(QObject*)), this, SLOT(deviceLinkDestroyed(QObject*)));
-
// Socket disconnection will now be handled by LanDeviceLink
disconnect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater()));
- //We kill any possible link from this same device
- QMap< QString, DeviceLink* >::iterator oldLinkIterator = mLinks.find(deviceLink->deviceId());
- if (oldLinkIterator != mLinks.end()) {
- DeviceLink* oldLink = oldLinkIterator.value();
- disconnect(oldLink, SIGNAL(destroyed(QObject*)),
- this, SLOT(deviceLinkDestroyed(QObject*)));
- oldLink->deleteLater();
- mLinks.erase(oldLinkIterator);
+ DeviceLink* deviceLink;
+ //Do we have a link for this device already?
+ QMap< QString, LanDeviceLink* >::iterator linkIterator = mLinks.find(deviceLink->deviceId());
+ if (linkIterator != mLinks.end()) {
+ deviceLink = linkIterator.value();
+ deviceLink->reset(socket, connectionOrigin);
+ } else {
+ deviceLink = new LanDeviceLink(deviceId, this, socket, connectionOrigin);
+ connect(deviceLink, SIGNAL(destroyed(QObject*)), this, SLOT(deviceLinkDestroyed(QObject*)));
+ mLinks[deviceId] = deviceLink;
}
- mLinks[deviceId] = deviceLink;
+
refreshPairingHandler(deviceId);
Q_EMIT onConnectionReceived(*receivedPackage, deviceLink);
diff --git a/core/backends/lan/lanlinkprovider.h b/core/backends/lan/lanlinkprovider.h
index 40e6afc..db82e63 100644
--- a/core/backends/lan/lanlinkprovider.h
+++ b/core/backends/lan/lanlinkprovider.h
@@ -74,7 +74,7 @@ private:
const static quint16 port = 1714;
quint16 mTcpPort;
- QMap<QString, DeviceLink*> mLinks;
+ QMap<QString, LanDeviceLink*> mLinks;
QMap<QString, LanPairingHandler*> mPairingHandlers;
struct PendingConnect {
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list