From f494e6b0864d63156cee959487b37f2066d38505 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 5 Apr 2012 12:25:24 -0400 Subject: [PATCH] Working on plugin manager --- .../IntegrationService/IntegrationService.cs | 112 ++++++++++++++++++ .../IntegrationServiceBase.cs | 36 +----- .../IntegrationService/PluginManager.cs | 87 ++++++++++++++ 3 files changed, 202 insertions(+), 33 deletions(-) diff --git a/OpenSim/Services/IntegrationService/IntegrationService.cs b/OpenSim/Services/IntegrationService/IntegrationService.cs index 07d527f118..4560941d5f 100644 --- a/OpenSim/Services/IntegrationService/IntegrationService.cs +++ b/OpenSim/Services/IntegrationService/IntegrationService.cs @@ -48,6 +48,118 @@ namespace OpenSim.Services.IntegrationService { 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 } } \ No newline at end of file diff --git a/OpenSim/Services/IntegrationService/IntegrationServiceBase.cs b/OpenSim/Services/IntegrationService/IntegrationServiceBase.cs index e965c7d16f..c72a4e985f 100644 --- a/OpenSim/Services/IntegrationService/IntegrationServiceBase.cs +++ b/OpenSim/Services/IntegrationService/IntegrationServiceBase.cs @@ -62,6 +62,7 @@ namespace OpenSim.Services.IntegrationService protected IGridService m_GridService; protected IHttpServer m_Server; protected string m_IntegrationConfig; + protected PluginManager m_PluginManager; IConfig m_IntegrationServerConfig; string m_IntegrationConfigLoc; @@ -77,6 +78,8 @@ namespace OpenSim.Services.IntegrationService string RegistryLocation = serverConfig.GetString("PluginRegistryLocation", "."); + m_PluginManager = new PluginManager(RegistryLocation); + // Deal with files only for now - will add url/environment later m_IntegrationConfigLoc = serverConfig.GetString("IntegrationConfig", String.Empty); if(String.IsNullOrEmpty(m_IntegrationConfigLoc)) @@ -94,18 +97,6 @@ namespace OpenSim.Services.IntegrationService 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); AddinManager.Initialize (RegistryLocation); AddinManager.Registry.Update (); @@ -190,26 +181,5 @@ namespace OpenSim.Services.IntegrationService 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 list = m_Database.ListNames(); -// -// foreach (UserData name in list) -// { -// MainConsole.Instance.Output(String.Format("{0} {1}",name.FirstName, name.LastName)); -// } - } - #endregion } } diff --git a/OpenSim/Services/IntegrationService/PluginManager.cs b/OpenSim/Services/IntegrationService/PluginManager.cs index 39eb08ae0f..bbf0f6b486 100644 --- a/OpenSim/Services/IntegrationService/PluginManager.cs +++ b/OpenSim/Services/IntegrationService/PluginManager.cs @@ -32,5 +32,92 @@ using Mono.Addins.Setup; namespace OpenSim.Services.IntegrationService { // 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"; + } + } } \ No newline at end of file