Skip to content

Commit

Permalink
Correct get Bias zone. Correct InvString conversion for NON UNICODE D…
Browse files Browse the repository at this point in the history
…elphi.
  • Loading branch information
mirus77 committed Jan 18, 2017
1 parent 0390d02 commit 9b9aa86
Show file tree
Hide file tree
Showing 4 changed files with 255 additions and 41 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# DelphiEET
Delphi component for registered sale data messages. http://www.etrzby.cz

- It may be compiled with Delphi 2007 and Delphi 10.2 Berlin
- It may be compiled with Delphi 2007 (only WinInet) and Delphi 10.2 Berlin (Indy and WinInet)


## Use with USE_LIBEET
Expand Down
12 changes: 5 additions & 7 deletions demo/u_main.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,13 @@ object TestEETForm: TTestEETForm
Gutter.ShowLineNumbers = True
Highlighter = synxmlsyn2
ReadOnly = True
FontSmoothing = fsmNone
end
end
end
object tsResponse: TTabSheet
Caption = 'Odpov'#283#271
ImageIndex = 1
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
object grpResponse: TGroupBox
Left = 0
Top = 0
Expand Down Expand Up @@ -115,6 +112,7 @@ object TestEETForm: TTestEETForm
Gutter.ShowLineNumbers = True
Highlighter = synxmlsyn2
ReadOnly = True
FontSmoothing = fsmNone
end
end
end
Expand Down Expand Up @@ -164,7 +162,6 @@ object TestEETForm: TTestEETForm
Align = alLeft
Caption = 'lblKeyValidFrom'
Layout = tlCenter
ExplicitHeight = 13
end
object lblKeyValidTo: TLabel
Left = 94
Expand All @@ -174,7 +171,6 @@ object TestEETForm: TTestEETForm
Align = alLeft
Caption = 'lblKeyValidTo'
Layout = tlCenter
ExplicitHeight = 13
end
object lblSpace1: TLabel
Left = 80
Expand Down Expand Up @@ -203,10 +199,12 @@ object TestEETForm: TTestEETForm
Align = alLeft
Caption = 'lblKeySubject'
Layout = tlCenter
ExplicitHeight = 13
end
end
object synxmlsyn2: TSynXMLSyn
Options.AutoDetectEnabled = False
Options.AutoDetectLineLimit = 0
Options.Visible = False
WantBracesParsed = False
Left = 752
Top = 208
Expand Down
32 changes: 24 additions & 8 deletions demo/u_main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ TTestEETForm = class(TForm)
{$ENDIF}
procedure AfterSendExecute(const MethodName: string; SOAPResponse: TStream);
{$IF Defined(USE_INDY) OR Defined(USE_DIRECTINDY)}
function VerifyPeer(Certificate: TIdX509; AOk: Boolean; ADepth, AError: Integer) : boolean;
function VerifyPeer(Certificate: TIdX509; AOk: Boolean{$IFNDEF LEGACY_RIO}; ADepth, AError: Integer{$ENDIF}) : boolean;
{$IFEND}
public
procedure DoOdeslatTrzba;
Expand Down Expand Up @@ -83,22 +83,28 @@ function FormatXML(XMLString : string): string;
procedure TTestEETForm.AfterSendExecute(const MethodName: string; SOAPResponse: TStream);
begin
(SOAPResponse as TMemoryStream).SaveToFile('response.xml');
synmResponse.Lines.LoadFromStream(SOAPResponse as TMemoryStream);
synmResponse.Lines.Text := synmResponse.Lines.Text;
end;

{$IFDEF LEGACY_RIO}
procedure TTestEETForm.BeforeSendExecute(const MethodName: string; var SOAPRequest: InvString);
var
MemStream : TMemoryStream;
S : string;
begin
synmRequest.Lines.Text := SOAPRequest;
synmRequest.Lines.SaveToFile('request.xml');
MemStream := TMemoryStream.Create;
try
MemStream.Position := 0;
MemStream.Write(S[1], Length(S));
MemStream.SaveToFile('request.xml');
finally
MemStream.Free;
end;
end;
{$ELSE}
procedure TTestEETForm.BeforeSendExecute(const MethodName: string; SOAPRequest: TStream);
begin
(SOAPRequest as TMemoryStream).SaveToFile('request.xml');
SOAPRequest.Seek(0, soFromBeginning);
synmRequest.Lines.LoadFromStream(SOAPRequest as TMemoryStream);
end;
{$ENDIF}

Expand Down Expand Up @@ -187,6 +193,8 @@ procedure TTestEETForm.DoOdeslatTrzba;
// EET.HttpsTrustName := 'www.eet.cz'; // for HTTPS validation default : 'www.eet.cz'
EET.PFXPassword := 'eet';
EET.ConnectTimeout := 2000;
// EET.UseProxy := true;
// EET.ProxyHost := 'proxy';
EET.Initialize;

lblKeySubject.Caption := 'Pøedmìt :' + EET.Signer.PrivKeyInfo.Subject;
Expand Down Expand Up @@ -234,8 +242,14 @@ procedure TTestEETForm.DoOdeslatTrzba;
{$ELSE}
{$MESSAGE HINT 'USE WinInet default SOAP WebRequest'}
{$IFEND}
Odp := EET.OdeslaniTrzby(eTrzba);
Odp := EET.OdeslaniTrzby(eTrzba, false, 5000);
{$IFEND}

EET.RequestStream.Position := 0;
EET.ResponseStream.Position := 0;
synmRequest.Lines.LoadFromStream(EET.RequestStream);
synmResponse.Lines.LoadFromStream(EET.ResponseStream);

if (EET.ErrorCode = 0) and (Odp <> nil) then
begin
if Odp.Potvrzeni <> nil then
Expand Down Expand Up @@ -313,13 +327,15 @@ procedure TTestEETForm.FormShow(Sender: TObject);
end;

{$IF Defined(USE_INDY) OR Defined(USE_DIRECTINDY)}
function TTestEETForm.VerifyPeer(Certificate: TIdX509; AOk: Boolean; ADepth, AError: Integer): boolean;
function TTestEETForm.VerifyPeer(Certificate: TIdX509; AOk: Boolean{$IFNDEF LEGACY_RIO}; ADepth, AError: Integer{$ENDIF}): boolean;
begin
Result := AOk;
{$IFNDEF LEGACY_RIO}
if ADepth = 0 then
begin
synmRequest.Lines.Add('<!-- https : Subject ' + Certificate.Subject.OneLine + ' -->');
end;
{$ENDIF}
end;
{$IFEND}

Expand Down
Loading

0 comments on commit 9b9aa86

Please sign in to comment.