Make sorted lists for selecting plugins for operations

integration
BlueWall 2012-04-21 17:51:44 -04:00
parent 05b369965e
commit bd0dfc1d6d
2 changed files with 46 additions and 15 deletions

View File

@ -87,7 +87,10 @@ namespace OpenSim.Services.IntegrationService
AddinRegistry registry ; AddinRegistry registry ;
bool DEVELOPMENT = serverConfig.GetBoolean("DevelopmentMode", false); bool DEVELOPMENT = serverConfig.GetBoolean("DevelopmentMode", false);
// Are we developing plugins? We will load them now // Are we developing plugins? We will load them now.
// This will allow debugging of the modules and will
// use the runtime directory for the registry. Will not
// be able to use the repo/registry commands ...
if (DEVELOPMENT == true) if (DEVELOPMENT == true)
{ {
AddinManager.Initialize ("."); AddinManager.Initialize (".");
@ -146,12 +149,11 @@ namespace OpenSim.Services.IntegrationService
AddinManager.AddinLoaded += on_addinloaded_; AddinManager.AddinLoaded += on_addinloaded_;
AddinManager.AddinLoadError += on_addinloaderror_; AddinManager.AddinLoadError += on_addinloaderror_;
AddinManager.AddinUnloaded += HandleAddinManagerAddinUnloaded; AddinManager.AddinUnloaded += HandleAddinManagerAddinUnloaded;
AddinManager.AddExtensionNodeHandler ("/OpenSim/IntegrationService", OnExtensionChanged); AddinManager.AddExtensionNodeHandler ("/OpenSim/IntegrationService", OnExtensionChanged);
} }
} }
#region addin event handlers
void HandleAddinManagerAddinEngineExtensionChanged (object sender, ExtensionEventArgs args) void HandleAddinManagerAddinEngineExtensionChanged (object sender, ExtensionEventArgs args)
{ {
MainConsole.Instance.Output(String.Format ("Plugin Extension Change Path:{0}", args.Path)); MainConsole.Instance.Output(String.Format ("Plugin Extension Change Path:{0}", args.Path));
@ -207,6 +209,7 @@ namespace OpenSim.Services.IntegrationService
{ {
m_log.Info ("[INTEGRATION SERVICE]: Plugin Loaded: " + args.AddinId); m_log.Info ("[INTEGRATION SERVICE]: Plugin Loaded: " + args.AddinId);
} }
#endregion addin-event handlers
private void LoadingPlugin(IntegrationPlugin plugin) private void LoadingPlugin(IntegrationPlugin plugin)
{ {

View File

@ -59,20 +59,23 @@ namespace OpenSim.Services.IntegrationService
IProgressStatus ps = new ConsoleProgressStatus(false); IProgressStatus ps = new ConsoleProgressStatus(false);
// m_Registry.Update(ps);
string name = Addin.GetIdName(args[1]); string name = Addin.GetIdName(args[1]);
string version = Addin.GetIdVersion(args[1]); string version = Addin.GetIdVersion(args[1]);
AddinRepositoryEntry[] available = GetSortedAvailbleAddins();
AddinRepositoryEntry[] aentry = Repositories.GetAvailableAddin(name, version); int n = Convert.ToInt16(args[1]);
if (n > (available.Length -1))
foreach (AddinRepositoryEntry ae in aentry)
{ {
Package p = Package.FromRepository(ae); MainConsole.Instance.Output("Selection out of range");
pack.Add(p); return "Error";
} }
AddinRepositoryEntry aentry = available[n];
Package p = Package.FromRepository(aentry);
pack.Add(p);
ResolveDependencies(ps, pack, out toUninstall, out unresolved); ResolveDependencies(ps, pack, out toUninstall, out unresolved);
if(Install(ps, pack) == true) if(Install(ps, pack) == true)
@ -133,14 +136,16 @@ namespace OpenSim.Services.IntegrationService
// List compatible plugins in registered repositories // List compatible plugins in registered repositories
public ArrayList ListAvailable() public ArrayList ListAvailable()
{ {
AddinRepositoryEntry[] addins = Repositories.GetAvailableAddins (); AddinRepositoryEntry[] addins = GetSortedAvailbleAddins();
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
int count = 0;
foreach (AddinRepositoryEntry addin in addins) foreach (AddinRepositoryEntry addin in addins)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.Append(String.Format("{0} rev. {1}, repo {2}", addin.Addin.Id, addin.Addin.Version, addin.RepositoryUrl)); sb.Append(String.Format("{0}) {1} rev. {2}, repo {3}", count.ToString(), addin.Addin.Name, addin.Addin.Version, addin.RepositoryName));
list.Add(sb.ToString()); list.Add(sb.ToString());
count++;
} }
return list; return list;
} }
@ -178,7 +183,7 @@ namespace OpenSim.Services.IntegrationService
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
@ -361,14 +366,37 @@ namespace OpenSim.Services.IntegrationService
} }
} }
// These will let us deal with numbered lists instead
// of needing to type in the full ids
private AddinRepositoryEntry[] GetSortedAvailbleAddins()
{
ArrayList list = new ArrayList();
list.AddRange(Repositories.GetAvailableAddins());
AddinRepositoryEntry[] addins = list.ToArray(typeof(AddinRepositoryEntry)) as AddinRepositoryEntry[];
Array.Sort(addins,(r1,r2) => r1.Addin.Id.CompareTo(r2.Addin.Id));
return addins;
}
private AddinRepository[] GetSortedAddinRepo()
{
ArrayList list = new ArrayList();
list.AddRange(Repositories.GetRepositories());
AddinRepository[] repos = list.ToArray(typeof(AddinRepository)) as AddinRepository[];
Array.Sort (repos,(r1,r2) => r1.Name.CompareTo(r2.Name));
return repos;
}
private Addin[] GetSortedAddinList(string category) private Addin[] GetSortedAddinList(string category)
{ {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
list.AddRange(m_Registry.GetAddins()); list.AddRange(m_Registry.GetAddins());
ArrayList xlist = new ArrayList(); ArrayList xlist = new ArrayList();
foreach (Addin addin in list) foreach (Addin addin in list)
{ {
if (addin.Description.Category == category) if (addin.Description.Category == category)