- fixed local file change detection in win poller

- fixed context menu at startup.
This commit is contained in:
Klaas Freitag 2012-03-30 13:57:02 +02:00
Родитель 3fb471edad
Коммит 8e637bd8c7
6 изменённых файлов: 352 добавлений и 228 удалений

Просмотреть файл

@ -85,7 +85,16 @@ Application::Application(int argc, char **argv) :
setQuitOnLastWindowClosed(false); setQuitOnLastWindowClosed(false);
_folderWizard = new FolderWizard( 0, _theme ); _folderWizard = new FolderWizard( 0, _theme );
_ocInfo = new ownCloudInfo( QString(), this );
connect( _ocInfo,SIGNAL(ownCloudInfoFound(QString,QString)),
SLOT(slotOwnCloudFound(QString,QString)));
connect( _ocInfo,SIGNAL(noOwncloudFound(QNetworkReply::NetworkError)),
SLOT(slotNoOwnCloudFound(QNetworkReply::NetworkError)));
_owncloudSetupWizard = new OwncloudSetupWizard( _folderMan, _theme ); _owncloudSetupWizard = new OwncloudSetupWizard( _folderMan, _theme );
connect( _owncloudSetupWizard, SIGNAL(ownCloudWizardDone(int)), SLOT(slotStartFolderSetup()));
_statusDialog = new StatusDialog( _theme ); _statusDialog = new StatusDialog( _theme );
connect( _statusDialog, SIGNAL(addASync()), this, SLOT(slotAddFolder()) ); connect( _statusDialog, SIGNAL(addASync()), this, SLOT(slotAddFolder()) );
@ -131,14 +140,7 @@ Application::~Application()
void Application::slotStartFolderSetup() void Application::slotStartFolderSetup()
{ {
_ocInfo = new ownCloudInfo( QString(), this );
if( _ocInfo->isConfigured() ) { if( _ocInfo->isConfigured() ) {
connect( _ocInfo,SIGNAL(ownCloudInfoFound(QString,QString)),
SLOT(slotOwnCloudFound(QString,QString)));
connect( _ocInfo,SIGNAL(noOwncloudFound(QNetworkReply::NetworkError)),
SLOT(slotNoOwnCloudFound(QNetworkReply::NetworkError)));
_ocInfo->checkInstallation(); _ocInfo->checkInstallation();
} else { } else {
slotNoOwnCloudFound( QNetworkReply::UnknownNetworkError ); slotNoOwnCloudFound( QNetworkReply::UnknownNetworkError );
@ -155,6 +157,8 @@ void Application::slotOwnCloudFound( const QString& url , const QString& version
if( _tray ) if( _tray )
_tray->showMessage(tr("ownCloud Sync Started"), tr("Sync started for %1 configured sync folder(s).").arg(cnt)); _tray->showMessage(tr("ownCloud Sync Started"), tr("Sync started for %1 configured sync folder(s).").arg(cnt));
} }
_actionAddFolder->setEnabled( true );
setupContextMenu(); setupContextMenu();
} }
@ -163,7 +167,8 @@ void Application::slotNoOwnCloudFound( QNetworkReply::NetworkError err )
qDebug() << "** Application: NO ownCloud found!"; qDebug() << "** Application: NO ownCloud found!";
QMessageBox::warning(0, tr("No ownCloud Connection"), QMessageBox::warning(0, tr("No ownCloud Connection"),
tr("There is no ownCloud connection available. Please configure one by clicking on the tray icon!")); tr("There is no ownCloud connection available. Please configure one by clicking on the tray icon!"));
_actionAddFolder->setEnabled( false );
setupContextMenu();
} }
void Application::slotHideSplash() void Application::slotHideSplash()
@ -191,8 +196,6 @@ void Application::setupSystemTray()
connect(_tray,SIGNAL(activated(QSystemTrayIcon::ActivationReason)), connect(_tray,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
SLOT(slotTrayClicked(QSystemTrayIcon::ActivationReason))); SLOT(slotTrayClicked(QSystemTrayIcon::ActivationReason)));
// setupContextMenu();
_tray->show(); _tray->show();
} }

Просмотреть файл

@ -29,6 +29,8 @@
namespace Mirall { namespace Mirall {
#define POLL_TIMER_EXCEED 10
ownCloudFolder::ownCloudFolder(const QString &alias, ownCloudFolder::ownCloudFolder(const QString &alias,
const QString &path, const QString &path,
const QString &secondPath, const QString &secondPath,
@ -36,6 +38,7 @@ ownCloudFolder::ownCloudFolder(const QString &alias,
: Folder(alias, path, secondPath, parent) : Folder(alias, path, secondPath, parent)
, _secondPath(secondPath) , _secondPath(secondPath)
, _localCheckOnly( false ) , _localCheckOnly( false )
, _localFileChanges( false )
, _csync(0) , _csync(0)
, _pollTimerCnt(0) , _pollTimerCnt(0)
, _csyncError(false) , _csyncError(false)
@ -66,13 +69,8 @@ ownCloudFolder::~ownCloudFolder()
#ifndef USE_WATCHER #ifndef USE_WATCHER
void ownCloudFolder::slotPollTimerRemoteCheck() void ownCloudFolder::slotPollTimerRemoteCheck()
{ {
_localCheckOnly = true;
_pollTimerCnt++; _pollTimerCnt++;
if( _pollTimerCnt == 15 ) { qDebug() << "**** Poll Timer Cnt increase: " << _pollTimerCnt;
_pollTimerCnt = 0;
_localCheckOnly = false;
}
qDebug() << "**** CSyncFolder Poll Timer check: " << _pollTimerCnt << " - " << _localCheckOnly;
} }
#endif #endif
@ -113,6 +111,17 @@ void ownCloudFolder::startSync(const QStringList &pathList)
QUrl url( _secondPath ); QUrl url( _secondPath );
url.setScheme( "owncloud" ); url.setScheme( "owncloud" );
#ifdef USE_WATCHER
// if there is a watcher and no polling, ever sync is remote.
_localCheckOnly = false;
#else
_localCheckOnly = true;
if( _pollTimerCnt == POLL_TIMER_EXCEED || _localFileChanges ) {
_localCheckOnly = false;
_pollTimerCnt = 0;
_localFileChanges = false;
}
#endif
qDebug() << "*** Start syncing to ownCloud, onlyLocal: " << _localCheckOnly; qDebug() << "*** Start syncing to ownCloud, onlyLocal: " << _localCheckOnly;
_csync = new CSyncThread( path(), url.toEncoded(), _localCheckOnly ); _csync = new CSyncThread( path(), url.toEncoded(), _localCheckOnly );
@ -145,22 +154,24 @@ void ownCloudFolder::slotThreadTreeWalkResult( WalkStats *wStats )
qDebug() << "Removed files: " << wStats->removed; qDebug() << "Removed files: " << wStats->removed;
qDebug() << "Renamed files: " << wStats->renamed; qDebug() << "Renamed files: " << wStats->renamed;
if( ! _localCheckOnly ) _lastSeenFiles = 0;
_localFileChanges = false;
#ifndef USE_WATCHER #ifndef USE_WATCHER
if( _lastSeenFiles > 0 && _lastSeenFiles != wStats->seenFiles ) { if( _lastSeenFiles > 0 && _lastSeenFiles != wStats->seenFiles ) {
qDebug() << "*** last seen files different from currently seen number => full Sync needed"; qDebug() << "*** last seen files different from currently seen number " << _lastSeenFiles << "<>" << wStats->seenFiles << " => full Sync needed";
_localCheckOnly = false; _localFileChanges = true;
_pollTimerCnt = 0;
} }
if( _localCheckOnly && (wStats->newFiles + wStats->eval + wStats->removed + wStats->renamed) > 0 ) { if( (wStats->newFiles + wStats->eval + wStats->removed + wStats->renamed) > 0 ) {
qDebug() << "*** Local changes, lets do a full sync!" ; qDebug() << "*** Local changes, lets do a full sync!" ;
_localCheckOnly = false; // next time it will be a non local check. _localFileChanges = true;
_pollTimerCnt = 0;
} }
if( _localCheckOnly ) { if( _pollTimerCnt < POLL_TIMER_EXCEED ) {
qDebug() << " *** No local changes, finalize, pollTimerCounter is "<< _pollTimerCnt ; qDebug() << " *** No local changes, finalize, pollTimerCounter is "<< _pollTimerCnt ;
} }
#endif #endif
_lastSeenFiles = wStats->seenFiles; _lastSeenFiles = wStats->seenFiles;
/* /*
* Attention: This is deleted here, outside of the thread, because the thread can * Attention: This is deleted here, outside of the thread, because the thread can
* faster die than this routine has read out the memory. * faster die than this routine has read out the memory.
@ -192,9 +203,11 @@ void ownCloudFolder::slotCSyncFinished()
res.setErrorStrings( _errors ); res.setErrorStrings( _errors );
qDebug() << " * owncloud csync thread finished with error"; qDebug() << " * owncloud csync thread finished with error";
} else { } else {
qDebug() << " * owncloud csync thread finished successfully"; qDebug() << " * owncloud csync thread finished successfully " << _localCheckOnly;
} }
if( ! _localCheckOnly ) _lastSeenFiles = 0;
emit syncFinished( res ); emit syncFinished( res );
} }

Просмотреть файл

@ -56,6 +56,7 @@ private:
QString _secondPath; QString _secondPath;
CSyncThread *_csync; CSyncThread *_csync;
bool _localCheckOnly; bool _localCheckOnly;
bool _localFileChanges;
int _pollTimerCnt; int _pollTimerCnt;
QStringList _errors; QStringList _errors;
bool _csyncError; bool _csyncError;

Просмотреть файл

@ -64,6 +64,8 @@ OwncloudSetupWizard::OwncloudSetupWizard( FolderMan *folderMan, Theme *theme, QO
connect( _ocWizard, SIGNAL(installOCLocalhost()), connect( _ocWizard, SIGNAL(installOCLocalhost()),
this, SLOT(slotCreateOCLocalhost())); this, SLOT(slotCreateOCLocalhost()));
connect( _ocWizard, SIGNAL(finished(int)),this,SIGNAL(ownCloudWizardDone(int)));
// in case of cancel, terminate the owncloud-admin script. // in case of cancel, terminate the owncloud-admin script.
connect( _ocWizard, SIGNAL(rejected()), _process, SLOT(terminate())); connect( _ocWizard, SIGNAL(rejected()), _process, SLOT(terminate()));

Просмотреть файл

@ -54,7 +54,10 @@ public:
OwncloudWizard *wizard(); OwncloudWizard *wizard();
signals: signals:
// issued if the oC Setup process (owncloud-admin) is finished.
void ownCloudSetupFinished( bool ); void ownCloudSetupFinished( bool );
// overall dialog close signal.
void ownCloudWizardDone( int );
public slots: public slots:

Разница между файлами не показана из-за своего большого размера Загрузить разницу