[Pkg-owncloud-commits] [owncloud-client] 07/38: Account: Read settings from ownCloud config if no branded exists.

Sandro Knauß hefee-guest at moszumanska.debian.org
Fri Sep 5 20:20:54 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch sid
in repository owncloud-client.

commit da4958c7160ded00b1f1f99567c99c3b7be47bff
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Thu Jun 12 16:55:00 2014 +0200

    Account: Read settings from ownCloud config if no branded exists.
    
    If there is not yet a config for a branded client, but one for the
    "normal" client targetting the same URL, it will be migrated.
---
 src/mirall/account.cpp | 38 ++++++++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/src/mirall/account.cpp b/src/mirall/account.cpp
index 49bc753..fc282d4 100644
--- a/src/mirall/account.cpp
+++ b/src/mirall/account.cpp
@@ -114,21 +114,46 @@ void Account::save()
 
 Account* Account::restore()
 {
+    // try to open the correctly themed settings
     QScopedPointer<QSettings> settings(settingsWithGroup(Theme::instance()->appName()));
-    QScopedPointer<ownCloudTheme> ocTheme(new ownCloudTheme);
 
     Account *acc = 0;
-    MirallConfigFile cfg;
+    bool migratedCreds = false;
 
+    // if the settings file could not be opened, the childKeys list is empty
     if( settings->childKeys().isEmpty() ) {
         // Now try to open the original ownCloud settings to see if they exist.
-        cfg.setTheme(ocTheme.data());
+        QString oCCfgFile = settings->fileName();
+        // replace the last two segments with ownCloud/owncloud.cfg
+        oCCfgFile = oCCfgFile.left( oCCfgFile.lastIndexOf('/'));
+        oCCfgFile = oCCfgFile.left( oCCfgFile.lastIndexOf('/'));
+        oCCfgFile += QLatin1String("/ownCloud/owncloud.cfg");
+
+        QFileInfo fi( oCCfgFile );
+        if( fi.isReadable() ) {
+            QSettings *oCSettings = new QSettings(oCCfgFile, QSettings::IniFormat);
+            oCSettings->beginGroup(QLatin1String("ownCloud"));
+
+            // Check the theme url to see if it is the same url that the oC config was for
+            QString overrideUrl = Theme::instance()->overrideServerUrl();
+            if( !overrideUrl.isEmpty() ) {
+                QString oCUrl = oCSettings->value(QLatin1String(urlC)).toString();
+
+                // in case the urls are equal reset the settings object to read from
+                // the ownCloud settings object
+                if( oCUrl == overrideUrl ) {
+                    migratedCreds = true;
+                    settings.reset( oCSettings );
+                } else {
+                    delete oCSettings;
+                }
+            }
+        }
     }
 
     if (!settings->childKeys().isEmpty()) {
         acc = new Account;
 
-        acc->setApprovedCerts(QSslCertificate::fromData(cfg.caCerts()));
         acc->setUrl(settings->value(QLatin1String(urlC)).toUrl());
         acc->setCredentials(CredentialsFactory::create(settings->value(QLatin1String(authTypeC)).toString()));
 
@@ -140,6 +165,11 @@ Account* Account::restore()
                 continue;
             acc->_settingsMap.insert(key, settings->value(key));
         }
+
+        // now the cert, it is in the general group
+        settings->beginGroup(QLatin1String("General"));
+        acc->setApprovedCerts(QSslCertificate::fromData(settings->value(QLatin1String("CaCertificates")).toByteArray()));
+        acc->setMigrated(migratedCreds);
         return acc;
     }
     return 0;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list