Working on plugin manager

integration
BlueWall 2012-04-05 12:25:24 -04:00
parent 2d9971ea93
commit f494e6b086
3 changed files with 202 additions and 33 deletions

View File

@ -48,6 +48,118 @@ namespace OpenSim.Services.IntegrationService
{ {
m_log.InfoFormat("[INTEGRATION SERVICE]: Loaded"); m_log.InfoFormat("[INTEGRATION SERVICE]: Loaded");
// Add a command to the console
if (MainConsole.Instance != null)
{
AddConsoleCommands();
}
} }
private void AddConsoleCommands()
{
MainConsole.Instance.Commands.AddCommand("Integration", true,
"install", "install \"plugin name\"", "Install plugin from repository",
HandleInstallPlugin);
MainConsole.Instance.Commands.AddCommand("Integration", true,
"uninstall", "uninstall \"plugin name\"", "Remove plugin from repository",
HandleUnInstallPlugin);
MainConsole.Instance.Commands.AddCommand("Integration", true, "check installed", "check installed \"plugin name=\"",
HandleCheckInstalledPlugin);
}
#region console handlers
private void HandleInstallPlugin(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.Install());
return;
}
private void HandleUnInstallPlugin(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.UnInstall());
return;
}
private void HandleCheckInstalledPlugin(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.CheckInstalled());
return;
}
private void HandleListInstalledPlugin(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.ListInstalled());
return;
}
private void HandleListAvailablePlugin(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.ListAvailable());
return;
}
private void HandleListUpdates(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.ListUpdates());
return;
}
private void HandleUpdatePlugin(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.Update());
return;
}
private void HandleAddRepo(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.AddRepository());
return;
}
private void HandleGetRepo(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.GetRepository());
return;
}
private void HandleRemoveRepo(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.RemoveRepository());
return;
}
private void HandleEnableRepo(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.EnableRepository());
return;
}
private void HandleDisableRepo(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.DisableRepository());
return;
}
private void HandleListRepos(string module, string[] cmd)
{
MainConsole.Instance.Output(m_PluginManager.ListRepositories());
return;
}
private void HandleShowAddinInfo(string module, string[] cmd)
{
if ( cmd.Length < 2 )
{
MainConsole.Instance.Output(m_PluginManager.AddinInfo());
return;
}
MainConsole.Instance.Output(String.Format("{0} {1}","Hello", "World!" ));
}
#endregion
} }
} }

View File

@ -62,6 +62,7 @@ namespace OpenSim.Services.IntegrationService
protected IGridService m_GridService; protected IGridService m_GridService;
protected IHttpServer m_Server; protected IHttpServer m_Server;
protected string m_IntegrationConfig; protected string m_IntegrationConfig;
protected PluginManager m_PluginManager;
IConfig m_IntegrationServerConfig; IConfig m_IntegrationServerConfig;
string m_IntegrationConfigLoc; string m_IntegrationConfigLoc;
@ -77,6 +78,8 @@ namespace OpenSim.Services.IntegrationService
string RegistryLocation = serverConfig.GetString("PluginRegistryLocation", string RegistryLocation = serverConfig.GetString("PluginRegistryLocation",
"."); ".");
m_PluginManager = new PluginManager(RegistryLocation);
// Deal with files only for now - will add url/environment later // Deal with files only for now - will add url/environment later
m_IntegrationConfigLoc = serverConfig.GetString("IntegrationConfig", String.Empty); m_IntegrationConfigLoc = serverConfig.GetString("IntegrationConfig", String.Empty);
if(String.IsNullOrEmpty(m_IntegrationConfigLoc)) if(String.IsNullOrEmpty(m_IntegrationConfigLoc))
@ -94,18 +97,6 @@ namespace OpenSim.Services.IntegrationService
return; return;
} }
// Add a command to the console
if (MainConsole.Instance != null)
{
MainConsole.Instance.Commands.AddCommand("Integration", true,
"show repos",
"show repos",
"Show list of registered plugin repositories",
String.Empty,
HandleShowRepos);
}
suppress_console_output_(true); suppress_console_output_(true);
AddinManager.Initialize (RegistryLocation); AddinManager.Initialize (RegistryLocation);
AddinManager.Registry.Update (); AddinManager.Registry.Update ();
@ -190,26 +181,5 @@ namespace OpenSim.Services.IntegrationService
System.Console.SetOut(prev_console_); System.Console.SetOut(prev_console_);
} }
} }
#region console handlers
private void HandleShowRepos(string module, string[] cmd)
{
if ( cmd.Length < 2 )
{
MainConsole.Instance.Output("Syntax: show repos");
return;
}
// List<UserData> list = m_Database.ListNames();
//
// foreach (UserData name in list)
// {
// MainConsole.Instance.Output(String.Format("{0} {1}",name.FirstName, name.LastName));
// }
}
#endregion
} }
} }

View File

@ -32,5 +32,92 @@ using Mono.Addins.Setup;
namespace OpenSim.Services.IntegrationService namespace OpenSim.Services.IntegrationService
{ {
// This will maintain the plugin repositories and plugins // This will maintain the plugin repositories and plugins
public class PluginManager
{
protected AddinRegistry m_Registry;
protected SetupService m_Manager;
public PluginManager(string registry_path)
{
m_Registry = new AddinRegistry(".", registry_path);
m_Manager = new SetupService(m_Registry);
}
public string Install()
{
return "Install";
}
public string UnInstall()
{
return "UnInstall";
}
public string CheckInstalled()
{
return "CheckInstall";
}
public string ListInstalled()
{
return "ListInstalled";
}
public string ListAvailable()
{
return "ListAvailable";
}
public string ListUpdates()
{
return "ListUpdates";
}
public string Update()
{
return "Update";
}
public string AddRepository()
{
return "AddRepository";
}
public string GetRepository()
{
return "GetRepository";
}
public string RemoveRepository()
{
return "RemoveRepository";
}
public string EnableRepository()
{
return "EnableRepository";
}
public string DisableRepository()
{
return DisableRepository();
}
public string ListRepositories()
{
return "ListRepositories";
}
public string UpdateRegistry()
{
return "UpdateRegistry";
}
public string AddinInfo()
{
return "AddinInfo";
}
}
} }