big header formatting cleanup: indentation, vtable formatting, consistent
[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 <gio/giotypes.h>
32
33 G_BEGIN_DECLS
34
35 /**
36  * G_VOLUME_IDENTIFIER_KIND_HAL_UDI:
37  *
38  * The string used to obtain a Hal UDI with g_volume_get_identifier().
39  */
40 #define G_VOLUME_IDENTIFIER_KIND_HAL_UDI "hal-udi"
41
42 /**
43  * G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE:
44  *
45  * The string used to obtain a Unix device path with g_volume_get_identifier().
46  */
47 #define G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE "unix-device"
48
49 /**
50  * G_VOLUME_IDENTIFIER_KIND_LABEL:
51  *
52  * The string used to obtain a filesystem label with g_volume_get_identifier().
53  */
54 #define G_VOLUME_IDENTIFIER_KIND_LABEL "label"
55
56 /**
57  * G_VOLUME_IDENTIFIER_KIND_UUID:
58  *
59  * The string used to obtain a UUID with g_volume_get_identifier().
60  */
61 #define G_VOLUME_IDENTIFIER_KIND_UUID "uuid"
62
63 /**
64  * G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT:
65  *
66  * The string used to obtain a NFS mount with g_volume_get_identifier().
67  */
68 #define G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT "nfs-mount"
69
70
71 #define G_TYPE_VOLUME            (g_volume_get_type ())
72 #define G_VOLUME(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_VOLUME, GVolume))
73 #define G_IS_VOLUME(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_VOLUME))
74 #define G_VOLUME_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_VOLUME, GVolumeIface))
75
76 /**
77  * GVolumeIface:
78  * @g_iface: The parent interface.
79  * @changed: Changed signal that is emitted when the volume's state has changed.
80  * @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.
81  * @get_name: Gets a string containing the name of the #GVolume.
82  * @get_icon: Gets a #GIcon for the #GVolume.
83  * @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.
84  * @get_drive: Gets a #GDrive the volume is located on. Returns %NULL if the #GVolume is not associated with a #GDrive.
85  * @get_mount: Gets a #GMount representing the mounted volume. Returns %NULL if the #GVolume is not mounted.
86  * @can_mount: Returns %TRUE if the #GVolume can be mounted.
87  * @can_eject: Checks if a #GVolume can be ejected.
88  * @mount_fn: Mounts a given #GVolume.
89  * @mount_finish: Finishes a mount operation.
90  * @eject: Ejects a given #GVolume.
91  * @eject_finish: Finishes an eject operation.
92  * @get_identifier: Returns the <link linkend="volume-identifier">identifier</link> of the given kind, or %NULL if
93  *    the #GVolume doesn't have one.
94  * @enumerate_identifiers: Returns an array strings listing the kinds
95  *    of <link linkend="volume-identifier">identifiers</link> which the #GVolume has.
96  * @should_automount: Returns %TRUE if the #GVolume should be automatically mounted.
97  * @get_activation_root: Returns the activation root for the #GVolume if it is known in advance or %NULL if
98  *   it is not known.
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                                          GMountMountFlags     flags,
124                                          GMountOperation     *mount_operation,
125                                          GCancellable        *cancellable,
126                                          GAsyncReadyCallback  callback,
127                                          gpointer             user_data);
128   gboolean    (* mount_finish)          (GVolume             *volume,
129                                          GAsyncResult        *result,
130                                          GError             **error);
131   void        (* eject)                 (GVolume             *volume,
132                                          GMountUnmountFlags   flags,
133                                          GCancellable        *cancellable,
134                                          GAsyncReadyCallback  callback,
135                                          gpointer             user_data);
136   gboolean    (* eject_finish)          (GVolume             *volume,
137                                          GAsyncResult        *result,
138                                          GError             **error);
139
140   char      * (* get_identifier)        (GVolume             *volume,
141                                          const char          *kind);
142   char     ** (* enumerate_identifiers) (GVolume             *volume);
143
144   gboolean    (* should_automount)      (GVolume             *volume);
145
146   GFile     * (* get_activation_root)   (GVolume             *volume);
147
148 };
149
150 GType    g_volume_get_type              (void) G_GNUC_CONST;
151
152 char *   g_volume_get_name              (GVolume              *volume);
153 GIcon *  g_volume_get_icon              (GVolume              *volume);
154 char *   g_volume_get_uuid              (GVolume              *volume);
155 GDrive * g_volume_get_drive             (GVolume              *volume);
156 GMount * g_volume_get_mount             (GVolume              *volume);
157 gboolean g_volume_can_mount             (GVolume              *volume);
158 gboolean g_volume_can_eject             (GVolume              *volume);
159 gboolean g_volume_should_automount      (GVolume              *volume);
160 void     g_volume_mount                 (GVolume              *volume,
161                                          GMountMountFlags      flags,
162                                          GMountOperation      *mount_operation,
163                                          GCancellable         *cancellable,
164                                          GAsyncReadyCallback   callback,
165                                          gpointer              user_data);
166 gboolean g_volume_mount_finish          (GVolume              *volume,
167                                          GAsyncResult         *result,
168                                          GError              **error);
169 void     g_volume_eject                 (GVolume              *volume,
170                                          GMountUnmountFlags    flags,
171                                          GCancellable         *cancellable,
172                                          GAsyncReadyCallback   callback,
173                                          gpointer              user_data);
174 gboolean g_volume_eject_finish          (GVolume              *volume,
175                                          GAsyncResult         *result,
176                                          GError              **error);
177 char *   g_volume_get_identifier        (GVolume              *volume,
178                                          const char           *kind);
179 char **  g_volume_enumerate_identifiers (GVolume              *volume);
180
181 GFile *  g_volume_get_activation_root   (GVolume              *volume);
182
183 G_END_DECLS
184
185 #endif /* __G_VOLUME_H__ */