1/* GIO - GLib Input, Output and Streaming Library
2 *
3 * Copyright (C) 2006-2007 Red Hat, Inc.
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 *
20 * Author: Alexander Larsson <alexl@redhat.com>
21 * David Zeuthen <davidz@redhat.com>
22 */
23
24#ifndef __G_DRIVE_H__
25#define __G_DRIVE_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
33G_BEGIN_DECLS
34
35/**
36 * G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE:
37 *
38 * The string used to obtain a Unix device path with g_drive_get_identifier().
39 *
40 * Since: 2.58
41 */
42#define G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE "unix-device"
43
44#define G_TYPE_DRIVE (g_drive_get_type ())
45#define G_DRIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_DRIVE, GDrive))
46#define G_IS_DRIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_DRIVE))
47#define G_DRIVE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_DRIVE, GDriveIface))
48
49/**
50 * GDriveIface:
51 * @g_iface: The parent interface.
52 * @changed: Signal emitted when the drive is changed.
53 * @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.
54 * @eject_button: Signal emitted when the physical eject button (if any) of a drive have been pressed.
55 * @get_name: Returns the name for the given #GDrive.
56 * @get_icon: Returns a #GIcon for the given #GDrive.
57 * @has_volumes: Returns %TRUE if the #GDrive has mountable volumes.
58 * @get_volumes: Returns a list #GList of #GVolume for the #GDrive.
59 * @is_removable: Returns %TRUE if the #GDrive and/or its media is considered removable by the user. Since 2.50.
60 * @is_media_removable: Returns %TRUE if the #GDrive supports removal and insertion of media.
61 * @has_media: Returns %TRUE if the #GDrive has media inserted.
62 * @is_media_check_automatic: Returns %TRUE if the #GDrive is capable of automatically detecting media changes.
63 * @can_poll_for_media: Returns %TRUE if the #GDrive is capable of manually polling for media change.
64 * @can_eject: Returns %TRUE if the #GDrive can eject media.
65 * @eject: Ejects a #GDrive.
66 * @eject_finish: Finishes an eject operation.
67 * @poll_for_media: Poll for media insertion/removal on a #GDrive.
68 * @poll_for_media_finish: Finishes a media poll operation.
69 * @get_identifier: Returns the identifier of the given kind, or %NULL if
70 * the #GDrive doesn't have one.
71 * @enumerate_identifiers: Returns an array strings listing the kinds
72 * of identifiers which the #GDrive has.
73 * @get_start_stop_type: Gets a #GDriveStartStopType with details about starting/stopping the drive. Since 2.22.
74 * @can_stop: Returns %TRUE if a #GDrive can be stopped. Since 2.22.
75 * @stop: Stops a #GDrive. Since 2.22.
76 * @stop_finish: Finishes a stop operation. Since 2.22.
77 * @can_start: Returns %TRUE if a #GDrive can be started. Since 2.22.
78 * @can_start_degraded: Returns %TRUE if a #GDrive can be started degraded. Since 2.22.
79 * @start: Starts a #GDrive. Since 2.22.
80 * @start_finish: Finishes a start operation. Since 2.22.
81 * @stop_button: Signal emitted when the physical stop button (if any) of a drive have been pressed. Since 2.22.
82 * @eject_with_operation: Starts ejecting a #GDrive using a #GMountOperation. Since 2.22.
83 * @eject_with_operation_finish: Finishes an eject operation using a #GMountOperation. Since 2.22.
84 * @get_sort_key: Gets a key used for sorting #GDrive instances or %NULL if no such key exists. Since 2.32.
85 * @get_symbolic_icon: Returns a symbolic #GIcon for the given #GDrive. Since 2.34.
86 *
87 * Interface for creating #GDrive implementations.
88 */
89typedef struct _GDriveIface GDriveIface;
90
91struct _GDriveIface
92{
93 GTypeInterface g_iface;
94
95 /* signals */
96 void (* changed) (GDrive *drive);
97 void (* disconnected) (GDrive *drive);
98 void (* eject_button) (GDrive *drive);
99
100 /* Virtual Table */
101 char * (* get_name) (GDrive *drive);
102 GIcon * (* get_icon) (GDrive *drive);
103 gboolean (* has_volumes) (GDrive *drive);
104 GList * (* get_volumes) (GDrive *drive);
105 gboolean (* is_media_removable) (GDrive *drive);
106 gboolean (* has_media) (GDrive *drive);
107 gboolean (* is_media_check_automatic) (GDrive *drive);
108 gboolean (* can_eject) (GDrive *drive);
109 gboolean (* can_poll_for_media) (GDrive *drive);
110 void (* eject) (GDrive *drive,
111 GMountUnmountFlags flags,
112 GCancellable *cancellable,
113 GAsyncReadyCallback callback,
114 gpointer user_data);
115 gboolean (* eject_finish) (GDrive *drive,
116 GAsyncResult *result,
117 GError **error);
118 void (* poll_for_media) (GDrive *drive,
119 GCancellable *cancellable,
120 GAsyncReadyCallback callback,
121 gpointer user_data);
122 gboolean (* poll_for_media_finish) (GDrive *drive,
123 GAsyncResult *result,
124 GError **error);
125
126 char * (* get_identifier) (GDrive *drive,
127 const char *kind);
128 char ** (* enumerate_identifiers) (GDrive *drive);
129
130 GDriveStartStopType (* get_start_stop_type) (GDrive *drive);
131
132 gboolean (* can_start) (GDrive *drive);
133 gboolean (* can_start_degraded) (GDrive *drive);
134 void (* start) (GDrive *drive,
135 GDriveStartFlags flags,
136 GMountOperation *mount_operation,
137 GCancellable *cancellable,
138 GAsyncReadyCallback callback,
139 gpointer user_data);
140 gboolean (* start_finish) (GDrive *drive,
141 GAsyncResult *result,
142 GError **error);
143
144 gboolean (* can_stop) (GDrive *drive);
145 void (* stop) (GDrive *drive,
146 GMountUnmountFlags flags,
147 GMountOperation *mount_operation,
148 GCancellable *cancellable,
149 GAsyncReadyCallback callback,
150 gpointer user_data);
151 gboolean (* stop_finish) (GDrive *drive,
152 GAsyncResult *result,
153 GError **error);
154 /* signal, not VFunc */
155 void (* stop_button) (GDrive *drive);
156
157 void (* eject_with_operation) (GDrive *drive,
158 GMountUnmountFlags flags,
159 GMountOperation *mount_operation,
160 GCancellable *cancellable,
161 GAsyncReadyCallback callback,
162 gpointer user_data);
163 gboolean (* eject_with_operation_finish) (GDrive *drive,
164 GAsyncResult *result,
165 GError **error);
166
167 const gchar * (* get_sort_key) (GDrive *drive);
168 GIcon * (* get_symbolic_icon) (GDrive *drive);
169 gboolean (* is_removable) (GDrive *drive);
170
171};
172
173GIO_AVAILABLE_IN_ALL
174GType g_drive_get_type (void) G_GNUC_CONST;
175
176GIO_AVAILABLE_IN_ALL
177char * g_drive_get_name (GDrive *drive);
178GIO_AVAILABLE_IN_ALL
179GIcon * g_drive_get_icon (GDrive *drive);
180GIO_AVAILABLE_IN_ALL
181GIcon * g_drive_get_symbolic_icon (GDrive *drive);
182GIO_AVAILABLE_IN_ALL
183gboolean g_drive_has_volumes (GDrive *drive);
184GIO_AVAILABLE_IN_ALL
185GList * g_drive_get_volumes (GDrive *drive);
186GIO_AVAILABLE_IN_2_50
187gboolean g_drive_is_removable (GDrive *drive);
188GIO_AVAILABLE_IN_ALL
189gboolean g_drive_is_media_removable (GDrive *drive);
190GIO_AVAILABLE_IN_ALL
191gboolean g_drive_has_media (GDrive *drive);
192GIO_AVAILABLE_IN_ALL
193gboolean g_drive_is_media_check_automatic (GDrive *drive);
194GIO_AVAILABLE_IN_ALL
195gboolean g_drive_can_poll_for_media (GDrive *drive);
196GIO_AVAILABLE_IN_ALL
197gboolean g_drive_can_eject (GDrive *drive);
198GIO_DEPRECATED_FOR(g_drive_eject_with_operation)
199void g_drive_eject (GDrive *drive,
200 GMountUnmountFlags flags,
201 GCancellable *cancellable,
202 GAsyncReadyCallback callback,
203 gpointer user_data);
204
205GIO_DEPRECATED_FOR(g_drive_eject_with_operation_finish)
206gboolean g_drive_eject_finish (GDrive *drive,
207 GAsyncResult *result,
208 GError **error);
209GIO_AVAILABLE_IN_ALL
210void g_drive_poll_for_media (GDrive *drive,
211 GCancellable *cancellable,
212 GAsyncReadyCallback callback,
213 gpointer user_data);
214GIO_AVAILABLE_IN_ALL
215gboolean g_drive_poll_for_media_finish (GDrive *drive,
216 GAsyncResult *result,
217 GError **error);
218GIO_AVAILABLE_IN_ALL
219char * g_drive_get_identifier (GDrive *drive,
220 const char *kind);
221GIO_AVAILABLE_IN_ALL
222char ** g_drive_enumerate_identifiers (GDrive *drive);
223
224GIO_AVAILABLE_IN_ALL
225GDriveStartStopType g_drive_get_start_stop_type (GDrive *drive);
226
227GIO_AVAILABLE_IN_ALL
228gboolean g_drive_can_start (GDrive *drive);
229GIO_AVAILABLE_IN_ALL
230gboolean g_drive_can_start_degraded (GDrive *drive);
231GIO_AVAILABLE_IN_ALL
232void g_drive_start (GDrive *drive,
233 GDriveStartFlags flags,
234 GMountOperation *mount_operation,
235 GCancellable *cancellable,
236 GAsyncReadyCallback callback,
237 gpointer user_data);
238GIO_AVAILABLE_IN_ALL
239gboolean g_drive_start_finish (GDrive *drive,
240 GAsyncResult *result,
241 GError **error);
242
243GIO_AVAILABLE_IN_ALL
244gboolean g_drive_can_stop (GDrive *drive);
245GIO_AVAILABLE_IN_ALL
246void g_drive_stop (GDrive *drive,
247 GMountUnmountFlags flags,
248 GMountOperation *mount_operation,
249 GCancellable *cancellable,
250 GAsyncReadyCallback callback,
251 gpointer user_data);
252GIO_AVAILABLE_IN_ALL
253gboolean g_drive_stop_finish (GDrive *drive,
254 GAsyncResult *result,
255 GError **error);
256
257GIO_AVAILABLE_IN_ALL
258void g_drive_eject_with_operation (GDrive *drive,
259 GMountUnmountFlags flags,
260 GMountOperation *mount_operation,
261 GCancellable *cancellable,
262 GAsyncReadyCallback callback,
263 gpointer user_data);
264GIO_AVAILABLE_IN_ALL
265gboolean g_drive_eject_with_operation_finish (GDrive *drive,
266 GAsyncResult *result,
267 GError **error);
268
269GIO_AVAILABLE_IN_2_32
270const gchar *g_drive_get_sort_key (GDrive *drive);
271
272G_END_DECLS
273
274#endif /* __G_DRIVE_H__ */
275