public final class RosterManager extends Manager
You can listen for roster updates (aka roster pushes) and for initial roster retrieval, by adding a Consumer.
| Modifier and Type | Method and Description |
|---|---|
void |
addContact(Contact contact,
boolean requestSubscription,
String status)
Adds a contact to the roster and optionally also sends a subscription request to it.
|
void |
addRosterListener(Consumer<RosterEvent> rosterListener)
Adds a roster listener, which will get notified, whenever the roster changes.
|
Contact |
getContact(rocks.xmpp.addr.Jid jid)
Gets a contact by its JID.
|
Collection<ContactGroup> |
getContactGroups()
Gets the contact groups.
|
Collection<Contact> |
getContacts()
Gets the contacts.
|
String |
getGroupDelimiter()
Gets the group delimiter.
|
Collection<Contact> |
getUnaffiliatedContacts()
Gets the contacts, which are not affiliated to any group.
|
boolean |
isAskForGroupDelimiter()
Indicates whether the server is asked for the roster delimiter before requesting the roster.
|
boolean |
isRetrieveRosterOnLogin()
Controls, whether the roster is automatically retrieved as soon as the user has logged in.
|
boolean |
isRosterVersioningSupported()
Indicates whether the server supports roster versioning.
|
void |
removeContact(rocks.xmpp.addr.Jid jid)
Removes a contact from the roster.
|
void |
removeContactGroup(ContactGroup contactGroup)
Removes a contact group.
|
void |
removeRosterListener(Consumer<RosterEvent> rosterListener)
Removes a previously added roster listener.
|
void |
renameContactGroup(ContactGroup contactGroup,
String name)
Renames a contact group.
|
Roster |
requestRoster()
Requests the roster from the server.
|
void |
setAskForGroupDelimiter(boolean askForGroupDelimiter)
Sets whether the server is asked for the roster delimiter before requesting the roster.
|
void |
setGroupDelimiter(String groupDelimiter)
Sets the group delimiter without storing it on the server.
|
void |
setRetrieveRosterOnLogin(boolean retrieveRosterOnLogin)
Controls, whether the roster is automatically retrieved as soon as the user has logged in.
|
void |
storeGroupDelimiter(String groupDelimiter)
Stores the roster group delimiter in the private storage and afterwards sets it.
|
void |
updateContact(Contact contact)
Updates a contact in the roster.
|
isEnabled, setEnabledpublic final Collection<Contact> getContacts()
public final Contact getContact(rocks.xmpp.addr.Jid jid)
jid - The JID.public final Collection<ContactGroup> getContactGroups()
public final Collection<Contact> getUnaffiliatedContacts()
public final void addRosterListener(Consumer<RosterEvent> rosterListener)
rosterListener - The roster listener.removeRosterListener(Consumer)public final void removeRosterListener(Consumer<RosterEvent> rosterListener)
rosterListener - The roster listener.addRosterListener(Consumer)public final boolean isRetrieveRosterOnLogin()
setRetrieveRosterOnLogin(boolean)public final void setRetrieveRosterOnLogin(boolean retrieveRosterOnLogin)
2.2. Retrieving the Roster on Login
Upon authenticating with a server and binding a resource (thus becoming a connected resource as defined in [XMPP-CORE]), a client SHOULD request the roster before sending initial presence (however, because receiving the roster is not necessarily desirable for all resources, e.g., a connection with limited bandwidth, the client's request for the roster is not mandatory).
retrieveRosterOnLogin - True, if the roster is automatically retrieved after login.public final Roster requestRoster() throws XmppException
Consumer are notified.
That means, you should first register a Consumer prior to calling this method.
Roster Versioning is supported, which means that this method checks if there's a cached version of your roster in the cache directory. If so and if Roster Versioning is supported by the server, the cached version is returned and any missing roster items are sent later by the server via roster pushes.
StanzaException - If the entity returned a stanza error.NoResponseException - If the entity did not respond.XmppExceptionpublic final void addContact(Contact contact, boolean requestSubscription, String status) throws XmppException
contact - The contact.requestSubscription - If true, the contact is also sent a subscription request.status - The optional status text, which is sent together with a subscription request. May be null.StanzaException - If the entity returned a stanza error.NoResponseException - If the entity did not respond.XmppExceptionpublic final void updateContact(Contact contact) throws XmppException
contact - The contact to update.StanzaException - If the entity returned a stanza error.NoResponseException - If the entity did not respond.XmppExceptionpublic final void removeContact(rocks.xmpp.addr.Jid jid)
throws XmppException
jid - The contact's JID.StanzaException - If the entity returned a stanza error.NoResponseException - If the entity did not respond.XmppExceptionpublic final void renameContactGroup(ContactGroup contactGroup, String name) throws XmppException
contactGroup - The contact group.name - The new name.StanzaException - If the entity returned a stanza error.NoResponseException - If the entity did not respond.XmppExceptionpublic final void removeContactGroup(ContactGroup contactGroup) throws XmppException
contactGroup - The contact group.StanzaException - If the entity returned a stanza error.NoResponseException - If the entity did not respond.XmppExceptionpublic final String getGroupDelimiter()
setGroupDelimiter(String)public final void setGroupDelimiter(String groupDelimiter)
If this is set to a non-null value, contact groups are split by the specified delimiter in order to build a nested hierarchy of groups.
groupDelimiter - The group delimiter.storeGroupDelimiter(String),
XEP-0083: Nested Roster Groupspublic final void storeGroupDelimiter(String groupDelimiter) throws XmppException
groupDelimiter - The group delimiter.StanzaException - If the entity returned a stanza error.NoResponseException - If the entity did not respond.XmppExceptionsetGroupDelimiter(String),
XEP-0083: Nested Roster Groupspublic boolean isAskForGroupDelimiter()
public void setAskForGroupDelimiter(boolean askForGroupDelimiter)
askForGroupDelimiter - True, if the server is asked for the roster delimiter before requesting the roster.requestRoster()public boolean isRosterVersioningSupported()
Copyright © 2014–2015 XMPP.rocks. All rights reserved.