Search in sources :

Example 1 with Buddy

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

the class IMBuddyListController method loadRoster.

private void loadRoster(ViewMode mode) {
    this.viewMode = mode;
    buddyList.clear();
    buddyList.getGroups().clear();
    boolean offlineUsers = (viewMode == ViewMode.offlineUsers);
    buddyList.getGroups().addAll(imService.getBuddyGroups(getIdentity(), offlineUsers));
    for (BuddyGroup group : buddyList.getGroups()) {
        for (Buddy buddy : group.getBuddy()) {
            forgeBuddyLink(group, buddy);
        }
    }
    buddiesListContent.setDirty(true);
}
Also used : BuddyGroup(org.olat.instantMessaging.model.BuddyGroup) Buddy(org.olat.instantMessaging.model.Buddy)

Example 2 with Buddy

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

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

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

the class ChatController method updateRosterList.

private void updateRosterList(Long identityKey, String name, boolean anonym, boolean vip) {
    if (buddyList != null && rosterCtrl != null) {
        Buddy entry;
        if (buddyList.contains(identityKey)) {
            entry = buddyList.get(identityKey);
        } else {
            entry = imService.getBuddyById(identityKey);
            buddyList.add(entry);
        }
        entry.setVip(vip);
        entry.setAnonym(anonym);
        if (StringHelper.containsNonWhitespace(name)) {
            entry.setName(name);
        }
        rosterCtrl.updateModel();
    }
}
Also used : Buddy(org.olat.instantMessaging.model.Buddy)

Example 4 with Buddy

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

the class Roster method getBuddies.

public synchronized List<Buddy> getBuddies() {
    Set<Buddy> buddies = new HashSet<Buddy>();
    Set<Buddy> vips = new HashSet<Buddy>();
    for (Buddy entry : entries) {
        if (entry.isVip()) {
            vips.add(entry);
        }
        buddies.add(entry);
    }
    for (BuddyGroup group : groups) {
        for (Buddy entry : group.getBuddy()) {
            if (entry.isVip()) {
                vips.add(entry);
            }
            buddies.add(entry);
        }
    }
    // if vip once, vip always
    List<Buddy> orderedBuddies = new ArrayList<Buddy>(buddies.size());
    for (Buddy buddy : buddies) {
        Buddy clone = buddy.clone();
        clone.setVip(vips.contains(buddy));
        orderedBuddies.add(clone);
    }
    Collections.sort(orderedBuddies);
    return orderedBuddies;
}
Also used : ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) BuddyGroup(org.olat.instantMessaging.model.BuddyGroup) Buddy(org.olat.instantMessaging.model.Buddy) HashSet(java.util.HashSet)

Example 5 with Buddy

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

the class HomePageDisplayController 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)
 */
public void event(UserRequest ureq, Component source, Event event) {
    if (imLink == source) {
        Buddy buddy = (Buddy) imLink.getUserObject();
        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)

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