Skip to content

Commit

Permalink
Create EETDefines.inc for simple compiation.
Browse files Browse the repository at this point in the history
  • Loading branch information
mirus77 committed Dec 20, 2018
1 parent 3d25646 commit 5597c1d
Show file tree
Hide file tree
Showing 18 changed files with 174 additions and 79 deletions.
Binary file modified demo/DX3/TestEET_DX3.res
Binary file not shown.
17 changes: 17 additions & 0 deletions demo/u_main.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ object TestEETForm: TTestEETForm
Font.Name = 'Courier New'
Font.Style = []
TabOrder = 0
CodeFolding.CollapsedLineColor = clGrayText
CodeFolding.FolderBarLinesColor = clGrayText
CodeFolding.ShowCollapsedLine = True
CodeFolding.IndentGuidesColor = clGray
CodeFolding.IndentGuides = True
UseCodeFolding = False
Gutter.AutoSize = True
Gutter.Font.Charset = DEFAULT_CHARSET
Gutter.Font.Color = clWindowText
Expand All @@ -75,6 +81,7 @@ object TestEETForm: TTestEETForm
Gutter.ShowLineNumbers = True
Highlighter = synxmlsyn2
ReadOnly = True
FontSmoothing = fsmNone
end
end
end
Expand All @@ -101,6 +108,12 @@ object TestEETForm: TTestEETForm
Font.Name = 'Courier New'
Font.Style = []
TabOrder = 0
CodeFolding.CollapsedLineColor = clGrayText
CodeFolding.FolderBarLinesColor = clGrayText
CodeFolding.ShowCollapsedLine = True
CodeFolding.IndentGuidesColor = clGray
CodeFolding.IndentGuides = True
UseCodeFolding = False
Gutter.AutoSize = True
Gutter.Font.Charset = DEFAULT_CHARSET
Gutter.Font.Color = clWindowText
Expand All @@ -110,6 +123,7 @@ object TestEETForm: TTestEETForm
Gutter.ShowLineNumbers = True
Highlighter = synxmlsyn2
ReadOnly = True
FontSmoothing = fsmNone
end
end
end
Expand Down Expand Up @@ -229,6 +243,9 @@ object TestEETForm: TTestEETForm
end
end
object synxmlsyn2: TSynXMLSyn
Options.AutoDetectEnabled = False
Options.AutoDetectLineLimit = 0
Options.Visible = False
WantBracesParsed = False
Left = 752
Top = 208
Expand Down
46 changes: 21 additions & 25 deletions demo/u_main.pas
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
{* ----------------------------------------------------------- *}
{* DelphiEET library at https://github.com/mirus77/DelphiEET *}
{* License info at file LICENSE *}
{* ----------------------------------------------------------- *}

unit u_main;

interface
{* Configure USE_*_CLIENT in EETDefines.inc *}
{$I EETDefines.inc}

{$IFNDEF UNICODE}
{$DEFINE LEGACY_RIO}
{$ENDIF}
// For Delphi XE3 and up:
{$IF CompilerVersion >= 24.0 }
{$LEGACYIFEND ON}
{$IFEND}

{.$DEFINE USE_INDY_CLIENT}
{$DEFINE USE_SYNAPSE_CLIENT}
{.$DEFINE USE_SBRIDGE_CLIENT}
{.$DEFINE USE_NETHTTP_CLIENT}
interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, Dialogs, StdCtrls, SynEdit, SynMemo, SynEditHighlighter,
SynHighlighterXML, XSBuiltIns, InvokeRegistry, ExtCtrls, ComCtrls,
SynHighlighterXML, ExtCtrls, ComCtrls,
u_EETSigner,
{$IFDEF USE_INDY_CLIENT} u_EETHttpClient_Indy, {$UNDEF USE_RIO_CLIENT}{$ENDIF}
{$IFDEF USE_NETHTTP_CLIENT} u_EETHttpClient_Net, {$UNDEF USE_RIO_CLIENT}{$ENDIF}
{$IFDEF USE_SBRIDGE_CLIENT} u_EETHttpClient_SB, {$UNDEF USE_RIO_CLIENT}{$ENDIF}
{$IFDEF USE_SYNAPSE_CLIENT} u_EETHttpClient_Synapse,{$UNDEF USE_RIO_CLIENT}{$ENDIF}
{$IFDEF USE_INDY_CLIENT} u_EETHttpClient_Indy, {$ENDIF}
{$IFDEF USE_NETHTTP_CLIENT} u_EETHttpClient_Net, {$ENDIF}
{$IFDEF USE_SBRIDGE_CLIENT} u_EETHttpClient_SB, {$ENDIF}
{$IFDEF USE_SYNAPSE_CLIENT} u_EETHttpClient_Synapse,{$ENDIF}
u_EETHttpClient;

type
Expand Down Expand Up @@ -201,7 +196,7 @@ procedure TTestEETForm.DoSendRevenue;
eTrzba.Data.id_provoz := 273;
eTrzba.Data.id_pokl := '/5546/RO24';
eTrzba.Data.porad_cis := '0/6460/ZQ42';
eTrzba.Data.dat_trzby := EET.EETDateTimeToXMLTime(now);
eTrzba.Data.dat_trzby := EET.DateTimeToXMLTime(now);
eTrzba.Data.celk_trzba := DoubleToCastkaType(34113);
eTrzba.Data.cerp_zuct := DoubleToCastkaType(679.00);
eTrzba.Data.cest_sluz := DoubleToCastkaType(5460.00);
Expand All @@ -218,21 +213,20 @@ procedure TTestEETForm.DoSendRevenue;
eTrzba.Data.zakl_nepodl_dph := DoubleToCastkaType(3036.00);


//EET.SignRevenue(eTrzba); // normalize date and PKP,BKP creating
//EET.SignRevenue(eTrzba); // PKP,BKP creating

// test for saving to XML amd load from XML
// loading don't work under Delphi 2007
// BEGIN - test for saving to XML and load from XML
ms.Clear;
EET.SaveToXML(eTrzba, ms);
ms.Position := 0;
ms.SaveToFile('eTrzba.xml');
eTrzba := nil;
// eTrzba := EET.NewRevenue;
eTrzba := nil; // Free before LoadFromXML
eTrzba := EET.LoadFromXML(ms);
ms.Clear;
EET.SaveToXML(eTrzba, ms);
ms.Position := 0;
ms.SaveToFile('eTrzbaLoaded.xml');
// END - test for saving to XML and load from XML

Odp := EET.SendRevenue(aClient, eTrzba, False, 0);

Expand All @@ -248,6 +242,7 @@ procedure TTestEETForm.DoSendRevenue;
synmRequest.Lines.LoadFromStream(EET.RequestStream);
synmResponse.Lines.LoadFromStream(EET.ResponseStream);

// backup request and response to file
EET.RequestStream.SaveToFile('request.xml');
EET.ResponseStream.SaveToFile('response.xml');

Expand Down Expand Up @@ -302,6 +297,7 @@ procedure TTestEETForm.DoSendRevenue;
ShowMessageFmt('Error : %d - %s', [EET.ErrorCode, EET.ErrorMessage]);
end;
synmResponse.Lines.Add('<!-- PKP : ' + eTrzba.KontrolniKody.pkp.Text + ' -->');
mmoLog.Lines.Add('ResponseCert : Subject ' + EET.Signer.ResponseCertInfo.Subject + ', Common Name : ' + EET.Signer.ResponseCertInfo.CommonName);
finally
Odp := nil;
eTrzba := nil;
Expand Down Expand Up @@ -338,7 +334,7 @@ procedure TTestEETForm.VerifyResponseCert(const ResponseCertInfo: TEETSignerCert
IsValidResponse := true;
if GetCurrentThreadID = MainThreadID then
begin
mmoLog.Lines.Add('ResponseCert : Subject ' + ResponseCertInfo.Subject + ', Common Name : ' + ResponseCertInfo.CommonName);
mmoLog.Lines.Add('OnVerifyResponseCert : Subject ' + ResponseCertInfo.Subject + ', Common Name : ' + ResponseCertInfo.CommonName);
end;
end;

Expand Down
53 changes: 53 additions & 0 deletions source/eet/EETDefines.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{* ----------------------------------------------------------- *}
{* DelphiEET library at https://github.com/mirus77/DelphiEET *}
{* License info at file LICENSE *}
{* ----------------------------------------------------------- *}

{* For Delphi XE3 and up: *}
{$IF CompilerVersion >= 24.0 }
{$LEGACYIFEND ON}
{$IFEND}

{*
USE_LIBEET - use wrapper libeetsigner.dll - static compiled into one library (libxml2, xmlsec, openssl)
compiled with Visual Studio 2013 U5 Express - VC12 (VS Runtime 2013) needed MSVCR120.dll
*}
{$DEFINE USE_LIBEET}

{*
USE_VS_LIBS - use libxml2 and xmlsec compiled with Visual Studio
solution for time_t compatibility
VS 2013 and lower using MSVCRxxx.dll
VS 2015 and higher VCRUNTIME140.dll (ucrtbase.dll)
without USE_VS_LIBS use MinGW library and libxmlsec at https://www.aleksey.com/xmlsec/download.html
*}
{$DEFINE USE_VS_LIBS}

{* ----------------------------------------------------------- *}
{* Select HTTP Post Client, choice only one !!! *}
{* ----------------------------------------------------------- *}
{* -- Indy Components version 10 *}
{.$DEFINE USE_INDY_CLIENT}
{* -- Synapse library *}
{$DEFINE USE_SYNAPSE_CLIENT}
{* -- SecureBridge Components *}
{.$DEFINE USE_SBRIDGE_CLIENT}
{* -- Delphi Net.HttpClient *}
{.$DEFINE USE_NETHTTP_CLIENT}

{* ----------------------------------------------------------- *}
{* EETSigner *}
{* ----------------------------------------------------------- *}
{* functions SHA1 is independent on libeay32.dll *}
{* when use synacode.pas unit, do uncomment this *}
{.$DEFINE USE_SYNACODE}


{* ----------------------------------------------------------- *}
{* Compatibility for non-Unicode Delphi *}
{* ----------------------------------------------------------- *}

{$IFNDEF UNICODE}
{$DEFINE LEGACY_RIO}
{$ENDIF}

16 changes: 8 additions & 8 deletions source/eet/u_EETSigner.pas
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
unit u_EETSigner;
{* ----------------------------------------------------------- *}
{* DelphiEET library at https://github.com/mirus77/DelphiEET *}
{* License info at file LICENSE *}
{* ----------------------------------------------------------- *}

interface
unit u_EETSigner;

{* functions SHA1 is independent on libeay32.dll when use synacode.pas unit, DEFINE USE_SYNACODE *}
{.$DEFINE USE_SYNACODE}
{$I EETDefines.inc}

{$IF CompilerVersion >= 24.0}
{$LEGACYIFEND ON}
{$IFEND}
interface

uses Classes,
{$IFDEF USE_LIBEET}
Expand Down Expand Up @@ -119,7 +119,7 @@ procedure EETSigner_EVP_MD_CTX_cleanup(ctx: pEVP_MD_CTX); cdecl;
implementation

uses
StrUtils, DateUtils, {$IF CompilerVersion >= 23.0 }AnsiStrings,{$IFEND}
StrUtils, DateUtils, {$IF RTLVersion >= 25 }AnsiStrings,{$IFEND}
{$IFNDEF USE_LIBEET}
libxmlsec_openssl,
{$IFDEF USE_SYNACODE}synacode,{$ENDIF}
Expand Down
5 changes: 5 additions & 0 deletions source/eet/u_EETSignerExceptions.pas
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{* ----------------------------------------------------------- *}
{* DelphiEET library at https://github.com/mirus77/DelphiEET *}
{* License info at file LICENSE *}
{* ----------------------------------------------------------- *}

unit u_EETSignerExceptions;

interface
Expand Down
30 changes: 14 additions & 16 deletions source/eet/u_EETTrzba.pas
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
{* ----------------------------------------------------------- *}
{* DelphiEET library at https://github.com/mirus77/DelphiEET *}
{* License info at file LICENSE *}
{* ----------------------------------------------------------- *}

unit u_EETTrzba;

interface
{$I EETDefines.inc}

{$IFNDEF UNICODE}
{$DEFINE LEGACY_RIO}
{$ENDIF}
// For Delphi XE3 and up:
{$IF CompilerVersion >= 24.0 }
{$LEGACYIFEND ON}
{$IFEND}
interface

uses
Windows, SysUtils, Classes, InvokeRegistry, Rio, SOAPHTTPClient, Types, XSBuiltIns,
SOAPHTTPTrans, WebNode, OPToSOAPDomConv, SOAPEnv, ActiveX, u_EETXMLSchema, XMLDoc,
XMLIntf, u_EETSigner, u_EETHttpClient;
Windows, SysUtils, Classes, InvokeRegistry, Rio, SOAPHTTPClient, Types,
SOAPEnv, ActiveX, u_EETXMLSchema, XMLDoc, XMLIntf, u_EETSigner, u_EETHttpClient;

type
TEETTrzba = class;
Expand Down Expand Up @@ -52,7 +50,7 @@ TEETTrzba = class(TComponent)
function LoadFromXML(const SourceStream: TStream) : IXMLTrzbaType;
procedure SignRequest(SOAPRequest: TStream);
procedure ValidateResponse(SOAPResponse: TStream);
function EETDateTimeToXMLTime(Value: TDateTime): string;
function DateTimeToXMLTime(Value: TDateTime): string;
published
property ValidResponse: boolean read FValidResponse;
property ValidResponseCert: boolean read FValidResponseCert;
Expand Down Expand Up @@ -93,7 +91,7 @@ destructor TEETTrzba.Destroy;
inherited;
end;

function TEETTrzba.EETDateTimeToXMLTime(Value: TDateTime): string;
function TEETTrzba.DateTimeToXMLTime(Value: TDateTime): string;

const
Neg: array [boolean] of string = ('+', '-');
Expand Down Expand Up @@ -309,7 +307,7 @@ function TEETTrzba.NewRevenue: IXMLTrzbaType;
result.Hlavicka.prvni_zaslani := True;
result.Hlavicka.overeni := false;

result.Hlavicka.dat_odesl := EETDateTimeToXMLTime(now);
result.Hlavicka.dat_odesl := DateTimeToXMLTime(now);

result.Data.Rezim := 0;

Expand Down Expand Up @@ -630,8 +628,8 @@ function TEETTrzba.SignRevenue(const parameters: IXMLTrzbaType): boolean;
exit;

// milisecond in output correction
// parameters.Hlavicka.dat_odesl.XSToNative(EETDateTimeToXMLTime(parameters.Hlavicka.dat_odesl.AsDateTime));
// parameters.Data.dat_trzby.XSToNative(EETDateTimeToXMLTime(parameters.Data.dat_trzby.AsDateTime));
// parameters.Hlavicka.dat_odesl.XSToNative(DateTimeToXMLTime(parameters.Hlavicka.dat_odesl.AsDateTime));
// parameters.Data.dat_trzby.XSToNative(DateTimeToXMLTime(parameters.Data.dat_trzby.AsDateTime));

parameters.KontrolniKody.pkp.Text := '';
parameters.KontrolniKody.bkp.Text := '';
Expand Down
15 changes: 11 additions & 4 deletions source/eet/u_libeet.pas
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
{* ----------------------------------------------------------- *}
{* DelphiEET library at https://github.com/mirus77/DelphiEET *}
{* License info at file LICENSE *}
{* ----------------------------------------------------------- *}

unit u_libeet;

interface

{$I EETDefines.inc}

{$ALIGN 8}
{$MINENUMSIZE 4}
{$M+}

{$IF CompilerVersion >= 24.0}
{$LEGACYIFEND ON}
{$IFEND}

uses Classes;

const
{$IFDEF MSWINDOWS}
LIBEET_SO : string = 'libeetsigner.dll';
{$ELSE}
LIBEET_SO : string = 'libeetsigner.so';
{$ENDIF}

type
TlibeetLogEvent = procedure(const file_: string; line: Longint; const func: string; const errorObject: string; const errorSubject: string; reason: Longint; const msg: string) of object;
Expand Down
5 changes: 5 additions & 0 deletions source/httpclient/u_EETHttpClient.pas
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{* ----------------------------------------------------------- *}
{* DelphiEET library at https://github.com/mirus77/DelphiEET *}
{* License info at file LICENSE *}
{* ----------------------------------------------------------- *}

unit u_EETHttpClient;

interface
Expand Down
10 changes: 7 additions & 3 deletions source/httpclient/u_EETHttpClient_Indy.pas
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{* ----------------------------------------------------------- *}
{* DelphiEET library at https://github.com/mirus77/DelphiEET *}
{* License info at file LICENSE *}
{* ----------------------------------------------------------- *}

unit u_EETHttpClient_Indy;

{$I EETDefines.inc}

interface
{$IFNDEF UNICODE}
{$DEFINE LEGACY_RIO}
{$ENDIF}

uses SysUtils, Classes, IdHttp, IdURI, IdSSLOpenSSL, u_EETHttpClient;

Expand Down
5 changes: 5 additions & 0 deletions source/httpclient/u_EETHttpClient_Net.pas
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{* ----------------------------------------------------------- *}
{* DelphiEET library at https://github.com/mirus77/DelphiEET *}
{* License info at file LICENSE *}
{* ----------------------------------------------------------- *}

unit u_EETHttpClient_Net;

interface
Expand Down
5 changes: 5 additions & 0 deletions source/httpclient/u_EETHttpClient_SB.pas
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{* ----------------------------------------------------------- *}
{* DelphiEET library at https://github.com/mirus77/DelphiEET *}
{* License info at file LICENSE *}
{* ----------------------------------------------------------- *}

{*
requirement : SecureBridge components at https://www.devart.com/sbridge/
*}
Expand Down
Loading

0 comments on commit 5597c1d

Please sign in to comment.