20
20
#ifndef EXTERNALCHANGEMONITOR_H
21
21
#define EXTERNALCHANGEMONITOR_H
23
#include "src/config.h"
27
#include <QSocketNotifier>
24
#include <QStringList>
26
class QSocketNotifier;
33
* Class for listening after changes to the disc representation of the
29
* Class for listening after changes to the disc representation of the
36
* The class use FAM (File Alteration Monitor) register for changes
37
* in the project directories.
39
* The use of the QSocketNotifier adds the monitoring of the FAM to the
40
* Qt main event loop and is documented at:
41
* http://oss.sgi.com/projects/fam/qt_gtk.html#qt
42
* FAM is documented many places most notably in the FAM man page.
32
* The class uses Inotify-tools to listen for changes
33
* in the project directories.
44
35
* @author Bjoern Erik Nilsen & Fredrik Berg Kjoelstad
51
42
* Initializes the ExternalChangeMonitor and registers the animationModel
52
* to notify of changes when the disk representation of the animation is
43
* to notify of changes when the disk representation of the animation is
55
46
ExternalChangeMonitor(QObject *parent = 0);
58
49
* Calls stopMonitoring and cleans up.
60
51
~ExternalChangeMonitor();
63
* Register the current workdirectory for monitorng.
64
* @param workDirectory the workDirectory to listen for changes in.
54
* Register the directory for monitoring.
55
* @param directory the directory to listen for changes in.
66
void changeWorkDirectory(const char* workDirectory);
57
void addDirectory(const QString &directory);
69
* Creates a FAM connection to the project directories and starts a thread
70
* which polls the FAM connection for changes in the tmp directory.
72
* To register the working project directory for monitoring also call
60
* Creates a inotify connection and listens for changes in the project directories.
75
62
void startMonitoring();
78
* Stops the thread polling the FAM connection and tears the connection down.
80
64
void stopMonitoring();
83
67
* Suspends the monitoring until resumeMonitor() is called.
85
69
void suspendMonitor();
88
72
* Resumes monitoring the directories.
90
74
void resumeMonitor();
93
static const int TIMER_INTERVAL = 500;
95
/** The connection to the fam deamon */
96
FAMConnection *famConn;
97
FAMRequest famRequest;
99
77
/** For polling the file connection through the qt event loop */
100
78
QSocketNotifier *socketNotifier;
102
QString workDirectory;
103
QString tmpDirectory;
80
QStringList directories;
112
* Callback function for when the QSocketNotifier recieves a fam event.
84
* Callback function for when the QSocketNotifier recieves an Inotify event.
86
void readInotifyEvents(int socket);