One more module converted: EmailModule.

integration
Diva Canto 2012-11-11 14:00:58 -08:00
parent f560d581bb
commit 84be90e5f8
1 changed files with 64 additions and 46 deletions

View File

@ -37,10 +37,12 @@ using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using Mono.Addins;
namespace OpenSim.Region.CoreModules.Scripting.EmailModules namespace OpenSim.Region.CoreModules.Scripting.EmailModules
{ {
public class EmailModule : IRegionModule, IEmailModule [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EmailModule")]
public class EmailModule : ISharedRegionModule, IEmailModule
{ {
// //
// Log // Log
@ -72,31 +74,9 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
private bool m_Enabled = false; private bool m_Enabled = false;
public void InsertEmail(UUID to, Email email) #region ISharedRegionModule
{
// It's tempting to create the queue here. Don't; objects which have
// not yet called GetNextEmail should have no queue, and emails to them
// should be silently dropped.
lock (m_MailQueues) public void Initialise(IConfigSource config)
{
if (m_MailQueues.ContainsKey(to))
{
if (m_MailQueues[to].Count >= m_MaxQueueSize)
{
// fail silently
return;
}
lock (m_MailQueues[to])
{
m_MailQueues[to].Add(email);
}
}
}
}
public void Initialise(Scene scene, IConfigSource config)
{ {
m_Config = config; m_Config = config;
IConfig SMTPConfig; IConfig SMTPConfig;
@ -129,36 +109,44 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT); SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT);
SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN); SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN);
SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD); SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD);
m_MaxEmailSize = SMTPConfig.GetInt("email_max_size", m_MaxEmailSize); m_MaxEmailSize = SMTPConfig.GetInt("email_max_size", m_MaxEmailSize);
} }
catch (Exception e) catch (Exception e)
{ {
m_log.Error("[EMAIL] DefaultEmailModule not configured: "+ e.Message); m_log.Error("[EMAIL] DefaultEmailModule not configured: " + e.Message);
m_Enabled = false; m_Enabled = false;
return; return;
} }
// It's a go! }
if (m_Enabled)
public void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
// It's a go!
lock (m_Scenes)
{ {
lock (m_Scenes) // Claim the interface slot
scene.RegisterModuleInterface<IEmailModule>(this);
// Add to scene list
if (m_Scenes.ContainsKey(scene.RegionInfo.RegionHandle))
{ {
// Claim the interface slot m_Scenes[scene.RegionInfo.RegionHandle] = scene;
scene.RegisterModuleInterface<IEmailModule>(this); }
else
// Add to scene list {
if (m_Scenes.ContainsKey(scene.RegionInfo.RegionHandle)) m_Scenes.Add(scene.RegionInfo.RegionHandle, scene);
{
m_Scenes[scene.RegionInfo.RegionHandle] = scene;
}
else
{
m_Scenes.Add(scene.RegionInfo.RegionHandle, scene);
}
} }
m_log.Info("[EMAIL] Activated DefaultEmailModule");
} }
m_log.Info("[EMAIL] Activated DefaultEmailModule");
}
public void RemoveRegion(Scene scene)
{
} }
public void PostInitialise() public void PostInitialise()
@ -174,9 +162,39 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
get { return "DefaultEmailModule"; } get { return "DefaultEmailModule"; }
} }
public bool IsSharedModule public Type ReplaceableInterface
{ {
get { return true; } get { return null; }
}
public void RegionLoaded(Scene scene)
{
}
#endregion
public void InsertEmail(UUID to, Email email)
{
// It's tempting to create the queue here. Don't; objects which have
// not yet called GetNextEmail should have no queue, and emails to them
// should be silently dropped.
lock (m_MailQueues)
{
if (m_MailQueues.ContainsKey(to))
{
if (m_MailQueues[to].Count >= m_MaxQueueSize)
{
// fail silently
return;
}
lock (m_MailQueues[to])
{
m_MailQueues[to].Add(email);
}
}
}
} }
private bool IsLocal(UUID objectID) private bool IsLocal(UUID objectID)