a07bc28b3ab085d6c63526ad4faef9d0a9f88dab
[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 #ifndef __G_MOUNT_OPERATION_H__
24 #define __G_MOUNT_OPERATION_H__
25
26 #include <sys/stat.h>
27
28 #include <glib-object.h>
29
30 G_BEGIN_DECLS
31
32 #define G_TYPE_MOUNT_OPERATION         (g_mount_operation_get_type ())
33 #define G_MOUNT_OPERATION(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_MOUNT_OPERATION, GMountOperation))
34 #define G_MOUNT_OPERATION_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_MOUNT_OPERATION, GMountOperationClass))
35 #define G_IS_MOUNT_OPERATION(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_MOUNT_OPERATION))
36 #define G_IS_MOUNT_OPERATION_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_MOUNT_OPERATION))
37 #define G_MOUNT_OPERATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_MOUNT_OPERATION, GMountOperationClass))
38
39 /**
40  * GMountOperation:
41  * 
42  * Class for providing authentication methods for mounting operations, 
43  * such as mounting a file locally, or authenticating with a server.
44  **/
45 typedef struct _GMountOperation        GMountOperation;
46 typedef struct _GMountOperationClass   GMountOperationClass;
47 typedef struct _GMountOperationPrivate GMountOperationPrivate;
48
49 struct _GMountOperation
50 {
51   GObject parent_instance;
52
53   GMountOperationPrivate *priv;
54 };
55
56 /**
57  * GPasswordFlags:
58  * @G_PASSWORD_FLAGS_NEED_PASSWORD: operation requires a password.
59  * @G_PASSWORD_FLAGS_NEED_USERNAME: operation requires a username.
60  * @G_PASSWORD_FLAGS_NEED_DOMAIN: operation requires a domain.
61  * @G_PASSWORD_FLAGS_SAVING_SUPPORTED: operation supports saving settings.
62  * @G_PASSWORD_FLAGS_ANON_SUPPORTED: operation supports anonymous users.
63  * 
64  * #GPasswordFlags are used to request specific information from the 
65  * user, or to notify the user of their choices in an authentication
66  * situation. 
67  * 
68  **/ 
69 typedef enum {
70   G_PASSWORD_FLAGS_NEED_PASSWORD    = 1<<0,
71   G_PASSWORD_FLAGS_NEED_USERNAME    = 1<<1,
72   G_PASSWORD_FLAGS_NEED_DOMAIN      = 1<<2,
73   G_PASSWORD_FLAGS_SAVING_SUPPORTED = 1<<4,
74   G_PASSWORD_FLAGS_ANON_SUPPORTED   = 1<<5
75 } GPasswordFlags;
76
77 /**
78  * GPasswordSave:
79  * @G_PASSWORD_SAVE_NEVER: never save a password.
80  * @G_PASSWORD_SAVE_FOR_SESSION: save a password for the session.
81  * @G_PASSWORD_SAVE_PERMANENTLY: save a password permanently.
82  * 
83  * #GPasswordSave is used to indicate the lifespan of a saved password.
84  **/ 
85 typedef enum {
86   G_PASSWORD_SAVE_NEVER,
87   G_PASSWORD_SAVE_FOR_SESSION,
88   G_PASSWORD_SAVE_PERMANENTLY
89 } GPasswordSave;
90
91 struct _GMountOperationClass
92 {
93   GObjectClass parent_class;
94
95   /* signals: */
96
97   gboolean (* ask_password) (GMountOperation *op,
98                              const char      *message,
99                              const char      *default_user,
100                              const char      *default_domain,
101                              GPasswordFlags   flags);
102
103   gboolean (* ask_question) (GMountOperation *op,
104                              const char      *message,
105                              const char      *choices[]);
106   
107   void     (* reply)        (GMountOperation *op,
108                              gboolean         abort);
109   
110   /*< private >*/
111   /* Padding for future expansion */
112   void (*_g_reserved1) (void);
113   void (*_g_reserved2) (void);
114   void (*_g_reserved3) (void);
115   void (*_g_reserved4) (void);
116   void (*_g_reserved5) (void);
117   void (*_g_reserved6) (void);
118   void (*_g_reserved7) (void);
119   void (*_g_reserved8) (void);
120   void (*_g_reserved9) (void);
121   void (*_g_reserved10) (void);
122   void (*_g_reserved11) (void);
123   void (*_g_reserved12) (void);
124 };
125
126 GType g_mount_operation_get_type (void) G_GNUC_CONST;
127   
128 GMountOperation *  g_mount_operation_new (void);
129
130 const char *  g_mount_operation_get_username      (GMountOperation *op);
131 void          g_mount_operation_set_username      (GMountOperation *op,
132                                                    const char      *username);
133 const char *  g_mount_operation_get_password      (GMountOperation *op);
134 void          g_mount_operation_set_password      (GMountOperation *op,
135                                                    const char      *password);
136 gboolean      g_mount_operation_get_anonymous     (GMountOperation *op);
137 void          g_mount_operation_set_anonymous     (GMountOperation *op,
138                                                    gboolean         anonymous);
139 const char *  g_mount_operation_get_domain        (GMountOperation *op);
140 void          g_mount_operation_set_domain        (GMountOperation *op,
141                                                    const char      *domain);
142 GPasswordSave g_mount_operation_get_password_save (GMountOperation *op);
143 void          g_mount_operation_set_password_save (GMountOperation *op,
144                                                    GPasswordSave    save);
145 int           g_mount_operation_get_choice        (GMountOperation *op);
146 void          g_mount_operation_set_choice        (GMountOperation *op,
147                                                    int              choice);
148 void          g_mount_operation_reply             (GMountOperation *op,
149                                                    gboolean         abort);
150
151 G_END_DECLS
152
153 #endif /* __G_MOUNT_OPERATION_H__ */