Hi,
I am trying to implement a function which will block a perticular user / group from his rosters. I am following the code from the smack documentation and from a post in this forum.
Unfortunately my code never worked and getting some errors mention below in red color.
Below is the code snippet.
public void XMPPAddNewPrivacyList(XMPPConnection connection, String userName)
{
// Set the name of the list
String listName = “newList”;
// Create the list of PrivacyItem that will allow or // deny some privacy aspect //ArrayList privacyItems = new ArrayList(); List<PrivacyItem> privacyItems = new Vector();
PrivacyItem item = new PrivacyItem(PrivacyItem.PrivacyRule.SUBSCRIPTION_NONE, true, 2); item.setValue(userName); privacyItems.add(item);
// Get the privacy manager for the current connection. PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(connection); // Create the new list. try { privacyManager.createPrivacyList(listName,privacyItems); } catch(XMPPException e) { System.out.println("PRIVACY_ERROR: " + e); }
}
I am calling this function with the valid connection and roster as mentioned below.
XMPPAddNewPrivacyList(conn,"testuesr1@yahoo.Xemon");
Exception in thread “main”
java.lang.IllegalArgumentException: No enum const class
org.jivesoftware.smack.packet.PrivacyItem$Type.noneat java.lang.Enum.valueOf(Unknown Source) at org.jivesoftware.smack.packet.PrivacyItem$Type.valueOf(PrivacyItem.java:430) at org.jivesoftware.smack.packet.PrivacyItem$PrivacyRule.fromString(PrivacyItem.ja va:329) at org.jivesoftware.smack.packet.PrivacyItem.<init>(PrivacyItem.java:45)
- Can anhybody please correct the below code so that i can use it to block a perticular user / group?
- Also how can i unblock the blocked user / group?
- Is there any other way
Regards,
Samba