diff --git a/Linphone/core/conference/ConferenceInfoList.cpp b/Linphone/core/conference/ConferenceInfoList.cpp index b3ae91c9c..a29300a05 100644 --- a/Linphone/core/conference/ConferenceInfoList.cpp +++ b/Linphone/core/conference/ConferenceInfoList.cpp @@ -63,9 +63,13 @@ void ConferenceInfoList::setSelf(QSharedPointer me) { QList> *items = new QList>(); mustBeInLinphoneThread(getClassName()); auto defaultAccount = CoreModel::getInstance()->getCore()->getDefaultAccount(); - if (!defaultAccount) return; + setAccountConnected(defaultAccount && defaultAccount->getState() == linphone::RegistrationState::Ok); + if (!defaultAccount || !mAccountConnected) { + return; + } std::list> conferenceInfos = defaultAccount->getConferenceInformationList(); + if (conferenceInfos.empty()) return; items->push_back(nullptr); // Add Dummy conference for today for (auto conferenceInfo : conferenceInfos) { if (conferenceInfo->getState() == linphone::ConferenceInfo::State::Cancelled) { @@ -75,8 +79,6 @@ void ConferenceInfoList::setSelf(QSharedPointer me) { auto confInfoCore = build(conferenceInfo); // Cancelled conference organized ourself me must be hidden if (confInfoCore) { - // qDebug() << log().arg("Add conf") << confInfoCore->getSubject() << "with state" - // << confInfoCore->getConferenceInfoState(); items->push_back(confInfoCore); } } @@ -94,11 +96,6 @@ void ConferenceInfoList::setSelf(QSharedPointer me) { }); }); - // This is needed because account does not have a contact address until - // it is connected, so we can't verify if it is the organizer of a deleted - // conference (which must hidden) - mCoreModelConnection->makeConnectToModel(&CoreModel::defaultAccountChanged, [this]() { emit lUpdate(true); }); - mCoreModelConnection->makeConnectToModel( &CoreModel::conferenceInfoReceived, [this](const std::shared_ptr &core, @@ -106,9 +103,48 @@ void ConferenceInfoList::setSelf(QSharedPointer me) { lDebug() << log().arg("conference info received") << conferenceInfo->getSubject(); addConference(conferenceInfo->clone()); }); + + // This is needed because account does not have a contact address until + // it is connected, so we can't verify if it is the organizer of a deleted + // conference (which must hidden) + mCoreModelConnection->makeConnectToModel( + &CoreModel::defaultAccountChanged, + [this](const std::shared_ptr &core, const std::shared_ptr &account) { + auto accountCore = account ? AccountCore::create(account) : nullptr; + mCoreModelConnection->invokeToCore([this, accountCore] { + if (mCurrentAccountCore) + disconnect(mCurrentAccountCore.get(), &AccountCore::registrationStateChanged, this, nullptr); + mCurrentAccountCore = accountCore; + if (mCurrentAccountCore) + connect(mCurrentAccountCore.get(), &AccountCore::registrationStateChanged, this, + [this] { emit lUpdate(); }); + emit lUpdate(true); + }); + }); + mCoreModelConnection->invokeToModel([this] { + auto defaultAccount = CoreModel::getInstance()->getCore()->getDefaultAccount(); + auto accountCore = defaultAccount ? AccountCore::create(defaultAccount) : nullptr; + mCoreModelConnection->invokeToCore([this, accountCore] { + mCurrentAccountCore = accountCore; + if (mCurrentAccountCore) + connect(mCurrentAccountCore.get(), &AccountCore::registrationStateChanged, this, + [this] { emit lUpdate(); }); + }); + }); emit lUpdate(true); } +void ConferenceInfoList::setAccountConnected(bool connected) { + if (mAccountConnected != connected) { + mAccountConnected = connected; + emit accountConnectedChanged(mAccountConnected); + } +} + +bool ConferenceInfoList::getAccountConnected() const { + return mAccountConnected; +} + void ConferenceInfoList::resetData(QList> data) { beginResetModel(); mList.clear(); diff --git a/Linphone/core/conference/ConferenceInfoList.hpp b/Linphone/core/conference/ConferenceInfoList.hpp index 48f57d26f..2445d7331 100644 --- a/Linphone/core/conference/ConferenceInfoList.hpp +++ b/Linphone/core/conference/ConferenceInfoList.hpp @@ -55,6 +55,9 @@ public: QHash roleNames() const override; + void setAccountConnected(bool connected); + bool getAccountConnected() const; + virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; signals: @@ -65,11 +68,13 @@ signals: void currentDateIndexChanged(int index); void confInfoInserted(QSharedPointer data); void confInfoUpdated(QSharedPointer data); + void accountConnectedChanged(bool connected); private: QSharedPointer> mCoreModelConnection; QSharedPointer mCurrentAccountCore; bool mHaveCurrentDate = false; + bool mAccountConnected = false; DECLARE_ABSTRACT_OBJECT }; #endif // CONFERENCE_INFO_LIST_H_ diff --git a/Linphone/core/conference/ConferenceInfoProxy.cpp b/Linphone/core/conference/ConferenceInfoProxy.cpp index 0563fc932..937eb628c 100644 --- a/Linphone/core/conference/ConferenceInfoProxy.cpp +++ b/Linphone/core/conference/ConferenceInfoProxy.cpp @@ -58,13 +58,19 @@ ConferenceInfoProxy::ConferenceInfoProxy(QObject *parent) : LimitProxy(parent) { }, Qt::QueuedConnection); connect(mList.get(), &ConferenceInfoList::initialized, this, &ConferenceInfoProxy::initialized); + connect(mList.get(), &ConferenceInfoList::accountConnectedChanged, this, + &ConferenceInfoProxy::accountConnectedChanged); } ConferenceInfoProxy::~ConferenceInfoProxy() { } bool ConferenceInfoProxy::haveCurrentDate() const { - return mList->haveCurrentDate(); + return mList && mList->haveCurrentDate(); +} + +bool ConferenceInfoProxy::getAccountConnected() const { + return mList && mList->getAccountConnected(); } bool ConferenceInfoProxy::SortFilterList::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { diff --git a/Linphone/core/conference/ConferenceInfoProxy.hpp b/Linphone/core/conference/ConferenceInfoProxy.hpp index 38523be28..86df88e89 100644 --- a/Linphone/core/conference/ConferenceInfoProxy.hpp +++ b/Linphone/core/conference/ConferenceInfoProxy.hpp @@ -32,6 +32,7 @@ class ConferenceInfoProxy : public LimitProxy, public AbstractObject { Q_OBJECT Q_PROPERTY(bool haveCurrentDate READ haveCurrentDate NOTIFY haveCurrentDateChanged) + Q_PROPERTY(bool accountConnected READ getAccountConnected NOTIFY accountConnectedChanged) public: enum ConferenceInfoFiltering { None = 0, Future = 1 }; @@ -43,6 +44,7 @@ public: ~ConferenceInfoProxy(); bool haveCurrentDate() const; + bool getAccountConnected() const; Q_INVOKABLE void clear(); Q_INVOKABLE int loadUntil(ConferenceInfoGui *confInfo); @@ -52,6 +54,7 @@ signals: void haveCurrentDateChanged(); void conferenceInfoCreated(ConferenceInfoGui *confInfo); void conferenceInfoUpdated(ConferenceInfoGui *confInfo); + void accountConnectedChanged(bool connected); private: QSharedPointer mList; diff --git a/Linphone/view/Control/Display/Chat/FileView.qml b/Linphone/view/Control/Display/Chat/FileView.qml index ebe792910..11e83a7de 100644 --- a/Linphone/view/Control/Display/Chat/FileView.qml +++ b/Linphone/view/Control/Display/Chat/FileView.qml @@ -157,7 +157,6 @@ Item { } Text { z: parent.z + 1 - RectangleTest{anchors.fill: parent} property int timeDisplayed: videoThumbnail.playbackState === MediaPlayer.PlayingState ? videoThumbnail.position : videoThumbnail.duration anchors.bottom: parent.bottom anchors.left: parent.left diff --git a/Linphone/view/Control/Display/Meeting/MeetingListView.qml b/Linphone/view/Control/Display/Meeting/MeetingListView.qml index 6348878cc..d8ef7f783 100644 --- a/Linphone/view/Control/Display/Meeting/MeetingListView.qml +++ b/Linphone/view/Control/Display/Meeting/MeetingListView.qml @@ -16,8 +16,9 @@ ListView { property var delegateButtons property ConferenceInfoGui selectedConference property bool _moveToIndex: false + property bool loading: false + property real busyIndicatorSize: Math.round(60 * DefaultStyle.dp) - visible: count > 0 clip: true cacheBuffer: height/2 @@ -88,8 +89,21 @@ ListView { filterType: ConferenceInfoProxy.None initialDisplayItems: Math.max(20, 2 * mainItem.height / (Math.round(63 * DefaultStyle.dp))) displayItemsStep: initialDisplayItems/2 + Component.onCompleted: { + mainItem.loading = !confInfoProxy.accountConnected + } + onModelAboutToBeReset: { + mainItem.loading = true + } + onModelReset: { + mainItem.loading = !confInfoProxy.accountConnected + } + onAccountConnectedChanged: (connected) => { + mainItem.loading = !connected + } function selectData(confInfoGui){ mainItem.currentIndex = loadUntil(confInfoGui) + mainItem.positionViewAtIndex(mainItem.currentIndex, ListView.Contain) } onConferenceInfoCreated: (confInfoGui) => { selectData(confInfoGui) @@ -102,6 +116,16 @@ ListView { selectData(null) } } + + BusyIndicator { + anchors.horizontalCenter: mainItem.horizontalCenter + visible: mainItem.loading + height: visible ? mainItem.busyIndicatorSize : 0 + width: mainItem.busyIndicatorSize + indicatorHeight: mainItem.busyIndicatorSize + indicatorWidth: mainItem.busyIndicatorSize + indicatorColor: DefaultStyle.main1_500_main + } ScrollBar.vertical: ScrollBar { id: scrollbar diff --git a/Linphone/view/Page/Main/Meeting/MeetingPage.qml b/Linphone/view/Page/Main/Meeting/MeetingPage.qml index 66cf635cf..e12bf78d7 100644 --- a/Linphone/view/Page/Main/Meeting/MeetingPage.qml +++ b/Linphone/view/Page/Main/Meeting/MeetingPage.qml @@ -55,7 +55,6 @@ AbstractMainPage { onVisibleChanged: if (!visible) { leftPanelStackView.clear() leftPanelStackView.push(leftPanelStackView.initialItem) - } onSelectedConferenceChanged: { @@ -193,7 +192,7 @@ AbstractMainPage { } } Text { - visible: conferenceList.count === 0 + visible: conferenceList.count === 0 && !conferenceList.loading Layout.topMargin: Math.round(137 * DefaultStyle.dp) Layout.fillHeight: true Layout.alignment: Qt.AlignHCenter @@ -215,7 +214,15 @@ AbstractMainPage { searchBarText: searchBar.text - onCountChanged: mainItem.meetingListCount = count + onCountChanged: { + mainItem.meetingListCount = count === 0 + } + Binding { + target: mainItem + property: "showDefaultItem" + when: conferenceList.loading + value: false + } onSelectedConferenceChanged: { mainItem.selectedConference = selectedConference }