Commit d8ff1b14 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(components): replace `broghammerus_reticulatus` variables by `camelusBactrianus`

parent c714ad8d
...@@ -34,7 +34,7 @@ using namespace std; ...@@ -34,7 +34,7 @@ using namespace std;
class AssistantModel::Handlers : public linphone::AccountCreatorListener { class AssistantModel::Handlers : public linphone::AccountCreatorListener {
public: public:
Handlers (AssistantModel *assistant) { Handlers (AssistantModel *assistant) {
m_assistant = assistant; mAssistant = assistant;
} }
void onCreateAccount ( void onCreateAccount (
...@@ -43,14 +43,14 @@ public: ...@@ -43,14 +43,14 @@ public:
const string & const string &
) override { ) override {
if (status == linphone::AccountCreatorStatusAccountCreated) if (status == linphone::AccountCreatorStatusAccountCreated)
emit m_assistant->createStatusChanged(""); emit mAssistant->createStatusChanged("");
else { else {
if (status == linphone::AccountCreatorStatusRequestFailed) if (status == linphone::AccountCreatorStatusRequestFailed)
emit m_assistant->createStatusChanged(tr("requestFailed")); emit mAssistant->createStatusChanged(tr("requestFailed"));
else if (status == linphone::AccountCreatorStatusServerError) else if (status == linphone::AccountCreatorStatusServerError)
emit m_assistant->createStatusChanged(tr("cannotSendSms")); emit mAssistant->createStatusChanged(tr("cannotSendSms"));
else else
emit m_assistant->createStatusChanged(tr("accountAlreadyExists")); emit mAssistant->createStatusChanged(tr("accountAlreadyExists"));
} }
} }
...@@ -61,12 +61,12 @@ public: ...@@ -61,12 +61,12 @@ public:
) override { ) override {
if (status == linphone::AccountCreatorStatusAccountExist || status == linphone::AccountCreatorStatusAccountExistWithAlias) { if (status == linphone::AccountCreatorStatusAccountExist || status == linphone::AccountCreatorStatusAccountExistWithAlias) {
CoreManager::getInstance()->getCore()->addProxyConfig(creator->configure()); CoreManager::getInstance()->getCore()->addProxyConfig(creator->configure());
emit m_assistant->loginStatusChanged(""); emit mAssistant->loginStatusChanged("");
} else { } else {
if (status == linphone::AccountCreatorStatusRequestFailed) if (status == linphone::AccountCreatorStatusRequestFailed)
emit m_assistant->loginStatusChanged(tr("requestFailed")); emit mAssistant->loginStatusChanged(tr("requestFailed"));
else else
emit m_assistant->loginStatusChanged(tr("loginWithUsernameFailed")); emit mAssistant->loginStatusChanged(tr("loginWithUsernameFailed"));
} }
} }
...@@ -79,12 +79,12 @@ public: ...@@ -79,12 +79,12 @@ public:
status == linphone::AccountCreatorStatusAccountActivated || status == linphone::AccountCreatorStatusAccountActivated ||
status == linphone::AccountCreatorStatusAccountAlreadyActivated status == linphone::AccountCreatorStatusAccountAlreadyActivated
) )
emit m_assistant->activateStatusChanged(""); emit mAssistant->activateStatusChanged("");
else { else {
if (status == linphone::AccountCreatorStatusRequestFailed) if (status == linphone::AccountCreatorStatusRequestFailed)
emit m_assistant->activateStatusChanged(tr("requestFailed")); emit mAssistant->activateStatusChanged(tr("requestFailed"));
else else
emit m_assistant->activateStatusChanged(tr("smsActivationFailed")); emit mAssistant->activateStatusChanged(tr("smsActivationFailed"));
} }
} }
...@@ -96,12 +96,12 @@ public: ...@@ -96,12 +96,12 @@ public:
if (status == linphone::AccountCreatorStatusAccountActivated) { if (status == linphone::AccountCreatorStatusAccountActivated) {
CoreManager::getInstance()->getAccountSettingsModel()->addOrUpdateProxyConfig(creator->configure()); CoreManager::getInstance()->getAccountSettingsModel()->addOrUpdateProxyConfig(creator->configure());
emit m_assistant->activateStatusChanged(""); emit mAssistant->activateStatusChanged("");
} else { } else {
if (status == linphone::AccountCreatorStatusRequestFailed) if (status == linphone::AccountCreatorStatusRequestFailed)
emit m_assistant->activateStatusChanged(tr("requestFailed")); emit mAssistant->activateStatusChanged(tr("requestFailed"));
else else
emit m_assistant->activateStatusChanged(tr("emailActivationFailed")); emit mAssistant->activateStatusChanged(tr("emailActivationFailed"));
} }
} }
...@@ -142,40 +142,40 @@ public: ...@@ -142,40 +142,40 @@ public:
// ) override {} // ) override {}
private: private:
AssistantModel *m_assistant; AssistantModel *mAssistant;
}; };
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
AssistantModel::AssistantModel (QObject *parent) : QObject(parent) { AssistantModel::AssistantModel (QObject *parent) : QObject(parent) {
m_handlers = make_shared<AssistantModel::Handlers>(this); mHandlers = make_shared<AssistantModel::Handlers>(this);
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
m_account_creator = core->createAccountCreator( mAccountCreator = core->createAccountCreator(
core->getConfig()->getString("assistant", "xmlrpc_url", DEFAULT_XMLRPC_URL) core->getConfig()->getString("assistant", "xmlrpc_url", DEFAULT_XMLRPC_URL)
); );
m_account_creator->setListener(m_handlers); mAccountCreator->setListener(mHandlers);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void AssistantModel::activate () { void AssistantModel::activate () {
if (m_account_creator->getEmail().empty()) if (mAccountCreator->getEmail().empty())
m_account_creator->activateAccount(); mAccountCreator->activateAccount();
else else
m_account_creator->isAccountActivated(); mAccountCreator->isAccountActivated();
} }
void AssistantModel::create () { void AssistantModel::create () {
m_account_creator->createAccount(); mAccountCreator->createAccount();
} }
void AssistantModel::login () { void AssistantModel::login () {
m_account_creator->isAccountExist(); mAccountCreator->isAccountExist();
} }
void AssistantModel::reset () { void AssistantModel::reset () {
m_account_creator->reset(); mAccountCreator->reset();
emit emailChanged("", ""); emit emailChanged("", "");
emit passwordChanged("", ""); emit passwordChanged("", "");
...@@ -186,14 +186,14 @@ void AssistantModel::reset () { ...@@ -186,14 +186,14 @@ void AssistantModel::reset () {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
QString AssistantModel::getEmail () const { QString AssistantModel::getEmail () const {
return ::Utils::linphoneStringToQString(m_account_creator->getEmail()); return ::Utils::linphoneStringToQString(mAccountCreator->getEmail());
} }
void AssistantModel::setEmail (const QString &email) { void AssistantModel::setEmail (const QString &email) {
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig(); shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
QString error; QString error;
switch (m_account_creator->setEmail(::Utils::qStringToLinphoneString(email))) { switch (mAccountCreator->setEmail(::Utils::qStringToLinphoneString(email))) {
case linphone::AccountCreatorEmailStatusOk: case linphone::AccountCreatorEmailStatusOk:
break; break;
case linphone::AccountCreatorEmailStatusMalformed: case linphone::AccountCreatorEmailStatusMalformed:
...@@ -208,14 +208,14 @@ void AssistantModel::setEmail (const QString &email) { ...@@ -208,14 +208,14 @@ void AssistantModel::setEmail (const QString &email) {
} }
QString AssistantModel::getPassword () const { QString AssistantModel::getPassword () const {
return ::Utils::linphoneStringToQString(m_account_creator->getPassword()); return ::Utils::linphoneStringToQString(mAccountCreator->getPassword());
} }
void AssistantModel::setPassword (const QString &password) { void AssistantModel::setPassword (const QString &password) {
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig(); shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
QString error; QString error;
switch (m_account_creator->setPassword(::Utils::qStringToLinphoneString(password))) { switch (mAccountCreator->setPassword(::Utils::qStringToLinphoneString(password))) {
case linphone::AccountCreatorPasswordStatusOk: case linphone::AccountCreatorPasswordStatusOk:
break; break;
case linphone::AccountCreatorPasswordStatusTooShort: case linphone::AccountCreatorPasswordStatusTooShort:
...@@ -238,27 +238,27 @@ void AssistantModel::setPassword (const QString &password) { ...@@ -238,27 +238,27 @@ void AssistantModel::setPassword (const QString &password) {
} }
QString AssistantModel::getPhoneNumber () const { QString AssistantModel::getPhoneNumber () const {
return ::Utils::linphoneStringToQString(m_account_creator->getPhoneNumber()); return ::Utils::linphoneStringToQString(mAccountCreator->getPhoneNumber());
} }
void AssistantModel::setPhoneNumber (const QString &phone_number) { void AssistantModel::setPhoneNumber (const QString &phoneNumber) {
// shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig(); // shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
QString error; QString error;
// TODO: use the future wrapped function: `set_phone_number`. // TODO: use the future wrapped function: `set_phone_number`.
emit phoneNumberChanged(phone_number, error); emit phoneNumberChanged(phoneNumber, error);
} }
QString AssistantModel::getUsername () const { QString AssistantModel::getUsername () const {
return ::Utils::linphoneStringToQString(m_account_creator->getUsername()); return ::Utils::linphoneStringToQString(mAccountCreator->getUsername());
} }
void AssistantModel::setUsername (const QString &username) { void AssistantModel::setUsername (const QString &username) {
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig(); shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
QString error; QString error;
switch (m_account_creator->setUsername(::Utils::qStringToLinphoneString(username))) { switch (mAccountCreator->setUsername(::Utils::qStringToLinphoneString(username))) {
case linphone::AccountCreatorUsernameStatusOk: case linphone::AccountCreatorUsernameStatusOk:
break; break;
case linphone::AccountCreatorUsernameStatusTooShort: case linphone::AccountCreatorUsernameStatusTooShort:
......
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,7 @@ public:
signals: signals:
void emailChanged (const QString &email, const QString &error); void emailChanged (const QString &email, const QString &error);
void passwordChanged (const QString &password, const QString &error); void passwordChanged (const QString &password, const QString &error);
void phoneNumberChanged (const QString &phone_number, const QString &error); void phoneNumberChanged (const QString &phoneNumber, const QString &error);
void usernameChanged (const QString &username, const QString &error); void usernameChanged (const QString &username, const QString &error);
void activateStatusChanged (const QString &error); void activateStatusChanged (const QString &error);
...@@ -65,13 +65,13 @@ private: ...@@ -65,13 +65,13 @@ private:
void setPassword (const QString &password); void setPassword (const QString &password);
QString getPhoneNumber () const; QString getPhoneNumber () const;
void setPhoneNumber (const QString &phone_number); void setPhoneNumber (const QString &phoneNumber);
QString getUsername () const; QString getUsername () const;
void setUsername (const QString &username); void setUsername (const QString &username);
std::shared_ptr<linphone::AccountCreator> m_account_creator; std::shared_ptr<linphone::AccountCreator> mAccountCreator;
std::shared_ptr<Handlers> m_handlers; std::shared_ptr<Handlers> mHandlers;
}; };
#endif // ASSISTANT_MODEL_H_ #endif // ASSISTANT_MODEL_H_
...@@ -36,9 +36,9 @@ using namespace std; ...@@ -36,9 +36,9 @@ using namespace std;
// ============================================================================= // =============================================================================
CallModel::CallModel (shared_ptr<linphone::Call> linphone_call) { CallModel::CallModel (shared_ptr<linphone::Call> linphoneCall) {
Q_ASSERT(linphone_call != nullptr); Q_ASSERT(linphoneCall != nullptr);
m_linphone_call = linphone_call; mLinphoneCall = linphoneCall;
// Deal with auto-answer. // Deal with auto-answer.
{ {
...@@ -57,42 +57,42 @@ CallModel::CallModel (shared_ptr<linphone::Call> linphone_call) { ...@@ -57,42 +57,42 @@ CallModel::CallModel (shared_ptr<linphone::Call> linphone_call) {
QObject::connect( QObject::connect(
&(*CoreManager::getInstance()->getHandlers()), &CoreHandlers::callStateChanged, &(*CoreManager::getInstance()->getHandlers()), &CoreHandlers::callStateChanged,
this, [this](const std::shared_ptr<linphone::Call> &call, linphone::CallState state) { this, [this](const shared_ptr<linphone::Call> &call, linphone::CallState state) {
if (call != m_linphone_call) if (call != mLinphoneCall)
return; return;
switch (state) { switch (state) {
case linphone::CallStateEnd: case linphone::CallStateEnd:
case linphone::CallStateError: case linphone::CallStateError:
stopAutoAnswerTimer(); stopAutoAnswerTimer();
m_paused_by_remote = false; mPausedByRemote = false;
break; break;
case linphone::CallStateConnected: case linphone::CallStateConnected:
case linphone::CallStateRefered: case linphone::CallStateRefered:
case linphone::CallStateReleased: case linphone::CallStateReleased:
case linphone::CallStateStreamsRunning: case linphone::CallStateStreamsRunning:
m_paused_by_remote = false; mPausedByRemote = false;
break; break;
case linphone::CallStatePausedByRemote: case linphone::CallStatePausedByRemote:
m_paused_by_remote = true; mPausedByRemote = true;
break; break;
case linphone::CallStatePausing: case linphone::CallStatePausing:
m_paused_by_user = true; mPausedByUser = true;
break; break;
case linphone::CallStateResuming: case linphone::CallStateResuming:
m_paused_by_user = false; mPausedByUser = false;
break; break;
case linphone::CallStateUpdatedByRemote: case linphone::CallStateUpdatedByRemote:
if ( if (
!m_linphone_call->getCurrentParams()->videoEnabled() && !mLinphoneCall->getCurrentParams()->videoEnabled() &&
m_linphone_call->getRemoteParams()->videoEnabled() mLinphoneCall->getRemoteParams()->videoEnabled()
) { ) {
m_linphone_call->deferUpdate(); mLinphoneCall->deferUpdate();
emit videoRequested(); emit videoRequested();
} }
...@@ -109,8 +109,8 @@ CallModel::CallModel (shared_ptr<linphone::Call> linphone_call) { ...@@ -109,8 +109,8 @@ CallModel::CallModel (shared_ptr<linphone::Call> linphone_call) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CallModel::setRecordFile (shared_ptr<linphone::CallParams> &call_params) { void CallModel::setRecordFile (shared_ptr<linphone::CallParams> &callParams) {
call_params->setRecordFile( callParams->setRecordFile(
::Utils::qStringToLinphoneString( ::Utils::qStringToLinphoneString(
CoreManager::getInstance()->getSettingsModel()->getSavedVideosFolder() + CoreManager::getInstance()->getSettingsModel()->getSavedVideosFolder() +
QDateTime::currentDateTime().toString("yyyy-MM-dd_hh:mm:ss") QDateTime::currentDateTime().toString("yyyy-MM-dd_hh:mm:ss")
...@@ -124,31 +124,31 @@ void CallModel::accept () { ...@@ -124,31 +124,31 @@ void CallModel::accept () {
stopAutoAnswerTimer(); stopAutoAnswerTimer();
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::CallParams> params = core->createCallParams(m_linphone_call); shared_ptr<linphone::CallParams> params = core->createCallParams(mLinphoneCall);
params->enableVideo(false); params->enableVideo(false);
setRecordFile(params); setRecordFile(params);
App::getInstance()->getCallsWindow()->show(); App::getInstance()->getCallsWindow()->show();
m_linphone_call->acceptWithParams(params); mLinphoneCall->acceptWithParams(params);
} }
void CallModel::acceptWithVideo () { void CallModel::acceptWithVideo () {
stopAutoAnswerTimer(); stopAutoAnswerTimer();
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::CallParams> params = core->createCallParams(m_linphone_call); shared_ptr<linphone::CallParams> params = core->createCallParams(mLinphoneCall);
params->enableVideo(true); params->enableVideo(true);
setRecordFile(params); setRecordFile(params);
App::getInstance()->getCallsWindow()->show(); App::getInstance()->getCallsWindow()->show();
m_linphone_call->acceptWithParams(params); mLinphoneCall->acceptWithParams(params);
} }
void CallModel::terminate () { void CallModel::terminate () {
CoreManager *core = CoreManager::getInstance(); CoreManager *core = CoreManager::getInstance();
core->lockVideoRender(); core->lockVideoRender();
m_linphone_call->terminate(); mLinphoneCall->terminate();
core->unlockVideoRender(); core->unlockVideoRender();
} }
...@@ -158,54 +158,54 @@ void CallModel::transfer () { ...@@ -158,54 +158,54 @@ void CallModel::transfer () {
void CallModel::acceptVideoRequest () { void CallModel::acceptVideoRequest () {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::CallParams> params = core->createCallParams(m_linphone_call); shared_ptr<linphone::CallParams> params = core->createCallParams(mLinphoneCall);
params->enableVideo(true); params->enableVideo(true);
m_linphone_call->acceptUpdate(params); mLinphoneCall->acceptUpdate(params);
} }
void CallModel::rejectVideoRequest () { void CallModel::rejectVideoRequest () {
m_linphone_call->acceptUpdate(m_linphone_call->getCurrentParams()); mLinphoneCall->acceptUpdate(mLinphoneCall->getCurrentParams());
} }
void CallModel::takeSnapshot () { void CallModel::takeSnapshot () {
static QString old_name; static QString oldName;
QString new_name = QDateTime::currentDateTime().toString("yyyy-MM-dd_hh:mm:ss") + ".jpg"; QString newName = QDateTime::currentDateTime().toString("yyyy-MM-dd_hh:mm:ss") + ".jpg";
if (new_name == old_name) { if (newName == oldName) {
qWarning() << "Unable to take snapshot. Wait one second."; qWarning() << "Unable to take snapshot. Wait one second.";
return; return;
} }
old_name = new_name; oldName = newName;
qInfo() << "Take snapshot of call:" << &m_linphone_call; qInfo() << "Take snapshot of call:" << &mLinphoneCall;
m_linphone_call->takeVideoSnapshot( mLinphoneCall->takeVideoSnapshot(
::Utils::qStringToLinphoneString( ::Utils::qStringToLinphoneString(
CoreManager::getInstance()->getSettingsModel()->getSavedScreenshotsFolder() + new_name CoreManager::getInstance()->getSettingsModel()->getSavedScreenshotsFolder() + newName
) )
); );
} }
void CallModel::startRecording () { void CallModel::startRecording () {
if (m_recording) if (mRecording)
return; return;
qInfo() << "Start recording call:" << &m_linphone_call; qInfo() << "Start recording call:" << &mLinphoneCall;
m_linphone_call->startRecording(); mLinphoneCall->startRecording();
m_recording = true; mRecording = true;
emit recordingChanged(true); emit recordingChanged(true);
} }
void CallModel::stopRecording () { void CallModel::stopRecording () {
if (m_recording) { if (mRecording) {
qInfo() << "Stop recording call:" << &m_linphone_call; qInfo() << "Stop recording call:" << &mLinphoneCall;
m_recording = false; mRecording = false;
m_linphone_call->stopRecording(); mLinphoneCall->stopRecording();
emit recordingChanged(false); emit recordingChanged(false);
} }
...@@ -222,11 +222,11 @@ void CallModel::stopAutoAnswerTimer () const { ...@@ -222,11 +222,11 @@ void CallModel::stopAutoAnswerTimer () const {
} }
QString CallModel::getSipAddress () const { QString CallModel::getSipAddress () const {
return ::Utils::linphoneStringToQString(m_linphone_call->getRemoteAddress()->asStringUriOnly()); return ::Utils::linphoneStringToQString(mLinphoneCall->getRemoteAddress()->asStringUriOnly());
} }
CallModel::CallStatus CallModel::getStatus () const { CallModel::CallStatus CallModel::getStatus () const {
switch (m_linphone_call->getState()) { switch (mLinphoneCall->getState()) {
case linphone::CallStateConnected: case linphone::CallStateConnected:
case linphone::CallStateStreamsRunning: case linphone::CallStateStreamsRunning:
return CallStatusConnected; return CallStatusConnected;
...@@ -245,7 +245,7 @@ CallModel::CallStatus CallModel::getStatus () const { ...@@ -245,7 +245,7 @@ CallModel::CallStatus CallModel::getStatus () const {
case linphone::CallStateUpdating: case linphone::CallStateUpdating:
case linphone::CallStateUpdatedByRemote: case linphone::CallStateUpdatedByRemote:
return m_paused_by_remote ? CallStatusPaused : CallStatusConnected; return mPausedByRemote ? CallStatusPaused : CallStatusConnected;
case linphone::CallStateEarlyUpdatedByRemote: case linphone::CallStateEarlyUpdatedByRemote:
case linphone::CallStateEarlyUpdating: case linphone::CallStateEarlyUpdating:
...@@ -259,17 +259,17 @@ CallModel::CallStatus CallModel::getStatus () const { ...@@ -259,17 +259,17 @@ CallModel::CallStatus CallModel::getStatus () const {
break; break;
} }
return m_linphone_call->getDir() == linphone::CallDirIncoming ? CallStatusIncoming : CallStatusOutgoing; return mLinphoneCall->getDir() == linphone::CallDirIncoming ? CallStatusIncoming : CallStatusOutgoing;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
int CallModel::getDuration () const { int CallModel::getDuration () const {
return m_linphone_call->getDuration(); return mLinphoneCall->getDuration();
} }
float CallModel::getQuality () const { float CallModel::getQuality () const {
return m_linphone_call->getCurrentQuality(); return mLinphoneCall->getCurrentQuality();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -287,11 +287,11 @@ inline float computeVu (float volume) { ...@@ -287,11 +287,11 @@ inline float computeVu (float volume) {
} }
float CallModel::getMicroVu () const { float CallModel::getMicroVu () const {
return computeVu(m_linphone_call->getRecordVolume()); return computeVu(mLinphoneCall->getRecordVolume());
} }
float CallModel::getSpeakerVu () const { float CallModel::getSpeakerVu () const {
return computeVu(m_linphone_call->getPlayVolume()); return computeVu(mLinphoneCall->getPlayVolume());
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -312,11 +312,11 @@ void CallModel::setMicroMuted (bool status) { ...@@ -312,11 +312,11 @@ void CallModel::setMicroMuted (bool status) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool CallModel::getPausedByUser () const { bool CallModel::getPausedByUser () const {
return m_paused_by_user; return mPausedByUser;
} }
void CallModel::setPausedByUser (bool status) { void CallModel::setPausedByUser (bool status) {
switch (m_linphone_call->getState()) { switch (mLinphoneCall->getState()) {
case linphone::CallStateConnected: case linphone::CallStateConnected:
case linphone::CallStateStreamsRunning: case linphone::CallStateStreamsRunning:
case linphone::CallStatePaused: case linphone::CallStatePaused:
...@@ -326,25 +326,25 @@ void CallModel::setPausedByUser (bool status) { ...@@ -326,25 +326,25 @@ void CallModel::setPausedByUser (bool status) {
} }
if (status) { if (status) {
if (!m_paused_by_user) if (!mPausedByUser)
m_linphone_call->pause(); mLinphoneCall->pause();
return; return;
} }
if (m_paused_by_user) if (mPausedByUser)
m_linphone_call->resume(); mLinphoneCall->resume();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool CallModel::getVideoEnabled () const { bool CallModel::getVideoEnabled () const {
shared_ptr<const linphone::CallParams> params = m_linphone_call->getCurrentParams(); shared_ptr<const linphone::CallParams> params = mLinphoneCall->getCurrentParams();
return params && params->videoEnabled() && getStatus() == CallStatusConnected; return params && params->videoEnabled() && getStatus() == CallStatusConnected;
} }
void CallModel::setVideoEnabled (bool status) { void CallModel::setVideoEnabled (bool status) {
switch (m_linphone_call->getState()) { switch (mLinphoneCall->getState()) {
case linphone::CallStateConnected: case linphone::CallStateConnected:
case linphone::CallStateStreamsRunning: case linphone::CallStateStreamsRunning:
break; break;
...@@ -355,16 +355,16 @@ void CallModel::setVideoEnabled (bool status) { ...@@ -355,16 +355,16 @@ void CallModel::setVideoEnabled (bool status) {
return; return;
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::CallParams> params = core->createCallParams(m_linphone_call); shared_ptr<linphone::CallParams> params = core->createCallParams(mLinphoneCall);
params->enableVideo(status); params->enableVideo(status);
m_linphone_call->update(params); mLinphoneCall->update(params);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool CallModel::getUpdating () const { bool CallModel::getUpdating () const {
switch (m_linphone_call->getState()) { switch (mLinphoneCall->getState()) {
case linphone::CallStateConnected: case linphone::CallStateConnected:
case linphone::CallStateStreamsRunning: case linphone::CallStateStreamsRunning:
case linphone::CallStatePaused: case linphone::CallStatePaused:
...@@ -379,5 +379,5 @@ bool CallModel::getUpdating () const { ...@@ -379,5 +379,5 @@ bool CallModel::getUpdating () const {
} }
bool CallModel::getRecording () const { bool CallModel::getRecording () const {
return m_recording; return mRecording;
} }
...@@ -61,14 +61,14 @@ public: ...@@ -61,14 +61,14 @@ public:
Q_ENUM(CallStatus); Q_ENUM(CallStatus);
CallModel (std::shared_ptr<linphone::Call> linphone_call); CallModel (std::shared_ptr<linphone::Call> linphoneCall);
~CallModel () = default; ~CallModel () = default;
std::shared_ptr<linphone::Call> getLinphoneCall () const { std::shared_ptr<linphone::Call> getLinphoneCall () const {
return m_linphone_call; return mLinphoneCall;
} }
static void setRecordFile (std::shared_ptr<linphone::CallParams> &call_params); static void setRecordFile (std::shared_ptr<linphone::CallParams> &callParams);
Q_INVOKABLE void accept (); Q_INVOKABLE void accept ();
Q_INVOKABLE void acceptWithVideo (); Q_INVOKABLE void acceptWithVideo ();
...@@ -96,7 +96,7 @@ private: ...@@ -96,7 +96,7 @@ private:
CallStatus getStatus () const; CallStatus getStatus () const;
bool isOutgoing () const { bool isOutgoing () const {
return m_linphone_call->getDir() == linphone::CallDirOutgoing; return mLinphoneCall->getDir() == linphone::CallDirOutgoing;
} }
int getDuration () const; int getDuration () const;
...@@ -117,11 +117,11 @@ private: ...@@ -117,11 +117,11 @@ private:
bool getRecording () const; bool getRecording () const;
bool m_paused_by_remote = false; bool mPausedByRemote = false;
bool m_paused_by_user = false; bool mPausedByUser = false;
bool m_recording = false; bool mRecording = false;
std::shared_ptr<linphone::Call> m_linphone_call; std::shared_ptr<linphone::Call> mLinphoneCall;
}; };
#endif // CALL_MODEL_H_ #endif // CALL_MODEL_H_
...@@ -38,11 +38,11 @@ using namespace std; ...@@ -38,11 +38,11 @@ using namespace std;
inline QList<CallModel *>::iterator findCall ( inline QList<CallModel *>::iterator findCall (
QList<CallModel *> &list, QList<CallModel *> &list,
const shared_ptr<linphone::Call> &linphone_call const shared_ptr<linphone::Call> &linphoneCall
) { ) {
return find_if( return find_if(
list.begin(), list.end(), [linphone_call](CallModel *call) { list.begin(), list.end(), [linphoneCall](CallModel *call) {
return linphone_call == call->getLinphoneCall(); return linphoneCall == call->getLinphoneCall();
} }
); );
} }
...@@ -50,24 +50,24 @@ inline QList<CallModel *>::iterator findCall ( ...@@ -50,24 +50,24 @@ inline QList<CallModel *>::iterator findCall (
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
CallsListModel::CallsListModel (QObject *parent) : QAbstractListModel(parent) { CallsListModel::CallsListModel (QObject *parent) : QAbstractListModel(parent) {
m_core_handlers = CoreManager::getInstance()->getHandlers(); mCoreHandlers = CoreManager::getInstance()->getHandlers();
QObject::connect( QObject::connect(
&(*m_core_handlers), &CoreHandlers::callStateChanged, &(*mCoreHandlers), &CoreHandlers::callStateChanged,
this, [this](const shared_ptr<linphone::Call> &linphone_call, linphone::CallState state) { this, [this](const shared_ptr<linphone::Call> &linphoneCall, linphone::CallState state) {
switch (state) { switch (state) {
case linphone::CallStateIncomingReceived: case linphone::CallStateIncomingReceived:
case linphone::CallStateOutgoingInit: case linphone::CallStateOutgoingInit:
addCall(linphone_call); addCall(linphoneCall);
break; break;
case linphone::CallStateEnd: case linphone::CallStateEnd:
case linphone::CallStateError: case linphone::CallStateError:
removeCall(linphone_call); removeCall(linphoneCall);
break; break;
case linphone::CallStateStreamsRunning: { case linphone::CallStateStreamsRunning: {
int index = static_cast<int>(distance(m_list.begin(), findCall(m_list, linphone_call))); int index = static_cast<int>(distance(mList.begin(), findCall(mList, linphoneCall)));
emit callRunning(index, &linphone_call->getData<CallModel>("call-model")); emit callRunning(index, &linphoneCall->getData<CallModel>("call-model"));
} }
break; break;
...@@ -79,7 +79,7 @@ CallsListModel::CallsListModel (QObject *parent) : QAbstractListModel(parent) { ...@@ -79,7 +79,7 @@ CallsListModel::CallsListModel (QObject *parent) : QAbstractListModel(parent) {
} }
int CallsListModel::rowCount (const QModelIndex &) const { int CallsListModel::rowCount (const QModelIndex &) const {
return m_list.count(); return mList.count();
} }
QHash<int, QByteArray> CallsListModel::roleNames () const { QHash<int, QByteArray> CallsListModel::roleNames () const {
...@@ -91,25 +91,25 @@ QHash<int, QByteArray> CallsListModel::roleNames () const { ...@@ -91,25 +91,25 @@ QHash<int, QByteArray> CallsListModel::roleNames () const {
QVariant CallsListModel::data (const QModelIndex &index, int role) const { QVariant CallsListModel::data (const QModelIndex &index, int role) const {
int row = index.row(); int row = index.row();
if (!index.isValid() || row < 0 || row >= m_list.count()) if (!index.isValid() || row < 0 || row >= mList.count())
return QVariant(); return QVariant();
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
return QVariant::fromValue(m_list[row]); return QVariant::fromValue(mList[row]);
return QVariant(); return QVariant();
} }
CallModel *CallsListModel::getCall (const shared_ptr<linphone::Call> &linphone_call) const { CallModel *CallsListModel::getCall (const shared_ptr<linphone::Call> &linphoneCall) const {
auto it = findCall(*(const_cast<QList<CallModel *> *>(&m_list)), linphone_call); auto it = findCall(*(const_cast<QList<CallModel *> *>(&mList)), linphoneCall);
return it != m_list.end() ? *it : nullptr; return it != mList.end() ? *it : nullptr;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CallsListModel::launchAudioCall (const QString &sip_uri) const { void CallsListModel::launchAudioCall (const QString &sipUri) const {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::Address> address = core->interpretUrl(::Utils::qStringToLinphoneString(sip_uri)); shared_ptr<linphone::Address> address = core->interpretUrl(::Utils::qStringToLinphoneString(sipUri));
if (!address) if (!address)
return; return;
...@@ -121,9 +121,9 @@ void CallsListModel::launchAudioCall (const QString &sip_uri) const { ...@@ -121,9 +121,9 @@ void CallsListModel::launchAudioCall (const QString &sip_uri) const {
core->inviteAddressWithParams(address, params); core->inviteAddressWithParams(address, params);
} }
void CallsListModel::launchVideoCall (const QString &sip_uri) const { void CallsListModel::launchVideoCall (const QString &sipUri) const {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::Address> address = core->interpretUrl(::Utils::qStringToLinphoneString(sip_uri)); shared_ptr<linphone::Address> address = core->interpretUrl(::Utils::qStringToLinphoneString(sipUri));
if (!address) if (!address)
return; return;
...@@ -155,13 +155,13 @@ bool CallsListModel::removeRow (int row, const QModelIndex &parent) { ...@@ -155,13 +155,13 @@ bool CallsListModel::removeRow (int row, const QModelIndex &parent) {
bool CallsListModel::removeRows (int row, int count, const QModelIndex &parent) { bool CallsListModel::removeRows (int row, int count, const QModelIndex &parent) {
int limit = row + count - 1; int limit = row + count - 1;
if (row < 0 || count < 0 || limit >= m_list.count()) if (row < 0 || count < 0 || limit >= mList.count())
return false; return false;
beginRemoveRows(parent, row, limit); beginRemoveRows(parent, row, limit);
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
m_list.takeAt(row)->deleteLater(); mList.takeAt(row)->deleteLater();
endRemoveRows(); endRemoveRows();
...@@ -170,38 +170,38 @@ bool CallsListModel::removeRows (int row, int count, const QModelIndex &parent) ...@@ -170,38 +170,38 @@ bool CallsListModel::removeRows (int row, int count, const QModelIndex &parent)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CallsListModel::addCall (const shared_ptr<linphone::Call> &linphone_call) { void CallsListModel::addCall (const shared_ptr<linphone::Call> &linphoneCall) {
if (linphone_call->getDir() == linphone::CallDirOutgoing) if (linphoneCall->getDir() == linphone::CallDirOutgoing)
App::getInstance()->getCallsWindow()->show(); App::getInstance()->getCallsWindow()->show();
CallModel *call = new CallModel(linphone_call); CallModel *call = new CallModel(linphoneCall);
qInfo() << "Add call:" << call; qInfo() << "Add call:" << call;
App::getInstance()->getEngine()->setObjectOwnership(call, QQmlEngine::CppOwnership); App::getInstance()->getEngine()->setObjectOwnership(call, QQmlEngine::CppOwnership);
linphone_call->setData("call-model", *call); linphoneCall->setData("call-model", *call);
int row = m_list.count(); int row = mList.count();
beginInsertRows(QModelIndex(), row, row); beginInsertRows(QModelIndex(), row, row);
m_list << call; mList << call;
endInsertRows(); endInsertRows();
} }
void CallsListModel::removeCall (const shared_ptr<linphone::Call> &linphone_call) { void CallsListModel::removeCall (const shared_ptr<linphone::Call> &linphoneCall) {
// TODO: It will be (maybe) necessary to use a single scheduled function in the future. // TODO: It will be (maybe) necessary to use a single scheduled function in the future.
QTimer::singleShot( QTimer::singleShot(
DELAY_BEFORE_REMOVE_CALL, this, [this, linphone_call]() { DELAY_BEFORE_REMOVE_CALL, this, [this, linphoneCall]() {
CallModel *call = &linphone_call->getData<CallModel>("call-model"); CallModel *call = &linphoneCall->getData<CallModel>("call-model");
linphone_call->unsetData("call-model"); linphoneCall->unsetData("call-model");
qInfo() << "Removing call:" << call; qInfo() << "Removing call:" << call;
int index = m_list.indexOf(call); int index = mList.indexOf(call);
if (index == -1 || !removeRow(index)) if (index == -1 || !removeRow(index))
qWarning() << "Unable to remove call:" << call; qWarning() << "Unable to remove call:" << call;
if (m_list.empty()) if (mList.empty())
App::getInstance()->getCallsWindow()->close(); App::getInstance()->getCallsWindow()->close();
} }
); );
......
...@@ -43,10 +43,10 @@ public: ...@@ -43,10 +43,10 @@ public:
QHash<int, QByteArray> roleNames () const override; QHash<int, QByteArray> roleNames () const override;
QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override;
CallModel *getCall (const std::shared_ptr<linphone::Call> &linphone_call) const; CallModel *getCall (const std::shared_ptr<linphone::Call> &linphoneCall) const;
Q_INVOKABLE void launchAudioCall (const QString &sip_uri) const; Q_INVOKABLE void launchAudioCall (const QString &sipUri) const;
Q_INVOKABLE void launchVideoCall (const QString &sip_uri) const; Q_INVOKABLE void launchVideoCall (const QString &sipUri) const;
Q_INVOKABLE int getRunningCallsNumber () const; Q_INVOKABLE int getRunningCallsNumber () const;
...@@ -59,12 +59,12 @@ private: ...@@ -59,12 +59,12 @@ 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 addCall (const std::shared_ptr<linphone::Call> &linphone_call); void addCall (const std::shared_ptr<linphone::Call> &linphoneCall);
void removeCall (const std::shared_ptr<linphone::Call> &linphone_call); void removeCall (const std::shared_ptr<linphone::Call> &linphoneCall);
QList<CallModel *> m_list; QList<CallModel *> mList;
std::shared_ptr<CoreHandlers> m_core_handlers; std::shared_ptr<CoreHandlers> mCoreHandlers;
}; };
#endif // CALLS_LIST_MODEL_H_ #endif // CALLS_LIST_MODEL_H_
...@@ -47,24 +47,24 @@ struct ContextInfo { ...@@ -47,24 +47,24 @@ struct ContextInfo {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
CameraRenderer::CameraRenderer () { CameraRenderer::CameraRenderer () {
m_context_info = new ContextInfo(); mContextInfo = new ContextInfo();
} }
CameraRenderer::~CameraRenderer () { CameraRenderer::~CameraRenderer () {
qInfo() << QStringLiteral("Delete context info:") << m_context_info; qInfo() << QStringLiteral("Delete context info:") << mContextInfo;
CoreManager *core = CoreManager::getInstance(); CoreManager *core = CoreManager::getInstance();
core->lockVideoRender(); core->lockVideoRender();
if (m_is_preview) if (mIsPreview)
CoreManager::getInstance()->getCore()->setNativePreviewWindowId(nullptr); CoreManager::getInstance()->getCore()->setNativePreviewWindowId(nullptr);
else if (m_linphone_call) else if (mLinphoneCall)
m_linphone_call->setNativeVideoWindowId(nullptr); mLinphoneCall->setNativeVideoWindowId(nullptr);
core->unlockVideoRender(); core->unlockVideoRender();
delete m_context_info; delete mContextInfo;
} }
QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize &size) { QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize &size) {
...@@ -78,10 +78,10 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize & ...@@ -78,10 +78,10 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize &
// It's not the same thread as render. // It's not the same thread as render.
core->lockVideoRender(); core->lockVideoRender();
m_context_info->width = size.width(); mContextInfo->width = size.width();
m_context_info->height = size.height(); mContextInfo->height = size.height();
m_context_info->functions = MSFunctions::getInstance()->getFunctions(); mContextInfo->functions = MSFunctions::getInstance()->getFunctions();
m_update_context_info = true; mUpdateContextInfo = true;
updateWindowId(); updateWindowId();
...@@ -91,7 +91,7 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize & ...@@ -91,7 +91,7 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize &
} }
void CameraRenderer::render () { void CameraRenderer::render () {
if (!m_linphone_call) if (!mLinphoneCall)
return; return;
// Draw with ms filter. // Draw with ms filter.
...@@ -102,48 +102,48 @@ void CameraRenderer::render () { ...@@ -102,48 +102,48 @@ void CameraRenderer::render () {
f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
CoreManager *core = CoreManager::getInstance(); CoreManager *core = CoreManager::getInstance();
MSFunctions *ms_functions = MSFunctions::getInstance(); MSFunctions *msFunctions = MSFunctions::getInstance();
core->lockVideoRender(); core->lockVideoRender();
ms_functions->bind(f); msFunctions->bind(f);
m_linphone_call->oglRender(m_is_preview); mLinphoneCall->oglRender(mIsPreview);
ms_functions->bind(nullptr); msFunctions->bind(nullptr);
core->unlockVideoRender(); core->unlockVideoRender();
} }
// Synchronize opengl calls with QML. // Synchronize opengl calls with QML.
if (m_window) if (mWindow)
m_window->resetOpenGLState(); mWindow->resetOpenGLState();
} }
void CameraRenderer::synchronize (QQuickFramebufferObject *item) { void CameraRenderer::synchronize (QQuickFramebufferObject *item) {
// No mutex needed here. It's a synchronized area. // No mutex needed here. It's a synchronized area.
m_window = item->window(); mWindow = item->window();
Camera *camera = qobject_cast<Camera *>(item); Camera *camera = qobject_cast<Camera *>(item);
m_linphone_call = camera->getCall()->getLinphoneCall(); mLinphoneCall = camera->getCall()->getLinphoneCall();
m_is_preview = camera->m_is_preview; mIsPreview = camera->mIsPreview;
updateWindowId(); updateWindowId();
} }
void CameraRenderer::updateWindowId () { void CameraRenderer::updateWindowId () {
if (!m_update_context_info) if (!mUpdateContextInfo)
return; return;
m_update_context_info = false; mUpdateContextInfo = false;
qInfo() << "Thread" << QThread::currentThread() << QStringLiteral("Set context info (width: %1, height: %2, is_preview: %3):") qInfo() << "Thread" << QThread::currentThread() << QStringLiteral("Set context info (width: %1, height: %2, is_preview: %3):")
.arg(m_context_info->width).arg(m_context_info->height).arg(m_is_preview) << m_context_info; .arg(mContextInfo->width).arg(mContextInfo->height).arg(mIsPreview) << mContextInfo;
if (m_is_preview) if (mIsPreview)
CoreManager::getInstance()->getCore()->setNativePreviewWindowId(m_context_info); CoreManager::getInstance()->getCore()->setNativePreviewWindowId(mContextInfo);
else if (m_linphone_call) else if (mLinphoneCall)
m_linphone_call->setNativeVideoWindowId(m_context_info); mLinphoneCall->setNativeVideoWindowId(mContextInfo);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -155,16 +155,16 @@ Camera::Camera (QQuickItem *parent) : QQuickFramebufferObject(parent) { ...@@ -155,16 +155,16 @@ Camera::Camera (QQuickItem *parent) : QQuickFramebufferObject(parent) {
// The fbo content must be y-mirrored because the ms rendering is y-inverted. // The fbo content must be y-mirrored because the ms rendering is y-inverted.
setMirrorVertically(true); setMirrorVertically(true);
m_refresh_timer = new QTimer(this); mRefreshTimer = new QTimer(this);
m_refresh_timer->setInterval(1 / MAX_FPS * 1000); mRefreshTimer->setInterval(1 / MAX_FPS * 1000);
QObject::connect( QObject::connect(
m_refresh_timer, &QTimer::timeout, mRefreshTimer, &QTimer::timeout,
this, &QQuickFramebufferObject::update, this, &QQuickFramebufferObject::update,
Qt::DirectConnection Qt::DirectConnection
); );
m_refresh_timer->start(); mRefreshTimer->start();
} }
QQuickFramebufferObject::Renderer *Camera::createRenderer () const { QQuickFramebufferObject::Renderer *Camera::createRenderer () const {
...@@ -178,25 +178,25 @@ void Camera::mousePressEvent (QMouseEvent *) { ...@@ -178,25 +178,25 @@ void Camera::mousePressEvent (QMouseEvent *) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
CallModel *Camera::getCall () const { CallModel *Camera::getCall () const {
return m_call; return mCall;
} }
void Camera::setCall (CallModel *call) { void Camera::setCall (CallModel *call) {
if (m_call != call) { if (mCall != call) {
m_call = call; mCall = call;
update(); update();
emit callChanged(m_call); emit callChanged(mCall);
} }
} }
bool Camera::getIsPreview () const { bool Camera::getIsPreview () const {
return m_is_preview; return mIsPreview;
} }
void Camera::setIsPreview (bool status) { void Camera::setIsPreview (bool status) {
if (m_is_preview != status) { if (mIsPreview != status) {
m_is_preview = status; mIsPreview = status;
update(); update();
emit isPreviewChanged(status); emit isPreviewChanged(status);
......
...@@ -53,13 +53,13 @@ protected: ...@@ -53,13 +53,13 @@ protected:
private: private:
void updateWindowId (); void updateWindowId ();
ContextInfo *m_context_info; ContextInfo *mContextInfo;
bool m_update_context_info = false; bool mUpdateContextInfo = false;
bool m_is_preview = false; bool mIsPreview = false;
std::shared_ptr<linphone::Call> m_linphone_call; std::shared_ptr<linphone::Call> mLinphoneCall;
QQuickWindow *m_window; QQuickWindow *mWindow;
}; };
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -80,7 +80,7 @@ public: ...@@ -80,7 +80,7 @@ public:
signals: signals:
void callChanged (CallModel *call); void callChanged (CallModel *call);
void isPreviewChanged (bool is_preview); void isPreviewChanged (bool isPreview);
protected: protected:
void mousePressEvent (QMouseEvent *event) override; void mousePressEvent (QMouseEvent *event) override;
...@@ -92,10 +92,10 @@ private: ...@@ -92,10 +92,10 @@ private:
bool getIsPreview () const; bool getIsPreview () const;
void setIsPreview (bool status); void setIsPreview (bool status);
bool m_is_preview = false; bool mIsPreview = false;
CallModel *m_call = nullptr; CallModel *mCall = nullptr;
QTimer *m_refresh_timer; QTimer *mRefreshTimer;
}; };
#endif // CAMERA_H_ #endif // CAMERA_H_
...@@ -27,12 +27,12 @@ ...@@ -27,12 +27,12 @@
// ============================================================================= // =============================================================================
MSFunctions *MSFunctions::m_instance = nullptr; MSFunctions *MSFunctions::mInstance = nullptr;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
MSFunctions::MSFunctions () { MSFunctions::MSFunctions () {
OpenGlFunctions *f = m_functions = new OpenGlFunctions(); OpenGlFunctions *f = mFunctions = new OpenGlFunctions();
f->glActiveTexture = qtResolveGlActiveTexture; f->glActiveTexture = qtResolveGlActiveTexture;
f->glAttachShader = qtResolveGlAttachShader; f->glAttachShader = qtResolveGlAttachShader;
...@@ -73,5 +73,5 @@ MSFunctions::MSFunctions () { ...@@ -73,5 +73,5 @@ MSFunctions::MSFunctions () {
} }
MSFunctions::~MSFunctions () { MSFunctions::~MSFunctions () {
delete m_functions; delete mFunctions;
} }
...@@ -26,16 +26,16 @@ ...@@ -26,16 +26,16 @@
#include <QOpenGLFunctions> #include <QOpenGLFunctions>
#define GL_ASSERT() \ #define GL_ASSERT() \
Q_ASSERT(m_instance->m_q_functions != NULL); \ Q_ASSERT(mInstance->mQtFunctions != NULL); \
Q_ASSERT(QOpenGLContext::currentContext()->functions() == m_instance->m_q_functions); Q_ASSERT(QOpenGLContext::currentContext()->functions() == mInstance->mQtFunctions);
#define GL_CALL(CALL) \ #define GL_CALL(CALL) \
GL_ASSERT() \ GL_ASSERT() \
m_instance->m_q_functions->CALL; mInstance->mQtFunctions->CALL;
#define GL_CALL_RET(CALL) \ #define GL_CALL_RET(CALL) \
GL_ASSERT() \ GL_ASSERT() \
return m_instance->m_q_functions->CALL; return mInstance->mQtFunctions->CALL;
// ============================================================================= // =============================================================================
...@@ -46,20 +46,20 @@ public: ...@@ -46,20 +46,20 @@ public:
~MSFunctions (); ~MSFunctions ();
void bind (QOpenGLFunctions *f) { void bind (QOpenGLFunctions *f) {
m_q_functions = f; // Qt functions. mQtFunctions = f; // Qt functions.
} }
OpenGlFunctions *getFunctions () { OpenGlFunctions *getFunctions () {
return m_functions; // Own implementation. return mFunctions; // Own implementation.
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
static MSFunctions *getInstance () { static MSFunctions *getInstance () {
if (!m_instance) if (!mInstance)
m_instance = new MSFunctions(); mInstance = new MSFunctions();
return m_instance; return mInstance;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -213,10 +213,10 @@ public: ...@@ -213,10 +213,10 @@ public:
private: private:
MSFunctions (); MSFunctions ();
OpenGlFunctions *m_functions = nullptr; OpenGlFunctions *mFunctions = nullptr;
QOpenGLFunctions *m_q_functions = nullptr; QOpenGLFunctions *mQtFunctions = nullptr;
static MSFunctions *m_instance; static MSFunctions *mInstance;
}; };
#undef GL_CALL #undef GL_CALL
......
...@@ -46,19 +46,19 @@ using namespace std; ...@@ -46,19 +46,19 @@ using namespace std;
// ============================================================================= // =============================================================================
inline void fillThumbnailProperty (QVariantMap &dest, const shared_ptr<linphone::ChatMessage> &message) { inline void fillThumbnailProperty (QVariantMap &dest, const shared_ptr<linphone::ChatMessage> &message) {
string file_id = message->getAppdata(); string fileId = message->getAppdata();
if (!file_id.empty() && !dest.contains("thumbnail")) if (!fileId.empty() && !dest.contains("thumbnail"))
dest["thumbnail"] = QStringLiteral("image://%1/%2") dest["thumbnail"] = QStringLiteral("image://%1/%2")
.arg(ThumbnailProvider::PROVIDER_ID).arg(::Utils::linphoneStringToQString(file_id)); .arg(ThumbnailProvider::PROVIDER_ID).arg(::Utils::linphoneStringToQString(fileId));
} }
inline void createThumbnail (const shared_ptr<linphone::ChatMessage> &message) { inline void createThumbnail (const shared_ptr<linphone::ChatMessage> &message) {
if (!message->getAppdata().empty()) if (!message->getAppdata().empty())
return; return;
QString thumbnail_path = ::Utils::linphoneStringToQString(message->getFileTransferFilepath()); QString thumbnailPath = ::Utils::linphoneStringToQString(message->getFileTransferFilepath());
QImage image(thumbnail_path); QImage image(thumbnailPath);
if (image.isNull()) if (image.isNull())
return; return;
...@@ -68,25 +68,25 @@ inline void createThumbnail (const shared_ptr<linphone::ChatMessage> &message) { ...@@ -68,25 +68,25 @@ inline void createThumbnail (const shared_ptr<linphone::ChatMessage> &message) {
); );
QString uuid = QUuid::createUuid().toString(); QString uuid = QUuid::createUuid().toString();
QString file_id = QStringLiteral("%1.jpg").arg(uuid.mid(1, uuid.length() - 2)); QString fileId = QStringLiteral("%1.jpg").arg(uuid.mid(1, uuid.length() - 2));
if (!thumbnail.save(::Utils::linphoneStringToQString(Paths::getThumbnailsDirpath()) + file_id, "jpg", 100)) { if (!thumbnail.save(::Utils::linphoneStringToQString(Paths::getThumbnailsDirpath()) + fileId, "jpg", 100)) {
qWarning() << QStringLiteral("Unable to create thumbnail of: `%1`.").arg(thumbnail_path); qWarning() << QStringLiteral("Unable to create thumbnail of: `%1`.").arg(thumbnailPath);
return; return;
} }
message->setAppdata(::Utils::qStringToLinphoneString(file_id)); message->setAppdata(::Utils::qStringToLinphoneString(fileId));
} }
inline void removeFileMessageThumbnail (const shared_ptr<linphone::ChatMessage> &message) { inline void removeFileMessageThumbnail (const shared_ptr<linphone::ChatMessage> &message) {
if (message && message->getFileTransferInformation()) { if (message && message->getFileTransferInformation()) {
message->cancelFileTransfer(); message->cancelFileTransfer();
string file_id = message->getAppdata(); string fileId = message->getAppdata();
if (!file_id.empty()) { if (!fileId.empty()) {
QString thumbnail_path = ::Utils::linphoneStringToQString(Paths::getThumbnailsDirpath() + file_id); QString thumbnailPath = ::Utils::linphoneStringToQString(Paths::getThumbnailsDirpath() + fileId);
if (!QFile::remove(thumbnail_path)) if (!QFile::remove(thumbnailPath))
qWarning() << QStringLiteral("Unable to remove `%1`.").arg(thumbnail_path); qWarning() << QStringLiteral("Unable to remove `%1`.").arg(thumbnailPath);
} }
} }
} }
...@@ -97,22 +97,22 @@ class ChatModel::MessageHandlers : public linphone::ChatMessageListener { ...@@ -97,22 +97,22 @@ class ChatModel::MessageHandlers : public linphone::ChatMessageListener {
friend class ChatModel; friend class ChatModel;
public: public:
MessageHandlers (ChatModel *chat_model) : m_chat_model(chat_model) {} MessageHandlers (ChatModel *chatModel) : mChatModel(chatModel) {}
~MessageHandlers () = default; ~MessageHandlers () = default;
private: private:
QList<ChatEntryData>::iterator findMessageEntry (const shared_ptr<linphone::ChatMessage> &message) { QList<ChatEntryData>::iterator findMessageEntry (const shared_ptr<linphone::ChatMessage> &message) {
return find_if( return find_if(
m_chat_model->m_entries.begin(), m_chat_model->m_entries.end(), [&message](const ChatEntryData &pair) { mChatModel->mEntries.begin(), mChatModel->mEntries.end(), [&message](const ChatEntryData &pair) {
return pair.second == message; return pair.second == message;
} }
); );
} }
void signalDataChanged (const QList<ChatEntryData>::iterator &it) { void signalDataChanged (const QList<ChatEntryData>::iterator &it) {
int row = static_cast<int>(distance(m_chat_model->m_entries.begin(), it)); int row = static_cast<int>(distance(mChatModel->mEntries.begin(), it));
emit m_chat_model->dataChanged(m_chat_model->index(row, 0), m_chat_model->index(row, 0)); emit mChatModel->dataChanged(mChatModel->index(row, 0), mChatModel->index(row, 0));
} }
shared_ptr<linphone::Buffer> onFileTransferSend ( shared_ptr<linphone::Buffer> onFileTransferSend (
...@@ -131,11 +131,11 @@ private: ...@@ -131,11 +131,11 @@ private:
size_t offset, size_t offset,
size_t size_t
) override { ) override {
if (!m_chat_model) if (!mChatModel)
return; return;
auto it = findMessageEntry(message); auto it = findMessageEntry(message);
if (it == m_chat_model->m_entries.end()) if (it == mChatModel->mEntries.end())
return; return;
(*it).first["fileOffset"] = static_cast<quint64>(offset); (*it).first["fileOffset"] = static_cast<quint64>(offset);
...@@ -144,11 +144,11 @@ private: ...@@ -144,11 +144,11 @@ private:
} }
void onMsgStateChanged (const shared_ptr<linphone::ChatMessage> &message, linphone::ChatMessageState state) override { void onMsgStateChanged (const shared_ptr<linphone::ChatMessage> &message, linphone::ChatMessageState state) override {
if (!m_chat_model) if (!mChatModel)
return; return;
auto it = findMessageEntry(message); auto it = findMessageEntry(message);
if (it == m_chat_model->m_entries.end()) if (it == mChatModel->mEntries.end())
return; return;
// File message downloaded. // File message downloaded.
...@@ -163,7 +163,7 @@ private: ...@@ -163,7 +163,7 @@ private:
signalDataChanged(it); signalDataChanged(it);
} }
ChatModel *m_chat_model; ChatModel *mChatModel;
}; };
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -171,17 +171,17 @@ private: ...@@ -171,17 +171,17 @@ private:
ChatModel::ChatModel (QObject *parent) : QAbstractListModel(parent) { ChatModel::ChatModel (QObject *parent) : QAbstractListModel(parent) {
CoreManager *core = CoreManager::getInstance(); CoreManager *core = CoreManager::getInstance();
m_core_handlers = core->getHandlers(); mCoreHandlers = core->getHandlers();
m_message_handlers = make_shared<MessageHandlers>(this); mMessageHandlers = make_shared<MessageHandlers>(this);
core->getSipAddressesModel()->connectToChatModel(this); core->getSipAddressesModel()->connectToChatModel(this);
QObject::connect(&(*m_core_handlers), &CoreHandlers::messageReceived, this, &ChatModel::handleMessageReceived); QObject::connect(&(*mCoreHandlers), &CoreHandlers::messageReceived, this, &ChatModel::handleMessageReceived);
QObject::connect(&(*m_core_handlers), &CoreHandlers::callStateChanged, this, &ChatModel::handleCallStateChanged); QObject::connect(&(*mCoreHandlers), &CoreHandlers::callStateChanged, this, &ChatModel::handleCallStateChanged);
} }
ChatModel::~ChatModel () { ChatModel::~ChatModel () {
m_message_handlers->m_chat_model = nullptr; mMessageHandlers->mChatModel = nullptr;
} }
QHash<int, QByteArray> ChatModel::roleNames () const { QHash<int, QByteArray> ChatModel::roleNames () const {
...@@ -192,20 +192,20 @@ QHash<int, QByteArray> ChatModel::roleNames () const { ...@@ -192,20 +192,20 @@ QHash<int, QByteArray> ChatModel::roleNames () const {
} }
int ChatModel::rowCount (const QModelIndex &) const { int ChatModel::rowCount (const QModelIndex &) const {
return m_entries.count(); return mEntries.count();
} }
QVariant ChatModel::data (const QModelIndex &index, int role) const { QVariant ChatModel::data (const QModelIndex &index, int role) const {
int row = index.row(); int row = index.row();
if (!index.isValid() || row < 0 || row >= m_entries.count()) if (!index.isValid() || row < 0 || row >= mEntries.count())
return QVariant(); return QVariant();
switch (role) { switch (role) {
case Roles::ChatEntry: case Roles::ChatEntry:
return QVariant::fromValue(m_entries[row].first); return QVariant::fromValue(mEntries[row].first);
case Roles::SectionDate: case Roles::SectionDate:
return QVariant::fromValue(m_entries[row].first["timestamp"].toDate()); return QVariant::fromValue(mEntries[row].first["timestamp"].toDate());
} }
return QVariant(); return QVariant();
...@@ -218,51 +218,51 @@ bool ChatModel::removeRow (int row, const QModelIndex &) { ...@@ -218,51 +218,51 @@ bool ChatModel::removeRow (int row, const QModelIndex &) {
bool ChatModel::removeRows (int row, int count, const QModelIndex &parent) { bool ChatModel::removeRows (int row, int count, const QModelIndex &parent) {
int limit = row + count - 1; int limit = row + count - 1;
if (row < 0 || count < 0 || limit >= m_entries.count()) if (row < 0 || count < 0 || limit >= mEntries.count())
return false; return false;
beginRemoveRows(parent, row, limit); beginRemoveRows(parent, row, limit);
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
removeEntry(m_entries[row]); removeEntry(mEntries[row]);
m_entries.removeAt(row); mEntries.removeAt(row);
} }
endRemoveRows(); endRemoveRows();
if (m_entries.count() == 0) if (mEntries.count() == 0)
emit allEntriesRemoved(); emit allEntriesRemoved();
return true; return true;
} }
QString ChatModel::getSipAddress () const { QString ChatModel::getSipAddress () const {
if (!m_chat_room) if (!mChatRoom)
return ""; return "";
return ::Utils::linphoneStringToQString( return ::Utils::linphoneStringToQString(
m_chat_room->getPeerAddress()->asStringUriOnly() mChatRoom->getPeerAddress()->asStringUriOnly()
); );
} }
void ChatModel::setSipAddress (const QString &sip_address) { void ChatModel::setSipAddress (const QString &sipAddress) {
if (sip_address == getSipAddress() || sip_address.isEmpty()) if (sipAddress == getSipAddress() || sipAddress.isEmpty())
return; return;
beginResetModel(); beginResetModel();
// Invalid old sip address entries. // Invalid old sip address entries.
m_entries.clear(); mEntries.clear();
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
m_chat_room = core->getChatRoomFromUri(::Utils::qStringToLinphoneString(sip_address)); mChatRoom = core->getChatRoomFromUri(::Utils::qStringToLinphoneString(sipAddress));
if (m_chat_room->getUnreadMessagesCount() > 0) if (mChatRoom->getUnreadMessagesCount() > 0)
resetMessagesCount(); resetMessagesCount();
// Get messages. // Get messages.
for (auto &message : m_chat_room->getHistory(0)) { for (auto &message : mChatRoom->getHistory(0)) {
QVariantMap map; QVariantMap map;
fillMessageEntry(map, message); fillMessageEntry(map, message);
...@@ -271,16 +271,16 @@ void ChatModel::setSipAddress (const QString &sip_address) { ...@@ -271,16 +271,16 @@ void ChatModel::setSipAddress (const QString &sip_address) {
if (message->getState() == linphone::ChatMessageStateInProgress) if (message->getState() == linphone::ChatMessageStateInProgress)
map["status"] = linphone::ChatMessageStateNotDelivered; map["status"] = linphone::ChatMessageStateNotDelivered;
m_entries << qMakePair(map, static_pointer_cast<void>(message)); mEntries << qMakePair(map, static_pointer_cast<void>(message));
} }
// Get calls. // Get calls.
for (auto &call_log : core->getCallHistoryForAddress(m_chat_room->getPeerAddress())) for (auto &callLog : core->getCallHistoryForAddress(mChatRoom->getPeerAddress()))
insertCall(call_log); insertCall(callLog);
endResetModel(); endResetModel();
emit sipAddressChanged(sip_address); emit sipAddressChanged(sipAddress);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -298,10 +298,10 @@ void ChatModel::removeAllEntries () { ...@@ -298,10 +298,10 @@ void ChatModel::removeAllEntries () {
beginResetModel(); beginResetModel();
for (auto &entry : m_entries) for (auto &entry : mEntries)
removeEntry(entry); removeEntry(entry);
m_entries.clear(); mEntries.clear();
endResetModel(); endResetModel();
...@@ -309,28 +309,28 @@ void ChatModel::removeAllEntries () { ...@@ -309,28 +309,28 @@ void ChatModel::removeAllEntries () {
} }
void ChatModel::sendMessage (const QString &message) { void ChatModel::sendMessage (const QString &message) {
if (!m_chat_room) if (!mChatRoom)
return; return;
shared_ptr<linphone::ChatMessage> _message = m_chat_room->createMessage(::Utils::qStringToLinphoneString(message)); shared_ptr<linphone::ChatMessage> _message = mChatRoom->createMessage(::Utils::qStringToLinphoneString(message));
_message->setListener(m_message_handlers); _message->setListener(mMessageHandlers);
insertMessageAtEnd(_message); insertMessageAtEnd(_message);
m_chat_room->sendChatMessage(_message); mChatRoom->sendChatMessage(_message);
emit messageSent(_message); emit messageSent(_message);
} }
void ChatModel::resendMessage (int id) { void ChatModel::resendMessage (int id) {
if (!m_chat_room) if (!mChatRoom)
return; return;
if (id < 0 || id > m_entries.count()) { if (id < 0 || id > mEntries.count()) {
qWarning() << QStringLiteral("Entry %1 not exists.").arg(id); qWarning() << QStringLiteral("Entry %1 not exists.").arg(id);
return; return;
} }
const ChatEntryData &entry = m_entries[id]; const ChatEntryData &entry = mEntries[id];
const QVariantMap &map = entry.first; const QVariantMap &map = entry.first;
if (map["type"] != EntryType::MessageEntry) { if (map["type"] != EntryType::MessageEntry) {
...@@ -345,8 +345,8 @@ void ChatModel::resendMessage (int id) { ...@@ -345,8 +345,8 @@ void ChatModel::resendMessage (int id) {
shared_ptr<linphone::ChatMessage> message = static_pointer_cast<linphone::ChatMessage>(entry.second); shared_ptr<linphone::ChatMessage> message = static_pointer_cast<linphone::ChatMessage>(entry.second);
shared_ptr<linphone::ChatMessage> message2 = message->clone(); shared_ptr<linphone::ChatMessage> message2 = message->clone();
message2->setListener(m_message_handlers); message2->setListener(mMessageHandlers);
m_chat_room->sendChatMessage(message2); mChatRoom->sendChatMessage(message2);
removeEntry(id); removeEntry(id);
insertMessageAtEnd(message2); insertMessageAtEnd(message2);
...@@ -360,7 +360,7 @@ void ChatModel::resendMessage (int id) { ...@@ -360,7 +360,7 @@ void ChatModel::resendMessage (int id) {
} }
void ChatModel::sendFileMessage (const QString &path) { void ChatModel::sendFileMessage (const QString &path) {
if (!m_chat_room) if (!mChatRoom)
return; return;
QFile file(path); QFile file(path);
...@@ -373,28 +373,28 @@ void ChatModel::sendFileMessage (const QString &path) { ...@@ -373,28 +373,28 @@ void ChatModel::sendFileMessage (const QString &path) {
content->setSize(file.size()); content->setSize(file.size());
content->setName(::Utils::qStringToLinphoneString(QFileInfo(file).fileName())); content->setName(::Utils::qStringToLinphoneString(QFileInfo(file).fileName()));
shared_ptr<linphone::ChatMessage> message = m_chat_room->createFileTransferMessage(content); shared_ptr<linphone::ChatMessage> message = mChatRoom->createFileTransferMessage(content);
message->setFileTransferFilepath(::Utils::qStringToLinphoneString(path)); message->setFileTransferFilepath(::Utils::qStringToLinphoneString(path));
message->setListener(m_message_handlers); message->setListener(mMessageHandlers);
createThumbnail(message); createThumbnail(message);
insertMessageAtEnd(message); insertMessageAtEnd(message);
m_chat_room->sendChatMessage(message); mChatRoom->sendChatMessage(message);
emit messageSent(message); emit messageSent(message);
} }
void ChatModel::downloadFile (int id, const QString &download_path) { void ChatModel::downloadFile (int id, const QString &downloadPath) {
if (!m_chat_room) if (!mChatRoom)
return; return;
if (id < 0 || id > m_entries.count()) { if (id < 0 || id > mEntries.count()) {
qWarning() << QStringLiteral("Entry %1 not exists.").arg(id); qWarning() << QStringLiteral("Entry %1 not exists.").arg(id);
return; return;
} }
const ChatEntryData &entry = m_entries[id]; const ChatEntryData &entry = mEntries[id];
if (entry.first["type"] != EntryType::MessageEntry) { if (entry.first["type"] != EntryType::MessageEntry) {
qWarning() << QStringLiteral("Unable to download entry %1. It's not a message.").arg(id); qWarning() << QStringLiteral("Unable to download entry %1. It's not a message.").arg(id);
return; return;
...@@ -419,12 +419,12 @@ void ChatModel::downloadFile (int id, const QString &download_path) { ...@@ -419,12 +419,12 @@ void ChatModel::downloadFile (int id, const QString &download_path) {
} }
message->setFileTransferFilepath( message->setFileTransferFilepath(
::Utils::qStringToLinphoneString(download_path.startsWith("file://") ::Utils::qStringToLinphoneString(downloadPath.startsWith("file://")
? download_path.mid(sizeof("file://") - 1) ? downloadPath.mid(sizeof("file://") - 1)
: download_path : downloadPath
) )
); );
message->setListener(m_message_handlers); message->setListener(mMessageHandlers);
if (message->downloadFile() < 0) if (message->downloadFile() < 0)
qWarning() << QStringLiteral("Unable to download file of entry %1.").arg(id); qWarning() << QStringLiteral("Unable to download file of entry %1.").arg(id);
...@@ -447,23 +447,23 @@ void ChatModel::fillMessageEntry (QVariantMap &dest, const shared_ptr<linphone:: ...@@ -447,23 +447,23 @@ void ChatModel::fillMessageEntry (QVariantMap &dest, const shared_ptr<linphone::
} }
} }
void ChatModel::fillCallStartEntry (QVariantMap &dest, const shared_ptr<linphone::CallLog> &call_log) { void ChatModel::fillCallStartEntry (QVariantMap &dest, const shared_ptr<linphone::CallLog> &callLog) {
QDateTime timestamp = QDateTime::fromMSecsSinceEpoch(call_log->getStartDate() * 1000); QDateTime timestamp = QDateTime::fromMSecsSinceEpoch(callLog->getStartDate() * 1000);
dest["type"] = EntryType::CallEntry; dest["type"] = EntryType::CallEntry;
dest["timestamp"] = timestamp; dest["timestamp"] = timestamp;
dest["isOutgoing"] = call_log->getDir() == linphone::CallDirOutgoing; dest["isOutgoing"] = callLog->getDir() == linphone::CallDirOutgoing;
dest["status"] = call_log->getStatus(); dest["status"] = callLog->getStatus();
dest["isStart"] = true; dest["isStart"] = true;
} }
void ChatModel::fillCallEndEntry (QVariantMap &dest, const shared_ptr<linphone::CallLog> &call_log) { void ChatModel::fillCallEndEntry (QVariantMap &dest, const shared_ptr<linphone::CallLog> &callLog) {
QDateTime timestamp = QDateTime::fromMSecsSinceEpoch((call_log->getStartDate() + call_log->getDuration()) * 1000); QDateTime timestamp = QDateTime::fromMSecsSinceEpoch((callLog->getStartDate() + callLog->getDuration()) * 1000);
dest["type"] = EntryType::CallEntry; dest["type"] = EntryType::CallEntry;
dest["timestamp"] = timestamp; dest["timestamp"] = timestamp;
dest["isOutgoing"] = call_log->getDir() == linphone::CallDirOutgoing; dest["isOutgoing"] = callLog->getDir() == linphone::CallDirOutgoing;
dest["status"] = call_log->getStatus(); dest["status"] = callLog->getStatus();
dest["isStart"] = false; dest["isStart"] = false;
} }
...@@ -476,7 +476,7 @@ void ChatModel::removeEntry (ChatEntryData &pair) { ...@@ -476,7 +476,7 @@ void ChatModel::removeEntry (ChatEntryData &pair) {
case ChatModel::MessageEntry: { case ChatModel::MessageEntry: {
shared_ptr<linphone::ChatMessage> message = static_pointer_cast<linphone::ChatMessage>(pair.second); shared_ptr<linphone::ChatMessage> message = static_pointer_cast<linphone::ChatMessage>(pair.second);
removeFileMessageThumbnail(message); removeFileMessageThumbnail(message);
m_chat_room->deleteMessage(message); mChatRoom->deleteMessage(message);
break; break;
} }
...@@ -485,15 +485,15 @@ void ChatModel::removeEntry (ChatEntryData &pair) { ...@@ -485,15 +485,15 @@ void ChatModel::removeEntry (ChatEntryData &pair) {
// WARNING: Unable to remove symmetric call here. (start/end) // WARNING: Unable to remove symmetric call here. (start/end)
// We are between `beginRemoveRows` and `endRemoveRows`. // We are between `beginRemoveRows` and `endRemoveRows`.
// A solution is to schedule a `removeEntry` call in the Qt main loop. // A solution is to schedule a `removeEntry` call in the Qt main loop.
shared_ptr<void> linphone_ptr = pair.second; shared_ptr<void> linphonePtr = pair.second;
QTimer::singleShot( QTimer::singleShot(
0, this, [this, linphone_ptr]() { 0, this, [this, linphonePtr]() {
auto it = find_if(m_entries.begin(), m_entries.end(), [linphone_ptr](const ChatEntryData &pair) { auto it = find_if(mEntries.begin(), mEntries.end(), [linphonePtr](const ChatEntryData &pair) {
return pair.second == linphone_ptr; return pair.second == linphonePtr;
}); });
if (it != m_entries.end()) if (it != mEntries.end())
removeEntry(static_cast<int>(distance(m_entries.begin(), it))); removeEntry(static_cast<int>(distance(mEntries.begin(), it)));
} }
); );
} }
...@@ -507,28 +507,28 @@ void ChatModel::removeEntry (ChatEntryData &pair) { ...@@ -507,28 +507,28 @@ void ChatModel::removeEntry (ChatEntryData &pair) {
} }
} }
void ChatModel::insertCall (const shared_ptr<linphone::CallLog> &call_log) { void ChatModel::insertCall (const shared_ptr<linphone::CallLog> &callLog) {
auto insert_entry = [this]( auto insertEntry = [this](
const ChatEntryData &pair, const ChatEntryData &pair,
const QList<ChatEntryData>::iterator *start = NULL const QList<ChatEntryData>::iterator *start = NULL
) { ) {
auto it = lower_bound( auto it = lower_bound(
start ? *start : m_entries.begin(), m_entries.end(), pair, start ? *start : mEntries.begin(), mEntries.end(), pair,
[](const ChatEntryData &a, const ChatEntryData &b) { [](const ChatEntryData &a, const ChatEntryData &b) {
return a.first["timestamp"] < b.first["timestamp"]; return a.first["timestamp"] < b.first["timestamp"];
} }
); );
int row = static_cast<int>(distance(m_entries.begin(), it)); int row = static_cast<int>(distance(mEntries.begin(), it));
beginInsertRows(QModelIndex(), row, row); beginInsertRows(QModelIndex(), row, row);
it = m_entries.insert(it, pair); it = mEntries.insert(it, pair);
endInsertRows(); endInsertRows();
return it; return it;
}; };
linphone::CallStatus status = call_log->getStatus(); linphone::CallStatus status = callLog->getStatus();
// Ignore aborted calls. // Ignore aborted calls.
if (status == linphone::CallStatusAborted) if (status == linphone::CallStatusAborted)
...@@ -536,43 +536,43 @@ void ChatModel::insertCall (const shared_ptr<linphone::CallLog> &call_log) { ...@@ -536,43 +536,43 @@ void ChatModel::insertCall (const shared_ptr<linphone::CallLog> &call_log) {
// Add start call. // Add start call.
QVariantMap start; QVariantMap start;
fillCallStartEntry(start, call_log); fillCallStartEntry(start, callLog);
auto it = insert_entry(qMakePair(start, static_pointer_cast<void>(call_log))); auto it = insertEntry(qMakePair(start, static_pointer_cast<void>(callLog)));
// Add end call. (if necessary) // Add end call. (if necessary)
if (status == linphone::CallStatusSuccess) { if (status == linphone::CallStatusSuccess) {
QVariantMap end; QVariantMap end;
fillCallEndEntry(end, call_log); fillCallEndEntry(end, callLog);
insert_entry(qMakePair(end, static_pointer_cast<void>(call_log)), &it); insertEntry(qMakePair(end, static_pointer_cast<void>(callLog)), &it);
} }
} }
void ChatModel::insertMessageAtEnd (const shared_ptr<linphone::ChatMessage> &message) { void ChatModel::insertMessageAtEnd (const shared_ptr<linphone::ChatMessage> &message) {
int row = m_entries.count(); int row = mEntries.count();
beginInsertRows(QModelIndex(), row, row); beginInsertRows(QModelIndex(), row, row);
QVariantMap map; QVariantMap map;
fillMessageEntry(map, message); fillMessageEntry(map, message);
m_entries << qMakePair(map, static_pointer_cast<void>(message)); mEntries << qMakePair(map, static_pointer_cast<void>(message));
endInsertRows(); endInsertRows();
} }
void ChatModel::resetMessagesCount () { void ChatModel::resetMessagesCount () {
m_chat_room->markAsRead(); mChatRoom->markAsRead();
emit messagesCountReset(); emit messagesCountReset();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void ChatModel::handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state) { void ChatModel::handleCallStateChanged (const shared_ptr<linphone::Call> &call, linphone::CallState state) {
if (m_chat_room == call->getChatRoom() && (state == linphone::CallStateEnd || state == linphone::CallStateError)) if (mChatRoom == call->getChatRoom() && (state == linphone::CallStateEnd || state == linphone::CallStateError))
insertCall(call->getCallLog()); insertCall(call->getCallLog());
} }
void ChatModel::handleMessageReceived (const std::shared_ptr<linphone::ChatMessage> &message) { void ChatModel::handleMessageReceived (const shared_ptr<linphone::ChatMessage> &message) {
if (m_chat_room == message->getChatRoom()) { if (mChatRoom == message->getChatRoom()) {
insertMessageAtEnd(message); insertMessageAtEnd(message);
resetMessagesCount(); resetMessagesCount();
......
...@@ -86,7 +86,7 @@ public: ...@@ -86,7 +86,7 @@ public:
bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override; bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override;
QString getSipAddress () const; QString getSipAddress () const;
void setSipAddress (const QString &sip_address); void setSipAddress (const QString &sipAddress);
void removeEntry (int id); void removeEntry (int id);
void removeAllEntries (); void removeAllEntries ();
...@@ -97,10 +97,10 @@ public: ...@@ -97,10 +97,10 @@ public:
void sendFileMessage (const QString &path); void sendFileMessage (const QString &path);
void downloadFile (int id, const QString &download_path); void downloadFile (int id, const QString &downloadPath);
signals: signals:
void sipAddressChanged (const QString &sip_address); void sipAddressChanged (const QString &sipAddress);
void allEntriesRemoved (); void allEntriesRemoved ();
void messageSent (const std::shared_ptr<linphone::ChatMessage> &message); void messageSent (const std::shared_ptr<linphone::ChatMessage> &message);
...@@ -112,12 +112,12 @@ private: ...@@ -112,12 +112,12 @@ private:
typedef QPair<QVariantMap, std::shared_ptr<void> > ChatEntryData; typedef QPair<QVariantMap, std::shared_ptr<void> > ChatEntryData;
void fillMessageEntry (QVariantMap &dest, const std::shared_ptr<linphone::ChatMessage> &message); void fillMessageEntry (QVariantMap &dest, const std::shared_ptr<linphone::ChatMessage> &message);
void fillCallStartEntry (QVariantMap &dest, const std::shared_ptr<linphone::CallLog> &call_log); void fillCallStartEntry (QVariantMap &dest, const std::shared_ptr<linphone::CallLog> &callLog);
void fillCallEndEntry (QVariantMap &dest, const std::shared_ptr<linphone::CallLog> &call_log); void fillCallEndEntry (QVariantMap &dest, const std::shared_ptr<linphone::CallLog> &callLog);
void removeEntry (ChatEntryData &pair); void removeEntry (ChatEntryData &pair);
void insertCall (const std::shared_ptr<linphone::CallLog> &call_log); void insertCall (const std::shared_ptr<linphone::CallLog> &callLog);
void insertMessageAtEnd (const std::shared_ptr<linphone::ChatMessage> &message); void insertMessageAtEnd (const std::shared_ptr<linphone::ChatMessage> &message);
void resetMessagesCount (); void resetMessagesCount ();
...@@ -125,11 +125,11 @@ private: ...@@ -125,11 +125,11 @@ private:
void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state); void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state);
void handleMessageReceived (const std::shared_ptr<linphone::ChatMessage> &message); void handleMessageReceived (const std::shared_ptr<linphone::ChatMessage> &message);
QList<ChatEntryData> m_entries; QList<ChatEntryData> mEntries;
std::shared_ptr<linphone::ChatRoom> m_chat_room; std::shared_ptr<linphone::ChatRoom> mChatRoom;
std::shared_ptr<CoreHandlers> m_core_handlers; std::shared_ptr<CoreHandlers> mCoreHandlers;
std::shared_ptr<MessageHandlers> m_message_handlers; std::shared_ptr<MessageHandlers> mMessageHandlers;
}; };
#endif // CHAT_MODEL_H_ #endif // CHAT_MODEL_H_
...@@ -30,32 +30,32 @@ using namespace std; ...@@ -30,32 +30,32 @@ using namespace std;
class ChatProxyModel::ChatModelFilter : public QSortFilterProxyModel { class ChatProxyModel::ChatModelFilter : public QSortFilterProxyModel {
public: public:
ChatModelFilter (QObject *parent) : QSortFilterProxyModel(parent) { ChatModelFilter (QObject *parent) : QSortFilterProxyModel(parent) {
setSourceModel(&m_chat_model); setSourceModel(&mChatModel);
} }
ChatModel::EntryType getEntryTypeFilter () { ChatModel::EntryType getEntryTypeFilter () {
return m_entry_type_filter; return mEntryTypeFilter;
} }
void setEntryTypeFilter (ChatModel::EntryType type) { void setEntryTypeFilter (ChatModel::EntryType type) {
m_entry_type_filter = type; mEntryTypeFilter = type;
invalidate(); invalidate();
} }
protected: protected:
bool filterAcceptsRow (int source_row, const QModelIndex &) const override { bool filterAcceptsRow (int sourceRow, const QModelIndex &) const override {
if (m_entry_type_filter == ChatModel::EntryType::GenericEntry) if (mEntryTypeFilter == ChatModel::EntryType::GenericEntry)
return true; return true;
QModelIndex index = sourceModel()->index(source_row, 0, QModelIndex()); QModelIndex index = sourceModel()->index(sourceRow, 0, QModelIndex());
const QVariantMap &data = index.data().toMap(); const QVariantMap &data = index.data().toMap();
return data["type"].toInt() == m_entry_type_filter; return data["type"].toInt() == mEntryTypeFilter;
} }
private: private:
ChatModel m_chat_model; ChatModel mChatModel;
ChatModel::EntryType m_entry_type_filter = ChatModel::EntryType::GenericEntry; ChatModel::EntryType mEntryTypeFilter = ChatModel::EntryType::GenericEntry;
}; };
// ============================================================================= // =============================================================================
...@@ -63,34 +63,34 @@ private: ...@@ -63,34 +63,34 @@ private:
const int ChatProxyModel::ENTRIES_CHUNK_SIZE = 50; const int ChatProxyModel::ENTRIES_CHUNK_SIZE = 50;
ChatProxyModel::ChatProxyModel (QObject *parent) : QSortFilterProxyModel(parent) { ChatProxyModel::ChatProxyModel (QObject *parent) : QSortFilterProxyModel(parent) {
m_chat_model_filter = new ChatModelFilter(this); mChatModelFilter = new ChatModelFilter(this);
setSourceModel(m_chat_model_filter); setSourceModel(mChatModelFilter);
ChatModel *chat = static_cast<ChatModel *>(m_chat_model_filter->sourceModel()); ChatModel *chat = static_cast<ChatModel *>(mChatModelFilter->sourceModel());
QObject::connect( QObject::connect(
chat, &ChatModel::messageReceived, this, [this](const shared_ptr<linphone::ChatMessage> &) { chat, &ChatModel::messageReceived, this, [this](const shared_ptr<linphone::ChatMessage> &) {
m_n_max_displayed_entries++; mMaxDisplayedEntries++;
} }
); );
QObject::connect( QObject::connect(
chat, &ChatModel::messageSent, this, [this](const shared_ptr<linphone::ChatMessage> &) { chat, &ChatModel::messageSent, this, [this](const shared_ptr<linphone::ChatMessage> &) {
m_n_max_displayed_entries++; mMaxDisplayedEntries++;
} }
); );
} }
void ChatProxyModel::loadMoreEntries () { void ChatProxyModel::loadMoreEntries () {
int count = rowCount(); int count = rowCount();
int parent_count = m_chat_model_filter->rowCount(); int parentCount = mChatModelFilter->rowCount();
if (count < parent_count) { if (count < parentCount) {
// Do not increase `m_n_max_displayed_entries` if it's not necessary... // Do not increase `mMaxDisplayedEntries` if it's not necessary...
// Limit qml calls. // Limit qml calls.
if (count == m_n_max_displayed_entries) if (count == mMaxDisplayedEntries)
m_n_max_displayed_entries += ENTRIES_CHUNK_SIZE; mMaxDisplayedEntries += ENTRIES_CHUNK_SIZE;
invalidateFilter(); invalidateFilter();
...@@ -101,59 +101,59 @@ void ChatProxyModel::loadMoreEntries () { ...@@ -101,59 +101,59 @@ void ChatProxyModel::loadMoreEntries () {
} }
void ChatProxyModel::setEntryTypeFilter (ChatModel::EntryType type) { void ChatProxyModel::setEntryTypeFilter (ChatModel::EntryType type) {
if (m_chat_model_filter->getEntryTypeFilter() != type) { if (mChatModelFilter->getEntryTypeFilter() != type) {
m_chat_model_filter->setEntryTypeFilter(type); mChatModelFilter->setEntryTypeFilter(type);
emit entryTypeFilterChanged(type); emit entryTypeFilterChanged(type);
} }
} }
void ChatProxyModel::removeEntry (int id) { void ChatProxyModel::removeEntry (int id) {
QModelIndex source_index = mapToSource(index(id, 0)); QModelIndex sourceIndex = mapToSource(index(id, 0));
static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->removeEntry( static_cast<ChatModel *>(mChatModelFilter->sourceModel())->removeEntry(
m_chat_model_filter->mapToSource(source_index).row() mChatModelFilter->mapToSource(sourceIndex).row()
); );
} }
void ChatProxyModel::removeAllEntries () { void ChatProxyModel::removeAllEntries () {
static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->removeAllEntries(); static_cast<ChatModel *>(mChatModelFilter->sourceModel())->removeAllEntries();
} }
void ChatProxyModel::sendMessage (const QString &message) { void ChatProxyModel::sendMessage (const QString &message) {
static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->sendMessage(message); static_cast<ChatModel *>(mChatModelFilter->sourceModel())->sendMessage(message);
} }
void ChatProxyModel::resendMessage (int id) { void ChatProxyModel::resendMessage (int id) {
QModelIndex source_index = mapToSource(index(id, 0)); QModelIndex sourceIndex = mapToSource(index(id, 0));
static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->resendMessage( static_cast<ChatModel *>(mChatModelFilter->sourceModel())->resendMessage(
m_chat_model_filter->mapToSource(source_index).row() mChatModelFilter->mapToSource(sourceIndex).row()
); );
} }
void ChatProxyModel::sendFileMessage (const QString &path) { void ChatProxyModel::sendFileMessage (const QString &path) {
static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->sendFileMessage(path); static_cast<ChatModel *>(mChatModelFilter->sourceModel())->sendFileMessage(path);
} }
void ChatProxyModel::downloadFile (int id, const QString &download_path) { void ChatProxyModel::downloadFile (int id, const QString &downloadPath) {
QModelIndex source_index = mapToSource(index(id, 0)); QModelIndex sourceIndex = mapToSource(index(id, 0));
static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->downloadFile( static_cast<ChatModel *>(mChatModelFilter->sourceModel())->downloadFile(
m_chat_model_filter->mapToSource(source_index).row(), download_path mChatModelFilter->mapToSource(sourceIndex).row(), downloadPath
); );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool ChatProxyModel::filterAcceptsRow (int source_row, const QModelIndex &) const { bool ChatProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex &) const {
return m_chat_model_filter->rowCount() - source_row <= m_n_max_displayed_entries; return mChatModelFilter->rowCount() - sourceRow <= mMaxDisplayedEntries;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
QString ChatProxyModel::getSipAddress () const { QString ChatProxyModel::getSipAddress () const {
return static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->getSipAddress(); return static_cast<ChatModel *>(mChatModelFilter->sourceModel())->getSipAddress();
} }
void ChatProxyModel::setSipAddress (const QString &sip_address) { void ChatProxyModel::setSipAddress (const QString &sipAddress) {
static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->setSipAddress( static_cast<ChatModel *>(mChatModelFilter->sourceModel())->setSipAddress(
sip_address sipAddress
); );
} }
...@@ -50,23 +50,23 @@ public: ...@@ -50,23 +50,23 @@ public:
Q_INVOKABLE void sendFileMessage (const QString &path); Q_INVOKABLE void sendFileMessage (const QString &path);
Q_INVOKABLE void downloadFile (int id, const QString &download_path); Q_INVOKABLE void downloadFile (int id, const QString &downloadPath);
signals: signals:
void sipAddressChanged (const QString &sip_address); void sipAddressChanged (const QString &sipAddress);
void moreEntriesLoaded (int n); void moreEntriesLoaded (int n);
void entryTypeFilterChanged (ChatModel::EntryType type); void entryTypeFilterChanged (ChatModel::EntryType type);
protected: protected:
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override; bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override;
private: private:
QString getSipAddress () const; QString getSipAddress () const;
void setSipAddress (const QString &sip_address); void setSipAddress (const QString &sipAddress);
ChatModelFilter *m_chat_model_filter; ChatModelFilter *mChatModelFilter;
int m_n_max_displayed_entries = ENTRIES_CHUNK_SIZE; int mMaxDisplayedEntries = ENTRIES_CHUNK_SIZE;
static const int ENTRIES_CHUNK_SIZE; static const int ENTRIES_CHUNK_SIZE;
}; };
......
...@@ -38,7 +38,7 @@ inline shared_ptr<linphone::PayloadType> getCodecFromMap (const QVariantMap &map ...@@ -38,7 +38,7 @@ inline shared_ptr<linphone::PayloadType> getCodecFromMap (const QVariantMap &map
AbstractCodecsModel::AbstractCodecsModel (QObject *parent) : QAbstractListModel(parent) {} AbstractCodecsModel::AbstractCodecsModel (QObject *parent) : QAbstractListModel(parent) {}
int AbstractCodecsModel::rowCount (const QModelIndex &) const { int AbstractCodecsModel::rowCount (const QModelIndex &) const {
return m_codecs.count(); return mCodecs.count();
} }
QHash<int, QByteArray> AbstractCodecsModel::roleNames () const { QHash<int, QByteArray> AbstractCodecsModel::roleNames () const {
...@@ -50,11 +50,11 @@ QHash<int, QByteArray> AbstractCodecsModel::roleNames () const { ...@@ -50,11 +50,11 @@ QHash<int, QByteArray> AbstractCodecsModel::roleNames () const {
QVariant AbstractCodecsModel::data (const QModelIndex &index, int role) const { QVariant AbstractCodecsModel::data (const QModelIndex &index, int role) const {
int row = index.row(); int row = index.row();
if (!index.isValid() || row < 0 || row >= m_codecs.count()) if (!index.isValid() || row < 0 || row >= mCodecs.count())
return QVariant(); return QVariant();
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
return m_codecs[row]; return mCodecs[row];
return QVariant(); return QVariant();
} }
...@@ -62,9 +62,9 @@ QVariant AbstractCodecsModel::data (const QModelIndex &index, int role) const { ...@@ -62,9 +62,9 @@ QVariant AbstractCodecsModel::data (const QModelIndex &index, int role) const {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void AbstractCodecsModel::enableCodec (int id, bool status) { void AbstractCodecsModel::enableCodec (int id, bool status) {
Q_ASSERT(id >= 0 && id < m_codecs.count()); Q_ASSERT(id >= 0 && id < mCodecs.count());
QVariantMap &map = m_codecs[id]; QVariantMap &map = mCodecs[id];
shared_ptr<linphone::PayloadType> codec = getCodecFromMap(map); shared_ptr<linphone::PayloadType> codec = getCodecFromMap(map);
codec->enable(status); codec->enable(status);
...@@ -78,9 +78,9 @@ void AbstractCodecsModel::moveCodec (int source, int destination) { ...@@ -78,9 +78,9 @@ void AbstractCodecsModel::moveCodec (int source, int destination) {
} }
void AbstractCodecsModel::setBitrate (int id, int bitrate) { void AbstractCodecsModel::setBitrate (int id, int bitrate) {
Q_ASSERT(id >= 0 && id < m_codecs.count()); Q_ASSERT(id >= 0 && id < mCodecs.count());
QVariantMap &map = m_codecs[id]; QVariantMap &map = mCodecs[id];
shared_ptr<linphone::PayloadType> codec = getCodecFromMap(map); shared_ptr<linphone::PayloadType> codec = getCodecFromMap(map);
codec->setNormalBitrate(bitrate); codec->setNormalBitrate(bitrate);
...@@ -89,13 +89,13 @@ void AbstractCodecsModel::setBitrate (int id, int bitrate) { ...@@ -89,13 +89,13 @@ void AbstractCodecsModel::setBitrate (int id, int bitrate) {
emit dataChanged(index(id, 0), index(id, 0)); emit dataChanged(index(id, 0), index(id, 0));
} }
void AbstractCodecsModel::setRecvFmtp (int id, const QString &recv_fmtp) { void AbstractCodecsModel::setRecvFmtp (int id, const QString &recvFmtp) {
Q_ASSERT(id >= 0 && id < m_codecs.count()); Q_ASSERT(id >= 0 && id < mCodecs.count());
QVariantMap &map = m_codecs[id]; QVariantMap &map = mCodecs[id];
shared_ptr<linphone::PayloadType> codec = getCodecFromMap(map); shared_ptr<linphone::PayloadType> codec = getCodecFromMap(map);
codec->setRecvFmtp(::Utils::qStringToLinphoneString(recv_fmtp)); codec->setRecvFmtp(::Utils::qStringToLinphoneString(recvFmtp));
map["recvFmtp"] = ::Utils::linphoneStringToQString(codec->getRecvFmtp()); map["recvFmtp"] = ::Utils::linphoneStringToQString(codec->getRecvFmtp());
emit dataChanged(index(id, 0), index(id, 0)); emit dataChanged(index(id, 0), index(id, 0));
...@@ -104,43 +104,43 @@ void AbstractCodecsModel::setRecvFmtp (int id, const QString &recv_fmtp) { ...@@ -104,43 +104,43 @@ void AbstractCodecsModel::setRecvFmtp (int id, const QString &recv_fmtp) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool AbstractCodecsModel::moveRows ( bool AbstractCodecsModel::moveRows (
const QModelIndex &source_parent, const QModelIndex &sourceParent,
int source_row, int sourceRow,
int count, int count,
const QModelIndex &destination_parent, const QModelIndex &destinationParent,
int destination_child int destinationChild
) { ) {
int limit = source_row + count - 1; int limit = sourceRow + count - 1;
{ {
int n_codecs = m_codecs.count(); int nCodecs = mCodecs.count();
if ( if (
source_row < 0 || sourceRow < 0 ||
destination_child < 0 || destinationChild < 0 ||
count < 0 || count < 0 ||
destination_child > n_codecs || destinationChild > nCodecs ||
limit >= n_codecs || limit >= nCodecs ||
(source_row <= destination_child && source_row + count >= destination_child) (sourceRow <= destinationChild && sourceRow + count >= destinationChild)
) )
return false; return false;
} }
beginMoveRows(source_parent, source_row, limit, destination_parent, destination_child); beginMoveRows(sourceParent, sourceRow, limit, destinationParent, destinationChild);
// Update UI. // Update UI.
if (destination_child > source_row) { if (destinationChild > sourceRow) {
--destination_child; --destinationChild;
for (int i = source_row; i <= limit; ++i) { for (int i = sourceRow; i <= limit; ++i) {
m_codecs.move(source_row, destination_child + i - source_row); mCodecs.move(sourceRow, destinationChild + i - sourceRow);
} }
} else { } else {
for (int i = source_row; i <= limit; ++i) for (int i = sourceRow; i <= limit; ++i)
m_codecs.move(source_row + i - source_row, destination_child + i - source_row); mCodecs.move(sourceRow + i - sourceRow, destinationChild + i - sourceRow);
} }
// Update linphone codecs list. // Update linphone codecs list.
list<shared_ptr<linphone::PayloadType> > codecs; list<shared_ptr<linphone::PayloadType> > codecs;
for (const auto &map : m_codecs) for (const auto &map : mCodecs)
codecs.push_back(getCodecFromMap(map)); codecs.push_back(getCodecFromMap(map));
updateCodecs(codecs); updateCodecs(codecs);
...@@ -151,7 +151,7 @@ bool AbstractCodecsModel::moveRows ( ...@@ -151,7 +151,7 @@ bool AbstractCodecsModel::moveRows (
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void AbstractCodecsModel::addCodec (std::shared_ptr<linphone::PayloadType> &codec) { void AbstractCodecsModel::addCodec (shared_ptr<linphone::PayloadType> &codec) {
QVariantMap map; QVariantMap map;
map["bitrate"] = codec->getNormalBitrate(); map["bitrate"] = codec->getNormalBitrate();
...@@ -167,5 +167,5 @@ void AbstractCodecsModel::addCodec (std::shared_ptr<linphone::PayloadType> &code ...@@ -167,5 +167,5 @@ void AbstractCodecsModel::addCodec (std::shared_ptr<linphone::PayloadType> &code
map["recvFmtp"] = ::Utils::linphoneStringToQString(codec->getRecvFmtp()); map["recvFmtp"] = ::Utils::linphoneStringToQString(codec->getRecvFmtp());
map["__codec"] = QVariant::fromValue(codec); map["__codec"] = QVariant::fromValue(codec);
m_codecs << map; mCodecs << map;
} }
...@@ -49,15 +49,15 @@ public: ...@@ -49,15 +49,15 @@ public:
Q_INVOKABLE void moveCodec (int source, int destination); Q_INVOKABLE void moveCodec (int source, int destination);
Q_INVOKABLE void setBitrate (int id, int bitrate); Q_INVOKABLE void setBitrate (int id, int bitrate);
Q_INVOKABLE void setRecvFmtp (int id, const QString &recv_fmtp); Q_INVOKABLE void setRecvFmtp (int id, const QString &recvFmtp);
protected: protected:
bool moveRows ( bool moveRows (
const QModelIndex &source_parent, const QModelIndex &sourceParent,
int source_row, int sourceRow,
int count, int count,
const QModelIndex &destination_parent, const QModelIndex &destinationParent,
int destination_child int destinationChild
) override; ) override;
void addCodec (std::shared_ptr<linphone::PayloadType> &codec); void addCodec (std::shared_ptr<linphone::PayloadType> &codec);
...@@ -65,7 +65,7 @@ protected: ...@@ -65,7 +65,7 @@ protected:
virtual void updateCodecs (std::list<std::shared_ptr<linphone::PayloadType> > &codecs) = 0; virtual void updateCodecs (std::list<std::shared_ptr<linphone::PayloadType> > &codecs) = 0;
private: private:
QList<QVariantMap> m_codecs; QList<QVariantMap> mCodecs;
}; };
Q_DECLARE_METATYPE(std::shared_ptr<linphone::PayloadType> ); Q_DECLARE_METATYPE(std::shared_ptr<linphone::PayloadType> );
......
...@@ -30,12 +30,12 @@ using namespace std; ...@@ -30,12 +30,12 @@ using namespace std;
// ============================================================================= // =============================================================================
ContactModel::ContactModel (QObject *parent, shared_ptr<linphone::Friend> linphone_friend) : QObject(parent) { ContactModel::ContactModel (QObject *parent, shared_ptr<linphone::Friend> linphoneFriend) : QObject(parent) {
m_linphone_friend = linphone_friend; mLinphoneFriend = linphoneFriend;
m_vcard = make_shared<VcardModel>(linphone_friend->getVcard()); mVcard = make_shared<VcardModel>(linphoneFriend->getVcard());
App::getInstance()->getEngine()->setObjectOwnership(m_vcard.get(), QQmlEngine::CppOwnership); App::getInstance()->getEngine()->setObjectOwnership(mVcard.get(), QQmlEngine::CppOwnership);
m_linphone_friend->setData("contact-model", *this); mLinphoneFriend->setData("contact-model", *this);
} }
ContactModel::ContactModel (QObject *parent, VcardModel *vcard) : QObject(parent) { ContactModel::ContactModel (QObject *parent, VcardModel *vcard) : QObject(parent) {
...@@ -45,17 +45,17 @@ ContactModel::ContactModel (QObject *parent, VcardModel *vcard) : QObject(parent ...@@ -45,17 +45,17 @@ ContactModel::ContactModel (QObject *parent, VcardModel *vcard) : QObject(parent
if (engine->objectOwnership(vcard) == QQmlEngine::CppOwnership) if (engine->objectOwnership(vcard) == QQmlEngine::CppOwnership)
throw invalid_argument("A contact is already linked to this vcard."); throw invalid_argument("A contact is already linked to this vcard.");
m_linphone_friend = linphone::Friend::newFromVcard(vcard->m_vcard); mLinphoneFriend = linphone::Friend::newFromVcard(vcard->mVcard);
m_linphone_friend->setData("contact-model", *this); mLinphoneFriend->setData("contact-model", *this);
m_vcard.reset(vcard); mVcard.reset(vcard);
engine->setObjectOwnership(vcard, QQmlEngine::CppOwnership); engine->setObjectOwnership(vcard, QQmlEngine::CppOwnership);
} }
void ContactModel::refreshPresence () { void ContactModel::refreshPresence () {
Presence::PresenceStatus status = static_cast<Presence::PresenceStatus>( Presence::PresenceStatus status = static_cast<Presence::PresenceStatus>(
m_linphone_friend->getConsolidatedPresence() mLinphoneFriend->getConsolidatedPresence()
); );
emit presenceStatusChanged(status); emit presenceStatusChanged(status);
...@@ -63,41 +63,41 @@ void ContactModel::refreshPresence () { ...@@ -63,41 +63,41 @@ void ContactModel::refreshPresence () {
} }
void ContactModel::startEdit () { void ContactModel::startEdit () {
m_linphone_friend->edit(); mLinphoneFriend->edit();
m_old_sip_addresses = m_vcard->getSipAddresses(); mOldSipAddresses = mVcard->getSipAddresses();
} }
void ContactModel::endEdit () { void ContactModel::endEdit () {
m_linphone_friend->done(); mLinphoneFriend->done();
QVariantList sip_addresses = m_vcard->getSipAddresses(); QVariantList sipAddresses = mVcard->getSipAddresses();
QSet<QString> done; QSet<QString> done;
for (const auto &variant_a : m_old_sip_addresses) { for (const auto &variantA : mOldSipAddresses) {
next: next:
const QString &sip_address = variant_a.toString(); const QString &sipAddress = variantA.toString();
if (done.contains(sip_address)) if (done.contains(sipAddress))
continue; continue;
done.insert(sip_address); done.insert(sipAddress);
// Check if old sip address exists in new set => No changes. // Check if old sip address exists in new set => No changes.
for (const auto &variant_b : sip_addresses) { for (const auto &variantB : sipAddresses) {
if (sip_address == variant_b.toString()) if (sipAddress == variantB.toString())
goto next; goto next;
} }
emit sipAddressRemoved(sip_address); emit sipAddressRemoved(sipAddress);
} }
m_old_sip_addresses.clear(); mOldSipAddresses.clear();
for (const auto &variant : sip_addresses) { for (const auto &variant : sipAddresses) {
const QString &sip_address = variant.toString(); const QString &sipAddress = variant.toString();
if (done.contains(sip_address)) if (done.contains(sipAddress))
continue; continue;
done.insert(sip_address); done.insert(sipAddress);
emit sipAddressAdded(sip_address); emit sipAddressAdded(sipAddress);
} }
emit contactUpdated(); emit contactUpdated();
...@@ -105,14 +105,14 @@ next: ...@@ -105,14 +105,14 @@ next:
void ContactModel::abortEdit () { void ContactModel::abortEdit () {
// TODO: call linphone friend abort function when available. // TODO: call linphone friend abort function when available.
// m_linphone_friend->abort(); // mLinphoneFriend->abort();
m_old_sip_addresses.clear(); mOldSipAddresses.clear();
emit contactUpdated(); emit contactUpdated();
} }
Presence::PresenceStatus ContactModel::getPresenceStatus () const { Presence::PresenceStatus ContactModel::getPresenceStatus () const {
return static_cast<Presence::PresenceStatus>(m_linphone_friend->getConsolidatedPresence()); return static_cast<Presence::PresenceStatus>(mLinphoneFriend->getConsolidatedPresence());
} }
Presence::PresenceLevel ContactModel::getPresenceLevel () const { Presence::PresenceLevel ContactModel::getPresenceLevel () const {
......
...@@ -40,12 +40,12 @@ class ContactModel : public QObject { ...@@ -40,12 +40,12 @@ class ContactModel : public QObject {
friend class SmartSearchBarModel; friend class SmartSearchBarModel;
public: public:
ContactModel (QObject *parent, std::shared_ptr<linphone::Friend> linphone_friend); ContactModel (QObject *parent, std::shared_ptr<linphone::Friend> linphoneFriend);
ContactModel (QObject *parent, VcardModel *vcard); ContactModel (QObject *parent, VcardModel *vcard);
~ContactModel () = default; ~ContactModel () = default;
std::shared_ptr<VcardModel> getVcardModel () const { std::shared_ptr<VcardModel> getVcardModel () const {
return m_vcard; return mVcard;
} }
void refreshPresence (); void refreshPresence ();
...@@ -58,21 +58,21 @@ signals: ...@@ -58,21 +58,21 @@ signals:
void contactUpdated (); void contactUpdated ();
void presenceStatusChanged (Presence::PresenceStatus status); void presenceStatusChanged (Presence::PresenceStatus status);
void presenceLevelChanged (Presence::PresenceLevel level); void presenceLevelChanged (Presence::PresenceLevel level);
void sipAddressAdded (const QString &sip_address); void sipAddressAdded (const QString &sipAddress);
void sipAddressRemoved (const QString &sip_address); void sipAddressRemoved (const QString &sipAddress);
private: private:
Presence::PresenceStatus getPresenceStatus () const; Presence::PresenceStatus getPresenceStatus () const;
Presence::PresenceLevel getPresenceLevel () const; Presence::PresenceLevel getPresenceLevel () const;
VcardModel *getVcardModelPtr () const { VcardModel *getVcardModelPtr () const {
return m_vcard.get(); return mVcard.get();
} }
QVariantList m_old_sip_addresses; QVariantList mOldSipAddresses;
std::shared_ptr<VcardModel> m_vcard; std::shared_ptr<VcardModel> mVcard;
std::shared_ptr<linphone::Friend> m_linphone_friend; std::shared_ptr<linphone::Friend> mLinphoneFriend;
}; };
Q_DECLARE_METATYPE(ContactModel *); Q_DECLARE_METATYPE(ContactModel *);
......
...@@ -74,33 +74,33 @@ inline shared_ptr<belcard::BelCardPhoto> findBelCardPhoto (const list<shared_ptr ...@@ -74,33 +74,33 @@ inline shared_ptr<belcard::BelCardPhoto> findBelCardPhoto (const list<shared_ptr
VcardModel::~VcardModel () { VcardModel::~VcardModel () {
// If it's a detached Vcard, the linked photo must be destroyed from fs. // If it's a detached Vcard, the linked photo must be destroyed from fs.
if (App::getInstance()->getEngine()->objectOwnership(this) != QQmlEngine::CppOwnership) { if (App::getInstance()->getEngine()->objectOwnership(this) != QQmlEngine::CppOwnership) {
shared_ptr<belcard::BelCardPhoto> photo(findBelCardPhoto(m_vcard->getVcard()->getPhotos())); shared_ptr<belcard::BelCardPhoto> photo(findBelCardPhoto(mVcard->getVcard()->getPhotos()));
if (!photo) if (!photo)
return; return;
QString image_path( QString imagePath(
::Utils::linphoneStringToQString( ::Utils::linphoneStringToQString(
Paths::getAvatarsDirpath() + Paths::getAvatarsDirpath() +
photo->getValue().substr(sizeof(VCARD_SCHEME) - 1) photo->getValue().substr(sizeof(VCARD_SCHEME) - 1)
) )
); );
if (!QFile::remove(image_path)) if (!QFile::remove(imagePath))
qWarning() << QStringLiteral("Unable to remove `%1`.").arg(image_path); qWarning() << QStringLiteral("Unable to remove `%1`.").arg(imagePath);
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
QString VcardModel::getUsername () const { QString VcardModel::getUsername () const {
return ::Utils::linphoneStringToQString(m_vcard->getFullName()); return ::Utils::linphoneStringToQString(mVcard->getFullName());
} }
void VcardModel::setUsername (const QString &username) { void VcardModel::setUsername (const QString &username) {
if (username.length() == 0 || username == getUsername()) if (username.length() == 0 || username == getUsername())
return; return;
m_vcard->setFullName(::Utils::qStringToLinphoneString(username)); mVcard->setFullName(::Utils::qStringToLinphoneString(username));
emit vcardUpdated(); emit vcardUpdated();
} }
...@@ -108,7 +108,7 @@ void VcardModel::setUsername (const QString &username) { ...@@ -108,7 +108,7 @@ void VcardModel::setUsername (const QString &username) {
QString VcardModel::getAvatar () const { QString VcardModel::getAvatar () const {
// Find desktop avatar. // Find desktop avatar.
list<shared_ptr<belcard::BelCardPhoto> > photos = m_vcard->getVcard()->getPhotos(); list<shared_ptr<belcard::BelCardPhoto> > photos = mVcard->getVcard()->getPhotos();
shared_ptr<belcard::BelCardPhoto> photo = findBelCardPhoto(photos); shared_ptr<belcard::BelCardPhoto> photo = findBelCardPhoto(photos);
// No path found. // No path found.
...@@ -130,11 +130,11 @@ bool VcardModel::setAvatar (const QString &path) { ...@@ -130,11 +130,11 @@ bool VcardModel::setAvatar (const QString &path) {
QFileInfo info(file); QFileInfo info(file);
QString uuid = QUuid::createUuid().toString(); QString uuid = QUuid::createUuid().toString();
QString file_id = QStringLiteral("%1.%2") QString fileId = QStringLiteral("%1.%2")
.arg(uuid.mid(1, uuid.length() - 2)) // Remove `{}`. .arg(uuid.mid(1, uuid.length() - 2)) // Remove `{}`.
.arg(info.suffix()); .arg(info.suffix());
QString dest = ::Utils::linphoneStringToQString(Paths::getAvatarsDirpath()) + file_id; QString dest = ::Utils::linphoneStringToQString(Paths::getAvatarsDirpath()) + fileId;
if (!file.copy(dest)) if (!file.copy(dest))
return false; return false;
...@@ -142,26 +142,26 @@ bool VcardModel::setAvatar (const QString &path) { ...@@ -142,26 +142,26 @@ bool VcardModel::setAvatar (const QString &path) {
qInfo() << QStringLiteral("Update avatar of `%1`. (path=%2)").arg(getUsername()).arg(dest); qInfo() << QStringLiteral("Update avatar of `%1`. (path=%2)").arg(getUsername()).arg(dest);
// 2. Edit vcard. // 2. Edit vcard.
shared_ptr<belcard::BelCard> belcard = m_vcard->getVcard(); shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
list<shared_ptr<belcard::BelCardPhoto> > photos = belcard->getPhotos(); list<shared_ptr<belcard::BelCardPhoto> > photos = belcard->getPhotos();
// 3. Remove oldest photo. // 3. Remove oldest photo.
shared_ptr<belcard::BelCardPhoto> old_photo = findBelCardPhoto(photos); shared_ptr<belcard::BelCardPhoto> oldPhoto = findBelCardPhoto(photos);
if (old_photo) { if (oldPhoto) {
QString image_path( QString imagePath(
::Utils::linphoneStringToQString( ::Utils::linphoneStringToQString(
Paths::getAvatarsDirpath() + old_photo->getValue().substr(sizeof(VCARD_SCHEME) - 1) Paths::getAvatarsDirpath() + oldPhoto->getValue().substr(sizeof(VCARD_SCHEME) - 1)
) )
); );
if (!QFile::remove(image_path)) if (!QFile::remove(imagePath))
qWarning() << QStringLiteral("Unable to remove `%1`.").arg(image_path); qWarning() << QStringLiteral("Unable to remove `%1`.").arg(imagePath);
belcard->removePhoto(old_photo); belcard->removePhoto(oldPhoto);
} }
// 4. Update. // 4. Update.
shared_ptr<belcard::BelCardPhoto> photo = belcard::BelCardGeneric::create<belcard::BelCardPhoto>(); shared_ptr<belcard::BelCardPhoto> photo = belcard::BelCardGeneric::create<belcard::BelCardPhoto>();
photo->setValue(VCARD_SCHEME + ::Utils::qStringToLinphoneString(file_id)); photo->setValue(VCARD_SCHEME + ::Utils::qStringToLinphoneString(fileId));
if (!belcard->addPhoto(photo)) if (!belcard->addPhoto(photo))
return false; return false;
...@@ -187,7 +187,7 @@ inline shared_ptr<belcard::BelCardAddress> getOrCreateBelCardAddress (shared_ptr ...@@ -187,7 +187,7 @@ inline shared_ptr<belcard::BelCardAddress> getOrCreateBelCardAddress (shared_ptr
} }
QVariantMap VcardModel::getAddress () const { QVariantMap VcardModel::getAddress () const {
list<shared_ptr<belcard::BelCardAddress> > addresses = m_vcard->getVcard()->getAddresses(); list<shared_ptr<belcard::BelCardAddress> > addresses = mVcard->getVcard()->getAddresses();
QVariantMap map; QVariantMap map;
if (addresses.empty()) if (addresses.empty())
...@@ -203,25 +203,25 @@ QVariantMap VcardModel::getAddress () const { ...@@ -203,25 +203,25 @@ QVariantMap VcardModel::getAddress () const {
} }
void VcardModel::setStreet (const QString &street) { void VcardModel::setStreet (const QString &street) {
shared_ptr<belcard::BelCardAddress> address = getOrCreateBelCardAddress(m_vcard->getVcard()); shared_ptr<belcard::BelCardAddress> address = getOrCreateBelCardAddress(mVcard->getVcard());
address->setStreet(::Utils::qStringToLinphoneString(street)); address->setStreet(::Utils::qStringToLinphoneString(street));
emit vcardUpdated(); emit vcardUpdated();
} }
void VcardModel::setLocality (const QString &locality) { void VcardModel::setLocality (const QString &locality) {
shared_ptr<belcard::BelCardAddress> address = getOrCreateBelCardAddress(m_vcard->getVcard()); shared_ptr<belcard::BelCardAddress> address = getOrCreateBelCardAddress(mVcard->getVcard());
address->setLocality(::Utils::qStringToLinphoneString(locality)); address->setLocality(::Utils::qStringToLinphoneString(locality));
emit vcardUpdated(); emit vcardUpdated();
} }
void VcardModel::setPostalCode (const QString &postal_code) { void VcardModel::setPostalCode (const QString &postalCode) {
shared_ptr<belcard::BelCardAddress> address = getOrCreateBelCardAddress(m_vcard->getVcard()); shared_ptr<belcard::BelCardAddress> address = getOrCreateBelCardAddress(mVcard->getVcard());
address->setPostalCode(::Utils::qStringToLinphoneString(postal_code)); address->setPostalCode(::Utils::qStringToLinphoneString(postalCode));
emit vcardUpdated(); emit vcardUpdated();
} }
void VcardModel::setCountry (const QString &country) { void VcardModel::setCountry (const QString &country) {
shared_ptr<belcard::BelCardAddress> address = getOrCreateBelCardAddress(m_vcard->getVcard()); shared_ptr<belcard::BelCardAddress> address = getOrCreateBelCardAddress(mVcard->getVcard());
address->setCountry(::Utils::qStringToLinphoneString(country)); address->setCountry(::Utils::qStringToLinphoneString(country));
emit vcardUpdated(); emit vcardUpdated();
} }
...@@ -232,37 +232,37 @@ QVariantList VcardModel::getSipAddresses () const { ...@@ -232,37 +232,37 @@ QVariantList VcardModel::getSipAddresses () const {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
QVariantList list; QVariantList list;
for (const auto &address : m_vcard->getVcard()->getImpp()) { for (const auto &address : mVcard->getVcard()->getImpp()) {
string value = address->getValue(); string value = address->getValue();
shared_ptr<linphone::Address> l_address = core->createAddress(value); shared_ptr<linphone::Address> linphoneAddress = core->createAddress(value);
if (l_address) if (linphoneAddress)
list.append(::Utils::linphoneStringToQString(l_address->asStringUriOnly())); list.append(::Utils::linphoneStringToQString(linphoneAddress->asStringUriOnly()));
} }
return list; return list;
} }
bool VcardModel::addSipAddress (const QString &sip_address) { bool VcardModel::addSipAddress (const QString &sipAddress) {
// Check sip address format. // Check sip address format.
shared_ptr<linphone::Address> l_address = CoreManager::getInstance()->getCore()->interpretUrl( shared_ptr<linphone::Address> linphoneAddress = CoreManager::getInstance()->getCore()->interpretUrl(
::Utils::qStringToLinphoneString(sip_address) ::Utils::qStringToLinphoneString(sipAddress)
); );
if (!l_address) { if (!linphoneAddress) {
qWarning() << QStringLiteral("Unable to add invalid sip address on vcard: `%1`.").arg(sip_address); qWarning() << QStringLiteral("Unable to add invalid sip address on vcard: `%1`.").arg(sipAddress);
return false; return false;
} }
// Add sip address in belcard. // Add sip address in belcard.
shared_ptr<belcard::BelCard> belcard = m_vcard->getVcard(); shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
shared_ptr<belcard::BelCardImpp> value = belcard::BelCardGeneric::create<belcard::BelCardImpp>(); shared_ptr<belcard::BelCardImpp> value = belcard::BelCardGeneric::create<belcard::BelCardImpp>();
value->setValue(l_address->asStringUriOnly()); value->setValue(linphoneAddress->asStringUriOnly());
qInfo() << QStringLiteral("Add new sip address on vcard: `%1`.").arg(sip_address); qInfo() << QStringLiteral("Add new sip address on vcard: `%1`.").arg(sipAddress);
if (!belcard->addImpp(value)) { if (!belcard->addImpp(value)) {
qWarning() << QStringLiteral("Unable to add sip address on vcard: `%1`.").arg(sip_address); qWarning() << QStringLiteral("Unable to add sip address on vcard: `%1`.").arg(sipAddress);
return false; return false;
} }
...@@ -270,33 +270,33 @@ bool VcardModel::addSipAddress (const QString &sip_address) { ...@@ -270,33 +270,33 @@ bool VcardModel::addSipAddress (const QString &sip_address) {
return true; return true;
} }
void VcardModel::removeSipAddress (const QString &sip_address) { void VcardModel::removeSipAddress (const QString &sipAddress) {
shared_ptr<belcard::BelCard> belcard = m_vcard->getVcard(); shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
list<shared_ptr<belcard::BelCardImpp> > addresses = belcard->getImpp(); list<shared_ptr<belcard::BelCardImpp> > addresses = belcard->getImpp();
shared_ptr<belcard::BelCardImpp> value = findBelCardValue(addresses, sip_address); shared_ptr<belcard::BelCardImpp> value = findBelCardValue(addresses, sipAddress);
if (!value) { if (!value) {
qWarning() << QStringLiteral("Unable to remove sip address on vcard: `%1`.").arg(sip_address); qWarning() << QStringLiteral("Unable to remove sip address on vcard: `%1`.").arg(sipAddress);
return; return;
} }
if (addresses.size() == 1) { if (addresses.size() == 1) {
qWarning() << QStringLiteral("Unable to remove the only existing sip address on vcard: `%1`.") qWarning() << QStringLiteral("Unable to remove the only existing sip address on vcard: `%1`.")
.arg(sip_address); .arg(sipAddress);
return; return;
} }
qInfo() << QStringLiteral("Remove sip address on vcard: `%1`.").arg(sip_address); qInfo() << QStringLiteral("Remove sip address on vcard: `%1`.").arg(sipAddress);
belcard->removeImpp(value); belcard->removeImpp(value);
emit vcardUpdated(); emit vcardUpdated();
} }
bool VcardModel::updateSipAddress (const QString &old_sip_address, const QString &sip_address) { bool VcardModel::updateSipAddress (const QString &oldSipAddress, const QString &sipAddress) {
if (old_sip_address == sip_address || !addSipAddress(sip_address)) if (oldSipAddress == sipAddress || !addSipAddress(sipAddress))
return false; return false;
removeSipAddress(old_sip_address); removeSipAddress(oldSipAddress);
return true; return true;
} }
...@@ -306,14 +306,14 @@ bool VcardModel::updateSipAddress (const QString &old_sip_address, const QString ...@@ -306,14 +306,14 @@ bool VcardModel::updateSipAddress (const QString &old_sip_address, const QString
QVariantList VcardModel::getCompanies () const { QVariantList VcardModel::getCompanies () const {
QVariantList list; QVariantList list;
for (const auto &company : m_vcard->getVcard()->getRoles()) for (const auto &company : mVcard->getVcard()->getRoles())
list.append(::Utils::linphoneStringToQString(company->getValue())); list.append(::Utils::linphoneStringToQString(company->getValue()));
return list; return list;
} }
bool VcardModel::addCompany (const QString &company) { bool VcardModel::addCompany (const QString &company) {
shared_ptr<belcard::BelCard> belcard = m_vcard->getVcard(); shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
shared_ptr<belcard::BelCardRole> value = belcard::BelCardGeneric::create<belcard::BelCardRole>(); shared_ptr<belcard::BelCardRole> value = belcard::BelCardGeneric::create<belcard::BelCardRole>();
value->setValue(::Utils::qStringToLinphoneString(company)); value->setValue(::Utils::qStringToLinphoneString(company));
...@@ -329,7 +329,7 @@ bool VcardModel::addCompany (const QString &company) { ...@@ -329,7 +329,7 @@ bool VcardModel::addCompany (const QString &company) {
} }
void VcardModel::removeCompany (const QString &company) { void VcardModel::removeCompany (const QString &company) {
shared_ptr<belcard::BelCard> belcard = m_vcard->getVcard(); shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
shared_ptr<belcard::BelCardRole> value = findBelCardValue(belcard->getRoles(), company); shared_ptr<belcard::BelCardRole> value = findBelCardValue(belcard->getRoles(), company);
if (!value) { if (!value) {
...@@ -343,11 +343,11 @@ void VcardModel::removeCompany (const QString &company) { ...@@ -343,11 +343,11 @@ void VcardModel::removeCompany (const QString &company) {
emit vcardUpdated(); emit vcardUpdated();
} }
bool VcardModel::updateCompany (const QString &old_company, const QString &company) { bool VcardModel::updateCompany (const QString &oldCompany, const QString &company) {
if (old_company == company || !addCompany(company)) if (oldCompany == company || !addCompany(company))
return false; return false;
removeCompany(old_company); removeCompany(oldCompany);
return true; return true;
} }
...@@ -357,14 +357,14 @@ bool VcardModel::updateCompany (const QString &old_company, const QString &compa ...@@ -357,14 +357,14 @@ bool VcardModel::updateCompany (const QString &old_company, const QString &compa
QVariantList VcardModel::getEmails () const { QVariantList VcardModel::getEmails () const {
QVariantList list; QVariantList list;
for (const auto &email : m_vcard->getVcard()->getEmails()) for (const auto &email : mVcard->getVcard()->getEmails())
list.append(::Utils::linphoneStringToQString(email->getValue())); list.append(::Utils::linphoneStringToQString(email->getValue()));
return list; return list;
} }
bool VcardModel::addEmail (const QString &email) { bool VcardModel::addEmail (const QString &email) {
shared_ptr<belcard::BelCard> belcard = m_vcard->getVcard(); shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
shared_ptr<belcard::BelCardEmail> value = belcard::BelCardGeneric::create<belcard::BelCardEmail>(); shared_ptr<belcard::BelCardEmail> value = belcard::BelCardGeneric::create<belcard::BelCardEmail>();
value->setValue(::Utils::qStringToLinphoneString(email)); value->setValue(::Utils::qStringToLinphoneString(email));
...@@ -380,7 +380,7 @@ bool VcardModel::addEmail (const QString &email) { ...@@ -380,7 +380,7 @@ bool VcardModel::addEmail (const QString &email) {
} }
void VcardModel::removeEmail (const QString &email) { void VcardModel::removeEmail (const QString &email) {
shared_ptr<belcard::BelCard> belcard = m_vcard->getVcard(); shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
shared_ptr<belcard::BelCardEmail> value = findBelCardValue(belcard->getEmails(), email); shared_ptr<belcard::BelCardEmail> value = findBelCardValue(belcard->getEmails(), email);
if (!value) { if (!value) {
...@@ -394,11 +394,11 @@ void VcardModel::removeEmail (const QString &email) { ...@@ -394,11 +394,11 @@ void VcardModel::removeEmail (const QString &email) {
emit vcardUpdated(); emit vcardUpdated();
} }
bool VcardModel::updateEmail (const QString &old_email, const QString &email) { bool VcardModel::updateEmail (const QString &oldEmail, const QString &email) {
if (old_email == email || !addEmail(email)) if (oldEmail == email || !addEmail(email))
return false; return false;
removeEmail(old_email); removeEmail(oldEmail);
return true; return true;
} }
...@@ -408,14 +408,14 @@ bool VcardModel::updateEmail (const QString &old_email, const QString &email) { ...@@ -408,14 +408,14 @@ bool VcardModel::updateEmail (const QString &old_email, const QString &email) {
QVariantList VcardModel::getUrls () const { QVariantList VcardModel::getUrls () const {
QVariantList list; QVariantList list;
for (const auto &url : m_vcard->getVcard()->getURLs()) for (const auto &url : mVcard->getVcard()->getURLs())
list.append(::Utils::linphoneStringToQString(url->getValue())); list.append(::Utils::linphoneStringToQString(url->getValue()));
return list; return list;
} }
bool VcardModel::addUrl (const QString &url) { bool VcardModel::addUrl (const QString &url) {
shared_ptr<belcard::BelCard> belcard = m_vcard->getVcard(); shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
shared_ptr<belcard::BelCardURL> value = belcard::BelCardGeneric::create<belcard::BelCardURL>(); shared_ptr<belcard::BelCardURL> value = belcard::BelCardGeneric::create<belcard::BelCardURL>();
value->setValue(::Utils::qStringToLinphoneString(url)); value->setValue(::Utils::qStringToLinphoneString(url));
...@@ -431,7 +431,7 @@ bool VcardModel::addUrl (const QString &url) { ...@@ -431,7 +431,7 @@ bool VcardModel::addUrl (const QString &url) {
} }
void VcardModel::removeUrl (const QString &url) { void VcardModel::removeUrl (const QString &url) {
shared_ptr<belcard::BelCard> belcard = m_vcard->getVcard(); shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
shared_ptr<belcard::BelCardURL> value = findBelCardValue(belcard->getURLs(), url); shared_ptr<belcard::BelCardURL> value = findBelCardValue(belcard->getURLs(), url);
if (!value) { if (!value) {
...@@ -445,11 +445,11 @@ void VcardModel::removeUrl (const QString &url) { ...@@ -445,11 +445,11 @@ void VcardModel::removeUrl (const QString &url) {
emit vcardUpdated(); emit vcardUpdated();
} }
bool VcardModel::updateUrl (const QString &old_url, const QString &url) { bool VcardModel::updateUrl (const QString &oldUrl, const QString &url) {
if (old_url == url || !addUrl(url)) if (oldUrl == url || !addUrl(url))
return false; return false;
removeUrl(old_url); removeUrl(oldUrl);
return true; return true;
} }
...@@ -42,32 +42,32 @@ class VcardModel : public QObject { ...@@ -42,32 +42,32 @@ class VcardModel : public QObject {
friend class ContactModel; friend class ContactModel;
public: public:
VcardModel (std::shared_ptr<linphone::Vcard> vcard) : m_vcard(vcard) {} VcardModel (std::shared_ptr<linphone::Vcard> vcard) : mVcard(vcard) {}
~VcardModel (); ~VcardModel ();
QString getUsername () const; QString getUsername () const;
QVariantList getSipAddresses () const; QVariantList getSipAddresses () const;
Q_INVOKABLE bool addSipAddress (const QString &sip_address); Q_INVOKABLE bool addSipAddress (const QString &sipAddress);
Q_INVOKABLE void removeSipAddress (const QString &sip_address); Q_INVOKABLE void removeSipAddress (const QString &sipAddress);
Q_INVOKABLE bool updateSipAddress (const QString &old_sip_address, const QString &sip_address); Q_INVOKABLE bool updateSipAddress (const QString &oldSipAddress, const QString &sipAddress);
Q_INVOKABLE bool addCompany (const QString &company); Q_INVOKABLE bool addCompany (const QString &company);
Q_INVOKABLE void removeCompany (const QString &company); Q_INVOKABLE void removeCompany (const QString &company);
Q_INVOKABLE bool updateCompany (const QString &old_company, const QString &company); Q_INVOKABLE bool updateCompany (const QString &oldCompany, const QString &company);
Q_INVOKABLE bool addEmail (const QString &email); Q_INVOKABLE bool addEmail (const QString &email);
Q_INVOKABLE void removeEmail (const QString &email); Q_INVOKABLE void removeEmail (const QString &email);
Q_INVOKABLE bool updateEmail (const QString &old_email, const QString &email); Q_INVOKABLE bool updateEmail (const QString &oldEmail, const QString &email);
Q_INVOKABLE bool addUrl (const QString &url); Q_INVOKABLE bool addUrl (const QString &url);
Q_INVOKABLE void removeUrl (const QString &url); Q_INVOKABLE void removeUrl (const QString &url);
Q_INVOKABLE bool updateUrl (const QString &old_url, const QString &url); Q_INVOKABLE bool updateUrl (const QString &oldUrl, const QString &url);
Q_INVOKABLE void setStreet (const QString &street); Q_INVOKABLE void setStreet (const QString &street);
Q_INVOKABLE void setLocality (const QString &locality); Q_INVOKABLE void setLocality (const QString &locality);
Q_INVOKABLE void setPostalCode (const QString &postal_code); Q_INVOKABLE void setPostalCode (const QString &postalCode);
Q_INVOKABLE void setCountry (const QString &country); Q_INVOKABLE void setCountry (const QString &country);
signals: signals:
...@@ -84,7 +84,7 @@ private: ...@@ -84,7 +84,7 @@ private:
QVariantList getEmails () const; QVariantList getEmails () const;
QVariantList getUrls () const; QVariantList getUrls () const;
std::shared_ptr<linphone::Vcard> m_vcard; std::shared_ptr<linphone::Vcard> mVcard;
}; };
Q_DECLARE_METATYPE(VcardModel *); Q_DECLARE_METATYPE(VcardModel *);
......
...@@ -33,11 +33,11 @@ using namespace std; ...@@ -33,11 +33,11 @@ using namespace std;
// ============================================================================= // =============================================================================
ContactsListModel::ContactsListModel (QObject *parent) : QAbstractListModel(parent) { ContactsListModel::ContactsListModel (QObject *parent) : QAbstractListModel(parent) {
m_linphone_friends = CoreManager::getInstance()->getCore()->getFriendsLists().front(); mLinphoneFriends = CoreManager::getInstance()->getCore()->getFriendsLists().front();
// Init contacts with linphone friends list. // Init contacts with linphone friends list.
for (const auto &friend_ : m_linphone_friends->getFriends()) { for (const auto &_friend : mLinphoneFriends->getFriends()) {
ContactModel *contact = new ContactModel(this, friend_); ContactModel *contact = new ContactModel(this, _friend);
// See: http://doc.qt.io/qt-5/qtqml-cppintegration-data.html#data-ownership // See: http://doc.qt.io/qt-5/qtqml-cppintegration-data.html#data-ownership
// The returned value must have a explicit parent or a QQmlEngine::CppOwnership. // The returned value must have a explicit parent or a QQmlEngine::CppOwnership.
...@@ -48,7 +48,7 @@ ContactsListModel::ContactsListModel (QObject *parent) : QAbstractListModel(pare ...@@ -48,7 +48,7 @@ ContactsListModel::ContactsListModel (QObject *parent) : QAbstractListModel(pare
} }
int ContactsListModel::rowCount (const QModelIndex &) const { int ContactsListModel::rowCount (const QModelIndex &) const {
return m_list.count(); return mList.count();
} }
QHash<int, QByteArray> ContactsListModel::roleNames () const { QHash<int, QByteArray> ContactsListModel::roleNames () const {
...@@ -60,11 +60,11 @@ QHash<int, QByteArray> ContactsListModel::roleNames () const { ...@@ -60,11 +60,11 @@ QHash<int, QByteArray> ContactsListModel::roleNames () const {
QVariant ContactsListModel::data (const QModelIndex &index, int role) const { QVariant ContactsListModel::data (const QModelIndex &index, int role) const {
int row = index.row(); int row = index.row();
if (!index.isValid() || row < 0 || row >= m_list.count()) if (!index.isValid() || row < 0 || row >= mList.count())
return QVariant(); return QVariant();
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
return QVariant::fromValue(m_list[row]); return QVariant::fromValue(mList[row]);
return QVariant(); return QVariant();
} }
...@@ -76,15 +76,15 @@ bool ContactsListModel::removeRow (int row, const QModelIndex &parent) { ...@@ -76,15 +76,15 @@ bool ContactsListModel::removeRow (int row, const QModelIndex &parent) {
bool ContactsListModel::removeRows (int row, int count, const QModelIndex &parent) { bool ContactsListModel::removeRows (int row, int count, const QModelIndex &parent) {
int limit = row + count - 1; int limit = row + count - 1;
if (row < 0 || count < 0 || limit >= m_list.count()) if (row < 0 || count < 0 || limit >= mList.count())
return false; return false;
beginRemoveRows(parent, row, limit); beginRemoveRows(parent, row, limit);
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
ContactModel *contact = m_list.takeAt(row); ContactModel *contact = mList.takeAt(row);
m_linphone_friends->removeFriend(contact->m_linphone_friend); mLinphoneFriends->removeFriend(contact->mLinphoneFriend);
emit contactRemoved(contact); emit contactRemoved(contact);
contact->deleteLater(); contact->deleteLater();
...@@ -104,7 +104,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcard) { ...@@ -104,7 +104,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcard) {
qInfo() << "Add contact:" << contact; qInfo() << "Add contact:" << contact;
if ( if (
m_linphone_friends->addFriend(contact->m_linphone_friend) != mLinphoneFriends->addFriend(contact->mLinphoneFriend) !=
linphone::FriendListStatus::FriendListStatusOK linphone::FriendListStatus::FriendListStatusOK
) { ) {
qWarning() << "Unable to add friend from vcard:" << vcard; qWarning() << "Unable to add friend from vcard:" << vcard;
...@@ -112,7 +112,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcard) { ...@@ -112,7 +112,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcard) {
return nullptr; return nullptr;
} }
int row = m_list.count(); int row = mList.count();
beginInsertRows(QModelIndex(), row, row); beginInsertRows(QModelIndex(), row, row);
addContact(contact); addContact(contact);
...@@ -126,7 +126,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcard) { ...@@ -126,7 +126,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcard) {
void ContactsListModel::removeContact (ContactModel *contact) { void ContactsListModel::removeContact (ContactModel *contact) {
qInfo() << "Removing contact:" << contact; qInfo() << "Removing contact:" << contact;
int index = m_list.indexOf(contact); int index = mList.indexOf(contact);
if (index == -1 || !removeRow(index)) if (index == -1 || !removeRow(index))
qWarning() << "Unable to remove contact:" << contact; qWarning() << "Unable to remove contact:" << contact;
} }
...@@ -141,15 +141,15 @@ void ContactsListModel::addContact (ContactModel *contact) { ...@@ -141,15 +141,15 @@ void ContactsListModel::addContact (ContactModel *contact) {
} }
); );
QObject::connect( QObject::connect(
contact, &ContactModel::sipAddressAdded, this, [this, contact](const QString &sip_address) { contact, &ContactModel::sipAddressAdded, this, [this, contact](const QString &sipAddress) {
emit sipAddressAdded(contact, sip_address); emit sipAddressAdded(contact, sipAddress);
} }
); );
QObject::connect( QObject::connect(
contact, &ContactModel::sipAddressRemoved, this, [this, contact](const QString &sip_address) { contact, &ContactModel::sipAddressRemoved, this, [this, contact](const QString &sipAddress) {
emit sipAddressRemoved(contact, sip_address); emit sipAddressRemoved(contact, sipAddress);
} }
); );
m_list << contact; mList << contact;
} }
...@@ -56,14 +56,14 @@ signals: ...@@ -56,14 +56,14 @@ signals:
void contactRemoved (const ContactModel *contact); void contactRemoved (const ContactModel *contact);
void contactUpdated (ContactModel *contact); void contactUpdated (ContactModel *contact);
void sipAddressAdded (ContactModel *contact, const QString &sip_address); void sipAddressAdded (ContactModel *contact, const QString &sipAddress);
void sipAddressRemoved (ContactModel *contact, const QString &sip_address); void sipAddressRemoved (ContactModel *contact, const QString &sipAddress);
private: private:
void addContact (ContactModel *contact); void addContact (ContactModel *contact);
QList<ContactModel *> m_list; QList<ContactModel *> mList;
std::shared_ptr<linphone::FriendList> m_linphone_friends; std::shared_ptr<linphone::FriendList> mLinphoneFriends;
}; };
#endif // CONTACTS_LIST_MODEL_H_ #endif // CONTACTS_LIST_MODEL_H_
...@@ -51,7 +51,7 @@ using namespace std; ...@@ -51,7 +51,7 @@ using namespace std;
// a separator like ` word`. // a separator like ` word`.
// //
// - [_.-;@ ] is the main pattern (a separator). // - [_.-;@ ] is the main pattern (a separator).
const QRegExp ContactsListProxyModel::m_search_separators("^[^_.-;@ ][_.-;@ ]"); const QRegExp ContactsListProxyModel::mSearchSeparators("^[^_.-;@ ][_.-;@ ]");
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -63,38 +63,38 @@ ContactsListProxyModel::ContactsListProxyModel (QObject *parent) : QSortFilterPr ...@@ -63,38 +63,38 @@ ContactsListProxyModel::ContactsListProxyModel (QObject *parent) : QSortFilterPr
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void ContactsListProxyModel::setFilter (const QString &pattern) { void ContactsListProxyModel::setFilter (const QString &pattern) {
m_filter = pattern; mFilter = pattern;
invalidate(); invalidate();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool ContactsListProxyModel::filterAcceptsRow ( bool ContactsListProxyModel::filterAcceptsRow (
int source_row, int sourceRow,
const QModelIndex &source_parent const QModelIndex &sourceParent
) const { ) const {
const QModelIndex &index = sourceModel()->index(source_row, 0, source_parent); const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent);
const ContactModel *contact = index.data().value<ContactModel *>(); const ContactModel *contact = index.data().value<ContactModel *>();
m_weights[contact] = static_cast<unsigned int>(round(computeContactWeight(contact))); mWeights[contact] = static_cast<unsigned int>(round(computeContactWeight(contact)));
return m_weights[contact] > 0 && ( return mWeights[contact] > 0 && (
!m_use_connected_filter || !mUseConnectedFilter ||
contact->getPresenceLevel() != Presence::PresenceLevel::White contact->getPresenceLevel() != Presence::PresenceLevel::White
); );
} }
bool ContactsListProxyModel::lessThan (const QModelIndex &left, const QModelIndex &right) const { bool ContactsListProxyModel::lessThan (const QModelIndex &left, const QModelIndex &right) const {
const ContactModel *contact_a = sourceModel()->data(left).value<ContactModel *>(); const ContactModel *contactA = sourceModel()->data(left).value<ContactModel *>();
const ContactModel *contact_b = sourceModel()->data(right).value<ContactModel *>(); const ContactModel *contactB = sourceModel()->data(right).value<ContactModel *>();
unsigned int weight_a = m_weights[contact_a]; unsigned int weightA = mWeights[contactA];
unsigned int weight_b = m_weights[contact_b]; unsigned int weightB = mWeights[contactB];
// Sort by weight and name. // Sort by weight and name.
return weight_a > weight_b || ( return weightA > weightB || (
weight_a == weight_b && weightA == weightB &&
contact_a->m_linphone_friend->getName() <= contact_b->m_linphone_friend->getName() contactA->mLinphoneFriend->getName() <= contactB->mLinphoneFriend->getName()
); );
} }
...@@ -105,12 +105,12 @@ float ContactsListProxyModel::computeStringWeight (const QString &string, float ...@@ -105,12 +105,12 @@ float ContactsListProxyModel::computeStringWeight (const QString &string, float
int offset = -1; int offset = -1;
// Search pattern. // Search pattern.
while ((index = string.indexOf(m_filter, index + 1, Qt::CaseInsensitive)) != -1) { while ((index = string.indexOf(mFilter, index + 1, Qt::CaseInsensitive)) != -1) {
// Search n chars between one separator and index. // Search n chars between one separator and index.
int tmp_offset = index - string.lastIndexOf(m_search_separators, index) - 1; int tmpOffset = index - string.lastIndexOf(mSearchSeparators, index) - 1;
if ((tmp_offset != -1 && tmp_offset < offset) || offset == -1) if ((tmpOffset != -1 && tmpOffset < offset) || offset == -1)
if ((offset = tmp_offset) == 0) break; if ((offset = tmpOffset) == 0) break;
} }
switch (offset) { switch (offset) {
...@@ -129,7 +129,7 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel *contact) ...@@ -129,7 +129,7 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel *contact)
float weight = computeStringWeight(contact->getVcardModel()->getUsername(), USERNAME_WEIGHT); float weight = computeStringWeight(contact->getVcardModel()->getUsername(), USERNAME_WEIGHT);
// Get all contact's addresses. // Get all contact's addresses.
const list<shared_ptr<linphone::Address> > addresses = contact->m_linphone_friend->getAddresses(); const list<shared_ptr<linphone::Address> > addresses = contact->mLinphoneFriend->getAddresses();
float size = static_cast<float>(addresses.size()); float size = static_cast<float>(addresses.size());
for (auto it = addresses.cbegin(); it != addresses.cend(); ++it) for (auto it = addresses.cbegin(); it != addresses.cend(); ++it)
...@@ -143,9 +143,9 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel *contact) ...@@ -143,9 +143,9 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel *contact)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void ContactsListProxyModel::setConnectedFilter (bool use_connected_filter) { void ContactsListProxyModel::setConnectedFilter (bool useConnectedFilter) {
if (use_connected_filter != m_use_connected_filter) { if (useConnectedFilter != mUseConnectedFilter) {
m_use_connected_filter = use_connected_filter; mUseConnectedFilter = useConnectedFilter;
invalidate(); invalidate();
} }
} }
...@@ -46,7 +46,7 @@ public: ...@@ -46,7 +46,7 @@ public:
Q_INVOKABLE void setFilter (const QString &pattern); Q_INVOKABLE void setFilter (const QString &pattern);
protected: protected:
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override; bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override;
bool lessThan (const QModelIndex &left, const QModelIndex &right) const override; bool lessThan (const QModelIndex &left, const QModelIndex &right) const override;
private: private:
...@@ -54,19 +54,19 @@ private: ...@@ -54,19 +54,19 @@ private:
float computeContactWeight (const ContactModel *contact) const; float computeContactWeight (const ContactModel *contact) const;
bool isConnectedFilterUsed () const { bool isConnectedFilterUsed () const {
return m_use_connected_filter; return mUseConnectedFilter;
} }
void setConnectedFilter (bool use_connected_filter); void setConnectedFilter (bool useConnectedFilter);
QString m_filter; QString mFilter;
bool m_use_connected_filter = false; bool mUseConnectedFilter = false;
// It's just a cache to save values computed by `filterAcceptsRow` // It's just a cache to save values computed by `filterAcceptsRow`
// and reused by `lessThan`. // and reused by `lessThan`.
mutable QHash<const ContactModel *, unsigned int> m_weights; mutable QHash<const ContactModel *, unsigned int> mWeights;
static const QRegExp m_search_separators; static const QRegExp mSearchSeparators;
}; };
#endif // CONTACTS_LIST_PROXY_MODEL_H_ #endif // CONTACTS_LIST_PROXY_MODEL_H_
...@@ -34,10 +34,10 @@ using namespace std; ...@@ -34,10 +34,10 @@ using namespace std;
void CoreHandlers::onAuthenticationRequested ( void CoreHandlers::onAuthenticationRequested (
const shared_ptr<linphone::Core> &, const shared_ptr<linphone::Core> &,
const shared_ptr<linphone::AuthInfo> &auth_info, const shared_ptr<linphone::AuthInfo> &authInfo,
linphone::AuthMethod linphone::AuthMethod
) { ) {
emit authenticationRequested(auth_info); emit authenticationRequested(authInfo);
} }
void CoreHandlers::onCallStateChanged ( void CoreHandlers::onCallStateChanged (
...@@ -57,9 +57,9 @@ void CoreHandlers::onMessageReceived ( ...@@ -57,9 +57,9 @@ void CoreHandlers::onMessageReceived (
const shared_ptr<linphone::ChatRoom> &, const shared_ptr<linphone::ChatRoom> &,
const shared_ptr<linphone::ChatMessage> &message const shared_ptr<linphone::ChatMessage> &message
) { ) {
const string content_type = message->getContentType(); const string contentType = message->getContentType();
if (content_type == "text/plain" || content_type == "application/vnd.gsma.rcs-ft-http+xml") { if (contentType == "text/plain" || contentType == "application/vnd.gsma.rcs-ft-http+xml") {
emit messageReceived(message); emit messageReceived(message);
const App *app = App::getInstance(); const App *app = App::getInstance();
...@@ -71,24 +71,24 @@ void CoreHandlers::onMessageReceived ( ...@@ -71,24 +71,24 @@ void CoreHandlers::onMessageReceived (
void CoreHandlers::onNotifyPresenceReceivedForUriOrTel ( void CoreHandlers::onNotifyPresenceReceivedForUriOrTel (
const shared_ptr<linphone::Core> &, const shared_ptr<linphone::Core> &,
const shared_ptr<linphone::Friend> &, const shared_ptr<linphone::Friend> &,
const string &uri_or_tel, const string &uriOrTel,
const shared_ptr<const linphone::PresenceModel> &presence_model const shared_ptr<const linphone::PresenceModel> &presenceModel
) { ) {
emit presenceReceived(::Utils::linphoneStringToQString(uri_or_tel), presence_model); emit presenceReceived(::Utils::linphoneStringToQString(uriOrTel), presenceModel);
} }
void CoreHandlers::onNotifyPresenceReceived ( void CoreHandlers::onNotifyPresenceReceived (
const shared_ptr<linphone::Core> &, const shared_ptr<linphone::Core> &,
const shared_ptr<linphone::Friend> &linphone_friend const shared_ptr<linphone::Friend> &linphoneFriend
) { ) {
linphone_friend->getData<ContactModel>("contact-model").refreshPresence(); linphoneFriend->getData<ContactModel>("contact-model").refreshPresence();
} }
void CoreHandlers::onRegistrationStateChanged ( void CoreHandlers::onRegistrationStateChanged (
const shared_ptr<linphone::Core> &, const shared_ptr<linphone::Core> &,
const shared_ptr<linphone::ProxyConfig> &proxy_config, const shared_ptr<linphone::ProxyConfig> &proxyConfig,
linphone::RegistrationState state, linphone::RegistrationState state,
const string & const string &
) { ) {
emit registrationStateChanged(proxy_config, state); emit registrationStateChanged(proxyConfig, state);
} }
...@@ -34,16 +34,16 @@ class CoreHandlers : ...@@ -34,16 +34,16 @@ class CoreHandlers :
Q_OBJECT; Q_OBJECT;
signals: signals:
void authenticationRequested (const std::shared_ptr<linphone::AuthInfo> &auth_info); void authenticationRequested (const std::shared_ptr<linphone::AuthInfo> &authInfo);
void callStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state); void callStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state);
void messageReceived (const std::shared_ptr<linphone::ChatMessage> &message); void messageReceived (const std::shared_ptr<linphone::ChatMessage> &message);
void presenceReceived (const QString &sip_address, const std::shared_ptr<const linphone::PresenceModel> &presence_model); void presenceReceived (const QString &sipAddress, const std::shared_ptr<const linphone::PresenceModel> &presenceModel);
void registrationStateChanged (const std::shared_ptr<linphone::ProxyConfig> &proxy_config, linphone::RegistrationState state); void registrationStateChanged (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig, linphone::RegistrationState state);
private: private:
void onAuthenticationRequested ( void onAuthenticationRequested (
const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::AuthInfo> &auth_info, const std::shared_ptr<linphone::AuthInfo> &authInfo,
linphone::AuthMethod method linphone::AuthMethod method
) override; ) override;
...@@ -62,19 +62,19 @@ private: ...@@ -62,19 +62,19 @@ private:
void onNotifyPresenceReceivedForUriOrTel ( void onNotifyPresenceReceivedForUriOrTel (
const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::Friend> &linphone_friend, const std::shared_ptr<linphone::Friend> &linphoneFriend,
const std::string &uri_or_tel, const std::string &uriOrTel,
const std::shared_ptr<const linphone::PresenceModel> &presence_model const std::shared_ptr<const linphone::PresenceModel> &presenceModel
) override; ) override;
void onNotifyPresenceReceived ( void onNotifyPresenceReceived (
const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::Friend> &linphone_friend const std::shared_ptr<linphone::Friend> &linphoneFriend
) override; ) override;
void onRegistrationStateChanged ( void onRegistrationStateChanged (
const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ProxyConfig> &proxy_config, const std::shared_ptr<linphone::ProxyConfig> &proxyConfig,
linphone::RegistrationState state, linphone::RegistrationState state,
const std::string &message const std::string &message
) override; ) override;
......
...@@ -34,42 +34,42 @@ using namespace std; ...@@ -34,42 +34,42 @@ using namespace std;
// ============================================================================= // =============================================================================
CoreManager *CoreManager::m_instance = nullptr; CoreManager *CoreManager::mInstance = nullptr;
CoreManager::CoreManager (QObject *parent, const QString &config_path) : QObject(parent), m_handlers(make_shared<CoreHandlers>()) { CoreManager::CoreManager (QObject *parent, const QString &configPath) : QObject(parent), mHandlers(make_shared<CoreHandlers>()) {
m_promise_build = QtConcurrent::run(this, &CoreManager::createLinphoneCore, config_path); mPromiseBuild = QtConcurrent::run(this, &CoreManager::createLinphoneCore, configPath);
QObject::connect( QObject::connect(
&m_promise_watcher, &QFutureWatcher<void>::finished, this, []() { &mPromiseWatcher, &QFutureWatcher<void>::finished, this, []() {
m_instance->m_calls_list_model = new CallsListModel(m_instance); mInstance->mCallsListModel = new CallsListModel(mInstance);
m_instance->m_contacts_list_model = new ContactsListModel(m_instance); mInstance->mContactsListModel = new ContactsListModel(mInstance);
m_instance->m_sip_addresses_model = new SipAddressesModel(m_instance); mInstance->mSipAddressesModel = new SipAddressesModel(mInstance);
m_instance->m_settings_model = new SettingsModel(m_instance); mInstance->mSettingsModel = new SettingsModel(mInstance);
m_instance->m_account_settings_model = new AccountSettingsModel(m_instance); mInstance->mAccountSettingsModel = new AccountSettingsModel(mInstance);
emit m_instance->linphoneCoreCreated(); emit mInstance->linphoneCoreCreated();
} }
); );
m_promise_watcher.setFuture(m_promise_build); mPromiseWatcher.setFuture(mPromiseBuild);
} }
void CoreManager::enableHandlers () { void CoreManager::enableHandlers () {
m_cbs_timer->start(); mCbsTimer->start();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CoreManager::init (QObject *parent, const QString &config_path) { void CoreManager::init (QObject *parent, const QString &configPath) {
if (m_instance) if (mInstance)
return; return;
m_instance = new CoreManager(parent, config_path); mInstance = new CoreManager(parent, configPath);
QTimer *timer = m_instance->m_cbs_timer = new QTimer(m_instance); QTimer *timer = mInstance->mCbsTimer = new QTimer(mInstance);
timer->setInterval(20); timer->setInterval(20);
QObject::connect(timer, &QTimer::timeout, m_instance, &CoreManager::iterate); QObject::connect(timer, &QTimer::timeout, mInstance, &CoreManager::iterate);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -80,27 +80,27 @@ VcardModel *CoreManager::createDetachedVcardModel () { ...@@ -80,27 +80,27 @@ VcardModel *CoreManager::createDetachedVcardModel () {
void CoreManager::forceRefreshRegisters () { void CoreManager::forceRefreshRegisters () {
qInfo() << QStringLiteral("Refresh registers."); qInfo() << QStringLiteral("Refresh registers.");
m_instance->m_core->refreshRegisters(); mInstance->mCore->refreshRegisters();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CoreManager::setDatabasesPaths () { void CoreManager::setDatabasesPaths () {
m_core->setFriendsDatabasePath(Paths::getFriendsListFilepath()); mCore->setFriendsDatabasePath(Paths::getFriendsListFilepath());
m_core->setCallLogsDatabasePath(Paths::getCallHistoryFilepath()); mCore->setCallLogsDatabasePath(Paths::getCallHistoryFilepath());
m_core->setChatDatabasePath(Paths::getMessageHistoryFilepath()); mCore->setChatDatabasePath(Paths::getMessageHistoryFilepath());
} }
void CoreManager::setOtherPaths () { void CoreManager::setOtherPaths () {
m_core->setZrtpSecretsFile(Paths::getZrtpSecretsFilepath()); mCore->setZrtpSecretsFile(Paths::getZrtpSecretsFilepath());
// This one is actually a database but it MUST be set after the zrtp secrets // This one is actually a database but it MUST be set after the zrtp secrets
// as it allows automatic migration from old version(secrets, xml) to new version (data, sqlite). // as it allows automatic migration from old version(secrets, xml) to new version (data, sqlite).
m_core->setZrtpCacheDatabasePath(Paths::getZrtpDataFilepath()); mCore->setZrtpCacheDatabasePath(Paths::getZrtpDataFilepath());
m_core->setUserCertificatesPath(Paths::getUserCertificatesDirpath()); mCore->setUserCertificatesPath(Paths::getUserCertificatesDirpath());
m_core->setRootCa(Paths::getRootCaFilepath()); mCore->setRootCa(Paths::getRootCaFilepath());
} }
void CoreManager::setResourcesPaths () { void CoreManager::setResourcesPaths () {
...@@ -111,7 +111,7 @@ void CoreManager::setResourcesPaths () { ...@@ -111,7 +111,7 @@ void CoreManager::setResourcesPaths () {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CoreManager::createLinphoneCore (const QString &config_path) { void CoreManager::createLinphoneCore (const QString &configPath) {
qInfo() << QStringLiteral("Launch async linphone core creation."); qInfo() << QStringLiteral("Launch async linphone core creation.");
// TODO: activate migration when ready to switch to this new version // TODO: activate migration when ready to switch to this new version
...@@ -119,10 +119,10 @@ void CoreManager::createLinphoneCore (const QString &config_path) { ...@@ -119,10 +119,10 @@ void CoreManager::createLinphoneCore (const QString &config_path) {
setResourcesPaths(); setResourcesPaths();
m_core = linphone::Factory::get()->createCore(m_handlers, Paths::getConfigFilepath(config_path), Paths::getFactoryConfigFilepath()); mCore = linphone::Factory::get()->createCore(mHandlers, Paths::getConfigFilepath(configPath), Paths::getFactoryConfigFilepath());
m_core->setVideoDisplayFilter("MSOGL"); mCore->setVideoDisplayFilter("MSOGL");
m_core->usePreviewWindow(true); mCore->usePreviewWindow(true);
setDatabasesPaths(); setDatabasesPaths();
setOtherPaths(); setOtherPaths();
...@@ -131,7 +131,7 @@ void CoreManager::createLinphoneCore (const QString &config_path) { ...@@ -131,7 +131,7 @@ void CoreManager::createLinphoneCore (const QString &config_path) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CoreManager::iterate () { void CoreManager::iterate () {
m_instance->lockVideoRender(); mInstance->lockVideoRender();
m_instance->m_core->iterate(); mInstance->mCore->iterate();
m_instance->unlockVideoRender(); mInstance->unlockVideoRender();
} }
...@@ -48,11 +48,11 @@ public: ...@@ -48,11 +48,11 @@ public:
void enableHandlers (); void enableHandlers ();
std::shared_ptr<linphone::Core> getCore () { std::shared_ptr<linphone::Core> getCore () {
return m_core; return mCore;
} }
std::shared_ptr<CoreHandlers> getHandlers () { std::shared_ptr<CoreHandlers> getHandlers () {
return m_handlers; return mHandlers;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -60,11 +60,11 @@ public: ...@@ -60,11 +60,11 @@ public:
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void lockVideoRender () { void lockVideoRender () {
m_mutex_video_render.lock(); mMutexVideoRender.lock();
} }
void unlockVideoRender () { void unlockVideoRender () {
m_mutex_video_render.unlock(); mMutexVideoRender.unlock();
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -72,33 +72,33 @@ public: ...@@ -72,33 +72,33 @@ public:
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
CallsListModel *getCallsListModel () const { CallsListModel *getCallsListModel () const {
return m_calls_list_model; return mCallsListModel;
} }
ContactsListModel *getContactsListModel () const { ContactsListModel *getContactsListModel () const {
return m_contacts_list_model; return mContactsListModel;
} }
SipAddressesModel *getSipAddressesModel () const { SipAddressesModel *getSipAddressesModel () const {
return m_sip_addresses_model; return mSipAddressesModel;
} }
SettingsModel *getSettingsModel () const { SettingsModel *getSettingsModel () const {
return m_settings_model; return mSettingsModel;
} }
AccountSettingsModel *getAccountSettingsModel () const { AccountSettingsModel *getAccountSettingsModel () const {
return m_account_settings_model; return mAccountSettingsModel;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Initialization. // Initialization.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
static void init (QObject *parent, const QString &config_path); static void init (QObject *parent, const QString &configPath);
static CoreManager *getInstance () { static CoreManager *getInstance () {
return m_instance; return mInstance;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -113,33 +113,33 @@ signals: ...@@ -113,33 +113,33 @@ signals:
void linphoneCoreCreated (); void linphoneCoreCreated ();
private: private:
CoreManager (QObject *parent, const QString &config_path); CoreManager (QObject *parent, const QString &configPath);
void setDatabasesPaths (); void setDatabasesPaths ();
void setOtherPaths (); void setOtherPaths ();
void setResourcesPaths (); void setResourcesPaths ();
void createLinphoneCore (const QString &config_path); void createLinphoneCore (const QString &configPath);
void iterate (); void iterate ();
std::shared_ptr<linphone::Core> m_core; std::shared_ptr<linphone::Core> mCore;
std::shared_ptr<CoreHandlers> m_handlers; std::shared_ptr<CoreHandlers> mHandlers;
CallsListModel *m_calls_list_model; CallsListModel *mCallsListModel;
ContactsListModel *m_contacts_list_model; ContactsListModel *mContactsListModel;
SipAddressesModel *m_sip_addresses_model; SipAddressesModel *mSipAddressesModel;
SettingsModel *m_settings_model; SettingsModel *mSettingsModel;
AccountSettingsModel *m_account_settings_model; AccountSettingsModel *mAccountSettingsModel;
QTimer *m_cbs_timer; QTimer *mCbsTimer;
QFuture<void> m_promise_build; QFuture<void> mPromiseBuild;
QFutureWatcher<void> m_promise_watcher; QFutureWatcher<void> mPromiseWatcher;
QMutex m_mutex_video_render; QMutex mMutexVideoRender;
static CoreManager *m_instance; static CoreManager *mInstance;
}; };
#endif // CORE_MANAGER_H_ #endif // CORE_MANAGER_H_
...@@ -59,10 +59,10 @@ using namespace std; ...@@ -59,10 +59,10 @@ using namespace std;
inline int getNotificationSize (const QObject &object, const char *property) { inline int getNotificationSize (const QObject &object, const char *property) {
QVariant variant = object.property(property); QVariant variant = object.property(property);
bool so_far_so_good; bool soFarSoGood;
int size = variant.toInt(&so_far_so_good); int size = variant.toInt(&soFarSoGood);
if (!so_far_so_good || size < 0) { if (!soFarSoGood || size < 0) {
qWarning() << "Unable to get notification size."; qWarning() << "Unable to get notification size.";
return -1; return -1;
} }
...@@ -89,13 +89,13 @@ Notifier::Notifier (QObject *parent) : ...@@ -89,13 +89,13 @@ Notifier::Notifier (QObject *parent) :
QQmlEngine *engine = App::getInstance()->getEngine(); QQmlEngine *engine = App::getInstance()->getEngine();
// Build components. // Build components.
m_components[Notifier::MessageReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_MESSAGE)); mComponents[Notifier::MessageReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_MESSAGE));
m_components[Notifier::FileMessageReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_FILE_MESSAGE)); mComponents[Notifier::FileMessageReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_FILE_MESSAGE));
m_components[Notifier::CallReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_CALL)); mComponents[Notifier::CallReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_CALL));
// Check errors. // Check errors.
for (int i = 0; i < Notifier::MaxNbTypes; ++i) { for (int i = 0; i < Notifier::MaxNbTypes; ++i) {
QQmlComponent *component = m_components[i]; QQmlComponent *component = mComponents[i];
if (component->isError()) { if (component->isError()) {
qWarning() << QStringLiteral("Errors found in `Notification` component %1:").arg(i) << component->errors(); qWarning() << QStringLiteral("Errors found in `Notification` component %1:").arg(i) << component->errors();
abort(); abort();
...@@ -105,37 +105,37 @@ Notifier::Notifier (QObject *parent) : ...@@ -105,37 +105,37 @@ Notifier::Notifier (QObject *parent) :
Notifier::~Notifier () { Notifier::~Notifier () {
for (int i = 0; i < Notifier::MaxNbTypes; ++i) for (int i = 0; i < Notifier::MaxNbTypes; ++i)
delete m_components[i]; delete mComponents[i];
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
QObject *Notifier::createNotification (Notifier::NotificationType type) { QObject *Notifier::createNotification (Notifier::NotificationType type) {
m_mutex.lock(); mMutex.lock();
Q_ASSERT(m_n_instances <= N_MAX_NOTIFICATIONS); Q_ASSERT(mInstancesNumber <= N_MAX_NOTIFICATIONS);
// Check existing instances. // Check existing instances.
if (m_n_instances == N_MAX_NOTIFICATIONS) { if (mInstancesNumber == N_MAX_NOTIFICATIONS) {
qWarning() << "Unable to create another notification"; qWarning() << "Unable to create another notification";
m_mutex.unlock(); mMutex.unlock();
return nullptr; return nullptr;
} }
// Create instance and set attributes. // Create instance and set attributes.
QObject *object = m_components[type]->create(); QObject *object = mComponents[type]->create();
int offset = getNotificationSize(*object, NOTIFICATION_PROPERTY_HEIGHT); int offset = getNotificationSize(*object, NOTIFICATION_PROPERTY_HEIGHT);
if (offset == -1 || !::setProperty(*object, NOTIFICATION_PROPERTY_OFFSET, m_offset)) { if (offset == -1 || !::setProperty(*object, NOTIFICATION_PROPERTY_OFFSET, mOffset)) {
delete object; delete object;
m_mutex.unlock(); mMutex.unlock();
return nullptr; return nullptr;
} }
m_offset = (offset + m_offset) + NOTIFICATION_SPACING; mOffset = (offset + mOffset) + NOTIFICATION_SPACING;
m_n_instances++; mInstancesNumber++;
m_mutex.unlock(); mMutex.unlock();
return object; return object;
} }
...@@ -166,13 +166,13 @@ void Notifier::showNotification (QObject *notification, int timeout) { ...@@ -166,13 +166,13 @@ void Notifier::showNotification (QObject *notification, int timeout) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void Notifier::deleteNotification (QVariant notification) { void Notifier::deleteNotification (QVariant notification) {
m_mutex.lock(); mMutex.lock();
QObject *instance = notification.value<QObject *>(); QObject *instance = notification.value<QObject *>();
// Notification marked destroyed. // Notification marked destroyed.
if (instance->property("__valid").isValid()) { if (instance->property("__valid").isValid()) {
m_mutex.unlock(); mMutex.unlock();
return; return;
} }
...@@ -181,13 +181,13 @@ void Notifier::deleteNotification (QVariant notification) { ...@@ -181,13 +181,13 @@ void Notifier::deleteNotification (QVariant notification) {
instance->setProperty("__valid", true); instance->setProperty("__valid", true);
instance->property(NOTIFICATION_PROPERTY_TIMER).value<QTimer *>()->stop(); instance->property(NOTIFICATION_PROPERTY_TIMER).value<QTimer *>()->stop();
m_n_instances--; mInstancesNumber--;
if (m_n_instances == 0) if (mInstancesNumber == 0)
m_offset = 0; mOffset = 0;
Q_ASSERT(m_n_instances >= 0); Q_ASSERT(mInstancesNumber >= 0);
m_mutex.unlock(); mMutex.unlock();
instance->deleteLater(); instance->deleteLater();
} }
......
...@@ -56,11 +56,11 @@ private: ...@@ -56,11 +56,11 @@ private:
QObject *createNotification (NotificationType type); QObject *createNotification (NotificationType type);
void showNotification (QObject *notification, int timeout); void showNotification (QObject *notification, int timeout);
QQmlComponent *m_components[MaxNbTypes]; QQmlComponent *mComponents[MaxNbTypes];
int m_offset = 0; int mOffset = 0;
int m_n_instances = 0; int mInstancesNumber = 0;
QMutex m_mutex; QMutex mMutex;
}; };
#endif // NOTIFIER_H_ #endif // NOTIFIER_H_
...@@ -59,21 +59,21 @@ AccountSettingsModel::AccountSettingsModel (QObject *parent) : QObject(parent) { ...@@ -59,21 +59,21 @@ AccountSettingsModel::AccountSettingsModel (QObject *parent) : QObject(parent) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool AccountSettingsModel::addOrUpdateProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxy_config) { bool AccountSettingsModel::addOrUpdateProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {
Q_ASSERT(proxy_config != nullptr); Q_ASSERT(proxyConfig != nullptr);
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
list<shared_ptr<linphone::ProxyConfig> > proxy_configs = core->getProxyConfigList(); list<shared_ptr<linphone::ProxyConfig> > proxyConfigs = core->getProxyConfigList();
if (find(proxy_configs.cbegin(), proxy_configs.cend(), proxy_config) != proxy_configs.cend()) { if (find(proxyConfigs.cbegin(), proxyConfigs.cend(), proxyConfig) != proxyConfigs.cend()) {
if (proxy_config->done() == -1) { if (proxyConfig->done() == -1) {
qWarning() << QStringLiteral("Unable to update proxy config: `%1`.") qWarning() << QStringLiteral("Unable to update proxy config: `%1`.")
.arg(::Utils::linphoneStringToQString(proxy_config->getIdentityAddress()->asString())); .arg(::Utils::linphoneStringToQString(proxyConfig->getIdentityAddress()->asString()));
return false; return false;
} }
} else if (core->addProxyConfig(proxy_config) == -1) { } else if (core->addProxyConfig(proxyConfig) == -1) {
qWarning() << QStringLiteral("Unable to add proxy config: `%1`.") qWarning() << QStringLiteral("Unable to add proxy config: `%1`.")
.arg(::Utils::linphoneStringToQString(proxy_config->getIdentityAddress()->asString())); .arg(::Utils::linphoneStringToQString(proxyConfig->getIdentityAddress()->asString()));
return false; return false;
} }
...@@ -82,51 +82,51 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (const shared_ptr<linphone::Pr ...@@ -82,51 +82,51 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (const shared_ptr<linphone::Pr
return true; return true;
} }
QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<linphone::ProxyConfig> &proxy_config) { QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {
Q_ASSERT(proxy_config != nullptr); Q_ASSERT(proxyConfig != nullptr);
QVariantMap map; QVariantMap map;
{ {
const shared_ptr<const linphone::Address> address = proxy_config->getIdentityAddress(); const shared_ptr<const linphone::Address> address = proxyConfig->getIdentityAddress();
map["sipAddress"] = address map["sipAddress"] = address
? ::Utils::linphoneStringToQString(proxy_config->getIdentityAddress()->asStringUriOnly()) ? ::Utils::linphoneStringToQString(proxyConfig->getIdentityAddress()->asStringUriOnly())
: ""; : "";
} }
map["serverAddress"] = ::Utils::linphoneStringToQString(proxy_config->getServerAddr()); map["serverAddress"] = ::Utils::linphoneStringToQString(proxyConfig->getServerAddr());
map["registrationDuration"] = proxy_config->getPublishExpires(); map["registrationDuration"] = proxyConfig->getPublishExpires();
map["transport"] = ::Utils::linphoneStringToQString(proxy_config->getTransport()); map["transport"] = ::Utils::linphoneStringToQString(proxyConfig->getTransport());
map["route"] = ::Utils::linphoneStringToQString(proxy_config->getRoute()); map["route"] = ::Utils::linphoneStringToQString(proxyConfig->getRoute());
map["contactParams"] = ::Utils::linphoneStringToQString(proxy_config->getContactParameters()); map["contactParams"] = ::Utils::linphoneStringToQString(proxyConfig->getContactParameters());
map["avpfInterval"] = proxy_config->getAvpfRrInterval(); map["avpfInterval"] = proxyConfig->getAvpfRrInterval();
map["registerEnabled"] = proxy_config->registerEnabled(); map["registerEnabled"] = proxyConfig->registerEnabled();
map["publishPresence"] = proxy_config->publishEnabled(); map["publishPresence"] = proxyConfig->publishEnabled();
map["avpfEnabled"] = proxy_config->getAvpfMode() == linphone::AVPFMode::AVPFModeEnabled; map["avpfEnabled"] = proxyConfig->getAvpfMode() == linphone::AVPFMode::AVPFModeEnabled;
map["registrationState"] = mapLinphoneRegistrationStateToUi(proxy_config->getState()); map["registrationState"] = mapLinphoneRegistrationStateToUi(proxyConfig->getState());
return map; return map;
} }
void AccountSettingsModel::setDefaultProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxy_config) { void AccountSettingsModel::setDefaultProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {
Q_ASSERT(proxy_config != nullptr); Q_ASSERT(proxyConfig != nullptr);
CoreManager::getInstance()->getCore()->setDefaultProxyConfig(proxy_config); CoreManager::getInstance()->getCore()->setDefaultProxyConfig(proxyConfig);
emit accountSettingsUpdated(); emit accountSettingsUpdated();
} }
void AccountSettingsModel::removeProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxy_config) { void AccountSettingsModel::removeProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {
Q_ASSERT(proxy_config != nullptr); Q_ASSERT(proxyConfig != nullptr);
CoreManager::getInstance()->getCore()->removeProxyConfig(proxy_config); CoreManager::getInstance()->getCore()->removeProxyConfig(proxyConfig);
emit accountSettingsUpdated(); emit accountSettingsUpdated();
} }
bool AccountSettingsModel::addOrUpdateProxyConfig ( bool AccountSettingsModel::addOrUpdateProxyConfig (
const shared_ptr<linphone::ProxyConfig> &proxy_config, const shared_ptr<linphone::ProxyConfig> &proxyConfig,
const QVariantMap &data const QVariantMap &data
) { ) {
Q_ASSERT(proxy_config != nullptr); Q_ASSERT(proxyConfig != nullptr);
QString literal = data["sipAddress"].toString(); QString literal = data["sipAddress"].toString();
...@@ -140,31 +140,31 @@ bool AccountSettingsModel::addOrUpdateProxyConfig ( ...@@ -140,31 +140,31 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
return false; return false;
} }
proxy_config->setIdentityAddress(address); proxyConfig->setIdentityAddress(address);
} }
// Server address. // Server address.
{ {
QString server_address = data["serverAddress"].toString(); QString serverAddress = data["serverAddress"].toString();
if (proxy_config->setServerAddr(::Utils::qStringToLinphoneString(server_address))) { if (proxyConfig->setServerAddr(::Utils::qStringToLinphoneString(serverAddress))) {
qWarning() << QStringLiteral("Unable to add server address: `%1`.").arg(server_address); qWarning() << QStringLiteral("Unable to add server address: `%1`.").arg(serverAddress);
return false; return false;
} }
} }
proxy_config->setPublishExpires(data["registrationDuration"].toInt()); proxyConfig->setPublishExpires(data["registrationDuration"].toInt());
proxy_config->setRoute(::Utils::qStringToLinphoneString(data["route"].toString())); proxyConfig->setRoute(::Utils::qStringToLinphoneString(data["route"].toString()));
proxy_config->setContactParameters(::Utils::qStringToLinphoneString(data["contactParams"].toString())); proxyConfig->setContactParameters(::Utils::qStringToLinphoneString(data["contactParams"].toString()));
proxy_config->setAvpfRrInterval(static_cast<uint8_t>(data["avpfInterval"].toInt())); proxyConfig->setAvpfRrInterval(static_cast<uint8_t>(data["avpfInterval"].toInt()));
proxy_config->enableRegister(data["registerEnabled"].toBool()); proxyConfig->enableRegister(data["registerEnabled"].toBool());
proxy_config->enablePublish(data["publishEnabled"].toBool()); proxyConfig->enablePublish(data["publishEnabled"].toBool());
proxy_config->setAvpfMode(data["avpfEnabled"].toBool() proxyConfig->setAvpfMode(data["avpfEnabled"].toBool()
? linphone::AVPFMode::AVPFModeEnabled ? linphone::AVPFMode::AVPFModeEnabled
: linphone::AVPFMode::AVPFModeDefault : linphone::AVPFMode::AVPFModeDefault
); );
return addOrUpdateProxyConfig(proxy_config); return addOrUpdateProxyConfig(proxyConfig);
} }
shared_ptr<linphone::ProxyConfig> AccountSettingsModel::createProxyConfig () { shared_ptr<linphone::ProxyConfig> AccountSettingsModel::createProxyConfig () {
...@@ -172,14 +172,14 @@ shared_ptr<linphone::ProxyConfig> AccountSettingsModel::createProxyConfig () { ...@@ -172,14 +172,14 @@ shared_ptr<linphone::ProxyConfig> AccountSettingsModel::createProxyConfig () {
} }
void AccountSettingsModel::addAuthInfo ( void AccountSettingsModel::addAuthInfo (
const shared_ptr<linphone::AuthInfo> &auth_info, const shared_ptr<linphone::AuthInfo> &authInfo,
const QString &password, const QString &password,
const QString &user_id const QString &userId
) { ) {
auth_info->setPasswd(::Utils::qStringToLinphoneString(password)); authInfo->setPasswd(::Utils::qStringToLinphoneString(password));
auth_info->setUserid(::Utils::qStringToLinphoneString(user_id)); authInfo->setUserid(::Utils::qStringToLinphoneString(userId));
CoreManager::getInstance()->getCore()->addAuthInfo(auth_info); CoreManager::getInstance()->getCore()->addAuthInfo(authInfo);
} }
void AccountSettingsModel::eraseAllPasswords () { void AccountSettingsModel::eraseAllPasswords () {
...@@ -190,22 +190,22 @@ void AccountSettingsModel::eraseAllPasswords () { ...@@ -190,22 +190,22 @@ void AccountSettingsModel::eraseAllPasswords () {
QString AccountSettingsModel::getUsername () const { QString AccountSettingsModel::getUsername () const {
shared_ptr<const linphone::Address> address = getUsedSipAddress(); shared_ptr<const linphone::Address> address = getUsedSipAddress();
const string &display_name = address->getDisplayName(); const string &displayName = address->getDisplayName();
return ::Utils::linphoneStringToQString( return ::Utils::linphoneStringToQString(
display_name.empty() ? address->getUsername() : display_name displayName.empty() ? address->getUsername() : displayName
); );
} }
void AccountSettingsModel::setUsername (const QString &username) { void AccountSettingsModel::setUsername (const QString &username) {
shared_ptr<const linphone::Address> address = getUsedSipAddress(); shared_ptr<const linphone::Address> address = getUsedSipAddress();
shared_ptr<linphone::Address> new_address = address->clone(); shared_ptr<linphone::Address> newAddress = address->clone();
if (new_address->setDisplayName(::Utils::qStringToLinphoneString(username))) { if (newAddress->setDisplayName(::Utils::qStringToLinphoneString(username))) {
qWarning() << QStringLiteral("Unable to set displayName on sip address: `%1`.") qWarning() << QStringLiteral("Unable to set displayName on sip address: `%1`.")
.arg(::Utils::linphoneStringToQString(new_address->asStringUriOnly())); .arg(::Utils::linphoneStringToQString(newAddress->asStringUriOnly()));
} else { } else {
setUsedSipAddress(new_address); setUsedSipAddress(newAddress);
} }
emit accountSettingsUpdated(); emit accountSettingsUpdated();
...@@ -216,8 +216,8 @@ QString AccountSettingsModel::getSipAddress () const { ...@@ -216,8 +216,8 @@ QString AccountSettingsModel::getSipAddress () const {
} }
AccountSettingsModel::RegistrationState AccountSettingsModel::getRegistrationState () const { AccountSettingsModel::RegistrationState AccountSettingsModel::getRegistrationState () const {
shared_ptr<linphone::ProxyConfig> proxy_config = CoreManager::getInstance()->getCore()->getDefaultProxyConfig(); shared_ptr<linphone::ProxyConfig> proxyConfig = CoreManager::getInstance()->getCore()->getDefaultProxyConfig();
return proxy_config ? mapLinphoneRegistrationStateToUi(proxy_config->getState()) : RegistrationStateNotRegistered; return proxyConfig ? mapLinphoneRegistrationStateToUi(proxyConfig->getState()) : RegistrationStateNotRegistered;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -274,10 +274,10 @@ QVariantList AccountSettingsModel::getAccounts () const { ...@@ -274,10 +274,10 @@ QVariantList AccountSettingsModel::getAccounts () const {
accounts << account; accounts << account;
} }
for (const auto &proxy_config : core->getProxyConfigList()) { for (const auto &proxyConfig : core->getProxyConfigList()) {
QVariantMap account; QVariantMap account;
account["sipAddress"] = ::Utils::linphoneStringToQString(proxy_config->getIdentityAddress()->asStringUriOnly()); account["sipAddress"] = ::Utils::linphoneStringToQString(proxyConfig->getIdentityAddress()->asStringUriOnly());
account["proxyConfig"].setValue(proxy_config); account["proxyConfig"].setValue(proxyConfig);
accounts << account; accounts << account;
} }
...@@ -288,16 +288,16 @@ QVariantList AccountSettingsModel::getAccounts () const { ...@@ -288,16 +288,16 @@ QVariantList AccountSettingsModel::getAccounts () const {
void AccountSettingsModel::setUsedSipAddress (const shared_ptr<const linphone::Address> &address) { void AccountSettingsModel::setUsedSipAddress (const shared_ptr<const linphone::Address> &address) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::ProxyConfig> proxy_config = core->getDefaultProxyConfig(); shared_ptr<linphone::ProxyConfig> proxyConfig = core->getDefaultProxyConfig();
proxy_config ? proxy_config->setIdentityAddress(address) : core->setPrimaryContact(address->asString()); proxyConfig ? proxyConfig->setIdentityAddress(address) : core->setPrimaryContact(address->asString());
} }
shared_ptr<const linphone::Address> AccountSettingsModel::getUsedSipAddress () const { shared_ptr<const linphone::Address> AccountSettingsModel::getUsedSipAddress () const {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::ProxyConfig> proxy_config = core->getDefaultProxyConfig(); shared_ptr<linphone::ProxyConfig> proxyConfig = core->getDefaultProxyConfig();
return proxy_config ? proxy_config->getIdentityAddress() : core->getPrimaryContactParsed(); return proxyConfig ? proxyConfig->getIdentityAddress() : core->getPrimaryContactParsed();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -55,21 +55,21 @@ public: ...@@ -55,21 +55,21 @@ public:
AccountSettingsModel (QObject *parent = Q_NULLPTR); AccountSettingsModel (QObject *parent = Q_NULLPTR);
~AccountSettingsModel () = default; ~AccountSettingsModel () = default;
bool addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config); bool addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
Q_INVOKABLE QVariantMap getProxyConfigDescription (const std::shared_ptr<linphone::ProxyConfig> &proxy_config); Q_INVOKABLE QVariantMap getProxyConfigDescription (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config); Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
Q_INVOKABLE bool addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config, const QVariantMap &data); Q_INVOKABLE bool addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig, const QVariantMap &data);
Q_INVOKABLE void removeProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config); Q_INVOKABLE void removeProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
Q_INVOKABLE std::shared_ptr<linphone::ProxyConfig> createProxyConfig (); Q_INVOKABLE std::shared_ptr<linphone::ProxyConfig> createProxyConfig ();
Q_INVOKABLE void addAuthInfo ( Q_INVOKABLE void addAuthInfo (
const std::shared_ptr<linphone::AuthInfo> &auth_info, const std::shared_ptr<linphone::AuthInfo> &authInfo,
const QString &password, const QString &password,
const QString &user_id const QString &userId
); );
Q_INVOKABLE void eraseAllPasswords (); Q_INVOKABLE void eraseAllPasswords ();
...@@ -105,7 +105,7 @@ private: ...@@ -105,7 +105,7 @@ private:
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void handleRegistrationStateChanged ( void handleRegistrationStateChanged (
const std::shared_ptr<linphone::ProxyConfig> &proxy_config, const std::shared_ptr<linphone::ProxyConfig> &proxyConfig,
linphone::RegistrationState state linphone::RegistrationState state
); );
}; };
......
...@@ -35,7 +35,7 @@ using namespace std; ...@@ -35,7 +35,7 @@ using namespace std;
const string SettingsModel::UI_SECTION("ui"); const string SettingsModel::UI_SECTION("ui");
SettingsModel::SettingsModel (QObject *parent) : QObject(parent) { SettingsModel::SettingsModel (QObject *parent) : QObject(parent) {
m_config = CoreManager::getInstance()->getCore()->getConfig(); mConfig = CoreManager::getInstance()->getCore()->getConfig();
} }
// ============================================================================= // =============================================================================
...@@ -103,13 +103,13 @@ QString SettingsModel::getRingPath () const { ...@@ -103,13 +103,13 @@ QString SettingsModel::getRingPath () const {
} }
void SettingsModel::setRingPath (const QString &path) { void SettingsModel::setRingPath (const QString &path) {
QString cleaned_path = QDir::cleanPath(path); QString cleanedPath = QDir::cleanPath(path);
CoreManager::getInstance()->getCore()->setRing( CoreManager::getInstance()->getCore()->setRing(
::Utils::qStringToLinphoneString(cleaned_path) ::Utils::qStringToLinphoneString(cleanedPath)
); );
emit ringPathChanged(cleaned_path); emit ringPathChanged(cleanedPath);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -182,22 +182,22 @@ void SettingsModel::setVideoFramerate (int framerate) { ...@@ -182,22 +182,22 @@ void SettingsModel::setVideoFramerate (int framerate) {
// ============================================================================= // =============================================================================
int SettingsModel::getAutoAnswerDelay () const { int SettingsModel::getAutoAnswerDelay () const {
return m_config->getInt(UI_SECTION, "auto_answer_delay", 0); return mConfig->getInt(UI_SECTION, "auto_answer_delay", 0);
} }
void SettingsModel::setAutoAnswerDelay (int delay) { void SettingsModel::setAutoAnswerDelay (int delay) {
m_config->setInt(UI_SECTION, "auto_answer_delay", delay); mConfig->setInt(UI_SECTION, "auto_answer_delay", delay);
emit autoAnswerDelayChanged(delay); emit autoAnswerDelayChanged(delay);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool SettingsModel::getAutoAnswerStatus () const { bool SettingsModel::getAutoAnswerStatus () const {
return !!m_config->getInt(UI_SECTION, "auto_answer", 0); return !!mConfig->getInt(UI_SECTION, "auto_answer", 0);
} }
void SettingsModel::setAutoAnswerStatus (bool status) { void SettingsModel::setAutoAnswerStatus (bool status) {
m_config->setInt(UI_SECTION, "auto_answer", status); mConfig->setInt(UI_SECTION, "auto_answer", status);
emit autoAnswerStatusChanged(status); emit autoAnswerStatusChanged(status);
} }
...@@ -429,10 +429,10 @@ bool SettingsModel::getIceEnabled () const { ...@@ -429,10 +429,10 @@ bool SettingsModel::getIceEnabled () const {
} }
void SettingsModel::setIceEnabled (bool status) { void SettingsModel::setIceEnabled (bool status) {
shared_ptr<linphone::NatPolicy> nat_policy = CoreManager::getInstance()->getCore()->getNatPolicy(); shared_ptr<linphone::NatPolicy> natPolicy = CoreManager::getInstance()->getCore()->getNatPolicy();
nat_policy->enableIce(status); natPolicy->enableIce(status);
nat_policy->enableStun(status); natPolicy->enableStun(status);
emit iceEnabledChanged(status); emit iceEnabledChanged(status);
} }
...@@ -456,9 +456,9 @@ QString SettingsModel::getStunServer () const { ...@@ -456,9 +456,9 @@ QString SettingsModel::getStunServer () const {
); );
} }
void SettingsModel::setStunServer (const QString &stun_server) { void SettingsModel::setStunServer (const QString &stunServer) {
CoreManager::getInstance()->getCore()->getNatPolicy()->setStunServer( CoreManager::getInstance()->getCore()->getNatPolicy()->setStunServer(
::Utils::qStringToLinphoneString(stun_server) ::Utils::qStringToLinphoneString(stunServer)
); );
} }
...@@ -482,28 +482,28 @@ void SettingsModel::setTurnUser (const QString &user) { ...@@ -482,28 +482,28 @@ void SettingsModel::setTurnUser (const QString &user) {
QString SettingsModel::getTurnPassword () const { QString SettingsModel::getTurnPassword () const {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::NatPolicy> nat_policy = core->getNatPolicy(); shared_ptr<linphone::NatPolicy> natPolicy = core->getNatPolicy();
shared_ptr<const linphone::AuthInfo> auth_info = core->findAuthInfo(nat_policy->getStunServerUsername(), "", ""); shared_ptr<const linphone::AuthInfo> authInfo = core->findAuthInfo(natPolicy->getStunServerUsername(), "", "");
return auth_info ? ::Utils::linphoneStringToQString(auth_info->getPasswd()) : ""; return authInfo ? ::Utils::linphoneStringToQString(authInfo->getPasswd()) : "";
} }
void SettingsModel::setTurnPassword (const QString &password) { void SettingsModel::setTurnPassword (const QString &password) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::NatPolicy> nat_policy = core->getNatPolicy(); shared_ptr<linphone::NatPolicy> natPolicy = core->getNatPolicy();
const string &username = nat_policy->getStunServerUsername(); const string &username = natPolicy->getStunServerUsername();
shared_ptr<const linphone::AuthInfo> auth_info = core->findAuthInfo(username, "", ""); shared_ptr<const linphone::AuthInfo> authInfo = core->findAuthInfo(username, "", "");
if (auth_info) { if (authInfo) {
shared_ptr<linphone::AuthInfo> auth_info_clone = auth_info->clone(); shared_ptr<linphone::AuthInfo> clonedAuthInfo = authInfo->clone();
auth_info_clone->setPasswd(::Utils::qStringToLinphoneString(password)); clonedAuthInfo->setPasswd(::Utils::qStringToLinphoneString(password));
core->removeAuthInfo(auth_info); core->removeAuthInfo(authInfo);
core->addAuthInfo(auth_info_clone); core->addAuthInfo(clonedAuthInfo);
} else { } else {
auth_info = linphone::Factory::get()->createAuthInfo(username, username, ::Utils::qStringToLinphoneString(password), "", "", ""); authInfo = linphone::Factory::get()->createAuthInfo(username, username, ::Utils::qStringToLinphoneString(password), "", "", "");
core->addAuthInfo(auth_info); core->addAuthInfo(authInfo);
} }
emit turnPasswordChanged(password); emit turnPasswordChanged(password);
...@@ -545,16 +545,16 @@ void SettingsModel::setDscpVideo (int dscp) { ...@@ -545,16 +545,16 @@ void SettingsModel::setDscpVideo (int dscp) {
QString SettingsModel::getSavedScreenshotsFolder () const { QString SettingsModel::getSavedScreenshotsFolder () const {
return QDir::cleanPath( return QDir::cleanPath(
::Utils::linphoneStringToQString( ::Utils::linphoneStringToQString(
m_config->getString(UI_SECTION, "saved_screenshots_folder", Paths::getCapturesDirpath()) mConfig->getString(UI_SECTION, "saved_screenshots_folder", Paths::getCapturesDirpath())
) )
) + QDir::separator(); ) + QDir::separator();
} }
void SettingsModel::setSavedScreenshotsFolder (const QString &folder) { void SettingsModel::setSavedScreenshotsFolder (const QString &folder) {
QString cleaned_folder = QDir::cleanPath(folder) + QDir::separator(); QString cleanedFolder = QDir::cleanPath(folder) + QDir::separator();
m_config->setString(UI_SECTION, "saved_screenshots_folder", ::Utils::qStringToLinphoneString(cleaned_folder)); mConfig->setString(UI_SECTION, "saved_screenshots_folder", ::Utils::qStringToLinphoneString(cleanedFolder));
emit savedScreenshotsFolderChanged(cleaned_folder); emit savedScreenshotsFolderChanged(cleanedFolder);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -562,7 +562,7 @@ void SettingsModel::setSavedScreenshotsFolder (const QString &folder) { ...@@ -562,7 +562,7 @@ void SettingsModel::setSavedScreenshotsFolder (const QString &folder) {
QString SettingsModel::getSavedVideosFolder () const { QString SettingsModel::getSavedVideosFolder () const {
return QDir::cleanPath( return QDir::cleanPath(
::Utils::linphoneStringToQString( ::Utils::linphoneStringToQString(
m_config->getString(UI_SECTION, "saved_videos_folder", Paths::getCapturesDirpath()) mConfig->getString(UI_SECTION, "saved_videos_folder", Paths::getCapturesDirpath())
) )
) + QDir::separator(); ) + QDir::separator();
} }
...@@ -570,6 +570,6 @@ QString SettingsModel::getSavedVideosFolder () const { ...@@ -570,6 +570,6 @@ QString SettingsModel::getSavedVideosFolder () const {
void SettingsModel::setSavedVideosFolder (const QString &folder) { void SettingsModel::setSavedVideosFolder (const QString &folder) {
QString _folder = QDir::cleanPath(folder) + QDir::separator(); QString _folder = QDir::cleanPath(folder) + QDir::separator();
m_config->setString(UI_SECTION, "saved_videos_folder", ::Utils::qStringToLinphoneString(_folder)); mConfig->setString(UI_SECTION, "saved_videos_folder", ::Utils::qStringToLinphoneString(_folder));
emit savedVideosFolderChanged(_folder); emit savedVideosFolderChanged(_folder);
} }
...@@ -220,7 +220,7 @@ public: ...@@ -220,7 +220,7 @@ public:
void setTurnEnabled (bool status); void setTurnEnabled (bool status);
QString getStunServer () const; QString getStunServer () const;
void setStunServer (const QString &stun_server); void setStunServer (const QString &stunServer);
QString getTurnUser () const; QString getTurnUser () const;
void setTurnUser (const QString &user); void setTurnUser (const QString &user);
...@@ -315,7 +315,7 @@ signals: ...@@ -315,7 +315,7 @@ signals:
void savedVideosFolderChanged (const QString &folder); void savedVideosFolderChanged (const QString &folder);
private: private:
std::shared_ptr<linphone::Config> m_config; std::shared_ptr<linphone::Config> mConfig;
}; };
#endif // SETTINGS_MODEL_H_ #endif // SETTINGS_MODEL_H_
...@@ -24,30 +24,30 @@ ...@@ -24,30 +24,30 @@
// ============================================================================= // =============================================================================
SipAddressObserver::SipAddressObserver (const QString &sip_address) { SipAddressObserver::SipAddressObserver (const QString &sipAddress) {
m_sip_address = sip_address; mSipAddress = sipAddress;
} }
void SipAddressObserver::setContact (ContactModel *contact) { void SipAddressObserver::setContact (ContactModel *contact) {
if (contact == m_contact) if (contact == mContact)
return; return;
m_contact = contact; mContact = contact;
emit contactChanged(contact); emit contactChanged(contact);
} }
void SipAddressObserver::setPresenceStatus (const Presence::PresenceStatus &presence_status) { void SipAddressObserver::setPresenceStatus (const Presence::PresenceStatus &presenceStatus) {
if (presence_status == m_presence_status) if (presenceStatus == mPresenceStatus)
return; return;
m_presence_status = presence_status; mPresenceStatus = presenceStatus;
emit presenceStatusChanged(presence_status); emit presenceStatusChanged(presenceStatus);
} }
void SipAddressObserver::setUnreadMessagesCount (int unread_messages_count) { void SipAddressObserver::setUnreadMessagesCount (int unreadMessagesCount) {
if (unread_messages_count == m_unread_messages_count) if (unreadMessagesCount == mUnreadMessagesCount)
return; return;
m_unread_messages_count = unread_messages_count; mUnreadMessagesCount = unreadMessagesCount;
emit unreadMessagesCountChanged(unread_messages_count); emit unreadMessagesCountChanged(unreadMessagesCount);
} }
...@@ -39,7 +39,7 @@ class SipAddressObserver : public QObject { ...@@ -39,7 +39,7 @@ class SipAddressObserver : public QObject {
Q_PROPERTY(int unreadMessagesCount READ getUnreadMessagesCount NOTIFY unreadMessagesCountChanged); Q_PROPERTY(int unreadMessagesCount READ getUnreadMessagesCount NOTIFY unreadMessagesCountChanged);
public: public:
SipAddressObserver (const QString &sip_address); SipAddressObserver (const QString &sipAddress);
~SipAddressObserver () = default; ~SipAddressObserver () = default;
signals: signals:
...@@ -49,13 +49,13 @@ signals: ...@@ -49,13 +49,13 @@ signals:
private: private:
QString getSipAddress () const { QString getSipAddress () const {
return m_sip_address; return mSipAddress;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
ContactModel *getContact () const { ContactModel *getContact () const {
return m_contact; return mContact;
} }
void setContact (ContactModel *contact); void setContact (ContactModel *contact);
...@@ -63,24 +63,24 @@ private: ...@@ -63,24 +63,24 @@ private:
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
Presence::PresenceStatus getPresenceStatus () const { Presence::PresenceStatus getPresenceStatus () const {
return m_presence_status; return mPresenceStatus;
} }
void setPresenceStatus (const Presence::PresenceStatus &presence_status); void setPresenceStatus (const Presence::PresenceStatus &presenceStatus);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
int getUnreadMessagesCount () const { int getUnreadMessagesCount () const {
return m_unread_messages_count; return mUnreadMessagesCount;
} }
void setUnreadMessagesCount (int unread_messages_count); void setUnreadMessagesCount (int unreadMessagesCount);
QString m_sip_address; QString mSipAddress;
ContactModel *m_contact = nullptr; ContactModel *mContact = nullptr;
Presence::PresenceStatus m_presence_status = Presence::PresenceStatus::Offline; Presence::PresenceStatus mPresenceStatus = Presence::PresenceStatus::Offline;
int m_unread_messages_count = 0; int mUnreadMessagesCount = 0;
}; };
Q_DECLARE_METATYPE(SipAddressObserver *); Q_DECLARE_METATYPE(SipAddressObserver *);
......
...@@ -37,7 +37,7 @@ using namespace std; ...@@ -37,7 +37,7 @@ using namespace std;
SipAddressesModel::SipAddressesModel (QObject *parent) : QAbstractListModel(parent) { SipAddressesModel::SipAddressesModel (QObject *parent) : QAbstractListModel(parent) {
initSipAddresses(); initSipAddresses();
m_core_handlers = CoreManager::getInstance()->getHandlers(); mCoreHandlers = CoreManager::getInstance()->getHandlers();
ContactsListModel *contacts = CoreManager::getInstance()->getContactsListModel(); ContactsListModel *contacts = CoreManager::getInstance()->getContactsListModel();
...@@ -47,15 +47,15 @@ SipAddressesModel::SipAddressesModel (QObject *parent) : QAbstractListModel(pare ...@@ -47,15 +47,15 @@ SipAddressesModel::SipAddressesModel (QObject *parent) : QAbstractListModel(pare
QObject::connect(contacts, &ContactsListModel::sipAddressAdded, this, &SipAddressesModel::handleSipAddressAdded); QObject::connect(contacts, &ContactsListModel::sipAddressAdded, this, &SipAddressesModel::handleSipAddressAdded);
QObject::connect(contacts, &ContactsListModel::sipAddressRemoved, this, &SipAddressesModel::handleSipAddressRemoved); QObject::connect(contacts, &ContactsListModel::sipAddressRemoved, this, &SipAddressesModel::handleSipAddressRemoved);
QObject::connect(&(*m_core_handlers), &CoreHandlers::messageReceived, this, &SipAddressesModel::handleMessageReceived); QObject::connect(&(*mCoreHandlers), &CoreHandlers::messageReceived, this, &SipAddressesModel::handleMessageReceived);
QObject::connect(&(*m_core_handlers), &CoreHandlers::callStateChanged, this, &SipAddressesModel::handleCallStateChanged); QObject::connect(&(*mCoreHandlers), &CoreHandlers::callStateChanged, this, &SipAddressesModel::handleCallStateChanged);
QObject::connect(&(*m_core_handlers), &CoreHandlers::presenceReceived, this, &SipAddressesModel::handlePresenceReceived); QObject::connect(&(*mCoreHandlers), &CoreHandlers::presenceReceived, this, &SipAddressesModel::handlePresenceReceived);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
int SipAddressesModel::rowCount (const QModelIndex &) const { int SipAddressesModel::rowCount (const QModelIndex &) const {
return m_refs.count(); return mRefs.count();
} }
QHash<int, QByteArray> SipAddressesModel::roleNames () const { QHash<int, QByteArray> SipAddressesModel::roleNames () const {
...@@ -67,34 +67,34 @@ QHash<int, QByteArray> SipAddressesModel::roleNames () const { ...@@ -67,34 +67,34 @@ QHash<int, QByteArray> SipAddressesModel::roleNames () const {
QVariant SipAddressesModel::data (const QModelIndex &index, int role) const { QVariant SipAddressesModel::data (const QModelIndex &index, int role) const {
int row = index.row(); int row = index.row();
if (!index.isValid() || row < 0 || row >= m_refs.count()) if (!index.isValid() || row < 0 || row >= mRefs.count())
return QVariant(); return QVariant();
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
return QVariant::fromValue(*m_refs[row]); return QVariant::fromValue(*mRefs[row]);
return QVariant(); return QVariant();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void SipAddressesModel::connectToChatModel (ChatModel *chat_model) { void SipAddressesModel::connectToChatModel (ChatModel *chatModel) {
QObject::connect(chat_model, &ChatModel::allEntriesRemoved, this, [this, chat_model] { QObject::connect(chatModel, &ChatModel::allEntriesRemoved, this, [this, chatModel] {
handleAllEntriesRemoved(chat_model->getSipAddress()); handleAllEntriesRemoved(chatModel->getSipAddress());
}); });
QObject::connect(chat_model, &ChatModel::messageSent, this, &SipAddressesModel::handleMessageSent); QObject::connect(chatModel, &ChatModel::messageSent, this, &SipAddressesModel::handleMessageSent);
QObject::connect(chat_model, &ChatModel::messagesCountReset, this, [this, chat_model] { QObject::connect(chatModel, &ChatModel::messagesCountReset, this, [this, chatModel] {
handleMessagesCountReset(chat_model->getSipAddress()); handleMessagesCountReset(chatModel->getSipAddress());
}); });
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
ContactModel *SipAddressesModel::mapSipAddressToContact (const QString &sip_address) const { ContactModel *SipAddressesModel::mapSipAddressToContact (const QString &sipAddress) const {
auto it = m_sip_addresses.find(sip_address); auto it = mSipAddresses.find(sipAddress);
if (it == m_sip_addresses.end()) if (it == mSipAddresses.end())
return nullptr; return nullptr;
return it->value("contact").value<ContactModel *>(); return it->value("contact").value<ContactModel *>();
...@@ -102,12 +102,12 @@ ContactModel *SipAddressesModel::mapSipAddressToContact (const QString &sip_addr ...@@ -102,12 +102,12 @@ ContactModel *SipAddressesModel::mapSipAddressToContact (const QString &sip_addr
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
SipAddressObserver *SipAddressesModel::getSipAddressObserver (const QString &sip_address) { SipAddressObserver *SipAddressesModel::getSipAddressObserver (const QString &sipAddress) {
SipAddressObserver *model = new SipAddressObserver(sip_address); SipAddressObserver *model = new SipAddressObserver(sipAddress);
{ {
auto it = m_sip_addresses.find(sip_address); auto it = mSipAddresses.find(sipAddress);
if (it != m_sip_addresses.end()) { if (it != mSipAddresses.end()) {
model->setContact(it->value("contact").value<ContactModel *>()); model->setContact(it->value("contact").value<ContactModel *>());
model->setPresenceStatus( model->setPresenceStatus(
it->value("presenceStatus", Presence::PresenceStatus::Offline).value<Presence::PresenceStatus>() it->value("presenceStatus", Presence::PresenceStatus::Offline).value<Presence::PresenceStatus>()
...@@ -118,12 +118,12 @@ SipAddressObserver *SipAddressesModel::getSipAddressObserver (const QString &sip ...@@ -118,12 +118,12 @@ SipAddressObserver *SipAddressesModel::getSipAddressObserver (const QString &sip
} }
} }
m_observers.insert(sip_address, model); mObservers.insert(sipAddress, model);
QObject::connect( QObject::connect(
model, &SipAddressObserver::destroyed, this, [this, model]() { model, &SipAddressObserver::destroyed, this, [this, model]() {
const QString &sip_address = model->getSipAddress(); const QString &sipAddress = model->getSipAddress();
if (m_observers.remove(sip_address, model) == 0) if (mObservers.remove(sipAddress, model) == 0)
qWarning() << QStringLiteral("Unable to remove sip address `%1` from observers.").arg(sip_address); qWarning() << QStringLiteral("Unable to remove sip address `%1` from observers.").arg(sipAddress);
} }
); );
...@@ -132,17 +132,17 @@ SipAddressObserver *SipAddressesModel::getSipAddressObserver (const QString &sip ...@@ -132,17 +132,17 @@ SipAddressObserver *SipAddressesModel::getSipAddressObserver (const QString &sip
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
QString SipAddressesModel::interpretUrl (const QString &sip_address) const { QString SipAddressesModel::interpretUrl (const QString &sipAddress) const {
shared_ptr<linphone::Address> l_address = CoreManager::getInstance()->getCore()->interpretUrl( shared_ptr<linphone::Address> lAddress = CoreManager::getInstance()->getCore()->interpretUrl(
::Utils::qStringToLinphoneString(sip_address) ::Utils::qStringToLinphoneString(sipAddress)
); );
return l_address ? ::Utils::linphoneStringToQString(l_address->asStringUriOnly()) : ""; return lAddress ? ::Utils::linphoneStringToQString(lAddress->asStringUriOnly()) : "";
} }
QString SipAddressesModel::getTransportFromSipAddress (const QString &sip_address) const { QString SipAddressesModel::getTransportFromSipAddress (const QString &sipAddress) const {
const shared_ptr<const linphone::Address> address = linphone::Factory::get()->createAddress( const shared_ptr<const linphone::Address> address = linphone::Factory::get()->createAddress(
::Utils::qStringToLinphoneString(sip_address) ::Utils::qStringToLinphoneString(sipAddress)
); );
if (!address) if (!address)
...@@ -162,20 +162,20 @@ QString SipAddressesModel::getTransportFromSipAddress (const QString &sip_addres ...@@ -162,20 +162,20 @@ QString SipAddressesModel::getTransportFromSipAddress (const QString &sip_addres
return QStringLiteral(""); return QStringLiteral("");
} }
QString SipAddressesModel::addTransportToSipAddress (const QString &sip_address, const QString &transport) const { QString SipAddressesModel::addTransportToSipAddress (const QString &sipAddress, const QString &transport) const {
shared_ptr<linphone::Address> address = linphone::Factory::get()->createAddress( shared_ptr<linphone::Address> address = linphone::Factory::get()->createAddress(
::Utils::qStringToLinphoneString(sip_address) ::Utils::qStringToLinphoneString(sipAddress)
); );
if (!address) if (!address)
return ""; return "";
QString _transport = transport.toUpper(); QString transportStr = transport.toUpper();
if (_transport == "TCP") if (transportStr == "TCP")
address->setTransport(linphone::TransportType::TransportTypeTcp); address->setTransport(linphone::TransportType::TransportTypeTcp);
else if (_transport == "UDP") else if (transportStr == "UDP")
address->setTransport(linphone::TransportType::TransportTypeUdp); address->setTransport(linphone::TransportType::TransportTypeUdp);
else if (_transport == "TLS") else if (transportStr == "TLS")
address->setTransport(linphone::TransportType::TransportTypeTls); address->setTransport(linphone::TransportType::TransportTypeTls);
else else
address->setTransport(linphone::TransportType::TransportTypeDtls); address->setTransport(linphone::TransportType::TransportTypeDtls);
...@@ -183,9 +183,9 @@ QString SipAddressesModel::addTransportToSipAddress (const QString &sip_address, ...@@ -183,9 +183,9 @@ QString SipAddressesModel::addTransportToSipAddress (const QString &sip_address,
return ::Utils::linphoneStringToQString(address->asString()); return ::Utils::linphoneStringToQString(address->asString());
} }
bool SipAddressesModel::sipAddressIsValid (const QString &sip_address) const { bool SipAddressesModel::sipAddressIsValid (const QString &sipAddress) const {
shared_ptr<linphone::Address> address = linphone::Factory::get()->createAddress( shared_ptr<linphone::Address> address = linphone::Factory::get()->createAddress(
::Utils::qStringToLinphoneString(sip_address) ::Utils::qStringToLinphoneString(sipAddress)
); );
return !!address; return !!address;
...@@ -200,17 +200,17 @@ bool SipAddressesModel::removeRow (int row, const QModelIndex &parent) { ...@@ -200,17 +200,17 @@ bool SipAddressesModel::removeRow (int row, const QModelIndex &parent) {
bool SipAddressesModel::removeRows (int row, int count, const QModelIndex &parent) { bool SipAddressesModel::removeRows (int row, int count, const QModelIndex &parent) {
int limit = row + count - 1; int limit = row + count - 1;
if (row < 0 || count < 0 || limit >= m_sip_addresses.count()) if (row < 0 || count < 0 || limit >= mSipAddresses.count())
return false; return false;
beginRemoveRows(parent, row, limit); beginRemoveRows(parent, row, limit);
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
const QVariantMap *map = m_refs.takeAt(row); const QVariantMap *map = mRefs.takeAt(row);
QString sip_address = (*map)["sipAddress"].toString(); QString sipAddress = (*map)["sipAddress"].toString();
qInfo() << QStringLiteral("Remove sip address: `%1`.").arg(sip_address); qInfo() << QStringLiteral("Remove sip address: `%1`.").arg(sipAddress);
m_sip_addresses.remove(sip_address); mSipAddresses.remove(sipAddress);
} }
endRemoveRows(); endRemoveRows();
...@@ -221,38 +221,38 @@ bool SipAddressesModel::removeRows (int row, int count, const QModelIndex &paren ...@@ -221,38 +221,38 @@ bool SipAddressesModel::removeRows (int row, int count, const QModelIndex &paren
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void SipAddressesModel::handleContactAdded (ContactModel *contact) { void SipAddressesModel::handleContactAdded (ContactModel *contact) {
for (const auto &sip_address : contact->getVcardModel()->getSipAddresses()) for (const auto &sipAddress : contact->getVcardModel()->getSipAddresses())
addOrUpdateSipAddress(sip_address.toString(), contact); addOrUpdateSipAddress(sipAddress.toString(), contact);
} }
void SipAddressesModel::handleContactRemoved (const ContactModel *contact) { void SipAddressesModel::handleContactRemoved (const ContactModel *contact) {
for (const auto &sip_address : contact->getVcardModel()->getSipAddresses()) for (const auto &sipAddress : contact->getVcardModel()->getSipAddresses())
removeContactOfSipAddress(sip_address.toString()); removeContactOfSipAddress(sipAddress.toString());
} }
void SipAddressesModel::handleSipAddressAdded (ContactModel *contact, const QString &sip_address) { void SipAddressesModel::handleSipAddressAdded (ContactModel *contact, const QString &sipAddress) {
ContactModel *mapped_contact = mapSipAddressToContact(sip_address); ContactModel *mappedContact = mapSipAddressToContact(sipAddress);
if (mapped_contact) { if (mappedContact) {
qWarning() << "Unable to map sip address" << sip_address << "to" << contact << "- already used by" << mapped_contact; qWarning() << "Unable to map sip address" << sipAddress << "to" << contact << "- already used by" << mappedContact;
return; return;
} }
addOrUpdateSipAddress(sip_address, contact); addOrUpdateSipAddress(sipAddress, contact);
} }
void SipAddressesModel::handleSipAddressRemoved (ContactModel *contact, const QString &sip_address) { void SipAddressesModel::handleSipAddressRemoved (ContactModel *contact, const QString &sipAddress) {
ContactModel *mapped_contact = mapSipAddressToContact(sip_address); ContactModel *mappedContact = mapSipAddressToContact(sipAddress);
if (contact != mapped_contact) { if (contact != mappedContact) {
qWarning() << "Unable to remove sip address" << sip_address << "of" << contact << "- already used by" << mapped_contact; qWarning() << "Unable to remove sip address" << sipAddress << "of" << contact << "- already used by" << mappedContact;
return; return;
} }
removeContactOfSipAddress(sip_address); removeContactOfSipAddress(sipAddress);
} }
void SipAddressesModel::handleMessageReceived (const shared_ptr<linphone::ChatMessage> &message) { void SipAddressesModel::handleMessageReceived (const shared_ptr<linphone::ChatMessage> &message) {
const QString &sip_address = ::Utils::linphoneStringToQString(message->getFromAddress()->asStringUriOnly()); const QString &sipAddress = ::Utils::linphoneStringToQString(message->getFromAddress()->asStringUriOnly());
addOrUpdateSipAddress(sip_address, message); addOrUpdateSipAddress(sipAddress, message);
} }
void SipAddressesModel::handleCallStateChanged ( void SipAddressesModel::handleCallStateChanged (
...@@ -270,12 +270,12 @@ void SipAddressesModel::handleCallStateChanged ( ...@@ -270,12 +270,12 @@ void SipAddressesModel::handleCallStateChanged (
} }
void SipAddressesModel::handlePresenceReceived ( void SipAddressesModel::handlePresenceReceived (
const QString &sip_address, const QString &sipAddress,
const shared_ptr<const linphone::PresenceModel> &presence_model const shared_ptr<const linphone::PresenceModel> &presenceModel
) { ) {
Presence::PresenceStatus status; Presence::PresenceStatus status;
switch (presence_model->getConsolidatedPresence()) { switch (presenceModel->getConsolidatedPresence()) {
case linphone::ConsolidatedPresenceOnline: case linphone::ConsolidatedPresenceOnline:
status = Presence::PresenceStatus::Online; status = Presence::PresenceStatus::Online;
break; break;
...@@ -290,27 +290,27 @@ void SipAddressesModel::handlePresenceReceived ( ...@@ -290,27 +290,27 @@ void SipAddressesModel::handlePresenceReceived (
break; break;
} }
auto it = m_sip_addresses.find(sip_address); auto it = mSipAddresses.find(sipAddress);
if (it != m_sip_addresses.end()) { if (it != mSipAddresses.end()) {
qInfo() << QStringLiteral("Update presence of `%1`: %2.").arg(sip_address).arg(status); qInfo() << QStringLiteral("Update presence of `%1`: %2.").arg(sipAddress).arg(status);
(*it)["presenceStatus"] = status; (*it)["presenceStatus"] = status;
int row = m_refs.indexOf(&(*it)); int row = mRefs.indexOf(&(*it));
Q_ASSERT(row != -1); Q_ASSERT(row != -1);
emit dataChanged(index(row, 0), index(row, 0)); emit dataChanged(index(row, 0), index(row, 0));
} }
updateObservers(sip_address, status); updateObservers(sipAddress, status);
} }
void SipAddressesModel::handleAllEntriesRemoved (const QString &sip_address) { void SipAddressesModel::handleAllEntriesRemoved (const QString &sipAddress) {
auto it = m_sip_addresses.find(sip_address); auto it = mSipAddresses.find(sipAddress);
if (it == m_sip_addresses.end()) { if (it == mSipAddresses.end()) {
qWarning() << QStringLiteral("Unable to found sip address: `%1`.").arg(sip_address); qWarning() << QStringLiteral("Unable to found sip address: `%1`.").arg(sipAddress);
return; return;
} }
int row = m_refs.indexOf(&(*it)); int row = mRefs.indexOf(&(*it));
Q_ASSERT(row != -1); Q_ASSERT(row != -1);
// No history, no contact => Remove sip address from list. // No history, no contact => Remove sip address from list.
...@@ -331,17 +331,17 @@ void SipAddressesModel::handleMessageSent (const shared_ptr<linphone::ChatMessag ...@@ -331,17 +331,17 @@ void SipAddressesModel::handleMessageSent (const shared_ptr<linphone::ChatMessag
); );
} }
void SipAddressesModel::handleMessagesCountReset (const QString &sip_address) { void SipAddressesModel::handleMessagesCountReset (const QString &sipAddress) {
auto it = m_sip_addresses.find(sip_address); auto it = mSipAddresses.find(sipAddress);
if (it != m_sip_addresses.end()) { if (it != mSipAddresses.end()) {
(*it)["unreadMessagesCount"] = 0; (*it)["unreadMessagesCount"] = 0;
int row = m_refs.indexOf(&(*it)); int row = mRefs.indexOf(&(*it));
Q_ASSERT(row != -1); Q_ASSERT(row != -1);
emit dataChanged(index(row, 0), index(row, 0)); emit dataChanged(index(row, 0), index(row, 0));
} }
updateObservers(sip_address, 0); updateObservers(sipAddress, 0);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -352,11 +352,11 @@ void SipAddressesModel::addOrUpdateSipAddress (QVariantMap &map, ContactModel *c ...@@ -352,11 +352,11 @@ void SipAddressesModel::addOrUpdateSipAddress (QVariantMap &map, ContactModel *c
} }
void SipAddressesModel::addOrUpdateSipAddress (QVariantMap &map, const shared_ptr<linphone::Call> &call) { void SipAddressesModel::addOrUpdateSipAddress (QVariantMap &map, const shared_ptr<linphone::Call> &call) {
const shared_ptr<linphone::CallLog> call_log = call->getCallLog(); const shared_ptr<linphone::CallLog> callLog = call->getCallLog();
map["timestamp"] = call_log->getStatus() == linphone::CallStatus::CallStatusSuccess map["timestamp"] = callLog->getStatus() == linphone::CallStatus::CallStatusSuccess
? QDateTime::fromMSecsSinceEpoch((call_log->getStartDate() + call_log->getDuration()) * 1000) ? QDateTime::fromMSecsSinceEpoch((callLog->getStartDate() + callLog->getDuration()) * 1000)
: QDateTime::fromMSecsSinceEpoch(call_log->getStartDate() * 1000); : QDateTime::fromMSecsSinceEpoch(callLog->getStartDate() * 1000);
} }
void SipAddressesModel::addOrUpdateSipAddress (QVariantMap &map, const shared_ptr<linphone::ChatMessage> &message) { void SipAddressesModel::addOrUpdateSipAddress (QVariantMap &map, const shared_ptr<linphone::ChatMessage> &message) {
...@@ -369,12 +369,12 @@ void SipAddressesModel::addOrUpdateSipAddress (QVariantMap &map, const shared_pt ...@@ -369,12 +369,12 @@ void SipAddressesModel::addOrUpdateSipAddress (QVariantMap &map, const shared_pt
} }
template<typename T> template<typename T>
void SipAddressesModel::addOrUpdateSipAddress (const QString &sip_address, T data) { void SipAddressesModel::addOrUpdateSipAddress (const QString &sipAddress, T data) {
auto it = m_sip_addresses.find(sip_address); auto it = mSipAddresses.find(sipAddress);
if (it != m_sip_addresses.end()) { if (it != mSipAddresses.end()) {
addOrUpdateSipAddress(*it, data); addOrUpdateSipAddress(*it, data);
int row = m_refs.indexOf(&(*it)); int row = mRefs.indexOf(&(*it));
Q_ASSERT(row != -1); Q_ASSERT(row != -1);
emit dataChanged(index(row, 0), index(row, 0)); emit dataChanged(index(row, 0), index(row, 0));
...@@ -382,36 +382,36 @@ void SipAddressesModel::addOrUpdateSipAddress (const QString &sip_address, T dat ...@@ -382,36 +382,36 @@ void SipAddressesModel::addOrUpdateSipAddress (const QString &sip_address, T dat
} }
QVariantMap map; QVariantMap map;
map["sipAddress"] = sip_address; map["sipAddress"] = sipAddress;
addOrUpdateSipAddress(map, data); addOrUpdateSipAddress(map, data);
int row = m_refs.count(); int row = mRefs.count();
beginInsertRows(QModelIndex(), row, row); beginInsertRows(QModelIndex(), row, row);
qInfo() << QStringLiteral("Add sip address: `%1`.").arg(sip_address); qInfo() << QStringLiteral("Add sip address: `%1`.").arg(sipAddress);
m_sip_addresses[sip_address] = map; mSipAddresses[sipAddress] = map;
m_refs << &m_sip_addresses[sip_address]; mRefs << &mSipAddresses[sipAddress];
endInsertRows(); endInsertRows();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void SipAddressesModel::removeContactOfSipAddress (const QString &sip_address) { void SipAddressesModel::removeContactOfSipAddress (const QString &sipAddress) {
auto it = m_sip_addresses.find(sip_address); auto it = mSipAddresses.find(sipAddress);
if (it == m_sip_addresses.end()) { if (it == mSipAddresses.end()) {
qWarning() << QStringLiteral("Unable to remove unavailable sip address: `%1`.").arg(sip_address); qWarning() << QStringLiteral("Unable to remove unavailable sip address: `%1`.").arg(sipAddress);
return; return;
} }
updateObservers(sip_address, nullptr); updateObservers(sipAddress, nullptr);
if (it->remove("contact") == 0) if (it->remove("contact") == 0)
qWarning() << QStringLiteral("`contact` field is empty on sip address: `%1`.").arg(sip_address); qWarning() << QStringLiteral("`contact` field is empty on sip address: `%1`.").arg(sipAddress);
int row = m_refs.indexOf(&(*it)); int row = mRefs.indexOf(&(*it));
Q_ASSERT(row != -1); Q_ASSERT(row != -1);
// History exists, signal changes. // History exists, signal changes.
...@@ -428,69 +428,69 @@ void SipAddressesModel::initSipAddresses () { ...@@ -428,69 +428,69 @@ void SipAddressesModel::initSipAddresses () {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
// Get sip addresses from chatrooms. // Get sip addresses from chatrooms.
for (const auto &chat_room : core->getChatRooms()) { for (const auto &chatRoom : core->getChatRooms()) {
list<shared_ptr<linphone::ChatMessage> > history = chat_room->getHistory(0); list<shared_ptr<linphone::ChatMessage> > history = chatRoom->getHistory(0);
if (history.size() == 0) if (history.size() == 0)
continue; continue;
QString sip_address = ::Utils::linphoneStringToQString(chat_room->getPeerAddress()->asStringUriOnly()); QString sipAddress = ::Utils::linphoneStringToQString(chatRoom->getPeerAddress()->asStringUriOnly());
QVariantMap map; QVariantMap map;
map["sipAddress"] = sip_address; map["sipAddress"] = sipAddress;
map["timestamp"] = QDateTime::fromMSecsSinceEpoch(history.back()->getTime() * 1000); map["timestamp"] = QDateTime::fromMSecsSinceEpoch(history.back()->getTime() * 1000);
map["unreadMessagesCount"] = chat_room->getUnreadMessagesCount(); map["unreadMessagesCount"] = chatRoom->getUnreadMessagesCount();
m_sip_addresses[sip_address] = map; mSipAddresses[sipAddress] = map;
} }
// Get sip addresses from calls. // Get sip addresses from calls.
QSet<QString> address_done; QSet<QString> addressDone;
for (const auto &call_log : core->getCallLogs()) { for (const auto &callLog : core->getCallLogs()) {
const QString &sip_address = ::Utils::linphoneStringToQString(call_log->getRemoteAddress()->asStringUriOnly()); const QString &sipAddress = ::Utils::linphoneStringToQString(callLog->getRemoteAddress()->asStringUriOnly());
if (address_done.contains(sip_address)) if (addressDone.contains(sipAddress))
continue; // Already used. continue; // Already used.
if (call_log->getStatus() == linphone::CallStatusAborted) if (callLog->getStatus() == linphone::CallStatusAborted)
continue; // Ignore aborted calls. continue; // Ignore aborted calls.
address_done << sip_address; addressDone << sipAddress;
QVariantMap map; QVariantMap map;
map["sipAddress"] = sip_address; map["sipAddress"] = sipAddress;
// The duration can be wrong if status is not success. // The duration can be wrong if status is not success.
map["timestamp"] = call_log->getStatus() == linphone::CallStatus::CallStatusSuccess map["timestamp"] = callLog->getStatus() == linphone::CallStatus::CallStatusSuccess
? QDateTime::fromMSecsSinceEpoch((call_log->getStartDate() + call_log->getDuration()) * 1000) ? QDateTime::fromMSecsSinceEpoch((callLog->getStartDate() + callLog->getDuration()) * 1000)
: QDateTime::fromMSecsSinceEpoch(call_log->getStartDate() * 1000); : QDateTime::fromMSecsSinceEpoch(callLog->getStartDate() * 1000);
auto it = m_sip_addresses.find(sip_address); auto it = mSipAddresses.find(sipAddress);
if (it == m_sip_addresses.end() || map["timestamp"] > (*it)["timestamp"]) if (it == mSipAddresses.end() || map["timestamp"] > (*it)["timestamp"])
m_sip_addresses[sip_address] = map; mSipAddresses[sipAddress] = map;
} }
for (const auto &map : m_sip_addresses) for (const auto &map : mSipAddresses)
m_refs << &map; mRefs << &map;
// Get sip addresses from contacts. // Get sip addresses from contacts.
for (auto &contact : CoreManager::getInstance()->getContactsListModel()->m_list) for (auto &contact : CoreManager::getInstance()->getContactsListModel()->mList)
handleContactAdded(contact); handleContactAdded(contact);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void SipAddressesModel::updateObservers (const QString &sip_address, ContactModel *contact) { void SipAddressesModel::updateObservers (const QString &sipAddress, ContactModel *contact) {
for (auto &observer : m_observers.values(sip_address)) for (auto &observer : mObservers.values(sipAddress))
observer->setContact(contact); observer->setContact(contact);
} }
void SipAddressesModel::updateObservers (const QString &sip_address, const Presence::PresenceStatus &presence_status) { void SipAddressesModel::updateObservers (const QString &sipAddress, const Presence::PresenceStatus &presenceStatus) {
for (auto &observer : m_observers.values(sip_address)) for (auto &observer : mObservers.values(sipAddress))
observer->setPresenceStatus(presence_status); observer->setPresenceStatus(presenceStatus);
} }
void SipAddressesModel::updateObservers (const QString &sip_address, int messages_count) { void SipAddressesModel::updateObservers (const QString &sipAddress, int messagesCount) {
for (auto &observer : m_observers.values(sip_address)) for (auto &observer : mObservers.values(sipAddress))
observer->setUnreadMessagesCount(messages_count); observer->setUnreadMessagesCount(messagesCount);
} }
...@@ -45,20 +45,20 @@ public: ...@@ -45,20 +45,20 @@ public:
QHash<int, QByteArray> roleNames () const override; QHash<int, QByteArray> roleNames () const override;
QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override;
void connectToChatModel (ChatModel *chat_model); void connectToChatModel (ChatModel *chatModel);
Q_INVOKABLE ContactModel *mapSipAddressToContact (const QString &sip_address) const; Q_INVOKABLE ContactModel *mapSipAddressToContact (const QString &sipAddress) const;
Q_INVOKABLE SipAddressObserver *getSipAddressObserver (const QString &sip_address); Q_INVOKABLE SipAddressObserver *getSipAddressObserver (const QString &sipAddress);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Sip addresses helpers. // Sip addresses helpers.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
Q_INVOKABLE QString interpretUrl (const QString &sip_address) const; Q_INVOKABLE QString interpretUrl (const QString &sipAddress) const;
Q_INVOKABLE QString getTransportFromSipAddress (const QString &sip_address) const; Q_INVOKABLE QString getTransportFromSipAddress (const QString &sipAddress) const;
Q_INVOKABLE QString addTransportToSipAddress (const QString &sip_address, const QString &transport) const; Q_INVOKABLE QString addTransportToSipAddress (const QString &sipAddress, const QString &transport) const;
Q_INVOKABLE bool sipAddressIsValid (const QString &sip_address) const; Q_INVOKABLE bool sipAddressIsValid (const QString &sipAddress) const;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -71,16 +71,16 @@ private: ...@@ -71,16 +71,16 @@ private:
void handleContactAdded (ContactModel *contact); void handleContactAdded (ContactModel *contact);
void handleContactRemoved (const ContactModel *contact); void handleContactRemoved (const ContactModel *contact);
void handleSipAddressAdded (ContactModel *contact, const QString &sip_address); void handleSipAddressAdded (ContactModel *contact, const QString &sipAddress);
void handleSipAddressRemoved (ContactModel *contact, const QString &sip_address); void handleSipAddressRemoved (ContactModel *contact, const QString &sipAddress);
void handleMessageReceived (const std::shared_ptr<linphone::ChatMessage> &message); void handleMessageReceived (const std::shared_ptr<linphone::ChatMessage> &message);
void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state); void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state);
void handlePresenceReceived (const QString &sip_address, const std::shared_ptr<const linphone::PresenceModel> &presence_model); void handlePresenceReceived (const QString &sipAddress, const std::shared_ptr<const linphone::PresenceModel> &presenceModel);
void handleAllEntriesRemoved (const QString &sip_address); void handleAllEntriesRemoved (const QString &sipAddress);
void handleMessageSent (const std::shared_ptr<linphone::ChatMessage> &message); void handleMessageSent (const std::shared_ptr<linphone::ChatMessage> &message);
void handleMessagesCountReset (const QString &sip_address); void handleMessagesCountReset (const QString &sipAddress);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -91,24 +91,24 @@ private: ...@@ -91,24 +91,24 @@ private:
void addOrUpdateSipAddress (QVariantMap &map, const std::shared_ptr<linphone::ChatMessage> &message); void addOrUpdateSipAddress (QVariantMap &map, const std::shared_ptr<linphone::ChatMessage> &message);
template<class T> template<class T>
void addOrUpdateSipAddress (const QString &sip_address, T data); void addOrUpdateSipAddress (const QString &sipAddress, T data);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void removeContactOfSipAddress (const QString &sip_address); void removeContactOfSipAddress (const QString &sipAddress);
void initSipAddresses (); void initSipAddresses ();
void updateObservers (const QString &sip_address, ContactModel *contact); void updateObservers (const QString &sipAddress, ContactModel *contact);
void updateObservers (const QString &sip_address, const Presence::PresenceStatus &presence_status); void updateObservers (const QString &sipAddress, const Presence::PresenceStatus &presenceStatus);
void updateObservers (const QString &sip_address, int messages_count); void updateObservers (const QString &sipAddress, int messagesCount);
QHash<QString, QVariantMap> m_sip_addresses; QHash<QString, QVariantMap> mSipAddresses;
QList<const QVariantMap *> m_refs; QList<const QVariantMap *> mRefs;
QMultiHash<QString, SipAddressObserver *> m_observers; QMultiHash<QString, SipAddressObserver *> mObservers;
std::shared_ptr<CoreHandlers> m_core_handlers; std::shared_ptr<CoreHandlers> mCoreHandlers;
}; };
#endif // SIP_ADDRESSES_MODEL_H_ #endif // SIP_ADDRESSES_MODEL_H_
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
// ============================================================================= // =============================================================================
const QRegExp SmartSearchBarModel::m_search_separators("^[^_.-;@ ][_.-;@ ]"); const QRegExp SmartSearchBarModel::mSearchSeparators("^[^_.-;@ ][_.-;@ ]");
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -50,54 +50,54 @@ QHash<int, QByteArray> SmartSearchBarModel::roleNames () const { ...@@ -50,54 +50,54 @@ QHash<int, QByteArray> SmartSearchBarModel::roleNames () const {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void SmartSearchBarModel::setFilter (const QString &pattern) { void SmartSearchBarModel::setFilter (const QString &pattern) {
m_filter = pattern; mFilter = pattern;
invalidate(); invalidate();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool SmartSearchBarModel::filterAcceptsRow (int source_row, const QModelIndex &source_parent) const { bool SmartSearchBarModel::filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const {
const QModelIndex &index = sourceModel()->index(source_row, 0, source_parent); const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent);
return computeEntryWeight(index.data().toMap()) > 0; return computeEntryWeight(index.data().toMap()) > 0;
} }
bool SmartSearchBarModel::lessThan (const QModelIndex &left, const QModelIndex &right) const { bool SmartSearchBarModel::lessThan (const QModelIndex &left, const QModelIndex &right) const {
const QVariantMap &map_a = sourceModel()->data(left).toMap(); const QVariantMap &mapA = sourceModel()->data(left).toMap();
const QVariantMap &map_b = sourceModel()->data(right).toMap(); const QVariantMap &mapB = sourceModel()->data(right).toMap();
const QString &sip_address_a = map_a["sipAddress"].toString(); const QString &sipAddressA = mapA["sipAddress"].toString();
const QString &sip_address_b = map_b["sipAddress"].toString(); const QString &sipAddressB = mapB["sipAddress"].toString();
// TODO: Use a cache, do not compute the same value as `filterAcceptsRow`. // TODO: Use a cache, do not compute the same value as `filterAcceptsRow`.
int weight_a = computeEntryWeight(map_a); int weightA = computeEntryWeight(mapA);
int weight_b = computeEntryWeight(map_b); int weightB = computeEntryWeight(mapB);
// 1. Not the same weight. // 1. Not the same weight.
if (weight_a != weight_b) if (weightA != weightB)
return weight_a > weight_b; return weightA > weightB;
const ContactModel *contact_a = map_a.value("contact").value<ContactModel *>(); const ContactModel *contactA = mapA.value("contact").value<ContactModel *>();
const ContactModel *contact_b = map_b.value("contact").value<ContactModel *>(); const ContactModel *contactB = mapB.value("contact").value<ContactModel *>();
// 2. No contacts. // 2. No contacts.
if (!contact_a && !contact_b) if (!contactA && !contactB)
return sip_address_a <= sip_address_b; return sipAddressA <= sipAddressB;
// 3. No contact for a or b. // 3. No contact for a or b.
if (!contact_a || !contact_b) if (!contactA || !contactB)
return !!contact_a; return !!contactA;
// 4. Same contact (address). // 4. Same contact (address).
if (contact_a == contact_b) if (contactA == contactB)
return sip_address_a <= sip_address_b; return sipAddressA <= sipAddressB;
// 5. Not the same contact name. // 5. Not the same contact name.
int diff = contact_a->m_linphone_friend->getName().compare(contact_b->m_linphone_friend->getName()); int diff = contactA->mLinphoneFriend->getName().compare(contactB->mLinphoneFriend->getName());
if (diff) if (diff)
return diff <= 0; return diff <= 0;
// 6. Same contact name, so compare sip addresses. // 6. Same contact name, so compare sip addresses.
return sip_address_a <= sip_address_b; return sipAddressA <= sipAddressB;
} }
int SmartSearchBarModel::computeEntryWeight (const QVariantMap &entry) const { int SmartSearchBarModel::computeEntryWeight (const QVariantMap &entry) const {
...@@ -114,10 +114,10 @@ int SmartSearchBarModel::computeStringWeight (const QString &string) const { ...@@ -114,10 +114,10 @@ int SmartSearchBarModel::computeStringWeight (const QString &string) const {
int index = -1; int index = -1;
int offset = -1; int offset = -1;
while ((index = string.indexOf(m_filter, index + 1, Qt::CaseInsensitive)) != -1) { while ((index = string.indexOf(mFilter, index + 1, Qt::CaseInsensitive)) != -1) {
int tmp_offset = index - string.lastIndexOf(m_search_separators, index) - 1; int tmpOffset = index - string.lastIndexOf(mSearchSeparators, index) - 1;
if ((tmp_offset != -1 && tmp_offset < offset) || offset == -1) if ((tmpOffset != -1 && tmpOffset < offset) || offset == -1)
if ((offset = tmp_offset) == 0) break; if ((offset = tmpOffset) == 0) break;
} }
switch (offset) { switch (offset) {
......
...@@ -39,15 +39,15 @@ public: ...@@ -39,15 +39,15 @@ public:
Q_INVOKABLE void setFilter (const QString &pattern); Q_INVOKABLE void setFilter (const QString &pattern);
protected: protected:
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override; bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override;
bool lessThan (const QModelIndex &left, const QModelIndex &right) const override; bool lessThan (const QModelIndex &left, const QModelIndex &right) const override;
private: private:
int computeEntryWeight (const QVariantMap &entry) const; int computeEntryWeight (const QVariantMap &entry) const;
int computeStringWeight (const QString &string) const; int computeStringWeight (const QString &string) const;
QString m_filter; QString mFilter;
static const QRegExp m_search_separators; static const QRegExp mSearchSeparators;
}; };
#endif // SMART_SEARCH_BAR_MODEL_H_ #endif // SMART_SEARCH_BAR_MODEL_H_
...@@ -41,8 +41,8 @@ QHash<int, QByteArray> TimelineModel::roleNames () const { ...@@ -41,8 +41,8 @@ QHash<int, QByteArray> TimelineModel::roleNames () const {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool TimelineModel::filterAcceptsRow (int source_row, const QModelIndex &source_parent) const { bool TimelineModel::filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const {
const QModelIndex &index = sourceModel()->index(source_row, 0, source_parent); const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent);
return index.data().toMap().contains("timestamp"); return index.data().toMap().contains("timestamp");
} }
......
...@@ -37,7 +37,7 @@ public: ...@@ -37,7 +37,7 @@ public:
QHash<int, QByteArray> roleNames () const override; QHash<int, QByteArray> roleNames () const override;
protected: protected:
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override; bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override;
bool lessThan (const QModelIndex &left, const QModelIndex &right) const override; bool lessThan (const QModelIndex &left, const QModelIndex &right) const override;
}; };
......
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