use of org.jivesoftware.smack.packet.ExtensionElement in project Smack by igniterealtime.
the class PacketParserUtils method addExtensionElement.
public static void addExtensionElement(Collection<ExtensionElement> collection, XmlPullParser parser, String elementName, String namespace) throws Exception {
ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser);
collection.add(packetExtension);
}
use of org.jivesoftware.smack.packet.ExtensionElement in project Smack by igniterealtime.
the class PacketParserUtils method addExtensionElement.
public static void addExtensionElement(Stanza packet, XmlPullParser parser, String elementName, String namespace) throws Exception {
ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser);
packet.addExtension(packetExtension);
}
use of org.jivesoftware.smack.packet.ExtensionElement in project Smack by igniterealtime.
the class AbstractXMPPConnection method parseFeatures.
protected final void parseFeatures(XmlPullParser parser) throws Exception {
streamFeatures.clear();
final int initialDepth = parser.getDepth();
while (true) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG && parser.getDepth() == initialDepth + 1) {
ExtensionElement streamFeature = null;
String name = parser.getName();
String namespace = parser.getNamespace();
switch(name) {
case StartTls.ELEMENT:
streamFeature = PacketParserUtils.parseStartTlsFeature(parser);
break;
case Mechanisms.ELEMENT:
streamFeature = new Mechanisms(PacketParserUtils.parseMechanisms(parser));
break;
case Bind.ELEMENT:
streamFeature = Bind.Feature.INSTANCE;
break;
case Session.ELEMENT:
streamFeature = PacketParserUtils.parseSessionFeature(parser);
break;
case Compress.Feature.ELEMENT:
streamFeature = PacketParserUtils.parseCompressionFeature(parser);
break;
default:
ExtensionElementProvider<ExtensionElement> provider = ProviderManager.getStreamFeatureProvider(name, namespace);
if (provider != null) {
streamFeature = provider.parse(parser);
}
break;
}
if (streamFeature != null) {
addStreamFeature(streamFeature);
}
} else if (eventType == XmlPullParser.END_TAG && parser.getDepth() == initialDepth) {
break;
}
}
if (hasFeature(Mechanisms.ELEMENT, Mechanisms.NAMESPACE)) {
// Only proceed with SASL auth if TLS is disabled or if the server doesn't announce it
if (!hasFeature(StartTls.ELEMENT, StartTls.NAMESPACE) || config.getSecurityMode() == SecurityMode.disabled) {
tlsHandled.reportSuccess();
saslFeatureReceived.reportSuccess();
}
}
// STARTTLS. We can then report that the last 'stream:features' have been parsed
if (hasFeature(Bind.ELEMENT, Bind.NAMESPACE)) {
if (!hasFeature(Compress.Feature.ELEMENT, Compress.NAMESPACE) || !config.isCompressionEnabled()) {
// This was was last features from the server is either it did not contain
// compression or if we disabled it
lastFeaturesReceived.reportSuccess();
}
}
afterFeaturesReceived();
}
use of org.jivesoftware.smack.packet.ExtensionElement in project Smack by igniterealtime.
the class Node method getSubscriptions.
private List<Subscription> getSubscriptions(List<ExtensionElement> additionalExtensions, Collection<ExtensionElement> returnedExtensions, PubSubNamespace pubSubNamespace) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS, getId()), pubSubNamespace);
if (additionalExtensions != null) {
for (ExtensionElement pe : additionalExtensions) {
pubSub.addExtension(pe);
}
}
PubSub reply = sendPubsubPacket(pubSub);
if (returnedExtensions != null) {
returnedExtensions.addAll(reply.getExtensions());
}
SubscriptionsExtension subElem = (SubscriptionsExtension) reply.getExtension(PubSubElementType.SUBSCRIPTIONS);
return subElem.getSubscriptions();
}
use of org.jivesoftware.smack.packet.ExtensionElement in project Smack by igniterealtime.
the class ItemProvider method parse.
@Override
public Item parse(XmlPullParser parser, int initialDepth) throws Exception {
String id = parser.getAttributeValue(null, "id");
String node = parser.getAttributeValue(null, "node");
int tag = parser.next();
if (tag == XmlPullParser.END_TAG) {
return new Item(id, node);
} else {
String payloadElemName = parser.getName();
String payloadNS = parser.getNamespace();
final ExtensionElementProvider<ExtensionElement> extensionProvider = ProviderManager.getExtensionProvider(payloadElemName, payloadNS);
if (extensionProvider == null) {
CharSequence payloadText = PacketParserUtils.parseElement(parser, true);
return new PayloadItem<SimplePayload>(id, node, new SimplePayload(payloadElemName, payloadNS, payloadText));
} else {
return new PayloadItem<ExtensionElement>(id, node, extensionProvider.parse(parser));
}
}
}
Aggregations