mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-31 10:59:23 +00:00
feat(app): calls in progress
This commit is contained in:
parent
2d4e1d9fb5
commit
af60c28e22
4 changed files with 71 additions and 7 deletions
|
|
@ -7,6 +7,36 @@
|
|||
|
||||
CallModel::CallModel (shared_ptr<linphone::Call> linphone_call) {
|
||||
m_linphone_call = linphone_call;
|
||||
|
||||
QObject::connect(
|
||||
&(*CoreManager::getInstance()->getHandlers()), &CoreHandlers::callStateChanged,
|
||||
this, [this](const std::shared_ptr<linphone::Call> &call, linphone::CallState state) {
|
||||
if (call != m_linphone_call)
|
||||
return;
|
||||
|
||||
switch (state) {
|
||||
case linphone::CallStateConnected:
|
||||
case linphone::CallStateEnd:
|
||||
case linphone::CallStateError:
|
||||
case linphone::CallStatePaused:
|
||||
case linphone::CallStateRefered:
|
||||
case linphone::CallStateReleased:
|
||||
case linphone::CallStateStreamsRunning:
|
||||
m_linphone_call_status = state;
|
||||
break;
|
||||
|
||||
case linphone::CallStatePausedByRemote:
|
||||
if (m_linphone_call_status != linphone::CallStatePaused)
|
||||
m_linphone_call_status = state;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
emit statusChanged(getStatus());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
@ -19,6 +49,10 @@ void CallModel::terminateCall () {
|
|||
CoreManager::getInstance()->getCore()->terminateCall(m_linphone_call);
|
||||
}
|
||||
|
||||
void CallModel::transferCall () {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString CallModel::getSipAddress () const {
|
||||
|
|
@ -26,7 +60,7 @@ QString CallModel::getSipAddress () const {
|
|||
}
|
||||
|
||||
CallModel::CallStatus CallModel::getStatus () const {
|
||||
switch (m_linphone_call->getState()) {
|
||||
switch (m_linphone_call_status) {
|
||||
case linphone::CallStateConnected:
|
||||
case linphone::CallStateStreamsRunning:
|
||||
return CallStatusConnected;
|
||||
|
|
@ -48,8 +82,24 @@ CallModel::CallStatus CallModel::getStatus () const {
|
|||
return m_linphone_call->getDir() == linphone::CallDirIncoming ? CallStatusIncoming : CallStatusOutgoing;
|
||||
}
|
||||
|
||||
bool CallModel::getMicroMuted () const {
|
||||
return m_micro_muted;
|
||||
}
|
||||
|
||||
void CallModel::setMicroMuted (bool status) {
|
||||
if (m_micro_muted != status) {
|
||||
m_micro_muted = status;
|
||||
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
if (m_micro_muted == core->micEnabled())
|
||||
core->enableMic(!m_micro_muted);
|
||||
|
||||
emit microMutedChanged(m_micro_muted);
|
||||
}
|
||||
}
|
||||
|
||||
bool CallModel::getPausedByUser () const {
|
||||
return m_linphone_call->getState() == linphone::CallStatePaused;
|
||||
return m_linphone_call_status == linphone::CallStatePaused;
|
||||
}
|
||||
|
||||
void CallModel::setPausedByUser (bool status) {
|
||||
|
|
|
|||
|
|
@ -10,16 +10,16 @@ class CallModel : public QObject {
|
|||
Q_OBJECT;
|
||||
|
||||
Q_PROPERTY(QString sipAddress READ getSipAddress CONSTANT);
|
||||
|
||||
Q_PROPERTY(CallStatus status READ getStatus NOTIFY statusChanged);
|
||||
Q_PROPERTY(bool isOutgoing READ isOutgoing CONSTANT);
|
||||
|
||||
Q_PROPERTY(bool microMuted READ getMicroMuted WRITE setMicroMuted NOTIFY microMutedChanged);
|
||||
Q_PROPERTY(bool pausedByUser READ getPausedByUser WRITE setPausedByUser NOTIFY pausedByUserChanged);
|
||||
|
||||
public:
|
||||
enum CallStatus {
|
||||
CallStatusConnected,
|
||||
CallStatusEnded,
|
||||
CallStatusIdle,
|
||||
CallStatusIncoming,
|
||||
CallStatusOutgoing,
|
||||
CallStatusPaused
|
||||
|
|
@ -32,23 +32,31 @@ public:
|
|||
|
||||
Q_INVOKABLE void acceptAudioCall ();
|
||||
Q_INVOKABLE void terminateCall ();
|
||||
Q_INVOKABLE void transferCall ();
|
||||
|
||||
signals:
|
||||
void statusChanged (CallStatus status);
|
||||
void pausedByUserChanged (bool status);
|
||||
void microMutedChanged (bool status);
|
||||
|
||||
private:
|
||||
QString getSipAddress () const;
|
||||
|
||||
CallStatus getStatus () const;
|
||||
|
||||
bool isOutgoing () const {
|
||||
return m_linphone_call->getDir() == linphone::CallDirOutgoing;
|
||||
}
|
||||
|
||||
bool getMicroMuted () const;
|
||||
void setMicroMuted (bool status);
|
||||
|
||||
bool getPausedByUser () const;
|
||||
void setPausedByUser (bool status);
|
||||
|
||||
bool m_micro_muted = false;
|
||||
|
||||
linphone::CallState m_linphone_call_status = linphone::CallStateIdle;
|
||||
|
||||
std::shared_ptr<linphone::Call> m_linphone_call;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@ public:
|
|||
// Singleton models.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
ContactsListModel *getContactsListModel () {
|
||||
ContactsListModel *getContactsListModel () const {
|
||||
return m_contacts_list_model;
|
||||
}
|
||||
|
||||
SipAddressesModel *getSipAddressesModel () {
|
||||
SipAddressesModel *getSipAddressesModel () const {
|
||||
return m_sip_addresses_model;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,16 @@ import Linphone.Styles 1.0
|
|||
ListView {
|
||||
id: calls
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
property var _mapStatusToParams
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
signal entrySelected (var entry)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function _getSignIcon (call) {
|
||||
if (call) {
|
||||
var string = _mapStatusToParams[call.status].string
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue