From 6fd803f24f5ab44fd917183ce9781944e0262666 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Wed, 25 Apr 2012 10:05:41 -0400 Subject: [PATCH] Some more handlers added/converted --- .../IntegrationService/IntegrationService.cs | 54 +++++++++++++++---- .../IntegrationService/PluginManager.cs | 51 +++++++++++------- 2 files changed, 75 insertions(+), 30 deletions(-) diff --git a/OpenSim/Services/IntegrationService/IntegrationService.cs b/OpenSim/Services/IntegrationService/IntegrationService.cs index 97286595c5..b761411b1b 100644 --- a/OpenSim/Services/IntegrationService/IntegrationService.cs +++ b/OpenSim/Services/IntegrationService/IntegrationService.cs @@ -166,7 +166,9 @@ namespace OpenSim.Services.IntegrationService s.AddRange(result.Keys); s.Sort(); - foreach (string k in s) + var list = result.Keys.ToList(); + list.Sort(); + foreach (var k in list) { Dictionary plugin = (Dictionary)result[k]; bool enabled = (bool)plugin["enabled"]; @@ -181,10 +183,20 @@ namespace OpenSim.Services.IntegrationService // List available plugins on registered repositories private void HandleConsoleListAvailablePlugin(string module, string[] cmd) { - ArrayList list = m_PluginManager.ListAvailable(); - foreach (string entry in list) - MainConsole.Instance.Output(entry); + Dictionary result = new Dictionary(); + m_PluginManager.ListAvailable(out result); + var list = result.Keys.ToList(); + list.Sort(); + foreach (var k in list) + { + // name, version, repository + Dictionary plugin = (Dictionary)result[k]; + MainConsole.Instance.OutputFormat("{0} rev. {1} {2}", + plugin["name"], + plugin["version"], + plugin["repository"]); + } return; } @@ -244,9 +256,23 @@ namespace OpenSim.Services.IntegrationService // List repositories private void HandleConsoleListRepos(string module, string[] cmd) { - ArrayList list = m_PluginManager.ListRepositories(); - foreach (string entry in list) - MainConsole.Instance.Output(entry); + Dictionary result = new Dictionary(); + m_PluginManager.ListRepositories(out result); + + var list = result.Keys.ToList(); + list.Sort(); + foreach (var k in list) + { + Dictionary repo = (Dictionary)result[k]; + bool enabled = (bool)repo["enabled"]; + MainConsole.Instance.OutputFormat("{0}) {1} {2}", + k, + enabled == true ? "[ ]" : "[X]", + repo["name"], repo["url"]); + } + //ArrayList list = m_PluginManager.ListRepositories(); + //foreach (string entry in list) + // MainConsole.Instance.Output(entry); return; } @@ -277,9 +303,12 @@ namespace OpenSim.Services.IntegrationService #endregion #region IIntegrationService implementation - public byte[] HandleWebListRepositories (OSDMap request) + public byte[] HandleWebListRepositories(OSDMap request) { - return Ux.FailureResult("Not Implemented"); + Dictionary result = new Dictionary(); + m_PluginManager.ListRepositories(out result); + string json = LitJson.JsonMapper.ToJson(result); + return Ux.DocToBytes(json); } public byte[] HandleWebAddRepository (OSDMap request) @@ -315,9 +344,12 @@ namespace OpenSim.Services.IntegrationService return Ux.FailureResult("Not Implemented"); } - public byte[] HandleWebListAvailablePlugins (OSDMap request) + public byte[] HandleWebListAvailablePlugins(OSDMap request) { - return Ux.FailureResult("Not Implemented"); + Dictionary result = new Dictionary(); + m_PluginManager.ListAvailable(out result); + string json = LitJson.JsonMapper.ToJson(result); + return Ux.DocToBytes(json); } public byte[] HandleWebInstallPlugin (OSDMap request) diff --git a/OpenSim/Services/IntegrationService/PluginManager.cs b/OpenSim/Services/IntegrationService/PluginManager.cs index 4b18ea514a..4ea99b4f66 100644 --- a/OpenSim/Services/IntegrationService/PluginManager.cs +++ b/OpenSim/Services/IntegrationService/PluginManager.cs @@ -133,33 +133,37 @@ namespace OpenSim.Services.IntegrationService r["name"] = addin.LocalId; r["version"] = addin.Version; - res.Add(count.ToString(), r); + result.Add(count.ToString(), r); count++; } - result = res; return; } // List compatible plugins in registered repositories - public ArrayList ListAvailable() + public void ListAvailable(out Dictionary result) { + Dictionary res = new Dictionary(); + AddinRepositoryEntry[] addins = GetSortedAvailbleAddins(); - ArrayList list = new ArrayList(); int count = 0; foreach (AddinRepositoryEntry addin in addins) { - StringBuilder sb = new StringBuilder(); - sb.Append(String.Format("{0}) {1} rev. {2}, repo {3}", count.ToString(), addin.Addin.Name, addin.Addin.Version, addin.RepositoryName)); - list.Add(sb.ToString()); + Dictionary r = new Dictionary(); + r["name"] = addin.Addin.Name; + r["version"] = addin.Addin.Version; + r["repository"] = addin.RepositoryName; + + res.Add(count.ToString(), r); count++; } - return list; + result = res; + return; } - // List available updates + // List available updates ** 1 public void ListUpdates() { IProgressStatus ps = new ConsoleProgressStatus(true); @@ -265,25 +269,30 @@ namespace OpenSim.Services.IntegrationService } // List registered repositories - public ArrayList ListRepositories() + public void ListRepositories(out Dictionary result) { - AddinRepository[] reps = Repositories.GetRepositories(); - Array.Sort (reps, (r1,r2) => r1.Title.CompareTo(r2.Title)); + Dictionary res = new Dictionary(); + result = res; + + AddinRepository[] reps = GetSortedAddinRepo(); if (reps.Length == 0) { MainConsole.Instance.Output("No repositories have been registered."); - return null; + return; } - ArrayList list = new ArrayList(); - - int n = 0; + int count = 0; foreach (AddinRepository rep in reps) { - list.Add(String.Format("{0}) {1} {2} {3}",n.ToString(), rep.Enabled == true ? "[ ]" : "[X]", rep.Name, rep.Url)); - n++; + 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 list; + return; } public void UpdateRegistry() @@ -418,5 +427,9 @@ namespace OpenSim.Services.IntegrationService return addins; } #endregion Util + + #region Notes + // ** 1 Not working + #endregion Notes } } \ No newline at end of file