mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-27 00:32:07 +01:00
ServiceDiscoveryManager: Anounce 'disco#info' and 'disco#items' on service discovery queries in accordance with XEP-0030
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13464 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
c309e27853
commit
7723b9fcfd
3 changed files with 10 additions and 2 deletions
|
@ -143,6 +143,10 @@ public class ServiceDiscoveryManager {
|
||||||
private void init() {
|
private void init() {
|
||||||
// Register the new instance and associate it with the connection
|
// Register the new instance and associate it with the connection
|
||||||
instances.put(connection, this);
|
instances.put(connection, this);
|
||||||
|
|
||||||
|
addFeature(DiscoverInfo.NAMESPACE);
|
||||||
|
addFeature(DiscoverItems.NAMESPACE);
|
||||||
|
|
||||||
// Add a listener to the connection that removes the registered instance when
|
// Add a listener to the connection that removes the registered instance when
|
||||||
// the connection is closed
|
// the connection is closed
|
||||||
connection.addConnectionListener(new ConnectionListener() {
|
connection.addConnectionListener(new ConnectionListener() {
|
||||||
|
|
|
@ -39,6 +39,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
*/
|
*/
|
||||||
public class DiscoverInfo extends IQ {
|
public class DiscoverInfo extends IQ {
|
||||||
|
|
||||||
|
public static final String NAMESPACE = "http://jabber.org/protocol/disco#info";
|
||||||
|
|
||||||
private final List<Feature> features = new CopyOnWriteArrayList<Feature>();
|
private final List<Feature> features = new CopyOnWriteArrayList<Feature>();
|
||||||
private final List<Identity> identities = new CopyOnWriteArrayList<Identity>();
|
private final List<Identity> identities = new CopyOnWriteArrayList<Identity>();
|
||||||
private String node;
|
private String node;
|
||||||
|
@ -133,7 +135,7 @@ public class DiscoverInfo extends IQ {
|
||||||
|
|
||||||
public String getChildElementXML() {
|
public String getChildElementXML() {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append("<query xmlns=\"http://jabber.org/protocol/disco#info\"");
|
buf.append("<query xmlns=\"" + NAMESPACE + "\"");
|
||||||
if (getNode() != null) {
|
if (getNode() != null) {
|
||||||
buf.append(" node=\"");
|
buf.append(" node=\"");
|
||||||
buf.append(StringUtils.escapeForXML(getNode()));
|
buf.append(StringUtils.escapeForXML(getNode()));
|
||||||
|
|
|
@ -39,6 +39,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
*/
|
*/
|
||||||
public class DiscoverItems extends IQ {
|
public class DiscoverItems extends IQ {
|
||||||
|
|
||||||
|
public static final String NAMESPACE = "http://jabber.org/protocol/disco#items";
|
||||||
|
|
||||||
private final List<Item> items = new CopyOnWriteArrayList<Item>();
|
private final List<Item> items = new CopyOnWriteArrayList<Item>();
|
||||||
private String node;
|
private String node;
|
||||||
|
|
||||||
|
@ -92,7 +94,7 @@ public class DiscoverItems extends IQ {
|
||||||
|
|
||||||
public String getChildElementXML() {
|
public String getChildElementXML() {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append("<query xmlns=\"http://jabber.org/protocol/disco#items\"");
|
buf.append("<query xmlns=\"" + NAMESPACE + "\"");
|
||||||
if (getNode() != null) {
|
if (getNode() != null) {
|
||||||
buf.append(" node=\"");
|
buf.append(" node=\"");
|
||||||
buf.append(StringUtils.escapeForXML(getNode()));
|
buf.append(StringUtils.escapeForXML(getNode()));
|
||||||
|
|
Loading…
Reference in a new issue