Use g_set_error_literal where appropriate. Patch from bug #535947.
[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 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
25 #error "Only <gio/gio.h> can be included directly."
26 #endif
27
28 #ifndef __G_DRIVE_H__
29 #define __G_DRIVE_H__
30
31 #include <glib-object.h>
32 #include <gio/gmount.h>
33 #include <gio/gvolume.h>
34 #include <gio/gmountoperation.h>
35
36 G_BEGIN_DECLS
37
38 #define G_TYPE_DRIVE           (g_drive_get_type ())
39 #define G_DRIVE(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_DRIVE, GDrive))
40 #define G_IS_DRIVE(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_DRIVE))
41 #define G_DRIVE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_DRIVE, GDriveIface))
42
43 /**
44  * GDriveIface:
45  * @g_iface: The parent interface.
46  * @changed: Signal emitted when the drive is changed.
47  * @disconnected: The removed signal that is emitted when the #GDrive have been disconnected. If the recipient is holding references to the object they should release them so the object can be finalized.
48  * @eject_button: Signal emitted when the physical eject button (if any) of a drive have been pressed.
49  * @get_name: Returns the name for the given #GDrive.
50  * @get_icon: Returns a #GIcon for the given #GDrive.
51  * @has_volumes: Returns %TRUE if the #GDrive has mountable volumes.
52  * @get_volumes: Returns a list #GList of #GVolume for the #GDrive.
53  * @is_media_removable: Returns %TRUE if the #GDrive supports removal and insertion of media.
54  * @has_media: Returns %TRUE if the #GDrive has media inserted.
55  * @is_media_check_automatic: Returns %TRUE if the #GDrive is capabable of automatically detecting media changes.
56  * @can_poll_for_media: Returns %TRUE if the #GDrive is capable of manually polling for media change.
57  * @can_eject: Returns %TRUE if the #GDrive can eject media.
58  * @eject: Ejects a #GDrive.
59  * @eject_finish: Finishes an eject operation.
60  * @poll_for_media: Poll for media insertion/removal on a #GDrive.
61  * @poll_for_media_finish: Finishes a media poll operation.
62  * @get_identifier: Returns the identifier of the given kind, or %NULL if 
63  *    the #GDrive doesn't have one.
64  * @enumerate_identifiers: Returns an array strings listing the kinds
65  *    of identifiers which the #GDrive has.
66  *
67  * 
68  * Interface for creating #GDrive implementations.
69  */ 
70 typedef struct _GDriveIface    GDriveIface;
71
72 struct _GDriveIface
73 {
74   GTypeInterface g_iface;
75
76   /* signals */
77   void (*changed)                      (GDrive              *drive);
78   void (*disconnected)                 (GDrive              *drive);
79   void (*eject_button)                 (GDrive              *drive);
80   
81   /* Virtual Table */
82   char *   (*get_name)                 (GDrive              *drive);
83   GIcon *  (*get_icon)                 (GDrive              *drive);
84   gboolean (*has_volumes)              (GDrive              *drive);
85   GList *  (*get_volumes)              (GDrive              *drive);
86   gboolean (*is_media_removable)       (GDrive              *drive);
87   gboolean (*has_media)                (GDrive              *drive);
88   gboolean (*is_media_check_automatic) (GDrive              *drive);
89   gboolean (*can_eject)                (GDrive              *drive);
90   gboolean (*can_poll_for_media)       (GDrive              *drive);
91   void     (*eject)                    (GDrive              *drive,
92                                         GMountUnmountFlags   flags,
93                                         GCancellable        *cancellable,
94                                         GAsyncReadyCallback  callback,
95                                         gpointer             user_data);
96   gboolean (*eject_finish)             (GDrive              *drive,
97                                         GAsyncResult        *result,
98                                         GError             **error);
99   void     (*poll_for_media)           (GDrive              *drive,
100                                         GCancellable        *cancellable,
101                                         GAsyncReadyCallback  callback,
102                                         gpointer             user_data);
103   gboolean (*poll_for_media_finish)    (GDrive              *drive,
104                                         GAsyncResult        *result,
105                                         GError             **error);
106
107   char *   (*get_identifier)           (GDrive              *drive,
108                                         const char          *kind);
109   char **  (*enumerate_identifiers)    (GDrive              *drive);
110 };
111
112 GType g_drive_get_type                    (void) G_GNUC_CONST;
113
114 char *   g_drive_get_name                 (GDrive               *drive);
115 GIcon *  g_drive_get_icon                 (GDrive               *drive);
116 gboolean g_drive_has_volumes              (GDrive               *drive);
117 GList *  g_drive_get_volumes              (GDrive               *drive);
118 gboolean g_drive_is_media_removable       (GDrive               *drive);
119 gboolean g_drive_has_media                (GDrive               *drive);
120 gboolean g_drive_is_media_check_automatic (GDrive               *drive);
121 gboolean g_drive_can_poll_for_media       (GDrive               *drive);
122 gboolean g_drive_can_eject                (GDrive               *drive);
123 void     g_drive_eject                    (GDrive               *drive,
124                                            GMountUnmountFlags    flags,
125                                            GCancellable         *cancellable,
126                                            GAsyncReadyCallback   callback,
127                                            gpointer              user_data);
128 gboolean g_drive_eject_finish             (GDrive               *drive,
129                                            GAsyncResult         *result,
130                                            GError              **error);
131 void     g_drive_poll_for_media           (GDrive               *drive,
132                                            GCancellable         *cancellable,
133                                            GAsyncReadyCallback   callback,
134                                            gpointer              user_data);
135 gboolean g_drive_poll_for_media_finish    (GDrive               *drive,
136                                            GAsyncResult         *result,
137                                            GError              **error);
138 char *   g_drive_get_identifier           (GDrive              *drive,
139                                            const char          *kind);
140 char **  g_drive_enumerate_identifiers    (GDrive              *drive);
141
142 G_END_DECLS
143
144 #endif /* __G_DRIVE_H__ */