1/* GIO - GLib Input, Output and Streaming Library
2 *
3 * Copyright (C) 2006-2007 Red Hat, Inc.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 *
18 * Author: Alexander Larsson <alexl@redhat.com>
19 */
20
21#ifndef __G_VFS_H__
22#define __G_VFS_H__
23
24#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
25#error "Only <gio/gio.h> can be included directly."
26#endif
27
28#include <gio/giotypes.h>
29
30G_BEGIN_DECLS
31
32#define G_TYPE_VFS (g_vfs_get_type ())
33#define G_VFS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_VFS, GVfs))
34#define G_VFS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_VFS, GVfsClass))
35#define G_VFS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_VFS, GVfsClass))
36#define G_IS_VFS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_VFS))
37#define G_IS_VFS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_VFS))
38
39/**
40 * GVfsFileLookupFunc:
41 * @vfs: a #GVfs
42 * @identifier: the identifier to lookup a #GFile for. This can either
43 * be an URI or a parse name as returned by g_file_get_parse_name()
44 * @user_data: user data passed to the function
45 *
46 * This function type is used by g_vfs_register_uri_scheme() to make it
47 * possible for a client to associate an URI scheme to a different #GFile
48 * implementation.
49 *
50 * The client should return a reference to the new file that has been
51 * created for @uri, or %NULL to continue with the default implementation.
52 *
53 * Returns: (transfer full): a #GFile for @identifier.
54 *
55 * Since: 2.50
56 */
57typedef GFile * (* GVfsFileLookupFunc) (GVfs *vfs,
58 const char *identifier,
59 gpointer user_data);
60
61/**
62 * G_VFS_EXTENSION_POINT_NAME:
63 *
64 * Extension point for #GVfs functionality.
65 * See [Extending GIO][extending-gio].
66 */
67#define G_VFS_EXTENSION_POINT_NAME "gio-vfs"
68
69/**
70 * GVfs:
71 *
72 * Virtual File System object.
73 **/
74typedef struct _GVfsClass GVfsClass;
75
76struct _GVfs
77{
78 GObject parent_instance;
79};
80
81struct _GVfsClass
82{
83 GObjectClass parent_class;
84
85 /* Virtual Table */
86
87 gboolean (* is_active) (GVfs *vfs);
88 GFile * (* get_file_for_path) (GVfs *vfs,
89 const char *path);
90 GFile * (* get_file_for_uri) (GVfs *vfs,
91 const char *uri);
92 const gchar * const * (* get_supported_uri_schemes) (GVfs *vfs);
93 GFile * (* parse_name) (GVfs *vfs,
94 const char *parse_name);
95
96 /*< private >*/
97 void (* local_file_add_info) (GVfs *vfs,
98 const char *filename,
99 guint64 device,
100 GFileAttributeMatcher *attribute_matcher,
101 GFileInfo *info,
102 GCancellable *cancellable,
103 gpointer *extra_data,
104 GDestroyNotify *free_extra_data);
105 void (* add_writable_namespaces) (GVfs *vfs,
106 GFileAttributeInfoList *list);
107 gboolean (* local_file_set_attributes) (GVfs *vfs,
108 const char *filename,
109 GFileInfo *info,
110 GFileQueryInfoFlags flags,
111 GCancellable *cancellable,
112 GError **error);
113 void (* local_file_removed) (GVfs *vfs,
114 const char *filename);
115 void (* local_file_moved) (GVfs *vfs,
116 const char *source,
117 const char *dest);
118 GIcon * (* deserialize_icon) (GVfs *vfs,
119 GVariant *value);
120 /* Padding for future expansion */
121 void (*_g_reserved1) (void);
122 void (*_g_reserved2) (void);
123 void (*_g_reserved3) (void);
124 void (*_g_reserved4) (void);
125 void (*_g_reserved5) (void);
126 void (*_g_reserved6) (void);
127};
128
129GLIB_AVAILABLE_IN_ALL
130GType g_vfs_get_type (void) G_GNUC_CONST;
131
132GLIB_AVAILABLE_IN_ALL
133gboolean g_vfs_is_active (GVfs *vfs);
134GLIB_AVAILABLE_IN_ALL
135GFile * g_vfs_get_file_for_path (GVfs *vfs,
136 const char *path);
137GLIB_AVAILABLE_IN_ALL
138GFile * g_vfs_get_file_for_uri (GVfs *vfs,
139 const char *uri);
140GLIB_AVAILABLE_IN_ALL
141const gchar* const * g_vfs_get_supported_uri_schemes (GVfs *vfs);
142
143GLIB_AVAILABLE_IN_ALL
144GFile * g_vfs_parse_name (GVfs *vfs,
145 const char *parse_name);
146
147GLIB_AVAILABLE_IN_ALL
148GVfs * g_vfs_get_default (void);
149GLIB_AVAILABLE_IN_ALL
150GVfs * g_vfs_get_local (void);
151
152GLIB_AVAILABLE_IN_2_50
153gboolean g_vfs_register_uri_scheme (GVfs *vfs,
154 const char *scheme,
155 GVfsFileLookupFunc uri_func,
156 gpointer uri_data,
157 GDestroyNotify uri_destroy,
158 GVfsFileLookupFunc parse_name_func,
159 gpointer parse_name_data,
160 GDestroyNotify parse_name_destroy);
161GLIB_AVAILABLE_IN_2_50
162gboolean g_vfs_unregister_uri_scheme (GVfs *vfs,
163 const char *scheme);
164
165
166G_END_DECLS
167
168#endif /* __G_VFS_H__ */
169