Commit fa162699 authored by Ronan Abhamon's avatar Ronan Abhamon

fix(app): coding style

parent 054f3907
...@@ -59,54 +59,7 @@ CallModel::CallModel (shared_ptr<linphone::Call> call) { ...@@ -59,54 +59,7 @@ CallModel::CallModel (shared_ptr<linphone::Call> call) {
QObject::connect( QObject::connect(
CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::callStateChanged, CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::callStateChanged,
this, [this](const shared_ptr<linphone::Call> &call, linphone::CallState state) { this, &CallModel::handleCallStateChanged
if (call != mCall)
return;
switch (state) {
case linphone::CallStateError:
setReason(call->getReason());
case linphone::CallStateEnd:
stopAutoAnswerTimer();
mPausedByRemote = false;
break;
case linphone::CallStateConnected:
case linphone::CallStateRefered:
case linphone::CallStateReleased:
case linphone::CallStateStreamsRunning:
mPausedByRemote = false;
break;
case linphone::CallStatePausedByRemote:
mPausedByRemote = true;
break;
case linphone::CallStatePausing:
mPausedByUser = true;
break;
case linphone::CallStateResuming:
mPausedByUser = false;
break;
case linphone::CallStateUpdatedByRemote:
if (
!mCall->getCurrentParams()->videoEnabled() &&
mCall->getRemoteParams()->videoEnabled()
) {
mCall->deferUpdate();
emit videoRequested();
}
break;
default:
break;
}
emit statusChanged(getStatus());
}
); );
} }
...@@ -235,6 +188,57 @@ void CallModel::stopRecording () { ...@@ -235,6 +188,57 @@ void CallModel::stopRecording () {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CallModel::handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state) {
if (call != mCall)
return;
switch (state) {
case linphone::CallStateError:
setReason(call->getReason());
case linphone::CallStateEnd:
stopAutoAnswerTimer();
mPausedByRemote = false;
break;
case linphone::CallStateConnected:
case linphone::CallStateRefered:
case linphone::CallStateReleased:
case linphone::CallStateStreamsRunning:
mPausedByRemote = false;
break;
case linphone::CallStatePausedByRemote:
mPausedByRemote = true;
break;
case linphone::CallStatePausing:
mPausedByUser = true;
break;
case linphone::CallStateResuming:
mPausedByUser = false;
break;
case linphone::CallStateUpdatedByRemote:
if (
!mCall->getCurrentParams()->videoEnabled() &&
mCall->getRemoteParams()->videoEnabled()
) {
mCall->deferUpdate();
emit videoRequested();
}
break;
default:
break;
}
emit statusChanged(getStatus());
}
// -----------------------------------------------------------------------------
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) {
...@@ -333,6 +337,9 @@ inline float computeVu (float volume) { ...@@ -333,6 +337,9 @@ inline float computeVu (float volume) {
return (volume - VU_MIN) / (VU_MAX - VU_MIN); return (volume - VU_MIN) / (VU_MAX - VU_MIN);
} }
#undef VU_MIN
#undef VU_MAX
float CallModel::getMicroVu () const { float CallModel::getMicroVu () const {
return computeVu(mCall->getRecordVolume()); return computeVu(mCall->getRecordVolume());
} }
......
...@@ -98,6 +98,8 @@ signals: ...@@ -98,6 +98,8 @@ signals:
void statsUpdated (); void statsUpdated ();
private: private:
void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state);
void stopAutoAnswerTimer () const; void stopAutoAnswerTimer () const;
QString getSipAddress () const; QString getSipAddress () const;
......
...@@ -53,28 +53,7 @@ CallsListModel::CallsListModel (QObject *parent) : QAbstractListModel(parent) { ...@@ -53,28 +53,7 @@ CallsListModel::CallsListModel (QObject *parent) : QAbstractListModel(parent) {
mCoreHandlers = CoreManager::getInstance()->getHandlers(); mCoreHandlers = CoreManager::getInstance()->getHandlers();
QObject::connect( QObject::connect(
mCoreHandlers.get(), &CoreHandlers::callStateChanged, mCoreHandlers.get(), &CoreHandlers::callStateChanged,
this, [this](const shared_ptr<linphone::Call> &call, linphone::CallState state) { this, &CallsListModel::handleCallStateChanged
switch (state) {
case linphone::CallStateIncomingReceived:
case linphone::CallStateOutgoingInit:
addCall(call);
break;
case linphone::CallStateEnd:
case linphone::CallStateError:
removeCall(call);
break;
case linphone::CallStateStreamsRunning: {
int index = static_cast<int>(distance(mList.begin(), findCallModel(mList, call)));
emit callRunning(index, &call->getData<CallModel>("call-model"));
}
break;
default:
break;
}
}
); );
} }
...@@ -148,6 +127,29 @@ void CallsListModel::terminateAllCalls () const { ...@@ -148,6 +127,29 @@ void CallsListModel::terminateAllCalls () const {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CallsListModel::handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state) {
switch (state) {
case linphone::CallStateIncomingReceived:
case linphone::CallStateOutgoingInit:
addCall(call);
break;
case linphone::CallStateEnd:
case linphone::CallStateError:
removeCall(call);
break;
case linphone::CallStateStreamsRunning: {
int index = static_cast<int>(distance(mList.begin(), findCallModel(mList, call)));
emit callRunning(index, &call->getData<CallModel>("call-model"));
}
break;
default:
break;
}
}
bool CallsListModel::removeRow (int row, const QModelIndex &parent) { bool CallsListModel::removeRow (int row, const QModelIndex &parent) {
return removeRows(row, 1, parent); return removeRows(row, 1, parent);
} }
......
...@@ -59,6 +59,8 @@ private: ...@@ -59,6 +59,8 @@ private:
bool removeRow (int row, const QModelIndex &parent = QModelIndex()); bool removeRow (int row, const QModelIndex &parent = QModelIndex());
bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override; bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override;
void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state);
void addCall (const std::shared_ptr<linphone::Call> &call); void addCall (const std::shared_ptr<linphone::Call> &call);
void removeCall (const std::shared_ptr<linphone::Call> &call); void removeCall (const std::shared_ptr<linphone::Call> &call);
......
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