1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 22:32:06 +01:00

SMACK-423 Parse unhandled IQ stanzas of type 'request' to dummy IQ class, so that the contents can be examined later on.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13538 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Florian Schmaus 2013-03-05 10:32:23 +00:00 committed by flow
parent 5c6f257027
commit 1167523c4f

View file

@ -171,13 +171,13 @@ public class PacketParserUtils {
*/
private static String parseContent(XmlPullParser parser)
throws XmlPullParserException, IOException {
String content = "";
StringBuffer content = new StringBuffer();
int parserDepth = parser.getDepth();
while (!(parser.next() == XmlPullParser.END_TAG && parser
.getDepth() == parserDepth)) {
content += parser.getText();
content.append(parser.getText());
}
return content;
return content.toString();
}
/**
@ -325,6 +325,13 @@ public class PacketParserUtils {
(Class<?>)provider, parser);
}
}
// Only handle unknown IQs of type result. Types of 'get' and 'set' which are not understood
// have to be answered with an IQ error response. See the code a few lines below
else if (IQ.Type.RESULT == type){
// No Provider found for the IQ stanza, parse it to an UnparsedIQ instance
// so that the content of the IQ can be examined later on
iqPacket = new UnparsedResultIQ(parseContent(parser));
}
}
}
else if (eventType == XmlPullParser.END_TAG) {
@ -340,6 +347,7 @@ public class PacketParserUtils {
// qualified by a namespace it does not understand, then answer an IQ of
// type "error" with code 501 ("feature-not-implemented")
iqPacket = new IQ() {
@Override
public String getChildElementXML() {
return null;
}
@ -355,6 +363,7 @@ public class PacketParserUtils {
else {
// If an IQ packet wasn't created above, create an empty IQ packet.
iqPacket = new IQ() {
@Override
public String getChildElementXML() {
return null;
}
@ -854,7 +863,7 @@ public class PacketParserUtils {
}
}
return object;
}
}
/**
* Decodes a String into an object of the specified type. If the object
@ -889,4 +898,24 @@ public class PacketParserUtils {
}
return null;
}
/**
* This class represents and unparsed IQ of the type 'result'. Usually it's created when no IQProvider
* was found for the IQ element.
*
* The child elements can be examined with the getChildElementXML() method.
*
*/
public static class UnparsedResultIQ extends IQ {
public UnparsedResultIQ(String content) {
this.str = content;
}
private final String str;
@Override
public String getChildElementXML() {
return this.str;
}
}
}