VFS: Tell the vfs plugin whether we have multiple accounts
authorHannah von Reth <hannah.vonreth@owncloud.com>
Thu, 18 Jun 2020 14:12:35 +0000 (16:12 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:59:14 +0000 (10:59 +0100)
This allows us to decide on the presentation of the account

src/common/vfs.h
src/gui/accountmanager.cpp
src/gui/accountmanager.h
src/gui/folder.cpp
test/stubfolderman.cpp
test/stubremotewipe.cpp

index ab39ea8fc1036aaec55b6b970c777e717b0d7b54..b77eae161a1296b3cc368f30326834d93fdf8550 100644 (file)
@@ -62,6 +62,11 @@ struct OCSYNC_EXPORT VfsSetupParams
     QString providerName;
     QString providerVersion;
 
+    /** when registering with the system we might use
+     *  a different presentaton to identify the accounts
+     */
+    bool multipleAccountsRegistered = false;
+
     /** Whether native shell integration shall be enabled
      *
      * For some plugins that doesn't work well in tests.
index 98357e3d30e1ca4a5c862cb76731740b6cea50e6..7d7b397ac88a50c44892a9c18e7cc2b57c44543f 100644 (file)
@@ -420,6 +420,11 @@ void AccountManager::shutdown()
     }
 }
 
+QList<AccountStatePtr> AccountManager::accounts() const
+{
+     return _accounts;
+}
+
 bool AccountManager::isAccountIdAvailable(const QString &id) const
 {
     if (_additionalBlockedAccountIds.contains(id))
index d96ad2e4ac2e7299f3468bf58088d232649bc994..356ba0e6f3aa665494f4a0934a2ad5a0a6134d36 100644 (file)
@@ -58,7 +58,7 @@ public:
      * Return a list of all accounts.
      * (this is a list of QSharedPointer for internal reasons, one should normally not keep a copy of them)
      */
-    QList<AccountStatePtr> accounts() { return _accounts; }
+    QList<AccountStatePtr> accounts() const;
 
     /**
      * Return the account state pointer for an account identified by its display name
index e513bce40bb81a46586485ec912e8d36cbfe5c9c..187377eab7fd7c8741ac507d0fb14bd472d2da8c 100644 (file)
@@ -16,6 +16,7 @@
 #include "config.h"
 
 #include "account.h"
+#include "accountmanager.h"
 #include "accountstate.h"
 #include "folder.h"
 #include "folderman.h"
@@ -489,6 +490,7 @@ void Folder::startVfs()
     vfsParams.journal = &_journal;
     vfsParams.providerName = Theme::instance()->appNameGUI();
     vfsParams.providerVersion = Theme::instance()->version();
+    vfsParams.multipleAccountsRegistered = AccountManager::instance()->accounts().size() > 1;
 
     connect(_vfs.data(), &Vfs::beginHydrating, this, &Folder::slotHydrationStarts);
     connect(_vfs.data(), &Vfs::doneHydrating, this, &Folder::slotHydrationDone);
index 0ee32d73150821222040aa61d0fc84b661719ed6..3df56d1d1012cf5fdff00dc2cf31ded8979b1408 100644 (file)
@@ -8,6 +8,7 @@ void OCC::AccountManager::save(bool) { }
 void OCC::AccountManager::saveAccountState(AccountState *) { }
 void OCC::AccountManager::deleteAccount(AccountState *) { }
 void OCC::AccountManager::accountRemoved(OCC::AccountState*) { }
+QList<OCC::AccountStatePtr> OCC::AccountManager::accounts() const { return QList<OCC::AccountStatePtr>(); }
 OCC::AccountStatePtr OCC::AccountManager::account(const QString &){ return AccountStatePtr(); }
 void OCC::AccountManager::removeAccountFolders(OCC::AccountState*) { }
 const QMetaObject OCC::AccountManager::staticMetaObject = QObject::staticMetaObject;
index d74dde2dae591477230521171661e513d9937da7..e434424fdf42121e66ae3a5f8e72a63c596d0ced 100644 (file)
@@ -9,6 +9,7 @@ void OCC::AccountManager::save(bool) { }
 OCC::AccountState *OCC::AccountManager::addAccount(const AccountPtr& ac) { return new OCC::AccountState(ac); }
 void OCC::AccountManager::deleteAccount(AccountState *) { }
 void OCC::AccountManager::accountRemoved(OCC::AccountState*) { }
+QList<OCC::AccountStatePtr> OCC::AccountManager::accounts() const { return QList<OCC::AccountStatePtr>(); }
 OCC::AccountStatePtr OCC::AccountManager::account(const QString &){ return AccountStatePtr(); }
 const QMetaObject OCC::AccountManager::staticMetaObject = QObject::staticMetaObject;