diff --git a/Linphone/core/account/AccountCore.cpp b/Linphone/core/account/AccountCore.cpp index 0005c404d..c16034dc2 100644 --- a/Linphone/core/account/AccountCore.cpp +++ b/Linphone/core/account/AccountCore.cpp @@ -97,6 +97,7 @@ AccountCore::AccountCore(const std::shared_ptr &account) : QO } INIT_CORE_MEMBER(VoicemailCount, mAccountModel) + INIT_CORE_MEMBER(ShowMwi, mAccountModel) } AccountCore::~AccountCore() { @@ -268,6 +269,7 @@ void AccountCore::setSelf(QSharedPointer me) { DEFINE_CORE_GET_CONNECT(mAccountModelConnection, AccountCore, AccountModel, mAccountModel, int, voicemailCount, VoicemailCount) + DEFINE_CORE_GET_CONNECT(mAccountModelConnection, AccountCore, AccountModel, mAccountModel, int, showMwi, ShowMwi) } const std::shared_ptr &AccountCore::getModel() const { diff --git a/Linphone/core/account/AccountCore.hpp b/Linphone/core/account/AccountCore.hpp index 00f1a9600..f830fcdc0 100644 --- a/Linphone/core/account/AccountCore.hpp +++ b/Linphone/core/account/AccountCore.hpp @@ -72,6 +72,7 @@ class AccountCore : public QObject, public AbstractObject { lSetAudioVideoConferenceFactoryAddress NOTIFY audioVideoConferenceFactoryAddressChanged) Q_PROPERTY(QString limeServerUrl READ getLimeServerUrl WRITE lSetLimeServerUrl NOTIFY limeServerUrlChanged) DECLARE_CORE_GET(int, voicemailCount, VoicemailCount) + DECLARE_CORE_GET(bool, showMwi, ShowMwi) public: static QSharedPointer create(const std::shared_ptr &account); diff --git a/Linphone/model/account/AccountModel.cpp b/Linphone/model/account/AccountModel.cpp index 7c8f15919..e4e78fd08 100644 --- a/Linphone/model/account/AccountModel.cpp +++ b/Linphone/model/account/AccountModel.cpp @@ -67,8 +67,10 @@ void AccountModel::onMessageWaitingIndicationChanged( auto userData = getUserData(account); if (!userData) userData = std::make_shared(); userData->voicemailCount = summary->getNbNew(); + userData->showMwi = mwi->hasMessageWaiting(); setUserData(account, userData); emit voicemailCountChanged(summary->getNbNew()); + emit showMwiChanged(mwi->hasMessageWaiting()); } } @@ -311,6 +313,12 @@ int AccountModel::getVoicemailCount() { else return 0; } +bool AccountModel::getShowMwi() { + auto userData = getUserData(mMonitor); + if (userData) return userData->showMwi; + else return false; +} + // UserData (see hpp for explanations) static QMap, std::shared_ptr> userDataMap; diff --git a/Linphone/model/account/AccountModel.hpp b/Linphone/model/account/AccountModel.hpp index c5583963d..7fa6e42d3 100644 --- a/Linphone/model/account/AccountModel.hpp +++ b/Linphone/model/account/AccountModel.hpp @@ -67,6 +67,7 @@ public: void setLimeServerUrl(QString value); QString dialPlanAsString(const std::shared_ptr &dialPlan); int getVoicemailCount(); + bool getShowMwi(); signals: void registrationStateChanged(const std::shared_ptr &account, @@ -94,6 +95,7 @@ signals: void limeServerUrlChanged(QString value); void removed(); void voicemailCountChanged(int count); + void showMwiChanged(bool show); private: /**Linphone **/ @@ -118,6 +120,7 @@ private: struct AccountUserData { int voicemailCount; + bool showMwi; // .. }; diff --git a/Linphone/view/Control/Display/Contact/Contact.qml b/Linphone/view/Control/Display/Contact/Contact.qml index e21842ea2..5d57281b0 100644 --- a/Linphone/view/Control/Display/Contact/Contact.qml +++ b/Linphone/view/Control/Display/Contact/Contact.qml @@ -148,6 +148,7 @@ Control.Control{ Layout.rightMargin: 20 * DefaultStyle.dp Layout.preferredWidth: 27 * DefaultStyle.dp Layout.preferredHeight: 28 * DefaultStyle.dp + visible: mainItem.account.core.showMwi voicemailCount: mainItem.account.core.voicemailCount >= 100 ? '99+' : mainItem.account.core.voicemailCount onClicked: { if (mainItem.account.core.mwiServerAddress.length > 0) diff --git a/Linphone/view/Control/Display/Contact/Voicemail.qml b/Linphone/view/Control/Display/Contact/Voicemail.qml index 1ff72f94f..8e60e63ad 100644 --- a/Linphone/view/Control/Display/Contact/Voicemail.qml +++ b/Linphone/view/Control/Display/Contact/Voicemail.qml @@ -9,7 +9,6 @@ import SettingsCpp Rectangle{ id: mainItem property int voicemailCount: 0 - visible: voicemailCount > 0 width: 27 * DefaultStyle.dp height: 28 * DefaultStyle.dp signal clicked() diff --git a/Linphone/view/Page/Layout/Main/MainLayout.qml b/Linphone/view/Page/Layout/Main/MainLayout.qml index c24e06d3b..8433db89c 100644 --- a/Linphone/view/Page/Layout/Main/MainLayout.qml +++ b/Linphone/view/Page/Layout/Main/MainLayout.qml @@ -398,14 +398,29 @@ Item { Layout.preferredWidth: 27 * DefaultStyle.dp Layout.preferredHeight: 28 * DefaultStyle.dp - function cumulatedVoicemailCount() { + Repeater { + model: accountProxy + Connections { + target: modelData.core + onMwiChanged: updateCumulatedMwi() + } + } + + function updateCumulatedMwi() { var count = 0 - for (var i=0 ; i < accountProxy.count ; i++ ) + var show = false + for (var i=0 ; i < accountProxy.count ; i++ ) { count += accountProxy.getAt(i).core.voicemailCount - return count + show |= accountProxy.getAt(i).core.showMwi + } + voicemail.visible = show + voicemail.voicemailCount = count + } + + Component.onCompleted: { + updateCumulatedMwi() } - voicemailCount: cumulatedVoicemailCount() onClicked: { if (accountProxy.count > 1) { avatarButton.popup.open()