Skip to content

Commit

Permalink
Merge pull request #65 from jpoutiai/remoteheld
Browse files Browse the repository at this point in the history
[voicecall] add support for remote held signal.Fixes MER#907
  • Loading branch information
jusa committed Apr 21, 2015
2 parents 31e28d4 + 81fef5d commit 5531f5d
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/src/abstractvoicecallhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class AbstractVoiceCallHandler : public QObject
Q_PROPERTY(bool isEmergency READ isEmergency NOTIFY emergencyChanged)
Q_PROPERTY(bool isMultiparty READ isMultiparty NOTIFY multipartyChanged)
Q_PROPERTY(bool isForwarded READ isForwarded NOTIFY forwardedChanged)
Q_PROPERTY(bool isRemoteHeld READ isRemoteHeld NOTIFY remoteHeldChanged)

public:
enum VoiceCallStatus {
Expand All @@ -69,6 +70,7 @@ class AbstractVoiceCallHandler : public QObject
virtual bool isMultiparty() const = 0;
virtual bool isEmergency() const = 0;
virtual bool isForwarded() const = 0;
virtual bool isRemoteHeld() const = 0;

virtual VoiceCallStatus status() const = 0;

Expand All @@ -83,6 +85,7 @@ class AbstractVoiceCallHandler : public QObject
void emergencyChanged(bool);
void multipartyChanged(bool);
void forwardedChanged(bool);
void remoteHeldChanged(bool);

public Q_SLOTS:
virtual void answer() = 0;
Expand Down
12 changes: 12 additions & 0 deletions lib/src/dbus/voicecallhandlerdbusadapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ VoiceCallHandlerDBusAdapter::VoiceCallHandlerDBusAdapter(AbstractVoiceCallHandle
QObject::connect(d->handler, SIGNAL(emergencyChanged(bool)), SIGNAL(emergencyChanged(bool)));
QObject::connect(d->handler, SIGNAL(multipartyChanged(bool)), SIGNAL(multipartyChanged(bool)));
QObject::connect(d->handler, SIGNAL(forwardedChanged(bool)), SIGNAL(forwardedChanged(bool)));
QObject::connect(d->handler, SIGNAL(remoteHeldChanged(bool)), SIGNAL(remoteHeldChanged(bool)));
}

VoiceCallHandlerDBusAdapter::~VoiceCallHandlerDBusAdapter()
Expand Down Expand Up @@ -148,6 +149,16 @@ bool VoiceCallHandlerDBusAdapter::isForwarded() const
return d->handler->isForwarded();
}

/*!
Returns this voice calls' remote held flag property.
*/
bool VoiceCallHandlerDBusAdapter::isRemoteHeld() const
{
TRACE
Q_D(const VoiceCallHandlerDBusAdapter);
return d->handler->isRemoteHeld();
}

/*!
Returns this voice calls' emergency flag property.
*/
Expand Down Expand Up @@ -254,6 +265,7 @@ QVariantMap VoiceCallHandlerDBusAdapter::getProperties()
props.insert("isEmergency", QVariant(isEmergency()));
props.insert("isMultiparty", QVariant(isMultiparty()));
props.insert("isForwarded", QVariant(isForwarded()));
props.insert("isRemoteHeld", QVariant(isRemoteHeld()));

return props;
}
Expand Down
3 changes: 3 additions & 0 deletions lib/src/dbus/voicecallhandlerdbusadapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class VoiceCallHandlerDBusAdapter : public QDBusAbstractAdaptor
Q_PROPERTY(bool isEmergency READ isEmergency NOTIFY emergencyChanged)
Q_PROPERTY(bool isMultiparty READ isMultiparty NOTIFY multipartyChanged)
Q_PROPERTY(bool isForwarded READ isForwarded NOTIFY forwardedChanged)
Q_PROPERTY(bool isRemoteHeld READ isRemoteHeld NOTIFY remoteHeldChanged)

public:
explicit VoiceCallHandlerDBusAdapter(AbstractVoiceCallHandler *parent = 0);
Expand All @@ -58,6 +59,7 @@ class VoiceCallHandlerDBusAdapter : public QDBusAbstractAdaptor
bool isMultiparty() const;
bool isEmergency() const;
bool isForwarded() const;
bool isRemoteHeld() const;

Q_SIGNALS:
void error(const QString &message);
Expand All @@ -68,6 +70,7 @@ class VoiceCallHandlerDBusAdapter : public QDBusAbstractAdaptor
void emergencyChanged(bool);
void multipartyChanged(bool);
void forwardedChanged(bool);
void remoteHeldChanged(bool);

public Q_SLOTS:
bool answer();
Expand Down
25 changes: 24 additions & 1 deletion plugins/declarative/src/voicecallhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class VoiceCallHandlerPrivate
public:
VoiceCallHandlerPrivate(VoiceCallHandler *q, const QString &pHandlerId)
: q_ptr(q), handlerId(pHandlerId), interface(NULL), connected(false)
, duration(0), status(0), emergency(false), multiparty(false), forwarded(false)
, duration(0), status(0), emergency(false), multiparty(false)
, forwarded(false), remoteHeld(false)
{ /* ... */ }

VoiceCallHandler *q_ptr;
Expand All @@ -39,6 +40,7 @@ class VoiceCallHandlerPrivate
bool emergency;
bool multiparty;
bool forwarded;
bool remoteHeld;
};

/*!
Expand Down Expand Up @@ -82,6 +84,7 @@ void VoiceCallHandler::initialize(bool notifyError)
success &= (bool)QObject::connect(d->interface, SIGNAL(emergencyChanged(bool)), SLOT(onEmergencyChanged(bool)));
success &= (bool)QObject::connect(d->interface, SIGNAL(multipartyChanged(bool)), SLOT(onMultipartyChanged(bool)));
success &= (bool)QObject::connect(d->interface, SIGNAL(forwardedChanged(bool)), SLOT(onForwardedChanged(bool)));
success &= (bool)QObject::connect(d->interface, SIGNAL(remoteHeldChanged(bool)), SLOT(onRemoteHeldChanged(bool)));
}

if(!(d->connected = success))
Expand All @@ -101,6 +104,7 @@ void VoiceCallHandler::initialize(bool notifyError)
d->multiparty = props["isMultiparty"].toBool();
d->emergency = props["isEmergency"].toBool();
d->forwarded = props["isForwarded"].toBool();
d->remoteHeld = props["isRemoteHeld"].toBool();
emit durationChanged();
emit statusChanged();
emit lineIdChanged();
Expand All @@ -109,6 +113,7 @@ void VoiceCallHandler::initialize(bool notifyError)
emit emergencyChanged();
emit forwardedChanged();
emit isReadyChanged();
emit isRemoteHeld();
} else if (notifyError) {
emit this->error("Failed to getProperties() from VCM D-Bus service.");
}
Expand Down Expand Up @@ -172,6 +177,14 @@ void VoiceCallHandler::onForwardedChanged(bool forwarded)
emit forwardedChanged();
}

void VoiceCallHandler::onRemoteHeldChanged(bool remoteHeld)
{
TRACE
Q_D(VoiceCallHandler);
d->remoteHeld = remoteHeld;
emit remoteHeldChanged();
}

/*!
Returns this voice calls' handler id.
*/
Expand Down Expand Up @@ -268,6 +281,16 @@ bool VoiceCallHandler::isForwarded() const
return d->forwarded;
}

/*!
Returns this voice calls' remote held flag property.
*/
bool VoiceCallHandler::isRemoteHeld() const
{
TRACE
Q_D(const VoiceCallHandler);
return d->remoteHeld;
}

/*!
Returns this voice calls' emergency flag property.
*/
Expand Down
4 changes: 4 additions & 0 deletions plugins/declarative/src/voicecallhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class VoiceCallHandler : public QObject
Q_PROPERTY(bool isMultiparty READ isMultiparty NOTIFY multipartyChanged)
Q_PROPERTY(bool isForwarded READ isForwarded NOTIFY forwardedChanged)
Q_PROPERTY(bool isReady READ isReady NOTIFY isReadyChanged)
Q_PROPERTY(bool isRemoteHeld READ isRemoteHeld NOTIFY remoteHeldChanged)

public:
enum VoiceCallStatus {
Expand Down Expand Up @@ -52,6 +53,7 @@ class VoiceCallHandler : public QObject
bool isEmergency() const;
bool isForwarded() const;
bool isReady() const;
bool isRemoteHeld() const;

Q_SIGNALS:
void error(const QString &error);
Expand All @@ -63,6 +65,7 @@ class VoiceCallHandler : public QObject
void multipartyChanged();
void forwardedChanged();
void isReadyChanged();
void remoteHeldChanged();

public Q_SLOTS:
void answer();
Expand All @@ -82,6 +85,7 @@ protected Q_SLOTS:
void onEmergencyChanged(bool emergency);
void onMultipartyChanged(bool multiparty);
void onForwardedChanged(bool forwarded);
void onRemoteHeldChanged(bool remoteHeld);

private:
class VoiceCallHandlerPrivate *d_ptr;
Expand Down
6 changes: 6 additions & 0 deletions plugins/providers/ofono/src/ofonovoicecallhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ bool OfonoVoiceCallHandler::isForwarded() const
return false;
}

bool OfonoVoiceCallHandler::isRemoteHeld() const
{
TRACE
return false;
}

AbstractVoiceCallHandler::VoiceCallStatus OfonoVoiceCallHandler::status() const
{
TRACE
Expand Down
1 change: 1 addition & 0 deletions plugins/providers/ofono/src/ofonovoicecallhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class OfonoVoiceCallHandler : public AbstractVoiceCallHandler
bool isMultiparty() const;
bool isEmergency() const;
bool isForwarded() const;
bool isRemoteHeld() const;

VoiceCallStatus status() const;

Expand Down
11 changes: 10 additions & 1 deletion plugins/providers/telepathy/src/callchannelhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class CallChannelHandlerPrivate
CallChannelHandlerPrivate(CallChannelHandler *q, const QString &id, Tp::CallChannelPtr c, const QDateTime &s, TelepathyProvider *p)
: q_ptr(q), handlerId(id), provider(p), startedAt(s), status(AbstractVoiceCallHandler::STATUS_NULL),
channel(c), fsChannel(NULL), duration(0), durationTimerId(-1), isEmergency(false),
isForwarded(false), isIncoming(false)
isForwarded(false), isIncoming(false), isRemoteHeld(false)
{ /* ... */ }

CallChannelHandler *q_ptr;
Expand All @@ -86,6 +86,7 @@ class CallChannelHandlerPrivate
bool isEmergency;
bool isForwarded;
bool isIncoming;
bool isRemoteHeld;
};

CallChannelHandler::CallChannelHandler(const QString &id, Tp::CallChannelPtr channel, const QDateTime &userActionTime, TelepathyProvider *provider)
Expand Down Expand Up @@ -180,6 +181,14 @@ bool CallChannelHandler::isForwarded() const
return d->isForwarded;
}

bool CallChannelHandler::isRemoteHeld() const
{
TRACE
Q_D(const CallChannelHandler);
if(!d->channel->isReady()) return false;
return d->isRemoteHeld;
}

AbstractVoiceCallHandler::VoiceCallStatus CallChannelHandler::status() const
{
TRACE
Expand Down
1 change: 1 addition & 0 deletions plugins/providers/telepathy/src/callchannelhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class CallChannelHandler : public AbstractVoiceCallHandler
bool isMultiparty() const;
bool isEmergency() const;
bool isForwarded() const;
bool isRemoteHeld() const;

VoiceCallStatus status() const;

Expand Down
24 changes: 23 additions & 1 deletion plugins/providers/telepathy/src/streamchannelhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class StreamChannelHandlerPrivate
StreamChannelHandlerPrivate(StreamChannelHandler *q, const QString &id, Tp::StreamedMediaChannelPtr c, const QDateTime &s, TelepathyProvider *p)
: q_ptr(q), handlerId(id), provider(p), startedAt(s), status(AbstractVoiceCallHandler::STATUS_NULL),
channel(c), servicePointInterface(NULL), duration(0), durationTimerId(-1), isEmergency(false),
isForwarded(false), isIncoming(false)
isForwarded(false), isIncoming(false), isRemoteHeld(false)
{ /* ... */ }

void listenToEmergencyStatus()
Expand Down Expand Up @@ -108,6 +108,7 @@ class StreamChannelHandlerPrivate
bool isEmergency;
bool isForwarded;
bool isIncoming;
bool isRemoteHeld;
};

StreamChannelHandler::StreamChannelHandler(const QString &id, Tp::StreamedMediaChannelPtr channel, const QDateTime &userActionTime, TelepathyProvider *provider)
Expand Down Expand Up @@ -203,6 +204,14 @@ bool StreamChannelHandler::isForwarded() const
return d->isForwarded;
}

bool StreamChannelHandler::isRemoteHeld() const
{
TRACE
Q_D(const StreamChannelHandler);
if(!d->channel->isReady()) return false;
return d->isRemoteHeld;
}

AbstractVoiceCallHandler::VoiceCallStatus StreamChannelHandler::status() const
{
TRACE
Expand Down Expand Up @@ -459,6 +468,19 @@ void StreamChannelHandler::onStreamedMediaChannelCallStateChanged(uint, uint sta
TRACE
Q_D(StreamChannelHandler);
bool forwarded = state & Tp::ChannelCallStateForwarded;

if ((d->status == STATUS_HELD) && !state) {
setStatus(STATUS_ACTIVE);
d->isRemoteHeld = false;
emit remoteHeldChanged(d->isRemoteHeld);
}

if (state & Tp::ChannelCallStateHeld) {
setStatus(STATUS_HELD);
d->isRemoteHeld = true;
emit remoteHeldChanged(d->isRemoteHeld);
}

if (forwarded != d->isForwarded) {
d->isForwarded = forwarded;
DEBUG_T(QString("Call forwarded: ") + (forwarded ? "true" : "false"));
Expand Down
1 change: 1 addition & 0 deletions plugins/providers/telepathy/src/streamchannelhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class StreamChannelHandler : public AbstractVoiceCallHandler
bool isMultiparty() const;
bool isEmergency() const;
bool isForwarded() const;
bool isRemoteHeld() const;

VoiceCallStatus status() const;

Expand Down

0 comments on commit 5531f5d

Please sign in to comment.