// Enable plugin /// <summary> /// Enables the plugin. /// </summary> /// <param name='args'> /// Arguments. /// </param> public void EnablePlugin(string[] args) { Addin[] addins = GetSortedAddinList("RobustPlugin"); int n = Convert.ToInt16(args[2]); if (n > (addins.Length - 1)) { MainConsole.Instance.Output("Selection out of range"); return; } Addin addin = addins[n]; addin.Enabled = true; AddinManager.Registry.EnableAddin(addin.Id); // AddinManager.Registry.Update(); if (PluginRegistry.IsAddinEnabled(addin.Id)) { ConsoleProgressStatus ps = new ConsoleProgressStatus(false); if (!AddinManager.AddinEngine.IsAddinLoaded(addin.Id)) { MainConsole.Instance.Output("Ignore the following error..."); AddinManager.Registry.Rebuild(ps); AddinManager.AddinEngine.LoadAddin(ps, addin.Id); } } else { MainConsole.Instance.Output("Not Enabled in this domain {0}", addin.Name); } return; }
protected void OnAdd(object sender, EventArgs e) { NewSiteDialog dlg = new NewSiteDialog(); try { if (dlg.Run()) { string url = dlg.Url; if (!url.StartsWith("http://") && !url.StartsWith("https://") && !url.StartsWith("file://")) { url = "http://" + url; } try { new Uri(url); } catch { Services.ShowError(null, "Invalid url: " + url, null, true); } if (!service.Repositories.ContainsRepository(url)) { IProgressStatus m = new ConsoleProgressStatus(false); AddinRepository rr = service.Repositories.RegisterRepository(m, url); if (rr == null) { Services.ShowError(null, "The repository could not be registered", null, true); return; } treeStore.AppendValues(rr.Url, rr.Title); } } } finally { dlg.Destroy(); } }
// Sync to repositories /// <summary> /// Update this instance. /// </summary> public string Update() { IProgressStatus ps = new ConsoleProgressStatus(true); Repositories.UpdateAllRepositories(ps); return("Update"); }
protected void OnAdd (object sender, EventArgs e) { NewSiteDialog dlg = new NewSiteDialog (); try { if (dlg.Run ()) { string url = dlg.Url; if (!url.StartsWith ("http://") && !url.StartsWith ("https://") && !url.StartsWith ("file://")) { url = "http://" + url; } try { new Uri (url); } catch { Services.ShowError (null, "Invalid url: " + url, null, true); } if (!service.Repositories.ContainsRepository (url)) { IProgressStatus m = new ConsoleProgressStatus (false); AddinRepository rr = service.Repositories.RegisterRepository (m, url); if (rr == null) { Services.ShowError (null, "The repository could not be registered", null, true); return; } treeStore.AppendValues (rr.Url, rr.Title); } } } finally { dlg.Destroy (); } }
public void TestSetup() { setup = new SetupService(); baseDir = Path.GetDirectoryName(new Uri(typeof(TestBase).Assembly.CodeBase).LocalPath); addinsDir = new DirectoryInfo(baseDir).Parent.Parent.Parent.FullName; addinsDir = Path.Combine(addinsDir, "lib"); repoDir = Path.Combine(TempDir, "repo"); repoExtrasDir = Path.Combine(repoDir, "extras"); monitor = new ConsoleProgressStatus(true); repoBaseUrl = new Uri(repoDir).ToString(); repoUrl = new Uri(Path.Combine(repoDir, "main.mrep")).ToString(); }
void Install(PackageCollection packs) { PackageCollection toUninstall; DependencyCollection unresolved; IProgressStatus m = new ConsoleProgressStatus(verbose); int n = packs.Count; if (!service.Store.ResolveDependencies(m, packs, out toUninstall, out unresolved)) { throw new InstallException("Not all dependencies could be resolved."); } bool ask = false; if (packs.Count != n || toUninstall.Count != 0) { Console.WriteLine("The following packages will be installed:"); foreach (Package p in packs) { Console.WriteLine(" - " + p.Name); } ask = true; } if (toUninstall.Count != 0) { Console.WriteLine("The following packages need to be uninstalled:"); foreach (Package p in toUninstall) { Console.WriteLine(" - " + p.Name); } ask = true; } if (ask) { Console.WriteLine(); Console.Write("Are you sure you want to continue? (y/N): "); string res = Console.ReadLine(); if (res != "y" && res != "Y") { return; } } if (!service.Store.Install(m, packs)) { Console.WriteLine("Install operation failed."); } }
// List available updates ** 1 /// <summary> /// Lists the updates. /// </summary> public void ListUpdates() { IProgressStatus ps = new ConsoleProgressStatus(true); Console.WriteLine("Looking for updates..."); Repositories.UpdateAllRepositories(ps); Console.WriteLine("Available add-in updates:"); AddinRepositoryEntry[] entries = Repositories.GetAvailableUpdates(); foreach (AddinRepositoryEntry entry in entries) { Console.WriteLine(String.Format("{0}", entry.Addin.Id)); } }
/// <summary> /// Installs the plugin. /// </summary> /// <returns> /// The plugin. /// </returns> /// <param name='args'> /// Arguments. /// </param> public bool InstallPlugin(int ndx, out Dictionary <string, object> result) { Dictionary <string, object> res = new Dictionary <string, object>(); PackageCollection pack = new PackageCollection(); PackageCollection toUninstall; DependencyCollection unresolved; IProgressStatus ps = new ConsoleProgressStatus(false); AddinRepositoryEntry[] available = GetSortedAvailbleAddins(); if (ndx > (available.Length - 1)) { MainConsole.Instance.Output("Selection out of range"); result = res; return(false); } AddinRepositoryEntry aentry = available[ndx]; Package p = Package.FromRepository(aentry); pack.Add(p); ResolveDependencies(ps, pack, out toUninstall, out unresolved); // Attempt to install the plugin disabled if (Install(ps, pack) == true) { MainConsole.Instance.Output("Ignore the following error..."); PluginRegistry.Update(ps); Addin addin = PluginRegistry.GetAddin(aentry.Addin.Id); PluginRegistry.DisableAddin(addin.Id); addin.Enabled = false; MainConsole.Instance.Output("Installation Success"); ListInstalledAddins(out res); result = res; return(true); } else { MainConsole.Instance.Output("Installation Failed"); result = res; return(false); } }
// Remove plugin /// <summary> /// Uns the install. /// </summary> /// <param name='args'> /// Arguments. /// </param> public void UnInstall(int ndx) { Addin[] addins = GetSortedAddinList("RobustPlugin"); if (ndx > (addins.Length - 1)) { MainConsole.Instance.Output("Selection out of range"); return; } Addin addin = addins[ndx]; MainConsole.Instance.Output("Uninstalling plugin {0}", addin.Id); AddinManager.Registry.DisableAddin(addin.Id); addin.Enabled = false; IProgressStatus ps = new ConsoleProgressStatus(false); Uninstall(ps, addin.Id); MainConsole.Instance.Output("Uninstall Success - restart to complete operation"); return; }
public void Update (IProgressStatus monitor) { if (monitor == null) monitor = new ConsoleProgressStatus (false); if (RunningSetupProcess) return; fatalDatabseError = false; DateTime tim = DateTime.Now; Hashtable installed = new Hashtable (); bool changesFound = CheckFolders (monitor); if (monitor.IsCanceled) return; if (monitor.VerboseLog) monitor.Log ("Folders checked (" + (int) (DateTime.Now - tim).TotalMilliseconds + " ms)"); if (changesFound) { // Something has changed, the add-ins need to be re-scanned, but it has // to be done in an external process using (fileDatabase.LockRead ()) { foreach (Addin ainfo in InternalGetInstalledAddins ()) { installed [ainfo.Id] = ainfo.Id; } } IProgressStatus scanMonitor = monitor; bool retry = false; do { try { if (monitor.VerboseLog) monitor.Log ("Looking for addins"); SetupProcess.ExecuteCommand (scanMonitor, registry.RegistryPath, AddinManager.StartupDirectory, "scan"); retry = false; } catch (Exception ex) { fatalDatabseError = true; // If the process has crashed, try to do a new scan, this time using verbose log, // to give the user more information about the origin of the crash. if (ex is ProcessFailedException && !retry) { monitor.ReportError ("Add-in scan operation failed. The Mono runtime may have encountered an error while trying to load an assembly.", null); if (!monitor.VerboseLog) { // Re-scan again using verbose log, to make it easy to find the origin of the error. retry = true; scanMonitor = new ConsoleProgressStatus (true); } } else retry = false; if (!retry) { monitor.ReportError ("Add-in scan operation failed", (ex is ProcessFailedException ? null : ex)); monitor.Cancel (); return; } } } while (retry); ResetCachedData (); } if (fatalDatabseError) monitor.ReportError ("The add-in database could not be updated. It may be due to file corruption. Try running the setup repair utility", null); // Update the currently loaded add-ins if (changesFound && AddinManager.IsInitialized && AddinManager.Registry.RegistryPath == registry.RegistryPath) { Hashtable newInstalled = new Hashtable (); foreach (Addin ainfo in GetInstalledAddins ()) { newInstalled [ainfo.Id] = ainfo.Id; } foreach (string aid in installed.Keys) { if (!newInstalled.Contains (aid)) AddinManager.SessionService.UnloadAddin (aid); } foreach (string aid in newInstalled.Keys) { if (!installed.Contains (aid)) { AddinManager.SessionService.ActivateAddin (aid); } } } }
public void Update(IProgressStatus monitor, string domain) { if (monitor == null) monitor = new ConsoleProgressStatus (false); if (RunningSetupProcess) return; fatalDatabseError = false; DateTime tim = DateTime.Now; RunPendingUninstalls (monitor); Hashtable installed = new Hashtable (); bool changesFound = CheckFolders (monitor, domain); if (monitor.IsCanceled) return; if (monitor.LogLevel > 1) monitor.Log ("Folders checked (" + (int) (DateTime.Now - tim).TotalMilliseconds + " ms)"); if (changesFound) { // Something has changed, the add-ins need to be re-scanned, but it has // to be done in an external process if (domain != null) { using (fileDatabase.LockRead ()) { foreach (Addin ainfo in InternalGetInstalledAddins (domain, AddinSearchFlagsInternal.IncludeAddins)) { installed [ainfo.Id] = ainfo.Id; } } } RunScannerProcess (monitor); ResetCachedData (); registry.NotifyDatabaseUpdated (); } if (fatalDatabseError) monitor.ReportError ("The add-in database could not be updated. It may be due to file corruption. Try running the setup repair utility", null); // Update the currently loaded add-ins if (changesFound && domain != null && addinEngine != null && addinEngine.IsInitialized) { Hashtable newInstalled = new Hashtable (); foreach (Addin ainfo in GetInstalledAddins (domain, AddinSearchFlagsInternal.IncludeAddins)) { newInstalled [ainfo.Id] = ainfo.Id; } foreach (string aid in installed.Keys) { // Always try to unload, event if the add-in was not currently loaded. // Required since the add-ins has to be marked as 'disabled', to avoid // extensions from this add-in to be loaded if (!newInstalled.Contains (aid)) addinEngine.UnloadAddin (aid); } foreach (string aid in newInstalled.Keys) { if (!installed.Contains (aid)) { Addin addin = addinEngine.Registry.GetAddin (aid); if (addin != null) addinEngine.ActivateAddin (aid); } } } }
void RunScannerProcess(IProgressStatus monitor) { ISetupHandler setup = GetSetupHandler (); IProgressStatus scanMonitor = monitor; ArrayList pparams = new ArrayList (); bool retry = false; do { try { if (monitor.LogLevel > 1) monitor.Log ("Looking for addins"); setup.Scan (scanMonitor, registry, null, (string[]) pparams.ToArray (typeof(string))); retry = false; } catch (Exception ex) { ProcessFailedException pex = ex as ProcessFailedException; if (pex != null) { // Get the last logged operation. if (pex.LastLog.StartsWith ("scan:")) { // It crashed while scanning a file. Add the file to the ignore list and try again. string file = pex.LastLog.Substring (5); pparams.Add (file); monitor.ReportWarning ("Could not scan file: " + file); retry = true; continue; } } fatalDatabseError = true; // If the process has crashed, try to do a new scan, this time using verbose log, // to give the user more information about the origin of the crash. if (pex != null && !retry) { monitor.ReportError ("Add-in scan operation failed. The runtime may have encountered an error while trying to load an assembly.", null); if (monitor.LogLevel <= 1) { // Re-scan again using verbose log, to make it easy to find the origin of the error. retry = true; scanMonitor = new ConsoleProgressStatus (true); } } else retry = false; if (!retry) { var pfex = ex as ProcessFailedException; monitor.ReportError ("Add-in scan operation failed", pfex != null? pfex.InnerException : ex); monitor.Cancel (); return; } } } while (retry); }
public void Update (IProgressStatus monitor, string domain) { if (monitor == null) monitor = new ConsoleProgressStatus (false); if (RunningSetupProcess) return; fatalDatabseError = false; DateTime tim = DateTime.Now; Hashtable installed = new Hashtable (); bool changesFound = CheckFolders (monitor); if (monitor.IsCanceled) return; if (monitor.LogLevel > 1) monitor.Log ("Folders checked (" + (int) (DateTime.Now - tim).TotalMilliseconds + " ms)"); if (changesFound) { // Something has changed, the add-ins need to be re-scanned, but it has // to be done in an external process if (domain != null) { using (fileDatabase.LockRead ()) { foreach (Addin ainfo in InternalGetInstalledAddins (domain, AddinType.Addin)) { installed [ainfo.Id] = ainfo.Id; } } } RunScannerProcess (monitor); ResetCachedData (); registry.NotifyDatabaseUpdated (); } if (fatalDatabseError) monitor.ReportError ("The add-in database could not be updated. It may be due to file corruption. Try running the setup repair utility", null); // Update the currently loaded add-ins if (changesFound && domain != null && AddinManager.IsInitialized && AddinManager.Registry.RegistryPath == registry.RegistryPath) { Hashtable newInstalled = new Hashtable (); foreach (Addin ainfo in GetInstalledAddins (domain, AddinType.Addin)) { newInstalled [ainfo.Id] = ainfo.Id; } foreach (string aid in installed.Keys) { if (!newInstalled.Contains (aid)) AddinManager.SessionService.UnloadAddin (aid); } foreach (string aid in newInstalled.Keys) { if (!installed.Contains (aid)) { AddinManager.SessionService.ActivateAddin (aid); } } } }