Start filling out commands

integration
BlueWall 2012-04-05 23:48:25 -04:00
parent de1d213117
commit 1aab096a83
2 changed files with 61 additions and 22 deletions

View File

@ -26,6 +26,7 @@
*/
using System;
using System.Collections;
using System.Reflection;
using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
@ -35,6 +36,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenMetaverse;
using Nini.Config;
using log4net;
using Mono.Addins;
namespace OpenSim.Services.IntegrationService
@ -48,7 +50,7 @@ namespace OpenSim.Services.IntegrationService
{
m_log.InfoFormat("[INTEGRATION SERVICE]: Loaded");
// Add a command to the console
// Add commands to the console
if (MainConsole.Instance != null)
{
AddConsoleCommands();
@ -77,7 +79,8 @@ namespace OpenSim.Services.IntegrationService
"list available", "list available \"plugin name=\"","List available plugins",
HandleListAvailablePlugin);
MainConsole.Instance.Commands.AddCommand("Integration", true, "list updates", "list updates","List availble updates",
MainConsole.Instance.Commands.AddCommand("Integration", true,
"list updates", "list updates","List availble updates",
HandleListUpdates);
MainConsole.Instance.Commands.AddCommand("Integration", true,
@ -88,7 +91,8 @@ namespace OpenSim.Services.IntegrationService
"add repo", "add repo \"url\"","Add repository",
HandleAddRepo);
MainConsole.Instance.Commands.AddCommand("Integration", true, "get repo", "get repo \"url\"", "Sync with a registered repository",
MainConsole.Instance.Commands.AddCommand("Integration", true,
"get repo", "get repo \"url\"", "Sync with a registered repository",
HandleGetRepo);
MainConsole.Instance.Commands.AddCommand("Integration", true,
@ -134,13 +138,13 @@ namespace OpenSim.Services.IntegrationService
private void HandleListInstalledPlugin(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.ListInstalled());
m_PluginManager.ListInstalledAddins();
return;
}
private void HandleListAvailablePlugin(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.ListAvailable());
m_PluginManager.ListAvailable();
return;
}
@ -176,7 +180,7 @@ namespace OpenSim.Services.IntegrationService
private void HandleEnableRepo(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.EnableRepository());
m_PluginManager.EnableRepository(cmd);
return;
}
@ -188,7 +192,7 @@ namespace OpenSim.Services.IntegrationService
private void HandleListRepos(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.ListRepositories());
m_PluginManager.ListRepositories();
return;
}

View File

@ -26,8 +26,10 @@
*/
using System;
using System.Collections;
using Mono.Addins;
using Mono.Addins.Setup;
using OpenSim.Framework;
namespace OpenSim.Services.IntegrationService
{
@ -35,14 +37,12 @@ namespace OpenSim.Services.IntegrationService
public class PluginManager
{
protected AddinRegistry m_Registry;
protected SetupService m_Manager;
protected SetupService m_Service;
public PluginManager(string registry_path)
{
m_Registry = new AddinRegistry(".", registry_path);
m_Manager = new SetupService(m_Registry);
m_Registry = new AddinRegistry(registry_path);
m_Service = new SetupService(m_Registry);
}
public string Install()
@ -60,14 +60,28 @@ namespace OpenSim.Services.IntegrationService
return "CheckInstall";
}
public string ListInstalled()
public void ListInstalledAddins()
{
return "ListInstalled";
ArrayList list = new ArrayList();
list.AddRange(m_Registry.GetAddins());
MainConsole.Instance.Output("Installed Plugins");
foreach (Addin addin in list)
{
MainConsole.Instance.Output(" - " + addin.Name + " " + addin.Version);
}
public string ListAvailable()
return;
}
public void ListAvailable()
{
return "ListAvailable";
MainConsole.Instance.Output("Available Plugins");
AddinRepositoryEntry[] addins = m_Service.Repositories.GetAvailableAddins ();
// foreach (PackageRepositoryEntry addin in addins)
foreach (AddinRepositoryEntry addin in addins)
{
MainConsole.Instance.OutputFormat("{0} - {1} ",addin.Addin.Name, addin.RepositoryName );
}
}
public string ListUpdates()
@ -95,9 +109,9 @@ namespace OpenSim.Services.IntegrationService
return "RemoveRepository";
}
public string EnableRepository()
public string EnableRepository(string[] args)
{
return "EnableRepository";
return "Test";
}
public string DisableRepository()
@ -105,14 +119,35 @@ namespace OpenSim.Services.IntegrationService
return DisableRepository();
}
public string ListRepositories()
public void ListRepositories()
{
return "ListRepositories";
AddinRepository[] reps = m_Service.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;
}
public string UpdateRegistry()
int n = 0;
MainConsole.Instance.Output("Registered Repositories");
foreach (AddinRepository rep in reps)
{
return "UpdateRegistry";
string num = n.ToString ();
MainConsole.Instance.Output(num + ") ");
if (!rep.Enabled)
MainConsole.Instance.Output("(Disabled) ");
MainConsole.Instance.Output(rep.Title);
if (rep.Title != rep.Url)
MainConsole.Instance.Output(new string (' ', num.Length + 2) + rep.Url);
n++;
}
}
public void UpdateRegistry()
{
m_Registry.Update();
}
public string AddinInfo()