I’'m interested in using the Privacy classes to block users from sending a client messages.
After having looked at the Privacy classes I can only figure out how to positively block users, i.e. I have to know the name/jid of the user before I can block them by doing something like:
PrivacyItem item = new PrivacyItem(PrivacyRule.JID, true, 1);
I’'d like to do something different: block all users, except the ones I allow – like have a default ‘‘deny all’’ privacy rule, except users I explicity say can contact me…
I did use subscription.both as an example. This one will make sure that only users which are on your roster can talk to you.
2nd PrivacyItem: I just tried it with “null” as I don’'t want to specify something there. For “false” you may want to read the Javadoc …/javadoc/org/jivesoftware/smack/PrivacyList.html
PrivacyItem(String type, boolean allow, int order)
So allow=false means block and order=2 means that this rule will be applied before rule 3 but before rule 1.
As this rules matches and blocks everything a following rule 3 will never match.