From 1cdefcc796b03c93548045e1053780e8302df115 Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Thu, 3 Nov 2005 16:53:07 +0000 Subject: [PATCH] Added RosterEntry#getStatus. SMACK-105 git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@3026 b35dd754-fafc-0310-a699-88a17e54d16e --- source/org/jivesoftware/smack/Roster.java | 5 +++-- .../org/jivesoftware/smack/RosterEntry.java | 22 +++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/source/org/jivesoftware/smack/Roster.java b/source/org/jivesoftware/smack/Roster.java index ea367d7a0..98c50a7ad 100644 --- a/source/org/jivesoftware/smack/Roster.java +++ b/source/org/jivesoftware/smack/Roster.java @@ -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. diff --git a/source/org/jivesoftware/smack/RosterEntry.java b/source/org/jivesoftware/smack/RosterEntry.java index 1698b3102..4b81a64ae 100644 --- a/source/org/jivesoftware/smack/RosterEntry.java +++ b/source/org/jivesoftware/smack/RosterEntry.java @@ -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();