mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-26 08:12: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:
parent
7eba4a484b
commit
b3a4c76f1f
1 changed files with 16 additions and 6 deletions
|
@ -54,11 +54,9 @@ package org.jivesoftware.smackx;
|
|||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.*;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smackx.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.packet.XHTMLExtension;
|
||||
import org.jivesoftware.smackx.packet.*;
|
||||
|
||||
/**
|
||||
* 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";
|
||||
|
||||
// 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
|
||||
* the message does not contain an XHTML extension.
|
||||
|
@ -128,7 +136,8 @@ public class XHTMLManager {
|
|||
|
||||
if (enabled) {
|
||||
ServiceDiscoveryManager.getInstanceFor(connection).addFeature(namespace);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ServiceDiscoveryManager.getInstanceFor(connection).removeFeature(namespace);
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +164,8 @@ public class XHTMLManager {
|
|||
DiscoverInfo result =
|
||||
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(userID);
|
||||
return result.containsFeature(namespace);
|
||||
} catch (XMPPException e) {
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue