13781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/* GIO - GLib Input, Output and Streaming Library 23781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 33781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Copyright (C) 2006-2007 Red Hat, Inc. 43781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 53781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * This library is free software; you can redistribute it and/or 63781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * modify it under the terms of the GNU Lesser General Public 73781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * License as published by the Free Software Foundation; either 83781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * version 2 of the License, or (at your option) any later version. 93781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 103781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * This library is distributed in the hope that it will be useful, 113781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * but WITHOUT ANY WARRANTY; without even the implied warranty of 123781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 133781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Lesser General Public License for more details. 143781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 153781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * You should have received a copy of the GNU Lesser General 163781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Public License along with this library; if not, write to the 173781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 183781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Boston, MA 02111-1307, USA. 193781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 203781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Author: Alexander Larsson <alexl@redhat.com> 213ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * David Zeuthen <davidz@redhat.com> 223781343738de4abddf56982325a77bd70a98cd26Alexander Larsson */ 233781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 24761424465aaad736916b029383483b6ac419d831Johan Dahlin#include "config.h" 253ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen#include "gmount.h" 263781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#include "gvolume.h" 273d93bf6968884d75dd2706ef85e2014305eb92f2Cody Russell#include "gasyncresult.h" 283781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#include "gsimpleasyncresult.h" 293d93bf6968884d75dd2706ef85e2014305eb92f2Cody Russell#include "gioerror.h" 303781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#include "glibintl.h" 313781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 327f3280230bc9448a5750fc17a6eabef691ba25f4Alexander Larsson#include "gioalias.h" 337f3280230bc9448a5750fc17a6eabef691ba25f4Alexander Larsson 345247f12f3649726471080440de0d37b78c1cec33Andrew Walton/** 350debd52858ffb4f468e55cd2f3c7e4dec5455b94Matthias Clasen * SECTION:gvolume 360debd52858ffb4f468e55cd2f3c7e4dec5455b94Matthias Clasen * @short_description: Volume management 37f3144c7efe8c84f7a00bff9b796d5e73efc151cfMatthias Clasen * @include: gio/gio.h 385247f12f3649726471080440de0d37b78c1cec33Andrew Walton * 393ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * The #GVolume interface represents user-visible objects that can be 403ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * mounted. Note, when porting from GnomeVFS, #GVolume is the moral 413ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * equivalent of #GnomeVFSDrive. 425247f12f3649726471080440de0d37b78c1cec33Andrew Walton * 433ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * Mounting a #GVolume instance is an asynchronous operation. For more 443ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * information about asynchronous operations, see #GAsyncReady and 453ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * #GSimpleAsyncReady. To mount a #GVolume, first call 4688679aba98d30ba069edfffb46257ef77451d641David Zeuthen * g_volume_mount() with (at least) the #GVolume instance, optionally 4788679aba98d30ba069edfffb46257ef77451d641David Zeuthen * a #GMountOperation object and a #GAsyncReadyCallback. 4888679aba98d30ba069edfffb46257ef77451d641David Zeuthen * 4988679aba98d30ba069edfffb46257ef77451d641David Zeuthen * Typically, one will only want to pass %NULL for the 5088679aba98d30ba069edfffb46257ef77451d641David Zeuthen * #GMountOperation if automounting all volumes when a desktop session 5188679aba98d30ba069edfffb46257ef77451d641David Zeuthen * starts since it's not desirable to put up a lot of dialogs asking 5288679aba98d30ba069edfffb46257ef77451d641David Zeuthen * for credentials. 5388679aba98d30ba069edfffb46257ef77451d641David Zeuthen * 5488679aba98d30ba069edfffb46257ef77451d641David Zeuthen * The callback will be fired when the operation has resolved (either 5588679aba98d30ba069edfffb46257ef77451d641David Zeuthen * with success or failure), and a #GAsyncReady structure will be 5688679aba98d30ba069edfffb46257ef77451d641David Zeuthen * passed to the callback. That callback should then call 5788679aba98d30ba069edfffb46257ef77451d641David Zeuthen * g_volume_mount_finish() with the #GVolume instance and the 5888679aba98d30ba069edfffb46257ef77451d641David Zeuthen * #GAsyncReady data to see if the operation was completed 5988679aba98d30ba069edfffb46257ef77451d641David Zeuthen * successfully. If an @error is present when g_volume_mount_finish() 6088679aba98d30ba069edfffb46257ef77451d641David Zeuthen * is called, then it will be filled with any error information. 61826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * 62826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * <para id="volume-identifier"> 632c1dc529e8d9b1ab2d8ccb8abb1efed836584616Matthias Clasen * It is sometimes necessary to directly access the underlying 64826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * operating system object behind a volume (e.g. for passing a volume 65826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * to an application via the commandline). For this purpose, GIO 66826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * allows to obtain an 'identifier' for the volume. There can be 67826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * different kinds of identifiers, such as Hal UDIs, filesystem labels, 68826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * traditional Unix devices (e.g. <filename>/dev/sda2</filename>), 69826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * uuids. GIO uses predefind strings as names for the different kinds 702c1dc529e8d9b1ab2d8ccb8abb1efed836584616Matthias Clasen * of identifiers: #G_VOLUME_IDENTIFIER_KIND_HAL_UDI, 712c1dc529e8d9b1ab2d8ccb8abb1efed836584616Matthias Clasen * #G_VOLUME_IDENTIFIER_KIND_LABEL, etc. Use g_volume_get_identifier() 72826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * to obtain an identifier for a volume. 73826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * </para> 742c1dc529e8d9b1ab2d8ccb8abb1efed836584616Matthias Clasen * 752c1dc529e8d9b1ab2d8ccb8abb1efed836584616Matthias Clasen * Note that #G_VOLUME_IDENTIFIER_KIND_HAL_UDI will only be available 762c1dc529e8d9b1ab2d8ccb8abb1efed836584616Matthias Clasen * when the gvfs hal volume monitor is in use. Other volume monitors 772c1dc529e8d9b1ab2d8ccb8abb1efed836584616Matthias Clasen * will generally be able to provide the #G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE 782c1dc529e8d9b1ab2d8ccb8abb1efed836584616Matthias Clasen * identifier, which can be used to obtain a hal device by means of 792c1dc529e8d9b1ab2d8ccb8abb1efed836584616Matthias Clasen * libhal_manger_find_device_string_match(). 802c1dc529e8d9b1ab2d8ccb8abb1efed836584616Matthias Clasen */ 815247f12f3649726471080440de0d37b78c1cec33Andrew Walton 823781343738de4abddf56982325a77bd70a98cd26Alexander Larssonstatic void g_volume_base_init (gpointer g_class); 833781343738de4abddf56982325a77bd70a98cd26Alexander Larssonstatic void g_volume_class_init (gpointer g_class, 843ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen gpointer class_data); 853781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 863781343738de4abddf56982325a77bd70a98cd26Alexander LarssonGType 873781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_volume_get_type (void) 883781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{ 89acb7f6449a8c553e4e4564cc24ed9916168b7e5fMatthias Clasen static volatile gsize g_define_type_id__volatile = 0; 903781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 91acb7f6449a8c553e4e4564cc24ed9916168b7e5fMatthias Clasen if (g_once_init_enter (&g_define_type_id__volatile)) 923781343738de4abddf56982325a77bd70a98cd26Alexander Larsson { 93acb7f6449a8c553e4e4564cc24ed9916168b7e5fMatthias Clasen const GTypeInfo volume_info = 943781343738de4abddf56982325a77bd70a98cd26Alexander Larsson { 953781343738de4abddf56982325a77bd70a98cd26Alexander Larsson sizeof (GVolumeIface), /* class_size */ 963781343738de4abddf56982325a77bd70a98cd26Alexander Larsson g_volume_base_init, /* base_init */ 973781343738de4abddf56982325a77bd70a98cd26Alexander Larsson NULL, /* base_finalize */ 983781343738de4abddf56982325a77bd70a98cd26Alexander Larsson g_volume_class_init, 993781343738de4abddf56982325a77bd70a98cd26Alexander Larsson NULL, /* class_finalize */ 1003781343738de4abddf56982325a77bd70a98cd26Alexander Larsson NULL, /* class_data */ 1013781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 0, 1023781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 0, /* n_preallocs */ 1033781343738de4abddf56982325a77bd70a98cd26Alexander Larsson NULL 1043781343738de4abddf56982325a77bd70a98cd26Alexander Larsson }; 105acb7f6449a8c553e4e4564cc24ed9916168b7e5fMatthias Clasen GType g_define_type_id = 1063781343738de4abddf56982325a77bd70a98cd26Alexander Larsson g_type_register_static (G_TYPE_INTERFACE, I_("GVolume"), 1073781343738de4abddf56982325a77bd70a98cd26Alexander Larsson &volume_info, 0); 1083781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 109acb7f6449a8c553e4e4564cc24ed9916168b7e5fMatthias Clasen g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_OBJECT); 110acb7f6449a8c553e4e4564cc24ed9916168b7e5fMatthias Clasen 111acb7f6449a8c553e4e4564cc24ed9916168b7e5fMatthias Clasen g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); 1123781343738de4abddf56982325a77bd70a98cd26Alexander Larsson } 1133781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 114acb7f6449a8c553e4e4564cc24ed9916168b7e5fMatthias Clasen return g_define_type_id__volatile; 1153781343738de4abddf56982325a77bd70a98cd26Alexander Larsson} 1163781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 1173781343738de4abddf56982325a77bd70a98cd26Alexander Larssonstatic void 1183781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_volume_class_init (gpointer g_class, 1193ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen gpointer class_data) 1203781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{ 1213781343738de4abddf56982325a77bd70a98cd26Alexander Larsson} 1223781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 1233781343738de4abddf56982325a77bd70a98cd26Alexander Larssonstatic void 1243781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_volume_base_init (gpointer g_class) 1253781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{ 1263781343738de4abddf56982325a77bd70a98cd26Alexander Larsson static gboolean initialized = FALSE; 1273781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 1283781343738de4abddf56982325a77bd70a98cd26Alexander Larsson if (! initialized) 1293781343738de4abddf56982325a77bd70a98cd26Alexander Larsson { 1305247f12f3649726471080440de0d37b78c1cec33Andrew Walton /** 1315247f12f3649726471080440de0d37b78c1cec33Andrew Walton * GVolume::changed: 1325247f12f3649726471080440de0d37b78c1cec33Andrew Walton * 1335247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Emitted when the volume has been changed. 1345247f12f3649726471080440de0d37b78c1cec33Andrew Walton **/ 1353781343738de4abddf56982325a77bd70a98cd26Alexander Larsson g_signal_new (I_("changed"), 1363781343738de4abddf56982325a77bd70a98cd26Alexander Larsson G_TYPE_VOLUME, 1373781343738de4abddf56982325a77bd70a98cd26Alexander Larsson G_SIGNAL_RUN_LAST, 1383781343738de4abddf56982325a77bd70a98cd26Alexander Larsson G_STRUCT_OFFSET (GVolumeIface, changed), 1393781343738de4abddf56982325a77bd70a98cd26Alexander Larsson NULL, NULL, 1403781343738de4abddf56982325a77bd70a98cd26Alexander Larsson g_cclosure_marshal_VOID__VOID, 1413781343738de4abddf56982325a77bd70a98cd26Alexander Larsson G_TYPE_NONE, 0); 1423781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 14388679aba98d30ba069edfffb46257ef77451d641David Zeuthen /** 14488679aba98d30ba069edfffb46257ef77451d641David Zeuthen * GVolume::removed: 14588679aba98d30ba069edfffb46257ef77451d641David Zeuthen * 14688679aba98d30ba069edfffb46257ef77451d641David Zeuthen * This signal is emitted when the #GVolume have been removed. If 14788679aba98d30ba069edfffb46257ef77451d641David Zeuthen * the recipient is holding references to the object they should 14888679aba98d30ba069edfffb46257ef77451d641David Zeuthen * release them so the object can be finalized. 14988679aba98d30ba069edfffb46257ef77451d641David Zeuthen **/ 15088679aba98d30ba069edfffb46257ef77451d641David Zeuthen g_signal_new (I_("removed"), 15188679aba98d30ba069edfffb46257ef77451d641David Zeuthen G_TYPE_VOLUME, 15288679aba98d30ba069edfffb46257ef77451d641David Zeuthen G_SIGNAL_RUN_LAST, 15388679aba98d30ba069edfffb46257ef77451d641David Zeuthen G_STRUCT_OFFSET (GVolumeIface, removed), 15488679aba98d30ba069edfffb46257ef77451d641David Zeuthen NULL, NULL, 15588679aba98d30ba069edfffb46257ef77451d641David Zeuthen g_cclosure_marshal_VOID__VOID, 15688679aba98d30ba069edfffb46257ef77451d641David Zeuthen G_TYPE_NONE, 0); 15788679aba98d30ba069edfffb46257ef77451d641David Zeuthen 1583781343738de4abddf56982325a77bd70a98cd26Alexander Larsson initialized = TRUE; 1593781343738de4abddf56982325a77bd70a98cd26Alexander Larsson } 1603781343738de4abddf56982325a77bd70a98cd26Alexander Larsson} 1613781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 1623781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/** 1633781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * g_volume_get_name: 1643781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * @volume: a #GVolume. 1653781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 1665247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Gets the name of @volume. 1673781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 168442e8df1b833e3311a214ae1bf02337b0c831544Matthias Clasen * Returns: the name for the given @volume. The returned string should 16907d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * be freed with g_free() when no longer needed. 1703781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/ 1713781343738de4abddf56982325a77bd70a98cd26Alexander Larssonchar * 1723781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_volume_get_name (GVolume *volume) 1733781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{ 1743781343738de4abddf56982325a77bd70a98cd26Alexander Larsson GVolumeIface *iface; 1753781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 1763781343738de4abddf56982325a77bd70a98cd26Alexander Larsson g_return_val_if_fail (G_IS_VOLUME (volume), NULL); 1773781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 1783781343738de4abddf56982325a77bd70a98cd26Alexander Larsson iface = G_VOLUME_GET_IFACE (volume); 1793781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 1803781343738de4abddf56982325a77bd70a98cd26Alexander Larsson return (* iface->get_name) (volume); 1813781343738de4abddf56982325a77bd70a98cd26Alexander Larsson} 1823781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 1833781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/** 1843781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * g_volume_get_icon: 1855247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @volume: a #GVolume. 1863781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 1875247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Gets the icon for @volume. 1883781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 1895247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Returns: a #GIcon. 19007d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * The returned object should be unreffed with g_object_unref() 19107d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * when no longer needed. 1923781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/ 1933781343738de4abddf56982325a77bd70a98cd26Alexander LarssonGIcon * 1943781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_volume_get_icon (GVolume *volume) 1953781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{ 1963781343738de4abddf56982325a77bd70a98cd26Alexander Larsson GVolumeIface *iface; 1973781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 1983781343738de4abddf56982325a77bd70a98cd26Alexander Larsson g_return_val_if_fail (G_IS_VOLUME (volume), NULL); 1993781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 2003781343738de4abddf56982325a77bd70a98cd26Alexander Larsson iface = G_VOLUME_GET_IFACE (volume); 2013781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 2023781343738de4abddf56982325a77bd70a98cd26Alexander Larsson return (* iface->get_icon) (volume); 2033781343738de4abddf56982325a77bd70a98cd26Alexander Larsson} 204f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 205f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen/** 206f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * g_volume_get_uuid: 207f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * @volume: a #GVolume. 208f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * 209f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * Gets the UUID for the @volume. The reference is typically based on 210f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * the file system UUID for the volume in question and should be 211f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * considered an opaque string. Returns %NULL if there is no UUID 212f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * available. 213f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * 214f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * Returns: the UUID for @volume or %NULL if no UUID can be computed. 21507d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * The returned string should be freed with g_free() 21607d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * when no longer needed. 217f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen **/ 218f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthenchar * 219f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeutheng_volume_get_uuid (GVolume *volume) 220f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen{ 221f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen GVolumeIface *iface; 222f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 223f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen g_return_val_if_fail (G_IS_VOLUME (volume), NULL); 224f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 225f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen iface = G_VOLUME_GET_IFACE (volume); 226f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 227f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen return (* iface->get_uuid) (volume); 228f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen} 2293781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 2303781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/** 2313781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * g_volume_get_drive: 2325247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @volume: a #GVolume. 2333781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 2345247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Gets the drive for the @volume. 2353781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 2363ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * Returns: a #GDrive or %NULL if @volume is not associated with a drive. 23707d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * The returned object should be unreffed with g_object_unref() 23807d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * when no longer needed. 2393781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/ 2403781343738de4abddf56982325a77bd70a98cd26Alexander LarssonGDrive * 2413781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_volume_get_drive (GVolume *volume) 2423781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{ 2433781343738de4abddf56982325a77bd70a98cd26Alexander Larsson GVolumeIface *iface; 2443781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 2453781343738de4abddf56982325a77bd70a98cd26Alexander Larsson g_return_val_if_fail (G_IS_VOLUME (volume), NULL); 2463781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 2473781343738de4abddf56982325a77bd70a98cd26Alexander Larsson iface = G_VOLUME_GET_IFACE (volume); 2483781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 2493781343738de4abddf56982325a77bd70a98cd26Alexander Larsson return (* iface->get_drive) (volume); 2503781343738de4abddf56982325a77bd70a98cd26Alexander Larsson} 2513781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 2523781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/** 2533ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * g_volume_get_mount: 2545247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @volume: a #GVolume. 2555247f12f3649726471080440de0d37b78c1cec33Andrew Walton * 2563ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * Gets the mount for the @volume. 2573781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 2583ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * Returns: a #GMount or %NULL if @volume isn't mounted. 25907d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * The returned object should be unreffed with g_object_unref() 26007d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * when no longer needed. 2613781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/ 2623ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid ZeuthenGMount * 2633ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeutheng_volume_get_mount (GVolume *volume) 2643781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{ 2653781343738de4abddf56982325a77bd70a98cd26Alexander Larsson GVolumeIface *iface; 2663781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 2673ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen g_return_val_if_fail (G_IS_VOLUME (volume), NULL); 2683781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 2693781343738de4abddf56982325a77bd70a98cd26Alexander Larsson iface = G_VOLUME_GET_IFACE (volume); 2703781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 2713ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen return (* iface->get_mount) (volume); 2723781343738de4abddf56982325a77bd70a98cd26Alexander Larsson} 2733781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 2743ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen 2753781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/** 2763ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * g_volume_can_mount: 2775247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @volume: a #GVolume. 2783781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 2793ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * Checks if a volume can be mounted. 2803781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 2813ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * Returns: %TRUE if the @volume can be mounted. %FALSE otherwise. 2823781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/ 2833781343738de4abddf56982325a77bd70a98cd26Alexander Larssongboolean 2843ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeutheng_volume_can_mount (GVolume *volume) 2853781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{ 2863781343738de4abddf56982325a77bd70a98cd26Alexander Larsson GVolumeIface *iface; 2873781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 2883781343738de4abddf56982325a77bd70a98cd26Alexander Larsson g_return_val_if_fail (G_IS_VOLUME (volume), FALSE); 2893781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 2903781343738de4abddf56982325a77bd70a98cd26Alexander Larsson iface = G_VOLUME_GET_IFACE (volume); 2913781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 2923ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen if (iface->can_mount == NULL) 2933ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen return FALSE; 2943781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 2953ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen return (* iface->can_mount) (volume); 2963781343738de4abddf56982325a77bd70a98cd26Alexander Larsson} 2973781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 2983781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/** 299f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * g_volume_can_eject: 300f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * @volume: a #GVolume. 301f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * 302f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * Checks if a volume can be ejected. 303f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * 304f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * Returns: %TRUE if the @volume can be ejected. %FALSE otherwise. 305f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen **/ 306f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthengboolean 307f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeutheng_volume_can_eject (GVolume *volume) 308f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen{ 309f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen GVolumeIface *iface; 310f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 311f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen g_return_val_if_fail (G_IS_VOLUME (volume), FALSE); 312f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 313f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen iface = G_VOLUME_GET_IFACE (volume); 314f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 315f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen if (iface->can_eject == NULL) 316f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen return FALSE; 317f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 318f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen return (* iface->can_eject) (volume); 319f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen} 320f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 321826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen/** 322826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * g_volume_should_automount: 323826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * @volume: a #GVolume 324826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * 325826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * Returns whether the volume should be automatically mounted. 326826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * 327826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * Returns: %TRUE if the volume should be automatically mounted. 328826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen */ 32961411a5fc2388639ae8e05f1b984fa4f2bebe4b5Alexander Larssongboolean 33061411a5fc2388639ae8e05f1b984fa4f2bebe4b5Alexander Larssong_volume_should_automount (GVolume *volume) 33161411a5fc2388639ae8e05f1b984fa4f2bebe4b5Alexander Larsson{ 33261411a5fc2388639ae8e05f1b984fa4f2bebe4b5Alexander Larsson GVolumeIface *iface; 33361411a5fc2388639ae8e05f1b984fa4f2bebe4b5Alexander Larsson 33461411a5fc2388639ae8e05f1b984fa4f2bebe4b5Alexander Larsson g_return_val_if_fail (G_IS_VOLUME (volume), FALSE); 33561411a5fc2388639ae8e05f1b984fa4f2bebe4b5Alexander Larsson 33661411a5fc2388639ae8e05f1b984fa4f2bebe4b5Alexander Larsson iface = G_VOLUME_GET_IFACE (volume); 33761411a5fc2388639ae8e05f1b984fa4f2bebe4b5Alexander Larsson 33861411a5fc2388639ae8e05f1b984fa4f2bebe4b5Alexander Larsson if (iface->should_automount == NULL) 33961411a5fc2388639ae8e05f1b984fa4f2bebe4b5Alexander Larsson return FALSE; 34061411a5fc2388639ae8e05f1b984fa4f2bebe4b5Alexander Larsson 34161411a5fc2388639ae8e05f1b984fa4f2bebe4b5Alexander Larsson return (* iface->should_automount) (volume); 34261411a5fc2388639ae8e05f1b984fa4f2bebe4b5Alexander Larsson} 34361411a5fc2388639ae8e05f1b984fa4f2bebe4b5Alexander Larsson 34461411a5fc2388639ae8e05f1b984fa4f2bebe4b5Alexander Larsson 345f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen/** 3463ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * g_volume_mount: 3475247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @volume: a #GVolume. 348e3fdcd1fa78c831f5cea78cf0a2c07bfdb4b6561Alexander Larsson * @flags: flags affecting the operation 34988679aba98d30ba069edfffb46257ef77451d641David Zeuthen * @mount_operation: a #GMountOperation or %NULL to avoid user interaction. 3503ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * @cancellable: optional #GCancellable object, %NULL to ignore. 351218827445d8b83b38c153ef810338cc41dd6d172Murray Cumming * @callback: a #GAsyncReadyCallback, or %NULL. 35207d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * @user_data: user data that gets passed to @callback 3535247f12f3649726471080440de0d37b78c1cec33Andrew Walton * 35407d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * Mounts a volume. This is an asynchronous operation, and is 35507d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * finished by calling g_volume_mount_finish() with the @volume 35607d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * and #GAsyncResult returned in the @callback. 3573781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/ 3583781343738de4abddf56982325a77bd70a98cd26Alexander Larssonvoid 35907d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Claseng_volume_mount (GVolume *volume, 360e3fdcd1fa78c831f5cea78cf0a2c07bfdb4b6561Alexander Larsson GMountMountFlags flags, 3613ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen GMountOperation *mount_operation, 3623ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen GCancellable *cancellable, 3633ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen GAsyncReadyCallback callback, 3643ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen gpointer user_data) 3653781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{ 3663781343738de4abddf56982325a77bd70a98cd26Alexander Larsson GVolumeIface *iface; 3673781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 3683781343738de4abddf56982325a77bd70a98cd26Alexander Larsson g_return_if_fail (G_IS_VOLUME (volume)); 3693781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 3703781343738de4abddf56982325a77bd70a98cd26Alexander Larsson iface = G_VOLUME_GET_IFACE (volume); 3713781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 3723ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen if (iface->mount_fn == NULL) 3733781343738de4abddf56982325a77bd70a98cd26Alexander Larsson { 3743ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen g_simple_async_report_error_in_idle (G_OBJECT (volume), callback, user_data, 3753781343738de4abddf56982325a77bd70a98cd26Alexander Larsson G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, 3763ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen _("volume doesn't implement mount")); 3773781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 3783781343738de4abddf56982325a77bd70a98cd26Alexander Larsson return; 3793781343738de4abddf56982325a77bd70a98cd26Alexander Larsson } 3803781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 381e3fdcd1fa78c831f5cea78cf0a2c07bfdb4b6561Alexander Larsson (* iface->mount_fn) (volume, flags, mount_operation, cancellable, callback, user_data); 3823781343738de4abddf56982325a77bd70a98cd26Alexander Larsson} 3833781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 3843781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/** 3853ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * g_volume_mount_finish: 38607d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * @volume: a #GVolume 38707d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * @result: a #GAsyncResult 38807d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * @error: a #GError location to store an error, or %NULL to ignore 3893781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * 39007d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * Finishes mounting a volume. If any errors occured during the operation, 39107d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * @error will be set to contain the errors and %FALSE will be returned. 3928070d3b02fecbf00b2e9d3b79d42c9402804d6feDavid Zeuthen * 3938070d3b02fecbf00b2e9d3b79d42c9402804d6feDavid Zeuthen * If the mount operation succeeded, g_volume_get_mount() on @volume 3948070d3b02fecbf00b2e9d3b79d42c9402804d6feDavid Zeuthen * is guaranteed to return the mount right after calling this 3958070d3b02fecbf00b2e9d3b79d42c9402804d6feDavid Zeuthen * function; there's no need to listen for the 'mount-added' signal on 3968070d3b02fecbf00b2e9d3b79d42c9402804d6feDavid Zeuthen * #GVolumeMonitor. 3975247f12f3649726471080440de0d37b78c1cec33Andrew Walton * 3983ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen * Returns: %TRUE, %FALSE if operation failed. 3993781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/ 4003781343738de4abddf56982325a77bd70a98cd26Alexander Larssongboolean 40107d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Claseng_volume_mount_finish (GVolume *volume, 40207d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen GAsyncResult *result, 40307d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen GError **error) 4043781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{ 4053781343738de4abddf56982325a77bd70a98cd26Alexander Larsson GVolumeIface *iface; 4063781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 4073781343738de4abddf56982325a77bd70a98cd26Alexander Larsson g_return_val_if_fail (G_IS_VOLUME (volume), FALSE); 4083781343738de4abddf56982325a77bd70a98cd26Alexander Larsson g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE); 4093781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 4103781343738de4abddf56982325a77bd70a98cd26Alexander Larsson if (G_IS_SIMPLE_ASYNC_RESULT (result)) 4113781343738de4abddf56982325a77bd70a98cd26Alexander Larsson { 4123781343738de4abddf56982325a77bd70a98cd26Alexander Larsson GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); 4133781343738de4abddf56982325a77bd70a98cd26Alexander Larsson if (g_simple_async_result_propagate_error (simple, error)) 4143781343738de4abddf56982325a77bd70a98cd26Alexander Larsson return FALSE; 4153781343738de4abddf56982325a77bd70a98cd26Alexander Larsson } 4163781343738de4abddf56982325a77bd70a98cd26Alexander Larsson 4173781343738de4abddf56982325a77bd70a98cd26Alexander Larsson iface = G_VOLUME_GET_IFACE (volume); 4183ca9fd4dbb134088bf70f2f6584f14a559e6820aDavid Zeuthen return (* iface->mount_finish) (volume, result, error); 4193781343738de4abddf56982325a77bd70a98cd26Alexander Larsson} 4207f3280230bc9448a5750fc17a6eabef691ba25f4Alexander Larsson 421f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen/** 422f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * g_volume_eject: 423f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * @volume: a #GVolume. 42433c055feb16c2af1983793463aaea1b57cb881a3Alexander Larsson * @flags: flags affecting the unmount if required for eject 425f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * @cancellable: optional #GCancellable object, %NULL to ignore. 426218827445d8b83b38c153ef810338cc41dd6d172Murray Cumming * @callback: a #GAsyncReadyCallback, or %NULL. 42707d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * @user_data: user data that gets passed to @callback 428f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * 42907d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * Ejects a volume. This is an asynchronous operation, and is 43007d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * finished by calling g_volume_eject_finish() with the @volume 43107d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * and #GAsyncResult returned in the @callback. 432f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen **/ 433f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthenvoid 43407d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Claseng_volume_eject (GVolume *volume, 43533c055feb16c2af1983793463aaea1b57cb881a3Alexander Larsson GMountUnmountFlags flags, 436f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen GCancellable *cancellable, 437f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen GAsyncReadyCallback callback, 438f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen gpointer user_data) 439f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen{ 440f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen GVolumeIface *iface; 441f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 442f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen g_return_if_fail (G_IS_VOLUME (volume)); 443f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 444f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen iface = G_VOLUME_GET_IFACE (volume); 445f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 446f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen if (iface->eject == NULL) 447f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen { 448f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen g_simple_async_report_error_in_idle (G_OBJECT (volume), callback, user_data, 449f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, 450f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen _("volume doesn't implement eject")); 451f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 452f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen return; 453f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen } 454f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 45533c055feb16c2af1983793463aaea1b57cb881a3Alexander Larsson (* iface->eject) (volume, flags, cancellable, callback, user_data); 456f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen} 457f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 458f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen/** 459f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * g_volume_eject_finish: 460f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * @volume: pointer to a #GVolume. 461f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * @result: a #GAsyncResult. 46207d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * @error: a #GError location to store an error, or %NULL to ignore 463f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * 46407d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * Finishes ejecting a volume. If any errors occured during the operation, 46507d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen * @error will be set to contain the errors and %FALSE will be returned. 466f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * 467f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen * Returns: %TRUE, %FALSE if operation failed. 468f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen **/ 469f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthengboolean 47007d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Claseng_volume_eject_finish (GVolume *volume, 47107d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen GAsyncResult *result, 47207d4c14f8de8b3e7716d5dee5254db7c3a7ac132Matthias Clasen GError **error) 473f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen{ 474f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen GVolumeIface *iface; 475f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 476f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen g_return_val_if_fail (G_IS_VOLUME (volume), FALSE); 477f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE); 478f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 479f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen if (G_IS_SIMPLE_ASYNC_RESULT (result)) 480f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen { 481f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); 482f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen if (g_simple_async_result_propagate_error (simple, error)) 483f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen return FALSE; 484f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen } 485f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 486f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen iface = G_VOLUME_GET_IFACE (volume); 487f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen return (* iface->eject_finish) (volume, result, error); 488f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen} 489f4add8f0faf4a8c2ca1cdb4f99f5f3d0d66aaff8David Zeuthen 490e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen/** 491e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen * g_volume_get_identifier: 492e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen * @volume: a #GVolume 493e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen * @kind: the kind of identifier to return 494e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen * 495826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * Gets the identifier of the given kind for @volume. 496826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * See the <link linkend="volume-identifier">introduction</link> 497826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * for more information about volume identifiers. 498e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen * 499e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen * Returns: a newly allocated string containing the 500e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen * requested identfier, or %NULL if the #GVolume 501e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen * doesn't have this kind of identifier 502e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen */ 503753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larssonchar * 504e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Claseng_volume_get_identifier (GVolume *volume, 505e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen const char *kind) 506753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson{ 507753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson GVolumeIface *iface; 508753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson 509753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson g_return_val_if_fail (G_IS_VOLUME (volume), NULL); 510753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson g_return_val_if_fail (kind != NULL, NULL); 511753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson 512753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson iface = G_VOLUME_GET_IFACE (volume); 513753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson 514753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson if (iface->get_identifier == NULL) 515753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson return NULL; 516753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson 517753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson return (* iface->get_identifier) (volume, kind); 518753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson} 519753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson 520e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen/** 521e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen * g_volume_enumerate_identifiers: 522e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen * @volume: a #GVolume 523826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * 524826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * Gets the kinds of <link linkend="volume-identifier">identifiers</link> 525826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * that @volume has. Use g_volume_get_identifer() to obtain 526826d8c5b41de02387dbfd5b815765c94d6128eacMatthias Clasen * the identifiers themselves. 527e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen * 528e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen * Returns: a %NULL-terminated array of strings containing 529e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen * kinds of identifiers. Use g_strfreev() to free. 530e2ba37ceb389a48eaa9912ca6cc241fcfa0c33baMatthias Clasen */ 531753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larssonchar ** 532753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larssong_volume_enumerate_identifiers (GVolume *volume) 533753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson{ 534753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson GVolumeIface *iface; 535753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson 536753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson g_return_val_if_fail (G_IS_VOLUME (volume), NULL); 537753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson iface = G_VOLUME_GET_IFACE (volume); 538753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson 539753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson if (iface->enumerate_identifiers == NULL) 540753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson return NULL; 541753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson 542753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson return (* iface->enumerate_identifiers) (volume); 543753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson} 544753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson 5452b714b5f203e1daae59a9955290ec71122b13205David Zeuthen/** 5462b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * g_volume_get_activation_root: 5472b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * @volume: a #GVolume 5482b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * 5492b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * Gets the activation root for a #GVolume if it is known ahead of 5502b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * mount time. Returns %NULL otherwise. If not %NULL and if @volume 5512b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * is mounted, then the result of g_mount_get_root() on the 5522b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * #GMount object obtained from g_volume_get_mount() will always 5532b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * either be equal or a prefix of what this function returns. In 5542b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * other words, in code 5552b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * 5562b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * <programlisting> 5572b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * GMount *mount; 5582b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * GFile *mount_root 5592b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * GFile *volume_activation_root; 5602b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * 561c8c5188fd511d46d45356c866459976ab442ab8bMatthias Clasen * mount = g_volume_get_mount (volume); /* mounted, so never NULL */ 5622b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * mount_root = g_mount_get_root (mount); 563c8c5188fd511d46d45356c866459976ab442ab8bMatthias Clasen * volume_activation_root = g_volume_get_activation_root(volume); /* assume not NULL */ 5642b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * </programlisting> 5652b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * 5662b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * then the expression 5672b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * 5682b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * <programlisting> 5692b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * (g_file_has_prefix (volume_activation_root, mount_root) || 5702b714b5f203e1daae59a9955290ec71122b13205David Zeuthen g_file_equal (volume_activation_root, mount_root)) 5712b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * </programlisting> 5722b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * 5732b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * will always be %TRUE. 5742b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * 575a95b7a3fab147ae79dccd8628576bae4cc82b438Alexander Larsson * Activation roots are typically used in #GVolumeMonitor 576a95b7a3fab147ae79dccd8628576bae4cc82b438Alexander Larsson * implementations to find the underlying mount to shadow, see 577a95b7a3fab147ae79dccd8628576bae4cc82b438Alexander Larsson * g_mount_is_shadowed() for more details. 5782b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * 5792b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * Returns: the activation root of @volume or %NULL. Use 5802b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * g_object_unref() to free. 5812b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * 5822b714b5f203e1daae59a9955290ec71122b13205David Zeuthen * Since: 2.18 5832b714b5f203e1daae59a9955290ec71122b13205David Zeuthen **/ 5842b714b5f203e1daae59a9955290ec71122b13205David ZeuthenGFile * 5852b714b5f203e1daae59a9955290ec71122b13205David Zeutheng_volume_get_activation_root (GVolume *volume) 5862b714b5f203e1daae59a9955290ec71122b13205David Zeuthen{ 5872b714b5f203e1daae59a9955290ec71122b13205David Zeuthen GVolumeIface *iface; 5882b714b5f203e1daae59a9955290ec71122b13205David Zeuthen 5892b714b5f203e1daae59a9955290ec71122b13205David Zeuthen g_return_val_if_fail (G_IS_VOLUME (volume), NULL); 5902b714b5f203e1daae59a9955290ec71122b13205David Zeuthen iface = G_VOLUME_GET_IFACE (volume); 5912b714b5f203e1daae59a9955290ec71122b13205David Zeuthen 5922b714b5f203e1daae59a9955290ec71122b13205David Zeuthen if (iface->get_activation_root == NULL) 5932b714b5f203e1daae59a9955290ec71122b13205David Zeuthen return NULL; 5942b714b5f203e1daae59a9955290ec71122b13205David Zeuthen 5952b714b5f203e1daae59a9955290ec71122b13205David Zeuthen return (* iface->get_activation_root) (volume); 5962b714b5f203e1daae59a9955290ec71122b13205David Zeuthen} 5972b714b5f203e1daae59a9955290ec71122b13205David Zeuthen 5982b714b5f203e1daae59a9955290ec71122b13205David Zeuthen 599753428dcf85cb5fc73009bd4ffb457d6a9166023Alexander Larsson 6007f3280230bc9448a5750fc17a6eabef691ba25f4Alexander Larsson#define __G_VOLUME_C__ 6017f3280230bc9448a5750fc17a6eabef691ba25f4Alexander Larsson#include "gioaliasdef.c" 602