1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-16 20:22:05 +01:00

Adds static init - Makes the XHTMLfeature available by default on every connection

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2183 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2003-12-19 18:00:16 +00:00 committed by gdombiak
parent 7eba4a484b
commit b3a4c76f1f

View file

@ -54,11 +54,9 @@ package org.jivesoftware.smackx;
import java.util.Iterator; import java.util.Iterator;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.*;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smackx.packet.DiscoverInfo; import org.jivesoftware.smackx.packet.*;
import org.jivesoftware.smackx.packet.XHTMLExtension;
/** /**
* Manages XHTML formatted texts within messages. A XHTMLManager provides a high level access to * Manages XHTML formatted texts within messages. A XHTMLManager provides a high level access to
@ -71,6 +69,16 @@ public class XHTMLManager {
private final static String namespace = "http://jabber.org/protocol/xhtml-im"; private final static String namespace = "http://jabber.org/protocol/xhtml-im";
// Enable the XHTML support on every established connection
// The ServiceDiscoveryManager class should have been already initialized
static {
XMPPConnection.addConnectionListener(new ConnectionEstablishedListener() {
public void connectionEstablished(XMPPConnection connection) {
XHTMLManager.setServiceEnabled(connection, true);
}
});
}
/** /**
* Returns an Iterator for the XHTML bodies in the message. Returns null if * Returns an Iterator for the XHTML bodies in the message. Returns null if
* the message does not contain an XHTML extension. * the message does not contain an XHTML extension.
@ -128,7 +136,8 @@ public class XHTMLManager {
if (enabled) { if (enabled) {
ServiceDiscoveryManager.getInstanceFor(connection).addFeature(namespace); ServiceDiscoveryManager.getInstanceFor(connection).addFeature(namespace);
} else { }
else {
ServiceDiscoveryManager.getInstanceFor(connection).removeFeature(namespace); ServiceDiscoveryManager.getInstanceFor(connection).removeFeature(namespace);
} }
} }
@ -155,7 +164,8 @@ public class XHTMLManager {
DiscoverInfo result = DiscoverInfo result =
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(userID); ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(userID);
return result.containsFeature(namespace); return result.containsFeature(namespace);
} catch (XMPPException e) { }
catch (XMPPException e) {
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }