mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Bind session parameter object to session manager list nodes, to be able to show the right vendor icon in that list.
This commit is contained in:
@ -111,6 +111,8 @@ object connform: Tconnform
|
|||||||
OnFocusChanging = ListSessionsFocusChanging
|
OnFocusChanging = ListSessionsFocusChanging
|
||||||
OnGetText = ListSessionsGetText
|
OnGetText = ListSessionsGetText
|
||||||
OnGetImageIndex = ListSessionsGetImageIndex
|
OnGetImageIndex = ListSessionsGetImageIndex
|
||||||
|
OnGetNodeDataSize = ListSessionsGetNodeDataSize
|
||||||
|
OnInitNode = ListSessionsInitNode
|
||||||
OnNewText = ListSessionsNewText
|
OnNewText = ListSessionsNewText
|
||||||
Columns = <
|
Columns = <
|
||||||
item
|
item
|
||||||
|
@ -10,7 +10,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Windows, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls,
|
Windows, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls,
|
||||||
VirtualTrees, Menus, Graphics,
|
VirtualTrees, Menus, Graphics, Contnrs, Generics.Collections,
|
||||||
dbconnection;
|
dbconnection;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -113,17 +113,18 @@ type
|
|||||||
procedure comboDatabasesDropDown(Sender: TObject);
|
procedure comboDatabasesDropDown(Sender: TObject);
|
||||||
procedure chkLoginPromptClick(Sender: TObject);
|
procedure chkLoginPromptClick(Sender: TObject);
|
||||||
procedure comboNetTypeChange(Sender: TObject);
|
procedure comboNetTypeChange(Sender: TObject);
|
||||||
|
procedure ListSessionsInitNode(Sender: TBaseVirtualTree; ParentNode,
|
||||||
|
Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
|
||||||
|
procedure ListSessionsGetNodeDataSize(Sender: TBaseVirtualTree;
|
||||||
|
var NodeDataSize: Integer);
|
||||||
private
|
private
|
||||||
{ Private declarations }
|
{ Private declarations }
|
||||||
FLoaded: Boolean;
|
FLoaded: Boolean;
|
||||||
FSessionNames: TStringlist;
|
FSessions: TObjectList<TConnectionParameters>;
|
||||||
FSessionModified, FOnlyPasswordModified, FSessionAdded: Boolean;
|
FSessionModified, FOnlyPasswordModified, FSessionAdded: Boolean;
|
||||||
FOrgParams: TConnectionParameters;
|
|
||||||
FWidthListSessions: Byte; // Percentage values
|
FWidthListSessions: Byte; // Percentage values
|
||||||
function SelectedSession: String;
|
function SelectedSession: String;
|
||||||
function CurrentParams: TConnectionParameters;
|
function CurrentParams: TConnectionParameters;
|
||||||
procedure SessionNamesChange(Sender: TObject);
|
|
||||||
procedure RefreshSessionList;
|
|
||||||
procedure FinalizeModifications(var CanProceed: Boolean);
|
procedure FinalizeModifications(var CanProceed: Boolean);
|
||||||
procedure SaveCurrentValues(Session: String; IsNew: Boolean);
|
procedure SaveCurrentValues(Session: String; IsNew: Boolean);
|
||||||
procedure ValidateControls;
|
procedure ValidateControls;
|
||||||
@ -144,10 +145,13 @@ uses Main, helpers, grideditlinks;
|
|||||||
procedure Tconnform.FormCreate(Sender: TObject);
|
procedure Tconnform.FormCreate(Sender: TObject);
|
||||||
var
|
var
|
||||||
LastActiveSession: String;
|
LastActiveSession: String;
|
||||||
LastSessions: TStringList;
|
SessionNames, LastSessions: TStringList;
|
||||||
|
Sess: TConnectionParameters;
|
||||||
|
PSess: PConnectionParameters;
|
||||||
hSysMenu: THandle;
|
hSysMenu: THandle;
|
||||||
idx: Integer;
|
i: Integer;
|
||||||
nt: TNetType;
|
nt: TNetType;
|
||||||
|
Node: PVirtualNode;
|
||||||
begin
|
begin
|
||||||
// Fix GUI stuff
|
// Fix GUI stuff
|
||||||
InheritFont(Font);
|
InheritFont(Font);
|
||||||
@ -163,21 +167,30 @@ begin
|
|||||||
for nt:=Low(nt) to High(nt) do
|
for nt:=Low(nt) to High(nt) do
|
||||||
comboNetType.Items.Add(TConnectionParameters.NetTypeName(nt, True));
|
comboNetType.Items.Add(TConnectionParameters.NetTypeName(nt, True));
|
||||||
|
|
||||||
FSessionNames := TStringList.Create;
|
FSessions := TObjectList<TConnectionParameters>.Create;
|
||||||
FSessionNames.OnChange := SessionNamesChange;
|
SessionNames := TStringList.Create;
|
||||||
RefreshSessionList;
|
MainReg.OpenKey(RegPath + REGKEY_SESSIONS, True);
|
||||||
|
MainReg.GetKeyNames(SessionNames);
|
||||||
|
for i:=0 to SessionNames.Count-1 do begin
|
||||||
|
Sess := LoadConnectionParams(SessionNames[i]);
|
||||||
|
FSessions.Add(Sess);
|
||||||
|
end;
|
||||||
|
ListSessions.RootNodeCount := FSessions.Count;
|
||||||
|
|
||||||
// Focus last session
|
// Focus last session
|
||||||
LastSessions := Explode(DELIM, GetRegValue(REGNAME_LASTSESSIONS, ''));
|
LastSessions := Explode(DELIM, GetRegValue(REGNAME_LASTSESSIONS, ''));
|
||||||
LastActiveSession := GetRegValue(REGNAME_LASTACTIVESESSION, '');
|
LastActiveSession := GetRegValue(REGNAME_LASTACTIVESESSION, '');
|
||||||
idx := FSessionNames.IndexOf(LastActiveSession);
|
if (LastActiveSession = '') and (LastSessions.Count > 0) then
|
||||||
if idx = -1 then begin
|
LastActiveSession := LastSessions[0];
|
||||||
if LastSessions.Count > 0 then
|
Node := ListSessions.GetFirst;
|
||||||
idx := FSessionNames.IndexOf(LastSessions[0]);
|
while Assigned(Node) do begin
|
||||||
if idx = -1 then
|
PSess := ListSessions.GetNodeData(Node);
|
||||||
idx := 0;
|
if PSess.SessionName = LastActiveSession then
|
||||||
|
SelectNode(ListSessions, Node);
|
||||||
|
Node := ListSessions.GetNextSibling(Node);
|
||||||
end;
|
end;
|
||||||
SelectNode(ListSessions, idx);
|
|
||||||
ValidateControls;
|
ValidateControls;
|
||||||
|
|
||||||
// Add own menu items to system menu
|
// Add own menu items to system menu
|
||||||
hSysMenu := GetSystemMenu(Handle, False);
|
hSysMenu := GetSystemMenu(Handle, False);
|
||||||
AppendMenu(hSysMenu, MF_SEPARATOR, 0, #0);
|
AppendMenu(hSysMenu, MF_SEPARATOR, 0, #0);
|
||||||
@ -225,7 +238,7 @@ var
|
|||||||
begin
|
begin
|
||||||
// Connect to selected session
|
// Connect to selected session
|
||||||
Screen.Cursor := crHourglass;
|
Screen.Cursor := crHourglass;
|
||||||
if Mainform.InitConnection(CurrentParams, SelectedSession, True, Connection) then
|
if Mainform.InitConnection(CurrentParams, True, Connection) then
|
||||||
ModalResult := mrOK
|
ModalResult := mrOK
|
||||||
else begin
|
else begin
|
||||||
TimerStatistics.OnTimer(Sender);
|
TimerStatistics.OnTimer(Sender);
|
||||||
@ -236,6 +249,8 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
procedure Tconnform.SaveCurrentValues(Session: String; IsNew: Boolean);
|
procedure Tconnform.SaveCurrentValues(Session: String; IsNew: Boolean);
|
||||||
|
var
|
||||||
|
Sess: PConnectionParameters;
|
||||||
begin
|
begin
|
||||||
OpenRegistry(Session);
|
OpenRegistry(Session);
|
||||||
MainReg.WriteString(REGNAME_HOST, editHost.Text);
|
MainReg.WriteString(REGNAME_HOST, editHost.Text);
|
||||||
@ -261,7 +276,29 @@ begin
|
|||||||
MainReg.WriteString(REGNAME_SESSIONCREATED, DateTimeToStr(Now));
|
MainReg.WriteString(REGNAME_SESSIONCREATED, DateTimeToStr(Now));
|
||||||
OpenRegistry;
|
OpenRegistry;
|
||||||
MainReg.WriteString(REGNAME_PLINKEXE, editSSHPlinkExe.Text);
|
MainReg.WriteString(REGNAME_PLINKEXE, editSSHPlinkExe.Text);
|
||||||
FOrgParams := LoadConnectionParams(Session);
|
|
||||||
|
// Overtake edited values for in-memory parameter object
|
||||||
|
Sess := ListSessions.GetNodeData(ListSessions.FocusedNode);
|
||||||
|
Sess.Hostname := editHost.Text;
|
||||||
|
Sess.Username := editUsername.Text;
|
||||||
|
Sess.Password := editPassword.Text;
|
||||||
|
Sess.LoginPrompt := chkLoginPrompt.Checked;
|
||||||
|
Sess.Port := updownPort.Position;
|
||||||
|
Sess.NetType := TNetType(comboNetType.ItemIndex);
|
||||||
|
Sess.Compressed := chkCompressed.Checked;
|
||||||
|
Sess.AllDatabasesStr := comboDatabases.Text;
|
||||||
|
Sess.StartupScriptFilename := editStartupScript.Text;
|
||||||
|
Sess.SSHHost := editSSHhost.Text;
|
||||||
|
Sess.SSHPort := MakeInt(editSSHport.Text);
|
||||||
|
Sess.SSHUser := editSSHUser.Text;
|
||||||
|
Sess.SSHPassword := editSSHPassword.Text;
|
||||||
|
Sess.SSHTimeout := updownSSHTimeout.Position;
|
||||||
|
Sess.SSHPrivateKey := editSSHPrivateKey.Text;
|
||||||
|
Sess.SSHLocalPort := MakeInt(editSSHlocalport.Text);
|
||||||
|
Sess.SSLPrivateKey := editSSLPrivateKey.Text;
|
||||||
|
Sess.SSLCertificate := editSSLCertificate.Text;
|
||||||
|
Sess.SSLCACertificate := editSSLCACertificate.Text;
|
||||||
|
|
||||||
FSessionModified := False;
|
FSessionModified := False;
|
||||||
FSessionAdded := False;
|
FSessionAdded := False;
|
||||||
ListSessions.Invalidate;
|
ListSessions.Invalidate;
|
||||||
@ -295,7 +332,6 @@ begin
|
|||||||
// Create the key and save its values
|
// Create the key and save its values
|
||||||
OpenRegistry(newName);
|
OpenRegistry(newName);
|
||||||
SaveCurrentValues(newName, True);
|
SaveCurrentValues(newName, True);
|
||||||
RefreshSessionList;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -303,9 +339,10 @@ end;
|
|||||||
|
|
||||||
procedure Tconnform.btnNewClick(Sender: TObject);
|
procedure Tconnform.btnNewClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
i, NewIdx: Integer;
|
i: Integer;
|
||||||
NewName: String;
|
|
||||||
CanProceed: Boolean;
|
CanProceed: Boolean;
|
||||||
|
NewSess: TConnectionParameters;
|
||||||
|
Node: PVirtualNode;
|
||||||
begin
|
begin
|
||||||
// Create new session
|
// Create new session
|
||||||
FinalizeModifications(CanProceed);
|
FinalizeModifications(CanProceed);
|
||||||
@ -313,19 +350,19 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
i := 0;
|
i := 0;
|
||||||
NewName := 'Unnamed';
|
NewSess := TConnectionParameters.Create;
|
||||||
while MainReg.KeyExists(RegPath + REGKEY_SESSIONS + NewName) do begin
|
NewSess.SessionName := 'Unnamed';
|
||||||
|
while MainReg.KeyExists(RegPath + REGKEY_SESSIONS + NewSess.SessionName) do begin
|
||||||
inc(i);
|
inc(i);
|
||||||
NewName := 'Unnamed-' + IntToStr(i);
|
NewSess.SessionName := 'Unnamed-' + IntToStr(i);
|
||||||
end;
|
end;
|
||||||
FSessionNames.Add(NewName);
|
FSessions.Add(NewSess);
|
||||||
FSessionNames.Sort;
|
Node := ListSessions.AddChild(nil, @NewSess);
|
||||||
NewIdx := FSessionNames.IndexOf(NewName);
|
|
||||||
// Select it
|
// Select it
|
||||||
SelectNode(ListSessions, NewIdx);
|
SelectNode(ListSessions, Node);
|
||||||
FSessionAdded := True;
|
FSessionAdded := True;
|
||||||
ValidateControls;
|
ValidateControls;
|
||||||
ListSessions.EditNode(ListSessions.FocusedNode, ListSessions.FocusedColumn);
|
ListSessions.EditNode(Node, 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -333,13 +370,16 @@ procedure Tconnform.btnDeleteClick(Sender: TObject);
|
|||||||
var
|
var
|
||||||
SessionKey: String;
|
SessionKey: String;
|
||||||
Node: PVirtualNode;
|
Node: PVirtualNode;
|
||||||
|
Sess: PConnectionParameters;
|
||||||
begin
|
begin
|
||||||
if MessageDlg('Delete session "' + SelectedSession + '" ?', mtConfirmation, [mbYes, mbCancel], 0) = mrYes then
|
Sess := ListSessions.GetNodeData(ListSessions.FocusedNode);
|
||||||
|
if MessageDlg('Delete session "' + Sess.SessionName + '" ?', mtConfirmation, [mbYes, mbCancel], 0) = mrYes then
|
||||||
begin
|
begin
|
||||||
SessionKey := RegPath + REGKEY_SESSIONS + SelectedSession;
|
SessionKey := RegPath + REGKEY_SESSIONS + Sess.SessionName;
|
||||||
if MainReg.KeyExists(SessionKey) then
|
if MainReg.KeyExists(SessionKey) then
|
||||||
MainReg.DeleteKey(SessionKey);
|
MainReg.DeleteKey(SessionKey);
|
||||||
FSessionNames.Delete(FSessionNames.IndexOf(SelectedSession));
|
ListSessions.DeleteSelectedNodes;
|
||||||
|
FSessions.Remove(Sess^);
|
||||||
if (not Assigned(ListSessions.FocusedNode)) and (ListSessions.RootNodeCount > 0) then
|
if (not Assigned(ListSessions.FocusedNode)) and (ListSessions.RootNodeCount > 0) then
|
||||||
SelectNode(ListSessions, ListSessions.RootNodeCount-1)
|
SelectNode(ListSessions, ListSessions.RootNodeCount-1)
|
||||||
else begin
|
else begin
|
||||||
@ -352,8 +392,11 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
function Tconnform.SelectedSession: String;
|
function Tconnform.SelectedSession: String;
|
||||||
|
var
|
||||||
|
Sess: PConnectionParameters;
|
||||||
begin
|
begin
|
||||||
Result := FSessionNames[ListSessions.FocusedNode.Index];
|
Sess := ListSessions.GetNodeData(ListSessions.FocusedNode);
|
||||||
|
Result := Sess.SessionName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -361,6 +404,7 @@ function Tconnform.CurrentParams: TConnectionParameters;
|
|||||||
begin
|
begin
|
||||||
// Return non-stored parameters
|
// Return non-stored parameters
|
||||||
Result := TConnectionParameters.Create;
|
Result := TConnectionParameters.Create;
|
||||||
|
Result.SessionName := SelectedSession;
|
||||||
Result.NetType := TNetType(comboNetType.ItemIndex);
|
Result.NetType := TNetType(comboNetType.ItemIndex);
|
||||||
Result.Hostname := editHost.Text;
|
Result.Hostname := editHost.Text;
|
||||||
Result.Username := editUsername.Text;
|
Result.Username := editUsername.Text;
|
||||||
@ -384,50 +428,61 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure Tconnform.SessionNamesChange(Sender: TObject);
|
|
||||||
begin
|
|
||||||
ListSessions.RootNodeCount := (Sender as TStringlist).Count;
|
|
||||||
ListSessions.Invalidate;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure Tconnform.RefreshSessionList;
|
|
||||||
begin
|
|
||||||
// Refresh list of session names
|
|
||||||
MainReg.OpenKey(RegPath + REGKEY_SESSIONS, True);
|
|
||||||
FSessionNames.BeginUpdate;
|
|
||||||
MainReg.GetKeyNames(FSessionNames);
|
|
||||||
FSessionNames.EndUpdate;
|
|
||||||
FSessionModified := False;
|
|
||||||
FSessionAdded := False;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure Tconnform.ListSessionsGetImageIndex(Sender: TBaseVirtualTree;
|
procedure Tconnform.ListSessionsGetImageIndex(Sender: TBaseVirtualTree;
|
||||||
Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
|
Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
|
||||||
var Ghosted: Boolean; var ImageIndex: Integer);
|
var Ghosted: Boolean; var ImageIndex: Integer);
|
||||||
|
var
|
||||||
|
Sess: PConnectionParameters;
|
||||||
begin
|
begin
|
||||||
// A new session gets an additional plus symbol, editing gets a pencil
|
// A new session gets an additional plus symbol, editing gets a pencil
|
||||||
if not (Kind in [ikNormal, ikSelected]) then Exit;
|
case Kind of
|
||||||
ImageIndex := 36;
|
ikNormal, ikSelected: begin
|
||||||
if Node = Sender.FocusedNode then begin
|
Sess := Sender.GetNodeData(Node);
|
||||||
if FSessionAdded then ImageIndex := 72
|
ImageIndex := Sess.ImageIndex;
|
||||||
else if FSessionModified then ImageIndex := 135;
|
end;
|
||||||
end
|
|
||||||
|
ikOverlay: if Node = Sender.FocusedNode then begin
|
||||||
|
if FSessionAdded then
|
||||||
|
ImageIndex := 163
|
||||||
|
else if FSessionModified then
|
||||||
|
ImageIndex := 162;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure Tconnform.ListSessionsGetNodeDataSize(Sender: TBaseVirtualTree;
|
||||||
|
var NodeDataSize: Integer);
|
||||||
|
begin
|
||||||
|
NodeDataSize := SizeOf(TConnectionParameters);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure Tconnform.ListSessionsGetText(Sender: TBaseVirtualTree;
|
procedure Tconnform.ListSessionsGetText(Sender: TBaseVirtualTree;
|
||||||
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
|
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
|
||||||
var CellText: String);
|
var CellText: String);
|
||||||
|
var
|
||||||
|
Sess: PConnectionParameters;
|
||||||
begin
|
begin
|
||||||
// Display session name cell
|
// Display session name cell
|
||||||
CellText := FSessionNames[Node.Index];
|
Sess := Sender.GetNodeData(Node);
|
||||||
|
CellText := Sess.SessionName;
|
||||||
if (FSessionModified or FSessionAdded) and (Node = Sender.FocusedNode) and (not Sender.IsEditing) then
|
if (FSessionModified or FSessionAdded) and (Node = Sender.FocusedNode) and (not Sender.IsEditing) then
|
||||||
CellText := CellText + ' *';
|
CellText := CellText + ' *';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure Tconnform.ListSessionsInitNode(Sender: TBaseVirtualTree; ParentNode,
|
||||||
|
Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
|
||||||
|
var
|
||||||
|
Sess: PConnectionParameters;
|
||||||
|
begin
|
||||||
|
Sess := Sender.GetNodeData(Node);
|
||||||
|
Sess^ := FSessions[Node.Index];
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure Tconnform.ListSessionsCreateEditor(Sender: TBaseVirtualTree; Node: PVirtualNode;
|
procedure Tconnform.ListSessionsCreateEditor(Sender: TBaseVirtualTree; Node: PVirtualNode;
|
||||||
Column: TColumnIndex; out EditLink: IVTEditLink);
|
Column: TColumnIndex; out EditLink: IVTEditLink);
|
||||||
begin
|
begin
|
||||||
@ -440,41 +495,36 @@ procedure Tconnform.ListSessionsFocusChanged(Sender: TBaseVirtualTree;
|
|||||||
Node: PVirtualNode; Column: TColumnIndex);
|
Node: PVirtualNode; Column: TColumnIndex);
|
||||||
var
|
var
|
||||||
SessionFocused: Boolean;
|
SessionFocused: Boolean;
|
||||||
|
Sess: PConnectionParameters;
|
||||||
begin
|
begin
|
||||||
// select one connection!
|
// select one connection!
|
||||||
Screen.Cursor := crHourglass;
|
Screen.Cursor := crHourglass;
|
||||||
TimerStatistics.Enabled := False;
|
TimerStatistics.Enabled := False;
|
||||||
OpenRegistry;
|
|
||||||
SessionFocused := Assigned(Node);
|
SessionFocused := Assigned(Node);
|
||||||
if SessionFocused then begin
|
if SessionFocused then begin
|
||||||
try
|
Sess := Sender.GetNodeData(Node);
|
||||||
FOrgParams := LoadConnectionParams(SelectedSession);
|
|
||||||
except
|
|
||||||
// Editing a new session, not saved yet
|
|
||||||
FOrgParams := TConnectionParameters.Create;
|
|
||||||
end;
|
|
||||||
|
|
||||||
FLoaded := False;
|
FLoaded := False;
|
||||||
comboNetType.ItemIndex := Integer(FOrgParams.NetType);
|
comboNetType.ItemIndex := Integer(Sess.NetType);
|
||||||
editHost.Text := FOrgParams.Hostname;
|
editHost.Text := Sess.Hostname;
|
||||||
editUsername.Text := FOrgParams.Username;
|
editUsername.Text := Sess.Username;
|
||||||
editPassword.Text := FOrgParams.Password;
|
editPassword.Text := Sess.Password;
|
||||||
chkLoginPrompt.Checked := FOrgParams.LoginPrompt;
|
chkLoginPrompt.Checked := Sess.LoginPrompt;
|
||||||
updownPort.Position := FOrgParams.Port;
|
updownPort.Position := Sess.Port;
|
||||||
chkCompressed.Checked := FOrgParams.Compressed;
|
chkCompressed.Checked := Sess.Compressed;
|
||||||
comboDatabases.Text := FOrgParams.AllDatabasesStr;
|
comboDatabases.Text := Sess.AllDatabasesStr;
|
||||||
editStartupScript.Text := FOrgParams.StartupScriptFilename;
|
editStartupScript.Text := Sess.StartupScriptFilename;
|
||||||
editSSHPlinkExe.Text := FOrgParams.SSHPlinkExe;
|
editSSHPlinkExe.Text := Sess.SSHPlinkExe;
|
||||||
editSSHHost.Text := FOrgParams.SSHHost;
|
editSSHHost.Text := Sess.SSHHost;
|
||||||
editSSHport.Text := IntToStr(FOrgParams.SSHPort);
|
editSSHport.Text := IntToStr(Sess.SSHPort);
|
||||||
editSSHUser.Text := FOrgParams.SSHUser;
|
editSSHUser.Text := Sess.SSHUser;
|
||||||
editSSHPassword.Text := FOrgParams.SSHPassword;
|
editSSHPassword.Text := Sess.SSHPassword;
|
||||||
updownSSHTimeout.Position := FOrgParams.SSHTimeout;
|
updownSSHTimeout.Position := Sess.SSHTimeout;
|
||||||
editSSHPrivateKey.Text := FOrgParams.SSHPrivateKey;
|
editSSHPrivateKey.Text := Sess.SSHPrivateKey;
|
||||||
editSSHlocalport.Text := IntToStr(FOrgParams.SSHLocalPort);
|
editSSHlocalport.Text := IntToStr(Sess.SSHLocalPort);
|
||||||
editSSLPrivateKey.Text := FOrgParams.SSLPrivateKey;
|
editSSLPrivateKey.Text := Sess.SSLPrivateKey;
|
||||||
editSSLCertificate.Text := FOrgParams.SSLCertificate;
|
editSSLCertificate.Text := Sess.SSLCertificate;
|
||||||
editSSLCACertificate.Text := FOrgParams.SSLCACertificate;
|
editSSLCACertificate.Text := Sess.SSLCACertificate;
|
||||||
FLoaded := True;
|
FLoaded := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -547,23 +597,25 @@ procedure Tconnform.ListSessionsNewText(Sender: TBaseVirtualTree;
|
|||||||
var
|
var
|
||||||
SessionKey: String;
|
SessionKey: String;
|
||||||
Connection: TDBConnection;
|
Connection: TDBConnection;
|
||||||
|
Sess: PConnectionParameters;
|
||||||
begin
|
begin
|
||||||
// Rename session
|
// Rename session
|
||||||
|
Sess := Sender.GetNodeData(Node);
|
||||||
OpenRegistry;
|
OpenRegistry;
|
||||||
if MainReg.KeyExists(REGKEY_SESSIONS + NewText) then begin
|
if MainReg.KeyExists(REGKEY_SESSIONS + NewText) then begin
|
||||||
MessageDLG('Session "'+NewText+'" already exists!', mtError, [mbCancel], 0);
|
MessageDLG('Session "'+NewText+'" already exists!', mtError, [mbCancel], 0);
|
||||||
NewText := SelectedSession;
|
NewText := Sess.SessionName;
|
||||||
end else begin
|
end else begin
|
||||||
SessionKey := RegPath + REGKEY_SESSIONS + SelectedSession;
|
SessionKey := RegPath + REGKEY_SESSIONS + Sess.SessionName;
|
||||||
if MainReg.KeyExists(SessionKey) then
|
if MainReg.KeyExists(SessionKey) then
|
||||||
MainReg.MoveKey(SessionKey, RegPath + REGKEY_SESSIONS + NewText, true);
|
MainReg.MoveKey(SessionKey, RegPath + REGKEY_SESSIONS + NewText, true);
|
||||||
// Also fix internal session names in main form, which gets used to store e.g. "lastuseddb" later
|
// Also fix internal session names in main form, which gets used to store e.g. "lastuseddb" later
|
||||||
for Connection in MainForm.Connections do begin
|
for Connection in MainForm.Connections do begin
|
||||||
if Connection.SessionName = SelectedSession then
|
if Connection.Parameters.SessionName = Sess.SessionName then
|
||||||
Connection.SessionName := NewText;
|
Connection.Parameters.SessionName := NewText;
|
||||||
end;
|
end;
|
||||||
MainForm.SetWindowCaption;
|
MainForm.SetWindowCaption;
|
||||||
FSessionNames[FSessionNames.IndexOf(SelectedSession)] := NewText;
|
Sess.SessionName := NewText;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -629,29 +681,31 @@ end;
|
|||||||
procedure Tconnform.Modification(Sender: TObject);
|
procedure Tconnform.Modification(Sender: TObject);
|
||||||
var
|
var
|
||||||
PasswordModified: Boolean;
|
PasswordModified: Boolean;
|
||||||
|
Sess: PConnectionParameters;
|
||||||
begin
|
begin
|
||||||
// Some modification -
|
// Some modification -
|
||||||
if FLoaded then begin
|
if FLoaded then begin
|
||||||
FSessionModified := (FOrgParams.Hostname <> editHost.Text)
|
Sess := ListSessions.GetNodeData(ListSessions.FocusedNode);
|
||||||
or (FOrgParams.Username <> editUsername.Text)
|
FSessionModified := (Sess.Hostname <> editHost.Text)
|
||||||
or (FOrgParams.LoginPrompt <> chkLoginPrompt.Checked)
|
or (Sess.Username <> editUsername.Text)
|
||||||
or (FOrgParams.Port <> updownPort.Position)
|
or (Sess.LoginPrompt <> chkLoginPrompt.Checked)
|
||||||
or (FOrgParams.Compressed <> chkCompressed.Checked)
|
or (Sess.Port <> updownPort.Position)
|
||||||
or (FOrgParams.NetType <> TNetType(comboNetType.ItemIndex))
|
or (Sess.Compressed <> chkCompressed.Checked)
|
||||||
or (FOrgParams.StartupScriptFilename <> editStartupScript.Text)
|
or (Sess.NetType <> TNetType(comboNetType.ItemIndex))
|
||||||
or (FOrgParams.AllDatabasesStr <> comboDatabases.Text)
|
or (Sess.StartupScriptFilename <> editStartupScript.Text)
|
||||||
or (FOrgParams.SSHHost <> editSSHHost.Text)
|
or (Sess.AllDatabasesStr <> comboDatabases.Text)
|
||||||
or (IntToStr(FOrgParams.SSHPort) <> editSSHPort.Text)
|
or (Sess.SSHHost <> editSSHHost.Text)
|
||||||
or (FOrgParams.SSHPlinkExe <> editSSHPlinkExe.Text)
|
or (IntToStr(Sess.SSHPort) <> editSSHPort.Text)
|
||||||
or (IntToStr(FOrgParams.SSHLocalPort) <> editSSHlocalport.Text)
|
or (Sess.SSHPlinkExe <> editSSHPlinkExe.Text)
|
||||||
or (FOrgParams.SSHUser <> editSSHUser.Text)
|
or (IntToStr(Sess.SSHLocalPort) <> editSSHlocalport.Text)
|
||||||
or (FOrgParams.SSHPassword <> editSSHPassword.Text)
|
or (Sess.SSHUser <> editSSHUser.Text)
|
||||||
or (FOrgParams.SSHTimeout <> updownSSHTimeout.Position)
|
or (Sess.SSHPassword <> editSSHPassword.Text)
|
||||||
or (FOrgParams.SSHPrivateKey <> editSSHPrivateKey.Text)
|
or (Sess.SSHTimeout <> updownSSHTimeout.Position)
|
||||||
or (FOrgParams.SSLPrivateKey <> editSSLPrivateKey.Text)
|
or (Sess.SSHPrivateKey <> editSSHPrivateKey.Text)
|
||||||
or (FOrgParams.SSLCertificate <> editSSLCertificate.Text)
|
or (Sess.SSLPrivateKey <> editSSLPrivateKey.Text)
|
||||||
or (FOrgParams.SSLCACertificate <> editSSLCACertificate.Text);
|
or (Sess.SSLCertificate <> editSSLCertificate.Text)
|
||||||
PasswordModified := FOrgParams.Password <> editPassword.Text;
|
or (Sess.SSLCACertificate <> editSSLCACertificate.Text);
|
||||||
|
PasswordModified := Sess.Password <> editPassword.Text;
|
||||||
FOnlyPasswordModified := PasswordModified and (not FSessionModified);
|
FOnlyPasswordModified := PasswordModified and (not FSessionModified);
|
||||||
FSessionModified := FSessionModified or PasswordModified;
|
FSessionModified := FSessionModified or PasswordModified;
|
||||||
|
|
||||||
@ -670,7 +724,6 @@ begin
|
|||||||
CanProceed := True;
|
CanProceed := True;
|
||||||
end;
|
end;
|
||||||
mrNo: begin
|
mrNo: begin
|
||||||
RefreshSessionList;
|
|
||||||
CanProceed := True;
|
CanProceed := True;
|
||||||
end;
|
end;
|
||||||
mrCancel: CanProceed := False;
|
mrCancel: CanProceed := False;
|
||||||
@ -696,7 +749,7 @@ begin
|
|||||||
if not SessionFocused then begin
|
if not SessionFocused then begin
|
||||||
PageControlDetails.Visible := False;
|
PageControlDetails.Visible := False;
|
||||||
lblHelp.Visible := True;
|
lblHelp.Visible := True;
|
||||||
if FSessionNames.Count = 0 then
|
if FSessions.Count = 0 then
|
||||||
lblHelp.Caption := 'New here? In order to connect to a MySQL server, you have to create a so called '+
|
lblHelp.Caption := 'New here? In order to connect to a MySQL server, you have to create a so called '+
|
||||||
'"session" at first. Just click the "New" button on the bottom left to create your first session.'+CRLF+CRLF+
|
'"session" at first. Just click the "New" button on the bottom left to create your first session.'+CRLF+CRLF+
|
||||||
'Give it a friendly name (e.g. "Local DB server") so you''ll recall it the next time you start '+APPNAME+'.'
|
'Give it a friendly name (e.g. "Local DB server") so you''ll recall it the next time you start '+APPNAME+'.'
|
||||||
|
@ -272,7 +272,7 @@ begin
|
|||||||
AllDatabases[i] := editDBname.Text
|
AllDatabases[i] := editDBname.Text
|
||||||
else
|
else
|
||||||
AllDatabases.Add(editDBname.Text);
|
AllDatabases.Add(editDBname.Text);
|
||||||
OpenRegistry(FConnection.SessionName);
|
OpenRegistry(FConnection.Parameters.SessionName);
|
||||||
FConnection.Parameters.AllDatabasesStr := ImplodeStr(';', AllDatabases);
|
FConnection.Parameters.AllDatabasesStr := ImplodeStr(';', AllDatabases);
|
||||||
MainReg.WriteString(REGNAME_DATABASES, FConnection.Parameters.AllDatabasesStr);
|
MainReg.WriteString(REGNAME_DATABASES, FConnection.Parameters.AllDatabasesStr);
|
||||||
end;
|
end;
|
||||||
|
@ -308,7 +308,7 @@ type
|
|||||||
strict private
|
strict private
|
||||||
FNetType: TNetType;
|
FNetType: TNetType;
|
||||||
FHostname, FUsername, FPassword, FAllDatabases, FStartupScriptFilename,
|
FHostname, FUsername, FPassword, FAllDatabases, FStartupScriptFilename,
|
||||||
FSSLPrivateKey, FSSLCertificate, FSSLCACertificate,
|
FSessionName, FSSLPrivateKey, FSSLCertificate, FSSLCACertificate,
|
||||||
FSSHHost, FSSHUser, FSSHPassword, FSSHPlinkExe, FSSHPrivateKey: String;
|
FSSHHost, FSSHUser, FSSHPassword, FSSHPlinkExe, FSSHPrivateKey: String;
|
||||||
FPort, FSSHPort, FSSHLocalPort, FSSHTimeout: Integer;
|
FPort, FSSHPort, FSSHLocalPort, FSSHTimeout: Integer;
|
||||||
FLoginPrompt, FCompressed: Boolean;
|
FLoginPrompt, FCompressed: Boolean;
|
||||||
@ -323,6 +323,7 @@ type
|
|||||||
published
|
published
|
||||||
property NetType: TNetType read FNetType write FNetType;
|
property NetType: TNetType read FNetType write FNetType;
|
||||||
property NetTypeGroup: TNetTypeGroup read GetNetTypeGroup;
|
property NetTypeGroup: TNetTypeGroup read GetNetTypeGroup;
|
||||||
|
property SessionName: String read FSessionName write FSessionName;
|
||||||
property Hostname: String read FHostname write FHostname;
|
property Hostname: String read FHostname write FHostname;
|
||||||
property Port: Integer read FPort write FPort;
|
property Port: Integer read FPort write FPort;
|
||||||
property Username: String read FUsername write FUsername;
|
property Username: String read FUsername write FUsername;
|
||||||
@ -343,6 +344,7 @@ type
|
|||||||
property SSLCertificate: String read FSSLCertificate write FSSLCertificate;
|
property SSLCertificate: String read FSSLCertificate write FSSLCertificate;
|
||||||
property SSLCACertificate: String read FSSLCACertificate write FSSLCACertificate;
|
property SSLCACertificate: String read FSSLCACertificate write FSSLCACertificate;
|
||||||
end;
|
end;
|
||||||
|
PConnectionParameters = ^TConnectionParameters;
|
||||||
|
|
||||||
|
|
||||||
{ TDBConnection }
|
{ TDBConnection }
|
||||||
@ -357,7 +359,6 @@ type
|
|||||||
FActive: Boolean;
|
FActive: Boolean;
|
||||||
FConnectionStarted: Integer;
|
FConnectionStarted: Integer;
|
||||||
FServerStarted: Integer;
|
FServerStarted: Integer;
|
||||||
FSessionName: String;
|
|
||||||
FParameters: TConnectionParameters;
|
FParameters: TConnectionParameters;
|
||||||
FLoginPromptDone: Boolean;
|
FLoginPromptDone: Boolean;
|
||||||
FDatabase: String;
|
FDatabase: String;
|
||||||
@ -445,7 +446,6 @@ type
|
|||||||
var Deterministic: Boolean; var Definer, Returns, DataAccess, Security, Comment, Body: String);
|
var Deterministic: Boolean; var Definer, Returns, DataAccess, Security, Comment, Body: String);
|
||||||
function GetDatatypeByName(Datatype: String): TDBDatatype;
|
function GetDatatypeByName(Datatype: String): TDBDatatype;
|
||||||
function ApplyLimitClause(QueryType, QueryBody: String; Limit, Offset: Cardinal): String;
|
function ApplyLimitClause(QueryType, QueryBody: String; Limit, Offset: Cardinal): String;
|
||||||
property SessionName: String read FSessionName write FSessionName;
|
|
||||||
property Parameters: TConnectionParameters read FParameters write FParameters;
|
property Parameters: TConnectionParameters read FParameters write FParameters;
|
||||||
property ThreadId: Cardinal read GetThreadId;
|
property ThreadId: Cardinal read GetThreadId;
|
||||||
property ConnectionUptime: Integer read GetConnectionUptime;
|
property ConnectionUptime: Integer read GetConnectionUptime;
|
||||||
@ -805,7 +805,6 @@ end;
|
|||||||
constructor TDBConnection.Create(AOwner: TComponent);
|
constructor TDBConnection.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
FSessionName := 'Unnamed';
|
|
||||||
FParameters := TConnectionParameters.Create;
|
FParameters := TConnectionParameters.Create;
|
||||||
FRowsFound := 0;
|
FRowsFound := 0;
|
||||||
FRowsAffected := 0;
|
FRowsAffected := 0;
|
||||||
|
@ -2691,6 +2691,7 @@ begin
|
|||||||
raise Exception.Create('Error: Session "'+Session+'" not found in registry.')
|
raise Exception.Create('Error: Session "'+Session+'" not found in registry.')
|
||||||
else begin
|
else begin
|
||||||
Result := TConnectionParameters.Create;
|
Result := TConnectionParameters.Create;
|
||||||
|
Result.SessionName := Session;
|
||||||
Result.NetType := TNetType(GetRegValue(REGNAME_NETTYPE, Integer(ntMySQL_TCPIP), Session));
|
Result.NetType := TNetType(GetRegValue(REGNAME_NETTYPE, Integer(ntMySQL_TCPIP), Session));
|
||||||
Result.Hostname := GetRegValue(REGNAME_HOST, '', Session);
|
Result.Hostname := GetRegValue(REGNAME_HOST, '', Session);
|
||||||
Result.Username := GetRegValue(REGNAME_USER, '', Session);
|
Result.Username := GetRegValue(REGNAME_USER, '', Session);
|
||||||
|
@ -80,7 +80,7 @@ uses main, helpers;
|
|||||||
procedure TfrmInsertFiles.FormShow(Sender: TObject);
|
procedure TfrmInsertFiles.FormShow(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
FConnection := Mainform.ActiveConnection;
|
FConnection := Mainform.ActiveConnection;
|
||||||
Caption := FConnection.SessionName + ' - Insert files into table ...';
|
Caption := FConnection.Parameters.SessionName + ' - Insert files into table ...';
|
||||||
ComboBoxDBs.Items.Clear;
|
ComboBoxDBs.Items.Clear;
|
||||||
ComboBoxDBs.Items.Assign(FConnection.AllDatabases);
|
ComboBoxDBs.Items.Assign(FConnection.AllDatabases);
|
||||||
ComboBoxDBs.ItemIndex := ComboBoxDBs.Items.IndexOf(FConnection.Database);
|
ComboBoxDBs.ItemIndex := ComboBoxDBs.Items.IndexOf(FConnection.Database);
|
||||||
|
@ -865,7 +865,6 @@ type
|
|||||||
FTreeRefreshInProgress: Boolean;
|
FTreeRefreshInProgress: Boolean;
|
||||||
FCmdlineFilenames: TStringlist;
|
FCmdlineFilenames: TStringlist;
|
||||||
FCmdlineConnectionParams: TConnectionParameters;
|
FCmdlineConnectionParams: TConnectionParameters;
|
||||||
FCmdlineSessionName: String;
|
|
||||||
FSearchReplaceExecuted: Boolean;
|
FSearchReplaceExecuted: Boolean;
|
||||||
FDataGridColumnWidthsCustomized: Boolean;
|
FDataGridColumnWidthsCustomized: Boolean;
|
||||||
FSnippetFilenames: TStringList;
|
FSnippetFilenames: TStringList;
|
||||||
@ -998,8 +997,7 @@ type
|
|||||||
procedure PopupQueryLoadRemoveAbsentFiles(Sender: TObject);
|
procedure PopupQueryLoadRemoveAbsentFiles(Sender: TObject);
|
||||||
procedure PopupQueryLoadRemoveAllFiles(Sender: TObject);
|
procedure PopupQueryLoadRemoveAllFiles(Sender: TObject);
|
||||||
procedure SessionConnect(Sender: TObject);
|
procedure SessionConnect(Sender: TObject);
|
||||||
function InitConnection(Params: TConnectionParameters; Session: String;
|
function InitConnection(Params: TConnectionParameters; ActivateMe: Boolean; var Connection: TDBConnection): Boolean;
|
||||||
ActivateMe: Boolean; var Connection: TDBConnection): Boolean;
|
|
||||||
procedure ConnectionsNotify(Sender: TObject; const Item: TDBConnection; Action: TCollectionNotification);
|
procedure ConnectionsNotify(Sender: TObject; const Item: TDBConnection; Action: TCollectionNotification);
|
||||||
function ActiveGrid: TVirtualStringTree;
|
function ActiveGrid: TVirtualStringTree;
|
||||||
function GridResult(Grid: TBaseVirtualTree): TDBQuery;
|
function GridResult(Grid: TBaseVirtualTree): TDBQuery;
|
||||||
@ -1221,11 +1219,11 @@ begin
|
|||||||
OpenRegistry;
|
OpenRegistry;
|
||||||
OpenSessions := '';
|
OpenSessions := '';
|
||||||
for Connection in Connections do
|
for Connection in Connections do
|
||||||
OpenSessions := OpenSessions + Connection.SessionName + DELIM;
|
OpenSessions := OpenSessions + Connection.Parameters.SessionName + DELIM;
|
||||||
Delete(OpenSessions, Length(OpenSessions)-Length(DELIM)+1, Length(DELIM));
|
Delete(OpenSessions, Length(OpenSessions)-Length(DELIM)+1, Length(DELIM));
|
||||||
MainReg.WriteString(REGNAME_LASTSESSIONS, OpenSessions);
|
MainReg.WriteString(REGNAME_LASTSESSIONS, OpenSessions);
|
||||||
if Assigned(ActiveConnection) then
|
if Assigned(ActiveConnection) then
|
||||||
MainReg.WriteString(REGNAME_LASTACTIVESESSION, ActiveConnection.SessionName);
|
MainReg.WriteString(REGNAME_LASTACTIVESESSION, ActiveConnection.Parameters.SessionName);
|
||||||
|
|
||||||
// Close database connections
|
// Close database connections
|
||||||
Connections.Clear;
|
Connections.Clear;
|
||||||
@ -1687,7 +1685,7 @@ begin
|
|||||||
ParseCommandLineParameters(CmdlineParameters);
|
ParseCommandLineParameters(CmdlineParameters);
|
||||||
if Assigned(FCmdlineConnectionParams) then begin
|
if Assigned(FCmdlineConnectionParams) then begin
|
||||||
// Minimal parameter for command line mode is hostname
|
// Minimal parameter for command line mode is hostname
|
||||||
Connected := InitConnection(FCmdlineConnectionParams, FCmdlineSessionName, True, Connection);
|
Connected := InitConnection(FCmdlineConnectionParams, True, Connection);
|
||||||
end else if GetRegValue(REGNAME_AUTORECONNECT, DEFAULT_AUTORECONNECT) then begin
|
end else if GetRegValue(REGNAME_AUTORECONNECT, DEFAULT_AUTORECONNECT) then begin
|
||||||
// Auto connection via preference setting
|
// Auto connection via preference setting
|
||||||
// Do not autoconnect if we're in commandline mode and the connection was not successful
|
// Do not autoconnect if we're in commandline mode and the connection was not successful
|
||||||
@ -1703,7 +1701,7 @@ begin
|
|||||||
for i:=0 to LastSessions.Count-1 do begin
|
for i:=0 to LastSessions.Count-1 do begin
|
||||||
try
|
try
|
||||||
LoadedParams := LoadConnectionParams(LastSessions[i]);
|
LoadedParams := LoadConnectionParams(LastSessions[i]);
|
||||||
if InitConnection(LoadedParams, LastSessions[i], LastActiveSession=LastSessions[i], Connection) then
|
if InitConnection(LoadedParams, LastActiveSession=LastSessions[i], Connection) then
|
||||||
Connected := True;
|
Connected := True;
|
||||||
except on E:Exception do
|
except on E:Exception do
|
||||||
MessageDlg(E.Message, mtError, [mbOK], 0);
|
MessageDlg(E.Message, mtError, [mbOK], 0);
|
||||||
@ -1740,7 +1738,7 @@ end;
|
|||||||
procedure TMainForm.ParseCommandLineParameters(Parameters: TStringlist);
|
procedure TMainForm.ParseCommandLineParameters(Parameters: TStringlist);
|
||||||
var
|
var
|
||||||
rx: TRegExpr;
|
rx: TRegExpr;
|
||||||
AllParams, Host, User, Pass, Socket: String;
|
AllParams, SessName, Host, User, Pass, Socket: String;
|
||||||
i, Port: Integer;
|
i, Port: Integer;
|
||||||
|
|
||||||
function GetParamValue(ShortName, LongName: String): String;
|
function GetParamValue(ShortName, LongName: String): String;
|
||||||
@ -1756,22 +1754,22 @@ begin
|
|||||||
if not Assigned(FCmdlineFilenames) then
|
if not Assigned(FCmdlineFilenames) then
|
||||||
FCmdlineFilenames := TStringlist.Create;
|
FCmdlineFilenames := TStringlist.Create;
|
||||||
FCmdlineFilenames.Clear;
|
FCmdlineFilenames.Clear;
|
||||||
FCmdlineSessionName := '';
|
SessName := '';
|
||||||
FreeAndNil(FCmdlineConnectionParams);
|
FreeAndNil(FCmdlineConnectionParams);
|
||||||
|
|
||||||
// Prepend a space, so the regular expression can request a mandantory space
|
// Prepend a space, so the regular expression can request a mandantory space
|
||||||
// before each param name including the first one
|
// before each param name including the first one
|
||||||
AllParams := ' ' + ImplodeStr(' ', Parameters);
|
AllParams := ' ' + ImplodeStr(' ', Parameters);
|
||||||
rx := TRegExpr.Create;
|
rx := TRegExpr.Create;
|
||||||
FCmdlineSessionName := GetParamValue('d', 'description');
|
SessName := GetParamValue('d', 'description');
|
||||||
if FCmdlineSessionName <> '' then begin
|
if SessName <> '' then begin
|
||||||
try
|
try
|
||||||
FCmdlineConnectionParams := LoadConnectionParams(FCmdlineSessionName);
|
FCmdlineConnectionParams := LoadConnectionParams(SessName);
|
||||||
except
|
except
|
||||||
on E:Exception do begin
|
on E:Exception do begin
|
||||||
// Session params not found in registry
|
// Session params not found in registry
|
||||||
LogSQL(E.Message);
|
LogSQL(E.Message);
|
||||||
FCmdlineSessionName := '';
|
SessName := '';
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1787,8 +1785,10 @@ begin
|
|||||||
// Leave out support for startup script, seems reasonable for command line connecting
|
// Leave out support for startup script, seems reasonable for command line connecting
|
||||||
|
|
||||||
if (Host <> '') or (User <> '') or (Pass <> '') or (Port <> 0) or (Socket <> '') then begin
|
if (Host <> '') or (User <> '') or (Pass <> '') or (Port <> 0) or (Socket <> '') then begin
|
||||||
if not Assigned(FCmdlineConnectionParams) then
|
if not Assigned(FCmdlineConnectionParams) then begin
|
||||||
FCmdlineConnectionParams := TConnectionParameters.Create;
|
FCmdlineConnectionParams := TConnectionParameters.Create;
|
||||||
|
FCmdlineConnectionParams.SessionName := SessName;
|
||||||
|
end;
|
||||||
if Host <> '' then FCmdlineConnectionParams.Hostname := Host;
|
if Host <> '' then FCmdlineConnectionParams.Hostname := Host;
|
||||||
if User <> '' then FCmdlineConnectionParams.Username := User;
|
if User <> '' then FCmdlineConnectionParams.Username := User;
|
||||||
if Pass <> '' then FCmdlineConnectionParams.Password := Pass;
|
if Pass <> '' then FCmdlineConnectionParams.Password := Pass;
|
||||||
@ -1798,8 +1798,8 @@ begin
|
|||||||
FCmdlineConnectionParams.NetType := ntMySQL_NamedPipe;
|
FCmdlineConnectionParams.NetType := ntMySQL_NamedPipe;
|
||||||
end;
|
end;
|
||||||
// Ensure we have a session name to pass to InitConnection
|
// Ensure we have a session name to pass to InitConnection
|
||||||
if (FCmdlineSessionName = '') and (FCmdlineConnectionParams.Hostname <> '') then
|
if (FCmdlineConnectionParams.SessionName = '') and (FCmdlineConnectionParams.Hostname <> '') then
|
||||||
FCmdlineSessionName := FCmdlineConnectionParams.Hostname;
|
FCmdlineConnectionParams.SessionName := FCmdlineConnectionParams.Hostname;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Check for valid filename(s) in parameters
|
// Check for valid filename(s) in parameters
|
||||||
@ -1871,7 +1871,7 @@ begin
|
|||||||
RefreshHelperNode(HELPERNODE_COLUMNS);}
|
RefreshHelperNode(HELPERNODE_COLUMNS);}
|
||||||
|
|
||||||
// Last chance to access connection related properties before disconnecting
|
// Last chance to access connection related properties before disconnecting
|
||||||
OpenRegistry(Item.SessionName);
|
OpenRegistry(Item.Parameters.SessionName);
|
||||||
MainReg.WriteString(REGNAME_LASTUSEDDB, Item.Database);
|
MainReg.WriteString(REGNAME_LASTUSEDDB, Item.Database);
|
||||||
|
|
||||||
// Disconnect
|
// Disconnect
|
||||||
@ -2070,7 +2070,7 @@ begin
|
|||||||
item.OnClick := SessionConnect;
|
item.OnClick := SessionConnect;
|
||||||
item.ImageIndex := 37;
|
item.ImageIndex := 37;
|
||||||
for Connection in Connections do begin
|
for Connection in Connections do begin
|
||||||
if SessionNames[i] = Connection.SessionName then begin
|
if SessionNames[i] = Connection.Parameters.SessionName then begin
|
||||||
item.Checked := True;
|
item.Checked := True;
|
||||||
item.ImageIndex := -1;
|
item.ImageIndex := -1;
|
||||||
break;
|
break;
|
||||||
@ -2099,7 +2099,7 @@ begin
|
|||||||
menuConnectTo.Delete(i);
|
menuConnectTo.Delete(i);
|
||||||
ConnectedSessions := TStringList.Create;
|
ConnectedSessions := TStringList.Create;
|
||||||
for i:=0 to Connections.Count-1 do
|
for i:=0 to Connections.Count-1 do
|
||||||
ConnectedSessions.Add(Connections[i].SessionName);
|
ConnectedSessions.Add(Connections[i].Parameters.SessionName);
|
||||||
SessionNames := TStringList.Create;
|
SessionNames := TStringList.Create;
|
||||||
MainReg.GetKeyNames(SessionNames);
|
MainReg.GetKeyNames(SessionNames);
|
||||||
for i:=0 to SessionNames.Count-1 do begin
|
for i:=0 to SessionNames.Count-1 do begin
|
||||||
@ -2774,7 +2774,7 @@ begin
|
|||||||
for i:=High(FTreeClickHistory) downto Low(FTreeClickHistory) do begin
|
for i:=High(FTreeClickHistory) downto Low(FTreeClickHistory) do begin
|
||||||
if FTreeClickHistory[i] <> nil then begin
|
if FTreeClickHistory[i] <> nil then begin
|
||||||
DBObj := DBtree.GetNodeData(FTreeClickHistory[i]);
|
DBObj := DBtree.GetNodeData(FTreeClickHistory[i]);
|
||||||
if DBObj.Connection.SessionName = Session then begin
|
if DBObj.Connection.Parameters.SessionName = Session then begin
|
||||||
Node := FTreeClickHistory[i];
|
Node := FTreeClickHistory[i];
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
@ -2785,7 +2785,7 @@ begin
|
|||||||
SessionNode := DBtree.GetFirstChild(nil);
|
SessionNode := DBtree.GetFirstChild(nil);
|
||||||
while Assigned(SessionNode) do begin
|
while Assigned(SessionNode) do begin
|
||||||
DBObj := DBtree.GetNodeData(SessionNode);
|
DBObj := DBtree.GetNodeData(SessionNode);
|
||||||
if DBObj.Connection.SessionName = Session then begin
|
if DBObj.Connection.Parameters.SessionName = Session then begin
|
||||||
Node := SessionNode;
|
Node := SessionNode;
|
||||||
end;
|
end;
|
||||||
SessionNode := DBtree.GetNextSibling(SessionNode);
|
SessionNode := DBtree.GetNextSibling(SessionNode);
|
||||||
@ -2796,7 +2796,7 @@ begin
|
|||||||
SelectNode(DBtree, Node)
|
SelectNode(DBtree, Node)
|
||||||
else begin
|
else begin
|
||||||
Params := LoadConnectionParams(Session);
|
Params := LoadConnectionParams(Session);
|
||||||
InitConnection(Params, Session, True, Connection);
|
InitConnection(Params, True, Connection);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2805,8 +2805,7 @@ end;
|
|||||||
Receive connection parameters and create a connection tree node
|
Receive connection parameters and create a connection tree node
|
||||||
Paremeters are either sent by connection-form or by commandline.
|
Paremeters are either sent by connection-form or by commandline.
|
||||||
}
|
}
|
||||||
function TMainform.InitConnection(Params: TConnectionParameters; Session: String;
|
function TMainform.InitConnection(Params: TConnectionParameters; ActivateMe: Boolean; var Connection: TDBConnection): Boolean;
|
||||||
ActivateMe: Boolean; var Connection: TDBConnection): Boolean;
|
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
SessionExists, RestoreLastActiveDatabase: Boolean;
|
SessionExists, RestoreLastActiveDatabase: Boolean;
|
||||||
@ -2820,7 +2819,6 @@ begin
|
|||||||
Connection.OnDBObjectsCleared := DBObjectsCleared;
|
Connection.OnDBObjectsCleared := DBObjectsCleared;
|
||||||
Connection.OnDatabaseChanged := DatabaseChanged;
|
Connection.OnDatabaseChanged := DatabaseChanged;
|
||||||
Connection.ObjectNamesInSelectedDB := SynSQLSyn1.TableNames;
|
Connection.ObjectNamesInSelectedDB := SynSQLSyn1.TableNames;
|
||||||
Connection.SessionName := Session;
|
|
||||||
try
|
try
|
||||||
Connection.Active := True;
|
Connection.Active := True;
|
||||||
except
|
except
|
||||||
@ -2829,13 +2827,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// attempt to establish connection
|
// attempt to establish connection
|
||||||
SessionExists := MainReg.KeyExists(REGPATH + REGKEY_SESSIONS + Session);
|
SessionExists := MainReg.KeyExists(REGPATH + REGKEY_SESSIONS + Params.SessionName);
|
||||||
if not Connection.Active then begin
|
if not Connection.Active then begin
|
||||||
// attempt failed
|
// attempt failed
|
||||||
if SessionExists then begin
|
if SessionExists then begin
|
||||||
// Save "refused" counter
|
// Save "refused" counter
|
||||||
OpenRegistry(Session);
|
OpenRegistry(Params.SessionName);
|
||||||
MainReg.WriteInteger(REGNAME_REFUSEDCOUNT, GetRegValue(REGNAME_REFUSEDCOUNT, 0, Session)+1);
|
MainReg.WriteInteger(REGNAME_REFUSEDCOUNT, GetRegValue(REGNAME_REFUSEDCOUNT, 0, Params.SessionName)+1);
|
||||||
end;
|
end;
|
||||||
Result := False;
|
Result := False;
|
||||||
FreeAndNil(Connection);
|
FreeAndNil(Connection);
|
||||||
@ -2846,8 +2844,8 @@ begin
|
|||||||
|
|
||||||
if SessionExists then begin
|
if SessionExists then begin
|
||||||
// Save "connected" counter
|
// Save "connected" counter
|
||||||
OpenRegistry(Session);
|
OpenRegistry(Params.SessionName);
|
||||||
MainReg.WriteInteger(REGNAME_CONNECTCOUNT, GetRegValue(REGNAME_CONNECTCOUNT, 0, Session)+1);
|
MainReg.WriteInteger(REGNAME_CONNECTCOUNT, GetRegValue(REGNAME_CONNECTCOUNT, 0, Params.SessionName)+1);
|
||||||
// Save server version
|
// Save server version
|
||||||
Mainreg.WriteInteger(REGNAME_SERVERVERSION, Connection.ServerVersionInt);
|
Mainreg.WriteInteger(REGNAME_SERVERVERSION, Connection.ServerVersionInt);
|
||||||
Mainreg.WriteString(REGNAME_LASTCONNECT, DateTimeToStr(Now));
|
Mainreg.WriteString(REGNAME_LASTCONNECT, DateTimeToStr(Now));
|
||||||
@ -2856,7 +2854,7 @@ begin
|
|||||||
if ActivateMe then begin
|
if ActivateMe then begin
|
||||||
// Set focus on last uses db. If not wanted or db is gone, go to root node at least
|
// Set focus on last uses db. If not wanted or db is gone, go to root node at least
|
||||||
RestoreLastActiveDatabase := GetRegValue(REGNAME_RESTORELASTUSEDDB, DEFAULT_RESTORELASTUSEDDB);
|
RestoreLastActiveDatabase := GetRegValue(REGNAME_RESTORELASTUSEDDB, DEFAULT_RESTORELASTUSEDDB);
|
||||||
LastActiveDatabase := GetRegValue(REGNAME_LASTUSEDDB, '', Session);
|
LastActiveDatabase := GetRegValue(REGNAME_LASTUSEDDB, '', Params.SessionName);
|
||||||
if RestoreLastActiveDatabase and (Connection.AllDatabases.IndexOf(LastActiveDatabase) >- 1) then begin
|
if RestoreLastActiveDatabase and (Connection.AllDatabases.IndexOf(LastActiveDatabase) >- 1) then begin
|
||||||
SetActiveDatabase(LastActiveDatabase, Connection);
|
SetActiveDatabase(LastActiveDatabase, Connection);
|
||||||
DBNode := FindDBNode(DBtree, LastActiveDatabase);
|
DBNode := FindDBNode(DBtree, LastActiveDatabase);
|
||||||
@ -3741,7 +3739,7 @@ begin
|
|||||||
cs.Dialog.Color := DBtree.Color;
|
cs.Dialog.Color := DBtree.Color;
|
||||||
if cs.Execute then begin
|
if cs.Execute then begin
|
||||||
DBtree.Color := cs.Dialog.Color;
|
DBtree.Color := cs.Dialog.Color;
|
||||||
OpenRegistry(ActiveConnection.SessionName);
|
OpenRegistry(ActiveConnection.Parameters.SessionName);
|
||||||
MainReg.WriteInteger(REGNAME_TREEBACKGROUND, cs.Dialog.Color);
|
MainReg.WriteInteger(REGNAME_TREEBACKGROUND, cs.Dialog.Color);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -3799,7 +3797,7 @@ begin
|
|||||||
try
|
try
|
||||||
Sess := '';
|
Sess := '';
|
||||||
if Assigned(Connection) then
|
if Assigned(Connection) then
|
||||||
Sess := Connection.SessionName;
|
Sess := Connection.Parameters.SessionName;
|
||||||
WriteLn(FileHandleSessionLog, Format('/* %s [%s] */ %s', [DateTimeToStr(Now), Sess, msg]));
|
WriteLn(FileHandleSessionLog, Format('/* %s [%s] */ %s', [DateTimeToStr(Now), Sess, msg]));
|
||||||
except
|
except
|
||||||
on E:Exception do begin
|
on E:Exception do begin
|
||||||
@ -6631,7 +6629,7 @@ begin
|
|||||||
DBObj := Sender.GetNodeData(Node);
|
DBObj := Sender.GetNodeData(Node);
|
||||||
case Column of
|
case Column of
|
||||||
0: case DBObj.NodeType of
|
0: case DBObj.NodeType of
|
||||||
lntNone: CellText := DBObj.Connection.SessionName;
|
lntNone: CellText := DBObj.Connection.Parameters.SessionName;
|
||||||
lntDb: CellText := DBObj.Database;
|
lntDb: CellText := DBObj.Database;
|
||||||
lntTable..lntEvent: CellText := DBObj.Name;
|
lntTable..lntEvent: CellText := DBObj.Name;
|
||||||
lntColumn: CellText := DBObj.Column;
|
lntColumn: CellText := DBObj.Column;
|
||||||
@ -6878,7 +6876,7 @@ begin
|
|||||||
TimerConnected.OnTimer(Sender);
|
TimerConnected.OnTimer(Sender);
|
||||||
TimerHostUptime.OnTimer(Sender);
|
TimerHostUptime.OnTimer(Sender);
|
||||||
DBObj.Connection.OnConnected(DBObj.Connection, DBObj.Connection.Database);
|
DBObj.Connection.OnConnected(DBObj.Connection, DBObj.Connection.Database);
|
||||||
DBTree.Color := GetRegValue(REGNAME_TREEBACKGROUND, clWindow, DBObj.Connection.SessionName);
|
DBTree.Color := GetRegValue(REGNAME_TREEBACKGROUND, clWindow, DBObj.Connection.Parameters.SessionName);
|
||||||
case DBObj.Connection.Parameters.NetTypeGroup of
|
case DBObj.Connection.Parameters.NetTypeGroup of
|
||||||
ngMySQL:
|
ngMySQL:
|
||||||
SynSQLSyn1.SQLDialect := sqlMySQL;
|
SynSQLSyn1.SQLDialect := sqlMySQL;
|
||||||
@ -7865,7 +7863,7 @@ end;
|
|||||||
function TMainForm.GetRegKeyTable: String;
|
function TMainForm.GetRegKeyTable: String;
|
||||||
begin
|
begin
|
||||||
// Return the slightly complex registry path to \Servers\ThisServer\curdb|curtable
|
// Return the slightly complex registry path to \Servers\ThisServer\curdb|curtable
|
||||||
Result := REGPATH + REGKEY_SESSIONS + ActiveDbObj.Connection.SessionName + '\' +
|
Result := REGPATH + REGKEY_SESSIONS + ActiveDbObj.Connection.Parameters.SessionName + '\' +
|
||||||
ActiveDatabase + DELIM + ActiveDbObj.Name;
|
ActiveDatabase + DELIM + ActiveDbObj.Name;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -8854,15 +8852,15 @@ begin
|
|||||||
Keys := TStringList.Create;
|
Keys := TStringList.Create;
|
||||||
if (Sender = btnClearFilters) or (Sender = menuClearFiltersTable) then begin
|
if (Sender = btnClearFilters) or (Sender = menuClearFiltersTable) then begin
|
||||||
Screen.Cursor := crHourGlass;
|
Screen.Cursor := crHourGlass;
|
||||||
OpenRegistry(ActiveDbObj.Connection.SessionName);
|
OpenRegistry(ActiveDbObj.Connection.Parameters.SessionName);
|
||||||
MainReg.GetKeyNames(Keys);
|
MainReg.GetKeyNames(Keys);
|
||||||
idx := Keys.IndexOf(ActiveDbObj.Database+'|'+ActiveDbObj.Name);
|
idx := Keys.IndexOf(ActiveDbObj.Database+'|'+ActiveDbObj.Name);
|
||||||
if idx > -1 then
|
if idx > -1 then
|
||||||
MainReg.DeleteKey(Keys[idx]);
|
MainReg.DeleteKey(Keys[idx]);
|
||||||
end else if Sender = menuClearFiltersSession then begin
|
end else if Sender = menuClearFiltersSession then begin
|
||||||
if MessageDlg('Remove all filter stuff for this session ('+ActiveDbObj.Connection.SessionName+') ?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin
|
if MessageDlg('Remove all filter stuff for this session ('+ActiveDbObj.Connection.Parameters.SessionName+') ?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin
|
||||||
Screen.Cursor := crHourGlass;
|
Screen.Cursor := crHourGlass;
|
||||||
OpenRegistry(ActiveDbObj.Connection.SessionName);
|
OpenRegistry(ActiveDbObj.Connection.Parameters.SessionName);
|
||||||
MainReg.GetKeyNames(Keys);
|
MainReg.GetKeyNames(Keys);
|
||||||
for idx:=0 to Keys.Count-1 do
|
for idx:=0 to Keys.Count-1 do
|
||||||
MainReg.DeleteKey(Keys[idx])
|
MainReg.DeleteKey(Keys[idx])
|
||||||
@ -9258,7 +9256,7 @@ begin
|
|||||||
// Set window caption and taskbar text
|
// Set window caption and taskbar text
|
||||||
Cap := '';
|
Cap := '';
|
||||||
if ActiveConnection <> nil then begin
|
if ActiveConnection <> nil then begin
|
||||||
Cap := Cap + ActiveConnection.SessionName;
|
Cap := Cap + ActiveConnection.Parameters.SessionName;
|
||||||
if ActiveDatabase <> '' then
|
if ActiveDatabase <> '' then
|
||||||
Cap := Cap + ' /' + ActiveDatabase;
|
Cap := Cap + ' /' + ActiveDatabase;
|
||||||
if Assigned(ActiveDbObj) and (ActiveDbObj.Name <> '') then
|
if Assigned(ActiveDbObj) and (ActiveDbObj.Name <> '') then
|
||||||
@ -9695,7 +9693,7 @@ begin
|
|||||||
QueryLoad(FCmdlineFilenames[i], True, True, nil);
|
QueryLoad(FCmdlineFilenames[i], True, True, nil);
|
||||||
end;
|
end;
|
||||||
if Assigned(FCmdlineConnectionParams) then
|
if Assigned(FCmdlineConnectionParams) then
|
||||||
InitConnection(FCmdlineConnectionParams, FCmdlineSessionName, True, Connection);
|
InitConnection(FCmdlineConnectionParams, True, Connection);
|
||||||
end else
|
end else
|
||||||
// Not the right message id
|
// Not the right message id
|
||||||
inherited;
|
inherited;
|
||||||
|
@ -284,7 +284,7 @@ begin
|
|||||||
MainReg.OpenKey(RegPath + REGKEY_SESSIONS, True);
|
MainReg.OpenKey(RegPath + REGKEY_SESSIONS, True);
|
||||||
MainReg.GetKeyNames(SessionNames);
|
MainReg.GetKeyNames(SessionNames);
|
||||||
for i:=0 to SessionNames.Count-1 do begin
|
for i:=0 to SessionNames.Count-1 do begin
|
||||||
if SessionNames[i] <> Mainform.ActiveConnection.SessionName then
|
if SessionNames[i] <> Mainform.ActiveConnection.Parameters.SessionName then
|
||||||
comboExportOutputType.Items.Add(OUTPUT_SERVER+SessionNames[i]);
|
comboExportOutputType.Items.Add(OUTPUT_SERVER+SessionNames[i]);
|
||||||
end;
|
end;
|
||||||
if (idx > -1) and (idx < comboExportOutputType.Items.Count) then
|
if (idx > -1) and (idx < comboExportOutputType.Items.Count) then
|
||||||
|
Reference in New Issue
Block a user