2011-04-06 13:48:02 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Duncan Mac-Vicar P. <duncan@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
2011-02-17 02:21:45 +03:00
|
|
|
#ifndef MIRALL_FOLDER_H
|
|
|
|
#define MIRALL_FOLDER_H
|
|
|
|
|
2011-04-06 17:57:18 +04:00
|
|
|
#include <QNetworkConfigurationManager>
|
2011-02-17 02:21:45 +03:00
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
2011-03-23 01:03:43 +03:00
|
|
|
#include <QStringList>
|
2011-02-17 02:21:45 +03:00
|
|
|
|
|
|
|
class QAction;
|
2011-04-05 14:16:24 +04:00
|
|
|
class QTimer;
|
2011-02-17 02:21:45 +03:00
|
|
|
|
|
|
|
namespace Mirall {
|
|
|
|
|
|
|
|
class FolderWatcher;
|
|
|
|
|
|
|
|
class Folder : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2011-04-06 11:52:02 +04:00
|
|
|
Folder(const QString &alias, const QString &path, QObject *parent = 0L);
|
2011-02-17 02:21:45 +03:00
|
|
|
virtual ~Folder();
|
|
|
|
|
2011-04-06 11:52:02 +04:00
|
|
|
/**
|
|
|
|
* alias or nickname
|
|
|
|
*/
|
|
|
|
QString alias() const;
|
|
|
|
|
2011-02-17 17:10:06 +03:00
|
|
|
/**
|
|
|
|
* local folder path
|
|
|
|
*/
|
|
|
|
QString path() const;
|
|
|
|
|
2011-02-17 13:27:05 +03:00
|
|
|
QAction *openAction() const;
|
2011-02-17 02:21:45 +03:00
|
|
|
|
|
|
|
/**
|
2011-04-05 14:16:24 +04:00
|
|
|
* Starts a sync operation
|
|
|
|
*
|
|
|
|
* If the list of changed files is known, it is passed.
|
|
|
|
*
|
|
|
|
* If the list of changed files is empty, the folder
|
|
|
|
* implementation should figure it by itself of
|
|
|
|
* perform a full scan of changes
|
2011-02-17 02:21:45 +03:00
|
|
|
*/
|
2011-03-25 20:25:56 +03:00
|
|
|
virtual void startSync(const QStringList &pathList) = 0;
|
2011-02-17 02:21:45 +03:00
|
|
|
|
2011-03-27 04:26:41 +04:00
|
|
|
/**
|
|
|
|
* True if the folder is busy and can't initiate
|
|
|
|
* a synchronization
|
|
|
|
*/
|
|
|
|
virtual bool isBusy() const = 0;
|
2011-03-23 01:03:43 +03:00
|
|
|
|
2011-04-06 17:22:40 +04:00
|
|
|
/**
|
|
|
|
* only sync when online in the network
|
|
|
|
*/
|
|
|
|
bool onlyOnlineEnabled() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see onlyOnlineEnabled
|
|
|
|
*/
|
|
|
|
void setOnlyOnlineEnabled(bool enabled);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* only sync when online in the same LAN
|
|
|
|
* as the one used during setup
|
|
|
|
*/
|
|
|
|
bool onlyThisLANEnabled() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see onlyThisLANEnabled
|
|
|
|
*/
|
|
|
|
void setOnlyThisLANEnabled(bool enabled);
|
|
|
|
|
|
|
|
|
2011-04-05 14:16:24 +04:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* The minimum amounts of seconds to wait before
|
|
|
|
* doing a full sync to see if the remote changed
|
|
|
|
*/
|
|
|
|
int pollInterval() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets minimum amounts of seconds that will separate
|
|
|
|
* poll intervals
|
|
|
|
*/
|
|
|
|
void setPollInterval(int seconds);
|
|
|
|
|
2011-02-17 02:21:45 +03:00
|
|
|
signals:
|
2011-03-27 04:26:41 +04:00
|
|
|
|
2011-02-17 02:21:45 +03:00
|
|
|
void syncStarted();
|
|
|
|
void syncFinished();
|
|
|
|
|
|
|
|
protected:
|
2011-04-04 20:41:14 +04:00
|
|
|
FolderWatcher *_watcher;
|
2011-04-05 14:16:24 +04:00
|
|
|
|
2011-02-17 02:21:45 +03:00
|
|
|
private:
|
2011-04-05 14:16:24 +04:00
|
|
|
|
2011-04-06 17:57:18 +04:00
|
|
|
/**
|
|
|
|
* Starts a sync (calling startSync)
|
|
|
|
* if the policies allow for it
|
|
|
|
*/
|
|
|
|
void evaluateSync(const QStringList &pathList);
|
|
|
|
|
2011-02-17 02:21:45 +03:00
|
|
|
QString _path;
|
2011-02-17 13:27:05 +03:00
|
|
|
QAction *_openAction;
|
2011-04-05 14:16:24 +04:00
|
|
|
// poll timer for remote syncs
|
|
|
|
QTimer *_pollTimer;
|
|
|
|
int _pollInterval;
|
2011-04-06 11:52:02 +04:00
|
|
|
QString _alias;
|
2011-04-06 17:22:40 +04:00
|
|
|
bool _onlyOnlineEnabled;
|
|
|
|
bool _onlyThisLANEnabled;
|
2011-04-06 17:57:18 +04:00
|
|
|
QNetworkConfigurationManager _networkMgr;
|
|
|
|
bool _online;
|
2011-03-27 04:26:41 +04:00
|
|
|
protected slots:
|
|
|
|
|
2011-04-06 17:57:18 +04:00
|
|
|
void slotOnlineChanged(bool online);
|
|
|
|
|
2011-04-05 14:16:24 +04:00
|
|
|
void slotPollTimerTimeout();
|
|
|
|
|
2011-03-27 04:26:41 +04:00
|
|
|
/* called when the watcher detect a list of changed
|
|
|
|
paths */
|
2011-03-23 01:03:43 +03:00
|
|
|
void slotChanged(const QStringList &pathList);
|
2011-03-27 04:26:41 +04:00
|
|
|
|
2011-02-17 02:21:45 +03:00
|
|
|
void slotOpenFolder();
|
2011-02-17 17:10:06 +03:00
|
|
|
|
|
|
|
void slotSyncStarted();
|
|
|
|
void slotSyncFinished();
|
2011-02-17 02:21:45 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|