Changing more methods to work with console and rest

integration
BlueWall 2012-04-26 22:12:10 -04:00
parent b5db5d7a57
commit def8012ec1
3 changed files with 176 additions and 35 deletions

View File

@ -75,7 +75,7 @@ namespace OpenSim.Server.Handlers.Integration
return FailureResult("Error, no command defined!"); return FailureResult("Error, no command defined!");
} }
string command = request["command"].AsString (); string command = request["command"].AsString();
switch (command) switch (command)
{ {
@ -85,6 +85,9 @@ namespace OpenSim.Server.Handlers.Integration
case "list_available": case "list_available":
return HandleListAvailablePlugins(request); return HandleListAvailablePlugins(request);
case "show_info":
return HandlePluginInfo(request);
case "install_plugin": case "install_plugin":
return HandleInstallPlugin(request); return HandleInstallPlugin(request);

View File

@ -135,7 +135,11 @@ namespace OpenSim.Services.IntegrationService
// Install plugin from registered repository // Install plugin from registered repository
private void HandleConsoleInstallPlugin(string module, string[] cmd) private void HandleConsoleInstallPlugin(string module, string[] cmd)
{ {
MainConsole.Instance.Output(m_PluginManager.InstallPlugin(cmd)); if (cmd.Length == 2)
{
int ndx = Convert.ToInt16(cmd[1]);
MainConsole.Instance.Output(m_PluginManager.InstallPlugin(ndx));
}
return; return;
} }
@ -144,7 +148,8 @@ namespace OpenSim.Services.IntegrationService
{ {
if (cmd.Length == 2) if (cmd.Length == 2)
{ {
m_PluginManager.UnInstall(cmd); int ndx = Convert.ToInt16(cmd[1]);
m_PluginManager.UnInstall(ndx);
} }
return; return;
} }
@ -220,7 +225,7 @@ namespace OpenSim.Services.IntegrationService
{ {
if ( cmd.Length == 3) if ( cmd.Length == 3)
{ {
m_PluginManager.AddRepository(cmd); m_PluginManager.AddRepository(cmd[2]);
} }
return; return;
} }
@ -271,9 +276,6 @@ namespace OpenSim.Services.IntegrationService
enabled == true ? "[ ]" : "[X]", enabled == true ? "[ ]" : "[X]",
repo["name"], repo["url"]); repo["name"], repo["url"]);
} }
//ArrayList list = m_PluginManager.ListRepositories();
//foreach (string entry in list)
// MainConsole.Instance.Output(entry);
return; return;
} }
@ -281,9 +283,22 @@ namespace OpenSim.Services.IntegrationService
// Show description information // Show description information
private void HandleConsoleShowAddinInfo(string module, string[] cmd) private void HandleConsoleShowAddinInfo(string module, string[] cmd)
{ {
if ( cmd.Length >= 3 ) if (cmd.Length >= 3)
{ {
m_PluginManager.AddinInfo(cmd);
Dictionary<string, object> result = new Dictionary<string, object>();
int ndx = Convert.ToInt16(cmd[2]);
m_PluginManager.AddinInfo(ndx, out result);
MainConsole.Instance.OutputFormat("Name: {0}\nURL: {1}\n{2}\n{3}",
result["name"],
result["url"],
result["file_name"],
result["author"],
result["category"],
result["description"]);
return; return;
} }
} }
@ -340,9 +355,21 @@ namespace OpenSim.Services.IntegrationService
return Ux.DocToBytes(json); return Ux.DocToBytes(json);
} }
public byte[] HandleWebPluginInfo (OSDMap request) public byte[] HandleWebPluginInfo(OSDMap request)
{ {
return Ux.FailureResult("Not Implemented"); Dictionary<string, object> result = new Dictionary<string, object>();
if(!String.IsNullOrEmpty(request["index"].ToString()))
{
int ndx = Convert.ToInt16(request["index"].ToString());
m_PluginManager.AddinInfo(ndx, out result);
string json = LitJson.JsonMapper.ToJson(result);
return Ux.DocToBytes(json);
}
else
{
return Ux.FailureResult("No index supplied");
}
} }
public byte[] HandleWebListAvailablePlugins(OSDMap request) public byte[] HandleWebListAvailablePlugins(OSDMap request)

View File

@ -44,13 +44,28 @@ namespace OpenSim.Services.IntegrationService
{ {
protected AddinRegistry m_Registry; protected AddinRegistry m_Registry;
/// <summary>
/// Initializes a new instance of the <see cref="OpenSim.Services.IntegrationService.PluginManager"/> class.
/// </summary>
/// <param name='r'>
/// R.
/// </param>
internal PluginManager( AddinRegistry r): base (r) internal PluginManager( AddinRegistry r): base (r)
{ {
m_Registry = r; m_Registry = r;
m_Registry.Update(); m_Registry.Update();
} }
public string InstallPlugin(string[] args) /// <summary>
/// Installs the plugin.
/// </summary>
/// <returns>
/// The plugin.
/// </returns>
/// <param name='args'>
/// Arguments.
/// </param>
public string InstallPlugin(int ndx)
{ {
PackageCollection pack = new PackageCollection(); PackageCollection pack = new PackageCollection();
PackageCollection toUninstall; PackageCollection toUninstall;
@ -58,19 +73,15 @@ namespace OpenSim.Services.IntegrationService
IProgressStatus ps = new ConsoleProgressStatus(false); IProgressStatus ps = new ConsoleProgressStatus(false);
string name = Addin.GetIdName(args[1]);
string version = Addin.GetIdVersion(args[1]);
AddinRepositoryEntry[] available = GetSortedAvailbleAddins(); AddinRepositoryEntry[] available = GetSortedAvailbleAddins();
int n = Convert.ToInt16(args[1]); if (ndx > (available.Length - 1))
if (n > (available.Length - 1))
{ {
MainConsole.Instance.Output("Selection out of range"); MainConsole.Instance.Output("Selection out of range");
return "Error"; return "Error";
} }
AddinRepositoryEntry aentry = available[n]; AddinRepositoryEntry aentry = available[ndx];
Package p = Package.FromRepository(aentry); Package p = Package.FromRepository(aentry);
pack.Add(p); pack.Add(p);
@ -93,18 +104,23 @@ namespace OpenSim.Services.IntegrationService
} }
// Remove plugin // Remove plugin
public void UnInstall(string[] args) /// <summary>
/// Uns the install.
/// </summary>
/// <param name='args'>
/// Arguments.
/// </param>
public void UnInstall(int ndx)
{ {
Addin[] addins = GetSortedAddinList("IntegrationPlugin"); Addin[] addins = GetSortedAddinList("IntegrationPlugin");
int n = Convert.ToInt16(args[1]); if (ndx > (addins.Length -1))
if (n > (addins.Length -1))
{ {
MainConsole.Instance.Output("Selection out of range"); MainConsole.Instance.Output("Selection out of range");
return; return;
} }
Addin addin = addins[n]; Addin addin = addins[ndx];
MainConsole.Instance.OutputFormat("Uninstalling plugin {0}", addin.Id); MainConsole.Instance.OutputFormat("Uninstalling plugin {0}", addin.Id);
AddinManager.Registry.DisableAddin(addin.Id); AddinManager.Registry.DisableAddin(addin.Id);
addin.Enabled = false; addin.Enabled = false;
@ -113,12 +129,23 @@ namespace OpenSim.Services.IntegrationService
return; return;
} }
/// <summary>
/// Checks the installed.
/// </summary>
/// <returns>
/// The installed.
/// </returns>
public string CheckInstalled() public string CheckInstalled()
{ {
return "CheckInstall"; return "CheckInstall";
} }
// List instaled addins /// <summary>
/// Lists the installed addins.
/// </summary>
/// <param name='result'>
/// Result.
/// </param>
public void ListInstalledAddins(out Dictionary<string, object> result) public void ListInstalledAddins(out Dictionary<string, object> result)
{ {
Dictionary<string, object> res = new Dictionary<string, object>(); Dictionary<string, object> res = new Dictionary<string, object>();
@ -142,6 +169,12 @@ namespace OpenSim.Services.IntegrationService
} }
// List compatible plugins in registered repositories // List compatible plugins in registered repositories
/// <summary>
/// Lists the available.
/// </summary>
/// <param name='result'>
/// Result.
/// </param>
public void ListAvailable(out Dictionary<string, object> result) public void ListAvailable(out Dictionary<string, object> result)
{ {
Dictionary<string, object> res = new Dictionary<string, object>(); Dictionary<string, object> res = new Dictionary<string, object>();
@ -164,6 +197,9 @@ namespace OpenSim.Services.IntegrationService
} }
// List available updates ** 1 // List available updates ** 1
/// <summary>
/// Lists the updates.
/// </summary>
public void ListUpdates() public void ListUpdates()
{ {
IProgressStatus ps = new ConsoleProgressStatus(true); IProgressStatus ps = new ConsoleProgressStatus(true);
@ -180,6 +216,9 @@ namespace OpenSim.Services.IntegrationService
} }
// Sync to repositories // Sync to repositories
/// <summary>
/// Update this instance.
/// </summary>
public string Update() public string Update()
{ {
IProgressStatus ps = new ConsoleProgressStatus(true); IProgressStatus ps = new ConsoleProgressStatus(true);
@ -188,18 +227,36 @@ namespace OpenSim.Services.IntegrationService
} }
// Register a repository // Register a repository
public string AddRepository(string[] args) /// <summary>
/// Register a repository with our server.
/// </summary>
/// <returns>
/// result of the action
/// </returns>
/// <param name='repo'>
/// The URL of the repository we want to add
/// </param>
public bool AddRepository(string repo)
{ {
Repositories.RegisterRepository(null, args[2].ToString(), true); Repositories.RegisterRepository(null, repo, true);
return "AddRepository"; return true;
} }
/// <summary>
/// Gets the repository.
/// </summary>
public void GetRepository() public void GetRepository()
{ {
Repositories.UpdateAllRepositories(new ConsoleProgressStatus(false)); Repositories.UpdateAllRepositories(new ConsoleProgressStatus(false));
} }
// Remove a repository from the list // Remove a repository from the list
/// <summary>
/// Removes the repository.
/// </summary>
/// <param name='args'>
/// Arguments.
/// </param>
public void RemoveRepository(string[] args) public void RemoveRepository(string[] args)
{ {
AddinRepository[] reps = Repositories.GetRepositories(); AddinRepository[] reps = Repositories.GetRepositories();
@ -223,6 +280,12 @@ namespace OpenSim.Services.IntegrationService
} }
// Enable repository // Enable repository
/// <summary>
/// Enables the repository.
/// </summary>
/// <param name='args'>
/// Arguments.
/// </param>
public void EnableRepository(string[] args) public void EnableRepository(string[] args)
{ {
AddinRepository[] reps = Repositories.GetRepositories(); AddinRepository[] reps = Repositories.GetRepositories();
@ -246,6 +309,12 @@ namespace OpenSim.Services.IntegrationService
} }
// Disable a repository // Disable a repository
/// <summary>
/// Disables the repository.
/// </summary>
/// <param name='args'>
/// Arguments.
/// </param>
public void DisableRepository(string[] args) public void DisableRepository(string[] args)
{ {
AddinRepository[] reps = Repositories.GetRepositories(); AddinRepository[] reps = Repositories.GetRepositories();
@ -269,6 +338,12 @@ namespace OpenSim.Services.IntegrationService
} }
// List registered repositories // List registered repositories
/// <summary>
/// Lists the repositories.
/// </summary>
/// <param name='result'>
/// Result.
/// </param>
public void ListRepositories(out Dictionary<string, object> result) public void ListRepositories(out Dictionary<string, object> result)
{ {
Dictionary<string, object> res = new Dictionary<string, object>(); Dictionary<string, object> res = new Dictionary<string, object>();
@ -295,32 +370,62 @@ namespace OpenSim.Services.IntegrationService
return; return;
} }
/// <summary>
/// Updates the registry.
/// </summary>
public void UpdateRegistry() public void UpdateRegistry()
{ {
m_Registry.Update(); m_Registry.Update();
} }
// Show plugin info // Show plugin info
public string AddinInfo(string[] args) /// <summary>
/// Addins the info.
/// </summary>
/// <returns>
/// The info.
/// </returns>
/// <param name='args'>
/// Arguments.
/// </param>
public bool AddinInfo(int ndx, out Dictionary<string, object> result)
{ {
Dictionary<string, object> res = new Dictionary<string, object>();
result = res;
Addin[] addins = GetSortedAddinList("IntegrationPlugin"); Addin[] addins = GetSortedAddinList("IntegrationPlugin");
int n = Convert.ToInt16(args[2]); if (ndx > (addins.Length - 1))
if (n > (addins.Length -1))
{ {
MainConsole.Instance.Output("Selection out of range"); MainConsole.Instance.Output("Selection out of range");
return "XXX"; return false;
} }
// author category description
Addin addin = addins[ndx];
Addin addin = addins[n]; res["author"] = addin.Description.Author;
MainConsole.Instance.OutputFormat("Name: {0}\nURL: {1}\n{2}", res["category"] = addin.Description.Category;
addin.Name, addin.Description.Url, res["description"] = addin.Description.Description;
addin.Description.FileName); res["name"] = addin.Name;
res["url"] = addin.Description.Url;
res["file_name"] = addin.Description.FileName;
return "AddinInfo"; // MainConsole.Instance.OutputFormat("Name: {0}\nURL: {1}\n{2}",
// addin.Name, addin.Description.Url,
// addin.Description.FileName);
result = res;
return true;
} }
// Disable a plugin // Disable a plugin
/// <summary>
/// Disables the plugin.
/// </summary>
/// <param name='args'>
/// Arguments.
/// </param>
public void DisablePlugin(string[] args) public void DisablePlugin(string[] args)
{ {
Addin[] addins = GetSortedAddinList("IntegrationPlugin"); Addin[] addins = GetSortedAddinList("IntegrationPlugin");
@ -339,6 +444,12 @@ namespace OpenSim.Services.IntegrationService
} }
// Enable plugin // Enable plugin
/// <summary>
/// Enables the plugin.
/// </summary>
/// <param name='args'>
/// Arguments.
/// </param>
public void EnablePlugin(string[] args) public void EnablePlugin(string[] args)
{ {
Addin[] addins = GetSortedAddinList("IntegrationPlugin"); Addin[] addins = GetSortedAddinList("IntegrationPlugin");