Changeset 171
- Timestamp:
- Feb 13, 2006 6:37:25 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/Makefile.in
r158 r171 184 184 185 185 libraries: 186 cd filexfer; make all 186 187 187 188 doc: … … 277 278 278 279 clean: 280 cd filexfer; make clean 279 281 -test -z "$(BINARIES)" || rm -f $(BINARIES) 280 282 -rm -f *.o core *.core … … 338 340 $(INSTALL_DATA) pkgIndex.tcl $(DESTDIR)$(pkglibdir)/pkgIndex.tcl 339 341 $(INSTALL_DATA) init.tcl $(DESTDIR)$(pkglibdir)/init.tcl 342 $(mkinstalldirs) $(pkglibdir)/filexfer 343 @for i in $(srcdir)/filexfer/filexfer.jar \ 344 $(srcdir)/filexfer/*.class; do \ 345 echo "Installing $$i" ; \ 346 $(INSTALL_DATA) $$i $(DESTDIR)$(pkglibdir)/filexfer ; \ 347 done; 340 348 341 349 #======================================================================== -
trunk/gui/filexfer/filexfer.java
r115 r171 23 23 public PrintStream ostream; 24 24 public TextArea status; 25 public int port;26 25 27 private Socket socket; 28 private monitor mon; 29 30 private String user; 31 private String cookie; 26 private monitor mon = null; 32 27 33 28 public void init() { 29 int port = 0; 34 30 String portstr = getParameter("port"); 35 31 if (portstr == null) { … … 39 35 } 40 36 37 String user = ""; 41 38 user = getParameter("user"); 42 39 if (user == null) 43 40 user = "???"; 44 41 42 String cookie = ""; 45 43 cookie = getParameter("cookie"); 46 44 if (cookie == null) 47 45 cookie = "<missing>"; 48 49 String mesg="OK";50 try {51 socket = new Socket(getCodeBase().getHost(), port);52 istream = new BufferedReader(53 new InputStreamReader(socket.getInputStream())54 );55 ostream = new PrintStream(socket.getOutputStream());56 }57 catch (UnknownHostException e) { mesg="Unknown host"; }58 catch (Exception e) { mesg="Can't connect to server"; }59 46 60 47 String ipAddr = ""; … … 68 55 ipAddr = "???"; 69 56 } 70 71 try {72 ostream.println("REGISTER "+user+" "+ipAddr+" "+cookie+" RAPPTURE");73 }74 catch (Exception e) { mesg="Can't talk to server"; }75 57 76 58 GridBagLayout gridbag = new GridBagLayout(); … … 88 70 gridbag.setConstraints(status, cons); 89 71 add(status); 90 status.setText(mesg);91 72 92 if (mesg == "OK") { 93 mon = new monitor(this); 94 mon.start(); 95 } 73 mon = new monitor(this, getCodeBase().getHost(), port, 74 user, ipAddr, cookie); 75 mon.start(); 96 76 } 97 77 98 78 public void destroy() { 99 try { 100 ostream.println("UNREGISTER RAPPTURE"); 101 socket.close(); 102 } 103 catch (Exception e) { 104 status.append("\nUNREGISTER notice failed"); 105 } 79 mon.disconnect(); 106 80 } 107 81 108 82 public void start() { 109 try { 110 ostream.println("ACTIVATE RAPPTURE"); 111 } 112 catch (Exception e) { 113 status.append("\nACTIVATE notice failed"); 114 } 83 mon.activate(); 115 84 } 116 85 117 86 public void stop() { 118 try { 119 ostream.println("DEACTIVATE RAPPTURE"); 120 } 121 catch (Exception e) { 122 status.append("\nDEACTIVATE notice failed"); 123 } 87 mon.deactivate(); 124 88 } 125 89 } -
trunk/gui/filexfer/monitor.java
r115 r171 20 20 public class monitor extends Thread { 21 21 private filexfer parent; 22 private String hostName; 23 private int hostPort; 24 private String user; 25 private String ipAddr; 26 private String cookie; 22 27 23 public monitor(filexfer parent) { 28 private Socket socket = null; 29 public BufferedReader istream; 30 public PrintStream ostream; 31 32 private boolean run = true; 33 34 public monitor(filexfer parent, String hostName, int hostPort, 35 String user, String ipAddr, String cookie) { 24 36 this.parent = parent; 37 this.hostName = hostName; 38 this.hostPort = hostPort; 39 this.user = user; 40 this.ipAddr = ipAddr; 41 this.cookie = cookie; 25 42 } 26 43 27 44 public void run() { 28 45 String line = ""; 29 while (true) { 30 try { 31 line = parent.istream.readLine(); 32 if (line == null) { 33 parent.status.append("\nCLOSED"); 34 stop(); 46 while (run) { 47 if (socket == null) { 48 if (!connect()) { 49 try { 50 // sleep a little, so we don't chew up CPU 51 sleep(5000); 52 } 53 catch (java.lang.InterruptedException e) { 54 // just move on 55 } 35 56 } 36 parent.status.append("\nread "+line); 37 38 if (line.startsWith("url ")) { 39 URL url = new URL("http", 40 parent.getCodeBase().getHost(), 41 parent.port, line.substring(4)); 42 43 try { 44 parent.getAppletContext().showDocument(url,"_blank"); 45 parent.status.append("\nlaunched "+url); 57 } else { 58 try { 59 line = istream.readLine(); 60 if (line == null) { 61 parent.status.append("CLOSED\n"); 62 socket.close(); 63 socket = null; 64 } else { 65 handle(line); 46 66 } 47 catch (Exception e) {48 parent.status.append("\nBad URL "+url);49 }50 } else {51 parent.status.append("huh? |"+line+"|");52 67 } 53 }54 catch (java.io.IOException e){55 parent.status.append("\nI/O error: "+e.getMessage());56 }57 catch (Exception e) {58 parent.status.append("\nInternal error: "+e.getMessage());68 catch (java.io.IOException e){ 69 parent.status.append("I/O error: "+e.getMessage()+"\n"); 70 } 71 catch (Exception e) { 72 parent.status.append("Internal error: "+e.getMessage()+"\n"); 73 } 59 74 } 60 75 } 61 76 } 77 78 public void disconnect() { 79 if (socket != null) { 80 try { 81 ostream.println("UNREGISTER RAPPTURE"); 82 } 83 catch (Exception e) { 84 parent.status.append("UNREGISTER notice failed\n"); 85 } 86 try { 87 socket.close(); 88 } 89 catch (Exception e) { 90 parent.status.append("trouble closing socket\n"); 91 } 92 socket = null; 93 } 94 run = false; 95 } 96 97 public void activate() { 98 if (socket != null) { 99 try { 100 ostream.println("ACTIVATE RAPPTURE"); 101 } 102 catch (Exception e) { 103 parent.status.append("ACTIVATE notice failed\n"); 104 } 105 } 106 } 107 108 public void deactivate() { 109 if (socket != null) { 110 try { 111 ostream.println("DEACTIVATE RAPPTURE"); 112 } 113 catch (Exception e) { 114 parent.status.append("DEACTIVATE notice failed\n"); 115 } 116 } 117 } 118 119 public boolean connect() { 120 try { 121 socket = new Socket(hostName, hostPort); 122 istream = new BufferedReader( 123 new InputStreamReader(socket.getInputStream()) 124 ); 125 ostream = new PrintStream(socket.getOutputStream()); 126 } 127 catch (UnknownHostException e) { 128 parent.status.append("Can't connect: Unknown host "+hostName+"\n"); 129 socket = null; 130 return false; 131 } 132 catch (Exception e) { 133 socket = null; 134 return false; 135 } 136 137 try { 138 ostream.println("REGISTER "+user+" "+ipAddr+" "+cookie+" RAPPTURE"); 139 ostream.println("ACTIVATE RAPPTURE"); 140 parent.status.append("Connected\n"); 141 } 142 catch (Exception e) { 143 parent.status.append("\nCan't talk to server"); 144 } 145 return true; 146 } 147 148 public void handle(String line) { 149 parent.status.append("read "+line+"\n"); 150 151 if (line.startsWith("url ")) { 152 try { 153 URL url = new URL("http", 154 hostName, hostPort, line.substring(4)); 155 156 try { 157 parent.getAppletContext().showDocument(url,"_blank"); 158 parent.status.append("launched "+url+"\n"); 159 } 160 catch (Exception e) { 161 parent.status.append("Bad URL "+url+"\n"); 162 } 163 } 164 catch (Exception e) { 165 parent.status.append("Malformed URL "+line.substring(4)+"\n"); 166 } 167 } else { 168 parent.status.append("huh? |"+line+"|\n"); 169 } 170 } 62 171 } -
trunk/gui/init.tcl.in
r158 r171 14 14 proc RapptureGUI_init {} { 15 15 global auto_path 16 global rappture_library17 16 18 17 package require BLT 19 18 20 19 set dir [file dirname [info script]] 21 22 set rappture_library [file join $dir scripts] 23 lappend auto_path $rappture_library 20 lappend auto_path [file join $dir scripts] 24 21 25 22 set suffix [info sharedlibextension] … … 27 24 load $library RapptureGUI 28 25 29 namespace eval Rappture {26 namespace eval RapptureGUI " 30 27 variable version @EXACT_VERSION@ 31 28 variable patchlevel @PATCHLEVEL@ 32 } 29 variable library $dir 30 " 33 31 34 32 package provide RapptureGUI @VERSION@ -
trunk/gui/scripts/analyzer.tcl
r170 r171 186 186 pack $w.top.l -side left 187 187 188 if {[Rappture::filexfer::enabled]} { 189 itk_component add download { 190 button $w.top.dl -text "Download..." \ 191 -command [itcl::code $this download] 192 } 193 pack $itk_component(download) -side right -padx {4 0} 194 Rappture::Tooltip::for $itk_component(download) "Downloads the current result to a new web browser window on your desktop. From there, you can easily print or save results. 195 196 NOTE: Your web browser must allow pop-ups from this site. If your output does not appear, look for a 'pop-up blocked' message and enable pop-ups." 197 } 198 188 199 itk_component add resultselector { 189 200 Rappture::Combobox $w.top.sel -width 50 -editable no … … 194 205 pack $itk_component(resultselector) -side left -expand yes -fill x 195 206 bind $itk_component(resultselector) <<Value>> [itcl::code $this _fixResult] 196 197 if {[Rappture::filexfer::enabled]} {198 itk_component add download {199 button $w.top.dl -text "Download..." \200 -command [itcl::code $this download]201 }202 pack $itk_component(download) -side right -padx {4 0}203 Rappture::Tooltip::for $itk_component(download) "Downloads the current result to a new web browser window on your desktop. From there, you can easily print or save results."204 }205 207 206 208 itk_component add results { -
trunk/gui/scripts/filexfer.tcl
r115 r171 185 185 close $fid 186 186 187 set cid [lindex $clients(order) 0] 188 if {$cid == ""} { 187 set sent 0 188 set access($filename) [bakeCookie] 189 foreach cid $clients(order) { 190 if {[info exists clients($cid)] && $clients($cid)} { 191 catch { 192 puts $cid [format "url /spool/%s/%s?access=%s" \ 193 $env(SESSION) $filename $access($filename)] 194 } 195 set sent 1 196 } 197 } 198 if {!$sent} { 189 199 error "no clients" 190 200 } 191 192 set access($filename) [bakeCookie]193 puts $cid "url /spool/$env(SESSION)/$filename?access=$access($filename)"194 201 } 195 202 } … … 439 446 # 440 447 set url [string trimleft $url /] 441 set file [file join $Rappture ::installdirfilexfer $url]448 set file [file join $RapptureGUI::library filexfer $url] 442 449 response $cid file -path $file -connection $headers(Connection) 443 450 } else { -
trunk/gui/scripts/postern.tcl
r115 r171 132 132 133 133 eval itk_initialize $args 134 135 # this makes it easier to find the magic spot 136 bind $itk_component(hull) <Alt-Enter> [list $itk_component(hull) configure -background $itk_option(-activecolor)] 137 bind $itk_component(hull) <Leave> [list $itk_component(hull) configure -background $itk_option(-background)] 134 138 } 135 139 -
trunk/tcl/install.tcl
r161 r171 59 59 foreach file { 60 60 ./scripts/library.tcl 61 ../gui/scripts/exec.tcl 61 ./scripts/exec.tcl 62 ./scripts/result.tcl 62 63 ../gui/scripts/units.tcl 63 ../gui/scripts/result.tcl64 64 } { 65 65 set target [file join $targetdir scripts [file tail $file]]
Note: See TracChangeset
for help on using the changeset viewer.