You've already forked lazarus-ccr
LazMapViewer: Add proxy support to WinINet download engine. Adapt both "fulldemo" samples.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9031 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -6,7 +6,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Types, Forms, Controls, Graphics, Dialogs,
|
||||
ExtCtrls, StdCtrls, ComCtrls, Buttons, IntfGraphics, ColorBox,
|
||||
ExtCtrls, StdCtrls, ComCtrls, Buttons, IntfGraphics, ColorBox, Spin,
|
||||
mvGeoNames, mvMapViewer, mvTypes, mvGpsObj, mvDrawingEngine,
|
||||
mvDE_RGBGraphics, mvDE_BGRA, mvDLEFPC, mvDLEWin, mvDLESynapse;
|
||||
|
||||
@ -27,6 +27,8 @@ type
|
||||
CbFoundLocations: TComboBox;
|
||||
CbLocations: TComboBox;
|
||||
CbProviders: TComboBox;
|
||||
rbProxyData: TRadioButton;
|
||||
rbSystemProxy: TRadioButton;
|
||||
CbUseThreads: TCheckBox;
|
||||
CbMouseCoords: TGroupBox;
|
||||
CbDistanceUnits: TComboBox;
|
||||
@ -38,8 +40,12 @@ type
|
||||
CbCyclic: TCheckBox;
|
||||
CbPreviewTiles: TCheckBox;
|
||||
clbBackColor: TColorButton;
|
||||
edProxyHost: TEdit;
|
||||
edProxyPassword: TEdit;
|
||||
edProxyUserName: TEdit;
|
||||
FontDialog: TFontDialog;
|
||||
GbCenterCoords: TGroupBox;
|
||||
gbProxy: TGroupBox;
|
||||
GbScreenSize: TGroupBox;
|
||||
GbSearch: TGroupBox;
|
||||
GbGPS: TGroupBox;
|
||||
@ -52,6 +58,10 @@ type
|
||||
Label1: TLabel;
|
||||
Label2: TLabel;
|
||||
LblPOITextBgColor: TLabel;
|
||||
lblProxyHost: TLabel;
|
||||
lblProxyPassword: TLabel;
|
||||
lblProxyPort: TLabel;
|
||||
lblProxyUserName: TLabel;
|
||||
LblSelectLocation: TLabel;
|
||||
LblCenterLatitude: TLabel;
|
||||
LblViewportHeight: TLabel;
|
||||
@ -71,6 +81,8 @@ type
|
||||
PageControl: TPageControl;
|
||||
PgData: TTabSheet;
|
||||
PgConfig: TTabSheet;
|
||||
rbNoProxy: TRadioButton;
|
||||
seProxyPort: TSpinEdit;
|
||||
ZoomTrackBar: TTrackBar;
|
||||
procedure BtnGoToClick(Sender: TObject);
|
||||
procedure BtnLoadGPXFileClick(Sender: TObject);
|
||||
@ -108,6 +120,7 @@ type
|
||||
procedure MapViewZoomChange(Sender: TObject);
|
||||
procedure BtnLoadMapProvidersClick(Sender: TObject);
|
||||
procedure BtnSaveMapProvidersClick(Sender: TObject);
|
||||
procedure rbProxyChange(Sender: TObject);
|
||||
procedure ZoomTrackBarChange(Sender: TObject);
|
||||
|
||||
private
|
||||
@ -121,6 +134,7 @@ type
|
||||
POIImage: TCustomBitmap;
|
||||
procedure ClearFoundLocations;
|
||||
procedure UpdateCoords(X, Y: Integer);
|
||||
procedure UpdateDownloadEngineProxy;
|
||||
procedure UpdateDropdownWidth(ACombobox: TCombobox);
|
||||
procedure UpdateLocationHistory(ALocation: String);
|
||||
procedure UpdateViewportSize;
|
||||
@ -187,6 +201,11 @@ begin
|
||||
MapView.Engine.WriteProvidersToXML(Application.Location + MAP_PROVIDER_FILENAME);
|
||||
end;
|
||||
|
||||
procedure TMainForm.rbProxyChange(Sender: TObject);
|
||||
begin
|
||||
UpdateDownloadEngineProxy;
|
||||
end;
|
||||
|
||||
procedure TMainForm.BtnSearchClick(Sender: TObject);
|
||||
begin
|
||||
ClearFoundLocations;
|
||||
@ -291,6 +310,7 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
UpdateDownloadEngineProxy;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CbDrawingEngineChange(Sender: TObject);
|
||||
@ -659,6 +679,19 @@ begin
|
||||
List.Free;
|
||||
end;
|
||||
|
||||
i := ini.ReadInteger('Proxy', 'UseProxy', 0);
|
||||
case i of
|
||||
0: rbNoProxy.Checked := true;
|
||||
1: rbSystemProxy.Checked := true;
|
||||
2: rbProxyData.Checked := true;
|
||||
end;
|
||||
edProxyHost.Text := ini.ReadString('Proxy', 'ProxyHost', edProxyHost.Text);
|
||||
seProxyPort.Value := ini.ReadInteger('Proxy', 'ProxyPort', seProxyPort.Value);
|
||||
edProxyUserName.Text := ini.ReadString('Proxy', 'ProxyName', edProxyUserName.Text);
|
||||
edProxyPassword.Text := ini.ReadString('Proxy', 'ProxyPassword', edProxyPassword.Text);
|
||||
|
||||
UpdateDownloadEngineProxy;
|
||||
|
||||
finally
|
||||
ini.Free;
|
||||
end;
|
||||
@ -682,6 +715,26 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.UpdateDownloadEngineProxy;
|
||||
begin
|
||||
if MapView.DownloadEngine.HasProxySupport then
|
||||
begin
|
||||
MapView.DownloadEngine.SetProxy(
|
||||
rbSystemProxy.Checked, rbProxyData.Checked,
|
||||
edProxyHost.Name, seProxyPort.Value, edProxyUserName.Text, edProxyPassword.Text
|
||||
);
|
||||
rbSystemProxy.Enabled := MapView.DownloadEngine.SupportsSystemProxy;
|
||||
lblProxyHost.Enabled := rbProxyData.Checked;
|
||||
edProxyHost.Enabled := rbProxyData.Checked;
|
||||
lblProxyPort.Enabled := rbProxyData.Checked;
|
||||
seProxyPort.Enabled := rbProxyData.Checked;
|
||||
lblProxyUserName.Enabled := rbProxyData.Checked;
|
||||
edProxyUserName.Enabled := rbProxyData.Checked;
|
||||
lblProxyPassword.Enabled := rbProxyData.Checked;
|
||||
edProxyPassword.Enabled := rbProxyData.Checked;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.UpdateDropdownWidth(ACombobox: TCombobox);
|
||||
var
|
||||
cnv: TControlCanvas;
|
||||
@ -782,6 +835,16 @@ begin
|
||||
for i := 0 to CbLocations.Items.Count-1 do
|
||||
ini.WriteString('Locations', 'Item'+IntToStr(i), CbLocations.Items[i]);
|
||||
|
||||
ini.EraseSection('Proxy');
|
||||
if rbSystemProxy.Checked then i := 1
|
||||
else if rbProxyData.Checked then i := 2
|
||||
else i := 0;
|
||||
ini.WriteInteger('Proxy', 'UseProxy', i);
|
||||
ini.WriteString('Proxy', 'ProxyHost', edProxyHost.Text);
|
||||
ini.WriteInteger('Proxy', 'ProxyPort', seProxyPort.Value);
|
||||
ini.WriteString('Proxy', 'ProxyName', edProxyUserName.Text);
|
||||
ini.WriteString('Proxy', 'ProxyPassword', edProxyPassword.Text);
|
||||
|
||||
finally
|
||||
ini.Free;
|
||||
end;
|
||||
|
Reference in New Issue
Block a user