1 /* $Id: subs_subscription.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 "subs_subscription.h"
26 #include "idwsf2_strings.h"
27 
28 /**
29  * SECTION:subs_subscription
30  * @short_description: &lt;subs:Subscription&gt;
31  *
32  * <figure><title>Schema fragment for subs:Subscription</title>
33  * <programlisting><![CDATA[
34  *
35  * <xs:complexType name="SubscriptionType">
36  *   <xs:sequence>
37  *     <xs:element ref="subs:RefItem" minOccurs="0" maxOccurs="unbounded"/>
38  *     <xs:element ref="lu:Extension" minOccurs="0" maxOccurs="unbounded"/>
39  *   </xs:sequence>
40  *   <xs:attribute name="subscriptionID" use="required" type="lu:IDType"/>
41  *   <xs:attribute name="notifyToRef" use="required" type="xs:anyURI"/>
42  *   <xs:attribute name="adminNotifyToRef" use="optional" type="xs:anyURI"/>
43  *   <xs:attribute name="starts" use="optional" type="xs:dateTime"/>
44  *   <xs:attribute name="expires" use="optional" type="xs:dateTime"/>
45  *   <xs:attribute name="id" use="optional" type="xs:ID"/>
46  *   <xs:attribute name="includeData" use="optional">
47  *     <xs:simpleType>
48  *       <xs:restriction base="xs:string">
49  *         <xs:enumeration value="Yes"/>
50  *         <xs:enumeration value="No"/>
51  *         <xs:enumeration value="YesWithCommonAttributes"/>
52  *       </xs:restriction>
53  *     </xs:simpleType>
54  *   </xs:attribute>
55  * </xs:complexType>
56  * ]]></programlisting>
57  * </figure>
58  */
59 
60 /*****************************************************************************/
61 /* private methods                                                           */
62 /*****************************************************************************/
63 
64 
65 static struct XmlSnippet schema_snippets[] = {
66 	{ "RefItem", SNIPPET_LIST_NODES,
67 		G_STRUCT_OFFSET(LassoIdWsf2SubsSubscription, RefItem), NULL, NULL, NULL},
68 	{ "Extension", SNIPPET_LIST_NODES,
69 		G_STRUCT_OFFSET(LassoIdWsf2SubsSubscription, Extension),
70 		"LassoIdWsf2Utilextension", LASSO_IDWSF2_UTIL_PREFIX, LASSO_IDWSF2_UTIL_HREF},
71 	{ "subscriptionID", SNIPPET_ATTRIBUTE,
72 		G_STRUCT_OFFSET(LassoIdWsf2SubsSubscription, subscriptionID), NULL, NULL, NULL},
73 	{ "notifyToRef", SNIPPET_ATTRIBUTE,
74 		G_STRUCT_OFFSET(LassoIdWsf2SubsSubscription, notifyToRef), NULL, NULL, NULL},
75 	{ "adminNotifyToRef", SNIPPET_ATTRIBUTE | SNIPPET_OPTIONAL,
76 		G_STRUCT_OFFSET(LassoIdWsf2SubsSubscription, adminNotifyToRef), NULL, NULL, NULL},
77 	{ "starts", SNIPPET_ATTRIBUTE | SNIPPET_OPTIONAL,
78 		G_STRUCT_OFFSET(LassoIdWsf2SubsSubscription, starts), NULL, NULL, NULL},
79 	{ "expires", SNIPPET_ATTRIBUTE | SNIPPET_OPTIONAL,
80 		G_STRUCT_OFFSET(LassoIdWsf2SubsSubscription, expires), NULL, NULL, NULL},
81 	{ "id", SNIPPET_ATTRIBUTE | SNIPPET_OPTIONAL,
82 		G_STRUCT_OFFSET(LassoIdWsf2SubsSubscription, id), NULL, NULL, NULL},
83 	{ "includeData", SNIPPET_ATTRIBUTE | SNIPPET_OPTIONAL,
84 		G_STRUCT_OFFSET(LassoIdWsf2SubsSubscription, includeData), NULL, NULL, NULL},
85 	{NULL, 0, 0, NULL, NULL, NULL}
86 };
87 
88 static LassoNodeClass *parent_class = NULL;
89 
90 
91 /*****************************************************************************/
92 /* instance and class init functions                                         */
93 /*****************************************************************************/
94 
95 
96 static void
class_init(LassoIdWsf2SubsSubscriptionClass * klass,void * unused G_GNUC_UNUSED)97 class_init(LassoIdWsf2SubsSubscriptionClass *klass, void *unused G_GNUC_UNUSED)
98 {
99 	LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
100 
101 	parent_class = g_type_class_peek_parent(klass);
102 	nclass->node_data = g_new0(LassoNodeClassData, 1);
103 	lasso_node_class_set_nodename(nclass, "Subscription");
104 	lasso_node_class_set_ns(nclass, LASSO_IDWSF2_SUBS_HREF, LASSO_IDWSF2_SUBS_PREFIX);
105 	lasso_node_class_add_snippets(nclass, schema_snippets);
106 }
107 
108 GType
lasso_idwsf2_subs_subscription_get_type()109 lasso_idwsf2_subs_subscription_get_type()
110 {
111 	static GType this_type = 0;
112 
113 	if (!this_type) {
114 		static const GTypeInfo this_info = {
115 			sizeof (LassoIdWsf2SubsSubscriptionClass),
116 			NULL,
117 			NULL,
118 			(GClassInitFunc) class_init,
119 			NULL,
120 			NULL,
121 			sizeof(LassoIdWsf2SubsSubscription),
122 			0,
123 			NULL,
124 			NULL
125 		};
126 
127 		this_type = g_type_register_static(LASSO_TYPE_NODE,
128 				"LassoIdWsf2SubsSubscription", &this_info, 0);
129 	}
130 	return this_type;
131 }
132 
133 /**
134  * lasso_idwsf2_subs_subscription_new:
135  *
136  * Creates a new #LassoIdWsf2SubsSubscription object.
137  *
138  * Return value: a newly created #LassoIdWsf2SubsSubscription object
139  **/
140 LassoIdWsf2SubsSubscription*
lasso_idwsf2_subs_subscription_new()141 lasso_idwsf2_subs_subscription_new()
142 {
143 	return g_object_new(LASSO_TYPE_IDWSF2_SUBS_SUBSCRIPTION, NULL);
144 }
145