1 /* $Id: disco_svc_md_register.c,v 1.0 2005/10/14 15:17:55 fpeters Exp $
2  *
3  * Lasso - A free implementation of the Liberty Alliance specifications.
4  *
5  * Copyright (C) 2004-2007 Entr'ouvert
6  * http://lasso.entrouvert.org
7  *
8  * Authors: See AUTHORS file in top-level directory.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #include "../private.h"
25 #include "disco_svc_md_register.h"
26 #include "idwsf2_strings.h"
27 #include "disco_svc_metadata.h"
28 
29 /**
30  * SECTION:disco_svc_md_register
31  * @short_description: &lt;disco:SvcMDRegister&gt;
32  *
33  * <figure><title>Schema fragment for disco:SvcMDRegister</title>
34  * <programlisting><![CDATA[
35  *
36  * <xs:complexType name="SvcMDRegisterType">
37  *   <xs:sequence>
38  *     <xs:element ref="SvcMD" maxOccurs="unbounded" />
39  *   </xs:sequence>
40  *   <xs:anyAttribute namespace="##other" processContents="lax"/>
41  * </xs:complexType>
42  * ]]></programlisting>
43  * </figure>
44  */
45 
46 /*****************************************************************************/
47 /* private methods                                                           */
48 /*****************************************************************************/
49 
50 
51 static struct XmlSnippet schema_snippets[] = {
52 	{ "SvcMD", SNIPPET_LIST_NODES,
53 		G_STRUCT_OFFSET(LassoIdWsf2DiscoSvcMDRegister, SvcMD),
54 		"LassoIdWsf2DiscoSvcMetadata", NULL, NULL },
55 	{ "attributes", SNIPPET_ATTRIBUTE | SNIPPET_ANY,
56 		G_STRUCT_OFFSET(LassoIdWsf2DiscoSvcMDRegister, attributes), NULL, NULL, NULL},
57 	{NULL, 0, 0, NULL, NULL, NULL}
58 };
59 
60 static LassoNodeClass *parent_class = NULL;
61 
62 
63 /*****************************************************************************/
64 /* instance and class init functions                                         */
65 /*****************************************************************************/
66 
67 static void
instance_init(LassoIdWsf2DiscoSvcMDRegister * node)68 instance_init(LassoIdWsf2DiscoSvcMDRegister *node)
69 {
70 	node->attributes = g_hash_table_new_full(
71 		g_str_hash, g_str_equal, g_free, g_free);
72 }
73 
74 static void
class_init(LassoIdWsf2DiscoSvcMDRegisterClass * klass,void * unused G_GNUC_UNUSED)75 class_init(LassoIdWsf2DiscoSvcMDRegisterClass *klass, void *unused G_GNUC_UNUSED)
76 {
77 	LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
78 
79 	parent_class = g_type_class_peek_parent(klass);
80 	nclass->node_data = g_new0(LassoNodeClassData, 1);
81 	lasso_node_class_set_nodename(nclass, "SvcMDRegister");
82 	lasso_node_class_set_ns(nclass, LASSO_IDWSF2_DISCOVERY_HREF, LASSO_IDWSF2_DISCOVERY_PREFIX);
83 	lasso_node_class_add_snippets(nclass, schema_snippets);
84 }
85 
86 GType
lasso_idwsf2_disco_svc_md_register_get_type()87 lasso_idwsf2_disco_svc_md_register_get_type()
88 {
89 	static GType this_type = 0;
90 
91 	if (!this_type) {
92 		static const GTypeInfo this_info = {
93 			sizeof (LassoIdWsf2DiscoSvcMDRegisterClass),
94 			NULL,
95 			NULL,
96 			(GClassInitFunc) class_init,
97 			NULL,
98 			NULL,
99 			sizeof(LassoIdWsf2DiscoSvcMDRegister),
100 			0,
101 			(GInstanceInitFunc) instance_init,
102 			NULL
103 		};
104 
105 		this_type = g_type_register_static(LASSO_TYPE_NODE,
106 				"LassoIdWsf2DiscoSvcMDRegister", &this_info, 0);
107 	}
108 	return this_type;
109 }
110 
111 /**
112  * lasso_idwsf2_disco_svc_md_register_new:
113  *
114  * Creates a new #LassoIdWsf2DiscoSvcMDRegister object.
115  *
116  * Return value: a newly created #LassoIdWsf2DiscoSvcMDRegister object
117  **/
118 LassoIdWsf2DiscoSvcMDRegister*
lasso_idwsf2_disco_svc_md_register_new()119 lasso_idwsf2_disco_svc_md_register_new()
120 {
121 	return g_object_new(LASSO_TYPE_IDWSF2_DISCO_SVC_MD_REGISTER, NULL);
122 }
123 
124 
125 /**
126  * lasso_idwsf2_disco_svc_md_register_new_full:
127  * @service_type: the service type for the registered metadatas
128  * @abstract: the human description for the service
129  * @provider_id: the SAML provider id of the service
130  * @soap_endpoint: the SOAP endpoint URL for the service
131  *
132  * Create and initialize a complete message for registering new metadatas at a discovery service.
133  *
134  * Return value: a new filled and initialized #LassoIdWsf2DiscoSvcMDRegister if successfull, NULL
135  * otherwise.
136  */
137 LassoIdWsf2DiscoSvcMDRegister*
lasso_idwsf2_disco_svc_md_register_new_full(const gchar * service_type,const gchar * abstract,const gchar * provider_id,const gchar * soap_endpoint)138 lasso_idwsf2_disco_svc_md_register_new_full(const gchar *service_type, const gchar *abstract,
139 		const gchar *provider_id, const gchar *soap_endpoint)
140 {
141 	LassoIdWsf2DiscoSvcMDRegister *metadata_register;
142 	LassoIdWsf2DiscoSvcMetadata *metadata;
143 
144 	metadata_register = lasso_idwsf2_disco_svc_md_register_new();
145 	metadata = lasso_idwsf2_disco_svc_metadata_new_full(service_type, abstract, provider_id,
146 			soap_endpoint);
147 	metadata_register->SvcMD = g_list_append(
148 			metadata_register->SvcMD, metadata);
149 
150 	return metadata_register;
151 }
152