From 949933a9d1b09cef60b76f0f4e70ac7df36b6e90 Mon Sep 17 00:00:00 2001 From: Matt Tucker Date: Fri, 25 Apr 2003 20:12:56 +0000 Subject: [PATCH] Various fixes. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1898 b35dd754-fafc-0310-a699-88a17e54d16e --- .../org/jivesoftware/smack/RosterEntry.java | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/source/org/jivesoftware/smack/RosterEntry.java b/source/org/jivesoftware/smack/RosterEntry.java index 08e6c32e1..127bd8a5e 100644 --- a/source/org/jivesoftware/smack/RosterEntry.java +++ b/source/org/jivesoftware/smack/RosterEntry.java @@ -15,11 +15,21 @@ public class RosterEntry { private String user; private String name; + private RosterPacket.ItemType type; private XMPPConnection connection; - RosterEntry(String user, String name, XMPPConnection connection) { + /** + * Creates a new roster entry. + * + * @param user the user. + * @param name the nickname for the entry. + * @param type the subscription type. + * @param connection a connection to the XMPP server. + */ + RosterEntry(String user, String name, RosterPacket.ItemType type, XMPPConnection connection) { this.user = user; this.name = name; + this.type = type; this.connection = connection; } @@ -41,7 +51,16 @@ public class RosterEntry { return name; } + /** + * Sets the name associated with this entry. + * + * @param name the name. + */ public void setName(String name) { + // Do nothing if the name hasn't changed. + if (this.name.equals(name)) { + return; + } this.name = name; RosterPacket packet = new RosterPacket(); packet.setType(IQ.Type.SET); @@ -67,6 +86,16 @@ public class RosterEntry { return results.iterator(); } + /** + * Returns the roster subscription type of the entry. When the type is + * {@link RosterPacket.ItemType#NONE}, the subscription request is pending. + * + * @return the type. + */ + public RosterPacket.ItemType getType() { + return type; + } + public boolean equals(Object object) { if (this == object) { return true; @@ -81,7 +110,7 @@ public class RosterEntry { static RosterPacket.Item toRosterItem(RosterEntry entry) { RosterPacket.Item item = new RosterPacket.Item(entry.getUser(), entry.getName()); - item.setItemType(RosterPacket.ItemType.BOTH); + item.setItemType(entry.getType()); // Set the correct group names for the item. for (Iterator j=entry.getGroups(); j.hasNext(); ) { RosterGroup group = (RosterGroup)j.next();