1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
3 /* gnome-vfs-async-ops.h - Asynchronous operations in the GNOME Virtual File
6 Copyright (C) 1999 Free Software Foundation
8 The Gnome Library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version.
13 The Gnome Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
18 You should have received a copy of the GNU Library General Public
19 License along with the Gnome Library; see the file COPYING.LIB. If not,
20 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.
23 Author: Ettore Perazzoli <ettore@comm2000.it> */
25 #ifndef GNOME_VFS_ASYNC_OPS_H
26 #define GNOME_VFS_ASYNC_OPS_H
28 #include <glib/giochannel.h>
29 #include <libgnomevfs/gnome-vfs-file-info.h>
30 #include <libgnomevfs/gnome-vfs-find-directory.h>
31 #include <libgnomevfs/gnome-vfs-handle.h>
32 #include <libgnomevfs/gnome-vfs-xfer.h>
37 * GNOME_VFS_PRIORITY_MIN:
39 * The minimuum priority a job can have.
42 * GNOME_VFS_PRIORITY_MAX:
44 * The maximuum priority a job can have.
47 * GNOME_VFS_PRIORITY_DEFAULT:
49 * The default job priority. Its best to use this
50 * unless you have a reason to do otherwise.
53 #define GNOME_VFS_PRIORITY_MIN -10
54 #define GNOME_VFS_PRIORITY_MAX 10
55 #define GNOME_VFS_PRIORITY_DEFAULT 0
57 typedef struct GnomeVFSAsyncHandle GnomeVFSAsyncHandle;
60 * GnomeVFSAsyncCallback:
61 * @handle: handle of the operation generating the callback
62 * @result: %GNOME_VFS_OK if the operation was successful, otherwise
64 * @callback_data: user data defined when the callback was established
66 * Basic callback from an async operation that passes no data back,
67 * informing the user of the @result of the operation.
69 typedef void (* GnomeVFSAsyncCallback) (GnomeVFSAsyncHandle *handle,
70 GnomeVFSResult result,
71 gpointer callback_data);
74 * GnomeVFSAsyncOpenCallback:
75 * @handle: handle of the operation generating the callback
76 * @result: %GNOME_VFS_OK if the operation was successful, otherwise
78 * @callback_data: user data defined when the callback was established
80 * Basic callback from an async operation that passes no data back,
81 * informing the user of the @result of the operation.
83 typedef GnomeVFSAsyncCallback GnomeVFSAsyncOpenCallback;
86 * GnomeVFSAsyncCreateCallback:
87 * @handle: handle of the operation generating the callback
88 * @result: %GNOME_VFS_OK if the operation was successful, otherwise
90 * @callback_data: user data defined when the callback was established
92 * Basic callback from an async operation that passes no data back,
93 * informing the user of the @result of the operation.
95 typedef GnomeVFSAsyncCallback GnomeVFSAsyncCreateCallback;
98 * GnomeVFSAsyncCloseCallback:
99 * @handle: handle of the operation generating the callback
100 * @result: %GNOME_VFS_OK if the operation was successful, otherwise
102 * @callback_data: user data defined when the callback was established
104 * Basic callback from an async operation that passes no data back,
105 * informing the user of the @result of the operation.
107 typedef GnomeVFSAsyncCallback GnomeVFSAsyncCloseCallback;
110 * GnomeVFSAsyncOpenAsChannelCallback:
111 * @handle: handle of the operation generating the callback
112 * @channel: a #GIOChannel corresponding to the file opened
113 * @result: %GNOME_VFS_OK if the operation was successful, otherwise
115 * @callback_data: user data defined when the callback was established
117 * Callback for the gnome_vfs_async_open_as_channel() function.
119 typedef void (* GnomeVFSAsyncOpenAsChannelCallback)
120 (GnomeVFSAsyncHandle *handle,
122 GnomeVFSResult result,
123 gpointer callback_data);
126 * GnomeVFSAsyncCreateAsChannelCallback:
127 * @handle: handle of the operation generating the callback
128 * @channel: a #GIOChannel corresponding to the file created
129 * @result: %GNOME_VFS_OK if the operation was successful, otherwise
131 * @callback_data: user data defined when the callback was established
133 * Callback for the gnome_vfs_async_create_as_channel() function.
135 typedef GnomeVFSAsyncOpenAsChannelCallback GnomeVFSAsyncCreateAsChannelCallback;
138 * GnomeVFSAsyncReadCallback:
139 * @handle: handle of the operation generating the callback
140 * @result: %GNOME_VFS_OK if the operation was successful, otherwise
142 * @buffer: buffer containing data read from @handle.
143 * @bytes_requested: the number of bytes asked for in the call to
144 * gnome_vfs_async_read().
145 * @bytes_read: the number of bytes actually read from @handle into @buffer.
146 * @callback_data: user data defined when the callback was established
148 * Callback for the gnome_vfs_async_read() function.
150 typedef void (* GnomeVFSAsyncReadCallback) (GnomeVFSAsyncHandle *handle,
151 GnomeVFSResult result,
153 GnomeVFSFileSize bytes_requested,
154 GnomeVFSFileSize bytes_read,
155 gpointer callback_data);
158 * GnomeVFSAsyncWriteCallback:
159 * @handle: handle of the operation generating the callback
160 * @result: %GNOME_VFS_OK if the operation was successful, otherwise
162 * @buffer: buffer containing data written to @handle.
163 * @bytes_requested: the number of bytes asked to write in the call to
164 * gnome_vfs_async_write().
165 * @bytes_written: the number of bytes actually written to @handle from @buffer.
166 * @callback_data: user data defined when the callback was established
168 * Callback for the gnome_vfs_async_write() function.
170 typedef void (* GnomeVFSAsyncWriteCallback) (GnomeVFSAsyncHandle *handle,
171 GnomeVFSResult result,
172 gconstpointer buffer,
173 GnomeVFSFileSize bytes_requested,
174 GnomeVFSFileSize bytes_written,
175 gpointer callback_data);
179 * GnomeVFSAsyncGetFileInfoCallback:
180 * @handle: handle of the operation generating the callback
181 * @results: #GList of #GnomeVFSFileInfoResult * items representing
182 * the success of each gnome_vfs_get_file_info() and the data retrieved.
183 * @callback_data: user data defined when the callback was established
185 * Callback for the gnome_vfs_async_get_file_info() function.
187 typedef void (* GnomeVFSAsyncGetFileInfoCallback)
188 (GnomeVFSAsyncHandle *handle,
189 GList *results, /* GnomeVFSGetFileInfoResult* items */
190 gpointer callback_data);
193 * GnomeVFSAsyncSetFileInfoCallback:
194 * @handle: handle of the operation generating the callback
195 * @result: %GNOME_VFS_OK if the operation was successful, otherwise a
196 * #GnomeVFSResult error code
197 * @file_info: if @result is %GNOME_VFS_OK, a #GnomeVFSFileInfo struct containing
198 * requested information about the file
199 * @callback_data: user data defined when the callback was established
201 * Callback for th egnome_vfs_async_set_file_info() function.
203 typedef void (* GnomeVFSAsyncSetFileInfoCallback)
204 (GnomeVFSAsyncHandle *handle,
205 GnomeVFSResult result,
206 GnomeVFSFileInfo *file_info,
207 gpointer callback_data);
211 * GnomeVFSAsyncDirectoryLoadCallback:
212 * @handle: handle of the operation generating the callback
213 * @result: %GNOME_VFS_OK if the operation was sucessful,
214 * %GNOME_VFS_ERROR_EOF if the last file in the directory
215 * has been read, otherwise a #GnomeVFSResult error code
216 * @list: a #GList of #GnomeVFSFileInfo structs representing
217 * information about the files just loaded
218 * @entries_read: number of entries read from @handle for this instance of
220 * @callback_data: user data defined when the callback was established
222 * Callback for the gnome_vfs_async_directory_load() function.
224 typedef void (* GnomeVFSAsyncDirectoryLoadCallback)
225 (GnomeVFSAsyncHandle *handle,
226 GnomeVFSResult result,
229 gpointer callback_data);
232 * GnomeVFSAsyncXferProgressCallback:
233 * @handle: handle of the xfer operation generating the callback
234 * @info: information on the current progress in the transfer
235 * @data: user data defined when the transfer was established
237 * Callback for the gnome_vfs_async_xfer() function. Called periodically
238 * to update the caller about the status of the transfer (percent complete,
239 * phase of the operation, etc). If @info->status is not %GNOME_VFS_XFER_PROGRESS_STATUS_OK
240 * then the callback is expected to make a "decision" about some problem / query
241 * during the operation. The appropriate #GnomeVFSXferErrorAction or #GnomeVFSOverwriteAction
242 * (depending on the particular state of @info->status) should be returned
243 * informing the transfer engine how to proceed.
245 * Return value: 0 or an item from #GnomeVFSXferErrorAction or #GnomeVFSOverwriteAction
247 typedef gint (* GnomeVFSAsyncXferProgressCallback)
248 (GnomeVFSAsyncHandle *handle,
249 GnomeVFSXferProgressInfo *info,
254 GnomeVFSResult result;
256 /* Reserved to avoid future breaks in ABI compatibility */
259 } GnomeVFSFindDirectoryResult;
262 * GnomeVFSAsyncFindDirectoryCallback:
263 * @handle: handle of the operation generating the callback
264 * @results: #GList of #GnomeVFSFindDirectoryResult *s containing
265 * special directories matching the find criteria.
266 * @data: user data defined when the operation was established
268 * Callback for the gnome_vfs_async_find_directory() function.
270 typedef void (* GnomeVFSAsyncFindDirectoryCallback)
271 (GnomeVFSAsyncHandle *handle,
272 GList *results /* GnomeVFSFindDirectoryResult */,
275 typedef void (* GnomeVFSAsyncFileControlCallback) (GnomeVFSAsyncHandle *handle,
276 GnomeVFSResult result,
277 gpointer operation_data,
278 gpointer callback_data);
280 void gnome_vfs_async_cancel (GnomeVFSAsyncHandle *handle);
282 void gnome_vfs_async_open (GnomeVFSAsyncHandle **handle_return,
283 const gchar *text_uri,
284 GnomeVFSOpenMode open_mode,
286 GnomeVFSAsyncOpenCallback callback,
287 gpointer callback_data);
288 void gnome_vfs_async_open_uri (GnomeVFSAsyncHandle **handle_return,
290 GnomeVFSOpenMode open_mode,
292 GnomeVFSAsyncOpenCallback callback,
293 gpointer callback_data);
294 void gnome_vfs_async_open_as_channel (GnomeVFSAsyncHandle **handle_return,
295 const gchar *text_uri,
296 GnomeVFSOpenMode open_mode,
297 guint advised_block_size,
299 GnomeVFSAsyncOpenAsChannelCallback callback,
300 gpointer callback_data);
301 void gnome_vfs_async_open_uri_as_channel (GnomeVFSAsyncHandle **handle_return,
303 GnomeVFSOpenMode open_mode,
304 guint advised_block_size,
306 GnomeVFSAsyncOpenAsChannelCallback callback,
307 gpointer callback_data);
308 void gnome_vfs_async_create (GnomeVFSAsyncHandle **handle_return,
309 const gchar *text_uri,
310 GnomeVFSOpenMode open_mode,
314 GnomeVFSAsyncOpenCallback callback,
315 gpointer callback_data);
316 void gnome_vfs_async_create_uri (GnomeVFSAsyncHandle **handle_return,
318 GnomeVFSOpenMode open_mode,
322 GnomeVFSAsyncOpenCallback callback,
323 gpointer callback_data);
324 void gnome_vfs_async_create_symbolic_link (GnomeVFSAsyncHandle **handle_return,
326 const gchar *uri_reference,
328 GnomeVFSAsyncOpenCallback callback,
329 gpointer callback_data);
330 void gnome_vfs_async_create_as_channel (GnomeVFSAsyncHandle **handle_return,
331 const gchar *text_uri,
332 GnomeVFSOpenMode open_mode,
336 GnomeVFSAsyncCreateAsChannelCallback callback,
337 gpointer callback_data);
338 void gnome_vfs_async_create_uri_as_channel (GnomeVFSAsyncHandle **handle_return,
340 GnomeVFSOpenMode open_mode,
344 GnomeVFSAsyncCreateAsChannelCallback callback,
345 gpointer callback_data);
346 void gnome_vfs_async_close (GnomeVFSAsyncHandle *handle,
347 GnomeVFSAsyncCloseCallback callback,
348 gpointer callback_data);
349 void gnome_vfs_async_read (GnomeVFSAsyncHandle *handle,
352 GnomeVFSAsyncReadCallback callback,
353 gpointer callback_data);
354 void gnome_vfs_async_write (GnomeVFSAsyncHandle *handle,
355 gconstpointer buffer,
357 GnomeVFSAsyncWriteCallback callback,
358 gpointer callback_data);
359 void gnome_vfs_async_get_file_info (GnomeVFSAsyncHandle **handle_return,
361 GnomeVFSFileInfoOptions options,
363 GnomeVFSAsyncGetFileInfoCallback callback,
364 gpointer callback_data);
366 /* Setting the file info sometimes changes more info than the
367 * caller specified; for example, if the name changes the MIME type might
368 * change, and if the owner changes the SUID & SGID bits might change.
369 * Therefore the callback returns the new file info for the caller's
370 * convenience. The GnomeVFSFileInfoOptions passed here are those used
371 * for the returned file info; they are not used when setting.
373 void gnome_vfs_async_set_file_info (GnomeVFSAsyncHandle **handle_return,
375 GnomeVFSFileInfo *info,
376 GnomeVFSSetFileInfoMask mask,
377 GnomeVFSFileInfoOptions options,
379 GnomeVFSAsyncSetFileInfoCallback callback,
380 gpointer callback_data);
381 void gnome_vfs_async_load_directory (GnomeVFSAsyncHandle **handle_return,
382 const gchar *text_uri,
383 GnomeVFSFileInfoOptions options,
384 guint items_per_notification,
386 GnomeVFSAsyncDirectoryLoadCallback callback,
387 gpointer callback_data);
388 void gnome_vfs_async_load_directory_uri (GnomeVFSAsyncHandle **handle_return,
390 GnomeVFSFileInfoOptions options,
391 guint items_per_notification,
393 GnomeVFSAsyncDirectoryLoadCallback callback,
394 gpointer callback_data);
395 GnomeVFSResult gnome_vfs_async_xfer (GnomeVFSAsyncHandle **handle_return,
396 GList *source_uri_list,
397 GList *target_uri_list,
398 GnomeVFSXferOptions xfer_options,
399 GnomeVFSXferErrorMode error_mode,
400 GnomeVFSXferOverwriteMode overwrite_mode,
402 GnomeVFSAsyncXferProgressCallback progress_update_callback,
403 gpointer update_callback_data,
404 GnomeVFSXferProgressCallback progress_sync_callback,
405 gpointer sync_callback_data);
406 void gnome_vfs_async_find_directory (GnomeVFSAsyncHandle **handle_return,
407 GList *near_uri_list,
408 GnomeVFSFindDirectoryKind kind,
409 gboolean create_if_needed,
410 gboolean find_if_needed,
413 GnomeVFSAsyncFindDirectoryCallback callback,
416 void gnome_vfs_async_file_control (GnomeVFSAsyncHandle *handle,
417 const char *operation,
418 gpointer operation_data,
419 GDestroyNotify operation_data_destroy_func,
420 GnomeVFSAsyncFileControlCallback callback,
421 gpointer callback_data);
425 #endif /* GNOME_VFS_ASYNC_OPS_H */