Commit d8ff1b14 authored by Ronan Abhamon's avatar Ronan Abhamon

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

parent c714ad8d
...@@ -34,7 +34,7 @@ using namespace std; ...@@ -34,7 +34,7 @@ using namespace std;
class AssistantModel::Handlers : public linphone::AccountCreatorListener { class AssistantModel::Handlers : public linphone::AccountCreatorListener {
public: public:
Handlers (AssistantModel *assistant) { Handlers (AssistantModel *assistant) {
m_assistant = assistant; mAssistant = assistant;
} }
void onCreateAccount ( void onCreateAccount (
...@@ -43,14 +43,14 @@ public: ...@@ -43,14 +43,14 @@ public:
const string & const string &
) override { ) override {
if (status == linphone::AccountCreatorStatusAccountCreated) if (status == linphone::AccountCreatorStatusAccountCreated)
emit m_assistant->createStatusChanged(""); emit mAssistant->createStatusChanged("");
else { else {
if (status == linphone::AccountCreatorStatusRequestFailed) if (status == linphone::AccountCreatorStatusRequestFailed)
emit m_assistant->createStatusChanged(tr("requestFailed")); emit mAssistant->createStatusChanged(tr("requestFailed"));
else if (status == linphone::AccountCreatorStatusServerError) else if (status == linphone::AccountCreatorStatusServerError)
emit m_assistant->createStatusChanged(tr("cannotSendSms")); emit mAssistant->createStatusChanged(tr("cannotSendSms"));
else else
emit m_assistant->createStatusChanged(tr("accountAlreadyExists")); emit mAssistant->createStatusChanged(tr("accountAlreadyExists"));
} }
} }
...@@ -61,12 +61,12 @@ public: ...@@ -61,12 +61,12 @@ public:
) override { ) override {
if (status == linphone::AccountCreatorStatusAccountExist || status == linphone::AccountCreatorStatusAccountExistWithAlias) { if (status == linphone::AccountCreatorStatusAccountExist || status == linphone::AccountCreatorStatusAccountExistWithAlias) {
CoreManager::getInstance()->getCore()->addProxyConfig(creator->configure()); CoreManager::getInstance()->getCore()->addProxyConfig(creator->configure());
emit m_assistant->loginStatusChanged(""); emit mAssistant->loginStatusChanged("");
} else { } else {
if (status == linphone::AccountCreatorStatusRequestFailed) if (status == linphone::AccountCreatorStatusRequestFailed)
emit m_assistant->loginStatusChanged(tr("requestFailed")); emit mAssistant->loginStatusChanged(tr("requestFailed"));
else else
emit m_assistant->loginStatusChanged(tr("loginWithUsernameFailed")); emit mAssistant->loginStatusChanged(tr("loginWithUsernameFailed"));
} }
} }
...@@ -79,12 +79,12 @@ public: ...@@ -79,12 +79,12 @@ public:
status == linphone::AccountCreatorStatusAccountActivated || status == linphone::AccountCreatorStatusAccountActivated ||
status == linphone::AccountCreatorStatusAccountAlreadyActivated status == linphone::AccountCreatorStatusAccountAlreadyActivated
) )
emit m_assistant->activateStatusChanged(""); emit mAssistant->activateStatusChanged("");
else { else {
if (status == linphone::AccountCreatorStatusRequestFailed) if (status == linphone::AccountCreatorStatusRequestFailed)
emit m_assistant->activateStatusChanged(tr("requestFailed")); emit mAssistant->activateStatusChanged(tr("requestFailed"));
else else
emit m_assistant->activateStatusChanged(tr("smsActivationFailed")); emit mAssistant->activateStatusChanged(tr("smsActivationFailed"));
} }
} }
...@@ -96,12 +96,12 @@ public: ...@@ -96,12 +96,12 @@ public:
if (status == linphone::AccountCreatorStatusAccountActivated) { if (status == linphone::AccountCreatorStatusAccountActivated) {
CoreManager::getInstance()->getAccountSettingsModel()->addOrUpdateProxyConfig(creator->configure()); CoreManager::getInstance()->getAccountSettingsModel()->addOrUpdateProxyConfig(creator->configure());
emit m_assistant->activateStatusChanged(""); emit mAssistant->activateStatusChanged("");
} else { } else {
if (status == linphone::AccountCreatorStatusRequestFailed) if (status == linphone::AccountCreatorStatusRequestFailed)
emit m_assistant->activateStatusChanged(tr("requestFailed")); emit mAssistant->activateStatusChanged(tr("requestFailed"));
else else
emit m_assistant->activateStatusChanged(tr("emailActivationFailed")); emit mAssistant->activateStatusChanged(tr("emailActivationFailed"));
} }
} }
...@@ -142,40 +142,40 @@ public: ...@@ -142,40 +142,40 @@ public:
// ) override {} // ) override {}
private: private:
AssistantModel *m_assistant; AssistantModel *mAssistant;
}; };
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
AssistantModel::AssistantModel (QObject *parent) : QObject(parent) { AssistantModel::AssistantModel (QObject *parent) : QObject(parent) {
m_handlers = make_shared<AssistantModel::Handlers>(this); mHandlers = make_shared<AssistantModel::Handlers>(this);
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
m_account_creator = core->createAccountCreator( mAccountCreator = core->createAccountCreator(
core->getConfig()->getString("assistant", "xmlrpc_url", DEFAULT_XMLRPC_URL) core->getConfig()->getString("assistant", "xmlrpc_url", DEFAULT_XMLRPC_URL)
); );
m_account_creator->setListener(m_handlers); mAccountCreator->setListener(mHandlers);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void AssistantModel::activate () { void AssistantModel::activate () {
if (m_account_creator->getEmail().empty()) if (mAccountCreator->getEmail().empty())
m_account_creator->activateAccount(); mAccountCreator->activateAccount();
else else
m_account_creator->isAccountActivated(); mAccountCreator->isAccountActivated();
} }
void AssistantModel::create () { void AssistantModel::create () {
m_account_creator->createAccount(); mAccountCreator->createAccount();
} }
void AssistantModel::login () { void AssistantModel::login () {
m_account_creator->isAccountExist(); mAccountCreator->isAccountExist();
} }
void AssistantModel::reset () { void AssistantModel::reset () {
m_account_creator->reset(); mAccountCreator->reset();
emit emailChanged("", ""); emit emailChanged("", "");
emit passwordChanged("", ""); emit passwordChanged("", "");
...@@ -186,14 +186,14 @@ void AssistantModel::reset () { ...@@ -186,14 +186,14 @@ void AssistantModel::reset () {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
QString AssistantModel::getEmail () const { QString AssistantModel::getEmail () const {
return ::Utils::linphoneStringToQString(m_account_creator->getEmail()); return ::Utils::linphoneStringToQString(mAccountCreator->getEmail());
} }
void AssistantModel::setEmail (const QString &email) { void AssistantModel::setEmail (const QString &email) {
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig(); shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
QString error; QString error;
switch (m_account_creator->setEmail(::Utils::qStringToLinphoneString(email))) { switch (mAccountCreator->setEmail(::Utils::qStringToLinphoneString(email))) {
case linphone::AccountCreatorEmailStatusOk: case linphone::AccountCreatorEmailStatusOk:
break; break;
case linphone::AccountCreatorEmailStatusMalformed: case linphone::AccountCreatorEmailStatusMalformed:
...@@ -208,14 +208,14 @@ void AssistantModel::setEmail (const QString &email) { ...@@ -208,14 +208,14 @@ void AssistantModel::setEmail (const QString &email) {
} }
QString AssistantModel::getPassword () const { QString AssistantModel::getPassword () const {
return ::Utils::linphoneStringToQString(m_account_creator->getPassword()); return ::Utils::linphoneStringToQString(mAccountCreator->getPassword());
} }
void AssistantModel::setPassword (const QString &password) { void AssistantModel::setPassword (const QString &password) {
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig(); shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
QString error; QString error;
switch (m_account_creator->setPassword(::Utils::qStringToLinphoneString(password))) { switch (mAccountCreator->setPassword(::Utils::qStringToLinphoneString(password))) {
case linphone::AccountCreatorPasswordStatusOk: case linphone::AccountCreatorPasswordStatusOk:
break; break;
case linphone::AccountCreatorPasswordStatusTooShort: case linphone::AccountCreatorPasswordStatusTooShort:
...@@ -238,27 +238,27 @@ void AssistantModel::setPassword (const QString &password) { ...@@ -238,27 +238,27 @@ void AssistantModel::setPassword (const QString &password) {
} }
QString AssistantModel::getPhoneNumber () const { QString AssistantModel::getPhoneNumber () const {
return ::Utils::linphoneStringToQString(m_account_creator->getPhoneNumber()); return ::Utils::linphoneStringToQString(mAccountCreator->getPhoneNumber());
} }
void AssistantModel::setPhoneNumber (const QString &phone_number) { void AssistantModel::setPhoneNumber (const QString &phoneNumber) {
// shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig(); // shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
QString error; QString error;
// TODO: use the future wrapped function: `set_phone_number`. // TODO: use the future wrapped function: `set_phone_number`.
emit phoneNumberChanged(phone_number, error); emit phoneNumberChanged(phoneNumber, error);
} }
QString AssistantModel::getUsername () const { QString AssistantModel::getUsername () const {
return ::Utils::linphoneStringToQString(m_account_creator->getUsername()); return ::Utils::linphoneStringToQString(mAccountCreator->getUsername());
} }
void AssistantModel::setUsername (const QString &username) { void AssistantModel::setUsername (const QString &username) {
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig(); shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
QString error; QString error;
switch (m_account_creator->setUsername(::Utils::qStringToLinphoneString(username))) { switch (mAccountCreator->setUsername(::Utils::qStringToLinphoneString(username))) {
case linphone::AccountCreatorUsernameStatusOk: case linphone::AccountCreatorUsernameStatusOk:
break; break;
case linphone::AccountCreatorUsernameStatusTooShort: case linphone::AccountCreatorUsernameStatusTooShort:
......
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,7 @@ public:
signals: signals:
void emailChanged (const QString &email, const QString &error); void emailChanged (const QString &email, const QString &error);
void passwordChanged (const QString &password, const QString &error); void passwordChanged (const QString &password, const QString &error);
void phoneNumberChanged (const QString &phone_number, const QString &error); void phoneNumberChanged (const QString &phoneNumber, const QString &error);
void usernameChanged (const QString &username, const QString &error); void usernameChanged (const QString &username, const QString &error);
void activateStatusChanged (const QString &error); void activateStatusChanged (const QString &error);
...@@ -65,13 +65,13 @@ private: ...@@ -65,13 +65,13 @@ private:
void setPassword (const QString &password); void setPassword (const QString &password);
QString getPhoneNumber () const; QString getPhoneNumber () const;
void setPhoneNumber (const QString &phone_number); void setPhoneNumber (const QString &phoneNumber);
QString getUsername () const; QString getUsername () const;
void setUsername (const QString &username); void setUsername (const QString &username);
std::shared_ptr<linphone::AccountCreator> m_account_creator; std::shared_ptr<linphone::AccountCreator> mAccountCreator;
std::shared_ptr<Handlers> m_handlers; std::shared_ptr<Handlers> mHandlers;
}; };
#endif // ASSISTANT_MODEL_H_ #endif // ASSISTANT_MODEL_H_
...@@ -61,14 +61,14 @@ public: ...@@ -61,14 +61,14 @@ public:
Q_ENUM(CallStatus); Q_ENUM(CallStatus);
CallModel (std::shared_ptr<linphone::Call> linphone_call); CallModel (std::shared_ptr<linphone::Call> linphoneCall);
~CallModel () = default; ~CallModel () = default;
std::shared_ptr<linphone::Call> getLinphoneCall () const { std::shared_ptr<linphone::Call> getLinphoneCall () const {
return m_linphone_call; return mLinphoneCall;
} }
static void setRecordFile (std::shared_ptr<linphone::CallParams> &call_params); static void setRecordFile (std::shared_ptr<linphone::CallParams> &callParams);
Q_INVOKABLE void accept (); Q_INVOKABLE void accept ();
Q_INVOKABLE void acceptWithVideo (); Q_INVOKABLE void acceptWithVideo ();
...@@ -96,7 +96,7 @@ private: ...@@ -96,7 +96,7 @@ private:
CallStatus getStatus () const; CallStatus getStatus () const;
bool isOutgoing () const { bool isOutgoing () const {
return m_linphone_call->getDir() == linphone::CallDirOutgoing; return mLinphoneCall->getDir() == linphone::CallDirOutgoing;
} }
int getDuration () const; int getDuration () const;
...@@ -117,11 +117,11 @@ private: ...@@ -117,11 +117,11 @@ private:
bool getRecording () const; bool getRecording () const;
bool m_paused_by_remote = false; bool mPausedByRemote = false;
bool m_paused_by_user = false; bool mPausedByUser = false;
bool m_recording = false; bool mRecording = false;
std::shared_ptr<linphone::Call> m_linphone_call; std::shared_ptr<linphone::Call> mLinphoneCall;
}; };
#endif // CALL_MODEL_H_ #endif // CALL_MODEL_H_
...@@ -38,11 +38,11 @@ using namespace std; ...@@ -38,11 +38,11 @@ using namespace std;
inline QList<CallModel *>::iterator findCall ( inline QList<CallModel *>::iterator findCall (
QList<CallModel *> &list, QList<CallModel *> &list,
const shared_ptr<linphone::Call> &linphone_call const shared_ptr<linphone::Call> &linphoneCall
) { ) {
return find_if( return find_if(
list.begin(), list.end(), [linphone_call](CallModel *call) { list.begin(), list.end(), [linphoneCall](CallModel *call) {
return linphone_call == call->getLinphoneCall(); return linphoneCall == call->getLinphoneCall();
} }
); );
} }
...@@ -50,24 +50,24 @@ inline QList<CallModel *>::iterator findCall ( ...@@ -50,24 +50,24 @@ inline QList<CallModel *>::iterator findCall (
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
CallsListModel::CallsListModel (QObject *parent) : QAbstractListModel(parent) { CallsListModel::CallsListModel (QObject *parent) : QAbstractListModel(parent) {
m_core_handlers = CoreManager::getInstance()->getHandlers(); mCoreHandlers = CoreManager::getInstance()->getHandlers();
QObject::connect( QObject::connect(
&(*m_core_handlers), &CoreHandlers::callStateChanged, &(*mCoreHandlers), &CoreHandlers::callStateChanged,
this, [this](const shared_ptr<linphone::Call> &linphone_call, linphone::CallState state) { this, [this](const shared_ptr<linphone::Call> &linphoneCall, linphone::CallState state) {
switch (state) { switch (state) {
case linphone::CallStateIncomingReceived: case linphone::CallStateIncomingReceived:
case linphone::CallStateOutgoingInit: case linphone::CallStateOutgoingInit:
addCall(linphone_call); addCall(linphoneCall);
break; break;
case linphone::CallStateEnd: case linphone::CallStateEnd:
case linphone::CallStateError: case linphone::CallStateError:
removeCall(linphone_call); removeCall(linphoneCall);
break; break;
case linphone::CallStateStreamsRunning: { case linphone::CallStateStreamsRunning: {
int index = static_cast<int>(distance(m_list.begin(), findCall(m_list, linphone_call))); int index = static_cast<int>(distance(mList.begin(), findCall(mList, linphoneCall)));
emit callRunning(index, &linphone_call->getData<CallModel>("call-model")); emit callRunning(index, &linphoneCall->getData<CallModel>("call-model"));
} }
break; break;
...@@ -79,7 +79,7 @@ CallsListModel::CallsListModel (QObject *parent) : QAbstractListModel(parent) { ...@@ -79,7 +79,7 @@ CallsListModel::CallsListModel (QObject *parent) : QAbstractListModel(parent) {
} }
int CallsListModel::rowCount (const QModelIndex &) const { int CallsListModel::rowCount (const QModelIndex &) const {
return m_list.count(); return mList.count();
} }
QHash<int, QByteArray> CallsListModel::roleNames () const { QHash<int, QByteArray> CallsListModel::roleNames () const {
...@@ -91,25 +91,25 @@ QHash<int, QByteArray> CallsListModel::roleNames () const { ...@@ -91,25 +91,25 @@ QHash<int, QByteArray> CallsListModel::roleNames () const {
QVariant CallsListModel::data (const QModelIndex &index, int role) const { QVariant CallsListModel::data (const QModelIndex &index, int role) const {
int row = index.row(); int row = index.row();
if (!index.isValid() || row < 0 || row >= m_list.count()) if (!index.isValid() || row < 0 || row >= mList.count())
return QVariant(); return QVariant();
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
return QVariant::fromValue(m_list[row]); return QVariant::fromValue(mList[row]);
return QVariant(); return QVariant();
} }
CallModel *CallsListModel::getCall (const shared_ptr<linphone::Call> &linphone_call) const { CallModel *CallsListModel::getCall (const shared_ptr<linphone::Call> &linphoneCall) const {
auto it = findCall(*(const_cast<QList<CallModel *> *>(&m_list)), linphone_call); auto it = findCall(*(const_cast<QList<CallModel *> *>(&mList)), linphoneCall);
return it != m_list.end() ? *it : nullptr; return it != mList.end() ? *it : nullptr;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CallsListModel::launchAudioCall (const QString &sip_uri) const { void CallsListModel::launchAudioCall (const QString &sipUri) const {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::Address> address = core->interpretUrl(::Utils::qStringToLinphoneString(sip_uri)); shared_ptr<linphone::Address> address = core->interpretUrl(::Utils::qStringToLinphoneString(sipUri));
if (!address) if (!address)
return; return;
...@@ -121,9 +121,9 @@ void CallsListModel::launchAudioCall (const QString &sip_uri) const { ...@@ -121,9 +121,9 @@ void CallsListModel::launchAudioCall (const QString &sip_uri) const {
core->inviteAddressWithParams(address, params); core->inviteAddressWithParams(address, params);
} }
void CallsListModel::launchVideoCall (const QString &sip_uri) const { void CallsListModel::launchVideoCall (const QString &sipUri) const {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::Address> address = core->interpretUrl(::Utils::qStringToLinphoneString(sip_uri)); shared_ptr<linphone::Address> address = core->interpretUrl(::Utils::qStringToLinphoneString(sipUri));
if (!address) if (!address)
return; return;
...@@ -155,13 +155,13 @@ bool CallsListModel::removeRow (int row, const QModelIndex &parent) { ...@@ -155,13 +155,13 @@ bool CallsListModel::removeRow (int row, const QModelIndex &parent) {
bool CallsListModel::removeRows (int row, int count, const QModelIndex &parent) { bool CallsListModel::removeRows (int row, int count, const QModelIndex &parent) {
int limit = row + count - 1; int limit = row + count - 1;
if (row < 0 || count < 0 || limit >= m_list.count()) if (row < 0 || count < 0 || limit >= mList.count())
return false; return false;
beginRemoveRows(parent, row, limit); beginRemoveRows(parent, row, limit);
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
m_list.takeAt(row)->deleteLater(); mList.takeAt(row)->deleteLater();
endRemoveRows(); endRemoveRows();
...@@ -170,38 +170,38 @@ bool CallsListModel::removeRows (int row, int count, const QModelIndex &parent) ...@@ -170,38 +170,38 @@ bool CallsListModel::removeRows (int row, int count, const QModelIndex &parent)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CallsListModel::addCall (const shared_ptr<linphone::Call> &linphone_call) { void CallsListModel::addCall (const shared_ptr<linphone::Call> &linphoneCall) {
if (linphone_call->getDir() == linphone::CallDirOutgoing) if (linphoneCall->getDir() == linphone::CallDirOutgoing)
App::getInstance()->getCallsWindow()->show(); App::getInstance()->getCallsWindow()->show();
CallModel *call = new CallModel(linphone_call); CallModel *call = new CallModel(linphoneCall);
qInfo() << "Add call:" << call; qInfo() << "Add call:" << call;
App::getInstance()->getEngine()->setObjectOwnership(call, QQmlEngine::CppOwnership); App::getInstance()->getEngine()->setObjectOwnership(call, QQmlEngine::CppOwnership);
linphone_call->setData("call-model", *call); linphoneCall->setData("call-model", *call);
int row = m_list.count(); int row = mList.count();
beginInsertRows(QModelIndex(), row, row); beginInsertRows(QModelIndex(), row, row);
m_list << call; mList << call;
endInsertRows(); endInsertRows();
} }
void CallsListModel::removeCall (const shared_ptr<linphone::Call> &linphone_call) { void CallsListModel::removeCall (const shared_ptr<linphone::Call> &linphoneCall) {
// TODO: It will be (maybe) necessary to use a single scheduled function in the future. // TODO: It will be (maybe) necessary to use a single scheduled function in the future.
QTimer::singleShot( QTimer::singleShot(
DELAY_BEFORE_REMOVE_CALL, this, [this, linphone_call]() { DELAY_BEFORE_REMOVE_CALL, this, [this, linphoneCall]() {
CallModel *call = &linphone_call->getData<CallModel>("call-model"); CallModel *call = &linphoneCall->getData<CallModel>("call-model");
linphone_call->unsetData("call-model"); linphoneCall->unsetData("call-model");
qInfo() << "Removing call:" << call; qInfo() << "Removing call:" << call;
int index = m_list.indexOf(call); int index = mList.indexOf(call);
if (index == -1 || !removeRow(index)) if (index == -1 || !removeRow(index))
qWarning() << "Unable to remove call:" << call; qWarning() << "Unable to remove call:" << call;
if (m_list.empty()) if (mList.empty())
App::getInstance()->getCallsWindow()->close(); App::getInstance()->getCallsWindow()->close();
} }
); );
......
...@@ -43,10 +43,10 @@ public: ...@@ -43,10 +43,10 @@ public:
QHash<int, QByteArray> roleNames () const override; QHash<int, QByteArray> roleNames () const override;
QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override;
CallModel *getCall (const std::shared_ptr<linphone::Call> &linphone_call) const; CallModel *getCall (const std::shared_ptr<linphone::Call> &linphoneCall) const;
Q_INVOKABLE void launchAudioCall (const QString &sip_uri) const; Q_INVOKABLE void launchAudioCall (const QString &sipUri) const;
Q_INVOKABLE void launchVideoCall (const QString &sip_uri) const; Q_INVOKABLE void launchVideoCall (const QString &sipUri) const;
Q_INVOKABLE int getRunningCallsNumber () const; Q_INVOKABLE int getRunningCallsNumber () const;
...@@ -59,12 +59,12 @@ private: ...@@ -59,12 +59,12 @@ private:
bool removeRow (int row, const QModelIndex &parent = QModelIndex()); bool removeRow (int row, const QModelIndex &parent = QModelIndex());
bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override; bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override;
void addCall (const std::shared_ptr<linphone::Call> &linphone_call); void addCall (const std::shared_ptr<linphone::Call> &linphoneCall);
void removeCall (const std::shared_ptr<linphone::Call> &linphone_call); void removeCall (const std::shared_ptr<linphone::Call> &linphoneCall);
QList<CallModel *> m_list; QList<CallModel *> mList;
std::shared_ptr<CoreHandlers> m_core_handlers; std::shared_ptr<CoreHandlers> mCoreHandlers;
}; };
#endif // CALLS_LIST_MODEL_H_ #endif // CALLS_LIST_MODEL_H_
...@@ -47,24 +47,24 @@ struct ContextInfo { ...@@ -47,24 +47,24 @@ struct ContextInfo {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
CameraRenderer::CameraRenderer () { CameraRenderer::CameraRenderer () {
m_context_info = new ContextInfo(); mContextInfo = new ContextInfo();
} }
CameraRenderer::~CameraRenderer () { CameraRenderer::~CameraRenderer () {
qInfo() << QStringLiteral("Delete context info:") << m_context_info; qInfo() << QStringLiteral("Delete context info:") << mContextInfo;
CoreManager *core = CoreManager::getInstance(); CoreManager *core = CoreManager::getInstance();
core->lockVideoRender(); core->lockVideoRender();
if (m_is_preview) if (mIsPreview)
CoreManager::getInstance()->getCore()->setNativePreviewWindowId(nullptr); CoreManager::getInstance()->getCore()->setNativePreviewWindowId(nullptr);
else if (m_linphone_call) else if (mLinphoneCall)
m_linphone_call->setNativeVideoWindowId(nullptr); mLinphoneCall->setNativeVideoWindowId(nullptr);
core->unlockVideoRender(); core->unlockVideoRender();
delete m_context_info; delete mContextInfo;
} }
QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize &size) { QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize &size) {
...@@ -78,10 +78,10 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize & ...@@ -78,10 +78,10 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize &
// It's not the same thread as render. // It's not the same thread as render.
core->lockVideoRender(); core->lockVideoRender();
m_context_info->width = size.width(); mContextInfo->width = size.width();
m_context_info->height = size.height(); mContextInfo->height = size.height();
m_context_info->functions = MSFunctions::getInstance()->getFunctions(); mContextInfo->functions = MSFunctions::getInstance()->getFunctions();
m_update_context_info = true; mUpdateContextInfo = true;
updateWindowId(); updateWindowId();
...@@ -91,7 +91,7 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize & ...@@ -91,7 +91,7 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize &
} }
void CameraRenderer::render () { void CameraRenderer::render () {
if (!m_linphone_call) if (!mLinphoneCall)
return; return;
// Draw with ms filter. // Draw with ms filter.
...@@ -102,48 +102,48 @@ void CameraRenderer::render () { ...@@ -102,48 +102,48 @@ void CameraRenderer::render () {
f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
CoreManager *core = CoreManager::getInstance(); CoreManager *core = CoreManager::getInstance();
MSFunctions *ms_functions = MSFunctions::getInstance(); MSFunctions *msFunctions = MSFunctions::getInstance();
core->lockVideoRender(); core->lockVideoRender();
ms_functions->bind(f); msFunctions->bind(f);
m_linphone_call->oglRender(m_is_preview); mLinphoneCall->oglRender(mIsPreview);
ms_functions->bind(nullptr); msFunctions->bind(nullptr);
core->unlockVideoRender(); core->unlockVideoRender();
} }
// Synchronize opengl calls with QML. // Synchronize opengl calls with QML.
if (m_window) if (mWindow)
m_window->resetOpenGLState(); mWindow->resetOpenGLState();
} }
void CameraRenderer::synchronize (QQuickFramebufferObject *item) { void CameraRenderer::synchronize (QQuickFramebufferObject *item) {
// No mutex needed here. It's a synchronized area. // No mutex needed here. It's a synchronized area.
m_window = item->window(); mWindow = item->window();
Camera *camera = qobject_cast<Camera *>(item); Camera *camera = qobject_cast<Camera *>(item);
m_linphone_call = camera->getCall()->getLinphoneCall(); mLinphoneCall = camera->getCall()->getLinphoneCall();
m_is_preview = camera->m_is_preview; mIsPreview = camera->mIsPreview;
updateWindowId(); updateWindowId();
} }
void CameraRenderer::updateWindowId () { void CameraRenderer::updateWindowId () {
if (!m_update_context_info) if (!mUpdateContextInfo)
return; return;
m_update_context_info = false; mUpdateContextInfo = false;
qInfo() << "Thread" << QThread::currentThread() << QStringLiteral("Set context info (width: %1, height: %2, is_preview: %3):") qInfo() << "Thread" << QThread::currentThread() << QStringLiteral("Set context info (width: %1, height: %2, is_preview: %3):")
.arg(m_context_info->width).arg(m_context_info->height).arg(m_is_preview) << m_context_info; .arg(mContextInfo->width).arg(mContextInfo->height).arg(mIsPreview) << mContextInfo;
if (m_is_preview) if (mIsPreview)
CoreManager::getInstance()->getCore()->setNativePreviewWindowId(m_context_info); CoreManager::getInstance()->getCore()->setNativePreviewWindowId(mContextInfo);
else if (m_linphone_call) else if (mLinphoneCall)
m_linphone_call->setNativeVideoWindowId(m_context_info); mLinphoneCall->setNativeVideoWindowId(mContextInfo);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -155,16 +155,16 @@ Camera::Camera (QQuickItem *parent) : QQuickFramebufferObject(parent) { ...@@ -155,16 +155,16 @@ Camera::Camera (QQuickItem *parent) : QQuickFramebufferObject(parent) {
// The fbo content must be y-mirrored because the ms rendering is y-inverted. // The fbo content must be y-mirrored because the ms rendering is y-inverted.
setMirrorVertically(true); setMirrorVertically(true);
m_refresh_timer = new QTimer(this); mRefreshTimer = new QTimer(this);
m_refresh_timer->setInterval(1 / MAX_FPS * 1000); mRefreshTimer->setInterval(1 / MAX_FPS * 1000);
QObject::connect( QObject::connect(
m_refresh_timer, &QTimer::timeout, mRefreshTimer, &QTimer::timeout,
this, &QQuickFramebufferObject::update, this, &QQuickFramebufferObject::update,
Qt::DirectConnection Qt::DirectConnection
); );
m_refresh_timer->start(); mRefreshTimer->start();
} }
QQuickFramebufferObject::Renderer *Camera::createRenderer () const { QQuickFramebufferObject::Renderer *Camera::createRenderer () const {
...@@ -178,25 +178,25 @@ void Camera::mousePressEvent (QMouseEvent *) { ...@@ -178,25 +178,25 @@ void Camera::mousePressEvent (QMouseEvent *) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
CallModel *Camera::getCall () const { CallModel *Camera::getCall () const {
return m_call; return mCall;
} }
void Camera::setCall (CallModel *call) { void Camera::setCall (CallModel *call) {
if (m_call != call) { if (mCall != call) {
m_call = call; mCall = call;
update(); update();
emit callChanged(m_call); emit callChanged(mCall);
} }
} }
bool Camera::getIsPreview () const { bool Camera::getIsPreview () const {
return m_is_preview; return mIsPreview;
} }
void Camera::setIsPreview (bool status) { void Camera::setIsPreview (bool status) {
if (m_is_preview != status) { if (mIsPreview != status) {
m_is_preview = status; mIsPreview = status;
update(); update();
emit isPreviewChanged(status); emit isPreviewChanged(status);
......
...@@ -53,13 +53,13 @@ protected: ...@@ -53,13 +53,13 @@ protected:
private: private:
void updateWindowId (); void updateWindowId ();
ContextInfo *m_context_info; ContextInfo *mContextInfo;
bool m_update_context_info = false; bool mUpdateContextInfo = false;
bool m_is_preview = false; bool mIsPreview = false;
std::shared_ptr<linphone::Call> m_linphone_call; std::shared_ptr<linphone::Call> mLinphoneCall;
QQuickWindow *m_window; QQuickWindow *mWindow;
}; };
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -80,7 +80,7 @@ public: ...@@ -80,7 +80,7 @@ public:
signals: signals:
void callChanged (CallModel *call); void callChanged (CallModel *call);
void isPreviewChanged (bool is_preview); void isPreviewChanged (bool isPreview);
protected: protected:
void mousePressEvent (QMouseEvent *event) override; void mousePressEvent (QMouseEvent *event) override;
...@@ -92,10 +92,10 @@ private: ...@@ -92,10 +92,10 @@ private:
bool getIsPreview () const; bool getIsPreview () const;
void setIsPreview (bool status); void setIsPreview (bool status);
bool m_is_preview = false; bool mIsPreview = false;
CallModel *m_call = nullptr; CallModel *mCall = nullptr;
QTimer *m_refresh_timer; QTimer *mRefreshTimer;
}; };
#endif // CAMERA_H_ #endif // CAMERA_H_
...@@ -27,12 +27,12 @@ ...@@ -27,12 +27,12 @@
// ============================================================================= // =============================================================================
MSFunctions *MSFunctions::m_instance = nullptr; MSFunctions *MSFunctions::mInstance = nullptr;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
MSFunctions::MSFunctions () { MSFunctions::MSFunctions () {
OpenGlFunctions *f = m_functions = new OpenGlFunctions(); OpenGlFunctions *f = mFunctions = new OpenGlFunctions();
f->glActiveTexture = qtResolveGlActiveTexture; f->glActiveTexture = qtResolveGlActiveTexture;
f->glAttachShader = qtResolveGlAttachShader; f->glAttachShader = qtResolveGlAttachShader;
...@@ -73,5 +73,5 @@ MSFunctions::MSFunctions () { ...@@ -73,5 +73,5 @@ MSFunctions::MSFunctions () {
} }
MSFunctions::~MSFunctions () { MSFunctions::~MSFunctions () {
delete m_functions; delete mFunctions;
} }
...@@ -26,16 +26,16 @@ ...@@ -26,16 +26,16 @@
#include <QOpenGLFunctions> #include <QOpenGLFunctions>
#define GL_ASSERT() \ #define GL_ASSERT() \
Q_ASSERT(m_instance->m_q_functions != NULL); \ Q_ASSERT(mInstance->mQtFunctions != NULL); \
Q_ASSERT(QOpenGLContext::currentContext()->functions() == m_instance->m_q_functions); Q_ASSERT(QOpenGLContext::currentContext()->functions() == mInstance->mQtFunctions);
#define GL_CALL(CALL) \ #define GL_CALL(CALL) \
GL_ASSERT() \ GL_ASSERT() \
m_instance->m_q_functions->CALL; mInstance->mQtFunctions->CALL;
#define GL_CALL_RET(CALL) \ #define GL_CALL_RET(CALL) \
GL_ASSERT() \ GL_ASSERT() \
return m_instance->m_q_functions->CALL; return mInstance->mQtFunctions->CALL;
// ============================================================================= // =============================================================================
...@@ -46,20 +46,20 @@ public: ...@@ -46,20 +46,20 @@ public:
~MSFunctions (); ~MSFunctions ();
void bind (QOpenGLFunctions *f) { void bind (QOpenGLFunctions *f) {
m_q_functions = f; // Qt functions. mQtFunctions = f; // Qt functions.
} }
OpenGlFunctions *getFunctions () { OpenGlFunctions *getFunctions () {
return m_functions; // Own implementation. return mFunctions; // Own implementation.
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
static MSFunctions *getInstance () { static MSFunctions *getInstance () {
if (!m_instance) if (!mInstance)
m_instance = new MSFunctions(); mInstance = new MSFunctions();
return m_instance; return mInstance;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -213,10 +213,10 @@ public: ...@@ -213,10 +213,10 @@ public:
private: private:
MSFunctions (); MSFunctions ();
OpenGlFunctions *m_functions = nullptr; OpenGlFunctions *mFunctions = nullptr;
QOpenGLFunctions *m_q_functions = nullptr; QOpenGLFunctions *mQtFunctions = nullptr;
static MSFunctions *m_instance; static MSFunctions *mInstance;
}; };
#undef GL_CALL #undef GL_CALL
......
...@@ -86,7 +86,7 @@ public: ...@@ -86,7 +86,7 @@ public:
bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override; bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override;
QString getSipAddress () const; QString getSipAddress () const;
void setSipAddress (const QString &sip_address); void setSipAddress (const QString &sipAddress);
void removeEntry (int id); void removeEntry (int id);
void removeAllEntries (); void removeAllEntries ();
...@@ -97,10 +97,10 @@ public: ...@@ -97,10 +97,10 @@ public:
void sendFileMessage (const QString &path); void sendFileMessage (const QString &path);
void downloadFile (int id, const QString &download_path); void downloadFile (int id, const QString &downloadPath);
signals: signals:
void sipAddressChanged (const QString &sip_address); void sipAddressChanged (const QString &sipAddress);
void allEntriesRemoved (); void allEntriesRemoved ();
void messageSent (const std::shared_ptr<linphone::ChatMessage> &message); void messageSent (const std::shared_ptr<linphone::ChatMessage> &message);
...@@ -112,12 +112,12 @@ private: ...@@ -112,12 +112,12 @@ private:
typedef QPair<QVariantMap, std::shared_ptr<void> > ChatEntryData; typedef QPair<QVariantMap, std::shared_ptr<void> > ChatEntryData;
void fillMessageEntry (QVariantMap &dest, const std::shared_ptr<linphone::ChatMessage> &message); void fillMessageEntry (QVariantMap &dest, const std::shared_ptr<linphone::ChatMessage> &message);
void fillCallStartEntry (QVariantMap &dest, const std::shared_ptr<linphone::CallLog> &call_log); void fillCallStartEntry (QVariantMap &dest, const std::shared_ptr<linphone::CallLog> &callLog);
void fillCallEndEntry (QVariantMap &dest, const std::shared_ptr<linphone::CallLog> &call_log); void fillCallEndEntry (QVariantMap &dest, const std::shared_ptr<linphone::CallLog> &callLog);
void removeEntry (ChatEntryData &pair); void removeEntry (ChatEntryData &pair);
void insertCall (const std::shared_ptr<linphone::CallLog> &call_log); void insertCall (const std::shared_ptr<linphone::CallLog> &callLog);
void insertMessageAtEnd (const std::shared_ptr<linphone::ChatMessage> &message); void insertMessageAtEnd (const std::shared_ptr<linphone::ChatMessage> &message);
void resetMessagesCount (); void resetMessagesCount ();
...@@ -125,11 +125,11 @@ private: ...@@ -125,11 +125,11 @@ private:
void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state); void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state);
void handleMessageReceived (const std::shared_ptr<linphone::ChatMessage> &message); void handleMessageReceived (const std::shared_ptr<linphone::ChatMessage> &message);
QList<ChatEntryData> m_entries; QList<ChatEntryData> mEntries;
std::shared_ptr<linphone::ChatRoom> m_chat_room; std::shared_ptr<linphone::ChatRoom> mChatRoom;
std::shared_ptr<CoreHandlers> m_core_handlers; std::shared_ptr<CoreHandlers> mCoreHandlers;
std::shared_ptr<MessageHandlers> m_message_handlers; std::shared_ptr<MessageHandlers> mMessageHandlers;
}; };
#endif // CHAT_MODEL_H_ #endif // CHAT_MODEL_H_
...@@ -30,32 +30,32 @@ using namespace std; ...@@ -30,32 +30,32 @@ using namespace std;
class ChatProxyModel::ChatModelFilter : public QSortFilterProxyModel { class ChatProxyModel::ChatModelFilter : public QSortFilterProxyModel {
public: public:
ChatModelFilter (QObject *parent) : QSortFilterProxyModel(parent) { ChatModelFilter (QObject *parent) : QSortFilterProxyModel(parent) {
setSourceModel(&m_chat_model); setSourceModel(&mChatModel);
} }
ChatModel::EntryType getEntryTypeFilter () { ChatModel::EntryType getEntryTypeFilter () {
return m_entry_type_filter; return mEntryTypeFilter;
} }
void setEntryTypeFilter (ChatModel::EntryType type) { void setEntryTypeFilter (ChatModel::EntryType type) {
m_entry_type_filter = type; mEntryTypeFilter = type;
invalidate(); invalidate();
} }
protected: protected:
bool filterAcceptsRow (int source_row, const QModelIndex &) const override { bool filterAcceptsRow (int sourceRow, const QModelIndex &) const override {
if (m_entry_type_filter == ChatModel::EntryType::GenericEntry) if (mEntryTypeFilter == ChatModel::EntryType::GenericEntry)
return true; return true;
QModelIndex index = sourceModel()->index(source_row, 0, QModelIndex()); QModelIndex index = sourceModel()->index(sourceRow, 0, QModelIndex());
const QVariantMap &data = index.data().toMap(); const QVariantMap &data = index.data().toMap();
return data["type"].toInt() == m_entry_type_filter; return data["type"].toInt() == mEntryTypeFilter;
} }
private: private:
ChatModel m_chat_model; ChatModel mChatModel;
ChatModel::EntryType m_entry_type_filter = ChatModel::EntryType::GenericEntry; ChatModel::EntryType mEntryTypeFilter = ChatModel::EntryType::GenericEntry;
}; };
// ============================================================================= // =============================================================================
...@@ -63,34 +63,34 @@ private: ...@@ -63,34 +63,34 @@ private:
const int ChatProxyModel::ENTRIES_CHUNK_SIZE = 50; const int ChatProxyModel::ENTRIES_CHUNK_SIZE = 50;
ChatProxyModel::ChatProxyModel (QObject *parent) : QSortFilterProxyModel(parent) { ChatProxyModel::ChatProxyModel (QObject *parent) : QSortFilterProxyModel(parent) {
m_chat_model_filter = new ChatModelFilter(this); mChatModelFilter = new ChatModelFilter(this);
setSourceModel(m_chat_model_filter); setSourceModel(mChatModelFilter);
ChatModel *chat = static_cast<ChatModel *>(m_chat_model_filter->sourceModel()); ChatModel *chat = static_cast<ChatModel *>(mChatModelFilter->sourceModel());
QObject::connect( QObject::connect(
chat, &ChatModel::messageReceived, this, [this](const shared_ptr<linphone::ChatMessage> &) { chat, &ChatModel::messageReceived, this, [this](const shared_ptr<linphone::ChatMessage> &) {
m_n_max_displayed_entries++; mMaxDisplayedEntries++;
} }
); );
QObject::connect( QObject::connect(
chat, &ChatModel::messageSent, this, [this](const shared_ptr<linphone::ChatMessage> &) { chat, &ChatModel::messageSent, this, [this](const shared_ptr<linphone::ChatMessage> &) {
m_n_max_displayed_entries++; mMaxDisplayedEntries++;
} }
); );
} }
void ChatProxyModel::loadMoreEntries () { void ChatProxyModel::loadMoreEntries () {
int count = rowCount(); int count = rowCount();
int parent_count = m_chat_model_filter->rowCount(); int parentCount = mChatModelFilter->rowCount();
if (count < parent_count) { if (count < parentCount) {
// Do not increase `m_n_max_displayed_entries` if it's not necessary... // Do not increase `mMaxDisplayedEntries` if it's not necessary...
// Limit qml calls. // Limit qml calls.
if (count == m_n_max_displayed_entries) if (count == mMaxDisplayedEntries)
m_n_max_displayed_entries += ENTRIES_CHUNK_SIZE; mMaxDisplayedEntries += ENTRIES_CHUNK_SIZE;
invalidateFilter(); invalidateFilter();
...@@ -101,59 +101,59 @@ void ChatProxyModel::loadMoreEntries () { ...@@ -101,59 +101,59 @@ void ChatProxyModel::loadMoreEntries () {
} }
void ChatProxyModel::setEntryTypeFilter (ChatModel::EntryType type) { void ChatProxyModel::setEntryTypeFilter (ChatModel::EntryType type) {
if (m_chat_model_filter->getEntryTypeFilter() != type) { if (mChatModelFilter->getEntryTypeFilter() != type) {
m_chat_model_filter->setEntryTypeFilter(type); mChatModelFilter->setEntryTypeFilter(type);
emit entryTypeFilterChanged(type); emit entryTypeFilterChanged(type);
} }
} }
void ChatProxyModel::removeEntry (int id) { void ChatProxyModel::removeEntry (int id) {
QModelIndex source_index = mapToSource(index(id, 0)); QModelIndex sourceIndex = mapToSource(index(id, 0));
static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->removeEntry( static_cast<ChatModel *>(mChatModelFilter->sourceModel())->removeEntry(
m_chat_model_filter->mapToSource(source_index).row() mChatModelFilter->mapToSource(sourceIndex).row()
); );
} }
void ChatProxyModel::removeAllEntries () { void ChatProxyModel::removeAllEntries () {
static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->removeAllEntries(); static_cast<ChatModel *>(mChatModelFilter->sourceModel())->removeAllEntries();
} }
void ChatProxyModel::sendMessage (const QString &message) { void ChatProxyModel::sendMessage (const QString &message) {
static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->sendMessage(message); static_cast<ChatModel *>(mChatModelFilter->sourceModel())->sendMessage(message);
} }
void ChatProxyModel::resendMessage (int id) { void ChatProxyModel::resendMessage (int id) {
QModelIndex source_index = mapToSource(index(id, 0)); QModelIndex sourceIndex = mapToSource(index(id, 0));
static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->resendMessage( static_cast<ChatModel *>(mChatModelFilter->sourceModel())->resendMessage(
m_chat_model_filter->mapToSource(source_index).row() mChatModelFilter->mapToSource(sourceIndex).row()
); );
} }
void ChatProxyModel::sendFileMessage (const QString &path) { void ChatProxyModel::sendFileMessage (const QString &path) {
static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->sendFileMessage(path); static_cast<ChatModel *>(mChatModelFilter->sourceModel())->sendFileMessage(path);
} }
void ChatProxyModel::downloadFile (int id, const QString &download_path) { void ChatProxyModel::downloadFile (int id, const QString &downloadPath) {
QModelIndex source_index = mapToSource(index(id, 0)); QModelIndex sourceIndex = mapToSource(index(id, 0));
static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->downloadFile( static_cast<ChatModel *>(mChatModelFilter->sourceModel())->downloadFile(
m_chat_model_filter->mapToSource(source_index).row(), download_path mChatModelFilter->mapToSource(sourceIndex).row(), downloadPath
); );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool ChatProxyModel::filterAcceptsRow (int source_row, const QModelIndex &) const { bool ChatProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex &) const {
return m_chat_model_filter->rowCount() - source_row <= m_n_max_displayed_entries; return mChatModelFilter->rowCount() - sourceRow <= mMaxDisplayedEntries;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
QString ChatProxyModel::getSipAddress () const { QString ChatProxyModel::getSipAddress () const {
return static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->getSipAddress(); return static_cast<ChatModel *>(mChatModelFilter->sourceModel())->getSipAddress();
} }
void ChatProxyModel::setSipAddress (const QString &sip_address) { void ChatProxyModel::setSipAddress (const QString &sipAddress) {
static_cast<ChatModel *>(m_chat_model_filter->sourceModel())->setSipAddress( static_cast<ChatModel *>(mChatModelFilter->sourceModel())->setSipAddress(
sip_address sipAddress
); );
} }
...@@ -50,23 +50,23 @@ public: ...@@ -50,23 +50,23 @@ public:
Q_INVOKABLE void sendFileMessage (const QString &path); Q_INVOKABLE void sendFileMessage (const QString &path);
Q_INVOKABLE void downloadFile (int id, const QString &download_path); Q_INVOKABLE void downloadFile (int id, const QString &downloadPath);
signals: signals:
void sipAddressChanged (const QString &sip_address); void sipAddressChanged (const QString &sipAddress);
void moreEntriesLoaded (int n); void moreEntriesLoaded (int n);
void entryTypeFilterChanged (ChatModel::EntryType type); void entryTypeFilterChanged (ChatModel::EntryType type);
protected: protected:
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override; bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override;
private: private:
QString getSipAddress () const; QString getSipAddress () const;
void setSipAddress (const QString &sip_address); void setSipAddress (const QString &sipAddress);
ChatModelFilter *m_chat_model_filter; ChatModelFilter *mChatModelFilter;
int m_n_max_displayed_entries = ENTRIES_CHUNK_SIZE; int mMaxDisplayedEntries = ENTRIES_CHUNK_SIZE;
static const int ENTRIES_CHUNK_SIZE; static const int ENTRIES_CHUNK_SIZE;
}; };
......
...@@ -38,7 +38,7 @@ inline shared_ptr<linphone::PayloadType> getCodecFromMap (const QVariantMap &map ...@@ -38,7 +38,7 @@ inline shared_ptr<linphone::PayloadType> getCodecFromMap (const QVariantMap &map
AbstractCodecsModel::AbstractCodecsModel (QObject *parent) : QAbstractListModel(parent) {} AbstractCodecsModel::AbstractCodecsModel (QObject *parent) : QAbstractListModel(parent) {}
int AbstractCodecsModel::rowCount (const QModelIndex &) const { int AbstractCodecsModel::rowCount (const QModelIndex &) const {
return m_codecs.count(); return mCodecs.count();
} }
QHash<int, QByteArray> AbstractCodecsModel::roleNames () const { QHash<int, QByteArray> AbstractCodecsModel::roleNames () const {
...@@ -50,11 +50,11 @@ QHash<int, QByteArray> AbstractCodecsModel::roleNames () const { ...@@ -50,11 +50,11 @@ QHash<int, QByteArray> AbstractCodecsModel::roleNames () const {
QVariant AbstractCodecsModel::data (const QModelIndex &index, int role) const { QVariant AbstractCodecsModel::data (const QModelIndex &index, int role) const {
int row = index.row(); int row = index.row();
if (!index.isValid() || row < 0 || row >= m_codecs.count()) if (!index.isValid() || row < 0 || row >= mCodecs.count())
return QVariant(); return QVariant();
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
return m_codecs[row]; return mCodecs[row];
return QVariant(); return QVariant();
} }
...@@ -62,9 +62,9 @@ QVariant AbstractCodecsModel::data (const QModelIndex &index, int role) const { ...@@ -62,9 +62,9 @@ QVariant AbstractCodecsModel::data (const QModelIndex &index, int role) const {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void AbstractCodecsModel::enableCodec (int id, bool status) { void AbstractCodecsModel::enableCodec (int id, bool status) {
Q_ASSERT(id >= 0 && id < m_codecs.count()); Q_ASSERT(id >= 0 && id < mCodecs.count());
QVariantMap &map = m_codecs[id]; QVariantMap &map = mCodecs[id];
shared_ptr<linphone::PayloadType> codec = getCodecFromMap(map); shared_ptr<linphone::PayloadType> codec = getCodecFromMap(map);
codec->enable(status); codec->enable(status);
...@@ -78,9 +78,9 @@ void AbstractCodecsModel::moveCodec (int source, int destination) { ...@@ -78,9 +78,9 @@ void AbstractCodecsModel::moveCodec (int source, int destination) {
} }
void AbstractCodecsModel::setBitrate (int id, int bitrate) { void AbstractCodecsModel::setBitrate (int id, int bitrate) {
Q_ASSERT(id >= 0 && id < m_codecs.count()); Q_ASSERT(id >= 0 && id < mCodecs.count());
QVariantMap &map = m_codecs[id]; QVariantMap &map = mCodecs[id];
shared_ptr<linphone::PayloadType> codec = getCodecFromMap(map); shared_ptr<linphone::PayloadType> codec = getCodecFromMap(map);
codec->setNormalBitrate(bitrate); codec->setNormalBitrate(bitrate);
...@@ -89,13 +89,13 @@ void AbstractCodecsModel::setBitrate (int id, int bitrate) { ...@@ -89,13 +89,13 @@ void AbstractCodecsModel::setBitrate (int id, int bitrate) {
emit dataChanged(index(id, 0), index(id, 0)); emit dataChanged(index(id, 0), index(id, 0));
} }
void AbstractCodecsModel::setRecvFmtp (int id, const QString &recv_fmtp) { void AbstractCodecsModel::setRecvFmtp (int id, const QString &recvFmtp) {
Q_ASSERT(id >= 0 && id < m_codecs.count()); Q_ASSERT(id >= 0 && id < mCodecs.count());
QVariantMap &map = m_codecs[id]; QVariantMap &map = mCodecs[id];
shared_ptr<linphone::PayloadType> codec = getCodecFromMap(map); shared_ptr<linphone::PayloadType> codec = getCodecFromMap(map);
codec->setRecvFmtp(::Utils::qStringToLinphoneString(recv_fmtp)); codec->setRecvFmtp(::Utils::qStringToLinphoneString(recvFmtp));
map["recvFmtp"] = ::Utils::linphoneStringToQString(codec->getRecvFmtp()); map["recvFmtp"] = ::Utils::linphoneStringToQString(codec->getRecvFmtp());
emit dataChanged(index(id, 0), index(id, 0)); emit dataChanged(index(id, 0), index(id, 0));
...@@ -104,43 +104,43 @@ void AbstractCodecsModel::setRecvFmtp (int id, const QString &recv_fmtp) { ...@@ -104,43 +104,43 @@ void AbstractCodecsModel::setRecvFmtp (int id, const QString &recv_fmtp) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool AbstractCodecsModel::moveRows ( bool AbstractCodecsModel::moveRows (
const QModelIndex &source_parent, const QModelIndex &sourceParent,
int source_row, int sourceRow,
int count, int count,
const QModelIndex &destination_parent, const QModelIndex &destinationParent,
int destination_child int destinationChild
) { ) {
int limit = source_row + count - 1; int limit = sourceRow + count - 1;
{ {
int n_codecs = m_codecs.count(); int nCodecs = mCodecs.count();
if ( if (
source_row < 0 || sourceRow < 0 ||
destination_child < 0 || destinationChild < 0 ||
count < 0 || count < 0 ||
destination_child > n_codecs || destinationChild > nCodecs ||
limit >= n_codecs || limit >= nCodecs ||
(source_row <= destination_child && source_row + count >= destination_child) (sourceRow <= destinationChild && sourceRow + count >= destinationChild)
) )
return false; return false;
} }
beginMoveRows(source_parent, source_row, limit, destination_parent, destination_child); beginMoveRows(sourceParent, sourceRow, limit, destinationParent, destinationChild);
// Update UI. // Update UI.
if (destination_child > source_row) { if (destinationChild > sourceRow) {
--destination_child; --destinationChild;
for (int i = source_row; i <= limit; ++i) { for (int i = sourceRow; i <= limit; ++i) {
m_codecs.move(source_row, destination_child + i - source_row); mCodecs.move(sourceRow, destinationChild + i - sourceRow);
} }
} else { } else {
for (int i = source_row; i <= limit; ++i) for (int i = sourceRow; i <= limit; ++i)
m_codecs.move(source_row + i - source_row, destination_child + i - source_row); mCodecs.move(sourceRow + i - sourceRow, destinationChild + i - sourceRow);
} }
// Update linphone codecs list. // Update linphone codecs list.
list<shared_ptr<linphone::PayloadType> > codecs; list<shared_ptr<linphone::PayloadType> > codecs;
for (const auto &map : m_codecs) for (const auto &map : mCodecs)
codecs.push_back(getCodecFromMap(map)); codecs.push_back(getCodecFromMap(map));
updateCodecs(codecs); updateCodecs(codecs);
...@@ -151,7 +151,7 @@ bool AbstractCodecsModel::moveRows ( ...@@ -151,7 +151,7 @@ bool AbstractCodecsModel::moveRows (
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void AbstractCodecsModel::addCodec (std::shared_ptr<linphone::PayloadType> &codec) { void AbstractCodecsModel::addCodec (shared_ptr<linphone::PayloadType> &codec) {
QVariantMap map; QVariantMap map;
map["bitrate"] = codec->getNormalBitrate(); map["bitrate"] = codec->getNormalBitrate();
...@@ -167,5 +167,5 @@ void AbstractCodecsModel::addCodec (std::shared_ptr<linphone::PayloadType> &code ...@@ -167,5 +167,5 @@ void AbstractCodecsModel::addCodec (std::shared_ptr<linphone::PayloadType> &code
map["recvFmtp"] = ::Utils::linphoneStringToQString(codec->getRecvFmtp()); map["recvFmtp"] = ::Utils::linphoneStringToQString(codec->getRecvFmtp());
map["__codec"] = QVariant::fromValue(codec); map["__codec"] = QVariant::fromValue(codec);
m_codecs << map; mCodecs << map;
} }
...@@ -49,15 +49,15 @@ public: ...@@ -49,15 +49,15 @@ public:
Q_INVOKABLE void moveCodec (int source, int destination); Q_INVOKABLE void moveCodec (int source, int destination);
Q_INVOKABLE void setBitrate (int id, int bitrate); Q_INVOKABLE void setBitrate (int id, int bitrate);
Q_INVOKABLE void setRecvFmtp (int id, const QString &recv_fmtp); Q_INVOKABLE void setRecvFmtp (int id, const QString &recvFmtp);
protected: protected:
bool moveRows ( bool moveRows (
const QModelIndex &source_parent, const QModelIndex &sourceParent,
int source_row, int sourceRow,
int count, int count,
const QModelIndex &destination_parent, const QModelIndex &destinationParent,
int destination_child int destinationChild
) override; ) override;
void addCodec (std::shared_ptr<linphone::PayloadType> &codec); void addCodec (std::shared_ptr<linphone::PayloadType> &codec);
...@@ -65,7 +65,7 @@ protected: ...@@ -65,7 +65,7 @@ protected:
virtual void updateCodecs (std::list<std::shared_ptr<linphone::PayloadType> > &codecs) = 0; virtual void updateCodecs (std::list<std::shared_ptr<linphone::PayloadType> > &codecs) = 0;
private: private:
QList<QVariantMap> m_codecs; QList<QVariantMap> mCodecs;
}; };
Q_DECLARE_METATYPE(std::shared_ptr<linphone::PayloadType> ); Q_DECLARE_METATYPE(std::shared_ptr<linphone::PayloadType> );
......
...@@ -30,12 +30,12 @@ using namespace std; ...@@ -30,12 +30,12 @@ using namespace std;
// ============================================================================= // =============================================================================
ContactModel::ContactModel (QObject *parent, shared_ptr<linphone::Friend> linphone_friend) : QObject(parent) { ContactModel::ContactModel (QObject *parent, shared_ptr<linphone::Friend> linphoneFriend) : QObject(parent) {
m_linphone_friend = linphone_friend; mLinphoneFriend = linphoneFriend;
m_vcard = make_shared<VcardModel>(linphone_friend->getVcard()); mVcard = make_shared<VcardModel>(linphoneFriend->getVcard());
App::getInstance()->getEngine()->setObjectOwnership(m_vcard.get(), QQmlEngine::CppOwnership); App::getInstance()->getEngine()->setObjectOwnership(mVcard.get(), QQmlEngine::CppOwnership);
m_linphone_friend->setData("contact-model", *this); mLinphoneFriend->setData("contact-model", *this);
} }
ContactModel::ContactModel (QObject *parent, VcardModel *vcard) : QObject(parent) { ContactModel::ContactModel (QObject *parent, VcardModel *vcard) : QObject(parent) {
...@@ -45,17 +45,17 @@ ContactModel::ContactModel (QObject *parent, VcardModel *vcard) : QObject(parent ...@@ -45,17 +45,17 @@ ContactModel::ContactModel (QObject *parent, VcardModel *vcard) : QObject(parent
if (engine->objectOwnership(vcard) == QQmlEngine::CppOwnership) if (engine->objectOwnership(vcard) == QQmlEngine::CppOwnership)
throw invalid_argument("A contact is already linked to this vcard."); throw invalid_argument("A contact is already linked to this vcard.");
m_linphone_friend = linphone::Friend::newFromVcard(vcard->m_vcard); mLinphoneFriend = linphone::Friend::newFromVcard(vcard->mVcard);
m_linphone_friend->setData("contact-model", *this); mLinphoneFriend->setData("contact-model", *this);
m_vcard.reset(vcard); mVcard.reset(vcard);
engine->setObjectOwnership(vcard, QQmlEngine::CppOwnership); engine->setObjectOwnership(vcard, QQmlEngine::CppOwnership);
} }
void ContactModel::refreshPresence () { void ContactModel::refreshPresence () {
Presence::PresenceStatus status = static_cast<Presence::PresenceStatus>( Presence::PresenceStatus status = static_cast<Presence::PresenceStatus>(
m_linphone_friend->getConsolidatedPresence() mLinphoneFriend->getConsolidatedPresence()
); );
emit presenceStatusChanged(status); emit presenceStatusChanged(status);
...@@ -63,41 +63,41 @@ void ContactModel::refreshPresence () { ...@@ -63,41 +63,41 @@ void ContactModel::refreshPresence () {
} }
void ContactModel::startEdit () { void ContactModel::startEdit () {
m_linphone_friend->edit(); mLinphoneFriend->edit();
m_old_sip_addresses = m_vcard->getSipAddresses(); mOldSipAddresses = mVcard->getSipAddresses();
} }
void ContactModel::endEdit () { void ContactModel::endEdit () {
m_linphone_friend->done(); mLinphoneFriend->done();
QVariantList sip_addresses = m_vcard->getSipAddresses(); QVariantList sipAddresses = mVcard->getSipAddresses();
QSet<QString> done; QSet<QString> done;
for (const auto &variant_a : m_old_sip_addresses) { for (const auto &variantA : mOldSipAddresses) {
next: next:
const QString &sip_address = variant_a.toString(); const QString &sipAddress = variantA.toString();
if (done.contains(sip_address)) if (done.contains(sipAddress))
continue; continue;
done.insert(sip_address); done.insert(sipAddress);
// Check if old sip address exists in new set => No changes. // Check if old sip address exists in new set => No changes.
for (const auto &variant_b : sip_addresses) { for (const auto &variantB : sipAddresses) {
if (sip_address == variant_b.toString()) if (sipAddress == variantB.toString())
goto next; goto next;
} }
emit sipAddressRemoved(sip_address); emit sipAddressRemoved(sipAddress);
} }
m_old_sip_addresses.clear(); mOldSipAddresses.clear();
for (const auto &variant : sip_addresses) { for (const auto &variant : sipAddresses) {
const QString &sip_address = variant.toString(); const QString &sipAddress = variant.toString();
if (done.contains(sip_address)) if (done.contains(sipAddress))
continue; continue;
done.insert(sip_address); done.insert(sipAddress);
emit sipAddressAdded(sip_address); emit sipAddressAdded(sipAddress);
} }
emit contactUpdated(); emit contactUpdated();
...@@ -105,14 +105,14 @@ next: ...@@ -105,14 +105,14 @@ next:
void ContactModel::abortEdit () { void ContactModel::abortEdit () {
// TODO: call linphone friend abort function when available. // TODO: call linphone friend abort function when available.
// m_linphone_friend->abort(); // mLinphoneFriend->abort();
m_old_sip_addresses.clear(); mOldSipAddresses.clear();
emit contactUpdated(); emit contactUpdated();
} }
Presence::PresenceStatus ContactModel::getPresenceStatus () const { Presence::PresenceStatus ContactModel::getPresenceStatus () const {
return static_cast<Presence::PresenceStatus>(m_linphone_friend->getConsolidatedPresence()); return static_cast<Presence::PresenceStatus>(mLinphoneFriend->getConsolidatedPresence());
} }
Presence::PresenceLevel ContactModel::getPresenceLevel () const { Presence::PresenceLevel ContactModel::getPresenceLevel () const {
......
...@@ -40,12 +40,12 @@ class ContactModel : public QObject { ...@@ -40,12 +40,12 @@ class ContactModel : public QObject {
friend class SmartSearchBarModel; friend class SmartSearchBarModel;
public: public:
ContactModel (QObject *parent, std::shared_ptr<linphone::Friend> linphone_friend); ContactModel (QObject *parent, std::shared_ptr<linphone::Friend> linphoneFriend);
ContactModel (QObject *parent, VcardModel *vcard); ContactModel (QObject *parent, VcardModel *vcard);
~ContactModel () = default; ~ContactModel () = default;
std::shared_ptr<VcardModel> getVcardModel () const { std::shared_ptr<VcardModel> getVcardModel () const {
return m_vcard; return mVcard;
} }
void refreshPresence (); void refreshPresence ();
...@@ -58,21 +58,21 @@ signals: ...@@ -58,21 +58,21 @@ signals:
void contactUpdated (); void contactUpdated ();
void presenceStatusChanged (Presence::PresenceStatus status); void presenceStatusChanged (Presence::PresenceStatus status);
void presenceLevelChanged (Presence::PresenceLevel level); void presenceLevelChanged (Presence::PresenceLevel level);
void sipAddressAdded (const QString &sip_address); void sipAddressAdded (const QString &sipAddress);
void sipAddressRemoved (const QString &sip_address); void sipAddressRemoved (const QString &sipAddress);
private: private:
Presence::PresenceStatus getPresenceStatus () const; Presence::PresenceStatus getPresenceStatus () const;
Presence::PresenceLevel getPresenceLevel () const; Presence::PresenceLevel getPresenceLevel () const;
VcardModel *getVcardModelPtr () const { VcardModel *getVcardModelPtr () const {
return m_vcard.get(); return mVcard.get();
} }
QVariantList m_old_sip_addresses; QVariantList mOldSipAddresses;
std::shared_ptr<VcardModel> m_vcard; std::shared_ptr<VcardModel> mVcard;
std::shared_ptr<linphone::Friend> m_linphone_friend; std::shared_ptr<linphone::Friend> mLinphoneFriend;
}; };
Q_DECLARE_METATYPE(ContactModel *); Q_DECLARE_METATYPE(ContactModel *);
......
...@@ -42,32 +42,32 @@ class VcardModel : public QObject { ...@@ -42,32 +42,32 @@ class VcardModel : public QObject {
friend class ContactModel; friend class ContactModel;
public: public:
VcardModel (std::shared_ptr<linphone::Vcard> vcard) : m_vcard(vcard) {} VcardModel (std::shared_ptr<linphone::Vcard> vcard) : mVcard(vcard) {}
~VcardModel (); ~VcardModel ();
QString getUsername () const; QString getUsername () const;
QVariantList getSipAddresses () const; QVariantList getSipAddresses () const;
Q_INVOKABLE bool addSipAddress (const QString &sip_address); Q_INVOKABLE bool addSipAddress (const QString &sipAddress);
Q_INVOKABLE void removeSipAddress (const QString &sip_address); Q_INVOKABLE void removeSipAddress (const QString &sipAddress);
Q_INVOKABLE bool updateSipAddress (const QString &old_sip_address, const QString &sip_address); Q_INVOKABLE bool updateSipAddress (const QString &oldSipAddress, const QString &sipAddress);
Q_INVOKABLE bool addCompany (const QString &company); Q_INVOKABLE bool addCompany (const QString &company);
Q_INVOKABLE void removeCompany (const QString &company); Q_INVOKABLE void removeCompany (const QString &company);
Q_INVOKABLE bool updateCompany (const QString &old_company, const QString &company); Q_INVOKABLE bool updateCompany (const QString &oldCompany, const QString &company);
Q_INVOKABLE bool addEmail (const QString &email); Q_INVOKABLE bool addEmail (const QString &email);
Q_INVOKABLE void removeEmail (const QString &email); Q_INVOKABLE void removeEmail (const QString &email);
Q_INVOKABLE bool updateEmail (const QString &old_email, const QString &email); Q_INVOKABLE bool updateEmail (const QString &oldEmail, const QString &email);
Q_INVOKABLE bool addUrl (const QString &url); Q_INVOKABLE bool addUrl (const QString &url);
Q_INVOKABLE void removeUrl (const QString &url); Q_INVOKABLE void removeUrl (const QString &url);
Q_INVOKABLE bool updateUrl (const QString &old_url, const QString &url); Q_INVOKABLE bool updateUrl (const QString &oldUrl, const QString &url);
Q_INVOKABLE void setStreet (const QString &street); Q_INVOKABLE void setStreet (const QString &street);
Q_INVOKABLE void setLocality (const QString &locality); Q_INVOKABLE void setLocality (const QString &locality);
Q_INVOKABLE void setPostalCode (const QString &postal_code); Q_INVOKABLE void setPostalCode (const QString &postalCode);
Q_INVOKABLE void setCountry (const QString &country); Q_INVOKABLE void setCountry (const QString &country);
signals: signals:
...@@ -84,7 +84,7 @@ private: ...@@ -84,7 +84,7 @@ private:
QVariantList getEmails () const; QVariantList getEmails () const;
QVariantList getUrls () const; QVariantList getUrls () const;
std::shared_ptr<linphone::Vcard> m_vcard; std::shared_ptr<linphone::Vcard> mVcard;
}; };
Q_DECLARE_METATYPE(VcardModel *); Q_DECLARE_METATYPE(VcardModel *);
......
...@@ -33,11 +33,11 @@ using namespace std; ...@@ -33,11 +33,11 @@ using namespace std;
// ============================================================================= // =============================================================================
ContactsListModel::ContactsListModel (QObject *parent) : QAbstractListModel(parent) { ContactsListModel::ContactsListModel (QObject *parent) : QAbstractListModel(parent) {
m_linphone_friends = CoreManager::getInstance()->getCore()->getFriendsLists().front(); mLinphoneFriends = CoreManager::getInstance()->getCore()->getFriendsLists().front();
// Init contacts with linphone friends list. // Init contacts with linphone friends list.
for (const auto &friend_ : m_linphone_friends->getFriends()) { for (const auto &_friend : mLinphoneFriends->getFriends()) {
ContactModel *contact = new ContactModel(this, friend_); ContactModel *contact = new ContactModel(this, _friend);
// See: http://doc.qt.io/qt-5/qtqml-cppintegration-data.html#data-ownership // See: http://doc.qt.io/qt-5/qtqml-cppintegration-data.html#data-ownership
// The returned value must have a explicit parent or a QQmlEngine::CppOwnership. // The returned value must have a explicit parent or a QQmlEngine::CppOwnership.
...@@ -48,7 +48,7 @@ ContactsListModel::ContactsListModel (QObject *parent) : QAbstractListModel(pare ...@@ -48,7 +48,7 @@ ContactsListModel::ContactsListModel (QObject *parent) : QAbstractListModel(pare
} }
int ContactsListModel::rowCount (const QModelIndex &) const { int ContactsListModel::rowCount (const QModelIndex &) const {
return m_list.count(); return mList.count();
} }
QHash<int, QByteArray> ContactsListModel::roleNames () const { QHash<int, QByteArray> ContactsListModel::roleNames () const {
...@@ -60,11 +60,11 @@ QHash<int, QByteArray> ContactsListModel::roleNames () const { ...@@ -60,11 +60,11 @@ QHash<int, QByteArray> ContactsListModel::roleNames () const {
QVariant ContactsListModel::data (const QModelIndex &index, int role) const { QVariant ContactsListModel::data (const QModelIndex &index, int role) const {
int row = index.row(); int row = index.row();
if (!index.isValid() || row < 0 || row >= m_list.count()) if (!index.isValid() || row < 0 || row >= mList.count())
return QVariant(); return QVariant();
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
return QVariant::fromValue(m_list[row]); return QVariant::fromValue(mList[row]);
return QVariant(); return QVariant();
} }
...@@ -76,15 +76,15 @@ bool ContactsListModel::removeRow (int row, const QModelIndex &parent) { ...@@ -76,15 +76,15 @@ bool ContactsListModel::removeRow (int row, const QModelIndex &parent) {
bool ContactsListModel::removeRows (int row, int count, const QModelIndex &parent) { bool ContactsListModel::removeRows (int row, int count, const QModelIndex &parent) {
int limit = row + count - 1; int limit = row + count - 1;
if (row < 0 || count < 0 || limit >= m_list.count()) if (row < 0 || count < 0 || limit >= mList.count())
return false; return false;
beginRemoveRows(parent, row, limit); beginRemoveRows(parent, row, limit);
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
ContactModel *contact = m_list.takeAt(row); ContactModel *contact = mList.takeAt(row);
m_linphone_friends->removeFriend(contact->m_linphone_friend); mLinphoneFriends->removeFriend(contact->mLinphoneFriend);
emit contactRemoved(contact); emit contactRemoved(contact);
contact->deleteLater(); contact->deleteLater();
...@@ -104,7 +104,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcard) { ...@@ -104,7 +104,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcard) {
qInfo() << "Add contact:" << contact; qInfo() << "Add contact:" << contact;
if ( if (
m_linphone_friends->addFriend(contact->m_linphone_friend) != mLinphoneFriends->addFriend(contact->mLinphoneFriend) !=
linphone::FriendListStatus::FriendListStatusOK linphone::FriendListStatus::FriendListStatusOK
) { ) {
qWarning() << "Unable to add friend from vcard:" << vcard; qWarning() << "Unable to add friend from vcard:" << vcard;
...@@ -112,7 +112,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcard) { ...@@ -112,7 +112,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcard) {
return nullptr; return nullptr;
} }
int row = m_list.count(); int row = mList.count();
beginInsertRows(QModelIndex(), row, row); beginInsertRows(QModelIndex(), row, row);
addContact(contact); addContact(contact);
...@@ -126,7 +126,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcard) { ...@@ -126,7 +126,7 @@ ContactModel *ContactsListModel::addContact (VcardModel *vcard) {
void ContactsListModel::removeContact (ContactModel *contact) { void ContactsListModel::removeContact (ContactModel *contact) {
qInfo() << "Removing contact:" << contact; qInfo() << "Removing contact:" << contact;
int index = m_list.indexOf(contact); int index = mList.indexOf(contact);
if (index == -1 || !removeRow(index)) if (index == -1 || !removeRow(index))
qWarning() << "Unable to remove contact:" << contact; qWarning() << "Unable to remove contact:" << contact;
} }
...@@ -141,15 +141,15 @@ void ContactsListModel::addContact (ContactModel *contact) { ...@@ -141,15 +141,15 @@ void ContactsListModel::addContact (ContactModel *contact) {
} }
); );
QObject::connect( QObject::connect(
contact, &ContactModel::sipAddressAdded, this, [this, contact](const QString &sip_address) { contact, &ContactModel::sipAddressAdded, this, [this, contact](const QString &sipAddress) {
emit sipAddressAdded(contact, sip_address); emit sipAddressAdded(contact, sipAddress);
} }
); );
QObject::connect( QObject::connect(
contact, &ContactModel::sipAddressRemoved, this, [this, contact](const QString &sip_address) { contact, &ContactModel::sipAddressRemoved, this, [this, contact](const QString &sipAddress) {
emit sipAddressRemoved(contact, sip_address); emit sipAddressRemoved(contact, sipAddress);
} }
); );
m_list << contact; mList << contact;
} }
...@@ -56,14 +56,14 @@ signals: ...@@ -56,14 +56,14 @@ signals:
void contactRemoved (const ContactModel *contact); void contactRemoved (const ContactModel *contact);
void contactUpdated (ContactModel *contact); void contactUpdated (ContactModel *contact);
void sipAddressAdded (ContactModel *contact, const QString &sip_address); void sipAddressAdded (ContactModel *contact, const QString &sipAddress);
void sipAddressRemoved (ContactModel *contact, const QString &sip_address); void sipAddressRemoved (ContactModel *contact, const QString &sipAddress);
private: private:
void addContact (ContactModel *contact); void addContact (ContactModel *contact);
QList<ContactModel *> m_list; QList<ContactModel *> mList;
std::shared_ptr<linphone::FriendList> m_linphone_friends; std::shared_ptr<linphone::FriendList> mLinphoneFriends;
}; };
#endif // CONTACTS_LIST_MODEL_H_ #endif // CONTACTS_LIST_MODEL_H_
...@@ -51,7 +51,7 @@ using namespace std; ...@@ -51,7 +51,7 @@ using namespace std;
// a separator like ` word`. // a separator like ` word`.
// //
// - [_.-;@ ] is the main pattern (a separator). // - [_.-;@ ] is the main pattern (a separator).
const QRegExp ContactsListProxyModel::m_search_separators("^[^_.-;@ ][_.-;@ ]"); const QRegExp ContactsListProxyModel::mSearchSeparators("^[^_.-;@ ][_.-;@ ]");
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -63,38 +63,38 @@ ContactsListProxyModel::ContactsListProxyModel (QObject *parent) : QSortFilterPr ...@@ -63,38 +63,38 @@ ContactsListProxyModel::ContactsListProxyModel (QObject *parent) : QSortFilterPr
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void ContactsListProxyModel::setFilter (const QString &pattern) { void ContactsListProxyModel::setFilter (const QString &pattern) {
m_filter = pattern; mFilter = pattern;
invalidate(); invalidate();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool ContactsListProxyModel::filterAcceptsRow ( bool ContactsListProxyModel::filterAcceptsRow (
int source_row, int sourceRow,
const QModelIndex &source_parent const QModelIndex &sourceParent
) const { ) const {
const QModelIndex &index = sourceModel()->index(source_row, 0, source_parent); const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent);
const ContactModel *contact = index.data().value<ContactModel *>(); const ContactModel *contact = index.data().value<ContactModel *>();
m_weights[contact] = static_cast<unsigned int>(round(computeContactWeight(contact))); mWeights[contact] = static_cast<unsigned int>(round(computeContactWeight(contact)));
return m_weights[contact] > 0 && ( return mWeights[contact] > 0 && (
!m_use_connected_filter || !mUseConnectedFilter ||
contact->getPresenceLevel() != Presence::PresenceLevel::White contact->getPresenceLevel() != Presence::PresenceLevel::White
); );
} }
bool ContactsListProxyModel::lessThan (const QModelIndex &left, const QModelIndex &right) const { bool ContactsListProxyModel::lessThan (const QModelIndex &left, const QModelIndex &right) const {
const ContactModel *contact_a = sourceModel()->data(left).value<ContactModel *>(); const ContactModel *contactA = sourceModel()->data(left).value<ContactModel *>();
const ContactModel *contact_b = sourceModel()->data(right).value<ContactModel *>(); const ContactModel *contactB = sourceModel()->data(right).value<ContactModel *>();
unsigned int weight_a = m_weights[contact_a]; unsigned int weightA = mWeights[contactA];
unsigned int weight_b = m_weights[contact_b]; unsigned int weightB = mWeights[contactB];
// Sort by weight and name. // Sort by weight and name.
return weight_a > weight_b || ( return weightA > weightB || (
weight_a == weight_b && weightA == weightB &&
contact_a->m_linphone_friend->getName() <= contact_b->m_linphone_friend->getName() contactA->mLinphoneFriend->getName() <= contactB->mLinphoneFriend->getName()
); );
} }
...@@ -105,12 +105,12 @@ float ContactsListProxyModel::computeStringWeight (const QString &string, float ...@@ -105,12 +105,12 @@ float ContactsListProxyModel::computeStringWeight (const QString &string, float
int offset = -1; int offset = -1;
// Search pattern. // Search pattern.
while ((index = string.indexOf(m_filter, index + 1, Qt::CaseInsensitive)) != -1) { while ((index = string.indexOf(mFilter, index + 1, Qt::CaseInsensitive)) != -1) {
// Search n chars between one separator and index. // Search n chars between one separator and index.
int tmp_offset = index - string.lastIndexOf(m_search_separators, index) - 1; int tmpOffset = index - string.lastIndexOf(mSearchSeparators, index) - 1;
if ((tmp_offset != -1 && tmp_offset < offset) || offset == -1) if ((tmpOffset != -1 && tmpOffset < offset) || offset == -1)
if ((offset = tmp_offset) == 0) break; if ((offset = tmpOffset) == 0) break;
} }
switch (offset) { switch (offset) {
...@@ -129,7 +129,7 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel *contact) ...@@ -129,7 +129,7 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel *contact)
float weight = computeStringWeight(contact->getVcardModel()->getUsername(), USERNAME_WEIGHT); float weight = computeStringWeight(contact->getVcardModel()->getUsername(), USERNAME_WEIGHT);
// Get all contact's addresses. // Get all contact's addresses.
const list<shared_ptr<linphone::Address> > addresses = contact->m_linphone_friend->getAddresses(); const list<shared_ptr<linphone::Address> > addresses = contact->mLinphoneFriend->getAddresses();
float size = static_cast<float>(addresses.size()); float size = static_cast<float>(addresses.size());
for (auto it = addresses.cbegin(); it != addresses.cend(); ++it) for (auto it = addresses.cbegin(); it != addresses.cend(); ++it)
...@@ -143,9 +143,9 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel *contact) ...@@ -143,9 +143,9 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel *contact)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void ContactsListProxyModel::setConnectedFilter (bool use_connected_filter) { void ContactsListProxyModel::setConnectedFilter (bool useConnectedFilter) {
if (use_connected_filter != m_use_connected_filter) { if (useConnectedFilter != mUseConnectedFilter) {
m_use_connected_filter = use_connected_filter; mUseConnectedFilter = useConnectedFilter;
invalidate(); invalidate();
} }
} }
...@@ -46,7 +46,7 @@ public: ...@@ -46,7 +46,7 @@ public:
Q_INVOKABLE void setFilter (const QString &pattern); Q_INVOKABLE void setFilter (const QString &pattern);
protected: protected:
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override; bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override;
bool lessThan (const QModelIndex &left, const QModelIndex &right) const override; bool lessThan (const QModelIndex &left, const QModelIndex &right) const override;
private: private:
...@@ -54,19 +54,19 @@ private: ...@@ -54,19 +54,19 @@ private:
float computeContactWeight (const ContactModel *contact) const; float computeContactWeight (const ContactModel *contact) const;
bool isConnectedFilterUsed () const { bool isConnectedFilterUsed () const {
return m_use_connected_filter; return mUseConnectedFilter;
} }
void setConnectedFilter (bool use_connected_filter); void setConnectedFilter (bool useConnectedFilter);
QString m_filter; QString mFilter;
bool m_use_connected_filter = false; bool mUseConnectedFilter = false;
// It's just a cache to save values computed by `filterAcceptsRow` // It's just a cache to save values computed by `filterAcceptsRow`
// and reused by `lessThan`. // and reused by `lessThan`.
mutable QHash<const ContactModel *, unsigned int> m_weights; mutable QHash<const ContactModel *, unsigned int> mWeights;
static const QRegExp m_search_separators; static const QRegExp mSearchSeparators;
}; };
#endif // CONTACTS_LIST_PROXY_MODEL_H_ #endif // CONTACTS_LIST_PROXY_MODEL_H_
...@@ -34,10 +34,10 @@ using namespace std; ...@@ -34,10 +34,10 @@ using namespace std;
void CoreHandlers::onAuthenticationRequested ( void CoreHandlers::onAuthenticationRequested (
const shared_ptr<linphone::Core> &, const shared_ptr<linphone::Core> &,
const shared_ptr<linphone::AuthInfo> &auth_info, const shared_ptr<linphone::AuthInfo> &authInfo,
linphone::AuthMethod linphone::AuthMethod
) { ) {
emit authenticationRequested(auth_info); emit authenticationRequested(authInfo);
} }
void CoreHandlers::onCallStateChanged ( void CoreHandlers::onCallStateChanged (
...@@ -57,9 +57,9 @@ void CoreHandlers::onMessageReceived ( ...@@ -57,9 +57,9 @@ void CoreHandlers::onMessageReceived (
const shared_ptr<linphone::ChatRoom> &, const shared_ptr<linphone::ChatRoom> &,
const shared_ptr<linphone::ChatMessage> &message const shared_ptr<linphone::ChatMessage> &message
) { ) {
const string content_type = message->getContentType(); const string contentType = message->getContentType();
if (content_type == "text/plain" || content_type == "application/vnd.gsma.rcs-ft-http+xml") { if (contentType == "text/plain" || contentType == "application/vnd.gsma.rcs-ft-http+xml") {
emit messageReceived(message); emit messageReceived(message);
const App *app = App::getInstance(); const App *app = App::getInstance();
...@@ -71,24 +71,24 @@ void CoreHandlers::onMessageReceived ( ...@@ -71,24 +71,24 @@ void CoreHandlers::onMessageReceived (
void CoreHandlers::onNotifyPresenceReceivedForUriOrTel ( void CoreHandlers::onNotifyPresenceReceivedForUriOrTel (
const shared_ptr<linphone::Core> &, const shared_ptr<linphone::Core> &,
const shared_ptr<linphone::Friend> &, const shared_ptr<linphone::Friend> &,
const string &uri_or_tel, const string &uriOrTel,
const shared_ptr<const linphone::PresenceModel> &presence_model const shared_ptr<const linphone::PresenceModel> &presenceModel
) { ) {
emit presenceReceived(::Utils::linphoneStringToQString(uri_or_tel), presence_model); emit presenceReceived(::Utils::linphoneStringToQString(uriOrTel), presenceModel);
} }
void CoreHandlers::onNotifyPresenceReceived ( void CoreHandlers::onNotifyPresenceReceived (
const shared_ptr<linphone::Core> &, const shared_ptr<linphone::Core> &,
const shared_ptr<linphone::Friend> &linphone_friend const shared_ptr<linphone::Friend> &linphoneFriend
) { ) {
linphone_friend->getData<ContactModel>("contact-model").refreshPresence(); linphoneFriend->getData<ContactModel>("contact-model").refreshPresence();
} }
void CoreHandlers::onRegistrationStateChanged ( void CoreHandlers::onRegistrationStateChanged (
const shared_ptr<linphone::Core> &, const shared_ptr<linphone::Core> &,
const shared_ptr<linphone::ProxyConfig> &proxy_config, const shared_ptr<linphone::ProxyConfig> &proxyConfig,
linphone::RegistrationState state, linphone::RegistrationState state,
const string & const string &
) { ) {
emit registrationStateChanged(proxy_config, state); emit registrationStateChanged(proxyConfig, state);
} }
...@@ -34,16 +34,16 @@ class CoreHandlers : ...@@ -34,16 +34,16 @@ class CoreHandlers :
Q_OBJECT; Q_OBJECT;
signals: signals:
void authenticationRequested (const std::shared_ptr<linphone::AuthInfo> &auth_info); void authenticationRequested (const std::shared_ptr<linphone::AuthInfo> &authInfo);
void callStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state); void callStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state);
void messageReceived (const std::shared_ptr<linphone::ChatMessage> &message); void messageReceived (const std::shared_ptr<linphone::ChatMessage> &message);
void presenceReceived (const QString &sip_address, const std::shared_ptr<const linphone::PresenceModel> &presence_model); void presenceReceived (const QString &sipAddress, const std::shared_ptr<const linphone::PresenceModel> &presenceModel);
void registrationStateChanged (const std::shared_ptr<linphone::ProxyConfig> &proxy_config, linphone::RegistrationState state); void registrationStateChanged (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig, linphone::RegistrationState state);
private: private:
void onAuthenticationRequested ( void onAuthenticationRequested (
const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::AuthInfo> &auth_info, const std::shared_ptr<linphone::AuthInfo> &authInfo,
linphone::AuthMethod method linphone::AuthMethod method
) override; ) override;
...@@ -62,19 +62,19 @@ private: ...@@ -62,19 +62,19 @@ private:
void onNotifyPresenceReceivedForUriOrTel ( void onNotifyPresenceReceivedForUriOrTel (
const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::Friend> &linphone_friend, const std::shared_ptr<linphone::Friend> &linphoneFriend,
const std::string &uri_or_tel, const std::string &uriOrTel,
const std::shared_ptr<const linphone::PresenceModel> &presence_model const std::shared_ptr<const linphone::PresenceModel> &presenceModel
) override; ) override;
void onNotifyPresenceReceived ( void onNotifyPresenceReceived (
const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::Friend> &linphone_friend const std::shared_ptr<linphone::Friend> &linphoneFriend
) override; ) override;
void onRegistrationStateChanged ( void onRegistrationStateChanged (
const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Core> &core,
const std::shared_ptr<linphone::ProxyConfig> &proxy_config, const std::shared_ptr<linphone::ProxyConfig> &proxyConfig,
linphone::RegistrationState state, linphone::RegistrationState state,
const std::string &message const std::string &message
) override; ) override;
......
...@@ -34,42 +34,42 @@ using namespace std; ...@@ -34,42 +34,42 @@ using namespace std;
// ============================================================================= // =============================================================================
CoreManager *CoreManager::m_instance = nullptr; CoreManager *CoreManager::mInstance = nullptr;
CoreManager::CoreManager (QObject *parent, const QString &config_path) : QObject(parent), m_handlers(make_shared<CoreHandlers>()) { CoreManager::CoreManager (QObject *parent, const QString &configPath) : QObject(parent), mHandlers(make_shared<CoreHandlers>()) {
m_promise_build = QtConcurrent::run(this, &CoreManager::createLinphoneCore, config_path); mPromiseBuild = QtConcurrent::run(this, &CoreManager::createLinphoneCore, configPath);
QObject::connect( QObject::connect(
&m_promise_watcher, &QFutureWatcher<void>::finished, this, []() { &mPromiseWatcher, &QFutureWatcher<void>::finished, this, []() {
m_instance->m_calls_list_model = new CallsListModel(m_instance); mInstance->mCallsListModel = new CallsListModel(mInstance);
m_instance->m_contacts_list_model = new ContactsListModel(m_instance); mInstance->mContactsListModel = new ContactsListModel(mInstance);
m_instance->m_sip_addresses_model = new SipAddressesModel(m_instance); mInstance->mSipAddressesModel = new SipAddressesModel(mInstance);
m_instance->m_settings_model = new SettingsModel(m_instance); mInstance->mSettingsModel = new SettingsModel(mInstance);
m_instance->m_account_settings_model = new AccountSettingsModel(m_instance); mInstance->mAccountSettingsModel = new AccountSettingsModel(mInstance);
emit m_instance->linphoneCoreCreated(); emit mInstance->linphoneCoreCreated();
} }
); );
m_promise_watcher.setFuture(m_promise_build); mPromiseWatcher.setFuture(mPromiseBuild);
} }
void CoreManager::enableHandlers () { void CoreManager::enableHandlers () {
m_cbs_timer->start(); mCbsTimer->start();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CoreManager::init (QObject *parent, const QString &config_path) { void CoreManager::init (QObject *parent, const QString &configPath) {
if (m_instance) if (mInstance)
return; return;
m_instance = new CoreManager(parent, config_path); mInstance = new CoreManager(parent, configPath);
QTimer *timer = m_instance->m_cbs_timer = new QTimer(m_instance); QTimer *timer = mInstance->mCbsTimer = new QTimer(mInstance);
timer->setInterval(20); timer->setInterval(20);
QObject::connect(timer, &QTimer::timeout, m_instance, &CoreManager::iterate); QObject::connect(timer, &QTimer::timeout, mInstance, &CoreManager::iterate);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -80,27 +80,27 @@ VcardModel *CoreManager::createDetachedVcardModel () { ...@@ -80,27 +80,27 @@ VcardModel *CoreManager::createDetachedVcardModel () {
void CoreManager::forceRefreshRegisters () { void CoreManager::forceRefreshRegisters () {
qInfo() << QStringLiteral("Refresh registers."); qInfo() << QStringLiteral("Refresh registers.");
m_instance->m_core->refreshRegisters(); mInstance->mCore->refreshRegisters();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CoreManager::setDatabasesPaths () { void CoreManager::setDatabasesPaths () {
m_core->setFriendsDatabasePath(Paths::getFriendsListFilepath()); mCore->setFriendsDatabasePath(Paths::getFriendsListFilepath());
m_core->setCallLogsDatabasePath(Paths::getCallHistoryFilepath()); mCore->setCallLogsDatabasePath(Paths::getCallHistoryFilepath());
m_core->setChatDatabasePath(Paths::getMessageHistoryFilepath()); mCore->setChatDatabasePath(Paths::getMessageHistoryFilepath());
} }
void CoreManager::setOtherPaths () { void CoreManager::setOtherPaths () {
m_core->setZrtpSecretsFile(Paths::getZrtpSecretsFilepath()); mCore->setZrtpSecretsFile(Paths::getZrtpSecretsFilepath());
// This one is actually a database but it MUST be set after the zrtp secrets // This one is actually a database but it MUST be set after the zrtp secrets
// as it allows automatic migration from old version(secrets, xml) to new version (data, sqlite). // as it allows automatic migration from old version(secrets, xml) to new version (data, sqlite).
m_core->setZrtpCacheDatabasePath(Paths::getZrtpDataFilepath()); mCore->setZrtpCacheDatabasePath(Paths::getZrtpDataFilepath());
m_core->setUserCertificatesPath(Paths::getUserCertificatesDirpath()); mCore->setUserCertificatesPath(Paths::getUserCertificatesDirpath());
m_core->setRootCa(Paths::getRootCaFilepath()); mCore->setRootCa(Paths::getRootCaFilepath());
} }
void CoreManager::setResourcesPaths () { void CoreManager::setResourcesPaths () {
...@@ -111,7 +111,7 @@ void CoreManager::setResourcesPaths () { ...@@ -111,7 +111,7 @@ void CoreManager::setResourcesPaths () {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CoreManager::createLinphoneCore (const QString &config_path) { void CoreManager::createLinphoneCore (const QString &configPath) {
qInfo() << QStringLiteral("Launch async linphone core creation."); qInfo() << QStringLiteral("Launch async linphone core creation.");
// TODO: activate migration when ready to switch to this new version // TODO: activate migration when ready to switch to this new version
...@@ -119,10 +119,10 @@ void CoreManager::createLinphoneCore (const QString &config_path) { ...@@ -119,10 +119,10 @@ void CoreManager::createLinphoneCore (const QString &config_path) {
setResourcesPaths(); setResourcesPaths();
m_core = linphone::Factory::get()->createCore(m_handlers, Paths::getConfigFilepath(config_path), Paths::getFactoryConfigFilepath()); mCore = linphone::Factory::get()->createCore(mHandlers, Paths::getConfigFilepath(configPath), Paths::getFactoryConfigFilepath());
m_core->setVideoDisplayFilter("MSOGL"); mCore->setVideoDisplayFilter("MSOGL");
m_core->usePreviewWindow(true); mCore->usePreviewWindow(true);
setDatabasesPaths(); setDatabasesPaths();
setOtherPaths(); setOtherPaths();
...@@ -131,7 +131,7 @@ void CoreManager::createLinphoneCore (const QString &config_path) { ...@@ -131,7 +131,7 @@ void CoreManager::createLinphoneCore (const QString &config_path) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CoreManager::iterate () { void CoreManager::iterate () {
m_instance->lockVideoRender(); mInstance->lockVideoRender();
m_instance->m_core->iterate(); mInstance->mCore->iterate();
m_instance->unlockVideoRender(); mInstance->unlockVideoRender();
} }
...@@ -48,11 +48,11 @@ public: ...@@ -48,11 +48,11 @@ public:
void enableHandlers (); void enableHandlers ();
std::shared_ptr<linphone::Core> getCore () { std::shared_ptr<linphone::Core> getCore () {
return m_core; return mCore;
} }
std::shared_ptr<CoreHandlers> getHandlers () { std::shared_ptr<CoreHandlers> getHandlers () {
return m_handlers; return mHandlers;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -60,11 +60,11 @@ public: ...@@ -60,11 +60,11 @@ public:
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void lockVideoRender () { void lockVideoRender () {
m_mutex_video_render.lock(); mMutexVideoRender.lock();
} }
void unlockVideoRender () { void unlockVideoRender () {
m_mutex_video_render.unlock(); mMutexVideoRender.unlock();
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -72,33 +72,33 @@ public: ...@@ -72,33 +72,33 @@ public:
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
CallsListModel *getCallsListModel () const { CallsListModel *getCallsListModel () const {
return m_calls_list_model; return mCallsListModel;
} }
ContactsListModel *getContactsListModel () const { ContactsListModel *getContactsListModel () const {
return m_contacts_list_model; return mContactsListModel;
} }
SipAddressesModel *getSipAddressesModel () const { SipAddressesModel *getSipAddressesModel () const {
return m_sip_addresses_model; return mSipAddressesModel;
} }
SettingsModel *getSettingsModel () const { SettingsModel *getSettingsModel () const {
return m_settings_model; return mSettingsModel;
} }
AccountSettingsModel *getAccountSettingsModel () const { AccountSettingsModel *getAccountSettingsModel () const {
return m_account_settings_model; return mAccountSettingsModel;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Initialization. // Initialization.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
static void init (QObject *parent, const QString &config_path); static void init (QObject *parent, const QString &configPath);
static CoreManager *getInstance () { static CoreManager *getInstance () {
return m_instance; return mInstance;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -113,33 +113,33 @@ signals: ...@@ -113,33 +113,33 @@ signals:
void linphoneCoreCreated (); void linphoneCoreCreated ();
private: private:
CoreManager (QObject *parent, const QString &config_path); CoreManager (QObject *parent, const QString &configPath);
void setDatabasesPaths (); void setDatabasesPaths ();
void setOtherPaths (); void setOtherPaths ();
void setResourcesPaths (); void setResourcesPaths ();
void createLinphoneCore (const QString &config_path); void createLinphoneCore (const QString &configPath);
void iterate (); void iterate ();
std::shared_ptr<linphone::Core> m_core; std::shared_ptr<linphone::Core> mCore;
std::shared_ptr<CoreHandlers> m_handlers; std::shared_ptr<CoreHandlers> mHandlers;
CallsListModel *m_calls_list_model; CallsListModel *mCallsListModel;
ContactsListModel *m_contacts_list_model; ContactsListModel *mContactsListModel;
SipAddressesModel *m_sip_addresses_model; SipAddressesModel *mSipAddressesModel;
SettingsModel *m_settings_model; SettingsModel *mSettingsModel;
AccountSettingsModel *m_account_settings_model; AccountSettingsModel *mAccountSettingsModel;
QTimer *m_cbs_timer; QTimer *mCbsTimer;
QFuture<void> m_promise_build; QFuture<void> mPromiseBuild;
QFutureWatcher<void> m_promise_watcher; QFutureWatcher<void> mPromiseWatcher;
QMutex m_mutex_video_render; QMutex mMutexVideoRender;
static CoreManager *m_instance; static CoreManager *mInstance;
}; };
#endif // CORE_MANAGER_H_ #endif // CORE_MANAGER_H_
...@@ -59,10 +59,10 @@ using namespace std; ...@@ -59,10 +59,10 @@ using namespace std;
inline int getNotificationSize (const QObject &object, const char *property) { inline int getNotificationSize (const QObject &object, const char *property) {
QVariant variant = object.property(property); QVariant variant = object.property(property);
bool so_far_so_good; bool soFarSoGood;
int size = variant.toInt(&so_far_so_good); int size = variant.toInt(&soFarSoGood);
if (!so_far_so_good || size < 0) { if (!soFarSoGood || size < 0) {
qWarning() << "Unable to get notification size."; qWarning() << "Unable to get notification size.";
return -1; return -1;
} }
...@@ -89,13 +89,13 @@ Notifier::Notifier (QObject *parent) : ...@@ -89,13 +89,13 @@ Notifier::Notifier (QObject *parent) :
QQmlEngine *engine = App::getInstance()->getEngine(); QQmlEngine *engine = App::getInstance()->getEngine();
// Build components. // Build components.
m_components[Notifier::MessageReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_MESSAGE)); mComponents[Notifier::MessageReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_MESSAGE));
m_components[Notifier::FileMessageReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_FILE_MESSAGE)); mComponents[Notifier::FileMessageReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_FILE_MESSAGE));
m_components[Notifier::CallReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_CALL)); mComponents[Notifier::CallReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_CALL));
// Check errors. // Check errors.
for (int i = 0; i < Notifier::MaxNbTypes; ++i) { for (int i = 0; i < Notifier::MaxNbTypes; ++i) {
QQmlComponent *component = m_components[i]; QQmlComponent *component = mComponents[i];
if (component->isError()) { if (component->isError()) {
qWarning() << QStringLiteral("Errors found in `Notification` component %1:").arg(i) << component->errors(); qWarning() << QStringLiteral("Errors found in `Notification` component %1:").arg(i) << component->errors();
abort(); abort();
...@@ -105,37 +105,37 @@ Notifier::Notifier (QObject *parent) : ...@@ -105,37 +105,37 @@ Notifier::Notifier (QObject *parent) :
Notifier::~Notifier () { Notifier::~Notifier () {
for (int i = 0; i < Notifier::MaxNbTypes; ++i) for (int i = 0; i < Notifier::MaxNbTypes; ++i)
delete m_components[i]; delete mComponents[i];
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
QObject *Notifier::createNotification (Notifier::NotificationType type) { QObject *Notifier::createNotification (Notifier::NotificationType type) {
m_mutex.lock(); mMutex.lock();
Q_ASSERT(m_n_instances <= N_MAX_NOTIFICATIONS); Q_ASSERT(mInstancesNumber <= N_MAX_NOTIFICATIONS);
// Check existing instances. // Check existing instances.
if (m_n_instances == N_MAX_NOTIFICATIONS) { if (mInstancesNumber == N_MAX_NOTIFICATIONS) {
qWarning() << "Unable to create another notification"; qWarning() << "Unable to create another notification";
m_mutex.unlock(); mMutex.unlock();
return nullptr; return nullptr;
} }
// Create instance and set attributes. // Create instance and set attributes.
QObject *object = m_components[type]->create(); QObject *object = mComponents[type]->create();
int offset = getNotificationSize(*object, NOTIFICATION_PROPERTY_HEIGHT); int offset = getNotificationSize(*object, NOTIFICATION_PROPERTY_HEIGHT);
if (offset == -1 || !::setProperty(*object, NOTIFICATION_PROPERTY_OFFSET, m_offset)) { if (offset == -1 || !::setProperty(*object, NOTIFICATION_PROPERTY_OFFSET, mOffset)) {
delete object; delete object;
m_mutex.unlock(); mMutex.unlock();
return nullptr; return nullptr;
} }
m_offset = (offset + m_offset) + NOTIFICATION_SPACING; mOffset = (offset + mOffset) + NOTIFICATION_SPACING;
m_n_instances++; mInstancesNumber++;
m_mutex.unlock(); mMutex.unlock();
return object; return object;
} }
...@@ -166,13 +166,13 @@ void Notifier::showNotification (QObject *notification, int timeout) { ...@@ -166,13 +166,13 @@ void Notifier::showNotification (QObject *notification, int timeout) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void Notifier::deleteNotification (QVariant notification) { void Notifier::deleteNotification (QVariant notification) {
m_mutex.lock(); mMutex.lock();
QObject *instance = notification.value<QObject *>(); QObject *instance = notification.value<QObject *>();
// Notification marked destroyed. // Notification marked destroyed.
if (instance->property("__valid").isValid()) { if (instance->property("__valid").isValid()) {
m_mutex.unlock(); mMutex.unlock();
return; return;
} }
...@@ -181,13 +181,13 @@ void Notifier::deleteNotification (QVariant notification) { ...@@ -181,13 +181,13 @@ void Notifier::deleteNotification (QVariant notification) {
instance->setProperty("__valid", true); instance->setProperty("__valid", true);
instance->property(NOTIFICATION_PROPERTY_TIMER).value<QTimer *>()->stop(); instance->property(NOTIFICATION_PROPERTY_TIMER).value<QTimer *>()->stop();
m_n_instances--; mInstancesNumber--;
if (m_n_instances == 0) if (mInstancesNumber == 0)
m_offset = 0; mOffset = 0;
Q_ASSERT(m_n_instances >= 0); Q_ASSERT(mInstancesNumber >= 0);
m_mutex.unlock(); mMutex.unlock();
instance->deleteLater(); instance->deleteLater();
} }
......
...@@ -56,11 +56,11 @@ private: ...@@ -56,11 +56,11 @@ private:
QObject *createNotification (NotificationType type); QObject *createNotification (NotificationType type);
void showNotification (QObject *notification, int timeout); void showNotification (QObject *notification, int timeout);
QQmlComponent *m_components[MaxNbTypes]; QQmlComponent *mComponents[MaxNbTypes];
int m_offset = 0; int mOffset = 0;
int m_n_instances = 0; int mInstancesNumber = 0;
QMutex m_mutex; QMutex mMutex;
}; };
#endif // NOTIFIER_H_ #endif // NOTIFIER_H_
...@@ -55,21 +55,21 @@ public: ...@@ -55,21 +55,21 @@ public:
AccountSettingsModel (QObject *parent = Q_NULLPTR); AccountSettingsModel (QObject *parent = Q_NULLPTR);
~AccountSettingsModel () = default; ~AccountSettingsModel () = default;
bool addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config); bool addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
Q_INVOKABLE QVariantMap getProxyConfigDescription (const std::shared_ptr<linphone::ProxyConfig> &proxy_config); Q_INVOKABLE QVariantMap getProxyConfigDescription (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config); Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
Q_INVOKABLE bool addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config, const QVariantMap &data); Q_INVOKABLE bool addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig, const QVariantMap &data);
Q_INVOKABLE void removeProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config); Q_INVOKABLE void removeProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
Q_INVOKABLE std::shared_ptr<linphone::ProxyConfig> createProxyConfig (); Q_INVOKABLE std::shared_ptr<linphone::ProxyConfig> createProxyConfig ();
Q_INVOKABLE void addAuthInfo ( Q_INVOKABLE void addAuthInfo (
const std::shared_ptr<linphone::AuthInfo> &auth_info, const std::shared_ptr<linphone::AuthInfo> &authInfo,
const QString &password, const QString &password,
const QString &user_id const QString &userId
); );
Q_INVOKABLE void eraseAllPasswords (); Q_INVOKABLE void eraseAllPasswords ();
...@@ -105,7 +105,7 @@ private: ...@@ -105,7 +105,7 @@ private:
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void handleRegistrationStateChanged ( void handleRegistrationStateChanged (
const std::shared_ptr<linphone::ProxyConfig> &proxy_config, const std::shared_ptr<linphone::ProxyConfig> &proxyConfig,
linphone::RegistrationState state linphone::RegistrationState state
); );
}; };
......
...@@ -35,7 +35,7 @@ using namespace std; ...@@ -35,7 +35,7 @@ using namespace std;
const string SettingsModel::UI_SECTION("ui"); const string SettingsModel::UI_SECTION("ui");
SettingsModel::SettingsModel (QObject *parent) : QObject(parent) { SettingsModel::SettingsModel (QObject *parent) : QObject(parent) {
m_config = CoreManager::getInstance()->getCore()->getConfig(); mConfig = CoreManager::getInstance()->getCore()->getConfig();
} }
// ============================================================================= // =============================================================================
...@@ -103,13 +103,13 @@ QString SettingsModel::getRingPath () const { ...@@ -103,13 +103,13 @@ QString SettingsModel::getRingPath () const {
} }
void SettingsModel::setRingPath (const QString &path) { void SettingsModel::setRingPath (const QString &path) {
QString cleaned_path = QDir::cleanPath(path); QString cleanedPath = QDir::cleanPath(path);
CoreManager::getInstance()->getCore()->setRing( CoreManager::getInstance()->getCore()->setRing(
::Utils::qStringToLinphoneString(cleaned_path) ::Utils::qStringToLinphoneString(cleanedPath)
); );
emit ringPathChanged(cleaned_path); emit ringPathChanged(cleanedPath);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -182,22 +182,22 @@ void SettingsModel::setVideoFramerate (int framerate) { ...@@ -182,22 +182,22 @@ void SettingsModel::setVideoFramerate (int framerate) {
// ============================================================================= // =============================================================================
int SettingsModel::getAutoAnswerDelay () const { int SettingsModel::getAutoAnswerDelay () const {
return m_config->getInt(UI_SECTION, "auto_answer_delay", 0); return mConfig->getInt(UI_SECTION, "auto_answer_delay", 0);
} }
void SettingsModel::setAutoAnswerDelay (int delay) { void SettingsModel::setAutoAnswerDelay (int delay) {
m_config->setInt(UI_SECTION, "auto_answer_delay", delay); mConfig->setInt(UI_SECTION, "auto_answer_delay", delay);
emit autoAnswerDelayChanged(delay); emit autoAnswerDelayChanged(delay);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool SettingsModel::getAutoAnswerStatus () const { bool SettingsModel::getAutoAnswerStatus () const {
return !!m_config->getInt(UI_SECTION, "auto_answer", 0); return !!mConfig->getInt(UI_SECTION, "auto_answer", 0);
} }
void SettingsModel::setAutoAnswerStatus (bool status) { void SettingsModel::setAutoAnswerStatus (bool status) {
m_config->setInt(UI_SECTION, "auto_answer", status); mConfig->setInt(UI_SECTION, "auto_answer", status);
emit autoAnswerStatusChanged(status); emit autoAnswerStatusChanged(status);
} }
...@@ -429,10 +429,10 @@ bool SettingsModel::getIceEnabled () const { ...@@ -429,10 +429,10 @@ bool SettingsModel::getIceEnabled () const {
} }
void SettingsModel::setIceEnabled (bool status) { void SettingsModel::setIceEnabled (bool status) {
shared_ptr<linphone::NatPolicy> nat_policy = CoreManager::getInstance()->getCore()->getNatPolicy(); shared_ptr<linphone::NatPolicy> natPolicy = CoreManager::getInstance()->getCore()->getNatPolicy();
nat_policy->enableIce(status); natPolicy->enableIce(status);
nat_policy->enableStun(status); natPolicy->enableStun(status);
emit iceEnabledChanged(status); emit iceEnabledChanged(status);
} }
...@@ -456,9 +456,9 @@ QString SettingsModel::getStunServer () const { ...@@ -456,9 +456,9 @@ QString SettingsModel::getStunServer () const {
); );
} }
void SettingsModel::setStunServer (const QString &stun_server) { void SettingsModel::setStunServer (const QString &stunServer) {
CoreManager::getInstance()->getCore()->getNatPolicy()->setStunServer( CoreManager::getInstance()->getCore()->getNatPolicy()->setStunServer(
::Utils::qStringToLinphoneString(stun_server) ::Utils::qStringToLinphoneString(stunServer)
); );
} }
...@@ -482,28 +482,28 @@ void SettingsModel::setTurnUser (const QString &user) { ...@@ -482,28 +482,28 @@ void SettingsModel::setTurnUser (const QString &user) {
QString SettingsModel::getTurnPassword () const { QString SettingsModel::getTurnPassword () const {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::NatPolicy> nat_policy = core->getNatPolicy(); shared_ptr<linphone::NatPolicy> natPolicy = core->getNatPolicy();
shared_ptr<const linphone::AuthInfo> auth_info = core->findAuthInfo(nat_policy->getStunServerUsername(), "", ""); shared_ptr<const linphone::AuthInfo> authInfo = core->findAuthInfo(natPolicy->getStunServerUsername(), "", "");
return auth_info ? ::Utils::linphoneStringToQString(auth_info->getPasswd()) : ""; return authInfo ? ::Utils::linphoneStringToQString(authInfo->getPasswd()) : "";
} }
void SettingsModel::setTurnPassword (const QString &password) { void SettingsModel::setTurnPassword (const QString &password) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::NatPolicy> nat_policy = core->getNatPolicy(); shared_ptr<linphone::NatPolicy> natPolicy = core->getNatPolicy();
const string &username = nat_policy->getStunServerUsername(); const string &username = natPolicy->getStunServerUsername();
shared_ptr<const linphone::AuthInfo> auth_info = core->findAuthInfo(username, "", ""); shared_ptr<const linphone::AuthInfo> authInfo = core->findAuthInfo(username, "", "");
if (auth_info) { if (authInfo) {
shared_ptr<linphone::AuthInfo> auth_info_clone = auth_info->clone(); shared_ptr<linphone::AuthInfo> clonedAuthInfo = authInfo->clone();
auth_info_clone->setPasswd(::Utils::qStringToLinphoneString(password)); clonedAuthInfo->setPasswd(::Utils::qStringToLinphoneString(password));
core->removeAuthInfo(auth_info); core->removeAuthInfo(authInfo);
core->addAuthInfo(auth_info_clone); core->addAuthInfo(clonedAuthInfo);
} else { } else {
auth_info = linphone::Factory::get()->createAuthInfo(username, username, ::Utils::qStringToLinphoneString(password), "", "", ""); authInfo = linphone::Factory::get()->createAuthInfo(username, username, ::Utils::qStringToLinphoneString(password), "", "", "");
core->addAuthInfo(auth_info); core->addAuthInfo(authInfo);
} }
emit turnPasswordChanged(password); emit turnPasswordChanged(password);
...@@ -545,16 +545,16 @@ void SettingsModel::setDscpVideo (int dscp) { ...@@ -545,16 +545,16 @@ void SettingsModel::setDscpVideo (int dscp) {
QString SettingsModel::getSavedScreenshotsFolder () const { QString SettingsModel::getSavedScreenshotsFolder () const {
return QDir::cleanPath( return QDir::cleanPath(
::Utils::linphoneStringToQString( ::Utils::linphoneStringToQString(
m_config->getString(UI_SECTION, "saved_screenshots_folder", Paths::getCapturesDirpath()) mConfig->getString(UI_SECTION, "saved_screenshots_folder", Paths::getCapturesDirpath())
) )
) + QDir::separator(); ) + QDir::separator();
} }
void SettingsModel::setSavedScreenshotsFolder (const QString &folder) { void SettingsModel::setSavedScreenshotsFolder (const QString &folder) {
QString cleaned_folder = QDir::cleanPath(folder) + QDir::separator(); QString cleanedFolder = QDir::cleanPath(folder) + QDir::separator();
m_config->setString(UI_SECTION, "saved_screenshots_folder", ::Utils::qStringToLinphoneString(cleaned_folder)); mConfig->setString(UI_SECTION, "saved_screenshots_folder", ::Utils::qStringToLinphoneString(cleanedFolder));
emit savedScreenshotsFolderChanged(cleaned_folder); emit savedScreenshotsFolderChanged(cleanedFolder);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -562,7 +562,7 @@ void SettingsModel::setSavedScreenshotsFolder (const QString &folder) { ...@@ -562,7 +562,7 @@ void SettingsModel::setSavedScreenshotsFolder (const QString &folder) {
QString SettingsModel::getSavedVideosFolder () const { QString SettingsModel::getSavedVideosFolder () const {
return QDir::cleanPath( return QDir::cleanPath(
::Utils::linphoneStringToQString( ::Utils::linphoneStringToQString(
m_config->getString(UI_SECTION, "saved_videos_folder", Paths::getCapturesDirpath()) mConfig->getString(UI_SECTION, "saved_videos_folder", Paths::getCapturesDirpath())
) )
) + QDir::separator(); ) + QDir::separator();
} }
...@@ -570,6 +570,6 @@ QString SettingsModel::getSavedVideosFolder () const { ...@@ -570,6 +570,6 @@ QString SettingsModel::getSavedVideosFolder () const {
void SettingsModel::setSavedVideosFolder (const QString &folder) { void SettingsModel::setSavedVideosFolder (const QString &folder) {
QString _folder = QDir::cleanPath(folder) + QDir::separator(); QString _folder = QDir::cleanPath(folder) + QDir::separator();
m_config->setString(UI_SECTION, "saved_videos_folder", ::Utils::qStringToLinphoneString(_folder)); mConfig->setString(UI_SECTION, "saved_videos_folder", ::Utils::qStringToLinphoneString(_folder));
emit savedVideosFolderChanged(_folder); emit savedVideosFolderChanged(_folder);
} }
...@@ -220,7 +220,7 @@ public: ...@@ -220,7 +220,7 @@ public:
void setTurnEnabled (bool status); void setTurnEnabled (bool status);
QString getStunServer () const; QString getStunServer () const;
void setStunServer (const QString &stun_server); void setStunServer (const QString &stunServer);
QString getTurnUser () const; QString getTurnUser () const;
void setTurnUser (const QString &user); void setTurnUser (const QString &user);
...@@ -315,7 +315,7 @@ signals: ...@@ -315,7 +315,7 @@ signals:
void savedVideosFolderChanged (const QString &folder); void savedVideosFolderChanged (const QString &folder);
private: private:
std::shared_ptr<linphone::Config> m_config; std::shared_ptr<linphone::Config> mConfig;
}; };
#endif // SETTINGS_MODEL_H_ #endif // SETTINGS_MODEL_H_
...@@ -24,30 +24,30 @@ ...@@ -24,30 +24,30 @@
// ============================================================================= // =============================================================================
SipAddressObserver::SipAddressObserver (const QString &sip_address) { SipAddressObserver::SipAddressObserver (const QString &sipAddress) {
m_sip_address = sip_address; mSipAddress = sipAddress;
} }
void SipAddressObserver::setContact (ContactModel *contact) { void SipAddressObserver::setContact (ContactModel *contact) {
if (contact == m_contact) if (contact == mContact)
return; return;
m_contact = contact; mContact = contact;
emit contactChanged(contact); emit contactChanged(contact);
} }
void SipAddressObserver::setPresenceStatus (const Presence::PresenceStatus &presence_status) { void SipAddressObserver::setPresenceStatus (const Presence::PresenceStatus &presenceStatus) {
if (presence_status == m_presence_status) if (presenceStatus == mPresenceStatus)
return; return;
m_presence_status = presence_status; mPresenceStatus = presenceStatus;
emit presenceStatusChanged(presence_status); emit presenceStatusChanged(presenceStatus);
} }
void SipAddressObserver::setUnreadMessagesCount (int unread_messages_count) { void SipAddressObserver::setUnreadMessagesCount (int unreadMessagesCount) {
if (unread_messages_count == m_unread_messages_count) if (unreadMessagesCount == mUnreadMessagesCount)
return; return;
m_unread_messages_count = unread_messages_count; mUnreadMessagesCount = unreadMessagesCount;
emit unreadMessagesCountChanged(unread_messages_count); emit unreadMessagesCountChanged(unreadMessagesCount);
} }
...@@ -39,7 +39,7 @@ class SipAddressObserver : public QObject { ...@@ -39,7 +39,7 @@ class SipAddressObserver : public QObject {
Q_PROPERTY(int unreadMessagesCount READ getUnreadMessagesCount NOTIFY unreadMessagesCountChanged); Q_PROPERTY(int unreadMessagesCount READ getUnreadMessagesCount NOTIFY unreadMessagesCountChanged);
public: public:
SipAddressObserver (const QString &sip_address); SipAddressObserver (const QString &sipAddress);
~SipAddressObserver () = default; ~SipAddressObserver () = default;
signals: signals:
...@@ -49,13 +49,13 @@ signals: ...@@ -49,13 +49,13 @@ signals:
private: private:
QString getSipAddress () const { QString getSipAddress () const {
return m_sip_address; return mSipAddress;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
ContactModel *getContact () const { ContactModel *getContact () const {
return m_contact; return mContact;
} }
void setContact (ContactModel *contact); void setContact (ContactModel *contact);
...@@ -63,24 +63,24 @@ private: ...@@ -63,24 +63,24 @@ private:
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
Presence::PresenceStatus getPresenceStatus () const { Presence::PresenceStatus getPresenceStatus () const {
return m_presence_status; return mPresenceStatus;
} }
void setPresenceStatus (const Presence::PresenceStatus &presence_status); void setPresenceStatus (const Presence::PresenceStatus &presenceStatus);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
int getUnreadMessagesCount () const { int getUnreadMessagesCount () const {
return m_unread_messages_count; return mUnreadMessagesCount;
} }
void setUnreadMessagesCount (int unread_messages_count); void setUnreadMessagesCount (int unreadMessagesCount);
QString m_sip_address; QString mSipAddress;
ContactModel *m_contact = nullptr; ContactModel *mContact = nullptr;
Presence::PresenceStatus m_presence_status = Presence::PresenceStatus::Offline; Presence::PresenceStatus mPresenceStatus = Presence::PresenceStatus::Offline;
int m_unread_messages_count = 0; int mUnreadMessagesCount = 0;
}; };
Q_DECLARE_METATYPE(SipAddressObserver *); Q_DECLARE_METATYPE(SipAddressObserver *);
......
...@@ -45,20 +45,20 @@ public: ...@@ -45,20 +45,20 @@ public:
QHash<int, QByteArray> roleNames () const override; QHash<int, QByteArray> roleNames () const override;
QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override;
void connectToChatModel (ChatModel *chat_model); void connectToChatModel (ChatModel *chatModel);
Q_INVOKABLE ContactModel *mapSipAddressToContact (const QString &sip_address) const; Q_INVOKABLE ContactModel *mapSipAddressToContact (const QString &sipAddress) const;
Q_INVOKABLE SipAddressObserver *getSipAddressObserver (const QString &sip_address); Q_INVOKABLE SipAddressObserver *getSipAddressObserver (const QString &sipAddress);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Sip addresses helpers. // Sip addresses helpers.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
Q_INVOKABLE QString interpretUrl (const QString &sip_address) const; Q_INVOKABLE QString interpretUrl (const QString &sipAddress) const;
Q_INVOKABLE QString getTransportFromSipAddress (const QString &sip_address) const; Q_INVOKABLE QString getTransportFromSipAddress (const QString &sipAddress) const;
Q_INVOKABLE QString addTransportToSipAddress (const QString &sip_address, const QString &transport) const; Q_INVOKABLE QString addTransportToSipAddress (const QString &sipAddress, const QString &transport) const;
Q_INVOKABLE bool sipAddressIsValid (const QString &sip_address) const; Q_INVOKABLE bool sipAddressIsValid (const QString &sipAddress) const;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -71,16 +71,16 @@ private: ...@@ -71,16 +71,16 @@ private:
void handleContactAdded (ContactModel *contact); void handleContactAdded (ContactModel *contact);
void handleContactRemoved (const ContactModel *contact); void handleContactRemoved (const ContactModel *contact);
void handleSipAddressAdded (ContactModel *contact, const QString &sip_address); void handleSipAddressAdded (ContactModel *contact, const QString &sipAddress);
void handleSipAddressRemoved (ContactModel *contact, const QString &sip_address); void handleSipAddressRemoved (ContactModel *contact, const QString &sipAddress);
void handleMessageReceived (const std::shared_ptr<linphone::ChatMessage> &message); void handleMessageReceived (const std::shared_ptr<linphone::ChatMessage> &message);
void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state); void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state);
void handlePresenceReceived (const QString &sip_address, const std::shared_ptr<const linphone::PresenceModel> &presence_model); void handlePresenceReceived (const QString &sipAddress, const std::shared_ptr<const linphone::PresenceModel> &presenceModel);
void handleAllEntriesRemoved (const QString &sip_address); void handleAllEntriesRemoved (const QString &sipAddress);
void handleMessageSent (const std::shared_ptr<linphone::ChatMessage> &message); void handleMessageSent (const std::shared_ptr<linphone::ChatMessage> &message);
void handleMessagesCountReset (const QString &sip_address); void handleMessagesCountReset (const QString &sipAddress);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -91,24 +91,24 @@ private: ...@@ -91,24 +91,24 @@ private:
void addOrUpdateSipAddress (QVariantMap &map, const std::shared_ptr<linphone::ChatMessage> &message); void addOrUpdateSipAddress (QVariantMap &map, const std::shared_ptr<linphone::ChatMessage> &message);
template<class T> template<class T>
void addOrUpdateSipAddress (const QString &sip_address, T data); void addOrUpdateSipAddress (const QString &sipAddress, T data);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void removeContactOfSipAddress (const QString &sip_address); void removeContactOfSipAddress (const QString &sipAddress);
void initSipAddresses (); void initSipAddresses ();
void updateObservers (const QString &sip_address, ContactModel *contact); void updateObservers (const QString &sipAddress, ContactModel *contact);
void updateObservers (const QString &sip_address, const Presence::PresenceStatus &presence_status); void updateObservers (const QString &sipAddress, const Presence::PresenceStatus &presenceStatus);
void updateObservers (const QString &sip_address, int messages_count); void updateObservers (const QString &sipAddress, int messagesCount);
QHash<QString, QVariantMap> m_sip_addresses; QHash<QString, QVariantMap> mSipAddresses;
QList<const QVariantMap *> m_refs; QList<const QVariantMap *> mRefs;
QMultiHash<QString, SipAddressObserver *> m_observers; QMultiHash<QString, SipAddressObserver *> mObservers;
std::shared_ptr<CoreHandlers> m_core_handlers; std::shared_ptr<CoreHandlers> mCoreHandlers;
}; };
#endif // SIP_ADDRESSES_MODEL_H_ #endif // SIP_ADDRESSES_MODEL_H_
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
// ============================================================================= // =============================================================================
const QRegExp SmartSearchBarModel::m_search_separators("^[^_.-;@ ][_.-;@ ]"); const QRegExp SmartSearchBarModel::mSearchSeparators("^[^_.-;@ ][_.-;@ ]");
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -50,54 +50,54 @@ QHash<int, QByteArray> SmartSearchBarModel::roleNames () const { ...@@ -50,54 +50,54 @@ QHash<int, QByteArray> SmartSearchBarModel::roleNames () const {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void SmartSearchBarModel::setFilter (const QString &pattern) { void SmartSearchBarModel::setFilter (const QString &pattern) {
m_filter = pattern; mFilter = pattern;
invalidate(); invalidate();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool SmartSearchBarModel::filterAcceptsRow (int source_row, const QModelIndex &source_parent) const { bool SmartSearchBarModel::filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const {
const QModelIndex &index = sourceModel()->index(source_row, 0, source_parent); const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent);
return computeEntryWeight(index.data().toMap()) > 0; return computeEntryWeight(index.data().toMap()) > 0;
} }
bool SmartSearchBarModel::lessThan (const QModelIndex &left, const QModelIndex &right) const { bool SmartSearchBarModel::lessThan (const QModelIndex &left, const QModelIndex &right) const {
const QVariantMap &map_a = sourceModel()->data(left).toMap(); const QVariantMap &mapA = sourceModel()->data(left).toMap();
const QVariantMap &map_b = sourceModel()->data(right).toMap(); const QVariantMap &mapB = sourceModel()->data(right).toMap();
const QString &sip_address_a = map_a["sipAddress"].toString(); const QString &sipAddressA = mapA["sipAddress"].toString();
const QString &sip_address_b = map_b["sipAddress"].toString(); const QString &sipAddressB = mapB["sipAddress"].toString();
// TODO: Use a cache, do not compute the same value as `filterAcceptsRow`. // TODO: Use a cache, do not compute the same value as `filterAcceptsRow`.
int weight_a = computeEntryWeight(map_a); int weightA = computeEntryWeight(mapA);
int weight_b = computeEntryWeight(map_b); int weightB = computeEntryWeight(mapB);
// 1. Not the same weight. // 1. Not the same weight.
if (weight_a != weight_b) if (weightA != weightB)
return weight_a > weight_b; return weightA > weightB;
const ContactModel *contact_a = map_a.value("contact").value<ContactModel *>(); const ContactModel *contactA = mapA.value("contact").value<ContactModel *>();
const ContactModel *contact_b = map_b.value("contact").value<ContactModel *>(); const ContactModel *contactB = mapB.value("contact").value<ContactModel *>();
// 2. No contacts. // 2. No contacts.
if (!contact_a && !contact_b) if (!contactA && !contactB)
return sip_address_a <= sip_address_b; return sipAddressA <= sipAddressB;
// 3. No contact for a or b. // 3. No contact for a or b.
if (!contact_a || !contact_b) if (!contactA || !contactB)
return !!contact_a; return !!contactA;
// 4. Same contact (address). // 4. Same contact (address).
if (contact_a == contact_b) if (contactA == contactB)
return sip_address_a <= sip_address_b; return sipAddressA <= sipAddressB;
// 5. Not the same contact name. // 5. Not the same contact name.
int diff = contact_a->m_linphone_friend->getName().compare(contact_b->m_linphone_friend->getName()); int diff = contactA->mLinphoneFriend->getName().compare(contactB->mLinphoneFriend->getName());
if (diff) if (diff)
return diff <= 0; return diff <= 0;
// 6. Same contact name, so compare sip addresses. // 6. Same contact name, so compare sip addresses.
return sip_address_a <= sip_address_b; return sipAddressA <= sipAddressB;
} }
int SmartSearchBarModel::computeEntryWeight (const QVariantMap &entry) const { int SmartSearchBarModel::computeEntryWeight (const QVariantMap &entry) const {
...@@ -114,10 +114,10 @@ int SmartSearchBarModel::computeStringWeight (const QString &string) const { ...@@ -114,10 +114,10 @@ int SmartSearchBarModel::computeStringWeight (const QString &string) const {
int index = -1; int index = -1;
int offset = -1; int offset = -1;
while ((index = string.indexOf(m_filter, index + 1, Qt::CaseInsensitive)) != -1) { while ((index = string.indexOf(mFilter, index + 1, Qt::CaseInsensitive)) != -1) {
int tmp_offset = index - string.lastIndexOf(m_search_separators, index) - 1; int tmpOffset = index - string.lastIndexOf(mSearchSeparators, index) - 1;
if ((tmp_offset != -1 && tmp_offset < offset) || offset == -1) if ((tmpOffset != -1 && tmpOffset < offset) || offset == -1)
if ((offset = tmp_offset) == 0) break; if ((offset = tmpOffset) == 0) break;
} }
switch (offset) { switch (offset) {
......
...@@ -39,15 +39,15 @@ public: ...@@ -39,15 +39,15 @@ public:
Q_INVOKABLE void setFilter (const QString &pattern); Q_INVOKABLE void setFilter (const QString &pattern);
protected: protected:
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override; bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override;
bool lessThan (const QModelIndex &left, const QModelIndex &right) const override; bool lessThan (const QModelIndex &left, const QModelIndex &right) const override;
private: private:
int computeEntryWeight (const QVariantMap &entry) const; int computeEntryWeight (const QVariantMap &entry) const;
int computeStringWeight (const QString &string) const; int computeStringWeight (const QString &string) const;
QString m_filter; QString mFilter;
static const QRegExp m_search_separators; static const QRegExp mSearchSeparators;
}; };
#endif // SMART_SEARCH_BAR_MODEL_H_ #endif // SMART_SEARCH_BAR_MODEL_H_
...@@ -41,8 +41,8 @@ QHash<int, QByteArray> TimelineModel::roleNames () const { ...@@ -41,8 +41,8 @@ QHash<int, QByteArray> TimelineModel::roleNames () const {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool TimelineModel::filterAcceptsRow (int source_row, const QModelIndex &source_parent) const { bool TimelineModel::filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const {
const QModelIndex &index = sourceModel()->index(source_row, 0, source_parent); const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent);
return index.data().toMap().contains("timestamp"); return index.data().toMap().contains("timestamp");
} }
......
...@@ -37,7 +37,7 @@ public: ...@@ -37,7 +37,7 @@ public:
QHash<int, QByteArray> roleNames () const override; QHash<int, QByteArray> roleNames () const override;
protected: protected:
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override; bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override;
bool lessThan (const QModelIndex &left, const QModelIndex &right) const override; bool lessThan (const QModelIndex &left, const QModelIndex &right) const override;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment