1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-29 17:52:06 +01:00

Various fixes.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1898 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2003-04-25 20:12:56 +00:00 committed by mtucker
parent 571c91ebbf
commit 949933a9d1

View file

@ -15,11 +15,21 @@ public class RosterEntry {
private String user; private String user;
private String name; private String name;
private RosterPacket.ItemType type;
private XMPPConnection connection; 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.user = user;
this.name = name; this.name = name;
this.type = type;
this.connection = connection; this.connection = connection;
} }
@ -41,7 +51,16 @@ public class RosterEntry {
return name; return name;
} }
/**
* Sets the name associated with this entry.
*
* @param name the name.
*/
public void setName(String name) { public void setName(String name) {
// Do nothing if the name hasn't changed.
if (this.name.equals(name)) {
return;
}
this.name = name; this.name = name;
RosterPacket packet = new RosterPacket(); RosterPacket packet = new RosterPacket();
packet.setType(IQ.Type.SET); packet.setType(IQ.Type.SET);
@ -67,6 +86,16 @@ public class RosterEntry {
return results.iterator(); 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) { public boolean equals(Object object) {
if (this == object) { if (this == object) {
return true; return true;
@ -81,7 +110,7 @@ public class RosterEntry {
static RosterPacket.Item toRosterItem(RosterEntry entry) { static RosterPacket.Item toRosterItem(RosterEntry entry) {
RosterPacket.Item item = new RosterPacket.Item(entry.getUser(), entry.getName()); 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. // Set the correct group names for the item.
for (Iterator j=entry.getGroups(); j.hasNext(); ) { for (Iterator j=entry.getGroups(); j.hasNext(); ) {
RosterGroup group = (RosterGroup)j.next(); RosterGroup group = (RosterGroup)j.next();