Recent

Author Topic: ICS - Internet Component Suite for Lazarus?  (Read 15381 times)

GoodBoyAlex

  • New member
  • *
  • Posts: 9
ICS - Internet Component Suite for Lazarus?
« on: August 20, 2014, 09:50:30 am »
Hello! First of all, sorry of my English.

I write first version of my program on Delphi. Now by some reasons (new delphi's version work so slow =( ) i want to migrate my project to Lazarus. It almost succeeded, but i cann't find alternative for ICS - Internet Component Suite (from http://www.overbyte.be/). More precisely, components TMultipartHttpDownloader and TMultiProgressBar. They were used for downloading files from the site. Standard sentences like DownloadFile terminated download. How to do this?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8112
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: ICS - Internet Component Suite for Lazarus?
« Reply #1 on: August 20, 2014, 10:37:22 am »
AFAIK ICS works on FPC, as Marco has always said, but I'm not certain about the components for Lazarus. There are a lot of networking solutions as a replacement, though (read the wiki). Even the distributed fcl-web is already capable doing what you need though not in the form of component, but rather a library.

rvk

  • Hero Member
  • *****
  • Posts: 3842
Re: ICS - Internet Component Suite for Lazarus?
« Reply #2 on: August 20, 2014, 10:55:37 am »
Even the distributed fcl-web is already capable doing what you need though not in the form of component, but rather a library.
Although you can find it with the search function on this forum I guess a direct link to a working example with fcl-web would be welcome:

http://forum.lazarus.freepascal.org/index.php/topic,21824.msg128329.html#msg128329

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7508
Re: ICS - Internet Component Suite for Lazarus?
« Reply #3 on: August 20, 2014, 11:24:27 am »
ICS compiled in 2005-2007, and I quickly tested most components for which there were demoes. That quite covered some ground, since then ICS by far had the most and best demo/test programs, including 10+ console programs.

At the time I was mostly interested in mail (imap,pop,smtp) in console programs and terminal (telnet).

GoodBoyAlex

  • New member
  • *
  • Posts: 9
Re: ICS - Internet Component Suite for Lazarus?
« Reply #4 on: August 20, 2014, 12:15:12 pm »
Even the distributed fcl-web is already capable doing what you need though not in the form of component, but rather a library.
Although you can find it with the search function on this forum I guess a direct link to a working example with fcl-web would be welcome:

http://forum.lazarus.freepascal.org/index.php/topic,21824.msg128329.html#msg128329

Good. But how display speed and how many bytes downloaded?

rvk

  • Hero Member
  • *****
  • Posts: 3842
Re: ICS - Internet Component Suite for Lazarus?
« Reply #5 on: August 20, 2014, 12:25:47 pm »
Good. But how display speed and how many bytes downloaded?
How many bytes downloaded is already visible by the progressbar.

Look at the "TStreamAdapter.DoProgress" in that example. You have FStream.Position (number of bytes already downloaded) and FStream.Size (total bytes of file). With is the fPercent is calculated which in turn is used to call your TForm1.Progress. You could easily change the TOnProgress to include .Position and .Size. You would need to calculate the speed yourself. You could add a starttime to the mix and calculate the milliseconds gone by in the "TStreamAdapter.DoProgress" and give that back too with TOnProgress. (Let us know if you need additional help with that) How where you going to display these figures?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8112
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: ICS - Internet Component Suite for Lazarus?
« Reply #6 on: August 20, 2014, 12:31:11 pm »
Good. But how display speed and how many bytes downloaded?
If you use that code, modify TStreamAdapter.DoProgress to give Position and Size of the stream instead of the counted percentage. With a timer, you can also count the speed. Or you can normalize between two Now() call:
Code: [Select]
pBd = bytes downloaded until previous call
Bd = bytes downloaded until this call
pN = previous now call
N  = this now call

speed in bytes per seconds = (Bd - pBd) / SecondSpan(N,pN)

GoodBoyAlex

  • New member
  • *
  • Posts: 9
Re: ICS - Internet Component Suite for Lazarus?
« Reply #7 on: August 20, 2014, 01:33:03 pm »
Увы, но способ не работает:

rvk

  • Hero Member
  • *****
  • Posts: 3842
Re: ICS - Internet Component Suite for Lazarus?
« Reply #8 on: August 20, 2014, 01:42:18 pm »
Увы, но способ не работает:
Oooo, I had to translate that with Google  :D
Quote
Alas, the method does not work
You are probably calling the procedure with a wrong variable.
In that unit2.pas there is a procedure defined: "procedure DonwloaFile(OnProgress: TOnProgress);"
But you need to define a procedure in your own TMainFrm like "procedure Progress(Sender: TObject; Percent: integer);".
See unit1.pas in that example.
In that procedure you can update your own Progressbar1 on your TMainFrm.

Then you can call DownloaFile with that method Progress as parameter.
« Last Edit: August 20, 2014, 01:44:43 pm by rvk »

GoodBoyAlex

  • New member
  • *
  • Posts: 9
Re: ICS - Internet Component Suite for Lazarus?
« Reply #9 on: August 20, 2014, 01:52:10 pm »
Увы, но способ не работает:
Oooo, I had to translate that with Google  :D
Quote
Alas, the method does not work
You are probably calling the procedure with a wrong variable.
In that unit2.pas there is a procedure defined: "procedure DonwloaFile(OnProgress: TOnProgress);"
But you need to define a procedure in your own TMainFrm like "procedure Progress(Sender: TObject; Percent: integer);".
See unit1.pas in that example.
In that procedure you can update your own Progressbar1 on your TMainFrm.

Then you can call DownloaFile with that method Progress as parameter.
All of this was done from the beginning. "Public" section of MainFrm has such a procedure, but the result above.

rvk

  • Hero Member
  • *****
  • Posts: 3842
Re: ICS - Internet Component Suite for Lazarus?
« Reply #10 on: August 20, 2014, 02:05:03 pm »
All of this was done from the beginning. "Public" section of MainFrm has such a procedure, but the result above.
Maybe you're in {$mode delphi}. In that case you might want to remove the @ before @Progress.
(in {$mode objfpc} you need to use @ but in {$mode delphi} not)

If that doesn't work we need to see more of your code.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8112
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: ICS - Internet Component Suite for Lazarus?
« Reply #11 on: August 20, 2014, 02:06:06 pm »
All of this was done from the beginning. "Public" section of MainFrm has such a procedure, but the result above.
[/quote]
Show us your code

rvk

  • Hero Member
  • *****
  • Posts: 3842
Re: ICS - Internet Component Suite for Lazarus?
« Reply #12 on: August 20, 2014, 02:15:17 pm »
Show us your code
The problem is definitively due to the @ before Progress.
I checked this with {$mode delphi} and i got the exact same error.

GoodBoyAlex, either change the {$mode delphi} to {$mode objfpc} or remove the @ from the call.


GoodBoyAlex

  • New member
  • *
  • Posts: 9
Re: ICS - Internet Component Suite for Lazarus?
« Reply #13 on: August 20, 2014, 02:31:09 pm »
Show us your code
The problem is definitively due to the @ before Progress.
I checked this with {$mode delphi} and i got the exact same error.

GoodBoyAlex, either change the {$mode delphi} to {$mode objfpc} or remove the @ from the call.
Yes, thank you! It works great now.

GoodBoyAlex

  • New member
  • *
  • Posts: 9
Re: ICS - Internet Component Suite for Lazarus?
« Reply #14 on: August 20, 2014, 04:14:48 pm »
New problem: