Doc additions
[platform/upstream/glib.git] / gio / gmountoperation.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  */
22
23 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
24 #error "Only <gio/gio.h> can be included directly."
25 #endif
26
27 #ifndef __G_MOUNT_OPERATION_H__
28 #define __G_MOUNT_OPERATION_H__
29
30 #include <sys/stat.h>
31
32 #include <glib-object.h>
33
34 G_BEGIN_DECLS
35
36 #define G_TYPE_MOUNT_OPERATION         (g_mount_operation_get_type ())
37 #define G_MOUNT_OPERATION(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_MOUNT_OPERATION, GMountOperation))
38 #define G_MOUNT_OPERATION_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_MOUNT_OPERATION, GMountOperationClass))
39 #define G_IS_MOUNT_OPERATION(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_MOUNT_OPERATION))
40 #define G_IS_MOUNT_OPERATION_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_MOUNT_OPERATION))
41 #define G_MOUNT_OPERATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_MOUNT_OPERATION, GMountOperationClass))
42
43 /**
44  * GMountOperation:
45  * 
46  * Class for providing authentication methods for mounting operations, 
47  * such as mounting a file locally, or authenticating with a server.
48  **/
49 typedef struct _GMountOperation        GMountOperation;
50 typedef struct _GMountOperationClass   GMountOperationClass;
51 typedef struct _GMountOperationPrivate GMountOperationPrivate;
52
53 struct _GMountOperation
54 {
55   GObject parent_instance;
56
57   GMountOperationPrivate *priv;
58 };
59
60 /**
61  * GAskPasswordFlags:
62  * @G_ASK_PASSWORD_NEED_PASSWORD: operation requires a password.
63  * @G_ASK_PASSWORD_NEED_USERNAME: operation requires a username.
64  * @G_ASK_PASSWORD_NEED_DOMAIN: operation requires a domain.
65  * @G_ASK_PASSWORD_SAVING_SUPPORTED: operation supports saving settings.
66  * @G_ASK_PASSWORD_ANONYMOUS_SUPPORTED: operation supports anonymous users.
67  * 
68  * #GAskPasswordFlags are used to request specific information from the 
69  * user, or to notify the user of their choices in an authentication
70  * situation. 
71  * 
72  **/ 
73 typedef enum {
74   G_ASK_PASSWORD_NEED_PASSWORD       = 1<<0,
75   G_ASK_PASSWORD_NEED_USERNAME       = 1<<1,
76   G_ASK_PASSWORD_NEED_DOMAIN         = 1<<2,
77   G_ASK_PASSWORD_SAVING_SUPPORTED    = 1<<3,
78   G_ASK_PASSWORD_ANONYMOUS_SUPPORTED = 1<<4
79 } GAskPasswordFlags;
80
81 /**
82  * GPasswordSave:
83  * @G_PASSWORD_SAVE_NEVER: never save a password.
84  * @G_PASSWORD_SAVE_FOR_SESSION: save a password for the session.
85  * @G_PASSWORD_SAVE_PERMANENTLY: save a password permanently.
86  * 
87  * #GPasswordSave is used to indicate the lifespan of a saved password.
88  *
89  * #Gvfs stores passwords in the Gnome keyring when this flag allows it
90  * to, and later retrieves it again from there. 
91  **/ 
92 typedef enum {
93   G_PASSWORD_SAVE_NEVER,
94   G_PASSWORD_SAVE_FOR_SESSION,
95   G_PASSWORD_SAVE_PERMANENTLY
96 } GPasswordSave;
97
98 /**
99  * GMountOperationResult:
100  * @G_MOUNT_OPERATION_HANDLED: The request was fulfilled and the user specified data is now availible
101  * @G_MOUNT_OPERATION_ABORTED: The user requested the mount operation to be aborted
102  * @G_MOUNT_OPERATION_UNHANDLED: The request was unhandled (i.e. not implemented)
103  * 
104  * #GMountOperationResult is returned as a result when a request for information
105  * is send by the mounting operation.
106  **/ 
107 typedef enum {
108   G_MOUNT_OPERATION_HANDLED,
109   G_MOUNT_OPERATION_ABORTED,
110   G_MOUNT_OPERATION_UNHANDLED
111 } GMountOperationResult;
112
113 struct _GMountOperationClass
114 {
115   GObjectClass parent_class;
116
117   /* signals: */
118
119   void (* ask_password) (GMountOperation *op,
120                          const char      *message,
121                          const char      *default_user,
122                          const char      *default_domain,
123                          GAskPasswordFlags flags);
124
125   void (* ask_question) (GMountOperation *op,
126                          const char      *message,
127                          const char      *choices[]);
128   
129   void (* reply)        (GMountOperation *op,
130                          GMountOperationResult result);
131   
132   /*< private >*/
133   /* Padding for future expansion */
134   void (*_g_reserved1) (void);
135   void (*_g_reserved2) (void);
136   void (*_g_reserved3) (void);
137   void (*_g_reserved4) (void);
138   void (*_g_reserved5) (void);
139   void (*_g_reserved6) (void);
140   void (*_g_reserved7) (void);
141   void (*_g_reserved8) (void);
142   void (*_g_reserved9) (void);
143   void (*_g_reserved10) (void);
144   void (*_g_reserved11) (void);
145   void (*_g_reserved12) (void);
146 };
147
148 GType g_mount_operation_get_type (void) G_GNUC_CONST;
149   
150 GMountOperation *  g_mount_operation_new (void);
151
152 const char *  g_mount_operation_get_username      (GMountOperation *op);
153 void          g_mount_operation_set_username      (GMountOperation *op,
154                                                    const char      *username);
155 const char *  g_mount_operation_get_password      (GMountOperation *op);
156 void          g_mount_operation_set_password      (GMountOperation *op,
157                                                    const char      *password);
158 gboolean      g_mount_operation_get_anonymous     (GMountOperation *op);
159 void          g_mount_operation_set_anonymous     (GMountOperation *op,
160                                                    gboolean         anonymous);
161 const char *  g_mount_operation_get_domain        (GMountOperation *op);
162 void          g_mount_operation_set_domain        (GMountOperation *op,
163                                                    const char      *domain);
164 GPasswordSave g_mount_operation_get_password_save (GMountOperation *op);
165 void          g_mount_operation_set_password_save (GMountOperation *op,
166                                                    GPasswordSave    save);
167 int           g_mount_operation_get_choice        (GMountOperation *op);
168 void          g_mount_operation_set_choice        (GMountOperation *op,
169                                                    int              choice);
170 void          g_mount_operation_reply             (GMountOperation *op,
171                                                    GMountOperationResult result);
172
173 G_END_DECLS
174
175 #endif /* __G_MOUNT_OPERATION_H__ */