use of org.jivesoftware.smackx.privacy.packet.Privacy in project Smack by igniterealtime.
the class PrivacyListManager method declineActiveList.
/**
* Client declines the use of active lists.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public void declineActiveList() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request of the list is an privacy message with an empty list
Privacy request = new Privacy();
request.setDeclineActiveList(true);
// Send the package to the server
setRequest(request);
}
use of org.jivesoftware.smackx.privacy.packet.Privacy in project Smack by igniterealtime.
the class PrivacyListManager method getActiveList.
/**
* Answer the active privacy list. Returns <code>null</code> if there is no active list.
*
* @return the privacy list of the active list.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public PrivacyList getActiveList() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Privacy privacyAnswer = this.getPrivacyWithListNames();
String listName = privacyAnswer.getActiveName();
if (StringUtils.isNullOrEmpty(listName)) {
return null;
}
boolean isDefaultAndActive = listName != null && listName.equals(privacyAnswer.getDefaultName());
return new PrivacyList(true, isDefaultAndActive, listName, getPrivacyListItems(listName));
}
use of org.jivesoftware.smackx.privacy.packet.Privacy in project Smack by igniterealtime.
the class PrivacyProviderTest method parsePrivacyListWithFallThroughInclChildElements.
@Test
public void parsePrivacyListWithFallThroughInclChildElements() throws Exception {
// @formatter:off
final String xmlPrivacyList = "<iq type='result' id='getlist2' to='romeo@example.net/orchard'>" + "<query xmlns='jabber:iq:privacy'>" + "<list name='public'>" + "<item type='jid'" + "value='tybalt@example.com'" + "action='deny'" + "order='1'/>" + "<item action='allow' order='2'>" + "<message/>" + "<presence-in/>" + "</item>" + "</list>" + "</query>" + "</iq>";
// @formatter:on
IQ iqPrivacyList = (IQ) PacketParserUtils.parseStanza(xmlPrivacyList);
assertTrue(iqPrivacyList instanceof Privacy);
Privacy privacyList = (Privacy) iqPrivacyList;
List<PrivacyItem> pl = privacyList.getPrivacyList("public");
PrivacyItem first = pl.get(0);
assertEquals(PrivacyItem.Type.jid, first.getType());
assertEquals("tybalt@example.com", first.getValue());
assertEquals(false, first.isAllow());
assertEquals(1, first.getOrder());
PrivacyItem second = pl.get(1);
assertTrue(second.isAllow());
assertEquals(2, second.getOrder());
assertTrue(second.isFilterMessage());
assertTrue(second.isFilterPresenceIn());
assertFalse(second.isFilterPresenceOut());
assertFalse(second.isFilterIQ());
}
Aggregations