1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-14 06:51:08 +01:00

Rework Smack Provider design

this is the first stop towards fixing "SMACK-65: parsing should look for
depth", by providing the initial parsing depth to the provider. Some
methods (.e.g parseMessage) now use the depth as abort condition,
instead of a unclean String equals check.

parseIQ() and parseExtension() where both renamed to parse.

This also restricts the Exceptions thrown by the parse method, to just
XmlPullParserException, IOException and SmackException (not really a big
victory, but nevertheless a slight improvement).

StreamFeatureProvider is now gone, we simply use PacketExtensionProvider
for stream features.
This commit is contained in:
Florian Schmaus 2014-10-07 21:15:20 +02:00
parent d04517cd08
commit 6980c8e63d
137 changed files with 1101 additions and 841 deletions

View file

@ -20,7 +20,9 @@ import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@ -84,7 +86,7 @@ class SimpleUserSearch extends IQ {
}
}
protected void parseItems(XmlPullParser parser) throws Exception {
protected void parseItems(XmlPullParser parser) throws XmlPullParserException, IOException {
ReportedData data = new ReportedData();
data.addColumn(new ReportedData.Column("JID", "jid", "text-single"));

View file

@ -16,6 +16,9 @@
*/
package org.jivesoftware.smackx.search;
import java.io.IOException;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
@ -28,6 +31,7 @@ import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/**
* Implements the protocol currently used to search information repositories on the Jabber network. To date, the jabber:iq:search protocol
@ -124,16 +128,11 @@ public class UserSearch extends IQ {
/**
* Internal Search service Provider.
*/
public static class Provider implements IQProvider {
public static class Provider extends IQProvider<IQ> {
/**
* Provider Constructor.
*/
public Provider() {
super();
}
public IQ parseIQ(XmlPullParser parser) throws Exception {
// FIXME this provider does return two different types of IQs
@Override
public IQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
UserSearch search = null;
SimpleUserSearch simpleUserSearch = new SimpleUserSearch();
@ -169,7 +168,9 @@ public class UserSearch extends IQ {
}
}
private static void buildDataForm(SimpleUserSearch search, String instructions, XmlPullParser parser) throws Exception {
private static void buildDataForm(SimpleUserSearch search,
String instructions, XmlPullParser parser)
throws XmlPullParserException, IOException, SmackException {
DataForm dataForm = new DataForm(Form.TYPE_FORM);
boolean done = false;
dataForm.setTitle("User Search");