Search in sources :

Example 11 with Privacy

use of org.jivesoftware.smack.packet.Privacy in project ecf by eclipse.

the class PrivacyListManager method setActiveListName.

/**
 * Set or change the active list to listName.
 *
 * @param listName the list name to set as the active one.
 * @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);
}
Also used : Privacy(org.jivesoftware.smack.packet.Privacy)

Example 12 with Privacy

use of org.jivesoftware.smack.packet.Privacy in project ecf by eclipse.

the class PrivacyListManager method getDefaultList.

/**
 * Answer the default privacy list.
 *
 * @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));
}
Also used : Privacy(org.jivesoftware.smack.packet.Privacy)

Example 13 with Privacy

use of org.jivesoftware.smack.packet.Privacy in project ecf by eclipse.

the class PrivacyProvider method parseIQ.

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);
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("query")) {
                done = true;
            }
        }
    }
    return privacy;
}
Also used : Privacy(org.jivesoftware.smack.packet.Privacy) DefaultPacketExtension(org.jivesoftware.smack.packet.DefaultPacketExtension)

Aggregations

Privacy (org.jivesoftware.smack.packet.Privacy)13 PrivacyItem (org.jivesoftware.smack.packet.PrivacyItem)3 DefaultPacketExtension (org.jivesoftware.smack.packet.DefaultPacketExtension)1 IQ (org.jivesoftware.smack.packet.IQ)1 Packet (org.jivesoftware.smack.packet.Packet)1