Issue #437 - Updates to status handling - Added SessionManager user presence.
Former-commit-id: 77520e5b98de679a1f08b523fb85464a31bd4c02
This commit is contained in:
parent
18e9f2c6ad
commit
07bc1bf83e
7 changed files with 242 additions and 93 deletions
|
@ -23,10 +23,6 @@ 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.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;
|
||||||
|
@ -37,10 +33,7 @@ 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;
|
||||||
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.Tools;
|
|
||||||
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;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueUserId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* TODO Add Description
|
||||||
|
@ -123,7 +116,20 @@ public class Roster extends RosterItem implements IRoster {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addRosterEntry(IRosterEntry entry) {
|
public void addRosterEntry(IRosterEntry entry) {
|
||||||
entries.put(entry.getUser(), entry);
|
IRosterEntry re = null;
|
||||||
|
|
||||||
|
IQualifiedID id = entry.getUser();
|
||||||
|
re = internalEntries.get(id);
|
||||||
|
// ensure the entry is not present!
|
||||||
|
if(re == null) {
|
||||||
|
// put in the internal entries first.
|
||||||
|
internalEntries.put(entry.getUser(), entry);
|
||||||
|
|
||||||
|
for(IRosterGroup g : entry.getGroups()) {
|
||||||
|
RosterGroup rg = (RosterGroup) g;
|
||||||
|
rg.setRoster(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -198,7 +204,6 @@ public class Roster extends RosterItem implements IRoster {
|
||||||
@Override
|
@Override
|
||||||
public void addRosterEntry(IQualifiedID user, String nickName,
|
public void addRosterEntry(IQualifiedID user, String nickName,
|
||||||
String[] groups) {
|
String[] groups) {
|
||||||
|
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
IRosterEntry entry = internalEntries.get(user.getFQName());
|
IRosterEntry entry = internalEntries.get(user.getFQName());
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
|
@ -207,6 +212,8 @@ 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);
|
||||||
|
|
||||||
|
listRoster();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,4 +317,34 @@ public class Roster extends RosterItem implements IRoster {
|
||||||
// </pre>
|
// </pre>
|
||||||
// *******************************************
|
// *******************************************
|
||||||
|
|
||||||
|
|
||||||
|
public void listRoster() {
|
||||||
|
|
||||||
|
System.out.println("##########################################################################");
|
||||||
|
System.out.println("Roster for : " + user.getFQName());
|
||||||
|
System.out.println("#####################################");
|
||||||
|
System.out.println("# Ungrouped entries");
|
||||||
|
System.out.println("-------------------------------------");
|
||||||
|
Collection<IRosterEntry> entries = getEntries();
|
||||||
|
for(IRosterEntry r : entries) {
|
||||||
|
System.out.print(" " + r.getName());
|
||||||
|
}
|
||||||
|
System.out.println("#####################################");
|
||||||
|
System.out.println("# Groups ");
|
||||||
|
System.out.println("-------------------------------------");
|
||||||
|
Collection<IRosterGroup> groups = getGroups();
|
||||||
|
for(IRosterGroup g : groups) {
|
||||||
|
System.out.print(" " + g.getName());
|
||||||
|
entries = g.getEntries();
|
||||||
|
for(IRosterEntry r : entries) {
|
||||||
|
System.out.print(" " + r.getName());
|
||||||
|
}
|
||||||
|
System.out.println("-----------------");
|
||||||
|
}
|
||||||
|
System.out.println("##########################################################################");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,15 @@ 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.identity.ID;
|
||||||
|
|
||||||
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.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.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.Tools;
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.RosterId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* TODO Add Description
|
||||||
|
@ -143,6 +147,37 @@ public class RosterEntry extends RosterItem implements IRosterEntry,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param entry
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static IRosterEntry convertEntry(org.eclipse.ecf.presence.roster.IRosterEntry entry) {
|
||||||
|
RosterEntry rosterEntry = null;
|
||||||
|
if(entry != null) {
|
||||||
|
ID id = entry.getUser().getID();
|
||||||
|
|
||||||
|
String name = Tools.parseName(id.getName());
|
||||||
|
String host = Tools.parseHost(id.getName());
|
||||||
|
String resource = Tools.parseResource(id.getName());
|
||||||
|
IChatID rosterId = new RosterId(name, host, resource);
|
||||||
|
|
||||||
|
rosterEntry = new RosterEntry(rosterId);
|
||||||
|
IPresence p = Presence.convertPresence(entry.getPresence());
|
||||||
|
rosterEntry.setPresence(p);
|
||||||
|
|
||||||
|
// Now check the groups
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Collection<org.eclipse.ecf.presence.roster.IRosterGroup> inGroups = entry.getGroups();
|
||||||
|
for(org.eclipse.ecf.presence.roster.IRosterGroup g : inGroups) {
|
||||||
|
RosterGroup group = new RosterGroup(g.getName(), null,null);
|
||||||
|
rosterEntry.addGroup(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rosterEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static final void main(String[] args) {
|
public static final void main(String[] args) {
|
||||||
|
|
||||||
IChatID id = new IChatID() {
|
IChatID id = new IChatID() {
|
||||||
|
|
|
@ -19,13 +19,16 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.viz.collaboration.comm.provider.roster;
|
package com.raytheon.uf.viz.collaboration.comm.provider.roster;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
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.IRosterItem;
|
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterItem;
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.RosterId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* TODO Add Description
|
||||||
|
@ -46,19 +49,17 @@ import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterItem;
|
||||||
|
|
||||||
public class RosterGroup extends RosterItem implements IRosterGroup {
|
public class RosterGroup extends RosterItem implements IRosterGroup {
|
||||||
|
|
||||||
private Collection<IRosterEntry> entries = null;
|
private Map<IQualifiedID, IRosterEntry> entries = null;
|
||||||
|
|
||||||
private Collection<IRosterGroup> groups = null;
|
private Map<IRosterGroup, IRosterGroup> groups = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public RosterGroup(String name, IRosterItem parent, IRoster roster) {
|
public RosterGroup(String name, IRosterItem parent, IRoster roster) {
|
||||||
super(name, parent, roster);
|
super(name, parent, roster);
|
||||||
entries = new ArrayList<IRosterEntry>();
|
entries = new HashMap<IQualifiedID, IRosterEntry>();
|
||||||
if (roster.supportsNestedGroups()) {
|
groups = new HashMap<IRosterGroup, IRosterGroup>();
|
||||||
groups = new ArrayList<IRosterGroup>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +67,16 @@ public class RosterGroup extends RosterItem implements IRosterGroup {
|
||||||
* @param entry
|
* @param entry
|
||||||
*/
|
*/
|
||||||
public void addEntry(IRosterEntry entry) {
|
public void addEntry(IRosterEntry entry) {
|
||||||
entries.add(entry);
|
|
||||||
|
IRosterEntry re = entries.get(entry.getUser());
|
||||||
|
if (re == null) {
|
||||||
|
IQualifiedID user = entry.getUser();
|
||||||
|
RosterId id = new RosterId(user.getName(), user.getHost(), null,
|
||||||
|
user.getResource());
|
||||||
|
|
||||||
|
re = new RosterEntry(id);
|
||||||
|
entries.put(entry.getUser(), entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,7 +85,7 @@ public class RosterGroup extends RosterItem implements IRosterGroup {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Collection<IRosterEntry> getEntries() {
|
public Collection<IRosterEntry> getEntries() {
|
||||||
return entries;
|
return entries.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,11 +94,7 @@ public class RosterGroup extends RosterItem implements IRosterGroup {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public IRosterEntry removeEntry(IRosterEntry entry) {
|
public IRosterEntry removeEntry(IRosterEntry entry) {
|
||||||
IRosterEntry removed = null;
|
return entries.remove(entry.getUser());
|
||||||
if (entries.remove(entry)) {
|
|
||||||
removed = entry;
|
|
||||||
}
|
|
||||||
return removed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,6 +103,6 @@ public class RosterGroup extends RosterItem implements IRosterGroup {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Collection<IRosterGroup> getGroups() {
|
public Collection<IRosterGroup> getGroups() {
|
||||||
return groups;
|
return groups.values();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,12 +69,10 @@ public class RosterManager implements IRosterManager {
|
||||||
*
|
*
|
||||||
* @param roster
|
* @param roster
|
||||||
*/
|
*/
|
||||||
public RosterManager(org.eclipse.ecf.presence.roster.IRoster roster, SessionManager manager) {
|
public RosterManager(SessionManager manager) {
|
||||||
sessionManager = manager;
|
sessionManager = manager;
|
||||||
baseRoster = roster;
|
updateRoster();
|
||||||
owner = roster.getName();
|
}
|
||||||
this.roster = toLocalRoster(roster);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -86,6 +84,11 @@ public class RosterManager implements IRosterManager {
|
||||||
return roster;
|
return roster;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateRoster() {
|
||||||
|
baseRoster = sessionManager.getPresenceContainerAdapter().getRosterManager().getRoster();
|
||||||
|
roster = toLocalRoster(baseRoster);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param listener
|
* @param listener
|
||||||
|
@ -157,7 +160,6 @@ public class RosterManager implements IRosterManager {
|
||||||
.getRosterSubscriptionSender();
|
.getRosterSubscriptionSender();
|
||||||
|
|
||||||
ID id = sessionManager.createID(userId.getFQName());
|
ID id = sessionManager.createID(userId.getFQName());
|
||||||
System.out.println(" sendRosterRemove(" + id + ")");
|
|
||||||
try {
|
try {
|
||||||
sender.sendRosterRemove(id);
|
sender.sendRosterRemove(id);
|
||||||
} catch (ECFException e) {
|
} catch (ECFException e) {
|
||||||
|
@ -167,6 +169,33 @@ public class RosterManager implements IRosterManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param fromId
|
||||||
|
* @param presence
|
||||||
|
*/
|
||||||
|
public void updateEntry(IChatID fromId, IPresence presence) {
|
||||||
|
RosterEntry re = new RosterEntry(fromId);
|
||||||
|
re.setPresence(presence);
|
||||||
|
|
||||||
|
IRosterEntry modified = roster.modifyRosterEntry(re);
|
||||||
|
if(modified != null) {
|
||||||
|
sessionManager.getEventPublisher().post(re);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param fromId
|
||||||
|
* @param presence
|
||||||
|
*/
|
||||||
|
public void updateEntry(IRosterEntry entry) {
|
||||||
|
IRosterEntry modified = roster.modifyRosterEntry(entry);
|
||||||
|
if(modified != null) {
|
||||||
|
sessionManager.getEventPublisher().post(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param roster
|
* @param roster
|
||||||
|
@ -207,21 +236,6 @@ public class RosterManager implements IRosterManager {
|
||||||
return newRoster;
|
return newRoster;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param fromId
|
|
||||||
* @param presence
|
|
||||||
*/
|
|
||||||
public void updateEntry(IChatID fromId, IPresence presence) {
|
|
||||||
RosterEntry re = new RosterEntry(fromId);
|
|
||||||
re.setPresence(presence);
|
|
||||||
|
|
||||||
IRosterEntry modified = roster.modifyRosterEntry(re);
|
|
||||||
if(modified != null) {
|
|
||||||
sessionManager.getEventPublisher().post(re);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.ecf.core.identity.ID;
|
||||||
import org.eclipse.ecf.core.util.ECFException;
|
import org.eclipse.ecf.core.util.ECFException;
|
||||||
import org.eclipse.ecf.presence.IPresenceContainerAdapter;
|
import org.eclipse.ecf.presence.IPresenceContainerAdapter;
|
||||||
import org.eclipse.ecf.presence.IPresenceSender;
|
import org.eclipse.ecf.presence.IPresenceSender;
|
||||||
|
import org.eclipse.ecf.presence.roster.IRosterManager;
|
||||||
import org.eclipse.ecf.presence.roster.IRosterSubscriptionListener;
|
import org.eclipse.ecf.presence.roster.IRosterSubscriptionListener;
|
||||||
|
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
||||||
|
@ -74,17 +75,13 @@ public class AccountManager implements IAccountManager {
|
||||||
} else {
|
} else {
|
||||||
subscribedType = IPresence.Type.SUBSCRIBED;
|
subscribedType = IPresence.Type.SUBSCRIBED;
|
||||||
}
|
}
|
||||||
org.eclipse.ecf.presence.Presence.Type sType = Tools
|
|
||||||
.convertPresenceType(subscribedType);
|
|
||||||
|
|
||||||
org.eclipse.ecf.presence.IPresence presence = new org.eclipse.ecf.presence.Presence(
|
|
||||||
sType);
|
|
||||||
|
|
||||||
|
IPresence presence = new Presence(IPresence.Mode.AVAILABLE,
|
||||||
|
subscribedType, null);
|
||||||
try {
|
try {
|
||||||
presenceAdapter.getRosterManager().getPresenceSender()
|
sendPresence(presence);
|
||||||
.sendPresenceUpdate(fromID, presence);
|
} catch (CollaborationException e) {
|
||||||
} catch (ECFException e) {
|
e.printStackTrace();
|
||||||
// Will have to do something with this sooner or later.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,11 +102,14 @@ public class AccountManager implements IAccountManager {
|
||||||
|
|
||||||
private ISubscriptionResponder responder;
|
private ISubscriptionResponder responder;
|
||||||
|
|
||||||
|
private SessionManager sessionManager = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param adapter
|
* @param adapter
|
||||||
*/
|
*/
|
||||||
AccountManager(IPresenceContainerAdapter adapter) {
|
AccountManager(IPresenceContainerAdapter adapter, SessionManager manager) {
|
||||||
|
sessionManager = manager;
|
||||||
presenceAdapter = adapter;
|
presenceAdapter = adapter;
|
||||||
presenceAdapter.getRosterManager().addRosterSubscriptionListener(
|
presenceAdapter.getRosterManager().addRosterSubscriptionListener(
|
||||||
autoResponder);
|
autoResponder);
|
||||||
|
@ -138,7 +138,7 @@ public class AccountManager implements IAccountManager {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean getAutoSubscriptionMode() {
|
public boolean getAutoSubscriptionMode() {
|
||||||
return false;
|
return autoRespond;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -228,12 +228,27 @@ public class AccountManager implements IAccountManager {
|
||||||
* @see com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager#createAccount(java.lang.String,
|
* @see com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager#createAccount(java.lang.String,
|
||||||
* char[], java.util.Map)
|
* char[], java.util.Map)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
public void createAccount(String name, char[] password,
|
public void createAccount(String name, char[] password,
|
||||||
Map<String, String> attributes) throws CollaborationException {
|
Map<String, String> attributes) throws CollaborationException {
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
if (password != null) {
|
if (password != null) {
|
||||||
|
// create the account
|
||||||
|
org.eclipse.ecf.presence.IAccountManager manager = presenceAdapter
|
||||||
|
.getAccountManager();
|
||||||
|
if (manager != null) {
|
||||||
|
Map map = null;
|
||||||
|
if (attributes != null) {
|
||||||
|
map = (Map) attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
manager.createAccount(name, new String(password), map);
|
||||||
|
} catch (ECFException e) {
|
||||||
|
throw new CollaborationException("Could not create account ");
|
||||||
|
}
|
||||||
|
}
|
||||||
// all done so clear the password.
|
// all done so clear the password.
|
||||||
Arrays.fill(password, (char) 0);
|
Arrays.fill(password, (char) 0);
|
||||||
}
|
}
|
||||||
|
@ -249,13 +264,16 @@ public class AccountManager implements IAccountManager {
|
||||||
@Override
|
@Override
|
||||||
public void sendPresence(IPresence userPresence)
|
public void sendPresence(IPresence userPresence)
|
||||||
throws CollaborationException {
|
throws CollaborationException {
|
||||||
IPresenceSender sender = presenceAdapter.getRosterManager()
|
|
||||||
.getPresenceSender();
|
IRosterManager manager = presenceAdapter.getRosterManager();
|
||||||
|
IPresenceSender sender = manager.getPresenceSender();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sender.sendPresenceUpdate(null,
|
sender.sendPresenceUpdate(null,
|
||||||
Presence.convertPresence(userPresence));
|
Presence.convertPresence(userPresence));
|
||||||
|
sessionManager.setPresence(userPresence);
|
||||||
} catch (ECFException e) {
|
} catch (ECFException e) {
|
||||||
// TODO : Exception handing....
|
throw new CollaborationException("Could not send presence");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,6 @@ public abstract class BaseSession implements ISession {
|
||||||
*/
|
*/
|
||||||
public ID createID(String name) throws IDCreateException {
|
public ID createID(String name) throws IDCreateException {
|
||||||
ID id = null;
|
ID id = null;
|
||||||
name += "/foo"; // TODO fix this in a better way
|
|
||||||
if (connectionNamespace != null) {
|
if (connectionNamespace != null) {
|
||||||
id = IDFactory.getDefault().createID(connectionNamespace, name);
|
id = IDFactory.getDefault().createID(connectionNamespace, name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.Presence;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
|
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.event.VenueInvitationEvent;
|
import com.raytheon.uf.viz.collaboration.comm.provider.event.VenueInvitationEvent;
|
||||||
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.RosterEntry;
|
||||||
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.RosterId;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.RosterId;
|
||||||
|
@ -114,6 +115,10 @@ public class SessionManager implements IEventPublisher {
|
||||||
|
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
private IChatID user;
|
||||||
|
|
||||||
|
private IPresence userPresence;
|
||||||
|
|
||||||
private IChatRoomInvitationListener intInvitationListener;
|
private IChatRoomInvitationListener intInvitationListener;
|
||||||
|
|
||||||
private IPresenceContainerAdapter presenceAdapter;
|
private IPresenceContainerAdapter presenceAdapter;
|
||||||
|
@ -167,6 +172,14 @@ public class SessionManager implements IEventPublisher {
|
||||||
throw new CollaborationException(
|
throw new CollaborationException(
|
||||||
"Login failed. Invalid username or password", e);
|
"Login failed. Invalid username or password", e);
|
||||||
}
|
}
|
||||||
|
ID id = container.getConnectedID();
|
||||||
|
if(id != null) {
|
||||||
|
String name = Tools.parseName(id.getName());
|
||||||
|
String host = Tools.parseHost(id.getName());
|
||||||
|
String resource = Tools.parseResource(id.getName());
|
||||||
|
user = new RosterId(name, host, resource);
|
||||||
|
}
|
||||||
|
|
||||||
setupAccountManager();
|
setupAccountManager();
|
||||||
|
|
||||||
eventBus = new EventBus();
|
eventBus = new EventBus();
|
||||||
|
@ -198,6 +211,30 @@ public class SessionManager implements IEventPublisher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
* @see com.raytheon.uf.viz.collaboration.comm.identity.roster.IRoster#getUser()
|
||||||
|
*/
|
||||||
|
public IChatID getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IPresence getPresence() {
|
||||||
|
return userPresence;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public void setPresence(IPresence presence) {
|
||||||
|
userPresence = presence;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws CollaborationException
|
* @throws CollaborationException
|
||||||
* @throws ContainerConnectException
|
* @throws ContainerConnectException
|
||||||
|
@ -224,7 +261,7 @@ public class SessionManager implements IEventPublisher {
|
||||||
private void setupAccountManager() {
|
private void setupAccountManager() {
|
||||||
if (accountManager == null) {
|
if (accountManager == null) {
|
||||||
if (isConnected() && (presenceAdapter != null)) {
|
if (isConnected() && (presenceAdapter != null)) {
|
||||||
accountManager = new AccountManager(presenceAdapter);
|
accountManager = new AccountManager(presenceAdapter, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,16 +291,15 @@ public class SessionManager implements IEventPublisher {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private void setupRosterManager() {
|
private void setupRosterManager() {
|
||||||
IRoster roster = null;
|
rosterManager = new RosterManager(this);
|
||||||
IPresenceContainerAdapter presenceAdapter = Tools
|
}
|
||||||
.getPresenceContainerAdapter(container,
|
|
||||||
IPresenceContainerAdapter.class);
|
/**
|
||||||
if (presenceAdapter != null) {
|
*
|
||||||
roster = presenceAdapter.getRosterManager().getRoster();
|
* @return
|
||||||
if (roster != null) {
|
*/
|
||||||
rosterManager = new RosterManager(roster, this);
|
public IPresenceContainerAdapter getPresenceContainerAdapter() {
|
||||||
}
|
return presenceAdapter;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -384,8 +420,6 @@ public class SessionManager implements IEventPublisher {
|
||||||
session.setSessionDataProvider(me);
|
session.setSessionDataProvider(me);
|
||||||
|
|
||||||
IPresence presence = new Presence();
|
IPresence presence = new Presence();
|
||||||
presence.setMode(IPresence.Mode.AVAILABLE);
|
|
||||||
presence.setType(IPresence.Type.AVAILABLE);
|
|
||||||
presence.setProperty("DATA_PROVIDER", me.getFQName());
|
presence.setProperty("DATA_PROVIDER", me.getFQName());
|
||||||
presence.setProperty("SESSION_LEADER", me.getFQName());
|
presence.setProperty("SESSION_LEADER", me.getFQName());
|
||||||
|
|
||||||
|
@ -542,10 +576,11 @@ public class SessionManager implements IEventPublisher {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleRosterEntryAdd(IRosterEntry entry) {
|
public void handleRosterEntryAdd(IRosterEntry entry) {
|
||||||
System.out.println("Roster add " + entry.getUser());
|
com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry re = RosterEntry
|
||||||
System.out.println(" groups "
|
.convertEntry(entry);
|
||||||
+ entry.getGroups());
|
if (re != null) {
|
||||||
System.out.println(" name " + entry.getName());
|
getRosterManager().getRoster().addRosterEntry(re);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -554,31 +589,36 @@ public class SessionManager implements IEventPublisher {
|
||||||
|
|
||||||
if (changedValue instanceof IRosterEntry) {
|
if (changedValue instanceof IRosterEntry) {
|
||||||
IRosterEntry re = (IRosterEntry) changedValue;
|
IRosterEntry re = (IRosterEntry) changedValue;
|
||||||
System.out.println("Roster update RosterEntry "
|
System.out.println("Roster update RosterEntry "
|
||||||
+ re.getUser());
|
+ re.getUser());
|
||||||
System.out.println(" groups "
|
System.out.println(" groups "
|
||||||
+ re.getGroups());
|
+ re.getGroups());
|
||||||
System.out.println(" name " + re.getName());
|
System.out.println(" name " +
|
||||||
|
re.getName());
|
||||||
} else if (changedValue instanceof IRosterGroup) {
|
} else if (changedValue instanceof IRosterGroup) {
|
||||||
IRosterGroup rg = (IRosterGroup) changedValue;
|
IRosterGroup rg = (IRosterGroup) changedValue;
|
||||||
System.out.println("Roster update RosterGroup "
|
|
||||||
+ rg.getName());
|
|
||||||
System.out.println(" entries "
|
System.out.println("Roster update RosterGroup "
|
||||||
+ rg.getEntries());
|
+ rg.getName());
|
||||||
System.out.println(" name " + rg.getName());
|
System.out.println(" entries "
|
||||||
|
+ rg.getEntries());
|
||||||
|
System.out.println(" name " +
|
||||||
|
rg.getName());
|
||||||
} else if (changedValue instanceof IRoster) {
|
} else if (changedValue instanceof IRoster) {
|
||||||
IRoster r = (IRoster) changedValue;
|
IRoster r = (IRoster) changedValue;
|
||||||
System.out.println("Roster update Roster "
|
System.out.println("Roster update Roster "
|
||||||
+ r.getName());
|
+ r.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleRosterEntryRemove(IRosterEntry entry) {
|
public void handleRosterEntryRemove(IRosterEntry entry) {
|
||||||
System.out.println("Roster " + entry.getUser());
|
System.out.println("Roster " + entry.getUser());
|
||||||
System.out.println(" groups "
|
System.out.println(" groups "
|
||||||
+ entry.getGroups());
|
+ entry.getGroups());
|
||||||
System.out.println(" name " + entry.getName());
|
System.out.println(" name " +
|
||||||
|
entry.getName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue