Improve GSimpleActionGroup test coverage
[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 #ifndef __G_VOLUME_H__
25 #define __G_VOLUME_H__
26
27 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
28 #error "Only <gio/gio.h> can be included directly."
29 #endif
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  * G_VOLUME_IDENTIFIER_KIND_CLASS:
72  *
73  * The string used to obtain the volume <emphasis>class</emphasis>
74  * with g_volume_get_identifier().
75  *
76  * Known volume classes include <literal>device</literal> and
77  * <literal>network</literal>. Other classes may be added in the
78  * future.
79  *
80  * This is intended to be used by applications to classify #GVolume
81  * instances into different sections - for example a file manager or
82  * file chooser can use this information to show
83  * <literal>network</literal> volumes under a "Network" heading and
84  * <literal>device</literal> volumes under a "Devices" heading.
85  */
86 #define G_VOLUME_IDENTIFIER_KIND_CLASS "class"
87
88
89 #define G_TYPE_VOLUME            (g_volume_get_type ())
90 #define G_VOLUME(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_VOLUME, GVolume))
91 #define G_IS_VOLUME(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_VOLUME))
92 #define G_VOLUME_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_VOLUME, GVolumeIface))
93
94 /**
95  * GVolumeIface:
96  * @g_iface: The parent interface.
97  * @changed: Changed signal that is emitted when the volume's state has changed.
98  * @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.
99  * @get_name: Gets a string containing the name of the #GVolume.
100  * @get_icon: Gets a #GIcon for the #GVolume.
101  * @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.
102  * @get_drive: Gets a #GDrive the volume is located on. Returns %NULL if the #GVolume is not associated with a #GDrive.
103  * @get_mount: Gets a #GMount representing the mounted volume. Returns %NULL if the #GVolume is not mounted.
104  * @can_mount: Returns %TRUE if the #GVolume can be mounted.
105  * @can_eject: Checks if a #GVolume can be ejected.
106  * @mount_fn: Mounts a given #GVolume. 
107  *     #GVolume implementations must emit the #GMountOperation::aborted 
108  *     signal before completing a mount operation that is aborted while 
109  *     awaiting input from the user through a #GMountOperation instance.
110  * @mount_finish: Finishes a mount operation.
111  * @eject: Ejects a given #GVolume.
112  * @eject_finish: Finishes an eject operation.
113  * @get_identifier: Returns the <link linkend="volume-identifier">identifier</link> of the given kind, or %NULL if
114  *    the #GVolume doesn't have one.
115  * @enumerate_identifiers: Returns an array strings listing the kinds
116  *    of <link linkend="volume-identifier">identifiers</link> which the #GVolume has.
117  * @should_automount: Returns %TRUE if the #GVolume should be automatically mounted.
118  * @get_activation_root: Returns the activation root for the #GVolume if it is known in advance or %NULL if
119  *   it is not known.
120  * @eject_with_operation: Starts ejecting a #GVolume using a #GMountOperation. Since 2.22.
121  * @eject_with_operation_finish: Finishes an eject operation using a #GMountOperation. Since 2.22.
122  * @get_sort_key: Gets a key used for sorting #GVolume instance or %NULL if no such key exists. Since 2.32.
123  * @get_symbolic_icon: Gets a symbolic #GIcon for the #GVolume. Since 2.34.
124  *
125  * Interface for implementing operations for mountable volumes.
126  **/
127 typedef struct _GVolumeIface    GVolumeIface;
128
129 struct _GVolumeIface
130 {
131   GTypeInterface g_iface;
132
133   /* signals */
134
135   void        (* changed)               (GVolume             *volume);
136   void        (* removed)               (GVolume             *volume);
137
138   /* Virtual Table */
139
140   char      * (* get_name)              (GVolume             *volume);
141   GIcon     * (* get_icon)              (GVolume             *volume);
142   char      * (* get_uuid)              (GVolume             *volume);
143   GDrive    * (* get_drive)             (GVolume             *volume);
144   GMount    * (* get_mount)             (GVolume             *volume);
145   gboolean    (* can_mount)             (GVolume             *volume);
146   gboolean    (* can_eject)             (GVolume             *volume);
147   void        (* mount_fn)              (GVolume             *volume,
148                                          GMountMountFlags     flags,
149                                          GMountOperation     *mount_operation,
150                                          GCancellable        *cancellable,
151                                          GAsyncReadyCallback  callback,
152                                          gpointer             user_data);
153   gboolean    (* mount_finish)          (GVolume             *volume,
154                                          GAsyncResult        *result,
155                                          GError             **error);
156   void        (* eject)                 (GVolume             *volume,
157                                          GMountUnmountFlags   flags,
158                                          GCancellable        *cancellable,
159                                          GAsyncReadyCallback  callback,
160                                          gpointer             user_data);
161   gboolean    (* eject_finish)          (GVolume             *volume,
162                                          GAsyncResult        *result,
163                                          GError             **error);
164
165   char      * (* get_identifier)        (GVolume             *volume,
166                                          const char          *kind);
167   char     ** (* enumerate_identifiers) (GVolume             *volume);
168
169   gboolean    (* should_automount)      (GVolume             *volume);
170
171   GFile     * (* get_activation_root)   (GVolume             *volume);
172
173   void        (* eject_with_operation)      (GVolume             *volume,
174                                              GMountUnmountFlags   flags,
175                                              GMountOperation     *mount_operation,
176                                              GCancellable        *cancellable,
177                                              GAsyncReadyCallback  callback,
178                                              gpointer             user_data);
179   gboolean    (* eject_with_operation_finish) (GVolume           *volume,
180                                              GAsyncResult        *result,
181                                              GError             **error);
182
183   const gchar * (* get_sort_key)        (GVolume             *volume);
184   GIcon       * (* get_symbolic_icon)   (GVolume             *volume);
185 };
186
187 GLIB_AVAILABLE_IN_ALL
188 GType    g_volume_get_type              (void) G_GNUC_CONST;
189
190 GLIB_AVAILABLE_IN_ALL
191 char *   g_volume_get_name              (GVolume              *volume);
192 GLIB_AVAILABLE_IN_ALL
193 GIcon *  g_volume_get_icon              (GVolume              *volume);
194 GLIB_AVAILABLE_IN_ALL
195 GIcon *  g_volume_get_symbolic_icon     (GVolume              *volume);
196 GLIB_AVAILABLE_IN_ALL
197 char *   g_volume_get_uuid              (GVolume              *volume);
198 GLIB_AVAILABLE_IN_ALL
199 GDrive * g_volume_get_drive             (GVolume              *volume);
200 GLIB_AVAILABLE_IN_ALL
201 GMount * g_volume_get_mount             (GVolume              *volume);
202 GLIB_AVAILABLE_IN_ALL
203 gboolean g_volume_can_mount             (GVolume              *volume);
204 GLIB_AVAILABLE_IN_ALL
205 gboolean g_volume_can_eject             (GVolume              *volume);
206 GLIB_AVAILABLE_IN_ALL
207 gboolean g_volume_should_automount      (GVolume              *volume);
208 GLIB_AVAILABLE_IN_ALL
209 void     g_volume_mount                 (GVolume              *volume,
210                                          GMountMountFlags      flags,
211                                          GMountOperation      *mount_operation,
212                                          GCancellable         *cancellable,
213                                          GAsyncReadyCallback   callback,
214                                          gpointer              user_data);
215 GLIB_AVAILABLE_IN_ALL
216 gboolean g_volume_mount_finish          (GVolume              *volume,
217                                          GAsyncResult         *result,
218                                          GError              **error);
219 GLIB_DEPRECATED_FOR(g_volume_eject_with_operation)
220 void     g_volume_eject                 (GVolume              *volume,
221                                          GMountUnmountFlags    flags,
222                                          GCancellable         *cancellable,
223                                          GAsyncReadyCallback   callback,
224                                          gpointer              user_data);
225
226 GLIB_DEPRECATED_FOR(g_volume_eject_with_operation_finish)
227 gboolean g_volume_eject_finish          (GVolume              *volume,
228                                          GAsyncResult         *result,
229                                          GError              **error);
230 GLIB_AVAILABLE_IN_ALL
231 char *   g_volume_get_identifier        (GVolume              *volume,
232                                          const char           *kind);
233 GLIB_AVAILABLE_IN_ALL
234 char **  g_volume_enumerate_identifiers (GVolume              *volume);
235
236 GLIB_AVAILABLE_IN_ALL
237 GFile *  g_volume_get_activation_root   (GVolume              *volume);
238
239 GLIB_AVAILABLE_IN_ALL
240 void        g_volume_eject_with_operation     (GVolume             *volume,
241                                                GMountUnmountFlags   flags,
242                                                GMountOperation     *mount_operation,
243                                                GCancellable        *cancellable,
244                                                GAsyncReadyCallback  callback,
245                                                gpointer             user_data);
246 GLIB_AVAILABLE_IN_ALL
247 gboolean    g_volume_eject_with_operation_finish (GVolume          *volume,
248                                                GAsyncResult        *result,
249                                                GError             **error);
250
251 GLIB_AVAILABLE_IN_2_32
252 const gchar *g_volume_get_sort_key            (GVolume              *volume);
253
254 G_END_DECLS
255
256 #endif /* __G_VOLUME_H__ */