1 /* $Id: dstref_modify_item.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_item.h"
26 #include "idwsf2_strings.h"
27 
28 /**
29  * SECTION:dstref_modify_item
30  * @short_description: &lt;dstref:ModifyItem&gt;
31  *
32  * <figure><title>Schema fragment for dstref:ModifyItem</title>
33  * <programlisting><![CDATA[
34  *
35  * <xs:complexType name="ModifyItemType">
36  *   <xs:sequence>
37  *     <xs:element ref="dstref:Select" minOccurs="0" maxOccurs="1"/>
38  *     <xs:element ref="dstref:NewData" minOccurs="0" maxOccurs="1"/>
39  *   </xs:sequence>
40  *   <xs:attributeGroup ref="dst:ModifyItemAttributeGroup"/>
41  * </xs:complexType>
42  * ]]></programlisting>
43  * </figure>
44  */
45 
46 /*****************************************************************************/
47 /* private methods                                                           */
48 /*****************************************************************************/
49 
50 
51 static struct XmlSnippet schema_snippets[] = {
52 	{ "Select", SNIPPET_CONTENT,
53 		G_STRUCT_OFFSET(LassoIdWsf2DstRefModifyItem, Select), NULL, NULL, NULL},
54 	{ "NewData", SNIPPET_NODE,
55 		G_STRUCT_OFFSET(LassoIdWsf2DstRefModifyItem, NewData),
56 		"LassoIdWsf2DstRefAppData", NULL, NULL },
57 	{ "notChangedSince", SNIPPET_ATTRIBUTE | SNIPPET_OPTIONAL,
58 		G_STRUCT_OFFSET(LassoIdWsf2DstRefModifyItem, notChangedSince), NULL, NULL, NULL},
59 	{ "overrideAllowed", SNIPPET_ATTRIBUTE | SNIPPET_BOOLEAN | SNIPPET_OPTIONAL,
60 		G_STRUCT_OFFSET(LassoIdWsf2DstRefModifyItem, overrideAllowed), NULL, NULL, NULL},
61 	{ "id", SNIPPET_ATTRIBUTE | SNIPPET_OPTIONAL,
62 		G_STRUCT_OFFSET(LassoIdWsf2DstRefModifyItem, id), NULL, NULL, NULL},
63 	{ "itemID", SNIPPET_ATTRIBUTE,
64 		G_STRUCT_OFFSET(LassoIdWsf2DstRefModifyItem, itemID), NULL, NULL, NULL},
65 	{NULL, 0, 0, NULL, NULL, NULL}
66 };
67 
68 static LassoNodeClass *parent_class = NULL;
69 
70 
71 /*****************************************************************************/
72 /* instance and class init functions                                         */
73 /*****************************************************************************/
74 
75 
76 static void
class_init(LassoIdWsf2DstRefModifyItemClass * klass,void * unused G_GNUC_UNUSED)77 class_init(LassoIdWsf2DstRefModifyItemClass *klass, void *unused G_GNUC_UNUSED)
78 {
79 	LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
80 
81 	parent_class = g_type_class_peek_parent(klass);
82 	nclass->node_data = g_new0(LassoNodeClassData, 1);
83 	lasso_node_class_set_nodename(nclass, "ModifyItem");
84 	lasso_node_class_set_ns(nclass, LASSO_IDWSF2_DSTREF_HREF, LASSO_IDWSF2_DSTREF_PREFIX);
85 	lasso_node_class_add_snippets(nclass, schema_snippets);
86 }
87 
88 GType
lasso_idwsf2_dstref_modify_item_get_type()89 lasso_idwsf2_dstref_modify_item_get_type()
90 {
91 	static GType this_type = 0;
92 
93 	if (!this_type) {
94 		static const GTypeInfo this_info = {
95 			sizeof (LassoIdWsf2DstRefModifyItemClass),
96 			NULL,
97 			NULL,
98 			(GClassInitFunc) class_init,
99 			NULL,
100 			NULL,
101 			sizeof(LassoIdWsf2DstRefModifyItem),
102 			0,
103 			NULL,
104 			NULL
105 		};
106 
107 		this_type = g_type_register_static(LASSO_TYPE_NODE,
108 				"LassoIdWsf2DstRefModifyItem", &this_info, 0);
109 	}
110 	return this_type;
111 }
112 
113 /**
114  * lasso_idwsf2_dstref_modify_item_new:
115  *
116  * Creates a new #LassoIdWsf2DstRefModifyItem object.
117  *
118  * Return value: a newly created #LassoIdWsf2DstRefModifyItem object
119  **/
120 LassoIdWsf2DstRefModifyItem*
lasso_idwsf2_dstref_modify_item_new()121 lasso_idwsf2_dstref_modify_item_new()
122 {
123 	return g_object_new(LASSO_TYPE_IDWSF2_DSTREF_MODIFY_ITEM, NULL);
124 }
125 
126 LassoIdWsf2DstRefModifyItem*
lasso_idwsf2_dstref_modify_item_new_full(const gchar * item_xpath,const gchar * item_id,xmlNode * new_data,gboolean overrideAllowed)127 lasso_idwsf2_dstref_modify_item_new_full(const gchar *item_xpath, const gchar *item_id,
128 	xmlNode *new_data, gboolean overrideAllowed)
129 {
130 	LassoIdWsf2DstRefModifyItem *item;
131 
132 	item = g_object_new(LASSO_TYPE_IDWSF2_DSTREF_MODIFY_ITEM, NULL);
133 	item->Select = g_strdup(item_xpath);
134 	item->id = g_strdup(item_id);
135 	item->NewData = lasso_idwsf2_dstref_app_data_new();
136 	item->NewData->any = g_list_append(item->NewData->any, new_data);
137 	item->overrideAllowed = overrideAllowed;
138 
139 	return item;
140 }
141 
142