Java Code Examples for org.jivesoftware.smack.packet.Presence#isAway()

The following examples show how to use org.jivesoftware.smack.packet.Presence#isAway() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorkgroupManager.java    From Spark with Apache License 2.0 6 votes vote down vote up
public void handleContactItem(final ContactItem contactItem) {
    Presence presence = contactItem.getPresence();

    ExtensionElement workgroup = presence.getExtension("workgroup", "http://jivesoftware.com/protocol/workgroup");
    ExtensionElement notifyQueue = presence.getExtension("notify-queue", "http://jabber.org/protocol/workgroup");

    if (workgroup == null && notifyQueue == null) {
        return;
    }

    if (!presence.isAway()){
        contactItem.setIcon(FastpathRes.getImageIcon(FastpathRes.FASTPATH_IMAGE_16x16));
    }
    else {
        contactItem.setIcon(FastpathRes.getImageIcon(FastpathRes.FASTPATH_OFFLINE_IMAGE_16x16));
        contactItem.setStatus(null);
    }
}
 
Example 2
Source File: XMPPContactsService.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
private void handleContactResourceAvailable(XMPPContact contact, JID fullJid, Presence presence) {
  contact.setSubscribed();

  ContactStatus status;
  if (presence.isAway()) {
    status = ContactStatus.newInstance(Type.AWAY, presence.getMode().toString());
  } else {
    status = ContactStatus.TYPE_AVAILABLE;
  }
  if (contact.setResourceStatus(fullJid, status, isSarosClient(presence)))
    notifyListeners(contact, UpdateType.STATUS);
}
 
Example 3
Source File: PresenceManager.java    From Spark with Apache License 2.0 4 votes vote down vote up
public static boolean isAvailable(BareJid jid) {
    final Roster roster = Roster.getInstanceFor( SparkManager.getConnection() );
    Presence presence = roster.getPresence(jid);
    return presence.isAvailable() && !presence.isAway();
}
 
Example 4
Source File: PresenceManager.java    From Spark with Apache License 2.0 2 votes vote down vote up
/**
 * 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();
}