mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 17:19:39 +02: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:
parent
d04517cd08
commit
6980c8e63d
137 changed files with 1101 additions and 841 deletions
|
@ -17,11 +17,14 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.agent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
||||
public class OfferConfirmation extends IQ {
|
||||
|
@ -57,9 +60,11 @@ public class OfferConfirmation extends IQ {
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
public static class Provider implements IQProvider {
|
||||
public static class Provider extends IQProvider<OfferConfirmation> {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public OfferConfirmation parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
final OfferConfirmation confirmation = new OfferConfirmation();
|
||||
|
||||
boolean done = false;
|
||||
|
|
|
@ -17,10 +17,14 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.ext.forms;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class WorkgroupForm extends IQ {
|
||||
|
||||
|
@ -50,13 +54,12 @@ public class WorkgroupForm extends IQ {
|
|||
*
|
||||
* @author Derek DeMoro
|
||||
*/
|
||||
public static class InternalProvider implements IQProvider {
|
||||
public static class InternalProvider extends IQProvider<WorkgroupForm> {
|
||||
|
||||
public InternalProvider() {
|
||||
super();
|
||||
}
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public WorkgroupForm parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException,
|
||||
SmackException {
|
||||
WorkgroupForm answer = new WorkgroupForm();
|
||||
|
||||
boolean done = false;
|
||||
|
|
|
@ -20,7 +20,9 @@ package org.jivesoftware.smackx.workgroup.ext.history;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
@ -88,9 +90,10 @@ public class AgentChatHistory extends IQ {
|
|||
/**
|
||||
* Packet extension provider for AgentHistory packets.
|
||||
*/
|
||||
public static class InternalProvider implements IQProvider {
|
||||
public static class InternalProvider extends IQProvider<AgentChatHistory> {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public AgentChatHistory parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||
throw new IllegalStateException("Parser not in proper position, or bad XML.");
|
||||
}
|
||||
|
@ -111,7 +114,7 @@ public class AgentChatHistory extends IQ {
|
|||
return agentChatHistory;
|
||||
}
|
||||
|
||||
private AgentChatSession parseChatSetting(XmlPullParser parser) throws Exception {
|
||||
private AgentChatSession parseChatSetting(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
|
||||
boolean done = false;
|
||||
Date date = null;
|
||||
|
|
|
@ -21,7 +21,9 @@ import org.jivesoftware.smackx.workgroup.util.MetaDataUtils;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -76,13 +78,11 @@ public class ChatMetadata extends IQ {
|
|||
*
|
||||
* @author Derek DeMoro
|
||||
*/
|
||||
public static class Provider implements IQProvider {
|
||||
public static class Provider extends IQProvider<ChatMetadata> {
|
||||
|
||||
public Provider() {
|
||||
super();
|
||||
}
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public ChatMetadata parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
final ChatMetadata chatM = new ChatMetadata();
|
||||
|
||||
boolean done = false;
|
||||
|
|
|
@ -17,11 +17,13 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.ext.macros;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
|
@ -92,13 +94,10 @@ public class Macros extends IQ {
|
|||
*
|
||||
* @author Derek DeMoro
|
||||
*/
|
||||
public static class InternalProvider implements IQProvider {
|
||||
public static class InternalProvider extends IQProvider<Macros> {
|
||||
|
||||
public InternalProvider() {
|
||||
super();
|
||||
}
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public Macros parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
Macros macroGroup = new Macros();
|
||||
|
||||
boolean done = false;
|
||||
|
@ -121,7 +120,7 @@ public class Macros extends IQ {
|
|||
return macroGroup;
|
||||
}
|
||||
|
||||
public Macro parseMacro(XmlPullParser parser) throws Exception {
|
||||
public Macro parseMacro(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
Macro macro = new Macro();
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
|
@ -150,7 +149,7 @@ public class Macros extends IQ {
|
|||
return macro;
|
||||
}
|
||||
|
||||
public MacroGroup parseMacroGroup(XmlPullParser parser) throws Exception {
|
||||
public MacroGroup parseMacroGroup(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
MacroGroup group = new MacroGroup();
|
||||
|
||||
boolean done = false;
|
||||
|
@ -176,7 +175,7 @@ public class Macros extends IQ {
|
|||
return group;
|
||||
}
|
||||
|
||||
public MacroGroup parseMacroGroups(String macros) throws Exception {
|
||||
public MacroGroup parseMacroGroups(String macros) throws XmlPullParserException, IOException {
|
||||
|
||||
MacroGroup group = null;
|
||||
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
|
||||
|
|
|
@ -17,10 +17,13 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.ext.notes;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* IQ packet for retrieving and adding Chat Notes.
|
||||
|
@ -76,13 +79,10 @@ public class ChatNotes extends IQ {
|
|||
*
|
||||
* @author Derek DeMoro
|
||||
*/
|
||||
public static class Provider implements IQProvider {
|
||||
public static class Provider extends IQProvider<ChatNotes> {
|
||||
|
||||
public Provider() {
|
||||
super();
|
||||
}
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public ChatNotes parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
ChatNotes chatNotes = new ChatNotes();
|
||||
|
||||
boolean done = false;
|
||||
|
|
|
@ -17,9 +17,12 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* IQ packet for retrieving and changing the Agent personal information.
|
||||
|
@ -97,13 +100,10 @@ public class AgentInfo extends IQ {
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public static class Provider implements IQProvider {
|
||||
public static class Provider extends IQProvider<AgentInfo> {
|
||||
|
||||
public Provider() {
|
||||
super();
|
||||
}
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public AgentInfo parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
AgentInfo answer = new AgentInfo();
|
||||
|
||||
boolean done = false;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
|
@ -28,6 +29,7 @@ import java.util.TimeZone;
|
|||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Agent status packet.
|
||||
|
@ -221,9 +223,10 @@ public class AgentStatus implements PacketExtension {
|
|||
/**
|
||||
* Packet extension provider for AgentStatus packets.
|
||||
*/
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
public static class Provider extends PacketExtensionProvider<AgentStatus> {
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public AgentStatus parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
AgentStatus agentStatus = new AgentStatus();
|
||||
|
||||
agentStatus.workgroupJID = parser.getAttributeValue("", "jid");
|
||||
|
|
|
@ -20,7 +20,9 @@ package org.jivesoftware.smackx.workgroup.packet;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -114,15 +116,12 @@ public class AgentStatusRequest extends IQ {
|
|||
/**
|
||||
* Packet extension provider for AgentStatusRequest packets.
|
||||
*/
|
||||
public static class Provider implements IQProvider {
|
||||
public static class Provider extends IQProvider<AgentStatusRequest> {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public AgentStatusRequest parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
AgentStatusRequest statusRequest = new AgentStatusRequest();
|
||||
|
||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||
throw new IllegalStateException("Parser not in proper position, or bad XML.");
|
||||
}
|
||||
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
|
@ -138,7 +137,7 @@ public class AgentStatusRequest extends IQ {
|
|||
return statusRequest;
|
||||
}
|
||||
|
||||
private Item parseAgent(XmlPullParser parser) throws Exception {
|
||||
private Item parseAgent(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
|
||||
boolean done = false;
|
||||
String jid = parser.getAttributeValue("", "jid");
|
||||
|
|
|
@ -20,7 +20,9 @@ package org.jivesoftware.smackx.workgroup.packet;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
@ -96,13 +98,10 @@ public class AgentWorkgroups extends IQ {
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public static class Provider implements IQProvider {
|
||||
public static class Provider extends IQProvider<AgentWorkgroups> {
|
||||
|
||||
public Provider() {
|
||||
super();
|
||||
}
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public AgentWorkgroups parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
String agentJID = parser.getAttributeValue("", "jid");
|
||||
List<String> workgroups = new ArrayList<String>();
|
||||
|
||||
|
|
|
@ -17,29 +17,29 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.MetaData;
|
||||
import org.jivesoftware.smackx.workgroup.util.MetaDataUtils;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* This provider parses meta data if it's not contained already in a larger extension provider.
|
||||
*
|
||||
* @author loki der quaeler
|
||||
*/
|
||||
public class MetaDataProvider implements PacketExtensionProvider {
|
||||
public class MetaDataProvider extends PacketExtensionProvider<MetaData> {
|
||||
|
||||
/**
|
||||
* PacketExtensionProvider implementation
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
*/
|
||||
public PacketExtension parseExtension (XmlPullParser parser)
|
||||
throws Exception {
|
||||
public MetaData parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
Map<String, List<String>> metaData = MetaDataUtils.parseMetaData(parser);
|
||||
|
||||
return new MetaData(metaData);
|
||||
|
|
|
@ -16,9 +16,12 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class MonitorPacket extends IQ {
|
||||
|
||||
|
@ -79,13 +82,10 @@ public class MonitorPacket extends IQ {
|
|||
/**
|
||||
* Packet extension provider for Monitor Packets.
|
||||
*/
|
||||
public static class InternalProvider implements IQProvider {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||
throw new IllegalStateException("Parser not in proper position, or bad XML.");
|
||||
}
|
||||
public static class InternalProvider extends IQProvider<MonitorPacket> {
|
||||
|
||||
@Override
|
||||
public MonitorPacket parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
MonitorPacket packet = new MonitorPacket();
|
||||
|
||||
boolean done = false;
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
@ -24,9 +26,11 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Packet used for requesting information about occupants of a room or for retrieving information
|
||||
|
@ -126,12 +130,10 @@ public class OccupantsInfo extends IQ {
|
|||
/**
|
||||
* Packet extension provider for AgentStatusRequest packets.
|
||||
*/
|
||||
public static class Provider implements IQProvider {
|
||||
public static class Provider extends IQProvider<OccupantsInfo> {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||
throw new IllegalStateException("Parser not in proper position, or bad XML.");
|
||||
}
|
||||
@Override
|
||||
public OccupantsInfo parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
OccupantsInfo occupantsInfo = new OccupantsInfo(parser.getAttributeValue("", "roomID"));
|
||||
|
||||
boolean done = false;
|
||||
|
@ -148,7 +150,7 @@ public class OccupantsInfo extends IQ {
|
|||
return occupantsInfo;
|
||||
}
|
||||
|
||||
private OccupantInfo parseOccupantInfo(XmlPullParser parser) throws Exception {
|
||||
private OccupantInfo parseOccupantInfo(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
|
||||
boolean done = false;
|
||||
String jid = null;
|
||||
|
@ -163,7 +165,11 @@ public class OccupantsInfo extends IQ {
|
|||
nickname = parser.nextText();
|
||||
} else if ((eventType == XmlPullParser.START_TAG) &&
|
||||
("joined".equals(parser.getName()))) {
|
||||
joined = UTC_FORMAT.parse(parser.nextText());
|
||||
try {
|
||||
joined = UTC_FORMAT.parse(parser.nextText());
|
||||
} catch (ParseException e) {
|
||||
new SmackException(e);
|
||||
}
|
||||
} else if (eventType == XmlPullParser.END_TAG &&
|
||||
"occupant".equals(parser.getName())) {
|
||||
done = true;
|
||||
|
|
|
@ -23,11 +23,14 @@ import org.jivesoftware.smackx.workgroup.agent.OfferContent;
|
|||
import org.jivesoftware.smackx.workgroup.agent.TransferRequest;
|
||||
import org.jivesoftware.smackx.workgroup.agent.UserRequest;
|
||||
import org.jivesoftware.smackx.workgroup.util.MetaDataUtils;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -37,12 +40,14 @@ import java.util.Map;
|
|||
*
|
||||
* @author loki der quaeler
|
||||
*/
|
||||
public class OfferRequestProvider implements IQProvider {
|
||||
public class OfferRequestProvider extends IQProvider<IQ> {
|
||||
// FIXME It seems because OfferRequestPacket is also defined here, we can
|
||||
// not add it as generic to the provider, the provider and the packet should
|
||||
// be split, but since this is legacy code, I don't think that this will
|
||||
// happen anytime soon.
|
||||
|
||||
public OfferRequestProvider() {
|
||||
}
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public OfferRequestPacket parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
|
||||
int eventType = parser.getEventType();
|
||||
String sessionID = null;
|
||||
int timeout = -1;
|
||||
|
|
|
@ -17,18 +17,22 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* An IQProvider class which has savvy about the offer-revoke tag.<br>
|
||||
*
|
||||
* @author loki der quaeler
|
||||
*/
|
||||
public class OfferRevokeProvider implements IQProvider {
|
||||
public class OfferRevokeProvider extends IQProvider<IQ> {
|
||||
|
||||
public IQ parseIQ (XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public OfferRevokePacket parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
// The parser will be positioned on the opening IQ tag, so get the JID attribute.
|
||||
String userJID = parser.getAttributeValue("", "jid");
|
||||
// Default the userID to the JID.
|
||||
|
|
|
@ -18,10 +18,14 @@
|
|||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.QueueUser;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
|
@ -139,9 +143,12 @@ public class QueueDetails implements PacketExtension {
|
|||
/**
|
||||
* Provider class for QueueDetails packet extensions.
|
||||
*/
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
public static class Provider extends PacketExtensionProvider<QueueDetails> {
|
||||
|
||||
@Override
|
||||
public QueueDetails parse(XmlPullParser parser,
|
||||
int initialDepth) throws XmlPullParserException,
|
||||
IOException, SmackException {
|
||||
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
|
||||
QueueDetails queueDetails = new QueueDetails();
|
||||
|
@ -174,10 +181,19 @@ public class QueueDetails implements PacketExtension {
|
|||
time = Integer.parseInt(parser.nextText());
|
||||
}
|
||||
else if ("join-time".equals(parser.getName())) {
|
||||
joinTime = dateFormat.parse(parser.nextText());
|
||||
try {
|
||||
joinTime = dateFormat.parse(parser.nextText());
|
||||
} catch (ParseException e) {
|
||||
throw new SmackException(e);
|
||||
}
|
||||
}
|
||||
else if( parser.getName().equals( "waitTime" ) ) {
|
||||
Date wait = dateFormat.parse(parser.nextText());
|
||||
Date wait;
|
||||
try {
|
||||
wait = dateFormat.parse(parser.nextText());
|
||||
} catch (ParseException e) {
|
||||
throw new SmackException(e);
|
||||
}
|
||||
LOGGER.fine(wait.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -18,10 +18,14 @@
|
|||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.agent.WorkgroupQueue;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
|
@ -113,17 +117,16 @@ public class QueueOverview implements PacketExtension {
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
public static class Provider extends PacketExtensionProvider<QueueOverview> {
|
||||
|
||||
public PacketExtension parseExtension (XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public QueueOverview parse(XmlPullParser parser,
|
||||
int initialDepth) throws XmlPullParserException,
|
||||
IOException, SmackException {
|
||||
int eventType = parser.getEventType();
|
||||
QueueOverview queueOverview = new QueueOverview();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
|
||||
|
||||
if (eventType != XmlPullParser.START_TAG) {
|
||||
// throw exception
|
||||
}
|
||||
|
||||
eventType = parser.next();
|
||||
while ((eventType != XmlPullParser.END_TAG)
|
||||
|| (!ELEMENT_NAME.equals(parser.getName())))
|
||||
|
@ -135,7 +138,11 @@ public class QueueOverview implements PacketExtension {
|
|||
queueOverview.setAverageWaitTime(Integer.parseInt(parser.nextText()));
|
||||
}
|
||||
else if ("oldest".equals(parser.getName())) {
|
||||
queueOverview.setOldestEntry((dateFormat.parse(parser.nextText())));
|
||||
try {
|
||||
queueOverview.setOldestEntry((dateFormat.parse(parser.nextText())));
|
||||
} catch (ParseException e) {
|
||||
throw new SmackException(e);
|
||||
}
|
||||
}
|
||||
else if ("status".equals(parser.getName())) {
|
||||
queueOverview.setStatus(WorkgroupQueue.Status.fromString(parser.nextText()));
|
||||
|
|
|
@ -17,9 +17,12 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* An IQ packet that encapsulates both types of workgroup queue
|
||||
|
@ -87,9 +90,11 @@ public class QueueUpdate implements PacketExtension {
|
|||
return NAMESPACE;
|
||||
}
|
||||
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
public static class Provider extends PacketExtensionProvider<QueueUpdate> {
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public QueueUpdate parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
boolean done = false;
|
||||
int position = -1;
|
||||
int timeRemaining = -1;
|
||||
|
|
|
@ -17,9 +17,12 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Packet extension for {@link org.jivesoftware.smackx.workgroup.agent.InvitationRequest}.
|
||||
|
@ -138,9 +141,12 @@ public class RoomInvitation implements PacketExtension {
|
|||
workgroup
|
||||
}
|
||||
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
public static class Provider extends PacketExtensionProvider<RoomInvitation> {
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public RoomInvitation parse(XmlPullParser parser,
|
||||
int initialDepth) throws XmlPullParserException,
|
||||
IOException {
|
||||
final RoomInvitation invitation = new RoomInvitation();
|
||||
invitation.type = Type.valueOf(parser.getAttributeValue("", "type"));
|
||||
|
||||
|
|
|
@ -17,9 +17,12 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Packet extension for {@link org.jivesoftware.smackx.workgroup.agent.TransferRequest}.
|
||||
|
@ -138,9 +141,12 @@ public class RoomTransfer implements PacketExtension {
|
|||
workgroup
|
||||
}
|
||||
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
public static class Provider extends PacketExtensionProvider<RoomTransfer> {
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public RoomTransfer parse(XmlPullParser parser,
|
||||
int initialDepth) throws XmlPullParserException,
|
||||
IOException {
|
||||
final RoomTransfer invitation = new RoomTransfer();
|
||||
invitation.type = RoomTransfer.Type.valueOf(parser.getAttributeValue("", "type"));
|
||||
|
||||
|
|
|
@ -17,9 +17,12 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class SessionID implements PacketExtension {
|
||||
|
||||
|
@ -61,9 +64,11 @@ public class SessionID implements PacketExtension {
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
public static class Provider extends PacketExtensionProvider<SessionID> {
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public SessionID parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
String sessionID = parser.getAttributeValue("", "id");
|
||||
|
||||
// Advance to end of extension.
|
||||
|
|
|
@ -17,12 +17,14 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -31,13 +33,10 @@ import java.util.List;
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class TranscriptProvider implements IQProvider {
|
||||
public class TranscriptProvider extends IQProvider<Transcript> {
|
||||
|
||||
public TranscriptProvider() {
|
||||
super();
|
||||
}
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public Transcript parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
|
||||
String sessionID = parser.getAttributeValue("", "sessionID");
|
||||
List<Packet> packets = new ArrayList<Packet>();
|
||||
|
||||
|
|
|
@ -17,10 +17,14 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* IQ packet for retrieving the transcript search form, submiting the completed search form
|
||||
|
@ -56,13 +60,10 @@ public class TranscriptSearch extends IQ {
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public static class Provider implements IQProvider {
|
||||
public static class Provider extends IQProvider<TranscriptSearch> {
|
||||
|
||||
public Provider() {
|
||||
super();
|
||||
}
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public TranscriptSearch parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
|
||||
TranscriptSearch answer = new TranscriptSearch();
|
||||
|
||||
boolean done = false;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
@ -35,18 +34,15 @@ import java.util.TimeZone;
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class TranscriptsProvider implements IQProvider {
|
||||
public class TranscriptsProvider extends IQProvider<Transcripts> {
|
||||
|
||||
private static final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
|
||||
static {
|
||||
UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||
}
|
||||
|
||||
public TranscriptsProvider() {
|
||||
super();
|
||||
}
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public Transcripts parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
String userID = parser.getAttributeValue("", "userID");
|
||||
List<Transcripts.TranscriptSummary> summaries = new ArrayList<Transcripts.TranscriptSummary>();
|
||||
|
||||
|
|
|
@ -17,9 +17,12 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class UserID implements PacketExtension {
|
||||
|
||||
|
@ -61,9 +64,11 @@ public class UserID implements PacketExtension {
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
public static class Provider extends PacketExtensionProvider<UserID> {
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public UserID parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
String userID = parser.getAttributeValue("", "id");
|
||||
|
||||
// Advance to end of extension.
|
||||
|
|
|
@ -17,9 +17,12 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* A packet extension that contains information about the user and agent in a
|
||||
|
@ -65,13 +68,17 @@ public class WorkgroupInformation implements PacketExtension {
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
public static class Provider extends PacketExtensionProvider<WorkgroupInformation> {
|
||||
|
||||
/**
|
||||
* PacketExtensionProvider implementation
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
*/
|
||||
public PacketExtension parseExtension (XmlPullParser parser)
|
||||
throws Exception {
|
||||
@Override
|
||||
public WorkgroupInformation parse(XmlPullParser parser,
|
||||
int initialDepth) throws XmlPullParserException,
|
||||
IOException {
|
||||
String workgroupJID = parser.getAttributeValue("", "jid");
|
||||
|
||||
// since this is a start and end tag, and we arrive on the start, this should guarantee
|
||||
|
|
|
@ -20,7 +20,9 @@ package org.jivesoftware.smackx.workgroup.settings;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
@ -125,9 +127,10 @@ public class ChatSettings extends IQ {
|
|||
/**
|
||||
* Packet extension provider for AgentStatusRequest packets.
|
||||
*/
|
||||
public static class InternalProvider implements IQProvider {
|
||||
public static class InternalProvider extends IQProvider<ChatSettings> {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public ChatSettings parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||
throw new IllegalStateException("Parser not in proper position, or bad XML.");
|
||||
}
|
||||
|
@ -148,7 +151,7 @@ public class ChatSettings extends IQ {
|
|||
return chatSettings;
|
||||
}
|
||||
|
||||
private ChatSetting parseChatSetting(XmlPullParser parser) throws Exception {
|
||||
private ChatSetting parseChatSetting(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
|
||||
boolean done = false;
|
||||
String key = null;
|
||||
|
|
|
@ -21,7 +21,9 @@ import org.jivesoftware.smackx.workgroup.util.ModelUtil;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -77,13 +79,10 @@ public class GenericSettings extends IQ {
|
|||
/**
|
||||
* Packet extension provider for SoundSetting Packets.
|
||||
*/
|
||||
public static class InternalProvider implements IQProvider {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||
throw new IllegalStateException("Parser not in proper position, or bad XML.");
|
||||
}
|
||||
public static class InternalProvider extends IQProvider<GenericSettings> {
|
||||
|
||||
@Override
|
||||
public GenericSettings parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
GenericSettings setting = new GenericSettings();
|
||||
|
||||
boolean done = false;
|
||||
|
|
|
@ -17,10 +17,13 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.settings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.util.ModelUtil;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class OfflineSettings extends IQ {
|
||||
private String redirectURL;
|
||||
|
@ -108,13 +111,10 @@ public class OfflineSettings extends IQ {
|
|||
/**
|
||||
* Packet extension provider for AgentStatusRequest packets.
|
||||
*/
|
||||
public static class InternalProvider implements IQProvider {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||
throw new IllegalStateException("Parser not in proper position, or bad XML.");
|
||||
}
|
||||
public static class InternalProvider extends IQProvider<OfflineSettings> {
|
||||
|
||||
@Override
|
||||
public OfflineSettings parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
OfflineSettings offlineSettings = new OfflineSettings();
|
||||
|
||||
boolean done = false;
|
||||
|
|
|
@ -16,10 +16,13 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.workgroup.settings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.util.ModelUtil;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class SearchSettings extends IQ {
|
||||
private String forumsLocation;
|
||||
|
@ -79,13 +82,10 @@ public class SearchSettings extends IQ {
|
|||
/**
|
||||
* Packet extension provider for AgentStatusRequest packets.
|
||||
*/
|
||||
public static class InternalProvider implements IQProvider {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||
throw new IllegalStateException("Parser not in proper position, or bad XML.");
|
||||
}
|
||||
public static class InternalProvider extends IQProvider<SearchSettings> {
|
||||
|
||||
@Override
|
||||
public SearchSettings parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
SearchSettings settings = new SearchSettings();
|
||||
|
||||
boolean done = false;
|
||||
|
|
|
@ -17,10 +17,13 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.settings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class SoundSettings extends IQ {
|
||||
private String outgoingSound;
|
||||
|
@ -69,13 +72,10 @@ public class SoundSettings extends IQ {
|
|||
/**
|
||||
* Packet extension provider for SoundSetting Packets.
|
||||
*/
|
||||
public static class InternalProvider implements IQProvider {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||
throw new IllegalStateException("Parser not in proper position, or bad XML.");
|
||||
}
|
||||
public static class InternalProvider extends IQProvider<SoundSettings> {
|
||||
|
||||
@Override
|
||||
public SoundSettings parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
SoundSettings soundSettings = new SoundSettings();
|
||||
|
||||
boolean done = false;
|
||||
|
|
|
@ -17,10 +17,13 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.settings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.util.ModelUtil;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class WorkgroupProperties extends IQ {
|
||||
|
||||
|
@ -89,13 +92,10 @@ public class WorkgroupProperties extends IQ {
|
|||
/**
|
||||
* Packet extension provider for SoundSetting Packets.
|
||||
*/
|
||||
public static class InternalProvider implements IQProvider {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||
throw new IllegalStateException("Parser not in proper position, or bad XML.");
|
||||
}
|
||||
public static class InternalProvider extends IQProvider<WorkgroupProperties> {
|
||||
|
||||
@Override
|
||||
public WorkgroupProperties parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
WorkgroupProperties props = new WorkgroupProperties();
|
||||
|
||||
boolean done = false;
|
||||
|
|
|
@ -17,10 +17,12 @@
|
|||
|
||||
package org.jivesoftware.smackx.xevent.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smackx.xevent.packet.MessageEvent;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -28,24 +30,19 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MessageEventProvider implements PacketExtensionProvider {
|
||||
|
||||
/**
|
||||
* Creates a new MessageEventProvider.
|
||||
* ProviderManager requires that every PacketExtensionProvider has a public, no-argument constructor
|
||||
*/
|
||||
public MessageEventProvider() {
|
||||
}
|
||||
public class MessageEventProvider extends PacketExtensionProvider<MessageEvent> {
|
||||
|
||||
/**
|
||||
* Parses a MessageEvent packet (extension sub-packet).
|
||||
*
|
||||
* @param parser the XML parser, positioned at the starting element of the extension.
|
||||
* @return a PacketExtension.
|
||||
* @throws Exception if a parsing error occurs.
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
*/
|
||||
public PacketExtension parseExtension(XmlPullParser parser)
|
||||
throws Exception {
|
||||
@Override
|
||||
public MessageEvent parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
MessageEvent messageEvent = new MessageEvent();
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
|
|
|
@ -17,13 +17,14 @@
|
|||
|
||||
package org.jivesoftware.smackx.xroster.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smackx.xroster.RemoteRosterEntry;
|
||||
import org.jivesoftware.smackx.xroster.packet.RosterExchange;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -31,23 +32,19 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class RosterExchangeProvider implements PacketExtensionProvider {
|
||||
|
||||
/**
|
||||
* Creates a new RosterExchangeProvider.
|
||||
* ProviderManager requires that every PacketExtensionProvider has a public, no-argument constructor
|
||||
*/
|
||||
public RosterExchangeProvider() {
|
||||
}
|
||||
public class RosterExchangeProvider extends PacketExtensionProvider<RosterExchange> {
|
||||
|
||||
/**
|
||||
* Parses a RosterExchange packet (extension sub-packet).
|
||||
*
|
||||
* @param parser the XML parser, positioned at the starting element of the extension.
|
||||
* @return a PacketExtension.
|
||||
* @throws Exception if a parsing error occurs.
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
*/
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
@Override
|
||||
public RosterExchange parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
|
||||
RosterExchange rosterExchange = new RosterExchange();
|
||||
boolean done = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue