powered by Jive Software

Overriding RosterItemProvider Breaks Presence?


I’ve checked out the openfire source from svn, and got it working with a MySQL instance no problem, including adding some users, friends, and seeing that friends were online when logging in using either Adium or Spark IM clients.

Now I’ve tweaked the source, in particular I’ve overriden RosterItemProvider.getItems(). I’m trying to integrate with an in-house social app which already has a list of friends for each user (i.e. roster items). All works fine except one thing:

  • user1 logs in, say in Spark, and I will see their friend user2 is offline.

  • user2 logs in, say in Adium, and I will see their status changes to online in user1’s friends list in Spark, but according to user2’s list in Adium, user1 is offline.

  • If I change the status of user1 to something else (say busy), I will see their status change in user2’s list in Adium.

Does anyone have any suggestions why user2 doesn’t see that user1 is online straight away when user2 first logs in? If I revert to using the default RosterItemProvider it all works ok again.

Cheers, any advice/ideas welcome



I found what my problem was , I was using RosterItem.SubType.getTypeFromInt(2) instead of RosterItem.SubType.getTypeFromInt(3) … doh!

For anyone interested, when you build a roster item from a custom provider, make sure to call:

RosterItem item = new RosterItem(
new JID(friendUsername + “@” + domain),
preferredUsername, null);

Having the subtype be 3 (i.e. RosterItem.SUB_BOTH), enforces the probePresence in PresenceUpdateHandler which fixed my problem:

if (item.getSubStatus() == RosterItem.SUB_TO
|| item.getSubStatus() == RosterItem.SUB_BOTH) {
presenceManager.probePresence(session.getAddress(), item.getJid());

Also, to get it working I’ve set the domain to be “”, which works but I’m not terribly sure if it’s the right thing … anybody know what’s the best way to work out what the domain would be if I installed openfire on another server?