mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 14:02: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:
parent
5c6f257027
commit
1167523c4f
1 changed files with 33 additions and 4 deletions
|
@ -171,13 +171,13 @@ public class PacketParserUtils {
|
||||||
*/
|
*/
|
||||||
private static String parseContent(XmlPullParser parser)
|
private static String parseContent(XmlPullParser parser)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
String content = "";
|
StringBuffer content = new StringBuffer();
|
||||||
int parserDepth = parser.getDepth();
|
int parserDepth = parser.getDepth();
|
||||||
while (!(parser.next() == XmlPullParser.END_TAG && parser
|
while (!(parser.next() == XmlPullParser.END_TAG && parser
|
||||||
.getDepth() == parserDepth)) {
|
.getDepth() == parserDepth)) {
|
||||||
content += parser.getText();
|
content.append(parser.getText());
|
||||||
}
|
}
|
||||||
return content;
|
return content.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -325,6 +325,13 @@ public class PacketParserUtils {
|
||||||
(Class<?>)provider, parser);
|
(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) {
|
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
|
// qualified by a namespace it does not understand, then answer an IQ of
|
||||||
// type "error" with code 501 ("feature-not-implemented")
|
// type "error" with code 501 ("feature-not-implemented")
|
||||||
iqPacket = new IQ() {
|
iqPacket = new IQ() {
|
||||||
|
@Override
|
||||||
public String getChildElementXML() {
|
public String getChildElementXML() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -355,6 +363,7 @@ public class PacketParserUtils {
|
||||||
else {
|
else {
|
||||||
// If an IQ packet wasn't created above, create an empty IQ packet.
|
// If an IQ packet wasn't created above, create an empty IQ packet.
|
||||||
iqPacket = new IQ() {
|
iqPacket = new IQ() {
|
||||||
|
@Override
|
||||||
public String getChildElementXML() {
|
public String getChildElementXML() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -889,4 +898,24 @@ public class PacketParserUtils {
|
||||||
}
|
}
|
||||||
return null;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue