gdrive.h 14 KB

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