diff options
Diffstat (limited to 'meta/packages/pcmanfm/files/no-fam.patch')
-rw-r--r-- | meta/packages/pcmanfm/files/no-fam.patch | 432 |
1 files changed, 432 insertions, 0 deletions
diff --git a/meta/packages/pcmanfm/files/no-fam.patch b/meta/packages/pcmanfm/files/no-fam.patch new file mode 100644 index 0000000000..b87a02df01 --- /dev/null +++ b/meta/packages/pcmanfm/files/no-fam.patch | |||
@@ -0,0 +1,432 @@ | |||
1 | diff -urNd ../pcmanfm-0.3.0.1-r0/pcmanfm-0.3.0.1/configure.in pcmanfm-0.3.0.1/configure.in | ||
2 | --- ../pcmanfm-0.3.0.1-r0/pcmanfm-0.3.0.1/configure.in 2006-08-20 15:45:28.000000000 +0100 | ||
3 | +++ pcmanfm-0.3.0.1/configure.in 2006-08-20 20:37:36.000000000 +0100 | ||
4 | @@ -63,8 +63,8 @@ | ||
5 | LIBS="$LIBS $FAM_LIBS" | ||
6 | AC_CHECK_FUNCS([FAMNoExists]) | ||
7 | LIBS="$save_LIBS" | ||
8 | -else | ||
9 | - AC_MSG_ERROR([Fatal Error: no fam or gamin detected.]) | ||
10 | +#else | ||
11 | +# AC_MSG_ERROR([Fatal Error: no fam or gamin detected.]) | ||
12 | fi | ||
13 | |||
14 | AC_SUBST([FAM_CFLAGS]) | ||
15 | diff -urNd ../pcmanfm-0.3.0.1-r0/pcmanfm-0.3.0.1/src/vfs/vfs-file-monitor.c pcmanfm-0.3.0.1/src/vfs/vfs-file-monitor.c | ||
16 | --- ../pcmanfm-0.3.0.1-r0/pcmanfm-0.3.0.1/src/vfs/vfs-file-monitor.c 2006-07-16 20:00:46.000000000 +0100 | ||
17 | +++ pcmanfm-0.3.0.1/src/vfs/vfs-file-monitor.c 2006-08-20 20:54:07.000000000 +0100 | ||
18 | @@ -31,7 +31,6 @@ | ||
19 | VFSFileMonitorCallbackEntry; | ||
20 | |||
21 | static GHashTable* monitor_hash = NULL; | ||
22 | -static FAMConnection fam; | ||
23 | static GIOChannel* fam_io_channel = NULL; | ||
24 | static guint fam_io_watch = 0; | ||
25 | |||
26 | @@ -40,6 +39,8 @@ | ||
27 | GIOCondition cond, | ||
28 | gpointer user_data ); | ||
29 | |||
30 | +#ifdef HAVE_FAM_H | ||
31 | +static FAMConnection fam; | ||
32 | |||
33 | static gboolean connect_to_fam() | ||
34 | { | ||
35 | @@ -81,6 +82,16 @@ | ||
36 | FAMClose( &fam ); | ||
37 | } | ||
38 | } | ||
39 | +#else | ||
40 | +static gboolean connect_to_fam () | ||
41 | +{ | ||
42 | + return FALSE; | ||
43 | +} | ||
44 | + | ||
45 | +static void disconnect_from_fam () | ||
46 | +{ | ||
47 | +} | ||
48 | +#endif | ||
49 | |||
50 | /* final cleanup */ | ||
51 | void vfs_file_monitor_clean() | ||
52 | @@ -109,6 +120,7 @@ | ||
53 | VFSFileMonitorCallback cb, | ||
54 | gpointer user_data ) | ||
55 | { | ||
56 | +#ifdef HAVE_FAM_H | ||
57 | VFSFileMonitor * monitor; | ||
58 | VFSFileMonitorCallbackEntry cb_ent; | ||
59 | gboolean add_new = FALSE; | ||
60 | @@ -154,12 +166,16 @@ | ||
61 | } | ||
62 | ++monitor->n_ref; | ||
63 | return monitor; | ||
64 | +#else | ||
65 | + return NULL; | ||
66 | +#endif | ||
67 | } | ||
68 | |||
69 | void vfs_file_monitor_remove( VFSFileMonitor* fm, | ||
70 | VFSFileMonitorCallback cb, | ||
71 | gpointer user_data ) | ||
72 | { | ||
73 | +#ifdef HAVE_FAM_H | ||
74 | int i; | ||
75 | VFSFileMonitorCallbackEntry* callbacks; | ||
76 | if ( cb && fm->callbacks ) | ||
77 | @@ -183,12 +199,14 @@ | ||
78 | g_array_free( fm->callbacks, TRUE ); | ||
79 | g_slice_free( VFSFileMonitor, fm ); | ||
80 | } | ||
81 | +#endif | ||
82 | } | ||
83 | |||
84 | static void reconnect_fam( gpointer key, | ||
85 | gpointer value, | ||
86 | gpointer user_data ) | ||
87 | { | ||
88 | +#ifdef HAVE_FAM_H | ||
89 | struct stat file_stat; | ||
90 | VFSFileMonitor* monitor = ( VFSFileMonitor* ) value; | ||
91 | const char* path = ( const char* ) key; | ||
92 | @@ -209,6 +227,7 @@ | ||
93 | monitor ); | ||
94 | } | ||
95 | } | ||
96 | +#endif | ||
97 | } | ||
98 | |||
99 | /* event handler of all FAM events */ | ||
100 | @@ -216,6 +235,7 @@ | ||
101 | GIOCondition cond, | ||
102 | gpointer user_data ) | ||
103 | { | ||
104 | +#ifdef HAVE_FAM_H | ||
105 | FAMEvent evt; | ||
106 | VFSFileMonitor* monitor = NULL; | ||
107 | VFSFileMonitorCallbackEntry* cb; | ||
108 | @@ -266,5 +286,8 @@ | ||
109 | } | ||
110 | } | ||
111 | return TRUE; | ||
112 | +#else | ||
113 | + return TRUE; | ||
114 | +#endif | ||
115 | } | ||
116 | |||
117 | diff -urNd ../pcmanfm-0.3.0.1-r0/pcmanfm-0.3.0.1/src/vfs/vfs-file-monitor.c~ pcmanfm-0.3.0.1/src/vfs/vfs-file-monitor.c~ | ||
118 | --- ../pcmanfm-0.3.0.1-r0/pcmanfm-0.3.0.1/src/vfs/vfs-file-monitor.c~ 1970-01-01 01:00:00.000000000 +0100 | ||
119 | +++ pcmanfm-0.3.0.1/src/vfs/vfs-file-monitor.c~ 2006-08-20 20:50:49.000000000 +0100 | ||
120 | @@ -0,0 +1,292 @@ | ||
121 | +/* | ||
122 | +* C Implementation: vfs-monitor | ||
123 | +* | ||
124 | +* Description: | ||
125 | +* | ||
126 | +* | ||
127 | +* Author: Hong Jen Yee (PCMan) <pcman.tw (AT) gmail.com>, (C) 2006 | ||
128 | +* | ||
129 | +* Copyright: See COPYING file that comes with this distribution | ||
130 | +* | ||
131 | +*/ | ||
132 | + | ||
133 | +#ifdef HAVE_CONFIG_H | ||
134 | +#include "config.h" | ||
135 | +#endif | ||
136 | + | ||
137 | +#include "vfs-file-monitor.h" | ||
138 | +#include <sys/types.h> /* for stat */ | ||
139 | +#include <sys/stat.h> | ||
140 | + | ||
141 | +#include <stdlib.h> | ||
142 | +#include <string.h> | ||
143 | + | ||
144 | +#include "glib-mem.h" | ||
145 | + | ||
146 | +typedef struct | ||
147 | +{ | ||
148 | + VFSFileMonitorCallback callback; | ||
149 | + gpointer user_data; | ||
150 | +} | ||
151 | +VFSFileMonitorCallbackEntry; | ||
152 | + | ||
153 | +static GHashTable* monitor_hash = NULL; | ||
154 | +static FAMConnection fam; | ||
155 | +static GIOChannel* fam_io_channel = NULL; | ||
156 | +static guint fam_io_watch = 0; | ||
157 | + | ||
158 | +/* event handler of all FAM events */ | ||
159 | +static gboolean on_fam_event( GIOChannel *channel, | ||
160 | + GIOCondition cond, | ||
161 | + gpointer user_data ); | ||
162 | + | ||
163 | +#ifdef HAVE_FAM_H | ||
164 | +static gboolean connect_to_fam() | ||
165 | +{ | ||
166 | + if ( FAMOpen( &fam ) ) | ||
167 | + { | ||
168 | + fam_io_channel = NULL; | ||
169 | + fam.fd = -1; | ||
170 | + g_warning( "There is no FAM/gamin server\n" ); | ||
171 | + return FALSE; | ||
172 | + } | ||
173 | +#if HAVE_FAMNOEXISTS | ||
174 | + /* | ||
175 | + * Disable the initital directory content loading. | ||
176 | + * This can greatly speed up directory loading, but | ||
177 | + * unfortunately, it's not compatible with original FAM. | ||
178 | + */ | ||
179 | + FAMNoExists( &fam ); /* This is an extension of gamin */ | ||
180 | +#endif | ||
181 | + | ||
182 | + fam_io_channel = g_io_channel_unix_new( fam.fd ); | ||
183 | + g_io_channel_set_encoding( fam_io_channel, NULL, NULL ); | ||
184 | + g_io_channel_set_buffered( fam_io_channel, FALSE ); | ||
185 | + | ||
186 | + fam_io_watch = g_io_add_watch( fam_io_channel, | ||
187 | + G_IO_IN | G_IO_HUP, | ||
188 | + on_fam_event, | ||
189 | + NULL ); | ||
190 | + return TRUE; | ||
191 | +} | ||
192 | + | ||
193 | +static void disconnect_from_fam() | ||
194 | +{ | ||
195 | + if ( fam_io_channel ) | ||
196 | + { | ||
197 | + g_io_channel_unref( fam_io_channel ); | ||
198 | + fam_io_channel = NULL; | ||
199 | + g_source_remove( fam_io_watch ); | ||
200 | + | ||
201 | + FAMClose( &fam ); | ||
202 | + } | ||
203 | +} | ||
204 | +#else | ||
205 | +static gboolean connect_to_fam () | ||
206 | +{ | ||
207 | + return FALSE; | ||
208 | +} | ||
209 | + | ||
210 | +static void disconnect_from_fam () | ||
211 | +{ | ||
212 | +} | ||
213 | +#endif | ||
214 | + | ||
215 | +/* final cleanup */ | ||
216 | +void vfs_file_monitor_clean() | ||
217 | +{ | ||
218 | + disconnect_from_fam(); | ||
219 | + if ( monitor_hash ) | ||
220 | + { | ||
221 | + g_hash_table_destroy( monitor_hash ); | ||
222 | + monitor_hash = NULL; | ||
223 | + } | ||
224 | +} | ||
225 | + | ||
226 | +/* | ||
227 | +* Init monitor: | ||
228 | +* Establish connection with gamin/fam. | ||
229 | +*/ | ||
230 | +gboolean vfs_file_monitor_init() | ||
231 | +{ | ||
232 | + monitor_hash = g_hash_table_new( g_str_hash, g_str_equal ); | ||
233 | + if ( ! connect_to_fam() ) | ||
234 | + return FALSE; | ||
235 | + return TRUE; | ||
236 | +} | ||
237 | + | ||
238 | +VFSFileMonitor* vfs_file_monitor_add( const char* path, | ||
239 | + VFSFileMonitorCallback cb, | ||
240 | + gpointer user_data ) | ||
241 | +{ | ||
242 | +#ifdef HAVE_FAM_H | ||
243 | + VFSFileMonitor * monitor; | ||
244 | + VFSFileMonitorCallbackEntry cb_ent; | ||
245 | + gboolean add_new = FALSE; | ||
246 | + struct stat file_stat; | ||
247 | + | ||
248 | + if ( ! monitor_hash ) | ||
249 | + { | ||
250 | + if ( !vfs_file_monitor_init() ) | ||
251 | + return NULL; | ||
252 | + } | ||
253 | + monitor = ( VFSFileMonitor* ) g_hash_table_lookup ( monitor_hash, path ); | ||
254 | + if ( ! monitor ) | ||
255 | + { | ||
256 | + monitor = g_slice_new0( VFSFileMonitor ); | ||
257 | + monitor->path = g_strdup( path ); | ||
258 | + monitor->callbacks = g_array_new ( FALSE, FALSE, sizeof( VFSFileMonitorCallbackEntry ) ); | ||
259 | + g_hash_table_insert ( monitor_hash, | ||
260 | + path, | ||
261 | + monitor ); | ||
262 | + if ( lstat( path, &file_stat ) != -1 ) | ||
263 | + { | ||
264 | + if ( S_ISDIR( file_stat.st_mode ) ) | ||
265 | + { | ||
266 | + FAMMonitorDirectory( &fam, | ||
267 | + path, | ||
268 | + &monitor->request, | ||
269 | + monitor ); | ||
270 | + } | ||
271 | + else | ||
272 | + { | ||
273 | + FAMMonitorFile( &fam, | ||
274 | + path, | ||
275 | + &monitor->request, | ||
276 | + monitor ); | ||
277 | + } | ||
278 | + } | ||
279 | + } | ||
280 | + if ( cb ) | ||
281 | + { /* Install a callback */ | ||
282 | + cb_ent.callback = cb; | ||
283 | + cb_ent.user_data = user_data; | ||
284 | + monitor->callbacks = g_array_append_val( monitor->callbacks, cb_ent ); | ||
285 | + } | ||
286 | + ++monitor->n_ref; | ||
287 | + return monitor; | ||
288 | +#else | ||
289 | + return NULL; | ||
290 | +#endif | ||
291 | +} | ||
292 | + | ||
293 | +void vfs_file_monitor_remove( VFSFileMonitor* fm, | ||
294 | + VFSFileMonitorCallback cb, | ||
295 | + gpointer user_data ) | ||
296 | +{ | ||
297 | +#ifdef HAVE_FAM_H | ||
298 | + int i; | ||
299 | + VFSFileMonitorCallbackEntry* callbacks; | ||
300 | + if ( cb && fm->callbacks ) | ||
301 | + { | ||
302 | + callbacks = ( VFSFileMonitorCallbackEntry* ) fm->callbacks->data; | ||
303 | + for ( i = 0; i < fm->callbacks->len; ++i ) | ||
304 | + { | ||
305 | + if ( callbacks[ i ].callback == cb && callbacks[ i ].user_data == user_data ) | ||
306 | + { | ||
307 | + fm->callbacks = g_array_remove_index_fast ( fm->callbacks, i ); | ||
308 | + break; | ||
309 | + } | ||
310 | + } | ||
311 | + } | ||
312 | + --fm->n_ref; | ||
313 | + if ( 0 >= fm->n_ref ) | ||
314 | + { | ||
315 | + FAMCancelMonitor( &fam, &fm->request ); | ||
316 | + g_hash_table_remove( monitor_hash, fm->path ); | ||
317 | + g_free( fm->path ); | ||
318 | + g_array_free( fm->callbacks, TRUE ); | ||
319 | + g_slice_free( VFSFileMonitor, fm ); | ||
320 | + } | ||
321 | +#endif | ||
322 | +} | ||
323 | + | ||
324 | +static void reconnect_fam( gpointer key, | ||
325 | + gpointer value, | ||
326 | + gpointer user_data ) | ||
327 | +{ | ||
328 | +#ifdef HAVE_FAM_H | ||
329 | + struct stat file_stat; | ||
330 | + VFSFileMonitor* monitor = ( VFSFileMonitor* ) value; | ||
331 | + const char* path = ( const char* ) key; | ||
332 | + if ( lstat( path, &file_stat ) != -1 ) | ||
333 | + { | ||
334 | + if ( S_ISDIR( file_stat.st_mode ) ) | ||
335 | + { | ||
336 | + FAMMonitorDirectory( &fam, | ||
337 | + path, | ||
338 | + &monitor->request, | ||
339 | + monitor ); | ||
340 | + } | ||
341 | + else | ||
342 | + { | ||
343 | + FAMMonitorFile( &fam, | ||
344 | + path, | ||
345 | + &monitor->request, | ||
346 | + monitor ); | ||
347 | + } | ||
348 | + } | ||
349 | +#endif | ||
350 | +} | ||
351 | + | ||
352 | +/* event handler of all FAM events */ | ||
353 | +static gboolean on_fam_event( GIOChannel *channel, | ||
354 | + GIOCondition cond, | ||
355 | + gpointer user_data ) | ||
356 | +{ | ||
357 | +#ifdef HAVE_FAM_H | ||
358 | + FAMEvent evt; | ||
359 | + VFSFileMonitor* monitor = NULL; | ||
360 | + VFSFileMonitorCallbackEntry* cb; | ||
361 | + VFSFileMonitorCallback func; | ||
362 | + int i; | ||
363 | + | ||
364 | + if ( cond & G_IO_HUP ) | ||
365 | + { | ||
366 | + disconnect_from_fam(); | ||
367 | + if ( g_hash_table_size ( monitor_hash ) > 0 ) | ||
368 | + { | ||
369 | + /* | ||
370 | + Disconnected from FAM server, but there are still monitors. | ||
371 | + This may be caused by crash of FAM server. | ||
372 | + So we have to reconnect to FAM server. | ||
373 | + */ | ||
374 | + connect_to_fam(); | ||
375 | + g_hash_table_foreach( monitor_hash, ( GHFunc ) reconnect_fam, NULL ); | ||
376 | + } | ||
377 | + return TRUE; /* don't need to remove the event source since | ||
378 | + it has been removed by disconnect_from_fam(). */ | ||
379 | + } | ||
380 | + | ||
381 | + while ( FAMPending( &fam ) ) | ||
382 | + { | ||
383 | + if ( FAMNextEvent( &fam, &evt ) > 0 ) | ||
384 | + { | ||
385 | + monitor = ( VFSFileMonitor* ) evt.userdata; | ||
386 | + switch ( evt.code ) | ||
387 | + { | ||
388 | + case FAMCreated: | ||
389 | + case FAMDeleted: | ||
390 | + case FAMChanged: | ||
391 | + /* Call the callback functions */ | ||
392 | + if ( monitor->callbacks && monitor->callbacks->len ) | ||
393 | + { | ||
394 | + cb = ( VFSFileMonitorCallbackEntry* ) monitor->callbacks->data; | ||
395 | + for ( i = 0; i < monitor->callbacks->len; ++i ) | ||
396 | + { | ||
397 | + func = cb[ i ].callback; | ||
398 | + func( monitor, evt.code, evt.filename, cb[ i ].user_data ); | ||
399 | + } | ||
400 | + } | ||
401 | + break; | ||
402 | + default: | ||
403 | + return TRUE; /* Other events are not supported */ | ||
404 | + } | ||
405 | + } | ||
406 | + } | ||
407 | + return TRUE; | ||
408 | +#else | ||
409 | + return TRUE; | ||
410 | +#endif | ||
411 | +} | ||
412 | + | ||
413 | diff -urNd ../pcmanfm-0.3.0.1-r0/pcmanfm-0.3.0.1/src/vfs/vfs-file-monitor.h pcmanfm-0.3.0.1/src/vfs/vfs-file-monitor.h | ||
414 | --- ../pcmanfm-0.3.0.1-r0/pcmanfm-0.3.0.1/src/vfs/vfs-file-monitor.h 2006-04-03 00:38:33.000000000 +0100 | ||
415 | +++ pcmanfm-0.3.0.1/src/vfs/vfs-file-monitor.h 2006-08-20 20:47:00.000000000 +0100 | ||
416 | @@ -20,7 +20,16 @@ | ||
417 | #define _VFS_FILE_MONITOR_H_ | ||
418 | |||
419 | #include <glib.h> | ||
420 | +#ifdef HAVE_FAM_H | ||
421 | #include <fam.h> | ||
422 | +#else | ||
423 | +# define FAMCreated 0 | ||
424 | +# define FAMDeleted 1 | ||
425 | +# define FAMChanged 2 | ||
426 | +typedef struct { | ||
427 | + int reqnum; | ||
428 | +} FAMRequest; | ||
429 | +#endif | ||
430 | |||
431 | G_BEGIN_DECLS | ||
432 | |||