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.1 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, see <http://www.gnu.org/licenses/>.
17 *
18 * Author: Alexander Larsson <alexl@redhat.com>
19 * David Zeuthen <davidz@redhat.com>
20 */
21
22#ifndef __G_DRIVE_H__
23#define __G_DRIVE_H__
24
25#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
26#error "Only <gio/gio.h> can be included directly."
27#endif
28
29#include <gio/giotypes.h>
30
31G_BEGIN_DECLS
32
33#define G_TYPE_DRIVE (g_drive_get_type ())
34#define G_DRIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_DRIVE, GDrive))
35#define G_IS_DRIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_DRIVE))
36#define G_DRIVE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_DRIVE, GDriveIface))
37
38/**
39 * GDriveIface:
40 * @g_iface: The parent interface.
41 * @changed: Signal emitted when the drive is changed.
42 * @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.
43 * @eject_button: Signal emitted when the physical eject button (if any) of a drive have been pressed.
44 * @get_name: Returns the name for the given #GDrive.
45 * @get_icon: Returns a #GIcon for the given #GDrive.
46 * @has_volumes: Returns %TRUE if the #GDrive has mountable volumes.
47 * @get_volumes: Returns a list #GList of #GVolume for the #GDrive.
48 * @is_removable: Returns %TRUE if the #GDrive and/or its media is considered removable by the user. Since 2.50.
49 * @is_media_removable: Returns %TRUE if the #GDrive supports removal and insertion of media.
50 * @has_media: Returns %TRUE if the #GDrive has media inserted.
51 * @is_media_check_automatic: Returns %TRUE if the #GDrive is capabable of automatically detecting media changes.
52 * @can_poll_for_media: Returns %TRUE if the #GDrive is capable of manually polling for media change.
53 * @can_eject: Returns %TRUE if the #GDrive can eject media.
54 * @eject: Ejects a #GDrive.
55 * @eject_finish: Finishes an eject operation.
56 * @poll_for_media: Poll for media insertion/removal on a #GDrive.
57 * @poll_for_media_finish: Finishes a media poll operation.
58 * @get_identifier: Returns the identifier of the given kind, or %NULL if
59 * the #GDrive doesn't have one.
60 * @enumerate_identifiers: Returns an array strings listing the kinds
61 * of identifiers which the #GDrive has.
62 * @get_start_stop_type: Gets a #GDriveStartStopType with details about starting/stopping the drive. Since 2.22.
63 * @can_stop: Returns %TRUE if a #GDrive can be stopped. Since 2.22.
64 * @stop: Stops a #GDrive. Since 2.22.
65 * @stop_finish: Finishes a stop operation. Since 2.22.
66 * @can_start: Returns %TRUE if a #GDrive can be started. Since 2.22.
67 * @can_start_degraded: Returns %TRUE if a #GDrive can be started degraded. 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 * @eject_with_operation: Starts ejecting a #GDrive using a #GMountOperation. Since 2.22.
72 * @eject_with_operation_finish: Finishes an eject operation using a #GMountOperation. Since 2.22.
73 * @get_sort_key: Gets a key used for sorting #GDrive instances or %NULL if no such key exists. Since 2.32.
74 * @get_symbolic_icon: Returns a symbolic #GIcon for the given #GDrive. Since 2.34.
75 *
76 * Interface for creating #GDrive implementations.
77 */
78typedef struct _GDriveIface GDriveIface;
79
80struct _GDriveIface
81{
82 GTypeInterface g_iface;
83
84 /* signals */
85 void (* changed) (GDrive *drive);
86 void (* disconnected) (GDrive *drive);
87 void (* eject_button) (GDrive *drive);
88
89 /* Virtual Table */
90 char * (* get_name) (GDrive *drive);
91 GIcon * (* get_icon) (GDrive *drive);
92 gboolean (* has_volumes) (GDrive *drive);
93 GList * (* get_volumes) (GDrive *drive);
94 gboolean (* is_media_removable) (GDrive *drive);
95 gboolean (* has_media) (GDrive *drive);
96 gboolean (* is_media_check_automatic) (GDrive *drive);
97 gboolean (* can_eject) (GDrive *drive);
98 gboolean (* can_poll_for_media) (GDrive *drive);
99 void (* eject) (GDrive *drive,
100 GMountUnmountFlags flags,
101 GCancellable *cancellable,
102 GAsyncReadyCallback callback,
103 gpointer user_data);
104 gboolean (* eject_finish) (GDrive *drive,
105 GAsyncResult *result,
106 GError **error);
107 void (* poll_for_media) (GDrive *drive,
108 GCancellable *cancellable,
109 GAsyncReadyCallback callback,
110 gpointer user_data);
111 gboolean (* poll_for_media_finish) (GDrive *drive,
112 GAsyncResult *result,
113 GError **error);
114
115 char * (* get_identifier) (GDrive *drive,
116 const char *kind);
117 char ** (* enumerate_identifiers) (GDrive *drive);
118
119 GDriveStartStopType (* get_start_stop_type) (GDrive *drive);
120
121 gboolean (* can_start) (GDrive *drive);
122 gboolean (* can_start_degraded) (GDrive *drive);
123 void (* start) (GDrive *drive,
124 GDriveStartFlags flags,
125 GMountOperation *mount_operation,
126 GCancellable *cancellable,
127 GAsyncReadyCallback callback,
128 gpointer user_data);
129 gboolean (* start_finish) (GDrive *drive,
130 GAsyncResult *result,
131 GError **error);
132
133 gboolean (* can_stop) (GDrive *drive);
134 void (* stop) (GDrive *drive,
135 GMountUnmountFlags flags,
136 GMountOperation *mount_operation,
137 GCancellable *cancellable,
138 GAsyncReadyCallback callback,
139 gpointer user_data);
140 gboolean (* stop_finish) (GDrive *drive,
141 GAsyncResult *result,
142 GError **error);
143 /* signal, not VFunc */
144 void (* stop_button) (GDrive *drive);
145
146 void (* eject_with_operation) (GDrive *drive,
147 GMountUnmountFlags flags,
148 GMountOperation *mount_operation,
149 GCancellable *cancellable,
150 GAsyncReadyCallback callback,
151 gpointer user_data);
152 gboolean (* eject_with_operation_finish) (GDrive *drive,
153 GAsyncResult *result,
154 GError **error);
155
156 const gchar * (* get_sort_key) (GDrive *drive);
157 GIcon * (* get_symbolic_icon) (GDrive *drive);
158 gboolean (* is_removable) (GDrive *drive);
159
160};
161
162GLIB_AVAILABLE_IN_ALL
163GType g_drive_get_type (void) G_GNUC_CONST;
164
165GLIB_AVAILABLE_IN_ALL
166char * g_drive_get_name (GDrive *drive);
167GLIB_AVAILABLE_IN_ALL
168GIcon * g_drive_get_icon (GDrive *drive);
169GLIB_AVAILABLE_IN_ALL
170GIcon * g_drive_get_symbolic_icon (GDrive *drive);
171GLIB_AVAILABLE_IN_ALL
172gboolean g_drive_has_volumes (GDrive *drive);
173GLIB_AVAILABLE_IN_ALL
174GList * g_drive_get_volumes (GDrive *drive);
175GLIB_AVAILABLE_IN_2_50
176gboolean g_drive_is_removable (GDrive *drive);
177GLIB_AVAILABLE_IN_ALL
178gboolean g_drive_is_media_removable (GDrive *drive);
179GLIB_AVAILABLE_IN_ALL
180gboolean g_drive_has_media (GDrive *drive);
181GLIB_AVAILABLE_IN_ALL
182gboolean g_drive_is_media_check_automatic (GDrive *drive);
183GLIB_AVAILABLE_IN_ALL
184gboolean g_drive_can_poll_for_media (GDrive *drive);
185GLIB_AVAILABLE_IN_ALL
186gboolean g_drive_can_eject (GDrive *drive);
187GLIB_DEPRECATED_FOR(g_drive_eject_with_operation)
188void g_drive_eject (GDrive *drive,
189 GMountUnmountFlags flags,
190 GCancellable *cancellable,
191 GAsyncReadyCallback callback,
192 gpointer user_data);
193
194GLIB_DEPRECATED_FOR(g_drive_eject_with_operation_finish)
195gboolean g_drive_eject_finish (GDrive *drive,
196 GAsyncResult *result,
197 GError **error);
198GLIB_AVAILABLE_IN_ALL
199void g_drive_poll_for_media (GDrive *drive,
200 GCancellable *cancellable,
201 GAsyncReadyCallback callback,
202 gpointer user_data);
203GLIB_AVAILABLE_IN_ALL
204gboolean g_drive_poll_for_media_finish (GDrive *drive,
205 GAsyncResult *result,
206 GError **error);
207GLIB_AVAILABLE_IN_ALL
208char * g_drive_get_identifier (GDrive *drive,
209 const char *kind);
210GLIB_AVAILABLE_IN_ALL
211char ** g_drive_enumerate_identifiers (GDrive *drive);
212
213GLIB_AVAILABLE_IN_ALL
214GDriveStartStopType g_drive_get_start_stop_type (GDrive *drive);
215
216GLIB_AVAILABLE_IN_ALL
217gboolean g_drive_can_start (GDrive *drive);
218GLIB_AVAILABLE_IN_ALL
219gboolean g_drive_can_start_degraded (GDrive *drive);
220GLIB_AVAILABLE_IN_ALL
221void g_drive_start (GDrive *drive,
222 GDriveStartFlags flags,
223 GMountOperation *mount_operation,
224 GCancellable *cancellable,
225 GAsyncReadyCallback callback,
226 gpointer user_data);
227GLIB_AVAILABLE_IN_ALL
228gboolean g_drive_start_finish (GDrive *drive,
229 GAsyncResult *result,
230 GError **error);
231
232GLIB_AVAILABLE_IN_ALL
233gboolean g_drive_can_stop (GDrive *drive);
234GLIB_AVAILABLE_IN_ALL
235void g_drive_stop (GDrive *drive,
236 GMountUnmountFlags flags,
237 GMountOperation *mount_operation,
238 GCancellable *cancellable,
239 GAsyncReadyCallback callback,
240 gpointer user_data);
241GLIB_AVAILABLE_IN_ALL
242gboolean g_drive_stop_finish (GDrive *drive,
243 GAsyncResult *result,
244 GError **error);
245
246GLIB_AVAILABLE_IN_ALL
247void g_drive_eject_with_operation (GDrive *drive,
248 GMountUnmountFlags flags,
249 GMountOperation *mount_operation,
250 GCancellable *cancellable,
251 GAsyncReadyCallback callback,
252 gpointer user_data);
253GLIB_AVAILABLE_IN_ALL
254gboolean g_drive_eject_with_operation_finish (GDrive *drive,
255 GAsyncResult *result,
256 GError **error);
257
258GLIB_AVAILABLE_IN_2_32
259const gchar *g_drive_get_sort_key (GDrive *drive);
260
261G_END_DECLS
262
263#endif /* __G_DRIVE_H__ */
264