From b4d930bcb90efb5bab04530498f698c6c9bee72f Mon Sep 17 00:00:00 2001 From: Brian Clements Date: Mon, 27 Jan 2014 17:21:17 -0600 Subject: [PATCH] Issue #2700 added contact request dialog user is now prompted to accept contact request added support for managing contacts that haven't accepted contact requests contacts list shows new icon for contacts that haven't accepted contact requests Former-commit-id: bd19366ada2a6a12c03e4cc1ce48fe7a4aec0acd [formerly 8ad4c1674d2719a7781eb137669eb15212a1488c] Former-commit-id: 6b1843f19a58f32a658dcf5a1760e955d60cebcb --- .../comm/identity/IAccountManager.java | 29 ++- .../roster/ISubscriptionResponder.java | 17 +- .../comm/provider/session/AccountManager.java | 90 ++++++-- .../comm/provider/user/ContactsManager.java | 61 ++++- .../icons/blocked.gif | Bin 0 -> 104 bytes .../ui/AbstractUserLabelProvider.java | 50 +++- .../ui/CollaborationGroupView.java | 58 ++--- .../ui/ConnectionSubscriber.java | 16 +- .../ui/SiteConfigurationManager.java | 13 +- .../collaboration/ui/SubRequestDialog.java | 183 +++++++++++++++ .../ui/UsersTreeContentProvider.java | 13 +- .../ui/UsersTreeLabelProvider.java | 11 +- .../ui/actions/SendSubReqAction.java | 81 +++++++ .../prefs/AutoSubscribePropertyListener.java | 215 ++++++++++++++++++ .../ui/prefs/CollabPrefConstants.java | 3 + .../ui/prefs/CollabPrefInitializer.java | 2 + .../ui/prefs/CollaborationPreferencePage.java | 7 + 17 files changed, 751 insertions(+), 98 deletions(-) create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/icons/blocked.gif create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/SubRequestDialog.java create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/SendSubReqAction.java create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/AutoSubscribePropertyListener.java diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/IAccountManager.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/IAccountManager.java index 3d9f0faae0..acaabd5072 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/IAccountManager.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/IAccountManager.java @@ -24,6 +24,7 @@ import java.util.Map; import org.jivesoftware.smack.packet.Presence; import com.raytheon.uf.viz.collaboration.comm.identity.roster.ISubscriptionResponder; +import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; /** * Chat server account management interface @@ -45,6 +46,8 @@ import com.raytheon.uf.viz.collaboration.comm.identity.roster.ISubscriptionRespo * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Mar 16, 2012 jkorman Initial creation + * Jan 27, 2014 2700 bclement reworked responder methods + * added method to send presence without updating status * * * @@ -54,24 +57,25 @@ import com.raytheon.uf.viz.collaboration.comm.identity.roster.ISubscriptionRespo public interface IAccountManager { - /** - * Disable automatically accepting subscribe requests - */ - public void disableAutoSubscribe(); /** - * @return true if automatically accepts subscribe requests + * @return true if there is a request responder set to handle subscription + * requests and events. If there is not a responder set, the default + * action is to accept all requests. */ - public boolean autoSubscribeEnabled(); + public boolean isSubscriptionRequestResponderSet(); /** + * Set a responder to handle subscription requests and events (ie prompt + * user for authorization) * * @param responder */ public void setSubscriptionRequestResponder(ISubscriptionResponder responder); /** - * Removes the current subscription request responder. + * Removes the current subscription request responder. The default action + * without a responder is to accept all requests. */ public void removeSubscriptionRequestResponder(); @@ -121,4 +125,15 @@ public interface IAccountManager { * @throws CollaborationException */ public void sendPresence(Presence presence) throws CollaborationException; + + /** + * Send presence packet directly to user. This does not affect the account's + * current presence. + * + * @param toId + * @param userPresence + * @throws CollaborationException + */ + public void sendPresence(UserId toId, Presence userPresence) + throws CollaborationException; } diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/roster/ISubscriptionResponder.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/roster/ISubscriptionResponder.java index 56844a4ae1..5eb83929ef 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/roster/ISubscriptionResponder.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/roster/ISubscriptionResponder.java @@ -19,9 +19,7 @@ **/ package com.raytheon.uf.viz.collaboration.comm.identity.roster; -import org.jivesoftware.smack.packet.Presence; - -import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; +import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; /** * Interface for handling subscription invitation events from other users @@ -33,6 +31,8 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Mar 16, 2012 jkorman Initial creation + * Jan 27, 2014 2700 bclement handle subscribe request returns a boolean + * all methods take user id instead of qualified id * * * @@ -43,22 +43,25 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; public interface ISubscriptionResponder { /** + * Triggered when a contact requests a presence subscription * * @param fromID - * @return The response that should be returned to the subscriber. + * @return true if the subscribe request is accepted. */ - public Presence.Type handleSubscribeRequest(IQualifiedID fromID); + public boolean handleSubscribeRequest(UserId fromID); /** + * Triggered when a contact subscribes to user * * @param fromID */ - public void handleSubscribed(IQualifiedID fromID); + public void handleSubscribed(UserId fromID); /** + * Triggered when a contact unsubscribes to user * * @param fromID */ - public void handleUnsubscribed(IQualifiedID fromID); + public void handleUnsubscribed(UserId fromID); } diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/AccountManager.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/AccountManager.java index 76671ee933..ed4d30da21 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/AccountManager.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/AccountManager.java @@ -23,6 +23,7 @@ import java.util.Arrays; import java.util.Map; import org.jivesoftware.smack.PacketListener; +import org.jivesoftware.smack.RosterEntry; import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.filter.PacketTypeFilter; import org.jivesoftware.smack.packet.Packet; @@ -35,8 +36,12 @@ import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; import com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager; 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.IRosterChangeEvent; +import com.raytheon.uf.viz.collaboration.comm.identity.event.RosterChangeType; import com.raytheon.uf.viz.collaboration.comm.identity.roster.ISubscriptionResponder; +import com.raytheon.uf.viz.collaboration.comm.provider.event.RosterChangeEvent; import com.raytheon.uf.viz.collaboration.comm.provider.event.UserPresenceChangedEvent; +import com.raytheon.uf.viz.collaboration.comm.provider.user.ContactsManager; import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; @@ -58,6 +63,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; * Mar 16, 2012 jkorman Initial creation * Dec 6, 2013 2561 bclement removed ECF * Jan 07, 2013 2563 bclement fixed id parsing in auto responder + * Jan 27, 2014 2700 bclement changes to subscription request responders * * * @@ -69,7 +75,12 @@ public class AccountManager implements IAccountManager { private final IUFStatusHandler log = UFStatus.getHandler(this.getClass()); - private PacketListener autoResponder = new PacketListener() { + /** + * Listens for subscription events including subscription requests. If the + * subscription responder is null, the default action is to accept + * subscription requests. + */ + private PacketListener subscriptionEventListener = new PacketListener() { @Override public void processPacket(Packet packet) { @@ -82,17 +93,23 @@ public class AccountManager implements IAccountManager { UserId fromId = IDConverter.convertFrom(pres.getFrom()); switch (type) { case subscribe: - handleSubRequest(fromId); + boolean accept = true; + if (responder != null) { + accept = responder.handleSubscribeRequest(fromId); + } + handleSubRequest(fromId, accept); break; case subscribed: if (responder != null) { responder.handleSubscribed(fromId); } + handleSubscribed(fromId); break; case unsubscribed: if (responder != null) { responder.handleUnsubscribed(fromId); } + handleUnsubscribed(fromId); break; default: // do nothing @@ -101,16 +118,58 @@ public class AccountManager implements IAccountManager { } } - private void handleSubRequest(UserId fromId) { + /** + * notify UI that someone subscribed to user + * + * @param fromID + */ + private void handleSubscribed(UserId fromID) { + ContactsManager cm = sessionManager.getContactsManager(); + RosterEntry entry = cm.getRosterEntry((UserId) fromID); + IRosterChangeEvent event = new RosterChangeEvent( + RosterChangeType.ADD, entry); + sessionManager.postEvent(event); + } + + /** + * notify UI that someone unsubscribed to user + * + * @param fromID + */ + private void handleUnsubscribed(UserId fromID) { + ContactsManager cm = sessionManager.getContactsManager(); + RosterEntry entry = cm.getRosterEntry((UserId) fromID); + if (entry == null) { + return; + } + IRosterChangeEvent event = new RosterChangeEvent( + RosterChangeType.DELETE, entry); + sessionManager.postEvent(event); + } + + /** + * process subscription request + * + * @param fromId + */ + private void handleSubRequest(UserId fromId, boolean accept) { Presence.Type subscribedType; - if (responder != null) { - subscribedType = responder.handleSubscribeRequest(fromId); + + if (accept) { + ContactsManager cm = sessionManager.getContactsManager(); + RosterEntry entry = cm.getRosterEntry(fromId); + if (entry == null || ContactsManager.isBlocked(entry)) { + // we aren't subscribed to them, subscribe back + subscribedType = Presence.Type.subscribe; + } else { + // we are already subscribed, let them know + subscribedType = Presence.Type.subscribed; + } } else { - subscribedType = Presence.Type.subscribed; + subscribedType = Presence.Type.unsubscribed; } - Presence presence = new Presence(subscribedType, null, 0, - Presence.Mode.available); + Presence presence = new Presence(subscribedType); try { sendPresence(fromId, presence); } catch (CollaborationException e) { @@ -135,20 +194,10 @@ public class AccountManager implements IAccountManager { sessionManager = manager; smackManager = new org.jivesoftware.smack.AccountManager( manager.getXmppConnection()); - sessionManager.getXmppConnection().addPacketListener(autoResponder, + sessionManager.getXmppConnection().addPacketListener(subscriptionEventListener, new PacketTypeFilter(Presence.class)); } - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager# - * disableAutoSubscribe() - */ - public void disableAutoSubscribe() { - responder = null; - } - /* * (non-Javadoc) * @@ -156,7 +205,7 @@ public class AccountManager implements IAccountManager { * autoSubscribeEnabled() */ @Override - public boolean autoSubscribeEnabled() { + public boolean isSubscriptionRequestResponderSet() { return responder != null; } @@ -274,7 +323,6 @@ public class AccountManager implements IAccountManager { throws CollaborationException { userPresence.setFrom(sessionManager.getUser().getFQName()); userPresence.setTo(toId.getNormalizedId()); - sessionManager.setPresence(userPresence); sessionManager.getXmppConnection().sendPacket(userPresence); } diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/user/ContactsManager.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/user/ContactsManager.java index 4e1a827146..9abc9bc0ff 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/user/ContactsManager.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/user/ContactsManager.java @@ -34,6 +34,8 @@ import org.jivesoftware.smack.RosterGroup; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.packet.Presence; +import org.jivesoftware.smack.packet.RosterPacket.ItemStatus; +import org.jivesoftware.smack.packet.RosterPacket.ItemType; import org.jivesoftware.smack.packet.XMPPError; import org.jivesoftware.smackx.SharedGroupManager; @@ -64,6 +66,8 @@ import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConn * Jan 24, 2014 2701 bclement removed roster manager * switched local groups to roster groups * added shared groups + * Jan 27, 2014 2700 bclement fixed ungrouped entries being out of date + * added utility methods for subscription status * * * @@ -567,7 +571,62 @@ public class ContactsManager { * @return */ public Collection getNonGroupedContacts() { - return getRoster().getUnfiledEntries(); + Collection unfiled = getRoster().getUnfiledEntries(); + List rval = new ArrayList(unfiled.size()); + for (RosterEntry entry : unfiled) { + if (isBlocked(entry)) { + // check to see if we are really blocked + entry = update(entry); + } + if (hasInteraction(entry)) { + rval.add(entry); + } + } + return rval; + } + + /** + * Get updated entry from roster. This is a work around for a smack + * limitation where unfiled entry objects are not updated when the roster + * entry objects are. + * + * @param entry + * @return + */ + public RosterEntry update(RosterEntry entry) { + RosterEntry rval = searchRoster(entry.getUser()); + return rval != null ? rval : entry; + } + + /** + * @param entry + * @return true if we are blocked from seeing updates from user in entry + */ + public static boolean isBlocked(RosterEntry entry) { + ItemType type = entry.getType(); + return type != null + && (type.equals(ItemType.none) || type.equals(ItemType.from)); + } + + /** + * Test for interaction between this user and entry. Returns true if either + * has a subscription to the other or there is a pending subscription + * request. + * + * @param entry + * @return + */ + public static boolean hasInteraction(RosterEntry entry) { + ItemType type = entry.getType(); + boolean rval = true; + if (type != null) { + if (type.equals(ItemType.none)) { + ItemStatus status = entry.getStatus(); + rval = status != null + && status.equals(ItemStatus.SUBSCRIPTION_PENDING); + } + } + return rval; } /** diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/icons/blocked.gif b/cave/com.raytheon.uf.viz.collaboration.ui/icons/blocked.gif new file mode 100644 index 0000000000000000000000000000000000000000..5a08c945b014abf4edb34aedad3301a0bc8784e9 GIT binary patch literal 104 zcmZ?wbhEHb6krfwXkcXc&j137{{)?jQWHy3QxwWGOEMJPJ$(Zh6o0ZXaxpM6=zvs! zlru1C_4Kb~ * @@ -57,10 +63,14 @@ public abstract class AbstractUserLabelProvider extends ColumnLabelProvider { @Override public String getText(Object element) { - if (!(element instanceof UserId)) { + UserId user; + if (element instanceof UserId) { + user = (UserId) element; + } else if ( element instanceof RosterEntry){ + user = IDConverter.convertFrom((RosterEntry) element); + } else { return null; } - UserId user = (UserId) element; StringBuilder name = new StringBuilder(); name.append(getDisplayName(user)); Presence presence = getPresence(user); @@ -80,13 +90,17 @@ public abstract class AbstractUserLabelProvider extends ColumnLabelProvider { } return name.toString(); } - + @Override public Image getImage(Object element) { - if (!(element instanceof UserId)) { + UserId user; + if (element instanceof UserId) { + user = (UserId) element; + } else if (element instanceof RosterEntry) { + user = IDConverter.convertFrom((RosterEntry) element); + } else { return null; } - UserId user = (UserId) element; Presence presence = getPresence(user); String key = ""; if (presence != null && presence.getType() == Type.available) { @@ -98,6 +112,11 @@ public abstract class AbstractUserLabelProvider extends ColumnLabelProvider { } else { key = "contact_disabled"; } + if (element instanceof RosterEntry) { + if (ContactsManager.isBlocked((RosterEntry) element)) { + key = "blocked"; + } + } if (imageMap.get(key) == null && !key.equals("")) { imageMap.put(key, CollaborationUtils.getNodeImage(key)); } @@ -106,16 +125,20 @@ public abstract class AbstractUserLabelProvider extends ColumnLabelProvider { @Override public String getToolTipText(Object element) { - if (!(element instanceof UserId)) { + UserId user; + if (element instanceof UserId) { + user = (UserId) element; + } else if (element instanceof RosterEntry) { + user = IDConverter.convertFrom((RosterEntry) element); + } else { return null; } - UserId user = (UserId) element; Presence presence = getPresence(user); StringBuilder text = new StringBuilder(); text.append("Name: ").append(getDisplayName(user)).append("\n"); text.append("Status: "); if (presence == null || presence.getType() != Type.available) { - text.append("Offline\n"); + text.append("Offline \n"); } else { text.append(CollaborationUtils.formatMode(presence.getMode())) .append("\n"); @@ -130,6 +153,17 @@ public abstract class AbstractUserLabelProvider extends ColumnLabelProvider { } } } + if (element instanceof RosterEntry) { + RosterEntry entry = (RosterEntry) element; + ItemType type = entry.getType(); + if (type != null) { + text.append("Subscription: ").append(type).append("\n"); + } + ItemStatus status = entry.getStatus(); + if (status != null) { + text.append(status).append(" pending\n"); + } + } // delete trailing newline text.deleteCharAt(text.length() - 1); return text.toString(); diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java index 84526b0e6b..1fb00992c2 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java @@ -111,6 +111,7 @@ import com.raytheon.uf.viz.collaboration.ui.actions.LogoutAction; import com.raytheon.uf.viz.collaboration.ui.actions.PeerToPeerChatAction; import com.raytheon.uf.viz.collaboration.ui.actions.RemoveFromGroupAction; import com.raytheon.uf.viz.collaboration.ui.actions.RemoveFromRosterAction; +import com.raytheon.uf.viz.collaboration.ui.actions.SendSubReqAction; import com.raytheon.uf.viz.collaboration.ui.actions.ShowVenueAction; import com.raytheon.uf.viz.collaboration.ui.actions.UserSearchAction; import com.raytheon.uf.viz.collaboration.ui.data.AlertWordWrapper; @@ -138,6 +139,7 @@ import com.raytheon.viz.ui.views.CaveFloatingView; * Dec 20, 2013 2563 bclement fixed support for ungrouped roster items * Jan 24, 2014 2701 bclement removed local groups, added shared groups * removed option to create empty group + * Jan 27, 2014 2700 bclement fixed context menu for roster entries * * * @@ -391,18 +393,33 @@ public class CollaborationGroupView extends CaveFloatingView implements manager.add(new ArchiveViewerAction((IVenueSession) o)); return; } else if (o instanceof RosterEntry) { - // roster entries that are not in a group RosterEntry entry = (RosterEntry) o; UserId user = IDConverter.convertFrom(entry); addOnlineMenuOptions(manager, selection, user); addAliasAction(manager, selection, user); manager.add(new ArchiveViewerAction(user)); - manager.add(new AddToGroupAction(entry)); - manager.add(new RemoveFromRosterAction(entry)); + manager.add(new AddToGroupAction(getSelectedUsers())); + String groupName = null; + Object group = selection.getPaths()[0].getFirstSegment(); + if (group instanceof RosterGroup) { + groupName = ((RosterGroup) group).getName(); + manager.add(new RemoveFromGroupAction(groupName, + getSelectedUsers())); + } else if (!(group instanceof SharedGroup)) { + manager.add(new RemoveFromRosterAction(entry)); + } + if (ContactsManager.isBlocked(entry)) { + manager.add(new SendSubReqAction(entry)); + } } else if (o instanceof UserId) { - // the user, both the logged in user as well as entries in groups + // the user UserId user = (UserId) o; - fillContextMenu(manager, selection, user); + CollaborationConnection connection = CollaborationConnection + .getConnection(); + UserId me = connection.getUser(); + if (me.isSameUser(user)) { + createMenu(manager); + } } else if (o instanceof RosterGroup || o instanceof SharedGroup) { manager.add(createSessionAction); if (o instanceof RosterGroup) { @@ -414,36 +431,6 @@ public class CollaborationGroupView extends CaveFloatingView implements } } } - - /** - * Populate menu for roster entries. Checks for current user to create - * appropriate menu. - * - * @param manager - * @param selection - * @param user - */ - private void fillContextMenu(IMenuManager manager, TreeSelection selection, - UserId user) { - CollaborationConnection connection = CollaborationConnection - .getConnection(); - UserId me = connection.getUser(); - if (me.isSameUser(user)) { - createMenu(manager); - return; - } - addOnlineMenuOptions(manager, selection, user); - addAliasAction(manager, selection, user); - - manager.add(new ArchiveViewerAction(user)); - manager.add(new AddToGroupAction(getSelectedUsers())); - String groupName = null; - Object group = selection.getPaths()[0].getFirstSegment(); - if (group instanceof RosterGroup) { - groupName = ((RosterGroup) group).getName(); - manager.add(new RemoveFromGroupAction(groupName, getSelectedUsers())); - } - } /** * Add interaction menu options for contact if they are online @@ -905,6 +892,7 @@ public class CollaborationGroupView extends CaveFloatingView implements @Override public void groupDeleted(RosterGroup group) { + refreshUsersTreeViewerAsync(group); refreshUsersTreeViewerAsync(usersTreeViewer.getInput()); } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/ConnectionSubscriber.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/ConnectionSubscriber.java index 5f5802e592..1972cc663b 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/ConnectionSubscriber.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/ConnectionSubscriber.java @@ -50,6 +50,7 @@ import com.raytheon.uf.viz.collaboration.display.data.SessionColorManager; import com.raytheon.uf.viz.collaboration.display.data.SharedDisplaySessionMgr; import com.raytheon.uf.viz.collaboration.ui.actions.PeerToPeerChatAction; import com.raytheon.uf.viz.collaboration.ui.jobs.AwayTimeOut; +import com.raytheon.uf.viz.collaboration.ui.prefs.AutoSubscribePropertyListener; import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants; import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView; import com.raytheon.uf.viz.collaboration.ui.session.PeerToPeerView; @@ -69,7 +70,8 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager; * ------------ ---------- ----------- -------------------------- * Jun 8, 2012 njensen Initial creation * Dec 18, 2013 2562 bclement fixed venue invite - * Jan 14, 2014 2630 bclement added away timeout + * Jan 14, 2014 2630 bclement added away timeout + * Jan 27, 2014 2700 bclement added auto subscribe property listener * * * @@ -89,7 +91,11 @@ public class ConnectionSubscriber { private final AwayTimeOut awayTimeOut = new AwayTimeOut(); private ConnectionSubscriber() { - + Activator + .getDefault() + .getPreferenceStore() + .addPropertyChangeListener( + AutoSubscribePropertyListener.getInstance()); } /** @@ -121,6 +127,9 @@ public class ConnectionSubscriber { private void setup(final CollaborationConnection connection) { if (connection != null) { + AutoSubscribePropertyListener autoSub = AutoSubscribePropertyListener + .getInstance(); + autoSub.initialize(connection); // Register handlers and events for the new sessionManager. connection.registerEventHandler(this); try { @@ -164,6 +173,9 @@ public class ConnectionSubscriber { "Error unregistering peer to peer handler", e); } connection.unregisterEventHandler(this); + AutoSubscribePropertyListener autoSub = AutoSubscribePropertyListener + .getInstance(); + autoSub.close(); } PlatformUI.getWorkbench().removeWorkbenchListener(wbListener); } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/SiteConfigurationManager.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/SiteConfigurationManager.java index 42b7d137ab..d137ee83d4 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/SiteConfigurationManager.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/SiteConfigurationManager.java @@ -64,6 +64,7 @@ import com.raytheon.uf.viz.collaboration.ui.SiteColorInformation.SiteColor; * Jun 12, 2012 mnash Initial creation * Jan 08, 2014 2563 bclement duplicate code elimination * added methods to partially modify user config + * Jan 27, 2014 2700 bclement fixed null list from jaxb object * * * @@ -470,10 +471,12 @@ public class SiteConfigurationManager { */ public static List getSubscribeList(String site) { List subscribed = new ArrayList(); - for (SiteConfig config : instance.getConfig()) { - if (config.getSite().equals(site)) { - subscribed = Arrays.asList(config.getSubscribedSites()); - break; + if (instance.getConfig() != null) { + for (SiteConfig config : instance.getConfig()) { + if (config.getSite().equals(site)) { + subscribed = Arrays.asList(config.getSubscribedSites()); + break; + } } } return subscribed; @@ -491,7 +494,7 @@ public class SiteConfigurationManager { if (userInstance == null) { readUserSiteConfigInformation(); } - if (userInstance != null) { + if (userInstance != null && userInstance.getConfig() != null) { for (SiteConfig config : userInstance.getConfig()) { if (config.getSubscribedSites() != null) { subscribed = new ArrayList(); diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/SubRequestDialog.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/SubRequestDialog.java new file mode 100644 index 0000000000..bde2600723 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/SubRequestDialog.java @@ -0,0 +1,183 @@ +/** + * 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.ui; + +import java.util.Collection; +import java.util.Iterator; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.window.IShellProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.jivesoftware.smack.RosterGroup; + +import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection; +import com.raytheon.uf.viz.collaboration.comm.provider.user.ContactsManager; +import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; + +/** + * Dialog to respond to a chat subscription request + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jan 27, 2014 2700       bclement     Initial creation
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public class SubRequestDialog extends Dialog { + + private final String title; + + private final String message; + + private final UserId userid; + + private Combo groupCombo; + + /** + * @param parentShell + */ + public SubRequestDialog(Shell parentShell, String title, String message, + UserId userid) { + super(parentShell); + this.title = title; + this.message = message; + this.userid = userid; + } + + /** + * @param parentShell + */ + public SubRequestDialog(IShellProvider parentShell, String title, + String message, UserId userid) { + super(parentShell); + this.title = title; + this.message = message; + this.userid = userid; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) + */ + @Override + protected void buttonPressed(int buttonId) { + if (buttonId == IDialogConstants.OK_ID) { + int count = groupCombo.getItemCount(); + int index = groupCombo.getSelectionIndex(); + String group = null; + if ( index == count - 1){ + // new group + CreateGroupDialog dialog = new CreateGroupDialog(Display + .getCurrent().getActiveShell()); + dialog.open(); + group = dialog.getNewGroup(); + } else if ( index >= 0){ + group = groupCombo.getItem(index); + } + CollaborationConnection connection = CollaborationConnection.getConnection(); + if ( group != null && connection != null){ + ContactsManager cm = connection.getContactsManager(); + cm.addToGroup(group, userid); + } + } + super.buttonPressed(buttonId); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + @Override + protected Control createDialogArea(Composite parent) { + Composite container = (Composite) super.createDialogArea(parent); + + new Label(container, SWT.NONE).setText(message); + + Composite groupComposite = new Composite(container, SWT.NONE); + groupComposite.setLayout(new GridLayout(2, false)); + groupComposite.setLayoutData(new GridData(SWT.LEFT, SWT.DEFAULT, + true, false)); + new Label(groupComposite, SWT.NONE).setText("Group: "); + + groupCombo = new Combo(groupComposite, SWT.BORDER | SWT.READ_ONLY + | SWT.DROP_DOWN); + groupCombo.setItems(getGroupNames()); + + return container; + } + + /** + * @return list of existing group names + */ + private String[] getGroupNames() { + CollaborationConnection connection = CollaborationConnection + .getConnection(); + if (connection == null) { + return new String[0]; + } + Collection groups = connection.getContactsManager() + .getGroups(); + String[] rval = new String[groups.size() + 1]; + Iterator iter = groups.iterator(); + int i = 0; + for (; iter.hasNext(); ++i) { + rval[i] = iter.next().getName(); + } + rval[i] = "New Group..."; + return rval; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) + */ + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(title); + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse + * .swt.widgets.Composite) + */ + @Override + protected void createButtonsForButtonBar(Composite parent) { + createButton(parent, IDialogConstants.OK_ID, "Allow", true); + createButton(parent, IDialogConstants.CANCEL_ID, "Deny", false); + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeContentProvider.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeContentProvider.java index 7ad8dae547..94e5ac0a12 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeContentProvider.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeContentProvider.java @@ -32,7 +32,7 @@ import org.jivesoftware.smack.RosterEntry; import org.jivesoftware.smack.RosterGroup; import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection; -import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter; +import com.raytheon.uf.viz.collaboration.comm.provider.user.ContactsManager; import com.raytheon.uf.viz.collaboration.comm.provider.user.SharedGroup; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; import com.raytheon.uf.viz.collaboration.ui.data.CollaborationGroupContainer; @@ -50,6 +50,7 @@ import com.raytheon.uf.viz.collaboration.ui.data.SessionGroupContainer; * Mar 1, 2012 rferrel Initial creation * Dec 6, 2013 2561 bclement removed ECF * Jan 24, 2014 2701 bclement removed local groups, added shared groups + * Jan 27, 2014 2700 bclement added support roster entries * * * @@ -135,12 +136,14 @@ public class UsersTreeContentProvider implements ITreeContentProvider { * @return */ private Object[] getRosterChildren(Collection entries) { - List result = new ArrayList(); - UserId localUser = CollaborationConnection.getConnection().getUser(); + List result = new ArrayList(); + CollaborationConnection connection = CollaborationConnection.getConnection(); + UserId localUser = connection.getUser(); for (RosterEntry entry : entries) { String user = entry.getUser(); - if (!localUser.isSameUser(user)) { - result.add(IDConverter.convertFrom(entry)); + if (!localUser.isSameUser(user) + && ContactsManager.hasInteraction(entry)) { + result.add(entry); } } return result.toArray(); diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeLabelProvider.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeLabelProvider.java index a7e9c0df3c..d8c38f13b0 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeLabelProvider.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeLabelProvider.java @@ -42,7 +42,6 @@ import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo; import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection; -import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter; import com.raytheon.uf.viz.collaboration.comm.provider.user.SharedGroup; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; import com.raytheon.uf.viz.collaboration.ui.data.SessionGroupContainer; @@ -60,6 +59,7 @@ import com.raytheon.uf.viz.collaboration.ui.data.SessionGroupContainer; * Dec 6, 2013 2561 bclement removed ECF * Dec 20, 2013 2563 bclement fixed support for ungrouped roster items * Jan 24, 2014 2701 bclement removed local groups, added shared groups + * Jan 27, 2014 2700 bclement pass roster entries directly to userLabelProvider * * * @@ -103,8 +103,7 @@ public class UsersTreeLabelProvider extends ColumnLabelProvider { if (element instanceof UserId) { return userLabelProvider.getImage(element); } else if (element instanceof RosterEntry) { - return userLabelProvider.getImage(IDConverter - .convertFrom((RosterEntry) element)); + return userLabelProvider.getImage((RosterEntry) element); } else if (element instanceof RosterGroup) { key = "roster_group"; } else if (element instanceof SharedGroup) { @@ -128,8 +127,7 @@ public class UsersTreeLabelProvider extends ColumnLabelProvider { } else if (element instanceof SharedGroup) { return ((SharedGroup) element).getName(); } else if (element instanceof RosterEntry) { - return userLabelProvider.getText(IDConverter - .convertFrom((RosterEntry) element)); + return userLabelProvider.getText((RosterEntry) element); } else if (element instanceof SessionGroupContainer) { return "Active Sessions"; } else if (element instanceof UserId) { @@ -185,8 +183,7 @@ public class UsersTreeLabelProvider extends ColumnLabelProvider { if (element instanceof UserId) { return userLabelProvider.getToolTipText(element); } else if (element instanceof RosterEntry) { - return userLabelProvider.getToolTipText(IDConverter - .convertFrom((RosterEntry) element)); + return userLabelProvider.getToolTipText((RosterEntry) element); } // builds the tooltip text for the session group // portion of the view diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/SendSubReqAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/SendSubReqAction.java new file mode 100644 index 0000000000..4f1ce04b1f --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/SendSubReqAction.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.ui.actions; + +import org.eclipse.jface.action.Action; +import org.jivesoftware.smack.RosterEntry; +import org.jivesoftware.smack.packet.Presence; +import org.jivesoftware.smack.packet.Presence.Type; + +import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; +import com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager; +import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection; +import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter; +import com.raytheon.uf.viz.collaboration.ui.Activator; + +/** + * Action to send a subscription request to a user + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jan 24, 2014            bclement     Initial creation
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public class SendSubReqAction extends Action { + + private final RosterEntry entry; + + + /** + * @param entry + * roster entry to request a subscription to + */ + public SendSubReqAction(RosterEntry entry) { + super("Send Contact Request"); + this.entry = entry; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.action.Action#run() + */ + @Override + public void run() { + CollaborationConnection connection = CollaborationConnection.getConnection(); + IAccountManager manager = connection.getAccountManager(); + try { + manager.sendPresence(IDConverter.convertFrom(entry), new Presence( + Type.subscribe)); + } catch (CollaborationException e) { + Activator.statusHandler.error( + "Unable to send subscription request", e); + } + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/AutoSubscribePropertyListener.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/AutoSubscribePropertyListener.java new file mode 100644 index 0000000000..6f87141a71 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/AutoSubscribePropertyListener.java @@ -0,0 +1,215 @@ +/** + * 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.ui.prefs; + +import java.util.List; + +import org.eclipse.jface.preference.IPersistentPreferenceStore; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.jivesoftware.smack.XMPPException; + +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager; +import com.raytheon.uf.viz.collaboration.comm.identity.roster.ISubscriptionResponder; +import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection; +import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; +import com.raytheon.uf.viz.collaboration.comm.provider.user.UserSearch; +import com.raytheon.uf.viz.collaboration.ui.Activator; +import com.raytheon.uf.viz.collaboration.ui.SubRequestDialog; +import com.raytheon.uf.viz.core.VizApp; + +/** + * Listens to collaboration preferences and alters the subscription request + * handler as appropriate. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jan 24, 2014 2700       bclement     Initial creation
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public class AutoSubscribePropertyListener implements IPropertyChangeListener { + + private static final IUFStatusHandler log = UFStatus + .getHandler(AutoSubscribePropertyListener.class); + + private static AutoSubscribePropertyListener instance; + + private static final Object INSTANCE_MUTEX = new Object(); + + public static AutoSubscribePropertyListener getInstance() { + synchronized (INSTANCE_MUTEX) { + if (instance == null) { + instance = new AutoSubscribePropertyListener(); + } + } + return instance; + } + + private CollaborationConnection connection; + + private IAccountManager accountManager; + + private AutoSubscribePropertyListener() { + } + + /** + * Initialize auto subscribe state after login + * + * @param connection + */ + public synchronized void initialize(CollaborationConnection connection) { + this.connection = connection; + this.accountManager = connection.getAccountManager(); + updateManager(isAutoInPrefs()); + } + + /** + * Clean up auto subscribe state after logout + */ + public synchronized void close() { + this.accountManager = null; + this.connection = null; + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse + * .jface.util.PropertyChangeEvent) + */ + @Override + public void propertyChange(PropertyChangeEvent event) { + if (event.getProperty().equals( + CollabPrefConstants.AUTO_ACCEPT_SUBSCRIBE) + && accountManager != null) { + updateManager((Boolean) event.getNewValue()); + } + } + + /** + * @return true if preferences have auto accept enabled + */ + private boolean isAutoInPrefs() { + IPersistentPreferenceStore prefs = Activator.getDefault() + .getPreferenceStore(); + return prefs.getBoolean(CollabPrefConstants.AUTO_ACCEPT_SUBSCRIBE); + } + + /** + * Update auto subscribe state in account manager + * + * @param auto + */ + private void updateManager(boolean auto) { + // manager auto accepts by default if responder is not set + boolean accountManagerAutoAccepts = !accountManager + .isSubscriptionRequestResponderSet(); + // update if the settings don't match + if (auto != accountManagerAutoAccepts) { + if (auto) { + accountManager.removeSubscriptionRequestResponder(); + } else { + accountManager.setSubscriptionRequestResponder(newResponder()); + } + } + } + + /** + * Create responder to handle subscription requests + * + * @return + */ + private ISubscriptionResponder newResponder() { + return new ISubscriptionResponder() { + + private final UserSearch search = connection.createSearch(); + + @Override + public void handleUnsubscribed(UserId fromID) { + } + + @Override + public void handleSubscribed(UserId fromID) { + } + + @Override + public boolean handleSubscribeRequest(final UserId fromID) { + String displayName = getDisplayName(fromID); + StringBuilder builder = new StringBuilder(); + builder.append(fromID.getFQName()); + if ( displayName != null){ + builder.append(" (").append(displayName).append(")"); + } + builder.append(" wants to add you to his or her contacts list."); + final String msg = builder.toString(); + final boolean[] rval = new boolean[1]; + VizApp.runSync(new Runnable() { + + @Override + public void run() { + Shell shell = new Shell(Display.getCurrent()); + SubRequestDialog dlg = new SubRequestDialog(shell, + "Authorize Collaboration Contact", msg, fromID); + int index = dlg.open(); + rval[0] = index == Window.OK; + } + }); + + return rval[0]; + } + + /** + * Get display name for user from server + * + * @param fromID + * @return null if none found + */ + private String getDisplayName(UserId fromID) { + String rval = null; + try { + List users = search.byUsername(fromID.getName()); + if ( users != null && !users.isEmpty()){ + UserId user = users.get(0); + return user.getAlias(); + } + } catch (XMPPException e) { + log.error("Unable to get display name for user: " + fromID, + e); + } + return rval; + } + }; + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollabPrefConstants.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollabPrefConstants.java index 712ba41bad..57a5b9ab7a 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollabPrefConstants.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollabPrefConstants.java @@ -30,6 +30,7 @@ package com.raytheon.uf.viz.collaboration.ui.prefs; * ------------ ---------- ----------- -------------------------- * Apr 24, 2012 njensen Initial creation * Jan 14, 2014 2630 bclement added away on idle constants + * Jan 27, 2014 2700 bclement added auto accept subscribe * * * @@ -52,6 +53,8 @@ public class CollabPrefConstants { public static final String AWAY_TIMEOUT = "awayTimeOut"; + public static final String AUTO_ACCEPT_SUBSCRIBE = "autoAcceptSubscribe"; + public static final int AWAY_TIMEOUT_DEFAULT = 10; // ten minutes public class HttpCollaborationConfiguration { diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollabPrefInitializer.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollabPrefInitializer.java index 82b2c2ff58..37b3cdf442 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollabPrefInitializer.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollabPrefInitializer.java @@ -36,6 +36,7 @@ import com.raytheon.uf.viz.collaboration.ui.Activator; * ------------ ---------- ----------- -------------------------- * Apr 24, 2012 njensen Initial creation * Jan 14, 2014 2630 bclement added away on idle defaults + * Jan 27, 2014 2700 bclement added auto accept subscribe * * * @@ -67,6 +68,7 @@ public class CollabPrefInitializer extends AbstractPreferenceInitializer { store.setDefault(CollabPrefConstants.AWAY_ON_IDLE, true); store.setDefault(CollabPrefConstants.AWAY_TIMEOUT, CollabPrefConstants.AWAY_TIMEOUT_DEFAULT); + store.setDefault(CollabPrefConstants.AUTO_ACCEPT_SUBSCRIBE, false); } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferencePage.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferencePage.java index dd2ea485f7..fa6155ab5c 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferencePage.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferencePage.java @@ -40,6 +40,7 @@ import com.raytheon.uf.viz.collaboration.ui.Activator; * ------------ ---------- ----------- -------------------------- * Apr 27, 2012 mnash Initial creation * Jan 14, 2014 2630 bclement added away on idle + * Jan 27, 2014 2700 bclement added auto accept subscribe * * * @@ -90,6 +91,12 @@ public class CollaborationPreferencePage extends FieldEditorPreferencePage CollabPrefConstants.AWAY_TIMEOUT, "Minutes Before Becoming Idle:", getFieldEditorParent()); this.addField(awayTimeOut); + FieldEditor autoSubscribe = new BooleanFieldEditor( + CollabPrefConstants.AUTO_ACCEPT_SUBSCRIBE, + "Automatically Accept Contact Requests", + getFieldEditorParent()); + + this.addField(autoSubscribe); } /*