Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 50 additions & 41 deletions plugins/declarative/src/voicecallhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ QDBusInterface* VoiceCallHandler::interface() const
return d->interface;
}

void VoiceCallHandler::initialize(bool notifyError)
void VoiceCallHandler::initialize()
{
TRACE
Q_D(VoiceCallHandler);
Expand All @@ -114,47 +114,56 @@ void VoiceCallHandler::initialize(bool notifyError)

if (!(d->connected = success)) {
QTimer::singleShot(2000, this, SLOT(initialize()));
if (notifyError)
emit this->error("Failed to connect to VCM D-Bus service.");
} else {
QDBusReply<QVariantMap> reply = d->interface->call("getProperties");
if (reply.isValid()) {
QVariantMap props = reply.value();
d->providerId = props["providerId"].toString();
d->duration = props["duration"].toInt();
d->status = props["status"].toInt();
d->statusText = props["statusText"].toString();
d->lineId = props["lineId"].toString();
d->startedAt = QDateTime::fromMSecsSinceEpoch(props["startedAt"].toULongLong());
d->multiparty = props["isMultiparty"].toBool();
d->emergency = props["isEmergency"].toBool();
d->forwarded = props["isForwarded"].toBool();
d->remoteHeld = props["isRemoteHeld"].toBool();
d->parentHandlerId = props["parentHandlerId"].toString();
emit durationChanged();
emit statusChanged();
emit lineIdChanged();
emit startedAtChanged();
if (d->multiparty)
emit multipartyChanged();
if (d->emergency)
emit emergencyChanged();
if (d->forwarded)
emit forwardedChanged();
if (d->remoteHeld)
emit isRemoteHeld();
if (!d->parentHandlerId.isEmpty()) {
d->parentCall = VoiceCallManager::getCallHandler(d->parentHandlerId);
emit parentCallChanged();
}
if (d->multiparty) {
d->childCalls = new VoiceCallModel(this);
emit childCallsListChanged();
emit childCallsChanged();
}

} else if (notifyError) {
emit this->error("Failed to getProperties() from VCM D-Bus service.");
QDBusPendingCall call = d->interface->asyncCall("getProperties");
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
connect(watcher, &QDBusPendingCallWatcher::finished,
this, &VoiceCallHandler::onGetPropertiesFinished);
}
}

void VoiceCallHandler::onGetPropertiesFinished(QDBusPendingCallWatcher *watcher)
{
Q_D(VoiceCallHandler);
QDBusPendingReply<QVariantMap> reply = *watcher;
watcher->deleteLater();

if (reply.isError()) {
qWarning() << "VoicecallHandler GetProperties D-Bus call failed" << reply.error().message();
} else {
QVariantMap props = reply.value();
d->providerId = props["providerId"].toString();
d->duration = props["duration"].toInt();
d->status = props["status"].toInt();
d->statusText = props["statusText"].toString();
d->lineId = props["lineId"].toString();
d->startedAt = QDateTime::fromMSecsSinceEpoch(props["startedAt"].toULongLong());
d->multiparty = props["isMultiparty"].toBool();
d->emergency = props["isEmergency"].toBool();
d->forwarded = props["isForwarded"].toBool();
d->remoteHeld = props["isRemoteHeld"].toBool();
d->parentHandlerId = props["parentHandlerId"].toString();

emit durationChanged();
emit statusChanged();
emit lineIdChanged();
emit startedAtChanged();
if (d->multiparty)
emit multipartyChanged();
if (d->emergency)
emit emergencyChanged();
if (d->forwarded)
emit forwardedChanged();
if (d->remoteHeld)
emit isRemoteHeld();
if (!d->parentHandlerId.isEmpty()) {
d->parentCall = VoiceCallManager::getCallHandler(d->parentHandlerId);
emit parentCallChanged();
}
if (d->multiparty) {
d->childCalls = new VoiceCallModel(this);
emit childCallsListChanged();
emit childCallsChanged();
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions plugins/declarative/src/voicecallhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public Q_SLOTS:
void merge(const QString &callHandle);
void split();

protected Q_SLOTS:
void initialize(bool notifyError = false);
private Q_SLOTS:
void initialize();

void onPendingCallFinished(QDBusPendingCallWatcher *watcher);
void onPendingVoidCallFinished(QDBusPendingCallWatcher *watcher);
Expand All @@ -100,6 +100,7 @@ protected Q_SLOTS:
void onRemoteHeldChanged(bool remoteHeld);
void onMultipartyHandlerIdChanged(QString handlerId);
void onChildCallsChanged(const QStringList &);
void onGetPropertiesFinished(QDBusPendingCallWatcher *watcher);

private:
class VoiceCallHandlerPrivate *d_ptr;
Expand Down
67 changes: 35 additions & 32 deletions plugins/declarative/src/voicecallmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,30 @@ class VoiceCallManagerPrivate
public:
VoiceCallManagerPrivate(VoiceCallManager *q)
: q_ptr(q),
interface(NULL),
voicecalls(NULL),
providers(NULL),
activeVoiceCall(NULL),
interface(nullptr),
voicecalls(nullptr),
providers(nullptr),
activeVoiceCall(nullptr),
#ifdef WITH_NGF
ngf(0),
ngf(nullptr),
#endif
eventId(0),
connected(false)
{ /*...*/ }
{
}

VoiceCallManager *q_ptr;

QDBusInterface *interface;

VoiceCallModel *voicecalls;
VoiceCallProviderModel *providers;

VoiceCallHandler* activeVoiceCall;

#ifdef WITH_NGF
Ngf::Client *ngf;
#endif

quint32 eventId;

bool connected;

QString modemPath;
};

Expand Down Expand Up @@ -75,7 +71,7 @@ VoiceCallManager::~VoiceCallManager()
delete d;
}

void VoiceCallManager::initialize(bool notifyError)
void VoiceCallManager::initialize()
{
TRACE
Q_D(VoiceCallManager);
Expand Down Expand Up @@ -103,8 +99,6 @@ void VoiceCallManager::initialize(bool notifyError)

if (!(d->connected = success)) {
QTimer::singleShot(2000, this, SLOT(initialize()));
if (notifyError)
emit this->error("Failed to connect to VCM D-Bus service.");
}
}

Expand Down Expand Up @@ -222,7 +216,8 @@ void VoiceCallManager::dial(const QString &provider, const QString &msisdn)
QDBusPendingCall call = d->interface->asyncCall("dial", provider, msisdn);

QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(onPendingBoolCallFinished(QDBusPendingCallWatcher*)));
QObject::connect(watcher, &QDBusPendingCallWatcher::finished,
this, &VoiceCallManager::onPendingBoolCallFinished);
}

void VoiceCallManager::playRingtone(const QString &ringtonePath)
Expand All @@ -231,7 +226,8 @@ void VoiceCallManager::playRingtone(const QString &ringtonePath)
Q_D(const VoiceCallManager);
QDBusPendingCall call = d->interface->asyncCall("playRingtone", ringtonePath);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(onPendingVoidCallFinished(QDBusPendingCallWatcher*)));
QObject::connect(watcher, &QDBusPendingCallWatcher::finished,
this, &VoiceCallManager::onPendingVoidCallFinished);
}

void VoiceCallManager::silenceRingtone()
Expand All @@ -240,42 +236,49 @@ void VoiceCallManager::silenceRingtone()
Q_D(const VoiceCallManager);
QDBusPendingCall call = d->interface->asyncCall("silenceRingtone");
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(onPendingVoidCallFinished(QDBusPendingCallWatcher*)));
QObject::connect(watcher, &QDBusPendingCallWatcher::finished,
this, &VoiceCallManager::onPendingVoidCallFinished);
}

/*
- Use of method calls instead of property setters to allow status checking.
*/
bool VoiceCallManager::setAudioMode(const QString &mode)
void VoiceCallManager::setAudioMode(const QString &mode)
{
TRACE
Q_D(const VoiceCallManager);
QDBusPendingReply<bool> reply = d->interface->call("setAudioMode", mode);
return reply.isError() ? false : reply.value();

QDBusPendingCall call = d->interface->asyncCall("setAudioMode", mode);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished,
this, &VoiceCallManager::onPendingBoolCallFinished);
}

bool VoiceCallManager::setAudioRouted(bool on)
void VoiceCallManager::setAudioRouted(bool on)
{
TRACE
Q_D(const VoiceCallManager);
QDBusPendingReply<bool> reply = d->interface->call("setAudioRouted", on);
return reply.isError() ? false : reply.value();
QDBusPendingCall call = d->interface->asyncCall("setAudioRouted", on);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished,
this, &VoiceCallManager::onPendingBoolCallFinished);
}

bool VoiceCallManager::setMuteMicrophone(bool on)
void VoiceCallManager::setMuteMicrophone(bool on)
{
TRACE
Q_D(VoiceCallManager);
QDBusPendingReply<bool> reply = d->interface->call("setMuteMicrophone", on);
return reply.isError() ? false : reply.value();
QDBusPendingCall call = d->interface->asyncCall("setMuteMicrophone", on);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished,
this, &VoiceCallManager::onPendingBoolCallFinished);
}

bool VoiceCallManager::setMuteSpeaker(bool on)
void VoiceCallManager::setMuteSpeaker(bool on)
{
TRACE
Q_D(VoiceCallManager);
QDBusPendingReply<bool> reply = d->interface->call("setMuteSpeaker", on);
return reply.isError() ? false : reply.value();
QDBusPendingCall call = d->interface->asyncCall("setMuteSpeaker", on);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished,
this, &VoiceCallManager::onPendingBoolCallFinished);
}

bool VoiceCallManager::startDtmfTone(const QString &tone)
Expand Down
13 changes: 5 additions & 8 deletions plugins/declarative/src/voicecallmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
class VoiceCallManager : public QObject
{
Q_OBJECT

Q_PROPERTY(QDBusInterface* interface READ interface)

Q_PROPERTY(VoiceCallModel* voiceCalls READ voiceCalls NOTIFY voiceCallsChanged)
Q_PROPERTY(VoiceCallProviderModel* providers READ providers NOTIFY providersChanged)
Q_PROPERTY(VoiceCallHandler* activeVoiceCall READ activeVoiceCall NOTIFY activeVoiceCallChanged)
Expand Down Expand Up @@ -79,16 +76,16 @@ public Q_SLOTS:
void playRingtone(const QString &ringtonePath = QString());
void silenceRingtone();

bool setAudioMode(const QString &mode);
bool setAudioRouted(bool on);
bool setMuteMicrophone(bool on = true);
bool setMuteSpeaker(bool on = true);
void setAudioMode(const QString &mode);
void setAudioRouted(bool on);
void setMuteMicrophone(bool on = true);
void setMuteSpeaker(bool on = true);

bool startDtmfTone(const QString &tone);
bool stopDtmfTone();

protected Q_SLOTS:
void initialize(bool notifyError = false);
void initialize();

void onProvidersChanged();
void onVoiceCallsChanged();
Expand Down
13 changes: 8 additions & 5 deletions plugins/declarative/src/voicecallmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ class VoiceCallModelPrivate

public:
VoiceCallModelPrivate(VoiceCallModel *q, VoiceCallManager *pManager)
: q_ptr(q), manager(pManager), confHandler(0)
{/*...*/}
: q_ptr(q), manager(pManager), confHandler(nullptr)
{
}

VoiceCallModelPrivate(VoiceCallModel *q, VoiceCallHandler *pConf)
: q_ptr(q), manager(0), confHandler(pConf)
{/*...*/}
: q_ptr(q), manager(nullptr), confHandler(pConf)
{
}

VoiceCallModel *q_ptr;

Expand All @@ -77,7 +79,8 @@ VoiceCallModel::VoiceCallModel(VoiceCallManager *manager)
}

VoiceCallModel::VoiceCallModel(VoiceCallHandler *conf)
: QAbstractListModel(conf), d_ptr(new VoiceCallModelPrivate(this, conf))
: QAbstractListModel(conf)
, d_ptr(new VoiceCallModelPrivate(this, conf))
{
TRACE
Q_D(VoiceCallModel);
Expand Down
2 changes: 2 additions & 0 deletions plugins/declarative/src/voicecallplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ QObject *voice_call_audio_recorder_api_factory(QQmlEngine *qmlEngine, QJSEngine

void VoiceCallPlugin::registerTypes(const char *uri)
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.nemomobile.voicecall"));

qmlRegisterUncreatableType<VoiceCallHandler>(uri, 1, 0, "VoiceCall", "uncreatable type");
qmlRegisterUncreatableType<VoiceCallModel>(uri, 1, 0, "VoiceCallModel", "uncreatable type");
qmlRegisterUncreatableType<VoiceCallProviderModel>(uri, 1, 0, "VoiceCallProviderModel", "uncreatable type");
Expand Down
23 changes: 14 additions & 9 deletions plugins/declarative/src/voicecallprovidermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@
class VoiceCallProviderData
{
public:
VoiceCallProviderData() {/*..*/}
VoiceCallProviderData()
{
}

VoiceCallProviderData(const QString &pId, const QString &pType, const QString &pLabel)
: id(pId), type(pType), label(pLabel) {/*...*/}
: id(pId), type(pType), label(pLabel)
{
}

QString id;
QString type;
Expand All @@ -59,20 +64,20 @@ class VoiceCallProviderModelPrivate

public:
VoiceCallProviderModelPrivate(VoiceCallProviderModel *q, VoiceCallManager *pManager)
: q_ptr(q), manager(pManager)
{/*...*/}
: q_ptr(q)
, manager(pManager)
{
}

VoiceCallProviderModel *q_ptr;

VoiceCallManager *manager;

QHash<QString,VoiceCallProviderData> providers;

QHash<QString, VoiceCallProviderData> providers;
QHash<int, QByteArray> headerData;
};

VoiceCallProviderModel::VoiceCallProviderModel(VoiceCallManager *manager)
: QAbstractListModel(manager), d_ptr(new VoiceCallProviderModelPrivate(this, manager))
: QAbstractListModel(manager)
, d_ptr(new VoiceCallProviderModelPrivate(this, manager))
{
TRACE
Q_D(VoiceCallProviderModel);
Expand Down
3 changes: 2 additions & 1 deletion plugins/ngf/src/ngfringtoneplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class NgfRingtonePluginPrivate
};

NgfRingtonePlugin::NgfRingtonePlugin(QObject *parent)
: AbstractVoiceCallManagerPlugin(parent), d_ptr(new NgfRingtonePluginPrivate(this))
: AbstractVoiceCallManagerPlugin(parent)
, d_ptr(new NgfRingtonePluginPrivate(this))
{
TRACE
}
Expand Down