From 99bb6c930479fedee4e55a662fa715702f6110b7 Mon Sep 17 00:00:00 2001
From: BlueWall
Date: Fri, 19 Oct 2012 07:38:36 -0400
Subject: Move PluginManager
Move PluginManager out to OpenSimFramework for general use
---
OpenSim/Framework/PluginManager.cs | 561 ++++++++++++++++++++++++
OpenSim/Server/Base/CommandManager.cs | 10 +-
OpenSim/Server/Base/PluginManager.cs | 557 -----------------------
OpenSim/Server/Base/ServerUtils.cs | 5 +-
OpenSim/Server/Handlers/Base/ServerConnector.cs | 8 +-
5 files changed, 577 insertions(+), 564 deletions(-)
create mode 100644 OpenSim/Framework/PluginManager.cs
delete mode 100644 OpenSim/Server/Base/PluginManager.cs
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/PluginManager.cs b/OpenSim/Framework/PluginManager.cs
new file mode 100644
index 0000000..188d90a
--- /dev/null
+++ b/OpenSim/Framework/PluginManager.cs
@@ -0,0 +1,561 @@
+
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+using System;
+using System.Text;
+using System.Linq;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using Mono.Addins;
+using Mono.Addins.Setup;
+using Mono.Addins.Description;
+using OpenSim.Framework;
+
+
+namespace OpenSim.Framework
+{
+ ///
+ /// Manager for registries and plugins
+ ///
+ public class PluginManager : SetupService
+ {
+ public AddinRegistry PluginRegistry;
+
+ public PluginManager(AddinRegistry registry): base (registry)
+ {
+ PluginRegistry = registry;
+
+ }
+
+ ///
+ /// Installs the plugin.
+ ///
+ ///
+ /// The plugin.
+ ///
+ ///
+ /// Arguments.
+ ///
+ public bool InstallPlugin(int ndx, out Dictionary result)
+ {
+ Dictionary res = new Dictionary();
+
+ 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)
+ {
+ 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
+ ///
+ /// Uns the install.
+ ///
+ ///
+ /// Arguments.
+ ///
+ 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.OutputFormat("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;
+ }
+
+ ///
+ /// Checks the installed.
+ ///
+ ///
+ /// The installed.
+ ///
+ public string CheckInstalled()
+ {
+ return "CheckInstall";
+ }
+
+ ///
+ /// Lists the installed addins.
+ ///
+ ///
+ /// Result.
+ ///
+ public void ListInstalledAddins(out Dictionary result)
+ {
+ Dictionary res = new Dictionary();
+
+ Addin[] addins = GetSortedAddinList("RobustPlugin");
+ if(addins.Count() < 1)
+ {
+ MainConsole.Instance.Output("Error!");
+ }
+ int count = 0;
+ foreach (Addin addin in addins)
+ {
+ Dictionary r = new Dictionary();
+ r["enabled"] = addin.Enabled == true ? true : false;
+ r["name"] = addin.LocalId;
+ r["version"] = addin.Version;
+
+ res.Add(count.ToString(), r);
+
+ count++;
+ }
+ result = res;
+ return;
+ }
+
+ // List compatible plugins in registered repositories
+ ///
+ /// Lists the available.
+ ///
+ ///
+ /// Result.
+ ///
+ public void ListAvailable(out Dictionary result)
+ {
+ Dictionary res = new Dictionary();
+
+ AddinRepositoryEntry[] addins = GetSortedAvailbleAddins();
+
+ int count = 0;
+ foreach (AddinRepositoryEntry addin in addins)
+ {
+ Dictionary r = new Dictionary();
+ r["name"] = addin.Addin.Name;
+ r["version"] = addin.Addin.Version;
+ r["repository"] = addin.RepositoryName;
+
+ res.Add(count.ToString(), r);
+ count++;
+ }
+ result = res;
+ return;
+ }
+
+ // List available updates ** 1
+ ///
+ /// Lists the updates.
+ ///
+ public void ListUpdates()
+ {
+ IProgressStatus ps = new ConsoleProgressStatus(true);
+ Console.WriteLine ("Looking for updates...");
+ Repositories.UpdateAllRepositories (ps);
+ Console.WriteLine ("Available add-in updates:");
+ bool found = false;
+ AddinRepositoryEntry[] entries = Repositories.GetAvailableUpdates();
+
+ foreach (AddinRepositoryEntry entry in entries)
+ {
+ Console.WriteLine(String.Format("{0}",entry.Addin.Id));
+ }
+ }
+
+ // Sync to repositories
+ ///
+ /// Update this instance.
+ ///
+ public string Update()
+ {
+ IProgressStatus ps = new ConsoleProgressStatus(true);
+ Repositories.UpdateAllRepositories(ps);
+ return "Update";
+ }
+
+ // Register a repository
+ ///
+ /// Register a repository with our server.
+ ///
+ ///
+ /// result of the action
+ ///
+ ///
+ /// The URL of the repository we want to add
+ ///
+ public bool AddRepository(string repo)
+ {
+ Repositories.RegisterRepository(null, repo, true);
+ PluginRegistry.Rebuild(null);
+
+ return true;
+ }
+
+ ///
+ /// Gets the repository.
+ ///
+ public void GetRepository()
+ {
+ Repositories.UpdateAllRepositories(new ConsoleProgressStatus(false));
+ }
+
+ // Remove a repository from the list
+ ///
+ /// Removes the repository.
+ ///
+ ///
+ /// Arguments.
+ ///
+ public void RemoveRepository(string[] args)
+ {
+ AddinRepository[] reps = Repositories.GetRepositories();
+ Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
+ if (reps.Length == 0)
+ {
+ MainConsole.Instance.Output("No repositories have been registered.");
+ return;
+ }
+
+ int n = Convert.ToInt16(args[2]);
+ if (n > (reps.Length -1))
+ {
+ MainConsole.Instance.Output("Selection out of range");
+ return;
+ }
+
+ AddinRepository rep = reps[n];
+ Repositories.RemoveRepository(rep.Url);
+ return;
+ }
+
+ // Enable repository
+ ///
+ /// Enables the repository.
+ ///
+ ///
+ /// Arguments.
+ ///
+ public void EnableRepository(string[] args)
+ {
+ AddinRepository[] reps = Repositories.GetRepositories();
+ Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
+ if (reps.Length == 0)
+ {
+ MainConsole.Instance.Output("No repositories have been registered.");
+ return;
+ }
+
+ int n = Convert.ToInt16(args[2]);
+ if (n > (reps.Length -1))
+ {
+ MainConsole.Instance.Output("Selection out of range");
+ return;
+ }
+
+ AddinRepository rep = reps[n];
+ Repositories.SetRepositoryEnabled(rep.Url, true);
+ return;
+ }
+
+ // Disable a repository
+ ///
+ /// Disables the repository.
+ ///
+ ///
+ /// Arguments.
+ ///
+ public void DisableRepository(string[] args)
+ {
+ AddinRepository[] reps = Repositories.GetRepositories();
+ Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
+ if (reps.Length == 0)
+ {
+ MainConsole.Instance.Output("No repositories have been registered.");
+ return;
+ }
+
+ int n = Convert.ToInt16(args[2]);
+ if (n > (reps.Length -1))
+ {
+ MainConsole.Instance.Output("Selection out of range");
+ return;
+ }
+
+ AddinRepository rep = reps[n];
+ Repositories.SetRepositoryEnabled(rep.Url, false);
+ return;
+ }
+
+ // List registered repositories
+ ///
+ /// Lists the repositories.
+ ///
+ ///
+ /// Result.
+ ///
+ public void ListRepositories(out Dictionary result)
+ {
+ Dictionary res = new Dictionary();
+ result = res;
+
+ AddinRepository[] reps = GetSortedAddinRepo();
+ if (reps.Length == 0)
+ {
+ MainConsole.Instance.Output("No repositories have been registered.");
+ return;
+ }
+
+ int count = 0;
+ foreach (AddinRepository rep in reps)
+ {
+ Dictionary r = new Dictionary();
+ r["enabled"] = rep.Enabled == true ? true : false;
+ r["name"] = rep.Name;
+ r["url"] = rep.Url;
+
+ res.Add(count.ToString(), r);
+ count++;
+ }
+ return;
+ }
+
+ ///
+ /// Updates the registry.
+ ///
+ public void UpdateRegistry()
+ {
+ PluginRegistry.Update();
+ }
+
+ // Show plugin info
+ ///
+ /// Addins the info.
+ ///
+ ///
+ /// The info.
+ ///
+ ///
+ /// Arguments.
+ ///
+ public bool AddinInfo(int ndx, out Dictionary result)
+ {
+ Dictionary res = new Dictionary();
+ result = res;
+
+ Addin[] addins = GetSortedAddinList("RobustPlugin");
+
+ if (ndx > (addins.Length - 1))
+ {
+ MainConsole.Instance.Output("Selection out of range");
+ return false;
+ }
+ // author category description
+ Addin addin = addins[ndx];
+
+ res["author"] = addin.Description.Author;
+ res["category"] = addin.Description.Category;
+ res["description"] = addin.Description.Description;
+ res["name"] = addin.Name;
+ res["url"] = addin.Description.Url;
+ res["file_name"] = addin.Description.FileName;
+
+ result = res;
+ return true;
+ }
+
+ // Disable a plugin
+ ///
+ /// Disables the plugin.
+ ///
+ ///
+ /// Arguments.
+ ///
+ public void DisablePlugin(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];
+ AddinManager.Registry.DisableAddin(addin.Id);
+ addin.Enabled = false;
+ return;
+ }
+
+ // Enable plugin
+ ///
+ /// Enables the plugin.
+ ///
+ ///
+ /// Arguments.
+ ///
+ 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))
+ {
+ AddinManager.Registry.Rebuild(ps);
+ AddinManager.AddinEngine.LoadAddin(ps, addin.Id);
+ }
+ }
+ else
+ {
+ MainConsole.Instance.OutputFormat("Not Enabled in this domain {0}", addin.Name);
+ }
+ return;
+ }
+
+
+
+ #region Util
+ private void Testing()
+ {
+ Addin[] list = Registry.GetAddins();
+
+ var addins = list.Where( a => a.Description.Category == "RobustPlugin");
+
+ foreach (Addin addin in addins)
+ {
+ MainConsole.Instance.OutputFormat("Addin {0}", addin.Name);
+ }
+ }
+
+ // These will let us deal with numbered lists instead
+ // of needing to type in the full ids
+ private AddinRepositoryEntry[] GetSortedAvailbleAddins()
+ {
+ ArrayList list = new ArrayList();
+ list.AddRange(Repositories.GetAvailableAddins());
+
+ AddinRepositoryEntry[] addins = list.ToArray(typeof(AddinRepositoryEntry)) as AddinRepositoryEntry[];
+
+ Array.Sort(addins,(r1,r2) => r1.Addin.Id.CompareTo(r2.Addin.Id));
+
+ return addins;
+ }
+
+ private AddinRepository[] GetSortedAddinRepo()
+ {
+ ArrayList list = new ArrayList();
+ list.AddRange(Repositories.GetRepositories());
+
+ AddinRepository[] repos = list.ToArray(typeof(AddinRepository)) as AddinRepository[];
+ Array.Sort (repos,(r1,r2) => r1.Name.CompareTo(r2.Name));
+
+ return repos;
+ }
+
+ private Addin[] GetSortedAddinList(string category)
+ {
+
+ ArrayList xlist = new ArrayList();
+ ArrayList list = new ArrayList();
+ try
+ {
+ list.AddRange(PluginRegistry.GetAddins());
+ }
+ catch(Exception e)
+ {
+ Addin[] x = xlist.ToArray(typeof(Addin)) as Addin[];
+ return x;
+ }
+
+ foreach (Addin addin in list)
+ {
+ if (addin.Description.Category == category)
+ xlist.Add(addin);
+ }
+
+ Addin[] addins = xlist.ToArray(typeof(Addin)) as Addin[];
+ Array.Sort(addins,(r1,r2) => r1.Id.CompareTo(r2.Id));
+
+ return addins;
+ }
+ #endregion Util
+ }
+}
diff --git a/OpenSim/Server/Base/CommandManager.cs b/OpenSim/Server/Base/CommandManager.cs
index 45652b3..88aac00 100644
--- a/OpenSim/Server/Base/CommandManager.cs
+++ b/OpenSim/Server/Base/CommandManager.cs
@@ -33,15 +33,21 @@ using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Mono.Addins;
-using Mono.Addins.Setup;
+// using Mono.Addins.Setup;
using Mono.Addins.Description;
using OpenSim.Framework;
namespace OpenSim.Server.Base
{
+ ///
+ /// Command manager -
+ /// Wrapper for OpenSim.Framework.PluginManager to allow
+ /// us to add commands to the console to perform operations
+ /// on our repos and plugins
+ ///
public class CommandManager
{
- protected AddinRegistry PluginRegistry;
+ public AddinRegistry PluginRegistry;
protected PluginManager PluginManager;
public CommandManager(AddinRegistry registry)
diff --git a/OpenSim/Server/Base/PluginManager.cs b/OpenSim/Server/Base/PluginManager.cs
deleted file mode 100644
index d2cf668..0000000
--- a/OpenSim/Server/Base/PluginManager.cs
+++ /dev/null
@@ -1,557 +0,0 @@
-
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-using System;
-using System.Text;
-using System.Linq;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using Mono.Addins;
-using Mono.Addins.Setup;
-using Mono.Addins.Description;
-using OpenSim.Framework;
-
-namespace OpenSim.Server.Base
-{
- public class PluginManager : SetupService
- {
- protected AddinRegistry PluginRegistry;
-
- internal PluginManager(AddinRegistry registry): base (registry)
- {
- PluginRegistry = registry;
-
- }
-
- ///
- /// Installs the plugin.
- ///
- ///
- /// The plugin.
- ///
- ///
- /// Arguments.
- ///
- public bool InstallPlugin(int ndx, out Dictionary result)
- {
- Dictionary res = new Dictionary();
-
- 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)
- {
- 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
- ///
- /// Uns the install.
- ///
- ///
- /// Arguments.
- ///
- 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.OutputFormat("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;
- }
-
- ///
- /// Checks the installed.
- ///
- ///
- /// The installed.
- ///
- public string CheckInstalled()
- {
- return "CheckInstall";
- }
-
- ///
- /// Lists the installed addins.
- ///
- ///
- /// Result.
- ///
- public void ListInstalledAddins(out Dictionary result)
- {
- Dictionary res = new Dictionary();
-
- Addin[] addins = GetSortedAddinList("RobustPlugin");
- if(addins.Count() < 1)
- {
- MainConsole.Instance.Output("Error!");
- }
- int count = 0;
- foreach (Addin addin in addins)
- {
- Dictionary r = new Dictionary();
- r["enabled"] = addin.Enabled == true ? true : false;
- r["name"] = addin.LocalId;
- r["version"] = addin.Version;
-
- res.Add(count.ToString(), r);
-
- count++;
- }
- result = res;
- return;
- }
-
- // List compatible plugins in registered repositories
- ///
- /// Lists the available.
- ///
- ///
- /// Result.
- ///
- public void ListAvailable(out Dictionary result)
- {
- Dictionary res = new Dictionary();
-
- AddinRepositoryEntry[] addins = GetSortedAvailbleAddins();
-
- int count = 0;
- foreach (AddinRepositoryEntry addin in addins)
- {
- Dictionary r = new Dictionary();
- r["name"] = addin.Addin.Name;
- r["version"] = addin.Addin.Version;
- r["repository"] = addin.RepositoryName;
-
- res.Add(count.ToString(), r);
- count++;
- }
- result = res;
- return;
- }
-
- // List available updates ** 1
- ///
- /// Lists the updates.
- ///
- public void ListUpdates()
- {
- IProgressStatus ps = new ConsoleProgressStatus(true);
- Console.WriteLine ("Looking for updates...");
- Repositories.UpdateAllRepositories (ps);
- Console.WriteLine ("Available add-in updates:");
- bool found = false;
- AddinRepositoryEntry[] entries = Repositories.GetAvailableUpdates();
-
- foreach (AddinRepositoryEntry entry in entries)
- {
- Console.WriteLine(String.Format("{0}",entry.Addin.Id));
- }
- }
-
- // Sync to repositories
- ///
- /// Update this instance.
- ///
- public string Update()
- {
- IProgressStatus ps = new ConsoleProgressStatus(true);
- Repositories.UpdateAllRepositories(ps);
- return "Update";
- }
-
- // Register a repository
- ///
- /// Register a repository with our server.
- ///
- ///
- /// result of the action
- ///
- ///
- /// The URL of the repository we want to add
- ///
- public bool AddRepository(string repo)
- {
- Repositories.RegisterRepository(null, repo, true);
- PluginRegistry.Rebuild(null);
-
- return true;
- }
-
- ///
- /// Gets the repository.
- ///
- public void GetRepository()
- {
- Repositories.UpdateAllRepositories(new ConsoleProgressStatus(false));
- }
-
- // Remove a repository from the list
- ///
- /// Removes the repository.
- ///
- ///
- /// Arguments.
- ///
- public void RemoveRepository(string[] args)
- {
- AddinRepository[] reps = Repositories.GetRepositories();
- Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
- if (reps.Length == 0)
- {
- MainConsole.Instance.Output("No repositories have been registered.");
- return;
- }
-
- int n = Convert.ToInt16(args[2]);
- if (n > (reps.Length -1))
- {
- MainConsole.Instance.Output("Selection out of range");
- return;
- }
-
- AddinRepository rep = reps[n];
- Repositories.RemoveRepository(rep.Url);
- return;
- }
-
- // Enable repository
- ///
- /// Enables the repository.
- ///
- ///
- /// Arguments.
- ///
- public void EnableRepository(string[] args)
- {
- AddinRepository[] reps = Repositories.GetRepositories();
- Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
- if (reps.Length == 0)
- {
- MainConsole.Instance.Output("No repositories have been registered.");
- return;
- }
-
- int n = Convert.ToInt16(args[2]);
- if (n > (reps.Length -1))
- {
- MainConsole.Instance.Output("Selection out of range");
- return;
- }
-
- AddinRepository rep = reps[n];
- Repositories.SetRepositoryEnabled(rep.Url, true);
- return;
- }
-
- // Disable a repository
- ///
- /// Disables the repository.
- ///
- ///
- /// Arguments.
- ///
- public void DisableRepository(string[] args)
- {
- AddinRepository[] reps = Repositories.GetRepositories();
- Array.Sort(reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
- if (reps.Length == 0)
- {
- MainConsole.Instance.Output("No repositories have been registered.");
- return;
- }
-
- int n = Convert.ToInt16(args[2]);
- if (n > (reps.Length -1))
- {
- MainConsole.Instance.Output("Selection out of range");
- return;
- }
-
- AddinRepository rep = reps[n];
- Repositories.SetRepositoryEnabled(rep.Url, false);
- return;
- }
-
- // List registered repositories
- ///
- /// Lists the repositories.
- ///
- ///
- /// Result.
- ///
- public void ListRepositories(out Dictionary result)
- {
- Dictionary res = new Dictionary();
- result = res;
-
- AddinRepository[] reps = GetSortedAddinRepo();
- if (reps.Length == 0)
- {
- MainConsole.Instance.Output("No repositories have been registered.");
- return;
- }
-
- int count = 0;
- foreach (AddinRepository rep in reps)
- {
- Dictionary r = new Dictionary();
- r["enabled"] = rep.Enabled == true ? true : false;
- r["name"] = rep.Name;
- r["url"] = rep.Url;
-
- res.Add(count.ToString(), r);
- count++;
- }
- return;
- }
-
- ///
- /// Updates the registry.
- ///
- public void UpdateRegistry()
- {
- PluginRegistry.Update();
- }
-
- // Show plugin info
- ///
- /// Addins the info.
- ///
- ///
- /// The info.
- ///
- ///
- /// Arguments.
- ///
- public bool AddinInfo(int ndx, out Dictionary result)
- {
- Dictionary res = new Dictionary();
- result = res;
-
- Addin[] addins = GetSortedAddinList("RobustPlugin");
-
- if (ndx > (addins.Length - 1))
- {
- MainConsole.Instance.Output("Selection out of range");
- return false;
- }
- // author category description
- Addin addin = addins[ndx];
-
- res["author"] = addin.Description.Author;
- res["category"] = addin.Description.Category;
- res["description"] = addin.Description.Description;
- res["name"] = addin.Name;
- res["url"] = addin.Description.Url;
- res["file_name"] = addin.Description.FileName;
-
- result = res;
- return true;
- }
-
- // Disable a plugin
- ///
- /// Disables the plugin.
- ///
- ///
- /// Arguments.
- ///
- public void DisablePlugin(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];
- AddinManager.Registry.DisableAddin(addin.Id);
- addin.Enabled = false;
- return;
- }
-
- // Enable plugin
- ///
- /// Enables the plugin.
- ///
- ///
- /// Arguments.
- ///
- 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))
- {
- AddinManager.Registry.Rebuild(ps);
- AddinManager.AddinEngine.LoadAddin(ps, addin.Id);
- }
- }
- else
- {
- MainConsole.Instance.OutputFormat("Not Enabled in this domain {0}", addin.Name);
- }
- return;
- }
-
-
-
- #region Util
- private void Testing()
- {
- Addin[] list = Registry.GetAddins();
-
- var addins = list.Where( a => a.Description.Category == "RobustPlugin");
-
- foreach (Addin addin in addins)
- {
- MainConsole.Instance.OutputFormat("Addin {0}", addin.Name);
- }
- }
-
- // These will let us deal with numbered lists instead
- // of needing to type in the full ids
- private AddinRepositoryEntry[] GetSortedAvailbleAddins()
- {
- ArrayList list = new ArrayList();
- list.AddRange(Repositories.GetAvailableAddins());
-
- AddinRepositoryEntry[] addins = list.ToArray(typeof(AddinRepositoryEntry)) as AddinRepositoryEntry[];
-
- Array.Sort(addins,(r1,r2) => r1.Addin.Id.CompareTo(r2.Addin.Id));
-
- return addins;
- }
-
- private AddinRepository[] GetSortedAddinRepo()
- {
- ArrayList list = new ArrayList();
- list.AddRange(Repositories.GetRepositories());
-
- AddinRepository[] repos = list.ToArray(typeof(AddinRepository)) as AddinRepository[];
- Array.Sort (repos,(r1,r2) => r1.Name.CompareTo(r2.Name));
-
- return repos;
- }
-
- private Addin[] GetSortedAddinList(string category)
- {
-
- ArrayList xlist = new ArrayList();
- ArrayList list = new ArrayList();
- try
- {
- list.AddRange(PluginRegistry.GetAddins());
- }
- catch(Exception e)
- {
- Addin[] x = xlist.ToArray(typeof(Addin)) as Addin[];
- return x;
- }
-
- foreach (Addin addin in list)
- {
- if (addin.Description.Category == category)
- xlist.Add(addin);
- }
-
- Addin[] addins = xlist.ToArray(typeof(Addin)) as Addin[];
- Array.Sort(addins,(r1,r2) => r1.Id.CompareTo(r2.Id));
-
- return addins;
- }
- #endregion Util
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index 8ecf3d3..31b0446 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -111,17 +111,18 @@ namespace OpenSim.Server.Base
case ExtensionChange.Add:
if (a.AddinFile.Contains(Registry.DefaultAddinsFolder))
{
- m_log.InfoFormat("[SERVER]: Adding {0}", a.Name);
+ m_log.InfoFormat("[SERVER]: Adding {0} from registry", a.Name);
connector.PluginPath = String.Format("{0}/{1}", Registry.DefaultAddinsFolder, a.Name.Replace(',', '.'));
}
else
{
- m_log.InfoFormat("[SERVER]: Removing {0}", a.Name);
+ m_log.InfoFormat("[SERVER]: Adding {0} from ./bin", a.Name);
connector.PluginPath = a.AddinFile;
}
LoadPlugin(connector);
break;
case ExtensionChange.Remove:
+ m_log.InfoFormat("[SERVER]: Removing {0}", a.Name);
UnloadPlugin(connector);
break;
}
diff --git a/OpenSim/Server/Handlers/Base/ServerConnector.cs b/OpenSim/Server/Handlers/Base/ServerConnector.cs
index 067fd2a..72014db 100644
--- a/OpenSim/Server/Handlers/Base/ServerConnector.cs
+++ b/OpenSim/Server/Handlers/Base/ServerConnector.cs
@@ -41,8 +41,7 @@ namespace OpenSim.Server.Handlers.Base
{
public virtual string ConfigURL
{
- get;
- protected set;
+ get { return String.Empty; }
}
public virtual string ConfigName
@@ -95,7 +94,10 @@ namespace OpenSim.Server.Handlers.Base
return config;
}
- // We get our remote initial configuration for bootstrapping
+ // We get our remote initial configuration for bootstrapping in case
+ // we have no configuration in our main file or in an existing
+ // modular config file. This is the last resort to bootstrap the
+ // configuration, likely a new plugin loading for the first time.
private IConfigSource GetConfigSource()
{
IConfigSource source = null;
--
cgit v1.1