Thank you, DoranZemlja, for a patch that implements local inter-object email
delivery. Leaving Mantis #3145 open so that more code can be added.0.6.3-post-fixes
parent
3542630478
commit
4bc52888be
|
@ -57,12 +57,32 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
|||
private string SMTP_SERVER_LOGIN = string.Empty;
|
||||
private string SMTP_SERVER_PASSWORD = string.Empty;
|
||||
|
||||
private int m_MaxQueueSize = 50; // maximum size of an object mail queue
|
||||
private Dictionary<UUID, List<Email>> m_MailQueues = new Dictionary<UUID, List<Email>>();
|
||||
private string m_InterObjectHostname;
|
||||
|
||||
// Scenes by Region Handle
|
||||
private Dictionary<ulong, Scene> m_Scenes =
|
||||
new Dictionary<ulong, Scene>();
|
||||
|
||||
private bool m_Enabled = false;
|
||||
|
||||
public void InsertEmail(UUID to, Email email)
|
||||
{
|
||||
if (!m_MailQueues.ContainsKey(to))
|
||||
{
|
||||
m_MailQueues.Add(to, new List<Email>());
|
||||
}
|
||||
|
||||
if (m_MailQueues[to].Count >= m_MaxQueueSize)
|
||||
{
|
||||
// fail silently
|
||||
return;
|
||||
}
|
||||
|
||||
m_MailQueues[to].Add(email);
|
||||
}
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource config)
|
||||
{
|
||||
m_Config = config;
|
||||
|
@ -93,7 +113,8 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
|||
}
|
||||
|
||||
m_HostName = SMTPConfig.GetString("host_domain_header_from", m_HostName);
|
||||
SMTP_SERVER_HOSTNAME = SMTPConfig.GetString("SMTP_SERVER_HOSTNAME",SMTP_SERVER_HOSTNAME);
|
||||
m_InterObjectHostname = SMTPConfig.GetString("internal_object_host", "lsl.secondlife.com");
|
||||
SMTP_SERVER_HOSTNAME = SMTPConfig.GetString("SMTP_SERVER_HOSTNAME", SMTP_SERVER_HOSTNAME);
|
||||
SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT);
|
||||
SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN);
|
||||
SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD);
|
||||
|
@ -160,6 +181,12 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
|||
}
|
||||
}
|
||||
|
||||
private bool IsLocal(UUID objectID)
|
||||
{
|
||||
string unused;
|
||||
return (null != findPrim(objectID, out unused));
|
||||
}
|
||||
|
||||
private SceneObjectPart findPrim(UUID objectID, out string ObjectRegionName)
|
||||
{
|
||||
lock (m_Scenes)
|
||||
|
@ -228,18 +255,24 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
|||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
string LastObjectName = string.Empty;
|
||||
string LastObjectPosition = string.Empty;
|
||||
string LastObjectRegionName = string.Empty;
|
||||
//DONE: Message as Second Life style
|
||||
//20 second delay - AntiSpam System - for now only 10 seconds
|
||||
DelayInSeconds(10);
|
||||
|
||||
resolveNamePositionRegionName(objectID, out LastObjectName, out LastObjectPosition, out LastObjectRegionName);
|
||||
|
||||
if (!address.EndsWith(m_InterObjectHostname))
|
||||
{
|
||||
// regular email, send it out
|
||||
try
|
||||
{
|
||||
//Creation EmailMessage
|
||||
EmailMessage emailMessage = new EmailMessage();
|
||||
//From
|
||||
emailMessage.FromAddress = new EmailAddress(objectID.ToString()+"@"+m_HostName);
|
||||
emailMessage.FromAddress = new EmailAddress(objectID.ToString() + "@" + m_HostName);
|
||||
//To - Only One
|
||||
emailMessage.AddToAddress(new EmailAddress(address));
|
||||
//Subject
|
||||
|
@ -248,18 +281,19 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
|||
resolveNamePositionRegionName(objectID, out LastObjectName, out LastObjectPosition, out LastObjectRegionName);
|
||||
emailMessage.TextPart = new TextAttachment("Object-Name: " + LastObjectName +
|
||||
"\r\nRegion: " + LastObjectRegionName + "\r\nLocal-Position: " +
|
||||
LastObjectPosition+"\r\n\r\n\r\n" + body);
|
||||
LastObjectPosition + "\r\n\r\n" + body);
|
||||
|
||||
//HTML Body
|
||||
emailMessage.HtmlPart = new HtmlAttachment("<html><body><p>" +
|
||||
"<BR>Object-Name: " + LastObjectName +
|
||||
"<BR>Region: " + LastObjectRegionName +
|
||||
"<BR>Local-Position: " + LastObjectPosition + "<BR><BR><BR>"
|
||||
+body+"\r\n</p></body><html>");
|
||||
+ body + "\r\n</p></body><html>");
|
||||
|
||||
//Set SMTP SERVER config
|
||||
SmtpServer smtpServer=new SmtpServer(SMTP_SERVER_HOSTNAME,SMTP_SERVER_PORT);
|
||||
SmtpServer smtpServer = new SmtpServer(SMTP_SERVER_HOSTNAME, SMTP_SERVER_PORT);
|
||||
//Authentication
|
||||
smtpServer.SmtpAuthToken=new SmtpAuthToken(SMTP_SERVER_LOGIN, SMTP_SERVER_PASSWORD);
|
||||
smtpServer.SmtpAuthToken = new SmtpAuthToken(SMTP_SERVER_LOGIN, SMTP_SERVER_PASSWORD);
|
||||
//Send Email Message
|
||||
emailMessage.Send(smtpServer);
|
||||
//Log
|
||||
|
@ -267,10 +301,37 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[EMAIL] DefaultEmailModule Exception: "+e.Message);
|
||||
m_log.Error("[EMAIL] DefaultEmailModule Exception: " + e.Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// inter object email, keep it in the family
|
||||
Email email = new Email();
|
||||
email.time = ((DateTime.UtcNow - new DateTime(1970,1,1,0,0,0)).TotalSeconds).ToString();
|
||||
email.subject = subject;
|
||||
email.sender = objectID.ToString() + "@" + m_InterObjectHostname;
|
||||
email.message = "Object-Name: " + LastObjectName +
|
||||
"\nRegion: " + LastObjectRegionName + "\nLocal-Position: " +
|
||||
LastObjectPosition + "\n\n" + body;
|
||||
|
||||
UUID toID = new UUID(address.Substring(0, address.IndexOf("@")));
|
||||
|
||||
String unused;
|
||||
|
||||
if (IsLocal(toID)) // TODO FIX check to see if it is local
|
||||
{
|
||||
// object in this region
|
||||
InsertEmail(toID, email);
|
||||
}
|
||||
else
|
||||
{
|
||||
// object on another region
|
||||
// TODO FIX
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -281,6 +342,33 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
|||
/// <returns></returns>
|
||||
public Email GetNextEmail(UUID objectID, string sender, string subject)
|
||||
{
|
||||
if (m_MailQueues.ContainsKey(objectID))
|
||||
{
|
||||
List<Email> queue = m_MailQueues[objectID];
|
||||
|
||||
if (queue.Count > 0)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < queue.Count; i++)
|
||||
{
|
||||
if ((sender == null || sender.Equals("") || sender.Equals(queue[i].sender)) &&
|
||||
(subject == null || subject.Equals("") || subject.Equals(queue[i].subject)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i != queue.Count)
|
||||
{
|
||||
Email ret = queue[i];
|
||||
queue.Remove(ret);
|
||||
ret.numLeft = queue.Count;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2702,7 +2702,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
m_host.AddScriptLPS(1);
|
||||
IEmailModule emailModule = m_ScriptEngine.World.RequestModuleInterface<IEmailModule>();
|
||||
if (emailModule == null)
|
||||
{
|
||||
ShoutError("llEmail: email module not configured");
|
||||
return;
|
||||
}
|
||||
|
||||
emailModule.SendEmail(m_host.UUID, address, subject, message);
|
||||
// ScriptSleep(20000);
|
||||
|
@ -2713,7 +2716,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
m_host.AddScriptLPS(1);
|
||||
IEmailModule emailModule = m_ScriptEngine.World.RequestModuleInterface<IEmailModule>();
|
||||
if (emailModule == null)
|
||||
{
|
||||
ShoutError("llGetNextEmail: email module not configured");
|
||||
return;
|
||||
}
|
||||
Email email;
|
||||
|
||||
email = emailModule.GetNextEmail(m_host.UUID, address, subject);
|
||||
|
@ -3668,11 +3674,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
|
||||
UUID partItemID;
|
||||
foreach (SceneObjectPart part in parts)
|
||||
{
|
||||
foreach (TaskInventoryItem item in part.TaskInventory.Values)
|
||||
{
|
||||
if (item.Type == ScriptBaseClass.INVENTORY_SCRIPT)
|
||||
{
|
||||
|
||||
partItemID = item.ItemID;
|
||||
int linkNumber = m_host.LinkNum;
|
||||
if (m_host.ParentGroup.Children.Count == 1)
|
||||
|
@ -3690,6 +3696,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void llPushObject(string target, LSL_Vector impulse, LSL_Vector ang_impulse, int local)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue