Smack

org.jivesoftware.smack.packet
Class Privacy

java.lang.Object
  extended by org.jivesoftware.smack.packet.Packet
      extended by org.jivesoftware.smack.packet.IQ
          extended by org.jivesoftware.smack.packet.Privacy

public class Privacy
extends IQ

A Privacy IQ Packet, is used by the PrivacyListManager and PrivacyProvider to allow and block communications from other users. It contains the appropriate structure to suit user-defined privacy lists. Different configured Privacy packages are used in the server & manager communication in order to:

Privacy Items can handle different kind of blocking communications based on JID, group, subscription type or globally PrivacyItem

Author:
Francisco Vives

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jivesoftware.smack.packet.IQ
IQ.Type
 
Field Summary
 
Fields inherited from class org.jivesoftware.smack.packet.Packet
DEFAULT_LANGUAGE, ID_NOT_AVAILABLE
 
Constructor Summary
Privacy()
           
 
Method Summary
 boolean changeDefaultList(String newDefault)
          Sets a given privacy list as the new user default list.
 void deleteList(String listName)
          Remove the list.
 void deletePrivacyList(String listName)
          Deletes an existing privacy list.
 String getActiveName()
          Returns the name associated with the active list set for the session.
 List<PrivacyItem> getActivePrivacyList()
          Returns the active privacy list or null if none was found.
 String getChildElementXML()
          Returns the sub-element XML section of the IQ packet, or null if there isn't one.
 String getDefaultName()
          Returns the name of the default list that applies to the user as a whole.
 List<PrivacyItem> getDefaultPrivacyList()
          Returns the default privacy list or null if none was found.
 PrivacyItem getItem(String listName, int order)
          Returns the privacy item in the specified order.
 Map<String,List<PrivacyItem>> getItemLists()
          Returns the collection of privacy list that the user holds.
 List<PrivacyItem> getPrivacyList(String listName)
          Returns a specific privacy list.
 Set<String> getPrivacyListNames()
          Returns all the list names the user has defined to group restrictions.
 boolean isDeclineActiveList()
          Returns whether the receiver allows or declines the use of an active list.
 boolean isDeclineDefaultList()
          Returns whether the receiver allows or declines the use of a default list.
 void setActiveName(String activeName)
          Sets the name associated with the active list set for the session.
 List<PrivacyItem> setActivePrivacyList()
          Set the active list based on the default list.
 void setDeclineActiveList(boolean declineActiveList)
          Sets whether the receiver allows or declines the use of an active list.
 void setDeclineDefaultList(boolean declineDefaultList)
          Sets whether the receiver allows or declines the use of a default list.
 void setDefaultName(String defaultName)
          Sets the name of the default list that applies to the user as a whole.
 List setPrivacyList(String listName, List<PrivacyItem> listItem)
          Set or update a privacy list with privacy items.
 
Methods inherited from class org.jivesoftware.smack.packet.IQ
createErrorResponse, createResultIQ, getType, setType, toXML
 
Methods inherited from class org.jivesoftware.smack.packet.Packet
addExtension, deleteProperty, equals, getDefaultLanguage, getError, getExtension, getExtension, getExtensions, getExtensionsXML, getFrom, getPacketID, getProperty, getPropertyNames, getTo, getXmlns, hashCode, nextID, removeExtension, setDefaultXmlns, setError, setFrom, setPacketID, setProperty, setTo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Privacy

public Privacy()
Method Detail

setPrivacyList

public List setPrivacyList(String listName,
                           List<PrivacyItem> listItem)
Set or update a privacy list with privacy items.

Parameters:
listName - the name of the new privacy list.
listItem - the PrivacyItem that rules the list.
Returns:
the privacy List.

setActivePrivacyList

public List<PrivacyItem> setActivePrivacyList()
Set the active list based on the default list.

Returns:
the active List.

deletePrivacyList

public void deletePrivacyList(String listName)
Deletes an existing privacy list. If the privacy list being deleted was the default list then the user will end up with no default list. Therefore, the user will have to set a new default list.

Parameters:
listName - the name of the list being deleted.

getActivePrivacyList

public List<PrivacyItem> getActivePrivacyList()
Returns the active privacy list or null if none was found.

Returns:
list with PrivacyItem or null if none was found.

getDefaultPrivacyList

public List<PrivacyItem> getDefaultPrivacyList()
Returns the default privacy list or null if none was found.

Returns:
list with PrivacyItem or null if none was found.

getPrivacyList

public List<PrivacyItem> getPrivacyList(String listName)
Returns a specific privacy list.

Parameters:
listName - the name of the list to get.
Returns:
a List with PrivacyItem

getItem

public PrivacyItem getItem(String listName,
                           int order)
Returns the privacy item in the specified order.

Parameters:
listName - the name of the privacy list.
order - the order of the element.
Returns:
a List with PrivacyItem

changeDefaultList

public boolean changeDefaultList(String newDefault)
Sets a given privacy list as the new user default list.

Parameters:
newDefault - the new default privacy list.
Returns:
if the default list was changed.

deleteList

public void deleteList(String listName)
Remove the list.

Parameters:
listName - name of the list to remove.

getActiveName

public String getActiveName()
Returns the name associated with the active list set for the session. Communications will be verified against the active list.

Returns:
the name of the active list.

setActiveName

public void setActiveName(String activeName)
Sets the name associated with the active list set for the session. Communications will be verified against the active list.

Parameters:
activeName - is the name of the active list.

getDefaultName

public String getDefaultName()
Returns the name of the default list that applies to the user as a whole. Default list is processed if there is no active list set for the target session/resource to which a stanza is addressed, or if there are no current sessions for the user.

Returns:
the name of the default list.

setDefaultName

public void setDefaultName(String defaultName)
Sets the name of the default list that applies to the user as a whole. Default list is processed if there is no active list set for the target session/resource to which a stanza is addressed, or if there are no current sessions for the user. If there is no default list set, then all Privacy Items are processed.

Parameters:
defaultName - is the name of the default list.

getItemLists

public Map<String,List<PrivacyItem>> getItemLists()
Returns the collection of privacy list that the user holds. A Privacy List contains a set of rules that define if communication with the list owner is allowed or denied. Users may have zero, one or more privacy items.

Returns:
a map where the key is the name of the list and the value the collection of privacy items.

isDeclineActiveList

public boolean isDeclineActiveList()
Returns whether the receiver allows or declines the use of an active list.

Returns:
the decline status of the list.

setDeclineActiveList

public void setDeclineActiveList(boolean declineActiveList)
Sets whether the receiver allows or declines the use of an active list.

Parameters:
declineActiveList - indicates if the receiver declines the use of an active list.

isDeclineDefaultList

public boolean isDeclineDefaultList()
Returns whether the receiver allows or declines the use of a default list.

Returns:
the decline status of the list.

setDeclineDefaultList

public void setDeclineDefaultList(boolean declineDefaultList)
Sets whether the receiver allows or declines the use of a default list.

Parameters:
declineDefaultList - indicates if the receiver declines the use of a default list.

getPrivacyListNames

public Set<String> getPrivacyListNames()
Returns all the list names the user has defined to group restrictions.

Returns:
a Set with Strings containing every list names.

getChildElementXML

public String getChildElementXML()
Description copied from class: IQ
Returns the sub-element XML section of the IQ packet, or null if there isn't one. Packet extensions must be included, if any are defined.

Extensions of this class must override this method.

Specified by:
getChildElementXML in class IQ
Returns:
the child element section of the IQ XML.

Smack

Copyright © 2003-2007 Jive Software.