gvolume.h 11 KB

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