changing IRCBridgeModule to new region module scheme
parent
ac2fe53e89
commit
37726764be
|
@ -38,87 +38,61 @@ using OpenSim.Region.Framework.Scenes;
|
||||||
|
|
||||||
namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
||||||
{
|
{
|
||||||
public class IRCBridgeModule : IRegionModule
|
public class IRCBridgeModule : INonSharedRegionModule
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log =
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
internal static bool configured = false;
|
internal static bool m_pluginEnabled = false;
|
||||||
internal static bool enabled = false;
|
internal static IConfig m_config = null;
|
||||||
internal static IConfig m_config = null;
|
|
||||||
|
|
||||||
internal static List<ChannelState> m_channels = new List<ChannelState>();
|
internal static List<ChannelState> m_channels = new List<ChannelState>();
|
||||||
internal static List<RegionState> m_regions = new List<RegionState>();
|
internal static List<RegionState> m_regions = new List<RegionState>();
|
||||||
|
|
||||||
internal static string password = String.Empty;
|
internal static string m_password = String.Empty;
|
||||||
|
internal RegionState m_region = null;
|
||||||
|
|
||||||
internal RegionState region = null;
|
#region INonSharedRegionModule Members
|
||||||
|
|
||||||
#region IRegionModule Members
|
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return "IRCBridgeModule"; }
|
get { return "IRCBridgeModule"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsSharedModule
|
public void Initialise(IConfigSource config)
|
||||||
{
|
{
|
||||||
get { return false; }
|
m_config = config.Configs["IRC"];
|
||||||
}
|
if (m_config == null)
|
||||||
|
|
||||||
public void Initialise(Scene scene, IConfigSource config)
|
|
||||||
{
|
|
||||||
// Do a once-only scan of the configuration file to make
|
|
||||||
// sure it's basically intact.
|
|
||||||
|
|
||||||
if (!configured)
|
|
||||||
{
|
{
|
||||||
configured = true;
|
m_log.InfoFormat("[IRC-Bridge] module not configured");
|
||||||
|
return;
|
||||||
try
|
|
||||||
{
|
|
||||||
if ((m_config = config.Configs["IRC"]) == null)
|
|
||||||
{
|
|
||||||
m_log.InfoFormat("[IRC-Bridge] module not configured");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_config.GetBoolean("enabled", false))
|
|
||||||
{
|
|
||||||
m_log.InfoFormat("[IRC-Bridge] module disabled in configuration");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[IRC-Bridge] configuration failed : {0}", e.Message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
enabled = true;
|
|
||||||
|
|
||||||
if (config.Configs["RemoteAdmin"] != null)
|
|
||||||
{
|
|
||||||
password = config.Configs["RemoteAdmin"].GetString("access_password", password);
|
|
||||||
scene.CommsManager.HttpServer.AddXmlRPCHandler("irc_admin", XmlRpcAdminMethod, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iff the IRC bridge is enabled, then each new region may be
|
if (!m_config.GetBoolean("enabled", false))
|
||||||
// connected to IRC. But it should NOT be obligatory (and it
|
{
|
||||||
// is not).
|
m_log.InfoFormat("[IRC-Bridge] module disabled in configuration");
|
||||||
// We have to do ALL of the startup here because PostInitialize
|
return;
|
||||||
// is not called when a region gets created in-flight from the
|
}
|
||||||
// command line.
|
|
||||||
|
if (config.Configs["RemoteAdmin"] != null)
|
||||||
if (enabled)
|
{
|
||||||
|
m_password = config.Configs["RemoteAdmin"].GetString("access_password", m_password);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pluginEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddRegion(Scene scene)
|
||||||
|
{
|
||||||
|
if (m_pluginEnabled)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[IRC-Bridge] Connecting region {0}", scene.RegionInfo.RegionName);
|
m_log.InfoFormat("[IRC-Bridge] Connecting region {0}", scene.RegionInfo.RegionName);
|
||||||
region = new RegionState(scene, m_config);
|
if (!String.IsNullOrEmpty(m_password))
|
||||||
lock (m_regions) m_regions.Add(region);
|
scene.CommsManager.HttpServer.AddXmlRPCHandler("irc_admin", XmlRpcAdminMethod, false);
|
||||||
region.Open();
|
m_region = new RegionState(scene, m_config);
|
||||||
|
lock (m_regions) m_regions.Add(m_region);
|
||||||
|
m_region.Open();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -132,34 +106,33 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This module can be called in-flight in which case PostInitialize
|
|
||||||
// is not called following Initialize. So no use is made of this
|
|
||||||
// call.
|
|
||||||
|
|
||||||
public void PostInitialise()
|
public void RegionLoaded(Scene scene)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called immediately before the region module is unloaded. Cleanup
|
public void RemoveRegion(Scene scene)
|
||||||
// the region.
|
{
|
||||||
|
if (!m_pluginEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_region == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!String.IsNullOrEmpty(m_password))
|
||||||
|
scene.CommsManager.HttpServer.RemoveXmlRPCHandler("irc_admin");
|
||||||
|
|
||||||
|
m_region.Close();
|
||||||
|
|
||||||
|
if (m_regions.Contains(m_region))
|
||||||
|
{
|
||||||
|
lock (m_regions) m_regions.Remove(m_region);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
if (!enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (region == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
region.Close();
|
|
||||||
|
|
||||||
if (m_regions.Contains(region))
|
|
||||||
{
|
|
||||||
lock (m_regions) m_regions.Remove(region);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static XmlRpcResponse XmlRpcAdminMethod(XmlRpcRequest request)
|
public static XmlRpcResponse XmlRpcAdminMethod(XmlRpcRequest request)
|
||||||
|
@ -175,11 +148,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
||||||
bool found = false;
|
bool found = false;
|
||||||
string region = String.Empty;
|
string region = String.Empty;
|
||||||
|
|
||||||
if (password != String.Empty)
|
if (m_password != String.Empty)
|
||||||
{
|
{
|
||||||
if (!requestData.ContainsKey("password"))
|
if (!requestData.ContainsKey("password"))
|
||||||
throw new Exception("Invalid request");
|
throw new Exception("Invalid request");
|
||||||
if ((string)requestData["password"] != password)
|
if ((string)requestData["password"] != m_password)
|
||||||
throw new Exception("Invalid request");
|
throw new Exception("Invalid request");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<Addin id="OpenSim.Region.OptionalModules" version="0.1">
|
<Addin id="OpenSim.Region.OptionalModules" version="0.2">
|
||||||
<Runtime>
|
<Runtime>
|
||||||
<Import assembly="OpenSim.Region.OptionalModules.dll"/>
|
<Import assembly="OpenSim.Region.OptionalModules.dll"/>
|
||||||
</Runtime>
|
</Runtime>
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
</Dependencies>
|
</Dependencies>
|
||||||
|
|
||||||
<Extension path = "/OpenSim/RegionModules">
|
<Extension path = "/OpenSim/RegionModules">
|
||||||
|
<RegionModule id="IRCBridge" type="OpenSim.Region.OptionalModules.Avatar.Chat.IRCBridgeModule" />
|
||||||
<RegionModule id="XmlRpcGroups" type="OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.XmlRpcGroupsModule" />
|
<RegionModule id="XmlRpcGroups" type="OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.XmlRpcGroupsModule" />
|
||||||
<RegionModule id="XmlRpcGroupsMessaging" type="OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.XmlRpcGroupsMessaging" />
|
<RegionModule id="XmlRpcGroupsMessaging" type="OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.XmlRpcGroupsMessaging" />
|
||||||
</Extension>
|
</Extension>
|
||||||
|
|
Loading…
Reference in New Issue