/** * A shared group of the user has been renamed. Update the existing roster items with the new * name of the shared group and make a roster push for all the available resources. * * @param users group users of the renamed group. */ void shareGroupRenamed(Collection<JID> users) { JID userJID = getUserJID(); for (JID user : users) { if (userJID.equals(user)) { continue; } RosterItem item; try { // Get the RosterItem for the *local* user to add item = getRosterItem(user); // Broadcast to all the user resources of the updated roster item broadcast(item, true); } catch (UserNotFoundException e) { // Do nothing since the contact does not exist in the user's roster. (strange case!) Log.warn( "Unexpected error while broadcasting shared group rename for user '{}'!", user, e); } } }
@Override public boolean canProbePresence(JID prober, String probee) throws UserNotFoundException { if (probee.equals(prober.getNode()) && XMPPServer.getInstance().isLocal(prober)) { return true; } RosterItem item = rosterManager.getRoster(probee).getRosterItem(prober); return item.getSubStatus() == RosterItem.SUB_FROM || item.getSubStatus() == RosterItem.SUB_BOTH; }
try { RosterItem item = roster.getRosterItem(jid); contactGroups = item.getGroups(); try { RosterItem item = roster.getRosterItem(jid); contactSubscription = item.getSubStatus();
@Override public Iterator<Element> getUserItems(String name, JID senderJID) { List<Element> answer = new ArrayList<>(); try { User user = UserManager.getInstance().getUser(name); RosterItem item = user.getRoster().getRosterItem(senderJID); // If the requesting entity is subscribed to the account's presence then // answer the user's "available resources" if (item.getSubStatus() == RosterItem.SUB_FROM || item.getSubStatus() == RosterItem.SUB_BOTH) { for (Session session : SessionManager.getInstance().getSessions(name)) { Element element = DocumentHelper.createElement("item"); element.addAttribute("jid", session.getAddress().toString()); answer.add(element); } } return answer.iterator(); } catch (UserNotFoundException e) { return answer.iterator(); } }
/** * Returns true if the the prober is allowed to see the presence of the probee. * * @param prober the user that is trying to probe the presence of another user. * @param probee the username of the uset that is being probed. * @return true if the the prober is allowed to see the presence of the probee. * @throws UserNotFoundException If the probee does not exist in the local server or the prober * is not present in the roster of the probee. */ private boolean canProbePresence(JID prober, JID probee) throws UserNotFoundException { Roster roster; roster = XMPPServer.getInstance().getRosterManager().getRoster(prober.getNode()); RosterItem item = roster.getRosterItem(probee); if (item.getSubStatus() == RosterItem.SUB_BOTH || item.getSubStatus() == RosterItem.SUB_FROM) { return true; } return false; }
try { RosterItem item = getRosterItem(deletedUser); int groupSize = item.getSharedGroups().size() + item.getInvisibleSharedGroups().size(); if (item.isOnlyShared() && groupSize == 1) {
try { Roster roster = server.getRosterManager().getRoster(nodeOwner.getNode()); RosterItem item = roster.getRosterItem(owner);
rosterItem = roster.getRosterItem(update.getTo());
try { if (roster.isRosterItem(target)) { item = roster.getRosterItem(target);
try { item = getRosterItem(addedUser);
final RosterManager rosterManager = XMPPServer.getInstance().getRosterManager(); RosterItem item = getRosterItem(deletedUser); int groupSize = item.getSharedGroups().size() + item.getInvisibleSharedGroups().size(); if (item.isOnlyShared() && groupSize == 1 &&
RosterItem rosterItem = recipientRoster.getRosterItem(sender);
if (cachedRoster.isRosterItem(item.getJID())) { RosterItem cachedItem = cachedRoster.getRosterItem(item.getJID()); cachedItem.setAsCopyOf(item); cachedRoster.updateRosterItem(cachedItem);
try { item = getRosterItem(addedUser); newItem = false; } catch (UserNotFoundException e) {
RosterItem.SubType subType = recipientRoster.getRosterItem(senderJID) .getSubStatus(); if (subType == RosterItem.SUB_FROM || subType == RosterItem.SUB_BOTH) {
try { Roster roster = rosterManager.getRoster(username); RosterItem item = roster.getRosterItem(packet.getFrom()); if (item.getSubStatus() == RosterItem.SUB_FROM || item.getSubStatus() == RosterItem.SUB_BOTH) {
/** * A shared group of the user has been renamed. Update the existing roster items with the new * name of the shared group and make a roster push for all the available resources. * * @param users group users of the renamed group. */ void shareGroupRenamed(Collection<JID> users) { JID userJID = getUserJID(); for (JID user : users) { if (userJID.equals(user)) { continue; } RosterItem item; try { // Get the RosterItem for the *local* user to add item = getRosterItem(user); // Broadcast to all the user resources of the updated roster item broadcast(item, true); } catch (UserNotFoundException e) { // Do nothing since the contact does not exist in the user's roster. (strange case!) Log.warn( "Unexpected error while broadcasting shared group rename for user '{}'!", user, e); } } }
@Override public boolean canProbePresence(JID prober, String probee) throws UserNotFoundException { if (probee.equals(prober.getNode()) && XMPPServer.getInstance().isLocal(prober)) { return true; } RosterItem item = rosterManager.getRoster(probee).getRosterItem(prober); return item.getSubStatus() == RosterItem.SUB_FROM || item.getSubStatus() == RosterItem.SUB_BOTH; }
@Override public Iterator<Element> getUserItems(String name, JID senderJID) { List<Element> answer = new ArrayList<>(); try { User user = UserManager.getInstance().getUser(name); RosterItem item = user.getRoster().getRosterItem(senderJID); // If the requesting entity is subscribed to the account's presence then // answer the user's "available resources" if (item.getSubStatus() == RosterItem.SUB_FROM || item.getSubStatus() == RosterItem.SUB_BOTH) { for (Session session : SessionManager.getInstance().getSessions(name)) { Element element = DocumentHelper.createElement("item"); element.addAttribute("jid", session.getAddress().toString()); answer.add(element); } } return answer.iterator(); } catch (UserNotFoundException e) { return answer.iterator(); } } }
/** * Returns true if the the prober is allowed to see the presence of the probee. * * @param prober the user that is trying to probe the presence of another user. * @param probee the username of the uset that is being probed. * @return true if the the prober is allowed to see the presence of the probee. * @throws UserNotFoundException If the probee does not exist in the local server or the prober * is not present in the roster of the probee. */ private boolean canProbePresence(JID prober, JID probee) throws UserNotFoundException { Roster roster; roster = XMPPServer.getInstance().getRosterManager().getRoster(prober.getNode()); RosterItem item = roster.getRosterItem(probee); if (item.getSubStatus() == RosterItem.SUB_BOTH || item.getSubStatus() == RosterItem.SUB_FROM) { return true; } return false; }