Added a getter for dbus path in Device

This commit is contained in:
Albert Vaca 2013-08-20 13:52:25 +02:00
parent 40c4f1654b
commit 8627c8da51
3 changed files with 4 additions and 3 deletions

View file

@ -27,7 +27,7 @@ Device::Device(const QString& id, const QString& name)
reloadPlugins(); reloadPlugins();
//Register in bus //Register in bus
QDBusConnection::sessionBus().registerObject("/modules/kdeconnect/devices/"+id, this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors); QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
} }
@ -44,7 +44,7 @@ Device::Device(const QString& id, const QString& name, DeviceLink* link)
reloadPlugins(); reloadPlugins();
//Register in bus //Register in bus
QDBusConnection::sessionBus().registerObject("/modules/kdeconnect/devices/"+id, this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors); QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
} }

View file

@ -50,6 +50,7 @@ public:
QString id() const { return m_deviceId; } QString id() const { return m_deviceId; }
QString name() const { return m_deviceName; } QString name() const { return m_deviceName; }
QString dbusPath() const { return "/modules/kdeconnect/devices/"+id(); }
//Add and remove links //Add and remove links
void addLink(DeviceLink*); void addLink(DeviceLink*);

View file

@ -43,7 +43,7 @@ BatteryPlugin::BatteryPlugin(QObject *parent, const QVariantList &args)
BatteryPlugin::~BatteryPlugin() BatteryPlugin::~BatteryPlugin()
{ {
//FIXME: Qt dbus does not allow to remove an adaptor! (it causes a crash in //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 // the next dbus access to its parent). The implication of not deleting this
// is that disabling the plugin does not remove the interface (that will // is that disabling the plugin does not remove the interface (that will
// return outdated values) and that enabling it again instantiates a second // 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 // adaptor. This is a partial memory leak (the memory will be freed when the