Package org.jivesoftware.smack.packet

Examples of org.jivesoftware.smack.packet.Privacy


     *
     * @return an array of privacy lists.
     * @throws XMPPException if an error occurs.
     */
    public PrivacyList[] getPrivacyLists() throws XMPPException {
        Privacy privacyAnswer = this.getPrivacyWithListNames();
        Set<String> names = privacyAnswer.getPrivacyListNames();
        PrivacyList[] lists = new PrivacyList[names.size()];
        boolean isActiveList;
        boolean isDefaultList;
        int index=0;
        for (String listName : names) {
            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

     * @throws XMPPException if an error occurs.
   */
  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

     * @throws XMPPException if an error occurs.
   */
  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

     * @throws XMPPException if an error occurs.
     */
    public void updatePrivacyList(String listName, List<PrivacyItem> 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

     * @throws XMPPException if an error occurs.
   */
  public void deletePrivacyList(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<PrivacyItem>());

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

  public PrivacyProvider() {
  }

  public IQ parseIQ(XmlPullParser parser) throws Exception {
        Privacy privacy = new Privacy();
        /* privacy.addExtension(PacketParserUtils.parsePacketExtension(parser
                .getName(), parser.getNamespace(), parser)); */
        privacy.addExtension(new DefaultPacketExtension(parser.getName(), parser.getNamespace()));
        boolean done = false;
        while (!done) {
            int eventType = parser.next();
            if (eventType == XmlPullParser.START_TAG) {
                if (parser.getName().equals("active")) {
                  String activeName = parser.getAttributeValue("", "name");
                  if (activeName == null) {
                    privacy.setDeclineActiveList(true);
                  } else {
                    privacy.setActiveName(activeName);
                  }
                }
                else if (parser.getName().equals("default")) {
                  String defaultName = parser.getAttributeValue("", "name");
                  if (defaultName == null) {
                    privacy.setDeclineDefaultList(true);
                  } else {
                    privacy.setDefaultName(defaultName);
                  }
                }
                else if (parser.getName().equals("list")) {
                    parseList(parser, privacy);
                }
View Full Code Here

                if (packet == null || packet.getError() != null) {
                    return;
                }
                // The packet is correct.
                Privacy privacy = (Privacy) packet;
               
                // Prepare the information before starting the notification
                int listNameSize = privacy.getItemLists().size();
                Object[] listItemsPairs = privacy.getItemLists().entrySet().toArray();
              
                // Notifies the event to the listeners.
                synchronized (listeners) {
                    for (Iterator i = listeners.iterator(); i.hasNext();) {
                        PrivacyListListener listener = (PrivacyListListener) i.next();
View Full Code Here

       
        // Send create & join packet.
        connection.sendPacket(requestPrivacy);
       
        // Wait up to a certain number of seconds for a reply.
        Privacy privacyAnswer =
            (Privacy) response.nextResult(SmackConfiguration.getPacketReplyTimeout());
       
        // Stop queuing results
        response.cancel();

        // Interprete the result and answer the privacy only if it is valid
        if (privacyAnswer == null) {
            throw new XMPPException("No response from server.");
        }
        else if (privacyAnswer.getError() != null) {
            throw new XMPPException(privacyAnswer.getError());
        }
        return privacyAnswer;
  }
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.