Commit 073412a4 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Fixed triggering of roster events. Many events were not being triggered.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8175 b35dd754-fafc-0310-a699-88a17e54d16e
parent 8bdad43b
......@@ -275,9 +275,7 @@ public class Roster implements Cacheable, Externalizable {
public RosterItem createRosterItem(JID user, String nickname, List<String> groups, boolean push,
boolean persistent)
throws UserAlreadyExistsException, SharedGroupException {
RosterItem item = provideRosterItem(user, nickname, groups, push, persistent);
rosterItems.put(item.getJid().toBareJID(), item);
return item;
return provideRosterItem(user, nickname, groups, push, persistent);
}
/**
......@@ -289,23 +287,7 @@ public class Roster implements Cacheable, Externalizable {
*/
public void createRosterItem(org.xmpp.packet.Roster.Item item)
throws UserAlreadyExistsException, SharedGroupException {
RosterItem rosterItem = provideRosterItem(item, true, true);
rosterItems.put(item.getJID().toBareJID(), rosterItem);
}
/**
* <p>Generate a new RosterItem for use with createRosterItem.<p>
*
* @param item The item to copy settings for the new item in this roster.
* @param push True if the new item must be push to the user.
* @param persistent True if the new roster item should be persisted to the DB.
* @return The newly created roster items ready to be stored by the Roster item's hash table.
*/
protected RosterItem provideRosterItem(org.xmpp.packet.Roster.Item item, boolean push,
boolean persistent)
throws UserAlreadyExistsException, SharedGroupException {
return provideRosterItem(item.getJID(), item.getName(),
new ArrayList<String>(item.getGroups()), push, persistent);
provideRosterItem(item.getJID(), item.getName(), new ArrayList<String>(item.getGroups()), true, true);
}
/**
......@@ -351,6 +333,8 @@ public class Roster implements Cacheable, Externalizable {
broadcast(roster);
}
rosterItems.put(user.toBareJID(), rosterItem);
// Fire event indicating that a roster item has been added
RosterEventDispatcher.contactAdded(this, rosterItem);
......@@ -368,6 +352,8 @@ public class Roster implements Cacheable, Externalizable {
if (implicitFrom.remove(item.getJid().toBareJID()) != null) {
// Ensure that the item is an explicit roster item
rosterItems.put(item.getJid().toBareJID(), item);
// Fire event indicating that a roster item has been updated
RosterEventDispatcher.contactUpdated(this, item);
}
if (rosterItems.putIfAbsent(item.getJid().toBareJID(), item) == null) {
rosterItems.remove(item.getJid().toBareJID());
......@@ -483,7 +469,9 @@ public class Roster implements Cacheable, Externalizable {
else {
// Verify if the item being removed is an implicit roster item
// that only exists due to some shared group
if (implicitFrom.remove(user.toBareJID()) != null) {
RosterItem item = getImplicitRosterItem(user);
if (item != null) {
implicitFrom.remove(user.toBareJID());
// If the contact being removed is not a local user then ACK unsubscription
if (!server.isLocal(user)) {
Presence presence = new Presence();
......@@ -492,6 +480,8 @@ public class Roster implements Cacheable, Externalizable {
presence.setType(Presence.Type.unsubscribed);
server.getPacketRouter().route(presence);
}
// Fire event indicating that a roster item has been deleted
RosterEventDispatcher.contactDeleted(this, item);
}
}
......@@ -835,6 +825,14 @@ public class Roster implements Cacheable, Externalizable {
probePresence(item.getJid());
}
}
if (newItem) {
// Fire event indicating that a roster item has been added
RosterEventDispatcher.contactAdded(this, item);
}
else {
// Fire event indicating that a roster item has been updated
RosterEventDispatcher.contactUpdated(this, item);
}
}
/**
......@@ -946,6 +944,14 @@ public class Roster implements Cacheable, Externalizable {
probePresence(item.getJid());
}
}
if (newItem) {
// Fire event indicating that a roster item has been added
RosterEventDispatcher.contactAdded(this, item);
}
else {
// Fire event indicating that a roster item has been updated
RosterEventDispatcher.contactUpdated(this, item);
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment