powered by Jive Software

Privacy

In the documentation, one of the the use cases for Privacy states that

Allowing or blocking outbound presence notifications based on JID, group, or subscription type (or globally).

This would appear to be a suitable replacement for the INVISIBLE presence mode of Smack 2 and this is what i am trying to implement as i have migrated to smack 3 and now find my code busted owing to the INVISIBLE presence mode usage. Unfortunately, I can find no examples that replicate the effect of the INVISIBLE presence mode even though privacy lists claim to perform this function.

I have also tried the setFilterPresence_in() and setFilterPresence_out() of PrivacyItem but these do not appear to make much difference.

Would someone be able to demonstrate how to accomplish the above use case?

Thanks and best wishes

Steven

P.S I have posted this message on the other smack forum as a follow up to Francisco’'s advice. Sorry for the cross posting but i am unsure which forum is the active one.

Nobody know?

I have been trying at this for some time now and still cannot achieve what i so easily achieved in Smack 2x with Presence.Mode.INVISIBLE. I realise that the invisible mode had to go but there must be a straightforward way to replicate the effect?

Privacy lists do not seem very intuitive and the very few examples that i have found on this forum do not appear to work correctly. I did not find the examples in the documentation or javadoc very informative either.

Please guys, any advice would be really appreciated

Thanks again,

Steven

Are you aware of XEP-0126? It describes the awkward hack you want to implement in great detail.

I personally am waiting for support for XEP-0186 before implementing anything in this direction. Trying to add auto-generated content to a potentially human-generated privacy list is more an AI issue than something an everyday app should implement.

Hi anlumo

Thanks for your reply.

I have tried the suggestions in XEP-0126 however i find that when i do get it working it appears that blocking presence is reciprocal. i.e user ‘‘a’’ successfully blocks his roster contacts seeing him online but user ‘‘a’’ is not informed of presence updates either.

Specifically, the aspects from XEP-0126 i am trying to implement are below in blue. for the first case, i tried the below.

java.util.List<PrivacyItem> list = new ArrayList();

PrivacyItem item = new PrivacyItem(PrivacyItem.Type.group.name(), false, 1);

item.setFilterPresence_in(true);

item.setFilterMessage(true);

item.setFilterPresence_out(false);

item.setFilterIQ(true);

list.add(item);

try {

PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(connection);

privacyManager.createPrivacyList(“invisible”, list);

privacyManager.setActiveListName(“invisible”);

} catch (XMPPException ex) {

ex.printStackTrace();

}

connection.sendPacket(presence);

this doesnt work. Would you know how to get the all the cases listed below working in smack?

Best wishes,

Steven

If a user wants to log in as invisible, a certain order of events MUST be followed. Specifically, after authenticating but before sending initial presence, the user MUST define (if necessary) and set as active a privacy list that blocks all outbound presence notifications.
Example 1. User Defines and Sets Global Invisibility Privacy Rule
… authentication / session establishment … <iq from=’‘bilbo@tolkien.lit/shire’’ type=’‘set’’ id=’‘inv1’’>
<query xmlns=’‘jabber:iq:privacy’’>
<list name=’‘invisible’’>
<item action=’‘deny’’ order=’‘1’’>
<presence-out/>
</item>
</list>
</query>
</iq> <iq from=’‘bilbo@tolkien.lit/shire’’ type=’‘set’’ id=’‘active1’’>
<query xmlns=’‘jabber:iq:privacy’’>
<active name=’‘invisible’’/>
</query>
</iq> Naturally, the user could have defined this list during a previous session and could simply set the relevant list as active when logging in, rather than defining the list on login. Both steps are shown here for completeness.
The user may now send initial presence to the server.
Example 2. User Sends Initial Presence
<presence>
<status>I’‘m not really here, you understand!</status>
</presence> Even though the user has sent initial presence, that presence information will not be broadcasted to any of the user’‘s contacts, since the active privacy list blocks all outbound presence notifications.
3.5 Become Globally Invisible
In order to become globally invisible again, the user does the following.
First, the user sends unavailable presence for broadcasting to all contacts:
Example 21. User Sends Unavailable Presence
<presence type=’‘unavailable’’/> Second, the user sets as active the global invisibility list previously defined:
Example 22. User Becomes Globally Invisible
<iq from=’‘bilbo@tolkien.lit/shire’’ type=’‘set’’ id=’‘active10’’>
<query xmlns=’‘jabber:iq:privacy’’>
<active name=’‘invisible’’/>
</query>
</iq> In order to appear globally invisible, the client MUST now re-send the user’‘s presence for broadcasting to all contacts, which the active rule will block to all contacts:
Example 23. Client Sends Available Presence
<presence>
<status>I’'m not really here, you understand!</status>
</presence>

3.5 Become Globally Invisible
In order to become globally invisible again, the user does the following.
First, the user sends unavailable presence for broadcasting to all contacts:
Example 21. User Sends Unavailable Presence
<presence type=’‘unavailable’’/> Second, the user sets as active the global invisibility list previously defined:
Example 22. User Becomes Globally Invisible
<iq from=’‘bilbo@tolkien.lit/shire’’ type=’‘set’’ id=’‘active10’’>
<query xmlns=’‘jabber:iq:privacy’’>
<active name=’‘invisible’’/>
</query>
</iq> In order to appear globally invisible, the client MUST now re-send the user’‘s presence for broadcasting to all contacts, which the active rule will block to all contacts:
Example 23. Client Sends Available Presence
<presence>
<status>I’'m not really here, you understand!</status>
</presence>

Hi Steven,

I did not use any code but I did write http://wiki.igniterealtime.org/display/SPARK/Privacy+Lists some month ago.

Create “invisible” Privacy List

This list should allow you to become nearly invisible for other xmpp users. As you are not offline you’‘ll receive messages which are sent to you and that’'s the most easy way to detect that you are online.

If you allow also IQ packets one can query your time and client version - that’'s a more easy way to tell that you are online. Blocking IQ packets will cause a lot of trouble for Spark and you will no longer be able to use a lot of its features.

LG

Hi All,

Thanks to Anlumo and it2000 for your advice. It helped me come to the solution below

However, I have+ kind of+ gotten around the problem i spoke about earlier only to bring up to other problems.

The below code sends the unavailable presence to each user on the roster. this gives the impression of the user being invisible whilst still receiving presence updates from those contacts in their roster.

Collection entries = roster.getEntries();

for (RosterEntry entry : entries) {

presence.setType(Presence.Type.unavailable);

presence.setMode(Presence.Mode.xa); //set to a mode

presence.setTo(VCard.getJabberId(entry.getName())); //my own vCard wrapper class

connection.sendPacket(presence);

}

Now, i have 2 further problems

  1. I have an option to log in as invisible. by doing this snippet directly, all my contacts appear offline even when they are not. The way around this is to send an available presence to the server and then send the unavailable presence to all of the users on the roster. This works but surely there must be a better way? The main problem with this is that it causes problem (2) which is:

  2. I am using the new Last Activity in Smack 3 to show the elapsed time since a user last logged on. I am not using the last activity message. The last activity of the user reverts to 0 seconds if they login in as invisible. clearly, this isn’'t very stealthy

These problems are linked but as of yet i have found no way to counteract them. Any help would be greatly appreciated.

Thanks and best wishes

Steven