parent
1aab096a83
commit
90a2296983
|
@ -27,6 +27,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
@ -61,142 +62,155 @@ namespace OpenSim.Services.IntegrationService
|
|||
{
|
||||
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||
"install", "install \"plugin name\"", "Install plugin from repository",
|
||||
HandleInstallPlugin);
|
||||
HandleConsoleInstallPlugin);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||
"uninstall", "uninstall \"plugin name\"", "Remove plugin from repository",
|
||||
HandleUnInstallPlugin);
|
||||
HandleConsoleUnInstallPlugin);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||
"check installed", "check installed \"plugin name=\"","Check installed plugin",
|
||||
HandleCheckInstalledPlugin);
|
||||
HandleConsoleCheckInstalledPlugin);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||
"list installed", "list installed \"plugin name=\"","List install plugins",
|
||||
HandleListInstalledPlugin);
|
||||
HandleConsoleListInstalledPlugin);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||
"list available", "list available \"plugin name=\"","List available plugins",
|
||||
HandleListAvailablePlugin);
|
||||
HandleConsoleListAvailablePlugin);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||
"list updates", "list updates","List availble updates",
|
||||
HandleListUpdates);
|
||||
HandleConsoleListUpdates);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||
"update", "update \"plugin name=\"","Update the plugin",
|
||||
HandleUpdatePlugin);
|
||||
HandleConsoleUpdatePlugin);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||
"add repo", "add repo \"url\"","Add repository",
|
||||
HandleAddRepo);
|
||||
HandleConsoleAddRepo);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||
"get repo", "get repo \"url\"", "Sync with a registered repository",
|
||||
HandleGetRepo);
|
||||
HandleConsoleGetRepo);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||
"remove repo", "remove repo \"[url | index]\"","Remove registered repository",
|
||||
HandleRemoveRepo);
|
||||
HandleConsoleRemoveRepo);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||
"enable repo", "enable repo \"[url | index]\"","Enable registered repository",
|
||||
HandleEnableRepo);
|
||||
HandleConsoleEnableRepo);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||
"disable repo", "disable repo \"[url | index]\"","Disable registered repository",
|
||||
HandleDisableRepo);
|
||||
HandleConsoleDisableRepo);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||
"list repos", "list repos","List registered repositories",
|
||||
HandleListRepos);
|
||||
HandleConsoleListRepos);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("Integration", true,
|
||||
"show info", "show info \"plugin name\"","Show detailed information for plugin",
|
||||
HandleShowAddinInfo);
|
||||
HandleConsoleShowAddinInfo);
|
||||
|
||||
}
|
||||
|
||||
#region console handlers
|
||||
private void HandleInstallPlugin(string module, string[] cmd)
|
||||
private void HandleConsoleInstallPlugin(string module, string[] cmd)
|
||||
{
|
||||
MainConsole.Instance.Output(m_PluginManager.Install());
|
||||
MainConsole.Instance.Output(m_PluginManager.InstallPlugin(cmd));
|
||||
return;
|
||||
}
|
||||
|
||||
private void HandleUnInstallPlugin(string module, string[] cmd)
|
||||
private void HandleConsoleUnInstallPlugin(string module, string[] cmd)
|
||||
{
|
||||
MainConsole.Instance.Output(m_PluginManager.UnInstall());
|
||||
if (cmd.Length == 2)
|
||||
{
|
||||
m_PluginManager.UnInstall(cmd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private void HandleCheckInstalledPlugin(string module, string[] cmd)
|
||||
private void HandleConsoleCheckInstalledPlugin(string module, string[] cmd)
|
||||
{
|
||||
MainConsole.Instance.Output(m_PluginManager.CheckInstalled());
|
||||
return;
|
||||
}
|
||||
|
||||
private void HandleListInstalledPlugin(string module, string[] cmd)
|
||||
private void HandleConsoleListInstalledPlugin(string module, string[] cmd)
|
||||
{
|
||||
m_PluginManager.ListInstalledAddins();
|
||||
return;
|
||||
}
|
||||
|
||||
private void HandleListAvailablePlugin(string module, string[] cmd)
|
||||
private void HandleConsoleListAvailablePlugin(string module, string[] cmd)
|
||||
{
|
||||
m_PluginManager.ListAvailable();
|
||||
ArrayList list = m_PluginManager.ListAvailable();
|
||||
foreach (string entry in list)
|
||||
MainConsole.Instance.Output(entry);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private void HandleListUpdates(string module, string[] cmd)
|
||||
private void HandleConsoleListUpdates(string module, string[] cmd)
|
||||
{
|
||||
MainConsole.Instance.Output(m_PluginManager.ListUpdates());
|
||||
return;
|
||||
}
|
||||
|
||||
private void HandleUpdatePlugin(string module, string[] cmd)
|
||||
private void HandleConsoleUpdatePlugin(string module, string[] cmd)
|
||||
{
|
||||
MainConsole.Instance.Output(m_PluginManager.Update());
|
||||
return;
|
||||
}
|
||||
|
||||
private void HandleAddRepo(string module, string[] cmd)
|
||||
private void HandleConsoleAddRepo(string module, string[] cmd)
|
||||
{
|
||||
MainConsole.Instance.Output(m_PluginManager.AddRepository());
|
||||
if ( cmd.Length == 3)
|
||||
{
|
||||
m_PluginManager.AddRepository(cmd);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private void HandleGetRepo(string module, string[] cmd)
|
||||
private void HandleConsoleGetRepo(string module, string[] cmd)
|
||||
{
|
||||
MainConsole.Instance.Output(m_PluginManager.GetRepository());
|
||||
return;
|
||||
}
|
||||
|
||||
private void HandleRemoveRepo(string module, string[] cmd)
|
||||
private void HandleConsoleRemoveRepo(string module, string[] cmd)
|
||||
{
|
||||
MainConsole.Instance.Output(m_PluginManager.RemoveRepository());
|
||||
MainConsole.Instance.Output(m_PluginManager.RemoveRepository(cmd));
|
||||
return;
|
||||
}
|
||||
|
||||
private void HandleEnableRepo(string module, string[] cmd)
|
||||
private void HandleConsoleEnableRepo(string module, string[] cmd)
|
||||
{
|
||||
m_PluginManager.EnableRepository(cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
private void HandleDisableRepo(string module, string[] cmd)
|
||||
private void HandleConsoleDisableRepo(string module, string[] cmd)
|
||||
{
|
||||
MainConsole.Instance.Output(m_PluginManager.DisableRepository());
|
||||
m_PluginManager.DisableRepository(cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
private void HandleListRepos(string module, string[] cmd)
|
||||
private void HandleConsoleListRepos(string module, string[] cmd)
|
||||
{
|
||||
m_PluginManager.ListRepositories();
|
||||
ArrayList list = m_PluginManager.ListRepositories();
|
||||
foreach (string entry in list)
|
||||
MainConsole.Instance.Output(entry);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private void HandleShowAddinInfo(string module, string[] cmd)
|
||||
private void HandleConsoleShowAddinInfo(string module, string[] cmd)
|
||||
{
|
||||
if ( cmd.Length < 2 )
|
||||
{
|
||||
|
|
|
@ -77,8 +77,8 @@ namespace OpenSim.Services.IntegrationService
|
|||
// defaults to the ./bin directory
|
||||
string RegistryLocation = serverConfig.GetString("PluginRegistryLocation",
|
||||
".");
|
||||
|
||||
m_PluginManager = new PluginManager(RegistryLocation);
|
||||
AddinRegistry registry = new AddinRegistry(RegistryLocation, ".");
|
||||
m_PluginManager = new PluginManager(registry);
|
||||
|
||||
// Deal with files only for now - will add url/environment later
|
||||
m_IntegrationConfigLoc = serverConfig.GetString("IntegrationConfig", String.Empty);
|
||||
|
|
|
@ -26,33 +26,69 @@
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
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.Services.IntegrationService
|
||||
{
|
||||
// This will maintain the plugin repositories and plugins
|
||||
public class PluginManager
|
||||
public class PluginManager : SetupService
|
||||
{
|
||||
protected AddinRegistry m_Registry;
|
||||
protected SetupService m_Service;
|
||||
// protected SetupService m_Service;
|
||||
|
||||
public PluginManager(string registry_path)
|
||||
internal PluginManager( AddinRegistry r): base (r)
|
||||
{
|
||||
m_Registry = new AddinRegistry(registry_path);
|
||||
m_Service = new SetupService(m_Registry);
|
||||
m_Registry = r;
|
||||
}
|
||||
|
||||
public string Install()
|
||||
// public PluginManager(string registry_path)
|
||||
// {
|
||||
// m_Registry = new AddinRegistry(registry_path);
|
||||
// m_Service = new SetupService(m_Registry);
|
||||
// }
|
||||
//
|
||||
public string InstallPlugin(string[] args)
|
||||
{
|
||||
return "Install";
|
||||
PackageCollection pack = new PackageCollection();
|
||||
PackageCollection toUninstall;
|
||||
DependencyCollection unresolved;
|
||||
|
||||
IProgressStatus ps = new ConsoleProgressStatus(true);
|
||||
|
||||
string name = Addin.GetIdName(args[1]);
|
||||
string version = Addin.GetIdVersion(args[1]);
|
||||
|
||||
AddinRepositoryEntry[] aentry = Repositories.GetAvailableAddin(name, version);
|
||||
|
||||
foreach (AddinRepositoryEntry ae in aentry)
|
||||
{
|
||||
Package p = Package.FromRepository(ae);
|
||||
pack.Add(p);
|
||||
}
|
||||
|
||||
|
||||
ResolveDependencies(ps, pack, out toUninstall, out unresolved);
|
||||
|
||||
|
||||
if(Install(ps, pack) == true)
|
||||
return "Install";
|
||||
else
|
||||
return "Bomb";
|
||||
}
|
||||
|
||||
public string UnInstall()
|
||||
public void UnInstall(string[] args)
|
||||
{
|
||||
return "UnInstall";
|
||||
IProgressStatus ps = new ConsoleProgressStatus(true);
|
||||
Addin addin = m_Registry.GetAddin(args[1]);
|
||||
Uninstall(ps, addin.Id);
|
||||
return;
|
||||
}
|
||||
|
||||
public string CheckInstalled()
|
||||
|
@ -67,21 +103,24 @@ namespace OpenSim.Services.IntegrationService
|
|||
MainConsole.Instance.Output("Installed Plugins");
|
||||
foreach (Addin addin in list)
|
||||
{
|
||||
MainConsole.Instance.Output(" - " + addin.Name + " " + addin.Version);
|
||||
MainConsole.Instance.OutputFormat("* {0} rev. {1}", addin.Name, addin.Version);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void ListAvailable()
|
||||
public ArrayList ListAvailable()
|
||||
{
|
||||
MainConsole.Instance.Output("Available Plugins");
|
||||
AddinRepositoryEntry[] addins = m_Service.Repositories.GetAvailableAddins ();
|
||||
// foreach (PackageRepositoryEntry addin in addins)
|
||||
AddinRepositoryEntry[] addins = Repositories.GetAvailableAddins ();
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
foreach (AddinRepositoryEntry addin in addins)
|
||||
{
|
||||
MainConsole.Instance.OutputFormat("{0} - {1} ",addin.Addin.Name, addin.RepositoryName );
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(String.Format("{0} rev. {1}, repo {2}", addin.Addin.Id, addin.Addin.Version, addin.RepositoryUrl));
|
||||
list.Add(sb.ToString());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public string ListUpdates()
|
||||
|
@ -94,8 +133,9 @@ namespace OpenSim.Services.IntegrationService
|
|||
return "Update";
|
||||
}
|
||||
|
||||
public string AddRepository()
|
||||
public string AddRepository(string[] args)
|
||||
{
|
||||
Repositories.RegisterRepository(null, args[2].ToString(), true);
|
||||
return "AddRepository";
|
||||
}
|
||||
|
||||
|
@ -104,24 +144,14 @@ namespace OpenSim.Services.IntegrationService
|
|||
return "GetRepository";
|
||||
}
|
||||
|
||||
public string RemoveRepository()
|
||||
public string RemoveRepository(string[] args)
|
||||
{
|
||||
return "RemoveRepository";
|
||||
}
|
||||
|
||||
public string EnableRepository(string[] args)
|
||||
public void EnableRepository(string[] args)
|
||||
{
|
||||
return "Test";
|
||||
}
|
||||
|
||||
public string DisableRepository()
|
||||
{
|
||||
return DisableRepository();
|
||||
}
|
||||
|
||||
public void ListRepositories()
|
||||
{
|
||||
AddinRepository[] reps = m_Service.Repositories.GetRepositories();
|
||||
AddinRepository[] reps = Repositories.GetRepositories();
|
||||
Array.Sort (reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
|
||||
if (reps.Length == 0)
|
||||
{
|
||||
|
@ -129,20 +159,73 @@ namespace OpenSim.Services.IntegrationService
|
|||
return;
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
MainConsole.Instance.Output("Registered Repositories");
|
||||
int n = Convert.ToInt16(args[2]);
|
||||
if (n > (reps.Length -1))
|
||||
{
|
||||
MainConsole.Instance.Output("Selection out of range");
|
||||
return;
|
||||
}
|
||||
|
||||
AddinRepository rep = reps[n];
|
||||
//return "TEST";
|
||||
Repositories.SetRepositoryEnabled(rep.Url, true);
|
||||
return;
|
||||
//return DisableRepository();
|
||||
}
|
||||
|
||||
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];
|
||||
//return "TEST";
|
||||
Repositories.SetRepositoryEnabled(rep.Url, false);
|
||||
return;
|
||||
//return DisableRepository();
|
||||
}
|
||||
|
||||
public ArrayList ListRepositories()
|
||||
{
|
||||
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 null;
|
||||
}
|
||||
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
int n = 0;
|
||||
foreach (AddinRepository rep in reps)
|
||||
{
|
||||
string num = n.ToString ();
|
||||
MainConsole.Instance.Output(num + ") ");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.AppendFormat("{0}) ", n.ToString());
|
||||
if (!rep.Enabled)
|
||||
MainConsole.Instance.Output("(Disabled) ");
|
||||
MainConsole.Instance.Output(rep.Title);
|
||||
sb.AppendFormat("(Disabled) ");
|
||||
sb.AppendFormat("{0}", rep.Title);
|
||||
if (rep.Title != rep.Url)
|
||||
MainConsole.Instance.Output(new string (' ', num.Length + 2) + rep.Url);
|
||||
sb.AppendFormat("{0}", rep.Url);
|
||||
|
||||
list.Add(sb.ToString());
|
||||
n++;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public void UpdateRegistry()
|
||||
|
|
Loading…
Reference in New Issue