Search in sources :

Example 21 with Buddy

use of org.olat.instantMessaging.model.Buddy in project OpenOLAT by OpenOLAT.

the class GroupController method doIm.

private void doIm(UserRequest ureq, Identity identity) {
    Buddy buddy = imService.getBuddyById(identity.getKey());
    OpenInstantMessageEvent e = new OpenInstantMessageEvent(ureq, buddy);
    ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, InstantMessagingService.TOWER_EVENT_ORES);
}
Also used : OpenInstantMessageEvent(org.olat.instantMessaging.OpenInstantMessageEvent) Buddy(org.olat.instantMessaging.model.Buddy)

Example 22 with Buddy

use of org.olat.instantMessaging.model.Buddy in project OpenOLAT by OpenOLAT.

the class GroupController method doIm.

private void doIm(UserRequest ureq, Identity identity) {
    Buddy buddy = imService.getBuddyById(identity.getKey());
    OpenInstantMessageEvent e = new OpenInstantMessageEvent(ureq, buddy);
    ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(e, InstantMessagingService.TOWER_EVENT_ORES);
}
Also used : OpenInstantMessageEvent(org.olat.instantMessaging.OpenInstantMessageEvent) Buddy(org.olat.instantMessaging.model.Buddy)

Example 23 with Buddy

use of org.olat.instantMessaging.model.Buddy in project OpenOLAT by OpenOLAT.

the class InstantMessagingServiceImpl method getBuddiesListenTo.

@Override
public List<Buddy> getBuddiesListenTo(OLATResourceable chatResource) {
    List<RosterEntryView> roster = rosterDao.getRosterView(chatResource, 0, -1);
    List<Buddy> buddies = new ArrayList<Buddy>();
    if (roster != null) {
        for (RosterEntryView entry : roster) {
            String name = entry.isAnonym() ? entry.getNickName() : entry.getFullName();
            String status = getOnlineStatus(entry.getIdentityKey());
            buddies.add(new Buddy(entry.getIdentityKey(), entry.getUsername(), name, entry.isAnonym(), entry.isVip(), status));
        }
    }
    return buddies;
}
Also used : RosterEntryView(org.olat.instantMessaging.model.RosterEntryView) ArrayList(java.util.ArrayList) Buddy(org.olat.instantMessaging.model.Buddy)

Example 24 with Buddy

use of org.olat.instantMessaging.model.Buddy in project OpenOLAT by OpenOLAT.

the class InstantMessagingServiceImpl method getBuddyById.

@Override
public Buddy getBuddyById(Long identityKey) {
    IdentityShort identity = securityManager.loadIdentityShortByKey(identityKey);
    String fullname = userManager.getUserDisplayName(identity);
    String status;
    boolean online = isOnline(identityKey);
    if (online) {
        String prefStatus = prefsDao.getStatus(identityKey);
        if (prefStatus == null) {
            status = Presence.available.name();
        } else {
            status = prefStatus;
        }
    } else {
        status = Presence.unavailable.name();
    }
    return new Buddy(identity.getKey(), identity.getName(), fullname, false, status);
}
Also used : IdentityShort(org.olat.basesecurity.IdentityShort) Buddy(org.olat.instantMessaging.model.Buddy)

Example 25 with Buddy

use of org.olat.instantMessaging.model.Buddy in project OpenOLAT by OpenOLAT.

the class InstantMessagingServiceImpl method addBuddyToGroupList.

private void addBuddyToGroupList(ContactViewExtended member, Identity me, Map<Long, BuddyGroup> groupMap, List<BuddyGroup> groups, Map<Long, String> identityKeyToStatus, boolean offlineUsers) {
    if (me != null && me.getKey().equals(member.getIdentityKey())) {
        return;
    }
    String status = identityKeyToStatus.get(member.getIdentityKey());
    if (status == null) {
        boolean online = isOnline(member.getIdentityKey());
        if (online) {
            status = prefsDao.getStatus(member.getIdentityKey());
            if (status == null) {
                status = Presence.available.name();
            }
        } else {
            status = Presence.unavailable.name();
        }
        identityKeyToStatus.put(member.getIdentityKey(), status);
    }
    if (offlineUsers || Presence.available.name().equals(status)) {
        BuddyGroup group = groupMap.get(member.getGroupKey());
        if (group == null) {
            group = new BuddyGroup(member.getGroupKey(), member.getGroupName());
            groupMap.put(member.getGroupKey(), group);
            groups.add(group);
        }
        boolean vip = GroupRoles.coach.name().equals(member.getRole());
        String name = userManager.getUserDisplayName(member);
        group.addBuddy(new Buddy(member.getIdentityKey(), member.getUsername(), name, false, vip, status));
    }
}
Also used : BuddyGroup(org.olat.instantMessaging.model.BuddyGroup) Buddy(org.olat.instantMessaging.model.Buddy)

Aggregations

Buddy (org.olat.instantMessaging.model.Buddy)36 OpenInstantMessageEvent (org.olat.instantMessaging.OpenInstantMessageEvent)16 BuddyGroup (org.olat.instantMessaging.model.BuddyGroup)6 ArrayList (java.util.ArrayList)4 Link (org.olat.core.gui.components.link.Link)4 HashSet (java.util.HashSet)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 Test (org.junit.Test)2 UserSessionView (org.olat.admin.sysinfo.model.UserSessionView)2 IdentityShort (org.olat.basesecurity.IdentityShort)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2 SyntheticUserRequest (org.olat.core.gui.util.SyntheticUserRequest)2 Identity (org.olat.core.id.Identity)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 UserSession (org.olat.core.util.UserSession)2 InstantMessageNotification (org.olat.instantMessaging.InstantMessageNotification)2 RosterEntryView (org.olat.instantMessaging.model.RosterEntryView)2