X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fstatusnotifieritemdbus.cpp;h=5e67e698a3ae86a71acdef7ebb74d6da06a8f0af;hp=9c0487b9c46ab1ed397b12edd3ae25448d9fe436;hb=d5f5ce565bf61a020029f52c16fd3ea4f494d23e;hpb=4476cfb22f36ad9ba96e4978c3bcce1c2f6b5a04 diff --git a/src/qtui/statusnotifieritemdbus.cpp b/src/qtui/statusnotifieritemdbus.cpp index 9c0487b9..5e67e698 100644 --- a/src/qtui/statusnotifieritemdbus.cpp +++ b/src/qtui/statusnotifieritemdbus.cpp @@ -19,9 +19,10 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include "mainwin.h" +#include "qtui.h" #include "statusnotifieritemdbus.h" #include "statusnotifieritem.h" -#include "qtui.h" #include #include @@ -146,14 +147,31 @@ StatusNotifierItemDBus::StatusNotifierItemDBus(StatusNotifierItem *parent) m_dbus(QDBusConnection::connectToBus(QDBusConnection::SessionBus, m_service)) { new StatusNotifierItemAdaptor(this); - qDebug() << "service is" << m_service; - m_dbus.registerService(m_service); + //qDebug() << "service is" << m_service; + registerService(); m_dbus.registerObject("/StatusNotifierItem", this); } StatusNotifierItemDBus::~StatusNotifierItemDBus() { - m_dbus.unregisterService(m_service); + unregisterService(); +} + +// FIXME: prevent double registrations, also test this on platforms != KDE +// +void StatusNotifierItemDBus::registerService() +{ + //qDebug() << "registering to" << m_service; + m_dbus.registerService(m_service); +} + +// FIXME: see above +void StatusNotifierItemDBus::unregisterService() +{ + //qDebug() << "unregistering from" << m_service; + if(m_dbus.isConnected()) { + m_dbus.unregisterService(m_service); + } } QString StatusNotifierItemDBus::service() const @@ -180,7 +198,7 @@ QString StatusNotifierItemDBus::Id() const } QString StatusNotifierItemDBus::Status() const - { +{ return m_statusNotifierItem->metaObject()->enumerator(m_statusNotifierItem->metaObject()->indexOfEnumerator("State")).valueToKey(m_statusNotifierItem->state()); }