Commit 25ea2819 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(src/components/calls/CallsListProxyModel): handle conference changes on calls

parent 777017f4
...@@ -197,6 +197,8 @@ void CallModel::handleCallStateChanged (const shared_ptr<linphone::Call> &call, ...@@ -197,6 +197,8 @@ void CallModel::handleCallStateChanged (const shared_ptr<linphone::Call> &call,
if (call != mCall) if (call != mCall)
return; return;
updateIsInConference();
switch (state) { switch (state) {
case linphone::CallStateError: case linphone::CallStateError:
case linphone::CallStateEnd: case linphone::CallStateEnd:
...@@ -251,6 +253,15 @@ void CallModel::handleCallStateChanged (const shared_ptr<linphone::Call> &call, ...@@ -251,6 +253,15 @@ void CallModel::handleCallStateChanged (const shared_ptr<linphone::Call> &call,
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CallModel::updateIsInConference () {
if (mIsInConference != !!mCall->getConference()) {
mIsInConference = !mIsInConference;
emit isInConferenceChanged(mIsInConference);
}
}
// -----------------------------------------------------------------------------
void CallModel::stopAutoAnswerTimer () const { void CallModel::stopAutoAnswerTimer () const {
QTimer *timer = findChild<QTimer *>(AUTO_ANSWER_OBJECT_NAME, Qt::FindDirectChildrenOnly); QTimer *timer = findChild<QTimer *>(AUTO_ANSWER_OBJECT_NAME, Qt::FindDirectChildrenOnly);
if (timer) { if (timer) {
...@@ -259,6 +270,8 @@ void CallModel::stopAutoAnswerTimer () const { ...@@ -259,6 +270,8 @@ void CallModel::stopAutoAnswerTimer () const {
} }
} }
// -----------------------------------------------------------------------------
CallModel::CallStatus CallModel::getStatus () const { CallModel::CallStatus CallModel::getStatus () const {
switch (mCall->getState()) { switch (mCall->getState()) {
case linphone::CallStateConnected: case linphone::CallStateConnected:
......
...@@ -37,6 +37,8 @@ class CallModel : public QObject { ...@@ -37,6 +37,8 @@ class CallModel : public QObject {
Q_PROPERTY(bool isOutgoing READ isOutgoing CONSTANT); Q_PROPERTY(bool isOutgoing READ isOutgoing CONSTANT);
Q_PROPERTY(bool isInConference READ isInConference NOTIFY isInConferenceChanged);
Q_PROPERTY(int duration READ getDuration CONSTANT); // Constants but called with a timer in qml. Q_PROPERTY(int duration READ getDuration CONSTANT); // Constants but called with a timer in qml.
Q_PROPERTY(float quality READ getQuality CONSTANT); Q_PROPERTY(float quality READ getQuality CONSTANT);
Q_PROPERTY(float microVu READ getMicroVu CONSTANT); Q_PROPERTY(float microVu READ getMicroVu CONSTANT);
...@@ -94,6 +96,7 @@ public: ...@@ -94,6 +96,7 @@ public:
signals: signals:
void callErrorChanged (const QString &callError); void callErrorChanged (const QString &callError);
void isInConferenceChanged (bool status);
void microMutedChanged (bool status); void microMutedChanged (bool status);
void recordingChanged (bool status); void recordingChanged (bool status);
void statsUpdated (); void statsUpdated ();
...@@ -106,10 +109,17 @@ private: ...@@ -106,10 +109,17 @@ private:
void stopAutoAnswerTimer () const; void stopAutoAnswerTimer () const;
CallStatus getStatus () const; CallStatus getStatus () const;
bool isOutgoing () const { bool isOutgoing () const {
return mCall->getDir() == linphone::CallDirOutgoing; return mCall->getDir() == linphone::CallDirOutgoing;
} }
bool isInConference () const {
return mIsInConference;
}
void updateIsInConference ();
void acceptWithAutoAnswerDelay (); void acceptWithAutoAnswerDelay ();
QString getCallError () const; QString getCallError () const;
...@@ -139,6 +149,8 @@ private: ...@@ -139,6 +149,8 @@ private:
QString iceStateToString (linphone::IceState state) const; QString iceStateToString (linphone::IceState state) const;
bool mIsInConference = false;
bool mPausedByRemote = false; bool mPausedByRemote = false;
bool mPausedByUser = false; bool mPausedByUser = false;
bool mRecording = false; bool mRecording = false;
......
...@@ -37,15 +37,18 @@ using namespace std; ...@@ -37,15 +37,18 @@ using namespace std;
// ============================================================================= // =============================================================================
inline QList<CallModel *>::iterator findCallModel ( inline int findCallIndex (QList<CallModel *> &list, const shared_ptr<linphone::Call> &call) {
QList<CallModel *> &list, auto it = find_if(list.begin(), list.end(), [call](CallModel *callModel) {
const shared_ptr<linphone::Call> &call
) {
return find_if(
list.begin(), list.end(), [call](CallModel *callModel) {
return call == callModel->getCall(); return call == callModel->getCall();
} });
);
Q_ASSERT(it != list.end());
return static_cast<int>(distance(list.begin(), it));
}
inline int findCallIndex (QList<CallModel *> &list, const CallModel &callModel) {
return findCallIndex(list, callModel.getCall());
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -136,7 +139,7 @@ void CallsListModel::handleCallStateChanged (const std::shared_ptr<linphone::Cal ...@@ -136,7 +139,7 @@ void CallsListModel::handleCallStateChanged (const std::shared_ptr<linphone::Cal
break; break;
case linphone::CallStateStreamsRunning: { case linphone::CallStateStreamsRunning: {
int index = static_cast<int>(distance(mList.begin(), findCallModel(mList, call))); int index = findCallIndex(mList, call);
emit callRunning(index, &call->getData<CallModel>("call-model")); emit callRunning(index, &call->getData<CallModel>("call-model"));
} }
break; break;
...@@ -173,11 +176,17 @@ void CallsListModel::addCall (const shared_ptr<linphone::Call> &call) { ...@@ -173,11 +176,17 @@ void CallsListModel::addCall (const shared_ptr<linphone::Call> &call) {
App::smartShowWindow(App::getInstance()->getCallsWindow()); App::smartShowWindow(App::getInstance()->getCallsWindow());
CallModel *callModel = new CallModel(call); CallModel *callModel = new CallModel(call);
qInfo() << QStringLiteral("Add call:") << callModel; qInfo() << QStringLiteral("Add call:") << callModel;
App::getInstance()->getEngine()->setObjectOwnership(callModel, QQmlEngine::CppOwnership); App::getInstance()->getEngine()->setObjectOwnership(callModel, QQmlEngine::CppOwnership);
// This connection is (only) useful for `CallsListProxyModel`.
QObject::connect(
callModel, &CallModel::isInConferenceChanged, this, [this, callModel](bool) {
int id = findCallIndex(mList, *callModel);
emit dataChanged(index(id, 0), index(id, 0));
}
);
int row = mList.count(); int row = mList.count();
beginInsertRows(QModelIndex(), row, row); beginInsertRows(QModelIndex(), row, row);
......
...@@ -45,5 +45,5 @@ bool CallsListProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex &so ...@@ -45,5 +45,5 @@ bool CallsListProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex &so
const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent); const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent);
shared_ptr<linphone::Call> call = index.data().value<CallModel *>()->getCall(); shared_ptr<linphone::Call> call = index.data().value<CallModel *>()->getCall();
return call->getConference() != nullptr; return call->getConference() == nullptr;
} }
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