~ubuntu-branches/ubuntu/maverick/stopmotion/maverick

« back to all changes in this revision

Viewing changes to src/application/externalchangemonitor.h

  • Committer: Bazaar Package Importer
  • Author(s): Bjoern Erik Nilsen
  • Date: 2008-07-25 12:59:29 UTC
  • mfrom: (1.1.7 upstream) (2.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080725125929-bc75ds4t1f4hbywy
Tags: 0.6.2-1
* New upstream release
  - Fixed an invalid read reported by Valgrind.
  - Fixed a crash occuring on some 64-bit systems.
  - Fixed the default translation to be the same as the locale.
  - Rewrote the file system watcher to use inotify-tools instead of FAM.
  - Included the man page in upstream tarball.
  - Updated the Italian translation.
* segfault at startup (Closes: #488621)
* Upgrade to Standards-Version 3.8.0.
* Replace libfam-dev with libinotifytools-dev in control/Build-Depends

* Upload sponsored by Petter Reinholdtsen.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#ifndef EXTERNALCHANGEMONITOR_H
21
21
#define EXTERNALCHANGEMONITOR_H
22
22
 
23
 
#include "src/config.h"
24
 
 
25
23
#include <QObject>
26
 
#include <QTimer>
27
 
#include <QSocketNotifier>
28
 
 
29
 
#include <fam.h>
30
 
 
 
24
#include <QStringList>
 
25
 
 
26
class QSocketNotifier;
31
27
 
32
28
/**
33
 
 * Class for listening after changes to the disc representation of the 
 
29
 * Class for listening after changes to the disc representation of the
34
30
 * animationmodel.
35
31
 *
36
 
 * The class use FAM (File Alteration Monitor) register for changes
37
 
 * in the project directories. 
38
 
 *
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.
43
34
 *
44
35
 * @author Bjoern Erik Nilsen & Fredrik Berg Kjoelstad
45
36
 */
49
40
public:
50
41
        /**
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
53
44
         * changed
54
45
         */
55
46
        ExternalChangeMonitor(QObject *parent = 0);
56
 
        
 
47
 
57
48
        /**
58
49
         * Calls stopMonitoring and cleans up.
59
50
         */
60
51
        ~ExternalChangeMonitor();
61
 
        
 
52
 
62
53
        /**
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.
65
56
         */
66
 
        void changeWorkDirectory(const char* workDirectory);
67
 
        
 
57
        void addDirectory(const QString &directory);
 
58
 
68
59
        /**
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.
71
 
         *
72
 
         * To register the working project directory for monitoring also call 
73
 
         * changeWorkDirectory
 
60
         * Creates a inotify connection and listens for changes in the project directories.
74
61
         */
75
62
        void startMonitoring();
76
 
        
77
 
        /**
78
 
         * Stops the thread polling the FAM connection and tears the connection down.
79
 
         */
 
63
 
80
64
        void stopMonitoring();
81
 
        
 
65
 
82
66
        /**
83
67
         * Suspends the monitoring until resumeMonitor() is called.
84
68
         */
85
69
        void suspendMonitor();
86
 
        
 
70
 
87
71
        /**
88
72
         * Resumes monitoring the directories.
89
73
         */
90
74
        void resumeMonitor();
91
 
        
 
75
 
92
76
private:
93
 
        static const int TIMER_INTERVAL = 500;
94
 
        
95
 
        /** The connection to the fam deamon */
96
 
        FAMConnection *famConn;
97
 
        FAMRequest    famRequest;
98
 
        
99
77
        /** For polling the file connection through the qt event loop */
100
78
        QSocketNotifier *socketNotifier;
101
 
        
102
 
        QString workDirectory;
103
 
        QString tmpDirectory;
104
 
        
105
 
        QTimer timer;
106
 
        QString fileName;
107
 
        bool refresh;
108
 
        bool running;
109
 
        
 
79
        bool isMonitoring;
 
80
        QStringList directories;
 
81
 
110
82
private slots:
111
83
        /**
112
 
         * Callback function for when the QSocketNotifier recieves a fam event.
 
84
         * Callback function for when the QSocketNotifier recieves an Inotify event.
113
85
         */
114
 
        void readFam();
115
 
        void timeout();
 
86
        void readInotifyEvents(int socket);
116
87
};
117
88
 
118
89
#endif