gvolume.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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_VOLUME_H__
  24. #define __G_VOLUME_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_VOLUME_IDENTIFIER_KIND_HAL_UDI:
  32. *
  33. * The string used to obtain a Hal UDI with g_volume_get_identifier().
  34. *
  35. * Deprecated: 2.58: Do not use, HAL is deprecated.
  36. */
  37. #define G_VOLUME_IDENTIFIER_KIND_HAL_UDI "hal-udi" GIO_DEPRECATED_MACRO_IN_2_58
  38. /**
  39. * G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE:
  40. *
  41. * The string used to obtain a Unix device path with g_volume_get_identifier().
  42. */
  43. #define G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE "unix-device"
  44. /**
  45. * G_VOLUME_IDENTIFIER_KIND_LABEL:
  46. *
  47. * The string used to obtain a filesystem label with g_volume_get_identifier().
  48. */
  49. #define G_VOLUME_IDENTIFIER_KIND_LABEL "label"
  50. /**
  51. * G_VOLUME_IDENTIFIER_KIND_UUID:
  52. *
  53. * The string used to obtain a UUID with g_volume_get_identifier().
  54. */
  55. #define G_VOLUME_IDENTIFIER_KIND_UUID "uuid"
  56. /**
  57. * G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT:
  58. *
  59. * The string used to obtain a NFS mount with g_volume_get_identifier().
  60. */
  61. #define G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT "nfs-mount"
  62. /**
  63. * G_VOLUME_IDENTIFIER_KIND_CLASS:
  64. *
  65. * The string used to obtain the volume class with g_volume_get_identifier().
  66. *
  67. * Known volume classes include `device`, `network`, and `loop`. Other
  68. * classes may be added in the future.
  69. *
  70. * This is intended to be used by applications to classify #GVolume
  71. * instances into different sections - for example a file manager or
  72. * file chooser can use this information to show `network` volumes under
  73. * a "Network" heading and `device` volumes under a "Devices" heading.
  74. */
  75. #define G_VOLUME_IDENTIFIER_KIND_CLASS "class"
  76. #define G_TYPE_VOLUME (g_volume_get_type ())
  77. #define G_VOLUME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_VOLUME, GVolume))
  78. #define G_IS_VOLUME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_VOLUME))
  79. #define G_VOLUME_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_VOLUME, GVolumeIface))
  80. /**
  81. * GVolumeIface:
  82. * @g_iface: The parent interface.
  83. * @changed: Changed signal that is emitted when the volume's state has changed.
  84. * @removed: The removed signal that is emitted when the #GVolume have been removed. If the recipient is holding references to the object they should release them so the object can be finalized.
  85. * @get_name: Gets a string containing the name of the #GVolume.
  86. * @get_icon: Gets a #GIcon for the #GVolume.
  87. * @get_uuid: Gets the UUID for the #GVolume. The reference is typically based on the file system UUID for the mount in question and should be considered an opaque string. Returns %NULL if there is no UUID available.
  88. * @get_drive: Gets a #GDrive the volume is located on. Returns %NULL if the #GVolume is not associated with a #GDrive.
  89. * @get_mount: Gets a #GMount representing the mounted volume. Returns %NULL if the #GVolume is not mounted.
  90. * @can_mount: Returns %TRUE if the #GVolume can be mounted.
  91. * @can_eject: Checks if a #GVolume can be ejected.
  92. * @mount_fn: Mounts a given #GVolume.
  93. * #GVolume implementations must emit the #GMountOperation::aborted
  94. * signal before completing a mount operation that is aborted while
  95. * awaiting input from the user through a #GMountOperation instance.
  96. * @mount_finish: Finishes a mount operation.
  97. * @eject: Ejects a given #GVolume.
  98. * @eject_finish: Finishes an eject operation.
  99. * @get_identifier: Returns the [identifier](#volume-identifiers) of the given kind, or %NULL if
  100. * the #GVolume doesn't have one.
  101. * @enumerate_identifiers: Returns an array strings listing the kinds
  102. * of [identifiers](#volume-identifiers) which the #GVolume has.
  103. * @should_automount: Returns %TRUE if the #GVolume should be automatically mounted.
  104. * @get_activation_root: Returns the activation root for the #GVolume if it is known in advance or %NULL if
  105. * it is not known.
  106. * @eject_with_operation: Starts ejecting a #GVolume using a #GMountOperation. Since 2.22.
  107. * @eject_with_operation_finish: Finishes an eject operation using a #GMountOperation. Since 2.22.
  108. * @get_sort_key: Gets a key used for sorting #GVolume instance or %NULL if no such key exists. Since 2.32.
  109. * @get_symbolic_icon: Gets a symbolic #GIcon for the #GVolume. Since 2.34.
  110. *
  111. * Interface for implementing operations for mountable volumes.
  112. **/
  113. typedef struct _GVolumeIface GVolumeIface;
  114. struct _GVolumeIface
  115. {
  116. GTypeInterface g_iface;
  117. /* signals */
  118. void (* changed) (GVolume *volume);
  119. void (* removed) (GVolume *volume);
  120. /* Virtual Table */
  121. char * (* get_name) (GVolume *volume);
  122. GIcon * (* get_icon) (GVolume *volume);
  123. char * (* get_uuid) (GVolume *volume);
  124. GDrive * (* get_drive) (GVolume *volume);
  125. GMount * (* get_mount) (GVolume *volume);
  126. gboolean (* can_mount) (GVolume *volume);
  127. gboolean (* can_eject) (GVolume *volume);
  128. void (* mount_fn) (GVolume *volume,
  129. GMountMountFlags flags,
  130. GMountOperation *mount_operation,
  131. GCancellable *cancellable,
  132. GAsyncReadyCallback callback,
  133. gpointer user_data);
  134. gboolean (* mount_finish) (GVolume *volume,
  135. GAsyncResult *result,
  136. GError **error);
  137. void (* eject) (GVolume *volume,
  138. GMountUnmountFlags flags,
  139. GCancellable *cancellable,
  140. GAsyncReadyCallback callback,
  141. gpointer user_data);
  142. gboolean (* eject_finish) (GVolume *volume,
  143. GAsyncResult *result,
  144. GError **error);
  145. char * (* get_identifier) (GVolume *volume,
  146. const char *kind);
  147. char ** (* enumerate_identifiers) (GVolume *volume);
  148. gboolean (* should_automount) (GVolume *volume);
  149. GFile * (* get_activation_root) (GVolume *volume);
  150. void (* eject_with_operation) (GVolume *volume,
  151. GMountUnmountFlags flags,
  152. GMountOperation *mount_operation,
  153. GCancellable *cancellable,
  154. GAsyncReadyCallback callback,
  155. gpointer user_data);
  156. gboolean (* eject_with_operation_finish) (GVolume *volume,
  157. GAsyncResult *result,
  158. GError **error);
  159. const gchar * (* get_sort_key) (GVolume *volume);
  160. GIcon * (* get_symbolic_icon) (GVolume *volume);
  161. };
  162. GIO_AVAILABLE_IN_ALL
  163. GType g_volume_get_type (void) G_GNUC_CONST;
  164. GIO_AVAILABLE_IN_ALL
  165. char * g_volume_get_name (GVolume *volume);
  166. GIO_AVAILABLE_IN_ALL
  167. GIcon * g_volume_get_icon (GVolume *volume);
  168. GIO_AVAILABLE_IN_ALL
  169. GIcon * g_volume_get_symbolic_icon (GVolume *volume);
  170. GIO_AVAILABLE_IN_ALL
  171. char * g_volume_get_uuid (GVolume *volume);
  172. GIO_AVAILABLE_IN_ALL
  173. GDrive * g_volume_get_drive (GVolume *volume);
  174. GIO_AVAILABLE_IN_ALL
  175. GMount * g_volume_get_mount (GVolume *volume);
  176. GIO_AVAILABLE_IN_ALL
  177. gboolean g_volume_can_mount (GVolume *volume);
  178. GIO_AVAILABLE_IN_ALL
  179. gboolean g_volume_can_eject (GVolume *volume);
  180. GIO_AVAILABLE_IN_ALL
  181. gboolean g_volume_should_automount (GVolume *volume);
  182. GIO_AVAILABLE_IN_ALL
  183. void g_volume_mount (GVolume *volume,
  184. GMountMountFlags flags,
  185. GMountOperation *mount_operation,
  186. GCancellable *cancellable,
  187. GAsyncReadyCallback callback,
  188. gpointer user_data);
  189. GIO_AVAILABLE_IN_ALL
  190. gboolean g_volume_mount_finish (GVolume *volume,
  191. GAsyncResult *result,
  192. GError **error);
  193. GIO_DEPRECATED_FOR(g_volume_eject_with_operation)
  194. void g_volume_eject (GVolume *volume,
  195. GMountUnmountFlags flags,
  196. GCancellable *cancellable,
  197. GAsyncReadyCallback callback,
  198. gpointer user_data);
  199. GIO_DEPRECATED_FOR(g_volume_eject_with_operation_finish)
  200. gboolean g_volume_eject_finish (GVolume *volume,
  201. GAsyncResult *result,
  202. GError **error);
  203. GIO_AVAILABLE_IN_ALL
  204. char * g_volume_get_identifier (GVolume *volume,
  205. const char *kind);
  206. GIO_AVAILABLE_IN_ALL
  207. char ** g_volume_enumerate_identifiers (GVolume *volume);
  208. GIO_AVAILABLE_IN_ALL
  209. GFile * g_volume_get_activation_root (GVolume *volume);
  210. GIO_AVAILABLE_IN_ALL
  211. void g_volume_eject_with_operation (GVolume *volume,
  212. GMountUnmountFlags flags,
  213. GMountOperation *mount_operation,
  214. GCancellable *cancellable,
  215. GAsyncReadyCallback callback,
  216. gpointer user_data);
  217. GIO_AVAILABLE_IN_ALL
  218. gboolean g_volume_eject_with_operation_finish (GVolume *volume,
  219. GAsyncResult *result,
  220. GError **error);
  221. GIO_AVAILABLE_IN_2_32
  222. const gchar *g_volume_get_sort_key (GVolume *volume);
  223. G_END_DECLS
  224. #endif /* __G_VOLUME_H__ */