Rework how volumes, drives and volume monitoring is done. Previosly the
[platform/upstream/glib.git] / gio / gmount.h
1 /* GIO - GLib Input, Output and Streaming Library
2  * 
3  * Copyright (C) 2006-2007 Red Hat, Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General
16  * Public License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Author: Alexander Larsson <alexl@redhat.com>
21  *         David Zeuthen <davidz@redhat.com>
22  */
23
24 #ifndef __G_MOUNT_H__
25 #define __G_MOUNT_H__
26
27 #include <glib-object.h>
28 #include <gio/gfile.h>
29
30 G_BEGIN_DECLS
31
32 #define G_TYPE_MOUNT            (g_mount_get_type ())
33 #define G_MOUNT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_MOUNT, GMount))
34 #define G_IS_MOUNT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_MOUNT))
35 #define G_MOUNT_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_MOUNT, GMountIface))
36
37 /* GMount typedef is in gfile.h due to include order issues */
38 /**
39  * GVolume:
40  * 
41  * Opaque mountable volume object.
42  **/
43 typedef struct _GVolume GVolume; /* Dummy typedef */
44
45 /**
46  * GDrive:
47  * 
48  * Opaque drive object.
49  **/
50 typedef struct _GDrive          GDrive; /* Dummy typedef */
51
52 typedef struct _GMountIface    GMountIface;
53
54 /**
55  * GMountIface:
56  * @g_iface: The parent interface.
57  * @changed: Changed signal that is emitted when the mount's state has changed.
58  * @get_root: Gets a #GFile to the root directory of the #GMount.
59  * @get_name: Gets a string containing the name of the #GMount.
60  * @get_icon: Gets a #GIcon for the #GMount.
61  * @get_volume: Gets a #GVolume the mount is located on. Returns %NULL if the #GMount is not associated with a #GVolume.
62  * @get_drive: Gets a #GDrive the volume of the mount is located on. Returns %NULL if the #GMount is not associated with a #GDrive or a #GVolume. This is convenience method for getting the #GVolume and using that to get the #GDrive.
63  * @can_unmount: Checks if a #GMount can be unmounted.
64  * @unmount: Starts unmounting a #GMount.
65  * @unmount_finish: Finishes an unmounting operation.
66  * 
67  * Interface for implementing operations for mounts.
68  **/
69 struct _GMountIface
70 {
71   GTypeInterface g_iface;
72
73   /* signals */
74
75   void (*changed) (GMount *mount);
76   
77   /* Virtual Table */
78
79   GFile *            (*get_root)             (GMount         *mount);
80   char *             (*get_name)             (GMount         *mount);
81   GIcon *            (*get_icon)             (GMount         *mount);
82   GVolume *          (*get_volume)           (GMount         *mount);
83   GDrive *           (*get_drive)            (GMount         *mount);
84   gboolean           (*can_unmount)          (GMount         *mount);
85   void               (*unmount)              (GMount         *mount,
86                                               GCancellable    *cancellable,
87                                               GAsyncReadyCallback callback,
88                                               gpointer         user_data);
89   gboolean           (*unmount_finish)       (GMount         *mount,
90                                               GAsyncResult    *result,
91                                               GError         **error);
92
93   /*< private >*/
94   /* Padding for future expansion */
95   void (*_g_reserved1) (void);
96   void (*_g_reserved2) (void);
97   void (*_g_reserved3) (void);
98   void (*_g_reserved4) (void);
99   void (*_g_reserved5) (void);
100   void (*_g_reserved6) (void);
101   void (*_g_reserved7) (void);
102   void (*_g_reserved8) (void);
103 };
104
105 GType g_mount_get_type (void) G_GNUC_CONST;
106
107 GFile *            g_mount_get_root             (GMount              *mount);
108 char *             g_mount_get_name             (GMount              *mount);
109 GIcon *            g_mount_get_icon             (GMount              *mount);
110 GVolume *          g_mount_get_volume           (GMount              *mount);
111 GDrive *           g_mount_get_drive            (GMount              *mount);
112 gboolean           g_mount_can_unmount          (GMount              *mount);
113 void               g_mount_unmount              (GMount              *mount,
114                                                  GCancellable         *cancellable,
115                                                  GAsyncReadyCallback   callback,
116                                                  gpointer              user_data);
117 gboolean           g_mount_unmount_finish       (GMount              *mount,
118                                                  GAsyncResult         *result,
119                                                  GError              **error);
120
121 G_END_DECLS
122
123 #endif /* __G_MOUNT_H__ */