-// FIXME remove deprecated slot with Qt 4.6
-void StatusNotifierItem::serviceChange(const QString& name, const QString& oldOwner, const QString& newOwner) {
- bool legacy = false;
- if(name == "org.kde.StatusNotifierWatcher") {
- if(newOwner.isEmpty()) {
- //unregistered
- //qDebug() << "Connection to the StatusNotifierWatcher lost";
- legacy = true;
- } else if(oldOwner.isEmpty()) {
- //registered
- legacy = false;
+
+void StatusNotifierItem::registerToDaemon()
+{
+ if (!_statusNotifierWatcher) {
+ _statusNotifierWatcher = new org::kde::StatusNotifierWatcher(_statusNotifierWatcherServiceName,
+ "/StatusNotifierWatcher",
+ QDBusConnection::sessionBus());
+ connect(_statusNotifierWatcher, SIGNAL(StatusNotifierHostRegistered()), SLOT(checkForRegisteredHosts()));
+ connect(_statusNotifierWatcher, SIGNAL(StatusNotifierHostUnregistered()), SLOT(checkForRegisteredHosts()));
+ }
+ if (_statusNotifierWatcher->isValid()
+ && _statusNotifierWatcher->property("ProtocolVersion").toInt() == _protocolVersion) {
+ _statusNotifierWatcher->RegisterStatusNotifierItem(_statusNotifierItemDBus->service());
+ checkForRegisteredHosts();