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
return delegate.handleIQ(packet);
}
Session session = null;
try {
session = sessionManager.getSession(packet.getFrom());
}
catch (Exception e) {
}
Session session = sessionManager.getSession(packet.getFrom());
IQ reply = null;
if (!enabled) {
reply = IQ.createResultIQ(packet);
......@@ -169,19 +164,31 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
}
else if (IQ.Type.get.equals(packet.getType())) {
reply = IQ.createResultIQ(packet);
probeResult.setParent(null);
if (session.getStatus() == Session.STATUS_AUTHENTICATED) {
try {
User user = userManager.getUser(session.getUsername());
Element currentRegistration = probeResult.createCopy();
currentRegistration.element("registered").setText(null);
currentRegistration.addElement("registered");
currentRegistration.element("username").setText(user.getUsername());
currentRegistration.element("password").setText(null);
currentRegistration.element("password").setText("");
currentRegistration.element("email").setText(user.getInfo().getEmail());
Element form = currentRegistration.element(QName.get("x", "jabber:x:data"));
form.element("username").setText(user.getUsername());
form.element("name").setText(user.getInfo().getName());
form.element("email").setText(user.getInfo().getEmail());
Iterator fields = form.elementIterator("field");
Element field;
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);
}
catch (UserNotFoundException e) {
......
......@@ -66,6 +66,7 @@ public class IQVersionHandler extends IQHandler implements ServerFeaturesProvide
versionElement.setText(localServer.getServerInfo().getVersion().getVersionString());
IQ result = null;
result = IQ.createResultIQ(packet);
bodyElement.setParent(null);
result.setChildElement(bodyElement.createCopy());
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