|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jivesoftware.smack.Roster
public class Roster
Represents a user's roster, which is the collection of users a person receives presence updates for. Roster items are categorized into groups for easier management.
Others users may attempt to subscribe to this user using a subscription request. Three modes are supported for handling these requests:
accept_all
-- accept all subscription requests.reject_all
-- reject all subscription requests.manual
-- manually process all subscription requests.
XMPPConnection.getRoster()
Nested Class Summary | |
---|---|
static class |
Roster.SubscriptionMode
An enumeration for the subscription mode options. |
Method Summary | |
---|---|
void |
addRosterListener(RosterListener rosterListener)
Adds a listener to this roster. |
void |
connectionClosed()
Notification that the connection was closed normally or that the reconnection process has been aborted. |
void |
connectionClosedOnError(Exception e)
Notification that the connection was closed due to an exception. |
boolean |
contains(String user)
Returns true if the specified XMPP address is an entry in the roster. |
void |
createEntry(String user,
String name,
String[] groups)
Creates a new roster entry and presence subscription. |
RosterGroup |
createGroup(String name)
Creates a new group. |
static Roster.SubscriptionMode |
getDefaultSubscriptionMode()
Returns the default subscription processing mode to use when a new Roster is created. |
Collection<RosterEntry> |
getEntries()
Returns an unmodifiable collection of all entries in the roster, including entries that don't belong to any groups. |
RosterEntry |
getEntry(String user)
Returns the roster entry associated with the given XMPP address or null if the user is not an entry in the roster. |
int |
getEntryCount()
Returns a count of the entries in the roster. |
RosterGroup |
getGroup(String name)
Returns the roster group with the specified name, or null if the group doesn't exist. |
int |
getGroupCount()
Returns the number of the groups in the roster. |
Collection<RosterGroup> |
getGroups()
Returns an unmodiable collections of all the roster groups. |
Presence |
getPresence(String user)
Returns the presence info for a particular user, or null if the user is unavailable (offline) or if no presence information is available, such as when you are not subscribed to the user's presence updates. |
Presence |
getPresenceResource(String userResource)
Returns the presence info for a particular user's resource, or null if the user is unavailable (offline) or if no presence information is available, such as when you are not subscribed to the user's presence updates. |
Iterator<Presence> |
getPresences(String user)
Returns an iterator (of Presence objects) for all the user's current presences or null if the user is unavailable (offline) or if no presence information is available, such as when you are not subscribed to the user's presence updates. |
Roster.SubscriptionMode |
getSubscriptionMode()
Returns the subscription processing mode, which dictates what action Smack will take when subscription requests from other users are made. |
Collection<RosterEntry> |
getUnfiledEntries()
Returns an unmodifiable collection for the unfiled roster entries. |
int |
getUnfiledEntryCount()
Returns a count of the unfiled entries in the roster. |
void |
reconnectingIn(int seconds)
The connection will retry to reconnect in the specified number of seconds. |
void |
reconnectionFailed(Exception e)
An attempt to connect to the server has failed. |
void |
reconnectionSuccessful()
The connection has reconnected successfully to the server. |
void |
reload()
Reloads the entire roster from the server. |
void |
removeEntry(RosterEntry entry)
Removes a roster entry from the roster. |
void |
removeRosterListener(RosterListener rosterListener)
Removes a listener from this roster. |
static void |
setDefaultSubscriptionMode(Roster.SubscriptionMode subscriptionMode)
Sets the default subscription processing mode to use when a new Roster is created. |
void |
setSubscriptionMode(Roster.SubscriptionMode subscriptionMode)
Sets the subscription processing mode, which dictates what action Smack will take when subscription requests from other users are made. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Roster.SubscriptionMode getDefaultSubscriptionMode()
Roster.SubscriptionMode.accept_all
.
public static void setDefaultSubscriptionMode(Roster.SubscriptionMode subscriptionMode)
Roster.SubscriptionMode.accept_all
.
subscriptionMode
- the default subscription mode to use for new Rosters.public Roster.SubscriptionMode getSubscriptionMode()
Roster.SubscriptionMode.accept_all
.
If using the manual mode, a PacketListener should be registered that
listens for Presence packets that have a type of
Presence.Type.subscribe
.
public void setSubscriptionMode(Roster.SubscriptionMode subscriptionMode)
Roster.SubscriptionMode.accept_all
.
If using the manual mode, a PacketListener should be registered that
listens for Presence packets that have a type of
Presence.Type.subscribe
.
subscriptionMode
- the subscription mode.public void reload()
public void addRosterListener(RosterListener rosterListener)
rosterListener
- a roster listener.public void removeRosterListener(RosterListener rosterListener)
rosterListener
- a roster listener.public RosterGroup createGroup(String name)
Note: you must add at least one entry to the group for the group to be kept after a logout/login. This is due to the way that XMPP stores group information.
name
- the name of the group.
public void createEntry(String user, String name, String[] groups) throws XMPPException
user
- the user. (e.g. johndoe@jabber.org)name
- the nickname of the user.groups
- the list of group names the entry will belong to, or null if the
the roster entry won't belong to a group.
XMPPException
- if an XMPP exception occurs.public void removeEntry(RosterEntry entry) throws XMPPException
entry
- a roster entry.
XMPPException
- if an XMPP error occurs.public int getEntryCount()
public Collection<RosterEntry> getEntries()
public int getUnfiledEntryCount()
public Collection<RosterEntry> getUnfiledEntries()
public RosterEntry getEntry(String user)
user
- the XMPP address of the user (eg "jsmith@example.com"). The address could be
in any valid format (e.g. "domain/resource", "user@domain" or "user@domain/resource").
public boolean contains(String user)
user
- the XMPP address of the user (eg "jsmith@example.com"). The address could be
in any valid format (e.g. "domain/resource", "user@domain" or "user@domain/resource").
public RosterGroup getGroup(String name)
name
- the name of the group.
public int getGroupCount()
public Collection<RosterGroup> getGroups()
public Presence getPresence(String user)
If the user has several presences (one for each resource) then answer the presence with the highest priority.
Note that presence information is received asynchronously. So, just after logging
in to the server, presence values for users in the roster might be null
even if they are actually online. In other words, the value returned by this
method should only be treated as a snapshot in time, and may not accurately reflect
other user's presence instant by instant. If you need to track presence over time,
such as when showing a visual representation of the roster, consider using a
RosterListener
.
user
- a fully qualified xmpp ID. The address could be in any valid format (e.g.
"domain/resource", "user@domain" or "user@domain/resource").
public Presence getPresenceResource(String userResource)
userResource
- a fully qualified xmpp ID including a resource.
public Iterator<Presence> getPresences(String user)
user
- a fully qualified xmpp ID, e.g. jdoe@example.com
public void connectionClosed()
ConnectionListener
connectionClosed
in interface ConnectionListener
public void connectionClosedOnError(Exception e)
ConnectionListener
connectionClosedOnError
in interface ConnectionListener
e
- the exception.public void reconnectingIn(int seconds)
ConnectionListener
reconnectingIn
in interface ConnectionListener
seconds
- remaining seconds before attempting a reconnection.public void reconnectionFailed(Exception e)
ConnectionListener
reconnectionFailed
in interface ConnectionListener
e
- the exception that caused the reconnection to fail.public void reconnectionSuccessful()
ConnectionListener
reconnectionSuccessful
in interface ConnectionListener
|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |