Update of /cvsroot/instantobjects/Source/Brokers/UIB In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12718/Brokers/UIB Modified Files: InstantUIB.pas InstantUIBConnectionDefEdit.dfm InstantUIBConnectionDefEdit.pas InstantUIBReg.pas Removed Files: InstantUIBConnection.pas Log Message: Refactored UIB broker so that it uses an external JvUIBDataBase component and does not parse connection strings anymore Index: InstantUIBConnectionDefEdit.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Brokers/UIB/InstantUIBConnectionDefEdit.pas,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** InstantUIBConnectionDefEdit.pas 4 Sep 2005 23:15:53 -0000 1.3 --- InstantUIBConnectionDefEdit.pas 21 Oct 2005 09:15:08 -0000 1.4 *************** *** 43,55 **** TInstantUIBConnectionDefEditForm = class(TForm) ClientPanel: TPanel; ! ServerLabel: TLabel; ! ProtocolLabel: TLabel; ! DatabaseLabel: TLabel; ! LocalRadioButton: TRadioButton; ! RemoteRadioButton: TRadioButton; ! ServerEdit: TEdit; ! ProtocolEdit: TComboBox; ! DatabaseEdit: TEdit; ! DatabaseButton: TButton; BottomPanel: TPanel; OkButton: TButton; --- 43,49 ---- TInstantUIBConnectionDefEditForm = class(TForm) ClientPanel: TPanel; ! ConnectionStringLabel: TLabel; ! ConnectionStringEdit: TEdit; ! ConnectionStringButton: TButton; BottomPanel: TPanel; OkButton: TButton; *************** *** 59,63 **** StreamFormatComboBox: TComboBox; UseDelimitedIdentsCheckBox: TCheckBox; - LoginPromptCheckBox: TCheckBox; ParamsLabel: TLabel; ParamsEditor: TMemo; --- 53,56 ---- *************** *** 66,71 **** IdSizeEdit: TEdit; Label2: TLabel; ! procedure LocalRemoteChange(Sender: TObject); ! procedure DatabaseButtonClick(Sender: TObject); procedure FormCreate(Sender: TObject); private --- 59,64 ---- IdSizeEdit: TEdit; Label2: TLabel; ! LoginPromptCheckBox: TCheckBox; ! procedure ConnectionStringButtonClick(Sender: TObject); procedure FormCreate(Sender: TObject); private *************** *** 87,91 **** { TInstantUIBConnectionDefEditForm } ! procedure TInstantUIBConnectionDefEditForm.DatabaseButtonClick( Sender: TObject); begin --- 80,84 ---- { TInstantUIBConnectionDefEditForm } ! procedure TInstantUIBConnectionDefEditForm.ConnectionStringButtonClick( Sender: TObject); begin *************** *** 93,101 **** try Filter := ! 'FireBird Database (*.fdb)|*.fdb|' + 'InterBase Database (*.gdb)|*.gdb|' + 'All Files (*.*)|*.*'; if Execute then ! DatabaseEdit.Text := FileName; finally Free; --- 86,94 ---- try Filter := ! 'Firebird Database (*.fdb)|*.fdb|' + 'InterBase Database (*.gdb)|*.gdb|' + 'All Files (*.*)|*.*'; if Execute then ! ConnectionStringEdit.Text := FileName; finally Free; *************** *** 114,120 **** function TInstantUIBConnectionDefEditForm.GetIsValid: Boolean; begin ! Result := ! (LocalRadioButton.Checked or (ServerEdit.Text <> '')) and ! (DatabaseEdit.Text <> ''); end; --- 107,111 ---- function TInstantUIBConnectionDefEditForm.GetIsValid: Boolean; begin ! Result := ConnectionStringEdit.Text <> ''; end; *************** *** 124,130 **** with ConnectionDef do begin ! ProtocolEdit.ItemIndex := Ord(NetType) - 1; ! ServerEdit.Text := ServerName; ! DatabaseEdit.Text := Path; StreamFormatComboBox.ItemIndex := Ord(BlobStreamFormat); UseDelimitedIdentsCheckBox.Checked := UIBUseDelimitedIdents in Options; --- 115,119 ---- with ConnectionDef do begin ! ConnectionStringEdit.Text := ConnectionString; StreamFormatComboBox.ItemIndex := Ord(BlobStreamFormat); UseDelimitedIdentsCheckBox.Checked := UIBUseDelimitedIdents in Options; *************** *** 137,146 **** end; - procedure TInstantUIBConnectionDefEditForm.LocalRemoteChange( - Sender: TObject); - begin - UpdateControls; - end; - procedure TInstantUIBConnectionDefEditForm.SaveData( ConnectionDef: TInstantUIBConnectionDef); --- 126,129 ---- *************** *** 148,157 **** with ConnectionDef do begin ! if LocalRadioButton.Checked then ! NetType := ntLocal ! else ! NetType := TUIBNetType(ProtocolEdit.ItemIndex + 1); ! ServerName := ServerEdit.Text; ! Path := DatabaseEdit.Text; BlobStreamFormat := TInstantStreamFormat(StreamFormatComboBox.ItemIndex); Options := []; --- 131,135 ---- with ConnectionDef do begin ! ConnectionString := ConnectionStringEdit.Text; BlobStreamFormat := TInstantStreamFormat(StreamFormatComboBox.ItemIndex); Options := []; *************** *** 166,185 **** procedure TInstantUIBConnectionDefEditForm.UpdateControls; - const - Colors: array[Boolean] of TColor = (clBtnFace, clWindow); - var - UseRemote: Boolean; begin - UseRemote := RemoteRadioButton.Checked; - ServerLabel.Enabled := UseRemote; - ServerEdit.Enabled := UseRemote; - ServerEdit.Color := Colors[UseRemote]; - ProtocolLabel.Enabled := UseRemote; - ProtocolEdit.Enabled := UseRemote; - ProtocolEdit.Color := Colors[UseRemote]; - DatabaseButton.Enabled := not UseRemote; - with ProtocolEdit do - if ItemIndex = -1 then - ItemIndex := 0; end; --- 144,148 ---- Index: InstantUIBConnectionDefEdit.dfm =================================================================== RCS file: /cvsroot/instantobjects/Source/Brokers/UIB/InstantUIBConnectionDefEdit.dfm,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** InstantUIBConnectionDefEdit.dfm 24 Jul 2005 16:34:51 -0000 1.4 --- InstantUIBConnectionDefEdit.dfm 21 Oct 2005 09:15:08 -0000 1.5 *************** *** 4,8 **** BorderStyle = bsDialog Caption = 'UIB Connection' ! ClientHeight = 399 ClientWidth = 362 Color = clBtnFace --- 4,8 ---- BorderStyle = bsDialog Caption = 'UIB Connection' ! ClientHeight = 329 ClientWidth = 362 Color = clBtnFace *************** *** 19,23 **** object BottomBevel: TBevel Left = 0 ! Top = 362 Width = 362 Height = 2 --- 19,23 ---- object BottomBevel: TBevel Left = 0 ! Top = 292 Width = 362 Height = 2 *************** *** 29,63 **** Top = 0 Width = 362 ! Height = 362 Align = alClient BevelOuter = bvNone TabOrder = 0 ! object ServerLabel: TLabel ! Left = 16 ! Top = 36 ! Width = 31 ! Height = 13 ! Caption = '&Server' ! FocusControl = ServerEdit ! end ! object ProtocolLabel: TLabel ! Left = 235 ! Top = 36 ! Width = 39 ! Height = 13 ! Caption = '&Protocol' ! FocusControl = ProtocolEdit ! end ! object DatabaseLabel: TLabel Left = 16 ! Top = 76 ! Width = 46 Height = 13 ! Caption = '&Database' ! FocusControl = DatabaseEdit end object StreamFormatLabel: TLabel Left = 16 ! Top = 312 Width = 53 Height = 13 --- 29,47 ---- Top = 0 Width = 362 ! Height = 292 Align = alClient BevelOuter = bvNone TabOrder = 0 ! object ConnectionStringLabel: TLabel Left = 16 ! Top = 12 ! Width = 84 Height = 13 ! Caption = '&Connection String' ! FocusControl = ConnectionStringEdit end object StreamFormatLabel: TLabel Left = 16 ! Top = 248 Width = 53 Height = 13 *************** *** 67,71 **** object ParamsLabel: TLabel Left = 16 ! Top = 140 Width = 95 Height = 13 --- 51,55 ---- object ParamsLabel: TLabel Left = 16 ! Top = 76 Width = 95 Height = 13 *************** *** 75,79 **** object Label1: TLabel Left = 136 ! Top = 312 Width = 62 Height = 13 --- 59,63 ---- object Label1: TLabel Left = 136 ! Top = 248 Width = 62 Height = 13 *************** *** 83,87 **** object Label2: TLabel Left = 256 ! Top = 312 Width = 32 Height = 13 --- 67,71 ---- object Label2: TLabel Left = 256 ! Top = 248 Width = 32 Height = 13 *************** *** 89,151 **** FocusControl = IdDataTypeComboBox end ! object LocalRadioButton: TRadioButton ! Left = 16 ! Top = 16 ! Width = 57 ! Height = 17 ! Caption = '&Local' ! Checked = True ! TabOrder = 0 ! TabStop = True ! OnClick = LocalRemoteChange ! end ! object RemoteRadioButton: TRadioButton ! Left = 86 ! Top = 16 ! Width = 65 ! Height = 17 ! Caption = '&Remote' ! TabOrder = 1 ! OnClick = LocalRemoteChange ! end ! object ServerEdit: TEdit ! Left = 16 ! Top = 52 ! Width = 209 ! Height = 21 ! TabOrder = 2 ! end ! object ProtocolEdit: TComboBox ! Left = 235 ! Top = 52 ! Width = 110 ! Height = 21 ! Style = csDropDownList ! ItemHeight = 13 ! TabOrder = 3 ! Items.Strings = ( ! 'TCP/IP' ! 'NetBEUI' ! 'SPX') ! end ! object DatabaseEdit: TEdit Left = 16 ! Top = 92 Width = 305 Height = 21 ! TabOrder = 4 end ! object DatabaseButton: TButton Left = 321 ! Top = 92 Width = 21 Height = 21 Caption = '...' ! TabOrder = 5 ! OnClick = DatabaseButtonClick end object StreamFormatComboBox: TComboBox Left = 16 ! Top = 328 Width = 113 Height = 21 --- 73,95 ---- FocusControl = IdDataTypeComboBox end ! object ConnectionStringEdit: TEdit Left = 16 ! Top = 28 Width = 305 Height = 21 ! TabOrder = 0 end ! object ConnectionStringButton: TButton Left = 321 ! Top = 28 Width = 21 Height = 21 Caption = '...' ! TabOrder = 1 ! OnClick = ConnectionStringButtonClick end object StreamFormatComboBox: TComboBox Left = 16 ! Top = 264 Width = 113 Height = 21 *************** *** 153,201 **** ItemHeight = 13 Sorted = True ! TabOrder = 9 end object UseDelimitedIdentsCheckBox: TCheckBox Left = 16 ! Top = 118 Width = 150 Height = 17 Caption = '&Use delimited identifiers' ! TabOrder = 6 ! end ! object LoginPromptCheckBox: TCheckBox ! Left = 196 ! Top = 118 ! Width = 150 ! Height = 17 ! Caption = '&Login Prompt' ! TabOrder = 7 end object ParamsEditor: TMemo Left = 17 ! Top = 160 Width = 328 Height = 149 ! TabOrder = 8 end object IdDataTypeComboBox: TComboBox Left = 136 ! Top = 328 Width = 113 Height = 21 Style = csDropDownList ItemHeight = 13 ! TabOrder = 10 end object IdSizeEdit: TEdit Left = 256 ! Top = 328 Width = 89 Height = 21 ! TabOrder = 11 end end object BottomPanel: TPanel Left = 0 ! Top = 364 Width = 362 Height = 35 --- 97,145 ---- ItemHeight = 13 Sorted = True ! TabOrder = 5 end object UseDelimitedIdentsCheckBox: TCheckBox Left = 16 ! Top = 54 Width = 150 Height = 17 Caption = '&Use delimited identifiers' ! TabOrder = 2 end object ParamsEditor: TMemo Left = 17 ! Top = 96 Width = 328 Height = 149 ! TabOrder = 4 end object IdDataTypeComboBox: TComboBox Left = 136 ! Top = 264 Width = 113 Height = 21 Style = csDropDownList ItemHeight = 13 ! TabOrder = 6 end object IdSizeEdit: TEdit Left = 256 ! Top = 264 Width = 89 Height = 21 ! TabOrder = 7 ! end ! object LoginPromptCheckBox: TCheckBox ! Left = 196 ! Top = 54 ! Width = 150 ! Height = 17 ! Caption = '&Login Prompt' ! TabOrder = 3 end end object BottomPanel: TPanel Left = 0 ! Top = 294 Width = 362 Height = 35 --- InstantUIBConnection.pas DELETED --- Index: InstantUIB.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Brokers/UIB/InstantUIB.pas,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** InstantUIB.pas 4 Sep 2005 23:15:53 -0000 1.14 --- InstantUIB.pas 21 Oct 2005 09:15:08 -0000 1.15 *************** *** 37,41 **** uses ! Classes, Db, jvuib, jvuibdataset, jvuiblib, SysUtils, InstantUIBConnection, InstantPersistence, InstantClasses, InstantCommand; --- 37,41 ---- uses ! Classes, Db, jvuib, jvuibdataset, jvuiblib, SysUtils, InstantPersistence, InstantClasses, InstantCommand; *************** *** 48,64 **** type ! TUIBNetType = (ntLocal, ntTCP, ntNetBEUI, ntSPX); ! ! TInstantUIBConnectionDef = class(TInstantConnectionBasedConnectionDef) private ! FPath: string; ! FServerName: string; ! FNetType: TUIBNetType; FOptions: TInstantUIBOptions; FParams: string; - function GetDatabaseName: string; - function GetServerName: string; protected ! function CreateConnection(AOwner: TComponent): TCustomConnection; override; procedure InitConnector(Connector: TInstantConnector); override; public --- 48,59 ---- type ! TInstantUIBConnectionDef = class(TInstantRelationalConnectionDef) private ! FLoginPrompt: Boolean; ! FConnectionString: string; FOptions: TInstantUIBOptions; FParams: string; protected ! function CreateDataBase(AOwner: TComponent): TJvUIBDataBase; procedure InitConnector(Connector: TInstantConnector); override; public *************** *** 67,88 **** constructor Create(Collection: TCollection); override; function Edit: Boolean; override; - property DatabaseName: string read GetDatabaseName; published ! property Path: string read FPath write FPath; ! property NetType: TUIBNetType read FNetType write FNetType; ! property ServerName: string read GetServerName write FServerName; property Options: TInstantUIBOptions read FOptions write FOptions; property Params: string read FParams write FParams; end; ! TInstantUIBConnector = class(TInstantConnectionBasedConnector) private FTransaction: TJvUIBTransaction; FOptions: TInstantUIBOptions; ! FOnLogin: TLoginEvent; ! function GetConnection: TInstantUIBConnection; function GetTransaction: TJvUIBTransaction; ! procedure SetConnection(const Value: TInstantUIBConnection); protected function CreateBroker: TInstantBroker; override; procedure InternalBuildDatabase(Scheme: TInstantScheme); override; --- 62,87 ---- constructor Create(Collection: TCollection); override; function Edit: Boolean; override; published ! property ConnectionString: string read FConnectionString write FConnectionString; ! property LoginPrompt: Boolean read FLoginPrompt write FLoginPrompt default True; property Options: TInstantUIBOptions read FOptions write FOptions; property Params: string read FParams write FParams; end; ! TInstantUIBConnector = class(TInstantRelationalConnector) private + FDataBase: TJvUIBDataBase; FTransaction: TJvUIBTransaction; FOptions: TInstantUIBOptions; ! FLoginPrompt: Boolean; ! function GetDataBase: TJvUIBDataBase; function GetTransaction: TJvUIBTransaction; ! procedure SetDataBase(const Value: TJvUIBDataBase); ! procedure DataBaseLogin; protected + procedure CheckDataBase; + function GetConnected: Boolean; override; + procedure InternalConnect; override; + procedure InternalDisconnect; override; function CreateBroker: TInstantBroker; override; procedure InternalBuildDatabase(Scheme: TInstantScheme); override; *************** *** 91,95 **** procedure InternalStartTransaction; override; procedure InternalCreateDatabase; override; - procedure AssignLoginOptions; override; function GetDatabaseExists: Boolean; override; public --- 90,93 ---- *************** *** 97,110 **** destructor Destroy; override; class function ConnectionDefClass: TInstantConnectionDefClass; override; property Transaction: TJvUIBTransaction read GetTransaction; published ! property Connection: TInstantUIBConnection read GetConnection write SetConnection; property Options: TInstantUIBOptions read FOptions write FOptions default DefaultInstantUIBOptions; - property OnLogin: TLoginEvent read FOnLogin write FOnLogin; end; TInstantUIBBroker = class(TInstantSQLBroker) private ! function GetDialect: Integer; function GetConnector: TInstantUIBConnector; function DelimitedIdentsEnabled: Boolean; --- 95,110 ---- destructor Destroy; override; class function ConnectionDefClass: TInstantConnectionDefClass; override; + procedure Notification(AComponent: TComponent; Operation: TOperation); override; property Transaction: TJvUIBTransaction read GetTransaction; + function HasDataBase: Boolean; published ! property DataBase: TJvUIBDataBase read GetDataBase write SetDataBase; ! property LoginPrompt: Boolean read FLoginPrompt write FLoginPrompt; property Options: TInstantUIBOptions read FOptions write FOptions default DefaultInstantUIBOptions; end; TInstantUIBBroker = class(TInstantSQLBroker) private ! function GetSQLDialect: Integer; function GetConnector: TInstantUIBConnector; function DelimitedIdentsEnabled: Boolean; *************** *** 125,129 **** function Execute(const AStatement: string; AParams: TParams = nil): Integer; override; property Connector: TInstantUIBConnector read GetConnector; ! property Dialect: Integer read GetDialect; end; --- 125,129 ---- function Execute(const AStatement: string; AParams: TParams = nil): Integer; override; property Connector: TInstantUIBConnector read GetConnector; ! property SQLDialect: Integer read GetSQLDialect; end; *************** *** 165,186 **** begin inherited; FOptions := DefaultInstantUIBOptions; end; ! function TInstantUIBConnectionDef.CreateConnection( ! AOwner: TComponent): TCustomConnection; ! var ! Connection: TInstantUIBConnection; begin ! Connection := TInstantUIBConnection.Create(AOwner); try ! Connection.Database.DatabaseName := DatabaseName; ! Connection.Database.SQLDialect := 3; ! Connection.Database.Params.Text := Params; except ! Connection.Free; raise; end; - Result := Connection; end; --- 165,184 ---- begin inherited; + FLoginPrompt := True; FOptions := DefaultInstantUIBOptions; end; ! function TInstantUIBConnectionDef.CreateDataBase( ! AOwner: TComponent): TJvUIBDataBase; begin ! Result := TJvUIBDataBase.Create(AOwner); try ! Result.Params.Text := Params; ! Result.DatabaseName := ConnectionString; ! Result.SQLDialect := 3; except ! Result.Free; raise; end; end; *************** *** 198,243 **** end; - function TInstantUIBConnectionDef.GetDatabaseName: string; - var - Fmt: string; - begin - if NetType = ntLocal then - Result := Path - else begin - case NetType of - ntTCP: Fmt := '%s:%s'; - ntNetBEUI: Fmt := '\\%s\%s'; - ntSPX: Fmt := '%s@%s'; - end; - Result := Format(Fmt, [ServerName, Path]); - end; - end; - - function TInstantUIBConnectionDef.GetServerName: string; - begin - if NetType = ntLocal then - Result := '' - else - Result := FServerName; - end; - procedure TInstantUIBConnectionDef.InitConnector(Connector: TInstantConnector); begin inherited; ! (Connector as TInstantUIBConnector).Options := FOptions; end; { TInstantUIBConnector } - procedure TInstantUIBConnector.AssignLoginOptions; - begin - inherited; - if HasConnection then - begin - if Assigned(FOnLogin) and not Assigned(Connection.OnLogin) then - Connection.OnLogin := FOnLogin; - end; - end; - class function TInstantUIBConnector.ConnectionDefClass: TInstantConnectionDefClass; begin --- 196,217 ---- end; procedure TInstantUIBConnectionDef.InitConnector(Connector: TInstantConnector); + var + DataBase: TJvUIBDataBase; begin inherited; ! DataBase := CreateDatabase(Connector); ! try ! (Connector as TInstantUIBConnector).DataBase := DataBase; ! (Connector as TInstantUIBConnector).LoginPrompt := LoginPrompt; ! (Connector as TInstantUIBConnector).Options := FOptions; ! except ! DataBase.Free; ! raise; ! end; end; { TInstantUIBConnector } class function TInstantUIBConnector.ConnectionDefClass: TInstantConnectionDefClass; begin *************** *** 248,251 **** --- 222,226 ---- begin inherited; + FLoginPrompt := True; FOptions := DefaultInstantUIBOptions; end; *************** *** 258,268 **** destructor TInstantUIBConnector.Destroy; begin ! FTransaction.Free; inherited; end; ! function TInstantUIBConnector.GetConnection: TInstantUIBConnection; begin ! Result := inherited Connection as TInstantUIBConnection; end; --- 233,245 ---- destructor TInstantUIBConnector.Destroy; begin ! FreeAndNil(FTransaction); inherited; end; ! function TInstantUIBConnector.GetDataBase: TJvUIBDataBase; begin ! if not (csDesigning in ComponentState) then ! CheckDataBase; ! Result := FDataBase; end; *************** *** 271,282 **** if not Assigned(FTransaction) then begin ! CheckConnection; FTransaction := TJvUIBTransaction.Create(nil); try ! FTransaction.Database := Connection.Database; FTransaction.AutoStart := True; FTransaction.AutoStop := True; FTransaction.DefaultAction := etmRollback; ! FTransaction.Options := [tpReadCommitted]; except FTransaction.Free; --- 248,259 ---- if not Assigned(FTransaction) then begin ! CheckDataBase; FTransaction := TJvUIBTransaction.Create(nil); try ! FTransaction.DataBase := FDatabase; FTransaction.AutoStart := True; FTransaction.AutoStop := True; FTransaction.DefaultAction := etmRollback; ! FTransaction.Options := [tpReadCommitted]; except FTransaction.Free; *************** *** 316,322 **** end; ! procedure TInstantUIBConnector.SetConnection(const Value: TInstantUIBConnection); begin ! inherited Connection := Value; end; --- 293,307 ---- end; ! procedure TInstantUIBConnector.SetDataBase(const Value: TJvUIBDataBase); begin ! if Value <> FDataBase then ! begin ! Disconnect; ! if Assigned(FDataBase) then ! FDataBase.RemoveFreeNotification(Self); ! FDataBase := Value; ! if Assigned(FDataBase) then ! FDataBase.FreeNotification(Self); ! end; end; *************** *** 324,332 **** begin inherited; ! Connection.Close; try ! Connection.Database.CreateDatabase(4096); finally ! Connection.Close; end; end; --- 309,318 ---- begin inherited; ! if DataBase.Connected then ! raise EInstantError.Create(SDatabaseOpen); try ! DataBase.CreateDatabase(4096); finally ! Disconnect; end; end; *************** *** 334,350 **** function TInstantUIBConnector.GetDatabaseExists: Boolean; begin - AssignLoginOptions; try ! Connection.Open; try Result := True; finally ! Connection.Close; end; except ! Result := False end; end; { TInstantUIBBroker} --- 320,402 ---- function TInstantUIBConnector.GetDatabaseExists: Boolean; begin try ! DataBase.Connected := True; try Result := True; finally ! DataBase.Connected := False; end; except ! on E: EUIBError do begin ! if (E.SQLCode = -902) and (E.ErrorCode = 335544344) then ! Result := False ! else ! raise; ! end; ! end; ! end; ! ! procedure TInstantUIBConnector.CheckDataBase; ! begin ! if not Assigned(FDataBase) then ! raise EInstantError.Create(SUnassignedConnection); ! end; ! ! function TInstantUIBConnector.GetConnected: Boolean; ! begin ! if HasDataBase then ! Result := DataBase.Connected ! else ! Result := inherited GetConnected; ! end; ! ! procedure TInstantUIBConnector.InternalConnect; ! begin ! CheckDataBase; ! if FLoginPrompt and not DataBase.Connected then ! DataBaseLogin; ! DataBase.Connected := True; ! end; ! ! procedure TInstantUIBConnector.InternalDisconnect; ! begin ! if HasDataBase then ! DataBase.Connected := False; ! end; ! ! procedure TInstantUIBConnector.Notification(AComponent: TComponent; ! Operation: TOperation); ! begin ! inherited; ! if (AComponent = FDataBase) and (Operation = opRemove) then ! begin ! Disconnect; ! FDataBase := nil; end; end; + function TInstantUIBConnector.HasDataBase: Boolean; + begin + Result := Assigned(FDataBase); + end; + + procedure TInstantUIBConnector.DataBaseLogin; + var + LUserName, LPassWord: string; + begin + LUserName := DataBase.UserName; + LPassWord := DataBase.PassWord; + if Assigned(LoginDialogProc) then + begin + if LoginDialogProc(FDataBase.DatabaseName, LUserName, LPassWord) then + begin + FDataBase.UserName := LUserName; + FDataBase.PassWord := LPassWord; + end; + end + else + raise EDatabaseError.Create(SLoginPromptFailure); + end; + { TInstantUIBBroker} *************** *** 419,423 **** Query := TJvUIBDataSet.Create(nil); try ! Query.Database := Connector.Connection.Database; Query.FetchBlobs := True; Query.OnError := etmStayIn; --- 471,475 ---- Query := TJvUIBDataSet.Create(nil); try ! Query.Database := Connector.DataBase; Query.FetchBlobs := True; Query.OnError := etmStayIn; *************** *** 467,471 **** function TInstantUIBBroker.GetDatabaseName: string; begin ! Result := Connector.Connection.Database.DatabaseName; end; --- 519,523 ---- function TInstantUIBBroker.GetDatabaseName: string; begin ! Result := Connector.DataBase.DatabaseName; end; *************** *** 475,486 **** end; ! function TInstantUIBBroker.GetDialect: Integer; begin ! Result := Connector.Connection.Database.SQLDialect; end; function TInstantUIBBroker.GetSQLDelimiters: string; begin ! if (Dialect = 3) and DelimitedIdentsEnabled() then Result := '""' else --- 527,538 ---- end; ! function TInstantUIBBroker.GetSQLDialect: Integer; begin ! Result := Connector.DataBase.SQLDialect; end; function TInstantUIBBroker.GetSQLDelimiters: string; begin ! if (SQLDialect = 3) and DelimitedIdentsEnabled() then Result := '""' else Index: InstantUIBReg.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Brokers/UIB/InstantUIBReg.pas,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** InstantUIBReg.pas 4 Sep 2005 23:15:53 -0000 1.3 --- InstantUIBReg.pas 21 Oct 2005 09:15:08 -0000 1.4 *************** *** 41,50 **** uses ! Classes, InstantUIB, InstantUIBConnection; procedure Register; begin RegisterComponents('InstantObjects', [TInstantUIBConnector]); - RegisterComponents('InstantObjects', [TInstantUIBConnection]); end; --- 41,49 ---- uses ! Classes, InstantUIB; procedure Register; begin RegisterComponents('InstantObjects', [TInstantUIBConnector]); end; |