From cba26597f1c09764d37be0d13863ec5d5c340da0 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Sat, 24 Sep 2011 00:31:46 +0200 Subject: new partially working incoming call plugin --- ckitcallnotification/ckitcallnotification.pro | 37 ++++++++++++++++++++ ckitcallnotification/ckitcallplugin.cpp | 29 ++++++++++++++++ ckitcallnotification/ckitcallplugin.h | 24 +++++++++++++ ckitcallnotification/ckitcallprovider.cpp | 40 ++++++++++++++++++++++ ckitcallnotification/ckitcallprovider.h | 34 ++++++++++++++++++ libsowatch/notification.h | 4 +-- libsowatch/notificationprovider.h | 4 +++ libsowatch/watch.h | 2 ++ libsowatch/watchserver.cpp | 12 +++++++ libsowatch/watchserver.h | 2 ++ meegohandsetnotification/watchnotificationsink.cpp | 15 ++++++-- metawatch/metawatch.cpp | 19 ++++++++-- metawatch/metawatch.h | 4 ++- sowatch.pro | 3 +- sowatchd/daemon.cpp | 4 +-- 15 files changed, 222 insertions(+), 11 deletions(-) create mode 100644 ckitcallnotification/ckitcallnotification.pro create mode 100644 ckitcallnotification/ckitcallplugin.cpp create mode 100644 ckitcallnotification/ckitcallplugin.h create mode 100644 ckitcallnotification/ckitcallprovider.cpp create mode 100644 ckitcallnotification/ckitcallprovider.h diff --git a/ckitcallnotification/ckitcallnotification.pro b/ckitcallnotification/ckitcallnotification.pro new file mode 100644 index 0000000..17bdf8b --- /dev/null +++ b/ckitcallnotification/ckitcallnotification.pro @@ -0,0 +1,37 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2011-09-24T00:00:03 +# +#------------------------------------------------- + +TARGET = ckitcallnotification +TEMPLATE = lib +# CONFIG += plugin # Stupid Qt creator doesn't want to deploy plugins +QT += dbus + +SOURCES += ckitcallplugin.cpp \ + ckitcallprovider.cpp + +HEADERS += ckitcallplugin.h \ + ckitcallprovider.h + +CONFIG += link_pkgconfig +PKGCONFIG += contextsubscriber-1.0 + +unix: LIBS += -L$$OUT_PWD/../libsowatch/ -lsowatch + +INCLUDEPATH += $$PWD/../libsowatch +DEPENDPATH += $$PWD/../libsowatch + +unix:!symbian { + maemo5 { + target.path = /opt/sowatch/notifications + } else { + target.path = /usr/lib/sowatch/notifications + } + INSTALLS += target +} + + + + diff --git a/ckitcallnotification/ckitcallplugin.cpp b/ckitcallnotification/ckitcallplugin.cpp new file mode 100644 index 0000000..aea82c2 --- /dev/null +++ b/ckitcallnotification/ckitcallplugin.cpp @@ -0,0 +1,29 @@ +#include "ckitcallprovider.h" +#include "ckitcallplugin.h" + +using namespace sowatch; + +CKitCallPlugin::CKitCallPlugin(QObject *parent) : + QObject(parent) +{ +} + +CKitCallPlugin::~CKitCallPlugin() +{ +} + +QStringList CKitCallPlugin::providers() +{ + QStringList providers; + providers << "ckitcall"; + return providers; +} + +NotificationProvider* CKitCallPlugin::getProvider(const QString& driver, QSettings& settings, QObject *parent) +{ + Q_UNUSED(driver); + Q_UNUSED(settings); + return new CKitCallProvider(parent); +} + +Q_EXPORT_PLUGIN2(ckitcallnotification, CKitCallPlugin) diff --git a/ckitcallnotification/ckitcallplugin.h b/ckitcallnotification/ckitcallplugin.h new file mode 100644 index 0000000..a9d432d --- /dev/null +++ b/ckitcallnotification/ckitcallplugin.h @@ -0,0 +1,24 @@ +#ifndef CKITCALLPLUGIN_H +#define CKITCALLPLUGIN_H + +#include + +namespace sowatch +{ + +class CKitCallPlugin : public QObject, public NotificationPluginInterface +{ + Q_OBJECT + Q_INTERFACES(sowatch::NotificationPluginInterface) + +public: + CKitCallPlugin(QObject *parent = 0); + ~CKitCallPlugin(); + + QStringList providers(); + NotificationProvider* getProvider(const QString& driver, QSettings& settings, QObject *parent = 0); +}; + +} + +#endif // CKITCALLPLUGIN_H diff --git a/ckitcallnotification/ckitcallprovider.cpp b/ckitcallnotification/ckitcallprovider.cpp new file mode 100644 index 0000000..85f85b2 --- /dev/null +++ b/ckitcallnotification/ckitcallprovider.cpp @@ -0,0 +1,40 @@ +#include +#include +#include "ckitcallprovider.h" + +using namespace sowatch; + +CKitCallProvider::CKitCallProvider(QObject *parent) : + NotificationProvider(parent), + _inCall(false), + _activeCall(new ContextProperty("/com/nokia/CallUi/ActiveCall")) +{ + connect(_activeCall, SIGNAL(valueChanged()), SLOT(activeCallChanged())); + qDebug() << _activeCall->value(); +} + +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(); + } +} diff --git a/ckitcallnotification/ckitcallprovider.h b/ckitcallnotification/ckitcallprovider.h new file mode 100644 index 0000000..49d83a3 --- /dev/null +++ b/ckitcallnotification/ckitcallprovider.h @@ -0,0 +1,34 @@ +#ifndef CKITCALLPROVIDER_H +#define CKITCALLPROVIDER_H + +#include + +class ContextProperty; + +namespace sowatch +{ + +class CKitCallProvider : public NotificationProvider +{ + Q_OBJECT +public: + explicit CKitCallProvider(QObject *parent = 0); + ~CKitCallProvider(); + + int getCount(Notification::Type type); + +signals: + void incomingCall(const QString &displayName); + void endIncomingCall(); + +protected: + bool _inCall; + ContextProperty *_activeCall; + +protected slots: + void activeCallChanged(); +}; + +} + +#endif // CKITCALLPROVIDER_H diff --git a/libsowatch/notification.h b/libsowatch/notification.h index 80d7996..7a46ab7 100644 --- a/libsowatch/notification.h +++ b/libsowatch/notification.h @@ -13,11 +13,11 @@ class SOWATCH_EXPORT Notification public: enum Type { OtherNotification = 0, - CallNotification, - EmailNotification, MissedCallNotification, SmsNotification, + MmsNotification, ImNotification, + EmailNotification, CalendarNotification, TypeCount }; diff --git a/libsowatch/notificationprovider.h b/libsowatch/notificationprovider.h index 6f31581..fe835ef 100644 --- a/libsowatch/notificationprovider.h +++ b/libsowatch/notificationprovider.h @@ -22,6 +22,10 @@ signals: void notification(const Notification& n); void unreadCountChanged(Notification::Type type); + void weatherUpdate(); + + void incomingCall(const QString& displayName); + void endIncomingCall(); }; } diff --git a/libsowatch/watch.h b/libsowatch/watch.h index fff4c15..5552a8c 100644 --- a/libsowatch/watch.h +++ b/libsowatch/watch.h @@ -41,6 +41,8 @@ signals: public slots: virtual void vibrate(bool on) = 0; virtual void showNotification(const Notification& n) = 0; + virtual void startRinging(const QString& text) = 0; + virtual void stopRinging() = 0; }; } diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp index 8d00088..942131f 100644 --- a/libsowatch/watchserver.cpp +++ b/libsowatch/watchserver.cpp @@ -26,6 +26,8 @@ void WatchServer::addProvider(NotificationProvider *provider) connect(provider, SIGNAL(notification(Notification)), SLOT(notificationEmitted(Notification))); connect(provider, SIGNAL(unreadCountChanged(Notification::Type)), SLOT(unreadCountUpdated(Notification::Type))); + connect(provider, SIGNAL(incomingCall(QString)), SLOT(incomingCall(QString))); + connect(provider, SIGNAL(endIncomingCall()), SLOT(endIncomingCall())); _providers.append(provider); } @@ -85,3 +87,13 @@ void WatchServer::unreadCountUpdated(Notification::Type type) } _watch->updateNotificationCount(type, count); } + +void WatchServer::incomingCall(const QString &displayText) +{ + qDebug() << "Incoming call" << displayText; +} + +void WatchServer::endIncomingCall() +{ + qDebug() << "End incoming call"; +} diff --git a/libsowatch/watchserver.h b/libsowatch/watchserver.h index 0ca1f4f..27d29aa 100644 --- a/libsowatch/watchserver.h +++ b/libsowatch/watchserver.h @@ -44,6 +44,8 @@ protected slots: void watchDisconnected(); void notificationEmitted(const Notification& notification); void unreadCountUpdated(Notification::Type type); + void incomingCall(const QString& displayText); + void endIncomingCall(); friend class Watchlet; }; diff --git a/meegohandsetnotification/watchnotificationsink.cpp b/meegohandsetnotification/watchnotificationsink.cpp index 0d97562..c80c4ae 100644 --- a/meegohandsetnotification/watchnotificationsink.cpp +++ b/meegohandsetnotification/watchnotificationsink.cpp @@ -13,10 +13,16 @@ void WatchNotificationSink::addNotification(const Notification ¬ification) { const NotificationParameters& p = notification.parameters(); sowatch::Notification::Type type = notificationTypeFromEventType(p.value("eventType").toString()); - uint count = p.value("count").toUInt(); + const uint count = p.value("count").toUInt(); + const uint notificationId = notification.notificationId(); + + if (_trackedNotifications.contains(notificationId)) { + const NotificationParameters& oldParams = _trackedNotifications[notificationId].parameters(); + _counts[type] -= oldParams.value("count").toUInt(); + } _counts[type] += count; - _trackedNotifications[notification.notificationId()] = notification; + _trackedNotifications[notificationId] = notification; emit countsChanged(type); @@ -61,12 +67,17 @@ int WatchNotificationSink::getCount(sowatch::Notification::Type type) sowatch::Notification::Type WatchNotificationSink::notificationTypeFromEventType(const QString& eventType) { + qDebug() << "incoming " << eventType; if (eventType == "email.arrived") return sowatch::Notification::EmailNotification; else if (eventType == "x-nokia.call.missed") return sowatch::Notification::MissedCallNotification; else if (eventType == "x-nokia.messaging.im") return sowatch::Notification::ImNotification; + else if (eventType == "x-nokia.messaging.sms") + return sowatch::Notification::SmsNotification; + else if (eventType == "x-nokia.messaging.mms") + return sowatch::Notification::MmsNotification; else return sowatch::Notification::OtherNotification; } diff --git a/metawatch/metawatch.cpp b/metawatch/metawatch.cpp index e59db2a..657548a 100644 --- a/metawatch/metawatch.cpp +++ b/metawatch/metawatch.cpp @@ -87,7 +87,7 @@ MetaWatch::MetaWatch(const QBluetoothAddress& address, QObject *parent) : _sendTimer(new QTimer(this)), _currentMode(IdleMode), _paintMode(IdleMode), - _nMails(0), _nCalls(0), _nIms(0), _nSms(0) + _nMails(0), _nCalls(0), _nIms(0), _nSms(0), _nMms(0) { QImage baseImage(screenWidth, screenHeight, QImage::Format_MonoLSB); baseImage.setColor(0, QColor(Qt::white).rgb()); @@ -185,8 +185,8 @@ void MetaWatch::setDateTime(const QDateTime &dateTime) msg.data[5] = time.hour(); msg.data[6] = time.minute(); msg.data[7] = time.second(); - msg.data[8] = 1; - msg.data[9] = 1; + msg.data[8] = _24hMode ? 1 : 0; + msg.data[9] = _dayMonthOrder ? 1 : 0; send(msg); } @@ -206,6 +206,9 @@ void MetaWatch::updateNotificationCount(Notification::Type type, int count) case Notification::SmsNotification: _nSms = count; break; + case Notification::MmsNotification: + _nMms = count; + break; default: // Ignore break; @@ -224,6 +227,16 @@ void MetaWatch::showNotification(const Notification &n) qDebug() << "It's time for a notification" << n.title(); } +void MetaWatch::startRinging(const QString &text) +{ + +} + +void MetaWatch::stopRinging() +{ + +} + MetaWatch::Mode MetaWatch::currentMode() const { return _currentMode; diff --git a/metawatch/metawatch.h b/metawatch/metawatch.h index 9da21bb..48b7be6 100644 --- a/metawatch/metawatch.h +++ b/metawatch/metawatch.h @@ -80,6 +80,8 @@ public: void vibrate(bool on); void showNotification(const Notification& n); + void startRinging(const QString &text); + void stopRinging(); Mode currentMode() const; Mode paintTargetMode() const; @@ -126,7 +128,7 @@ protected: quint8 _buttonState; // Notifications: Unread count - uint _nMails, _nCalls, _nIms, _nSms; + uint _nMails, _nCalls, _nIms, _nSms, _nMms; static const quint8 bitRevTable[16]; static const quint16 crcTable[256]; diff --git a/sowatch.pro b/sowatch.pro index d872f29..0402176 100644 --- a/sowatch.pro +++ b/sowatch.pro @@ -4,7 +4,7 @@ SUBDIRS = libsowatch \ sowatchd !isEmpty(MEEGO_VERSION_MAJOR) { - #SUBDIRS += meegohandsetnotification + SUBDIRS += meegohandsetnotification ckitcallnotification } unix:!symbian { @@ -36,3 +36,4 @@ OTHER_FILES += \ + diff --git a/sowatchd/daemon.cpp b/sowatchd/daemon.cpp index 7889c70..645ecf6 100644 --- a/sowatchd/daemon.cpp +++ b/sowatchd/daemon.cpp @@ -37,7 +37,7 @@ void Daemon::loadDrivers() loader.unload(); } } else { - qWarning() << "Invalid plugin" << file; + qWarning() << "Invalid plugin" << file << loader.errorString(); loader.unload(); } } @@ -67,7 +67,7 @@ void Daemon::loadProviders() loader.unload(); } } else { - qWarning() << "Invalid plugin" << file; + qWarning() << "Invalid plugin" << file << loader.errorString(); loader.unload(); } } -- cgit v1.2.3