From df18c98af8f585f2d357fb8c072e81aa79facb48 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sat, 5 Mar 2016 18:36:44 +0000 Subject: [PATCH] Make keep-alive-interval customizable in "Advanced" tab on session manager. See http://www.heidisql.com/forum.php?t=20829 --- out/locale/en/LC_MESSAGES/default.po | 5 ++++- source/connections.dfm | 29 ++++++++++++++++++++++++++-- source/connections.pas | 7 +++++++ source/dbconnection.pas | 11 ++++++++--- source/helpers.pas | 3 ++- 5 files changed, 48 insertions(+), 7 deletions(-) diff --git a/out/locale/en/LC_MESSAGES/default.po b/out/locale/en/LC_MESSAGES/default.po index cc5038c5..7103be55 100644 --- a/out/locale/en/LC_MESSAGES/default.po +++ b/out/locale/en/LC_MESSAGES/default.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: HeidiSQL\n" "POT-Creation-Date: 2012-11-05 21:40\n" -"PO-Revision-Date: 2016-01-23 10:52+0100\n" +"PO-Revision-Date: 2016-03-05 19:33+0100\n" "Last-Translator: Ansgar Becker \n" "Language-Team: English (http://www.transifex.com/projects/p/heidisql/" "language/en/)\n" @@ -5869,6 +5869,9 @@ msgstr "GUID without braces" msgid "Query timeout:" msgstr "Query timeout:" +msgid "Ping every X seconds:" +msgstr "Ping every X seconds:" + msgid "Connection attempts:" msgstr "Connection attempts:" diff --git a/source/connections.dfm b/source/connections.dfm index 02045ec8..0221b378 100644 --- a/source/connections.dfm +++ b/source/connections.dfm @@ -628,6 +628,13 @@ object connform: Tconnform Height = 13 Caption = 'SSL cipher:' end + object lblKeepAlive: TLabel + Left = 3 + Top = 224 + Width = 106 + Height = 13 + Caption = 'Ping every X seconds:' + end object editSSLPrivateKey: TButtonedEdit Left = 120 Top = 36 @@ -685,7 +692,7 @@ object connform: Tconnform end object chkLocalTimeZone: TCheckBox Left = 120 - Top = 224 + Top = 246 Width = 294 Height = 17 Hint = @@ -712,7 +719,7 @@ object connform: Tconnform end object chkFullTableStatus: TCheckBox Left = 120 - Top = 247 + Top = 269 Width = 294 Height = 17 Hint = @@ -753,6 +760,24 @@ object connform: Tconnform TextHint = 'List of permissible ciphers to use for SSL encryption' OnChange = Modification end + object editKeepAlive: TEdit + Left = 120 + Top = 219 + Width = 90 + Height = 21 + TabOrder = 10 + Text = '0' + OnChange = Modification + end + object updownKeepAlive: TUpDown + Left = 210 + Top = 219 + Width = 16 + Height = 21 + Associate = editKeepAlive + Max = 86400 + TabOrder = 11 + end end object tabStatistics: TTabSheet Caption = 'Statistics' diff --git a/source/connections.pas b/source/connections.pas index ddbd5b2c..64b1325f 100644 --- a/source/connections.pas +++ b/source/connections.pas @@ -109,6 +109,9 @@ type menuRename: TMenuItem; lblSSLcipher: TLabel; editSSLcipher: TEdit; + lblKeepAlive: TLabel; + editKeepAlive: TEdit; + updownKeepAlive: TUpDown; procedure FormCreate(Sender: TObject); procedure btnOpenClick(Sender: TObject); procedure FormShow(Sender: TObject); @@ -347,6 +350,7 @@ begin Sess.NetType := TNetType(comboNetType.ItemIndex); Sess.Compressed := chkCompressed.Checked; Sess.QueryTimeout := updownQueryTimeout.Position; + Sess.KeepAlive := updownKeepAlive.Position; Sess.LocalTimeZone := chkLocalTimeZone.Checked; Sess.FullTableStatus := chkFullTableStatus.Checked; Sess.AllDatabasesStr := editDatabases.Text; @@ -559,6 +563,7 @@ begin Result.StartupScriptFilename := editStartupScript.Text; Result.Compressed := chkCompressed.Checked; Result.QueryTimeout := updownQueryTimeout.Position; + Result.KeepAlive := updownKeepAlive.Position; Result.LocalTimeZone := chkLocalTimeZone.Checked; Result.FullTableStatus := chkFullTableStatus.Checked; end; @@ -800,6 +805,7 @@ begin updownPort.Position := Sess.Port; chkCompressed.Checked := Sess.Compressed; updownQueryTimeout.Position := Sess.QueryTimeout; + updownKeepAlive.Position := Sess.KeepAlive; chkLocalTimeZone.Checked := Sess.LocalTimeZone; chkFullTableStatus.Checked := Sess.FullTableStatus; editDatabases.Text := Sess.AllDatabasesStr; @@ -1058,6 +1064,7 @@ begin or (Sess.Port <> updownPort.Position) or (Sess.Compressed <> chkCompressed.Checked) or (Sess.QueryTimeout <> updownQueryTimeout.Position) + or (Sess.KeepAlive <> updownKeepAlive.Position) or (Sess.LocalTimeZone <> chkLocalTimeZone.Checked) or (Sess.FullTableStatus <> chkFullTableStatus.Checked) or (Sess.NetType <> TNetType(comboNetType.ItemIndex)) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index b4bc78f0..b9b214b5 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -207,7 +207,7 @@ type FHostname, FUsername, FPassword, FAllDatabases, FComment, FStartupScriptFilename, FSessionPath, FSSLPrivateKey, FSSLCertificate, FSSLCACertificate, FSSLCipher, FServerVersion, FSSHHost, FSSHUser, FSSHPassword, FSSHPlinkExe, FSSHPrivateKey: String; - FPort, FSSHPort, FSSHLocalPort, FSSHTimeout, FCounter, FQueryTimeout: Integer; + FPort, FSSHPort, FSSHLocalPort, FSSHTimeout, FCounter, FQueryTimeout, FKeepAlive: Integer; FLoginPrompt, FCompressed, FLocalTimeZone, FFullTableStatus, FWindowsAuth, FWantSSL, FIsFolder: Boolean; FSessionColor: TColor; FLastConnect: TDateTime; @@ -251,6 +251,7 @@ type property Comment: String read FComment write FComment; property StartupScriptFilename: String read FStartupScriptFilename write FStartupScriptFilename; property QueryTimeout: Integer read FQueryTimeout write FQueryTimeout; + property KeepAlive: Integer read FKeepAlive write FKeepAlive; property Compressed: Boolean read FCompressed write FCompressed; property LocalTimeZone: Boolean read FLocalTimeZone write FLocalTimeZone; property FullTableStatus: Boolean read FFullTableStatus write FFullTableStatus; @@ -1134,6 +1135,7 @@ begin FStartupScriptFilename := AppSettings.ReadString(asStartupScriptFilename); FCompressed := AppSettings.ReadBool(asCompressed); FQueryTimeout := AppSettings.ReadInt(asQueryTimeout); + FKeepAlive := AppSettings.ReadInt(asKeepAlive); FLocalTimeZone := AppSettings.ReadBool(asLocalTimeZone); FFullTableStatus := AppSettings.ReadBool(asFullTableStatus); FServerVersion := AppSettings.ReadString(asServerVersionFull); @@ -1168,6 +1170,7 @@ begin AppSettings.WriteBool(asCompressed, FCompressed); AppSettings.WriteBool(asLocalTimeZone, FLocalTimeZone); AppSettings.WriteInt(asQueryTimeout, FQueryTimeout); + AppSettings.WriteInt(asKeepAlive, FKeepAlive); AppSettings.WriteBool(asFullTableStatus, FFullTableStatus); AppSettings.WriteString(asDatabases, FAllDatabases); AppSettings.WriteString(asComment, FComment); @@ -1394,8 +1397,6 @@ begin FLoginPromptDone := False; FCurrentUserHostCombination := ''; FKeepAliveTimer := TTimer.Create(Self); - FKeepAliveTimer.Interval := 20000; - FKeepAliveTimer.OnTimer := KeepAliveTimerEvent; FFavorites := TStringList.Create; end; @@ -2125,6 +2126,10 @@ begin FParameters.ServerVersion := FServerVersionUntouched; if Assigned(FOnConnected) then FOnConnected(Self, FDatabase); + if FParameters.KeepAlive > 0 then begin + FKeepAliveTimer.Interval := FParameters.KeepAlive * 1000; + FKeepAliveTimer.OnTimer := KeepAliveTimerEvent; + end; end; diff --git a/source/helpers.pas b/source/helpers.pas index 14f45c9f..182c7426 100644 --- a/source/helpers.pas +++ b/source/helpers.pas @@ -141,7 +141,7 @@ type asUser, asPassword, asWindowsAuth, asLoginPrompt, asPort, asPlinkExecutable, asSSHtunnelHost, asSSHtunnelHostPort, asSSHtunnelPort, asSSHtunnelUser, asSSHtunnelPassword, asSSHtunnelTimeout, asSSHtunnelPrivateKey, asSSLActive, asSSLKey, - asSSLCert, asSSLCA, asSSLCipher, asNetType, asCompressed, asLocalTimeZone, asQueryTimeout, + asSSLCert, asSSLCA, asSSLCipher, asNetType, asCompressed, asLocalTimeZone, asQueryTimeout, asKeepAlive, asStartupScriptFilename, asDatabases, asComment, asDatabaseFilter, asTableFilter, asExportSQLCreateDatabases, asExportSQLCreateTables, asExportSQLDataHow, asExportSQLDataInsertSize, asExportSQLFilenames, asExportZIPFilenames, asExportSQLDirectories, asExportSQLDatabase, asExportSQLServerDatabase, asExportSQLOutput, asExportSQLAddComments, asExportSQLRemoveAutoIncrement, @@ -3217,6 +3217,7 @@ begin InitSetting(asCompressed, 'Compressed', 0, False, '', True); InitSetting(asLocalTimeZone, 'LocalTimeZone', 0, False, '', True); InitSetting(asQueryTimeout, 'QueryTimeout', 30, False, '', True); + InitSetting(asKeepAlive, 'KeepAlive', 20, False, '', True); InitSetting(asStartupScriptFilename, 'StartupScriptFilename', 0, False, '', True); InitSetting(asDatabases, 'Databases', 0, False, '', True); InitSetting(asComment, 'Comment', 0, False, '', True);