Skip to content
Permalink
Browse files

Define default values for port and username of all supported server t…

…ypes. Also, do not change them in the session manager, when user selects a different sub type of the same server.
  • Loading branch information...
ansgarbecker committed Jun 9, 2019
1 parent 5995a40 commit bda7b932d15ae2e20e310b6c3f2419c2d9b25583
Showing with 42 additions and 22 deletions.
  1. +2 −2 source/apphelpers.pas
  2. +14 −18 source/connections.pas
  3. +26 −2 source/dbconnection.pas
@@ -3519,11 +3519,11 @@ constructor TAppSettings.Create;
InitSetting(asSQLHelpPnlLeftWidth, 'SQLHelp_PnlLeftWidth', 150);
InitSetting(asSQLHelpPnlRightTopHeight, 'SQLHelp_PnlRightTopHeight', 150);
InitSetting(asHost, 'Host', 0, False, '127.0.0.1', True);
InitSetting(asUser, 'User', 0, False, 'root', True);
InitSetting(asUser, 'User', 0, False, '', True);
InitSetting(asPassword, 'Password', 0, False, '', True);
InitSetting(asWindowsAuth, 'WindowsAuth', 0, False, '', True);
InitSetting(asLoginPrompt, 'LoginPrompt', 0, False, '', True);
InitSetting(asPort, 'Port', 0, False, '3306', True);
InitSetting(asPort, 'Port', 0, False, '', True);
InitSetting(asPlinkExecutable, 'PlinkExecutable', 0, False, '');
InitSetting(asSSHtunnelHost, 'SSHtunnelHost', 0, False, '', True);
InitSetting(asSSHtunnelHostPort, 'SSHtunnelHostPort', 22, False, '', True);
@@ -178,6 +178,7 @@ Tconnform = class(TFormWithSizeGrip)
FSettingsImportWaitTime: Cardinal;
FPopupDatabases: TPopupMenu;
FButtonAnimationStep: Integer;
FLastSelectedNetTypeGroup: TNetTypeGroup;
procedure RefreshSessions(ParentNode: PVirtualNode);
function SelectedSessionPath: String;
function CurrentParams: TConnectionParameters;
@@ -1062,25 +1063,20 @@ procedure Tconnform.comboNetTypeChange(Sender: TObject);
Params: TConnectionParameters;
begin
// Autoset default connection data as long as that was not modified by user
// and only if net type group has now changed
if not FLoaded then
Exit;

Params := CurrentParams;
if (not editPort.Modified) and (FLoaded) then
case Params.NetTypeGroup of
ngMySQL:
begin
updownPort.Position := MakeInt(AppSettings.GetDefaultString(asPort));
editUsername.Text := AppSettings.GetDefaultString(asUser)
end;
ngMSSQL:
begin
updownPort.Position := 1433;
editUsername.Text := AppSettings.GetDefaultString(asUser)
end;
ngPgSQL:
begin
updownPort.Position := 5432;
editUsername.Text := 'postgres';
end;
end;

if Params.NetTypeGroup <> FLastSelectedNetTypeGroup then begin
if not editPort.Modified then
updownPort.Position := Params.DefaultPort;
if not editUsername.Modified then
editUsername.Text := Params.DefaultUsername;
end;

FLastSelectedNetTypeGroup := Params.NetTypeGroup;
FreeAndNil(Params);
Modification(Sender);
end;
@@ -242,6 +242,8 @@ TConnectionParameters = class(TObject)
function IsAzure: Boolean;
function IsMemSQL: Boolean;
property ImageIndex: Integer read GetImageIndex;
function DefaultPort: Integer;
function DefaultUsername: String;
published
property IsFolder: Boolean read FIsFolder write FIsFolder;
property NetType: TNetType read FNetType write FNetType;
@@ -1125,9 +1127,9 @@ constructor TConnectionParameters.Create;
FHostname := AppSettings.GetDefaultString(asHost);
FLoginPrompt := AppSettings.GetDefaultBool(asLoginPrompt);
FWindowsAuth := AppSettings.GetDefaultBool(asWindowsAuth);
FUsername := AppSettings.GetDefaultString(asUser);
FUsername := DefaultUsername;
FPassword := AppSettings.GetDefaultString(asPassword);
FPort := MakeInt(AppSettings.GetDefaultString(asPort));
FPort := DefaultPort;
FCompressed := AppSettings.GetDefaultBool(asCompressed);
FAllDatabases := AppSettings.GetDefaultString(asDatabases);
FComment := AppSettings.GetDefaultString(asComment);
@@ -1466,6 +1468,28 @@ function TConnectionParameters.GetImageIndex: Integer;
end;


function TConnectionParameters.DefaultPort: Integer;
begin
case NetTypeGroup of
ngMySQL: Result := 3306;
ngMSSQL: Result := 1433;
ngPgSQL: Result := 5432;
else Result := 0;
end;
end;


function TConnectionParameters.DefaultUsername: String;
begin
case NetTypeGroup of
ngMySQL: Result := 'root';
ngMSSQL: Result := 'sa';
ngPgSQL: Result := 'postgres';
else Result := '';
end;
end;


function TConnectionParameters.GetSessionName: String;
var
LastBackSlash: Integer;

0 comments on commit bda7b93

Please sign in to comment.
You can’t perform that action at this time.