From 7b740f5e9a91fb6c814fae6946b3f8ca4260855e Mon Sep 17 00:00:00 2001 From: Michael Schuster Date: Wed, 15 Jan 2020 16:30:05 +0100 Subject: [PATCH] Remove setTalkCapability() from AccountState and filter for Talk upon App list building Since the per Account App list is now being built in AccountState's slotNavigationAppsFetched it's easy to filter for the availability of the Talk app on the server by its ID property upon App list building, thus eliminating the need for an extra fetch job. Signed-off-by: Michael Schuster --- src/gui/accountstate.cpp | 22 ++++------------------ src/gui/accountstate.h | 1 - 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/gui/accountstate.cpp b/src/gui/accountstate.cpp index b9b42eca5..5651e623f 100644 --- a/src/gui/accountstate.cpp +++ b/src/gui/accountstate.cpp @@ -45,6 +45,7 @@ AccountState::AccountState(AccountPtr account) , _notificationsEtagResponseHeader("*") , _maintenanceToConnectedDelay(60000 + (qrand() % (4 * 60000))) // 1-5min delay , _remoteWipe(new RemoteWipe(_account)) + , _hasTalk(false) { qRegisterMetaType("AccountState*"); @@ -96,23 +97,6 @@ AccountState::State AccountState::state() const return _state; } -void AccountState::setTalkCapability() -{ - QNetworkAccessManager *manager = new QNetworkAccessManager(this); - connect(manager, &QNetworkAccessManager::finished, - this, [=](QNetworkReply *reply) { - if (reply->error()) { - return; - } - //TODO: This is **** dirty, but atm I don't see a capability-way to determine talk integration - _hasTalk = (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 303) ? true : false; - }); - QNetworkRequest request; - QString url = this->account()->url().toString() + "/apps/spreed"; - request.setUrl(QUrl(url)); - manager->get(request); -} - void AccountState::setState(State state) { if (_state != state) { @@ -320,7 +304,6 @@ void AccountState::slotConnectionValidatorResult(ConnectionValidator::Status sta case ConnectionValidator::Connected: if (_state != Connected) { setState(Connected); - setTalkCapability(); // Get the Apps available on the server. fetchNavigationApps(); @@ -479,6 +462,9 @@ void AccountState::slotNavigationAppsFetched(const QJsonDocument &reply, int sta navLink.value("id").toString(), QUrl(navLink.value("icon").toString())); _apps << app; + + if(app->id() == QLatin1String("spreed")) + _hasTalk = true; } } } diff --git a/src/gui/accountstate.h b/src/gui/accountstate.h index 8bacdcd9c..c89c664b0 100644 --- a/src/gui/accountstate.h +++ b/src/gui/accountstate.h @@ -167,7 +167,6 @@ public slots: private: void setState(State state); - void setTalkCapability(); void fetchNavigationApps(); signals: -- 2.30.2