diff options
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs')
-rw-r--r-- | OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs | 87 |
1 files changed, 53 insertions, 34 deletions
diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs index 510be37..e03483a 100644 --- a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs +++ b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs | |||
@@ -32,6 +32,7 @@ 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 | ||
@@ -45,6 +46,12 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
45 | LogManager.GetLogger( | 46 | LogManager.GetLogger( |
46 | MethodBase.GetCurrentMethod().DeclaringType); | 47 | MethodBase.GetCurrentMethod().DeclaringType); |
47 | 48 | ||
49 | /// <summary> | ||
50 | /// Controls whether we load modules from Mono.Addins. | ||
51 | /// </summary> | ||
52 | /// <remarks>For debug purposes. Defaults to true.</remarks> | ||
53 | public bool LoadModulesFromAddins { get; set; } | ||
54 | |||
48 | // Config access | 55 | // Config access |
49 | private OpenSimBase m_openSim; | 56 | private OpenSimBase m_openSim; |
50 | 57 | ||
@@ -61,6 +68,11 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
61 | private List<ISharedRegionModule> m_sharedInstances = | 68 | private List<ISharedRegionModule> m_sharedInstances = |
62 | new List<ISharedRegionModule>(); | 69 | new List<ISharedRegionModule>(); |
63 | 70 | ||
71 | public RegionModulesControllerPlugin() | ||
72 | { | ||
73 | LoadModulesFromAddins = true; | ||
74 | } | ||
75 | |||
64 | #region IApplicationPlugin implementation | 76 | #region IApplicationPlugin implementation |
65 | 77 | ||
66 | public void Initialise (OpenSimBase openSim) | 78 | public void Initialise (OpenSimBase openSim) |
@@ -69,6 +81,9 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
69 | m_openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this); | 81 | m_openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this); |
70 | m_log.DebugFormat("[REGIONMODULES]: Initializing..."); | 82 | m_log.DebugFormat("[REGIONMODULES]: Initializing..."); |
71 | 83 | ||
84 | if (!LoadModulesFromAddins) | ||
85 | return; | ||
86 | |||
72 | // Who we are | 87 | // Who we are |
73 | string id = AddinManager.CurrentAddin.Id; | 88 | string id = AddinManager.CurrentAddin.Id; |
74 | 89 | ||
@@ -88,40 +103,8 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
88 | Dictionary<RuntimeAddin, IList<int>> loadedModules = new Dictionary<RuntimeAddin, IList<int>>(); | 103 | Dictionary<RuntimeAddin, IList<int>> loadedModules = new Dictionary<RuntimeAddin, IList<int>>(); |
89 | 104 | ||
90 | // Scan modules and load all that aren't disabled | 105 | // Scan modules and load all that aren't disabled |
91 | foreach (TypeExtensionNode node in | 106 | foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/OpenSim/RegionModules")) |
92 | AddinManager.GetExtensionNodes("/OpenSim/RegionModules")) | 107 | AddNode(node, modulesConfig, loadedModules); |
93 | { | ||
94 | IList<int> loadedModuleData; | ||
95 | |||
96 | if (!loadedModules.ContainsKey(node.Addin)) | ||
97 | loadedModules.Add(node.Addin, new List<int> { 0, 0, 0 }); | ||
98 | |||
99 | loadedModuleData = loadedModules[node.Addin]; | ||
100 | |||
101 | if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null) | ||
102 | { | ||
103 | if (CheckModuleEnabled(node, modulesConfig)) | ||
104 | { | ||
105 | m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type); | ||
106 | m_sharedModules.Add(node); | ||
107 | loadedModuleData[0]++; | ||
108 | } | ||
109 | } | ||
110 | else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null) | ||
111 | { | ||
112 | if (CheckModuleEnabled(node, modulesConfig)) | ||
113 | { | ||
114 | m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type); | ||
115 | m_nonSharedModules.Add(node); | ||
116 | loadedModuleData[1]++; | ||
117 | } | ||
118 | } | ||
119 | else | ||
120 | { | ||
121 | m_log.WarnFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type); | ||
122 | loadedModuleData[2]++; | ||
123 | } | ||
124 | } | ||
125 | 108 | ||
126 | foreach (KeyValuePair<RuntimeAddin, IList<int>> loadedModuleData in loadedModules) | 109 | foreach (KeyValuePair<RuntimeAddin, IList<int>> loadedModuleData in loadedModules) |
127 | { | 110 | { |
@@ -194,6 +177,41 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
194 | 177 | ||
195 | #region IPlugin implementation | 178 | #region IPlugin implementation |
196 | 179 | ||
180 | private void AddNode( | ||
181 | TypeExtensionNode node, IConfig modulesConfig, Dictionary<RuntimeAddin, IList<int>> loadedModules) | ||
182 | { | ||
183 | IList<int> loadedModuleData; | ||
184 | |||
185 | if (!loadedModules.ContainsKey(node.Addin)) | ||
186 | loadedModules.Add(node.Addin, new List<int> { 0, 0, 0 }); | ||
187 | |||
188 | loadedModuleData = loadedModules[node.Addin]; | ||
189 | |||
190 | if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null) | ||
191 | { | ||
192 | if (CheckModuleEnabled(node, modulesConfig)) | ||
193 | { | ||
194 | m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type); | ||
195 | m_sharedModules.Add(node); | ||
196 | loadedModuleData[0]++; | ||
197 | } | ||
198 | } | ||
199 | else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null) | ||
200 | { | ||
201 | if (CheckModuleEnabled(node, modulesConfig)) | ||
202 | { | ||
203 | m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type); | ||
204 | m_nonSharedModules.Add(node); | ||
205 | loadedModuleData[1]++; | ||
206 | } | ||
207 | } | ||
208 | else | ||
209 | { | ||
210 | m_log.WarnFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type); | ||
211 | loadedModuleData[2]++; | ||
212 | } | ||
213 | } | ||
214 | |||
197 | // We don't do that here | 215 | // We don't do that here |
198 | // | 216 | // |
199 | public void Initialise () | 217 | public void Initialise () |
@@ -215,6 +233,7 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController | |||
215 | m_sharedInstances[0].Close(); | 233 | m_sharedInstances[0].Close(); |
216 | m_sharedInstances.RemoveAt(0); | 234 | m_sharedInstances.RemoveAt(0); |
217 | } | 235 | } |
236 | |||
218 | m_sharedModules.Clear(); | 237 | m_sharedModules.Clear(); |
219 | m_nonSharedModules.Clear(); | 238 | m_nonSharedModules.Clear(); |
220 | } | 239 | } |