From 48611ac2f53269fe58441d3a0ceb4c4c898dd902 Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Thu, 25 Sep 2003 13:00:48 +0000 Subject: [PATCH] updates roster entries with remote notifications git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2106 b35dd754-fafc-0310-a699-88a17e54d16e --- source/org/jivesoftware/smack/Roster.java | 5 +++++ source/org/jivesoftware/smack/RosterEntry.java | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/source/org/jivesoftware/smack/Roster.java b/source/org/jivesoftware/smack/Roster.java index 9abd8e92a..2d7a3e2b3 100644 --- a/source/org/jivesoftware/smack/Roster.java +++ b/source/org/jivesoftware/smack/Roster.java @@ -547,6 +547,11 @@ public class Roster { // Make sure the entry is in the entry list. if (!entries.contains(entry)) { entries.add(entry); + } else { + // 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()); } // 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 4ed4d590f..77b36134f 100644 --- a/source/org/jivesoftware/smack/RosterEntry.java +++ b/source/org/jivesoftware/smack/RosterEntry.java @@ -68,6 +68,17 @@ public class RosterEntry { connection.sendPacket(packet); } + /** + * Updates the state of the entry with the new values. + * + * @param name the nickname for the entry. + * @param type the subscription type. + */ + void updateState(String name, RosterPacket.ItemType type) { + this.name = name; + this.type = type; + } + /** * Returns an iterator for all the roster groups that this entry belongs to. *