mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-26 16:22:06 +01:00
Added RosterEntry#getStatus. SMACK-105
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@3026 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
90ada2fc42
commit
1cdefcc796
2 changed files with 23 additions and 4 deletions
|
@ -671,7 +671,7 @@ public class Roster {
|
|||
for (Iterator i=rosterPacket.getRosterItems(); i.hasNext(); ) {
|
||||
RosterPacket.Item item = (RosterPacket.Item)i.next();
|
||||
RosterEntry entry = new RosterEntry(item.getUser(), item.getName(),
|
||||
item.getItemType(), connection);
|
||||
item.getItemType(), item.getItemStatus(), connection);
|
||||
|
||||
// If the packet is of the type REMOVE then remove the entry
|
||||
if (RosterPacket.ItemType.REMOVE.equals(item.getItemType())) {
|
||||
|
@ -700,7 +700,8 @@ public class Roster {
|
|||
// If the entry was in then list then update its state with the new values
|
||||
RosterEntry existingEntry =
|
||||
(RosterEntry) entries.get(entries.indexOf(entry));
|
||||
existingEntry.updateState(entry.getName(), entry.getType());
|
||||
existingEntry
|
||||
.updateState(entry.getName(), entry.getType(), entry.getStatus());
|
||||
}
|
||||
// If the roster entry belongs to any groups, remove it from the
|
||||
// list of unfiled entries.
|
||||
|
|
|
@ -36,6 +36,7 @@ public class RosterEntry {
|
|||
private String user;
|
||||
private String name;
|
||||
private RosterPacket.ItemType type;
|
||||
private RosterPacket.ItemStatus status;
|
||||
private XMPPConnection connection;
|
||||
|
||||
/**
|
||||
|
@ -44,12 +45,15 @@ public class RosterEntry {
|
|||
* @param user the user.
|
||||
* @param name the nickname for the entry.
|
||||
* @param type the subscription type.
|
||||
* @param status the subscription status (related to subscriptions pending to be approbed).
|
||||
* @param connection a connection to the XMPP server.
|
||||
*/
|
||||
RosterEntry(String user, String name, RosterPacket.ItemType type, XMPPConnection connection) {
|
||||
RosterEntry(String user, String name, RosterPacket.ItemType type,
|
||||
RosterPacket.ItemStatus status, XMPPConnection connection) {
|
||||
this.user = user;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.status = status;
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
|
@ -93,10 +97,12 @@ public class RosterEntry {
|
|||
*
|
||||
* @param name the nickname for the entry.
|
||||
* @param type the subscription type.
|
||||
* @param status the subscription status (related to subscriptions pending to be approbed).
|
||||
*/
|
||||
void updateState(String name, RosterPacket.ItemType type) {
|
||||
void updateState(String name, RosterPacket.ItemType type, RosterPacket.ItemStatus status) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -127,6 +133,17 @@ public class RosterEntry {
|
|||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the roster subscription status of the entry. When the status is
|
||||
* RosterPacket.ItemStatus.SUBSCRIPTION_PENDING, the contact has to answer the subscription
|
||||
* request.
|
||||
*
|
||||
* @return the status.
|
||||
*/
|
||||
public RosterPacket.ItemStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
if (name != null) {
|
||||
|
@ -163,6 +180,7 @@ public class RosterEntry {
|
|||
static RosterPacket.Item toRosterItem(RosterEntry entry) {
|
||||
RosterPacket.Item item = new RosterPacket.Item(entry.getUser(), entry.getName());
|
||||
item.setItemType(entry.getType());
|
||||
item.setItemStatus(entry.getStatus());
|
||||
// Set the correct group names for the item.
|
||||
for (Iterator j=entry.getGroups(); j.hasNext(); ) {
|
||||
RosterGroup group = (RosterGroup)j.next();
|
||||
|
|
Loading…
Reference in a new issue