Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Molkentin <danimo@owncloud.com>2012-12-04 21:15:37 +0400
committerDaniel Molkentin <danimo@owncloud.com>2012-12-04 21:24:25 +0400
commit214261e7642249026544808408bebb35cd07d223 (patch)
tree588df68bf4ca4dce581f11d45cdb2e67eb9e1c10 /src
parentb74cfcfec53fd3dd7ceb7b157fea26518574e47e (diff)
pimpl folderwatcher
Diffstat (limited to 'src')
-rw-r--r--src/mirall/folderwatcher.cpp3
-rw-r--r--src/mirall/folderwatcher.h8
-rw-r--r--src/mirall/folderwatcher_inotify.cpp23
-rw-r--r--src/mirall/folderwatcher_win.cpp21
-rw-r--r--src/mirall/inotify.cpp4
-rw-r--r--src/mirall/inotify.h2
6 files changed, 43 insertions, 18 deletions
diff --git a/src/mirall/folderwatcher.cpp b/src/mirall/folderwatcher.cpp
index 62ac774ef..b52de742c 100644
--- a/src/mirall/folderwatcher.cpp
+++ b/src/mirall/folderwatcher.cpp
@@ -50,6 +50,7 @@ namespace Mirall {
FolderWatcher::FolderWatcher(const QString &root, QObject *parent)
: QObject(parent),
+ _d(new FolderWatcherPrivate),
_eventsEnabled(true),
_eventInterval(DEFAULT_EVENT_INTERVAL_MSEC),
_root(root),
@@ -65,7 +66,7 @@ FolderWatcher::FolderWatcher(const QString &root, QObject *parent)
FolderWatcher::~FolderWatcher()
{
-
+ delete _d;
}
QString FolderWatcher::root() const
diff --git a/src/mirall/folderwatcher.h b/src/mirall/folderwatcher.h
index 558fa2196..7aeb8b3f8 100644
--- a/src/mirall/folderwatcher.h
+++ b/src/mirall/folderwatcher.h
@@ -30,9 +30,7 @@ class QTimer;
namespace Mirall {
-#ifdef USE_INOTIFY
-class INotify;
-#endif
+class FolderWatcherPrivate;
/**
* Watches a folder and sub folders for changes
@@ -127,9 +125,7 @@ private:
private:
bool _eventsEnabled;
int _eventInterval;
-#ifdef USE_INOTIFY
- INotify *_inotify;
-#endif
+ FolderWatcherPrivate *_d;
QString _root;
// paths pending to notified
// QStringList _pendingPaths;
diff --git a/src/mirall/folderwatcher_inotify.cpp b/src/mirall/folderwatcher_inotify.cpp
index b77468500..c4595476c 100644
--- a/src/mirall/folderwatcher_inotify.cpp
+++ b/src/mirall/folderwatcher_inotify.cpp
@@ -20,6 +20,11 @@
namespace Mirall {
+class FolderWatcherPrivate {
+public:
+ INotify *inotify;
+};
+
static const uint32_t standard_event_mask =
IN_CLOSE_WRITE | IN_ATTRIB | IN_MOVE |
IN_CREATE |IN_DELETE | IN_DELETE_SELF |
@@ -29,16 +34,16 @@ static const uint32_t standard_event_mask =
void FolderWatcher::setupBackend() {
_processTimer->setSingleShot(true);
QObject::connect(_processTimer, SIGNAL(timeout()), this, SLOT(slotProcessTimerTimeout()));
-
- _inotify = new INotify(standard_event_mask);
+ _d = new FolderWatcherPrivate;
+ _d->inotify = new INotify(this, standard_event_mask);
slotAddFolderRecursive(_root);
- QObject::connect(_inotify, SIGNAL(notifyEvent(int, int, const QString &)),
+ QObject::connect(_d->inotify, SIGNAL(notifyEvent(int, int, const QString &)),
this, SLOT(slotINotifyEvent(int, int, const QString &)));
}
QStringList FolderWatcher::folders() const
{
- return _inotify->directories();
+ return _d->inotify->directories();
}
void FolderWatcher::slotAddFolderRecursive(const QString &path)
@@ -46,8 +51,8 @@ void FolderWatcher::slotAddFolderRecursive(const QString &path)
int subdirs = 0;
qDebug() << "(+) Watcher:" << path;
- _inotify->addPath(path);
- QStringList watchedFolders(_inotify->directories());
+ _d->inotify->addPath(path);
+ QStringList watchedFolders(_d->inotify->directories());
// qDebug() << "currently watching " << watchedFolders;
QStringListIterator subfoldersIt(FileUtils::subFoldersList(path, FileUtils::SubFolderRecursive));
while (subfoldersIt.hasNext()) {
@@ -66,7 +71,7 @@ void FolderWatcher::slotAddFolderRecursive(const QString &path)
}
}
- _inotify->addPath(folder.path());
+ _d->inotify->addPath(folder.path());
}
else
qDebug() << " `-> discarded:" << folder.path();
@@ -110,9 +115,9 @@ void FolderWatcher::slotINotifyEvent(int mask, int cookie, const QString &path)
}
else if (mask & IN_DELETE) {
//qDebug() << cookie << " DELETE: " << path;
- if ( QFileInfo(path).isDir() && _inotify->directories().contains(path) ) {
+ if ( QFileInfo(path).isDir() && _d->inotify->directories().contains(path) ) {
qDebug() << "(-) Watcher:" << path;
- _inotify->removePath(path);
+ _d->inotify->removePath(path);
}
}
else if (mask & IN_CLOSE_WRITE) {
diff --git a/src/mirall/folderwatcher_win.cpp b/src/mirall/folderwatcher_win.cpp
new file mode 100644
index 000000000..6d3b0fbc8
--- /dev/null
+++ b/src/mirall/folderwatcher_win.cpp
@@ -0,0 +1,21 @@
+/*
+ * 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
+ * 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.
+ */
+
+#include "mirall/folderwatcher.h"
+
+namespace Mirall {
+
+
+
+}
diff --git a/src/mirall/inotify.cpp b/src/mirall/inotify.cpp
index f2b55997c..2064336a3 100644
--- a/src/mirall/inotify.cpp
+++ b/src/mirall/inotify.cpp
@@ -36,7 +36,9 @@
namespace Mirall {
-INotify::INotify(int mask) : _mask(mask)
+INotify::INotify(QObject *parent, int mask)
+ : QObject(parent),
+ _mask(mask)
{
_fd = inotify_init();
_notifier = new QSocketNotifier(_fd, QSocketNotifier::Read);
diff --git a/src/mirall/inotify.h b/src/mirall/inotify.h
index 9b0df5efd..9299f2c82 100644
--- a/src/mirall/inotify.h
+++ b/src/mirall/inotify.h
@@ -35,7 +35,7 @@ class INotify : public QObject
public:
- INotify(int mask);
+ INotify(QObject *parent, int mask);
~INotify();
static void initialize();