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