Package org.jivesoftware.smack.packet

Examples of org.jivesoftware.smack.packet.Privacy


     * @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;
               
                // Notifies the event to the listeners.
                synchronized (listeners) {
                    for (PrivacyListListener listener : listeners) {
                        // Notifies the created or updated privacy lists
                        for (Map.Entry<String,List<PrivacyItem>> entry : privacy.getItemLists().entrySet()) {
                            String listName = entry.getKey();
                            List<PrivacyItem> items = entry.getValue();
                            if (items.isEmpty()) {
                                listener.updatedPrivacyList(listName);
                            } else {
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

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

     *
     * @return the privacy list of the active list.
     * @throws XMPPException if an error occurs.
     */
    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

     *
     * @return the privacy list of the default list.
     * @throws XMPPException if an error occurs.
     */
    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

     * @throws XMPPException if an error occurs.
     */
    private List<PrivacyItem> 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<PrivacyItem>());
       
        // Send the package to the server and get the answer
        Privacy privacyAnswer = getRequest(request);
       
        return privacyAnswer.getPrivacyList(listName);
    }
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.