Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 496
  • Last Modified:

best way to implement a download manager: extension

This is a question for TheRealLoki and is a reference to:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21854739.html

TheRealLoki,
Can you please post the extended code example you mentioned in your previous answer?
0
hibbidiji
Asked:
hibbidiji
  • 7
  • 5
  • 4
1 Solution
 
hibbidijiAuthor Commented:
What I need to implement will ne in a new window and will use a gridview for it's display.  I will be calling these objects from my main form.
0
 
wildzeroCommented:
I also look forward to seeing the extended code, TheRealLoki answered my questions about Threads the other day and I found his code to be excellent, I read the previous question (in your question) and again his code is really nice to read.... learning alot from you TheRealLoki  =) keep up the good work.
0
 
hibbidijiAuthor Commented:
I'm glad to see that these questions are helping other people - I always worry that I'm too specific :)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
TheRealLokiSenior DeveloperCommented:
I've made a Delphi 7 Indy 9 version. Will start on an indy 10 version later.
I haven't finished the "highlighting" in the TListView, but that's just cosmetic, and not necessary for the basic design.
You can easily adapt it to show the updates (% downloaded) in a grid on another form.

https://sourceforge.net/project/showfiles.php?group_id=168004&package_id=191386&release_id=419131

If you get a zero length .zip when you download the demo, just wait and try again. It can take a few mins for sourceforge to get the package out to all its' mirrors.
0
 
TheRealLokiSenior DeveloperCommented:
oh, for later versions, check the main page directly
https://sourceforge.net/projects/internetdemos/
0
 
wildzeroCommented:
Hey there,

Thanks for this, however I goto download it and it says invalid archive (16.6k big)
tired all the mirrors and get the same on all of them...  Will try again in 15 but just a heads up.
0
 
hibbidijiAuthor Commented:
TheRealLoki,
I downloaded and opened the project in D2005 with Indy9.    On opening the project for the first time I got a couple messages about properties that did not exist for the client - these did not return (for me to report to you) on any subsequent open.    When attempting to compile, I get the following errors:

[Error] MultiFileDownloaderMain.pas(235): E2009 Incompatible types: 'Parameter lists differ'
[Error] MultiFileDownloaderMain.pas(236): E2009 Incompatible types: 'Parameter lists differ'
[Fatal Error] MultiFileDownloader.dpr(5): F2063 Could not compile used unit 'MultiFileDownloaderMain.pas'

0
 
wildzeroCommented:
It seems that trying to open the zip file with winzip gives that error, however winrar was OK.
I compiled the source ok and only got a res file error when opening first time (no issue though).

:D
0
 
TheRealLokiSenior DeveloperCommented:
you are not using Indy 9
you are most likely using indy 10, that is why I have the demos in specific releases, 1 for each environment I actually own.
so, "Indy 9 Delphi 7" and "Indy 10 Delphi 5"
I have just made an Indy 10 demo also
goto the main site, and click on download for the appropriate version you have
0
 
TheRealLokiSenior DeveloperCommented:
hmmm, maybe i should start zipping these up with an older pkzip just to be compatible with everyone. I use WinRar 8 for most things
0
 
hibbidijiAuthor Commented:
My errors even with package titled:  
0
 
hibbidijiAuthor Commented:
I take it back - I DID get an error when opening the indy10 packaged app but it compiled fine and runs like a champ :)
Fantastic work as usual - now I just need to read it enough times to understand it.   Kudos.
0
 
hibbidijiAuthor Commented:
Loki,
If you are still watching this question, I would like to add pause and cancel functionality as well as cancel all downloads.    I'm happy to open a new question but I would appreciate assistance if you see this.
0
 
wildzeroCommented:
A good way to learn is first write down on paper how you think it would work in just enlish
ie
get thread name
pause/stop thread
display this to user

or something
then from there look at writing the code as to how you think it would work, and then post here
just a suggestion =)
0
 
TheRealLokiSenior DeveloperCommented:
You cannot just "pause", so I'm guessing you mean, stop, but allow this to be continued  (resumed) later.
note: not all servers support "resuming"

to "cancel" - all you need to do, is terminate the thread, and have the indy IdHTTP component stop somehow.
1 way to do this is raise an exception in the IdHTTP.OnWOrk event.
eg. in the IdHTTP.OnWork have some code like
if terminated then raise EUserAskedMeToCancel.create('cancelling.') else....
( declared as:  type EUserAskedMeToCancel = class Exception; // made my own exception to show cancelling )
This unfortunately means you will have to keep track of the thread
ie. instead of just
 TIndyInAThread.create(....
you will need to have
IndyInAThread: TIndyInAThread;
..
IndyInAThread := TIndyInAThread.Create(...
so that you can just say "IndyInAThread.Terminate;" to cancel.
perhaps put this in a "StopDownload" procedure of TDownloadableFile

so to stop all, you would do

    var
        i: integer;
    begin
        for i := 0 to pred(DownloadableFileList.Count) do
          TDownloadableFile(DownloadableFileList[i]).StopDownload;
    end;


Info I'm sure you'll want later...
To have Indy "resume" a download from a specifed point, you set the
Request.ContentRangeStart and Request.ContentRangeEnd values before you perform the GET()
It is possible to have 5 threads (for example) grabbing different parts of the same file. This is a common method to improve download speeds where servers throttle each connection. you have 5 connections, so you get the file faster. (assuming you have an internet connection faster than the server's "throttled" limit for each connection)
Note: some servers have caught on to this, and only allow 1 or 2 connections per IP adddress

Let me know if you want me to do a proper demo for you on this, but I know the above works
0
 
hibbidijiAuthor Commented:
TheRealLoki:
In the interest of making sure this is done right, I've opened a new question. it is here:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21875700.html

Your work is excellent and I hope you will be able to update your demo with this new functionality (just cancellation, not pause / resume)
I am working in d2005 with indy10

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 7
  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now