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);
}
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);
}
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);
}
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;
}
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);
}
Aggregations