1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-10 17:49:38 +02:00

SMACK-452 Correctly parse stream error packets

Modified PacketParserUtils.parseStreamError() to take into account that
there may be an optional text element and an optional application
specific element.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_3_2@13767 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Florian Schmaus 2013-10-09 17:02:34 +00:00 committed by flow
parent b253203cfb
commit bd709dc323
3 changed files with 126 additions and 7 deletions

View file

@ -695,21 +695,33 @@ public class PacketParserUtils {
*/
public static StreamError parseStreamError(XmlPullParser parser) throws IOException,
XmlPullParserException {
StreamError streamError = null;
final int depth = parser.getDepth();
boolean done = false;
String code = null;
String text = null;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
streamError = new StreamError(parser.getName());
}
else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("error")) {
done = true;
String namespace = parser.getNamespace();
if (StreamError.NAMESPACE.equals(namespace)) {
String name = parser.getName();
if (name.equals("text") && !parser.isEmptyElementTag()) {
parser.next();
text = parser.getText();
}
else {
// If it's not a text element, that is qualified by the StreamError.NAMESPACE,
// then it has to be the stream error code
code = name;
}
}
}
else if (eventType == XmlPullParser.END_TAG && depth == parser.getDepth()) {
done = true;
}
}
return streamError;
return new StreamError(code, text);
}
/**