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.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];
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<string, object> result = new Dictionary<string, object>();
m_PluginManager.ListAvailable(out result);
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;
}
@ -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<string, object> result = new Dictionary<string, object>();
m_PluginManager.ListRepositories(out result);
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;
}
@ -279,7 +305,10 @@ namespace OpenSim.Services.IntegrationService
#region IIntegrationService implementation
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)
@ -317,7 +346,10 @@ namespace OpenSim.Services.IntegrationService
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)

View File

@ -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<string, object> result)
{
Dictionary<string, object> res = new Dictionary<string, object>();
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<string, object> r = new Dictionary<string, object>();
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<string, object> result)
{
AddinRepository[] reps = Repositories.GetRepositories();
Array.Sort (reps, (r1,r2) => r1.Title.CompareTo(r2.Title));
Dictionary<string, object> res = new Dictionary<string, object>();
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<string, object> r = new Dictionary<string, object>();
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
}
}