2012-12-04 20:46:44 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
|
|
|
|
*
|
|
|
|
* 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
|
2016-10-25 12:00:07 +03:00
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2012-12-04 20:46:44 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2012-12-05 21:23:35 +04:00
|
|
|
#ifndef MIRALL_FOLDERWATCHER_WIN_H
|
|
|
|
#define MIRALL_FOLDERWATCHER_WIN_H
|
|
|
|
|
|
|
|
#include <QThread>
|
2016-03-31 15:04:53 +03:00
|
|
|
#include <QAtomicInt>
|
2012-12-06 19:26:27 +04:00
|
|
|
#include <windows.h>
|
2012-12-04 20:46:44 +04:00
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
namespace OCC {
|
2012-12-04 20:46:44 +04:00
|
|
|
|
2012-12-05 21:23:35 +04:00
|
|
|
class FolderWatcher;
|
2012-12-04 20:46:44 +04:00
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
|
|
|
* @brief The WatcherThread class
|
|
|
|
* @ingroup gui
|
2015-06-26 18:07:47 +03:00
|
|
|
*/
|
2012-12-05 21:23:35 +04:00
|
|
|
class WatcherThread : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
WatcherThread(const QString &path)
|
2016-03-31 15:04:53 +03:00
|
|
|
: QThread()
|
|
|
|
, _path(path)
|
|
|
|
, _directory(0)
|
|
|
|
, _resultEvent(0)
|
|
|
|
, _stopEvent(0)
|
|
|
|
, _done(false)
|
|
|
|
{
|
|
|
|
}
|
2012-12-04 20:46:44 +04:00
|
|
|
|
2012-12-06 19:26:27 +04:00
|
|
|
~WatcherThread();
|
|
|
|
|
2016-03-31 15:04:53 +03:00
|
|
|
void stop();
|
|
|
|
|
2012-12-06 19:26:27 +04:00
|
|
|
protected:
|
2012-12-05 21:23:35 +04:00
|
|
|
void run();
|
2014-11-06 02:36:04 +03:00
|
|
|
void watchChanges(size_t fileNotifyBufferSize,
|
|
|
|
bool *increaseBufferSize);
|
2016-03-31 15:04:53 +03:00
|
|
|
void closeHandle();
|
2012-12-04 20:46:44 +04:00
|
|
|
|
2012-12-05 21:23:35 +04:00
|
|
|
signals:
|
2012-12-06 19:26:27 +04:00
|
|
|
void changed(const QString &path);
|
2012-12-04 20:46:44 +04:00
|
|
|
|
2012-12-05 21:23:35 +04:00
|
|
|
private:
|
|
|
|
QString _path;
|
2016-03-31 15:04:53 +03:00
|
|
|
HANDLE _directory;
|
|
|
|
HANDLE _resultEvent;
|
|
|
|
HANDLE _stopEvent;
|
|
|
|
QAtomicInt _done;
|
2012-12-05 21:23:35 +04:00
|
|
|
};
|
2012-12-04 20:46:44 +04:00
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
|
|
|
* @brief Windows implementation of FolderWatcher
|
|
|
|
* @ingroup gui
|
2015-06-26 18:07:47 +03:00
|
|
|
*/
|
2012-12-05 21:23:35 +04:00
|
|
|
class FolderWatcherPrivate : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-01-13 18:23:52 +04:00
|
|
|
FolderWatcherPrivate(FolderWatcher *p, const QString &path);
|
2012-12-05 21:23:35 +04:00
|
|
|
~FolderWatcherPrivate();
|
2013-08-19 19:41:42 +04:00
|
|
|
|
|
|
|
void addPath(const QString &) {}
|
|
|
|
void removePath(const QString &) {}
|
|
|
|
|
2012-12-05 21:23:35 +04:00
|
|
|
private:
|
|
|
|
FolderWatcher *_parent;
|
|
|
|
WatcherThread *_thread;
|
|
|
|
};
|
2012-12-04 20:46:44 +04:00
|
|
|
}
|
|
|
|
|
2012-12-05 21:23:35 +04:00
|
|
|
#endif // MIRALL_FOLDERWATCHER_WIN_H
|