rem ' BBjHtmlViewDownloadEvent::getClientFileSize
url$ = ::BBUtils.bbj::BBUtils.getWebServerURL()+"index.html"
filename$ = "zip.zip"; rem ' must be a binary file
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(25,25,600,500,url$,$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.setCallback(window!.ON_RESIZE,"resize")
htmlview! = window!.addHtmlView(102,25,25,550,450,"",$$)
htmlview!.setCallback(htmlview!.ON_PAGE_LOADED,"on_page_loaded")
htmlview!.setUrl(url$)
clientType$ = htmlview!.getClientType()
clientVersion$ = htmlview!.getClientVersion()
title$ = window!.getTitle() + " " + clientType$ + " " + clientVersion$
window!.setTitle(title$)
print "getDownloadDirectory ",htmlview!.getDownloadDirectory()
download$ = System@.getProperty("user.home")+"/Downloads"
htmlview!.setDownloadDirectory(download$)
print "getDownloadDirectory ",htmlview!.getDownloadDirectory()
copyFromClient = 0
if (msgbox("ON_HTMLVIEW_DOWNLOAD?",4+32)=6) then
htmlview!.setCallback(htmlview!.ON_HTMLVIEW_DOWNLOAD,"on_htmlview_download")
copyFromClient = msgbox("Copy downloaded files from client to server?",4+32)=6
endif
process_events
eoj:
release
resize:
gosub event
width = event!.getWidth() - 50
height = event!.getHeight() - 50
htmlview!.setSize(width,height)
print width,height
return
event:
event! = sysgui!.getLastEvent()
print event!.getEventName()," ",event!.getControl()
return
on_page_loaded:
event! = sysgui!.getLastEvent()
print event!.getEventName()," ",event!.getUrl()
if event!.getUrl().equals("about:blank") then return
htmlview!.clearCallback(htmlview!.ON_PAGE_LOADED)
rem ' This must be a binary file to trigger a file download
script$ = "window.location.href=""/"+filename$+""""
print script$
htmlview!.executeScript(script$)
return
on_htmlview_download:
event! = sysgui!.getLastEvent()
print event!.getEventName()," suggested=",event!.getSuggestedFileName()," filename=",event!.getClientFileName()," size=",event!.getClientFileSize()
if (copyFromClient) then
tc! = bbjapi().getThinClient()
fs! = tc!.getClientFileSystem()
cf! = fs!.getClientFile(event!.getClientFileName())
if (cf!.exists()) then
server$ = cf!.copyFromClient()
print "Copied client file ",cf!," to server file ",server$
server = unt
open (server)server$
xfin$ = xfin(server)
bytes = dec(xfin$(1,8))
close (server)
print "Server file ",server$," size:",bytes," bytes."
else
print "Client file ",cf!," doesn't exist."
endif
endif
return
|