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:
Florian Schmaus 2013-02-11 17:22:31 +00:00 committed by flow
parent c309e27853
commit 7723b9fcfd
3 changed files with 10 additions and 2 deletions

View File

@ -143,6 +143,10 @@ public class ServiceDiscoveryManager {
private void init() {
// Register the new instance and associate it with the connection
instances.put(connection, this);
addFeature(DiscoverInfo.NAMESPACE);
addFeature(DiscoverItems.NAMESPACE);
// Add a listener to the connection that removes the registered instance when
// the connection is closed
connection.addConnectionListener(new ConnectionListener() {

View File

@ -39,6 +39,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
*/
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<Identity> identities = new CopyOnWriteArrayList<Identity>();
private String node;
@ -133,7 +135,7 @@ public class DiscoverInfo extends IQ {
public String getChildElementXML() {
StringBuilder buf = new StringBuilder();
buf.append("<query xmlns=\"http://jabber.org/protocol/disco#info\"");
buf.append("<query xmlns=\"" + NAMESPACE + "\"");
if (getNode() != null) {
buf.append(" node=\"");
buf.append(StringUtils.escapeForXML(getNode()));

View File

@ -39,6 +39,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
*/
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 String node;
@ -92,7 +94,7 @@ public class DiscoverItems extends IQ {
public String getChildElementXML() {
StringBuilder buf = new StringBuilder();
buf.append("<query xmlns=\"http://jabber.org/protocol/disco#items\"");
buf.append("<query xmlns=\"" + NAMESPACE + "\"");
if (getNode() != null) {
buf.append(" node=\"");
buf.append(StringUtils.escapeForXML(getNode()));