2 <title>GIO Overview</title>
5 <title>Introduction</title>
8 GIO is striving to provide a modern, easy-to-use VFS API that sits
9 at the right level in the library stack. The goal is to overcome the
10 shortcomings of GnomeVFS and provide an API that is so good that
11 developers prefer it over raw POSIX calls. Among other things
12 that means using GObject. It also means not cloning the POSIX
13 API, but providing higher-level, document-centric interfaces.
17 The abstract file system model of GIO consists of a number of
18 interfaces and base classes for I/O and files:
22 <listitem><para>reference to a file</para></listitem>
25 <term>GFileInfo</term>
26 <listitem><para>information about a file or filesystem</para></listitem>
29 <term>GFileEnumerator</term>
30 <listitem><para>list files in directories</para></listitem>
34 <listitem><para>represents a drive</para></listitem>
38 <listitem><para>represents a file system in an abstract way</para></listitem>
42 <listitem><para>represents a mounted file system</para></listitem>
45 Then there is a number of stream classes, similar to the input and
46 output stream hierarchies that can be found in frameworks like Java:
49 <term>GInputStream</term>
50 <listitem><para>read data</para></listitem>
53 <term>GOutputStream</term>
54 <listitem><para>write data</para></listitem>
57 <term>GIOStream</term>
58 <listitem><para>read and write data</para></listitem>
61 <term>GSeekable</term>
62 <listitem><para>interface optionally implemented by streams to support seeking</para></listitem>
65 There are interfaces related to applications and the types
70 <listitem><para>information about an installed application</para></listitem>
74 <listitem><para>abstract type for file and application icons</para></listitem>
77 There is a framework for storing and retrieving application settings:
80 <term>GSettings</term>
81 <listitem><para>stores and retrieves application settings</para></listitem>
84 There is support for network programming, including name resolution, lowlevel socket
85 APIs and highlevel client and server helper classes:
89 <listitem><para>lowlevel platform independent socket object</para></listitem>
92 <term>GResolver</term>
93 <listitem><para>asynchronous and cancellable DNS resolver</para></listitem>
96 <term>GSocketClient</term>
97 <listitem><para>high-level network client helper</para></listitem>
100 <term>GSocketService</term>
101 <listitem><para>high-level network server helper</para></listitem>
104 <term>GSocketConnection</term>
105 <listitem><para>network connection stream</para></listitem>
108 There is support for connecting to <link linkend="http://www.freedesktop.org/wiki/Software/dbus">D-Bus</link>,
109 sending and receiving messages, owning and watching bus names,
110 and making objects available on the bus:
113 <term>GDBusConnection</term>
114 <listitem><para>a D-Bus connection</para></listitem>
118 <term>GDBusMethodInvocation</term>
119 <listitem><para>for handling remove calls</para></listitem>
123 <term>GDBusServer</term>
124 <listitem><para>helper for accepting connections</para></listitem>
128 <term>GDBusProxy</term>
129 <listitem><para>proxy to access D-Bus interfaces on a remote object</para></listitem>
133 Beyond these, GIO provides facilities for file monitoring,
134 asynchronous I/O and filename completion. In addition to the
135 interfaces, GIO provides implementations for the local case.
136 Implementations for various network file systems are provided
137 by the GVFS package as loadable modules.
141 Other design choices which consciously break with the GnomeVFS
142 design are to move backends out-of-process, which minimizes the
143 dependency bloat and makes the whole system more robust. The backends
144 are not included in GIO, but in the separate GVFS package. The GVFS
145 package also contains the GVFS daemon, which spawn further mount
146 daemons for each individual connection.
149 <figure id="gvfs-overview">
150 <title>GIO in the GTK+ library stack</title>
151 <graphic fileref="gvfs-overview.png" format="PNG"></graphic>
155 The GIO model of I/O is stateful: if an application establishes e.g.
156 a SFTP connection to a server, it becomes available to all applications
157 in the session; the user does not have to enter his password over
161 One of the big advantages of putting the VFS in the GLib layer
162 is that GTK+ can directly use it, e.g. in the filechooser.
167 <title>Compiling GIO applications</title>
170 GIO comes with a <filename>gio-2.0.pc</filename> file that you
171 should use together with <literal>pkg-config</literal> to obtain
172 the necessary information about header files and libraries. See
173 the <literal>pkg-config</literal> man page or the GLib documentation
174 for more information on how to use <literal>pkg-config</literal>
175 to compile your application.
179 If you are using GIO on UNIX-like systems, you may want to use
180 UNIX-specific GIO interfaces such as #GUnixInputStream,
181 #GUnixOutputStream, #GUnixMount or #GDesktopAppInfo.
182 To do so, use the <filename>gio-unix-2.0.pc</filename> file
183 instead of <filename>gio-2.0.pc</filename>
187 Since GIO is based on GObject, you need to call g_type_init()
188 before you can use any GIO functions. If your application uses
189 GTK+, this is already taken care of by gtk_init().
194 <title>Running GIO applications</title>
197 GIO inspects a few of environment variables in addition to the
202 <title><envar>XDG_DATA_HOME</envar>, <envar>XDG_DATA_DIRS</envar></title>
205 GIO uses these environment variables to locate MIME information.
206 For more information, see the <ulink url="http://freedesktop.org/Standards/shared-mime-info-spec">Shared MIME-info Database</ulink>
207 and the <ulink url="http://freedesktop.org/Standards/basedir-spec">Base Directory Specification</ulink>.
212 <title><envar>GVFS_DISABLE_FUSE</envar></title>
215 This variable can be set to keep #Gvfs from starting the fuse backend,
216 which may be unwanted or unnecessary in certain situations.
221 The following environment variables are only useful for debugging
222 GIO itself or modules that it loads. They should not be set in a
223 production environment.
226 <title><envar>GIO_USE_VFS</envar></title>
229 This environment variable can be set to the name of a #GVfs
230 implementation to override the default for debugging purposes.
231 The #GVfs implementation for local files that is included in GIO
232 has the name "local", the implementation in the gvfs module has
238 <title><envar>GIO_USE_VOLUME_MONITOR</envar></title>
241 This variable can be set to the name of a #GVolumeMonitor
242 implementation to override the default for debugging purposes.
243 The #GVolumeMonitor implementation for local files that is included
244 in GIO has the name "unix", the hal-based implementation in the
245 gvfs module has the name "hal".
250 <title><envar>GIO_USE_TLS</envar></title>
253 This variable can be set to the name of a #GTlsBackend
254 implementation to override the default for debugging purposes.
255 GIO does not include a #GTlsBackend implementation, the gnutls-based
256 implementation in the glib-networking module has the name "gnutls".
261 <title><envar>GVFS_INOTIFY_DIAG</envar></title>
264 When this environment variable is set and GIO has been built
265 with inotify support, a dump of diagnostic inotify information
266 will be written every 20 seconds to a file named
267 <filename>/tmp/gvfsdid.<replaceable>pid</replaceable></filename>.
272 <title><envar>GIO_EXTRA_MODULES</envar></title>
275 When this environment variable is set to a path, or a set of
276 paths separated by a colon, GIO will attempt to load
277 modules from within the path.
282 <title><envar>GSETTINGS_BACKEND</envar></title>
285 This variable can be set to the name of a #GSettingsBackend
286 implementation to override the default for debugging purposes.
287 The memory-based implementation that is included in GIO has
288 the name "memory", the one in dconf has the name "dconf-settings".
293 <title><envar>GSETTINGS_SCHEMA_DIR</envar></title>
296 This variable can be set to the name of a directory that is
297 considered in addition to the <filename>glib-2.0/schemas</filename>
298 subdirectories of the XDG system data dirs when looking
299 for compiled schemas for #GSettings.
304 <title><envar>DBUS_SYSTEM_BUS_ADDRESS</envar></title>
307 This variable is consulted to find the address of the D-Bus system
308 bus. For the format of D-Bus addresses, see the D-Bus
309 <ulink url="http://dbus.freedesktop.org/doc/dbus-specification.html#addresses">specification</ulink>.
312 Setting this variable overrides platform-specific ways of determining
313 the system bus address.
318 <title><envar>DBUS_SESSION_BUS_ADDRESS</envar></title>
321 This variable is consulted to find the address of the D-Bus session bus.
324 Setting this variable overrides platform-specific ways of determining
325 the session bus address.
330 <title><envar>DBUS_STARTER_BUS_TYPE</envar></title>
333 This variable is consulted to find out the 'starter' bus for an
334 application that has been started via D-Bus activation. The possible
335 values are 'system' or 'session'.
340 <title><envar>G_DBUS_DEBUG</envar></title>
343 This variable can be set to a list of debug options, which
344 cause GLib to print out different types of debugging
345 information when using the D-Bus routines.
348 <term>transport</term>
349 <listitem><para>Show IO activity (e.g. reads and writes)</para></listitem>
353 <listitem><para>Show all sent and received D-Bus messages</para></listitem>
357 <listitem><para>Show payload for all sent and received D-Bus messages (implies message)</para></listitem>
361 <listitem><para>Trace g_dbus_connection_call() and g_dbus_connection_call_sync() API usage</para></listitem>
365 <listitem><para>Show when a D-Bus signal is received</para></listitem>
368 <term>incoming</term>
369 <listitem><para>Show when an incoming D-Bus method call is received</para></listitem>
373 <listitem><para>Show when a reply is returned via the #GDBusMethodInvocation API</para></listitem>
376 <term>emission</term>
377 <listitem><para>Trace g_dbus_connection_emit_signal() API usage</para></listitem>
380 <term>authentication</term>
381 <listitem><para>Show information about connection authentication</para></listitem>
385 <listitem><para>Show information about D-Bus address lookups and autolaunching</para></listitem>
388 The special value <literal>all</literal> can be used to turn
389 on all debug options. The special value
390 <literal>help</literal> can be used to print a list of
391 supported options to standard output.
396 <title><envar>G_DBUS_COOKIE_SHA1_KEYRING_DIR</envar></title>
399 Can be used to override the directory used to store the
400 keyring used in the <literal>DBUS_COOKIE_SHA1</literal>
401 authentication mechanism. Normally the directory used is
402 <filename>.dbus-keyrings</filename> in the user's home
408 <title><envar>G_DBUS_COOKIE_SHA1_KEYRING_DIR_IGNORE_PERMISSION</envar></title>
411 If set, the permissions of the directory used to store the
412 keyring used in the <literal>DBUS_COOKIE_SHA1</literal>
413 authentication mechanism won't be checked. Normally the
414 directory must be readable only by the user.
419 <chapter id="extending-gio">
420 <title>Extending GIO</title>
423 A lot of the functionality that is accessible through GIO
424 is implemented in loadable modules, and modules provide a convenient
425 way to extend GIO. In addition to the #GIOModule API which supports
426 writing such modules, GIO has a mechanism to define extension points,
427 and register implementations thereof, see #GIOExtensionPoint.
430 The following extension points are currently defined by GIO:
434 <title>G_VFS_EXTENSION_POINT_NAME</title>
437 Allows to override the functionality of the #GVfs class.
438 Implementations of this extension point must be derived from #GVfs.
439 GIO uses the implementation with the highest priority that is active,
440 see g_vfs_is_active().
443 GIO implements this extension point for local files, gvfs contains
444 an implementation that supports all the backends in gvfs.
449 <title>G_VOLUME_MONITOR_EXTENSION_POINT_NAME</title>
452 Allows to add more volume monitors.
453 Implementations of this extension point must be derived from
454 #GVolumeMonitor. GIO uses all registered extensions.
457 gvfs contains an implementation that works together with the #GVfs
458 implementation in gvfs.
463 <title>G_NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME</title>
466 Allows to override the 'native' volume monitor.
467 Implementations of this extension point must be derived from
468 #GNativeVolumeMonitor. GIO uses the implementation with
469 the highest priority that is supported, as determined by the
470 is_supported() vfunc in #GVolumeMonitorClass.
473 GIO implements this extension point for local mounts,
474 gvfs contains a hal-based implementation.
479 <title>G_LOCAL_FILE_MONITOR_EXTENSION_POINT_NAME</title>
482 Allows to override the file monitor implementation for
483 local files. Implementations of this extension point must
484 be derived from #GLocalFileMonitor. GIO uses the implementation
485 with the highest priority that is supported, as determined by the
486 is_supported() vfunc in #GLocalFileMonitorClass.
489 GIO uses this extension point internally, to switch between
490 its fam-based and inotify-based file monitoring implementations.
495 <title>G_LOCAL_DIRECTORY_MONITOR_EXTENSION_POINT_NAME</title>
498 Allows to override the directory monitor implementation for
499 local files. Implementations of this extension point must be
500 derived from #GLocalDirectoryMonitor. GIO uses the implementation
501 with the highest priority that is supported, as determined by the
502 is_supported() vfunc in #GLocalDirectoryMonitorClass.
505 GIO uses this extension point internally, to switch between
506 its fam-based and inotify-based directory monitoring implementations.
511 <title>G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME</title>
514 Unix-only. Allows to provide a way to associate default handlers
515 with URI schemes. Implementations of this extension point must
516 implement the #GDesktopAppInfoLookup interface. GIO uses the
517 implementation with the highest priority.
520 This extension point has been discontinued in GLib 2.28. It is
521 still available to keep API and ABI stability, but GIO is no
522 longer using it for default handlers. Instead, the mime handler
523 mechanism is used, together with x-scheme-handler pseudo-mimetypes.
528 <title>G_SETTINGS_BACKEND_EXTENSION_POINT_NAME</title>
531 Allows to provide an alternative storage for #GSettings.
532 Implementations of this extension point must derive from the
533 #GSettingsBackend type. GIO contains a keyfile-based
534 implementation of this extension point, another one is provided
540 <title>G_PROXY_EXTENSION_POINT_NAME</title>
543 Allows to provide implementations for network proxying.
544 Implementations of this extension point must provide the
545 #GProxy interface, and must be named after the network
546 protocol they are proxying.
549 glib-networking contains an implementation of this extension
550 point based on libproxy.
555 <title>G_TLS_BACKEND_EXTENSION_POINT_NAME</title>
558 Allows to provide implementations for TLS support.
559 Implementations of this extension point must implement
560 the #GTlsBackend interface.
563 glib-networking contains an implementation of this extension