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 |
|---|---|
AsyncResult<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.
|
AsyncResult<Void> |
removeContact(rocks.xmpp.addr.Jid jid)
Removes a contact from the roster.
|
AsyncResult<Void> |
removeContactGroup(ContactGroup contactGroup)
Removes a contact group.
|
void |
removeRosterListener(Consumer<RosterEvent> rosterListener)
Removes a previously added roster listener.
|
AsyncResult<Void> |
renameContactGroup(ContactGroup contactGroup,
String name)
Renames a contact group.
|
AsyncResult<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.
|
AsyncResult<Void> |
storeGroupDelimiter(String groupDelimiter)
Stores the roster group delimiter in the private storage and afterwards sets it.
|
AsyncResult<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 AsyncResult<Roster> requestRoster()
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.
public final AsyncResult<Void> addContact(Contact contact, boolean requestSubscription, String status)
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.public final AsyncResult<Void> updateContact(Contact contact)
contact - The contact to update.public final AsyncResult<Void> removeContact(rocks.xmpp.addr.Jid jid)
jid - The contact's JID.public final AsyncResult<Void> renameContactGroup(ContactGroup contactGroup, String name)
contactGroup - The contact group.name - The new name.public final AsyncResult<Void> removeContactGroup(ContactGroup contactGroup)
contactGroup - The contact group.public 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 AsyncResult<Void> storeGroupDelimiter(String groupDelimiter)
groupDelimiter - The group delimiter.setGroupDelimiter(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–2017 XMPP.rocks. All rights reserved.