Commit 743a376b authored by Darin Adler's avatar Darin Adler

Changes to use FAM if it's there. Now the hard part is getting FAM

	installed on people's systems.

	* libnautilus-extensions/nautilus-directory-async.c:
	(find_monitor): Tightened up the function.
	(monitor_file_compare), (find_any_monitor): Functions to see if a
	file still has a reason to be monitored.
	(nautilus_directory_monitor_add_internal): Start FAM monitoring.
	(nautilus_directory_monitor_remove_internal): Stop FAM monitoring.
	* libnautilus-extensions/nautilus-directory-private.h: Add a place
	to keep track of the FAM monitor.
	* libnautilus-extensions/nautilus-file-private.h: Add a place
	to keep track of the FAM monitor.
	* libnautilus-extensions/nautilus-directory.c:
	(nautilus_directory_destroy): Stop FAM monitoring.
	* libnautilus-extensions/nautilus-file.c: (destroy): Stop FAM
	monitoring.

	* libnautilus-extensions/nautilus-monitor.c:
	(get_event_uri): Use FAMREQUEST_GETREQNUM instead of going
	directly at the struct.
	(process_fam_notifications): Get rid of the messages and call
	nautilus_file_changes_consume_changes on the way out.
	(nautilus_monitor_file): Get rid of the message.
	(nautilus_monitor_directory): Get rid of the message and use
	FAMREQUEST_GETREQNUM instead of going directly at the struct.
	(nautilus_monitor_cancel): Get rid of the message and use
	FAMREQUEST_GETREQNUM instead of going directly at the struct.
parent 061ecc3f
2001-04-16 Darin Adler <darin@eazel.com>
Changes to use FAM if it's there. Now the hard part is getting FAM
installed on people's systems.
* libnautilus-extensions/nautilus-directory-async.c:
(find_monitor): Tightened up the function.
(monitor_file_compare), (find_any_monitor): Functions to see if a
file still has a reason to be monitored.
(nautilus_directory_monitor_add_internal): Start FAM monitoring.
(nautilus_directory_monitor_remove_internal): Stop FAM monitoring.
* libnautilus-extensions/nautilus-directory-private.h: Add a place
to keep track of the FAM monitor.
* libnautilus-extensions/nautilus-file-private.h: Add a place
to keep track of the FAM monitor.
* libnautilus-extensions/nautilus-directory.c:
(nautilus_directory_destroy): Stop FAM monitoring.
* libnautilus-extensions/nautilus-file.c: (destroy): Stop FAM
monitoring.
* libnautilus-extensions/nautilus-monitor.c:
(get_event_uri): Use FAMREQUEST_GETREQNUM instead of going
directly at the struct.
(process_fam_notifications): Get rid of the messages and call
nautilus_file_changes_consume_changes on the way out.
(nautilus_monitor_file): Get rid of the message.
(nautilus_monitor_directory): Get rid of the message and use
FAMREQUEST_GETREQNUM instead of going directly at the struct.
(nautilus_monitor_cancel): Get rid of the message and use
FAMREQUEST_GETREQNUM instead of going directly at the struct.
2001-04-16 Ramiro Estrugo <ramiro@eazel.com>
* libnautilus/Makefile.am:
......
......@@ -431,20 +431,43 @@ find_monitor (NautilusDirectory *directory,
NautilusFile *file,
gconstpointer client)
{
GList *result;
Monitor *monitor;
Monitor monitor;
monitor = g_new0 (Monitor, 1);
monitor->client = client;
monitor->file = file;
monitor.client = client;
monitor.file = file;
return g_list_find_custom (directory->details->monitor_list,
&monitor,
monitor_key_compare);
}
result = g_list_find_custom (directory->details->monitor_list,
monitor,
monitor_key_compare);
static int
monitor_file_compare (gconstpointer a,
gconstpointer data)
{
const Monitor *monitor;
NautilusFile *file;
g_free (monitor);
monitor = a;
file = (NautilusFile *) data;
return result;
if (monitor->file < file) {
return -1;
}
if (monitor->file > file) {
return +1;
}
return 0;
}
static gboolean
find_any_monitor (NautilusDirectory *directory,
NautilusFile *file)
{
return g_list_find_custom (directory->details->monitor_list,
file,
monitor_file_compare) != NULL;
}
static void
......@@ -573,6 +596,7 @@ nautilus_directory_monitor_add_internal (NautilusDirectory *directory,
{
Monitor *monitor;
GList *file_list;
char *file_uri;
g_assert (NAUTILUS_IS_DIRECTORY (directory));
......@@ -604,13 +628,26 @@ nautilus_directory_monitor_add_internal (NautilusDirectory *directory,
}
}
/* Start the "real" monitoring (FAM or whatever). */
if (file == NULL) {
if (directory->details->monitor == NULL) {
directory->details->monitor = nautilus_monitor_directory (directory->details->uri);
}
} else {
if (file->details->monitor == NULL) {
file_uri = nautilus_file_get_uri (file);
file->details->monitor = nautilus_monitor_file (file_uri);
g_free (file_uri);
}
}
/* We could just call update_metadata_monitors here, but we can be smarter
* since we know what monitor was just added.
*/
if (monitor->request.metafile && directory->details->metafile_monitor == NULL) {
nautilus_directory_register_metadata_monitor (directory);
}
/* Kick off I/O. */
nautilus_directory_async_state_changed (directory);
}
......@@ -1029,6 +1066,20 @@ nautilus_directory_monitor_remove_internal (NautilusDirectory *directory,
remove_monitor (directory, file, client);
if (file == NULL) {
if (directory->details->monitor != NULL
&& !find_any_monitor (directory, NULL)) {
nautilus_monitor_cancel (directory->details->monitor);
directory->details->monitor = NULL;
}
} else {
if (file->details->monitor != NULL
&& !find_any_monitor (directory, file)) {
nautilus_monitor_cancel (file->details->monitor);
file->details->monitor = NULL;
}
}
update_metadata_monitors (directory);
nautilus_directory_async_state_changed (directory);
......
......@@ -22,18 +22,16 @@
Author: Darin Adler <darin@eazel.com>
*/
#include "nautilus-directory-metafile-monitor.h"
#include "nautilus-directory.h"
#include <libgnomevfs/gnome-vfs-types.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-file-info.h>
#include <gnome-xml/tree.h>
#include "nautilus-file.h"
#include <eel/eel-vfs-extensions.h>
#include "nautilus-directory-metafile-monitor.h"
#include "nautilus-metafile-server.h"
#include "nautilus-monitor.h"
#include <eel/eel-vfs-extensions.h>
#include <gnome-xml/tree.h>
#include <libgnomevfs/gnome-vfs-file-info.h>
#include <libgnomevfs/gnome-vfs-types.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libnautilus/nautilus-idle-queue.h>
typedef struct ActivationURIReadState ActivationURIReadState;
......@@ -56,6 +54,8 @@ struct NautilusDirectoryDetails
GList *call_when_ready_list;
GList *monitor_list;
NautilusMonitor *monitor;
NautilusIdleQueue *idle_queue;
NautilusMetafileMonitor *metafile_monitor;
Nautilus_Metafile metafile_corba_object;
......
......@@ -170,6 +170,10 @@ nautilus_directory_destroy (GtkObject *object)
eel_g_list_free_deep (directory->details->monitor_list);
}
if (directory->details->monitor != NULL) {
nautilus_monitor_cancel (directory->details->monitor);
}
if (directory->details->metafile_monitor != NULL) {
nautilus_directory_unregister_metadata_monitor (directory);
}
......
......@@ -22,8 +22,9 @@
Author: Darin Adler <darin@eazel.com>
*/
#include "nautilus-file.h"
#include "nautilus-directory.h"
#include "nautilus-file.h"
#include "nautilus-monitor.h"
#include <eel/eel-glib-extensions.h>
#define NAUTILUS_FILE_TOP_LEFT_TEXT_MAXIMUM_CHARACTERS_PER_LINE 80
......@@ -48,14 +49,12 @@ struct NautilusFileDetails
{
NautilusDirectory *directory;
char *relative_uri;
/* Set by the NautilusDirectory while it's loading the file
* list so the file knows not to do redundant I/O.
*/
GnomeVFSFileInfo *info;
GnomeVFSResult get_info_error;
NautilusMonitor *monitor;
guint directory_count;
guint deep_directory_count;
......@@ -83,6 +82,9 @@ struct NautilusFileDetails
eel_boolean_bit unconfirmed : 1;
eel_boolean_bit is_gone : 1;
/* Set by the NautilusDirectory while it's loading the file
* list so the file knows not to do redundant I/O.
*/
eel_boolean_bit loading_directory : 1;
/* got_info known from info field being non-NULL */
eel_boolean_bit get_info_failed : 1;
......@@ -92,7 +94,7 @@ struct NautilusFileDetails
eel_boolean_bit directory_count_failed : 1;
eel_boolean_bit directory_count_is_up_to_date : 1;
NautilusRequestStatus deep_counts_status : 2;
NautilusRequestStatus deep_counts_status : 2;
/* no deep_counts_are_up_to_date field; since we expose
intermediate values for this attribute, we do actually
forget it rather than invalidating. */
......
......@@ -413,6 +413,10 @@ destroy (GtkObject *object)
g_assert (file->details->operations_in_progress == NULL);
if (file->details->monitor != NULL) {
nautilus_monitor_cancel (file->details->monitor);
}
nautilus_async_destroying_file (file);
remove_from_link_hash_table (file);
......
......@@ -81,7 +81,7 @@ get_request_hash_table (void)
if (table == NULL) {
table = eel_g_hash_table_new_free_at_exit
(NULL, NULL, "FAM hash table");
(NULL, NULL, "nautilus-monitor.c: FAM requests");
}
return table;
}
......@@ -104,7 +104,7 @@ get_event_uri (const FAMEvent *event)
* notification and tack that on.
*/
base_path = g_hash_table_lookup (get_request_hash_table (),
GINT_TO_POINTER (event->fr.reqnum));
GINT_TO_POINTER (FAMREQUEST_GETREQNUM (&event->fr)));
g_return_val_if_fail (base_path != NULL, NULL);
path = g_concat_dir_and_file (base_path, event->filename);
uri = gnome_vfs_get_uri_from_local_path (path);
......@@ -139,7 +139,6 @@ process_fam_notifications (gpointer callback_data, int fd, GdkInputCondition con
if (uri == NULL) {
break;
}
g_message ("FAMChanged: %s", uri);
nautilus_file_changes_queue_file_changed (uri);
g_free (uri);
break;
......@@ -149,7 +148,6 @@ process_fam_notifications (gpointer callback_data, int fd, GdkInputCondition con
if (uri == NULL) {
break;
}
g_message ("FAMDeleted: %s", uri);
nautilus_file_changes_queue_file_removed (uri);
g_free (uri);
break;
......@@ -159,7 +157,6 @@ process_fam_notifications (gpointer callback_data, int fd, GdkInputCondition con
if (uri == NULL) {
break;
}
g_message ("FAMCreated: %s", uri);
nautilus_file_changes_queue_file_added (uri);
g_free (uri);
break;
......@@ -211,6 +208,8 @@ process_fam_notifications (gpointer callback_data, int fd, GdkInputCondition con
break;
}
}
nautilus_file_changes_consume_changes (TRUE);
}
#endif /* HAVE_FAM_H */
......@@ -240,9 +239,6 @@ nautilus_monitor_file (const char *uri)
g_free (path);
g_message ("ADDED: %d) file monitor for %s",
monitor->request.reqnum, path);
return monitor;
#endif
}
......@@ -273,15 +269,12 @@ nautilus_monitor_directory (const char *uri)
FAMMonitorDirectory (connection, path, &monitor->request, NULL);
g_assert (g_hash_table_lookup (get_request_hash_table (),
GINT_TO_POINTER (monitor->request.reqnum)) == NULL);
GINT_TO_POINTER (FAMREQUEST_GETREQNUM (&monitor->request))) == NULL);
g_hash_table_insert (get_request_hash_table (),
GINT_TO_POINTER (monitor->request.reqnum),
GINT_TO_POINTER (FAMREQUEST_GETREQNUM (&monitor->request)),
path);
g_message ("ADDED: %d) directory monitor for %s",
monitor->request.reqnum, path);
return monitor;
#endif
}
......@@ -300,21 +293,17 @@ nautilus_monitor_cancel (NautilusMonitor *monitor)
return;
}
reqnum = monitor->request.reqnum;
reqnum = FAMREQUEST_GETREQNUM (&monitor->request);
path = g_hash_table_lookup (get_request_hash_table (),
GINT_TO_POINTER (reqnum));
g_hash_table_remove (get_request_hash_table (),
GINT_TO_POINTER (reqnum));
g_free (path);
connection = get_fam_connection ();
g_return_if_fail (connection != NULL);
FAMCancelMonitor (connection, &monitor->request);
g_free (monitor);
g_message ("REMOVED: %d) directory monitor for %s",
reqnum, path);
g_free (path);
#endif
}
......@@ -431,20 +431,43 @@ find_monitor (NautilusDirectory *directory,
NautilusFile *file,
gconstpointer client)
{
GList *result;
Monitor *monitor;
Monitor monitor;
monitor = g_new0 (Monitor, 1);
monitor->client = client;
monitor->file = file;
monitor.client = client;
monitor.file = file;
return g_list_find_custom (directory->details->monitor_list,
&monitor,
monitor_key_compare);
}
result = g_list_find_custom (directory->details->monitor_list,
monitor,
monitor_key_compare);
static int
monitor_file_compare (gconstpointer a,
gconstpointer data)
{
const Monitor *monitor;
NautilusFile *file;
g_free (monitor);
monitor = a;
file = (NautilusFile *) data;
return result;
if (monitor->file < file) {
return -1;
}
if (monitor->file > file) {
return +1;
}
return 0;
}
static gboolean
find_any_monitor (NautilusDirectory *directory,
NautilusFile *file)
{
return g_list_find_custom (directory->details->monitor_list,
file,
monitor_file_compare) != NULL;
}
static void
......@@ -573,6 +596,7 @@ nautilus_directory_monitor_add_internal (NautilusDirectory *directory,
{
Monitor *monitor;
GList *file_list;
char *file_uri;
g_assert (NAUTILUS_IS_DIRECTORY (directory));
......@@ -604,13 +628,26 @@ nautilus_directory_monitor_add_internal (NautilusDirectory *directory,
}
}
/* Start the "real" monitoring (FAM or whatever). */
if (file == NULL) {
if (directory->details->monitor == NULL) {
directory->details->monitor = nautilus_monitor_directory (directory->details->uri);
}
} else {
if (file->details->monitor == NULL) {
file_uri = nautilus_file_get_uri (file);
file->details->monitor = nautilus_monitor_file (file_uri);
g_free (file_uri);
}
}
/* We could just call update_metadata_monitors here, but we can be smarter
* since we know what monitor was just added.
*/
if (monitor->request.metafile && directory->details->metafile_monitor == NULL) {
nautilus_directory_register_metadata_monitor (directory);
}
/* Kick off I/O. */
nautilus_directory_async_state_changed (directory);
}
......@@ -1029,6 +1066,20 @@ nautilus_directory_monitor_remove_internal (NautilusDirectory *directory,
remove_monitor (directory, file, client);
if (file == NULL) {
if (directory->details->monitor != NULL
&& !find_any_monitor (directory, NULL)) {
nautilus_monitor_cancel (directory->details->monitor);
directory->details->monitor = NULL;
}
} else {
if (file->details->monitor != NULL
&& !find_any_monitor (directory, file)) {
nautilus_monitor_cancel (file->details->monitor);
file->details->monitor = NULL;
}
}
update_metadata_monitors (directory);
nautilus_directory_async_state_changed (directory);
......
......@@ -22,18 +22,16 @@
Author: Darin Adler <darin@eazel.com>
*/
#include "nautilus-directory-metafile-monitor.h"
#include "nautilus-directory.h"
#include <libgnomevfs/gnome-vfs-types.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-file-info.h>
#include <gnome-xml/tree.h>
#include "nautilus-file.h"
#include <eel/eel-vfs-extensions.h>
#include "nautilus-directory-metafile-monitor.h"
#include "nautilus-metafile-server.h"
#include "nautilus-monitor.h"
#include <eel/eel-vfs-extensions.h>
#include <gnome-xml/tree.h>
#include <libgnomevfs/gnome-vfs-file-info.h>
#include <libgnomevfs/gnome-vfs-types.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libnautilus/nautilus-idle-queue.h>
typedef struct ActivationURIReadState ActivationURIReadState;
......@@ -56,6 +54,8 @@ struct NautilusDirectoryDetails
GList *call_when_ready_list;
GList *monitor_list;
NautilusMonitor *monitor;
NautilusIdleQueue *idle_queue;
NautilusMetafileMonitor *metafile_monitor;
Nautilus_Metafile metafile_corba_object;
......
......@@ -170,6 +170,10 @@ nautilus_directory_destroy (GtkObject *object)
eel_g_list_free_deep (directory->details->monitor_list);
}
if (directory->details->monitor != NULL) {
nautilus_monitor_cancel (directory->details->monitor);
}
if (directory->details->metafile_monitor != NULL) {
nautilus_directory_unregister_metadata_monitor (directory);
}
......
......@@ -22,8 +22,9 @@
Author: Darin Adler <darin@eazel.com>
*/
#include "nautilus-file.h"
#include "nautilus-directory.h"
#include "nautilus-file.h"
#include "nautilus-monitor.h"
#include <eel/eel-glib-extensions.h>
#define NAUTILUS_FILE_TOP_LEFT_TEXT_MAXIMUM_CHARACTERS_PER_LINE 80
......@@ -48,14 +49,12 @@ struct NautilusFileDetails
{
NautilusDirectory *directory;
char *relative_uri;
/* Set by the NautilusDirectory while it's loading the file
* list so the file knows not to do redundant I/O.
*/
GnomeVFSFileInfo *info;
GnomeVFSResult get_info_error;
NautilusMonitor *monitor;
guint directory_count;
guint deep_directory_count;
......@@ -83,6 +82,9 @@ struct NautilusFileDetails
eel_boolean_bit unconfirmed : 1;
eel_boolean_bit is_gone : 1;
/* Set by the NautilusDirectory while it's loading the file
* list so the file knows not to do redundant I/O.
*/
eel_boolean_bit loading_directory : 1;
/* got_info known from info field being non-NULL */
eel_boolean_bit get_info_failed : 1;
......@@ -92,7 +94,7 @@ struct NautilusFileDetails
eel_boolean_bit directory_count_failed : 1;
eel_boolean_bit directory_count_is_up_to_date : 1;
NautilusRequestStatus deep_counts_status : 2;
NautilusRequestStatus deep_counts_status : 2;
/* no deep_counts_are_up_to_date field; since we expose
intermediate values for this attribute, we do actually
forget it rather than invalidating. */
......
......@@ -413,6 +413,10 @@ destroy (GtkObject *object)
g_assert (file->details->operations_in_progress == NULL);
if (file->details->monitor != NULL) {
nautilus_monitor_cancel (file->details->monitor);
}
nautilus_async_destroying_file (file);
remove_from_link_hash_table (file);
......
......@@ -81,7 +81,7 @@ get_request_hash_table (void)
if (table == NULL) {
table = eel_g_hash_table_new_free_at_exit
(NULL, NULL, "FAM hash table");
(NULL, NULL, "nautilus-monitor.c: FAM requests");
}
return table;
}
......@@ -104,7 +104,7 @@ get_event_uri (const FAMEvent *event)
* notification and tack that on.
*/
base_path = g_hash_table_lookup (get_request_hash_table (),
GINT_TO_POINTER (event->fr.reqnum));
GINT_TO_POINTER (FAMREQUEST_GETREQNUM (&event->fr)));
g_return_val_if_fail (base_path != NULL, NULL);
path = g_concat_dir_and_file (base_path, event->filename);
uri = gnome_vfs_get_uri_from_local_path (path);
......@@ -139,7 +139,6 @@ process_fam_notifications (gpointer callback_data, int fd, GdkInputCondition con
if (uri == NULL) {
break;
}
g_message ("FAMChanged: %s", uri);
nautilus_file_changes_queue_file_changed (uri);
g_free (uri);
break;
......@@ -149,7 +148,6 @@ process_fam_notifications (gpointer callback_data, int fd, GdkInputCondition con
if (uri == NULL) {
break;
}
g_message ("FAMDeleted: %s", uri);
nautilus_file_changes_queue_file_removed (uri);
g_free (uri);
break;
......@@ -159,7 +157,6 @@ process_fam_notifications (gpointer callback_data, int fd, GdkInputCondition con
if (uri == NULL) {
break;
}
g_message ("FAMCreated: %s", uri);
nautilus_file_changes_queue_file_added (uri);
g_free (uri);
break;
......@@ -211,6 +208,8 @@ process_fam_notifications (gpointer callback_data, int fd, GdkInputCondition con
break;
}
}
nautilus_file_changes_consume_changes (TRUE);
}
#endif /* HAVE_FAM_H */
......@@ -240,9 +239,6 @@ nautilus_monitor_file (const char *uri)
g_free (path);
g_message ("ADDED: %d) file monitor for %s",
monitor->request.reqnum, path);
return monitor;
#endif
}
......@@ -273,15 +269,12 @@ nautilus_monitor_directory (const char *uri)
FAMMonitorDirectory (connection, path, &monitor->request, NULL);
g_assert (g_hash_table_lookup (get_request_hash_table (),
GINT_TO_POINTER (monitor->request.reqnum)) == NULL);
GINT_TO_POINTER (FAMREQUEST_GETREQNUM (&monitor->request))) == NULL);
g_hash_table_insert (get_request_hash_table (),
GINT_TO_POINTER (monitor->request.reqnum),
GINT_TO_POINTER (FAMREQUEST_GETREQNUM (&monitor->request)),
path);
g_message ("ADDED: %d) directory monitor for %s",
monitor->request.reqnum, path);
return monitor;
#endif
}
......@@ -300,21 +293,17 @@ nautilus_monitor_cancel (NautilusMonitor *monitor)
return;
}
reqnum = monitor->request.reqnum;
reqnum = FAMREQUEST_GETREQNUM (&monitor->request);
path = g_hash_table_lookup (get_request_hash_table (),
GINT_TO_POINTER (reqnum));
g_hash_table_remove (get_request_hash_table (),
GINT_TO_POINTER (reqnum));
g_free (path);
connection = get_fam_connection ();
g_return_if_fail (connection != NULL);
FAMCancelMonitor (connection, &monitor->request);
g_free (monitor);
g_message ("REMOVED: %d) directory monitor for %s",
reqnum, path);
g_free (path);
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment