diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins/RegionModulesController')
3 files changed, 78 insertions, 37 deletions
diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/Properties/AssemblyInfo.cs b/OpenSim/ApplicationPlugins/RegionModulesController/Properties/AssemblyInfo.cs index 14527d9..acbdc3a 100644 --- a/OpenSim/ApplicationPlugins/RegionModulesController/Properties/AssemblyInfo.cs +++ b/OpenSim/ApplicationPlugins/RegionModulesController/Properties/AssemblyInfo.cs | |||
@@ -1,6 +1,7 @@ | |||
1 | using System.Reflection; | 1 | using System.Reflection; |
2 | using System.Runtime.CompilerServices; | 2 | using System.Runtime.CompilerServices; |
3 | using System.Runtime.InteropServices; | 3 | using System.Runtime.InteropServices; |
4 | using Mono.Addins; | ||
4 | 5 | ||
5 | // General Information about an assembly is controlled through the following | 6 | // General Information about an assembly is controlled through the following |
6 | // set of attributes. Change these attribute values to modify the information | 7 | // set of attributes. Change these attribute values to modify the information |
@@ -29,5 +30,7 @@ using System.Runtime.InteropServices; | |||
29 | // Build Number | 30 | // Build Number |
30 | // Revision | 31 | // Revision |
31 | // | 32 | // |
32 | [assembly: AssemblyVersion("0.7.5.*")] | 33 | [assembly: AssemblyVersion("0.8.3.*")] |
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | 34 | |
35 | [assembly: Addin("OpenSim.ApplicationPlugins.RegionModulesController", OpenSim.VersionInfo.VersionNumber)] | ||
36 | [assembly: AddinDependency("OpenSim", OpenSim.VersionInfo.VersionNumber)] | ||
diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs index 633d005..8f38a29 100644 --- a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs +++ b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs | |||
@@ -32,11 +32,13 @@ using log4net; | |||
32 | using Mono.Addins; | 32 | using Mono.Addins; |
33 | using Nini.Config; | 33 | using Nini.Config; |
34 | using OpenSim; | 34 | using OpenSim; |
35 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
37 | 38 | ||
38 | namespace OpenSim.ApplicationPlugins.RegionModulesController | 39 | namespace OpenSim.ApplicationPlugins.RegionModulesController |
39 | { | 40 | { |
41 | [Extension(Path = "/OpenSim/Startup", Id = "LoadRegions", NodeName = "Plugin")] | ||
40 | public class RegionModulesControllerPlugin : IRegionModulesController, | 42 | public class RegionModulesControllerPlugin : IRegionModulesController, |
41 | IApplicationPlugin | 43 | IApplicationPlugin |
42 | { | 44 | { |
@@ -45,6 +47,12 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
45 | LogManager.GetLogger( | 47 | LogManager.GetLogger( |
46 | MethodBase.GetCurrentMethod().DeclaringType); | 48 | MethodBase.GetCurrentMethod().DeclaringType); |
47 | 49 | ||
50 | /// <summary> | ||
51 | /// Controls whether we load modules from Mono.Addins. | ||
52 | /// </summary> | ||
53 | /// <remarks>For debug purposes. Defaults to true.</remarks> | ||
54 | public bool LoadModulesFromAddins { get; set; } | ||
55 | |||
48 | // Config access | 56 | // Config access |
49 | private OpenSimBase m_openSim; | 57 | private OpenSimBase m_openSim; |
50 | 58 | ||
@@ -61,6 +69,11 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
61 | private List<ISharedRegionModule> m_sharedInstances = | 69 | private List<ISharedRegionModule> m_sharedInstances = |
62 | new List<ISharedRegionModule>(); | 70 | new List<ISharedRegionModule>(); |
63 | 71 | ||
72 | public RegionModulesControllerPlugin() | ||
73 | { | ||
74 | LoadModulesFromAddins = true; | ||
75 | } | ||
76 | |||
64 | #region IApplicationPlugin implementation | 77 | #region IApplicationPlugin implementation |
65 | 78 | ||
66 | public void Initialise (OpenSimBase openSim) | 79 | public void Initialise (OpenSimBase openSim) |
@@ -69,6 +82,9 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
69 | m_openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this); | 82 | m_openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this); |
70 | m_log.DebugFormat("[REGIONMODULES]: Initializing..."); | 83 | m_log.DebugFormat("[REGIONMODULES]: Initializing..."); |
71 | 84 | ||
85 | if (!LoadModulesFromAddins) | ||
86 | return; | ||
87 | |||
72 | // Who we are | 88 | // Who we are |
73 | string id = AddinManager.CurrentAddin.Id; | 89 | string id = AddinManager.CurrentAddin.Id; |
74 | 90 | ||
@@ -85,30 +101,20 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
85 | if (modulesConfig == null) | 101 | if (modulesConfig == null) |
86 | modulesConfig = m_openSim.ConfigSource.Source.AddConfig("Modules"); | 102 | modulesConfig = m_openSim.ConfigSource.Source.AddConfig("Modules"); |
87 | 103 | ||
104 | Dictionary<RuntimeAddin, IList<int>> loadedModules = new Dictionary<RuntimeAddin, IList<int>>(); | ||
105 | |||
88 | // Scan modules and load all that aren't disabled | 106 | // Scan modules and load all that aren't disabled |
89 | foreach (TypeExtensionNode node in | 107 | foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/OpenSim/RegionModules")) |
90 | AddinManager.GetExtensionNodes("/OpenSim/RegionModules")) | 108 | AddNode(node, modulesConfig, loadedModules); |
109 | |||
110 | foreach (KeyValuePair<RuntimeAddin, IList<int>> loadedModuleData in loadedModules) | ||
91 | { | 111 | { |
92 | if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null) | 112 | m_log.InfoFormat( |
93 | { | 113 | "[REGIONMODULES]: From plugin {0}, (version {1}), loaded {2} modules, {3} shared, {4} non-shared {5} unknown", |
94 | if (CheckModuleEnabled(node, modulesConfig)) | 114 | loadedModuleData.Key.Id, |
95 | { | 115 | loadedModuleData.Key.Version, |
96 | m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type); | 116 | loadedModuleData.Value[0] + loadedModuleData.Value[1] + loadedModuleData.Value[2], |
97 | m_sharedModules.Add(node); | 117 | loadedModuleData.Value[0], loadedModuleData.Value[1], loadedModuleData.Value[2]); |
98 | } | ||
99 | } | ||
100 | else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null) | ||
101 | { | ||
102 | if (CheckModuleEnabled(node, modulesConfig)) | ||
103 | { | ||
104 | m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type); | ||
105 | m_nonSharedModules.Add(node); | ||
106 | } | ||
107 | } | ||
108 | else | ||
109 | { | ||
110 | m_log.DebugFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type); | ||
111 | } | ||
112 | } | 118 | } |
113 | 119 | ||
114 | // Load and init the module. We try a constructor with a port | 120 | // Load and init the module. We try a constructor with a port |
@@ -125,6 +131,9 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
125 | // Read the config again | 131 | // Read the config again |
126 | string moduleString = | 132 | string moduleString = |
127 | modulesConfig.GetString("Setup_" + node.Id, String.Empty); | 133 | modulesConfig.GetString("Setup_" + node.Id, String.Empty); |
134 | // Test to see if we want this module | ||
135 | if (moduleString == "disabled") | ||
136 | continue; | ||
128 | 137 | ||
129 | // Get the port number, if there is one | 138 | // Get the port number, if there is one |
130 | if (moduleString != String.Empty) | 139 | if (moduleString != String.Empty) |
@@ -172,6 +181,41 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
172 | 181 | ||
173 | #region IPlugin implementation | 182 | #region IPlugin implementation |
174 | 183 | ||
184 | private void AddNode( | ||
185 | TypeExtensionNode node, IConfig modulesConfig, Dictionary<RuntimeAddin, IList<int>> loadedModules) | ||
186 | { | ||
187 | IList<int> loadedModuleData; | ||
188 | |||
189 | if (!loadedModules.ContainsKey(node.Addin)) | ||
190 | loadedModules.Add(node.Addin, new List<int> { 0, 0, 0 }); | ||
191 | |||
192 | loadedModuleData = loadedModules[node.Addin]; | ||
193 | |||
194 | if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null) | ||
195 | { | ||
196 | if (CheckModuleEnabled(node, modulesConfig)) | ||
197 | { | ||
198 | m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type); | ||
199 | m_sharedModules.Add(node); | ||
200 | loadedModuleData[0]++; | ||
201 | } | ||
202 | } | ||
203 | else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null) | ||
204 | { | ||
205 | if (CheckModuleEnabled(node, modulesConfig)) | ||
206 | { | ||
207 | m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type); | ||
208 | m_nonSharedModules.Add(node); | ||
209 | loadedModuleData[1]++; | ||
210 | } | ||
211 | } | ||
212 | else | ||
213 | { | ||
214 | m_log.WarnFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type); | ||
215 | loadedModuleData[2]++; | ||
216 | } | ||
217 | } | ||
218 | |||
175 | // We don't do that here | 219 | // We don't do that here |
176 | // | 220 | // |
177 | public void Initialise () | 221 | public void Initialise () |
@@ -193,6 +237,7 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
193 | m_sharedInstances[0].Close(); | 237 | m_sharedInstances[0].Close(); |
194 | m_sharedInstances.RemoveAt(0); | 238 | m_sharedInstances.RemoveAt(0); |
195 | } | 239 | } |
240 | |||
196 | m_sharedModules.Clear(); | 241 | m_sharedModules.Clear(); |
197 | m_nonSharedModules.Clear(); | 242 | m_nonSharedModules.Clear(); |
198 | } | 243 | } |
@@ -323,6 +368,10 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
323 | string moduleString = | 368 | string moduleString = |
324 | modulesConfig.GetString("Setup_" + node.Id, String.Empty); | 369 | modulesConfig.GetString("Setup_" + node.Id, String.Empty); |
325 | 370 | ||
371 | // We may not want to load this at all | ||
372 | if (moduleString == "disabled") | ||
373 | continue; | ||
374 | |||
326 | // Get the port number, if there is one | 375 | // Get the port number, if there is one |
327 | if (moduleString != String.Empty) | 376 | if (moduleString != String.Empty) |
328 | { | 377 | { |
@@ -460,6 +509,8 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
460 | { | 509 | { |
461 | module.RegionLoaded(scene); | 510 | module.RegionLoaded(scene); |
462 | } | 511 | } |
512 | |||
513 | scene.AllModulesLoaded(); | ||
463 | } | 514 | } |
464 | 515 | ||
465 | public void RemoveRegionFromModules (Scene scene) | 516 | public void RemoveRegionFromModules (Scene scene) |
diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/Resources/RegionModulesControllerPlugin.addin.xml b/OpenSim/ApplicationPlugins/RegionModulesController/Resources/RegionModulesControllerPlugin.addin.xml deleted file mode 100644 index a92713b..0000000 --- a/OpenSim/ApplicationPlugins/RegionModulesController/Resources/RegionModulesControllerPlugin.addin.xml +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | <Addin id="OpenSim.ApplicationPlugins.RegionModulesController" version="0.1"> | ||
2 | <Runtime> | ||
3 | <Import assembly="OpenSim.ApplicationPlugins.RegionModulesController.dll"/> | ||
4 | </Runtime> | ||
5 | |||
6 | <Dependencies> | ||
7 | <Addin id="OpenSim" version="0.5" /> | ||
8 | </Dependencies> | ||
9 | |||
10 | <Extension path = "/OpenSim/Startup"> | ||
11 | <Plugin id="RegionModulesController" type="OpenSim.ApplicationPlugins.RegionModulesController.RegionModulesControllerPlugin" /> | ||
12 | </Extension> | ||
13 | </Addin> | ||