ed12
November 7, 2006, 11:56am
#1
Hi,
I’‘m using the PrivacyItem class in the Smack dev libraries (2006-08-24) and I’'ve got the following code in my application:
import static org.jivesoftware.smack.packet.PrivacyItem.PrivacyRule.JID;
PrivacyItem item = new PrivacyItem(JID, true, 1);
item.setValue(participant);
list.add(item);
/code
I’‘ve just downloaded a newer version of the Smack dev libs (2006-11-05) and now this won’‘t compile. Has there been changes to the API in the dev libs? If so, how can I use the existing functionality I have in the new version(s) of the libs? (i.e. filter on JID’'s).
Sorry if I’‘ve missed anything, I’'ve been away from Smack for a month or so.
Thanks,
Ed.
Hi ed,
The PrivacyItem implementation changed using the enum facilities of the java 5.
The new way to create a new Item is:
PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid.name (), true, 1);
Let me know if it works.
Regards,
Francisco
ed12
November 8, 2006, 12:08pm
#3
Hi Francisco,
Thanks for the reply. Unfortunately when I try and compile the line you gave (with 2006-11-07 dev libs) the compile fails with the message:
org.jivesoftware.smack.packet.PrivacyItem.Type has protected access in org.jivesoftware.smack.packet.PrivacyItem
If this is to be used in this way, should this really be protected access?
Or is there another way to do this? I’'m stumped!
Thanks again.
Ed.
Message was edited by: eds (s/reaply/reply).
Hi Ed,
You are right, the PrivacyItem.Type must be declared public.
Now you will find the new version in the SVN with the fix.
The class org.jivesoftware.smack.packet.PrivacyTest has lot of examples about privacy usage.
Regards,
Francisco