Search in sources :

Example 11 with Buddy

use of org.olat.instantMessaging.model.Buddy in project openolat by klemens.

the class InstantMessagingMainController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (source == available || source == dnd || source == unavailable) {
        Link link = (Link) source;
        doChangeStatus((String) link.getUserObject());
    } else if (source == onlineOfflineCount) {
        doOpenRoster(ureq);
    } else if (source instanceof Link) {
        Link link = (Link) source;
        // chat gets created by click on buddy list
        if (link.getCommand().equals(ACTION_MSG)) {
            // chats gets created by click on new message icon
            Object obj = link.getUserObject();
            if (obj instanceof Buddy) {
                Buddy buddy = (Buddy) obj;
                chatMgrCtrl.createChat(ureq, buddy);
                showNewMessageHolder.remove(buddy.getIdentityKey());
            }
            newMsgIcon.setDirty(true);
        }
    }
}
Also used : Link(org.olat.core.gui.components.link.Link) Buddy(org.olat.instantMessaging.model.Buddy)

Example 12 with Buddy

use of org.olat.instantMessaging.model.Buddy in project openolat by klemens.

the class InstantMessagingMainController method loadNotifications.

private void loadNotifications() {
    List<InstantMessageNotification> notifications = imService.getNotifications(getIdentity());
    for (InstantMessageNotification notification : notifications) {
        if (!showNewMessageHolder.contains(notification.getFromIdentityKey())) {
            showNewMessageHolder.add(notification.getFromIdentityKey());
            Buddy buddy = imService.getBuddyById(notification.getFromIdentityKey());
            createShowNewMessageLink(buddy);
        }
    }
}
Also used : InstantMessageNotification(org.olat.instantMessaging.InstantMessageNotification) Buddy(org.olat.instantMessaging.model.Buddy)

Example 13 with Buddy

use of org.olat.instantMessaging.model.Buddy in project openolat by klemens.

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)

Example 14 with Buddy

use of org.olat.instantMessaging.model.Buddy in project openolat by klemens.

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 15 with Buddy

use of org.olat.instantMessaging.model.Buddy in project openolat by klemens.

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)

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