mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 21:42:07 +01:00
Add StreamFeatureProvider
so that AccountManager and the CapsExtension can be moved to smack-extensions, where they belong.
This commit is contained in:
parent
fc51f3df48
commit
46a4402a69
22 changed files with 396 additions and 151 deletions
|
@ -49,17 +49,17 @@ import org.jivesoftware.smack.filter.IQReplyFilter;
|
||||||
import org.jivesoftware.smack.filter.PacketFilter;
|
import org.jivesoftware.smack.filter.PacketFilter;
|
||||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||||
import org.jivesoftware.smack.packet.Bind;
|
import org.jivesoftware.smack.packet.Bind;
|
||||||
import org.jivesoftware.smack.packet.CapsExtension;
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.Mechanisms;
|
import org.jivesoftware.smack.packet.Mechanisms;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.jivesoftware.smack.packet.PacketExtension;
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
import org.jivesoftware.smack.packet.Presence;
|
import org.jivesoftware.smack.packet.Presence;
|
||||||
import org.jivesoftware.smack.packet.Registration;
|
|
||||||
import org.jivesoftware.smack.packet.RosterVer;
|
import org.jivesoftware.smack.packet.RosterVer;
|
||||||
import org.jivesoftware.smack.packet.Session;
|
import org.jivesoftware.smack.packet.Session;
|
||||||
import org.jivesoftware.smack.packet.StartTls;
|
import org.jivesoftware.smack.packet.StartTls;
|
||||||
import org.jivesoftware.smack.packet.PlainStreamElement;
|
import org.jivesoftware.smack.packet.PlainStreamElement;
|
||||||
|
import org.jivesoftware.smack.provider.ProviderManager;
|
||||||
|
import org.jivesoftware.smack.provider.StreamFeatureProvider;
|
||||||
import org.jivesoftware.smack.rosterstore.RosterStore;
|
import org.jivesoftware.smack.rosterstore.RosterStore;
|
||||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
import org.jxmpp.util.XmppStringUtils;
|
import org.jxmpp.util.XmppStringUtils;
|
||||||
|
@ -1015,42 +1015,32 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void parseFeatures(XmlPullParser parser) throws XmlPullParserException,
|
protected final void parseFeatures(XmlPullParser parser) throws XmlPullParserException,
|
||||||
IOException, SecurityRequiredException, NotConnectedException {
|
IOException, SmackException {
|
||||||
streamFeatures.clear();
|
streamFeatures.clear();
|
||||||
final int initialDepth = parser.getDepth();
|
final int initialDepth = parser.getDepth();
|
||||||
while (true) {
|
while (true) {
|
||||||
int eventType = parser.next();
|
int eventType = parser.next();
|
||||||
|
|
||||||
if (eventType == XmlPullParser.START_TAG && parser.getDepth() == initialDepth + 1) {
|
if (eventType == XmlPullParser.START_TAG && parser.getDepth() == initialDepth + 1) {
|
||||||
|
PacketExtension streamFeature = null;
|
||||||
String name = parser.getName();
|
String name = parser.getName();
|
||||||
String namespace = parser.getNamespace();
|
String namespace = parser.getNamespace();
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case StartTls.ELEMENT:
|
case StartTls.ELEMENT:
|
||||||
StartTls startTls = PacketParserUtils.parseStartTlsFeature(parser);
|
streamFeature = PacketParserUtils.parseStartTlsFeature(parser);
|
||||||
addStreamFeature(startTls);
|
|
||||||
break;
|
break;
|
||||||
case Mechanisms.ELEMENT:
|
case Mechanisms.ELEMENT:
|
||||||
Mechanisms mechanisms = new Mechanisms(PacketParserUtils.parseMechanisms(parser));
|
streamFeature = new Mechanisms(PacketParserUtils.parseMechanisms(parser));
|
||||||
addStreamFeature(mechanisms);
|
|
||||||
break;
|
break;
|
||||||
case Bind.ELEMENT:
|
case Bind.ELEMENT:
|
||||||
addStreamFeature(Bind.Feature.INSTANCE);
|
streamFeature = Bind.Feature.INSTANCE;
|
||||||
break;
|
|
||||||
case CapsExtension.ELEMENT:
|
|
||||||
// Set the entity caps node for the server if one is send
|
|
||||||
// See http://xmpp.org/extensions/xep-0115.html#stream
|
|
||||||
String node = parser.getAttributeValue(null, "node");
|
|
||||||
String ver = parser.getAttributeValue(null, "ver");
|
|
||||||
String hash = parser.getAttributeValue(null, "hash");
|
|
||||||
CapsExtension capsExtension = new CapsExtension(node, ver, hash);
|
|
||||||
addStreamFeature(capsExtension);
|
|
||||||
break;
|
break;
|
||||||
case Session.ELEMENT:
|
case Session.ELEMENT:
|
||||||
addStreamFeature(Session.Feature.INSTANCE);
|
streamFeature = Session.Feature.INSTANCE;
|
||||||
break;
|
break;
|
||||||
case RosterVer.ELEMENT:
|
case RosterVer.ELEMENT:
|
||||||
if(namespace.equals(RosterVer.NAMESPACE)) {
|
if(namespace.equals(RosterVer.NAMESPACE)) {
|
||||||
addStreamFeature(RosterVer.INSTANCE);
|
streamFeature = RosterVer.INSTANCE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOGGER.severe("Unkown Roster Versioning Namespace: "
|
LOGGER.severe("Unkown Roster Versioning Namespace: "
|
||||||
|
@ -1059,16 +1049,18 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Compress.Feature.ELEMENT:
|
case Compress.Feature.ELEMENT:
|
||||||
Compress.Feature compression = PacketParserUtils.parseCompressionFeature(parser);
|
streamFeature = PacketParserUtils.parseCompressionFeature(parser);
|
||||||
addStreamFeature(compression);
|
|
||||||
break;
|
|
||||||
case Registration.Feature.ELEMENT:
|
|
||||||
addStreamFeature(Registration.Feature.INSTANCE);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
parseFeaturesSubclass(name, namespace, parser);
|
StreamFeatureProvider provider = ProviderManager.getStreamFeatureProvider(name, namespace);
|
||||||
|
if (provider != null) {
|
||||||
|
streamFeature = provider.parseStreamFeature(parser);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (streamFeature != null) {
|
||||||
|
addStreamFeature(streamFeature);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (eventType == XmlPullParser.END_TAG && parser.getDepth() == initialDepth) {
|
else if (eventType == XmlPullParser.END_TAG && parser.getDepth() == initialDepth) {
|
||||||
break;
|
break;
|
||||||
|
@ -1096,10 +1088,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
afterFeaturesReceived();
|
afterFeaturesReceived();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void parseFeaturesSubclass (String name, String namespace, XmlPullParser parser) {
|
|
||||||
// Default implementation does nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void afterFeaturesReceived() throws SecurityRequiredException, NotConnectedException {
|
protected void afterFeaturesReceived() throws SecurityRequiredException, NotConnectedException {
|
||||||
// Default implementation does nothing
|
// Default implementation does nothing
|
||||||
}
|
}
|
||||||
|
@ -1115,7 +1103,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
return getFeature(element, namespace) != null;
|
return getFeature(element, namespace) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addStreamFeature(PacketExtension feature) {
|
private void addStreamFeature(PacketExtension feature) {
|
||||||
String key = XmppStringUtils.generateKey(feature.getElementName(), feature.getNamespace());
|
String key = XmppStringUtils.generateKey(feature.getElementName(), feature.getNamespace());
|
||||||
streamFeatures.put(key, feature);
|
streamFeatures.put(key, feature);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package org.jivesoftware.smack.provider;
|
package org.jivesoftware.smack.provider;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -40,8 +39,9 @@ import org.xmlpull.v1.XmlPullParser;
|
||||||
public class ProviderFileLoader implements ProviderLoader {
|
public class ProviderFileLoader implements ProviderLoader {
|
||||||
private static final Logger LOGGER = Logger.getLogger(ProviderFileLoader.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ProviderFileLoader.class.getName());
|
||||||
|
|
||||||
private Collection<IQProviderInfo> iqProviders;
|
private final Collection<IQProviderInfo> iqProviders = new LinkedList<IQProviderInfo>();
|
||||||
private Collection<ExtensionProviderInfo> extProviders;
|
private final Collection<ExtensionProviderInfo> extProviders = new LinkedList<ExtensionProviderInfo>();
|
||||||
|
private final Collection<StreamFeatureProviderInfo> sfProviders = new LinkedList<StreamFeatureProviderInfo>();
|
||||||
|
|
||||||
private List<Exception> exceptions = new LinkedList<Exception>();
|
private List<Exception> exceptions = new LinkedList<Exception>();
|
||||||
|
|
||||||
|
@ -51,9 +51,6 @@ public class ProviderFileLoader implements ProviderLoader {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public ProviderFileLoader(InputStream providerStream, ClassLoader classLoader) {
|
public ProviderFileLoader(InputStream providerStream, ClassLoader classLoader) {
|
||||||
iqProviders = new ArrayList<IQProviderInfo>();
|
|
||||||
extProviders = new ArrayList<ExtensionProviderInfo>();
|
|
||||||
|
|
||||||
// Load processing providers.
|
// Load processing providers.
|
||||||
try {
|
try {
|
||||||
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
|
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
|
||||||
|
@ -62,7 +59,7 @@ public class ProviderFileLoader implements ProviderLoader {
|
||||||
int eventType = parser.getEventType();
|
int eventType = parser.getEventType();
|
||||||
do {
|
do {
|
||||||
if (eventType == XmlPullParser.START_TAG) {
|
if (eventType == XmlPullParser.START_TAG) {
|
||||||
String typeName = parser.getName();
|
final String typeName = parser.getName();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!"smackProviders".equals(typeName)) {
|
if (!"smackProviders".equals(typeName)) {
|
||||||
|
@ -78,21 +75,21 @@ public class ProviderFileLoader implements ProviderLoader {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Class<?> provider = classLoader.loadClass(className);
|
final Class<?> provider = classLoader.loadClass(className);
|
||||||
// Attempt to load the provider class and then create
|
switch (typeName) {
|
||||||
// a new instance if it's an IQProvider. Otherwise, if it's
|
case "iqProvider":
|
||||||
// an IQ class, add the class object itself, then we'll use
|
// Attempt to load the provider class and then create
|
||||||
// reflection later to create instances of the class.
|
// a new instance if it's an IQProvider. Otherwise, if it's
|
||||||
if ("iqProvider".equals(typeName)) {
|
// an IQ class, add the class object itself, then we'll use
|
||||||
|
// reflection later to create instances of the class.
|
||||||
// Add the provider to the map.
|
// Add the provider to the map.
|
||||||
|
|
||||||
if (IQProvider.class.isAssignableFrom(provider)) {
|
if (IQProvider.class.isAssignableFrom(provider)) {
|
||||||
iqProviders.add(new IQProviderInfo(elementName, namespace, (IQProvider) provider.newInstance()));
|
iqProviders.add(new IQProviderInfo(elementName, namespace, (IQProvider) provider.newInstance()));
|
||||||
}
|
}
|
||||||
else if (IQ.class.isAssignableFrom(provider)) {
|
else if (IQ.class.isAssignableFrom(provider)) {
|
||||||
iqProviders.add(new IQProviderInfo(elementName, namespace, (Class<? extends IQ>)provider));
|
iqProviders.add(new IQProviderInfo(elementName, namespace, (Class<? extends IQ>)provider));
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else {
|
case "extensionProvider":
|
||||||
// Attempt to load the provider class and then create
|
// Attempt to load the provider class and then create
|
||||||
// a new instance if it's an ExtensionProvider. Otherwise, if it's
|
// a new instance if it's an ExtensionProvider. Otherwise, if it's
|
||||||
// a PacketExtension, add the class object itself and
|
// a PacketExtension, add the class object itself and
|
||||||
|
@ -104,6 +101,14 @@ public class ProviderFileLoader implements ProviderLoader {
|
||||||
else if (PacketExtension.class.isAssignableFrom(provider)) {
|
else if (PacketExtension.class.isAssignableFrom(provider)) {
|
||||||
extProviders.add(new ExtensionProviderInfo(elementName, namespace, provider));
|
extProviders.add(new ExtensionProviderInfo(elementName, namespace, provider));
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case "streamFeatureProvider":
|
||||||
|
sfProviders.add(new StreamFeatureProviderInfo(elementName,
|
||||||
|
namespace,
|
||||||
|
(StreamFeatureProvider) provider.newInstance()));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LOGGER.warning("Unkown provider type: " + typeName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException cnfe) {
|
catch (ClassNotFoundException cnfe) {
|
||||||
|
@ -145,6 +150,11 @@ public class ProviderFileLoader implements ProviderLoader {
|
||||||
return extProviders;
|
return extProviders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<StreamFeatureProviderInfo> getStreamFeatureProviderInfo() {
|
||||||
|
return sfProviders;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Exception> getLoadingExceptions() {
|
public List<Exception> getLoadingExceptions() {
|
||||||
return Collections.unmodifiableList(exceptions);
|
return Collections.unmodifiableList(exceptions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,4 +36,12 @@ public interface ProviderLoader {
|
||||||
* @return The extension provider info to load.
|
* @return The extension provider info to load.
|
||||||
*/
|
*/
|
||||||
Collection<ExtensionProviderInfo> getExtensionProviderInfo();
|
Collection<ExtensionProviderInfo> getExtensionProviderInfo();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the stream feature providers information for the creation of stream feature
|
||||||
|
* providers to be added to the <code>ProviderManager</code>.
|
||||||
|
*
|
||||||
|
* @return The extension provider info to load.
|
||||||
|
*/
|
||||||
|
Collection<StreamFeatureProviderInfo> getStreamFeatureProviderInfo();
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,7 @@ public final class ProviderManager {
|
||||||
|
|
||||||
private static final Map<String, Object> extensionProviders = new ConcurrentHashMap<String, Object>();
|
private static final Map<String, Object> extensionProviders = new ConcurrentHashMap<String, Object>();
|
||||||
private static final Map<String, Object> iqProviders = new ConcurrentHashMap<String, Object>();
|
private static final Map<String, Object> iqProviders = new ConcurrentHashMap<String, Object>();
|
||||||
|
private static final Map<String, StreamFeatureProvider> streamFeatureProviders = new ConcurrentHashMap<String, StreamFeatureProvider>();
|
||||||
|
|
||||||
public static void addLoader(ProviderLoader loader) {
|
public static void addLoader(ProviderLoader loader) {
|
||||||
if (loader.getIQProviderInfo() != null) {
|
if (loader.getIQProviderInfo() != null) {
|
||||||
|
@ -262,6 +263,21 @@ public final class ProviderManager {
|
||||||
return Collections.unmodifiableCollection(extensionProviders.values());
|
return Collections.unmodifiableCollection(extensionProviders.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static StreamFeatureProvider getStreamFeatureProvider(String elementName, String namespace) {
|
||||||
|
String key = getKey(elementName, namespace);
|
||||||
|
return streamFeatureProviders.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addStreamFeatureProvider(String elementName, String namespace, StreamFeatureProvider provider) {
|
||||||
|
String key = getKey(elementName, namespace);
|
||||||
|
streamFeatureProviders.put(key, provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeStreamFeatureProvider(String elementName, String namespace) {
|
||||||
|
String key = getKey(elementName, namespace);
|
||||||
|
streamFeatureProviders.remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
private static String getKey(String elementName, String namespace) {
|
private static String getKey(String elementName, String namespace) {
|
||||||
return XmppStringUtils.generateKey(elementName, namespace);
|
return XmppStringUtils.generateKey(elementName, namespace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright © 2014 Florian Schmaus
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jivesoftware.smack.provider;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.SmackException;
|
||||||
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface StreamFeatureProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param parser an XML parser.
|
||||||
|
* @return a new PacketExtension instance.
|
||||||
|
* @throws XmlPullParserException if an error occurs parsing the XML.
|
||||||
|
*/
|
||||||
|
public PacketExtension parseStreamFeature(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException;
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright © 2014 Florian Schmaus
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.jivesoftware.smack.provider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final class StreamFeatureProviderInfo extends AbstractProviderInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines an extension provider which implements the <code>StreamFeatureProvider</code> interface.
|
||||||
|
*
|
||||||
|
* @param elementName Element that provider parses.
|
||||||
|
* @param namespace Namespace that provider parses.
|
||||||
|
* @param extProvider The provider implementation.
|
||||||
|
*/
|
||||||
|
public StreamFeatureProviderInfo(String elementName, String namespace, StreamFeatureProvider extProvider) {
|
||||||
|
super(elementName, namespace, extProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -22,11 +22,10 @@ import java.io.StringReader;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@ -39,7 +38,6 @@ import org.jivesoftware.smack.packet.Message;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.jivesoftware.smack.packet.PacketExtension;
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
import org.jivesoftware.smack.packet.Presence;
|
import org.jivesoftware.smack.packet.Presence;
|
||||||
import org.jivesoftware.smack.packet.Registration;
|
|
||||||
import org.jivesoftware.smack.packet.RosterPacket;
|
import org.jivesoftware.smack.packet.RosterPacket;
|
||||||
import org.jivesoftware.smack.packet.StartTls;
|
import org.jivesoftware.smack.packet.StartTls;
|
||||||
import org.jivesoftware.smack.packet.StreamError;
|
import org.jivesoftware.smack.packet.StreamError;
|
||||||
|
@ -539,9 +537,6 @@ public class PacketParserUtils {
|
||||||
else if (elementName.equals("query") && namespace.equals("jabber:iq:roster")) {
|
else if (elementName.equals("query") && namespace.equals("jabber:iq:roster")) {
|
||||||
iqPacket = parseRoster(parser);
|
iqPacket = parseRoster(parser);
|
||||||
}
|
}
|
||||||
else if (elementName.equals("query") && namespace.equals("jabber:iq:register")) {
|
|
||||||
iqPacket = parseRegistration(parser);
|
|
||||||
}
|
|
||||||
else if (elementName.equals(Bind.ELEMENT) && namespace.equals(Bind.NAMESPACE)) {
|
else if (elementName.equals(Bind.ELEMENT) && namespace.equals(Bind.NAMESPACE)) {
|
||||||
iqPacket = parseResourceBinding(parser);
|
iqPacket = parseResourceBinding(parser);
|
||||||
}
|
}
|
||||||
|
@ -658,52 +653,6 @@ public class PacketParserUtils {
|
||||||
return roster;
|
return roster;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Registration parseRegistration(XmlPullParser parser) throws Exception {
|
|
||||||
Registration registration = new Registration();
|
|
||||||
Map<String, String> fields = null;
|
|
||||||
boolean done = false;
|
|
||||||
while (!done) {
|
|
||||||
int eventType = parser.next();
|
|
||||||
if (eventType == XmlPullParser.START_TAG) {
|
|
||||||
// Any element that's in the jabber:iq:register namespace,
|
|
||||||
// attempt to parse it if it's in the form <name>value</name>.
|
|
||||||
if (parser.getNamespace().equals("jabber:iq:register")) {
|
|
||||||
String name = parser.getName();
|
|
||||||
String value = "";
|
|
||||||
if (fields == null) {
|
|
||||||
fields = new HashMap<String, String>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parser.next() == XmlPullParser.TEXT) {
|
|
||||||
value = parser.getText();
|
|
||||||
}
|
|
||||||
// Ignore instructions, but anything else should be added to the map.
|
|
||||||
if (!name.equals("instructions")) {
|
|
||||||
fields.put(name, value);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
registration.setInstructions(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Otherwise, it must be a packet extension.
|
|
||||||
else {
|
|
||||||
registration.addExtension(
|
|
||||||
PacketParserUtils.parsePacketExtension(
|
|
||||||
parser.getName(),
|
|
||||||
parser.getNamespace(),
|
|
||||||
parser));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (eventType == XmlPullParser.END_TAG) {
|
|
||||||
if (parser.getName().equals("query")) {
|
|
||||||
done = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
registration.setAttributes(fields);
|
|
||||||
return registration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Bind parseResourceBinding(XmlPullParser parser) throws IOException,
|
public static Bind parseResourceBinding(XmlPullParser parser) throws IOException,
|
||||||
XmlPullParserException {
|
XmlPullParserException {
|
||||||
assert (parser.getEventType() == XmlPullParser.START_TAG);
|
assert (parser.getEventType() == XmlPullParser.START_TAG);
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
<className>org.jivesoftware.smack.initializer.extensions.ExtensionsInitializer</className>
|
<className>org.jivesoftware.smack.initializer.extensions.ExtensionsInitializer</className>
|
||||||
<className>org.jivesoftware.smack.initializer.experimental.ExperimentalInitializer</className>
|
<className>org.jivesoftware.smack.initializer.experimental.ExperimentalInitializer</className>
|
||||||
<className>org.jivesoftware.smack.initializer.legacy.LegacyInitializer</className>
|
<className>org.jivesoftware.smack.initializer.legacy.LegacyInitializer</className>
|
||||||
|
<className>org.jivesoftware.smack.initializer.tcp.SmackTcpSmackInitializer</className>
|
||||||
<className>org.jivesoftware.smack.sasl.javax.SASLJavaXSmackInitializer</className>
|
<className>org.jivesoftware.smack.sasl.javax.SASLJavaXSmackInitializer</className>
|
||||||
<className>org.jivesoftware.smack.sasl.provided.SASLProvidedSmackInitializer</className>
|
<className>org.jivesoftware.smack.sasl.provided.SASLProvidedSmackInitializer</className>
|
||||||
<className>org.jivesoftware.smack.android.AndroidSmackInitializer</className>
|
<className>org.jivesoftware.smack.android.AndroidSmackInitializer</className>
|
||||||
|
|
|
@ -43,6 +43,11 @@ public class ProviderConfigTest {
|
||||||
public Collection<ExtensionProviderInfo> getExtensionProviderInfo() {
|
public Collection<ExtensionProviderInfo> getExtensionProviderInfo() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<StreamFeatureProviderInfo> getStreamFeatureProviderInfo() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Assert.assertNotNull(ProviderManager.getIQProvider("provider", "test:provider"));
|
Assert.assertNotNull(ProviderManager.getIQProvider("provider", "test:provider"));
|
||||||
|
|
|
@ -26,7 +26,6 @@ import org.jivesoftware.smack.PacketInterceptor;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
||||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||||
import org.jivesoftware.smack.packet.CapsExtension;
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.jivesoftware.smack.packet.PacketExtension;
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
|
@ -39,6 +38,7 @@ import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||||
import org.jivesoftware.smack.util.Cache;
|
import org.jivesoftware.smack.util.Cache;
|
||||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||||
import org.jivesoftware.smackx.caps.cache.EntityCapsPersistentCache;
|
import org.jivesoftware.smackx.caps.cache.EntityCapsPersistentCache;
|
||||||
|
import org.jivesoftware.smackx.caps.packet.CapsExtension;
|
||||||
import org.jivesoftware.smackx.disco.NodeInformationProvider;
|
import org.jivesoftware.smackx.disco.NodeInformationProvider;
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||||
|
|
|
@ -14,8 +14,10 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smack.packet;
|
package org.jivesoftware.smackx.caps.packet;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -19,14 +19,15 @@ package org.jivesoftware.smackx.caps.provider;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.jivesoftware.smack.SmackException;
|
import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.packet.CapsExtension;
|
|
||||||
import org.jivesoftware.smack.packet.PacketExtension;
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||||
|
import org.jivesoftware.smack.provider.StreamFeatureProvider;
|
||||||
import org.jivesoftware.smackx.caps.EntityCapsManager;
|
import org.jivesoftware.smackx.caps.EntityCapsManager;
|
||||||
|
import org.jivesoftware.smackx.caps.packet.CapsExtension;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
public class CapsExtensionProvider implements PacketExtensionProvider {
|
public class CapsExtensionProvider implements PacketExtensionProvider, StreamFeatureProvider {
|
||||||
|
|
||||||
public PacketExtension parseExtension(XmlPullParser parser) throws XmlPullParserException, IOException,
|
public PacketExtension parseExtension(XmlPullParser parser) throws XmlPullParserException, IOException,
|
||||||
SmackException {
|
SmackException {
|
||||||
|
@ -55,4 +56,10 @@ public class CapsExtensionProvider implements PacketExtensionProvider {
|
||||||
throw new SmackException("Caps elment with missing attributes");
|
throw new SmackException("Caps elment with missing attributes");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PacketExtension parseStreamFeature(XmlPullParser parser) throws XmlPullParserException,
|
||||||
|
IOException, SmackException {
|
||||||
|
return parseExtension(parser);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jivesoftware.smack;
|
package org.jivesoftware.smackx.iqregister;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -23,12 +23,17 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.Manager;
|
||||||
|
import org.jivesoftware.smack.PacketCollector;
|
||||||
|
import org.jivesoftware.smack.SmackException;
|
||||||
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.Registration;
|
import org.jivesoftware.smackx.iqregister.packet.Registration;
|
||||||
import org.jxmpp.util.XmppStringUtils;
|
import org.jxmpp.util.XmppStringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -221,12 +226,11 @@ public class AccountManager extends Manager {
|
||||||
*/
|
*/
|
||||||
public void createAccount(String username, String password, Map<String, String> attributes)
|
public void createAccount(String username, String password, Map<String, String> attributes)
|
||||||
throws NoResponseException, XMPPErrorException, NotConnectedException {
|
throws NoResponseException, XMPPErrorException, NotConnectedException {
|
||||||
Registration reg = new Registration();
|
|
||||||
reg.setType(IQ.Type.set);
|
|
||||||
reg.setTo(connection().getServiceName());
|
|
||||||
attributes.put("username", username);
|
attributes.put("username", username);
|
||||||
attributes.put("password", password);
|
attributes.put("password", password);
|
||||||
reg.setAttributes(attributes);
|
Registration reg = new Registration(attributes);
|
||||||
|
reg.setType(IQ.Type.set);
|
||||||
|
reg.setTo(connection().getServiceName());
|
||||||
createPacketCollectorAndSend(reg).nextResultOrThrow();
|
createPacketCollectorAndSend(reg).nextResultOrThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,13 +245,12 @@ public class AccountManager extends Manager {
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
*/
|
*/
|
||||||
public void changePassword(String newPassword) throws NoResponseException, XMPPErrorException, NotConnectedException {
|
public void changePassword(String newPassword) throws NoResponseException, XMPPErrorException, NotConnectedException {
|
||||||
Registration reg = new Registration();
|
|
||||||
reg.setType(IQ.Type.set);
|
|
||||||
reg.setTo(connection().getServiceName());
|
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
map.put("username",XmppStringUtils.parseLocalpart(connection().getUser()));
|
map.put("username",XmppStringUtils.parseLocalpart(connection().getUser()));
|
||||||
map.put("password",newPassword);
|
map.put("password",newPassword);
|
||||||
reg.setAttributes(map);
|
Registration reg = new Registration(map);
|
||||||
|
reg.setType(IQ.Type.set);
|
||||||
|
reg.setTo(connection().getServiceName());
|
||||||
createPacketCollectorAndSend(reg).nextResultOrThrow();
|
createPacketCollectorAndSend(reg).nextResultOrThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,13 +265,12 @@ public class AccountManager extends Manager {
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
*/
|
*/
|
||||||
public void deleteAccount() throws NoResponseException, XMPPErrorException, NotConnectedException {
|
public void deleteAccount() throws NoResponseException, XMPPErrorException, NotConnectedException {
|
||||||
Registration reg = new Registration();
|
|
||||||
reg.setType(IQ.Type.set);
|
|
||||||
reg.setTo(connection().getServiceName());
|
|
||||||
Map<String, String> attributes = new HashMap<String, String>();
|
Map<String, String> attributes = new HashMap<String, String>();
|
||||||
// To delete an account, we add a single attribute, "remove", that is blank.
|
// To delete an account, we add a single attribute, "remove", that is blank.
|
||||||
attributes.put("remove", "");
|
attributes.put("remove", "");
|
||||||
reg.setAttributes(attributes);
|
Registration reg = new Registration(attributes);
|
||||||
|
reg.setType(IQ.Type.set);
|
||||||
|
reg.setTo(connection().getServiceName());
|
||||||
createPacketCollectorAndSend(reg).nextResultOrThrow();
|
createPacketCollectorAndSend(reg).nextResultOrThrow();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,12 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jivesoftware.smack.packet;
|
package org.jivesoftware.smackx.iqregister.packet;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,8 +50,21 @@ public class Registration extends IQ {
|
||||||
|
|
||||||
public static final String NAMESPACE = "jabber:iq:register";
|
public static final String NAMESPACE = "jabber:iq:register";
|
||||||
|
|
||||||
private String instructions = null;
|
private final String instructions;
|
||||||
private Map<String, String> attributes = null;
|
private final Map<String, String> attributes;
|
||||||
|
|
||||||
|
public Registration() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Registration(Map<String, String> attributes) {
|
||||||
|
this(null, attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Registration(String instructions, Map<String, String> attributes) {
|
||||||
|
this.instructions = instructions;
|
||||||
|
this.attributes = attributes;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the registration instructions, or <tt>null</tt> if no instructions
|
* Returns the registration instructions, or <tt>null</tt> if no instructions
|
||||||
|
@ -62,15 +77,6 @@ public class Registration extends IQ {
|
||||||
return instructions;
|
return instructions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the registration instructions.
|
|
||||||
*
|
|
||||||
* @param instructions the registration instructions.
|
|
||||||
*/
|
|
||||||
public void setInstructions(String instructions) {
|
|
||||||
this.instructions = instructions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the map of String key/value pairs of account attributes.
|
* Returns the map of String key/value pairs of account attributes.
|
||||||
*
|
*
|
||||||
|
@ -80,15 +86,6 @@ public class Registration extends IQ {
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the account attributes. The map must only contain String key/value pairs.
|
|
||||||
*
|
|
||||||
* @param attributes the account attributes.
|
|
||||||
*/
|
|
||||||
public void setAttributes(Map<String, String> attributes) {
|
|
||||||
this.attributes = attributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XmlStringBuilder getChildElementXML() {
|
public XmlStringBuilder getChildElementXML() {
|
||||||
XmlStringBuilder xml = new XmlStringBuilder();
|
XmlStringBuilder xml = new XmlStringBuilder();
|
|
@ -0,0 +1,77 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright 2003-2007 Jive Software.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.jivesoftware.smackx.iqregister.provider;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
|
import org.jivesoftware.smack.provider.IQProvider;
|
||||||
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
|
import org.jivesoftware.smackx.iqregister.packet.Registration;
|
||||||
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
|
public class RegistrationProvider implements IQProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||||
|
String instruction = null;
|
||||||
|
Map<String, String> fields = new HashMap<String, String>();
|
||||||
|
List<PacketExtension> packetExtensions = new LinkedList<PacketExtension>();
|
||||||
|
outerloop:
|
||||||
|
while (true) {
|
||||||
|
int eventType = parser.next();
|
||||||
|
if (eventType == XmlPullParser.START_TAG) {
|
||||||
|
// Any element that's in the jabber:iq:register namespace,
|
||||||
|
// attempt to parse it if it's in the form <name>value</name>.
|
||||||
|
if (parser.getNamespace().equals(Registration.NAMESPACE)) {
|
||||||
|
String name = parser.getName();
|
||||||
|
String value = "";
|
||||||
|
|
||||||
|
if (parser.next() == XmlPullParser.TEXT) {
|
||||||
|
value = parser.getText();
|
||||||
|
}
|
||||||
|
// Ignore instructions, but anything else should be added to the map.
|
||||||
|
if (!name.equals("instructions")) {
|
||||||
|
fields.put(name, value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
instruction = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Otherwise, it must be a packet extension.
|
||||||
|
else {
|
||||||
|
packetExtensions.add(PacketParserUtils.parsePacketExtension(
|
||||||
|
parser.getName(), parser.getNamespace(),
|
||||||
|
parser));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (eventType == XmlPullParser.END_TAG) {
|
||||||
|
if (parser.getName().equals(IQ.QUERY_ELEMENT)) {
|
||||||
|
break outerloop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Registration registration = new Registration(instruction, fields);
|
||||||
|
registration.addExtensions(packetExtensions);
|
||||||
|
return registration;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright © 2014 Florian Schmaus
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.jivesoftware.smackx.iqregister.provider;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
|
import org.jivesoftware.smack.provider.StreamFeatureProvider;
|
||||||
|
import org.jivesoftware.smackx.iqregister.packet.Registration;
|
||||||
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
|
public class RegistrationStreamFeatureProvider implements StreamFeatureProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PacketExtension parseStreamFeature(XmlPullParser parser) {
|
||||||
|
return Registration.Feature.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -59,12 +59,12 @@ import org.jivesoftware.smack.packet.Message;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.jivesoftware.smack.packet.PacketExtension;
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
import org.jivesoftware.smack.packet.Presence;
|
import org.jivesoftware.smack.packet.Presence;
|
||||||
import org.jivesoftware.smack.packet.Registration;
|
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
import org.jivesoftware.smackx.disco.NodeInformationProvider;
|
import org.jivesoftware.smackx.disco.NodeInformationProvider;
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||||
|
import org.jivesoftware.smackx.iqregister.packet.Registration;
|
||||||
import org.jivesoftware.smackx.muc.packet.Destroy;
|
import org.jivesoftware.smackx.muc.packet.Destroy;
|
||||||
import org.jivesoftware.smackx.muc.packet.MUCAdmin;
|
import org.jivesoftware.smackx.muc.packet.MUCAdmin;
|
||||||
import org.jivesoftware.smackx.muc.packet.MUCInitialPresence;
|
import org.jivesoftware.smackx.muc.packet.MUCInitialPresence;
|
||||||
|
|
|
@ -421,6 +421,12 @@
|
||||||
<className>org.jivesoftware.smackx.caps.provider.CapsExtensionProvider</className>
|
<className>org.jivesoftware.smackx.caps.provider.CapsExtensionProvider</className>
|
||||||
</extensionProvider>
|
</extensionProvider>
|
||||||
|
|
||||||
|
<streamFeatureProvider>
|
||||||
|
<elementName>c</elementName>
|
||||||
|
<namespace>http://jabber.org/protocol/caps</namespace>
|
||||||
|
<className>org.jivesoftware.smackx.caps.provider.CapsExtensionProvider</className>
|
||||||
|
</streamFeatureProvider>
|
||||||
|
|
||||||
<!-- XEP-0297 Stanza Forwarding -->
|
<!-- XEP-0297 Stanza Forwarding -->
|
||||||
<extensionProvider>
|
<extensionProvider>
|
||||||
<elementName>forwarded</elementName>
|
<elementName>forwarded</elementName>
|
||||||
|
@ -455,4 +461,17 @@
|
||||||
<namespace>http://www.jivesoftware.com/xmlns/xmpp/properties</namespace>
|
<namespace>http://www.jivesoftware.com/xmlns/xmpp/properties</namespace>
|
||||||
<className>org.jivesoftware.smackx.jiveproperties.provider.JivePropertiesExtensionProvider</className>
|
<className>org.jivesoftware.smackx.jiveproperties.provider.JivePropertiesExtensionProvider</className>
|
||||||
</extensionProvider>
|
</extensionProvider>
|
||||||
|
|
||||||
|
<!-- XEP-0077: In-Band Registration -->
|
||||||
|
<iqProvider>
|
||||||
|
<elementName>query</elementName>
|
||||||
|
<namespace>jabber:iq:register</namespace>
|
||||||
|
<className>org.jivesoftware.smackx.iqregister.provider.RegistrationProvider</className>
|
||||||
|
</iqProvider>
|
||||||
|
|
||||||
|
<streamFeatureProvider>
|
||||||
|
<elementName>register</elementName>
|
||||||
|
<namespace>http://jabber.org/features/iq-register</namespace>
|
||||||
|
<className>org.jivesoftware.smackx.iqregister.provider.RegistrationStreamFeatureProvider</className>
|
||||||
|
</streamFeatureProvider>
|
||||||
</smackProviders>
|
</smackProviders>
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright © 2014 Florian Schmaus
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.jivesoftware.smack.initializer.tcp;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.initializer.UrlInitializer;
|
||||||
|
|
||||||
|
public class SmackTcpSmackInitalizer extends UrlInitializer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getProvidersUrl() {
|
||||||
|
return "classpath:org.jivesoftware.smack/smacktcp.providers";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -917,19 +917,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
this.writer = writer;
|
this.writer = writer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void parseFeaturesSubclass(String name, String namespace, XmlPullParser parser) {
|
|
||||||
switch(name) {
|
|
||||||
case StreamManagementFeature.ELEMENT:
|
|
||||||
if (namespace.equals(StreamManagement.NAMESPACE)) {
|
|
||||||
addStreamFeature(StreamManagementFeature.INSTANCE);
|
|
||||||
} else {
|
|
||||||
LOGGER.fine("Unsupported Stream Management version: " + namespace);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void afterFeaturesReceived() throws SecurityRequiredException, NotConnectedException {
|
protected void afterFeaturesReceived() throws SecurityRequiredException, NotConnectedException {
|
||||||
StartTls startTlsFeature = getFeature(StartTls.ELEMENT, StartTls.NAMESPACE);
|
StartTls startTlsFeature = getFeature(StartTls.ELEMENT, StartTls.NAMESPACE);
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright © 2014 Florian Schmaus
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.jivesoftware.smack.tcp.sm.provider;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
|
import org.jivesoftware.smack.provider.StreamFeatureProvider;
|
||||||
|
import org.jivesoftware.smack.tcp.sm.packet.StreamManagement.StreamManagementFeature;
|
||||||
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
public class StreamManagementStreamFeatureProvider implements StreamFeatureProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PacketExtension parseStreamFeature(XmlPullParser parser)
|
||||||
|
throws XmlPullParserException {
|
||||||
|
return StreamManagementFeature.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<smackProviders>
|
||||||
|
|
||||||
|
<!-- XEP-0198: Stream Management -->
|
||||||
|
<streamFeatureProvider>
|
||||||
|
<elementName>sm</elementName>
|
||||||
|
<namespace>urn:xmpp:sm:3</namespace>
|
||||||
|
<className>org.jivesoftware.smack.tcp.sm.provider.StreamManagementStreamFeatureProvider</className>
|
||||||
|
</streamFeatureProvider>
|
||||||
|
|
||||||
|
</smackProviders>
|
Loading…
Reference in a new issue