4c932f61da35082cf0b847fdb2dd93464679368c
[platform/upstream/glib.git] / gio / gdrive.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_DRIVE_H__
29 #define __G_DRIVE_H__
30
31 #include <gio/giotypes.h>
32
33 G_BEGIN_DECLS
34
35 #define G_TYPE_DRIVE           (g_drive_get_type ())
36 #define G_DRIVE(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_DRIVE, GDrive))
37 #define G_IS_DRIVE(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_DRIVE))
38 #define G_DRIVE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_DRIVE, GDriveIface))
39
40 /**
41  * GDriveIface:
42  * @g_iface: The parent interface.
43  * @changed: Signal emitted when the drive is changed.
44  * @disconnected: The removed signal that is emitted when the #GDrive have been disconnected. If the recipient is holding references to the object they should release them so the object can be finalized.
45  * @eject_button: Signal emitted when the physical eject button (if any) of a drive have been pressed.
46  * @get_name: Returns the name for the given #GDrive.
47  * @get_icon: Returns a #GIcon for the given #GDrive.
48  * @has_volumes: Returns %TRUE if the #GDrive has mountable volumes.
49  * @get_volumes: Returns a list #GList of #GVolume for the #GDrive.
50  * @is_media_removable: Returns %TRUE if the #GDrive supports removal and insertion of media.
51  * @has_media: Returns %TRUE if the #GDrive has media inserted.
52  * @is_media_check_automatic: Returns %TRUE if the #GDrive is capabable of automatically detecting media changes.
53  * @can_poll_for_media: Returns %TRUE if the #GDrive is capable of manually polling for media change.
54  * @can_eject: Returns %TRUE if the #GDrive can eject media.
55  * @eject: Ejects a #GDrive.
56  * @eject_finish: Finishes an eject operation.
57  * @poll_for_media: Poll for media insertion/removal on a #GDrive.
58  * @poll_for_media_finish: Finishes a media poll operation.
59  * @get_identifier: Returns the identifier of the given kind, or %NULL if
60  *    the #GDrive doesn't have one.
61  * @enumerate_identifiers: Returns an array strings listing the kinds
62  *    of identifiers which the #GDrive has.
63  * @get_start_stop_type: Gets a #GDriveStartStopType with details about starting/stopping the drive. Since 2.22.
64  * @can_stop: Returns %TRUE if a #GDrive can be stopped. Since 2.22.
65  * @stop: Stops a #GDrive. Since 2.22.
66  * @stop_finish: Finishes a stop operation. Since 2.22.
67  * @can_start: Returns %TRUE if a #GDrive can be started. Since 2.22.
68  * @start: Starts a #GDrive. Since 2.22.
69  * @start_finish: Finishes a start operation. Since 2.22.
70  * @stop_button: Signal emitted when the physical stop button (if any) of a drive have been pressed. Since 2.22.
71  *
72  * Interface for creating #GDrive implementations.
73  */
74 typedef struct _GDriveIface    GDriveIface;
75
76 struct _GDriveIface
77 {
78   GTypeInterface g_iface;
79
80   /* signals */
81   void     (* changed)                  (GDrive              *drive);
82   void     (* disconnected)             (GDrive              *drive);
83   void     (* eject_button)             (GDrive              *drive);
84
85   /* Virtual Table */
86   char *   (* get_name)                 (GDrive              *drive);
87   GIcon *  (* get_icon)                 (GDrive              *drive);
88   gboolean (* has_volumes)              (GDrive              *drive);
89   GList *  (* get_volumes)              (GDrive              *drive);
90   gboolean (* is_media_removable)       (GDrive              *drive);
91   gboolean (* has_media)                (GDrive              *drive);
92   gboolean (* is_media_check_automatic) (GDrive              *drive);
93   gboolean (* can_eject)                (GDrive              *drive);
94   gboolean (* can_poll_for_media)       (GDrive              *drive);
95   void     (* eject)                    (GDrive              *drive,
96                                          GMountUnmountFlags   flags,
97                                          GCancellable        *cancellable,
98                                          GAsyncReadyCallback  callback,
99                                          gpointer             user_data);
100   gboolean (* eject_finish)             (GDrive              *drive,
101                                          GAsyncResult        *result,
102                                          GError             **error);
103   void     (* poll_for_media)           (GDrive              *drive,
104                                          GCancellable        *cancellable,
105                                          GAsyncReadyCallback  callback,
106                                          gpointer             user_data);
107   gboolean (* poll_for_media_finish)    (GDrive              *drive,
108                                          GAsyncResult        *result,
109                                          GError             **error);
110
111   char *   (* get_identifier)           (GDrive              *drive,
112                                          const char          *kind);
113   char **  (* enumerate_identifiers)    (GDrive              *drive);
114
115   GDriveStartStopType (* get_start_stop_type) (GDrive        *drive);
116
117   gboolean (* can_start)                (GDrive              *drive);
118   void     (* start)                    (GDrive              *drive,
119                                          GDriveStartFlags     flags,
120                                          GMountOperation     *start_operation,
121                                          GCancellable        *cancellable,
122                                          GAsyncReadyCallback  callback,
123                                          gpointer             user_data);
124   gboolean (* start_finish)             (GDrive              *drive,
125                                          GAsyncResult        *result,
126                                          GError             **error);
127
128   gboolean (* can_stop)                 (GDrive              *drive);
129   void     (* stop)                     (GDrive              *drive,
130                                          GMountUnmountFlags   flags,
131                                          GCancellable        *cancellable,
132                                          GAsyncReadyCallback  callback,
133                                          gpointer             user_data);
134   gboolean (* stop_finish)              (GDrive              *drive,
135                                          GAsyncResult        *result,
136                                          GError             **error);
137   /* signal, not VFunc */
138   void     (* stop_button)              (GDrive              *drive);
139
140 };
141
142 GType    g_drive_get_type                 (void) G_GNUC_CONST;
143
144 char *   g_drive_get_name                 (GDrive               *drive);
145 GIcon *  g_drive_get_icon                 (GDrive               *drive);
146 gboolean g_drive_has_volumes              (GDrive               *drive);
147 GList *  g_drive_get_volumes              (GDrive               *drive);
148 gboolean g_drive_is_media_removable       (GDrive               *drive);
149 gboolean g_drive_has_media                (GDrive               *drive);
150 gboolean g_drive_is_media_check_automatic (GDrive               *drive);
151 gboolean g_drive_can_poll_for_media       (GDrive               *drive);
152 gboolean g_drive_can_eject                (GDrive               *drive);
153 void     g_drive_eject                    (GDrive               *drive,
154                                            GMountUnmountFlags    flags,
155                                            GCancellable         *cancellable,
156                                            GAsyncReadyCallback   callback,
157                                            gpointer              user_data);
158 gboolean g_drive_eject_finish             (GDrive               *drive,
159                                            GAsyncResult         *result,
160                                            GError              **error);
161 void     g_drive_poll_for_media           (GDrive               *drive,
162                                            GCancellable         *cancellable,
163                                            GAsyncReadyCallback   callback,
164                                            gpointer              user_data);
165 gboolean g_drive_poll_for_media_finish    (GDrive               *drive,
166                                            GAsyncResult         *result,
167                                            GError              **error);
168 char *   g_drive_get_identifier           (GDrive              *drive,
169                                            const char          *kind);
170 char **  g_drive_enumerate_identifiers    (GDrive              *drive);
171
172 GDriveStartStopType g_drive_get_start_stop_type (GDrive        *drive);
173
174 gboolean g_drive_can_start                (GDrive              *drive);
175 void     g_drive_start                    (GDrive              *drive,
176                                            GDriveStartFlags     flags,
177                                            GMountOperation     *start_operation,
178                                            GCancellable        *cancellable,
179                                            GAsyncReadyCallback  callback,
180                                            gpointer             user_data);
181 gboolean g_drive_start_finish             (GDrive               *drive,
182                                            GAsyncResult         *result,
183                                            GError              **error);
184
185 gboolean g_drive_can_stop                 (GDrive               *drive);
186 void     g_drive_stop                     (GDrive               *drive,
187                                            GMountUnmountFlags    flags,
188                                            GCancellable         *cancellable,
189                                            GAsyncReadyCallback   callback,
190                                            gpointer              user_data);
191 gboolean g_drive_stop_finish              (GDrive               *drive,
192                                            GAsyncResult         *result,
193                                            GError              **error);
194
195 G_END_DECLS
196
197 #endif /* __G_DRIVE_H__ */