diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/IRosterChangeEvent.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/IRosterChangeEvent.java index 782268a151..5fef24d866 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/IRosterChangeEvent.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/IRosterChangeEvent.java @@ -19,6 +19,8 @@ **/ package com.raytheon.uf.viz.collaboration.comm.identity.event; +import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry; + /** * TODO Add Description * @@ -37,18 +39,17 @@ package com.raytheon.uf.viz.collaboration.comm.identity.event; */ public interface IRosterChangeEvent { - - public enum ChangeType { ADD, DELETE, MODIFY, }; /** - * - * @return + * Get the event type. + * @return The event type. */ - ChangeType getType(); - - - - + RosterChangeType getType(); + /** + * Get the changed entry + * @return The changed entry. + */ + IRosterEntry getEntry(); } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/IRosterEventSubscriber.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/IRosterEventSubscriber.java new file mode 100644 index 0000000000..6ec508b62c --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/IRosterEventSubscriber.java @@ -0,0 +1,41 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.comm.identity.event; + +/** + * TODO Add Description + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 11, 2012            jkorman     Initial creation
+ *
+ * 
+ * + * @author jkorman + * @version 1.0 + */ + +public interface IRosterEventSubscriber { + // Tag interface. +} diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/RosterChangeType.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/RosterChangeType.java new file mode 100644 index 0000000000..9a70f8528c --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/event/RosterChangeType.java @@ -0,0 +1,41 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.comm.identity.event; + +/** + * TODO Add Description + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 11, 2012            jkorman     Initial creation
+ *
+ * 
+ * + * @author jkorman + * @version 1.0 + */ + +public enum RosterChangeType { + ADD, DELETE, MODIFY, PRESENCE +} diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/RosterChangeEvent.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/RosterChangeEvent.java new file mode 100644 index 0000000000..61ffb3925a --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/event/RosterChangeEvent.java @@ -0,0 +1,81 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.comm.provider.event; + +import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent; +import com.raytheon.uf.viz.collaboration.comm.identity.event.RosterChangeType; +import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 11, 2012            jkorman     Initial creation
+ * 
+ * 
+ * + * @author jkorman + * @version 1.0 + */ + +public class RosterChangeEvent implements IRosterChangeEvent { + + private final RosterChangeType type; + + private final IRosterEntry entry; + + /** + * Create an instance of this event using the given type and + * entry. + * @param type The event type. + * @param entry The changed entry. + */ + public RosterChangeEvent(RosterChangeType type, IRosterEntry entry) { + this.type = type; + this.entry = entry; + } + + /** + * Get the event type. + * + * @return The event type. + * @see com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent#getType() + */ + @Override + public RosterChangeType getType() { + return type; + } + + /** + * Get the changed entry + * @return The changed entry. + * @see com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent#getEntry() + */ + @Override + public IRosterEntry getEntry() { + return entry; + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/RosterEventHandler.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/RosterEventHandler.java new file mode 100644 index 0000000000..d6035f2012 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/RosterEventHandler.java @@ -0,0 +1,91 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.collaboration.comm.provider.session; + +import java.util.Collection; + +import com.google.common.eventbus.Subscribe; +import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; +import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent; +import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry; +import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterGroup; + +/** + * TODO Add Description + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 11, 2012            jkorman     Initial creation
+ *
+ * 
+ * + * @author jkorman + * @version 1.0 + */ + +public class RosterEventHandler { + + + @Subscribe + public void eventHandler(IRosterChangeEvent event) { + + StringBuilder sb = new StringBuilder("-------------------------------------------------------\n"); + sb.append("RosterEventHandler.eventHandler("); + switch(event.getType()) { + + case ADD : { + sb.append("ADD)"); + break; + } + case MODIFY : { + sb.append("MODIFY)"); + break; + } + case DELETE : { + sb.append("DELETE)"); + break; + } + case PRESENCE : { + sb.append("PRESENCE)"); + break; + } + } + System.out.println(sb.toString()); + printRosterEntry(event.getEntry()); + } + + private void printRosterEntry(IRosterEntry entry) { + // System.out.println("handleRosterEntryAdd " + System.currentTimeMillis()); + System.out.println(" user : " + entry.getUser().getFQName()); + Collection groups = entry.getGroups(); + for(IRosterGroup group : groups) { + System.out.println(" " + group.getName()); + } + IPresence presence = entry.getPresence(); + if(presence != null) { + System.out.println(" pres : " + presence.getType() + " : " + presence.getMode()); + } + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SessionManager.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SessionManager.java index 9672925f83..f5cf49af89 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SessionManager.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SessionManager.java @@ -57,7 +57,10 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; import com.raytheon.uf.viz.collaboration.comm.identity.ISession; import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; import com.raytheon.uf.viz.collaboration.comm.identity.event.IEventPublisher; +import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent; +import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterEventSubscriber; import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent; +import com.raytheon.uf.viz.collaboration.comm.identity.event.RosterChangeType; import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo; import com.raytheon.uf.viz.collaboration.comm.identity.invite.SharedDisplayInvite; import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterManager; @@ -67,6 +70,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant; import com.raytheon.uf.viz.collaboration.comm.provider.Errors; 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.event.RosterChangeEvent; 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.roster.RosterEntry; @@ -87,6 +91,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; *
  • IConnectionStatusEvent : This event is posted when the * state of the underlying connection changes, reconnecting, connecting, * disconnected, for example.
  • + *
  • IRosterChangeEvent : This event is posted when roster changes have occurred.
  • *
  • --------------- : ---------------.
  • * * @@ -143,6 +148,10 @@ public class SessionManager implements IEventPublisher { private EventBus eventBus; + private IRosterEventSubscriber rosterEventSubscriber = null; + + RosterEventHandler rosterEventHandler = null; + /** * @throws CollaborationException * @throws ContainerCreateException @@ -150,7 +159,49 @@ public class SessionManager implements IEventPublisher { */ public SessionManager(String account, String password) throws CollaborationException { - // XMPPConnection.DEBUG_ENABLED = true; + this(account, password, (IRosterEventSubscriber) null); + } + + /** + * + * @param account + * The account name to connect to. + * @param password + * The password to use for connection. + * @param initialPresence + * The initial presence for the account name. + * @throws ContainerCreateException + * + */ + public SessionManager(String account, String password, + IPresence initialPresence) throws Exception { + this(account, password, (IRosterEventSubscriber) null); + if (accountManager != null) { + accountManager.sendPresence(initialPresence); + } + } + + /** + * + * The roster event subscriber must be ready to accept events before this + * constructor is called. + * + * @param account + * The account name to connect to. + * @param password + * The password to use for connection. + * @param rosterEventSubscriber + * A roster event subscriber. + * @throws CollaborationException + */ + public SessionManager(String account, String password, + IRosterEventSubscriber rosterEventSubscriber) + throws CollaborationException { + eventBus = new EventBus(); + if (rosterEventSubscriber != null) { + this.rosterEventSubscriber = rosterEventSubscriber; + eventBus.register(rosterEventSubscriber); + } try { container = ContainerFactory.getDefault().createContainer(PROVIDER); @@ -193,33 +244,13 @@ public class SessionManager implements IEventPublisher { setupAccountManager(); - eventBus = new EventBus(); - sessions = new HashMap(); setupInternalConnectionListeners(); setupInternalVenueInvitationListener(); setupP2PComm(presenceAdapter); getPeerToPeerSession(); - } - /** - * - * @param account - * The account name to connect to. - * @param password - * The password to use for connection. - * @param initialPresence - * The initial presence for the account name. - * @throws ContainerCreateException - * - */ - public SessionManager(String account, String password, - IPresence initialPresence) throws Exception { - this(account, password); - if (accountManager != null) { - accountManager.sendPresence(initialPresence); - } } /** @@ -338,7 +369,9 @@ public class SessionManager implements IEventPublisher { */ public void closeManager() { if (container != null) { - + if (rosterEventSubscriber != null) { + eventBus.unregister(rosterEventSubscriber); + } // Close any created sessions. for (ISession session : sessions.values()) { if ((chatInstance != null) && chatInstance.equals(session)) { @@ -442,6 +475,16 @@ public class SessionManager implements IEventPublisher { session.setCurrentDataProvider(me); session.setUserId(me); + IPresence presence = new Presence(); + presence.setProperty("DATA_PROVIDER", me.getFQName()); + presence.setProperty("SESSION_LEADER", me.getFQName()); + + presenceAdapter + .getRosterManager() + .getPresenceSender() + .sendPresenceUpdate(null, + Presence.convertPresence(presence)); + sessions.put(session.getSessionId(), session); } } @@ -591,32 +634,30 @@ public class SessionManager implements IEventPublisher { public void handleRosterEntryAdd(IRosterEntry entry) { com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry re = RosterEntry .convertEntry(entry); - if (re != null) { - getRosterManager().getRoster().addRosterEntry(re); - } + IRosterChangeEvent event = new RosterChangeEvent( + RosterChangeType.ADD, re); + eventBus.post(event); } @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; - + IRosterItem item) { + if (item instanceof IRosterEntry) { + com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry re = RosterEntry + .convertEntry((IRosterEntry) item); + IRosterChangeEvent event = new RosterChangeEvent( + RosterChangeType.MODIFY, re); + eventBus.post(event); + } else if (item instanceof IRosterGroup) { + IRosterGroup rg = (IRosterGroup) item; 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(" entries " + // + rg.getEntries()); + // System.out.println(" name " + + // rg.getName()); + } else if (item instanceof IRoster) { + IRoster r = (IRoster) item; System.out.println("Roster update Roster " + r.getName()); } @@ -624,13 +665,13 @@ public class SessionManager implements IEventPublisher { @Override public void handleRosterEntryRemove(IRosterEntry entry) { - System.out.println("Roster " + entry.getUser()); - System.out.println(" groups " - + entry.getGroups()); - System.out.println(" name " + entry.getName()); + com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry re = RosterEntry + .convertEntry((IRosterEntry) entry); + IRosterChangeEvent event = new RosterChangeEvent( + RosterChangeType.MODIFY, re); + eventBus.post(event); } }); - } // *************************** @@ -674,6 +715,7 @@ public class SessionManager implements IEventPublisher { XMPPRoomID room = (XMPPRoomID) roomID; venueId = new VenueId(); venueId.setName(room.getLongName()); + } if (venueId != null) { IQualifiedID id = IDConverter.convertFrom(from);