diff options
Diffstat (limited to 'rockworkd/platformintegration/sailfish/voicecallmanager.cpp')
| -rw-r--r-- | rockworkd/platformintegration/sailfish/voicecallmanager.cpp | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/rockworkd/platformintegration/sailfish/voicecallmanager.cpp b/rockworkd/platformintegration/sailfish/voicecallmanager.cpp index afb3629..eda4fe3 100644 --- a/rockworkd/platformintegration/sailfish/voicecallmanager.cpp +++ b/rockworkd/platformintegration/sailfish/voicecallmanager.cpp @@ -4,6 +4,10 @@ #include <QTimer> #include <QDBusInterface> #include <QDBusPendingReply> +#include <QtContacts/QContactManager> +#include <QtContacts/QContactDetailFilter> +#include <QtContacts/QContactPhoneNumber> + class VoiceCallManagerPrivate { @@ -29,8 +33,8 @@ public: bool connected; }; -VoiceCallManager::VoiceCallManager(Settings *settings, QObject *parent) - : QObject(parent), l(metaObject()->className()), d_ptr(new VoiceCallManagerPrivate(this)), settings(settings) +VoiceCallManager::VoiceCallManager(QObject *parent) + : QObject(parent), l(metaObject()->className()), d_ptr(new VoiceCallManagerPrivate(this)) { this->initialize(); } @@ -46,6 +50,13 @@ void VoiceCallManager::initialize(bool notifyError) Q_D(VoiceCallManager); bool success = false; + QMap<QString, QString> parameters; + parameters.insert(QString::fromLatin1("mergePresenceChanges"), QString::fromLatin1("false")); + contacts = new QContactManager("", parameters, this); + + numberFilter.setDetailType(QContactDetail::TypePhoneNumber, QContactPhoneNumber::FieldNumber); + numberFilter.setMatchFlags(QContactFilter::MatchPhoneNumber); + delete d->interface; d->interface = new QDBusInterface("org.nemomobile.voicecall", "/", @@ -109,6 +120,18 @@ QString VoiceCallManager::defaultProviderId() const return provider.id; } +QString VoiceCallManager::findPersonByNumber(QString number) +{ + QString person; + numberFilter.setValue(number); + + const QList<QContact> &found = contacts->contacts(numberFilter); + if (found.size() > 0) { + person = found[0].detail(QContactDetail::TypeDisplayLabel).value(0).toString(); + } + return person; +} + VoiceCallHandler* VoiceCallManager::activeVoiceCall() const { Q_D(const VoiceCallManager); @@ -139,6 +162,11 @@ bool VoiceCallManager::isSpeakerMuted() const return d->interface->property("isSpeakerMuted").toBool(); } +void VoiceCallManager::onVoiceError(const QString &message) +{ + qCritical() << "Error:" << message; +} + void VoiceCallManager::dial(const QString &provider, const QString &msisdn) { Q_D(VoiceCallManager); @@ -148,6 +176,16 @@ void VoiceCallManager::dial(const QString &provider, const QString &msisdn) QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(onPendingCallFinished(QDBusPendingCallWatcher*))); } +void VoiceCallManager::hangUp(uint cookie) { + foreach (VoiceCallHandler* handler, voiceCalls()) { + uint handlerId = qHash(handler->handlerId()); + if (cookie == handlerId) { + handler->hangup(); + return; + } + } +} + void VoiceCallManager::hangupAll() { foreach (VoiceCallHandler* handler, voiceCalls()) { @@ -196,6 +234,7 @@ bool VoiceCallManager::setMuteSpeaker(bool on) void VoiceCallManager::onVoiceCallsChanged() { + qDebug() << "VoiceCallsChanged"; Q_D(VoiceCallManager); QStringList nIds = d->interface->property("voiceCalls").toStringList(); QStringList oIds; @@ -226,8 +265,10 @@ void VoiceCallManager::onVoiceCallsChanged() { for (int i = 0; i < d->voicecalls.count(); ++i) { VoiceCallHandler *handler = d->voicecalls.at(i); + if (!handler) continue; if(handler->handlerId() == removeId) { + qDebug() << "removing " << handler->handlerId(); handler->disconnect(this); d->voicecalls.removeAt(i); handler->deleteLater(); @@ -239,6 +280,7 @@ void VoiceCallManager::onVoiceCallsChanged() // Add handlers that need to be added. foreach(QString addId, added) { + qDebug() << "adding " << addId; VoiceCallHandler *handler = new VoiceCallHandler(addId, this); d->voicecalls.append(handler); } @@ -263,6 +305,7 @@ void VoiceCallManager::onProvidersChanged() void VoiceCallManager::onActiveVoiceCallChanged() { + qDebug() << "ActiveVoiceCallChanged"; Q_D(VoiceCallManager); QString voiceCallId = d->interface->property("activeVoiceCall").toString(); |
