60 |
|
{ } |
61 |
|
{************************************************************************} |
62 |
|
unit FBEvents; |
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 |
|
|
84 |
|
FAttachment: IAttachment; |
85 |
|
FEventCounts: TEventCounts; |
86 |
|
protected |
87 |
< |
FEventBuffer: PChar; |
87 |
> |
FEventBuffer: PByte; |
88 |
|
FEventBufferLen: integer; |
89 |
< |
FResultBuffer: PChar; |
89 |
> |
FResultBuffer: PByte; |
90 |
|
FEventHandler: TEventHandler; |
91 |
|
FCriticalSection: TCriticalSection; |
92 |
|
FInWaitState: boolean; |
102 |
|
{IEvents} |
103 |
|
procedure GetEvents(EventNames: TStrings); |
104 |
|
procedure SetEvents(EventNames: TStrings); overload; |
105 |
< |
procedure SetEvents(Event: string); overload; |
105 |
> |
procedure SetEvents(Event: AnsiString); overload; |
106 |
|
procedure Cancel; |
107 |
|
function ExtractEventCounts: TEventCounts; |
108 |
|
function GetAttachment: IAttachment; |
122 |
|
procedure TFBEvents.CreateEventBlock; |
123 |
|
var |
124 |
|
i: integer; |
125 |
< |
EventNames: array of PChar; |
125 |
> |
EventNames: array of PAnsiChar; |
126 |
> |
EventName: AnsiString; |
127 |
|
begin |
128 |
|
with FirebirdClientAPI do |
129 |
|
begin |
137 |
|
setlength(EventNames,MaxEvents); |
138 |
|
try |
139 |
|
for i := 0 to FEvents.Count-1 do |
140 |
< |
EventNames[i] := PChar(FEvents[i]); |
140 |
> |
begin |
141 |
> |
EventName := FEvents[i]; |
142 |
> |
EventNames[i] := PAnsiChar(EventName); |
143 |
> |
end; |
144 |
|
|
145 |
|
FEventBufferlen := isc_event_block(@FEventBuffer,@FResultBuffer, |
146 |
|
FEvents.Count, |
196 |
|
with FirebirdClientAPI do |
197 |
|
isc_event_counts( @EventCountList, FEventBufferLen, FEventBuffer, FResultBuffer); |
198 |
|
j := 0; |
199 |
< |
P := EventCountList; |
199 |
> |
P := @EventCountList; |
200 |
|
for i := 0 to FEvents.Count - 1 do |
201 |
|
begin |
202 |
|
if EventCountList[i] <> 0 then |
246 |
|
|
247 |
|
procedure TFBEvents.SetEvents(EventNames: TStrings); |
248 |
|
begin |
249 |
+ |
if (EventNames.Count > 0) and not IsMultiThread then |
250 |
+ |
IBError(ibxMultiThreadRequired,['Firebird Events Handling']); |
251 |
|
if EventNames.Text <> FEvents.Text then |
252 |
|
begin |
253 |
|
Cancel; |
256 |
|
end; |
257 |
|
end; |
258 |
|
|
259 |
< |
procedure TFBEvents.SetEvents(Event: string); |
259 |
> |
procedure TFBEvents.SetEvents(Event: AnsiString); |
260 |
|
var S: TStringList; |
261 |
|
begin |
262 |
|
S := TStringList.Create; |