Issue #427 login data stored in preferences

Change-Id: I0ac9d34f6a7eaf8f6db80d6c573115bd43e2e11c

Former-commit-id: 287dae35ae3566f22a2d9e5a22760f3ef9d29ca2
This commit is contained in:
Nate Jensen 2012-04-24 14:11:27 -05:00
parent f4193b0e4e
commit c4afe61f01
15 changed files with 277 additions and 433 deletions

View file

@ -176,4 +176,8 @@
class="com.raytheon.uf.viz.collaboration.ui.rsc.rendering.WireframeShapeRenderingHandler"> class="com.raytheon.uf.viz.collaboration.ui.rsc.rendering.WireframeShapeRenderingHandler">
</renderingExtension> </renderingExtension>
</extension> </extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer class="com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefInitializer"/>
</extension>
</plugin> </plugin>

View file

@ -48,6 +48,7 @@ import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.status.UFStatus.Priority;
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.IPresence.Mode;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type;
import com.raytheon.uf.viz.collaboration.comm.identity.ISession; import com.raytheon.uf.viz.collaboration.comm.identity.ISession;
import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession; import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession;
@ -63,14 +64,12 @@ 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.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole; import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole;
import com.raytheon.uf.viz.collaboration.comm.provider.Presence;
import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage; import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage;
import com.raytheon.uf.viz.collaboration.comm.provider.roster.RosterEntry; import com.raytheon.uf.viz.collaboration.comm.provider.roster.RosterEntry;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection; 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.UserId;
import com.raytheon.uf.viz.collaboration.ui.SessionColorManager; import com.raytheon.uf.viz.collaboration.ui.SessionColorManager;
import com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor; import com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor;
import com.raytheon.uf.viz.collaboration.ui.login.LoginData;
import com.raytheon.uf.viz.collaboration.ui.login.LoginDialog; import com.raytheon.uf.viz.collaboration.ui.login.LoginDialog;
import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView; import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView;
import com.raytheon.uf.viz.collaboration.ui.session.PeerToPeerView; import com.raytheon.uf.viz.collaboration.ui.session.PeerToPeerView;
@ -102,11 +101,7 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
/** /**
* The connection to the server. * The connection to the server.
*/ */
private CollaborationConnection sessionManager; private CollaborationConnection connection;
private UserId loginId;
private LoginData loginData;
Shell shell; Shell shell;
@ -139,21 +134,6 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
return instance; return instance;
} }
public LoginData getLoginData() {
return loginData;
}
/**
* Converts the venu's Id into a string that usable for a view's secondary
* ID. This is the used as the key in the session Map.
*
* @param venueId
* @return sessionId
*/
public String venueIdToSessionId(String venueId) {
return venueId.replace(':', ';');
}
/** /**
* Private constructor to for singleton class. * Private constructor to for singleton class.
*/ */
@ -166,7 +146,7 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
} }
private void populateGroups() { private void populateGroups() {
IRoster roster = sessionManager.getRosterManager().getRoster(); IRoster roster = connection.getRosterManager().getRoster();
for (IRosterGroup rosterGroup : roster.getGroups()) { for (IRosterGroup rosterGroup : roster.getGroups()) {
groups.add(rosterGroup); groups.add(rosterGroup);
@ -179,6 +159,9 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
for (IRosterEntry rosterEntry : roster.getEntries()) { for (IRosterEntry rosterEntry : roster.getEntries()) {
usersMap.put(rosterEntry.getUser(), rosterEntry); usersMap.put(rosterEntry.getUser(), rosterEntry);
} }
usersMap.put(connection.getUser(),
new RosterEntry(connection.getUser()));
} }
/** /**
@ -219,10 +202,6 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
return display; return display;
} }
public UserId getLoginId() {
return loginId;
}
public void setLinkCollaboration(boolean state) { public void setLinkCollaboration(boolean state) {
this.linkCollaboration = state; this.linkCollaboration = state;
} }
@ -258,21 +237,20 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
} }
LoginDialog dlg = new LoginDialog(shell, LoginDialog dlg = new LoginDialog(shell,
CollaborationDataManager.this); CollaborationDataManager.this);
loginData = null; CollaborationConnection newConn = null;
loginData = (LoginData) dlg.open(); newConn = (CollaborationConnection) dlg.open();
dlg.close(); dlg.close();
if (loginData != null) { if (newConn != null) {
sessionManager = dlg.getSessionManager(); connection = newConn;
loginId = loginData.getAccount();
} }
} }
}); });
if (isConnected()) { if (isConnected()) {
// Register handlers and events for the new sessionManager. // Register handlers and events for the new sessionManager.
sessionManager.registerEventHandler(this); connection.registerEventHandler(this);
try { try {
ISession p2pSession = sessionManager.getPeerToPeerSession(); ISession p2pSession = connection.getPeerToPeerSession();
p2pSession.registerEventHandler(this); p2pSession.registerEventHandler(this);
} catch (CollaborationException e) { } catch (CollaborationException e) {
// TODO Auto-generated catch block. Please revise as // TODO Auto-generated catch block. Please revise as
@ -290,9 +268,9 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
@Override @Override
public void postShutdown(IWorkbench workbench) { public void postShutdown(IWorkbench workbench) {
if (sessionManager != null) { if (connection != null) {
try { try {
ISession p2pSession = sessionManager ISession p2pSession = connection
.getPeerToPeerSession(); .getPeerToPeerSession();
p2pSession.unRegisterEventHandler(this); p2pSession.unRegisterEventHandler(this);
} catch (CollaborationException e) { } catch (CollaborationException e) {
@ -301,32 +279,25 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e); e.getLocalizedMessage(), e);
} }
sessionManager.unRegisterEventHandler(this); connection.unRegisterEventHandler(this);
sessionManager.closeManager(); connection.closeManager();
sessionManager = null; connection = null;
} }
} }
}; };
PlatformUI.getWorkbench().addWorkbenchListener(wbListener); PlatformUI.getWorkbench().addWorkbenchListener(wbListener);
IPresence presence = sessionManager.getPresence();
if (sessionManager.getPresence() == null) {
presence = new Presence();
presence.setProperty("dummy", "dummy");
sessionManager.setPresence(presence);
}
fireModifiedPresence();
populateGroups(); populateGroups();
} }
} }
return sessionManager; return connection;
} }
synchronized public void closeManager() { synchronized public void closeManager() {
if (sessionManager != null) { if (connection != null) {
// The close unRegisters the event handler // The close unRegisters the event handler
sessionManager.closeManager(); connection.closeManager();
sessionManager = null; connection = null;
} }
if (wbListener != null) { if (wbListener != null) {
PlatformUI.getWorkbench().removeWorkbenchListener(wbListener); PlatformUI.getWorkbench().removeWorkbenchListener(wbListener);
@ -487,7 +458,7 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
} }
public boolean isConnected() { public boolean isConnected() {
return sessionManager != null && sessionManager.isConnected(); return connection != null && connection.isConnected();
} }
@Subscribe @Subscribe
@ -530,7 +501,7 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
return; return;
} }
try { try {
IVenueSession session = sessionManager IVenueSession session = connection
.joinCollaborationVenue(invitation); .joinCollaborationVenue(invitation);
String sessionId = session.getSessionId(); String sessionId = session.getSessionId();
sessionsMap.put(sessionId, session); sessionsMap.put(sessionId, session);
@ -615,14 +586,18 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
}); });
} }
public void fireModifiedPresence() { public void fireModifiedPresence(Mode mode, String msg) {
IPresence presence = sessionManager.getPresence(); IPresence presence = connection.getPresence();
presence.setMode(loginData.getMode()); if (mode != null) {
presence.setMode(mode);
}
presence.setType(Type.AVAILABLE); presence.setType(Type.AVAILABLE);
presence.setStatusMessage(loginData.getModeMessage()); if (msg != null) {
presence.setStatusMessage(msg);
}
try { try {
sessionManager.getAccountManager().sendPresence(presence); connection.getAccountManager().sendPresence(presence);
UserId id = sessionManager.getUser(); UserId id = connection.getUser();
RosterEntry rosterEntry = new RosterEntry(id); RosterEntry rosterEntry = new RosterEntry(id);
rosterEntry.setPresence(presence); rosterEntry.setPresence(presence);
handleModifiedPresence(rosterEntry); handleModifiedPresence(rosterEntry);

View file

@ -20,7 +20,10 @@ package com.raytheon.uf.viz.collaboration.ui;
* further licensing information. * further licensing information.
**/ **/
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
@ -48,11 +51,13 @@ public class Activator extends AbstractUIPlugin {
.getHandler(Activator.class); .getHandler(Activator.class);
// The plug-in ID // The plug-in ID
public static final String PLUGIN_ID = "com.raytheon.uf.viz.collaboration"; //$NON-NLS-1$ public static final String PLUGIN_ID = "com.raytheon.uf.viz.collaboration.ui"; //$NON-NLS-1$
// The shared instance // The shared instance
private static Activator plugin; private static Activator plugin;
private ScopedPreferenceStore prefs;
/** /**
* The constructor * The constructor
*/ */
@ -80,6 +85,7 @@ public class Activator extends AbstractUIPlugin {
*/ */
public void stop(BundleContext context) throws Exception { public void stop(BundleContext context) throws Exception {
plugin = null; plugin = null;
this.prefs.save();
super.stop(context); super.stop(context);
} }
@ -92,4 +98,13 @@ public class Activator extends AbstractUIPlugin {
return plugin; return plugin;
} }
@Override
public IPersistentPreferenceStore getPreferenceStore() {
if (prefs == null) {
prefs = new ScopedPreferenceStore(new InstanceScope(), PLUGIN_ID);
}
return prefs;
}
} }

View file

@ -73,7 +73,7 @@ public class ChangePasswordDialog extends CaveSWTDialog {
private Control createDialogArea(Composite parent) { private Control createDialogArea(Composite parent) {
CollaborationDataManager manager = CollaborationDataManager CollaborationDataManager manager = CollaborationDataManager
.getInstance(); .getInstance();
UserId user = manager.getLoginId(); UserId user = manager.getCollaborationConnection().getUser();
Composite body = new Composite(parent, SWT.NONE); Composite body = new Composite(parent, SWT.NONE);
body.setLayout(new GridLayout(2, false)); body.setLayout(new GridLayout(2, false));
// body.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL // body.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL

View file

@ -20,6 +20,7 @@ package com.raytheon.uf.viz.collaboration.ui;
* further licensing information. * further licensing information.
**/ **/
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -76,6 +77,7 @@ import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.status.UFStatus.Priority;
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.IPresence.Mode;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type;
import com.raytheon.uf.viz.collaboration.comm.identity.ISession; import com.raytheon.uf.viz.collaboration.comm.identity.ISession;
import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession; import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession;
@ -98,8 +100,7 @@ import com.raytheon.uf.viz.collaboration.data.SessionGroupContainer;
import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr; import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr;
import com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor; import com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor;
import com.raytheon.uf.viz.collaboration.ui.login.ChangeStatusDialog; import com.raytheon.uf.viz.collaboration.ui.login.ChangeStatusDialog;
import com.raytheon.uf.viz.collaboration.ui.login.LoginData; import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
import com.raytheon.uf.viz.collaboration.ui.login.LoginDialog;
import com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView; import com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView;
import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView; import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView;
import com.raytheon.uf.viz.collaboration.ui.session.PeerToPeerView; import com.raytheon.uf.viz.collaboration.ui.session.PeerToPeerView;
@ -350,7 +351,9 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
changeStatusAction = new Action("Change Status", changeStatusAction = new Action("Change Status",
Action.AS_DROP_DOWN_MENU) { Action.AS_DROP_DOWN_MENU) {
public void run() { public void run() {
changeStatus(getId()); Activator.getDefault().getPreferenceStore()
.setValue(CollabPrefConstants.P_STATUS, this.getId());
changeStatus();
}; };
}; };
changeStatusAction.setEnabled(false); changeStatusAction.setEnabled(false);
@ -433,24 +436,15 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
ChangeStatusDialog dialog = new ChangeStatusDialog(Display.getCurrent() ChangeStatusDialog dialog = new ChangeStatusDialog(Display.getCurrent()
.getActiveShell()); .getActiveShell());
dialog.open(); dialog.open();
changeStatus();
LoginData loginData = (LoginData) dialog.getReturnValue();
if (loginData != null) {
CollaborationDataManager.getInstance().fireModifiedPresence();
}
} }
private void changeStatus(String status) { private void changeStatus() {
CollaborationDataManager manager = CollaborationDataManager Mode mode = Mode.valueOf(Activator.getDefault().getPreferenceStore()
.getInstance(); .getString(CollabPrefConstants.P_STATUS));
LoginData loginData = manager.getLoginData(); String msg = Activator.getDefault().getPreferenceStore()
int index = Integer.parseInt(status); .getString(CollabPrefConstants.P_MESSAGE);
IPresence.Mode mode = CollaborationUtils.statusModes[index]; CollaborationDataManager.getInstance().fireModifiedPresence(mode, msg);
if (mode != loginData.getMode()) {
loginData.setMode(mode);
manager.fireModifiedPresence();
LoginDialog.saveUserLoginData(loginData);
}
} }
/** /**
@ -489,6 +483,12 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
.getActivePage().hideEditor(ref); .getActivePage().hideEditor(ref);
} }
} }
try {
Activator.getDefault().getPreferenceStore().save();
} catch (IOException e) {
statusHandler.handle(Priority.WARN,
"Unable to save preferences", e);
}
CollaborationDataManager.getInstance().closeManager(); CollaborationDataManager.getInstance().closeManager();
} }
} }
@ -543,7 +543,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
changeStatusAction.run(); changeStatusAction.run();
}; };
}; };
action.setId(Integer.toString(index)); action.setId(mode.toString());
ActionContributionItem item = new ActionContributionItem(action); ActionContributionItem item = new ActionContributionItem(action);
action.setImageDescriptor(IconUtil.getImageDescriptor(Activator action.setImageDescriptor(IconUtil.getImageDescriptor(Activator
.getDefault().getBundle(), mode.name().toLowerCase() .getDefault().getBundle(), mode.name().toLowerCase()
@ -934,7 +934,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
// make the first thing to show up in the list, which happens to be the // make the first thing to show up in the list, which happens to be the
// user's name and gives the user options to modify status and other // user's name and gives the user options to modify status and other
// things // things
UserId user = manager.getLoginId(); UserId user = manager.getCollaborationConnection().getUser();
topLevel.addObject(user); topLevel.addObject(user);
activeSessionGroup = new SessionGroupContainer(); activeSessionGroup = new SessionGroupContainer();
@ -1124,8 +1124,9 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
IRosterEntry user = (IRosterEntry) node; IRosterEntry user = (IRosterEntry) node;
if (user.getPresence().getType() == Type.AVAILABLE) { if (user.getPresence().getType() == Type.AVAILABLE) {
UserId loginUserId = CollaborationDataManager UserId loginUserId = CollaborationDataManager
.getInstance().getLoginId(); .getInstance().getCollaborationConnection()
if (loginUserId.equals(user) == false) { .getUser();
if (!loginUserId.equals(user)) {
createP2PChat(user.getUser()); createP2PChat(user.getUser());
} }
} }

View file

@ -57,21 +57,6 @@ public class CollaborationUtils {
private static final String PREFIX_CONFERENCE = "conference."; private static final String PREFIX_CONFERENCE = "conference.";
/**
* Get the statusModes' index for desired mode.
*
* @param mode
* @return index - the mode's index or -1 if not in statusModes
*/
public static int statusModesIndex(IPresence.Mode mode) {
for (int index = 0; index < statusModes.length; ++index) {
if (mode.equals(statusModes[index])) {
return index;
}
}
return -1;
}
/** /**
* Get an image associated with the node. * Get an image associated with the node.
* *

View file

@ -21,6 +21,7 @@ package com.raytheon.uf.viz.collaboration.ui.login;
**/ **/
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
@ -35,8 +36,10 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Mode;
import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils; import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog; import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/** /**
@ -120,14 +123,13 @@ public class ChangeStatusDialog extends CaveSWTDialog {
@Override @Override
protected void preOpened() { protected void preOpened() {
super.preOpened(); super.preOpened();
LoginData loginData = CollaborationDataManager.getInstance() IPreferenceStore prefStore = Activator.getDefault()
.getLoginData(); .getPreferenceStore();
userLabel.setText(loginData.getAccount().getFQName()); userLabel.setText(prefStore.getString(CollabPrefConstants.P_USERNAME)
statusCombo.select(CollaborationUtils.statusModesIndex(loginData + "@" + prefStore.getString(CollabPrefConstants.P_SERVER));
.getMode())); statusCombo.select(statusCombo.indexOf(prefStore
statusCombo.select(CollaborationUtils.statusModesIndex(loginData .getString(CollabPrefConstants.P_STATUS)));
.getMode())); messageTF.setText(prefStore.getString(CollabPrefConstants.P_MESSAGE));
messageTF.setText(loginData.getModeMessage());
messageTF.selectAll(); messageTF.selectAll();
statusCombo.setFocus(); statusCombo.setFocus();
} }
@ -179,26 +181,15 @@ public class ChangeStatusDialog extends CaveSWTDialog {
if (val != IDialogConstants.OK_ID) { if (val != IDialogConstants.OK_ID) {
setReturnValue(null); setReturnValue(null);
} else { } else {
LoginData loginData = CollaborationDataManager IPresence.Mode mode = Mode.valueOf(statusCombo
.getInstance().getLoginData(); .getItem(statusCombo.getSelectionIndex()));
boolean modified = false;
IPresence.Mode mode = CollaborationUtils.statusModes[statusCombo
.getSelectionIndex()];
if (mode != loginData.getMode()) {
modified = true;
}
String modeMessage = messageTF.getText().trim(); String modeMessage = messageTF.getText().trim();
if (modeMessage.equals(loginData.getModeMessage()) == false) { IPreferenceStore prefStore = Activator.getDefault()
modified = true; .getPreferenceStore();
} prefStore.setValue(CollabPrefConstants.P_STATUS,
if (modified) { mode.toString());
loginData.setMode(mode); prefStore.setValue(CollabPrefConstants.P_MESSAGE,
loginData.setModeMessage(modeMessage); modeMessage);
LoginDialog.saveUserLoginData(loginData);
setReturnValue(loginData);
} else {
setReturnValue(null);
}
} }
ChangeStatusDialog.this.getShell().dispose(); ChangeStatusDialog.this.getShell().dispose();
} }

View file

@ -1,128 +0,0 @@
package com.raytheon.uf.viz.collaboration.ui.login;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
/**
* 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.
**/
/**
* Data class that provides log on information. All but the password may be
* saved in a localized file.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 16, 2012 rferrel Initial creation
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
@XmlRootElement(name = "CollaborationLogon")
@XmlAccessorType(XmlAccessType.NONE)
public class LoginData implements ISerializableObject {
@XmlElement(name = "user")
private String user;
@XmlElement(name = "server")
private String server;
private transient String password;
@XmlElement(name = "mode")
private IPresence.Mode mode;
@XmlElement(name = "modeMessage")
private String modeMessage;
public LoginData() {
this.user = "";
this.server = "";
this.password = "";
this.mode = IPresence.Mode.AVAILABLE;
this.modeMessage = "";
}
public String getUser() {
return user;
}
public String getPassword() {
return password;
}
public void clearPassword() {
password = null;
}
public IPresence.Mode getMode() {
return mode;
}
public String getServer() {
return server;
}
public String getModeMessage() {
return modeMessage;
}
public UserId getAccount() {
return new UserId(user, server);
}
public void setUser(String user) {
this.user = user;
}
public void setServer(String server) {
this.server = server;
}
public void setPassword(String password) {
this.password = password;
}
public void setMode(IPresence.Mode mode) {
this.mode = mode;
}
public void setModeMessage(String statusMessage) {
this.modeMessage = statusMessage;
}
public String toString() {
return "userId: \"" + user + "\", server \"" + server + "\", mode:\""
+ mode.toString() + "\", modeMessage: \"" + modeMessage
+ "\", pw: "
+ ((password == null) ? "null" : password.length());
}
}

View file

@ -20,14 +20,12 @@ package com.raytheon.uf.viz.collaboration.ui.login;
* further licensing information. * further licensing information.
**/ **/
import java.io.File; import java.io.IOException;
import java.io.FileNotFoundException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.bind.JAXB;
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
@ -43,21 +41,18 @@ import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.exception.LocalizationException;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.status.UFStatus.Priority;
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.IPresence.Type;
import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterEventSubscriber; import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterEventSubscriber;
import com.raytheon.uf.viz.collaboration.comm.provider.Presence;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection; 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.ui.Activator;
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils; import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
import com.raytheon.uf.viz.core.localization.LocalizationManager; import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog; import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/** /**
@ -77,13 +72,10 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @version 1.0 * @version 1.0
*/ */
public class LoginDialog extends CaveSWTDialog { public class LoginDialog extends CaveSWTDialog {
private static final transient IUFStatusHandler statusHandler = UFStatus private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(LoginDialog.class); .getHandler(LoginDialog.class);
private static final String LOGIN_FILE_NAME = "collaboration"
+ File.separator + "config" + File.separator + "gui"
+ File.separator + "LoginData.xml";
private Text userTF; private Text userTF;
private Text serverTF; private Text serverTF;
@ -98,23 +90,22 @@ public class LoginDialog extends CaveSWTDialog {
private Button logOnButton; private Button logOnButton;
private String DEFAULT_SERVER = "awipscm.omaha.us.ray.com";
private Control[] noServerList; private Control[] noServerList;
private Control[] withServerList; private Control[] withServerList;
private LoginData loginData;
private IRosterEventSubscriber rosterEventSubscriber; private IRosterEventSubscriber rosterEventSubscriber;
private CollaborationConnection sessionManager; private CollaborationConnection sessionManager;
private IPersistentPreferenceStore prefStore;
public LoginDialog(Shell parentShell, public LoginDialog(Shell parentShell,
IRosterEventSubscriber rosterEventSubscriber) { IRosterEventSubscriber rosterEventSubscriber) {
super(parentShell, SWT.DIALOG_TRIM); super(parentShell, SWT.DIALOG_TRIM);
setText("Collaboration Server Login"); setText("Collaboration Server Login");
this.rosterEventSubscriber = rosterEventSubscriber; this.rosterEventSubscriber = rosterEventSubscriber;
this.prefStore = Activator.getDefault().getPreferenceStore();
} }
/** /**
@ -141,7 +132,6 @@ public class LoginDialog extends CaveSWTDialog {
// Set minimum width one time and the fill will handle the other fields. // Set minimum width one time and the fill will handle the other fields.
gd.minimumWidth = 200; gd.minimumWidth = 200;
serverTF.setLayoutData(gd); serverTF.setLayoutData(gd);
serverTF.setText(DEFAULT_SERVER);
serverTF.setEditable(false); serverTF.setEditable(false);
serverTF.setBackground(parent.getBackground()); serverTF.setBackground(parent.getBackground());
serverButton = new Button(body, SWT.PUSH); serverButton = new Button(body, SWT.PUSH);
@ -160,12 +150,7 @@ public class LoginDialog extends CaveSWTDialog {
serverTF.setEditable(false); serverTF.setEditable(false);
serverTF.setBackground(serverTF.getParent().getBackground()); serverTF.setBackground(serverTF.getParent().getBackground());
String server = serverTF.getText().trim(); String server = serverTF.getText().trim();
if (server.length() == 0) { serverTF.setText(server);
serverTF.setText(DEFAULT_SERVER);
} else {
serverTF.setText(server);
DEFAULT_SERVER = server;
}
serverTF.clearSelection(); serverTF.clearSelection();
serverTF.getParent().setTabList(noServerList); serverTF.getParent().setTabList(noServerList);
logOnButton.setEnabled(true); logOnButton.setEnabled(true);
@ -259,13 +244,12 @@ public class LoginDialog extends CaveSWTDialog {
@Override @Override
protected void preOpened() { protected void preOpened() {
super.preOpened(); super.preOpened();
this.loginData = LoginDialog.openUserLoginData(); userTF.setText(prefStore.getString(CollabPrefConstants.P_USERNAME));
userTF.setText(loginData.getUser()); serverTF.setText(prefStore.getString(CollabPrefConstants.P_SERVER));
serverTF.setText(loginData.getServer());
statusCombo.select(CollaborationUtils.statusModesIndex(loginData statusCombo.select(statusCombo.indexOf(prefStore
.getMode())); .getString(CollabPrefConstants.P_STATUS)));
messageTF.setText(loginData.getModeMessage()); messageTF.setText(prefStore.getString(CollabPrefConstants.P_MESSAGE));
userTF.selectAll(); userTF.selectAll();
userTF.setFocus(); userTF.setFocus();
} }
@ -349,38 +333,31 @@ public class LoginDialog extends CaveSWTDialog {
passwordTF.setText(""); passwordTF.setText("");
} }
if (focusField == null) { if (focusField == null) {
boolean doSaveLoginData = false; prefStore
if (!loginData.getUser().equals(user)) { .setValue(CollabPrefConstants.P_SERVER, server);
doSaveLoginData = true; prefStore
loginData.setUser(user); .setValue(CollabPrefConstants.P_USERNAME, user);
} prefStore.setValue(CollabPrefConstants.P_STATUS,
if (!loginData.getServer().equals(server)) { mode.toString());
doSaveLoginData = true; prefStore.setValue(CollabPrefConstants.P_MESSAGE,
loginData.setServer(server); modeMessage);
} try {
loginData.setPassword(password); prefStore.save();
if (!loginData.getMode().equals(mode)) { } catch (IOException e) {
doSaveLoginData = true; statusHandler.handle(Priority.WARN,
loginData.setMode(mode); "Unable to save login preferences", e);
}
if (!loginData.getModeMessage().equals(modeMessage)) {
doSaveLoginData = true;
loginData.setModeMessage(modeMessage);
}
if (doSaveLoginData) {
LoginDialog.saveUserLoginData(loginData);
} }
// loginData = new LoginData(user, server, password, IPresence initialPres = new Presence();
// CollaborationUtils.statusModes[statusCombo initialPres.setMode(mode);
// .getSelectionIndex()], messageTF initialPres.setType(Type.AVAILABLE);
// .getText().trim()); initialPres.setStatusMessage(modeMessage);
try { try {
sessionManager = new CollaborationConnection( sessionManager = new CollaborationConnection(
loginData.getAccount(), loginData new UserId(user, server), password,
.getPassword(), rosterEventSubscriber, initialPres);
rosterEventSubscriber); setReturnValue(sessionManager);
setReturnValue(loginData);
close(); close();
} catch (Exception e) { } catch (Exception e) {
if (focusField == null) { if (focusField == null) {
@ -421,69 +398,6 @@ public class LoginDialog extends CaveSWTDialog {
return button; return button;
} }
public static LoginData openUserLoginData() {
LoginData loginData = null;
IPathManager pm = PathManagerFactory.getPathManager();
File fname = pm.getStaticFile(LOGIN_FILE_NAME);
try {
if (fname != null) {
loginData = JAXB.unmarshal(fname, LoginData.class);
}
} catch (RuntimeException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
} finally {
if (loginData == null) {
loginData = new LoginData();
}
}
return loginData;
}
public static void saveUserLoginData(LoginData loginData) {
try {
LocalizationFile lFile = getFile(LOGIN_FILE_NAME);
File file = lFile.getFile(false);
file.getParentFile().mkdirs();
JAXB.marshal(loginData, file);
lFile.save();
} catch (FileNotFoundException ex) {
statusHandler
.handle(Priority.PROBLEM, ex.getLocalizedMessage(), ex);
} catch (LocalizationException e) {
// TODO Auto-generated catch block. Please revise as appropriate.
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
}
/**
* Obtains a localization file for desired file name.
*
* @param filename
* @return lFile
* @throws FileNotFoundException
*/
private static LocalizationFile getFile(String filename)
throws FileNotFoundException {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext context = pm.getContext(
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
LocalizationFile lFile = pm.getLocalizationFile(context, filename);
if (lFile == null) {
String user = LocalizationManager.getInstance().getCurrentUser();
throw new FileNotFoundException("Unable to find \"" + filename
+ "\" under the directory for user " + user + ".");
}
return lFile;
}
/**
* @return the loginData
*/
public LoginData getLoginData() {
return loginData;
}
/** /**
* @return the sessionManager * @return the sessionManager
*/ */

View file

@ -0,0 +1,49 @@
/**
* 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;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 24, 2012 njensen Initial creation
*
* </pre>
*
* @author njensen
* @version 1.0
*/
public class CollabPrefConstants {
public static final String P_SERVER = "collaborationServer";
public static final String P_USERNAME = "username";
public static final String P_STATUS = "status";
public static final String P_MESSAGE = "message";
}

View file

@ -0,0 +1,68 @@
/**
* 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 org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Mode;
import com.raytheon.uf.viz.collaboration.ui.Activator;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 24, 2012 njensen Initial creation
*
* </pre>
*
* @author njensen
* @version 1.0
*/
public class CollabPrefInitializer extends AbstractPreferenceInitializer {
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#
* initializeDefaultPreferences()
*/
@Override
public void initializeDefaultPreferences() {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
store.setDefault(CollabPrefConstants.P_SERVER, "");
// TODO better default?
store.setDefault(CollabPrefConstants.P_USERNAME,
System.getProperty("user.name"));
store.setDefault(CollabPrefConstants.P_STATUS,
Mode.AVAILABLE.toString());
store.setDefault(CollabPrefConstants.P_MESSAGE, "");
}
}

View file

@ -95,11 +95,12 @@ public class DataProviderEventController extends AbstractRoleEventController {
@Subscribe @Subscribe
public void participantChanged(IVenueParticipantEvent event) { public void participantChanged(IVenueParticipantEvent event) {
if (event.getEventType().equals(ParticipantEventType.ARRIVED)) { if (event.getEventType().equals(ParticipantEventType.ARRIVED)
// TODO this seems to trigger when you create the room, in which && !event.getParticipant().equals(session.getUserID())) {
// case you don't need to send it for yourself // TODO send over the one that is currently active, not the one
// TODO instead of going to active editor, should get ones SharedDisplaySessionMgr
// specifically shared with this session .getSessionContainer(this.session.getSessionId())
.getSharedEditors().get(0);
AbstractEditor editor = EditorUtil AbstractEditor editor = EditorUtil
.getActiveEditorAs(AbstractEditor.class); .getActiveEditorAs(AbstractEditor.class);
SharedEditorData se = EditorSetup.extractSharedEditorData(editor); SharedEditorData se = EditorSetup.extractSharedEditorData(editor);

View file

@ -115,8 +115,8 @@ public class PeerToPeerView extends AbstractSessionView {
IPeerToPeer p2p = (IPeerToPeer) manager IPeerToPeer p2p = (IPeerToPeer) manager
.getCollaborationConnection().getPeerToPeerSession(); .getCollaborationConnection().getPeerToPeerSession();
p2p.sendPeerToPeer(peer, message); p2p.sendPeerToPeer(peer, message);
appendMessage(manager.getLoginId(), System.currentTimeMillis(), appendMessage(manager.getCollaborationConnection().getUser(),
message); System.currentTimeMillis(), message);
} catch (CollaborationException e) { } catch (CollaborationException e) {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM,
"Unable to send message to " + peer.getName(), e); "Unable to send message to " + peer.getName(), e);
@ -127,7 +127,8 @@ public class PeerToPeerView extends AbstractSessionView {
protected void styleAndAppendText(StringBuilder sb, int offset, protected void styleAndAppendText(StringBuilder sb, int offset,
String name, UserId userId, List<StyleRange> ranges) { String name, UserId userId, List<StyleRange> ranges) {
Color color = null; Color color = null;
if (!userId.equals(CollaborationDataManager.getInstance().getLoginId())) { if (!userId.equals(CollaborationDataManager.getInstance()
.getCollaborationConnection().getUser())) {
color = chatterColor; color = chatterColor;
} else { } else {
color = userColor; color = userColor;

View file

@ -38,7 +38,6 @@ import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr; import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr;
import com.raytheon.uf.viz.collaboration.ui.ColorChangeEvent; import com.raytheon.uf.viz.collaboration.ui.ColorChangeEvent;
import com.raytheon.uf.viz.collaboration.ui.SessionColorManager; import com.raytheon.uf.viz.collaboration.ui.SessionColorManager;
import com.raytheon.uf.viz.collaboration.ui.login.LoginData;
import com.raytheon.uf.viz.collaboration.ui.telestrator.event.CollaborationDrawingEvent; import com.raytheon.uf.viz.collaboration.ui.telestrator.event.CollaborationDrawingEvent;
import com.raytheon.uf.viz.collaboration.ui.telestrator.event.CollaborationDrawingEvent.CollaborationEventType; import com.raytheon.uf.viz.collaboration.ui.telestrator.event.CollaborationDrawingEvent.CollaborationEventType;
import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget;
@ -89,6 +88,8 @@ public class CollaborationDrawingLayer extends DrawingLayer {
private String sessionId; private String sessionId;
private UserId userId;
private SessionColorManager colorManager; private SessionColorManager colorManager;
private IWireframeShape tempRemoteShape = null; private IWireframeShape tempRemoteShape = null;
@ -109,6 +110,8 @@ public class CollaborationDrawingLayer extends DrawingLayer {
for (String str : mgr.getSessions().keySet()) { for (String str : mgr.getSessions().keySet()) {
mgr.getSession(str).registerEventHandler(this); mgr.getSession(str).registerEventHandler(this);
} }
userId = mgr.getCollaborationConnection().getUser();
;
} }
/* /*
@ -134,9 +137,7 @@ public class CollaborationDrawingLayer extends DrawingLayer {
.synchronizedMultimap(this.deletedCollaboratorShapes); .synchronizedMultimap(this.deletedCollaboratorShapes);
colorManager = SharedDisplaySessionMgr.getSessionContainer(sessionId) colorManager = SharedDisplaySessionMgr.getSessionContainer(sessionId)
.getColorManager(); .getColorManager();
LoginData data = CollaborationDataManager.getInstance().getLoginData(); color = colorManager.getColors().get(userId);
UserId id = new UserId(data.getUser(), data.getServer());
color = colorManager.getColors().get(id);
} }
/* /*
@ -367,8 +368,6 @@ public class CollaborationDrawingLayer extends DrawingLayer {
super.undoAdd(); super.undoAdd();
CollaborationDrawingEvent event = new CollaborationDrawingEvent(); CollaborationDrawingEvent event = new CollaborationDrawingEvent();
event.setType(CollaborationEventType.UNDO); event.setType(CollaborationEventType.UNDO);
LoginData data = CollaborationDataManager.getInstance().getLoginData();
UserId userId = new UserId(data.getUser(), data.getServer());
event.setUserName(userId); event.setUserName(userId);
sendGenericEvent(event); sendGenericEvent(event);
} }
@ -383,8 +382,6 @@ public class CollaborationDrawingLayer extends DrawingLayer {
super.redoAdd(); super.redoAdd();
CollaborationDrawingEvent event = new CollaborationDrawingEvent(); CollaborationDrawingEvent event = new CollaborationDrawingEvent();
event.setType(CollaborationEventType.REDO); event.setType(CollaborationEventType.REDO);
LoginData data = CollaborationDataManager.getInstance().getLoginData();
UserId userId = new UserId(data.getUser(), data.getServer());
event.setUserName(userId); event.setUserName(userId);
sendGenericEvent(event); sendGenericEvent(event);
} }
@ -401,8 +398,6 @@ public class CollaborationDrawingLayer extends DrawingLayer {
CollaborationDrawingEvent eObject = new CollaborationDrawingEvent(); CollaborationDrawingEvent eObject = new CollaborationDrawingEvent();
eObject.setType(CollaborationEventType.ERASE); eObject.setType(CollaborationEventType.ERASE);
eObject.setContainer(container); eObject.setContainer(container);
LoginData data = CollaborationDataManager.getInstance().getLoginData();
UserId userId = new UserId(data.getUser(), data.getServer());
eObject.setUserName(userId); eObject.setUserName(userId);
sendGenericEvent(eObject); sendGenericEvent(eObject);
} }
@ -413,8 +408,6 @@ public class CollaborationDrawingLayer extends DrawingLayer {
CollaborationDrawingEvent tObject = new CollaborationDrawingEvent(); CollaborationDrawingEvent tObject = new CollaborationDrawingEvent();
tObject.setType(CollaborationEventType.DRAW); tObject.setType(CollaborationEventType.DRAW);
tObject.setContainer(container); tObject.setContainer(container);
LoginData data = CollaborationDataManager.getInstance().getLoginData();
UserId userId = new UserId(data.getUser(), data.getServer());
tObject.setUserName(userId); tObject.setUserName(userId);
sendGenericEvent(tObject); sendGenericEvent(tObject);
} }
@ -429,8 +422,6 @@ public class CollaborationDrawingLayer extends DrawingLayer {
super.reset(); super.reset();
CollaborationDrawingEvent event = new CollaborationDrawingEvent(); CollaborationDrawingEvent event = new CollaborationDrawingEvent();
event.setType(CollaborationEventType.CLEAR); event.setType(CollaborationEventType.CLEAR);
LoginData data = CollaborationDataManager.getInstance().getLoginData();
UserId userId = new UserId(data.getUser(), data.getServer());
event.setUserName(userId); event.setUserName(userId);
sendGenericEvent(event); sendGenericEvent(event);
} }

View file

@ -147,40 +147,10 @@ public class CollaborationConnection implements IEventPublisher {
private IRosterEventSubscriber rosterEventSubscriber = null; private IRosterEventSubscriber rosterEventSubscriber = null;
// Debug -- event viewer ---------------- // Debug -- event viewer ----------------
private IRosterEventSubscriber rosterEventHandler = null; // private IRosterEventSubscriber rosterEventHandler = null;
// Debug -- event viewer ---------------- // Debug -- event viewer ----------------
/**
* @throws CollaborationException
* @throws ContainerCreateException
*
*/
public CollaborationConnection(UserId account, String password)
throws CollaborationException {
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 CollaborationConnection(UserId account, String password,
IPresence initialPresence) throws Exception {
this(account, password, (IRosterEventSubscriber) null);
if (accountManager != null) {
userPresence = initialPresence;
accountManager.sendPresence(initialPresence);
}
}
/** /**
* *
* The roster event subscriber must be ready to accept events before this * The roster event subscriber must be ready to accept events before this
@ -192,11 +162,13 @@ public class CollaborationConnection implements IEventPublisher {
* The password to use for connection. * The password to use for connection.
* @param rosterEventSubscriber * @param rosterEventSubscriber
* A roster event subscriber. * A roster event subscriber.
* @param initialPresence
* the initial presence
* @throws CollaborationException * @throws CollaborationException
*/ */
public CollaborationConnection(UserId account, String password, public CollaborationConnection(UserId account, String password,
IRosterEventSubscriber rosterEventSubscriber) IRosterEventSubscriber rosterEventSubscriber,
throws CollaborationException { IPresence initialPresence) throws CollaborationException {
eventBus = new EventBus(); eventBus = new EventBus();
if (rosterEventSubscriber != null) { if (rosterEventSubscriber != null) {
this.rosterEventSubscriber = rosterEventSubscriber; this.rosterEventSubscriber = rosterEventSubscriber;
@ -253,6 +225,11 @@ public class CollaborationConnection implements IEventPublisher {
setupP2PComm(presenceAdapter); setupP2PComm(presenceAdapter);
getPeerToPeerSession(); getPeerToPeerSession();
if (accountManager != null && initialPresence != null) {
userPresence = initialPresence;
accountManager.sendPresence(initialPresence);
}
} }
/** /**