diff options
Diffstat (limited to 'daemon/manager.cpp')
| -rw-r--r-- | daemon/manager.cpp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/daemon/manager.cpp b/daemon/manager.cpp new file mode 100644 index 0000000..1bb71c0 --- /dev/null +++ b/daemon/manager.cpp @@ -0,0 +1,85 @@ +#include "manager.h" + +#include <QDebug> + +Manager::Manager(watch::WatchConnector *watch, VoiceCallManager *voice) : + QObject(0), watch(watch), voice(voice) +{ + connect(voice, SIGNAL(activeVoiceCallChanged()), SLOT(onActiveVoiceCallChanged())); + connect(voice, SIGNAL(error(const QString &)), SLOT(onVoiceError(const QString &))); + + // Watch instantiated hangup, follow the orders + connect(watch, SIGNAL(hangup()), SLOT(hangupAll())); + + if (btDevice.isValid()) { + qDebug() << "BT local name:" << btDevice.name(); + } +} + +void Manager::onActiveVoiceCallChanged() +{ + qDebug() << "Manager::onActiveVoiceCallChanged()"; + + VoiceCallHandler* handler = voice->activeVoiceCall(); + if (handler) { + connect(handler, SIGNAL(statusChanged()), SLOT(onActiveVoiceCallStatusChanged())); + return; + } +} + +void Manager::onActiveVoiceCallStatusChanged() +{ + VoiceCallHandler* handler = voice->activeVoiceCall(); + if (!handler) { + qWarning() << "ActiveVoiceCallStatusChanged but no activeVoiceCall??"; + return; + } + + qDebug() << "handlerId:" << handler->handlerId() + << "providerId:" << handler->providerId() + << "status:" << handler->status() + << "statusText:" << handler->statusText() + << "lineId:" << handler->lineId() + << "incoming:" << handler->isIncoming(); + + if (!watch->isConnected()) { + qDebug() << "Watch is not connected"; + return; + } + + switch ((VoiceCallHandler::VoiceCallStatus)handler->status()) { + case VoiceCallHandler::STATUS_ALERTING: + case VoiceCallHandler::STATUS_DIALING: + qDebug() << "Tell outgoing:" << handler->lineId(); + watch->ring("+48123123123", "person", false); + break; + case VoiceCallHandler::STATUS_INCOMING: + case VoiceCallHandler::STATUS_WAITING: + qDebug() << "Tell incoming:" << handler->lineId(); + watch->ring("+48123123123", "person"); + break; + case VoiceCallHandler::STATUS_NULL: + case VoiceCallHandler::STATUS_DISCONNECTED: + qDebug() << "Endphone"; + watch->endPhoneCall(); + break; + case VoiceCallHandler::STATUS_ACTIVE: + qDebug() << "Startphone"; + watch->startPhoneCall(); + break; + case VoiceCallHandler::STATUS_HELD: + break; + } +} + +void Manager::onVoiceError(const QString &message) +{ + qWarning() << "Error: " << message; +} + +void Manager::hangupAll() +{ + foreach (VoiceCallHandler* handler, voice->voiceCalls()) { + handler->hangup(); + } +} |
