From 20dddc2c2b7aecc7fc0c5790bf44d0c5abdf0cbf Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 12 May 2008 20:48:48 +0000 Subject: [PATCH] 2008-05-12 Dan Williams * gfilemonitor/glocaldirectorymonitor.c gfilemonitor/glocaldirectorymonitor.h - (g_local_directory_monitor_constructor): actually subscribe to the watch - (_g_local_directory_monitor_new): ensure that inotify is started up * gfilemonitor/glocalfilemonitor.c gfilemonitor/glocalfilemonitor.h - (g_local_file_monitor_constructor): actually subscribe to the watch - (_g_local_file_monitor_new): ensure that inotify is started up git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3661 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 13 +++++++++++++ gfilemonitor/glocaldirectorymonitor.c | 13 +++++++++++++ gfilemonitor/glocaldirectorymonitor.h | 2 ++ gfilemonitor/glocalfilemonitor.c | 20 ++++++++++++++++++++ gfilemonitor/glocalfilemonitor.h | 2 ++ 5 files changed, 50 insertions(+) diff --git a/ChangeLog b/ChangeLog index fa478bbf4b..fdfd3586c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2008-05-12 Dan Williams + + * gfilemonitor/glocaldirectorymonitor.c + gfilemonitor/glocaldirectorymonitor.h + - (g_local_directory_monitor_constructor): actually subscribe to the + watch + - (_g_local_directory_monitor_new): ensure that inotify is started up + + * gfilemonitor/glocalfilemonitor.c + gfilemonitor/glocalfilemonitor.h + - (g_local_file_monitor_constructor): actually subscribe to the watch + - (_g_local_file_monitor_new): ensure that inotify is started up + 2008-05-11 Dan Williams * configure.in diff --git a/gfilemonitor/glocaldirectorymonitor.c b/gfilemonitor/glocaldirectorymonitor.c index cc207c6808..778c8d97dc 100644 --- a/gfilemonitor/glocaldirectorymonitor.c +++ b/gfilemonitor/glocaldirectorymonitor.c @@ -22,7 +22,9 @@ #include #include +#include +#include "inotify-helper.h" #include "glocaldirectorymonitor.h" enum @@ -47,6 +49,8 @@ g_local_directory_monitor_finalize (GObject *object) g_free (local_monitor->dirname); + _ih_sub_free (local_monitor->sub); + #if 0 if (local_monitor->mount_monitor) { @@ -108,8 +112,13 @@ g_local_directory_monitor_constructor (GType type, } } + g_assert (dirname); local_monitor->dirname = g_strdup (dirname); + local_monitor->sub = _ih_sub_new (local_monitor->dirname, NULL, local_monitor); + g_assert (local_monitor->sub); + g_assert (_ih_sub_add (local_monitor->sub)); + #if 0 if (!klass->mount_notify) { @@ -223,6 +232,10 @@ _g_local_directory_monitor_new (const char *dirname, GFileMonitorFlags flags, GError **error) { + if (!_ih_startup ()) { + g_set_error (error, 0, 0, "inotify is unsupported!!"); + return NULL; + } return G_FILE_MONITOR (g_object_new (G_TYPE_LOCAL_DIRECTORY_MONITOR, "dirname", dirname, NULL)); } diff --git a/gfilemonitor/glocaldirectorymonitor.h b/gfilemonitor/glocaldirectorymonitor.h index a82f1f6b88..29c733723f 100644 --- a/gfilemonitor/glocaldirectorymonitor.h +++ b/gfilemonitor/glocaldirectorymonitor.h @@ -25,6 +25,7 @@ #include #include "gfilemonitor.h" +#include "inotify-sub.h" G_BEGIN_DECLS @@ -43,6 +44,7 @@ struct _GLocalDirectoryMonitor { GFileMonitor parent_instance; gchar *dirname; + inotify_sub *sub; #if 0 /* For mount emulation */ GUnixMountMonitor *mount_monitor; diff --git a/gfilemonitor/glocalfilemonitor.c b/gfilemonitor/glocalfilemonitor.c index 1c4087c4e7..4a64503c60 100644 --- a/gfilemonitor/glocalfilemonitor.c +++ b/gfilemonitor/glocalfilemonitor.c @@ -22,7 +22,9 @@ #include #include +#include +#include "inotify-helper.h" #include "glocalfilemonitor.h" enum @@ -65,6 +67,7 @@ g_local_file_monitor_constructor (GType type, GObjectClass *parent_class; GLocalFileMonitor *local_monitor; const gchar *filename = NULL; + gchar *dname, *fname; gint i; klass = G_LOCAL_FILE_MONITOR_CLASS (g_type_class_peek (G_TYPE_LOCAL_FILE_MONITOR)); @@ -90,6 +93,17 @@ g_local_file_monitor_constructor (GType type, g_warning ("%s: warning: filename was NULL", __func__); local_monitor->filename = g_strdup (filename); + + fname = g_path_get_basename (filename); + dname = g_path_get_dirname (filename); + + local_monitor->sub = _ih_sub_new (dname, fname, local_monitor); + g_free (fname); + g_free (dname); + + g_assert (local_monitor->sub); + g_assert (_ih_sub_add (local_monitor->sub)); + return obj; } @@ -103,6 +117,8 @@ g_local_file_monitor_finalize (GObject *object) local_monitor->filename = NULL; } + _ih_sub_free (local_monitor->sub); + if (G_OBJECT_CLASS (g_local_file_monitor_parent_class)->finalize) (*G_OBJECT_CLASS (g_local_file_monitor_parent_class)->finalize) (object); } @@ -138,6 +154,10 @@ _g_local_file_monitor_new (const char *pathname, GFileMonitorFlags flags, GError **error) { + if (!_ih_startup ()) { + g_set_error (error, 0, 0, "inotify is unsupported!!"); + return NULL; + } return G_FILE_MONITOR (g_object_new (G_TYPE_LOCAL_FILE_MONITOR, "filename", pathname, NULL)); } diff --git a/gfilemonitor/glocalfilemonitor.h b/gfilemonitor/glocalfilemonitor.h index 0bbe8deb95..76141afd9d 100644 --- a/gfilemonitor/glocalfilemonitor.h +++ b/gfilemonitor/glocalfilemonitor.h @@ -25,6 +25,7 @@ #include #include "gfilemonitor.h" +#include "inotify-sub.h" G_BEGIN_DECLS @@ -43,6 +44,7 @@ struct _GLocalFileMonitor { GFileMonitor parent_instance; gchar *filename; + inotify_sub *sub; }; struct _GLocalFileMonitorClass {