source: trunk/third/ammonite/libammonite/authn-callback-wrapper.c @ 15506

Revision 15506, 4.5 KB checked in by ghudson, 24 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r15505, which included commits to RCS files with non-trunk default branches.
Line 
1
2/* $Id: authn-callback-wrapper.c,v 1.1.1.1 2001-01-16 15:25:55 ghudson Exp $
3 *
4 * Copyright (C) 2000 Eazel, Inc
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 *
21 * Author:  Michael Fleming <mfleming@eazel.com>
22 *
23 */
24
25#ifdef HAVE_CONFIG_H
26#include <config.h>
27#endif
28
29#include "libammonite.h"
30#include <glib.h>
31
32/* TRUE if no CORBA exception has occured */
33#define NO_CORBA_EXCEPTION(ev)  (CORBA_NO_EXCEPTION == (ev)._major)
34
35static void
36impl_EazelProxy_AuthnCallback_succeeded (
37        PortableServer_Servant servant,
38        const EazelProxy_User * user,
39        CORBA_Environment *ev
40);
41static void
42impl_EazelProxy_AuthnCallback_failed (
43        PortableServer_Servant servant,
44        const EazelProxy_User * user,
45        const EazelProxy_AuthnFailInfo *info,
46        CORBA_Environment *ev
47);
48
49typedef struct {
50        POA_EazelProxy_AuthnCallback    poa;
51        AmmoniteAuthCallbackWrapperFuncs funcs;
52        gpointer user_data;
53} impl_POA_EazelProxy_AuthnCallback;
54
55/*******************************************************************
56 * Module Globals
57 *******************************************************************/
58
59static PortableServer_ServantBase__epv base_epv = { NULL, NULL, NULL };
60static POA_EazelProxy_AuthnCallback__epv authncallback_epv = {
61        NULL,
62        impl_EazelProxy_AuthnCallback_succeeded,
63        impl_EazelProxy_AuthnCallback_failed
64};
65
66static POA_EazelProxy_AuthnCallback__vepv authncallback_vepv = {
67        &base_epv, &authncallback_epv
68};
69
70/*******************************************************************
71 * EazelProxy_AuthnCallback impl
72 *******************************************************************/
73
74static void
75impl_EazelProxy_AuthnCallback_succeeded (
76        PortableServer_Servant servant,
77        const EazelProxy_User * user,
78        CORBA_Environment *ev
79) {
80        impl_POA_EazelProxy_AuthnCallback *my_servant;
81        my_servant =  (impl_POA_EazelProxy_AuthnCallback *) servant;
82
83        if (my_servant->funcs.succeeded) {
84                my_servant->funcs.succeeded (user, my_servant->user_data, ev);
85        }
86}
87
88static void
89impl_EazelProxy_AuthnCallback_failed (
90        PortableServer_Servant servant,
91        const EazelProxy_User * user,
92        const EazelProxy_AuthnFailInfo *info,
93        CORBA_Environment *ev
94) {
95        impl_POA_EazelProxy_AuthnCallback *my_servant;
96        my_servant =  (impl_POA_EazelProxy_AuthnCallback *) servant;
97
98        if (my_servant->funcs.failed) {
99                my_servant->funcs.failed (user, info, my_servant->user_data, ev);
100        }
101}
102
103
104EazelProxy_AuthnCallback
105ammonite_auth_callback_wrapper_new (
106        PortableServer_POA poa,
107        const AmmoniteAuthCallbackWrapperFuncs *funcs,
108        gpointer user_data
109) {
110
111        CORBA_Environment ev;
112        impl_POA_EazelProxy_AuthnCallback *servant;
113        EazelProxy_AuthnCallback ret;
114
115        g_return_val_if_fail ( NULL != funcs, CORBA_OBJECT_NIL);       
116       
117        CORBA_exception_init (&ev);
118
119        servant = g_new0 (impl_POA_EazelProxy_AuthnCallback, 1);
120
121        servant->poa.vepv = &authncallback_vepv;
122
123        memcpy ( &(servant->funcs), funcs, sizeof(*funcs));
124        servant->user_data = user_data;
125
126        POA_EazelProxy_AuthnCallback__init (servant, &ev);
127
128        CORBA_free (PortableServer_POA_activate_object (poa, servant, &ev));
129
130        ret = (EazelProxy_AuthnCallback)PortableServer_POA_servant_to_reference (poa, servant, &ev);
131
132        if (! NO_CORBA_EXCEPTION (ev) ) {
133                g_warning ("Could not instantiate EazelProxy_AuthnCallback corba object");
134                g_free (servant);
135                servant = NULL;
136                ret = CORBA_OBJECT_NIL;
137        }
138
139        CORBA_exception_free (&ev);
140
141        return ret;
142}
143
144void
145ammonite_auth_callback_wrapper_free (PortableServer_POA poa, EazelProxy_AuthnCallback object)
146{
147        CORBA_Environment ev;
148        PortableServer_ObjectId *object_id;
149        impl_POA_EazelProxy_AuthnCallback * servant;
150
151        CORBA_exception_init (&ev);
152
153        servant = PortableServer_POA_reference_to_servant (poa, object, &ev);
154
155        object_id = PortableServer_POA_servant_to_id (poa, servant, &ev);
156
157        PortableServer_POA_deactivate_object (poa, object_id, &ev);
158
159        CORBA_free (object_id);
160
161        POA_EazelProxy_AuthnCallback__fini (servant, &ev);
162        g_free (servant);
163
164        CORBA_exception_free (&ev);
165}
166
Note: See TracBrowser for help on using the repository browser.