Package org.jivesoftware.smack.packet

Examples of org.jivesoftware.smack.packet.Privacy


   * @return a Privacy with the list names.
   */
  private Privacy getPrivacyWithListNames() throws XMPPException {
   
    // The request of the list is an empty privacy message
    Privacy request = new Privacy();
   
    // Send the package to the server and get the answer
    return getRequest(request);
  }
View Full Code Here


     * Answer the active privacy list.
     *
     * @return the {@see PrivacyList} of the active list.
     */
    public PrivacyList getActiveList() throws XMPPException {
        Privacy privacyAnswer = this.getPrivacyWithListNames();
        String listName = privacyAnswer.getActiveName();
        boolean isDefaultAndActive = privacyAnswer.getActiveName() != null
                && privacyAnswer.getDefaultName() != null
                && privacyAnswer.getActiveName().equals(
                privacyAnswer.getDefaultName());
        return new PrivacyList(true, isDefaultAndActive, listName, getPrivacyListItems(listName));
    }
View Full Code Here

     * Answer the default privacy list.
     *
     * @return the {@see PrivacyList} of the default list.
     */
    public PrivacyList getDefaultList() throws XMPPException {
        Privacy privacyAnswer = this.getPrivacyWithListNames();
        String listName = privacyAnswer.getDefaultName();
        boolean isDefaultAndActive = privacyAnswer.getActiveName() != null
                && privacyAnswer.getDefaultName() != null
                && privacyAnswer.getActiveName().equals(
                privacyAnswer.getDefaultName());
        return new PrivacyList(isDefaultAndActive, true, listName, getPrivacyListItems(listName));
    }
View Full Code Here

     * @return a list of {@link PrivacyItem} under the list listName.
     */
    private List getPrivacyListItems(String listName) throws XMPPException {
       
        // The request of the list is an privacy message with an empty list
        Privacy request = new Privacy();
        request.setPrivacyList(listName, new ArrayList());
       
        // Send the package to the server and get the answer
        Privacy privacyAnswer = getRequest(request);
       
        return privacyAnswer.getPrivacyList(listName);
    }
View Full Code Here

     * Answer every privacy list with the allowed and blocked permissions.
     *
     * @return a List of {@link PrivacyList}.
     */
    public PrivacyList[] getPrivacyLists() throws XMPPException {
        Privacy privacyAnswer = this.getPrivacyWithListNames();
        Set names = privacyAnswer.getPrivacyListNames();
        PrivacyList[] lists = new PrivacyList[names.size()];
        String listName;
        boolean isActiveList;
        boolean isDefaultList;
        int index=0;
        for (Iterator iter = names.iterator(); iter.hasNext();) {
            listName = (String) iter.next();
            isActiveList = listName.equals(privacyAnswer.getActiveName());
            isDefaultList = listName.equals(privacyAnswer.getDefaultName());
            lists[index] = new PrivacyList(isActiveList, isDefaultList,
                    listName, getPrivacyListItems(listName));
            index = index + 1;
        }
        return lists;
View Full Code Here

   * @exception XMPPException if the request or the answer failed, it raises an exception.
   */
  public void setActiveListName(String listName) throws XMPPException {
   
    // 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);
  }
View Full Code Here

   * Client declines the use of active lists.
   */
  public void declineActiveList() throws XMPPException {
   
    // 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);
  }
View Full Code Here

   * @exception XMPPException if the request or the answer failed, it raises an exception.
   */
  public void setDefaultListName(String listName) throws XMPPException {
   
    // The request of the list is an privacy message with an empty list
    Privacy request = new Privacy();
    request.setDefaultName(listName);
   
    // Send the package to the server
    setRequest(request);
  }
View Full Code Here

   * Client declines the use of default lists.
   */
  public void declineDefaultList() throws XMPPException {
   
    // 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);
  }
View Full Code Here

     * @param privacyItems a List with every {@link PrivacyItem} in the list.
     */
    public void updatePrivacyList(String listName, List privacyItems) throws XMPPException {

        // Build the privacy package to add or update the new list
        Privacy request = new Privacy();
        request.setPrivacyList(listName, privacyItems);

        // Send the package to the server
        setRequest(request);
    }
View Full Code Here

TOP

Related Classes of org.jivesoftware.smack.packet.Privacy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.