1 /* $Id: dstref_modify.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 "dstref_modify.h"
26 #include "idwsf2_strings.h"
27 
28 /**
29  * SECTION:dstref_modify
30  * @short_description: &lt;dstref:Modify&gt;
31  *
32  * <figure><title>Schema fragment for dstref:Modify</title>
33  * <programlisting><![CDATA[
34  *
35  * <xs:complexType name="ModifyType">
36  *   <xs:complexContent>
37  *     <xs:extension base="dst:RequestType">
38  *       <xs:sequence>
39  *         <xs:element ref="dstref:ModifyItem" minOccurs="1" maxOccurs="unbounded"/>
40  *         <xs:element ref="dstref:ResultQuery" minOccurs="0" maxOccurs="unbounded"/>
41  *       </xs:sequence>
42  *     </xs:extension>
43  *   </xs:complexContent>
44  * </xs:complexType>
45  * ]]></programlisting>
46  * </figure>
47  */
48 
49 /*****************************************************************************/
50 /* private methods                                                           */
51 /*****************************************************************************/
52 
53 
54 static struct XmlSnippet schema_snippets[] = {
55 	{ "ModifyItem", SNIPPET_LIST_NODES,
56 		G_STRUCT_OFFSET(LassoIdWsf2DstRefModify, ModifyItem),
57 		"LassoIdWsf2DstRefModifyItem", NULL, NULL },
58 	{ "ResultQuery", SNIPPET_LIST_NODES,
59 		G_STRUCT_OFFSET(LassoIdWsf2DstRefModify, ResultQuery),
60 		"LassoIdWsf2DstRefResultQuery", NULL, NULL },
61 	{NULL, 0, 0, NULL, NULL, NULL}
62 };
63 
64 static LassoNodeClass *parent_class = NULL;
65 
66 static xmlNode*
get_xmlNode(LassoNode * node,gboolean lasso_dump)67 get_xmlNode(LassoNode *node, gboolean lasso_dump)
68 {
69 	xmlNode *xmlnode;
70 
71 	xmlnode = parent_class->get_xmlNode(node, lasso_dump);
72 	xml_insure_namespace(xmlnode, NULL, TRUE,
73 			LASSO_IDWSF2_DSTREF_MODIFY(node)->hrefServiceType,
74 			LASSO_IDWSF2_DSTREF_MODIFY(node)->prefixServiceType);
75 
76 	return xmlnode;
77 }
78 
79 static int
init_from_xml(LassoNode * node,xmlNode * xmlnode)80 init_from_xml(LassoNode *node, xmlNode *xmlnode)
81 {
82 	LassoIdWsf2DstRefModify *object = LASSO_IDWSF2_DSTREF_MODIFY(node);
83 	int res;
84 
85 	res = parent_class->init_from_xml(node, xmlnode);
86 	if (res != 0) {
87 		return res;
88 	}
89 
90 	object->hrefServiceType = g_strdup((char*)xmlnode->ns->href);
91 	object->prefixServiceType = lasso_get_prefix_for_idwsf2_dst_service_href(
92 			object->hrefServiceType);
93 	if (object->prefixServiceType == NULL) {
94 		/* XXX: what to do here ? */
95 	}
96 
97 	return 0;
98 }
99 
100 /*****************************************************************************/
101 /* instance and class init functions                                         */
102 /*****************************************************************************/
103 
104 
105 static void
class_init(LassoIdWsf2DstRefModifyClass * klass,void * unused G_GNUC_UNUSED)106 class_init(LassoIdWsf2DstRefModifyClass *klass, void *unused G_GNUC_UNUSED)
107 {
108 	LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
109 
110 	parent_class = g_type_class_peek_parent(klass);
111 	nclass->get_xmlNode = get_xmlNode;
112 	nclass->init_from_xml = init_from_xml;
113 	nclass->node_data = g_new0(LassoNodeClassData, 1);
114 	lasso_node_class_set_nodename(nclass, "Modify");
115 	lasso_node_class_set_ns(nclass, LASSO_IDWSF2_DSTREF_HREF, LASSO_IDWSF2_DSTREF_PREFIX);
116 	lasso_node_class_add_snippets(nclass, schema_snippets);
117 }
118 
119 GType
lasso_idwsf2_dstref_modify_get_type()120 lasso_idwsf2_dstref_modify_get_type()
121 {
122 	static GType this_type = 0;
123 
124 	if (!this_type) {
125 		static const GTypeInfo this_info = {
126 			sizeof (LassoIdWsf2DstRefModifyClass),
127 			NULL,
128 			NULL,
129 			(GClassInitFunc) class_init,
130 			NULL,
131 			NULL,
132 			sizeof(LassoIdWsf2DstRefModify),
133 			0,
134 			NULL,
135 			NULL
136 		};
137 
138 		this_type = g_type_register_static(LASSO_TYPE_IDWSF2_DST_REQUEST,
139 				"LassoIdWsf2DstRefModify", &this_info, 0);
140 	}
141 	return this_type;
142 }
143 
144 /**
145  * lasso_idwsf2_dstref_modify_new:
146  *
147  * Creates a new #LassoIdWsf2DstRefModify object.
148  *
149  * Return value: a newly created #LassoIdWsf2DstRefModify object
150  **/
151 LassoIdWsf2DstRefModify*
lasso_idwsf2_dstref_modify_new()152 lasso_idwsf2_dstref_modify_new()
153 {
154 	return g_object_new(LASSO_TYPE_IDWSF2_DSTREF_MODIFY, NULL);
155 }
156