Issue #2798 - Fix user presence messages and settings

Peer review comments

Change-Id: I615edc12a7fe93540b5e62cf673b92829cac3dfa

Former-commit-id: b087558dce4e19596c93d47e986af50fae806a74
This commit is contained in:
Mike Duff 2014-03-05 09:58:16 -06:00
parent 2eea0b9205
commit 9c873e6dd9
6 changed files with 93 additions and 36 deletions

View file

@ -21,10 +21,8 @@ package com.raytheon.uf.viz.collaboration.comm.provider.info;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Presence;
@ -51,6 +49,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
* Jan 28, 2014 2698 bclement removed getInfo, added methods to replace
* Jan 30, 2014 2698 bclement changed UserId to VenueParticipant, getSubject never returns null
* Feb 13, 2014 2751 bclement changed to use VenueParticipant handle instead of alias
* Mar 05, 2014 2798 mpduff Get Presence from MUC.
*
* </pre>
*
@ -61,8 +60,6 @@ public class Venue implements IVenue {
private final MultiUserChat muc;
private Map<String, Presence> presenceMap = new HashMap<String, Presence>();
public Venue(XMPPConnection conn, MultiUserChat muc) {
this.muc = muc;
}
@ -80,7 +77,7 @@ public class Venue implements IVenue {
@Override
public Presence getPresence(VenueParticipant user) {
Presence presence = presenceMap.get(user.getHandle());
Presence presence = muc.getOccupantPresence(user.getFQName());
if (presence == null) {
presence = new Presence(Type.unavailable);
presence.setMode(Mode.away);
@ -88,10 +85,6 @@ public class Venue implements IVenue {
return presence;
}
public void handlePresenceUpdated(VenueParticipant fromID, Presence presence) {
presenceMap.put(fromID.getHandle(), presence);
}
/*
* (non-Javadoc)
*

View file

@ -100,6 +100,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
* Feb 18, 2014 2751 bclement Fixed history message 'from' type
* Feb 18, 2014 2751 bclement log privilege changes instead of spamming chat window
* Feb 24, 2014 2751 bclement added isRoomOwner()
* Mar 05, 2014 2798 mpduff Don't handle Presence, get from MUC instead..
*
* </pre>
*
@ -107,7 +108,6 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
* @version 1.0
* @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueParticipantEvent
* @see com.raytheon.uf.viz.collaboration.comm.provider.TextMessage
* @see com.raytheon.uf.viz.collaboration.comm.provider.CollaborationMessage
*/
public class VenueSession extends BaseSession implements IVenueSession {
@ -519,7 +519,7 @@ public class VenueSession extends BaseSession implements IVenueSession {
logParticipantEvent(participant, ParticipantEventType.UPDATED,
"is now an admin.");
}
private void logParticipantEvent(String participant,
ParticipantEventType type, String desciption) {
StringBuilder builder = new StringBuilder();
@ -537,6 +537,7 @@ public class VenueSession extends BaseSession implements IVenueSession {
VenueParticipantEvent event = new VenueParticipantEvent(user,
type);
event.setEventDescription(desciption);
postEvent(event);
}
@ -551,7 +552,6 @@ public class VenueSession extends BaseSession implements IVenueSession {
String fromID = p.getFrom();
VenueParticipant user = IDConverter.convertFromRoom(muc,
fromID);
venue.handlePresenceUpdated(user, p);
postEvent(new VenueParticipantEvent(user, p,
ParticipantEventType.PRESENCE_UPDATED));
}

View file

@ -146,6 +146,7 @@ import com.raytheon.viz.ui.views.CaveFloatingView;
* Feb 12, 2014 2799 bclement fixed double click chat not working for roster entries
* Feb 24, 2014 2632 mpduff Add Notifier actions.
* Mar 05, 2014 2837 bclement separate rename action for groups, added more icons
* Mar 05, 2014 2798 mpduff Add getter for displayFeedAction.
*
* </pre>
*
@ -950,4 +951,11 @@ public class CollaborationGroupView extends CaveFloatingView implements
}
});
}
/**
* @return the displayFeedAction
*/
public DisplayFeedAction getDisplayFeedAction() {
return displayFeedAction;
}
}

View file

@ -43,7 +43,8 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 1, 2012 rferrel Initial creation
* Mar 1, 2012 rferrel Initial creation
* Mar 05, 2014 2798 mpduff Don't create a new DisplayFeedAction
*
* </pre>
*
@ -58,6 +59,9 @@ public class CollaborationGroupAction extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
// this opens the collaboration group view
try {
// If connection is null then user has not logged in
boolean initialExecutionFlag = CollaborationConnection
.getConnection() == null;
new LoginAction().run();
CollaborationConnection connection = CollaborationConnection
.getConnection();
@ -66,15 +70,18 @@ public class CollaborationGroupAction extends AbstractHandler {
return event;
}
CaveWorkbenchPageManager.getActiveInstance().showView(
CollaborationGroupView.ID);
CollaborationGroupView view = (CollaborationGroupView) CaveWorkbenchPageManager
.getActiveInstance().showView(CollaborationGroupView.ID);
// if autojoin is selected (to join the default room)
if (Activator.getDefault().getPreferenceStore()
.getBoolean(CollabPrefConstants.AUTO_JOIN)) {
DisplayFeedAction displayFeed = new DisplayFeedAction();
displayFeed.setChecked(true);
displayFeed.run();
// Is this is the first log in
if (initialExecutionFlag) {
// if autojoin is selected (to join the default room)
if (Activator.getDefault().getPreferenceStore()
.getBoolean(CollabPrefConstants.AUTO_JOIN)) {
DisplayFeedAction action = view.getDisplayFeedAction();
action.setChecked(true);
action.run();
}
}
} catch (PartInitException e) {
statusHandler.handle(Priority.PROBLEM,

View file

@ -20,7 +20,10 @@
package com.raytheon.uf.viz.collaboration.ui.session;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
@ -66,6 +69,7 @@ import com.raytheon.uf.viz.core.icon.IconUtil;
* Feb 13, 2014 2751 bclement VenueParticipant refactor
* Feb 18, 2014 2631 mpduff Add processJoinAlert()
* Feb 19, 2014 2751 bclement add change color icon, fix NPE when user cancels change color
* Mar 05, 2014 2798 mpduff Changed how messages are processed for the feed view.
*
* </pre>
*
@ -91,6 +95,12 @@ public class SessionFeedView extends SessionView {
private List<SiteColor> colors;
/**
* Set of users logged in.
*/
private final Set<String> enabledUsers = Collections
.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
/**
*
*/
@ -382,17 +392,7 @@ public class SessionFeedView extends SessionView {
@Override
protected void sendParticipantSystemMessage(VenueParticipant participant,
String message) {
Presence presence = session.getVenue().getPresence(participant);
Object siteObj = presence.getProperty(SiteConfigInformation.SITE_NAME);
String siteName = siteObj == null ? "" : siteObj.toString();
// only show sites you care about
if (enabledSites.contains(siteName)
|| userEnabledSites.contains(siteName)) {
super.sendParticipantSystemMessage(participant, message);
} else {
usersTable.setInput(session.getVenue().getParticipants());
usersTable.refresh();
}
super.sendParticipantSystemMessage(participant, message);
}
/*
@ -406,8 +406,56 @@ public class SessionFeedView extends SessionView {
@Override
protected void participantPresenceUpdated(VenueParticipant participant,
Presence presence) {
setColorForSite(participant, presence);
super.participantPresenceUpdated(participant, presence);
usersTable.refresh();
// Verify we have properties
if (!presence.getPropertyNames().contains(
SiteConfigInformation.SITE_NAME)) {
return;
}
Object roleObj = presence.getProperty(SiteConfigInformation.ROLE_NAME);
String roleName = roleObj == null ? "" : roleObj.toString();
Object siteObj = presence.getProperty(SiteConfigInformation.SITE_NAME);
String siteName = siteObj == null ? "" : siteObj.toString();
String user = participant.getName();
// only show sites you care about
if (enabledSites.contains(siteName)
|| userEnabledSites.contains(siteName)) {
if (!enabledUsers.contains(user) && presence.isAvailable()) {
// New user
enabledUsers.add(user);
StringBuilder message = new StringBuilder();
message.append(user);
message.append(" ").append(roleName).append(" ")
.append(siteName);
setColorForSite(participant, presence);
sendSystemMessage(message);
processJoinAlert();
}
}
}
/**
* No operation for Session Feed View
*/
@Override
protected void participantArrived(VenueParticipant participant,
String description) {
usersTable.setInput(session.getVenue().getParticipants());
usersTable.refresh();
}
/**
* {@inheritDoc}
*/
@Override
protected void participantDeparted(VenueParticipant participant,
String description) {
if (enabledUsers.remove(participant.getName())) {
super.participantDeparted(participant, description);
}
}
/*

View file

@ -102,6 +102,8 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager;
* Feb 13, 2014 2751 bclement VenueParticipant refactor
* Feb 18, 2014 2631 mpduff Add processJoinAlert()
* Feb 24, 2014 2632 mpduff Move playSound to CollaborationUtils
* Mar 05, 2014 2798 mpduff Moved processJoinAlert() call from participantHandler
* to participantArrived.
*
* </pre>
*
@ -632,7 +634,6 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
switch (type) {
case ARRIVED:
participantArrived(participant, description);
processJoinAlert();
break;
case DEPARTED:
participantDeparted(participant, description);
@ -671,6 +672,7 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
String message = description != null ? description
: "has entered the room.";
sendParticipantSystemMessage(participant, message);
processJoinAlert();
}
/**
@ -728,7 +730,6 @@ public class SessionView extends AbstractSessionView<VenueParticipant>
protected SessionMsgArchive createMessageArchive() {
String sessionName = getSessionName();
UserId me = CollaborationConnection.getConnection().getUser();
// UserId me = session.getUserID();
return new SessionMsgArchive(me.getHost(), me.getName(), sessionName);
}