Remove setTalkCapability() from AccountState and filter for Talk upon App list building
authorMichael Schuster <michael@schuster.ms>
Wed, 15 Jan 2020 15:30:05 +0000 (16:30 +0100)
committerMichael Schuster <michael@schuster.ms>
Wed, 15 Jan 2020 15:30:05 +0000 (16:30 +0100)
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 <michael@schuster.ms>
src/gui/accountstate.cpp
src/gui/accountstate.h

index b9b42eca548d11a15b4ead2ca7560614a5174224..5651e623f823d6623c92af8178e9af4ea0d34fbc 100644 (file)
@@ -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 *>("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;
                     }
                 }
             }
index 8bacdcd9c7db318f3288058e5b4b6b534e62e2f2..c89c664b0d6835f628f8c4ff10533fb97b643b9f 100644 (file)
@@ -167,7 +167,6 @@ public slots:
 
 private:
     void setState(State state);
-    void setTalkCapability();
     void fetchNavigationApps();
 
 signals: