gdrive.h 14.2 KB
Newer Older
1
/* GIO - GLib Input, Output and Streaming Library
2
 *
3 4 5 6 7
 * Copyright (C) 2006-2007 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * 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 11 12 13 14 15
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * 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 23 24
#ifndef __G_DRIVE_H__
#define __G_DRIVE_H__

25 26 27 28
#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
#error "Only <gio/gio.h> can be included directly."
#endif

29
#include <gio/giotypes.h>
30 31 32

G_BEGIN_DECLS

33 34 35 36 37 38 39 40 41
/**
 * G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE:
 *
 * The string used to obtain a Unix device path with g_drive_get_identifier().
 *
 * Since: 2.58
 */
#define G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE "unix-device"

42 43
#define G_TYPE_DRIVE           (g_drive_get_type ())
#define G_DRIVE(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_DRIVE, GDrive))
44
#define G_IS_DRIVE(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_DRIVE))
45 46
#define G_DRIVE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_DRIVE, GDriveIface))

47 48 49 50
/**
 * GDriveIface:
 * @g_iface: The parent interface.
 * @changed: Signal emitted when the drive is changed.
51 52
 * @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.
 * @eject_button: Signal emitted when the physical eject button (if any) of a drive have been pressed.
53 54 55
 * @get_name: Returns the name for the given #GDrive.
 * @get_icon: Returns a #GIcon for the given #GDrive.
 * @has_volumes: Returns %TRUE if the #GDrive has mountable volumes.
56
 * @get_volumes: Returns a list #GList of #GVolume for the #GDrive.
57
 * @is_removable: Returns %TRUE if the #GDrive and/or its media is considered removable by the user. Since 2.50.
58 59 60 61 62
 * @is_media_removable: Returns %TRUE if the #GDrive supports removal and insertion of media.
 * @has_media: Returns %TRUE if the #GDrive has media inserted.
 * @is_media_check_automatic: Returns %TRUE if the #GDrive is capabable of automatically detecting media changes.
 * @can_poll_for_media: Returns %TRUE if the #GDrive is capable of manually polling for media change.
 * @can_eject: Returns %TRUE if the #GDrive can eject media.
63 64
 * @eject: Ejects a #GDrive.
 * @eject_finish: Finishes an eject operation.
65 66
 * @poll_for_media: Poll for media insertion/removal on a #GDrive.
 * @poll_for_media_finish: Finishes a media poll operation.
67
 * @get_identifier: Returns the identifier of the given kind, or %NULL if
Matthias Clasen's avatar
Matthias Clasen committed
68 69 70
 *    the #GDrive doesn't have one.
 * @enumerate_identifiers: Returns an array strings listing the kinds
 *    of identifiers which the #GDrive has.
71 72 73 74 75
 * @get_start_stop_type: Gets a #GDriveStartStopType with details about starting/stopping the drive. Since 2.22.
 * @can_stop: Returns %TRUE if a #GDrive can be stopped. Since 2.22.
 * @stop: Stops a #GDrive. Since 2.22.
 * @stop_finish: Finishes a stop operation. Since 2.22.
 * @can_start: Returns %TRUE if a #GDrive can be started. Since 2.22.
76
 * @can_start_degraded: Returns %TRUE if a #GDrive can be started degraded. Since 2.22.
77 78 79
 * @start: Starts a #GDrive. Since 2.22.
 * @start_finish: Finishes a start operation. Since 2.22.
 * @stop_button: Signal emitted when the physical stop button (if any) of a drive have been pressed. Since 2.22.
80 81
 * @eject_with_operation: Starts ejecting a #GDrive using a #GMountOperation. Since 2.22.
 * @eject_with_operation_finish: Finishes an eject operation using a #GMountOperation. Since 2.22.
82
 * @get_sort_key: Gets a key used for sorting #GDrive instances or %NULL if no such key exists. Since 2.32.
83
 * @get_symbolic_icon: Returns a symbolic #GIcon for the given #GDrive. Since 2.34.
Matthias Clasen's avatar
Matthias Clasen committed
84
 *
85
 * Interface for creating #GDrive implementations.
86
 */
87 88 89 90 91 92 93
typedef struct _GDriveIface    GDriveIface;

struct _GDriveIface
{
  GTypeInterface g_iface;

  /* signals */
94 95 96 97
  void     (* changed)                  (GDrive              *drive);
  void     (* disconnected)             (GDrive              *drive);
  void     (* eject_button)             (GDrive              *drive);

98
  /* Virtual Table */
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
  char *   (* get_name)                 (GDrive              *drive);
  GIcon *  (* get_icon)                 (GDrive              *drive);
  gboolean (* has_volumes)              (GDrive              *drive);
  GList *  (* get_volumes)              (GDrive              *drive);
  gboolean (* is_media_removable)       (GDrive              *drive);
  gboolean (* has_media)                (GDrive              *drive);
  gboolean (* is_media_check_automatic) (GDrive              *drive);
  gboolean (* can_eject)                (GDrive              *drive);
  gboolean (* can_poll_for_media)       (GDrive              *drive);
  void     (* eject)                    (GDrive              *drive,
                                         GMountUnmountFlags   flags,
                                         GCancellable        *cancellable,
                                         GAsyncReadyCallback  callback,
                                         gpointer             user_data);
  gboolean (* eject_finish)             (GDrive              *drive,
                                         GAsyncResult        *result,
                                         GError             **error);
  void     (* poll_for_media)           (GDrive              *drive,
                                         GCancellable        *cancellable,
                                         GAsyncReadyCallback  callback,
                                         gpointer             user_data);
  gboolean (* poll_for_media_finish)    (GDrive              *drive,
                                         GAsyncResult        *result,
                                         GError             **error);
123

124 125 126
  char *   (* get_identifier)           (GDrive              *drive,
                                         const char          *kind);
  char **  (* enumerate_identifiers)    (GDrive              *drive);
127 128 129 130

  GDriveStartStopType (* get_start_stop_type) (GDrive        *drive);

  gboolean (* can_start)                (GDrive              *drive);
131
  gboolean (* can_start_degraded)       (GDrive              *drive);
132 133
  void     (* start)                    (GDrive              *drive,
                                         GDriveStartFlags     flags,
134
                                         GMountOperation     *mount_operation,
135 136 137 138 139 140 141 142 143 144
                                         GCancellable        *cancellable,
                                         GAsyncReadyCallback  callback,
                                         gpointer             user_data);
  gboolean (* start_finish)             (GDrive              *drive,
                                         GAsyncResult        *result,
                                         GError             **error);

  gboolean (* can_stop)                 (GDrive              *drive);
  void     (* stop)                     (GDrive              *drive,
                                         GMountUnmountFlags   flags,
145
                                         GMountOperation     *mount_operation,
146 147 148 149 150 151 152 153 154
                                         GCancellable        *cancellable,
                                         GAsyncReadyCallback  callback,
                                         gpointer             user_data);
  gboolean (* stop_finish)              (GDrive              *drive,
                                         GAsyncResult        *result,
                                         GError             **error);
  /* signal, not VFunc */
  void     (* stop_button)              (GDrive              *drive);

155 156 157 158 159 160 161 162 163
  void        (* eject_with_operation)      (GDrive              *drive,
                                             GMountUnmountFlags   flags,
                                             GMountOperation     *mount_operation,
                                             GCancellable        *cancellable,
                                             GAsyncReadyCallback  callback,
                                             gpointer             user_data);
  gboolean    (* eject_with_operation_finish) (GDrive            *drive,
                                             GAsyncResult        *result,
                                             GError             **error);
164 165

  const gchar * (* get_sort_key)        (GDrive              *drive);
166
  GIcon *       (* get_symbolic_icon)   (GDrive              *drive);
Ondrej Holy's avatar
Ondrej Holy committed
167
  gboolean      (* is_removable)        (GDrive              *drive);
168

169 170
};

171
GLIB_AVAILABLE_IN_ALL
172
GType    g_drive_get_type                 (void) G_GNUC_CONST;
173

174
GLIB_AVAILABLE_IN_ALL
175
char *   g_drive_get_name                 (GDrive               *drive);
176
GLIB_AVAILABLE_IN_ALL
177
GIcon *  g_drive_get_icon                 (GDrive               *drive);
178
GLIB_AVAILABLE_IN_ALL
179
GIcon *  g_drive_get_symbolic_icon        (GDrive               *drive);
180
GLIB_AVAILABLE_IN_ALL
181
gboolean g_drive_has_volumes              (GDrive               *drive);
182
GLIB_AVAILABLE_IN_ALL
183
GList *  g_drive_get_volumes              (GDrive               *drive);
184 185
GLIB_AVAILABLE_IN_2_50
gboolean g_drive_is_removable             (GDrive               *drive);
186
GLIB_AVAILABLE_IN_ALL
187
gboolean g_drive_is_media_removable       (GDrive               *drive);
188
GLIB_AVAILABLE_IN_ALL
189
gboolean g_drive_has_media                (GDrive               *drive);
190
GLIB_AVAILABLE_IN_ALL
191
gboolean g_drive_is_media_check_automatic (GDrive               *drive);
192
GLIB_AVAILABLE_IN_ALL
193
gboolean g_drive_can_poll_for_media       (GDrive               *drive);
194
GLIB_AVAILABLE_IN_ALL
195
gboolean g_drive_can_eject                (GDrive               *drive);
196
GLIB_DEPRECATED_FOR(g_drive_eject_with_operation)
197
void     g_drive_eject                    (GDrive               *drive,
198
                                           GMountUnmountFlags    flags,
199 200
                                           GCancellable         *cancellable,
                                           GAsyncReadyCallback   callback,
201 202 203
                                           gpointer              user_data);

GLIB_DEPRECATED_FOR(g_drive_eject_with_operation_finish)
204 205
gboolean g_drive_eject_finish             (GDrive               *drive,
                                           GAsyncResult         *result,
206
                                           GError              **error);
207
GLIB_AVAILABLE_IN_ALL
208 209 210 211
void     g_drive_poll_for_media           (GDrive               *drive,
                                           GCancellable         *cancellable,
                                           GAsyncReadyCallback   callback,
                                           gpointer              user_data);
212
GLIB_AVAILABLE_IN_ALL
213 214 215
gboolean g_drive_poll_for_media_finish    (GDrive               *drive,
                                           GAsyncResult         *result,
                                           GError              **error);
216
GLIB_AVAILABLE_IN_ALL
217
char *   g_drive_get_identifier           (GDrive              *drive,
218
                                           const char          *kind);
219
GLIB_AVAILABLE_IN_ALL
220
char **  g_drive_enumerate_identifiers    (GDrive              *drive);
221

222
GLIB_AVAILABLE_IN_ALL
223 224
GDriveStartStopType g_drive_get_start_stop_type (GDrive        *drive);

225
GLIB_AVAILABLE_IN_ALL
226
gboolean g_drive_can_start                (GDrive              *drive);
227
GLIB_AVAILABLE_IN_ALL
228
gboolean g_drive_can_start_degraded       (GDrive              *drive);
229
GLIB_AVAILABLE_IN_ALL
230 231
void     g_drive_start                    (GDrive              *drive,
                                           GDriveStartFlags     flags,
232
                                           GMountOperation     *mount_operation,
233 234 235
                                           GCancellable        *cancellable,
                                           GAsyncReadyCallback  callback,
                                           gpointer             user_data);
236
GLIB_AVAILABLE_IN_ALL
237 238 239 240
gboolean g_drive_start_finish             (GDrive               *drive,
                                           GAsyncResult         *result,
                                           GError              **error);

241
GLIB_AVAILABLE_IN_ALL
242
gboolean g_drive_can_stop                 (GDrive               *drive);
243
GLIB_AVAILABLE_IN_ALL
244
void     g_drive_stop                     (GDrive               *drive,
245
                                           GMountUnmountFlags    flags,
246
                                           GMountOperation      *mount_operation,
247 248 249
                                           GCancellable         *cancellable,
                                           GAsyncReadyCallback   callback,
                                           gpointer              user_data);
250
GLIB_AVAILABLE_IN_ALL
251 252 253 254
gboolean g_drive_stop_finish              (GDrive               *drive,
                                           GAsyncResult         *result,
                                           GError              **error);

255
GLIB_AVAILABLE_IN_ALL
256 257 258 259 260 261
void        g_drive_eject_with_operation      (GDrive              *drive,
                                               GMountUnmountFlags   flags,
                                               GMountOperation     *mount_operation,
                                               GCancellable        *cancellable,
                                               GAsyncReadyCallback  callback,
                                               gpointer             user_data);
262
GLIB_AVAILABLE_IN_ALL
263 264 265 266
gboolean    g_drive_eject_with_operation_finish (GDrive            *drive,
                                               GAsyncResult        *result,
                                               GError             **error);

267
GLIB_AVAILABLE_IN_2_32
268 269
const gchar *g_drive_get_sort_key         (GDrive               *drive);

270 271 272
G_END_DECLS

#endif /* __G_DRIVE_H__ */