Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Program Announcements / Download plugin (with progress tracking)

Author
Message
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 5th Jun 2011 20:03 Edited at: 17th Dec 2012 20:42
---------------------------------
THE PLUGIN HAS BEEN REWRITTEN AS OF 2012-12-17.
GO HERE FOR THE NEW VERSION.
---------------------------------



I saw someone asking about how to query the download progress of URLDownloadToFile. "Shouldn't be too hard", I thought and set out to look through the api documentation. I hit a brick wall when it turned out one had to pass an actual interface pointer to the function and not just a struct; in other words, it wouldn't be possible to achieve the desired effect in DBP using just call dll (unless you managed to set up and emulate the full desired interface), so I decided to throw together a custom plugin that does the trick instead.
I figure it could come in handy for some people wanting to download some media or whatever without using ftp and want to be able to keep track of the progress.

Download here.
Documentation is included in the archive.

Update 2011-06-07:
Fixed a typo in the is download in progress() function, causing it to sometimes indicate a non-finished download to be complete.
Also added two new functions and updated the help files accordingly.
The original download link has been updated.

Change log:


Notes:
♦ When retrieving a cached file to continue download from, the process can sometimes seem to freeze for a few seconds. This is not the case and the download will be picked up given enough time.

Small example:



Cheers


"Why do programmers get Halloween and Christmas mixed up?"
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Jun 2011 15:04
That's a really handy plugin particularly if anyone wants to add downloadable content to their game.

Thanks a lot for sharing!

sberk
13
Years of Service
User Offline
Joined: 6th Jun 2010
Location: next to a cup of coffee
Posted: 6th Jun 2011 16:35
Hi,
I tried it. While the download seems to work perfectly, I have some problems with the functions which query the status of the download. Neither the query whether the download is still running nor the functions regarding download status seem to work.
Here I give you my code:

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 6th Jun 2011 17:17
@baxslash: thanks

@sberk: that's odd... I never really tried it with very large files; it seems it handles smaller ones (for example a 5Mb song I've been testing with: http://files.squarefantasy.net/Constellation.mp3) but gets stuck at status code 11 (which I believe is "sending request") with your file as well as another ~50Mb one I've tried. Odd thing is that the file does indeed get downloaded still...
I'll try to look into it further tonight.


"Why do programmers get Halloween and Christmas mixed up?"
sberk
13
Years of Service
User Offline
Joined: 6th Jun 2010
Location: next to a cup of coffee
Posted: 7th Jun 2011 12:54 Edited at: 7th Jun 2011 12:55
Hi,
I played a little bit more around with this and it's seems it depends on the timing of the network. If I use small files (200-300kb) and a traffic shaper, which limits my connection speed, the I the function is download in progress() stops working. It always returns 1, although the download has finished.
If you need assistance or help, I'm more than happy to provide it.
yours
sberK
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 7th Jun 2011 15:15 Edited at: 7th Jun 2011 15:23
Hi again, sorry foor taking longer than I had thought.
Turned out I had a typo in the setting of the isDownloadInProgress flag... x)
Anyway, it seems to function as intended now; give it a try
I've updated the original download link in the first post.

Here's another small demo, making use of two new functions I added and operating on the gnome file sberk mentioned:


Also, thanks for offering to help.


"Why do programmers get Halloween and Christmas mixed up?"
sberk
13
Years of Service
User Offline
Joined: 6th Jun 2010
Location: next to a cup of coffee
Posted: 7th Jun 2011 23:01
I don't know whether this is help. I just tried your example and got a new problem. The application crashes instantly and doesn't create any "C:\temp\test.img".
I have no really idea what's going wrong. Windows 7 just give the following error Message:


If there is any way I can provide additional information, just ask.

sberK
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 8th Jun 2011 00:12
Oh, hm... afraid I neither have Windows 7, nor speak decent german.
Any chance you can track down the function that generates the error (download file, is download in progress, get download status text, etc.)?

Maybe try a different location directory? One thing you have to be wary about is that the location folder (in this case "C:\temp") must exist. But I think you should have that...
Otherwise I take it you've tried running it with administrator rights and all those usual tips?

Also, I've attached a compiled version of my example. Maybe you could tell me if that one works?


"Why do programmers get Halloween and Christmas mixed up?"

Attachments

Login to view attachments
Mudbud Productions
12
Years of Service
User Offline
Joined: 1st May 2011
Location: Cloud 9
Posted: 8th Jun 2011 05:43
wow this is really helpful! Thanks rudolpho

Silence is golden but duck tape is silver - Anonymous
sberk
13
Years of Service
User Offline
Joined: 6th Jun 2010
Location: next to a cup of coffee
Posted: 8th Jun 2011 13:40 Edited at: 8th Jun 2011 13:41
Hi,
thanks a lot for your effort. I've test your programm and I got exactly the same result. I just tried a translation of the windows error message:

I tried to identify the functions which raise the errors.
These functions raise always an error:
avgDownloadRate
get download size()
get downloaded bytes()
While these functions doesn't raise always an error. The first time the loop runs, they are fine, however the second time the programm crashs.
get download status description()
get download status code()

And I found an additional error while exiting the programm. It always crashes irrespective whether the download was completed or canceled.
thanks again for your help,
I just want
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Jun 2011 13:54
This looks like it could be extremely useful once the little bugs are ironed out, keeping my eye on this one

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 8th Jun 2011 19:22
@Mudbud and BatVink, thank you very much

@sberk: seems like there is an access violation somewhere.
I've thrown together a version of the plugin that streams some debugging output to a console; I would be grateful if you could test to run the code with that one (attached) and then report back at which point it crashes.


"Why do programmers get Halloween and Christmas mixed up?"

Attachments

Login to view attachments
sberk
13
Years of Service
User Offline
Joined: 6th Jun 2010
Location: next to a cup of coffee
Posted: 8th Jun 2011 19:43 Edited at: 8th Jun 2011 19:52
Hi,
I can't directly access the console, since the moment I have access to the console, the complete programm has crashed. Therefore I attached two screenshoots.
- start1.png is the first start
- start2.png is the second start, shortly after the first has crashed.
If you need the whole console-output it is probably necessary to write it directly into a file. If the file-name has to be hard-coded, please put something into the C:\temp\ directory.
I just checked the programm on Vista and I get it also crashes. However the console doesn't open at all, so I can't give you a image.
I really appreciate your time investment
sberK

Attachments

Login to view attachments
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 8th Jun 2011 20:43
No, I don't need the entire output, just the last few lines (probably from the last two OnProgress() called statements, if it gets that far). Again, I don't have Windows 7, but the way it works on XP, when the program crashes you can still access the console until such time that you confirm the notification that the application has crashed. The idea was to see at which point in the code the crash occurs, which would hopefully be decently well indicated by the last thing written to the console.
I can redirect it to a file if you can indeed not access the console when the crash notification shows up?


"Why do programmers get Halloween and Christmas mixed up?"
sberk
13
Years of Service
User Offline
Joined: 6th Jun 2010
Location: next to a cup of coffee
Posted: 8th Jun 2011 21:55
The last lines of the crash are attached as screen shoot in my post above. If you need additional output, I try work out a way to get the console. Just using redirecting it ">" doesn't help.
sberK
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 8th Jun 2011 22:43
Hm, I see... it sounds rather illogic that it should crash with a access violation exception at that point though...
I've attached a version that instead writes to "C:\Download.log" instead, if you wouldn't mind trying that and attaching the result.


"Why do programmers get Halloween and Christmas mixed up?"

Attachments

Login to view attachments
sberk
13
Years of Service
User Offline
Joined: 6th Jun 2010
Location: next to a cup of coffee
Posted: 8th Jun 2011 23:31
Of, course. I logged three different trials. Tomorrow morning, I can also check the behaviour under vista.
sberK

Attachments

Login to view attachments
sberk
13
Years of Service
User Offline
Joined: 6th Jun 2010
Location: next to a cup of coffee
Posted: 8th Jun 2011 23:36
Another tip: Microsoft provides Images for testing purpose. These images consists of a completly installed windows system

http://www.microsoft.com/downloads/en/details.aspx?familyid=21eabb90-958f-4b64-b5f1-73d0a413c8ef&displaylang=en

You don't need a license to use them. So they may be handy to compare the behaviour under different operting systems.
I'm at home at the moment and my small computer is not able to run a virtual computer. However tomorrow morning I will see whether I can replicate the behaviour in a virtual pc.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 9th Jun 2011 13:48 Edited at: 9th Jun 2011 14:07
Hmm... have you tried running it on just one processor core (task manager -> right click on the process and choose the appropriate option), if the problem might be that the two threads are running on separate cores and trying to access the shared memory at once?
I have multiple cores too and haven't experienced any such issues though.

Edit: Also, have you tried removing all the progress retrieval functions (essentially just running download file and then waiting) to see if the errors still occur? Judging by your logs it doesn't seem like the OnProgress callback is causing the crash, which I initially thought.

As for the virtual machines, I'm not sure that will work; usually they do not support (nor is there any way to install) direct x, thus making it impossible to run any DB programs on them. There might be exceptione though.


"Why do programmers get Halloween and Christmas mixed up?"
sberk
13
Years of Service
User Offline
Joined: 6th Jun 2010
Location: next to a cup of coffee
Posted: 9th Jun 2011 14:55
No,
I tried to remove all retrival functions. While the download works fine and finishes the application crashes when trying to end the programm. However the end of the programm was directly after finishing the program. Maybe a little bit more time helps.
I just tried it to run it on just one processor, however nothing new. I attached you the download.log
I try to add some extra time as soon as I get to it, hopefully during this night.
yours
sberK

Attachments

Login to view attachments
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 9th Jun 2011 20:34
Ok.
Try this then and see if it will display any error messages (attached below).

And thank you very much for your help on this.


"Why do programmers get Halloween and Christmas mixed up?"

Attachments

Login to view attachments
sberk
13
Years of Service
User Offline
Joined: 6th Jun 2010
Location: next to a cup of coffee
Posted: 10th Jun 2011 00:43
Ok, some good news. It is an big improvement. I just included the for loop, everythings seems fine. Including the end of the programm. However including progress retriaval functions still crashes the application.

I'm going on holiday till monday (and I had to promise to not check Mails ). I will try to see on monday which retriaval function exactly crashs.

Thanks for your help. You added an important function to Dark Basic Pro.

sberK
sberk
13
Years of Service
User Offline
Joined: 6th Jun 2010
Location: next to a cup of coffee
Posted: 16th Jun 2011 18:15
Hi,
I have now done some more testing. It seems that the programm runs only on Computer which have installed Visual Studio. One probable reason could be, that this programm depends on msvcr90d.dll and msvcp90d.dll which are booth part of Visual Studio and not Windows. I get the same errors on the windows xp, vista and windows 7 computers without visual studio (just an appcrash.)
Could you please look into the dll if your version is a relase version and not a version which aims at developers?
sberK
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 16th Jun 2011 20:03
Oh shoot, now that's rather embarrassing...

Well, give this one a try then
(Also updated the archive in the opening post).


"Why do programmers get Halloween and Christmas mixed up?"

Attachments

Login to view attachments
sberk
13
Years of Service
User Offline
Joined: 6th Jun 2010
Location: next to a cup of coffee
Posted: 17th Jun 2011 12:08
Hi,
I just tried it. It still doesn't work on a Computer without visual studio. Probably still some problems with dlls? MSVCP90d.dll is not part of windows. I will see whether placing this file in application directory helps.
sberK
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 17th Jun 2011 16:37 Edited at: 17th Jun 2011 16:37
Well, I did find some more debugging references when reading the linker output log... sneaky stuff.
I stripped out everything superfluous and now have this (attached), which I hope should be fully compatible with any contemporary windows system, debug libraries installed or not. Let me know how it goes


"Why do programmers get Halloween and Christmas mixed up?"

Attachments

Login to view attachments
sberk
13
Years of Service
User Offline
Joined: 6th Jun 2010
Location: next to a cup of coffee
Posted: 17th Jun 2011 18:41 Edited at: 17th Jun 2011 18:46
Hi,
I just tested it on a Windows XP and the core functions seem to work. (downloading and testing whether the download is still downloading). However I haven't been able to test windows vista or windows 7 systems.
sberK

Edit:
Did just a test with a virtual vista and it seemed working,
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 29th Aug 2011 18:49 Edited at: 29th Aug 2011 18:58
I can help by trying win7x64 if you like

{urm please give Me instructions I zipped through the thread...

EDIT

btw as this is HTTP isnt there an http proceed command? in case of dropouts? ie... bad conection? {on the user side... perhaps a resume function? im gonna eat now will probably put more on here shortly

Soup Anybody?

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 31st Aug 2011 15:25
This is really just a wrapper library for the UrlDownloadToFile function with some extra functions to access callback data not normally available to DBPro. I do not handle the connection myself, so no, there is no proceed command.


"Why do programmers get Halloween and Christmas mixed up?"
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 31st Aug 2011 15:51
I will give it a go... but I am looking at Smart packer Pro... and see if that will solve my self update conundrum... but I might use this for other reasons such as image/sound/file downloading for some projects perhaps... Is there any requirements for usage... like crediting you?

Ah du er svensker jeg taler jo dansk haha hey-ho similar languages, I used to live in Denmark for 4 years.

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 31st Aug 2011 19:34
Nah, no requirements; do what you want with it
Trevligt med språket.


"Why do programmers get Halloween and Christmas mixed up?"
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 31st Aug 2011 20:16 Edited at: 31st Aug 2011 20:19
Cheers!

Skol!

EDIT

Actually is there any issue using FTP for downloads??? for example if my code is encrypted... and I have a generic ftp account {I have unlimited FTP accounts} it shouldnt really matter right? is avoiding using ftp simply due to restrictions on some hosting providers allowing few if not just 1 ftp account?

I mean can someone intercept the login data? is that the only issue with using ftp?

Login to post a reply

Server time is: 2024-03-29 04:59:48
Your offset time is: 2024-03-29 04:59:48