aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDatabaseDocument.m
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-11-12 01:42:02 +0100
committerMax <post@wickenrode.com>2015-11-12 01:42:02 +0100
commit0dbadf887635bb3904d3aa64a0588a0b23d884dc (patch)
tree34288e2ff62716e7f702692e8985f3a7f5a47678 /Source/SPDatabaseDocument.m
parentafd6f72c968547a0b228b02780409d8f01096da5 (diff)
downloadsequelpro-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/SPDatabaseDocument.m')
-rw-r--r--Source/SPDatabaseDocument.m34
1 files changed, 34 insertions, 0 deletions
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
/**