Documentation additions
[platform/upstream/glib.git] / gio / gvolume.h
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 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, write to the
17  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Author: Alexander Larsson <alexl@redhat.com>
21  *         David Zeuthen <davidz@redhat.com>
22  */
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 #ifndef __G_VOLUME_H__
29 #define __G_VOLUME_H__
30
31 #include <glib-object.h>
32 #include <gio/gfile.h>
33 #include <gio/gdrive.h>
34
35 G_BEGIN_DECLS
36
37 /**
38  * G_VOLUME_IDENTIFIER_KIND_HAL_UDI:
39  *
40  * The string used to obtain a Hal UDI with g_volume_get_identifier().
41  */
42 #define G_VOLUME_IDENTIFIER_KIND_HAL_UDI "hal-udi"
43
44 /**
45  * G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE:
46  *
47  * The string used to obtain a Unix device path with g_volume_get_identifier().
48  */
49 #define G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE "unix-device"
50
51 /**
52  * G_VOLUME_IDENTIFIER_KIND_LABEL:
53  *
54  * The string used to obtain a filesystem label with g_volume_get_identifier().
55  */
56 #define G_VOLUME_IDENTIFIER_KIND_LABEL "label"
57
58 /**
59  * G_VOLUME_IDENTIFIER_KIND_UUID:
60  *
61  * The string used to obtain a UUID with g_volume_get_identifier().
62  */
63 #define G_VOLUME_IDENTIFIER_KIND_UUID "uuid"
64
65 /**
66  * G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT:
67  *
68  * The string used to obtain a NFS mount with g_volume_get_identifier().
69  */
70 #define G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT "nfs-mount"
71
72
73 #define G_TYPE_VOLUME            (g_volume_get_type ())
74 #define G_VOLUME(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_VOLUME, GVolume))
75 #define G_IS_VOLUME(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_VOLUME))
76 #define G_VOLUME_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_VOLUME, GVolumeIface))
77
78 /**
79  * GVolumeIface:
80  * @g_iface: The parent interface.
81  * @changed: Changed signal that is emitted when the volume's state has changed.
82  * @removed: The removed signal that is emitted when the #GVolume have been removed. If the recipient is holding references to the object they should release them so the object can be finalized.
83  * @get_name: Gets a string containing the name of the #GVolume.
84  * @get_icon: Gets a #GIcon for the #GVolume.
85  * @get_uuid: Gets the UUID for the #GVolume. The reference is typically based on the file system UUID for the mount in question and should be considered an opaque string. Returns %NULL if there is no UUID available.
86  * @get_drive: Gets a #GDrive the volume is located on. Returns %NULL if the #GVolume is not associated with a #GDrive.
87  * @get_mount: Gets a #GMount representing the mounted volume. Returns %NULL if the #GVolume is not mounted.
88  * @can_mount: Returns %TRUE if the #GVolume can be mounted.
89  * @can_eject: Checks if a #GVolume can be ejected.
90  * @mount_fn: Mounts a given #GVolume.
91  * @mount_finish: Finishes a mount operation.
92  * @eject: Ejects a given #GVolume.
93  * @eject_finish: Finishes an eject operation.
94  * @get_identifier: Returns the <link linkend="volume-identifier">identifier</link> of the given kind, or %NULL if 
95  *    the #GVolume doesn't have one.
96  * @enumerate_identifiers: Returns an array strings listing the kinds
97  *    of <link linkend="volume-identifier">identifiers</link> which the #GVolume has.
98  * @should_automount: Returns %TRUE if the #GVolume should be automatically mounted.
99  * 
100  * Interface for implementing operations for mountable volumes.
101  **/
102 typedef struct _GVolumeIface    GVolumeIface;
103
104 struct _GVolumeIface
105 {
106   GTypeInterface g_iface;
107
108   /* signals */
109
110   void (*changed) (GVolume *volume);
111   void (*removed) (GVolume *volume);
112   
113   /* Virtual Table */
114
115   char *    (*get_name)       (GVolume             *volume);
116   GIcon *   (*get_icon)       (GVolume             *volume);
117   char *    (*get_uuid)       (GVolume             *volume);
118   GDrive *  (*get_drive)      (GVolume             *volume);
119   GMount *  (*get_mount)      (GVolume             *volume);
120   gboolean  (*can_mount)      (GVolume             *volume);
121   gboolean  (*can_eject)      (GVolume             *volume);
122   void      (*mount_fn)       (GVolume             *volume,
123                                GMountOperation     *mount_operation,
124                                GCancellable        *cancellable,
125                                GAsyncReadyCallback  callback,
126                                gpointer             user_data);
127   gboolean  (*mount_finish)   (GVolume             *volume,
128                                GAsyncResult        *result,
129                                GError             **error);
130   void      (*eject)          (GVolume             *volume,
131                                GMountUnmountFlags   flags,
132                                GCancellable        *cancellable,
133                                GAsyncReadyCallback  callback,
134                                gpointer             user_data);
135   gboolean  (*eject_finish)   (GVolume             *volume,
136                                GAsyncResult        *result,
137                                GError             **error);
138   
139   char *   (*get_identifier)           (GVolume             *volume,
140                                         const char          *kind);
141   char **  (*enumerate_identifiers)    (GVolume             *volume);
142
143   gboolean (*should_automount)         (GVolume             *volume);
144   
145 };
146
147 GType     g_volume_get_type       (void) G_GNUC_CONST;
148
149 char *   g_volume_get_name              (GVolume              *volume);
150 GIcon *  g_volume_get_icon              (GVolume              *volume);
151 char *   g_volume_get_uuid              (GVolume              *volume);
152 GDrive * g_volume_get_drive             (GVolume              *volume);
153 GMount * g_volume_get_mount             (GVolume              *volume);
154 gboolean g_volume_can_mount             (GVolume              *volume);
155 gboolean g_volume_can_eject             (GVolume              *volume);
156 gboolean g_volume_should_automount      (GVolume              *volume);
157 void     g_volume_mount                 (GVolume              *volume,
158                                          GMountOperation      *mount_operation,
159                                          GCancellable         *cancellable,
160                                          GAsyncReadyCallback   callback,
161                                          gpointer              user_data);
162 gboolean g_volume_mount_finish          (GVolume              *volume,
163                                          GAsyncResult         *result,
164                                          GError              **error);
165 void     g_volume_eject                 (GVolume              *volume,
166                                          GMountUnmountFlags    flags,
167                                          GCancellable         *cancellable,
168                                          GAsyncReadyCallback   callback,
169                                          gpointer              user_data);
170 gboolean g_volume_eject_finish          (GVolume              *volume,
171                                          GAsyncResult         *result,
172                                          GError              **error);
173 char *   g_volume_get_identifier        (GVolume              *volume,
174                                          const char           *kind);
175 char **  g_volume_enumerate_identifiers (GVolume              *volume);
176
177
178 G_END_DECLS
179
180 #endif /* __G_VOLUME_H__ */