[no subject]



The code:

Index: libgnomevfs/gnome-vfs-async-ops.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-async-ops.c,v
retrieving revision 1.6
diff -u -p -r1.6 gnome-vfs-async-ops.c
--- libgnomevfs/gnome-vfs-async-ops.c	24 Jul 2002 08:06:35 -0000	1.6
+++ libgnomevfs/gnome-vfs-async-ops.c	8 Nov 2002 16:15:48 -0000
@@ -950,6 +950,39 @@ gnome_vfs_async_xfer (GnomeVFSAsyncHandl
 	return GNOME_VFS_OK;
 }
 
+void
+gnome_vfs_async_file_control (GnomeVFSAsyncHandle *handle,
+			      const char *operation,
+			      gpointer operation_data,
+			      GnomeVFSAsyncFileControlCallback callback,
+			      gpointer callback_data)
+{
+	GnomeVFSJob *job;
+	GnomeVFSFileControlOp *file_control_op;
+
+	g_return_if_fail (handle != NULL);
+	g_return_if_fail (operation != NULL);
+	g_return_if_fail (callback != NULL);
+
+	gnome_vfs_async_job_map_lock ();
+	job = gnome_vfs_async_job_map_get_job (handle);
+	if (job == NULL) {
+		g_warning ("trying to call file_control on a non-existing handle");
+		gnome_vfs_async_job_map_unlock ();
+		return;
+	}
+
+	gnome_vfs_job_set (job, GNOME_VFS_OP_FILE_CONTROL,
+			   (GFunc) callback, callback_data);
+
+	file_control_op = &job->op->specifics.file_control;
+	file_control_op->operation = g_strdup (operation);
+	file_control_op->operation_data = operation_data;
+
+	gnome_vfs_job_go (job);
+	gnome_vfs_async_job_map_unlock ();
+}
+
 #ifdef OLD_CONTEXT_DEPRECATED
 
 guint
Index: libgnomevfs/gnome-vfs-async-ops.h
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-async-ops.h,v
retrieving revision 1.33
diff -u -p -r1.33 gnome-vfs-async-ops.h
--- libgnomevfs/gnome-vfs-async-ops.h	26 Jun 2002 19:26:43 -0000	1.33
+++ libgnomevfs/gnome-vfs-async-ops.h	8 Nov 2002 16:15:48 -0000
@@ -271,6 +271,10 @@ typedef void    (* GnomeVFSAsyncFindDire
 						 GList *results /* GnomeVFSFindDirectoryResult */,
 						 gpointer data);
 
+typedef void	(* GnomeVFSAsyncFileControlCallback)	(GnomeVFSAsyncHandle *handle,
+							 GnomeVFSResult result,
+							 gpointer operation_data,
+							 gpointer callback_data);
 
 void           gnome_vfs_async_cancel                 (GnomeVFSAsyncHandle                   *handle);
 
@@ -407,6 +411,12 @@ void           gnome_vfs_async_find_dire
 						       int				      priority,
 						       GnomeVFSAsyncFindDirectoryCallback     callback,
 						       gpointer                               user_data);
+
+void           gnome_vfs_async_file_control           (GnomeVFSAsyncHandle                   *handle,
+						       const char                            *operation,
+						       gpointer                               operation_data,
+						       GnomeVFSAsyncFileControlCallback       callback,
+						       gpointer                               callback_data);
 
 G_END_DECLS
 
Index: libgnomevfs/gnome-vfs-cancellable-ops.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-cancellable-ops.c,v
retrieving revision 1.27
diff -u -p -r1.27 gnome-vfs-cancellable-ops.c
--- libgnomevfs/gnome-vfs-cancellable-ops.c	28 Jul 2002 06:56:46 -0000	1.27
+++ libgnomevfs/gnome-vfs-cancellable-ops.c	8 Nov 2002 16:15:48 -0000
@@ -429,3 +429,19 @@ gnome_vfs_set_file_info_cancellable (Gno
 
 	return a->method->set_file_info (a->method, a, info, mask, context);
 }
+
+GnomeVFSResult
+gnome_vfs_file_control_cancellable (GnomeVFSHandle *handle,
+				    const char *operation,
+				    gpointer operation_data,
+				    GnomeVFSContext *context)
+{
+	g_return_val_if_fail (handle != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
+	g_return_val_if_fail (operation != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
+
+	if (gnome_vfs_context_check_cancellation (context))
+		return GNOME_VFS_ERROR_CANCELLED;
+
+	return gnome_vfs_handle_do_file_control (handle, operation, operation_data, context);
+}
+
Index: libgnomevfs/gnome-vfs-cancellable-ops.h
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-cancellable-ops.h,v
retrieving revision 1.19
diff -u -p -r1.19 gnome-vfs-cancellable-ops.h
--- libgnomevfs/gnome-vfs-cancellable-ops.h	22 Aug 2001 08:04:40 -0000	1.19
+++ libgnomevfs/gnome-vfs-cancellable-ops.h	8 Nov 2002 16:15:48 -0000
@@ -152,6 +152,12 @@ GnomeVFSResult  gnome_vfs_directory_open
 					 GnomeVFSFileInfoOptions options,
 					 GnomeVFSContext *context);
 
+GnomeVFSResult  gnome_vfs_file_control_cancellable
+                                        (GnomeVFSHandle *handle,
+					 const char *operation,
+					 gpointer operation_data,
+					 GnomeVFSContext *context);
+
 G_END_DECLS
 
 #endif /* GNOME_VFS_CANCELLABLE_OPS_H */
Index: libgnomevfs/gnome-vfs-handle-private.h
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-handle-private.h,v
retrieving revision 1.1
diff -u -p -r1.1 gnome-vfs-handle-private.h
--- libgnomevfs/gnome-vfs-handle-private.h	16 Jun 2002 07:33:26 -0000	1.1
+++ libgnomevfs/gnome-vfs-handle-private.h	8 Nov 2002 16:15:48 -0000
@@ -61,6 +61,10 @@ GnomeVFSResult   gnome_vfs_handle_do_get
 GnomeVFSResult   gnome_vfs_handle_do_truncate        (GnomeVFSHandle          *handle,
 						      GnomeVFSFileSize         length,
 						      GnomeVFSContext         *context);
+GnomeVFSResult   gnome_vfs_handle_do_file_control    (GnomeVFSHandle          *handle,
+						      const char              *operation,
+						      gpointer                 operation_data,
+						      GnomeVFSContext         *context);
 
 G_END_DECLS
 
Index: libgnomevfs/gnome-vfs-handle.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-handle.c,v
retrieving revision 1.21
diff -u -p -r1.21 gnome-vfs-handle.c
--- libgnomevfs/gnome-vfs-handle.c	16 Jun 2002 07:33:26 -0000	1.21
+++ libgnomevfs/gnome-vfs-handle.c	8 Nov 2002 16:15:48 -0000
@@ -183,3 +183,12 @@ GnomeVFSResult gnome_vfs_handle_do_trunc
 {
 	INVOKE_AND_RETURN (handle, truncate_handle, (handle->uri->method, handle->method_handle, length, context));
 }
+
+GnomeVFSResult
+gnome_vfs_handle_do_file_control  (GnomeVFSHandle          *handle,
+				   const char              *operation,
+				   gpointer                 operation_data,
+				   GnomeVFSContext         *context)
+{
+	INVOKE_AND_RETURN (handle, file_control, (handle->uri->method, handle->method_handle, operation, operation_data, context));
+}
Index: libgnomevfs/gnome-vfs-job.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-job.c,v
retrieving revision 1.89
diff -u -p -r1.89 gnome-vfs-job.c
--- libgnomevfs/gnome-vfs-job.c	10 Sep 2002 03:31:11 -0000	1.89
+++ libgnomevfs/gnome-vfs-job.c	8 Nov 2002 16:15:48 -0000
@@ -131,6 +131,7 @@ gnome_vfs_job_complete (GnomeVFSJob *job
 		g_assert_not_reached();
 		return FALSE;
 	case GNOME_VFS_OP_READ_WRITE_DONE:
+	case GNOME_VFS_OP_FILE_CONTROL:
 		return FALSE;
 	
 	default:
@@ -314,6 +315,15 @@ dispatch_module_callback (GnomeVFSNotify
 }
 
 static void
+dispatch_file_control_callback (GnomeVFSNotifyResult *notify_result)
+{
+	notify_result->specifics.file_control.callback (notify_result->job_handle,
+							notify_result->specifics.file_control.result,
+							notify_result->specifics.file_control.operation_data,
+							notify_result->specifics.file_control.callback_data);
+}
+
+static void
 empty_close_callback (GnomeVFSAsyncHandle *handle,
 		      GnomeVFSResult result,
 		      gpointer callback_data)
@@ -377,6 +387,7 @@ gnome_vfs_job_destroy_notify_result (Gno
 	case GNOME_VFS_OP_OPEN_AS_CHANNEL:
 	case GNOME_VFS_OP_READ:
 	case GNOME_VFS_OP_XFER:
+	case GNOME_VFS_OP_FILE_CONTROL:
 		g_free (notify_result);
 		break;
 		
@@ -559,6 +570,9 @@ dispatch_job_callback (gpointer data)
 	case GNOME_VFS_OP_WRITE:
 		dispatch_write_callback (notify_result);
 		break;
+	case GNOME_VFS_OP_FILE_CONTROL:
+		dispatch_file_control_callback (notify_result);
+		break;
 	default:
 		g_assert_not_reached ();
 		break;
@@ -703,6 +717,9 @@ gnome_vfs_op_destroy (GnomeVFSOp *op)
 	case GNOME_VFS_OP_CLOSE:
 	case GNOME_VFS_OP_READ_WRITE_DONE:
 		break;
+	case GNOME_VFS_OP_FILE_CONTROL:
+		g_free (op->specifics.file_control.operation);
+		break;
 	default:
 		g_warning (_("Unknown op type %u"), op->type);
 	}
@@ -1536,6 +1553,32 @@ execute_xfer (GnomeVFSJob *job)
 	}
 }
 
+static void
+execute_file_control (GnomeVFSJob *job)
+{
+	GnomeVFSFileControlOp *file_control_op;
+	GnomeVFSNotifyResult *notify_result;
+	
+	file_control_op = &job->op->specifics.file_control;
+
+	notify_result = g_new0 (GnomeVFSNotifyResult, 1);
+	notify_result->job_handle = job->job_handle;
+	notify_result->type = job->op->type;
+	notify_result->specifics.file_control.callback = (GnomeVFSAsyncFileControlCallback) job->op->callback;
+	notify_result->specifics.file_control.callback_data = job->op->callback_data;
+	notify_result->specifics.file_control.operation_data = file_control_op->operation_data;
+	
+	notify_result->specifics.file_control.result = gnome_vfs_file_control_cancellable (job->handle,
+											   file_control_op->operation,
+											   file_control_op->operation_data,
+											   job->op->context);
+
+	job->op->type = GNOME_VFS_OP_FILE_CONTROL;
+
+	job_oneway_notify (job, notify_result);
+}
+
+
 /*
  * gnome_vfs_job_execute:
  * @job: the job to execute
@@ -1596,6 +1639,9 @@ gnome_vfs_job_execute (GnomeVFSJob *job)
 			break;
 		case GNOME_VFS_OP_SET_FILE_INFO:
 			execute_set_file_info (job);
+			break;
+		case GNOME_VFS_OP_FILE_CONTROL:
+			execute_file_control (job);
 			break;
 		default:
 			g_warning (_("Unknown job kind %u"), job->op->type);
Index: libgnomevfs/gnome-vfs-job.h
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-job.h,v
retrieving revision 1.45
diff -u -p -r1.45 gnome-vfs-job.h
--- libgnomevfs/gnome-vfs-job.h	24 Jul 2002 08:06:35 -0000	1.45
+++ libgnomevfs/gnome-vfs-job.h	8 Nov 2002 16:15:48 -0000
@@ -91,7 +91,8 @@ enum GnomeVFSOpType {
 	/* This is not a real OpType; its intended to mark
 	 * GnomeVFSAsyncModuleCallback's in the job_callback queue
 	 */
-	GNOME_VFS_OP_MODULE_CALLBACK
+	GNOME_VFS_OP_MODULE_CALLBACK,
+	GNOME_VFS_OP_FILE_CONTROL
 };
 
 typedef enum GnomeVFSOpType GnomeVFSOpType;
@@ -272,6 +273,18 @@ typedef struct {
 	gpointer                       response_data;
 } GnomeVFSModuleCallbackOpResult;
 
+typedef struct {
+	char *operation;
+	gpointer operation_data;
+} GnomeVFSFileControlOp;
+
+typedef struct {
+	GnomeVFSAsyncFileControlCallback callback;
+	gpointer callback_data;
+	GnomeVFSResult result;
+	gpointer operation_data;
+} GnomeVFSFileControlOpResult;
+
 typedef union {
 	GnomeVFSOpenOp open;
 	GnomeVFSOpenAsChannelOp open_as_channel;
@@ -286,6 +299,7 @@ typedef union {
 	GnomeVFSGetFileInfoOp get_file_info;
 	GnomeVFSSetFileInfoOp set_file_info;
 	GnomeVFSFindDirectoryOp find_directory;
+	GnomeVFSFileControlOp file_control;
 } GnomeVFSSpecificOp;
 
 typedef struct {
@@ -318,6 +332,7 @@ typedef union {
 	GnomeVFSLoadDirectoryOpResult load_directory;
 	GnomeVFSXferOpResult xfer;
 	GnomeVFSModuleCallbackOpResult callback;
+	GnomeVFSFileControlOpResult file_control;
 } GnomeVFSSpecificNotifyResult;
 
 typedef struct {
Index: libgnomevfs/gnome-vfs-method.h
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-method.h,v
retrieving revision 1.12
diff -u -p -r1.12 gnome-vfs-method.h
--- libgnomevfs/gnome-vfs-method.h	12 Feb 2002 14:33:43 -0000	1.12
+++ libgnomevfs/gnome-vfs-method.h	8 Nov 2002 16:15:48 -0000
@@ -208,6 +208,13 @@ typedef GnomeVFSResult (* GnomeVFSMethod
      					(GnomeVFSMethod *method,
       					 GnomeVFSMethodHandle *handle);
 
+typedef GnomeVFSResult (* GnomeVFSMethodFileControlFunc)
+     					(GnomeVFSMethod *method,
+      					 GnomeVFSMethodHandle *method_handle,
+					 const char *operation,
+					 gpointer operation_data,
+					 GnomeVFSContext *context);
+
 
 
 /* Use this macro to test whether a given function is implemented in
@@ -246,6 +253,7 @@ struct GnomeVFSMethod {
 	GnomeVFSMethodCreateSymbolicLinkFunc create_symbolic_link;
 	GnomeVFSMethodMonitorAddFunc monitor_add;
 	GnomeVFSMethodMonitorCancelFunc monitor_cancel;
+	GnomeVFSMethodFileControlFunc file_control;
 };
 
 gboolean	   gnome_vfs_method_init   (void);
Index: libgnomevfs/gnome-vfs-ops.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-ops.c,v
retrieving revision 1.34
diff -u -p -r1.34 gnome-vfs-ops.c
--- libgnomevfs/gnome-vfs-ops.c	16 Jun 2002 23:43:34 -0000	1.34
+++ libgnomevfs/gnome-vfs-ops.c	8 Nov 2002 16:15:49 -0000
@@ -786,3 +786,11 @@ gnome_vfs_monitor_cancel (GnomeVFSMonito
 	return gnome_vfs_monitor_do_cancel (handle);
 }
 
+GnomeVFSResult
+gnome_vfs_file_control (GnomeVFSHandle *handle,
+			const char *operation,
+			gpointer operation_data)
+{
+	return gnome_vfs_file_control_cancellable (handle, operation, operation_data, NULL);
+}
+
Index: libgnomevfs/gnome-vfs-ops.h
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-ops.h,v
retrieving revision 1.24
diff -u -p -r1.24 gnome-vfs-ops.h
--- libgnomevfs/gnome-vfs-ops.h	16 Jun 2002 05:02:41 -0000	1.24
+++ libgnomevfs/gnome-vfs-ops.h	8 Nov 2002 16:15:49 -0000
@@ -137,6 +137,10 @@ GnomeVFSResult gnome_vfs_monitor_add (Gn
 
 GnomeVFSResult gnome_vfs_monitor_cancel (GnomeVFSMonitorHandle *handle);
 
+GnomeVFSResult gnome_vfs_file_control   (GnomeVFSHandle *handle,
+					 const char *operation,
+					 gpointer operation_data);
+
 G_END_DECLS
 
 #endif /* GNOME_VFS_OPS_H */
Index: modules/file-method.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/modules/file-method.c,v
retrieving revision 1.110
diff -u -p -r1.110 file-method.c
--- modules/file-method.c	29 Oct 2002 13:44:59 -0000	1.110
+++ modules/file-method.c	8 Nov 2002 16:15:49 -0000
@@ -2242,6 +2242,20 @@ do_monitor_cancel (GnomeVFSMethod *metho
 #endif
 }
 
+static GnomeVFSResult
+do_file_control (GnomeVFSMethod *method,
+		 GnomeVFSMethodHandle *method_handle,
+		 const char *operation,
+		 gpointer operation_data,
+		 GnomeVFSContext *context)
+{
+	if (strcmp (operation, "file:test") == 0) {
+		*(char **)operation_data = g_strdup ("test ok");
+		return GNOME_VFS_OK;
+	}
+	return GNOME_VFS_ERROR_NOT_SUPPORTED;
+}
+
 static GnomeVFSMethod method = {
 	sizeof (GnomeVFSMethod),
 	do_open,
@@ -2268,7 +2282,8 @@ static GnomeVFSMethod method = {
 	do_find_directory,
 	do_create_symbolic_link,
 	do_monitor_add,
-	do_monitor_cancel
+	do_monitor_cancel,
+	do_file_control
 };
 
 GnomeVFSMethod *
Index: test/test-async.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/test/test-async.c,v
retrieving revision 1.18
diff -u -p -r1.18 test-async.c
--- test/test-async.c	15 Jul 2002 14:29:19 -0000	1.18
+++ test/test-async.c	8 Nov 2002 16:15:49 -0000
@@ -43,6 +43,24 @@ close_callback (GnomeVFSAsyncHandle *han
 }
 
 static void
+file_control_callback (GnomeVFSAsyncHandle *handle,
+		       GnomeVFSResult result,
+		       gpointer operation_data,
+		       gpointer callback_data)
+{
+	if (result != GNOME_VFS_OK) {
+		fprintf (stderr, "file_control failed: %s\n",
+			 gnome_vfs_result_to_string (result));
+	} else {
+		printf ("file_control result: %s\n", *(char **)operation_data);
+		g_free (operation_data);
+	}
+	
+	fprintf (stderr, "Now closing the file.\n");
+	gnome_vfs_async_close (handle, close_callback, "close");
+}
+
+static void
 read_callback (GnomeVFSAsyncHandle *handle,
 	       GnomeVFSResult result,
                gpointer buffer,
@@ -50,6 +68,8 @@ read_callback (GnomeVFSAsyncHandle *hand
 	       GnomeVFSFileSize bytes_read,
                gpointer callback_data)
 {
+	char **op_data;
+	
 	if (result != GNOME_VFS_OK) {
 		fprintf (stderr, "Read failed: %s\n",
 			 gnome_vfs_result_to_string (result));
@@ -63,8 +83,9 @@ read_callback (GnomeVFSAsyncHandle *hand
 		fprintf (stderr, "%s", (char *) buffer);
 	}
 
-	fprintf (stderr, "Now closing the file.\n");
-	gnome_vfs_async_close (handle, close_callback, "close");
+	fprintf (stderr, "Now testing file_control.\n");
+	op_data = g_new (char *, 1);
+	gnome_vfs_async_file_control (handle, "file:test", op_data, file_control_callback, "file_control");
 }
 
 static void
Index: test/test-sync.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/test/test-sync.c,v
retrieving revision 1.9
diff -u -p -r1.9 test-sync.c
--- test/test-sync.c	3 Aug 2001 19:04:43 -0000	1.9
+++ test/test-sync.c	8 Nov 2002 16:15:49 -0000
@@ -34,7 +34,7 @@ show_result (GnomeVFSResult result, cons
 {
 	fprintf (stderr, "%s `%s': %s\n",
 		 what, text_uri, gnome_vfs_result_to_string (result));
-	if (result != GNOME_VFS_OK)
+	if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF)
 		exit (1);
 }
 
@@ -47,6 +47,7 @@ main (int argc, char **argv)
 	GnomeVFSFileSize  bytes_read;
 	GnomeVFSURI 	 *uri;
 	gchar            *text_uri;
+	gchar            *out;
 
 	if (argc != 2) {
 		printf ("Usage: %s <uri>\n", argv[0]);
@@ -79,6 +80,14 @@ main (int argc, char **argv)
 		if(!bytes_read) break;
 	}
 
+	result = gnome_vfs_file_control (handle, "file:test", &out);
+	show_result (result, "file_control", text_uri);
+	if (result == GNOME_VFS_OK) {
+		g_print ("file_control file:test: %s\n", out);
+	} 
+		
+	
+	
 	result = gnome_vfs_close (handle);
 	show_result (result, "close", text_uri);
 
-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's an impetuous guerilla ex-con who hangs with the wrong crowd. She's a 
vivacious cigar-chomping traffic cop with her own daytime radio talk show. 
They fight crime! 




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