Java 类org.jivesoftware.smackx.privacy.packet.PrivacyItem 实例源码

项目:Smack    文件:PrivacyProvider.java   
private static void parseList(XmlPullParser parser, Privacy privacy) throws XmlPullParserException, IOException, SmackException {
       boolean done = false;
       String listName = parser.getAttributeValue("", "name");
       ArrayList<PrivacyItem> items = new ArrayList<PrivacyItem>();
       while (!done) {
           int eventType = parser.next();
           if (eventType == XmlPullParser.START_TAG) {
               if (parser.getName().equals("item")) {
                items.add(parseItem(parser));
               }
           }
           else if (eventType == XmlPullParser.END_TAG) {
               if (parser.getName().equals("list")) {
                   done = true;
               }
           }
       }

       privacy.setPrivacyList(listName, items);
}
项目:maxs    文件:XMPPPrivacyList.java   
private final void setPrivacyList(XMPPConnection connection) throws NoResponseException,
        XMPPErrorException, NotConnectedException, InterruptedException {
    List<PrivacyItem> list = new ArrayList<PrivacyItem>(PRIVACY_LIST.size() + 10);
    list.addAll(PRIVACY_LIST);

    // Whitelist all JIDs of the own service, e.g. conference.service.com, proxy.service.com
    for (Item i : ServiceDiscoveryManager.getInstanceFor(connection)
            .discoverItems(connection.getServiceName()).getItems()) {
        PrivacyItem allow = new PrivacyItem(Type.jid, i.getEntityID(), true, list.size() + 1);
        list.add(allow);
    }

    // This is an ugly workaround for XMPP servers that apply privacy lists also to stanzas
    // originating from themselves. For example http://issues.igniterealtime.org/browse/OF-724
    // Because there are such services in the wild and XEP-0016 is not clear on that topic, we
    // explicitly have to add a JID rule that allows stanzas from the service
    PrivacyItem allowService = new PrivacyItem(Type.jid, connection.getServiceName(), true,
            list.size() + 1);
    list.add(allowService);

    mPrivacyListManager.createPrivacyList(PRIVACY_LIST_NAME, list);
    mPrivacyListManager.setDefaultListName(PRIVACY_LIST_NAME);
}
项目:Smack    文件:PrivacyListManager.java   
/**
 * Answer the privacy list items under listName with the allowed and blocked permissions.
 * 
 * @param listName the name of the list to get the allowed and blocked permissions.
 * @return a list of privacy items under the list listName.
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */ 
private List<PrivacyItem> getPrivacyListItems(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException  {
    assert StringUtils.isNotEmpty(listName);
    // 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);
}
项目:Smack    文件:PrivacyListManager.java   
/**
 * Remove a privacy list.
 * 
    * @param listName the list that has changed its content.
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */ 
public void deletePrivacyList(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException {
    // 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);
}
项目:Smack    文件:PrivacyList.java   
protected PrivacyList(boolean isActiveList, boolean isDefaultList,
        String listName, List<PrivacyItem> privacyItems) {
    super();
    this.isActiveList = isActiveList;
    this.isDefaultList = isDefaultList;
    this.listName = listName;
    this.items = privacyItems;
}
项目:Smack    文件:PrivacyProvider.java   
private static void parseItemChildElements(XmlPullParser parser, PrivacyItem privacyItem) throws XmlPullParserException, IOException {
    final int initialDepth = parser.getDepth();

    outerloop: while (true) {
        int eventType = parser.next();
        switch (eventType) {
        case XmlPullParser.START_TAG:
            String name = parser.getName();
            switch (name) {
            case "iq":
                privacyItem.setFilterIQ(true);
                break;
            case "message":
                privacyItem.setFilterMessage(true);
                break;
            case "presence-in":
                privacyItem.setFilterPresenceIn(true);
                break;
            case "presence-out":
                privacyItem.setFilterPresenceOut(true);
                break;
            }
            break;
        case XmlPullParser.END_TAG:
            if (parser.getDepth() == initialDepth) {
                break outerloop;
            }
        }
    }
}
项目:Smack    文件:PrivacyList.java   
public List<PrivacyItem> getItems() {
    return items;
}
项目:Smack    文件:PrivacyListManager.java   
/**
 * The client has edited an existing list. It updates the server content with the resulting 
 * list of privacy items. The {@link PrivacyItem} list MUST contain all elements in the 
 * list (not the "delta").
 * 
 * @param listName the list that has changed its content.
 * @param privacyItems a List with every privacy item in the list.
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */ 
public void updatePrivacyList(String listName, List<PrivacyItem> privacyItems) throws NoResponseException, XMPPErrorException, NotConnectedException  {
    // 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);
}
项目:Smack    文件:PrivacyListManager.java   
/**
 * The client has created a new list. It send the new one to the server.
 * 
    * @param listName the list that has changed its content.
    * @param privacyItems a List with every privacy item in the list.
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */ 
public void createPrivacyList(String listName, List<PrivacyItem> privacyItems) throws NoResponseException, XMPPErrorException, NotConnectedException  {
    updatePrivacyList(listName, privacyItems);
}
项目:Smack    文件:PrivacyListListener.java   
/**
 * Set or update a privacy list with PrivacyItem.
 *
 * @param listName the name of the new or updated privacy list.
 * @param listItem the PrivacyItems that rules the list.
 */
public void setPrivacyList(String listName, List<PrivacyItem> listItem);