Add forceLegacyImport property to accountmanager
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 5 May 2023 02:44:10 +0000 (10:44 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 16 May 2023 13:23:43 +0000 (21:23 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/accountmanager.cpp
src/gui/accountmanager.h

index 61b2409854ffcafe9cad35b3798e48f5dac2baeb..d266bf54d798cc14f3893e932301f403e2195e97 100644 (file)
@@ -558,4 +558,19 @@ void AccountManager::addAccountState(AccountState *accountState)
     ptr->trySignIn();
     emit accountAdded(accountState);
 }
+
+bool AccountManager::forceLegacyImport() const
+{
+    return _forceLegacyImport;
+}
+
+void AccountManager::setForceLegacyImport(const bool forceLegacyImport)
+{
+    if (_forceLegacyImport == forceLegacyImport) {
+        return;
+    }
+
+    _forceLegacyImport = forceLegacyImport;
+    Q_EMIT forceLegacyImportChanged();
+}
 }
index 8f853df8970e83168287b4904414e4d6a21d44d7..da5f3464a7106a75a78d0c6b3757036537d31a14 100644 (file)
@@ -26,6 +26,9 @@ namespace OCC {
 class AccountManager : public QObject
 {
     Q_OBJECT
+
+    Q_PROPERTY(bool forceLegacyImport READ forceLegacyImport WRITE setForceLegacyImport NOTIFY forceLegacyImportChanged)
+
 public:
     enum AccountsRestoreResult {
         AccountsRestoreFailure = 0,
@@ -69,6 +72,12 @@ public:
 
     [[nodiscard]] AccountStatePtr accountFromUserId(const QString &id) const;
 
+    /**
+     * Returns whether the account setup will force an import of
+     * legacy clients' accounts (true), or ask first (false)
+     */
+    [[nodiscard]] bool forceLegacyImport() const;
+
     /**
      * Creates an account and sets up some basic handlers.
      * Does *not* add the account to the account manager just yet.
@@ -97,11 +106,14 @@ public slots:
     /// Remove all accounts
     void shutdown();
 
+    void setForceLegacyImport(const bool forceLegacyImport);
+
 signals:
     void accountAdded(OCC::AccountState *account);
     void accountRemoved(OCC::AccountState *account);
     void accountSyncConnectionRemoved(OCC::AccountState *account);
     void removeAccountFolders(OCC::AccountState *account);
+    void forceLegacyImportChanged();
 
 private:
     // saving and loading Account to settings
@@ -120,5 +132,6 @@ private:
     QList<AccountStatePtr> _accounts;
     /// Account ids from settings that weren't read
     QSet<QString> _additionalBlockedAccountIds;
+    bool _forceLegacyImport = false;
 };
 }