1 /* GDBus - GLib D-Bus Library
3 * Copyright (C) 2008-2010 Red Hat, Inc.
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.
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.
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.
20 * Author: David Zeuthen <davidz@redhat.com>
23 #ifndef __G_DBUS_AUTH_MECHANISM_H__
24 #define __G_DBUS_AUTH_MECHANISM_H__
26 #if !defined (GIO_COMPILATION)
27 #error "gdbusauthmechanism.h is a private header file."
30 #include <gio/giotypes.h>
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))
41 typedef struct _GDBusAuthMechanism GDBusAuthMechanism
;
42 typedef struct _GDBusAuthMechanismClass GDBusAuthMechanismClass
;
43 typedef struct _GDBusAuthMechanismPrivate GDBusAuthMechanismPrivate
;
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
;
53 struct _GDBusAuthMechanismClass
56 GObjectClass parent_class
;
62 /* TODO: server_initiate and client_initiate probably needs to have a
63 * GCredentials parameter...
66 gint (*get_priority
) (void);
67 const gchar
*(*get_name
) (void);
69 /* functions shared by server/client */
70 gboolean (*is_supported
) (GDBusAuthMechanism
*mechanism
);
71 gchar
*(*encode_data
) (GDBusAuthMechanism
*mechanism
,
75 gchar
*(*decode_data
) (GDBusAuthMechanism
*mechanism
,
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
,
88 gchar
*(*server_data_send
) (GDBusAuthMechanism
*mechanism
,
90 gchar
*(*server_get_reject_reason
) (GDBusAuthMechanism
*mechanism
);
91 void (*server_shutdown
) (GDBusAuthMechanism
*mechanism
);
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
,
100 gchar
*(*client_data_send
) (GDBusAuthMechanism
*mechanism
,
101 gsize
*out_data_len
);
102 void (*client_shutdown
) (GDBusAuthMechanism
*mechanism
);
105 struct _GDBusAuthMechanism
107 GObject parent_instance
;
108 GDBusAuthMechanismPrivate
*priv
;
111 GType
_g_dbus_auth_mechanism_get_type (void) G_GNUC_CONST
;
113 gint
_g_dbus_auth_mechanism_get_priority (GType mechanism_type
);
114 const gchar
*_g_dbus_auth_mechanism_get_name (GType mechanism_type
);
116 GIOStream
*_g_dbus_auth_mechanism_get_stream (GDBusAuthMechanism
*mechanism
);
117 GCredentials
*_g_dbus_auth_mechanism_get_credentials (GDBusAuthMechanism
*mechanism
);
119 gboolean
_g_dbus_auth_mechanism_is_supported (GDBusAuthMechanism
*mechanism
);
120 gchar
*_g_dbus_auth_mechanism_encode_data (GDBusAuthMechanism
*mechanism
,
123 gsize
*out_data_len
);
124 gchar
*_g_dbus_auth_mechanism_decode_data (GDBusAuthMechanism
*mechanism
,
127 gsize
*out_data_len
);
129 GDBusAuthMechanismState
_g_dbus_auth_mechanism_server_get_state (GDBusAuthMechanism
*mechanism
);
130 void _g_dbus_auth_mechanism_server_initiate (GDBusAuthMechanism
*mechanism
,
131 const gchar
*initial_response
,
132 gsize initial_response_len
);
133 void _g_dbus_auth_mechanism_server_data_receive (GDBusAuthMechanism
*mechanism
,
136 gchar
*_g_dbus_auth_mechanism_server_data_send (GDBusAuthMechanism
*mechanism
,
137 gsize
*out_data_len
);
138 gchar
*_g_dbus_auth_mechanism_server_get_reject_reason (GDBusAuthMechanism
*mechanism
);
139 void _g_dbus_auth_mechanism_server_shutdown (GDBusAuthMechanism
*mechanism
);
141 GDBusAuthMechanismState
_g_dbus_auth_mechanism_client_get_state (GDBusAuthMechanism
*mechanism
);
142 gchar
*_g_dbus_auth_mechanism_client_initiate (GDBusAuthMechanism
*mechanism
,
143 gsize
*out_initial_response_len
);
144 void _g_dbus_auth_mechanism_client_data_receive (GDBusAuthMechanism
*mechanism
,
147 gchar
*_g_dbus_auth_mechanism_client_data_send (GDBusAuthMechanism
*mechanism
,
148 gsize
*out_data_len
);
149 void _g_dbus_auth_mechanism_client_shutdown (GDBusAuthMechanism
*mechanism
);
154 #endif /* __G_DBUS_AUTH_MECHANISM_H__ */