public final class CarbonManager
extends org.jivesoftware.smack.Manager
CarbonExtension
support, enabling and disabling message carbons, and for CarbonCopyReceivedListener
.
Note that it is important to match the 'from' attribute of the message wrapping a carbon copy, as otherwise it would
may be possible for others to impersonate users. Smack's CarbonManager takes care of that in
CarbonCopyReceivedListener
s which where registered with
addCarbonCopyReceivedListener(CarbonCopyReceivedListener)
.
You should call enableCarbons() before sending your first undirected presence (aka. the "initial presence").
Modifier and Type | Method and Description |
---|---|
boolean |
addCarbonCopyReceivedListener(CarbonCopyReceivedListener listener)
Add a carbon copy received listener.
|
void |
disableCarbons()
Helper method to disable carbons.
|
static void |
disableCarbons(org.jivesoftware.smack.packet.Message msg)
Deprecated.
|
void |
disableCarbonsAsync(org.jivesoftware.smack.ExceptionCallback exceptionCallback)
Disable carbons asynchronously.
|
void |
enableCarbons()
Helper method to enable carbons.
|
void |
enableCarbonsAsync(org.jivesoftware.smack.ExceptionCallback exceptionCallback)
Enable carbons asynchronously.
|
boolean |
getCarbonsEnabled()
Check if carbons are enabled on this connection.
|
static CarbonManager |
getInstanceFor(org.jivesoftware.smack.XMPPConnection connection)
Obtain the CarbonManager responsible for a connection.
|
boolean |
isSupportedByServer()
Returns true if XMPP Carbons are supported by the server.
|
boolean |
removeCarbonCopyReceivedListener(CarbonCopyReceivedListener listener)
Remove a carbon copy received listener.
|
void |
sendCarbonsEnabled(boolean new_state)
Deprecated.
|
void |
setCarbonsEnabled(boolean new_state)
Notify server to change the carbons state.
|
public static CarbonManager getInstanceFor(org.jivesoftware.smack.XMPPConnection connection)
connection
- the connection object.public boolean addCarbonCopyReceivedListener(CarbonCopyReceivedListener listener)
listener
- the listener to register.true
if the filter was not already registered.public boolean removeCarbonCopyReceivedListener(CarbonCopyReceivedListener listener)
listener
- the listener to register.true
if the filter was registered.public boolean isSupportedByServer() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException
org.jivesoftware.smack.SmackException.NotConnectedException
org.jivesoftware.smack.XMPPException.XMPPErrorException
org.jivesoftware.smack.SmackException.NoResponseException
java.lang.InterruptedException
@Deprecated public void sendCarbonsEnabled(boolean new_state) throws org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException
enableCarbonsAsync(ExceptionCallback)
or disableCarbonsAsync(ExceptionCallback)
instead.new_state
- whether carbons should be enabled or disabledorg.jivesoftware.smack.SmackException.NotConnectedException
java.lang.InterruptedException
public void enableCarbonsAsync(org.jivesoftware.smack.ExceptionCallback exceptionCallback) throws java.lang.InterruptedException
exceptionCallback
will be invoked.
Note that although this method is asynchronous, it may block if the outgoing stream element queue is full (e.g.
because of a slow network connection). Thus, if the thread performing this operation is interrupted while the
queue is full, an InterruptedException
is thrown.
exceptionCallback
- the optional exception callback.java.lang.InterruptedException
- if the thread got interrupted while this action is performed.public void disableCarbonsAsync(org.jivesoftware.smack.ExceptionCallback exceptionCallback) throws java.lang.InterruptedException
exceptionCallback
will be invoked.
Note that although this method is asynchronous, it may block if the outgoing stream element queue is full (e.g.
because of a slow network connection). Thus, if the thread performing this operation is interrupted while the
queue is full, an InterruptedException
is thrown.
exceptionCallback
- the optional exception callback.java.lang.InterruptedException
- if the thread got interrupted while this action is performed.public void setCarbonsEnabled(boolean new_state) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException
new_state
- whether carbons should be enabled or disabledorg.jivesoftware.smack.XMPPException.XMPPErrorException
org.jivesoftware.smack.SmackException.NoResponseException
org.jivesoftware.smack.SmackException.NotConnectedException
java.lang.InterruptedException
public void enableCarbons() throws org.jivesoftware.smack.XMPPException, org.jivesoftware.smack.SmackException, java.lang.InterruptedException
org.jivesoftware.smack.XMPPException
org.jivesoftware.smack.SmackException
- if there was no response from the server.java.lang.InterruptedException
public void disableCarbons() throws org.jivesoftware.smack.XMPPException, org.jivesoftware.smack.SmackException, java.lang.InterruptedException
org.jivesoftware.smack.XMPPException
org.jivesoftware.smack.SmackException
- if there was no response from the server.java.lang.InterruptedException
public boolean getCarbonsEnabled()
@Deprecated public static void disableCarbons(org.jivesoftware.smack.packet.Message msg)
CarbonExtension.Private.addTo(Message)
msg
- Message object to mark private