2013-03-18 09:50:48 +01:00
|
|
|
/**
|
|
|
|
*
|
2014-03-11 09:20:55 +01:00
|
|
|
* Copyright © 2009 Jonas Ådahl, 2011-2014 Florian Schmaus
|
2014-02-17 18:57:38 +01:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
2013-03-18 09:50:48 +01:00
|
|
|
* 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.
|
|
|
|
*/
|
2014-09-11 23:58:07 +02:00
|
|
|
package org.jivesoftware.smackx.caps.packet;
|
2013-03-18 09:50:48 +01:00
|
|
|
|
2015-02-26 18:41:17 +01:00
|
|
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
2017-06-14 17:12:43 +02:00
|
|
|
import org.jivesoftware.smack.packet.Stanza;
|
2014-03-21 09:51:52 +01:00
|
|
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
2013-03-18 09:50:48 +01:00
|
|
|
|
2014-09-11 09:49:16 +02:00
|
|
|
/**
|
|
|
|
* A XEP-0115 Entity Capabilities extension.
|
|
|
|
*/
|
2015-02-26 18:41:17 +01:00
|
|
|
public class CapsExtension implements ExtensionElement {
|
2014-09-11 09:49:16 +02:00
|
|
|
public static final String NAMESPACE = "http://jabber.org/protocol/caps";
|
|
|
|
public static final String ELEMENT = "c";
|
2013-03-18 09:50:48 +01:00
|
|
|
|
2014-03-11 09:20:55 +01:00
|
|
|
private final String node, ver, hash;
|
2013-03-18 09:50:48 +01:00
|
|
|
|
|
|
|
public CapsExtension(String node, String version, String hash) {
|
|
|
|
this.node = node;
|
|
|
|
this.ver = version;
|
|
|
|
this.hash = hash;
|
|
|
|
}
|
|
|
|
|
2017-02-11 16:16:41 +01:00
|
|
|
@Override
|
2013-03-18 09:50:48 +01:00
|
|
|
public String getElementName() {
|
2014-09-11 09:49:16 +02:00
|
|
|
return ELEMENT;
|
2013-03-18 09:50:48 +01:00
|
|
|
}
|
|
|
|
|
2017-02-11 16:16:41 +01:00
|
|
|
@Override
|
2013-03-18 09:50:48 +01:00
|
|
|
public String getNamespace() {
|
2014-09-11 09:49:16 +02:00
|
|
|
return NAMESPACE;
|
2013-03-18 09:50:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getNode() {
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getVer() {
|
|
|
|
return ver;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getHash() {
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
2014-09-11 09:49:16 +02:00
|
|
|
/**
|
2015-03-29 12:15:32 +02:00
|
|
|
* {@inheritDoc}.
|
|
|
|
*
|
2014-09-11 09:49:16 +02:00
|
|
|
* <pre>
|
2017-12-25 12:51:41 +01:00
|
|
|
* <c xmlns='http://jabber.org/protocol/caps'
|
2014-09-11 09:49:16 +02:00
|
|
|
* hash='sha-1'
|
|
|
|
* node='http://code.google.com/p/exodus'
|
2017-12-25 12:51:41 +01:00
|
|
|
* ver='QgayPKawpkPSDYmwT/WM94uAlu0='/>
|
2014-09-11 09:49:16 +02:00
|
|
|
* </pre>
|
2013-03-18 09:50:48 +01:00
|
|
|
*
|
|
|
|
*/
|
2014-09-11 09:49:16 +02:00
|
|
|
@Override
|
2019-02-04 13:27:41 +01:00
|
|
|
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
2014-03-21 09:51:52 +01:00
|
|
|
XmlStringBuilder xml = new XmlStringBuilder(this);
|
|
|
|
xml.attribute("hash", hash).attribute("node", node).attribute("ver", ver);
|
|
|
|
xml.closeEmptyElement();
|
|
|
|
return xml;
|
2013-03-18 09:50:48 +01:00
|
|
|
}
|
2014-09-11 09:49:16 +02:00
|
|
|
|
2015-02-05 11:17:27 +01:00
|
|
|
public static CapsExtension from(Stanza stanza) {
|
2014-09-11 09:49:16 +02:00
|
|
|
return stanza.getExtension(ELEMENT, NAMESPACE);
|
|
|
|
}
|
2013-03-18 09:50:48 +01:00
|
|
|
}
|