656a242559dd60da6da4c753f20f39305506a7b1
[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 #define G_VOLUME_IDENTIFIER_KIND_HAL_UDI "hal-udi"
38 #define G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE "unix-device"
39 #define G_VOLUME_IDENTIFIER_KIND_LABEL "label"
40 #define G_VOLUME_IDENTIFIER_KIND_UUID "uuid"
41 #define G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT "nfs-mount"
42
43
44 #define G_TYPE_VOLUME            (g_volume_get_type ())
45 #define G_VOLUME(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_VOLUME, GVolume))
46 #define G_IS_VOLUME(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_VOLUME))
47 #define G_VOLUME_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_VOLUME, GVolumeIface))
48
49 /**
50  * GVolumeIface:
51  * @g_iface: The parent interface.
52  * @changed: Changed signal that is emitted when the volume's state has changed.
53  * @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.
54  * @get_name: Gets a string containing the name of the #GVolume.
55  * @get_icon: Gets a #GIcon for the #GVolume.
56  * @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.
57  * @get_drive: Gets a #GDrive the volume is located on. Returns %NULL if the #GVolume is not associated with a #GDrive.
58  * @get_mount: Gets a #GMount representing the mounted volume. Returns %NULL if the #GVolume is not mounted.
59  * @can_mount: Returns %TRUE if the #GVolume can be mounted.
60  * @can_eject: Checks if a #GVolume can be ejected.
61  * @mount_fn: Mounts a given #GVolume.
62  * @mount_finish: Finishes a mount operation.
63  * @eject: Ejects a given #GVolume.
64  * @eject_finish: Finishes an eject operation.
65  * @get_identifier: Returns the identifier of the given kind, or %NULL if 
66  *    the #GVolume doesn't have one.
67  * @enumerate_identifiers: Returns an array strings listing the kinds
68  *    of identifiers which the #GVolume has.
69  * 
70  * Interface for implementing operations for mountable volumes.
71  **/
72 typedef struct _GVolumeIface    GVolumeIface;
73
74 struct _GVolumeIface
75 {
76   GTypeInterface g_iface;
77
78   /* signals */
79
80   void (*changed) (GVolume *volume);
81   void (*removed) (GVolume *volume);
82   
83   /* Virtual Table */
84
85   char *    (*get_name)       (GVolume             *volume);
86   GIcon *   (*get_icon)       (GVolume             *volume);
87   char *    (*get_uuid)       (GVolume             *volume);
88   GDrive *  (*get_drive)      (GVolume             *volume);
89   GMount *  (*get_mount)      (GVolume             *volume);
90   gboolean  (*can_mount)      (GVolume             *volume);
91   gboolean  (*can_eject)      (GVolume             *volume);
92   void      (*mount_fn)       (GVolume             *volume,
93                                GMountOperation     *mount_operation,
94                                GCancellable        *cancellable,
95                                GAsyncReadyCallback  callback,
96                                gpointer             user_data);
97   gboolean  (*mount_finish)   (GVolume             *volume,
98                                GAsyncResult        *result,
99                                GError             **error);
100   void      (*eject)          (GVolume             *volume,
101                                GMountUnmountFlags   flags,
102                                GCancellable        *cancellable,
103                                GAsyncReadyCallback  callback,
104                                gpointer             user_data);
105   gboolean  (*eject_finish)   (GVolume             *volume,
106                                GAsyncResult        *result,
107                                GError             **error);
108   
109   char *   (*get_identifier)           (GVolume             *volume,
110                                         const char          *kind);
111   char **  (*enumerate_identifiers)    (GVolume             *volume);
112 };
113
114 GType     g_volume_get_type       (void) G_GNUC_CONST;
115
116 char *   g_volume_get_name              (GVolume              *volume);
117 GIcon *  g_volume_get_icon              (GVolume              *volume);
118 char *   g_volume_get_uuid              (GVolume              *volume);
119 GDrive * g_volume_get_drive             (GVolume              *volume);
120 GMount * g_volume_get_mount             (GVolume              *volume);
121 gboolean g_volume_can_mount             (GVolume              *volume);
122 gboolean g_volume_can_eject             (GVolume              *volume);
123 void     g_volume_mount                 (GVolume              *volume,
124                                          GMountOperation      *mount_operation,
125                                          GCancellable         *cancellable,
126                                          GAsyncReadyCallback   callback,
127                                          gpointer              user_data);
128 gboolean g_volume_mount_finish          (GVolume              *volume,
129                                          GAsyncResult         *result,
130                                          GError              **error);
131 void     g_volume_eject                 (GVolume              *volume,
132                                          GMountUnmountFlags    flags,
133                                          GCancellable         *cancellable,
134                                          GAsyncReadyCallback   callback,
135                                          gpointer              user_data);
136 gboolean g_volume_eject_finish          (GVolume              *volume,
137                                          GAsyncResult         *result,
138                                          GError              **error);
139 char *   g_volume_get_identifier        (GVolume              *volume,
140                                          const char           *kind);
141 char **  g_volume_enumerate_identifiers (GVolume              *volume);
142
143
144 G_END_DECLS
145
146 #endif /* __G_VOLUME_H__ */