/* Copyright (C) 2007 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
//#include
//#include
//#include
#include
#include
#include
#include
#include
_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/interface_p.h)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GMountIface GMountIface;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
namespace Gio
{
class GIOMM_API File;
class GIOMM_API Drive;
class GIOMM_API Volume;
/** The Mount interface represents user-visible mounts.
* Mount is a "mounted" filesystem that you can access. Mounted is in quotes because it's not the same as a unix mount:
* it might be a gvfs mount, but you can still access the files on it if you use GIO. It might or might not be related to a volume object.
*
* Unmounting a Mount instance is an asynchronous operation. For more information about asynchronous operations, see AsyncReady.
* To unmount a Mount instance, first call unmount(). The callback slot will be called when the operation has resolved (either with success or failure),
* and a AsyncReady structure will be passed to the callback. That callback should then call unmount_finish() with the AsyncReady data to see if the operation was completed successfully.
*
* @ingroup Streams
*
* @newin{2,16}
*/
class GIOMM_API Mount : public Glib::Interface
{
_CLASS_INTERFACE(Mount, GMount, G_MOUNT, GMountIface, , , GIOMM_API)
public:
_WRAP_ENUM(UnmountFlags, GMountUnmountFlags, NO_GTYPE, decl_prefix GIOMM_API)
_WRAP_ENUM(MountFlags, GMountMountFlags, NO_GTYPE, decl_prefix GIOMM_API)
_WRAP_METHOD(Glib::RefPtr get_root(), g_mount_get_root, refreturn)
_WRAP_METHOD(Glib::RefPtr get_root() const, g_mount_get_root, refreturn, constversion)
_WRAP_METHOD(std::string get_name() const, g_mount_get_name)
_WRAP_METHOD(Glib::RefPtr get_icon(), g_mount_get_icon, refreturn)
_WRAP_METHOD(Glib::RefPtr get_icon() const, g_mount_get_icon, refreturn, constversion)
_WRAP_METHOD(Glib::RefPtr get_symbolic_icon(), g_mount_get_symbolic_icon, refreturn)
_WRAP_METHOD(Glib::RefPtr get_symbolic_icon() const, g_mount_get_symbolic_icon, refreturn, constversion)
_WRAP_METHOD(std::string get_uuid() const, g_mount_get_uuid)
_WRAP_METHOD(Glib::RefPtr get_volume(), g_mount_get_volume, refreturn)
_WRAP_METHOD(Glib::RefPtr get_volume() const, g_mount_get_volume, refreturn, constversion)
_WRAP_METHOD(Glib::RefPtr get_drive(), g_mount_get_drive, refreturn)
_WRAP_METHOD(Glib::RefPtr get_drive() const, g_mount_get_drive, refreturn, constversion)
_WRAP_METHOD(bool can_unmount() const, g_mount_can_unmount)
_WRAP_METHOD(bool can_eject() const, g_mount_can_eject)
void unmount(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, UnmountFlags flags = UnmountFlags::NONE);
void unmount(const SlotAsyncReady& slot, UnmountFlags flags = UnmountFlags::NONE);
void unmount(UnmountFlags flags = UnmountFlags::NONE);
void unmount(const Glib::RefPtr& mount_operation, UnmountFlags flags = UnmountFlags::NONE);
void unmount(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, UnmountFlags flags = UnmountFlags::NONE);
void unmount(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, UnmountFlags flags = UnmountFlags::NONE);
_IGNORE(g_mount_unmount)
_IGNORE(g_mount_unmount_with_operation)
_WRAP_METHOD(bool unmount_finish(const Glib::RefPtr& result), g_mount_unmount_with_operation_finish, errthrow)
_IGNORE(g_mount_unmount_finish)
/** Remounts a mount.
* This is an asynchronous operation, and is finished by calling mount_finish() with the AsyncResult data returned in the callback slot.
*
* Remounting is useful when some setting affecting the operation of the volume has been changed, as this may need a remount
* to take affect. While this is semantically equivalent with unmounting and then remounting, not all backends might need to
* actually be unmounted.
*
* @param operation A mount operation.
* @param slot A callback which will be called when the operation is completed or canceled.
* @param cancellable A cancellable object which can be used to cancel the operation.
* @param flags Flags affecting the operation.
*/
void remount(const Glib::RefPtr& operation, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountFlags flags = MountFlags::NONE);
/** Remounts a mount.
* This is an asynchronous operation, and is finished by calling mount_finish() with the AsyncResult data returned in the callback slot.
*
* Remounting is useful when some setting affecting the operation of the volume has been changed, as this may need a remount
* to take affect. While this is semantically equivalent with unmounting and then remounting, not all backends might need to
* actually be unmounted.
*
* @param operation A mount operation.
* @param slot A callback which will be called when the operation is completed or canceled.
* @param flags Flags affecting the operation.
*/
void remount(const Glib::RefPtr& operation, const SlotAsyncReady& slot, MountFlags flags = MountFlags::NONE);
/** Remounts a mount.
*
* Remounting is useful when some setting affecting the operation of the volume has been changed, as this may need a remount
* to take affect. While this is semantically equivalent with unmounting and then remounting, not all backends might need to
* actually be unmounted.
*
* @param operation A mount operation.
* @param flags Flags affecting the operation.
*/
void remount(const Glib::RefPtr& operation, MountFlags flags = MountFlags::NONE);
/** Remounts a mount, without user interaction.
*
* Remounting is useful when some setting affecting the operation of the volume has been changed, as this may need a remount
* to take affect. While this is semantically equivalent with unmounting and then remounting, not all backends might need to
* actually be unmounted.
*
* @param flags Flags affecting the operation.
*/
void remount(MountFlags flags = MountFlags::NONE);
_IGNORE(g_mount_remount)
_WRAP_METHOD(bool remount_finish(const Glib::RefPtr& result), g_mount_remount_finish, errthrow)
void eject(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, UnmountFlags flags = UnmountFlags::NONE);
void eject(const SlotAsyncReady& slot, UnmountFlags flags = UnmountFlags::NONE);
void eject(UnmountFlags flags = UnmountFlags::NONE);
void eject(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, UnmountFlags flags = UnmountFlags::NONE);
void eject(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, UnmountFlags flags = UnmountFlags::NONE);
void eject(const Glib::RefPtr& mount_operation, UnmountFlags flags = UnmountFlags::NONE);
_IGNORE(g_mount_eject)
_IGNORE(g_mount_eject_with_operation)
_WRAP_METHOD(bool eject_finish(const Glib::RefPtr& result), g_mount_eject_with_operation_finish, errthrow)
_IGNORE(g_mount_eject_finish)
/** Tries to guess the type of content stored on the mount.
* Returns one or more textual identifiers of well-known content types (typically
* prefixed with "x-content/"), e.g. x-content/image-dcf for camera
* memory cards. See the shared-mime-info specification for more on x-content types.
*
* This is an asynchronous operation, and is finished by calling
* guess_content_type_finish().
*
* @param slot A callback which will be called when the operation is completed or canceled.
* @param cancellable A cancellable object which can be used to cancel the operation.
* @param force_rescan Whether to force a rescan of the content. Otherwise a cached result will be used if available.
*
* @newin{2,18}
*/
void guess_content_type(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, bool force_rescan = true);
/** Tries to guess the type of content stored on the mount.
* Returns one or more textual identifiers of well-known content types (typically
* prefixed with "x-content/"), e.g. x-content/image-dcf for camera
* memory cards. See the shared-mime-info specification for more on x-content types.
*
* This is an asynchronous operation, and is finished by calling
* guess_content_type_finish().
*
* @param slot A callback which will be called when the operation is completed or canceled.
* @param force_rescan Whether to force a rescan of the content. Otherwise a cached result will be used if available.
*
* @newin{2,18}
*/
void guess_content_type(const SlotAsyncReady& slot, bool force_rescan = true);
/** Tries to guess the type of content stored on the mount.
* Returns one or more textual identifiers of well-known content types (typically
* prefixed with "x-content/"), e.g. x-content/image-dcf for camera
* memory cards. See the shared-mime-info specification for more on x-content types.
*
* @param force_rescan Whether to force a rescan of the content. Otherwise a cached result will be used if available.
*
* @newin{2,18}
*/
void guess_content_type(bool force_rescan = true);
_IGNORE(g_mount_guess_content_type)
void guess_content_type_sync(const Glib::RefPtr& cancellable, bool force_rescan = true);
void guess_content_type_sync(bool force_rescan = true);
_IGNORE(g_mount_guess_content_type_sync)
#m4 _CONVERSION(`gchar**',`std::vector',`Glib::ArrayHandler::array_to_vector($3, Glib::OWNERSHIP_DEEP)')
/** Finishes guessing content types of the Mount.
* If any errors occurred during the operation, an exception will be thrown.
* In particular, you may get a Gio::Error::NOT_SUPPORTED if the mount
* does not support content guessing.
*
* @newin{2,18}
*
* @param result An AsyncResult.
* @return An array of content types.
* @throw Glib::Error
*/
_WRAP_METHOD(std::vector guess_content_type_finish(const Glib::RefPtr& result), g_mount_guess_content_type_finish, errthrow)
_WRAP_METHOD(bool is_shadowed() const, g_mount_is_shadowed)
_WRAP_METHOD(void shadow(), g_mount_shadow)
_WRAP_METHOD(void unshadow(), g_mount_unshadow)
_WRAP_METHOD(Glib::RefPtr get_default_location() const, g_mount_get_default_location)
_WRAP_METHOD(Glib::ustring get_sort_key() const, g_mount_get_sort_key)
_WRAP_SIGNAL(void changed(), changed)
_WRAP_SIGNAL(void unmounted(), unmounted)
_WRAP_SIGNAL(void pre_unmount(), pre_unmount)
//There are no properties.
};
} // namespace Gio
namespace Glib
{
//Pre-declare this so we can use it in TypeTrait:
GIOMM_API
Glib::RefPtr wrap(GMount* object, bool take_copy);
namespace Container_Helpers
{
/** This specialization of TypeTraits exists
* because the default use of Glib::wrap(GObject*),
* instead of a specific Glib::wrap(GSomeInterface*),
* would not return a wrapper for an interface.
*/
template <>
struct TypeTraits< Glib::RefPtr >
{
using CppType = Glib::RefPtr;
using CType = GMount*;
using CTypeNonConst = GMount*;
static CType to_c_type (const CppType& item)
{ return Glib::unwrap (item); }
static CppType to_cpp_type (const CType& item)
{
//Use a specific Glib::wrap() function,
//because CType has the specific type (not just GObject):
return Glib::wrap(item, true /* take_copy */);
}
static void release_c_type (CType item)
{
GLIBMM_DEBUG_UNREFERENCE(nullptr, item);
g_object_unref(item);
}
};
} // Container_Helpers
} // Glib