Commit 639fabf8 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): many fixes on calls (pause, buttons, actions...)

parent 04961056
-DENABLE_CXX_WRAPPER=YES -DENABLE_CXX_WRAPPER=YES
-DENABLE_GTK_UI=NO
-DENABLE_JPEG=NO -DENABLE_JPEG=NO
<?xml version="1.0" encoding="UTF-8"?>
<svg width="12px" height="10px" viewBox="0 0 12 10" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 40.3 (33839) - http://www.bohemiancoding.com/sketch -->
<title>chat_error</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="chat_error">
<polygon id="Path-1067" fill="#FF0000" points="6.05012213 3.64153152e-14 0 10 12 10"></polygon>
<path d="M6,6 L6,3.5" id="chat_message_delivered-copy-4" stroke="#FFFFFF" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"></path>
<ellipse id="Oval-24" fill="#FFFFFF" cx="6.03499979" cy="8.13500017" rx="0.834999979" ry="0.834999979"></ellipse>
</g>
</g>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg width="12px" height="10px" viewBox="0 0 12 10" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 40.3 (33839) - http://www.bohemiancoding.com/sketch -->
<title>chat_error</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="chat_error">
<polygon id="Path-1067" fill="#FF0000" points="6.05012213 3.64153152e-14 0 10 12 10"></polygon>
<path d="M6,6 L6,3.5" id="chat_message_delivered-copy-4" stroke="#FFFFFF" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"></path>
<ellipse id="Oval-24" fill="#FFFFFF" cx="6.03499979" cy="8.13500017" rx="0.834999979" ry="0.834999979"></ellipse>
</g>
</g>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg width="12px" height="10px" viewBox="0 0 12 10" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 40.3 (33839) - http://www.bohemiancoding.com/sketch -->
<title>chat_error</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="chat_error">
<polygon id="Path-1067" fill="#FF0000" points="6.05012213 3.64153152e-14 0 10 12 10"></polygon>
<path d="M6,6 L6,3.5" id="chat_message_delivered-copy-4" stroke="#FFFFFF" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"></path>
<ellipse id="Oval-24" fill="#FFFFFF" cx="6.03499979" cy="8.13500017" rx="0.834999979" ry="0.834999979"></ellipse>
</g>
</g>
</svg>
\ No newline at end of file
...@@ -80,6 +80,9 @@ ...@@ -80,6 +80,9 @@
<file>assets/images/fullscreen_hovered.svg</file> <file>assets/images/fullscreen_hovered.svg</file>
<file>assets/images/fullscreen_normal.svg</file> <file>assets/images/fullscreen_normal.svg</file>
<file>assets/images/fullscreen_pressed.svg</file> <file>assets/images/fullscreen_pressed.svg</file>
<file>assets/images/generic_error_hovered.svg</file>
<file>assets/images/generic_error_normal.svg</file>
<file>assets/images/generic_error_pressed.svg</file>
<file>assets/images/generic_error.svg</file> <file>assets/images/generic_error.svg</file>
<file>assets/images/hangup_hovered.svg</file> <file>assets/images/hangup_hovered.svg</file>
<file>assets/images/hangup_normal.svg</file> <file>assets/images/hangup_normal.svg</file>
......
...@@ -18,16 +18,22 @@ CallModel::CallModel (shared_ptr<linphone::Call> linphone_call) { ...@@ -18,16 +18,22 @@ CallModel::CallModel (shared_ptr<linphone::Call> linphone_call) {
case linphone::CallStateConnected: case linphone::CallStateConnected:
case linphone::CallStateEnd: case linphone::CallStateEnd:
case linphone::CallStateError: case linphone::CallStateError:
case linphone::CallStatePaused:
case linphone::CallStateRefered: case linphone::CallStateRefered:
case linphone::CallStateReleased: case linphone::CallStateReleased:
case linphone::CallStateStreamsRunning: case linphone::CallStateStreamsRunning:
m_linphone_call_status = state; m_paused_by_remote = false;
break; break;
case linphone::CallStatePausedByRemote: case linphone::CallStatePausedByRemote:
if (m_linphone_call_status != linphone::CallStatePaused) m_paused_by_remote = true;
m_linphone_call_status = state; break;
case linphone::CallStatePausing:
m_paused_by_user = true;
break;
case linphone::CallStateResuming:
m_paused_by_user = false;
break; break;
default: default:
...@@ -64,7 +70,7 @@ QString CallModel::getSipAddress () const { ...@@ -64,7 +70,7 @@ QString CallModel::getSipAddress () const {
} }
CallModel::CallStatus CallModel::getStatus () const { CallModel::CallStatus CallModel::getStatus () const {
switch (m_linphone_call_status) { switch (m_linphone_call->getState()) {
case linphone::CallStateConnected: case linphone::CallStateConnected:
case linphone::CallStateStreamsRunning: case linphone::CallStateStreamsRunning:
return CallStatusConnected; return CallStatusConnected;
...@@ -77,9 +83,23 @@ CallModel::CallStatus CallModel::getStatus () const { ...@@ -77,9 +83,23 @@ CallModel::CallStatus CallModel::getStatus () const {
case linphone::CallStatePaused: case linphone::CallStatePaused:
case linphone::CallStatePausedByRemote: case linphone::CallStatePausedByRemote:
case linphone::CallStatePausing:
case linphone::CallStateResuming:
return CallStatusPaused; return CallStatusPaused;
default: case linphone::CallStateUpdating:
case linphone::CallStateUpdatedByRemote:
return m_paused_by_remote ? CallStatusPaused : CallStatusConnected;
case linphone::CallStateEarlyUpdatedByRemote:
case linphone::CallStateEarlyUpdating:
case linphone::CallStateIdle:
case linphone::CallStateIncomingEarlyMedia:
case linphone::CallStateIncomingReceived:
case linphone::CallStateOutgoingEarlyMedia:
case linphone::CallStateOutgoingInit:
case linphone::CallStateOutgoingProgress:
case linphone::CallStateOutgoingRinging:
break; break;
} }
...@@ -111,20 +131,18 @@ void CallModel::setMicroMuted (bool status) { ...@@ -111,20 +131,18 @@ void CallModel::setMicroMuted (bool status) {
} }
bool CallModel::getPausedByUser () const { bool CallModel::getPausedByUser () const {
return m_linphone_call_status == linphone::CallStatePaused; return m_paused_by_user;
} }
void CallModel::setPausedByUser (bool status) { void CallModel::setPausedByUser (bool status) {
bool paused = getPausedByUser();
if (status) { if (status) {
if (!paused) if (!m_paused_by_user)
CoreManager::getInstance()->getCore()->pauseCall(m_linphone_call); CoreManager::getInstance()->getCore()->pauseCall(m_linphone_call);
return; return;
} }
if (paused) if (m_paused_by_user)
CoreManager::getInstance()->getCore()->resumeCall(m_linphone_call); CoreManager::getInstance()->getCore()->resumeCall(m_linphone_call);
} }
......
...@@ -69,8 +69,8 @@ private: ...@@ -69,8 +69,8 @@ private:
void setVideoOutputEnabled (bool status); void setVideoOutputEnabled (bool status);
bool m_micro_muted = false; bool m_micro_muted = false;
bool m_paused_by_remote = false;
linphone::CallState m_linphone_call_status = linphone::CallStateIdle; bool m_paused_by_user = false;
std::shared_ptr<linphone::Call> m_linphone_call; std::shared_ptr<linphone::Call> m_linphone_call;
}; };
......
...@@ -76,8 +76,16 @@ void CallsListModel::launchAudioCall (const QString &sip_uri) const { ...@@ -76,8 +76,16 @@ void CallsListModel::launchAudioCall (const QString &sip_uri) const {
void CallsListModel::launchVideoCall (const QString &sip_uri) const { void CallsListModel::launchVideoCall (const QString &sip_uri) const {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
// TODO: Deal with videos. shared_ptr<linphone::Address> address = core->interpretUrl(::Utils::qStringToLinphoneString(sip_uri));
core->inviteAddress(core->interpretUrl(::Utils::qStringToLinphoneString(sip_uri)));
if (!address)
return;
shared_ptr<linphone::CallParams> params = core->createCallParams(nullptr);
params->enableEarlyMediaSending(true);
params->enableVideo(true);
core->inviteAddressWithParams(address, params);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -13,6 +13,7 @@ QtObject { ...@@ -13,6 +13,7 @@ QtObject {
property color g: '#6B7A86' property color g: '#6B7A86'
property color g10: '#1A6B7A86' property color g10: '#1A6B7A86'
property color g20: '#336B7A86' property color g20: '#336B7A86'
property color g90: '#E66B7A86'
property color h: '#687680' property color h: '#687680'
property color i: '#FE5E00' property color i: '#FE5E00'
property color i30: '#4DFE5E00' property color i30: '#4DFE5E00'
......
...@@ -17,17 +17,9 @@ ListView { ...@@ -17,17 +17,9 @@ ListView {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function _getSignIcon (call) {
if (call) {
return 'call_sign_' + _mapStatusToParams[call.status].string
}
return ''
}
function _getParams (call) { function _getParams (call) {
if (call) { if (call) {
return _mapStatusToParams[call.status] return _mapStatusToParams[call.status](call)
} }
} }
...@@ -42,63 +34,74 @@ ListView { ...@@ -42,63 +34,74 @@ ListView {
Component.onCompleted: { Component.onCompleted: {
_mapStatusToParams = {} _mapStatusToParams = {}
_mapStatusToParams[CallModel.CallStatusConnected] = { _mapStatusToParams[CallModel.CallStatusConnected] = (function (call) {
return {
actions: [{ actions: [{
handler: (function (call) { call.pausedByUser = false }), handler: (function () { call.pausedByUser = true }),
name: qsTr('resumeCall') name: qsTr('pauseCall')
}, { }, {
handler: (function (call) { call.transfer() }), handler: (function () { call.transfer() }),
name: qsTr('transferCall') name: qsTr('transferCall')
}, { }, {
handler: (function (call) { call.terminate() }), handler: (function () { call.terminate() }),
name: qsTr('terminateCall') name: qsTr('terminateCall')
}], }],
component: callActions, component: callActions,
icon: 'hangup',
string: 'connected' string: 'connected'
} }
})
_mapStatusToParams[CallModel.CallStatusEnded] = { _mapStatusToParams[CallModel.CallStatusEnded] = (function (call) {
icon: 'hangup', return {
string: 'ended' string: 'ended'
} }
})
_mapStatusToParams[CallModel.CallStatusIncoming] = { _mapStatusToParams[CallModel.CallStatusIncoming] = (function (call) {
return {
actions: [{ actions: [{
name: qsTr('acceptAudioCall'), name: qsTr('acceptAudioCall'),
handler: (function (call) { call.accept() }) handler: (function () { call.accept() })
}, { }, {
name: qsTr('acceptVideoCall'), name: qsTr('acceptVideoCall'),
handler: (function (call) { call.acceptWithVideo() }) handler: (function () { call.acceptWithVideo() })
}, { }, {
name: qsTr('terminateCall'), name: qsTr('terminateCall'),
handler: (function (call) { call.terminate() }) handler: (function () { call.terminate() })
}], }],
component: callActions, component: callActions,
string: 'incoming' string: 'incoming'
} }
})
_mapStatusToParams[CallModel.CallStatusOutgoing] = { _mapStatusToParams[CallModel.CallStatusOutgoing] = (function (call) {
return {
component: callAction, component: callAction,
handler: (function (call) { call.terminate() }), handler: (function () { call.terminate() }),
icon: 'hangup', icon: 'hangup',
string: 'outgoing' string: 'outgoing'
} }
})
_mapStatusToParams[CallModel.CallStatusPaused] = { _mapStatusToParams[CallModel.CallStatusPaused] = (function (call) {
actions: [{ return {
handler: (function (call) { call.pausedByUser = true }), actions: [(call.pausedByUser ? {
handler: (function () { call.pausedByUser = false }),
name: qsTr('resumeCall')
} : {
handler: (function () { call.pausedByUser = true }),
name: qsTr('pauseCall') name: qsTr('pauseCall')
}, { }), {
handler: (function (call) { call.transfer() }), handler: (function () { call.transfer() }),
name: qsTr('transferCall') name: qsTr('transferCall')
}, { }, {
handler: (function (call) { call.terminate() }), handler: (function () { call.terminate() }),
name: qsTr('terminateCall') name: qsTr('terminateCall')
}], }],
component: callActions, component: callActions,
string: 'paused' string: 'paused'
} }
})
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -107,10 +110,10 @@ ListView { ...@@ -107,10 +110,10 @@ ListView {
id: callAction id: callAction
ActionButton { ActionButton {
icon: params.icon icon: params.icon || 'generic_error'
iconSize: CallsStyle.entry.iconActionSize iconSize: CallsStyle.entry.iconActionSize
onClicked: params.handler(call) onClicked: params.handler()
} }
} }
...@@ -149,7 +152,7 @@ ListView { ...@@ -149,7 +152,7 @@ ListView {
onClicked: { onClicked: {
menu.hideMenu() menu.hideMenu()
params.actions[index].handler(call) params.actions[index].handler()
} }
} }
} }
...@@ -233,7 +236,11 @@ ListView { ...@@ -233,7 +236,11 @@ ListView {
? CallsStyle.entry.usernameColor.selected ? CallsStyle.entry.usernameColor.selected
: CallsStyle.entry.usernameColor.normal : CallsStyle.entry.usernameColor.normal
signIcon: _getSignIcon($call) signIcon: {
var params = loader.params
return params ? 'call_sign_' + params.string : ''
}
sipAddress: $call.sipAddress sipAddress: $call.sipAddress
width: parent.width width: parent.width
...@@ -245,6 +252,8 @@ ListView { ...@@ -245,6 +252,8 @@ ListView {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
Loader { Loader {
id: loader
property int callId: index property int callId: index
property var call: $call property var call: $call
property var callControls: _callControls property var callControls: _callControls
......
...@@ -13,6 +13,7 @@ Item { ...@@ -13,6 +13,7 @@ Item {
property alias presenceLevel: presenceLevel.level property alias presenceLevel: presenceLevel.level
property color backgroundColor: AvatarStyle.backgroundColor property color backgroundColor: AvatarStyle.backgroundColor
property color foregroundColor: 'transparent'
property string username property string username
property var image property var image
...@@ -45,6 +46,7 @@ Item { ...@@ -45,6 +46,7 @@ Item {
anchors.fill: parent anchors.fill: parent
backgroundColor: avatar.backgroundColor backgroundColor: avatar.backgroundColor
foregroundColor: avatar.foregroundColor
source: avatar.image || '' source: avatar.image || ''
} }
......
...@@ -148,11 +148,29 @@ Rectangle { ...@@ -148,11 +148,29 @@ Rectangle {
} }
backgroundColor: CallStyle.container.avatar.backgroundColor backgroundColor: CallStyle.container.avatar.backgroundColor
foregroundColor: call.status === CallModel.CallStatusPaused
? CallStyle.container.pause.color
: 'transparent'
image: _contactObserver.contact && _contactObserver.contact.vcard.avatar image: _contactObserver.contact && _contactObserver.contact.vcard.avatar
username: contactDescription.username username: contactDescription.username
height: _computeAvatarSize() height: _computeAvatarSize()
width: height width: height
Text {
anchors.fill: parent
color: CallStyle.container.pause.text.color
// `|| 1` => `pointSize` must be greater than 0.
font.pointSize: (width / CallStyle.container.pause.text.fontSizeFactor) || 1
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: '&#9616;&nbsp;&#9612;'
textFormat: Text.RichText
visible: call.status === CallModel.CallStatusPaused
}
} }
} }
......
...@@ -28,6 +28,15 @@ QtObject { ...@@ -28,6 +28,15 @@ QtObject {
property color backgroundColor: Colors.w property color backgroundColor: Colors.w
property int maxSize: 300 property int maxSize: 300
} }
property QtObject pause: QtObject {
property color color: Colors.g90
property QtObject text: QtObject {
property color color: Colors.k
property int fontSizeFactor: 10
}
}
} }
property QtObject header: QtObject { property QtObject header: QtObject {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment