From a4084dcd38a78dfc9113168e378b5fa7f7e9f6ea Mon Sep 17 00:00:00 2001 From: Philipp Andreas Date: Thu, 10 Jul 2014 21:56:19 +0200 Subject: Adding support for default notifications. --- daemon/manager.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'daemon/manager.cpp') diff --git a/daemon/manager.cpp b/daemon/manager.cpp index f25e724..11444fe 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -5,8 +5,8 @@ #include #include -Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice) : - QObject(0), watch(watch), dbus(dbus), voice(voice), +Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice, NotificationManager *notifications) : + QObject(0), watch(watch), dbus(dbus), voice(voice), notifications(notifications), notification(MNotification::DeviceEvent) { // We don't need to handle presence changes, so report them separately and ignore them @@ -24,6 +24,10 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan connect(voice, SIGNAL(activeVoiceCallChanged()), SLOT(onActiveVoiceCallChanged())); connect(voice, SIGNAL(error(const QString &)), SLOT(onVoiceError(const QString &))); + connect(notifications, SIGNAL(error(const QString &)), SLOT(onNotifyError(const QString &))); + connect(notifications, SIGNAL(emailNotify(const QString &,const QString &,const QString &)), SLOT(onEmailNotify(const QString &,const QString &,const QString &))); + connect(notifications, SIGNAL(smsNotify(const QString &,const QString &)), SLOT(onSmsNotify(const QString &,const QString &))); + // Watch instantiated hangup, follow the orders connect(watch, SIGNAL(hangup()), SLOT(hangupAll())); connect(watch, SIGNAL(connectedChanged()), SLOT(onConnectedChanged())); @@ -145,6 +149,29 @@ void Manager::onVoiceError(const QString &message) qWarning() << "Error: " << message; } + +void Manager::onNotifyError(const QString &message) +{ + qWarning() << "Error: " << message; +} + +void Manager::onSmsNotify(const QString &sender, const QString &data) +{ + qDebug() << "SMS:"; + qDebug() << sender; + qDebug() << data; + watch->sendSMSNotification(sender, data); +} + +void Manager::onEmailNotify(const QString &sender, const QString &data,const QString &subject) +{ + qDebug() << "Email:"; + qDebug() << sender; + qDebug() << data; + qDebug() << subject; + watch->sendEmailNotification(sender, data, subject); +} + void Manager::hangupAll() { foreach (VoiceCallHandler* handler, voice->voiceCalls()) { -- cgit v1.2.3