public final class CarbonManager extends 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(Message msg)
Deprecated.
|
void |
disableCarbonsAsync(ExceptionCallback exceptionCallback)
Disable carbons asynchronously.
|
void |
enableCarbons()
Helper method to enable carbons.
|
void |
enableCarbonsAsync(ExceptionCallback exceptionCallback)
Enable carbons asynchronously.
|
boolean |
getCarbonsEnabled()
Check if carbons are enabled on this connection.
|
static CarbonManager |
getInstanceFor(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.
|
connection, getAuthenticatedConnectionOrThrow
public static CarbonManager getInstanceFor(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 SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
SmackException.NotConnectedException
XMPPException.XMPPErrorException
SmackException.NoResponseException
java.lang.InterruptedException
@Deprecated public void sendCarbonsEnabled(boolean new_state) throws SmackException.NotConnectedException, java.lang.InterruptedException
enableCarbonsAsync(ExceptionCallback)
or disableCarbonsAsync(ExceptionCallback)
instead.new_state
- whether carbons should be enabled or disabledSmackException.NotConnectedException
java.lang.InterruptedException
public void enableCarbonsAsync(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(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 SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
new_state
- whether carbons should be enabled or disabledXMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
java.lang.InterruptedException
public void enableCarbons() throws XMPPException, SmackException, java.lang.InterruptedException
XMPPException
SmackException
- if there was no response from the server.java.lang.InterruptedException
public void disableCarbons() throws XMPPException, SmackException, java.lang.InterruptedException
XMPPException
SmackException
- if there was no response from the server.java.lang.InterruptedException
public boolean getCarbonsEnabled()
@Deprecated public static void disableCarbons(Message msg)
CarbonExtension.Private.addTo(Message)
msg
- Message object to mark private