shoes/shoes4 — pull request #612 by KCErb (2014-03-20 01:36:40+00:00)
Title: updated download to work as documented

OK, so this is a little sloppy/messy I'm afraid, so please comment liberally!

My main focus was to address #525 by adding the named functions (abort, transferred etc). In addition I added some things from the manual that weren't in there yet (headers, body, etc)

Most of my time was spent working on the :progress proc.

I put it inside open-uri's progress_proc option. This proc gets called every time a packet is transferred which is **way** faster than the gui can update. This results in a long line of asyncEvents waiting to be executed long after the download is over.

After a bit of searching the only solution I found was to have a variable toggle on and off to determine whether or not @gui.eval_block gets called on a given run of the progress_proc. This way the asyncEvent's only get triggered if the gui is ready to handle them.

The only trouble is, I found that unless my variable could be seen by both the Swt::Download, and Shoes:Download it was very slow (meaning, the gui would update every 5 seconds or so). So that means I used a global variable which is probably a no-no --> $async_has_finished.

More comments inline!