/** * Returns a List of all <b>available</b> Presence Objects for the given bare JID. If there are no available * presences, then the empty list will be returned. * * @param bareJid the bare JID from which the presences should be retrieved. * @return available presences for the bare JID. */ public List<Presence> getAvailablePresences(BareJid bareJid) { List<Presence> allPresences = getAllPresences(bareJid); List<Presence> res = new ArrayList<>(allPresences.size()); for (Presence presence : allPresences) { if (presence.isAvailable()) { // No need to clone presence here, getAllPresences already returns clones res.add(presence); } } return res; }
if (presence.isAvailable()) { answer.add(presence.clone());
@Override public void presenceChanged(Presence presence) { if (!presence.isAvailable()) { Jid xmppAddress = presence.getFrom(); JingleSession aux = null; for (JingleSession jingleSession : jingleSessions) { if (jingleSession.getInitiator().equals(xmppAddress) || jingleSession.getResponder().equals(xmppAddress)) { aux = jingleSession; } } if (aux != null) try { aux.terminate(); } catch (Exception e) { LOGGER.log(Level.WARNING, "exception", e); } } } });
@Test public void isPresenceAvailableTest() { Presence presence = getNewPresence(); presence.setType(Presence.Type.available); assertTrue(presence.isAvailable()); presence.setType(Presence.Type.unavailable); assertFalse(presence.isAvailable()); }
if (!p.isAvailable()) { unavailable = p; continue;
/** * Returns true if the user is online and their mode is available or free to chat. * * @param presence the users presence. * @return true if the user is online and their mode is available or free to chat. */ public static boolean isAvailable(Presence presence) { return presence.isAvailable() && !presence.isAway(); }
for (RosterEntry rosterEntry : collection) { Presence presence = null; presence = roster.getPresence(rosterEntry.getUser()); if(presence.isAvailable()) { //Do Something } else{ //Do Something else } }
/** * Returns a List of all <b>available</b> Presence Objects for the given bare JID. If there are no available * presences, then the empty list will be returned. * * @param bareJid the bare JID from which the presences should be retrieved. * @return available presences for the bare JID. */ public List<Presence> getAvailablePresences(BareJid bareJid) { List<Presence> allPresences = getAllPresences(bareJid); List<Presence> res = new ArrayList<>(allPresences.size()); for (Presence presence : allPresences) { if (presence.isAvailable()) { // No need to clone presence here, getAllPresences already returns clones res.add(presence); } } return res; }
<% Roster rst = roster; rst.addRosterListener(new RosterListener() { public void entriesAdded(final Collection args) {} public void entriesDeleted(final Collection<String> addresses) {} public void entriesUpdated(final Collection<String> addresses) {} public void presenceChanged(final Presence presence) { final Presence prsence1 = presence; prsenceChanged(prsence1); if (prsence1.isAvailable()) { System.out.println("Is Available: " + presence.isAvailable()); } } }); %> <%!void prsenceChanged(Presence presence){ if(null != presence){%> <script language="javascript"> alert("hai"); </script>
private boolean isOnline() { Presence presence = roster.getPresence(participantJID.asBareJid()); return presence.isAvailable(); }
private void changePresence(String user, Presence presence){ for (Object o : addressMap.keySet()) { final JiveTreeNode node = (JiveTreeNode) o; final String nodeUser = addressMap.get(node); if (user.startsWith(nodeUser)) { if (!presence.isAvailable()) { node.setIcon(SparkRes.getImageIcon(SparkRes.CLEAR_BALL_ICON)); } else { node.setIcon(SparkRes.getImageIcon(SparkRes.GREEN_BALL)); } } } }
public void poppingUp(Object object, JPopupMenu popup) { if (object instanceof ContactItem) { ContactItem item = (ContactItem)object; String bareAddress = XmppStringUtils.parseBareJid(item.getJID()); if (!item.getPresence().isAvailable() || item.getPresence().isAway()) { if (sparkContacts.contains(bareAddress)) { popup.add(removeAction); } else { popup.add(listenAction); } } } }
public void presenceChanged(Presence presence) { if (!presence.isAvailable()) { String xmppAddress = presence.getFrom(); JingleSession aux = null; for (JingleSession jingleSession : jingleSessions) { if (jingleSession.getInitiator().equals(xmppAddress) || jingleSession.getResponder().equals(xmppAddress)) { aux = jingleSession; } } if (aux != null) try { aux.terminate(); } catch (Exception e) { e.printStackTrace(); } } } });
/** * Returns true if the user is online. * * @param jidString the jid of the user. * @return true if online. */ public static boolean isOnline(BareJid jid) { final Roster roster = Roster.getInstanceFor( SparkManager.getConnection() ); Presence presence = roster.getPresence(jid); return presence.isAvailable(); }
public void presenceChanged(Presence presence) { if (!presence.isAvailable()) { String xmppAddress = presence.getFrom(); JingleSession aux = null; for (JingleSession jingleSession : jingleSessions) { if (jingleSession.getInitiator().equals(xmppAddress) || jingleSession.getResponder().equals(xmppAddress)) { aux = jingleSession; } } if (aux != null) try { aux.terminate(); } catch (XMPPException e) { e.printStackTrace(); } } } });
public static boolean isAvailable(BareJid jid) { final Roster roster = Roster.getInstanceFor( SparkManager.getConnection() ); Presence presence = roster.getPresence(jid); return presence.isAvailable() && !presence.isAway(); }
public void reconnectionSuccessful() { Presence usersPresence = PresenceManager.getPresence(getParticipantJID()); if (usersPresence.isAvailable()) { presence = usersPresence; } SparkManager.getChatManager().getChatContainer().fireChatRoomStateUpdated(this); getChatInputEditor().setEnabled(true); getSendButton().setEnabled(true); }
@Override public void doRun() { // Check to see if the user is offline, if so, move them to the offline group. Presence userPresence = PresenceManager.getPresence(bareJID); if (userPresence.isAvailable()) { return; } item.setPresence(presence); // Check for ContactItemHandler. group.removeContactItem(item); checkGroup(group); if (offlineGroup.getContactItemByJID(item.getJid()) == null) { moveToOffline(item); offlineGroup.fireContactGroupUpdated(); } } }, timeToRun);
private void registerListener() { preferences = SettingsManager.getLocalPreferences(); // Iterate through all online users and add them to the list. ContactList contactList = SparkManager.getWorkspace().getContactList(); for (ContactGroup contactGroup : contactList.getContactGroups()) { for (ContactItem item : contactGroup.getContactItems()) { if (item != null && item.getJid() != null && item.getPresence().isAvailable()) { BareJid bareJID = item.getJid().asBareJid(); onlineUsers.add(bareJID); } } } // Add Presence Listener SparkManager.getConnection().addAsyncStanzaListener(this, new StanzaTypeFilter(Presence.class)); }
public boolean handlePresence(ContactItem item, Presence presence) { if (presence.isAvailable()) { Domainpart domain = presence.getFrom().getDomain(); Transport transport = TransportUtils.getTransport(domain.toString()); if (transport != null) { if (presence.getType() == Presence.Type.available) { item.setSpecialIcon(transport.getIcon()); } else { item.setSpecialIcon(transport.getInactiveIcon()); } return false; } } return false; }