gvolume.h 11 KB

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