Commit 7219f000 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Refactoring fixes.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@658 b35dd754-fafc-0310-a699-88a17e54d16e
parent 423a0b10
...@@ -156,12 +156,7 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -156,12 +156,7 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
return delegate.handleIQ(packet); return delegate.handleIQ(packet);
} }
Session session = null; Session session = sessionManager.getSession(packet.getFrom());
try {
session = sessionManager.getSession(packet.getFrom());
}
catch (Exception e) {
}
IQ reply = null; IQ reply = null;
if (!enabled) { if (!enabled) {
reply = IQ.createResultIQ(packet); reply = IQ.createResultIQ(packet);
...@@ -169,19 +164,31 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -169,19 +164,31 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
} }
else if (IQ.Type.get.equals(packet.getType())) { else if (IQ.Type.get.equals(packet.getType())) {
reply = IQ.createResultIQ(packet); reply = IQ.createResultIQ(packet);
probeResult.setParent(null);
if (session.getStatus() == Session.STATUS_AUTHENTICATED) { if (session.getStatus() == Session.STATUS_AUTHENTICATED) {
try { try {
User user = userManager.getUser(session.getUsername()); User user = userManager.getUser(session.getUsername());
Element currentRegistration = probeResult.createCopy(); Element currentRegistration = probeResult.createCopy();
currentRegistration.element("registered").setText(null); currentRegistration.addElement("registered");
currentRegistration.element("username").setText(user.getUsername()); currentRegistration.element("username").setText(user.getUsername());
currentRegistration.element("password").setText(null); currentRegistration.element("password").setText("");
currentRegistration.element("email").setText(user.getInfo().getEmail()); currentRegistration.element("email").setText(user.getInfo().getEmail());
Element form = currentRegistration.element(QName.get("x", "jabber:x:data")); Element form = currentRegistration.element(QName.get("x", "jabber:x:data"));
form.element("username").setText(user.getUsername()); Iterator fields = form.elementIterator("field");
form.element("name").setText(user.getInfo().getName()); Element field;
form.element("email").setText(user.getInfo().getEmail()); while (fields.hasNext()) {
field = (Element) fields.next();
if ("username".equals(field.attributeValue("var"))) {
field.addElement("value").addText(user.getUsername());
}
else if ("name".equals(field.attributeValue("var"))) {
field.addElement("value").addText(user.getInfo().getName());
}
else if ("email".equals(field.attributeValue("var"))) {
field.addElement("value").addText(user.getInfo().getEmail());
}
}
reply.setChildElement(currentRegistration); reply.setChildElement(currentRegistration);
} }
catch (UserNotFoundException e) { catch (UserNotFoundException e) {
......
...@@ -66,6 +66,7 @@ public class IQVersionHandler extends IQHandler implements ServerFeaturesProvide ...@@ -66,6 +66,7 @@ public class IQVersionHandler extends IQHandler implements ServerFeaturesProvide
versionElement.setText(localServer.getServerInfo().getVersion().getVersionString()); versionElement.setText(localServer.getServerInfo().getVersion().getVersionString());
IQ result = null; IQ result = null;
result = IQ.createResultIQ(packet); result = IQ.createResultIQ(packet);
bodyElement.setParent(null);
result.setChildElement(bodyElement.createCopy()); result.setChildElement(bodyElement.createCopy());
return result; return result;
} }
......
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