[e-cvs] cvs commit: e/src/jsrc/net/vattp/data ConnectionsMgr.java DataConnection.java DataPath.java StartUpProtocol.java
markm@eros.cs.jhu.edu
markm@eros.cs.jhu.edu
Fri, 14 Sep 2001 16:54:05 -0400
markm 01/09/14 16:54:05
Modified: src/esrc/com/skyhunter/e/security
powerboxControllerMakerAuthor.emaker
src/esrc/scripts eBrowser.e
src/jsrc/net/captp/jcomm ProxyConnection.java
RemoteHandler.java
src/jsrc/net/vattp/data ConnectionsMgr.java
DataConnection.java DataPath.java
StartUpProtocol.java
Log:
new eBrowser, sky code. Some CapTP bugs fixed.
Revision Changes Path
1.3 +28 -9 e/src/esrc/com/skyhunter/e/security/powerboxControllerMakerAuthor.emaker
Index: powerboxControllerMakerAuthor.emaker
===================================================================
RCS file: /cvs/e/src/esrc/com/skyhunter/e/security/powerboxControllerMakerAuthor.emaker,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- powerboxControllerMakerAuthor.emaker 2001/09/12 00:01:50 1.2
+++ powerboxControllerMakerAuthor.emaker 2001/09/14 20:54:04 1.3
@@ -26,25 +26,44 @@
def powerbox
def caplet
def powersMap := [] asKeys() diverge()
+ def clipboard := <awt:Toolkit> getDefaultToolkit() getSystemClipboard()
+ //XXX document, when a caplet returns a copy or cut value, that
+ //XXX value must implement both transferable and ClipboardOwner
+ //XXX as does StringSelection
class powerbarControllerMaker(eFrame) :near {
- def cutRunner() {
+ def cutFunc() {
traceln("about to do cut reaction")
- def clipboardObject := caplet reactToCut(eFrame)
+ try {
+ def contents := caplet reactToCut(eFrame)
+ clipboard setContents(contents, contents)
+ } catch prob {
+ //No cut reaction
+ }
}
def cutURL := <resource:com/skyhunter/e/icons/cut.gif>
- def cutButton := uiKit newToolButton( <swing:ImageIcon> new(cutURL)getImage() , "Global Cut", cutRunner)
- def copyRunner() {
+ def cutButton := uiKit newToolButton( <swing:ImageIcon> new(cutURL)getImage() , "Global Cut", cutFunc)
+ def copyFunc() {
traceln("about to do copy reaction")
- def clipboardObject := caplet reactToCopy(eFrame)
+ try {
+ def contents := caplet reactToCopy(eFrame)
+ traceln("pbox copy contents: " + contents)
+ clipboard setContents(contents, contents)
+ } catch prob {
+ // No copy reaction
+ }
}
def copyURL := <resource:com/skyhunter/e/icons/copy.gif>
- def copyButton := uiKit newToolButton( <swing:ImageIcon> new(copyURL)getImage() , "Global Copy", copyRunner)
- def pasteRunner() {
+ def copyButton := uiKit newToolButton( <swing:ImageIcon> new(copyURL)getImage() , "Global Copy", copyFunc)
+ def pasteFunc() {
traceln("about to do paste reaction")
- caplet reactToPaste(eFrame, "dummy from-clipboard")
+ try {
+ caplet reactToPaste(eFrame, "dummy from-clipboard")
+ } catch prob {
+ traceln("paste prob: " + prob)
+ }
}
def pasteURL := <resource:com/skyhunter/e/icons/paste.gif>
- def pasteButton := uiKit newToolButton( <swing:ImageIcon> new(pasteURL)getImage() , "Global Paste", pasteRunner)
+ def pasteButton := uiKit newToolButton( <swing:ImageIcon> new(pasteURL)getImage() , "Global Paste", pasteFunc)
def spacer := <swing:JLabel> new(" ")
def powerPanel := JPanel`$cutButton $copyButton $pasteButton $spacer.X`
powerPanel setBorder(<swing:BorderFactory> createRaisedBevelBorder())
1.43 +33 -11 e/src/esrc/scripts/eBrowser.e
Index: eBrowser.e
===================================================================
RCS file: /cvs/e/src/esrc/scripts/eBrowser.e,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- eBrowser.e 2001/09/14 01:35:21 1.42
+++ eBrowser.e 2001/09/14 20:54:04 1.43
@@ -42,9 +42,10 @@
swing__uriGetter,
JPanel__quasiParser,
JFrameMaker)
-
+def setupDrop := <import:com.skyhunter.e.awt.dnd.setupDropFuncAuthor> (
+ <awt:dnd.DropTarget>, println)
+
def StringReaderMaker := <unsafe:java.io.StringReader>
-
def textSelectorMaker := <import:org.erights.ex.swing.textSelectorMaker>
def abbrev := <import:org.erights.e.tools.text.abbrev>
@@ -229,6 +230,11 @@
browseFile := <file: filePath>
textModel save()
}
+ to replaceStubFile(replacementFile) {
+ if (browseFile == dummyFile) {
+ browseFile := replacementFile
+ }
+ }
to storedVersionIsNewer() :any {
myTimeLastSaved < browseFile lastModified()
}
@@ -540,6 +546,29 @@
scrollingTextPane getViewport() add(textPane)
scrollingTextPane setMinimumSize(<awt:Dimension> new(200, 100))
scrollingTextPane setPreferredSize(<awt:Dimension> new(800, 600))
+ def openFile(file) {
+ def path := file getCanonicalPath()
+ #traceln(`current openFiles: $openFiles`)
+ if (openFiles maps(path)) {
+ openFiles[path] bringToTop()
+ } else if (!(textModel saveFileIsSet()) &&
+ textPane getText() trim() size() == 0) {
+ textModel replaceStubFile(file)
+ openFiles [path] := eBrowser
+ setTitle()
+ textPane setText(textModel reload())
+ } else {
+ def browser := eBrowserMaker new(textModelMaker new(file))
+ openFiles[path] := browser
+ }
+ }
+ def reactToFilesDrop(files) {
+ for i in 0..(files size() - 1) {
+ openFile(files[i])
+ }
+ }
+ setupDrop(textPane, [<awt:datatransfer.DataFlavor> javaFileListFlavor()
+ => reactToFilesDrop])
# build variable list pane
def varListPopup := <swing:JPopupMenu> new("Var Ops")
@@ -675,15 +704,8 @@
if (fileName != null && fileName size() > 0) {
def localPath := `${fileDialog getDirectory()}$fileName`
traceln(`path to new file: $localPath`)
- def openFile := <file: localPath>
- def path := openFile getCanonicalPath()
- #traceln(`current openFiles: $openFiles`)
- if (openFiles maps(path)) {
- openFiles[path] bringToTop()
- } else {
- def browser := eBrowserMaker new(textModelMaker new(openFile))
- openFiles[path] := browser
- }
+ def nextFile := <file: localPath>
+ openFile(nextFile)
}
}
def saveFunc() {eBrowser save()}
1.26 +11 -2 e/src/jsrc/net/captp/jcomm/ProxyConnection.java
Index: ProxyConnection.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/ProxyConnection.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- ProxyConnection.java 2001/09/06 09:55:38 1.25
+++ ProxyConnection.java 2001/09/14 20:54:04 1.26
@@ -313,6 +313,13 @@
/*package*/ Unsealer getUnsealer() { return myProxyMgr.myUnsealer; }
/**
+ * If non-null, this is a dead connection
+ */
+ /*package*/ Throwable getOptProblem() {
+ return myOptProblem;
+ }
+
+ /**
* Return our identity.
*/
/*package*/ String localVatID() {
@@ -793,7 +800,7 @@
* Receive a shutdown message from the other end. If we don't have any
* messages in flight, we shutdown the connection.
*/
- private void execShutdownOp(int receivedCount) {
+ private void execShutdownOp(int receivedCount) throws IOException {
if (Trace.captp.debug && Trace.ON) {
Trace.captp.debugm(
"exec ShutdownOp(" + receivedCount + ")");
@@ -1010,7 +1017,8 @@
*
* @param problem What went wrong
*/
- /*package*/ void killConnection(Throwable problem, boolean deliberate) {
+ /*package*/ void killConnection(Throwable problem, boolean deliberate)
+ {
if (null == problem) {
problem = new NullPointerException("dying with a null problem");
}
@@ -1027,6 +1035,7 @@
}
if (null == myOptProblem) { /* If this is the first time we've died... */
myOptProblem = problem;
+ myDataConnection.shutDownConnection(problem);
myQuestions.smash(problem);
myAnswers.smash(problem);
1.14 +5 -0 e/src/jsrc/net/captp/jcomm/RemoteHandler.java
Index: RemoteHandler.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/RemoteHandler.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- RemoteHandler.java 2001/09/06 09:55:38 1.13
+++ RemoteHandler.java 2001/09/14 20:54:04 1.14
@@ -195,6 +195,11 @@
*
*/
public void reactToGC() {
+ if (myConn.getOptProblem() != null) {
+ //If this is a dead connection, then gc doesn't need to be
+ //reported remotely.
+ return;
+ }
if (myPos > 0) {
myConn.sendGCExportOp(myPos, myWireCount);
myWireCount = 0;
1.8 +4 -4 e/src/jsrc/net/vattp/data/ConnectionsMgr.java
Index: ConnectionsMgr.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/vattp/data/ConnectionsMgr.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ConnectionsMgr.java 2001/09/06 09:55:39 1.7
+++ ConnectionsMgr.java 2001/09/14 20:54:04 1.8
@@ -774,12 +774,12 @@
remoteVatID, connection);
if (null != oldconn) {
Trace.comm.errorm("Overlaying " + oldconn + " with " + connection);
- try {
+// try {
oldconn.shutDownConnection(new ConnectionShutDownException(
"Replacing old connection with newly started one"));
- } catch(IOException e) {
- Trace.comm.errorm("Error shutting down connection", e);
- }
+// } catch(IOException e) {
+// Trace.comm.errorm("Error shutting down connection", e);
+// }
}
if (null != myReactor && !isResuming) {
if (Trace.comm.event && Trace.ON) {
1.5 +13 -4 e/src/jsrc/net/vattp/data/DataConnection.java
Index: DataConnection.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/vattp/data/DataConnection.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DataConnection.java 2001/09/06 09:55:39 1.4
+++ DataConnection.java 2001/09/14 20:54:04 1.5
@@ -881,22 +881,31 @@
/**
* Causes a clean shutdown of the connection. All messages sent
+ * (XXX markm asks: "All messages sent" or "All messages queued to be
+ * sent"?)
* previously will be sent. When the shut down is complete, the
* connectionDead method will be called on all registered MsgHandlers.
*/
- public void shutDownConnection() throws IOException {
+ public void shutDownConnection() {
shutDownConnection(new ConnectionShutDownException(
- "This end requested shutdown"));
+ "This end requested shutdown"));
}
/**
* Causes a clean shutdown of the connection. All messages sent
+ * (XXX markm asks: "All messages sent" or "All messages queued to be
+ * sent"?)
* previously will be sent. When the shut down is complete, the
* connectionDead method will be called on all registered MsgHandlers.
+ * <p>
+ * XXX markm: I made this public, and changed ProxyConnection to call
+ * this with a non-ConnectionShutDownException. As far as I can tell,
+ * this shouldn't break anything. But Bill, it would be good for you
+ * to double check this.
*
* @param reason indicates why the connection is shutting down
*/
- /*package*/ void shutDownConnection(Throwable reason) throws IOException {
+ public void shutDownConnection(Throwable reason) {
if (!myRunner.isCurrentThreadInVat()) {
Trace.comm.errorm("Caller doesn't hold vat lock", new Throwable());
}
@@ -1001,7 +1010,7 @@
NetAddr localNetAddr,
int remotePort,
AuthSecrets authParms)
- throws IOException {
+ {
Assertion.test(myRemoteVatID.equals(remoteVatID),
"DataPath's remote vatID=", remoteVatID,
" not equal my remote vatID=", myRemoteVatID);
1.5 +32 -28 e/src/jsrc/net/vattp/data/DataPath.java
Index: DataPath.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/vattp/data/DataPath.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DataPath.java 2001/09/06 09:55:39 1.4
+++ DataPath.java 2001/09/14 20:54:04 1.5
@@ -465,11 +465,11 @@
/*package*/void connectToSelf() {
Assertion.test(null == myDataConnection,
"Remote end should not be identitifed");
- try {
+// try {
shutDownPath();
- } catch(IOException e) {
- Trace.comm.errorm("Error shuting down path", e);
- }
+// } catch(IOException e) {
+// Trace.comm.errorm("Error shuting down path", e);
+// }
myConnMgr.connectToSelf(this);
}
@@ -496,9 +496,11 @@
* Enqueue a message for output.
*
* @param the message to queue
- * @exception throws IOException if state is DEAD or DIEING
+ * @exception throws IOException if state is DEAD or DIEING.
+ * XXX markm & Terry: removed throws IOException, since compiler didn't
+ * complain
*/
- /*package*/ void enqueue(Object message) throws IOException {
+ /*package*/ void enqueue(Object message) {
if (Trace.comm.verbose && Trace.ON) {
Trace.comm.verbosem("enqueue " + message);
}
@@ -667,11 +669,11 @@
* @param e The exception which describes the problem
*/
/*package*/ void noticeProblem(Throwable problem) {
- try {
+// try {
shutDownPath();
- } catch(IOException e) {
- Trace.comm.errorm("Exception shutting down connection", e);
- }
+// } catch(IOException e) {
+// Trace.comm.errorm("Exception shutting down connection", e);
+// }
if (null != myDataConnection) {
myDataConnection.noticeProblem(problem);
} else if (null != myConnMgr) {
@@ -689,23 +691,24 @@
long now = System.currentTimeMillis();
if ( (now - lastNetActivity) > Msg.PING_SENDTIME) {
if (0 == timePingSent && null != myWriter) {
- try {
+//No IOException?
+// try {
enqueue(thePingMsg); //Send a ping
if (Trace.comm.event && Trace.ON) {
Trace.comm.eventm("Ping " + this);
}
- } catch(IOException e) {
- Trace.comm.errorm("Exception sending ping", e);
- }
+// } catch(IOException e) {
+// Trace.comm.errorm("Exception sending ping", e);
+// }
timePingSent = System.currentTimeMillis();
} else {
if ( (now - timePingSent) > Msg.PING_TIMEOUT) {
if (null != myWriter) {
- try {
+// try {
shutDownPath();
- } catch(IOException e) {
- Trace.comm.errorm("Error on timeout shutdown", e);
- }
+// } catch(IOException e) {
+// Trace.comm.errorm("Error on timeout shutdown", e);
+// }
if (Trace.comm.usage && Trace.ON) {
Trace.comm.usagem("Connection timeout " + this);
}
@@ -744,11 +747,12 @@
*/
public void processMessage(byte[] message, DataConnection connection) {
if (Msg.PING == message[0]) { // got a ping, send pong
- try {
+//No IOException?
+// try {
enqueue(thePongMsg);
- } catch(IOException e) {
- Trace.comm.errorm("Error enqueuing pong msg", e);
- }
+// } catch(IOException e) {
+// Trace.comm.errorm("Error enqueuing pong msg", e);
+// }
}
//Do nothing with a PONG message. The time received will have already
//been updated, and that is all we need for keep alive.
@@ -891,7 +895,7 @@
* Causes a shutdown of the path. Any queued messages will be sent.
*/
- /*package*/ void shutDownPath() throws IOException {
+ /*package*/ void shutDownPath() {
if (Trace.comm.debug && Trace.ON) {
Trace.comm.debugm("shutDownPath " + this + "\nfor "
+ myDataConnection);
@@ -925,7 +929,7 @@
/*package*/ void startupSuccessful(
String eMsgProtocolVersion,
String protocolSuite)
- throws IOException {
+ throws IOException {
if (null != protocolSuite) {
myProtocolParms.myEProtocolVersion = eMsgProtocolVersion;
@@ -983,11 +987,11 @@
* try.
*/
/*package*/ void tryNext(String reason) {
- try {
+// try {
shutDownPath();
- } catch(IOException e) {
- Trace.comm.errorm("Error shuting down path", e);
- }
+// } catch(IOException e) {
+// Trace.comm.errorm("Error shuting down path", e);
+// }
String msg = myRemoteAddr + ": " + reason;
if (null == myDataConnection) {
myConnMgr.unidentifiedConnectionDied(this, msg, null);
1.4 +9 -9 e/src/jsrc/net/vattp/data/StartUpProtocol.java
Index: StartUpProtocol.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/vattp/data/StartUpProtocol.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StartUpProtocol.java 2001/09/06 09:55:39 1.3
+++ StartUpProtocol.java 2001/09/14 20:54:04 1.4
@@ -311,11 +311,11 @@
}
} catch(IOException e) {
Trace.comm.errorm("IOException starting up", e);
- try {
+// try {
myDataPath.shutDownPath();
- } catch(IOException e2) {
- Trace.comm.errorm("IOException shuting down connection", e2);
- }
+// } catch(IOException e2) {
+// Trace.comm.errorm("IOException shuting down connection", e2);
+// }
}
}
// Protocol methods. These methods are presented more or less in the order
@@ -708,7 +708,7 @@
*/
private void handleStateOutgoingExpectIAM(byte token,
DataInputStream packetIn, byte[] packet)
- throws IOException {
+ throws IOException {
hisMessagesToSign.addElement(packet);
if (myStop) {
startupError(TOK_DUP, "Stopped connection");
@@ -1115,11 +1115,11 @@
if (!myStop) {
myDataPath.tryNext(e.toString() + "\n" + ThrowableSugar.javaStack(e));
} else {
- try {
+// try {
myDataPath.shutDownPath();
- } catch(IOException ex) {
- Trace.comm.errorm("Exception shuting down", ex);
- }
+// } catch(IOException ex) {
+// Trace.comm.errorm("Exception shuting down", ex);
+// }
}
}
}