public void parseList(XmlPullParser parser, Privacy privacy) throws Exception { 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); }
public void setStatus(byte statusId) { if (!connection.isConnected()) { return; } //TODO add full visibility list control support if (statusId == XMPPEntityAdapter.INVISIBLE_STATUS_ID) { Privacy privacy1 = new Privacy(); PrivacyItem item = new PrivacyItem(null, false, 1); item.setFilterPresence_out(true); privacy1.setPrivacyList("invisible", Arrays.asList(new PrivacyItem[]{ item })); connection.sendPacket(privacy1); Privacy privacy2 = new Privacy(); privacy2.setActiveName("invisible"); privacy2.setType(Type.SET); connection.sendPacket(privacy2); } Presence presence = getService().getEntityAdapter().userStatus2XMPPPresence(statusId); connection.sendPacket(presence); }
@Override public void createPrivacyList(String listName, List<PrivacyListItem> items) throws RemoteException { Log.d(TAG, "BEGIN createPrivacyList."); try { List<PrivacyItem> privacyItems = new ArrayList<PrivacyItem>(); PrivacyItem item = new PrivacyItem(PrivacyItem.Type.subscription.name(), true, 2); item.setValue(PrivacyRule.SUBSCRIPTION_BOTH); privacyItems.add(item); mPrivacyListManager.createPrivacyList(listName, privacyItems); } catch (XMPPException e) { Log.e(TAG, e.getMessage()); } Log.d(TAG, "END createPrivacyList."); }
/** * Adds a node to a parent on the jtree using the defaultModel * * @param node * the node that should be added. this is the childnode * @param parent * the parent node, where the node should be added to */ private void addListNode(PrivacyTreeNode node, DefaultMutableTreeNode parent) { _model.insertNodeInto(node, parent, 0); SparkPrivacyList plist = node.getPrivacyList(); PrivacyTreeNode contacts = new PrivacyTreeNode(Res.getString("privacy.node.contacts")); contacts.setisContactGroup(true); _model.insertNodeInto(contacts, node, 0); PrivacyTreeNode groups = new PrivacyTreeNode(Res.getString("privacy.node.groups")); groups.setisGroupNode(true); _model.insertNodeInto(groups, node, 0); for (PrivacyItem pI : plist.getPrivacyItems()) { if (pI.getType().equals(PrivacyItem.Type.jid)) { _model.insertNodeInto(new PrivacyTreeNode(pI), contacts, 0); } else if (pI.getType().equals(PrivacyItem.Type.group)) { _model.insertNodeInto(new PrivacyTreeNode(pI), groups, 0); } } }
public SparkPrivacyList createPrivacyList(String listName) { PrivacyItem item = new PrivacyItem(null,true,999999); ArrayList<PrivacyItem> items = new ArrayList<PrivacyItem>(); items.add(item); SparkPrivacyList sparklist = null; try { privacyManager.createPrivacyList(listName, items); privacyManager.getPrivacyList(listName).getItems().remove(item); sparklist = new SparkPrivacyList(privacyManager.getPrivacyList(listName)); _privacyLists.add(sparklist); sparklist.addSparkPrivacyListener(_presenceHandler); } catch (XMPPException e) { Log.warning("Could not create PrivacyList "+listName); e.printStackTrace(); } return sparklist; }
/** * 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 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); }
/** * 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 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); }
/** * Remove a privacy list. * * @param listName the list that has changed its content. * @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); }
protected PrivacyList(boolean isActiveList, boolean isDefaultList, String listName, List<PrivacyItem> privacyItems) { super(); this.isActiveList = isActiveList; this.isDefaultList = isDefaultList; this.listName = listName; this.items = privacyItems; }
/** * 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 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); }
/** * Remove a privacy list. * * @param listName * the list that has changed its content. * @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); }
/** * 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 org.jivesoftware.smack.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); }
/** * The client has edited an existing list. It updates the server content with the resulting * list of privacy items. The {@link org.jivesoftware.smack.packet.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 org.jivesoftware.smack.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); }
/** * Remove a privacy list. * * @param listName the list that has changed its content. * @throws org.jivesoftware.smack.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); }