summaryrefslogtreecommitdiff
path: root/plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo
diff options
context:
space:
mode:
authorMikhail Grigoryev <sleuthhound@gmail.com>2013-05-22 09:48:12 +0000
committerMikhail Grigoryev <sleuthhound@gmail.com>2013-05-22 09:48:12 +0000
commit273b10c5ce28a955e6b7a6b384cba736f1762d77 (patch)
treedbbea2f0fad1523ddac35d4eefe3581a977cc970 /plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo
parentbe91c27a63f26c845a8f16b4a12cb048152ef182 (diff)
Added plugin MirandaNGHistoryToDB (www.im-history.ru)
git-svn-id: http://svn.miranda-ng.org/main/trunk@4793 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo')
-rw-r--r--plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTest.dpr15
-rw-r--r--plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTest.dproj109
-rw-r--r--plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTest.resbin0 -> 5280 bytes
-rw-r--r--plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTestUnit.dfm125
-rw-r--r--plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTestUnit.pas176
5 files changed, 425 insertions, 0 deletions
diff --git a/plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTest.dpr b/plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTest.dpr
new file mode 100644
index 0000000000..8942f8b61d
--- /dev/null
+++ b/plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTest.dpr
@@ -0,0 +1,15 @@
+program DownLoaderTest;
+
+uses
+ Forms,
+ DownLoaderTestUnit in 'DownLoaderTestUnit.pas' {MainForm};
+
+{$R *.res}
+
+begin
+ Application.Initialize;
+ Application.MainFormOnTaskbar := True;
+ Application.Title := 'IM Downloader Demo';
+ Application.CreateForm(TMainForm, MainForm);
+ Application.Run;
+end.
diff --git a/plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTest.dproj b/plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTest.dproj
new file mode 100644
index 0000000000..c0b14483c0
--- /dev/null
+++ b/plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTest.dproj
@@ -0,0 +1,109 @@
+п»ї <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <ProjectGuid>{8B841E47-C817-4F26-8ACF-89048F0E7C42}</ProjectGuid>
+ <MainSource>DownLoaderTest.dpr</MainSource>
+ <Base>True</Base>
+ <Config Condition="'$(Config)'==''">Release</Config>
+ <Platform>Win32</Platform>
+ <AppType>Application</AppType>
+ <FrameworkType>VCL</FrameworkType>
+ <DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
+ <ProjectVersion>12.3</ProjectVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
+ <Base>true</Base>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_1)'!=''">
+ <Cfg_1>true</Cfg_1>
+ <CfgParent>Base</CfgParent>
+ <Base>true</Base>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''">
+ <Cfg_2>true</Cfg_2>
+ <CfgParent>Base</CfgParent>
+ <Base>true</Base>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Base)'!=''">
+ <DCC_ImageBase>00400000</DCC_ImageBase>
+ <DCC_E>false</DCC_E>
+ <DCC_S>false</DCC_S>
+ <DCC_F>false</DCC_F>
+ <DCC_N>false</DCC_N>
+ <DCC_K>false</DCC_K>
+ <DCC_UnitAlias>WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;WinTypes=Windows;WinProcs=Windows;$(DCC_UnitAlias)</DCC_UnitAlias>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Cfg_1)'!=''">
+ <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
+ <DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
+ <DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
+ <DCC_DebugInformation>false</DCC_DebugInformation>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Cfg_2)'!=''">
+ <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
+ <DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
+ <DCC_Optimize>false</DCC_Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <DelphiCompile Include="DownLoaderTest.dpr">
+ <MainSource>MainSource</MainSource>
+ </DelphiCompile>
+ <DCCReference Include="DownLoaderTestUnit.pas">
+ <Form>MainForm</Form>
+ </DCCReference>
+ <BuildConfiguration Include="Debug">
+ <Key>Cfg_2</Key>
+ <CfgParent>Base</CfgParent>
+ </BuildConfiguration>
+ <BuildConfiguration Include="Base">
+ <Key>Base</Key>
+ </BuildConfiguration>
+ <BuildConfiguration Include="Release">
+ <Key>Cfg_1</Key>
+ <CfgParent>Base</CfgParent>
+ </BuildConfiguration>
+ </ItemGroup>
+ <Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
+ <Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/>
+ <ProjectExtensions>
+ <Borland.Personality>Delphi.Personality.12</Borland.Personality>
+ <Borland.ProjectType>VCLApplication</Borland.ProjectType>
+ <BorlandProject>
+ <Delphi.Personality>
+ <Source>
+ <Source Name="MainSource">DownLoaderTest.dpr</Source>
+ </Source>
+ <VersionInfo>
+ <VersionInfo Name="IncludeVerInfo">False</VersionInfo>
+ <VersionInfo Name="AutoIncBuild">False</VersionInfo>
+ <VersionInfo Name="MajorVer">1</VersionInfo>
+ <VersionInfo Name="MinorVer">0</VersionInfo>
+ <VersionInfo Name="Release">0</VersionInfo>
+ <VersionInfo Name="Build">0</VersionInfo>
+ <VersionInfo Name="Debug">False</VersionInfo>
+ <VersionInfo Name="PreRelease">False</VersionInfo>
+ <VersionInfo Name="Special">False</VersionInfo>
+ <VersionInfo Name="Private">False</VersionInfo>
+ <VersionInfo Name="DLL">False</VersionInfo>
+ <VersionInfo Name="Locale">1049</VersionInfo>
+ <VersionInfo Name="CodePage">1251</VersionInfo>
+ </VersionInfo>
+ <VersionInfoKeys>
+ <VersionInfoKeys Name="CompanyName"/>
+ <VersionInfoKeys Name="FileDescription"/>
+ <VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
+ <VersionInfoKeys Name="InternalName"/>
+ <VersionInfoKeys Name="LegalCopyright"/>
+ <VersionInfoKeys Name="LegalTrademarks"/>
+ <VersionInfoKeys Name="OriginalFilename"/>
+ <VersionInfoKeys Name="ProductName"/>
+ <VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
+ <VersionInfoKeys Name="Comments"/>
+ </VersionInfoKeys>
+ </Delphi.Personality>
+ <Platforms>
+ <Platform value="Win32">True</Platform>
+ </Platforms>
+ </BorlandProject>
+ <ProjectFileVersion>12</ProjectFileVersion>
+ </ProjectExtensions>
+ </Project>
diff --git a/plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTest.res b/plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTest.res
new file mode 100644
index 0000000000..fc1937e1c7
--- /dev/null
+++ b/plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTest.res
Binary files differ
diff --git a/plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTestUnit.dfm b/plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTestUnit.dfm
new file mode 100644
index 0000000000..b245bf8704
--- /dev/null
+++ b/plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTestUnit.dfm
@@ -0,0 +1,125 @@
+object MainForm: TMainForm
+ Left = 0
+ Top = 0
+ Caption = 'TIMDownloadThread Test'
+ ClientHeight = 252
+ ClientWidth = 608
+ Color = clBtnFace
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clWindowText
+ Font.Height = -11
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ OldCreateOrder = False
+ Position = poDesktopCenter
+ OnShow = FormShow
+ PixelsPerInch = 96
+ TextHeight = 13
+ object ToolBar1: TToolBar
+ Left = 0
+ Top = 0
+ Width = 608
+ Height = 25
+ ButtonHeight = 27
+ ButtonWidth = 79
+ Caption = 'ToolBar1'
+ List = True
+ ShowCaptions = True
+ TabOrder = 0
+ object Edit1: TEdit
+ Left = 0
+ Top = 0
+ Width = 385
+ Height = 27
+ TabOrder = 0
+ end
+ object TBDownload: TToolButton
+ Left = 385
+ Top = 0
+ AutoSize = True
+ Caption = #1057#1082#1072#1095#1072#1090#1100
+ ImageIndex = 0
+ OnClick = TBDownloadClick
+ end
+ object TBStopDownload: TToolButton
+ Left = 444
+ Top = 0
+ AutoSize = True
+ Caption = #1054#1089#1090#1072#1085#1086#1074#1080#1090#1100
+ ImageIndex = 1
+ Visible = False
+ OnClick = TBStopDownloadClick
+ end
+ object TBView: TToolButton
+ Left = 521
+ Top = 0
+ AutoSize = True
+ Caption = #1042#1099#1074#1077#1089#1090#1080
+ DropdownMenu = PopupMenu1
+ ImageIndex = 2
+ Style = tbsDropDown
+ Visible = False
+ OnClick = TBViewClick
+ end
+ end
+ object StatusBar1: TStatusBar
+ Left = 0
+ Top = 233
+ Width = 608
+ Height = 19
+ Panels = <>
+ SimplePanel = True
+ end
+ object RichEdit1: TRichEdit
+ Left = 0
+ Top = 25
+ Width = 608
+ Height = 191
+ Align = alClient
+ Font.Charset = RUSSIAN_CHARSET
+ Font.Color = clWindowText
+ Font.Height = -11
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ ParentFont = False
+ ReadOnly = True
+ ScrollBars = ssBoth
+ TabOrder = 2
+ end
+ object ProgressBar1: TProgressBar
+ Left = 0
+ Top = 216
+ Width = 608
+ Height = 17
+ Align = alBottom
+ TabOrder = 3
+ end
+ object IMDownloader_Demo: TIMDownloader
+ OnError = IMDownloader_DemoError
+ OnAccepted = IMDownloader_DemoAccepted
+ OnHeaders = IMDownloader_DemoHeaders
+ OnMD5Checked = IMDownloader_DemoMD5Checked
+ OnDownloading = IMDownloader_DemoDownloading
+ OnStartDownload = IMDownloader_DemoStartDownload
+ OnBreak = IMDownloader_DemoBreak
+ Left = 72
+ Top = 40
+ end
+ object SaveDialog1: TSaveDialog
+ Left = 136
+ Top = 96
+ end
+ object PopupMenu1: TPopupMenu
+ Left = 224
+ Top = 120
+ object ViewAsTest: TMenuItem
+ Caption = #1054#1090#1086#1073#1088#1072#1079#1080#1090#1100' '#1082#1072#1082' '#1090#1077#1082#1089#1090
+ Default = True
+ OnClick = ViewAsTestClick
+ end
+ object SaveToFile: TMenuItem
+ Caption = #1057#1086#1093#1088#1072#1085#1080#1090#1100' '#1074' '#1092#1072#1081#1083
+ OnClick = SaveToFileClick
+ end
+ end
+end
diff --git a/plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTestUnit.pas b/plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTestUnit.pas
new file mode 100644
index 0000000000..2ca42ac174
--- /dev/null
+++ b/plugins/MirandaNGHistoryToDB/IMDownloaderComponent/Demo/DownLoaderTestUnit.pas
@@ -0,0 +1,176 @@
+unit DownLoaderTestUnit;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+ Dialogs, uIMDownLoader, StdCtrls, ToolWin, ComCtrls, Menus;
+
+type
+ TMainForm = class(TForm)
+ IMDownloader_Demo: TIMDownloader;
+ Edit1: TEdit;
+ ToolBar1: TToolBar;
+ StatusBar1: TStatusBar;
+ RichEdit1: TRichEdit;
+ SaveDialog1: TSaveDialog;
+ TBDownload: TToolButton;
+ TBStopDownload: TToolButton;
+ TBView: TToolButton;
+ ViewAsTest: TMenuItem;
+ SaveToFile: TMenuItem;
+ PopupMenu1: TPopupMenu;
+ ProgressBar1: TProgressBar;
+ procedure FormShow(Sender: TObject);
+ procedure IMDownloader_DemoError(Sender: TObject; E: TIMDownLoadError);
+ procedure IMDownloader_DemoAccepted(Sender: TObject);
+ procedure IMDownloader_DemoStartDownload(Sender: TObject);
+ procedure IMDownloader_DemoBreak(Sender: TObject);
+ procedure ViewAsTestClick(Sender: TObject);
+ procedure SaveToFileClick(Sender: TObject);
+ procedure TBDownloadClick(Sender: TObject);
+ procedure TBStopDownloadClick(Sender: TObject);
+ procedure TBViewClick(Sender: TObject);
+ procedure IMDownloader_DemoDownloading(Sender: TObject; AcceptedSize, MaxSize: Cardinal);
+ procedure IMDownloader_DemoHeaders(Sender: TObject; Headers: string);
+ procedure IMDownloader_DemoMD5Checked(Sender: TObject; MD5Correct,
+ SizeCorrect: Boolean; MD5Str: string);
+ private
+ { Private declarations }
+ public
+ { Public declarations }
+ end;
+
+var
+ MainForm: TMainForm;
+
+const
+ uURL = 'http://im-history.ru/update/get.php?file=HistoryToDB-Update';
+
+implementation
+
+{$R *.dfm}
+
+procedure TMainForm.FormShow(Sender: TObject);
+begin
+ Edit1.Text := uURL;
+ IMDownloader_Demo.DirPath := ExtractFilePath(Application.ExeName);
+end;
+
+procedure TMainForm.IMDownloader_DemoAccepted(Sender: TObject);
+begin
+ ProgressBar1.Visible := False;
+ TBStopDownload.Visible := false;
+ TBDownload.Visible := true;
+ TBView.Visible := true;
+ Edit1.ReadOnly := false;
+ StatusBar1.SimpleText :=
+ 'Скачивание успешно завершено. Всего получено данных в байтах: ' + IntToStr
+ (IMDownloader_Demo.AcceptedSize);
+ //RichEdit1.Lines.Append('MD5 файла в памяти: '+MD5DigestToStr(MD5Stream(IMDownloader_Demo.OutStream)));
+end;
+
+procedure TMainForm.IMDownloader_DemoBreak(Sender: TObject);
+begin
+ ProgressBar1.Visible := False;
+ TBStopDownload.Visible := false;
+ TBStopDownload.Enabled := true;
+ TBDownload.Visible := true;
+ TBView.Visible := IMDownloader_Demo.AcceptedSize > 0;
+ Edit1.ReadOnly := false;
+ StatusBar1.SimpleText :=
+ 'Скачивание остановлено. Всего получено данных в байтах: ' + IntToStr
+ (IMDownloader_Demo.AcceptedSize);
+end;
+
+procedure TMainForm.IMDownloader_DemoDownloading(Sender: TObject; AcceptedSize,
+ MaxSize: Cardinal);
+begin
+ StatusBar1.SimpleText := 'Получено байт: ' + IntToStr(AcceptedSize);
+ ProgressBar1.Visible := MaxSize > AcceptedSize;
+ ProgressBar1.Max := MaxSize;
+ ProgressBar1.Position := AcceptedSize;
+end;
+
+procedure TMainForm.IMDownloader_DemoError(Sender: TObject; E: TIMDownLoadError);
+var
+ s: string;
+begin
+ ProgressBar1.Visible := False;
+ TBStopDownload.Visible := false;
+ TBDownload.Visible := true;
+ TBView.Visible := IMDownloader_Demo.AcceptedSize > 0;
+ Edit1.ReadOnly := false;
+ case E of
+ deInternetOpen: s := 'Ошибка при открытии сессии. ';
+ deInternetOpenUrl: s := 'Ошибка при запрашивании файла. ';
+ deDownloadingFile: s := 'Ошибка при чтении файла. ';
+ deRequest: s := 'Ошибка при запросе данных через прокси-сервер. ';
+ end;
+ StatusBar1.SimpleText :=
+ s + 'Всего получено данных в байтах: ' + IntToStr
+ (IMDownloader_Demo.AcceptedSize);
+end;
+
+procedure TMainForm.IMDownloader_DemoHeaders(Sender: TObject; Headers: string);
+begin
+ RichEdit1.Lines.Text := Headers;
+end;
+
+procedure TMainForm.IMDownloader_DemoMD5Checked(Sender: TObject; MD5Correct,
+ SizeCorrect: Boolean; MD5Str: string);
+begin
+ if MD5Correct then
+ RichEdit1.Lines.Append('Контрольная сумма MD5 = '+MD5Str+' - ВЕРНА!')
+ else
+ RichEdit1.Lines.Append('Контрольная сумма MD5 = '+MD5Str+' - НЕ ВЕРНА!');
+ if SizeCorrect then
+ RichEdit1.Lines.Append('Размер файла = '+IntToStr(IMDownloader_Demo.AcceptedSize)+' - ВЕРНЫЙ!')
+ else
+ RichEdit1.Lines.Append('Размер файла = '+IntToStr(IMDownloader_Demo.AcceptedSize)+' - НЕ ВЕРНЫЙ!');
+end;
+
+procedure TMainForm.IMDownloader_DemoStartDownload(Sender: TObject);
+begin
+ TBDownload.Visible := false;
+ TBStopDownload.Visible := true;
+ TBView.Visible := false;
+ Edit1.ReadOnly := true;
+ StatusBar1.SimpleText := 'Инициализация скачивания...';
+end;
+
+procedure TMainForm.ViewAsTestClick(Sender: TObject);
+begin
+ RichEdit1.Lines.LoadFromStream(IMDownloader_Demo.OutStream);
+end;
+
+procedure TMainForm.SaveToFileClick(Sender: TObject);
+begin
+ if Edit1.Text = uURL then
+ SaveDialog1.FileName := 'HistoryToDBCreateDB.rar';
+ if SaveDialog1.Execute then
+ IMDownloader_Demo.OutStream.SaveToFile(SaveDialog1.FileName);
+end;
+
+procedure TMainForm.TBDownloadClick(Sender: TObject);
+begin
+ IMDownloader_Demo.URL := Edit1.Text;
+ //IMDownloader_Demo.Proxy := '192.168.42.240:1522';
+ IMDownloader_Demo.Proxy := '172.29.72.168:8080';
+ IMDownloader_Demo.Download;
+end;
+
+procedure TMainForm.TBStopDownloadClick(Sender: TObject);
+begin
+ StatusBar1.SimpleText := 'Останавливаем скачку';
+ TBStopDownload.Enabled := false;
+ IMDownloader_Demo.BreakDownload;
+end;
+
+procedure TMainForm.TBViewClick(Sender: TObject);
+begin
+ TBView.DropdownMenu.Popup(TBView.ClientOrigin.X,
+ TBView.ClientOrigin.Y + TBView.Height);
+end;
+
+end.