Package org.jivesoftware.smackx.privacy
Class PrivacyListManager
- java.lang.Object
-
- org.jivesoftware.smack.Manager
-
- org.jivesoftware.smackx.privacy.PrivacyListManager
-
public final class PrivacyListManager extends Manager
A PrivacyListManager is used by XMPP clients to block or allow communications from other users. Use the manager to:- Retrieve privacy lists.
- Add, remove, and edit privacy lists.
- Set, change, or decline active lists.
- Set, change, or decline the default list (i.e., the list that is active by default).
PrivacyItem
).- See Also:
- XEP-16: Privacy Lists
-
-
Field Summary
Fields Modifier and Type Field Description static String
NAMESPACE
static StanzaFilter
PRIVACY_FILTER
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addListener(PrivacyListListener listener)
Adds a privacy list listener that will be notified of any new update in the user privacy communication.void
createPrivacyList(String listName, List<PrivacyItem> privacyItems)
The client has created a new list.void
declineActiveList()
Client declines the use of active lists.void
declineDefaultList()
Client declines the use of default lists.void
deletePrivacyList(String listName)
Remove a privacy list.PrivacyList
getActiveList()
Answer the active privacy list.String
getActiveListName()
Get the name of the active list.PrivacyList
getDefaultList()
Answer the default privacy list.String
getDefaultListName()
Get the name of the default list.String
getEffectiveListName()
Returns the name of the effective privacy list.static PrivacyListManager
getInstanceFor(XMPPConnection connection)
Returns the PrivacyListManager instance associated with a given XMPPConnection.PrivacyList
getPrivacyList(String listName)
Answer the privacy list items under listName with the allowed and blocked permissions.List<PrivacyList>
getPrivacyLists()
Answer every privacy list with the allowed and blocked permissions.boolean
isSupported()
Check if the user's server supports privacy lists.boolean
removeListener(PrivacyListListener listener)
Removes the privacy list listener.void
setActiveListName(String listName)
Set or change the active list to listName.void
setDefaultListName(String listName)
Set or change the default list to listName.void
updatePrivacyList(String listName, List<PrivacyItem> privacyItems)
The client has edited an existing list.-
Methods inherited from class org.jivesoftware.smack.Manager
connection, getAuthenticatedConnectionOrThrow, schedule, schedule, scheduleBlocking
-
-
-
-
Field Detail
-
NAMESPACE
public static final String NAMESPACE
- See Also:
- Constant Field Values
-
PRIVACY_FILTER
public static final StanzaFilter PRIVACY_FILTER
-
-
Method Detail
-
getInstanceFor
public static PrivacyListManager getInstanceFor(XMPPConnection connection)
Returns the PrivacyListManager instance associated with a given XMPPConnection.- Parameters:
connection
- the connection used to look for the proper PrivacyListManager.- Returns:
- the PrivacyListManager associated with a given XMPPConnection.
-
getActiveList
public PrivacyList getActiveList() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Answer the active privacy list. Returnsnull
if there is no active list.- Returns:
- the privacy list of the active list.
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getActiveListName
public String getActiveListName() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Get the name of the active list.- Returns:
- the name of the active list or null if there is none set.
- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.- Since:
- 4.1
-
getDefaultList
public PrivacyList getDefaultList() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Answer the default privacy list. Returnsnull
if there is no default list.- Returns:
- the privacy list of the default list.
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getDefaultListName
public String getDefaultListName() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Get the name of the default list.- Returns:
- the name of the default list or null if there is none set.
- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.- Since:
- 4.1
-
getEffectiveListName
public String getEffectiveListName() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Returns the name of the effective privacy list.The effective privacy list is the one that is currently enforced on the connection. It's either the active privacy list, or, if the active privacy list is not set, the default privacy list.
- Returns:
- the name of the effective privacy list or null if there is none set.
- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.- Since:
- 4.1
-
getPrivacyList
public PrivacyList getPrivacyList(String listName) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Answer the privacy list items under listName with the allowed and blocked permissions.- Parameters:
listName
- the name of the list to get the allowed and blocked permissions.- Returns:
- a privacy list under the list listName.
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getPrivacyLists
public List<PrivacyList> getPrivacyLists() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Answer every privacy list with the allowed and blocked permissions.- Returns:
- an array of privacy lists.
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
setActiveListName
public void setActiveListName(String listName) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Set or change the active list to listName.- Parameters:
listName
- the list name to set as the active one.- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
declineActiveList
public void declineActiveList() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Client declines the use of active lists.- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
setDefaultListName
public void setDefaultListName(String listName) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Set or change the default list to listName.- Parameters:
listName
- the list name to set as the default one.- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
declineDefaultList
public void declineDefaultList() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Client declines the use of default lists.- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
createPrivacyList
public void createPrivacyList(String listName, List<PrivacyItem> privacyItems) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
The client has created a new list. It send the new one to the server.- Parameters:
listName
- the list that has changed its content.privacyItems
- a List with every privacy item in the list.- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
updatePrivacyList
public void updatePrivacyList(String listName, List<PrivacyItem> privacyItems) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
The client has edited an existing list. It updates the server content with the resulting list of privacy items. ThePrivacyItem
list MUST contain all elements in the list (not the "delta").- Parameters:
listName
- the list that has changed its content.privacyItems
- a List with every privacy item in the list.- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
deletePrivacyList
public void deletePrivacyList(String listName) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Remove a privacy list.- Parameters:
listName
- the list that has changed its content.- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
addListener
public boolean addListener(PrivacyListListener listener)
Adds a privacy list listener that will be notified of any new update in the user privacy communication.- Parameters:
listener
- a privacy list listener.- Returns:
- true, if the listener was not already added.
-
removeListener
public boolean removeListener(PrivacyListListener listener)
Removes the privacy list listener.- Parameters:
listener
- TODO javadoc me please- Returns:
- true, if the listener was removed.
-
isSupported
public boolean isSupported() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Check if the user's server supports privacy lists.- Returns:
- true, if the server supports privacy lists, false otherwise.
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
-