1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD 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 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gio.DriveIF; 26 27 private import gio.AsyncResultIF; 28 private import gio.Cancellable; 29 private import gio.Icon; 30 private import gio.IconIF; 31 private import gio.MountOperation; 32 private import glib.ErrorG; 33 private import glib.GException; 34 private import glib.ListG; 35 private import glib.Str; 36 private import gobject.ObjectG; 37 private import gobject.Signals; 38 private import gtkc.gio; 39 public import gtkc.giotypes; 40 private import std.algorithm; 41 42 43 /** 44 * #GDrive - this represent a piece of hardware connected to the machine. 45 * It's generally only created for removable hardware or hardware with 46 * removable media. 47 * 48 * #GDrive is a container class for #GVolume objects that stem from 49 * the same piece of media. As such, #GDrive abstracts a drive with 50 * (or without) removable media and provides operations for querying 51 * whether media is available, determining whether media change is 52 * automatically detected and ejecting the media. 53 * 54 * If the #GDrive reports that media isn't automatically detected, one 55 * can poll for media; typically one should not do this periodically 56 * as a poll for media operation is potententially expensive and may 57 * spin up the drive creating noise. 58 * 59 * #GDrive supports starting and stopping drives with authentication 60 * support for the former. This can be used to support a diverse set 61 * of use cases including connecting/disconnecting iSCSI devices, 62 * powering down external disk enclosures and starting/stopping 63 * multi-disk devices such as RAID devices. Note that the actual 64 * semantics and side-effects of starting/stopping a #GDrive may vary 65 * according to implementation. To choose the correct verbs in e.g. a 66 * file manager, use g_drive_get_start_stop_type(). 67 * 68 * For porting from GnomeVFS note that there is no equivalent of 69 * #GDrive in that API. 70 */ 71 public interface DriveIF{ 72 /** Get the main Gtk struct */ 73 public GDrive* getDriveStruct(bool transferOwnership = false); 74 75 /** the main Gtk struct as a void* */ 76 protected void* getStruct(); 77 78 79 /** 80 * Checks if a drive can be ejected. 81 * 82 * Returns: %TRUE if the @drive can be ejected, %FALSE otherwise. 83 */ 84 public bool canEject(); 85 86 /** 87 * Checks if a drive can be polled for media changes. 88 * 89 * Returns: %TRUE if the @drive can be polled for media changes, 90 * %FALSE otherwise. 91 */ 92 public bool canPollForMedia(); 93 94 /** 95 * Checks if a drive can be started. 96 * 97 * Returns: %TRUE if the @drive can be started, %FALSE otherwise. 98 * 99 * Since: 2.22 100 */ 101 public bool canStart(); 102 103 /** 104 * Checks if a drive can be started degraded. 105 * 106 * Returns: %TRUE if the @drive can be started degraded, %FALSE otherwise. 107 * 108 * Since: 2.22 109 */ 110 public bool canStartDegraded(); 111 112 /** 113 * Checks if a drive can be stopped. 114 * 115 * Returns: %TRUE if the @drive can be stopped, %FALSE otherwise. 116 * 117 * Since: 2.22 118 */ 119 public bool canStop(); 120 121 /** 122 * Asynchronously ejects a drive. 123 * 124 * When the operation is finished, @callback will be called. 125 * You can then call g_drive_eject_finish() to obtain the 126 * result of the operation. 127 * 128 * Deprecated: Use g_drive_eject_with_operation() instead. 129 * 130 * Params: 131 * flags = flags affecting the unmount if required for eject 132 * cancellable = optional #GCancellable object, %NULL to ignore. 133 * callback = a #GAsyncReadyCallback, or %NULL. 134 * userData = user data to pass to @callback 135 */ 136 public void eject(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 137 138 /** 139 * Finishes ejecting a drive. 140 * 141 * Deprecated: Use g_drive_eject_with_operation_finish() instead. 142 * 143 * Params: 144 * result = a #GAsyncResult. 145 * 146 * Returns: %TRUE if the drive has been ejected successfully, 147 * %FALSE otherwise. 148 * 149 * Throws: GException on failure. 150 */ 151 public bool ejectFinish(AsyncResultIF result); 152 153 /** 154 * Ejects a drive. This is an asynchronous operation, and is 155 * finished by calling g_drive_eject_with_operation_finish() with the @drive 156 * and #GAsyncResult data returned in the @callback. 157 * 158 * Params: 159 * flags = flags affecting the unmount if required for eject 160 * mountOperation = a #GMountOperation or %NULL to avoid 161 * user interaction. 162 * cancellable = optional #GCancellable object, %NULL to ignore. 163 * callback = a #GAsyncReadyCallback, or %NULL. 164 * userData = user data passed to @callback. 165 * 166 * Since: 2.22 167 */ 168 public void ejectWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 169 170 /** 171 * Finishes ejecting a drive. If any errors occurred during the operation, 172 * @error will be set to contain the errors and %FALSE will be returned. 173 * 174 * Params: 175 * result = a #GAsyncResult. 176 * 177 * Returns: %TRUE if the drive was successfully ejected. %FALSE otherwise. 178 * 179 * Since: 2.22 180 * 181 * Throws: GException on failure. 182 */ 183 public bool ejectWithOperationFinish(AsyncResultIF result); 184 185 /** 186 * Gets the kinds of identifiers that @drive has. 187 * Use g_drive_get_identifier() to obtain the identifiers 188 * themselves. 189 * 190 * Returns: a %NULL-terminated 191 * array of strings containing kinds of identifiers. Use g_strfreev() 192 * to free. 193 */ 194 public string[] enumerateIdentifiers(); 195 196 /** 197 * Gets the icon for @drive. 198 * 199 * Returns: #GIcon for the @drive. 200 * Free the returned object with g_object_unref(). 201 */ 202 public IconIF getIcon(); 203 204 /** 205 * Gets the identifier of the given kind for @drive. 206 * 207 * Params: 208 * kind = the kind of identifier to return 209 * 210 * Returns: a newly allocated string containing the 211 * requested identfier, or %NULL if the #GDrive 212 * doesn't have this kind of identifier. 213 */ 214 public string getIdentifier(string kind); 215 216 /** 217 * Gets the name of @drive. 218 * 219 * Returns: a string containing @drive's name. The returned 220 * string should be freed when no longer needed. 221 */ 222 public string getName(); 223 224 /** 225 * Gets the sort key for @drive, if any. 226 * 227 * Returns: Sorting key for @drive or %NULL if no such key is available. 228 * 229 * Since: 2.32 230 */ 231 public string getSortKey(); 232 233 /** 234 * Gets a hint about how a drive can be started/stopped. 235 * 236 * Returns: A value from the #GDriveStartStopType enumeration. 237 * 238 * Since: 2.22 239 */ 240 public GDriveStartStopType getStartStopType(); 241 242 /** 243 * Gets the icon for @drive. 244 * 245 * Returns: symbolic #GIcon for the @drive. 246 * Free the returned object with g_object_unref(). 247 * 248 * Since: 2.34 249 */ 250 public IconIF getSymbolicIcon(); 251 252 /** 253 * Get a list of mountable volumes for @drive. 254 * 255 * The returned list should be freed with g_list_free(), after 256 * its elements have been unreffed with g_object_unref(). 257 * 258 * Returns: #GList containing any #GVolume objects on the given @drive. 259 */ 260 public ListG getVolumes(); 261 262 /** 263 * Checks if the @drive has media. Note that the OS may not be polling 264 * the drive for media changes; see g_drive_is_media_check_automatic() 265 * for more details. 266 * 267 * Returns: %TRUE if @drive has media, %FALSE otherwise. 268 */ 269 public bool hasMedia(); 270 271 /** 272 * Check if @drive has any mountable volumes. 273 * 274 * Returns: %TRUE if the @drive contains volumes, %FALSE otherwise. 275 */ 276 public bool hasVolumes(); 277 278 /** 279 * Checks if @drive is capabable of automatically detecting media changes. 280 * 281 * Returns: %TRUE if the @drive is capabable of automatically detecting 282 * media changes, %FALSE otherwise. 283 */ 284 public bool isMediaCheckAutomatic(); 285 286 /** 287 * Checks if the @drive supports removable media. 288 * 289 * Returns: %TRUE if @drive supports removable media, %FALSE otherwise. 290 */ 291 public bool isMediaRemovable(); 292 293 /** 294 * Checks if the #GDrive and/or its media is considered removable by the user. 295 * See g_drive_is_media_removable(). 296 * 297 * Returns: %TRUE if @drive and/or its media is considered removable, %FALSE otherwise. 298 * 299 * Since: 2.50 300 */ 301 public bool isRemovable(); 302 303 /** 304 * Asynchronously polls @drive to see if media has been inserted or removed. 305 * 306 * When the operation is finished, @callback will be called. 307 * You can then call g_drive_poll_for_media_finish() to obtain the 308 * result of the operation. 309 * 310 * Params: 311 * cancellable = optional #GCancellable object, %NULL to ignore. 312 * callback = a #GAsyncReadyCallback, or %NULL. 313 * userData = user data to pass to @callback 314 */ 315 public void pollForMedia(Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 316 317 /** 318 * Finishes an operation started with g_drive_poll_for_media() on a drive. 319 * 320 * Params: 321 * result = a #GAsyncResult. 322 * 323 * Returns: %TRUE if the drive has been poll_for_mediaed successfully, 324 * %FALSE otherwise. 325 * 326 * Throws: GException on failure. 327 */ 328 public bool pollForMediaFinish(AsyncResultIF result); 329 330 /** 331 * Asynchronously starts a drive. 332 * 333 * When the operation is finished, @callback will be called. 334 * You can then call g_drive_start_finish() to obtain the 335 * result of the operation. 336 * 337 * Params: 338 * flags = flags affecting the start operation. 339 * mountOperation = a #GMountOperation or %NULL to avoid 340 * user interaction. 341 * cancellable = optional #GCancellable object, %NULL to ignore. 342 * callback = a #GAsyncReadyCallback, or %NULL. 343 * userData = user data to pass to @callback 344 * 345 * Since: 2.22 346 */ 347 public void start(GDriveStartFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 348 349 /** 350 * Finishes starting a drive. 351 * 352 * Params: 353 * result = a #GAsyncResult. 354 * 355 * Returns: %TRUE if the drive has been started successfully, 356 * %FALSE otherwise. 357 * 358 * Since: 2.22 359 * 360 * Throws: GException on failure. 361 */ 362 public bool startFinish(AsyncResultIF result); 363 364 /** 365 * Asynchronously stops a drive. 366 * 367 * When the operation is finished, @callback will be called. 368 * You can then call g_drive_stop_finish() to obtain the 369 * result of the operation. 370 * 371 * Params: 372 * flags = flags affecting the unmount if required for stopping. 373 * mountOperation = a #GMountOperation or %NULL to avoid 374 * user interaction. 375 * cancellable = optional #GCancellable object, %NULL to ignore. 376 * callback = a #GAsyncReadyCallback, or %NULL. 377 * userData = user data to pass to @callback 378 * 379 * Since: 2.22 380 */ 381 public void stop(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 382 383 /** 384 * Finishes stopping a drive. 385 * 386 * Params: 387 * result = a #GAsyncResult. 388 * 389 * Returns: %TRUE if the drive has been stopped successfully, 390 * %FALSE otherwise. 391 * 392 * Since: 2.22 393 * 394 * Throws: GException on failure. 395 */ 396 public bool stopFinish(AsyncResultIF result); 397 398 /** 399 * Emitted when the drive's state has changed. 400 */ 401 gulong addOnChanged(void delegate(DriveIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 402 403 /** 404 * This signal is emitted when the #GDrive have been 405 * disconnected. If the recipient is holding references to the 406 * object they should release them so the object can be 407 * finalized. 408 */ 409 gulong addOnDisconnected(void delegate(DriveIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 410 411 /** 412 * Emitted when the physical eject button (if any) of a drive has 413 * been pressed. 414 */ 415 gulong addOnEjectButton(void delegate(DriveIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 416 417 /** 418 * Emitted when the physical stop button (if any) of a drive has 419 * been pressed. 420 * 421 * Since: 2.22 422 */ 423 gulong addOnStopButton(void delegate(DriveIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 424 }