Class PrivacyListManager


  • public final class PrivacyListManager
    extends org.jivesoftware.smack.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).
    Privacy Items can handle different kind of permission communications based on JID, group, subscription type or globally (see PrivacyItem).
    See Also:
    XEP-16: Privacy Lists
    • Field Detail

      • PRIVACY_FILTER

        public static final org.jivesoftware.smack.filter.StanzaFilter PRIVACY_FILTER
    • Method Detail

      • getInstanceFor

        public static PrivacyListManager getInstanceFor​(org.jivesoftware.smack.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 org.jivesoftware.smack.SmackException.NoResponseException,
                                         org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                         org.jivesoftware.smack.SmackException.NotConnectedException,
                                         java.lang.InterruptedException
        Answer the active privacy list. Returns null if there is no active list.
        Returns:
        the privacy list of the active list.
        Throws:
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • getActiveListName

        public java.lang.String getActiveListName()
                                           throws org.jivesoftware.smack.SmackException.NoResponseException,
                                                  org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                                  org.jivesoftware.smack.SmackException.NotConnectedException,
                                                  java.lang.InterruptedException
        Get the name of the active list.
        Returns:
        the name of the active list or null if there is none set.
        Throws:
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
        Since:
        4.1
      • getDefaultList

        public PrivacyList getDefaultList()
                                   throws org.jivesoftware.smack.SmackException.NoResponseException,
                                          org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                          org.jivesoftware.smack.SmackException.NotConnectedException,
                                          java.lang.InterruptedException
        Answer the default privacy list. Returns null if there is no default list.
        Returns:
        the privacy list of the default list.
        Throws:
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • getDefaultListName

        public java.lang.String getDefaultListName()
                                            throws org.jivesoftware.smack.SmackException.NoResponseException,
                                                   org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                                   org.jivesoftware.smack.SmackException.NotConnectedException,
                                                   java.lang.InterruptedException
        Get the name of the default list.
        Returns:
        the name of the default list or null if there is none set.
        Throws:
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
        Since:
        4.1
      • getEffectiveListName

        public java.lang.String getEffectiveListName()
                                              throws org.jivesoftware.smack.SmackException.NoResponseException,
                                                     org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                                     org.jivesoftware.smack.SmackException.NotConnectedException,
                                                     java.lang.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:
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
        Since:
        4.1
      • getPrivacyList

        public PrivacyList getPrivacyList​(java.lang.String listName)
                                   throws org.jivesoftware.smack.SmackException.NoResponseException,
                                          org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                          org.jivesoftware.smack.SmackException.NotConnectedException,
                                          java.lang.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:
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • getPrivacyLists

        public java.util.List<PrivacyList> getPrivacyLists()
                                                    throws org.jivesoftware.smack.SmackException.NoResponseException,
                                                           org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                                           org.jivesoftware.smack.SmackException.NotConnectedException,
                                                           java.lang.InterruptedException
        Answer every privacy list with the allowed and blocked permissions.
        Returns:
        an array of privacy lists.
        Throws:
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • setActiveListName

        public void setActiveListName​(java.lang.String listName)
                               throws org.jivesoftware.smack.SmackException.NoResponseException,
                                      org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                      org.jivesoftware.smack.SmackException.NotConnectedException,
                                      java.lang.InterruptedException
        Set or change the active list to listName.
        Parameters:
        listName - the list name to set as the active one.
        Throws:
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • declineActiveList

        public void declineActiveList()
                               throws org.jivesoftware.smack.SmackException.NoResponseException,
                                      org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                      org.jivesoftware.smack.SmackException.NotConnectedException,
                                      java.lang.InterruptedException
        Client declines the use of active lists.
        Throws:
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • setDefaultListName

        public void setDefaultListName​(java.lang.String listName)
                                throws org.jivesoftware.smack.SmackException.NoResponseException,
                                       org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                       org.jivesoftware.smack.SmackException.NotConnectedException,
                                       java.lang.InterruptedException
        Set or change the default list to listName.
        Parameters:
        listName - the list name to set as the default one.
        Throws:
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • declineDefaultList

        public void declineDefaultList()
                                throws org.jivesoftware.smack.SmackException.NoResponseException,
                                       org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                       org.jivesoftware.smack.SmackException.NotConnectedException,
                                       java.lang.InterruptedException
        Client declines the use of default lists.
        Throws:
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • createPrivacyList

        public void createPrivacyList​(java.lang.String listName,
                                      java.util.List<PrivacyItem> privacyItems)
                               throws org.jivesoftware.smack.SmackException.NoResponseException,
                                      org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                      org.jivesoftware.smack.SmackException.NotConnectedException,
                                      java.lang.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:
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • updatePrivacyList

        public void updatePrivacyList​(java.lang.String listName,
                                      java.util.List<PrivacyItem> privacyItems)
                               throws org.jivesoftware.smack.SmackException.NoResponseException,
                                      org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                      org.jivesoftware.smack.SmackException.NotConnectedException,
                                      java.lang.InterruptedException
        The client has edited an existing list. It updates the server content with the resulting list of privacy items. The PrivacyItem 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:
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • deletePrivacyList

        public void deletePrivacyList​(java.lang.String listName)
                               throws org.jivesoftware.smack.SmackException.NoResponseException,
                                      org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                      org.jivesoftware.smack.SmackException.NotConnectedException,
                                      java.lang.InterruptedException
        Remove a privacy list.
        Parameters:
        listName - the list that has changed its content.
        Throws:
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.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 org.jivesoftware.smack.SmackException.NoResponseException,
                                   org.jivesoftware.smack.XMPPException.XMPPErrorException,
                                   org.jivesoftware.smack.SmackException.NotConnectedException,
                                   java.lang.InterruptedException
        Check if the user's server supports privacy lists.
        Returns:
        true, if the server supports privacy lists, false otherwise.
        Throws:
        org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
        org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
        org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.