www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DFL, Progress Bar, and how to use it against a download

reply Lester L. Martin II <Lester ewam-associates.com> writes:
Hello,
I could probably figure this out if I actually put some time to it but I seldom
have enough time to think such through perfectly.
My question is how do you use DFL's progress bar with Tango's HTTPget and
display a progress.  
If anyone has an answer I would love to see it as this is going to be needed
really bad in the project I'm working on(maybe others will join) and I'd rather
not spend a whole day implementing this perfectly when their is already a way
to do it so I can put my attention to more important things.

Thanks in advance,
Lester L. Martin II
Nov 17 2007
parent reply Lester L. Martin II <Lester ewam-associates.com> writes:
Lester L. Martin II Wrote:

 Hello,
 I could probably figure this out if I actually put some time to it but I
seldom have enough time to think such through perfectly.
 My question is how do you use DFL's progress bar with Tango's HTTPget and
display a progress.  
 If anyone has an answer I would love to see it as this is going to be needed
really bad in the project I'm working on(maybe others will join) and I'd rather
not spend a whole day implementing this perfectly when their is already a way
to do it so I can put my attention to more important things.
 
 Thanks in advance,
 Lester L. Martin II
Or tango's httpclient; I think I know how I'm just not sure that when you call read with the delegate and length will read call the delegate and supply the array of specified length and do so until it gets through or will it read that length and stop and wait for you to call read again. If anyone has an example with HttpClient and the delegate read thing I described I'd love to see it. If it does require to call read more than once, how do you check that you have read everything and there is nothing more to read. Lester L. Martin II
Nov 17 2007
parent reply "Chris Miller" <chris dprogramming.com> writes:
On Sat, 17 Nov 2007 11:11:38 -0500, Lester L. Martin II  
<Lester ewam-associates.com> wrote:

 Lester L. Martin II Wrote:

 Hello,
 I could probably figure this out if I actually put some time to it but  
 I seldom have enough time to think such through perfectly.
 My question is how do you use DFL's progress bar with Tango's HTTPget  
 and display a progress.
 If anyone has an answer I would love to see it as this is going to be  
 needed really bad in the project I'm working on(maybe others will join)  
 and I'd rather not spend a whole day implementing this perfectly when  
 their is already a way to do it so I can put my attention to more  
 important things.

 Thanks in advance,
 Lester L. Martin II
Or tango's httpclient; I think I know how I'm just not sure that when you call read with the delegate and length will read call the delegate and supply the array of specified length and do so until it gets through or will it read that length and stop and wait for you to call read again. If anyone has an example with HttpClient and the delegate read thing I described I'd love to see it. If it does require to call read more than once, how do you check that you have read everything and there is nothing more to read. Lester L. Martin II
Not sure about Tango, but with the DFL ProgressBar, you can set the 'maximum' property to the file size and update the 'value' property to the current size downloaded.
Nov 17 2007
parent reply Lester L. Martin II <Lester ewam-associates.com> writes:
Chris Miller Wrote:

 On Sat, 17 Nov 2007 11:11:38 -0500, Lester L. Martin II  
 <Lester ewam-associates.com> wrote:
 
 Lester L. Martin II Wrote:

 Hello,
 I could probably figure this out if I actually put some time to it but  
 I seldom have enough time to think such through perfectly.
 My question is how do you use DFL's progress bar with Tango's HTTPget  
 and display a progress.
 If anyone has an answer I would love to see it as this is going to be  
 needed really bad in the project I'm working on(maybe others will join)  
 and I'd rather not spend a whole day implementing this perfectly when  
 their is already a way to do it so I can put my attention to more  
 important things.

 Thanks in advance,
 Lester L. Martin II
Or tango's httpclient; I think I know how I'm just not sure that when you call read with the delegate and length will read call the delegate and supply the array of specified length and do so until it gets through or will it read that length and stop and wait for you to call read again. If anyone has an example with HttpClient and the delegate read thing I described I'd love to see it. If it does require to call read more than once, how do you check that you have read everything and there is nothing more to read. Lester L. Martin II
Not sure about Tango, but with the DFL ProgressBar, you can set the 'maximum' property to the file size and update the 'value' property to the current size downloaded.
So are you using phobos or your own socket implementation. How would you use the socket for a HTTP connection if you are using sockets in you example. Lester L. Martin II
Nov 18 2007
parent Lester L. Martin II <Lester ewam-associates.com> writes:
Lester L. Martin II Wrote:

 Chris Miller Wrote:
 
 On Sat, 17 Nov 2007 11:11:38 -0500, Lester L. Martin II  
 <Lester ewam-associates.com> wrote:
 
 Lester L. Martin II Wrote:

 Hello,
 I could probably figure this out if I actually put some time to it but  
 I seldom have enough time to think such through perfectly.
 My question is how do you use DFL's progress bar with Tango's HTTPget  
 and display a progress.
 If anyone has an answer I would love to see it as this is going to be  
 needed really bad in the project I'm working on(maybe others will join)  
 and I'd rather not spend a whole day implementing this perfectly when  
 their is already a way to do it so I can put my attention to more  
 important things.

 Thanks in advance,
 Lester L. Martin II
Or tango's httpclient; I think I know how I'm just not sure that when you call read with the delegate and length will read call the delegate and supply the array of specified length and do so until it gets through or will it read that length and stop and wait for you to call read again. If anyone has an example with HttpClient and the delegate read thing I described I'd love to see it. If it does require to call read more than once, how do you check that you have read everything and there is nothing more to read. Lester L. Martin II
Not sure about Tango, but with the DFL ProgressBar, you can set the 'maximum' property to the file size and update the 'value' property to the current size downloaded.
So are you using phobos or your own socket implementation. How would you use the socket for a HTTP connection if you are using sockets in you example. Lester L. Martin II
Wait now I think I see a way. auto pb = new ProgressBar(); auto client = new HttpClient(HttpClient.Get, "http://www.yahoo.com"); client.open(); if (client.isResponseOK) { // extract content length auto length = client.getResponseHeaders.getInt (HttpHeader.ContentLength, uint.max); pb.maximum(length); client.read(&sink, length); } then the sink void sink(void[] content) { //assuming file is inside class; file.write(content); pb.value = content.length; } is there somewhere I messed up( such as I don't know if you can get the size of a void array, or should I have a loop that gets it maybe 10 bytes(whatever it measures by) at a time). Thanks for all your help. Lester L. Martin II
Nov 18 2007