diff options
-rw-r--r-- | libwatchfish.pri | 6 | ||||
-rw-r--r-- | libwatchfish.pro | 2 | ||||
-rw-r--r-- | notification.cpp | 2 | ||||
-rw-r--r-- | notificationmonitor.cpp | 3 | ||||
-rw-r--r-- | org.nemomobile.voicecall.VoiceCall.xml | 69 | ||||
-rw-r--r-- | org.nemomobile.voicecall.VoiceCallManager.xml | 53 | ||||
-rw-r--r-- | voicecallcontroller.cpp | 148 | ||||
-rw-r--r-- | voicecallcontroller.h | 60 | ||||
-rw-r--r-- | voicecallcontroller_p.h | 72 |
9 files changed, 413 insertions, 2 deletions
diff --git a/libwatchfish.pri b/libwatchfish.pri index 6ff0728..8a256c2 100644 --- a/libwatchfish.pri +++ b/libwatchfish.pri @@ -23,3 +23,9 @@ contains(WATCHFISH_FEATURES, calendar) { HEADERS += $$PWD/calendarsource.h $$PWD/calendarsource_p.h $$PWD/calendarevent.h SOURCES += $$PWD/calendarsource.cpp $$PWD/calendarevent.cpp } + +contains(WATCHFISH_FEATURES, voicecall) { + HEADERS += $$PWD/voicecallcontroller.h $$PWD/voicecallcontroller_p.h + SOURCES += $$PWD/voicecallcontroller.cpp + DBUS_INTERFACES += org.nemomobile.voicecall.VoiceCallManager.xml org.nemomobile.voicecall.VoiceCall.xml +} diff --git a/libwatchfish.pro b/libwatchfish.pro index 18313a4..246eda2 100644 --- a/libwatchfish.pro +++ b/libwatchfish.pro @@ -4,5 +4,5 @@ TEMPLATE = lib CONFIG += staticlib QT += dbus -WATCHFISH_FEATURES = notificationmonitor walltime music calendar +WATCHFISH_FEATURES = notificationmonitor walltime music calendar voicecall include(libwatchfish.pri) diff --git a/notification.cpp b/notification.cpp index d0addbd..76d9be7 100644 --- a/notification.cpp +++ b/notification.cpp @@ -57,6 +57,8 @@ Notification::Notification(uint id, QObject *parent) : QObject(parent), d_ptr(ne { Q_D(Notification); d->id = id; + d->urgency = 0; + d->transient = false; } Notification::~Notification() diff --git a/notificationmonitor.cpp b/notificationmonitor.cpp index 60e226a..85acc2d 100644 --- a/notificationmonitor.cpp +++ b/notificationmonitor.cpp @@ -101,7 +101,8 @@ void NotificationMonitorPrivate::processIncomingNotification(quint32 id, const P n = new Notification(id, q); } - n->setAppId(proto.appId); + n->setAppId(proto.appId); + n->setAppName(proto.appName); n->setSummary(proto.summary); n->setBody(proto.body); n->setIcon(proto.appIcon); diff --git a/org.nemomobile.voicecall.VoiceCall.xml b/org.nemomobile.voicecall.VoiceCall.xml new file mode 100644 index 0000000..6693af2 --- /dev/null +++ b/org.nemomobile.voicecall.VoiceCall.xml @@ -0,0 +1,69 @@ +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" +"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<node> + <interface name="org.nemomobile.voicecall.VoiceCall"> + <property name="handlerId" type="s" access="read"/> + <property name="providerId" type="s" access="read"/> + <property name="status" type="i" access="read"/> + <property name="statusText" type="s" access="read"/> + <property name="lineId" type="s" access="read"/> + <property name="startedAt" type="((iii)(iiii)i)" access="read"> + <annotation name="org.qtproject.QtDBus.QtTypeName" value="QDateTime"/> + </property> + <property name="duration" type="i" access="read"/> + <property name="isIncoming" type="b" access="read"/> + <property name="isEmergency" type="b" access="read"/> + <property name="isMultiparty" type="b" access="read"/> + <property name="isForwarded" type="b" access="read"/> + <signal name="error"> + <arg name="message" type="s" direction="out"/> + </signal> + <signal name="statusChanged"> + <arg type="i" direction="out"/> + <arg type="s" direction="out"/> + </signal> + <signal name="lineIdChanged"> + <arg type="s" direction="out"/> + </signal> + <signal name="startedAtChanged"> + <arg type="((iii)(iiii)i)" direction="out"/> + <!-- For some reason both directions are seemingly required here --> + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QDateTime"/> + <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QDateTime"/> + </signal> + <signal name="durationChanged"> + <arg type="i" direction="out"/> + </signal> + <signal name="emergencyChanged"> + <arg type="b" direction="out"/> + </signal> + <signal name="multipartyChanged"> + <arg type="b" direction="out"/> + </signal> + <signal name="forwardedChanged"> + <arg type="b" direction="out"/> + </signal> + <method name="answer"> + <arg type="b" direction="out"/> + </method> + <method name="hangup"> + <arg type="b" direction="out"/> + </method> + <method name="hold"> + <arg type="b" direction="out"/> + <arg name="on" type="b" direction="in"/> + </method> + <method name="deflect"> + <arg type="b" direction="out"/> + <arg name="target" type="s" direction="in"/> + </method> + <method name="sendDtmf"> + <arg name="tones" type="s" direction="in"/> + </method> + <method name="getProperties"> + <arg type="a{sv}" direction="out"/> + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/> + </method> + </interface> +</node> + diff --git a/org.nemomobile.voicecall.VoiceCallManager.xml b/org.nemomobile.voicecall.VoiceCallManager.xml new file mode 100644 index 0000000..cfdbae5 --- /dev/null +++ b/org.nemomobile.voicecall.VoiceCallManager.xml @@ -0,0 +1,53 @@ +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" +"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<node> + <interface name="org.nemomobile.voicecall.VoiceCallManager"> + <property name="providers" type="as" access="read"/> + <property name="voiceCalls" type="as" access="read"/> + <property name="activeVoiceCall" type="s" access="read"/> + <property name="audioMode" type="s" access="readwrite"/> + <property name="isAudioRouted" type="b" access="readwrite"/> + <property name="isMicrophoneMuted" type="b" access="readwrite"/> + <property name="isSpeakerMuted" type="b" access="readwrite"/> + <property name="totalOutgoingCallDuration" type="i" access="read"/> + <property name="totalIncomingCallDuration" type="i" access="read"/> + <signal name="error"> + <arg name="message" type="s" direction="out"/> + </signal> + <signal name="providersChanged"> + </signal> + <signal name="voiceCallsChanged"> + </signal> + <signal name="activeVoiceCallChanged"> + </signal> + <signal name="audioModeChanged"> + </signal> + <signal name="audioRoutedChanged"> + </signal> + <signal name="microphoneMutedChanged"> + </signal> + <signal name="speakerMutedChanged"> + </signal> + <signal name="totalOutgoingCallDurationChanged"> + </signal> + <signal name="totalIncomingCallDurationChanged"> + </signal> + <method name="dial"> + <arg type="b" direction="out"/> + <arg name="provider" type="s" direction="in"/> + <arg name="msisdn" type="s" direction="in"/> + </method> + <method name="silenceRingtone"> + </method> + <method name="startDtmfTone"> + <arg type="b" direction="out"/> + <arg name="tone" type="s" direction="in"/> + </method> + <method name="stopDtmfTone"> + <arg type="b" direction="out"/> + </method> + <method name="resetCallDurationCounters"> + </method> + </interface> +</node> + diff --git a/voicecallcontroller.cpp b/voicecallcontroller.cpp new file mode 100644 index 0000000..5e3487e --- /dev/null +++ b/voicecallcontroller.cpp @@ -0,0 +1,148 @@ +/* + * libwatchfish - library with common functionality for SailfishOS smartwatch connector programs. + * Copyright (C) 2016 Javier S. Pedro <dev.git@javispedro.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "voicecallcontroller.h" +#include "voicecallcontroller_p.h" + +namespace watchfish +{ + +Q_LOGGING_CATEGORY(voiceCallControllerCat, "watchfish-VoiceCallController") + +VoiceCallControllerPrivate::VoiceCallControllerPrivate(VoiceCallController *q) + : vcm(new OrgNemomobileVoicecallVoiceCallManagerInterface("org.nemomobile.voicecall", + "/", QDBusConnection::sessionBus(), this)), + activeCall(0), + curInCall(false), curRinging(false), + q_ptr(q) +{ + connect(vcm, &OrgNemomobileVoicecallVoiceCallManagerInterface::activeVoiceCallChanged, + this, &VoiceCallControllerPrivate::handleActiveVoiceCallChanged); + handleActiveVoiceCallChanged(); +} + +VoiceCallControllerPrivate::~VoiceCallControllerPrivate() +{ + delete activeCall; +} + +void VoiceCallControllerPrivate::handleActiveVoiceCallChanged() +{ + delete activeCall; + QString id = vcm->activeVoiceCall(); + qCDebug(voiceCallControllerCat) << "Active voice call changed" << id; + if (!id.isEmpty()) { + activeCall = new OrgNemomobileVoicecallVoiceCallInterface("org.nemomobile.voicecall", + QString("/calls/%1").arg(id), vcm->connection(), this); + connect(activeCall, &OrgNemomobileVoicecallVoiceCallInterface::statusChanged, + this, &VoiceCallControllerPrivate::handleActiveVoiceCallStatusChanged); + connect(activeCall, &OrgNemomobileVoicecallVoiceCallInterface::lineIdChanged, + this, &VoiceCallControllerPrivate::handleActiveVoiceCallLineIdChanged); + VoiceCallStatus status = static_cast<VoiceCallStatus>(activeCall->status()); + setCallerId(activeCall->lineId()); + setCallStatus(status); + qDebug() << "Status of new call:" << status << curCallerId; + } else { + activeCall = 0; + setCallStatus(STATUS_NULL); + setCallerId(QString()); + } +} + +void VoiceCallControllerPrivate::handleActiveVoiceCallStatusChanged(int status, const QString &statusText) +{ + qCDebug(voiceCallControllerCat) << "Status changed:" << status << statusText; + setCallStatus(static_cast<VoiceCallStatus>(status)); +} + +void VoiceCallControllerPrivate::handleActiveVoiceCallLineIdChanged(const QString &lineId) +{ + qCDebug(voiceCallControllerCat) << "LineID changed:" << lineId; + setCallerId(lineId); +} + +void VoiceCallControllerPrivate::setCallStatus(VoiceCallStatus status) +{ + Q_Q(VoiceCallController); + const bool oldInCall = curInCall, oldRinging = curRinging; + switch (status) { + case STATUS_INCOMING: + curInCall = true; + curRinging = true; + break; + case STATUS_ACTIVE: + case STATUS_HELD: + case STATUS_DIALING: + case STATUS_ALERTING: + case STATUS_WAITING: + curInCall = true; + curRinging = false; + break; + case STATUS_DISCONNECTED: + case STATUS_NULL: + default: + curInCall = false; + curRinging = false; + break; + } + if (oldInCall != curInCall) { + emit q->inCallChanged(); + } + if (oldRinging != curRinging) { + emit q->ringingChanged(); + } +} + +void VoiceCallControllerPrivate::setCallerId(const QString &callerId) +{ + Q_Q(VoiceCallController); + if (callerId != curCallerId) { + curCallerId = callerId; + emit q->callerIdChanged(); + } +} + +VoiceCallController::VoiceCallController(QObject *parent) + : QObject(parent), d_ptr(new VoiceCallControllerPrivate(this)) +{ +} + +VoiceCallController::~VoiceCallController() +{ + delete d_ptr; +} + +bool VoiceCallController::inCall() const +{ + Q_D(const VoiceCallController); + return d->curInCall; +} + +bool VoiceCallController::ringing() const +{ + Q_D(const VoiceCallController); + return d->curRinging; +} + +QString VoiceCallController::callerId() const +{ + Q_D(const VoiceCallController); + return d->curCallerId; +} + +} diff --git a/voicecallcontroller.h b/voicecallcontroller.h new file mode 100644 index 0000000..c374a41 --- /dev/null +++ b/voicecallcontroller.h @@ -0,0 +1,60 @@ +/* + * libwatchfish - library with common functionality for SailfishOS smartwatch connector programs. + * Copyright (C) 2016 Javier S. Pedro <dev.git@javispedro.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef WATCHFISH_VOICECALLCONTROLLER_H +#define WATCHFISH_VOICECALLCONTROLLER_H + +#include <QtCore/QLoggingCategory> + +namespace watchfish +{ + +Q_DECLARE_LOGGING_CATEGORY(voiceCallControllerCat) + +class VoiceCallControllerPrivate; + +class VoiceCallController : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(VoiceCallController) + + Q_PROPERTY(bool inCall READ inCall NOTIFY inCallChanged) + Q_PROPERTY(bool ringing READ ringing NOTIFY ringingChanged) + Q_PROPERTY(QString callerId READ callerId NOTIFY callerIdChanged) + +public: + explicit VoiceCallController(QObject *parent = 0); + ~VoiceCallController(); + + bool inCall() const; + bool ringing() const; + + QString callerId() const; + +signals: + void inCallChanged(); + void ringingChanged(); + void callerIdChanged(); + +private: + VoiceCallControllerPrivate * const d_ptr; +}; + +} + +#endif // WATCHFISH_VOICECALLCONTROLLER_H diff --git a/voicecallcontroller_p.h b/voicecallcontroller_p.h new file mode 100644 index 0000000..624e615 --- /dev/null +++ b/voicecallcontroller_p.h @@ -0,0 +1,72 @@ +/* + * libwatchfish - library with common functionality for SailfishOS smartwatch connector programs. + * Copyright (C) 2016 Javier S. Pedro <dev.git@javispedro.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef WATCHFISH_VOICECALLCONTROLLER_P_H +#define WATCHFISH_VOICECALLCONTROLLER_P_H + +#include "voicecallcontroller.h" +#include "voicecall_interface.h" +#include "voicecallmanager_interface.h" + +namespace watchfish +{ + +enum VoiceCallStatus { + STATUS_NULL, + STATUS_ACTIVE, + STATUS_HELD, + STATUS_DIALING, + STATUS_ALERTING, + STATUS_INCOMING, + STATUS_WAITING, + STATUS_DISCONNECTED +}; + +class VoiceCallControllerPrivate : public QObject +{ + Q_OBJECT + +public: + explicit VoiceCallControllerPrivate(VoiceCallController *q); + ~VoiceCallControllerPrivate(); + +public slots: + void handleActiveVoiceCallChanged(); + void handleActiveVoiceCallStatusChanged(int status, const QString &statusName); + void handleActiveVoiceCallLineIdChanged(const QString &lineId); + +public: + OrgNemomobileVoicecallVoiceCallManagerInterface *vcm; + OrgNemomobileVoicecallVoiceCallInterface *activeCall; + + bool curInCall; + bool curRinging; + QString curCallerId; + + void setCallStatus(VoiceCallStatus status); + void setCallerId(const QString &callerId); + +private: + VoiceCallController * const q_ptr; + Q_DECLARE_PUBLIC(VoiceCallController) +}; + +} + +#endif // WATCHFISH_VOICECALLCONTROLLER_P_H + |