Subject: PubSubIq (for node config) and xdatacontrol
Hello,
I am working on a pubsub implementation to keep content syndication catalogs updated between a set of syndication partners and have run into several small issues, many of which I have been able to work around, but this one has me stumped. I am sending OpenFire a request for the configuration form of a given topical node (stream captures below). I then intend to take the agsXMPP.protocol.x.data.Data that is returned and render it using the xdatacontrol. I create the request in this way
agsXMPP.protocol.extensions.pubsub.PubSubIq getter = new agsXMPP.protocol.extensions.pubsub.PubSubIq(IqType.get);
getter.PubSub.Namespace = "http://jabber.org/protocol/pubsub#owner";
getter.PubSub.Configure = new Configure(NodeName);
I cannot use the agsXMPP.protocol.extensions.pubsub.owner.PubSubIq class (which would already have this namespace) because the agsXMPP.protocol.extensions.pubsub.owner.Configure class renders without a tagname and causes stream termination.
(edit) I have discovered that this only happens when one uses the overloaded constructor that takes a node name... here is why (tagname and namespace are not set in that constructor)
#region << Constructor >>
public Configure()
{
this.TagName = "configure";
this.Namespace = Uri.PUBSUB_OWNER;
}
public Configure(string node)
{
this.Node = node;
}
At issue is in my call back I get the IQ object it is a straight IQ, not a PubSubIQ, which means it is expecting a query element as a child and not a pubsub element as a child. There seems to be no way to cast this to a pubsubIQ to that I can get to the x.data.DATA object expected by the xdatacontrol.createform() function and no way to gen ANY object by reading / loading it from the XML. I have tried this
private void GetNodeConfigCallBack(object sender, IQ Iq, object Data)
{
agsXMPP.protocol.extensions.pubsub.owner.PubSubIq oIq = new agsXMPP.protocol.extensions.pubsub.owner.PubSubIq(IqType.result);
agsXMPP.Xml.Dom.Element pubsub = Iq.SelectSingleElement("pubsub");
oIq.ReplaceChild(pubsub);
...
And although the innerxml of the oIq object now shows:
<pubsub xmlns=\"http://jabber.org/protocol/pubsub#owner\"><configure xmlns=\"http://jabber.org/protocol/pubsub\" node=\"Breast Cancer\"><x xmlns=\"jabber:x:data\" type=\"form\"><title>Node configuration</title><instructions>Please provide the configuration for node \"Breast Cancer\".</instructions><field type=\"jid-multi\" label=\"People to contact with questions\" var=\"pubsub#contact\" /><field type=\"text-single\" label=\"Default language\" var=\"pubsub#language\"><value>English</value></field>
...
<field type=\"text-single\" label=\"Max payload size in bytes\" var=\"pubsub#max_payload_size\"><value>5120</value></field></x></configure></pubsub>
the pubsub object property of oIq still appears to be empty:
<pubsub xmlns=\"http://jabber.org/protocol/pubsub#owner\" />
So, how does one?
A. Cast the Iq passed in the callback to something more meaningful in this context?
B. Create the agsXMPP namespace objects from preparsed xml (from other objects)?
C. Force a refresh of the object model after changing doing a replacechild at the DOM level?
D. Get to the agsXMPP.protocol.x.data.Data for pubsub configuration results Iqs?
Thanks,
ThomWill
From client:<iq type="get" to="pubsub.d194137" from="publisher" id="xmppClientIQ6"><pubsub xmlns="http://jabber.org/protocol/pubsub#owner"><configure xmlns="http://jabber.org/protocol/pubsub" node="Breast Cancer" /></pubsub></iq>
From server:<iq xmlns="jabber:client" from="pubsub.d194137" to="publisher@d194137/CDCPublisher" type="result" id="xmppClientIQ6"><pubsub xmlns="http://jabber.org/protocol/pubsub#owner"><configure xmlns="http://jabber.org/protocol/pubsub" node="Breast Cancer"><x xmlns="jabber:x:data" type="form"><title>Node configuration</title><instructions>Please provide the configuration for node "Breast Cancer".</instructions><field type="hidden" var="FORM_TYPE"><value>http://jabber.org/protocol/pubsub#node_config</value></field><field type="text-single" label="Short name for the node" var="pubsub#title"><value /></field><field type="text-single" label="Description of the node" var="pubsub#description"><value /></field><field type="boolean" label="Allow subscriptions to node" var="pubsub#subscribe"><value>1</value></field><field type="boolean" label="New subscriptions require configuration" var="pubsub#subscription_required"><value>0</value></field><field type="boolean" label="Deliver payloads with event notifications" var="pubsub#deliver_payloads"><value>1</value></field><field type="boolean" label="Notify subscribers when the node configuration changes" var="pubsub#notify_config"><value>1</value></field><field type="boolean" label="Notify subscribers when the node is deleted" var="pubsub#notify_delete"><value>1</value></field><field type="boolean" label="Notify subscribers when items are removed from the node" var="pubsub#notify_retract"><value>1</value></field><field type="boolean" label="Only deliver notifications to available users" var="pubsub#presence_based_delivery"><value>0</value></field><field type="text-single" label="Type of payload data to be provided at this node" var="pubsub#type"><value /></field><field type="text-single" label="Message body XSLT" var="pubsub#body_xslt"><value /></field><field type="text-single" label="Payload XSLT" var="pubsub#dataform_xslt"><value /></field><field type="list-single" label="Specify who may subscribe and retrieve items" var="pubsub#access_model"><option><value>authorize</value></option><option><value>open</value></option><option><value>presence</value></option><option><value>roster</value></option><option><value>whitelist</value></option><value>open</value></field><field type="list-single" label="Publisher model" var="pubsub#publish_model"><option><value>publishers</value></option><option><value>subscribers</value></option><option><value>open</value></option><value>publishers</value></field><field type="list-multi" label="Roster groups allowed to subscribe" var="pubsub#roster_groups_allowed" /><field type="jid-multi" label="People to contact with questions" var="pubsub#contact" /><field type="text-single" label="Default language" var="pubsub#language"><value>English</value></field><field type="jid-multi" label="Node owners" var="pubsub#owner"><value>publisher@d194137</value></field><field type="jid-multi" label="Node publishers" var="pubsub#publisher" /><field type="list-single" label="Select entity that should receive replies to items" var="pubsub#itemreply"><value>owner</value></field><field type="jid-multi" label="Multi-user chat room to which replies should be sent" var="pubsub#replyroom" /><field type="jid-multi" label="Users to which replies should be sent" var="pubsub#replyto" /><field type="boolean" label="Send items to new subscribers" var="pubsub#send_item_subscribe"><value>1</value></field><field type="boolean" label="Persist items to storage" var="pubsub#persist_items"><value>0</value></field><field type="text-single" label="Max number of items to persist" var="pubsub#max_items"><value>-1</value></field><field type="text-single" label="Max payload size in bytes" var="pubsub#max_payload_size"><value>5120</value></field></x></configure></pubsub></iq>
I am working on a pubsub implementation to keep content syndication catalogs updated between a set of syndication partners and have run into several small issues, many of which I have been able to work around, but this one has me stumped. I am sending OpenFire a request for the configuration form of a given topical node (stream captures below). I then intend to take the agsXMPP.protocol.x.data.Data that is returned and render it using the xdatacontrol. I create the request in this way
agsXMPP.protocol.extensions.pubsub.PubSubIq getter = new agsXMPP.protocol.extensions.pubsub.PubSubIq(IqType.get);
getter.PubSub.Namespace = "http://jabber.org/protocol/pubsub#owner";
getter.PubSub.Configure = new Configure(NodeName);
I cannot use the agsXMPP.protocol.extensions.pubsub.owner.PubSubIq class (which would already have this namespace) because the agsXMPP.protocol.extensions.pubsub.owner.Configure class renders without a tagname and causes stream termination.
(edit) I have discovered that this only happens when one uses the overloaded constructor that takes a node name... here is why (tagname and namespace are not set in that constructor)
#region << Constructor >>
public Configure()
{
this.TagName = "configure";
this.Namespace = Uri.PUBSUB_OWNER;
}
public Configure(string node)
{
this.Node = node;
}
At issue is in my call back I get the IQ object it is a straight IQ, not a PubSubIQ, which means it is expecting a query element as a child and not a pubsub element as a child. There seems to be no way to cast this to a pubsubIQ to that I can get to the x.data.DATA object expected by the xdatacontrol.createform() function and no way to gen ANY object by reading / loading it from the XML. I have tried this
private void GetNodeConfigCallBack(object sender, IQ Iq, object Data)
{
agsXMPP.protocol.extensions.pubsub.owner.PubSubIq oIq = new agsXMPP.protocol.extensions.pubsub.owner.PubSubIq(IqType.result);
agsXMPP.Xml.Dom.Element pubsub = Iq.SelectSingleElement("pubsub");
oIq.ReplaceChild(pubsub);
...
And although the innerxml of the oIq object now shows:
<pubsub xmlns=\"http://jabber.org/protocol/pubsub#owner\"><configure xmlns=\"http://jabber.org/protocol/pubsub\" node=\"Breast Cancer\"><x xmlns=\"jabber:x:data\" type=\"form\"><title>Node configuration</title><instructions>Please provide the configuration for node \"Breast Cancer\".</instructions><field type=\"jid-multi\" label=\"People to contact with questions\" var=\"pubsub#contact\" /><field type=\"text-single\" label=\"Default language\" var=\"pubsub#language\"><value>English</value></field>
...
<field type=\"text-single\" label=\"Max payload size in bytes\" var=\"pubsub#max_payload_size\"><value>5120</value></field></x></configure></pubsub>
the pubsub object property of oIq still appears to be empty:
<pubsub xmlns=\"http://jabber.org/protocol/pubsub#owner\" />
So, how does one?
A. Cast the Iq passed in the callback to something more meaningful in this context?
B. Create the agsXMPP namespace objects from preparsed xml (from other objects)?
C. Force a refresh of the object model after changing doing a replacechild at the DOM level?
D. Get to the agsXMPP.protocol.x.data.Data for pubsub configuration results Iqs?
Thanks,
ThomWill
From client:<iq type="get" to="pubsub.d194137" from="publisher" id="xmppClientIQ6"><pubsub xmlns="http://jabber.org/protocol/pubsub#owner"><configure xmlns="http://jabber.org/protocol/pubsub" node="Breast Cancer" /></pubsub></iq>
From server:<iq xmlns="jabber:client" from="pubsub.d194137" to="publisher@d194137/CDCPublisher" type="result" id="xmppClientIQ6"><pubsub xmlns="http://jabber.org/protocol/pubsub#owner"><configure xmlns="http://jabber.org/protocol/pubsub" node="Breast Cancer"><x xmlns="jabber:x:data" type="form"><title>Node configuration</title><instructions>Please provide the configuration for node "Breast Cancer".</instructions><field type="hidden" var="FORM_TYPE"><value>http://jabber.org/protocol/pubsub#node_config</value></field><field type="text-single" label="Short name for the node" var="pubsub#title"><value /></field><field type="text-single" label="Description of the node" var="pubsub#description"><value /></field><field type="boolean" label="Allow subscriptions to node" var="pubsub#subscribe"><value>1</value></field><field type="boolean" label="New subscriptions require configuration" var="pubsub#subscription_required"><value>0</value></field><field type="boolean" label="Deliver payloads with event notifications" var="pubsub#deliver_payloads"><value>1</value></field><field type="boolean" label="Notify subscribers when the node configuration changes" var="pubsub#notify_config"><value>1</value></field><field type="boolean" label="Notify subscribers when the node is deleted" var="pubsub#notify_delete"><value>1</value></field><field type="boolean" label="Notify subscribers when items are removed from the node" var="pubsub#notify_retract"><value>1</value></field><field type="boolean" label="Only deliver notifications to available users" var="pubsub#presence_based_delivery"><value>0</value></field><field type="text-single" label="Type of payload data to be provided at this node" var="pubsub#type"><value /></field><field type="text-single" label="Message body XSLT" var="pubsub#body_xslt"><value /></field><field type="text-single" label="Payload XSLT" var="pubsub#dataform_xslt"><value /></field><field type="list-single" label="Specify who may subscribe and retrieve items" var="pubsub#access_model"><option><value>authorize</value></option><option><value>open</value></option><option><value>presence</value></option><option><value>roster</value></option><option><value>whitelist</value></option><value>open</value></field><field type="list-single" label="Publisher model" var="pubsub#publish_model"><option><value>publishers</value></option><option><value>subscribers</value></option><option><value>open</value></option><value>publishers</value></field><field type="list-multi" label="Roster groups allowed to subscribe" var="pubsub#roster_groups_allowed" /><field type="jid-multi" label="People to contact with questions" var="pubsub#contact" /><field type="text-single" label="Default language" var="pubsub#language"><value>English</value></field><field type="jid-multi" label="Node owners" var="pubsub#owner"><value>publisher@d194137</value></field><field type="jid-multi" label="Node publishers" var="pubsub#publisher" /><field type="list-single" label="Select entity that should receive replies to items" var="pubsub#itemreply"><value>owner</value></field><field type="jid-multi" label="Multi-user chat room to which replies should be sent" var="pubsub#replyroom" /><field type="jid-multi" label="Users to which replies should be sent" var="pubsub#replyto" /><field type="boolean" label="Send items to new subscribers" var="pubsub#send_item_subscribe"><value>1</value></field><field type="boolean" label="Persist items to storage" var="pubsub#persist_items"><value>0</value></field><field type="text-single" label="Max number of items to persist" var="pubsub#max_items"><value>-1</value></field><field type="text-single" label="Max payload size in bytes" var="pubsub#max_payload_size"><value>5120</value></field></x></configure></pubsub></iq>
This post was edited on 2010-03-25, 21:08 by ThomWill.