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