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<Exception> exceptionCallback)
Disable carbons asynchronously.
|
void |
enableCarbons()
Helper method to enable carbons.
|
void |
enableCarbonsAsync(ExceptionCallback<Exception> 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, schedule
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, InterruptedException
SmackException.NotConnectedException
XMPPException.XMPPErrorException
SmackException.NoResponseException
InterruptedException
@Deprecated public void sendCarbonsEnabled(boolean new_state) throws SmackException.NotConnectedException, InterruptedException
enableCarbonsAsync(ExceptionCallback)
or disableCarbonsAsync(ExceptionCallback)
instead.new_state
- whether carbons should be enabled or disabledSmackException.NotConnectedException
InterruptedException
public void enableCarbonsAsync(ExceptionCallback<Exception> exceptionCallback)
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.public void disableCarbonsAsync(ExceptionCallback<Exception> exceptionCallback)
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.public void setCarbonsEnabled(boolean new_state) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
new_state
- whether carbons should be enabled or disabledXMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
InterruptedException
public void enableCarbons() throws XMPPException, SmackException, InterruptedException
XMPPException
SmackException
- if there was no response from the server.InterruptedException
public void disableCarbons() throws XMPPException, SmackException, InterruptedException
XMPPException
SmackException
- if there was no response from the server.InterruptedException
public boolean getCarbonsEnabled()
@Deprecated public static void disableCarbons(Message msg)
CarbonExtension.Private.addTo(Message)
msg
- Message object to mark private