~ubuntu-branches/ubuntu/gutsy/lasso/gutsy

« back to all changes in this revision

Viewing changes to lasso/xml/dst_query_response.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Hermann
  • Date: 2005-09-16 02:16:49 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050916021649-lr5tuka6pfmmks44
Tags: 0.6.2-3ubuntu1
* debian/control: removed hardcoded php dependency, added php:Depends
  substvar
* debian/rules: added phpapiver, added substitution of php:Depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: dst_query_response.c,v 1.17 2005/01/22 15:57:55 eraviart Exp $ 
 
2
 *
 
3
 * Lasso - A free implementation of the Liberty Alliance specifications.
 
4
 *
 
5
 * Copyright (C) 2004, 2005 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, write to the Free Software
 
22
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
23
 */
 
24
 
 
25
#include <lasso/xml/dst_query_response.h>
 
26
 
 
27
/*
 
28
 * Schema fragment (liberty-idwsf-dst-v1.0.xsd):
 
29
 *
 
30
 * <xs:element name="QueryResponse" type="QueryResponseType"/>
 
31
 * <xs:complexType name="QueryResponseType">
 
32
 *   <xs:sequence>
 
33
 *     <xs:element ref="Status"/>
 
34
 *     <xs:element name="Data" minOccurs="0" maxOccurs="unbounded"/>
 
35
 *     <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/>
 
36
 *   </xs:sequence>
 
37
 *   <xs:attribute name="id" type="xs:ID"/>
 
38
 *   <xs:attribute name="itemIDRef" type="IDReferenceType"/>
 
39
 *   <xs:attribute name="timeStamp" type="xs:dateTime"/>
 
40
 * </xs:complexType>
 
41
 *
 
42
 * Schema fragment (liberty-idwsf-utility-1.0-errata-v1.0.xsd):
 
43
 *
 
44
 * <xs:simpleType name="IDReferenceType">
 
45
 *   <xs:annotation>
 
46
 *     <xs:documentation> This type can be used when referring to elements that are
 
47
 *       identified using an IDType </xs:documentation>
 
48
 *     </xs:annotation>
 
49
 *   <xs:restriction base="xs:string"/>
 
50
 * </xs:simpleType>
 
51
 */
 
52
 
 
53
/*****************************************************************************/
 
54
/* private methods                                                           */
 
55
/*****************************************************************************/
 
56
 
 
57
static struct XmlSnippet schema_snippets[] = {
 
58
        { "Status", SNIPPET_NODE, G_STRUCT_OFFSET(LassoDstQueryResponse, Status) },
 
59
        { "Data", SNIPPET_LIST_NODES, G_STRUCT_OFFSET(LassoDstQueryResponse, Data) },
 
60
        { "Extension", SNIPPET_EXTENSION, G_STRUCT_OFFSET(LassoDstQueryResponse, Extension) },
 
61
        { "id", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoDstQueryResponse, id) },
 
62
        { "itemIDRef", SNIPPET_ATTRIBUTE,
 
63
                G_STRUCT_OFFSET(LassoDstQueryResponse, itemIDRef) },
 
64
        { "timeStamp", SNIPPET_ATTRIBUTE,
 
65
                G_STRUCT_OFFSET(LassoDstQueryResponse, timeStamp) },
 
66
        {NULL, 0, 0}
 
67
};
 
68
 
 
69
static LassoNodeClass *parent_class = NULL;
 
70
 
 
71
static void
 
72
insure_namespace(xmlNode *xmlnode, xmlNs *ns)
 
73
{
 
74
        xmlNode *t = xmlnode->children;
 
75
 
 
76
        xmlSetNs(xmlnode, ns);
 
77
        while (t) {
 
78
                if (t->type == XML_ELEMENT_NODE && t->ns == NULL)
 
79
                        insure_namespace(t, ns);
 
80
                t = t->next;
 
81
        }
 
82
}
 
83
 
 
84
static xmlNode*
 
85
get_xmlNode(LassoNode *node, gboolean lasso_dump)
 
86
{
 
87
        xmlNode *xmlnode;
 
88
        xmlNs *ns;
 
89
 
 
90
        xmlnode = parent_class->get_xmlNode(node, lasso_dump);
 
91
        ns = xmlNewNs(xmlnode, LASSO_DST_QUERY_RESPONSE(node)->hrefServiceType,
 
92
                        LASSO_DST_QUERY_RESPONSE(node)->prefixServiceType);
 
93
        insure_namespace(xmlnode, ns);
 
94
 
 
95
        return xmlnode;
 
96
}
 
97
 
 
98
/*****************************************************************************/
 
99
/* instance and class init functions                                         */
 
100
/*****************************************************************************/
 
101
 
 
102
static void
 
103
instance_init(LassoDstQueryResponse *node)
 
104
{
 
105
        node->Status = NULL;
 
106
        node->Data = NULL;
 
107
        node->Extension = NULL;
 
108
 
 
109
        node->id = NULL;
 
110
        node->itemIDRef = NULL;
 
111
        node->timeStamp = NULL;
 
112
 
 
113
        node->prefixServiceType = NULL;
 
114
        node->hrefServiceType = NULL;
 
115
}
 
116
 
 
117
static void
 
118
class_init(LassoDstQueryResponseClass *klass)
 
119
{
 
120
        LassoNodeClass *nodeClass = LASSO_NODE_CLASS(klass);
 
121
 
 
122
        parent_class = g_type_class_peek_parent(klass);
 
123
        nodeClass->get_xmlNode = get_xmlNode;
 
124
        nodeClass->node_data = g_new0(LassoNodeClassData, 1);
 
125
        lasso_node_class_set_nodename(nodeClass, "QueryResponse");
 
126
        lasso_node_class_add_snippets(nodeClass, schema_snippets);
 
127
}
 
128
 
 
129
GType
 
130
lasso_dst_query_response_get_type()
 
131
{
 
132
        static GType this_type = 0;
 
133
 
 
134
        if (!this_type) {
 
135
                static const GTypeInfo this_info = {
 
136
                        sizeof (LassoDstQueryResponseClass),
 
137
                        NULL,
 
138
                        NULL,
 
139
                        (GClassInitFunc) class_init,
 
140
                        NULL,
 
141
                        NULL,
 
142
                        sizeof(LassoDstQueryResponse),
 
143
                        0,
 
144
                        (GInstanceInitFunc) instance_init,
 
145
                };
 
146
 
 
147
                this_type = g_type_register_static(LASSO_TYPE_NODE,
 
148
                                "LassoDstQueryResponse", &this_info, 0);
 
149
        }
 
150
        return this_type;
 
151
}
 
152
 
 
153
LassoDstQueryResponse*
 
154
lasso_dst_query_response_new(LassoUtilityStatus *status)
 
155
{
 
156
        LassoDstQueryResponse *node;
 
157
 
 
158
        g_return_val_if_fail(LASSO_IS_UTILITY_STATUS(status), NULL);
 
159
 
 
160
        node = g_object_new(LASSO_TYPE_DST_QUERY_RESPONSE, NULL);
 
161
 
 
162
        node->Status = status;
 
163
 
 
164
        return node;
 
165
}
 
166