summaryrefslogtreecommitdiff
path: root/ckitcallnotification
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2011-09-24 20:52:17 +0200
committerJavier S. Pedro <maemo@javispedro.com>2011-09-24 20:52:17 +0200
commita1ec50943454ba4674c8c5e5d5dadcdbd414b111 (patch)
tree163aed51758c98fa6feec35a344aa8b5095c32e5 /ckitcallnotification
parentcba26597f1c09764d37be0d13863ec5d5c340da0 (diff)
downloadsowatch-a1ec50943454ba4674c8c5e5d5dadcdbd414b111.tar.gz
sowatch-a1ec50943454ba4674c8c5e5d5dadcdbd414b111.zip
Incoming phone calls working!
Diffstat (limited to 'ckitcallnotification')
-rw-r--r--ckitcallnotification/ckitcallnotification.cpp52
-rw-r--r--ckitcallnotification/ckitcallnotification.h40
-rw-r--r--ckitcallnotification/ckitcallnotification.pro8
-rw-r--r--ckitcallnotification/ckitcallprovider.cpp34
-rw-r--r--ckitcallnotification/ckitcallprovider.h9
5 files changed, 120 insertions, 23 deletions
diff --git a/ckitcallnotification/ckitcallnotification.cpp b/ckitcallnotification/ckitcallnotification.cpp
new file mode 100644
index 0000000..72a768e
--- /dev/null
+++ b/ckitcallnotification/ckitcallnotification.cpp
@@ -0,0 +1,52 @@
+#include "ckitcallnotification.h"
+
+using namespace sowatch;
+
+CKitCallNotification::CKitCallNotification(const QString& displayName, QObject *parent) :
+ Notification(parent),
+ _dateTime(QDateTime::currentDateTime()),
+ _displayName(displayName)
+{
+}
+
+Notification::Type CKitCallNotification::type() const
+{
+ return Notification::CallNotification;
+}
+
+uint CKitCallNotification::count() const
+{
+ return 1;
+}
+
+QDateTime CKitCallNotification::dateTime() const
+{
+ return _dateTime;
+}
+
+QString CKitCallNotification::title() const
+{
+ return _displayName;
+}
+
+QString CKitCallNotification::body() const
+{
+ return tr("Incoming call");
+}
+
+void CKitCallNotification::activate()
+{
+ // TODO Actually do something
+}
+
+void CKitCallNotification::clear()
+{
+ // TODO Actually reject the call
+ emit cleared();
+}
+
+void CKitCallNotification::changeDisplayName(const QString &displayName)
+{
+ _displayName = displayName;
+ emit changed();
+}
diff --git a/ckitcallnotification/ckitcallnotification.h b/ckitcallnotification/ckitcallnotification.h
new file mode 100644
index 0000000..10453be
--- /dev/null
+++ b/ckitcallnotification/ckitcallnotification.h
@@ -0,0 +1,40 @@
+#ifndef CKITCALLNOTIFICATION_H
+#define CKITCALLNOTIFICATION_H
+
+#include <sowatch.h>
+
+namespace sowatch
+{
+
+class CKitCallProvider;
+
+class CKitCallNotification : public Notification
+{
+ Q_OBJECT
+public:
+ explicit CKitCallNotification(const QString& displayName, QObject *parent = 0);
+
+ Type type() const;
+ uint count() const;
+ QDateTime dateTime() const;
+ QString title() const;
+ QString body() const;
+
+ void activate();
+ void clear();
+
+signals:
+ void changed();
+ void cleared();
+
+protected:
+ QDateTime _dateTime;
+ QString _displayName;
+ void changeDisplayName(const QString& displayName);
+
+ friend class CKitCallProvider;
+};
+
+}
+
+#endif // CKITCALLNOTIFICATION_H
diff --git a/ckitcallnotification/ckitcallnotification.pro b/ckitcallnotification/ckitcallnotification.pro
index 17bdf8b..2cee7f8 100644
--- a/ckitcallnotification/ckitcallnotification.pro
+++ b/ckitcallnotification/ckitcallnotification.pro
@@ -10,10 +10,12 @@ TEMPLATE = lib
QT += dbus
SOURCES += ckitcallplugin.cpp \
- ckitcallprovider.cpp
+ ckitcallprovider.cpp \
+ ckitcallnotification.cpp
HEADERS += ckitcallplugin.h \
- ckitcallprovider.h
+ ckitcallprovider.h \
+ ckitcallnotification.h
CONFIG += link_pkgconfig
PKGCONFIG += contextsubscriber-1.0
@@ -35,3 +37,5 @@ unix:!symbian {
+
+
diff --git a/ckitcallnotification/ckitcallprovider.cpp b/ckitcallnotification/ckitcallprovider.cpp
index 85f85b2..adcb6d5 100644
--- a/ckitcallnotification/ckitcallprovider.cpp
+++ b/ckitcallnotification/ckitcallprovider.cpp
@@ -1,16 +1,16 @@
#include <QtCore/QtDebug>
#include <contextsubscriber/contextproperty.h>
+#include "ckitcallnotification.h"
#include "ckitcallprovider.h"
using namespace sowatch;
CKitCallProvider::CKitCallProvider(QObject *parent) :
NotificationProvider(parent),
- _inCall(false),
- _activeCall(new ContextProperty("/com/nokia/CallUi/ActiveCall"))
+ _activeCall(new ContextProperty("/com/nokia/CallUi/ActiveCall")),
+ _notification(0)
{
connect(_activeCall, SIGNAL(valueChanged()), SLOT(activeCallChanged()));
- qDebug() << _activeCall->value();
}
CKitCallProvider::~CKitCallProvider()
@@ -18,23 +18,25 @@ CKitCallProvider::~CKitCallProvider()
}
-int CKitCallProvider::getCount(Notification::Type type)
-{
- Q_UNUSED(type);
- return 0;
-}
-
void CKitCallProvider::activeCallChanged()
{
QVariantMap info = _activeCall->value().toMap();
int state = info["state"].toInt();
if (state == 0) {
- // Incoming call, or update to a incoming call
- _inCall = true;
- emit incomingCall(info["displayName"].toString());
- } else if (_inCall) {
- // Call is no longer incoming
- _inCall = false;
- emit endIncomingCall();
+ QString displayName = info["displayName"].toString();
+ // "Incoming call"
+ if (_notification) {
+ _notification->changeDisplayName(displayName);
+ } else {
+ _notification = new CKitCallNotification(displayName, this);
+ emit incomingNotification(_notification);
+ }
+ } else {
+ // Call is either answered, dropped, missed, ..
+ if (_notification) {
+ _notification->clear();
+ _notification->deleteLater();
+ _notification = 0;
+ }
}
}
diff --git a/ckitcallnotification/ckitcallprovider.h b/ckitcallnotification/ckitcallprovider.h
index 49d83a3..1e1d289 100644
--- a/ckitcallnotification/ckitcallprovider.h
+++ b/ckitcallnotification/ckitcallprovider.h
@@ -8,6 +8,8 @@ class ContextProperty;
namespace sowatch
{
+class CKitCallNotification;
+
class CKitCallProvider : public NotificationProvider
{
Q_OBJECT
@@ -15,15 +17,12 @@ public:
explicit CKitCallProvider(QObject *parent = 0);
~CKitCallProvider();
- int getCount(Notification::Type type);
-
signals:
- void incomingCall(const QString &displayName);
- void endIncomingCall();
+ void incomingNotification(Notification *notification);
protected:
- bool _inCall;
ContextProperty *_activeCall;
+ CKitCallNotification *_notification;
protected slots:
void activeCallChanged();