1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 20:12:07 +01:00

Fixed parsing of packet properties, renamed error class.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1843 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2003-03-07 19:47:49 +00:00 committed by mtucker
parent 867e1714ad
commit 044e9cf71c

View file

@ -58,7 +58,7 @@ import java.io.ObjectInputStream;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import org.jivesoftware.smack.packet.*; import org.jivesoftware.smack.packet.*;
import org.jivesoftware.smack.packet.Error; import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.StringUtils;
@ -327,7 +327,7 @@ class PacketReader {
String to = parser.getAttributeValue("", "to"); String to = parser.getAttributeValue("", "to");
String from = parser.getAttributeValue("", "from"); String from = parser.getAttributeValue("", "from");
IQ.Type type = IQ.Type.fromString(parser.getAttributeValue("", "type")); IQ.Type type = IQ.Type.fromString(parser.getAttributeValue("", "type"));
Error error = null; XMPPError error = null;
Map properties = null; Map properties = null;
boolean done = false; boolean done = false;
@ -437,7 +437,7 @@ class PacketReader {
return roster; return roster;
} }
private static Error parseError(XmlPullParser parser) throws Exception { private static XMPPError parseError(XmlPullParser parser) throws Exception {
String errorCode = null; String errorCode = null;
for (int i=0; i<parser.getAttributeCount(); i++) { for (int i=0; i<parser.getAttributeCount(); i++) {
if (parser.getAttributeName(i).equals("code")) { if (parser.getAttributeName(i).equals("code")) {
@ -451,7 +451,7 @@ class PacketReader {
} }
parser.next(); parser.next();
} }
return new Error(Integer.parseInt(errorCode), message); return new XMPPError(Integer.parseInt(errorCode), message);
} }
/** /**
@ -592,7 +592,9 @@ class PacketReader {
Map properties = new HashMap(); Map properties = new HashMap();
while (true) { while (true) {
int eventType = parser.next(); int eventType = parser.next();
if (eventType == parser.START_TAG) { if (eventType == parser.START_TAG && parser.getName().equals("property")) {
// Advance to name element.
parser.next();
String name = parser.nextText(); String name = parser.nextText();
parser.next(); parser.next();
String type = parser.getAttributeValue("", "type"); String type = parser.getAttributeValue("", "type");
@ -613,6 +615,9 @@ class PacketReader {
else if ("boolean".equals(type)) { else if ("boolean".equals(type)) {
value = new Boolean(valueText); value = new Boolean(valueText);
} }
else if ("string".equals(type)) {
value = valueText;
}
else if ("java-object".equals(type)) { else if ("java-object".equals(type)) {
try { try {
byte [] bytes = StringUtils.decodeBase64(valueText).getBytes("ISO-8859-1"); byte [] bytes = StringUtils.decodeBase64(valueText).getBytes("ISO-8859-1");