From d00df295d6c87cfc5b2d8551921721cf5c5b3e45 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Fri, 27 Apr 2012 15:41:21 -0400 Subject: [PATCH] Converting more functions to new style for REST/Console --- .../IntegrationService/IntegrationService.cs | 49 +++++++++++++++++-- .../IntegrationService/PluginManager.cs | 21 ++++---- 2 files changed, 55 insertions(+), 15 deletions(-) diff --git a/OpenSim/Services/IntegrationService/IntegrationService.cs b/OpenSim/Services/IntegrationService/IntegrationService.cs index 20f106d581..e229edd041 100644 --- a/OpenSim/Services/IntegrationService/IntegrationService.cs +++ b/OpenSim/Services/IntegrationService/IntegrationService.cs @@ -133,12 +133,41 @@ namespace OpenSim.Services.IntegrationService // Handle our console commands // // Install plugin from registered repository + /// + /// Handles the console install plugin command. Attempts to install the selected plugin + /// and + /// + /// + /// Module. + /// + /// + /// Cmd. + /// private void HandleConsoleInstallPlugin(string module, string[] cmd) { + Dictionary result = new Dictionary(); + if (cmd.Length == 2) { int ndx = Convert.ToInt16(cmd[1]); - MainConsole.Instance.Output(m_PluginManager.InstallPlugin(ndx)); + if (m_PluginManager.InstallPlugin(ndx, out result) == true) + { + ArrayList s = new ArrayList(); + s.AddRange(result.Keys); + s.Sort(); + + var list = result.Keys.ToList(); + list.Sort(); + foreach (var k in list) + { + Dictionary plugin = (Dictionary)result[k]; + bool enabled = (bool)plugin["enabled"]; + MainConsole.Instance.OutputFormat("{0}) {1} {2} rev. {3}", + k, + enabled == true ? "[ ]" : "[X]", + plugin["name"], plugin["version"]); + } + } } return; } @@ -287,11 +316,11 @@ namespace OpenSim.Services.IntegrationService { Dictionary result = new Dictionary(); - + int ndx = Convert.ToInt16(cmd[2]); m_PluginManager.AddinInfo(ndx, out result); - MainConsole.Instance.OutputFormat("Name: {0}\nURL: {1}\n{2}\n{3}", + MainConsole.Instance.OutputFormat("Name: {0}\nURL: {1}\nFile: {2}\nAuthor: {3}\nCategory: {4}\nDesc: {5}", result["name"], result["url"], result["file_name"], @@ -380,9 +409,19 @@ namespace OpenSim.Services.IntegrationService return Ux.DocToBytes(json); } - public byte[] HandleWebInstallPlugin (OSDMap request) + public byte[] HandleWebInstallPlugin(OSDMap request) { - return Ux.FailureResult("Not Implemented"); + Dictionary result = new Dictionary(); + int ndx = Convert.ToInt16(request["index"].ToString()); + if (m_PluginManager.InstallPlugin(ndx, out result) == true) + { + string json = LitJson.JsonMapper.ToJson(result); + return Ux.DocToBytes(json); + } + else + { + return Ux.FailureResult("No index supplied"); + } } public byte[] HandleWebUnInstallPlugin (OSDMap request) diff --git a/OpenSim/Services/IntegrationService/PluginManager.cs b/OpenSim/Services/IntegrationService/PluginManager.cs index e18aeea700..85637003fd 100644 --- a/OpenSim/Services/IntegrationService/PluginManager.cs +++ b/OpenSim/Services/IntegrationService/PluginManager.cs @@ -65,8 +65,10 @@ namespace OpenSim.Services.IntegrationService /// /// Arguments. /// - public string InstallPlugin(int ndx) + public bool InstallPlugin(int ndx, out Dictionary result) { + Dictionary res = new Dictionary(); + PackageCollection pack = new PackageCollection(); PackageCollection toUninstall; DependencyCollection unresolved; @@ -78,7 +80,8 @@ namespace OpenSim.Services.IntegrationService if (ndx > (available.Length - 1)) { MainConsole.Instance.Output("Selection out of range"); - return "Error"; + result = res; + return false; } AddinRepositoryEntry aentry = available[ndx]; @@ -95,11 +98,14 @@ namespace OpenSim.Services.IntegrationService Addin addin = m_Registry.GetAddin(aentry.Addin.Id); m_Registry.DisableAddin(addin.Id); addin.Enabled = false; - return "Install"; - } + ListInstalledAddins(out res); + result = res; + return true; + } else { - return "Bomb"; + result = res; + return false; } } @@ -410,12 +416,7 @@ namespace OpenSim.Services.IntegrationService res["url"] = addin.Description.Url; res["file_name"] = addin.Description.FileName; -// MainConsole.Instance.OutputFormat("Name: {0}\nURL: {1}\n{2}", -// addin.Name, addin.Description.Url, -// addin.Description.FileName); - result = res; - return true; }