[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:26:45 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=0f38eb3
The following commit has been merged in the master branch:
commit 0f38eb34a4ee25f5a1c182822cebe5b44c788aaa
Author: Albert Vaca <albertvaka at gmail.com>
Date: Wed Aug 14 01:35:12 2013 +0200
Fixed crash: OMG QDbusAdaptors can not be removed!
Added a fixme for future reference
reloadPlugins() now recycles plugins already present
Lots of debug messages and minor changes added trying to fix the bug
---
daemon/device.cpp | 50 +++++++++++++---------
daemon/plugins/battery/batterydbusinterface.cpp | 4 ++
daemon/plugins/battery/batterydbusinterface.h | 3 +-
daemon/plugins/battery/batteryplugin.cpp | 12 +++++-
.../notifications/kdeconnect_notifications.desktop | 2 +-
.../pausemusic/kdeconnect_pausemusic.desktop | 4 +-
daemon/plugins/ping/pingplugin.cpp | 5 +++
daemon/plugins/ping/pingplugin.h | 3 +-
.../plugins/telephony/kdeconnect_telephony.desktop | 2 +-
9 files changed, 57 insertions(+), 28 deletions(-)
diff --git a/daemon/device.cpp b/daemon/device.cpp
index 6445309..32ee926 100644
--- a/daemon/device.cpp
+++ b/daemon/device.cpp
@@ -68,37 +68,47 @@ bool Device::hasPlugin(const QString& name)
void Device::reloadPlugins()
{
+ QMap< QString, KdeConnectPlugin* > newPluginMap;
- qDeleteAll(m_plugins);
- m_plugins.clear();
+ if (paired()) { //Do not load any plugin for unpaired devices
- QString path = KStandardDirs().resourceDirs("config").first()+"kdeconnect/";
- QMap<QString,QString> pluginStates = KSharedConfig::openConfig(path + id())->group("Plugins").entryMap();
+ QString path = KStandardDirs().resourceDirs("config").first()+"kdeconnect/";
+ QMap<QString,QString> pluginStates = KSharedConfig::openConfig(path + id())->group("Plugins").entryMap();
- PluginLoader* loader = PluginLoader::instance();
+ PluginLoader* loader = PluginLoader::instance();
- //Code borrowed from KWin
- foreach (const QString& pluginName, loader->getPluginList()) {
+ //Code borrowed from KWin
+ foreach (const QString& pluginName, loader->getPluginList()) {
- const QString value = pluginStates.value(pluginName + QString::fromLatin1("Enabled"), QString());
- KPluginInfo info = loader->getPluginInfo(pluginName);
- bool enabled = (value.isNull() ? info.isPluginEnabledByDefault() : QVariant(value).toBool());
+ const QString value = pluginStates.value(pluginName + QString::fromLatin1("Enabled"), QString());
+ KPluginInfo info = loader->getPluginInfo(pluginName);
+ bool enabled = (value.isNull() ? info.isPluginEnabledByDefault() : QVariant(value).toBool());
- qDebug() << pluginName << "enabled:" << enabled;
+ if (enabled) {
- if (enabled) {
- KdeConnectPlugin* plugin = loader->instantiatePluginForDevice(pluginName, this);
+ if (m_plugins.contains(pluginName)) {
+ //Already loaded, reuse it
+ newPluginMap[pluginName] = m_plugins[pluginName];
+ m_plugins.remove(pluginName);
+ } else {
+ KdeConnectPlugin* plugin = loader->instantiatePluginForDevice(pluginName, this);
- connect(this, SIGNAL(receivedPackage(const NetworkPackage&)),
- plugin, SLOT(receivePackage(const NetworkPackage&)));
- // connect(plugin, SIGNAL(sendPackage(const NetworkPackage&)),
- // device, SLOT(sendPackage(const NetworkPackage&)));
+ connect(this, SIGNAL(receivedPackage(const NetworkPackage&)),
+ plugin, SLOT(receivePackage(const NetworkPackage&)));
-
- m_plugins[pluginName] = plugin;
+ newPluginMap[pluginName] = plugin;
+ }
+ }
}
}
+ //Erase all the plugins left in the original map (it means that we don't want
+ //them anymore, otherways they would have been moved to the newPluginMap)
+ qDeleteAll(m_plugins);
+ m_plugins.clear();
+
+ m_plugins = newPluginMap;
+
Q_EMIT pluginsChanged();
}
@@ -106,7 +116,6 @@ void Device::reloadPlugins()
void Device::setPair(bool b)
{
- qDebug() << "setPair" << b;
m_paired = b;
KSharedConfigPtr config = KSharedConfig::openConfig("kdeconnectrc");
if (b) {
@@ -116,6 +125,7 @@ void Device::setPair(bool b)
qDebug() << name() << "unpaired";
config->group("devices").group("paired").deleteGroup(id());
}
+ reloadPlugins();
}
static bool lessThan(DeviceLink* p1, DeviceLink* p2)
diff --git a/daemon/plugins/battery/batterydbusinterface.cpp b/daemon/plugins/battery/batterydbusinterface.cpp
index d44a998..4efdd37 100644
--- a/daemon/plugins/battery/batterydbusinterface.cpp
+++ b/daemon/plugins/battery/batterydbusinterface.cpp
@@ -25,7 +25,11 @@
BatteryDbusInterface::BatteryDbusInterface(QObject *parent)
: QDBusAbstractAdaptor(parent)
{
+}
+BatteryDbusInterface::~BatteryDbusInterface()
+{
+ qDebug() << "Destroying BatteryDbusInterface";
}
void BatteryDbusInterface::updateValues(bool isCharging, int currentCharge)
diff --git a/daemon/plugins/battery/batterydbusinterface.h b/daemon/plugins/battery/batterydbusinterface.h
index 457cbb0..56317ff 100644
--- a/daemon/plugins/battery/batterydbusinterface.h
+++ b/daemon/plugins/battery/batterydbusinterface.h
@@ -33,7 +33,8 @@ class BatteryDbusInterface
public:
explicit BatteryDbusInterface(QObject *parent);
-
+ virtual ~BatteryDbusInterface();
+
int charge() { return mCharge; }
bool isCharging() { return mIsCharging; }
diff --git a/daemon/plugins/battery/batteryplugin.cpp b/daemon/plugins/battery/batteryplugin.cpp
index 5de2fd1..b4a9862 100644
--- a/daemon/plugins/battery/batteryplugin.cpp
+++ b/daemon/plugins/battery/batteryplugin.cpp
@@ -32,8 +32,9 @@ K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_battery", "kdeconnect_batte
BatteryPlugin::BatteryPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
- batteryDbusInterface = new BatteryDbusInterface(parent);
+ batteryDbusInterface = new BatteryDbusInterface(parent);
+
NetworkPackage np(PACKAGE_TYPE_BATTERY);
np.set("request",true);
device()->sendPackage(np);
@@ -42,7 +43,14 @@ BatteryPlugin::BatteryPlugin(QObject *parent, const QVariantList &args)
BatteryPlugin::~BatteryPlugin()
{
- batteryDbusInterface->deleteLater();
+ //FIXME: Qt dbus does not allow to remove an adaptor! (it causes a crash in
+ // the next access to device via dbus). The implication of not deleting this
+ // is that disabling the plugin does not remove the interface (that will
+ // return outdated values) and that enabling it again instantiates a second
+ // adaptor. This is a partial memory leak (the memory will be freed when the
+ // device is destroyed anyway)
+
+ //batteryDbusInterface->deleteLater();
}
bool BatteryPlugin::receivePackage(const NetworkPackage& np)
diff --git a/daemon/plugins/notifications/kdeconnect_notifications.desktop b/daemon/plugins/notifications/kdeconnect_notifications.desktop
index 916e6de..a30cbb4 100644
--- a/daemon/plugins/notifications/kdeconnect_notifications.desktop
+++ b/daemon/plugins/notifications/kdeconnect_notifications.desktop
@@ -12,4 +12,4 @@ X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
Icon=preferences-desktop-notification
Name=Notification sync
-Comment=Show every notification in KDE and keep them in sync
+Comment=Show phone notifications in KDE and keep them in sync
diff --git a/daemon/plugins/pausemusic/kdeconnect_pausemusic.desktop b/daemon/plugins/pausemusic/kdeconnect_pausemusic.desktop
index f28563c..67c1f5e 100644
--- a/daemon/plugins/pausemusic/kdeconnect_pausemusic.desktop
+++ b/daemon/plugins/pausemusic/kdeconnect_pausemusic.desktop
@@ -11,5 +11,5 @@ X-KDE-PluginInfo-Website=http://albertvaka.wordpress.com
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
Icon=speaker
-Name=Pause music on call
-Comment=Pause music during a phone call
+Name=Pause media during calls
+Comment=Pause music/videos during a phone call
diff --git a/daemon/plugins/ping/pingplugin.cpp b/daemon/plugins/ping/pingplugin.cpp
index 2532ede..a6061bd 100644
--- a/daemon/plugins/ping/pingplugin.cpp
+++ b/daemon/plugins/ping/pingplugin.cpp
@@ -33,6 +33,11 @@ PingPlugin::PingPlugin(QObject* parent, const QVariantList& args)
qDebug() << "Ping plugin constructor for device" << device()->name();
}
+PingPlugin::~PingPlugin()
+{
+ qDebug() << "Ping plugin destructor for device" << device()->name();
+}
+
bool PingPlugin::receivePackage(const NetworkPackage& np)
{
diff --git a/daemon/plugins/ping/pingplugin.h b/daemon/plugins/ping/pingplugin.h
index d8d6924..6de5b97 100644
--- a/daemon/plugins/ping/pingplugin.h
+++ b/daemon/plugins/ping/pingplugin.h
@@ -32,7 +32,8 @@ class KDE_EXPORT PingPlugin
public:
explicit PingPlugin(QObject *parent, const QVariantList &args);
-
+ virtual ~PingPlugin();
+
public Q_SLOTS:
virtual bool receivePackage(const NetworkPackage& np);
diff --git a/daemon/plugins/telephony/kdeconnect_telephony.desktop b/daemon/plugins/telephony/kdeconnect_telephony.desktop
index fc395e8..e56a12d 100644
--- a/daemon/plugins/telephony/kdeconnect_telephony.desktop
+++ b/daemon/plugins/telephony/kdeconnect_telephony.desktop
@@ -12,4 +12,4 @@ X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
Icon=call-start
Name=Telephony integration
-Comment=Currently it only shows notifications for calls and SMS
+Comment=Show notifications for calls and SMS (answering coming soon)
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list