diff options
author | Jeremie Laval <jeremie.laval@gmail.com> | 2012-03-13 21:12:37 +0400 |
---|---|---|
committer | Jeremie Laval <jeremie.laval@gmail.com> | 2012-03-13 21:12:37 +0400 |
commit | 8b1b62877edd788b9c928d3647653a2b720aa12d (patch) | |
tree | 37225af7266649d46fdf60ca93249734faeebfec /AppDelegate.cs | |
parent | 552cd23a2e24a2b10dc34ad65c9f7f8eda6ec168 (diff) |
[macdoc] Propagate root launcher error and report them to the user
Diffstat (limited to 'AppDelegate.cs')
-rw-r--r-- | AppDelegate.cs | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/AppDelegate.cs b/AppDelegate.cs index dfb04ee..8e18ebd 100644 --- a/AppDelegate.cs +++ b/AppDelegate.cs @@ -99,27 +99,7 @@ namespace macdoc }).ContinueWith (t => { if (!t.Result) return; - BeginInvokeOnMainThread (() => { - var infoDialog = new NSAlert { - AlertStyle = NSAlertStyle.Informational, - MessageText = "Documentation update available", - InformativeText = "We have detected your MonoTouch documentation can be upgraded with Apple documentation, would you like to launch the merge now (root password required)?" - }; - - infoDialog.AddButton ("Yes"); - infoDialog.AddButton ("Cancel"); - var dialogResult = infoDialog.RunModal (); - // If Cancel was clicked, just return - if (dialogResult == (int)NSAlertButtonReturn.Second) - return; - - // Launching AppleDocWizard as root - // First get the directory - var updaterPath = Path.Combine (Path.GetDirectoryName (NSBundle.MainBundle.BuiltinPluginsPath), "MacOS"); - // Next get the executable - updaterPath = Path.Combine (updaterPath, "AppleDocWizard.app", "Contents", "MacOS", "AppleDocWizard"); - RootLauncher.LaunchExternalTool (updaterPath); - }); + BeginInvokeOnMainThread (LaunchDocumentationUpdate); }); } } @@ -202,6 +182,38 @@ namespace macdoc BookmarkManager.SaveBookmarks (); } + void LaunchDocumentationUpdate () + { + var infoDialog = new NSAlert { + AlertStyle = NSAlertStyle.Informational, + MessageText = "Documentation update available", + InformativeText = "We have detected your MonoTouch documentation can be upgraded with Apple documentation, would you like to launch the merge now (root password required)?" + }; + + infoDialog.AddButton ("Yes"); + infoDialog.AddButton ("Cancel"); + var dialogResult = infoDialog.RunModal (); + // If Cancel was clicked, just return + if (dialogResult == (int)NSAlertButtonReturn.Second) + return; + + // Launching AppleDocWizard as root + // First get the directory + var updaterPath = Path.Combine (Path.GetDirectoryName (NSBundle.MainBundle.BuiltinPluginsPath), "MacOS"); + // Next get the executable + updaterPath = Path.Combine (updaterPath, "AppleDocWizard.app", "Contents", "MacOS", "AppleDocWizard"); + try { + RootLauncher.LaunchExternalTool (updaterPath); + } catch (RootLauncherException ex) { + var alertDialog = new NSAlert { + AlertStyle = NSAlertStyle.Critical, + MessageText = "Documentation updater error", + InformativeText = string.Format ("There was an error launching the documentation updater: {0}{1}{2}", ex.ResultCode.ToString (), Environment.NewLine, ex.Message) + }; + alertDialog.RunModal (); + } + } + // We use a working OpenDocument method that doesn't return anything because of MonoMac bug#3380 public void Call_OpenDocument (NSUrl absoluteUrl, bool displayDocument, out NSError outError) { |