diff --git a/src/mirall/application.cpp b/src/mirall/application.cpp
index 8a18338e9c..0198122775 100644
--- a/src/mirall/application.cpp
+++ b/src/mirall/application.cpp
@@ -77,7 +77,14 @@ Application::Application(int argc, char **argv) :
setupKnownFolders();
setupContextMenu();
- qDebug() << NetworkLocation::currentLocation().encoded();
+ // Check if sitecopy is installed
+ QFileInfo fi( SITECOPY_BIN );
+ if( !fi.exists() ) {
+ QMessageBox::critical( 0, tr("Sitecopy not Installed."),
+ tr("The program sitecopy is not installed but it is needed by mirall.
Please install sitecopy!"));
+ }
+
+ qDebug() << "Network Location: " << NetworkLocation::currentLocation().encoded();
}
Application::~Application()
@@ -331,9 +338,16 @@ void Application::setupFolderFromConfigFile(const QString &file) {
QString targetPath = settings.value("backend:sitecopy/targetPath").toString();
SiteCopyFolder *scf = new SiteCopyFolder( file, /* file is the same as the alias */
- path.toString(),
- targetPath,
- this);
+ path.toString(),
+ targetPath,
+ this);
+ QFileInfo fi( SITECOPY_BIN );
+ if( ! fi.exists() ) {
+ SyncResult sr( SyncResult::SetupError );
+ sr.setErrorString( tr("Sitecopy is not installed!"));
+ scf->slotSyncFinished( sr );
+ }
+
folder = scf;
} else if (backend == "unison") {
@@ -361,6 +375,7 @@ void Application::setupFolderFromConfigFile(const QString &file) {
folder->setOnlyThisLANEnabled(settings.value("folder/onlyThisLAN", false).toBool());
_folderMap[file] = folder;
+ qDebug() << "Adding folder to Folder Map " << folder;
QObject::connect(folder, SIGNAL(syncStarted()), SLOT(slotFolderSyncStarted()));
QObject::connect(folder, SIGNAL(syncFinished(const SyncResult &)), SLOT(slotFolderSyncFinished(const SyncResult &)));
}
diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp
index f8e858b35e..e25baab710 100644
--- a/src/mirall/folder.cpp
+++ b/src/mirall/folder.cpp
@@ -91,7 +91,10 @@ bool Folder::syncEnabled() const
void Folder::setSyncEnabled( bool doit )
{
+ if( _lastSyncResult.result() != SyncResult::Success ) doit = false;
+
_enabled = doit;
+ _watcher->setEventsEnabled( doit );
}
bool Folder::onlyOnlineEnabled() const
@@ -201,12 +204,20 @@ void Folder::slotSyncStarted()
void Folder::slotSyncFinished(const SyncResult &result)
{
_lastSyncResult = result;
+ qDebug() << "XX got a sync result: " << _lastSyncResult.result()<< " for folder " << this ;
+
+ bool enabled = ( result.result() == SyncResult::Success );
+ setSyncEnabled( enabled );
- _watcher->setEventsEnabled(true);
_openAction->setIcon(icon(22));
// reenable the poll timer
- qDebug() << "* " << alias() << "Poll timer enabled";
- _pollTimer->start();
+ if( enabled ) {
+ qDebug() << "* " << alias() << "Poll timer enabled";
+ _pollTimer->start();
+ } else {
+ qDebug() << "* Not enabling poll timer for " << alias();
+ _pollTimer->stop();
+ }
}
void Folder::setBackend( const QString& b )
diff --git a/src/mirall/folder.h b/src/mirall/folder.h
index 6bde467053..a366018cc1 100644
--- a/src/mirall/folder.h
+++ b/src/mirall/folder.h
@@ -126,6 +126,10 @@ public:
QString backend() const;
QIcon icon( int size ) const;
+
+public slots:
+ void slotSyncFinished(const SyncResult &);
+
protected:
/**
* The minimum amounts of seconds to wait before
@@ -156,19 +160,19 @@ private:
*/
void evaluateSync(const QStringList &pathList);
- QString _path;
- QAction *_openAction;
+ QString _path;
+ QAction *_openAction;
// poll timer for remote syncs
- QTimer *_pollTimer;
- int _pollInterval;
- QString _alias;
- bool _onlyOnlineEnabled;
- bool _onlyThisLANEnabled;
+ QTimer *_pollTimer;
+ int _pollInterval;
+ QString _alias;
+ bool _onlyOnlineEnabled;
+ bool _onlyThisLANEnabled;
QNetworkConfigurationManager _networkMgr;
- bool _online;
- bool _enabled;
+ bool _online;
+ bool _enabled;
SyncResult _lastSyncResult;
- QString _backend;
+ QString _backend;
protected slots:
@@ -183,7 +187,7 @@ protected slots:
void slotOpenFolder();
void slotSyncStarted();
- void slotSyncFinished(const SyncResult &);
+
};
}
diff --git a/src/mirall/sitecopyfolder.cpp b/src/mirall/sitecopyfolder.cpp
index 1073717394..570601e04d 100644
--- a/src/mirall/sitecopyfolder.cpp
+++ b/src/mirall/sitecopyfolder.cpp
@@ -70,6 +70,14 @@ void SiteCopyFolder::startSync(const QStringList &pathList)
{
QMutexLocker locker(&_syncMutex);
+ QFileInfo fi( SITECOPY_BIN );
+ if( ! fi.exists() ) {
+ SyncResult sr( SyncResult::SetupError );
+ sr.setErrorString( tr("Sitecopy is not installed!"));
+ this->slotSyncFinished( sr );
+ return;
+ }
+
emit syncStarted();
qDebug() << "PATHLIST: " << pathList;
@@ -99,7 +107,7 @@ void SiteCopyFolder::startSiteCopy( const QString& command, SiteCopyState nextSt
return;
}
- QString programm = "/usr/bin/sitecopy";
+ const QString programm( SITECOPY_BIN );
QStringList args;
args << command << alias();
qDebug() << "** starting command " << args;
diff --git a/src/mirall/sitecopyfolder.h b/src/mirall/sitecopyfolder.h
index f387bb818c..ad488ff51a 100644
--- a/src/mirall/sitecopyfolder.h
+++ b/src/mirall/sitecopyfolder.h
@@ -21,6 +21,8 @@
#include "mirall/folder.h"
+#define SITECOPY_BIN "/usr/bin/sitecopy"
+
class QProcess;
namespace Mirall {
diff --git a/src/mirall/statusdialog.cpp b/src/mirall/statusdialog.cpp
index 152915e492..64475af9a8 100644
--- a/src/mirall/statusdialog.cpp
+++ b/src/mirall/statusdialog.cpp
@@ -152,6 +152,7 @@ void StatusDialog::setFolderList( Folder::Map folders )
SyncResult res = f->lastSyncResult();
QString resultStr = tr("Undefined");
QString statusIcon = "view-refresh";
+ qDebug() << "Status: " << res.result();
if( res.result() == SyncResult::Error ) {
resultStr = tr("Error");
statusIcon = "dialog-close";
@@ -161,6 +162,9 @@ void StatusDialog::setFolderList( Folder::Map folders )
} else if( res.result() == SyncResult::Disabled ) {
resultStr = tr("Disabled");
statusIcon = "dialog-cancel";
+ } else if( res.result() == SyncResult::SetupError ) {
+ resultStr = tr( "Setup Error" );
+ statusIcon = "dialog-cancel";
}
item->setData( QIcon::fromTheme( statusIcon ), FolderViewDelegate::FolderStatusIcon );
item->setData( resultStr, FolderViewDelegate::FolderStatus );
diff --git a/src/mirall/statusdialog.h b/src/mirall/statusdialog.h
index c824bf0b3d..cfa0a4e2b4 100644
--- a/src/mirall/statusdialog.h
+++ b/src/mirall/statusdialog.h
@@ -47,7 +47,7 @@ class StatusDialog : public QDialog, public Ui::statusDialog
Q_OBJECT
public:
explicit StatusDialog(QWidget *parent = 0);
- void setFolderList( QHash );
+ void setFolderList( Folder::Map );
void setOCUrl( const QUrl& );
signals:
diff --git a/src/mirall/syncresult.h b/src/mirall/syncresult.h
index 2d345b5811..603586229a 100644
--- a/src/mirall/syncresult.h
+++ b/src/mirall/syncresult.h
@@ -28,7 +28,8 @@ public:
Undefined,
Success,
Error,
- Disabled
+ Disabled,
+ SetupError
};
SyncResult();