[or-cvs] Fix some-but-not-all compile errors in demo code
Nick Mathewson
nickm at seul.org
Thu Jun 23 21:36:08 UTC 2005
Update of /home/or/cvsroot/control/java/net/freehaven/tor/control/examples
In directory moria:/tmp/cvs-serv28887/net/freehaven/tor/control/examples
Modified Files:
DebuggingEventHandler.java Main.java
Log Message:
Fix some-but-not-all compile errors in demo code
Index: DebuggingEventHandler.java
===================================================================
RCS file: /home/or/cvsroot/control/java/net/freehaven/tor/control/examples/DebuggingEventHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- DebuggingEventHandler.java 4 Jun 2005 02:42:55 -0000 1.1
+++ DebuggingEventHandler.java 23 Jun 2005 21:36:06 -0000 1.2
@@ -3,11 +3,11 @@
// See LICENSE file for copying information
package net.freehaven.tor.control.examples;
-import net.freehaven.tor.control.*;
import java.io.PrintWriter;
import java.util.Iterator;
+import net.freehaven.tor.control.EventHandler;
-public class DebuggingEventHandler implements EventHandler, TorControlCommands {
+public class DebuggingEventHandler implements EventHandler {
protected PrintWriter out;
@@ -15,17 +15,14 @@
out = p;
}
- public void circuitStatus(int status, int circID, String path) {
- out.println("Circuit "+Integer.toHexString(circID)+" is now "+
- CIRC_STATUS_NAMES[status]+" (path="+path+")");
+ public void circuitStatus(String status, String circID, String path) {
+ out.println("Circuit "+circID+" is now "+status+" (path="+path+")");
}
- public void streamStatus(int status, int streamID, String target) {
- out.println("Stream "+Integer.toHexString(streamID)+" is now "+
- STREAM_STATUS_NAMES[status]+" (target="+target+")");
+ public void streamStatus(String status, String streamID, String target) {
+ out.println("Stream "+streamID+" is now "+status+" (target="+target+")");
}
- public void orConnStatus(int status, String orName) {
- out.println("OR connection to "+orName+" is now "+
- OR_CONN_STATUS_NAMES[status]);
+ public void orConnStatus(String status, String orName) {
+ out.println("OR connection to "+orName+" is now "+status);
}
public void bandwidthUsed(long read, long written) {
out.println("Bandwidth usage: "+read+" bytes read; "+
@@ -36,18 +33,12 @@
for (Iterator i = orList.iterator(); i.hasNext(); )
out.println(" "+i.next());
}
- public void message(int type, String msg) {
- String tp;
- switch (type) {
- case EVENT_MSG_INFO: tp = "info"; break;
- case EVENT_MSG_NOTICE: tp = "notice"; break;
- case EVENT_MSG_WARN: tp = "warn"; break;
- case EVENT_MSG_ERROR: tp = "error"; break;
- default:
- throw new Error("EventHandler.message() called with bad type: "+
- type);
- }
- out.println("["+tp+"] "+msg.trim());
+ public void message(String type, String msg) {
+ out.println("["+type+"] "+msg.trim());
+ }
+
+ public void unrecognized(String type, String msg) {
+ out.println("unrecognized event ["+type+"] "+msg.trim());
}
}
\ No newline at end of file
Index: Main.java
===================================================================
RCS file: /home/or/cvsroot/control/java/net/freehaven/tor/control/examples/Main.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Main.java 4 Jun 2005 02:42:55 -0000 1.1
+++ Main.java 23 Jun 2005 21:36:06 -0000 1.2
@@ -137,22 +137,8 @@
public static void signal(String[] args) throws IOException {
// Usage signal [reload|shutdown|dump|debug|halt]
- TorControlConnection conn = getConnection(args);
- byte sig;
- if (args[1].equals("reload"))
- sig = SIGNAL_HUP;
- else if (args[1].equals("shutdown"))
- sig = SIGNAL_INT;
- else if (args[1].equals("dump"))
- sig = SIGNAL_USR1;
- else if (args[1].equals("debug"))
- sig = SIGNAL_USR2;
- else if (args[1].equals("halt"))
- sig = SIGNAL_TERM;
- else {
- System.err.println("Unrecognized signal: "+args[1]);
- return;
- } conn.signal(sig);
+ TorControlConnection conn = getConnection(args, false);
+ conn.signal(args[1].toUpperCase());
}
public static void authDemo(String[] args) throws IOException {
More information about the tor-commits
mailing list