Rework how volumes, drives and volume monitoring is done. Previosly the
[platform/upstream/glib.git] / gio / gdrive.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_DRIVE_H__
25 #define __G_DRIVE_H__
26
27 #include <glib-object.h>
28 #include <gio/gmount.h>
29 #include <gio/gvolume.h>
30 #include <gio/gmountoperation.h>
31
32 G_BEGIN_DECLS
33
34 #define G_TYPE_DRIVE           (g_drive_get_type ())
35 #define G_DRIVE(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_DRIVE, GDrive))
36 #define G_IS_DRIVE(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_DRIVE))
37 #define G_DRIVE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_DRIVE, GDriveIface))
38
39 /**
40  * GDriveIface:
41  * @g_iface: The parent interface.
42  * @changed: Signal emitted when the drive is changed.
43  * @get_name: Returns the name for the given #GDrive.
44  * @get_icon: Returns a #GIcon for the given #GDrive.
45  * @has_volumes: Returns %TRUE if the #GDrive has mountable volumes.
46  * @get_volumes: Returns a list #GList of #GVolume for the #GDrive.
47  * @is_media_removable: Returns %TRUE if the #GDrive supports removal and insertion of media.
48  * @has_media: Returns %TRUE if the #GDrive has media inserted.
49  * @is_media_check_automatic: Returns %TRUE if the #GDrive is capabable of automatically detecting media changes.
50  * @can_poll_for_media: Returns %TRUE if the #GDrive is capable of manually polling for media change.
51  * @can_eject: Returns %TRUE if the #GDrive can eject media.
52  * @eject: Ejects a #GDrive.
53  * @eject_finish: Finishes an eject operation.
54  * @poll_for_media: Poll for media insertion/removal on a #GDrive.
55  * @poll_for_media_finish: Finishes a media poll operation.
56  * 
57  * Interface for creating #GDrive implementations.
58  */ 
59 typedef struct _GDriveIface    GDriveIface;
60
61 struct _GDriveIface
62 {
63   GTypeInterface g_iface;
64
65   /* signals */
66   void (*changed)                      (GDrive              *drive);
67   
68   /* Virtual Table */
69   char *   (*get_name)                 (GDrive              *drive);
70   GIcon *  (*get_icon)                 (GDrive              *drive);
71   gboolean (*has_volumes)              (GDrive              *drive);
72   GList *  (*get_volumes)              (GDrive              *drive);
73   gboolean (*is_media_removable)       (GDrive              *drive);
74   gboolean (*has_media)                (GDrive              *drive);
75   gboolean (*is_media_check_automatic) (GDrive              *drive);
76   gboolean (*can_eject)                (GDrive              *drive);
77   gboolean (*can_poll_for_media)       (GDrive              *drive);
78   void     (*eject)                    (GDrive              *drive,
79                                         GCancellable        *cancellable,
80                                         GAsyncReadyCallback  callback,
81                                         gpointer             user_data);
82   gboolean (*eject_finish)             (GDrive              *drive,
83                                         GAsyncResult        *result,
84                                         GError             **error);
85   void     (*poll_for_media)           (GDrive              *drive,
86                                         GCancellable        *cancellable,
87                                         GAsyncReadyCallback  callback,
88                                         gpointer             user_data);
89   gboolean (*poll_for_media_finish)    (GDrive              *drive,
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_drive_get_type                    (void) G_GNUC_CONST;
106
107 char *   g_drive_get_name                 (GDrive               *drive);
108 GIcon *  g_drive_get_icon                 (GDrive               *drive);
109 gboolean g_drive_has_volumes              (GDrive               *drive);
110 GList *  g_drive_get_volumes              (GDrive               *drive);
111 gboolean g_drive_is_media_removable       (GDrive               *drive);
112 gboolean g_drive_has_media                (GDrive               *drive);
113 gboolean g_drive_is_media_check_automatic (GDrive               *drive);
114 gboolean g_drive_can_poll_for_media       (GDrive               *drive);
115 gboolean g_drive_can_eject                (GDrive               *drive);
116 void     g_drive_eject                    (GDrive               *drive,
117                                            GCancellable         *cancellable,
118                                            GAsyncReadyCallback   callback,
119                                            gpointer              user_data);
120 gboolean g_drive_eject_finish             (GDrive               *drive,
121                                            GAsyncResult         *result,
122                                            GError              **error);
123 void     g_drive_poll_for_media           (GDrive               *drive,
124                                            GCancellable         *cancellable,
125                                            GAsyncReadyCallback   callback,
126                                            gpointer              user_data);
127 gboolean g_drive_poll_for_media_finish    (GDrive               *drive,
128                                            GAsyncResult         *result,
129                                            GError              **error);
130
131 G_END_DECLS
132
133 #endif /* __G_DRIVE_H__ */