mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-27 00:32:07 +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(); ) {
|
for (Iterator i=rosterPacket.getRosterItems(); i.hasNext(); ) {
|
||||||
RosterPacket.Item item = (RosterPacket.Item)i.next();
|
RosterPacket.Item item = (RosterPacket.Item)i.next();
|
||||||
RosterEntry entry = new RosterEntry(item.getUser(), item.getName(),
|
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 the packet is of the type REMOVE then remove the entry
|
||||||
if (RosterPacket.ItemType.REMOVE.equals(item.getItemType())) {
|
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
|
// If the entry was in then list then update its state with the new values
|
||||||
RosterEntry existingEntry =
|
RosterEntry existingEntry =
|
||||||
(RosterEntry) entries.get(entries.indexOf(entry));
|
(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
|
// If the roster entry belongs to any groups, remove it from the
|
||||||
// list of unfiled entries.
|
// list of unfiled entries.
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class RosterEntry {
|
||||||
private String user;
|
private String user;
|
||||||
private String name;
|
private String name;
|
||||||
private RosterPacket.ItemType type;
|
private RosterPacket.ItemType type;
|
||||||
|
private RosterPacket.ItemStatus status;
|
||||||
private XMPPConnection connection;
|
private XMPPConnection connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,12 +45,15 @@ public class RosterEntry {
|
||||||
* @param user the user.
|
* @param user the user.
|
||||||
* @param name the nickname for the entry.
|
* @param name the nickname for the entry.
|
||||||
* @param type the subscription type.
|
* @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.
|
* @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.user = user;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.status = status;
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,10 +97,12 @@ public class RosterEntry {
|
||||||
*
|
*
|
||||||
* @param name the nickname for the entry.
|
* @param name the nickname for the entry.
|
||||||
* @param type the subscription type.
|
* @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.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,6 +133,17 @@ public class RosterEntry {
|
||||||
return type;
|
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() {
|
public String toString() {
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
|
@ -163,6 +180,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(entry.getType());
|
item.setItemType(entry.getType());
|
||||||
|
item.setItemStatus(entry.getStatus());
|
||||||
// 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();
|
||||||
|
|
Loading…
Reference in a new issue