Search in sources :

Example 1 with IPresence

use of org.eclipse.ecf.presence.IPresence in project ecf by eclipse.

the class RosterWorkbenchAdapterFactory method getRosterEntryImageDescriptor.

protected ImageDescriptor getRosterEntryImageDescriptor(IRosterEntry entry) {
    IPresence p = entry.getPresence();
    if (p != null) {
        IPresence.Type pType = p.getType();
        IPresence.Mode pMode = p.getMode();
        // If type is unavailable then we're unavailable
        if (pType.equals(IPresence.Type.AVAILABLE)) {
            // available
            if (pMode.equals(IPresence.Mode.AVAILABLE))
                return getImageDescriptor(SharedImages.IMG_USER_AVAILABLE);
            else // If mode is away then we're away
            if (pMode.equals(IPresence.Mode.AWAY) || pMode.equals(IPresence.Mode.EXTENDED_AWAY))
                return getImageDescriptor(SharedImages.IMG_USER_AWAY);
            else if (pMode.equals(IPresence.Mode.DND))
                return getImageDescriptor(SharedImages.IMG_USER_DND);
        }
    }
    return getImageDescriptor(SharedImages.IMG_USER_UNAVAILABLE);
}
Also used : IPresence(org.eclipse.ecf.presence.IPresence)

Example 2 with IPresence

use of org.eclipse.ecf.presence.IPresence in project ecf by eclipse.

the class AbstractRosterMenuContributionItem method getRosterEntryImageDescriptor.

protected ImageDescriptor getRosterEntryImageDescriptor(IRosterEntry entry) {
    IPresence p = entry.getPresence();
    if (p != null) {
        IPresence.Type pType = p.getType();
        IPresence.Mode pMode = p.getMode();
        // If type is unavailable then we're unavailable
        if (pType.equals(IPresence.Type.AVAILABLE)) {
            // available
            if (pMode.equals(IPresence.Mode.AVAILABLE))
                return SharedImages.getImageDescriptor(SharedImages.IMG_USER_AVAILABLE);
            else // If mode is away then we're away
            if (pMode.equals(IPresence.Mode.AWAY) || pMode.equals(IPresence.Mode.EXTENDED_AWAY))
                return SharedImages.getImageDescriptor(SharedImages.IMG_USER_AWAY);
            else if (pMode.equals(IPresence.Mode.DND))
                return SharedImages.getImageDescriptor(SharedImages.IMG_USER_DND);
        }
    }
    return SharedImages.getImageDescriptor(SharedImages.IMG_USER_UNAVAILABLE);
}
Also used : IPresence(org.eclipse.ecf.presence.IPresence)

Example 3 with IPresence

use of org.eclipse.ecf.presence.IPresence in project ecf by eclipse.

the class AbstractRosterEntryContributionItem method isAvailable.

/**
 * Return true if given IRosterEntry has an IPresence, and it's
 * IPresence.Type and IPresence.Mode are both AVAILABLE.
 *
 * @param entry
 *            the IRosterEntry to check. If <code>null</code>,
 *            <code>false</code> will be returned.
 *
 * @return true if given <code>entry</code>'s IPresence.Mode and
 *         IPresence.Type are both AVAILABLE. <code>false</code>
 *         otherwise.
 */
protected boolean isAvailable(IRosterEntry entry) {
    if (entry == null)
        return false;
    IPresence presence = entry.getPresence();
    boolean type = (presence == null) ? false : presence.getType().equals(IPresence.Type.AVAILABLE);
    boolean mode = (presence == null) ? false : presence.getMode().equals(IPresence.Mode.AVAILABLE);
    return (type && mode);
}
Also used : IPresence(org.eclipse.ecf.presence.IPresence)

Example 4 with IPresence

use of org.eclipse.ecf.presence.IPresence in project ecf by eclipse.

the class XMPPChatRoomContainerHelper method createIPresence.

protected IPresence createIPresence(Presence xmppPresence) {
    final String status = xmppPresence.getStatus();
    final IPresence newPresence = new org.eclipse.ecf.presence.Presence(createIPresenceType(xmppPresence), status, createIPresenceMode(xmppPresence));
    return newPresence;
}
Also used : IPresence(org.eclipse.ecf.presence.IPresence) Presence(org.jivesoftware.smack.packet.Presence) IPresence(org.eclipse.ecf.presence.IPresence)

Example 5 with IPresence

use of org.eclipse.ecf.presence.IPresence in project ecf by eclipse.

the class XMPPChatRoomContainerHelper method handlePresenceEvent.

protected void handlePresenceEvent(PresenceEvent evt) {
    final Presence xmppPresence = evt.getPresence();
    final String from = canonicalizeRoomFrom(xmppPresence.getFrom());
    final IPresence newPresence = createIPresence(xmppPresence);
    final ID fromID = createUserIDFromName(from);
    if (newPresence.getType().equals(IPresence.Type.AVAILABLE)) {
        if (!chatRoomContainerParticipants.contains(fromID))
            chatRoomContainerParticipants.add(fromID);
    } else
        chatRoomContainerParticipants.remove(fromID);
    fireParticipant(fromID, newPresence);
}
Also used : IPresence(org.eclipse.ecf.presence.IPresence) Presence(org.jivesoftware.smack.packet.Presence) IPresence(org.eclipse.ecf.presence.IPresence) XMPPID(org.eclipse.ecf.provider.xmpp.identity.XMPPID) ID(org.eclipse.ecf.core.identity.ID) XMPPRoomID(org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID)

Aggregations

IPresence (org.eclipse.ecf.presence.IPresence)7 Presence (org.jivesoftware.smack.packet.Presence)4 XMPPID (org.eclipse.ecf.provider.xmpp.identity.XMPPID)2 ID (org.eclipse.ecf.core.identity.ID)1 XMPPRoomID (org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID)1