Browse Source

- simplified the folder wizard
- live check of the ownCloud connect

Klaas Freitag 14 years ago
parent
commit
f3123b6c02

+ 2 - 5
src/mirall/application.cpp

@@ -188,11 +188,8 @@ void Application::slotAddFolder()
             qDebug() << "Now writing sitecopy config " << _folderWizard->field("OCSiteAlias").toString(); ;
             SitecopyConfig scConfig;
 
-            scConfig.writeSiteConfig( _folderWizard->field("sourceFolder").toString(), /* local path */
-                                      alias,
-                                      _folderWizard->field("OCUrl").toString(),        /* site URL   */
-                                      _folderWizard->field("OCUser").toString(),
-                                      _folderWizard->field("OCPasswd").toString(),
+            scConfig.writeSiteConfig( alias,
+                                      _folderWizard->field("sourceFolder").toString(), /* local path */
                                       _folderWizard->field("targetOCFolder").toString() );
         } else {
             qWarning() << "* Folder not local and note remote?";

+ 1 - 1
src/mirall/folder.cpp

@@ -24,7 +24,7 @@
 #include "mirall/folder.h"
 #include "mirall/folderwatcher.h"
 
-#define DEFAULT_POLL_INTERVAL_SEC 10
+#define DEFAULT_POLL_INTERVAL_SEC 45
 
 namespace Mirall {
 

+ 11 - 13
src/mirall/folderwizard.cpp

@@ -98,8 +98,8 @@ void FolderWizardTargetPage::initializePage()
 
     ownCloudInfo *ocInfo = new ownCloudInfo( this );
     if( ocInfo->isConfigured() ) {
-      connect( ocInfo, SIGNAL(ownCloudInfoFound(QString,QString)),SLOT(slotOwnCloudFound(QString,QString)));
-      connect(ocInfo,SIGNAL(noOwncloudFound()),SLOT(slotOwnCloudFound(QString(),QString())));
+      connect(ocInfo, SIGNAL(ownCloudInfoFound(QString,QString)),SLOT(slotOwnCloudFound(QString,QString)));
+      connect(ocInfo,SIGNAL(noOwncloudFound()),SLOT(slotNoOwnCloudFound()));
       ocInfo->checkInstallation();
 
     } else {
@@ -110,19 +110,17 @@ void FolderWizardTargetPage::initializePage()
 
 void FolderWizardTargetPage::slotOwnCloudFound( const QString& url, const QString& infoStr )
 {
-  QString info( infoStr );
-  info.remove(0,1); // remove first char which is a "{"
-  info.remove(-1,1); // remove the last char which is a "}"
-  QStringList li = info.split( QChar(':') );
 
-  QString infoString;
-  foreach ( infoString, li ) {
-    if( infoString.contains( "versionstring") ) {
+  _ui.OCLabel->setText( tr("to your <a href=\"%1\">ownCloud</a> (version %2)").arg(url).arg(infoStr));
 
-    }
-  }
+  qDebug() << "ownCloud found on " << url << " with version: " << infoStr;
+}
 
-  qDebug() << "THis result on " << url << ": " << info;
+void FolderWizardTargetPage::slotNoOwnCloudFound()
+{
+  qDebug() << "No ownCloud configured!";
+  _ui.OCRadioBtn->setEnabled( false );
+  _ui.OCFolderLineEdit->setEnabled( false );
 }
 
 void FolderWizardTargetPage::on_localFolderRadioBtn_toggled()
@@ -232,7 +230,7 @@ FolderWizard::FolderWizard(QWidget *parent)
 {
     setPage(Page_Source,   new FolderWizardSourcePage());
     setPage(Page_Target,   new FolderWizardTargetPage());
-    setPage(Page_Network,  new FolderWizardNetworkPage());
+    // setPage(Page_Network,  new FolderWizardNetworkPage());
     // setPage(Page_Owncloud, new FolderWizardOwncloudPage());
 }
 

+ 1 - 1
src/mirall/folderwizard.h

@@ -72,7 +72,7 @@ protected slots:
     void on_urlFolderLineEdit_textChanged();
 
     void slotOwnCloudFound( const QString&, const QString& );
-
+    void slotNoOwnCloudFound();
 private:
     Ui_FolderWizardTargetPage _ui;
 };

+ 132 - 126
src/mirall/folderwizardtargetpage.ui

@@ -13,7 +13,7 @@
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout_3">
+  <layout class="QGridLayout" name="gridLayout_2">
    <item row="0" column="0">
     <layout class="QHBoxLayout" name="horizontalLayout_12">
      <item>
@@ -50,131 +50,137 @@
      <property name="title">
       <string>Pick a place where the data should go to:</string>
      </property>
-     <layout class="QGridLayout" name="gridLayout_2">
-      <item row="0" column="0">
-       <layout class="QGridLayout" name="gridLayout">
-        <item row="0" column="0" colspan="2">
-         <widget class="QRadioButton" name="localFolderRadioBtn">
-          <property name="text">
-           <string>Another local folder</string>
-          </property>
-          <property name="checked">
-           <bool>true</bool>
-          </property>
-         </widget>
-        </item>
-        <item row="1" column="0">
-         <spacer name="horizontalSpacer">
-          <property name="orientation">
-           <enum>Qt::Horizontal</enum>
-          </property>
-          <property name="sizeType">
-           <enum>QSizePolicy::Fixed</enum>
-          </property>
-          <property name="sizeHint" stdset="0">
-           <size>
-            <width>22</width>
-            <height>13</height>
-           </size>
-          </property>
-         </spacer>
-        </item>
-        <item row="1" column="1">
-         <widget class="QLabel" name="label">
-          <property name="text">
-           <string>Folder name:</string>
-          </property>
-         </widget>
-        </item>
-        <item row="1" column="2">
-         <widget class="QLineEdit" name="localFolder2LineEdit">
-          <property name="placeholderText">
-           <string>/home/local2</string>
-          </property>
-         </widget>
-        </item>
-        <item row="1" column="3">
-         <widget class="QPushButton" name="localFolder2ChooseBtn">
-          <property name="text">
-           <string>C&amp;hoose..</string>
-          </property>
-         </widget>
-        </item>
-        <item row="2" column="0" colspan="2">
-         <widget class="QRadioButton" name="urlFolderRadioBtn">
-          <property name="text">
-           <string>Remote folder (URL)</string>
-          </property>
-         </widget>
-        </item>
-        <item row="3" column="0">
-         <spacer name="horizontalSpacer_2">
-          <property name="orientation">
-           <enum>Qt::Horizontal</enum>
-          </property>
-          <property name="sizeType">
-           <enum>QSizePolicy::Fixed</enum>
-          </property>
-          <property name="sizeHint" stdset="0">
-           <size>
-            <width>22</width>
-            <height>13</height>
-           </size>
-          </property>
-         </spacer>
-        </item>
-        <item row="3" column="1">
-         <widget class="QLabel" name="label_2">
-          <property name="text">
-           <string>URL:</string>
-          </property>
-         </widget>
-        </item>
-        <item row="3" column="2">
-         <widget class="QLineEdit" name="urlFolderLineEdit">
-          <property name="placeholderText">
-           <string>scp://john@host.com//myfolder</string>
-          </property>
-         </widget>
-        </item>
-        <item row="4" column="0" colspan="2">
-         <widget class="QRadioButton" name="OCRadioBtn">
-          <property name="text">
-           <string>to Owncloud</string>
-          </property>
-         </widget>
-        </item>
-        <item row="5" column="0">
-         <spacer name="horizontalSpacer_3">
-          <property name="orientation">
-           <enum>Qt::Horizontal</enum>
-          </property>
-          <property name="sizeType">
-           <enum>QSizePolicy::Fixed</enum>
-          </property>
-          <property name="sizeHint" stdset="0">
-           <size>
-            <width>22</width>
-            <height>13</height>
-           </size>
-          </property>
-         </spacer>
-        </item>
-        <item row="5" column="1">
-         <widget class="QLabel" name="label_4">
-          <property name="text">
-           <string>Folder on Owncloud:</string>
-          </property>
-         </widget>
-        </item>
-        <item row="5" column="2">
-         <widget class="QLineEdit" name="OCFolderLineEdit">
-          <property name="placeholderText">
-           <string>Sync-directory</string>
-          </property>
-         </widget>
-        </item>
-       </layout>
+     <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="0" colspan="2">
+       <widget class="QRadioButton" name="localFolderRadioBtn">
+        <property name="text">
+         <string>Another local folder</string>
+        </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="0">
+       <spacer name="horizontalSpacer">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeType">
+         <enum>QSizePolicy::Fixed</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>22</width>
+          <height>13</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="1" column="1">
+       <widget class="QLabel" name="label">
+        <property name="text">
+         <string>Folder name:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="2">
+       <widget class="QLineEdit" name="localFolder2LineEdit">
+        <property name="placeholderText">
+         <string>/home/local2</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="3">
+       <widget class="QPushButton" name="localFolder2ChooseBtn">
+        <property name="text">
+         <string>C&amp;hoose..</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="0" colspan="2">
+       <widget class="QRadioButton" name="urlFolderRadioBtn">
+        <property name="text">
+         <string>Remote folder (URL)</string>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="0">
+       <spacer name="horizontalSpacer_2">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeType">
+         <enum>QSizePolicy::Fixed</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>22</width>
+          <height>13</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="3" column="1">
+       <widget class="QLabel" name="label_2">
+        <property name="text">
+         <string>URL:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="2">
+       <widget class="QLineEdit" name="urlFolderLineEdit">
+        <property name="placeholderText">
+         <string>scp://john@host.com//myfolder</string>
+        </property>
+       </widget>
+      </item>
+      <item row="4" column="0">
+       <widget class="QRadioButton" name="OCRadioBtn">
+        <property name="text">
+         <string/>
+        </property>
+       </widget>
+      </item>
+      <item row="4" column="1">
+       <widget class="QLabel" name="OCLabel">
+        <property name="text">
+         <string>to your ownCloud</string>
+        </property>
+        <property name="openExternalLinks">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="5" column="0">
+       <spacer name="horizontalSpacer_3">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeType">
+         <enum>QSizePolicy::Fixed</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>22</width>
+          <height>13</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="5" column="1">
+       <widget class="QLabel" name="label_4">
+        <property name="text">
+         <string>Folder on ownCloud:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="5" column="2">
+       <widget class="QLineEdit" name="OCFolderLineEdit">
+        <property name="placeholderText">
+         <string>Sync-directory</string>
+        </property>
+       </widget>
       </item>
      </layout>
     </widget>

+ 21 - 1
src/mirall/owncloudinfo.cpp

@@ -67,6 +67,8 @@ void ownCloudInfo::checkInstallation()
          this, SLOT(slotReplyFinished(QNetworkReply*)));
 
  _reply = manager->get(QNetworkRequest(QUrl( url() + "/status.php")));
+ _readBuffer.clear();
+
  connect( _reply, SIGNAL( error(QNetworkReply::NetworkError )),
           this, SLOT(slotError( QNetworkReply::NetworkError )));
  connect( _reply, SIGNAL( readyRead()), this, SLOT(slotReadyRead()));
@@ -79,7 +81,25 @@ void ownCloudInfo::slotReplyFinished( QNetworkReply *reply )
   const QString version( _readBuffer );
   const QString url = reply->url().toString();
 
-  emit ownCloudInfoFound( url, version );
+  QString info( version );
+
+  info.remove(0,1); // remove first char which is a "{"
+  info.remove(-1,1); // remove the last char which is a "}"
+  QStringList li = info.split( QChar(',') );
+
+  QString infoString;
+  QString versionStr;
+  foreach ( infoString, li ) {
+    if( infoString.contains( "versionstring") ) {
+      // get the version string out.
+      versionStr = infoString.mid(17);
+      versionStr.remove(-1, 1);
+    }
+  }
+  QString urlStr( url );
+  urlStr.remove("/status.php"); // get the plain url.
+
+  emit ownCloudInfoFound( urlStr, versionStr );
 }
 
 void ownCloudInfo::slotReadyRead()

+ 11 - 0
src/mirall/sitecopyconfig.cpp

@@ -13,6 +13,7 @@
  */
 
 #include "sitecopyconfig.h"
+#include "owncloudinfo.h"
 
 namespace Mirall {
 
@@ -21,6 +22,15 @@ SitecopyConfig::SitecopyConfig()
 
 }
 
+/*
+ * this uses the users ownCloud config written in mirall.cfg
+ */
+void SitecopyConfig::writeSiteConfig( const QString& alias, const QString& localPath, const QString& targetPath )
+{
+  ownCloudInfo ocInfo;
+  writeSiteConfig( localPath, alias, ocInfo.url(), ocInfo.user(), ocInfo.password(), targetPath );
+}
+
 void SitecopyConfig::writeSiteConfig( const QString& localPath,
                                       const QString& siteAlias, const QString& url,
                                       const QString& user, const QString& passwd,
@@ -40,6 +50,7 @@ void SitecopyConfig::writeSiteConfig( const QString& localPath,
   if( _Sites.contains( siteAlias ) ) {
     ocDefs = _Sites[siteAlias];
   }
+  qDebug() << "The url is " << url;
   QUrl ocUrl( url );
   QString host = ocUrl.host();
   QString path = ocUrl.path();

+ 18 - 11
src/mirall/sitecopyconfig.h

@@ -20,21 +20,28 @@ namespace Mirall {
 class SitecopyConfig
 {
 public:
-    SitecopyConfig();
+  SitecopyConfig();
 
-    void writeSiteConfig( const QString& localPath, const QString& siteAlias,
-                          const QString& host, const QString& user,
-                          const QString& passwd,
-                          const QString& remoteFolder = QString() );
-    bool parseSiteConfig();
+  /**
+   * write a sitecopy config for ownCloud.
+   * The ownCloud config values are taken from the users ownCloud config in mirall.cfg
+   */
+  void writeSiteConfig( const QString& alias, const QString& localPath,
+                        const QString& targetPath );
+
+  void writeSiteConfig( const QString& localPath, const QString& siteAlias,
+                        const QString& host, const QString& user,
+                        const QString& passwd,
+                        const QString& remoteFolder = QString() );
+  bool parseSiteConfig();
 
 private:
-    void processConfigLine( const QString& );
+  void processConfigLine( const QString& );
 
-    QHash<QString, QHash<QString, QString> > _Sites;
-    QHash<QString, QString>                  _CurrSite;
-    // QHash<QString, QStringList>              _ChangesHash;
-    QString _CurrSiteName;
+  QHash<QString, QHash<QString, QString> > _Sites;
+  QHash<QString, QString>                  _CurrSite;
+  // QHash<QString, QStringList>              _ChangesHash;
+  QString _CurrSiteName;
 };
 };