Java 类org.jivesoftware.smack.PrivacyList 实例源码

项目:Beem    文件:PrivacyListManagerAdapter.java   
@Override
   public List<String> getPrivacyLists() throws RemoteException {
Log.d(TAG, "BEGIN getPrivacyLists.");
List<String> res = new ArrayList<String>();
try {
    PrivacyList[] registeredPrivacyLists = mPrivacyListManager.getPrivacyLists();
    Log.d(TAG, "> registeredPrivacyLists size: " + registeredPrivacyLists.length);
    if (registeredPrivacyLists.length > 0) {
    for (int i = 0; i < registeredPrivacyLists.length; i++) {
        res.add(registeredPrivacyLists[i].toString());
        Log.d(TAG, "> " + res.get(i) + " added.");
    }
    }
} catch (XMPPException e) {
    Log.e(TAG, e.getMessage());
}
Log.d(TAG, "END getPrivacyLists.");
return res;
   }
项目:beem-fork-xmpp    文件:PrivacyListManagerAdapter.java   
@Override
   public List<String> getPrivacyLists() throws RemoteException {
Log.d(TAG, "BEGIN getPrivacyLists.");
List<String> res = new ArrayList<String>();
try {
    PrivacyList[] registeredPrivacyLists = mPrivacyListManager.getPrivacyLists();
    Log.d(TAG, "> registeredPrivacyLists size: " + registeredPrivacyLists.length);
    if (registeredPrivacyLists.length > 0) {
    for (int i = 0; i < registeredPrivacyLists.length; i++) {
        res.add(registeredPrivacyLists[i].toString());
        Log.d(TAG, "> " + res.get(i) + " added.");
    }
    }
} catch (XMPPException e) {
    Log.e(TAG, e.getMessage());
}
Log.d(TAG, "END getPrivacyLists.");
return res;
   }
项目:spark-svn-mirror    文件:PrivacyManager.java   
private void initializePrivacyLists()
{
    try {
        PrivacyList[] lists = privacyManager.getPrivacyLists();

        for (PrivacyList list: lists)
        {
           SparkPrivacyList sparkList = new SparkPrivacyList(list);
           sparkList.addSparkPrivacyListener(_presenceHandler);
           _privacyLists.add(sparkList);
        }  
    } catch (XMPPException e) {
        Log.error("Could not load PrivacyLists");
        e.printStackTrace();
    }

    if(hasDefaultList())
    {
        setListAsActive(getDefaultList().getListName());
    }
}
项目:Beem    文件:PrivacyListManagerAdapter.java   
@Override
   public String getActivePrivacyList() throws RemoteException {
try {
    PrivacyList activePrivacyList = mPrivacyListManager.getActiveList();
    return activePrivacyList.toString();
} catch (XMPPException e) {
    Log.e(TAG, e.getMessage());
}
return null;
   }
项目:Beem    文件:PrivacyListManagerAdapter.java   
@Override
   public List<String> getBlockedGroupsByList(String listName) throws RemoteException {
List<String> blockedGroups = new ArrayList<String>();
try {
    PrivacyList pL = mPrivacyListManager.getPrivacyList(listName);
    for (PrivacyItem pI : pL.getItems()) {
    if (pI.getType().equals(PrivacyItem.Type.group) && !pI.isAllow())
        blockedGroups.add(pI.getValue());
    }
} catch (XMPPException e) {
    Log.e(TAG, e.getMessage());
}
return blockedGroups;
   }
项目:Beem    文件:PrivacyListManagerAdapter.java   
@Override
   public List<String> getBlockedUsersByList(String listName) throws RemoteException {
List<String> blockedUsers = new ArrayList<String>();
try {
    PrivacyList pL = mPrivacyListManager.getPrivacyList(listName);
    for (PrivacyItem pI : pL.getItems()) {
    if (pI.getType().equals(PrivacyItem.Type.jid) && !pI.isAllow())
        blockedUsers.add(pI.getValue());
    }
} catch (XMPPException e) {
    Log.e(TAG, e.getMessage());
}
return blockedUsers;
   }
项目:Beem    文件:PrivacyListManagerAdapter.java   
@Override
   public String getDefaultPrivacyList() throws RemoteException {
try {
    PrivacyList defaultPrivacyList = mPrivacyListManager.getDefaultList();
    return defaultPrivacyList.toString();
} catch (XMPPException e) {
    Log.e(TAG, e.getMessage());
}
return null;
   }
项目:beem-fork-xmpp    文件:PrivacyListManagerAdapter.java   
@Override
   public String getActivePrivacyList() throws RemoteException {
try {
    PrivacyList activePrivacyList = mPrivacyListManager.getActiveList();
    return activePrivacyList.toString();
} catch (XMPPException e) {
    Log.e(TAG, e.getMessage());
}
return null;
   }
项目:beem-fork-xmpp    文件:PrivacyListManagerAdapter.java   
@Override
   public List<String> getBlockedGroupsByList(String listName) throws RemoteException {
List<String> blockedGroups = new ArrayList<String>();
try {
    PrivacyList pL = mPrivacyListManager.getPrivacyList(listName);
    for (PrivacyItem pI : pL.getItems()) {
    if (pI.getType().equals(PrivacyItem.Type.group) && !pI.isAllow())
        blockedGroups.add(pI.getValue());
    }
} catch (XMPPException e) {
    Log.e(TAG, e.getMessage());
}
return blockedGroups;
   }
项目:beem-fork-xmpp    文件:PrivacyListManagerAdapter.java   
@Override
   public List<String> getBlockedUsersByList(String listName) throws RemoteException {
List<String> blockedUsers = new ArrayList<String>();
try {
    PrivacyList pL = mPrivacyListManager.getPrivacyList(listName);
    for (PrivacyItem pI : pL.getItems()) {
    if (pI.getType().equals(PrivacyItem.Type.jid) && !pI.isAllow())
        blockedUsers.add(pI.getValue());
    }
} catch (XMPPException e) {
    Log.e(TAG, e.getMessage());
}
return blockedUsers;
   }
项目:beem-fork-xmpp    文件:PrivacyListManagerAdapter.java   
@Override
   public String getDefaultPrivacyList() throws RemoteException {
try {
    PrivacyList defaultPrivacyList = mPrivacyListManager.getDefaultList();
    return defaultPrivacyList.toString();
} catch (XMPPException e) {
    Log.e(TAG, e.getMessage());
}
return null;
   }
项目:spark-svn-mirror    文件:SparkPrivacyList.java   
/**
 * Action associated with the items, it MUST be filled and will allow or deny
 * the communication by default
 */


public SparkPrivacyList(PrivacyList list)
{
    _listName = list.toString();
    _myPrivacyList = list;
    _isActive = _myPrivacyList.isActiveList();
    _isDefault = _myPrivacyList.isDefaultList();
    loadItems();
}
项目:Smack    文件:PrivacyTest.java   
/**
 * Check when a client set more than one list.
 */
public void testCreateTwoLists() {
    try {
        String listName1 = "1testCreateTwoLists";
        String listName2 = "2testCreateTwoLists";
        String groupName = "testCreateTwoListsGroup";

        PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(getConnection(0));
        PrivacyClient client = new PrivacyClient(privacyManager);
        privacyManager.addListener(client);

        // Add a list
        ArrayList<PrivacyItem> items = new ArrayList<PrivacyItem>();
        PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid.name(), true, 1);
        item.setValue(getConnection(0).getUser());
        items.add(item);
        privacyManager.createPrivacyList(listName1, items);

        Thread.sleep(500);

        // Add the another list
        ArrayList<PrivacyItem> itemsList2 = new ArrayList<PrivacyItem>();
        item = new PrivacyItem(PrivacyItem.Type.group.name(), false, 2);
        item.setValue(groupName);
        item.setFilterMessage(true);
        itemsList2.add(item);
        privacyManager.createPrivacyList(listName2, itemsList2);

        Thread.sleep(500);

        // Assert the list composition.
        PrivacyList[] privacyLists = privacyManager.getPrivacyLists();
        PrivacyList receivedList1 = null;
        PrivacyList receivedList2 = null;
        for (PrivacyList privacyList : privacyLists) {
            if (listName1.equals(privacyList.toString())) {
                receivedList1 = privacyList;
            }
            if (listName2.equals(privacyList.toString())) {
                receivedList2 = privacyList;
            }
        }


        PrivacyItem receivedItem;
        // Assert on the list 1
        assertNotNull(receivedList1);
        assertEquals(1, receivedList1.getItems().size());
        receivedItem = receivedList1.getItems().get(0);
        assertEquals(1, receivedItem.getOrder());
        assertEquals(PrivacyItem.Type.jid, receivedItem.getType());
        assertEquals(true, receivedItem.isAllow());
        assertEquals(getConnection(0).getUser(), receivedItem.getValue());

        // Assert on the list 2
        assertNotNull(receivedList2);
        assertEquals(1, receivedList2.getItems().size());
        receivedItem = receivedList2.getItems().get(0);
        assertEquals(2, receivedItem.getOrder());
        assertEquals(PrivacyItem.Type.group, receivedItem.getType());
        assertEquals(groupName, receivedItem.getValue());
        assertEquals(false, receivedItem.isAllow());
        assertEquals(groupName, receivedItem.getValue());
        assertEquals(false, receivedItem.isFilterEverything());
        assertEquals(true, receivedItem.isFilterMessage());
        assertEquals(false, receivedItem.isFilterPresence_in());
        assertEquals(false, receivedItem.isFilterPresence_out());

        privacyManager.deletePrivacyList(listName1);
        privacyManager.deletePrivacyList(listName2);
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
}
项目:java-bells    文件:PrivacyTest.java   
/**
 * Check when a client set more than one list.
 */
public void testCreateTwoLists() {
    try {
        String listName1 = "1testCreateTwoLists";
        String listName2 = "2testCreateTwoLists";
        String groupName = "testCreateTwoListsGroup";

        PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(getConnection(0));
        PrivacyClient client = new PrivacyClient(privacyManager);
        privacyManager.addListener(client);

        // Add a list
        ArrayList<PrivacyItem> items = new ArrayList<PrivacyItem>();
        PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid.name(), true, 1);
        item.setValue(getConnection(0).getUser());
        items.add(item);
        privacyManager.createPrivacyList(listName1, items);

        Thread.sleep(500);

        // Add the another list
        ArrayList<PrivacyItem> itemsList2 = new ArrayList<PrivacyItem>();
        item = new PrivacyItem(PrivacyItem.Type.group.name(), false, 2);
        item.setValue(groupName);
        item.setFilterMessage(true);
        itemsList2.add(item);
        privacyManager.createPrivacyList(listName2, itemsList2);

        Thread.sleep(500);

        // Assert the list composition.
        PrivacyList[] privacyLists = privacyManager.getPrivacyLists();
        PrivacyList receivedList1 = null;
        PrivacyList receivedList2 = null;
        for (PrivacyList privacyList : privacyLists) {
            if (listName1.equals(privacyList.toString())) {
                receivedList1 = privacyList;
            }
            if (listName2.equals(privacyList.toString())) {
                receivedList2 = privacyList;
            }
        }


        PrivacyItem receivedItem;
        // Assert on the list 1
        assertNotNull(receivedList1);
        assertEquals(1, receivedList1.getItems().size());
        receivedItem = receivedList1.getItems().get(0);
        assertEquals(1, receivedItem.getOrder());
        assertEquals(PrivacyItem.Type.jid, receivedItem.getType());
        assertEquals(true, receivedItem.isAllow());
        assertEquals(getConnection(0).getUser(), receivedItem.getValue());

        // Assert on the list 2
        assertNotNull(receivedList2);
        assertEquals(1, receivedList2.getItems().size());
        receivedItem = receivedList2.getItems().get(0);
        assertEquals(2, receivedItem.getOrder());
        assertEquals(PrivacyItem.Type.group, receivedItem.getType());
        assertEquals(groupName, receivedItem.getValue());
        assertEquals(false, receivedItem.isAllow());
        assertEquals(groupName, receivedItem.getValue());
        assertEquals(false, receivedItem.isFilterEverything());
        assertEquals(true, receivedItem.isFilterMessage());
        assertEquals(false, receivedItem.isFilterPresence_in());
        assertEquals(false, receivedItem.isFilterPresence_out());

        privacyManager.deletePrivacyList(listName1);
        privacyManager.deletePrivacyList(listName2);
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
}