summaryrefslogtreecommitdiffstats
path: root/tdejava/koala/org/trinitydesktop/koala/KDirWatch.java
blob: c0051beb6eb75b9371a699f62a68cd0632f52f32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
//Auto-generated by kalyptus. DO NOT EDIT.
package org.trinitydesktop.koala;

import org.trinitydesktop.qt.Qt;
import org.trinitydesktop.qt.TQMetaObject;
import org.trinitydesktop.qt.QtSupport;
import org.trinitydesktop.qt.TQObject;
import java.util.Calendar;
import org.trinitydesktop.qt.TQObject;

/**

 Watch directories and files for changes.
 The watched directories or files don't have to exist yet.
 When a watched directory is changed, i.e. when files therein are
 created or deleted, KDirWatch will emit the signal dirty().
 When a watched, but previously not existing directory gets created,
 KDirWatch will emit the signal created().
 When a watched directory gets deleted, KDirWatch will emit the
 signal deleted(). The directory is still watched for new
 creation.
 When a watched file is changed, i.e. attributes changed or written
 to, KDirWatch will emit the signal dirty().
 Scanning of particular directories or files can be stopped temporarily
 and restarted. The whole class can be stopped and restarted.
 Directories and files can be added/removed from the list in any state.
 The implementation uses the FAM service when available;
 if FAM is not available, the DNOTIFY functionality is used on LINUX.
 As a last resort, a regular polling for change of modification times
 is done; the polling interval is a global config option:
 DirWatch/PollInterval and DirWatch/NFSPollInterval for NFS mounted
 directories.
 See {@link KDirWatchSignals} for signals emitted by KDirWatch
		@author Sven Radej <sven@lisa.exp.univie.ac.at>

		@short Class for watching directory and file changes.
		@see #self

*/
public class KDirWatch extends TQObject  {
	protected KDirWatch(Class dummy){super((Class) null);}
	public static final int FAM = 0;
	public static final int DNotify = 1;
	public static final int Stat = 2;

	public native TQMetaObject metaObject();
	public native String className();
	/**
		 Constructor.
			 Scanning begins immediately when a dir/file watch
		 is added.
			@param parent the parent of the TQObject (or 0 for parent-less KDataTools)
			@param name the name of the TQObject, can be 0
		    		@short    Constructor.
	*/
	public KDirWatch(TQObject parent, String name) {
		super((Class) null);
		newKDirWatch(parent,name);
	}
	private native void newKDirWatch(TQObject parent, String name);
	public KDirWatch(TQObject parent) {
		super((Class) null);
		newKDirWatch(parent);
	}
	private native void newKDirWatch(TQObject parent);
	public KDirWatch() {
		super((Class) null);
		newKDirWatch();
	}
	private native void newKDirWatch();
	/**
		 Adds a directory to be watched.
			 The directory does not have to exist. When <code>watchFiles</code> is
		 false (the default), the signals dirty(), created(), deleted()
		 can be emitted, all for the watched directory.
		 When <code>watchFiles</code> is true, all files in the watched directory
		 are watched for changes, too. Thus, the signals dirty(),
		 created(), deleted() can be emitted.
			@param path the path to watch
			@param watchFiles if true, the KDirWatch will also watch files - NOT IMPLEMENTED YET
			@param recursive if true, all sub directories are also watched - NOT IMPLEMENTED YET
		    		@short    Adds a directory to be watched.
	*/
	public native void addDir(String path, boolean watchFiles, boolean recursive);
	public native void addDir(String path, boolean watchFiles);
	public native void addDir(String path);
	/**
		 Adds a file to be watched.
			@param file the file to watch
		    		@short    Adds a file to be watched.
	*/
	public native void addFile(String file);
	/**
		 Returns the time the directory/file was last changed.
			@param path the file to check
				@return the date of the last modification

		@short    Returns the time the directory/file was last changed.
	*/
	public native Calendar ctime(String path);
	/**
		 Removes a directory from the list of scanned directories.
			 If specified path is not in the list this does nothing.
			@param path the path of the dir to be removed from the list
		    		@short    Removes a directory from the list of scanned directories.
	*/
	public native void removeDir(String path);
	/**
		 Removes a file from the list of watched files.
			 If specified path is not in the list this does nothing.
			@param file the file to be removed from the list
		    		@short    Removes a file from the list of watched files.
	*/
	public native void removeFile(String file);
	/**
		 Stops scanning the specified path.
			 The <code>path</code> is not deleted from the interal just, it is just skipped.
		 Call this function when you perform an huge operation
		 on this directory (copy/move big files or many files). When finished,
		 call restartDirScan(path).
			@param path the path to skip
				@return true if the <code>path</code> is being watched, otherwise false

		@short    Stops scanning the specified path.
		@see #restartDirScanning
	*/
	public native boolean stopDirScan(String path);
	/**
		 Restarts scanning for specified path.
			 Resets ctime. It doesn't notify
		 the change (by emitted a signal), since the ctime value is reset.
			 Call it when you are finished with big operations on that path,
		 <b>and</b> when <b>you</b> have refreshed that path.
			@param path the path to restart scanning
				@return true if the <code>path</code> is being watched, otherwise false

		@short    Restarts scanning for specified path.
		@see #stopDirScanning
	*/
	public native boolean restartDirScan(String path);
	/**
		 Starts scanning of all dirs in list.
			@param notify If true, all changed directories (since
		 stopScan() call) will be notified for refresh. If notify is
		 false, all ctimes will be reset (except those who are stopped,
		 but only if <code>skippedToo</code> is false) and changed dirs won't be
		 notified. You can start scanning even if the list is
		 empty. First call should be called with <code>false</code> or else all
		 directories
		 in list will be notified.
			@param skippedToo if true, the skipped directoris (scanning of which was
		 stopped with stopDirScan() ) will be reset and notified
		 for change. Otherwise, stopped directories will continue to be
		 unnotified.
		    		@short    Starts scanning of all dirs in list.
	*/
	public native void startScan(boolean notify, boolean skippedToo);
	public native void startScan(boolean notify);
	public native void startScan();
	/**
		 Stops scanning of all directories in internal list.
			 The timer is stopped, but the list is not cleared.
		    		@short    Stops scanning of all directories in internal list.
	*/
	public native void stopScan();
	/**
		 Is scanning stopped?
		 After creation of a KDirWatch instance, this is false.
				@return true when scanning stopped

		@short    Is scanning stopped?  After creation of a KDirWatch instance, this is false.
	*/
	public native boolean isStopped();
	/**
		 Check if a directory is being watched by this KDirWatch instance
			@param path the directory to check
				@return true if the directory is being watched

		@short    Check if a directory is being watched by this KDirWatch instance
	*/
	public native boolean contains(String path);
	/**
		 Emits created().
			@param path the path of the file or directory
		    		@short     Emits created().
	*/
	public native void setCreated(String path);
	/**
		 Emits dirty().
			@param path the path of the file or directory
		    		@short     Emits dirty().
	*/
	public native void setDirty(String path);
	/**
		 Emits deleted().
			@param path the path of the file or directory
		    		@short     Emits deleted().
	*/
	public native void setDeleted(String path);
	/**
		 Returns the preferred internal method to
		 watch for changes.
				@short    Returns the preferred internal method to  watch for changes.
	*/
	public native int internalMethod();
	/**
		 Dump statistic information about all KDirWatch instances.
		 This checks for consistency, too.
		    		@short    Dump statistic information about all KDirWatch instances.
	*/
	public static native void statistics();
	/**
		 The KDirWatch instance usually globally used in an application.
		 It is automatically deleted when the application exits.
			 However, you can create an arbitrary number of KDirWatch instances
		 aside from this one - for those you have to take care of memory management.
			 This function returns an instance of KDirWatch. If there is none, it
		 will be created.
				@return a KDirWatch instance

		@short    The KDirWatch instance usually globally used in an application.
	*/
	public static native KDirWatch self();
	/**
		 Returns true if there is an instance of KDirWatch.
				@return true if there is an instance of KDirWatch.

		@short    Returns true if there is an instance of KDirWatch.
		@see KDirWatch#self
	*/
	public static native boolean exists();
	/** Deletes the wrapped C++ instance */
	protected native void finalize() throws InternalError;
	/** Delete the wrapped C++ instance ahead of finalize() */
	public native void dispose();
	/** Has the wrapped C++ instance been deleted? */
	public native boolean isDisposed();
}