2008-09-12 17:06:58 +02:00
|
|
|
/* $Id$
|
2004-12-10 14:13:13 +01:00
|
|
|
*
|
|
|
|
* Lasso - A free implementation of the Liberty Alliance specifications.
|
|
|
|
*
|
2007-05-30 19:17:45 +02:00
|
|
|
* Copyright (C) 2004-2007 Entr'ouvert
|
2004-12-10 14:13:13 +01:00
|
|
|
* http://lasso.entrouvert.org
|
2008-09-12 17:06:58 +02:00
|
|
|
*
|
2005-01-22 16:57:56 +01:00
|
|
|
* Authors: See AUTHORS file in top-level directory.
|
2004-12-10 14:13:13 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2008-09-12 17:06:58 +02:00
|
|
|
*
|
2004-12-10 14:13:13 +01:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2008-09-12 17:06:58 +02:00
|
|
|
*
|
2004-12-10 14:13:13 +01:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2009-03-27 16:04:26 +01:00
|
|
|
#include "private.h"
|
2009-08-26 17:14:32 +02:00
|
|
|
#include "dst_modify.h"
|
2004-12-10 14:13:13 +01:00
|
|
|
|
2008-05-15 23:17:44 +02:00
|
|
|
/**
|
|
|
|
* SECTION:dst_modify
|
|
|
|
* @short_description: <dst:Modify>
|
|
|
|
*
|
|
|
|
* <figure><title>Schema fragment for dst:Modify</title>
|
|
|
|
* <programlisting><![CDATA[
|
2004-12-10 14:13:13 +01:00
|
|
|
*
|
|
|
|
* <xs:element name="Modify" type="ModifyType"/>
|
|
|
|
* <xs:complexType name="ModifyType">
|
|
|
|
* <xs:sequence>
|
|
|
|
* <xs:group ref="ResourceIDGroup" minOccurs="0"/>
|
|
|
|
* <xs:element name="Modification" maxOccurs="unbounded">
|
|
|
|
* <xs:complexType>
|
|
|
|
* <xs:sequence>
|
|
|
|
* <xs:element name="Select" type="SelectType"/>
|
|
|
|
* <xs:element name="NewData" minOccurs="0">
|
|
|
|
* <xs:complexType>
|
|
|
|
* <xs:sequence>
|
|
|
|
* <xs:any minOccurs="0" maxOccurs="unbounded"/>
|
|
|
|
* </xs:sequence>
|
|
|
|
* </xs:complexType>
|
|
|
|
* </xs:element>
|
|
|
|
* </xs:sequence>
|
|
|
|
* <xs:attribute name="id" type="xs:ID"/>
|
|
|
|
* <xs:attribute name="notChangedSince" type="xs:dateTime"/>
|
|
|
|
* <xs:attribute name="overrideAllowed" type="xs:boolean" default="0"/>
|
|
|
|
* </xs:complexType>
|
|
|
|
* </xs:element>
|
|
|
|
* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/>
|
|
|
|
* </xs:sequence>
|
|
|
|
* <xs:attribute name="id" type="xs:ID"/>
|
|
|
|
* <xs:attribute name="itemID" type="IDType"/>
|
|
|
|
* </xs:complexType>
|
2008-05-15 23:17:44 +02:00
|
|
|
* ]]></programlisting>
|
|
|
|
* </figure>
|
2004-12-10 14:13:13 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* private methods */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
static struct XmlSnippet schema_snippets[] = {
|
2009-01-24 10:33:40 +01:00
|
|
|
{ "ResourceID", SNIPPET_NODE, G_STRUCT_OFFSET(LassoDstModify, ResourceID), NULL, NULL, NULL},
|
2004-12-10 14:13:13 +01:00
|
|
|
{ "EncryptedResourceID", SNIPPET_NODE, G_STRUCT_OFFSET(LassoDstModify,
|
2009-01-24 10:33:40 +01:00
|
|
|
EncryptedResourceID), NULL, NULL, NULL },
|
2004-12-15 14:12:56 +01:00
|
|
|
{ "Modification", SNIPPET_LIST_NODES, G_STRUCT_OFFSET(LassoDstModify,
|
2009-01-24 10:33:40 +01:00
|
|
|
Modification), NULL, NULL, NULL },
|
|
|
|
{ "Extension", SNIPPET_EXTENSION, G_STRUCT_OFFSET(LassoDstModify, Extension), NULL, NULL, NULL},
|
|
|
|
{ "id", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoDstModify, id), NULL, NULL, NULL},
|
|
|
|
{ "itemID", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoDstModify, itemID), NULL, NULL, NULL},
|
|
|
|
{NULL, 0, 0, NULL, NULL, NULL}
|
2004-12-10 14:13:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static LassoNodeClass *parent_class = NULL;
|
|
|
|
|
|
|
|
static void
|
|
|
|
insure_namespace(xmlNode *xmlnode, xmlNs *ns)
|
|
|
|
{
|
2004-12-20 18:26:13 +01:00
|
|
|
xmlNode *t = xmlnode->children;
|
2004-12-10 14:13:13 +01:00
|
|
|
|
2004-12-20 18:26:13 +01:00
|
|
|
xmlSetNs(xmlnode, ns);
|
2004-12-10 14:13:13 +01:00
|
|
|
while (t) {
|
2007-09-21 17:12:18 +02:00
|
|
|
if (t->type == XML_ELEMENT_NODE && t->ns == NULL) {
|
2004-12-20 18:26:13 +01:00
|
|
|
insure_namespace(t, ns);
|
2007-09-21 17:12:18 +02:00
|
|
|
}
|
2004-12-10 14:13:13 +01:00
|
|
|
t = t->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static xmlNode*
|
2004-12-19 21:34:22 +01:00
|
|
|
get_xmlNode(LassoNode *node, gboolean lasso_dump)
|
2004-12-10 14:13:13 +01:00
|
|
|
{
|
|
|
|
xmlNode *xmlnode;
|
|
|
|
xmlNs *ns;
|
|
|
|
|
2004-12-19 21:34:22 +01:00
|
|
|
xmlnode = parent_class->get_xmlNode(node, lasso_dump);
|
2005-07-31 00:36:54 +02:00
|
|
|
ns = xmlNewNs(xmlnode, (xmlChar*)LASSO_DST_MODIFY(node)->hrefServiceType,
|
|
|
|
(xmlChar*)LASSO_DST_MODIFY(node)->prefixServiceType);
|
2004-12-10 14:13:13 +01:00
|
|
|
insure_namespace(xmlnode, ns);
|
|
|
|
|
|
|
|
return xmlnode;
|
|
|
|
}
|
|
|
|
|
2005-08-25 16:23:08 +02:00
|
|
|
static int
|
|
|
|
init_from_xml(LassoNode *node, xmlNode *xmlnode)
|
|
|
|
{
|
2007-09-21 17:12:18 +02:00
|
|
|
LassoDstModify *modify = LASSO_DST_MODIFY(node);
|
2010-04-30 11:23:01 +02:00
|
|
|
int rc = 0;
|
2005-08-25 16:23:08 +02:00
|
|
|
|
|
|
|
rc = parent_class->init_from_xml(node, xmlnode);
|
2007-09-21 17:12:18 +02:00
|
|
|
if (rc) {
|
|
|
|
return rc;
|
|
|
|
}
|
2005-08-25 16:23:08 +02:00
|
|
|
|
2007-09-21 17:12:18 +02:00
|
|
|
modify->hrefServiceType = g_strdup((char*)xmlnode->ns->href);
|
|
|
|
modify->prefixServiceType = lasso_get_prefix_for_dst_service_href(
|
|
|
|
modify->hrefServiceType);
|
|
|
|
if (modify->prefixServiceType == NULL) {
|
2005-09-11 11:08:31 +02:00
|
|
|
/* XXX: what to do here ? */
|
2005-08-25 16:23:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-12-10 14:13:13 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* instance and class init functions */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
class_init(LassoDstModifyClass *klass)
|
|
|
|
{
|
2005-08-25 16:23:08 +02:00
|
|
|
LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
|
2004-12-10 14:13:13 +01:00
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent(klass);
|
2005-08-25 16:23:08 +02:00
|
|
|
nclass->get_xmlNode = get_xmlNode;
|
|
|
|
nclass->init_from_xml = init_from_xml;
|
|
|
|
nclass->node_data = g_new0(LassoNodeClassData, 1);
|
|
|
|
lasso_node_class_set_nodename(nclass, "Modify");
|
|
|
|
lasso_node_class_add_snippets(nclass, schema_snippets);
|
2004-12-10 14:13:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
GType
|
|
|
|
lasso_dst_modify_get_type()
|
|
|
|
{
|
|
|
|
static GType this_type = 0;
|
|
|
|
|
|
|
|
if (!this_type) {
|
|
|
|
static const GTypeInfo this_info = {
|
|
|
|
sizeof (LassoDstModifyClass),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof(LassoDstModify),
|
|
|
|
0,
|
2009-08-26 17:14:48 +02:00
|
|
|
NULL,
|
2009-01-24 10:33:40 +01:00
|
|
|
NULL
|
2004-12-10 14:13:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
this_type = g_type_register_static(LASSO_TYPE_NODE,
|
|
|
|
"LassoDstModify", &this_info, 0);
|
|
|
|
}
|
|
|
|
return this_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
LassoDstModify*
|
2010-01-04 10:14:38 +01:00
|
|
|
lasso_dst_modify_new()
|
2004-12-10 14:13:13 +01:00
|
|
|
{
|
|
|
|
LassoDstModify *modify;
|
2004-12-15 14:12:56 +01:00
|
|
|
|
2004-12-10 14:13:13 +01:00
|
|
|
modify = g_object_new(LASSO_TYPE_DST_MODIFY, NULL);
|
|
|
|
|
|
|
|
return modify;
|
|
|
|
}
|
|
|
|
|