Changeset 565 for trunk/gui/filexfer
- Timestamp:
- Jan 17, 2007, 2:29:31 PM (18 years ago)
- Location:
- trunk/gui/filexfer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/filexfer/filexfer.java
r171 r565 45 45 cookie = "<missing>"; 46 46 47 String connect_param = null; 48 connect_param = getParameter("connect"); 49 47 50 String ipAddr = ""; 48 51 try { … … 72 75 73 76 mon = new monitor(this, getCodeBase().getHost(), port, 74 user, ipAddr, cookie );77 user, ipAddr, cookie, connect_param); 75 78 mon.start(); 76 79 } -
trunk/gui/filexfer/monitor.java
r213 r565 27 27 private String ipAddr; 28 28 private String cookie; 29 private String connect_param; 29 30 30 31 private Socket socket = null; … … 35 36 36 37 public monitor(filexfer parent, String hostName, int hostPort, 37 String user, String ipAddr, String cookie ) {38 String user, String ipAddr, String cookie, String connect_param) { 38 39 this.parent = parent; 39 40 this.hostName = hostName; … … 42 43 this.ipAddr = ipAddr; 43 44 this.cookie = cookie; 45 this.connect_param = connect_param; 46 } 47 48 private void snooze(int sec) { 49 int ms = sec * 1000; 50 parent.status.append("Snoozing " + Integer.toString(sec) + " sec.\n"); 51 try { 52 // sleep a little, so we don't chew up CPU 53 sleep(ms); 54 } 55 catch (java.lang.InterruptedException e) { 56 // just move on 57 } 44 58 } 45 59 … … 49 63 if (socket == null) { 50 64 if (!connect()) { 51 try { 52 // sleep a little, so we don't chew up CPU 53 sleep(5000); 54 } 55 catch (java.lang.InterruptedException e) { 56 // just move on 57 } 65 snooze(60); 58 66 } 59 67 } else { 60 68 try { 61 line = istream.readLine(); 62 if (line == null) { 63 parent.status.append("CLOSED\n"); 64 socket.close(); 65 socket = null; 66 } else { 67 handle(line); 69 while(true) { 70 line = istream.readLine(); 71 if (line == null) { 72 parent.status.append("CLOSED\n"); 73 socket.close(); 74 socket = null; 75 } else { 76 handle(line); 77 } 68 78 } 69 79 } 70 80 catch (java.io.IOException e){ 71 81 parent.status.append("I/O error: "+e.getMessage()+"\n"); 82 try { 83 socket.close(); 84 } 85 catch (Exception e2) { 86 // Ignore errors. 87 } 88 socket = null; 72 89 } 73 90 catch (Exception e) { 74 91 parent.status.append("Internal error: "+e.getMessage()+"\n"); 75 } 92 try { 93 socket.close(); 94 } 95 catch (Exception e2) { 96 // Ignore errors. 97 } 98 socket = null; 99 } 100 snooze(60); 76 101 } 77 102 } … … 137 162 } 138 163 164 if (connect_param != null) { 165 try { 166 ostream.println("CONNECT " + connect_param + " HTTP/1.1"); 167 ostream.println("Host: " + connect_param); 168 ostream.println(""); 169 } 170 catch (Exception e) { 171 parent.status.append("\nCan't forward connection."); 172 return false; 173 } 174 try { 175 while(true) { 176 String line = istream.readLine(); 177 if (line.length() == 0) { 178 parent.status.append("\nDone with forward."); 179 break; 180 } 181 if (line == null) { 182 parent.status.append("\nNull forward."); 183 break; 184 } 185 parent.status.append("\n" + Integer.toString(line.length()) + ":" + line); 186 } 187 } 188 catch (Exception e) { 189 parent.status.append("\nCan't get forward response."); 190 return false; 191 } 192 } 193 139 194 try { 140 195 ostream.println("REGISTER "+user+" "+ipAddr+" "+cookie+" RAPPTURE/"+protocol); … … 144 199 catch (Exception e) { 145 200 parent.status.append("\nCan't talk to server"); 201 return false; 146 202 } 147 203 return true; … … 153 209 if (line.startsWith("url ")) { 154 210 try { 155 URL url = new URL("http", 156 hostName, hostPort, line.substring(4)); 211 URL url = null; 212 if (connect_param == null) { 213 url = new URL("http", 214 hostName, hostPort, line.substring(4)); 215 } else { 216 url = new URL("https", hostName, 217 "/" + connect_param.replace(':','/') + 218 line.substring(4)); 219 } 157 220 158 221 try {
Note: See TracChangeset
for help on using the changeset viewer.