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

« back to all changes in this revision

Viewing changes to lasso/xml/disco_service_instance.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: disco_service_instance.c,v 1.9 2005/04/25 17:00:03 nclapies 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/disco_service_instance.h>
 
26
 
 
27
/*
 
28
 * Schema fragment (liberty-idwsf-disco-svc-1.0-errata-v1.0.xsd):
 
29
 * 
 
30
 * <xs:complexType name="ServiceInstanceType">
 
31
 *   <xs:sequence>
 
32
 *     <xs:element ref="ServiceType"/>
 
33
 *     <xs:element name="ProviderID" type="md:entityIDType"/>
 
34
 *     <xs:element name="Description" type="DescriptionType" minOccurs="1" maxOccurs="unbounded"/>
 
35
 *   </xs:sequence>
 
36
 * </xs:complexType>
 
37
 * 
 
38
 * <xs:element name="ServiceType" type="xs:anyURI"/>
 
39
 */
 
40
 
 
41
/*****************************************************************************/
 
42
/* private methods                                                           */
 
43
/*****************************************************************************/
 
44
 
 
45
static struct XmlSnippet schema_snippets[] = {
 
46
        { "ServiceType", SNIPPET_CONTENT,
 
47
          G_STRUCT_OFFSET(LassoDiscoServiceInstance, ServiceType) },
 
48
        { "ProviderID",  SNIPPET_CONTENT,
 
49
          G_STRUCT_OFFSET(LassoDiscoServiceInstance, ProviderID) },
 
50
        { "Description", SNIPPET_LIST_NODES,
 
51
          G_STRUCT_OFFSET(LassoDiscoServiceInstance, Description) },
 
52
        { NULL, 0, 0}
 
53
};
 
54
 
 
55
/*****************************************************************************/
 
56
/* instance and class init functions                                         */
 
57
/*****************************************************************************/
 
58
 
 
59
static void
 
60
instance_init(LassoDiscoServiceInstance *node)
 
61
{
 
62
        node->ServiceType = NULL;
 
63
        node->ProviderID = NULL;
 
64
        node->Description = NULL;
 
65
}
 
66
 
 
67
static void
 
68
class_init(LassoDiscoServiceInstanceClass *klass)
 
69
{
 
70
        LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
 
71
 
 
72
        nclass->node_data = g_new0(LassoNodeClassData, 1);
 
73
        lasso_node_class_set_nodename(nclass, "ServiceInstance");
 
74
        lasso_node_class_set_ns(nclass, LASSO_DISCO_HREF, LASSO_DISCO_PREFIX);
 
75
        lasso_node_class_add_snippets(nclass, schema_snippets);
 
76
}
 
77
 
 
78
GType
 
79
lasso_disco_service_instance_get_type()
 
80
{
 
81
        static GType this_type = 0;
 
82
 
 
83
        if (!this_type) {
 
84
                static const GTypeInfo this_info = {
 
85
                        sizeof (LassoDiscoServiceInstanceClass),
 
86
                        NULL,
 
87
                        NULL,
 
88
                        (GClassInitFunc) class_init,
 
89
                        NULL,
 
90
                        NULL,
 
91
                        sizeof(LassoDiscoServiceInstance),
 
92
                        0,
 
93
                        (GInstanceInitFunc) instance_init,
 
94
                };
 
95
 
 
96
                this_type = g_type_register_static(LASSO_TYPE_NODE,
 
97
                                "LassoDiscoServiceInstance", &this_info, 0);
 
98
        }
 
99
        return this_type;
 
100
}
 
101
 
 
102
LassoDiscoServiceInstance*
 
103
lasso_disco_service_instance_new(const gchar *serviceType,
 
104
                                 const gchar *providerID,
 
105
                                 LassoDiscoDescription *description)
 
106
{
 
107
        LassoDiscoServiceInstance *service_instance;
 
108
 
 
109
        g_return_val_if_fail (serviceType != NULL, NULL);
 
110
        g_return_val_if_fail (providerID != NULL, NULL);
 
111
        g_return_val_if_fail(LASSO_IS_DISCO_DESCRIPTION(description) == TRUE, NULL);
 
112
 
 
113
        g_object_ref(description);
 
114
 
 
115
        service_instance = g_object_new(LASSO_TYPE_DISCO_SERVICE_INSTANCE, NULL);
 
116
 
 
117
        service_instance->ServiceType = g_strdup(serviceType);
 
118
        service_instance->ProviderID = g_strdup(providerID);
 
119
 
 
120
        service_instance->Description = g_list_append(service_instance->Description,
 
121
                                                      description);
 
122
 
 
123
        return service_instance;
 
124
}
 
125
 
 
126
LassoDiscoServiceInstance*
 
127
lasso_disco_service_instance_copy(LassoDiscoServiceInstance *serviceInstance)
 
128
{
 
129
        LassoDiscoServiceInstance *newServiceInstance;
 
130
        LassoDiscoDescription *newDescription;
 
131
        GList *description;
 
132
 
 
133
        g_return_val_if_fail(LASSO_IS_DISCO_SERVICE_INSTANCE(serviceInstance) == TRUE, NULL);
 
134
        
 
135
        newServiceInstance = g_object_new(LASSO_TYPE_DISCO_SERVICE_INSTANCE, NULL);
 
136
 
 
137
        newServiceInstance->ServiceType = g_strdup(serviceInstance->ServiceType);
 
138
        newServiceInstance->ProviderID = g_strdup(serviceInstance->ProviderID);
 
139
        
 
140
        description = serviceInstance->Description;
 
141
        while (description) {
 
142
                newDescription = lasso_disco_description_copy(
 
143
                        LASSO_DISCO_DESCRIPTION(description->data));
 
144
                newServiceInstance->Description = g_list_append(newServiceInstance->Description,
 
145
                                                                newDescription);
 
146
                description = description->next;
 
147
        }
 
148
 
 
149
        return newServiceInstance;
 
150
}