powered by Jive Software

Howto get RosterEntry online-status after denying presence_in via privacy lists

Hi!

I am using tho following code to deny presence_in notifications to save power (my client is running on a mobile device):

List privacyItems = new ArrayList();

PrivacyItem itemBoth = new PrivacyItem(“subscription”, false, 1);

itemBoth.setFilterPresence_in(true);

itemBoth.setValue(“both”);

privacyItems.add(itemBoth);

privacyManager.createPrivacyList(listName, privacyItems);

privacyManager.setActiveListName(listname);

This prohibits presence-sending to my client.

When the user opens the Roster I want to update all RosterEntries to their current state. I tried the following:

Roster roster = connection,getRoster();

Collection entries = roster.getEntries();

for (RosterEntry entry : entries) {

Presence presence = roster.getPresence(entry.getUser());

}

This does not work. The state in the presence seems also to rely on the denied presence packets.

  1. Is there a better way to have the server NOT send any presence-notifications for the time the user is not looking at the Roster?

  2. How can I poll the current state of some user in my Roster?

Regards,

Dirk

I think I found a way to probe for presences.

When I send a presence with type “probe” (after patching Smack to allow this) to all users in my Roster I get updated presences.

This seems a bit too much traffic. Is there another way to get updated on presence?

Regards,

Dirk

Install a RosterListener

Hi chihiro2009!

I am already using a RosterListener. The Problem is that the denied Presences are not send when the privacy list is deinstalled. So the server just does not send the presences during the time when the privacy list is active. Let me give an example with time stamps:

0000s my client logs in

0001s my client gets Roster with current entries

0002s User A logs into his server

0003s my client receives presence about the availability of User A

0007s my client installs privacy list that denies presence_in

0010s User A is disconnects from his server and his server sends away-presence to my server

0010s my server DOES NOT send presence to me (because of the privacy list that denies it)

0020s my client removes the privacy list

0020s my server still does not send the presence showing that User A is unavailable

0030s User A is available again

0031s User As server sends presence to my server

0032s my client receives a presence

So between 0020s and 0032s my client is not aware that user A is offline. If I had only one user in my Roster I could just probe for presence after deinstalling the privacy list. But then I would not have to use a privacy list in the first place. I have about 200 Users in my Roster receiving all those presences with the Handset in my pocket were I do not even care if someone goes idle/away it drains the battery.