Issue #437 - Adding roster api message handling.
Former-commit-id:dcdb98319d
[formerly4c7f2465fc
] [formerlydcdb98319d
[formerly4c7f2465fc
] [formerlyafeea4d9d2
[formerly 8c7b4a55e6fa10e3e120e12334ba2d04d2d40a32]]] Former-commit-id:afeea4d9d2
Former-commit-id:2307245201
[formerlyf496523681
] Former-commit-id:0766652a82
This commit is contained in:
parent
cef8c6770b
commit
425edcec63
9 changed files with 322 additions and 25 deletions
|
@ -21,6 +21,7 @@ package com.raytheon.uf.viz.collaboration.comm.identity.roster;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID;
|
import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.ID;
|
import com.raytheon.uf.viz.collaboration.comm.identity.user.ID;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
||||||
|
@ -118,4 +119,19 @@ public interface IRoster {
|
||||||
*/
|
*/
|
||||||
boolean isRoomRoster();
|
boolean isRoomRoster();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param account
|
||||||
|
* @param nickName
|
||||||
|
* @param groups
|
||||||
|
*/
|
||||||
|
void sendRosterAdd(String account, String nickName, String[] groups)
|
||||||
|
throws CollaborationException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
*/
|
||||||
|
void sendRosterRemove(IChatID userId) throws CollaborationException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@ package com.raytheon.uf.viz.collaboration.comm.identity.roster;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IRosterListener;
|
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IRosterListener;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.ID;
|
import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
|
@ -75,4 +75,19 @@ public interface IRosterManager {
|
||||||
*/
|
*/
|
||||||
IRosterListener removeRosterListener(IRosterListener listener);
|
IRosterListener removeRosterListener(IRosterListener listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param account
|
||||||
|
* @param nickName
|
||||||
|
* @param groups
|
||||||
|
*/
|
||||||
|
void sendRosterAdd(String account, String nickName, String[] groups)
|
||||||
|
throws CollaborationException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
*/
|
||||||
|
void sendRosterRemove(IChatID userId) throws CollaborationException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,15 +223,22 @@ public class Presence implements IPresence {
|
||||||
IPresence presence) {
|
IPresence presence) {
|
||||||
org.eclipse.ecf.presence.IPresence newPresence = null;
|
org.eclipse.ecf.presence.IPresence newPresence = null;
|
||||||
if (presence != null) {
|
if (presence != null) {
|
||||||
newPresence = new org.eclipse.ecf.presence.Presence();
|
org.eclipse.ecf.presence.IPresence.Type type = Tools.convertPresenceType(presence.getType());
|
||||||
|
org.eclipse.ecf.presence.IPresence.Mode mode = Tools.convertPresenceMode(presence.getMode());
|
||||||
// Map<String, String> properties = presence.getProperties();
|
|
||||||
// if(properties != null) {
|
|
||||||
// for(String key : properties.keySet()) {
|
|
||||||
// newPresence.setProperty(key, properties.get(key));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
Map<String, String> props = new HashMap<String, String>();
|
||||||
|
String status = presence.getStatusMessage();
|
||||||
|
Collection<Property> properties = presence.getProperties();
|
||||||
|
for (Property p : properties) {
|
||||||
|
props.put(p.getKey(), p.getValue());
|
||||||
|
}
|
||||||
|
if (props.size() > 0) {
|
||||||
|
newPresence = new org.eclipse.ecf.presence.Presence(type,
|
||||||
|
status, mode, props);
|
||||||
|
} else {
|
||||||
|
newPresence = new org.eclipse.ecf.presence.Presence(type,
|
||||||
|
status, mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return newPresence;
|
return newPresence;
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,6 +248,46 @@ public abstract class Tools {
|
||||||
return sType;
|
return sType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts from an IPresence.Mode to ECF Presence Mode.
|
||||||
|
*
|
||||||
|
* @param mode
|
||||||
|
* A mode to convert.
|
||||||
|
* @return The converted mode.
|
||||||
|
*/
|
||||||
|
public static org.eclipse.ecf.presence.Presence.Mode convertPresenceMode(
|
||||||
|
IPresence.Mode mode) {
|
||||||
|
|
||||||
|
org.eclipse.ecf.presence.Presence.Mode sMode = null;
|
||||||
|
switch (mode) {
|
||||||
|
case AVAILABLE: {
|
||||||
|
sMode = org.eclipse.ecf.presence.Presence.Mode.AVAILABLE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AWAY: {
|
||||||
|
sMode = org.eclipse.ecf.presence.Presence.Mode.AWAY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CHAT: {
|
||||||
|
sMode = org.eclipse.ecf.presence.Presence.Mode.CHAT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DND: {
|
||||||
|
sMode = org.eclipse.ecf.presence.Presence.Mode.DND;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EXTENDED_AWAY: {
|
||||||
|
sMode = org.eclipse.ecf.presence.Presence.Mode.EXTENDED_AWAY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case INVISIBLE: {
|
||||||
|
sMode = org.eclipse.ecf.presence.Presence.Mode.INVISIBLE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sMode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode Base64 encoded String data into a byte array.
|
* Decode Base64 encoded String data into a byte array.
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,10 +23,16 @@ import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.ecf.core.util.ECFException;
|
||||||
|
import org.eclipse.ecf.presence.IPresenceContainerAdapter;
|
||||||
|
import org.eclipse.ecf.presence.roster.IRosterSubscriptionSender;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
|
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRoster;
|
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRoster;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry;
|
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterGroup;
|
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterGroup;
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterManager;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID;
|
import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.ID;
|
import com.raytheon.uf.viz.collaboration.comm.identity.user.ID;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
||||||
|
@ -65,11 +71,14 @@ public class Roster extends RosterItem implements IRoster {
|
||||||
|
|
||||||
private boolean roomRoster = false;
|
private boolean roomRoster = false;
|
||||||
|
|
||||||
|
private IRosterManager rosterManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param user
|
* @param user
|
||||||
*/
|
*/
|
||||||
public Roster(IChatID user) {
|
public Roster(IChatID user, IRosterManager manager) {
|
||||||
|
rosterManager = manager;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
internalEntries = new HashMap<IQualifiedID, IRosterEntry>();
|
internalEntries = new HashMap<IQualifiedID, IRosterEntry>();
|
||||||
entries = new HashMap<IQualifiedID, IRosterEntry>();
|
entries = new HashMap<IQualifiedID, IRosterEntry>();
|
||||||
|
@ -196,16 +205,29 @@ public class Roster extends RosterItem implements IRoster {
|
||||||
entry = new RosterEntry(id);
|
entry = new RosterEntry(id);
|
||||||
}
|
}
|
||||||
internalEntries.put(entry.getUser(), entry);
|
internalEntries.put(entry.getUser(), entry);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @see com.raytheon.uf.viz.collaboration.comm.identity.roster.IRoster#modifyRosterEntry(com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry)
|
* @see com.raytheon.uf.viz.collaboration.comm.identity.roster.IRoster#modifyRosterEntry(com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void modifyRosterEntry(IRosterEntry entry) {
|
public void modifyRosterEntry(IRosterEntry entry) {
|
||||||
|
|
||||||
|
// First attempt to find the entry in the internal entry collection
|
||||||
|
if(entry != null) {
|
||||||
|
IRosterEntry re = internalEntries.get(entry.getUser());
|
||||||
|
if(re != null) {
|
||||||
|
// We've found the roster entry in the internal entries
|
||||||
|
// so update with the presence.
|
||||||
|
RosterEntry ret = (RosterEntry) re;
|
||||||
|
ret.setPresence(entry.getPresence());
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// nothing to do. And this shouldn't happen!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -216,7 +238,28 @@ public class Roster extends RosterItem implements IRoster {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void removeFromRoster(ID user) {
|
public void removeFromRoster(ID user) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param account
|
||||||
|
* @param nickName
|
||||||
|
* @param groups
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sendRosterAdd(String account, String nickName, String[] groups)
|
||||||
|
throws CollaborationException {
|
||||||
|
rosterManager.sendRosterAdd(account, nickName, groups);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sendRosterRemove(IChatID userId) throws CollaborationException {
|
||||||
|
rosterManager.sendRosterRemove(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,12 +21,19 @@ package com.raytheon.uf.viz.collaboration.comm.provider.roster;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import org.eclipse.ecf.core.identity.ID;
|
||||||
|
import org.eclipse.ecf.core.util.ECFException;
|
||||||
|
import org.eclipse.ecf.presence.IPresenceContainerAdapter;
|
||||||
|
import org.eclipse.ecf.presence.roster.IRosterSubscriptionSender;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
|
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IRosterListener;
|
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IRosterListener;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRoster;
|
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRoster;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterManager;
|
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterManager;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID;
|
import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.Presence;
|
import com.raytheon.uf.viz.collaboration.comm.provider.Presence;
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.provider.session.SessionManager;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.RosterId;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.RosterId;
|
||||||
|
|
||||||
|
@ -54,12 +61,15 @@ public class RosterManager implements IRosterManager {
|
||||||
private IRoster roster;
|
private IRoster roster;
|
||||||
|
|
||||||
private org.eclipse.ecf.presence.roster.IRoster baseRoster;
|
private org.eclipse.ecf.presence.roster.IRoster baseRoster;
|
||||||
|
|
||||||
|
private SessionManager sessionManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param roster
|
* @param roster
|
||||||
*/
|
*/
|
||||||
public RosterManager(org.eclipse.ecf.presence.roster.IRoster roster) {
|
public RosterManager(org.eclipse.ecf.presence.roster.IRoster roster, SessionManager manager) {
|
||||||
|
sessionManager = manager;
|
||||||
baseRoster = roster;
|
baseRoster = roster;
|
||||||
owner = roster.getName();
|
owner = roster.getName();
|
||||||
this.roster = toLocalRoster(roster);
|
this.roster = toLocalRoster(roster);
|
||||||
|
@ -108,6 +118,53 @@ public class RosterManager implements IRosterManager {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param account
|
||||||
|
* @param nickName
|
||||||
|
* @param groups
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sendRosterAdd(String account, String nickName, String[] groups)
|
||||||
|
throws CollaborationException {
|
||||||
|
org.eclipse.ecf.presence.roster.IRosterManager manager = baseRoster
|
||||||
|
.getPresenceContainerAdapter().getRosterManager();
|
||||||
|
|
||||||
|
IRosterSubscriptionSender sender = manager
|
||||||
|
.getRosterSubscriptionSender();
|
||||||
|
|
||||||
|
try {
|
||||||
|
sender.sendRosterAdd(account, nickName, groups);
|
||||||
|
} catch (ECFException e) {
|
||||||
|
throw new CollaborationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sendRosterRemove(IChatID userId) throws CollaborationException {
|
||||||
|
|
||||||
|
IPresenceContainerAdapter adapter = baseRoster
|
||||||
|
.getPresenceContainerAdapter();
|
||||||
|
org.eclipse.ecf.presence.roster.IRosterManager manager = adapter
|
||||||
|
.getRosterManager();
|
||||||
|
|
||||||
|
IRosterSubscriptionSender sender = manager
|
||||||
|
.getRosterSubscriptionSender();
|
||||||
|
|
||||||
|
ID id = sessionManager.createID(userId.getFQName());
|
||||||
|
|
||||||
|
try {
|
||||||
|
sender.sendRosterRemove(id);
|
||||||
|
} catch (ECFException e) {
|
||||||
|
throw new CollaborationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param roster
|
* @param roster
|
||||||
|
@ -118,7 +175,7 @@ public class RosterManager implements IRosterManager {
|
||||||
|
|
||||||
if (roster != null) {
|
if (roster != null) {
|
||||||
IChatID id = IDConverter.convertFrom(roster.getUser());
|
IChatID id = IDConverter.convertFrom(roster.getUser());
|
||||||
newRoster = new Roster(id);
|
newRoster = new Roster(id, this);
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
Collection items = roster.getItems();
|
Collection items = roster.getItems();
|
||||||
|
@ -158,4 +215,20 @@ public class RosterManager implements IRosterManager {
|
||||||
return newRoster;
|
return newRoster;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateEntry(IChatID fromId, IPresence presence) {
|
||||||
|
RosterEntry re = new RosterEntry(fromId);
|
||||||
|
re.setPresence(presence);
|
||||||
|
|
||||||
|
roster.modifyRosterEntry(re);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public SessionManager getSessionManager() {
|
||||||
|
return sessionManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,10 @@ public class PeerToPeerCommHelper implements IIMMessageListener {
|
||||||
routeMessage(msg);
|
routeMessage(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if(messageEvent != null) {
|
||||||
|
System.out.println(messageEvent.getClass().getName() + " trapped in PeerToPeerCommHelper");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,14 +31,20 @@ import org.eclipse.ecf.core.IContainer;
|
||||||
import org.eclipse.ecf.core.IContainerListener;
|
import org.eclipse.ecf.core.IContainerListener;
|
||||||
import org.eclipse.ecf.core.events.IContainerEvent;
|
import org.eclipse.ecf.core.events.IContainerEvent;
|
||||||
import org.eclipse.ecf.core.identity.ID;
|
import org.eclipse.ecf.core.identity.ID;
|
||||||
|
import org.eclipse.ecf.core.identity.IDCreateException;
|
||||||
import org.eclipse.ecf.core.identity.IDFactory;
|
import org.eclipse.ecf.core.identity.IDFactory;
|
||||||
import org.eclipse.ecf.core.identity.Namespace;
|
import org.eclipse.ecf.core.identity.Namespace;
|
||||||
import org.eclipse.ecf.core.security.ConnectContextFactory;
|
import org.eclipse.ecf.core.security.ConnectContextFactory;
|
||||||
import org.eclipse.ecf.presence.IPresenceContainerAdapter;
|
import org.eclipse.ecf.presence.IPresenceContainerAdapter;
|
||||||
|
import org.eclipse.ecf.presence.IPresenceListener;
|
||||||
import org.eclipse.ecf.presence.chatroom.IChatRoomInfo;
|
import org.eclipse.ecf.presence.chatroom.IChatRoomInfo;
|
||||||
import org.eclipse.ecf.presence.chatroom.IChatRoomInvitationListener;
|
import org.eclipse.ecf.presence.chatroom.IChatRoomInvitationListener;
|
||||||
import org.eclipse.ecf.presence.chatroom.IChatRoomManager;
|
import org.eclipse.ecf.presence.chatroom.IChatRoomManager;
|
||||||
import org.eclipse.ecf.presence.roster.IRoster;
|
import org.eclipse.ecf.presence.roster.IRoster;
|
||||||
|
import org.eclipse.ecf.presence.roster.IRosterEntry;
|
||||||
|
import org.eclipse.ecf.presence.roster.IRosterGroup;
|
||||||
|
import org.eclipse.ecf.presence.roster.IRosterItem;
|
||||||
|
import org.eclipse.ecf.presence.roster.IRosterListener;
|
||||||
import org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID;
|
import org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
|
|
||||||
|
@ -60,7 +66,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.event.VenueInvitationEven
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.info.InfoAdapter;
|
import com.raytheon.uf.viz.collaboration.comm.provider.info.InfoAdapter;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.roster.RosterManager;
|
import com.raytheon.uf.viz.collaboration.comm.provider.roster.RosterManager;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.RosterId;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueUserId;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueUserId;
|
||||||
|
|
||||||
|
@ -104,8 +110,6 @@ public class SessionManager implements IEventPublisher {
|
||||||
|
|
||||||
private Map<String, ISession> sessions;
|
private Map<String, ISession> sessions;
|
||||||
|
|
||||||
private Map<String, ISession> following;
|
|
||||||
|
|
||||||
private String account;
|
private String account;
|
||||||
|
|
||||||
private String password;
|
private String password;
|
||||||
|
@ -113,6 +117,8 @@ public class SessionManager implements IEventPublisher {
|
||||||
private IChatRoomInvitationListener intInvitationListener;
|
private IChatRoomInvitationListener intInvitationListener;
|
||||||
|
|
||||||
private IPresenceContainerAdapter presenceAdapter;
|
private IPresenceContainerAdapter presenceAdapter;
|
||||||
|
|
||||||
|
private Namespace connectionNamespace = null;
|
||||||
|
|
||||||
private PeerToPeerChat chatInstance = null;
|
private PeerToPeerChat chatInstance = null;
|
||||||
|
|
||||||
|
@ -149,7 +155,6 @@ public class SessionManager implements IEventPublisher {
|
||||||
eventBus = new EventBus();
|
eventBus = new EventBus();
|
||||||
|
|
||||||
sessions = new HashMap<String, ISession>();
|
sessions = new HashMap<String, ISession>();
|
||||||
following = new HashMap<String, ISession>();
|
|
||||||
|
|
||||||
setupInternalConnectionListeners();
|
setupInternalConnectionListeners();
|
||||||
setupInternalVenueInvitationListener();
|
setupInternalVenueInvitationListener();
|
||||||
|
@ -181,11 +186,11 @@ public class SessionManager implements IEventPublisher {
|
||||||
*/
|
*/
|
||||||
private void connectToContainer() {
|
private void connectToContainer() {
|
||||||
if (container.getConnectedID() == null) {
|
if (container.getConnectedID() == null) {
|
||||||
Namespace namespace = container.getConnectNamespace();
|
connectionNamespace = container.getConnectNamespace();
|
||||||
|
|
||||||
ID targetID = IDFactory.getDefault().createID(namespace, account);
|
|
||||||
// Now connect
|
// Now connect
|
||||||
try {
|
try {
|
||||||
|
ID targetID = createID(account);
|
||||||
container.connect(targetID, ConnectContextFactory
|
container.connect(targetID, ConnectContextFactory
|
||||||
.createPasswordConnectContext(password));
|
.createPasswordConnectContext(password));
|
||||||
|
|
||||||
|
@ -194,6 +199,9 @@ public class SessionManager implements IEventPublisher {
|
||||||
} catch (ContainerConnectException e) {
|
} catch (ContainerConnectException e) {
|
||||||
System.out.println("Error attempting to connect");
|
System.out.println("Error attempting to connect");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
} catch (CollaborationException ce) {
|
||||||
|
System.out.println("Error attempting to create identifier.");
|
||||||
|
ce.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +240,7 @@ public class SessionManager implements IEventPublisher {
|
||||||
if (presenceAdapter != null) {
|
if (presenceAdapter != null) {
|
||||||
roster = presenceAdapter.getRosterManager().getRoster();
|
roster = presenceAdapter.getRosterManager().getRoster();
|
||||||
if (roster != null) {
|
if (roster != null) {
|
||||||
rosterManager = new RosterManager(roster);
|
rosterManager = new RosterManager(roster, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -462,6 +470,69 @@ public class SessionManager implements IEventPublisher {
|
||||||
*/
|
*/
|
||||||
private void setupInternalConnectionListeners() {
|
private void setupInternalConnectionListeners() {
|
||||||
|
|
||||||
|
presenceAdapter.getRosterManager().addPresenceListener(new IPresenceListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handlePresence(ID fromId,
|
||||||
|
org.eclipse.ecf.presence.IPresence presence) {
|
||||||
|
System.out.println("Presence from " + fromId.getName());
|
||||||
|
System.out.println(" type " + presence.getType());
|
||||||
|
System.out.println(" mode " + presence.getMode());
|
||||||
|
System.out.println(" status " + presence.getStatus());
|
||||||
|
|
||||||
|
IPresence p = Presence.convertPresence(presence);
|
||||||
|
|
||||||
|
String name = Tools.parseName(fromId.getName());
|
||||||
|
String host = Tools.parseHost(fromId.getName());
|
||||||
|
String resource = Tools.parseResource(fromId.getName());
|
||||||
|
|
||||||
|
IChatID id = new RosterId(name, host, resource);
|
||||||
|
|
||||||
|
if(rosterManager != null) {
|
||||||
|
((RosterManager) rosterManager).updateEntry(id, p);
|
||||||
|
} else {
|
||||||
|
// No rosterManager
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
presenceAdapter.getRosterManager().addRosterListener(new IRosterListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleRosterEntryAdd(IRosterEntry entry) {
|
||||||
|
System.out.println("Roster add " + entry.getUser());
|
||||||
|
System.out.println(" groups " + entry.getGroups());
|
||||||
|
System.out.println(" name " + entry.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleRosterUpdate(IRoster roster,
|
||||||
|
IRosterItem changedValue) {
|
||||||
|
|
||||||
|
if(changedValue instanceof IRosterEntry) {
|
||||||
|
IRosterEntry re = (IRosterEntry) changedValue;
|
||||||
|
System.out.println("Roster update RosterEntry " + re.getUser());
|
||||||
|
System.out.println(" groups " + re.getGroups());
|
||||||
|
System.out.println(" name " + re.getName());
|
||||||
|
} else if (changedValue instanceof IRosterGroup) {
|
||||||
|
IRosterGroup rg = (IRosterGroup) changedValue;
|
||||||
|
System.out.println("Roster update RosterGroup " + rg.getName());
|
||||||
|
System.out.println(" entries " + rg.getEntries());
|
||||||
|
System.out.println(" name " + rg.getName());
|
||||||
|
} else if (changedValue instanceof IRoster) {
|
||||||
|
IRoster r = (IRoster) changedValue;
|
||||||
|
System.out.println("Roster update Roster " + r.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleRosterEntryRemove(IRosterEntry entry) {
|
||||||
|
System.out.println("Roster " + entry.getUser());
|
||||||
|
System.out.println(" groups " + entry.getGroups());
|
||||||
|
System.out.println(" name " + entry.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (container != null) {
|
if (container != null) {
|
||||||
container.addListener(new IContainerListener() {
|
container.addListener(new IContainerListener() {
|
||||||
|
|
||||||
|
@ -558,5 +629,23 @@ public class SessionManager implements IEventPublisher {
|
||||||
public EventBus getEventPublisher() {
|
public EventBus getEventPublisher() {
|
||||||
return eventBus;
|
return eventBus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public ID createID(String name) throws CollaborationException {
|
||||||
|
ID id = null;
|
||||||
|
try {
|
||||||
|
if (connectionNamespace != null) {
|
||||||
|
id = IDFactory.getDefault().createID(connectionNamespace, name);
|
||||||
|
}
|
||||||
|
} catch(IDCreateException idce) {
|
||||||
|
throw new CollaborationException("Could not create id");
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,19 @@ public class RosterId extends UserId implements IChatID {
|
||||||
|
|
||||||
private String nickname;
|
private String nickname;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userName
|
||||||
|
* @param hostName
|
||||||
|
* @param nickName
|
||||||
|
* @param resource
|
||||||
|
*/
|
||||||
|
public RosterId(String userName, String hostName, String resource) {
|
||||||
|
super(userName, hostName, resource);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param userName
|
* @param userName
|
||||||
|
@ -81,8 +94,6 @@ public class RosterId extends UserId implements IChatID {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = super.hashCode();
|
int result = super.hashCode();
|
||||||
result = prime * result
|
|
||||||
+ ((nickname == null) ? 0 : nickname.hashCode());
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,8 +114,7 @@ public class RosterId extends UserId implements IChatID {
|
||||||
if (nickname == null) {
|
if (nickname == null) {
|
||||||
if (other.nickname != null)
|
if (other.nickname != null)
|
||||||
return false;
|
return false;
|
||||||
} else if (!nickname.equals(other.nickname))
|
}
|
||||||
return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue