Some more handlers added/converted

integration
BlueWall 2012-04-25 10:05:41 -04:00
parent 32a70fb7e9
commit 6fd803f24f
2 changed files with 75 additions and 30 deletions

View File

@ -166,7 +166,9 @@ namespace OpenSim.Services.IntegrationService
s.AddRange(result.Keys); s.AddRange(result.Keys);
s.Sort(); s.Sort();
foreach (string k in s) var list = result.Keys.ToList();
list.Sort();
foreach (var k in list)
{ {
Dictionary<string, object> plugin = (Dictionary<string, object>)result[k]; Dictionary<string, object> plugin = (Dictionary<string, object>)result[k];
bool enabled = (bool)plugin["enabled"]; bool enabled = (bool)plugin["enabled"];
@ -181,10 +183,20 @@ namespace OpenSim.Services.IntegrationService
// List available plugins on registered repositories // List available plugins on registered repositories
private void HandleConsoleListAvailablePlugin(string module, string[] cmd) private void HandleConsoleListAvailablePlugin(string module, string[] cmd)
{ {
ArrayList list = m_PluginManager.ListAvailable(); Dictionary<string, object> result = new Dictionary<string, object>();
foreach (string entry in list) m_PluginManager.ListAvailable(out result);
MainConsole.Instance.Output(entry);
var list = result.Keys.ToList();
list.Sort();
foreach (var k in list)
{
// name, version, repository
Dictionary<string, object> plugin = (Dictionary<string, object>)result[k];
MainConsole.Instance.OutputFormat("{0} rev. {1} {2}",
plugin["name"],
plugin["version"],
plugin["repository"]);
}
return; return;
} }
@ -244,9 +256,23 @@ namespace OpenSim.Services.IntegrationService
// List repositories // List repositories
private void HandleConsoleListRepos(string module, string[] cmd) private void HandleConsoleListRepos(string module, string[] cmd)
{ {
ArrayList list = m_PluginManager.ListRepositories(); Dictionary<string, object> result = new Dictionary<string, object>();
foreach (string entry in list) m_PluginManager.ListRepositories(out result);
MainConsole.Instance.Output(entry);
var list = result.Keys.ToList();
list.Sort();
foreach (var k in list)
{
Dictionary<string, object> repo = (Dictionary<string, object>)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; return;
} }
@ -279,7 +305,10 @@ namespace OpenSim.Services.IntegrationService
#region IIntegrationService implementation #region IIntegrationService implementation
public byte[] HandleWebListRepositories(OSDMap request) public byte[] HandleWebListRepositories(OSDMap request)
{ {
return Ux.FailureResult("Not Implemented"); Dictionary<string, object> result = new Dictionary<string, object>();
m_PluginManager.ListRepositories(out result);
string json = LitJson.JsonMapper.ToJson(result);
return Ux.DocToBytes(json);
} }
public byte[] HandleWebAddRepository (OSDMap request) public byte[] HandleWebAddRepository (OSDMap request)
@ -317,7 +346,10 @@ namespace OpenSim.Services.IntegrationService
public byte[] HandleWebListAvailablePlugins(OSDMap request) public byte[] HandleWebListAvailablePlugins(OSDMap request)
{ {
return Ux.FailureResult("Not Implemented"); Dictionary<string, object> result = new Dictionary<string, object>();
m_PluginManager.ListAvailable(out result);
string json = LitJson.JsonMapper.ToJson(result);
return Ux.DocToBytes(json);
} }
public byte[] HandleWebInstallPlugin (OSDMap request) public byte[] HandleWebInstallPlugin (OSDMap request)

View File

@ -133,33 +133,37 @@ namespace OpenSim.Services.IntegrationService
r["name"] = addin.LocalId; r["name"] = addin.LocalId;
r["version"] = addin.Version; r["version"] = addin.Version;
res.Add(count.ToString(), r); result.Add(count.ToString(), r);
count++; count++;
} }
result = res; result = res;
return; return;
} }
// List compatible plugins in registered repositories // List compatible plugins in registered repositories
public ArrayList ListAvailable() public void ListAvailable(out Dictionary<string, object> result)
{ {
Dictionary<string, object> res = new Dictionary<string, object>();
AddinRepositoryEntry[] addins = GetSortedAvailbleAddins(); AddinRepositoryEntry[] addins = GetSortedAvailbleAddins();
ArrayList list = new ArrayList();
int count = 0; int count = 0;
foreach (AddinRepositoryEntry addin in addins) foreach (AddinRepositoryEntry addin in addins)
{ {
StringBuilder sb = new StringBuilder(); Dictionary<string, object> r = new Dictionary<string, object>();
sb.Append(String.Format("{0}) {1} rev. {2}, repo {3}", count.ToString(), addin.Addin.Name, addin.Addin.Version, addin.RepositoryName)); r["name"] = addin.Addin.Name;
list.Add(sb.ToString()); r["version"] = addin.Addin.Version;
r["repository"] = addin.RepositoryName;
res.Add(count.ToString(), r);
count++; count++;
} }
return list; result = res;
return;
} }
// List available updates // List available updates ** 1
public void ListUpdates() public void ListUpdates()
{ {
IProgressStatus ps = new ConsoleProgressStatus(true); IProgressStatus ps = new ConsoleProgressStatus(true);
@ -265,25 +269,30 @@ namespace OpenSim.Services.IntegrationService
} }
// List registered repositories // List registered repositories
public ArrayList ListRepositories() public void ListRepositories(out Dictionary<string, object> result)
{ {
AddinRepository[] reps = Repositories.GetRepositories(); Dictionary<string, object> res = new Dictionary<string, object>();
Array.Sort (reps, (r1,r2) => r1.Title.CompareTo(r2.Title)); result = res;
AddinRepository[] reps = GetSortedAddinRepo();
if (reps.Length == 0) if (reps.Length == 0)
{ {
MainConsole.Instance.Output("No repositories have been registered."); MainConsole.Instance.Output("No repositories have been registered.");
return null; return;
} }
ArrayList list = new ArrayList(); int count = 0;
int n = 0;
foreach (AddinRepository rep in reps) foreach (AddinRepository rep in reps)
{ {
list.Add(String.Format("{0}) {1} {2} {3}",n.ToString(), rep.Enabled == true ? "[ ]" : "[X]", rep.Name, rep.Url)); Dictionary<string, object> r = new Dictionary<string, object>();
n++; 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() public void UpdateRegistry()
@ -418,5 +427,9 @@ namespace OpenSim.Services.IntegrationService
return addins; return addins;
} }
#endregion Util #endregion Util
#region Notes
// ** 1 Not working
#endregion Notes
} }
} }