mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-11 15:49:32 +02:00
* Adapted patch from Laco to use new login prompt callback
git-svn-id: trunk@30431 -
This commit is contained in:
parent
94aadb23ab
commit
c4617ee2ad
@ -505,7 +505,25 @@ begin
|
||||
FBeforeConnect:=AValue;
|
||||
end;
|
||||
|
||||
procedure TCustomConnection.DoLoginPrompt;
|
||||
|
||||
var
|
||||
ADatabaseName, AUserName, APassword: string;
|
||||
|
||||
begin
|
||||
if FLoginPrompt then
|
||||
begin
|
||||
GetLoginParams(ADatabaseName, AUserName, APassword);
|
||||
if Assigned(FOnLogin) then
|
||||
FOnLogin(Self, AUserName, APassword)
|
||||
else if Assigned(LoginDialogExProc) then
|
||||
LoginDialogExProc(ADatabaseName, AUserName, APassword, False);
|
||||
SetLoginParams(ADatabaseName, AUserName, APassword);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomConnection.SetConnected(Value: boolean);
|
||||
|
||||
begin
|
||||
If Value<>Connected then
|
||||
begin
|
||||
@ -520,8 +538,7 @@ begin
|
||||
begin
|
||||
if Assigned(BeforeConnect) then
|
||||
BeforeConnect(self);
|
||||
if FLoginPrompt then if assigned(FOnLogin) then
|
||||
FOnLogin(self,'','');
|
||||
DoLoginPrompt;
|
||||
DoConnect;
|
||||
if Assigned(AfterConnect) then
|
||||
AfterConnect(self);
|
||||
@ -543,6 +560,26 @@ begin
|
||||
FBeforeDisconnect:=AValue;
|
||||
end;
|
||||
|
||||
procedure TCustomConnection.GetLoginParams(out ADatabaseName, AUserName, APassword: string);
|
||||
begin
|
||||
if IsPublishedProp(Self,'DatabaseName') then
|
||||
ADatabaseName := GetStrProp(Self,'DatabaseName');
|
||||
if IsPublishedProp(Self,'UserName') then
|
||||
AUserName := GetStrProp(Self,'UserName');
|
||||
if IsPublishedProp(Self,'Password') then
|
||||
APassword := 'Password';
|
||||
end;
|
||||
|
||||
procedure TCustomConnection.SetLoginParams(const ADatabaseName, AUserName, APassword: string);
|
||||
begin
|
||||
if IsPublishedProp(Self,'DatabaseName') then
|
||||
SetStrProp(Self,'DatabaseName',ADatabaseName);
|
||||
if IsPublishedProp(Self,'UserName') then
|
||||
SetStrProp(Self,'UserName',AUserName);
|
||||
if IsPublishedProp(Self,'Password') then
|
||||
SetStrProp(Self,'Password',APassword);
|
||||
end;
|
||||
|
||||
procedure TCustomConnection.DoConnect;
|
||||
|
||||
begin
|
||||
|
@ -1953,14 +1953,17 @@ type
|
||||
procedure SetBeforeConnect(const AValue: TNotifyEvent);
|
||||
procedure SetBeforeDisconnect(const AValue: TNotifyEvent);
|
||||
protected
|
||||
procedure DoLoginPrompt; virtual;
|
||||
procedure DoConnect; virtual;
|
||||
procedure DoDisconnect; virtual;
|
||||
function GetConnected : boolean; virtual;
|
||||
Function GetDataset(Index : longint) : TDataset; virtual;
|
||||
Function GetDataSetCount : Longint; virtual;
|
||||
procedure GetLoginParams(out ADatabaseName, AUserName, APassword: string); virtual;
|
||||
procedure InternalHandleException; virtual;
|
||||
procedure Loaded; override;
|
||||
procedure SetConnected (Value : boolean); virtual;
|
||||
procedure SetLoginParams(const ADatabaseName, AUserName, APassword: string); virtual;
|
||||
property ForcedClose : Boolean read FForcedClose write FForcedClose;
|
||||
property StreamedConnected: Boolean read FStreamedConnected write FStreamedConnected;
|
||||
public
|
||||
|
Loading…
Reference in New Issue
Block a user