示例#1
0
        void LaunchDocumentationUpdate(Product [] products, string informative)
        {
            var infoDialog = new NSAlert {
                AlertStyle      = NSAlertStyle.Informational,
                MessageText     = "Documentation update available",
                InformativeText = informative + "\n\nWarning: If you have not downloaded the documentation with Xcode, this program will download the documentation from Apple servers which can take a long time.\n\nWould you like to update the documentation now?"
            };

            infoDialog.AddButton("Update now");
            infoDialog.AddButton("Remind me later");
            var dialogResult = infoDialog.RunModal();

            // If Cancel was clicked, just return
            if (dialogResult == (int)NSAlertButtonReturn.Second)
            {
                return;
            }

            var mergerTasks = products.Select(p => Task.Factory.StartNew(() => {
                var mergeToolPath = ProductUtils.GetMergeToolForProduct(p);

                var psi = new System.Diagnostics.ProcessStartInfo(mergeToolPath, null);
                return(ProcessUtils.StartProcess(psi, null, null, CancellationToken.None));
            }).Unwrap());

            // No Task.WhenAll yet
            var tcs = new TaskCompletionSource <int> ();

            Task.Factory.ContinueWhenAll(mergerTasks.ToArray(), ts => {
                var faulteds = ts.Where(t => t.IsFaulted);
                if (faulteds.Any())
                {
                    tcs.SetException(faulteds.Select(t => t.Exception));
                }
                else
                {
                    tcs.SetResult(ts.Select(t => t.Result).FirstOrDefault(r => r != 0));
                }
            });

            var mergeController = new AppleDocMergeWindowController();

            mergeController.TrackProcessTask(tcs.Task);
            mergeController.ShowWindow(this);
            mergeController.Window.Center();
        }
示例#2
0
        void LaunchDocumentationUpdate(bool docOutdated, bool mergeOutdated)
        {
            var infoDialog = new NSAlert {
                AlertStyle      = NSAlertStyle.Informational,
                MessageText     = "Documentation update available",
                InformativeText = "We have detected your MonoTouch documentation can be upgraded with Apple documentation."
                                  + Environment.NewLine
                                  + Environment.NewLine
                                  + "Would you like to update the documentation now? You can continue to browse the documentation while the update is performed."
            };

            infoDialog.AddButton("Update now");
            infoDialog.AddButton("Remind me later");
            var dialogResult = infoDialog.RunModal();

            // If Cancel was clicked, just return
            if (dialogResult == (int)NSAlertButtonReturn.Second)
            {
                return;
            }

            // Launching AppleDocWizard as root
            var mergerTask = Task.Factory.StartNew(() => {
                // If the script has its setuid bit on and user as root, then we launch it directly otherwise we first restore it
                if (!RootLauncher.IsRootEnabled(MergeToolPath))
                {
                    RootLauncher.LaunchExternalTool(MergeToolPath, docOutdated ? new string[] { "--self-repair" } : (string[])null);
                    // No good way to know when the process will finish, so wait a bit. Not ideal but since this is an unlikely codepath, shouldn't matter.
                    System.Threading.Thread.Sleep(1000);
                }
                return(ProcessUtils.StartProcess(new System.Diagnostics.ProcessStartInfo(MergeToolPath, "--force-download"), null, null, CancellationToken.None));
            }).Unwrap();

            var mergeController = new AppleDocMergeWindowController();

            mergeController.TrackProcessTask(mergerTask);
            mergeController.ShowWindow(this);
            mergeController.Window.Center();
        }
示例#3
0
		void LaunchDocumentationUpdate (Dictionary<Product, Tuple<bool, bool>> toUpdate)
		{
			var informative = "We have detected your " + string.Join (" and ", toUpdate.Keys.Select (ProductUtils.GetFriendlyName)) +
				" documentation can be upgraded with Apple documentation.";
			// Check if we are going to be downloading stuff
			if (toUpdate.Any (kvp => kvp.Value.Item1))
				informative += Environment.NewLine + Environment.NewLine + "Warning: we are going to download documentation from Apple servers which can take a long time depending on your Internet connection.";
			informative += Environment.NewLine + Environment.NewLine + "Would you like to update the documentation now?";

			var infoDialog = new NSAlert {
				AlertStyle = NSAlertStyle.Informational,
				MessageText = "Documentation update available",
				InformativeText = informative
			};
			
			infoDialog.AddButton ("Update now");
			infoDialog.AddButton ("Remind me later");
			var dialogResult = infoDialog.RunModal ();
			// If Cancel was clicked, just return
			if (dialogResult == (int)NSAlertButtonReturn.Second)
				return;
			
			// Launching AppleDocWizard as root
			var mergerTasks = toUpdate
				.Where (kvp => kvp.Value.Item1 || kvp.Value.Item2)
				.Select (kvp => Task.Factory.StartNew (() => {
						var mergeToolPath = ProductUtils.GetMergeToolForProduct (kvp.Key);
						var docOutdated = kvp.Value.Item1;

						// If the script has its setuid bit on and user as root, then we launch it directly otherwise we first restore it
						if (!RootLauncher.IsRootEnabled (mergeToolPath)) {
							RootLauncher.LaunchExternalTool (mergeToolPath, new string[] { "--self-repair" });
							// No good way to know when the process will finish, so wait a bit. Not ideal but since this is an unlikely codepath, shouldn't matter.
							System.Threading.Thread.Sleep (1000);
						}
						var psi = new System.Diagnostics.ProcessStartInfo (mergeToolPath, docOutdated ? "--force-download" : null);
						return ProcessUtils.StartProcess (psi, null, null, CancellationToken.None);
					}).Unwrap ());
			// No Task.WhenAll yet
			var tcs = new TaskCompletionSource<int> ();
			Task.Factory.ContinueWhenAll (mergerTasks.ToArray (), ts => {
				var faulteds = ts.Where (t => t.IsFaulted);
				if (faulteds.Any ())
					tcs.SetException (faulteds.Select (t => t.Exception));
				else
					tcs.SetResult (ts.Select (t => t.Result).FirstOrDefault (r => r != 0));
			});

			var mergeController = new AppleDocMergeWindowController ();
			mergeController.TrackProcessTask (tcs.Task);
			mergeController.ShowWindow (this);
			mergeController.Window.Center ();
		}
示例#4
0
        void LaunchDocumentationUpdate(Dictionary <Product, Tuple <bool, bool> > toUpdate)
        {
            var outdatedProducts = string.Join(" and ", toUpdate.Where(kvp => kvp.Value.Item1 || kvp.Value.Item2).Select(kvp => ProductUtils.GetFriendlyName(kvp.Key)));
            var informative      = "We have detected your " + outdatedProducts + " documentation can be upgraded with Apple documentation.";

            // Check if we are going to be downloading stuff
            if (toUpdate.Any(kvp => kvp.Value.Item1))
            {
                informative += Environment.NewLine + Environment.NewLine + "Warning: we are going to download documentation from Apple servers which can take a long time depending on your Internet connection.";
            }
            informative += Environment.NewLine + Environment.NewLine + "Would you like to update the documentation now?";

            var infoDialog = new NSAlert {
                AlertStyle      = NSAlertStyle.Informational,
                MessageText     = "Documentation update available",
                InformativeText = informative
            };

            infoDialog.AddButton("Update now");
            infoDialog.AddButton("Remind me later");
            var dialogResult = infoDialog.RunModal();

            // If Cancel was clicked, just return
            if (dialogResult == (int)NSAlertButtonReturn.Second)
            {
                return;
            }

            // Launching AppleDocWizard as root
            var mergerTasks = toUpdate
                              .Where(kvp => kvp.Value.Item1 || kvp.Value.Item2)
                              .Select(kvp => Task.Factory.StartNew(() => {
                var mergeToolPath = ProductUtils.GetMergeToolForProduct(kvp.Key);
                var docOutdated   = kvp.Value.Item1;

                // If the script has its setuid bit on and user as root, then we launch it directly otherwise we first restore it
                if (!RootLauncher.IsRootEnabled(mergeToolPath))
                {
                    RootLauncher.LaunchExternalTool(mergeToolPath, new string[] { "--self-repair" });
                    // No good way to know when the process will finish, so wait a bit. Not ideal but since this is an unlikely codepath, shouldn't matter.
                    System.Threading.Thread.Sleep(1000);
                }
                var psi = new System.Diagnostics.ProcessStartInfo(mergeToolPath, docOutdated ? "--force-download" : null);
                return(ProcessUtils.StartProcess(psi, null, null, CancellationToken.None));
            }).Unwrap());
            // No Task.WhenAll yet
            var tcs = new TaskCompletionSource <int> ();

            Task.Factory.ContinueWhenAll(mergerTasks.ToArray(), ts => {
                var faulteds = ts.Where(t => t.IsFaulted);
                if (faulteds.Any())
                {
                    tcs.SetException(faulteds.Select(t => t.Exception));
                }
                else
                {
                    tcs.SetResult(ts.Select(t => t.Result).FirstOrDefault(r => r != 0));
                }
            });

            var mergeController = new AppleDocMergeWindowController();

            mergeController.TrackProcessTask(tcs.Task);
            mergeController.ShowWindow(this);
            mergeController.Window.Center();
        }
示例#5
0
		void LaunchDocumentationUpdate (Product [] products, string informative)
		{
			var infoDialog = new NSAlert {
				AlertStyle = NSAlertStyle.Informational,
				MessageText = "Documentation update available",
				InformativeText = informative + "\n\nWarning: If you have not downloaded the documentation with Xcode, this program will download the documentation from Apple servers which can take a long time.\n\nWould you like to update the documentation now?"
			};
			
			infoDialog.AddButton ("Update now");
			infoDialog.AddButton ("Remind me later");
			var dialogResult = infoDialog.RunModal ();
			// If Cancel was clicked, just return
			if (dialogResult == (int)NSAlertButtonReturn.Second)
				return;

			var mergerTasks = products.Select (p => Task.Factory.StartNew (() => {
				var mergeToolPath = ProductUtils.GetMergeToolForProduct (p);

				var psi = new System.Diagnostics.ProcessStartInfo (mergeToolPath, null);
				return ProcessUtils.StartProcess (psi, null, null, CancellationToken.None);
			}).Unwrap ());

			// No Task.WhenAll yet
			var tcs = new TaskCompletionSource<int> ();
			Task.Factory.ContinueWhenAll (mergerTasks.ToArray (), ts => {
				var faulteds = ts.Where (t => t.IsFaulted);
				if (faulteds.Any ())
					tcs.SetException (faulteds.Select (t => t.Exception));
				else
					tcs.SetResult (ts.Select (t => t.Result).FirstOrDefault (r => r != 0));
			});

			var mergeController = new AppleDocMergeWindowController ();
			mergeController.TrackProcessTask (tcs.Task);
			mergeController.ShowWindow (this);
			mergeController.Window.Center ();
		}
示例#6
0
		void LaunchDocumentationUpdate (bool docOutdated, bool mergeOutdated)
		{
			var infoDialog = new NSAlert {
				AlertStyle = NSAlertStyle.Informational,
				MessageText = "Documentation update available",
				InformativeText = "We have detected your MonoTouch documentation can be upgraded with Apple documentation."
					+ Environment.NewLine
					+ Environment.NewLine
					+ "Would you like to update the documentation now? You can continue to browse the documentation while the update is performed."
			};
			
			infoDialog.AddButton ("Update now");
			infoDialog.AddButton ("Remind me later");
			var dialogResult = infoDialog.RunModal ();
			// If Cancel was clicked, just return
			if (dialogResult == (int)NSAlertButtonReturn.Second)
				return;
			
			// Launching AppleDocWizard as root
			var mergerTask = Task.Factory.StartNew (() => {
				// If the script has its setuid bit on and user as root, then we launch it directly otherwise we first restore it
				if (!RootLauncher.IsRootEnabled (MergeToolPath)) {
					RootLauncher.LaunchExternalTool (MergeToolPath, docOutdated ? new string[] { "--self-repair" } : (string[])null);
					// No good way to know when the process will finish, so wait a bit. Not ideal but since this is an unlikely codepath, shouldn't matter.
					System.Threading.Thread.Sleep (1000);
				}
				return ProcessUtils.StartProcess (new System.Diagnostics.ProcessStartInfo (MergeToolPath, "--force-download"), null, null, CancellationToken.None);
			}).Unwrap ();

			var mergeController = new AppleDocMergeWindowController ();
			mergeController.TrackProcessTask (mergerTask);
			mergeController.ShowWindow (this);
			mergeController.Window.Center ();
		}