diff options
author | Max <post@wickenrode.com> | 2015-11-12 01:42:02 +0100 |
---|---|---|
committer | Max <post@wickenrode.com> | 2015-11-12 01:42:02 +0100 |
commit | 0dbadf887635bb3904d3aa64a0588a0b23d884dc (patch) | |
tree | 34288e2ff62716e7f702692e8985f3a7f5a47678 /Source | |
parent | afd6f72c968547a0b228b02780409d8f01096da5 (diff) | |
download | sequelpro-0dbadf887635bb3904d3aa64a0588a0b23d884dc.tar.gz sequelpro-0dbadf887635bb3904d3aa64a0588a0b23d884dc.tar.bz2 sequelpro-0dbadf887635bb3904d3aa64a0588a0b23d884dc.zip |
In order to enable even more people to shoot themselves in the foot, this commit adds support for remote server shutdown
💣
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPDatabaseDocument.h | 1 | ||||
-rw-r--r-- | Source/SPDatabaseDocument.m | 34 |
2 files changed, 35 insertions, 0 deletions
diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h index b094a65f..e36b4a58 100644 --- a/Source/SPDatabaseDocument.h +++ b/Source/SPDatabaseDocument.h @@ -359,6 +359,7 @@ - (IBAction) makeTableListFilterHaveFocus:(id)sender; - (IBAction)showServerVariables:(id)sender; - (IBAction)showServerProcesses:(id)sender; +- (IBAction)shutdownServer:(id)sender; - (IBAction)openCurrentConnectionInNewWindow:(id)sender; - (IBAction)showGotoDatabase:(id)sender; #endif diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index d4c568b2..05bdc849 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -968,6 +968,40 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; [processListController displayProcessListWindow]; } + +- (IBAction)shutdownServer:(id)sender +{ + // confirm user action + SPBeginAlertSheet( + NSLocalizedString(@"Do you really want to shutdown the server?", @"shutdown server : confirmation dialog : title"), + NSLocalizedString(@"Shutdown", @"shutdown server : confirmation dialog : shutdown button"), + NSLocalizedString(@"Cancel", @"shutdown server : confirmation dialog : cancel button"), + nil, + parentWindow, + self, + @selector(shutdownAlertDidEnd:returnCode:contextInfo:), + NULL, + NSLocalizedString(@"This will wait for open transactions to complete and then quit the mysql daemon. Afterwards neither you nor anyone else can connect to this database!\n\nFull management access to the server's operating system is required to restart MySQL!", @"shutdown server : confirmation dialog : message") + ); +} + +- (void)shutdownAlertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo +{ + if(returnCode != NSAlertDefaultReturn) return; //cancelled by user + + if(![mySQLConnection serverShutdown]) { + if([mySQLConnection isConnected]) { + SPOnewayAlertSheet( + NSLocalizedString(@"Shutdown failed!", @"shutdown server : error dialog : title"), + parentWindow, + [NSString stringWithFormat:NSLocalizedString(@"MySQL said:\n%@", @"shutdown server : error dialog : message"),[mySQLConnection lastErrorMessage]] + ); + } + } + // shutdown successful. + // Until s.o. has a good UI idea, do nothing. Sequel Pro should figure out the connection loss soon enough +} + #endif /** |