60 |
|
{ } |
61 |
|
{************************************************************************} |
62 |
|
unit FB25Events; |
63 |
+ |
{$IFDEF MSWINDOWS} |
64 |
+ |
{$DEFINE WINDOWS} |
65 |
+ |
{$ENDIF} |
66 |
|
|
67 |
|
{$IFDEF FPC} |
68 |
< |
{$mode objfpc}{$H+} |
68 |
> |
{$mode delphi} |
69 |
|
{$interfaces COM} |
70 |
|
{$ENDIF} |
71 |
|
|
73 |
|
|
74 |
|
uses |
75 |
|
{$IFDEF WINDOWS}Windows, {$ENDIF}Classes, SysUtils, IB, FB25ClientAPI, FB25Attachment, |
76 |
< |
IBExternals, IBHeader, syncobjs, FBEvents; |
76 |
> |
IBExternals, IBHeader, syncobjs, FBEvents |
77 |
> |
{$IF defined(FPC) and defined(UNIX)} ,cthreads {$IFEND}; |
78 |
|
|
79 |
|
type |
80 |
|
TFB25Events = class; |
94 |
|
public |
95 |
|
constructor Create(aOwner: TFB25Events); |
96 |
|
destructor Destroy; override; |
97 |
< |
procedure eventCallbackFunction(length: short; updated: PChar); |
97 |
> |
procedure eventCallbackFunction(length: short; updated: PAnsiChar); |
98 |
|
procedure WaitForEvent; |
99 |
|
procedure CancelWait; |
100 |
|
end; |
154 |
|
constructor TEventHandlerThread.Create(Owner: TFB25Events; |
155 |
|
EventHandler: TEventhandlerInterface); |
156 |
|
begin |
157 |
< |
inherited Create(true); |
157 |
> |
inherited Create(false); |
158 |
|
FOwner := Owner; |
159 |
|
FEventHandler := EventHandler; |
160 |
|
FreeOnTerminate := true; |
157 |
– |
Start; |
161 |
|
end; |
162 |
|
|
163 |
|
procedure TEventHandlerThread.Terminate; |
168 |
|
|
169 |
|
{This procedure is used for the event call back - note the cdecl } |
170 |
|
|
171 |
< |
procedure IBEventCallback( ptr: pointer; length: short; updated: PChar); cdecl; |
171 |
> |
procedure IBEventCallback( ptr: pointer; length: short; updated: PAnsiChar); cdecl; |
172 |
|
begin |
173 |
|
if (ptr = nil) or (length = 0) or (updated = nil) then |
174 |
|
Exit; |
217 |
|
end; |
218 |
|
|
219 |
|
procedure TEventhandlerInterface.eventCallbackFunction(length: short; |
220 |
< |
updated: PChar); |
220 |
> |
updated: PAnsiChar); |
221 |
|
begin |
222 |
|
FOwner.FCriticalSection.Enter; |
223 |
|
try |