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.MountT; 26 27 public import gio.AsyncResultIF; 28 public import gio.Cancellable; 29 public import gio.DriveIF; 30 public import gio.FileIF; 31 public import gio.IconIF; 32 public import gio.MountOperation; 33 public import gio.VolumeIF; 34 public import gio.c.functions; 35 public import gio.c.types; 36 public import glib.ErrorG; 37 public import glib.GException; 38 public import glib.Str; 39 public import gobject.ObjectG; 40 public import gobject.Signals; 41 public import gtkc.giotypes; 42 public import std.algorithm; 43 44 45 /** 46 * The #GMount interface represents user-visible mounts. Note, when 47 * porting from GnomeVFS, #GMount is the moral equivalent of #GnomeVFSVolume. 48 * 49 * #GMount is a "mounted" filesystem that you can access. Mounted is in 50 * quotes because it's not the same as a unix mount, it might be a gvfs 51 * mount, but you can still access the files on it if you use GIO. Might or 52 * might not be related to a volume object. 53 * 54 * Unmounting a #GMount instance is an asynchronous operation. For 55 * more information about asynchronous operations, see #GAsyncResult 56 * and #GTask. To unmount a #GMount instance, first call 57 * g_mount_unmount_with_operation() with (at least) the #GMount instance and a 58 * #GAsyncReadyCallback. The callback will be fired when the 59 * operation has resolved (either with success or failure), and a 60 * #GAsyncResult structure will be passed to the callback. That 61 * callback should then call g_mount_unmount_with_operation_finish() with the #GMount 62 * and the #GAsyncResult data to see if the operation was completed 63 * successfully. If an @error is present when g_mount_unmount_with_operation_finish() 64 * is called, then it will be filled with any error information. 65 */ 66 public template MountT(TStruct) 67 { 68 /** Get the main Gtk struct */ 69 public GMount* getMountStruct(bool transferOwnership = false) 70 { 71 if (transferOwnership) 72 ownedRef = false; 73 return cast(GMount*)getStruct(); 74 } 75 76 77 /** 78 * Checks if @mount can be ejected. 79 * 80 * Returns: %TRUE if the @mount can be ejected. 81 */ 82 public bool canEject() 83 { 84 return g_mount_can_eject(getMountStruct()) != 0; 85 } 86 87 /** 88 * Checks if @mount can be unmounted. 89 * 90 * Returns: %TRUE if the @mount can be unmounted. 91 */ 92 public bool canUnmount() 93 { 94 return g_mount_can_unmount(getMountStruct()) != 0; 95 } 96 97 /** 98 * Ejects a mount. This is an asynchronous operation, and is 99 * finished by calling g_mount_eject_finish() with the @mount 100 * and #GAsyncResult data returned in the @callback. 101 * 102 * Deprecated: Use g_mount_eject_with_operation() instead. 103 * 104 * Params: 105 * flags = flags affecting the unmount if required for eject 106 * cancellable = optional #GCancellable object, %NULL to ignore. 107 * callback = a #GAsyncReadyCallback, or %NULL. 108 * userData = user data passed to @callback. 109 */ 110 public void eject(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 111 { 112 g_mount_eject(getMountStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 113 } 114 115 /** 116 * Finishes ejecting a mount. If any errors occurred during the operation, 117 * @error will be set to contain the errors and %FALSE will be returned. 118 * 119 * Deprecated: Use g_mount_eject_with_operation_finish() instead. 120 * 121 * Params: 122 * result = a #GAsyncResult. 123 * 124 * Returns: %TRUE if the mount was successfully ejected. %FALSE otherwise. 125 * 126 * Throws: GException on failure. 127 */ 128 public bool ejectFinish(AsyncResultIF result) 129 { 130 GError* err = null; 131 132 auto __p = g_mount_eject_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 133 134 if (err !is null) 135 { 136 throw new GException( new ErrorG(err) ); 137 } 138 139 return __p; 140 } 141 142 /** 143 * Ejects a mount. This is an asynchronous operation, and is 144 * finished by calling g_mount_eject_with_operation_finish() with the @mount 145 * and #GAsyncResult data returned in the @callback. 146 * 147 * Params: 148 * flags = flags affecting the unmount if required for eject 149 * mountOperation = a #GMountOperation or %NULL to avoid 150 * user interaction. 151 * cancellable = optional #GCancellable object, %NULL to ignore. 152 * callback = a #GAsyncReadyCallback, or %NULL. 153 * userData = user data passed to @callback. 154 * 155 * Since: 2.22 156 */ 157 public void ejectWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 158 { 159 g_mount_eject_with_operation(getMountStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 160 } 161 162 /** 163 * Finishes ejecting a mount. If any errors occurred during the operation, 164 * @error will be set to contain the errors and %FALSE will be returned. 165 * 166 * Params: 167 * result = a #GAsyncResult. 168 * 169 * Returns: %TRUE if the mount was successfully ejected. %FALSE otherwise. 170 * 171 * Since: 2.22 172 * 173 * Throws: GException on failure. 174 */ 175 public bool ejectWithOperationFinish(AsyncResultIF result) 176 { 177 GError* err = null; 178 179 auto __p = g_mount_eject_with_operation_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 180 181 if (err !is null) 182 { 183 throw new GException( new ErrorG(err) ); 184 } 185 186 return __p; 187 } 188 189 /** 190 * Gets the default location of @mount. The default location of the given 191 * @mount is a path that reflects the main entry point for the user (e.g. 192 * the home directory, or the root of the volume). 193 * 194 * Returns: a #GFile. 195 * The returned object should be unreffed with 196 * g_object_unref() when no longer needed. 197 */ 198 public FileIF getDefaultLocation() 199 { 200 auto __p = g_mount_get_default_location(getMountStruct()); 201 202 if(__p is null) 203 { 204 return null; 205 } 206 207 return ObjectG.getDObject!(FileIF)(cast(GFile*) __p, true); 208 } 209 210 /** 211 * Gets the drive for the @mount. 212 * 213 * This is a convenience method for getting the #GVolume and then 214 * using that object to get the #GDrive. 215 * 216 * Returns: a #GDrive or %NULL if @mount is not 217 * associated with a volume or a drive. 218 * The returned object should be unreffed with 219 * g_object_unref() when no longer needed. 220 */ 221 public DriveIF getDrive() 222 { 223 auto __p = g_mount_get_drive(getMountStruct()); 224 225 if(__p is null) 226 { 227 return null; 228 } 229 230 return ObjectG.getDObject!(DriveIF)(cast(GDrive*) __p, true); 231 } 232 233 /** 234 * Gets the icon for @mount. 235 * 236 * Returns: a #GIcon. 237 * The returned object should be unreffed with 238 * g_object_unref() when no longer needed. 239 */ 240 public IconIF getIcon() 241 { 242 auto __p = g_mount_get_icon(getMountStruct()); 243 244 if(__p is null) 245 { 246 return null; 247 } 248 249 return ObjectG.getDObject!(IconIF)(cast(GIcon*) __p, true); 250 } 251 252 /** 253 * Gets the name of @mount. 254 * 255 * Returns: the name for the given @mount. 256 * The returned string should be freed with g_free() 257 * when no longer needed. 258 */ 259 public string getName() 260 { 261 auto retStr = g_mount_get_name(getMountStruct()); 262 263 scope(exit) Str.freeString(retStr); 264 return Str.toString(retStr); 265 } 266 267 /** 268 * Gets the root directory on @mount. 269 * 270 * Returns: a #GFile. 271 * The returned object should be unreffed with 272 * g_object_unref() when no longer needed. 273 */ 274 public FileIF getRoot() 275 { 276 auto __p = g_mount_get_root(getMountStruct()); 277 278 if(__p is null) 279 { 280 return null; 281 } 282 283 return ObjectG.getDObject!(FileIF)(cast(GFile*) __p, true); 284 } 285 286 /** 287 * Gets the sort key for @mount, if any. 288 * 289 * Returns: Sorting key for @mount or %NULL if no such key is available. 290 * 291 * Since: 2.32 292 */ 293 public string getSortKey() 294 { 295 return Str.toString(g_mount_get_sort_key(getMountStruct())); 296 } 297 298 /** 299 * Gets the symbolic icon for @mount. 300 * 301 * Returns: a #GIcon. 302 * The returned object should be unreffed with 303 * g_object_unref() when no longer needed. 304 * 305 * Since: 2.34 306 */ 307 public IconIF getSymbolicIcon() 308 { 309 auto __p = g_mount_get_symbolic_icon(getMountStruct()); 310 311 if(__p is null) 312 { 313 return null; 314 } 315 316 return ObjectG.getDObject!(IconIF)(cast(GIcon*) __p, true); 317 } 318 319 /** 320 * Gets the UUID for the @mount. The reference is typically based on 321 * the file system UUID for the mount in question and should be 322 * considered an opaque string. Returns %NULL if there is no UUID 323 * available. 324 * 325 * Returns: the UUID for @mount or %NULL if no UUID 326 * can be computed. 327 * The returned string should be freed with g_free() 328 * when no longer needed. 329 */ 330 public string getUuid() 331 { 332 auto retStr = g_mount_get_uuid(getMountStruct()); 333 334 scope(exit) Str.freeString(retStr); 335 return Str.toString(retStr); 336 } 337 338 /** 339 * Gets the volume for the @mount. 340 * 341 * Returns: a #GVolume or %NULL if @mount is not 342 * associated with a volume. 343 * The returned object should be unreffed with 344 * g_object_unref() when no longer needed. 345 */ 346 public VolumeIF getVolume() 347 { 348 auto __p = g_mount_get_volume(getMountStruct()); 349 350 if(__p is null) 351 { 352 return null; 353 } 354 355 return ObjectG.getDObject!(VolumeIF)(cast(GVolume*) __p, true); 356 } 357 358 /** 359 * Tries to guess the type of content stored on @mount. Returns one or 360 * more textual identifiers of well-known content types (typically 361 * prefixed with "x-content/"), e.g. x-content/image-dcf for camera 362 * memory cards. See the 363 * [shared-mime-info](http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec) 364 * specification for more on x-content types. 365 * 366 * This is an asynchronous operation (see 367 * g_mount_guess_content_type_sync() for the synchronous version), and 368 * is finished by calling g_mount_guess_content_type_finish() with the 369 * @mount and #GAsyncResult data returned in the @callback. 370 * 371 * Params: 372 * forceRescan = Whether to force a rescan of the content. 373 * Otherwise a cached result will be used if available 374 * cancellable = optional #GCancellable object, %NULL to ignore 375 * callback = a #GAsyncReadyCallback 376 * userData = user data passed to @callback 377 * 378 * Since: 2.18 379 */ 380 public void guessContentType(bool forceRescan, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 381 { 382 g_mount_guess_content_type(getMountStruct(), forceRescan, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 383 } 384 385 /** 386 * Finishes guessing content types of @mount. If any errors occurred 387 * during the operation, @error will be set to contain the errors and 388 * %FALSE will be returned. In particular, you may get an 389 * %G_IO_ERROR_NOT_SUPPORTED if the mount does not support content 390 * guessing. 391 * 392 * Params: 393 * result = a #GAsyncResult 394 * 395 * Returns: a %NULL-terminated array of content types or %NULL on error. 396 * Caller should free this array with g_strfreev() when done with it. 397 * 398 * Since: 2.18 399 * 400 * Throws: GException on failure. 401 */ 402 public string[] guessContentTypeFinish(AsyncResultIF result) 403 { 404 GError* err = null; 405 406 auto retStr = g_mount_guess_content_type_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err); 407 408 if (err !is null) 409 { 410 throw new GException( new ErrorG(err) ); 411 } 412 413 scope(exit) Str.freeStringArray(retStr); 414 return Str.toStringArray(retStr); 415 } 416 417 /** 418 * Tries to guess the type of content stored on @mount. Returns one or 419 * more textual identifiers of well-known content types (typically 420 * prefixed with "x-content/"), e.g. x-content/image-dcf for camera 421 * memory cards. See the 422 * [shared-mime-info](http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec) 423 * specification for more on x-content types. 424 * 425 * This is a synchronous operation and as such may block doing IO; 426 * see g_mount_guess_content_type() for the asynchronous version. 427 * 428 * Params: 429 * forceRescan = Whether to force a rescan of the content. 430 * Otherwise a cached result will be used if available 431 * cancellable = optional #GCancellable object, %NULL to ignore 432 * 433 * Returns: a %NULL-terminated array of content types or %NULL on error. 434 * Caller should free this array with g_strfreev() when done with it. 435 * 436 * Since: 2.18 437 * 438 * Throws: GException on failure. 439 */ 440 public string[] guessContentTypeSync(bool forceRescan, Cancellable cancellable) 441 { 442 GError* err = null; 443 444 auto retStr = g_mount_guess_content_type_sync(getMountStruct(), forceRescan, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 445 446 if (err !is null) 447 { 448 throw new GException( new ErrorG(err) ); 449 } 450 451 scope(exit) Str.freeStringArray(retStr); 452 return Str.toStringArray(retStr); 453 } 454 455 /** 456 * Determines if @mount is shadowed. Applications or libraries should 457 * avoid displaying @mount in the user interface if it is shadowed. 458 * 459 * A mount is said to be shadowed if there exists one or more user 460 * visible objects (currently #GMount objects) with a root that is 461 * inside the root of @mount. 462 * 463 * One application of shadow mounts is when exposing a single file 464 * system that is used to address several logical volumes. In this 465 * situation, a #GVolumeMonitor implementation would create two 466 * #GVolume objects (for example, one for the camera functionality of 467 * the device and one for a SD card reader on the device) with 468 * activation URIs `gphoto2://[usb:001,002]/store1/` 469 * and `gphoto2://[usb:001,002]/store2/`. When the 470 * underlying mount (with root 471 * `gphoto2://[usb:001,002]/`) is mounted, said 472 * #GVolumeMonitor implementation would create two #GMount objects 473 * (each with their root matching the corresponding volume activation 474 * root) that would shadow the original mount. 475 * 476 * The proxy monitor in GVfs 2.26 and later, automatically creates and 477 * manage shadow mounts (and shadows the underlying mount) if the 478 * activation root on a #GVolume is set. 479 * 480 * Returns: %TRUE if @mount is shadowed. 481 * 482 * Since: 2.20 483 */ 484 public bool isShadowed() 485 { 486 return g_mount_is_shadowed(getMountStruct()) != 0; 487 } 488 489 /** 490 * Remounts a mount. This is an asynchronous operation, and is 491 * finished by calling g_mount_remount_finish() with the @mount 492 * and #GAsyncResults data returned in the @callback. 493 * 494 * Remounting is useful when some setting affecting the operation 495 * of the volume has been changed, as these may need a remount to 496 * take affect. While this is semantically equivalent with unmounting 497 * and then remounting not all backends might need to actually be 498 * unmounted. 499 * 500 * Params: 501 * flags = flags affecting the operation 502 * mountOperation = a #GMountOperation or %NULL to avoid 503 * user interaction. 504 * cancellable = optional #GCancellable object, %NULL to ignore. 505 * callback = a #GAsyncReadyCallback, or %NULL. 506 * userData = user data passed to @callback. 507 */ 508 public void remount(GMountMountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 509 { 510 g_mount_remount(getMountStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 511 } 512 513 /** 514 * Finishes remounting a mount. If any errors occurred during the operation, 515 * @error will be set to contain the errors and %FALSE will be returned. 516 * 517 * Params: 518 * result = a #GAsyncResult. 519 * 520 * Returns: %TRUE if the mount was successfully remounted. %FALSE otherwise. 521 * 522 * Throws: GException on failure. 523 */ 524 public bool remountFinish(AsyncResultIF result) 525 { 526 GError* err = null; 527 528 auto __p = g_mount_remount_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 529 530 if (err !is null) 531 { 532 throw new GException( new ErrorG(err) ); 533 } 534 535 return __p; 536 } 537 538 /** 539 * Increments the shadow count on @mount. Usually used by 540 * #GVolumeMonitor implementations when creating a shadow mount for 541 * @mount, see g_mount_is_shadowed() for more information. The caller 542 * will need to emit the #GMount::changed signal on @mount manually. 543 * 544 * Since: 2.20 545 */ 546 public void shadow() 547 { 548 g_mount_shadow(getMountStruct()); 549 } 550 551 /** 552 * Unmounts a mount. This is an asynchronous operation, and is 553 * finished by calling g_mount_unmount_finish() with the @mount 554 * and #GAsyncResult data returned in the @callback. 555 * 556 * Deprecated: Use g_mount_unmount_with_operation() instead. 557 * 558 * Params: 559 * flags = flags affecting the operation 560 * cancellable = optional #GCancellable object, %NULL to ignore. 561 * callback = a #GAsyncReadyCallback, or %NULL. 562 * userData = user data passed to @callback. 563 */ 564 public void unmount(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 565 { 566 g_mount_unmount(getMountStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 567 } 568 569 /** 570 * Finishes unmounting a mount. If any errors occurred during the operation, 571 * @error will be set to contain the errors and %FALSE will be returned. 572 * 573 * Deprecated: Use g_mount_unmount_with_operation_finish() instead. 574 * 575 * Params: 576 * result = a #GAsyncResult. 577 * 578 * Returns: %TRUE if the mount was successfully unmounted. %FALSE otherwise. 579 * 580 * Throws: GException on failure. 581 */ 582 public bool unmountFinish(AsyncResultIF result) 583 { 584 GError* err = null; 585 586 auto __p = g_mount_unmount_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 587 588 if (err !is null) 589 { 590 throw new GException( new ErrorG(err) ); 591 } 592 593 return __p; 594 } 595 596 /** 597 * Unmounts a mount. This is an asynchronous operation, and is 598 * finished by calling g_mount_unmount_with_operation_finish() with the @mount 599 * and #GAsyncResult data returned in the @callback. 600 * 601 * Params: 602 * flags = flags affecting the operation 603 * mountOperation = a #GMountOperation or %NULL to avoid 604 * user interaction. 605 * cancellable = optional #GCancellable object, %NULL to ignore. 606 * callback = a #GAsyncReadyCallback, or %NULL. 607 * userData = user data passed to @callback. 608 * 609 * Since: 2.22 610 */ 611 public void unmountWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 612 { 613 g_mount_unmount_with_operation(getMountStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 614 } 615 616 /** 617 * Finishes unmounting a mount. If any errors occurred during the operation, 618 * @error will be set to contain the errors and %FALSE will be returned. 619 * 620 * Params: 621 * result = a #GAsyncResult. 622 * 623 * Returns: %TRUE if the mount was successfully unmounted. %FALSE otherwise. 624 * 625 * Since: 2.22 626 * 627 * Throws: GException on failure. 628 */ 629 public bool unmountWithOperationFinish(AsyncResultIF result) 630 { 631 GError* err = null; 632 633 auto __p = g_mount_unmount_with_operation_finish(getMountStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 634 635 if (err !is null) 636 { 637 throw new GException( new ErrorG(err) ); 638 } 639 640 return __p; 641 } 642 643 /** 644 * Decrements the shadow count on @mount. Usually used by 645 * #GVolumeMonitor implementations when destroying a shadow mount for 646 * @mount, see g_mount_is_shadowed() for more information. The caller 647 * will need to emit the #GMount::changed signal on @mount manually. 648 * 649 * Since: 2.20 650 */ 651 public void unshadow() 652 { 653 g_mount_unshadow(getMountStruct()); 654 } 655 656 /** 657 * Emitted when the mount has been changed. 658 */ 659 gulong addOnChanged(void delegate(MountIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 660 { 661 return Signals.connect(this, "changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 662 } 663 664 /** 665 * This signal may be emitted when the #GMount is about to be 666 * unmounted. 667 * 668 * This signal depends on the backend and is only emitted if 669 * GIO was used to unmount. 670 * 671 * Since: 2.22 672 */ 673 gulong addOnPreUnmount(void delegate(MountIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 674 { 675 return Signals.connect(this, "pre-unmount", dlg, connectFlags ^ ConnectFlags.SWAPPED); 676 } 677 678 /** 679 * This signal is emitted when the #GMount have been 680 * unmounted. If the recipient is holding references to the 681 * object they should release them so the object can be 682 * finalized. 683 */ 684 gulong addOnUnmounted(void delegate(MountIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 685 { 686 return Signals.connect(this, "unmounted", dlg, connectFlags ^ ConnectFlags.SWAPPED); 687 } 688 }