summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier S. Pedro <dev.git@javispedro.com>2014-09-14 20:56:29 +0200
committerJavier S. Pedro <dev.git@javispedro.com>2014-09-14 20:56:29 +0200
commit6a581ace4f14c30f1c66daf28064d7aefde546fc (patch)
tree9b777dc1669832a6bc785b313edf88bf19c36425
parent4bc56bff80046b74926289be8825726296f39791 (diff)
downloadsalmeta-6a581ace4f14c30f1c66daf28064d7aefde546fc.tar.gz
salmeta-6a581ace4f14c30f1c66daf28064d7aefde546fc.zip
simplify notification monitoring for now
-rw-r--r--src/controller.cpp3
-rw-r--r--src/controller.h3
-rw-r--r--src/notificationmonitor.cpp27
-rw-r--r--src/notificationmonitor.h13
4 files changed, 12 insertions, 34 deletions
diff --git a/src/controller.cpp b/src/controller.cpp
index a5ff22d..f4a2b09 100644
--- a/src/controller.cpp
+++ b/src/controller.cpp
@@ -16,6 +16,7 @@ Controller::Controller(const QString &settingsPrefix, QQuickView *view, QObject
_settings(new MDConfGroup(this)),
_metawatch(0),
_reconnect(new ReconnectTimer(this)),
+ _monitor(NotificationMonitor::instance()),
_widgets(new WidgetInfoModel(settingsPrefix, this)),
_curMode(MetaWatch::WatchModeIdle), _curPage(0),
_batteryCharge(0), _batteryCharging(false)
@@ -92,6 +93,8 @@ void Controller::connectToAddress(const QString &address)
connect(_metawatch, &MetaWatch::batteryStatus, this, &Controller::handleMetaWatchBatteryStatus);
connect(_reconnect, &ReconnectTimer::tryReconnect, _metawatch, &MetaWatch::connectDevice);
+ qDebug() << "Scheduling initial connection attempt to" << _address;
+
_reconnect->scheduleNextAttempt();
}
diff --git a/src/controller.h b/src/controller.h
index 604da2e..f4d4513 100644
--- a/src/controller.h
+++ b/src/controller.h
@@ -7,6 +7,7 @@
#include "metawatch.h"
#include "reconnecttimer.h"
+#include "notificationmonitor.h"
#include "widgetinfomodel.h"
class Controller : public QObject
@@ -51,7 +52,7 @@ private:
MDConfGroup *_settings;
MetaWatch *_metawatch;
ReconnectTimer *_reconnect;
-
+ NotificationMonitor *_monitor;
WidgetInfoModel *_widgets;
QString _address;
diff --git a/src/notificationmonitor.cpp b/src/notificationmonitor.cpp
index 50f7b91..50b2e3e 100644
--- a/src/notificationmonitor.cpp
+++ b/src/notificationmonitor.cpp
@@ -1,33 +1,25 @@
#include <QtCore/QDebug>
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusConnectionInterface>
-
#include "notificationmonitor.h"
static NotificationMonitor *global_monitor = 0;
-namespace
-{
-
-}
-
NotificationMonitor::NotificationMonitor(QObject *parent) :
QObject(parent)
{
QDBusConnection bus = QDBusConnection::sessionBus();
-
- _watcher = new QDBusServiceWatcher("org.freedesktop.Notifications", bus,
- QDBusServiceWatcher::WatchForOwnerChange,
- this);
- connect(_watcher, &QDBusServiceWatcher::serviceOwnerChanged,
- this, &NotificationMonitor::handleServiceOwnerChanged);
-
- bus.interface()->call("AddMatch",
- "interface='org.freedesktop.Notifications',member='Notify',type='method_call',eavesdrop='true'");
+ QDBusConnectionInterface *dbus = bus.interface();
+ dbus->call("AddMatch",
+ "interface='org.freedesktop.Notifications',member='Notify',type='method_call',eavesdrop='true'");
}
NotificationMonitor::~NotificationMonitor()
{
+ QDBusConnection bus = QDBusConnection::sessionBus();
+ QDBusConnectionInterface *dbus = bus.interface();
+ dbus->call("RemoveMatch",
+ "interface='org.freedesktop.Notifications',member='Notify',type='method_call',eavesdrop='true'");
}
NotificationMonitor *NotificationMonitor::instance()
@@ -37,8 +29,3 @@ NotificationMonitor *NotificationMonitor::instance()
}
return global_monitor;
}
-
-void NotificationMonitor::handleServiceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner)
-{
- qDebug() << "Service owner changed" << serviceName << oldOwner << newOwner;
-}
diff --git a/src/notificationmonitor.h b/src/notificationmonitor.h
index eac06ff..e8b6501 100644
--- a/src/notificationmonitor.h
+++ b/src/notificationmonitor.h
@@ -2,8 +2,6 @@
#define NOTIFICATIONMONITOR_H
#include <QtCore/QObject>
-#include <QtCore/QHash>
-#include <QtDBus/QDBusServiceWatcher>
#include "notification.h"
@@ -16,19 +14,8 @@ public:
static NotificationMonitor *instance();
-signals:
- void newNotification(Notification *notification);
-
private:
explicit NotificationMonitor(QObject *parent = 0);
-
-private slots:
- void handleServiceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner);
-
-private:
- QDBusServiceWatcher *_watcher;
- QHash<uint, Notification*> _pendingNotifications;
- QHash<uint, Notification*> _notifications;
};
#endif // NOTIFICATIONMONITOR_H