Class Privacy
java.lang.Object
org.jivesoftware.smack.packet.Stanza
org.jivesoftware.smack.packet.IQ
org.jivesoftware.smackx.privacy.packet.Privacy
- All Implemented Interfaces:
Element
,IqView
,NamedElement
,StanzaView
,TopLevelStreamElement
,XmlElement
,XmlLangElement
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 and manager communication in order to:
- Retrieving one's privacy lists.
- Adding, removing, and editing one's privacy lists.
- Setting, changing, or declining active lists.
- Setting, changing, or declining the default list (i.e., the list that is active by default).
PrivacyItem
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jivesoftware.smack.packet.IQ
IQ.IQChildElementXmlStringBuilder, IQ.ResponseType, IQ.Type
-
Field Summary
Fields inherited from class org.jivesoftware.smack.packet.IQ
IQ_ELEMENT, QUERY_ELEMENT
Fields inherited from class org.jivesoftware.smack.packet.Stanza
DEFAULT_LANGUAGE, ITEM, language, TEXT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
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.Returns the name associated with the active list set for the session.Returns the active privacy list ornull
if none was found.Returns the name of the default list that applies to the user as a whole.Returns the default privacy list ornull
if none was found.protected IQ.IQChildElementXmlStringBuilder
This method must be overwritten by IQ subclasses to create their child content.Returns the privacy item in the specified order.Returns the collection of privacy list that the user holds.getPrivacyList
(String listName) Returns a specific privacy list.Returns all the list names the user has defined to group restrictions.boolean
Returns whether the receiver allows or declines the use of an active list.boolean
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.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.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, createErrorResponse, createResultIQ, getChildElementName, getChildElementNamespace, getChildElementQName, getChildElementXML, getElementName, getType, setType, toString, toXML
Methods inherited from class org.jivesoftware.smack.packet.Stanza
addCommonAttributes, addExtension, addExtensions, appendErrorIfExists, getDefaultLanguage, getError, getExtension, getExtension, getExtensionElement, getExtensions, getExtensions, getExtensions, getExtensions, getExtensionsMap, getFrom, getLanguage, getNamespace, getStanzaId, getTo, hasExtension, hasExtension, hasStanzaIdSet, logCommonAttributes, overrideExtension, removeExtension, setError, setFrom, setNewStanzaId, setStanzaId, setTo, throwIfNoStanzaId
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jivesoftware.smack.packet.IqView
isRequestIQ, isResponseIQ
Methods inherited from interface org.jivesoftware.smack.packet.StanzaView
getError, getExtension, getExtension, getExtensions, getExtensions, getExtensions, getFrom, getStanzaId, getTo, hasExtension, hasExtension, hasExtension
Methods inherited from interface org.jivesoftware.smack.packet.XmlElement
getQName
-
Field Details
-
ELEMENT
- See Also:
-
NAMESPACE
- See Also:
-
-
Constructor Details
-
Privacy
public Privacy()
-
-
Method Details
-
setPrivacyList
Set or update a privacy list with privacy items.- Parameters:
listName
- the name of the new privacy list.listItem
- thePrivacyItem
that rules the list.- Returns:
- the privacy List.
-
setActivePrivacyList
Set the active list based on the default list.- Returns:
- the active List.
-
deletePrivacyList
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
Returns the active privacy list ornull
if none was found.- Returns:
- list with
PrivacyItem
ornull
if none was found.
-
getDefaultPrivacyList
Returns the default privacy list ornull
if none was found.- Returns:
- list with
PrivacyItem
ornull
if none was found.
-
getPrivacyList
Returns a specific privacy list.- Parameters:
listName
- the name of the list to get.- Returns:
- a List with
PrivacyItem
-
getItem
-
getItem
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
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
Remove the list.- Parameters:
listName
- name of the list to remove.
-
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
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
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
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
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
Returns whether the receiver allows or declines the use of an active list.- Returns:
- the decline status of the list.
-
setDeclineActiveList
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
Returns whether the receiver allows or declines the use of a default list.- Returns:
- the decline status of the list.
-
setDeclineDefaultList
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
Returns all the list names the user has defined to group restrictions.- Returns:
- a Set with Strings containing every list names.
-
getIQChildElementBuilder
protected IQ.IQChildElementXmlStringBuilder getIQChildElementBuilder(IQ.IQChildElementXmlStringBuilder buf) Description copied from class:IQ
This method must be overwritten by IQ subclasses to create their child content. It is important you don't use the builder to add the final end tag. This will be done automatically byIQ.IQChildElementXmlStringBuilder
after eventual existingExtensionElement
s have been added.For example to create an IQ with a extra attribute and an additional child element
<iq to='foo@example.org' id='123'> <bar xmlns='example:bar' extraAttribute='blaz'> <extraElement>elementText</extraElement> </bar> </iq>
getIQChildElementBuilder
looks like// The builder 'xml' will already have the child element and the 'xmlns' attribute added // So the current builder state is "<bar xmlns='example:bar'" xml.attribute("extraAttribute", "blaz"); xml.rightAngleBracket(); xml.element("extraElement", "elementText"); // Do not close the 'bar' attribute by calling xml.closeElement('bar')
xml.attribute("myAttribute", "myAttributeValue"); xml.setEmptyElement();
If your IQ does not contain any attributes or child elements (besidesExtensionElement
s), consider sub-classingSimpleIQ
instead.- Specified by:
getIQChildElementBuilder
in classIQ
- Parameters:
buf
- a pre-created builder which already has the child element and the 'xmlns' attribute set.- Returns:
- the build to create the IQ child content.
-