Commit 6327ffdb authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Fixed to include a childElement in the replies.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@693 b35dd754-fafc-0310-a699-88a17e54d16e
parent 6275ae0b
...@@ -93,6 +93,7 @@ public class IQDiscoInfoHandler extends IQHandler { ...@@ -93,6 +93,7 @@ public class IQDiscoInfoHandler extends IQHandler {
// Check if we have information about the requested name and node // Check if we have information about the requested name and node
if (infoProvider.hasInfo(name, node, packet.getFrom())) { if (infoProvider.hasInfo(name, node, packet.getFrom())) {
reply.setChildElement(iq.createCopy());
Element queryElement = reply.getChildElement(); Element queryElement = reply.getChildElement();
// Add to the reply all the identities provided by the DiscoInfoProvider // Add to the reply all the identities provided by the DiscoInfoProvider
......
...@@ -98,11 +98,11 @@ public class IQDiscoItemsHandler extends IQHandler implements ServerFeaturesProv ...@@ -98,11 +98,11 @@ public class IQDiscoItemsHandler extends IQHandler implements ServerFeaturesProv
// Get the requested node // Get the requested node
Element iq = packet.getChildElement(); Element iq = packet.getChildElement();
String node = iq.attributeValue("node"); String node = iq.attributeValue("node");
//String node = metaData.getProperty("query:node");
// Check if we have items associated with the requested name and node // Check if we have items associated with the requested name and node
Iterator<Element> itemsItr = itemsProvider.getItems(name, node, packet.getFrom()); Iterator<Element> itemsItr = itemsProvider.getItems(name, node, packet.getFrom());
if (itemsItr != null) { if (itemsItr != null) {
reply.setChildElement(iq.createCopy());
Element queryElement = reply.getChildElement(); Element queryElement = reply.getChildElement();
// Add to the reply all the items provided by the DiscoItemsProvider // Add to the reply all the items provided by the DiscoItemsProvider
......
...@@ -67,10 +67,8 @@ public class IQMUCRegisterHandler extends IQHandler { ...@@ -67,10 +67,8 @@ public class IQMUCRegisterHandler extends IQHandler {
public void initialize() { public void initialize() {
if (probeResult == null) { if (probeResult == null) {
// Create the basic element of the probeResult which contains the basic registration // Create the registration form of the room which contains information
// information for the room (e.g. first name, last name, nickname, etc.) // such as: first name, last name and nickname.
Element element = DocumentHelper.createElement(QName.get("query", "jabber:iq:register"));
XDataFormImpl registrationForm = new XDataFormImpl(DataForm.TYPE_FORM); XDataFormImpl registrationForm = new XDataFormImpl(DataForm.TYPE_FORM);
registrationForm.setTitle(LocaleUtils.getLocalizedString("muc.form.reg.title")); registrationForm.setTitle(LocaleUtils.getLocalizedString("muc.form.reg.title"));
registrationForm.addInstruction(LocaleUtils registrationForm.addInstruction(LocaleUtils
...@@ -114,8 +112,8 @@ public class IQMUCRegisterHandler extends IQHandler { ...@@ -114,8 +112,8 @@ public class IQMUCRegisterHandler extends IQHandler {
field.setLabel(LocaleUtils.getLocalizedString("muc.form.reg.faqentry")); field.setLabel(LocaleUtils.getLocalizedString("muc.form.reg.faqentry"));
registrationForm.addField(field); registrationForm.addField(field);
// Create the probeResult and add the basic info together with the registration form // Create the probeResult and add the registration form
probeResult = element; probeResult = DocumentHelper.createElement(QName.get("query", "jabber:iq:register"));
probeResult.add(registrationForm.asXMLElement()); probeResult.add(registrationForm.asXMLElement());
} }
} }
...@@ -139,14 +137,20 @@ public class IQMUCRegisterHandler extends IQHandler { ...@@ -139,14 +137,20 @@ public class IQMUCRegisterHandler extends IQHandler {
if (nickname != null) { if (nickname != null) {
// The user is already registered with the room so answer a completed form // The user is already registered with the room so answer a completed form
ElementUtil.setProperty(currentRegistration, "query.registered", null); ElementUtil.setProperty(currentRegistration, "query.registered", null);
XDataFormImpl form = new XDataFormImpl(); Element form = currentRegistration.element(QName.get("x", "jabber:x:data"));
form.parse(currentRegistration); Iterator fields = form.elementIterator("field");
form.getField("muc#register_roomnick").addValue(nickname); Element field;
reply.getElement().add(currentRegistration); while (fields.hasNext()) {
field = (Element) fields.next();
if ("muc#register_roomnick".equals(field.attributeValue("var"))) {
field.addElement("value").addText(nickname);
}
}
reply.setChildElement(currentRegistration);
} }
else { else {
// The user is not registered with the room so answer an empty form // The user is not registered with the room so answer an empty form
reply.getElement().add(currentRegistration); reply.setChildElement(currentRegistration);
} }
} }
else if (IQ.Type.set == packet.getType()) { else if (IQ.Type.set == packet.getType()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment