Added MOO_FILE_EVENT_CREATED; removed (suspend|resume)_monitor
parent
ed840c1b22
commit
7f98703017
|
@ -38,7 +38,7 @@
|
||||||
<useconfiguration>gtk-cvs</useconfiguration>
|
<useconfiguration>gtk-cvs</useconfiguration>
|
||||||
</general>
|
</general>
|
||||||
<run>
|
<run>
|
||||||
<mainprogram>tests/medit</mainprogram>
|
<mainprogram>medit/medit</mainprogram>
|
||||||
<directoryradio>executable</directoryradio>
|
<directoryradio>executable</directoryradio>
|
||||||
<customdirectory>/</customdirectory>
|
<customdirectory>/</customdirectory>
|
||||||
<programargs>-n</programargs>
|
<programargs>-n</programargs>
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
</run>
|
</run>
|
||||||
<configurations>
|
<configurations>
|
||||||
<debug>
|
<debug>
|
||||||
<configargs>--enable-debug --enable-all-gcc-warnings</configargs>
|
<configargs>--enable-debug --enable-all-warnings --without-python --prefix=/tmp/medit</configargs>
|
||||||
<builddir>build/debug</builddir>
|
<builddir>build/debug</builddir>
|
||||||
<ccompiler>kdevgccoptions</ccompiler>
|
<ccompiler>kdevgccoptions</ccompiler>
|
||||||
<cxxcompiler>kdevgppoptions</cxxcompiler>
|
<cxxcompiler>kdevgppoptions</cxxcompiler>
|
||||||
|
|
|
@ -938,6 +938,10 @@ file_watch_callback (G_GNUC_UNUSED MooFileWatch *watch,
|
||||||
case MOO_FILE_EVENT_ERROR:
|
case MOO_FILE_EVENT_ERROR:
|
||||||
/* XXX and what to do now? */
|
/* XXX and what to do now? */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MOO_FILE_EVENT_CREATED:
|
||||||
|
g_critical ("%s: oops", G_STRLOC);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
check_file_status (edit, FALSE);
|
check_file_status (edit, FALSE);
|
||||||
|
|
|
@ -184,23 +184,26 @@ folder_shutdown (MooFolderImpl *impl)
|
||||||
stop_populate (impl);
|
stop_populate (impl);
|
||||||
stop_monitor (impl);
|
stop_monitor (impl);
|
||||||
files_list_free (&impl->files_copy);
|
files_list_free (&impl->files_copy);
|
||||||
|
|
||||||
if (impl->reload_idle)
|
if (impl->reload_idle)
|
||||||
g_source_remove (impl->reload_idle);
|
g_source_remove (impl->reload_idle);
|
||||||
|
impl->reload_idle = 0;
|
||||||
|
|
||||||
if (impl->files)
|
if (impl->files)
|
||||||
g_hash_table_destroy (impl->files);
|
g_hash_table_destroy (impl->files);
|
||||||
|
impl->files = NULL;
|
||||||
|
|
||||||
if (impl->dir)
|
if (impl->dir)
|
||||||
g_dir_close (impl->dir);
|
g_dir_close (impl->dir);
|
||||||
|
impl->dir = NULL;
|
||||||
|
|
||||||
if (impl->populate_idle_id)
|
if (impl->populate_idle_id)
|
||||||
g_source_remove (impl->populate_idle_id);
|
g_source_remove (impl->populate_idle_id);
|
||||||
|
impl->populate_idle_id = 0;
|
||||||
|
|
||||||
if (impl->timer)
|
if (impl->timer)
|
||||||
g_timer_destroy (impl->timer);
|
g_timer_destroy (impl->timer);
|
||||||
if (impl->reload_idle)
|
|
||||||
g_source_remove (impl->reload_idle);
|
|
||||||
impl->populate_idle_id = 0;
|
|
||||||
impl->timer = NULL;
|
impl->timer = NULL;
|
||||||
impl->reload_idle = 0;
|
|
||||||
impl->files = NULL;
|
|
||||||
impl->reload_idle = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -777,6 +780,9 @@ fam_callback (MooFileWatch *watch,
|
||||||
case MOO_FILE_EVENT_CHANGED:
|
case MOO_FILE_EVENT_CHANGED:
|
||||||
file_changed (impl, event->filename);
|
file_changed (impl, event->filename);
|
||||||
break;
|
break;
|
||||||
|
case MOO_FILE_EVENT_CREATED:
|
||||||
|
file_created (impl, event->filename);
|
||||||
|
break;
|
||||||
case MOO_FILE_EVENT_DELETED:
|
case MOO_FILE_EVENT_DELETED:
|
||||||
file_deleted (impl, event->filename);
|
file_deleted (impl, event->filename);
|
||||||
break;
|
break;
|
||||||
|
@ -875,11 +881,6 @@ file_changed (MooFolderImpl *impl,
|
||||||
if (!impl->reload_idle)
|
if (!impl->reload_idle)
|
||||||
impl->reload_idle = g_idle_add ((GSourceFunc) moo_folder_do_reload, impl);
|
impl->reload_idle = g_idle_add ((GSourceFunc) moo_folder_do_reload, impl);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/* XXX */
|
|
||||||
g_return_if_reached ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -583,24 +583,6 @@
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(define-method suspend_monitor
|
|
||||||
(of-object "MooFileWatch")
|
|
||||||
(c-name "moo_file_watch_suspend_monitor")
|
|
||||||
(return-type "none")
|
|
||||||
(parameters
|
|
||||||
'("guint" "monitor_id")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
(define-method resume_monitor
|
|
||||||
(of-object "MooFileWatch")
|
|
||||||
(c-name "moo_file_watch_resume_monitor")
|
|
||||||
(return-type "none")
|
|
||||||
(parameters
|
|
||||||
'("guint" "monitor_id")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
(define-method cancel_monitor
|
(define-method cancel_monitor
|
||||||
(of-object "MooFileWatch")
|
(of-object "MooFileWatch")
|
||||||
(c-name "moo_file_watch_cancel_monitor")
|
(c-name "moo_file_watch_cancel_monitor")
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
#if defined(__WIN32__)
|
#if defined(__WIN32__)
|
||||||
#define DEBUG_PRINT _moo_message_async
|
#define DEBUG_PRINT _moo_message_async
|
||||||
#elif 0
|
#elif 1
|
||||||
#define DEBUG_PRINT _moo_message
|
#define DEBUG_PRINT _moo_message
|
||||||
#else
|
#else
|
||||||
static void DEBUG_PRINT (G_GNUC_UNUSED const char *format, ...)
|
static void DEBUG_PRINT (G_GNUC_UNUSED const char *format, ...)
|
||||||
|
@ -70,7 +70,6 @@ typedef struct {
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
guint isdir : 1;
|
guint isdir : 1;
|
||||||
guint suspended : 1;
|
|
||||||
guint alive : 1;
|
guint alive : 1;
|
||||||
} Monitor;
|
} Monitor;
|
||||||
|
|
||||||
|
@ -85,10 +84,6 @@ struct WatchFuncs {
|
||||||
GError **error);
|
GError **error);
|
||||||
void (*stop_monitor) (MooFileWatch *watch,
|
void (*stop_monitor) (MooFileWatch *watch,
|
||||||
Monitor *monitor);
|
Monitor *monitor);
|
||||||
gboolean (*suspend_monitor) (MooFileWatch *watch,
|
|
||||||
Monitor *monitor);
|
|
||||||
gboolean (*resume_monitor) (MooFileWatch *watch,
|
|
||||||
Monitor *monitor);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MooFileWatch {
|
struct _MooFileWatch {
|
||||||
|
@ -113,10 +108,6 @@ static gboolean watch_fam_shutdown (MooFileWatch *watch,
|
||||||
static gboolean watch_fam_start_monitor (MooFileWatch *watch,
|
static gboolean watch_fam_start_monitor (MooFileWatch *watch,
|
||||||
Monitor *monitor,
|
Monitor *monitor,
|
||||||
GError **error);
|
GError **error);
|
||||||
static gboolean watch_fam_suspend_monitor (MooFileWatch *watch,
|
|
||||||
Monitor *monitor);
|
|
||||||
static gboolean watch_fam_resume_monitor (MooFileWatch *watch,
|
|
||||||
Monitor *monitor);
|
|
||||||
static void watch_fam_stop_monitor (MooFileWatch *watch,
|
static void watch_fam_stop_monitor (MooFileWatch *watch,
|
||||||
Monitor *monitor);
|
Monitor *monitor);
|
||||||
#endif /* MOO_USE_FAM */
|
#endif /* MOO_USE_FAM */
|
||||||
|
@ -160,22 +151,16 @@ static struct WatchFuncs watch_funcs = {
|
||||||
watch_fam_start,
|
watch_fam_start,
|
||||||
watch_fam_shutdown,
|
watch_fam_shutdown,
|
||||||
watch_fam_start_monitor,
|
watch_fam_start_monitor,
|
||||||
watch_fam_stop_monitor,
|
watch_fam_stop_monitor
|
||||||
watch_fam_suspend_monitor,
|
|
||||||
watch_fam_resume_monitor
|
|
||||||
#elif defined(__WIN32__)
|
#elif defined(__WIN32__)
|
||||||
watch_win32_start,
|
watch_win32_start,
|
||||||
watch_win32_shutdown,
|
watch_win32_shutdown,
|
||||||
watch_win32_start_monitor,
|
watch_win32_start_monitor,
|
||||||
watch_win32_stop_monitor,
|
watch_win32_stop_monitor
|
||||||
watch_win32_suspend_monitor,
|
|
||||||
watch_win32_resume_monitor
|
|
||||||
#else
|
#else
|
||||||
watch_stat_start,
|
watch_stat_start,
|
||||||
watch_stat_shutdown,
|
watch_stat_shutdown,
|
||||||
watch_stat_start_monitor,
|
watch_stat_start_monitor,
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -452,52 +437,15 @@ moo_file_watch_cancel_monitor (MooFileWatch *watch,
|
||||||
g_hash_table_remove (watch->requests, GUINT_TO_POINTER (monitor->id));
|
g_hash_table_remove (watch->requests, GUINT_TO_POINTER (monitor->id));
|
||||||
|
|
||||||
if (monitor->alive && watch_funcs.stop_monitor)
|
if (monitor->alive && watch_funcs.stop_monitor)
|
||||||
|
{
|
||||||
|
DEBUG_PRINT ("stopped monitor for '%s'", monitor->filename);
|
||||||
watch_funcs.stop_monitor (watch, monitor);
|
watch_funcs.stop_monitor (watch, monitor);
|
||||||
|
}
|
||||||
|
|
||||||
monitor_free (monitor);
|
monitor_free (monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
moo_file_watch_suspend_monitor (MooFileWatch *watch,
|
|
||||||
guint monitor_id)
|
|
||||||
{
|
|
||||||
Monitor *monitor;
|
|
||||||
|
|
||||||
g_return_if_fail (watch != NULL);
|
|
||||||
|
|
||||||
monitor = g_hash_table_lookup (watch->requests,
|
|
||||||
GUINT_TO_POINTER (monitor_id));
|
|
||||||
g_return_if_fail (monitor != NULL);
|
|
||||||
|
|
||||||
if (monitor->alive && !monitor->suspended)
|
|
||||||
{
|
|
||||||
if (!watch_funcs.suspend_monitor || watch_funcs.suspend_monitor (watch, monitor))
|
|
||||||
monitor->suspended = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
moo_file_watch_resume_monitor (MooFileWatch *watch,
|
|
||||||
guint monitor_id)
|
|
||||||
{
|
|
||||||
Monitor *monitor;
|
|
||||||
|
|
||||||
g_return_if_fail (watch != NULL);
|
|
||||||
|
|
||||||
monitor = g_hash_table_lookup (watch->requests,
|
|
||||||
GUINT_TO_POINTER (monitor_id));
|
|
||||||
g_return_if_fail (monitor != NULL);
|
|
||||||
|
|
||||||
if (monitor->alive && monitor->suspended)
|
|
||||||
{
|
|
||||||
if (!watch_funcs.resume_monitor || watch_funcs.resume_monitor (watch, monitor))
|
|
||||||
monitor->suspended = FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
moo_file_watch_emit_event (MooFileWatch *watch,
|
moo_file_watch_emit_event (MooFileWatch *watch,
|
||||||
MooFileEvent *event,
|
MooFileEvent *event,
|
||||||
|
@ -505,8 +453,14 @@ moo_file_watch_emit_event (MooFileWatch *watch,
|
||||||
{
|
{
|
||||||
moo_file_watch_ref (watch);
|
moo_file_watch_ref (watch);
|
||||||
|
|
||||||
if (!monitor->suspended || event->code == MOO_FILE_EVENT_ERROR)
|
if (monitor->alive || event->code == MOO_FILE_EVENT_ERROR)
|
||||||
|
{
|
||||||
|
static const char *names[] = {
|
||||||
|
"changed", "created", "deleted", "error"
|
||||||
|
};
|
||||||
|
DEBUG_PRINT ("emitting event %s for %s", names[event->code], monitor->filename);
|
||||||
monitor->callback (watch, event, monitor->data);
|
monitor->callback (watch, event, monitor->data);
|
||||||
|
}
|
||||||
|
|
||||||
moo_file_watch_unref (watch);
|
moo_file_watch_unref (watch);
|
||||||
}
|
}
|
||||||
|
@ -658,66 +612,6 @@ watch_fam_start_monitor (MooFileWatch *watch,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
watch_fam_suspend_monitor (MooFileWatch *watch,
|
|
||||||
Monitor *monitor)
|
|
||||||
{
|
|
||||||
FAMRequest fr;
|
|
||||||
int result;
|
|
||||||
|
|
||||||
g_return_val_if_fail (monitor != NULL, FALSE);
|
|
||||||
|
|
||||||
fr.reqnum = monitor->fam_request;
|
|
||||||
|
|
||||||
result = FAMSuspendMonitor (&watch->fam_connection, &fr);
|
|
||||||
|
|
||||||
if (result != 0)
|
|
||||||
{
|
|
||||||
DEBUG_PRINT ("Connection %d: FAMSuspendMonitor for '%s' failed",
|
|
||||||
watch->fam_connection.fd,
|
|
||||||
monitor->filename);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DEBUG_PRINT ("Connection %d: suspended monitor for '%s'",
|
|
||||||
watch->fam_connection.fd,
|
|
||||||
monitor->filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
watch_fam_resume_monitor (MooFileWatch *watch,
|
|
||||||
Monitor *monitor)
|
|
||||||
{
|
|
||||||
FAMRequest fr;
|
|
||||||
int result;
|
|
||||||
|
|
||||||
g_return_val_if_fail (monitor != NULL, FALSE);
|
|
||||||
|
|
||||||
fr.reqnum = monitor->fam_request;
|
|
||||||
|
|
||||||
result = FAMResumeMonitor (&watch->fam_connection, &fr);
|
|
||||||
|
|
||||||
if (result != 0)
|
|
||||||
{
|
|
||||||
DEBUG_PRINT ("Connection %d: FAMResumeMonitor for '%s' failed",
|
|
||||||
watch->fam_connection.fd,
|
|
||||||
monitor->filename);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DEBUG_PRINT ("Connection %d: resumed monitor for '%s'",
|
|
||||||
watch->fam_connection.fd,
|
|
||||||
monitor->filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
watch_fam_stop_monitor (MooFileWatch *watch,
|
watch_fam_stop_monitor (MooFileWatch *watch,
|
||||||
Monitor *monitor)
|
Monitor *monitor)
|
||||||
|
@ -738,6 +632,81 @@ watch_fam_stop_monitor (MooFileWatch *watch,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_events (MooFileWatch *watch,
|
||||||
|
GSList *events)
|
||||||
|
{
|
||||||
|
while (events)
|
||||||
|
{
|
||||||
|
MooFileEvent *e;
|
||||||
|
Monitor *monitor;
|
||||||
|
|
||||||
|
e = events->data;
|
||||||
|
events = events->next;
|
||||||
|
|
||||||
|
monitor = g_hash_table_lookup (watch->requests, GUINT_TO_POINTER (e->monitor_id));
|
||||||
|
|
||||||
|
if (!monitor || !monitor->alive)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
moo_file_watch_emit_event (watch, e, monitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static MooFileEvent *
|
||||||
|
fam_event_to_file_event (FAMEvent *fe,
|
||||||
|
MooFileWatch *watch)
|
||||||
|
{
|
||||||
|
Monitor *monitor;
|
||||||
|
const char *filename;
|
||||||
|
MooFileEventCode code;
|
||||||
|
|
||||||
|
monitor = g_hash_table_lookup (watch->requests, fe->userdata);
|
||||||
|
|
||||||
|
if (!monitor)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
g_assert (GUINT_TO_POINTER (monitor->id) == fe->userdata);
|
||||||
|
g_assert (monitor->fam_request == fe->fr.reqnum);
|
||||||
|
|
||||||
|
filename = fe->filename;
|
||||||
|
|
||||||
|
switch (fe->code)
|
||||||
|
{
|
||||||
|
case FAMCreated:
|
||||||
|
code = MOO_FILE_EVENT_CREATED;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FAMChanged:
|
||||||
|
code = MOO_FILE_EVENT_CHANGED;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FAMDeleted:
|
||||||
|
code = MOO_FILE_EVENT_DELETED;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FAMMoved:
|
||||||
|
/* XXX never happens with FAM, what about gamin? */
|
||||||
|
g_print ("file moved: %s\n", fe->filename);
|
||||||
|
code = MOO_FILE_EVENT_CHANGED;
|
||||||
|
filename = monitor->filename;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FAMStartExecuting:
|
||||||
|
case FAMStopExecuting:
|
||||||
|
case FAMAcknowledge:
|
||||||
|
case FAMExists:
|
||||||
|
case FAMEndExist:
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
default:
|
||||||
|
g_warning ("%s: unknown FAM code %d", G_STRLOC, fe->code);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return moo_file_event_new (filename, monitor->id, code);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
read_fam_events (G_GNUC_UNUSED GIOChannel *source,
|
read_fam_events (G_GNUC_UNUSED GIOChannel *source,
|
||||||
GIOCondition condition,
|
GIOCondition condition,
|
||||||
|
@ -747,6 +716,8 @@ read_fam_events (G_GNUC_UNUSED GIOChannel *source,
|
||||||
int result;
|
int result;
|
||||||
FAMConnection *connection = &watch->fam_connection;
|
FAMConnection *connection = &watch->fam_connection;
|
||||||
gboolean retval = TRUE;
|
gboolean retval = TRUE;
|
||||||
|
GSList *events = NULL;
|
||||||
|
guint n_events;
|
||||||
|
|
||||||
moo_file_watch_ref (watch);
|
moo_file_watch_ref (watch);
|
||||||
|
|
||||||
|
@ -765,23 +736,35 @@ read_fam_events (G_GNUC_UNUSED GIOChannel *source,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((result = FAMPending (connection)))
|
for (n_events = 0; !error && n_events < 4096 && (result = FAMPending (connection)); n_events++)
|
||||||
{
|
{
|
||||||
FAMEvent fe;
|
|
||||||
MooFileEvent event;
|
|
||||||
gboolean emit = TRUE;
|
|
||||||
Monitor *monitor;
|
|
||||||
|
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
{
|
||||||
SET_FAM_ERROR (FAMPending, &error);
|
SET_FAM_ERROR (FAMPending, &error);
|
||||||
DEBUG_PRINT ("Connection %d: FAMPending failed", connection->fd);
|
DEBUG_PRINT ("Connection %d: FAMPending failed", connection->fd);
|
||||||
}
|
}
|
||||||
else if (FAMNextEvent (connection, &fe) != 1)
|
else
|
||||||
|
{
|
||||||
|
FAMEvent fe;
|
||||||
|
|
||||||
|
if (FAMNextEvent (connection, &fe) != 1)
|
||||||
{
|
{
|
||||||
SET_FAM_ERROR (FAMNextEvent, &error);
|
SET_FAM_ERROR (FAMNextEvent, &error);
|
||||||
DEBUG_PRINT ("Connection %d: FAMNextEvent failed", connection->fd);
|
DEBUG_PRINT ("Connection %d: FAMNextEvent failed", connection->fd);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MooFileEvent *e;
|
||||||
|
if ((e = fam_event_to_file_event (&fe, watch)))
|
||||||
|
events = g_slist_prepend (events, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
events = g_slist_reverse (events);
|
||||||
|
do_events (watch, events);
|
||||||
|
g_slist_foreach (events, (GFunc) moo_file_event_free, NULL);
|
||||||
|
g_slist_free (events);
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
|
@ -797,52 +780,6 @@ read_fam_events (G_GNUC_UNUSED GIOChannel *source,
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = FALSE;
|
retval = FALSE;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
monitor = g_hash_table_lookup (watch->requests, fe.userdata);
|
|
||||||
|
|
||||||
if (!monitor || monitor->suspended)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* TODO: check monitor here */
|
|
||||||
g_assert (monitor->fam_request == fe.fr.reqnum);
|
|
||||||
event.monitor_id = monitor->id;
|
|
||||||
event.filename = fe.filename;
|
|
||||||
event.error = NULL;
|
|
||||||
|
|
||||||
switch (fe.code)
|
|
||||||
{
|
|
||||||
case FAMChanged:
|
|
||||||
case FAMCreated:
|
|
||||||
event.code = MOO_FILE_EVENT_CHANGED;
|
|
||||||
event.filename = monitor->filename;
|
|
||||||
break;
|
|
||||||
case FAMDeleted:
|
|
||||||
event.code = MOO_FILE_EVENT_DELETED;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FAMMoved:
|
|
||||||
/* XXX never happens with FAM, what about gamin? */
|
|
||||||
event.code = MOO_FILE_EVENT_CHANGED;
|
|
||||||
event.filename = monitor->filename;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FAMStartExecuting:
|
|
||||||
case FAMStopExecuting:
|
|
||||||
case FAMAcknowledge:
|
|
||||||
case FAMExists:
|
|
||||||
case FAMEndExist:
|
|
||||||
emit = FALSE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
emit = FALSE;
|
|
||||||
g_warning ("%s: unknown FAM code %d", G_STRLOC, fe.code);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (emit)
|
|
||||||
moo_file_watch_emit_event (watch, &event, monitor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
|
@ -46,6 +46,7 @@ GQuark moo_file_watch_error_quark (void);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MOO_FILE_EVENT_CHANGED,
|
MOO_FILE_EVENT_CHANGED,
|
||||||
|
MOO_FILE_EVENT_CREATED,
|
||||||
MOO_FILE_EVENT_DELETED,
|
MOO_FILE_EVENT_DELETED,
|
||||||
MOO_FILE_EVENT_ERROR
|
MOO_FILE_EVENT_ERROR
|
||||||
} MooFileEventCode;
|
} MooFileEventCode;
|
||||||
|
@ -89,11 +90,6 @@ guint moo_file_watch_create_monitor (MooFileWatch *watch,
|
||||||
/* FAMCancelMonitor */
|
/* FAMCancelMonitor */
|
||||||
void moo_file_watch_cancel_monitor (MooFileWatch *watch,
|
void moo_file_watch_cancel_monitor (MooFileWatch *watch,
|
||||||
guint monitor_id);
|
guint monitor_id);
|
||||||
/* FAMSuspendMonitor, FAMResumeMonitor */
|
|
||||||
void moo_file_watch_suspend_monitor (MooFileWatch *watch,
|
|
||||||
guint monitor_id);
|
|
||||||
void moo_file_watch_resume_monitor (MooFileWatch *watch,
|
|
||||||
guint monitor_id);
|
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
Loading…
Reference in New Issue