Search in sources :

Example 6 with Privacy

use of org.jivesoftware.smackx.privacy.packet.Privacy in project Smack by igniterealtime.

the class PrivacyListManager method deletePrivacyList.

/**
     * Remove a privacy list.
     * 
     * @param listName the list that has changed its content.
     * @throws XMPPErrorException 
     * @throws NoResponseException 
     * @throws NotConnectedException 
     * @throws InterruptedException 
     */
public void deletePrivacyList(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    // The request of the list is an privacy message with an empty list
    Privacy request = new Privacy();
    request.setPrivacyList(listName, new ArrayList<PrivacyItem>());
    // Send the package to the server
    setRequest(request);
}
Also used : Privacy(org.jivesoftware.smackx.privacy.packet.Privacy) PrivacyItem(org.jivesoftware.smackx.privacy.packet.PrivacyItem)

Example 7 with Privacy

use of org.jivesoftware.smackx.privacy.packet.Privacy in project Smack by igniterealtime.

the class PrivacyListManager method setActiveListName.

/**
     * Set or change the active list to listName.
     * 
     * @param listName the list name to set as the active one.
     * @throws XMPPErrorException 
     * @throws NoResponseException 
     * @throws NotConnectedException 
     * @throws InterruptedException 
     */
public void setActiveListName(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    // The request of the list is an privacy message with an empty list
    Privacy request = new Privacy();
    request.setActiveName(listName);
    // Send the package to the server
    setRequest(request);
}
Also used : Privacy(org.jivesoftware.smackx.privacy.packet.Privacy)

Example 8 with Privacy

use of org.jivesoftware.smackx.privacy.packet.Privacy in project Smack by igniterealtime.

the class PrivacyListManager method getDefaultList.

/**
     * Answer the default privacy list. Returns <code>null</code> if there is no default list.
     * 
     * @return the privacy list of the default list.
     * @throws XMPPErrorException 
     * @throws NoResponseException 
     * @throws NotConnectedException 
     * @throws InterruptedException 
     */
public PrivacyList getDefaultList() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    Privacy privacyAnswer = this.getPrivacyWithListNames();
    String listName = privacyAnswer.getDefaultName();
    if (StringUtils.isNullOrEmpty(listName)) {
        return null;
    }
    boolean isDefaultAndActive = listName.equals(privacyAnswer.getActiveName());
    return new PrivacyList(isDefaultAndActive, true, listName, getPrivacyListItems(listName));
}
Also used : Privacy(org.jivesoftware.smackx.privacy.packet.Privacy)

Example 9 with Privacy

use of org.jivesoftware.smackx.privacy.packet.Privacy in project Smack by igniterealtime.

the class PrivacyListManager method getPrivacyLists.

/**
     * Answer every privacy list with the allowed and blocked permissions.
     * 
     * @return an array of privacy lists.
     * @throws XMPPErrorException 
     * @throws NoResponseException 
     * @throws NotConnectedException 
     * @throws InterruptedException 
     */
public List<PrivacyList> getPrivacyLists() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    Privacy privacyAnswer = getPrivacyWithListNames();
    Set<String> names = privacyAnswer.getPrivacyListNames();
    List<PrivacyList> lists = new ArrayList<>(names.size());
    for (String listName : names) {
        boolean isActiveList = listName.equals(privacyAnswer.getActiveName());
        boolean isDefaultList = listName.equals(privacyAnswer.getDefaultName());
        lists.add(new PrivacyList(isActiveList, isDefaultList, listName, getPrivacyListItems(listName)));
    }
    return lists;
}
Also used : Privacy(org.jivesoftware.smackx.privacy.packet.Privacy) ArrayList(java.util.ArrayList)

Example 10 with Privacy

use of org.jivesoftware.smackx.privacy.packet.Privacy in project Smack by igniterealtime.

the class PrivacyListManager method declineDefaultList.

/**
     * Client declines the use of default lists.
     * @throws XMPPErrorException 
     * @throws NoResponseException 
     * @throws NotConnectedException 
     * @throws InterruptedException 
     */
public void declineDefaultList() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    // The request of the list is an privacy message with an empty list
    Privacy request = new Privacy();
    request.setDeclineDefaultList(true);
    // Send the package to the server
    setRequest(request);
}
Also used : Privacy(org.jivesoftware.smackx.privacy.packet.Privacy)

Aggregations

Privacy (org.jivesoftware.smackx.privacy.packet.Privacy)13 PrivacyItem (org.jivesoftware.smackx.privacy.packet.PrivacyItem)4 IQ (org.jivesoftware.smack.packet.IQ)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1