diff --git a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs index b258e13dce..27f94ea9db 100644 --- a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.Collections.Generic; using System.Reflection; using log4net; @@ -34,9 +35,12 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using Mono.Addins; + namespace OpenSim.Region.CoreModules.Avatar.Groups { - public class GroupsModule : IRegionModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class GroupsModule : ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -55,9 +59,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups private static GroupMembershipData osGroup = new GroupMembershipData(); - #region IRegionModule Members + private bool m_Enabled = false; - public void Initialise(Scene scene, IConfigSource config) + #region ISharedRegionModule Members + + public void Initialise(IConfigSource config) { IConfig groupsConfig = config.Configs["Groups"]; @@ -67,7 +73,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups } else { - if (!groupsConfig.GetBoolean("Enabled", false)) + m_Enabled = groupsConfig.GetBoolean("Enabled", false); + if (!m_Enabled) { m_log.Info("[GROUPS]: Groups disabled in configuration"); return; @@ -77,6 +84,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups return; } + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + lock (m_SceneList) { if (!m_SceneList.Contains(scene)) @@ -96,7 +110,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups scene.EventManager.OnNewClient += OnNewClient; scene.EventManager.OnClientClosed += OnClientClosed; -// scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; + // scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + + lock (m_SceneList) + { + if (m_SceneList.Contains(scene)) + m_SceneList.Remove(scene); + } + + scene.EventManager.OnNewClient -= OnNewClient; + scene.EventManager.OnClientClosed -= OnClientClosed; + } + + public void RegionLoaded(Scene scene) + { } public void PostInitialise() @@ -105,6 +138,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups public void Close() { + if (!m_Enabled) + return; + // m_log.Debug("[GROUPS]: Shutting down group module."); lock (m_ClientMap) @@ -123,9 +159,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups get { return "GroupsModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return true; } + get { return null; } } #endregion