Commit fa162699 authored by Ronan's avatar Ronan
Browse files

fix(app): coding style

parent 054f3907
......@@ -59,54 +59,7 @@ CallModel::CallModel (shared_ptr<linphone::Call> call) {
QObject::connect(
CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::callStateChanged,
this, [this](const 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());
}
this, &CallModel::handleCallStateChanged
);
}
......@@ -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 {
QTimer *timer = findChild<QTimer *>(AUTO_ANSWER_OBJECT_NAME, Qt::FindDirectChildrenOnly);
if (timer) {
......@@ -333,6 +337,9 @@ inline float computeVu (float volume) {
return (volume - VU_MIN) / (VU_MAX - VU_MIN);
}
#undef VU_MIN
#undef VU_MAX
float CallModel::getMicroVu () const {
return computeVu(mCall->getRecordVolume());
}
......
......@@ -98,6 +98,8 @@ signals:
void statsUpdated ();
private:
void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state);
void stopAutoAnswerTimer () const;
QString getSipAddress () const;
......
......@@ -53,28 +53,7 @@ CallsListModel::CallsListModel (QObject *parent) : QAbstractListModel(parent) {
mCoreHandlers = CoreManager::getInstance()->getHandlers();
QObject::connect(
mCoreHandlers.get(), &CoreHandlers::callStateChanged,
this, [this](const 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;
}
}
this, &CallsListModel::handleCallStateChanged
);
}
......@@ -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) {
return removeRows(row, 1, parent);
}
......
......@@ -59,6 +59,8 @@ private:
bool removeRow (int row, const QModelIndex &parent = QModelIndex());
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 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