mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
Emailmodule. Receive mailbox dependis on prim having email event on scripts; send via smpt or to external prims are now options. The ini section name smtp is not wrong"
This commit is contained in:
@@ -68,6 +68,7 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
||||
private Dictionary<UUID, List<Email>> m_MailQueues = new Dictionary<UUID, List<Email>>();
|
||||
private Dictionary<UUID, double> m_LastGetEmailCall = new Dictionary<UUID, double>();
|
||||
private double m_QueueTimeout = 30 * 60; // 15min;
|
||||
private double m_nextQueuesExpire;
|
||||
private string m_InterObjectHostname = "lsl.opensim.local";
|
||||
|
||||
private int m_MaxEmailSize = 4096; // largest email allowed by default, as per lsl docs.
|
||||
@@ -75,6 +76,8 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
||||
private static SslPolicyErrors m_SMTP_SslPolicyErrorsMask;
|
||||
private bool m_checkSpecName;
|
||||
|
||||
private object m_queuesLock = new object();
|
||||
|
||||
// Scenes by Region Handle
|
||||
private Dictionary<ulong, Scene> m_Scenes = new Dictionary<ulong, Scene>();
|
||||
|
||||
@@ -149,6 +152,7 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
||||
return;
|
||||
}
|
||||
|
||||
m_nextQueuesExpire = Util.GetTimeStamp() + m_QueueTimeout;
|
||||
m_Enabled = true;
|
||||
}
|
||||
|
||||
@@ -198,28 +202,49 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
||||
|
||||
#endregion
|
||||
|
||||
public void AddPartMailBox(UUID objectID)
|
||||
{
|
||||
lock (m_queuesLock)
|
||||
{
|
||||
if (!m_MailQueues.TryGetValue(objectID, out List<Email> elist))
|
||||
{
|
||||
m_MailQueues[objectID] = null;
|
||||
//TODO external global
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RemovePartMailBox(UUID objectID)
|
||||
{
|
||||
lock (m_queuesLock)
|
||||
{
|
||||
m_LastGetEmailCall.Remove(objectID);
|
||||
if (m_MailQueues.Remove(objectID))
|
||||
{
|
||||
//TODO external global
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void InsertEmail(UUID to, Email email)
|
||||
{
|
||||
lock (m_MailQueues)
|
||||
lock (m_queuesLock)
|
||||
{
|
||||
if (m_MailQueues.TryGetValue(to, out List<Email> elist))
|
||||
{
|
||||
if (elist.Count >= m_MaxQueueSize)
|
||||
return;
|
||||
lock (elist)
|
||||
if(elist == null)
|
||||
{
|
||||
elist = new List<Email>();
|
||||
elist.Add(email);
|
||||
m_MailQueues[to] = elist;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (elist.Count >= m_MaxQueueSize)
|
||||
return;
|
||||
lock (elist)
|
||||
elist.Add(email);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
elist = new List<Email>();
|
||||
elist.Add(email);
|
||||
m_MailQueues[to] = elist;
|
||||
}
|
||||
|
||||
lock (m_LastGetEmailCall)
|
||||
{
|
||||
m_LastGetEmailCall[to] = Util.GetTimeStamp() + m_QueueTimeout;
|
||||
}
|
||||
}
|
||||
@@ -398,63 +423,55 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
|
||||
/// <returns></returns>
|
||||
public Email GetNextEmail(UUID objectID, string sender, string subject)
|
||||
{
|
||||
lock (m_LastGetEmailCall)
|
||||
lock (m_queuesLock)
|
||||
{
|
||||
double now = Util.GetTimeStamp();
|
||||
m_LastGetEmailCall[objectID] = now + m_QueueTimeout;
|
||||
|
||||
List<UUID> removal = new List<UUID>(m_LastGetEmailCall.Count);
|
||||
foreach (KeyValuePair<UUID, double> kpv in m_LastGetEmailCall)
|
||||
if( now > m_nextQueuesExpire)
|
||||
{
|
||||
if (kpv.Value < now)
|
||||
removal.Add(kpv.Key);
|
||||
}
|
||||
|
||||
foreach (UUID remove in removal)
|
||||
{
|
||||
m_LastGetEmailCall.Remove(remove);
|
||||
lock (m_MailQueues)
|
||||
List<UUID> removal = new List<UUID>(m_LastGetEmailCall.Count);
|
||||
foreach (KeyValuePair<UUID, double> kpv in m_LastGetEmailCall)
|
||||
{
|
||||
m_MailQueues.Remove(remove);
|
||||
if (kpv.Value < now)
|
||||
removal.Add(kpv.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Email> queue = null;
|
||||
lock (m_MailQueues)
|
||||
{
|
||||
m_MailQueues.TryGetValue(objectID, out queue);
|
||||
}
|
||||
|
||||
if (queue != null)
|
||||
{
|
||||
lock (queue)
|
||||
{
|
||||
if (queue.Count > 0)
|
||||
foreach (UUID remove in removal)
|
||||
{
|
||||
bool emptySender = string.IsNullOrEmpty(sender);
|
||||
bool emptySubject = string.IsNullOrEmpty(subject);
|
||||
m_LastGetEmailCall.Remove(remove);
|
||||
m_MailQueues[remove] = null;
|
||||
}
|
||||
m_nextQueuesExpire = now + m_QueueTimeout;
|
||||
}
|
||||
|
||||
int i;
|
||||
Email ret;
|
||||
for (i = 0; i < queue.Count; i++)
|
||||
m_MailQueues.TryGetValue(objectID, out List<Email> queue);
|
||||
if (queue != null)
|
||||
{
|
||||
lock (queue)
|
||||
{
|
||||
if (queue.Count > 0)
|
||||
{
|
||||
ret = queue[i];
|
||||
if (emptySender || sender.Equals(ret.sender, StringComparison.InvariantCultureIgnoreCase) &&
|
||||
(emptySubject || subject.Equals(ret.subject, StringComparison.InvariantCultureIgnoreCase)))
|
||||
bool emptySender = string.IsNullOrEmpty(sender);
|
||||
bool emptySubject = string.IsNullOrEmpty(subject);
|
||||
|
||||
int i;
|
||||
Email ret;
|
||||
for (i = 0; i < queue.Count; i++)
|
||||
{
|
||||
queue.RemoveAt(i);
|
||||
ret.numLeft = queue.Count;
|
||||
if (queue.Count == 0)
|
||||
ret = queue[i];
|
||||
if (emptySender || sender.Equals(ret.sender, StringComparison.InvariantCultureIgnoreCase) &&
|
||||
(emptySubject || subject.Equals(ret.subject, StringComparison.InvariantCultureIgnoreCase)))
|
||||
{
|
||||
lock (m_MailQueues)
|
||||
queue.RemoveAt(i);
|
||||
ret.numLeft = queue.Count;
|
||||
if (queue.Count == 0)
|
||||
{
|
||||
m_MailQueues.Remove(objectID);
|
||||
lock (m_LastGetEmailCall)
|
||||
m_LastGetEmailCall.Remove(objectID);
|
||||
m_MailQueues[objectID] = null;
|
||||
m_LastGetEmailCall.Remove(objectID);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,5 +42,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
{
|
||||
void SendEmail(UUID objectID, string address, string subject, string body);
|
||||
Email GetNextEmail(UUID objectID, string sender, string subject);
|
||||
void AddPartMailBox(UUID objectID);
|
||||
void RemovePartMailBox(UUID objectID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2872,6 +2872,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
part.KeyframeMotion = null;
|
||||
}
|
||||
|
||||
if ((part.AggregatedScriptEvents & scriptEvents.email) != 0)
|
||||
{
|
||||
IEmailModule imm = RequestModuleInterface<IEmailModule>();
|
||||
if (imm != null)
|
||||
imm.RemovePartMailBox(part.UUID);
|
||||
}
|
||||
if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0))
|
||||
{
|
||||
PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed?
|
||||
|
||||
@@ -3106,6 +3106,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
if((ev & (scriptEvents.anyTarget)) != 0 && ParentGroup != null)
|
||||
ParentGroup.RemoveScriptTargets(scriptid);
|
||||
if ((AggregatedScriptEvents & scriptEvents.email) != 0)
|
||||
{
|
||||
IEmailModule scriptEmail = ParentGroup.Scene.RequestModuleInterface<IEmailModule>();
|
||||
if (scriptEmail != null)
|
||||
scriptEmail.RemovePartMailBox(UUID);
|
||||
}
|
||||
m_scriptEvents.Remove(scriptid);
|
||||
aggregateScriptEvents();
|
||||
}
|
||||
@@ -5384,7 +5390,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
m_localFlags = (PrimFlags)objectflagupdate;
|
||||
|
||||
if (ParentGroup != null && ParentGroup.RootPart == this)
|
||||
if ((AggregatedScriptEvents & scriptEvents.email) != 0)
|
||||
{
|
||||
IEmailModule imm = ParentGroup.Scene.RequestModuleInterface<IEmailModule>();
|
||||
if (imm != null)
|
||||
imm.AddPartMailBox(UUID);
|
||||
}
|
||||
|
||||
if (ParentGroup.RootPart == this)
|
||||
{
|
||||
ParentGroup.aggregateScriptEvents();
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@
|
||||
; if not set SMTP_SERVER_FROM below
|
||||
; host_domain_header_from = "127.0.0.1"
|
||||
|
||||
;# {SMTP_SERVER_FROM} {[Startup]emailmodule:DefaultEmailModule2 enabled:true} {SMTP server from name?} {}
|
||||
;# {SMTP_SERVER_FROM} {[Startup]emailmodule:DefaultEmailModule enabled:true} {SMTP server from name?} {}
|
||||
; some smtp servers require a known From email address or will give Error 500 - Envelope from address is not authorised
|
||||
; set to a valid email address that smtp will accept (in some cases must be like SMTP_SERVER_LOGIN)
|
||||
; SMTP_SERVER_FROM = ""
|
||||
|
||||
Reference in New Issue
Block a user