Merge remote branch 'gvdb/master'
[platform/upstream/glib.git] / gio / gdbusauthmechanism.h
1 /* GDBus - GLib D-Bus Library
2  *
3  * Copyright (C) 2008-2010 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: David Zeuthen <davidz@redhat.com>
21  */
22
23 #if !defined (GIO_COMPILATION)
24 #error "gdbusauthmechanism.h is a private header file."
25 #endif
26
27 #ifndef __G_DBUS_AUTH_MECHANISM_H__
28 #define __G_DBUS_AUTH_MECHANISM_H__
29
30 #include <gio/giotypes.h>
31
32 G_BEGIN_DECLS
33
34 #define G_TYPE_DBUS_AUTH_MECHANISM         (_g_dbus_auth_mechanism_get_type ())
35 #define G_DBUS_AUTH_MECHANISM(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_AUTH_MECHANISM, GDBusAuthMechanism))
36 #define G_DBUS_AUTH_MECHANISM_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_AUTH_MECHANISM, GDBusAuthMechanismClass))
37 #define G_DBUS_AUTH_MECHANISM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_AUTH_MECHANISM, GDBusAuthMechanismClass))
38 #define G_IS_DBUS_AUTH_MECHANISM(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_AUTH_MECHANISM))
39 #define G_IS_DBUS_AUTH_MECHANISM_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_AUTH_MECHANISM))
40
41 typedef struct _GDBusAuthMechanism        GDBusAuthMechanism;
42 typedef struct _GDBusAuthMechanismClass   GDBusAuthMechanismClass;
43 typedef struct _GDBusAuthMechanismPrivate GDBusAuthMechanismPrivate;
44
45 typedef enum {
46   G_DBUS_AUTH_MECHANISM_STATE_INVALID,
47   G_DBUS_AUTH_MECHANISM_STATE_WAITING_FOR_DATA,
48   G_DBUS_AUTH_MECHANISM_STATE_HAVE_DATA_TO_SEND,
49   G_DBUS_AUTH_MECHANISM_STATE_REJECTED,
50   G_DBUS_AUTH_MECHANISM_STATE_ACCEPTED,
51 } GDBusAuthMechanismState;
52
53 struct _GDBusAuthMechanismClass
54 {
55   /*< private >*/
56   GObjectClass parent_class;
57
58   /*< public >*/
59
60   /* VTable */
61
62   /* TODO: server_initiate and client_initiate probably needs to have a
63    * GCredentials parameter...
64    */
65
66   gint                      (*get_priority)             (void);
67   const gchar              *(*get_name)                 (void);
68
69   /* functions shared by server/client */
70   gboolean                  (*is_supported)             (GDBusAuthMechanism   *mechanism);
71   gchar                    *(*encode_data)              (GDBusAuthMechanism   *mechanism,
72                                                          const gchar          *data,
73                                                          gsize                 data_len,
74                                                          gsize                *out_data_len);
75   gchar                    *(*decode_data)              (GDBusAuthMechanism   *mechanism,
76                                                          const gchar          *data,
77                                                          gsize                 data_len,
78                                                          gsize                *out_data_len);
79
80   /* functions for server-side authentication */
81   GDBusAuthMechanismState   (*server_get_state)         (GDBusAuthMechanism   *mechanism);
82   void                      (*server_initiate)          (GDBusAuthMechanism   *mechanism,
83                                                          const gchar          *initial_response,
84                                                          gsize                 initial_response_len);
85   void                      (*server_data_receive)      (GDBusAuthMechanism   *mechanism,
86                                                          const gchar          *data,
87                                                          gsize                 data_len);
88   gchar                    *(*server_data_send)         (GDBusAuthMechanism   *mechanism,
89                                                          gsize                *out_data_len);
90   gchar                    *(*server_get_reject_reason) (GDBusAuthMechanism   *mechanism);
91   void                      (*server_shutdown)          (GDBusAuthMechanism   *mechanism);
92
93   /* functions for client-side authentication */
94   GDBusAuthMechanismState   (*client_get_state)         (GDBusAuthMechanism   *mechanism);
95   gchar                    *(*client_initiate)          (GDBusAuthMechanism   *mechanism,
96                                                          gsize                *out_initial_response_len);
97   void                      (*client_data_receive)      (GDBusAuthMechanism   *mechanism,
98                                                          const gchar          *data,
99                                                          gsize                 data_len);
100   gchar                    *(*client_data_send)         (GDBusAuthMechanism   *mechanism,
101                                                          gsize                *out_data_len);
102   void                      (*client_shutdown)          (GDBusAuthMechanism   *mechanism);
103
104
105   /*< private >*/
106   /* Padding for future expansion */
107   void (*_g_reserved1) (void);
108   void (*_g_reserved2) (void);
109   void (*_g_reserved3) (void);
110   void (*_g_reserved4) (void);
111   void (*_g_reserved5) (void);
112   void (*_g_reserved6) (void);
113   void (*_g_reserved7) (void);
114   void (*_g_reserved8) (void);
115   void (*_g_reserved9) (void);
116   void (*_g_reserved10) (void);
117   void (*_g_reserved11) (void);
118   void (*_g_reserved12) (void);
119   void (*_g_reserved13) (void);
120   void (*_g_reserved14) (void);
121   void (*_g_reserved15) (void);
122   void (*_g_reserved16) (void);
123 };
124
125 struct _GDBusAuthMechanism
126 {
127   GObject parent_instance;
128   GDBusAuthMechanismPrivate *priv;
129 };
130
131 GType                     _g_dbus_auth_mechanism_get_type                 (void) G_GNUC_CONST;
132
133 gint                      _g_dbus_auth_mechanism_get_priority             (GType                 mechanism_type);
134 const gchar              *_g_dbus_auth_mechanism_get_name                 (GType                 mechanism_type);
135
136 GIOStream                *_g_dbus_auth_mechanism_get_stream               (GDBusAuthMechanism   *mechanism);
137 GCredentials             *_g_dbus_auth_mechanism_get_credentials          (GDBusAuthMechanism   *mechanism);
138
139 gboolean                  _g_dbus_auth_mechanism_is_supported             (GDBusAuthMechanism   *mechanism);
140 gchar                    *_g_dbus_auth_mechanism_encode_data              (GDBusAuthMechanism   *mechanism,
141                                                                            const gchar          *data,
142                                                                            gsize                 data_len,
143                                                                            gsize                *out_data_len);
144 gchar                    *_g_dbus_auth_mechanism_decode_data              (GDBusAuthMechanism   *mechanism,
145                                                                            const gchar          *data,
146                                                                            gsize                 data_len,
147                                                                            gsize                *out_data_len);
148
149 GDBusAuthMechanismState   _g_dbus_auth_mechanism_server_get_state         (GDBusAuthMechanism   *mechanism);
150 void                      _g_dbus_auth_mechanism_server_initiate          (GDBusAuthMechanism   *mechanism,
151                                                                            const gchar          *initial_response,
152                                                                            gsize                 initial_response_len);
153 void                      _g_dbus_auth_mechanism_server_data_receive      (GDBusAuthMechanism   *mechanism,
154                                                                            const gchar          *data,
155                                                                            gsize                 data_len);
156 gchar                    *_g_dbus_auth_mechanism_server_data_send         (GDBusAuthMechanism   *mechanism,
157                                                                            gsize                *out_data_len);
158 gchar                    *_g_dbus_auth_mechanism_server_get_reject_reason (GDBusAuthMechanism   *mechanism);
159 void                      _g_dbus_auth_mechanism_server_shutdown          (GDBusAuthMechanism   *mechanism);
160
161 GDBusAuthMechanismState   _g_dbus_auth_mechanism_client_get_state         (GDBusAuthMechanism   *mechanism);
162 gchar                    *_g_dbus_auth_mechanism_client_initiate          (GDBusAuthMechanism   *mechanism,
163                                                                            gsize                *out_initial_response_len);
164 void                      _g_dbus_auth_mechanism_client_data_receive      (GDBusAuthMechanism   *mechanism,
165                                                                            const gchar          *data,
166                                                                            gsize                 data_len);
167 gchar                    *_g_dbus_auth_mechanism_client_data_send         (GDBusAuthMechanism   *mechanism,
168                                                                           gsize                *out_data_len);
169 void                      _g_dbus_auth_mechanism_client_shutdown          (GDBusAuthMechanism   *mechanism);
170
171
172 G_END_DECLS
173
174 #endif /* __G_DBUS_AUTH_MECHANISM_H__ */