NetworkManager r3661 - in trunk: . gfilemonitor



Author: dcbw
Date: Mon May 12 20:48:48 2008
New Revision: 3661
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3661&view=rev

Log:
2008-05-12  Dan Williams  <dcbw redhat com>

	* 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



Modified:
   trunk/ChangeLog
   trunk/gfilemonitor/glocaldirectorymonitor.c
   trunk/gfilemonitor/glocaldirectorymonitor.h
   trunk/gfilemonitor/glocalfilemonitor.c
   trunk/gfilemonitor/glocalfilemonitor.h

Modified: trunk/gfilemonitor/glocaldirectorymonitor.c
==============================================================================
--- trunk/gfilemonitor/glocaldirectorymonitor.c	(original)
+++ trunk/gfilemonitor/glocaldirectorymonitor.c	Mon May 12 20:48:48 2008
@@ -22,7 +22,9 @@
 
 #include <config.h>
 #include <string.h>
+#include <glib.h>
 
+#include "inotify-helper.h"
 #include "glocaldirectorymonitor.h"
 
 enum
@@ -47,6 +49,8 @@
 
   g_free (local_monitor->dirname);
 
+  _ih_sub_free (local_monitor->sub);
+
 #if 0
   if (local_monitor->mount_monitor)
     {
@@ -108,8 +112,13 @@
         }
     }
 
+  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 @@
 				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));
 }
 

Modified: trunk/gfilemonitor/glocaldirectorymonitor.h
==============================================================================
--- trunk/gfilemonitor/glocaldirectorymonitor.h	(original)
+++ trunk/gfilemonitor/glocaldirectorymonitor.h	Mon May 12 20:48:48 2008
@@ -25,6 +25,7 @@
 
 #include <glib-object.h>
 #include "gfilemonitor.h"
+#include "inotify-sub.h"
 
 G_BEGIN_DECLS
 
@@ -43,6 +44,7 @@
 {
   GFileMonitor parent_instance;
   gchar *dirname;
+  inotify_sub *sub;
 #if 0
   /* For mount emulation */
   GUnixMountMonitor *mount_monitor;

Modified: trunk/gfilemonitor/glocalfilemonitor.c
==============================================================================
--- trunk/gfilemonitor/glocalfilemonitor.c	(original)
+++ trunk/gfilemonitor/glocalfilemonitor.c	Mon May 12 20:48:48 2008
@@ -22,7 +22,9 @@
 
 #include <config.h>
 #include <string.h>
+#include <glib.h>
 
+#include "inotify-helper.h"
 #include "glocalfilemonitor.h"
 
 enum
@@ -65,6 +67,7 @@
   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_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 @@
       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 @@
 			   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));
 }
 

Modified: trunk/gfilemonitor/glocalfilemonitor.h
==============================================================================
--- trunk/gfilemonitor/glocalfilemonitor.h	(original)
+++ trunk/gfilemonitor/glocalfilemonitor.h	Mon May 12 20:48:48 2008
@@ -25,6 +25,7 @@
 
 #include <glib-object.h>
 #include "gfilemonitor.h"
+#include "inotify-sub.h"
 
 G_BEGIN_DECLS
 
@@ -43,6 +44,7 @@
 {
   GFileMonitor parent_instance;
   gchar *filename;
+  inotify_sub *sub;
 };
 
 struct _GLocalFileMonitorClass {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]