Fix the plumbing in the offline message module.

No functionality yet.
0.6.5-rc1
Melanie Thielker 2009-03-28 04:02:30 +00:00
parent 0ff7c85a5d
commit b40ec850bb
2 changed files with 51 additions and 27 deletions

View File

@ -167,6 +167,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
return;
}
HandleUndeliveredMessage(im, result);
return;
}
private void HandleUndeliveredMessage(GridInstantMessage im, MessageResultNotification result)
{
UndeliveredMessage handlerUndeliveredMessage = OnUndeliveredMessage;
// If this event has handlers, then the IM will be considered
@ -181,7 +188,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
//m_log.DebugFormat("[INSTANT MESSAGE]: Undeliverable");
result(false);
return;
}
/// <summary>
@ -487,14 +493,14 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
if (upd.Handle == prevRegionHandle)
{
m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
result(false);
HandleUndeliveredMessage(im, result);
return;
}
}
else
{
m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
result(false);
HandleUndeliveredMessage(im, result);
return;
}
}
@ -544,18 +550,18 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
else
{
m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.Handle);
result(false);
HandleUndeliveredMessage(im, result);
}
}
else
{
result(false);
HandleUndeliveredMessage(im, result);
}
}
else
{
m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find user {0}", toAgentID);
result(false);
HandleUndeliveredMessage(im, result);
}
}

View File

@ -55,18 +55,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
lock (m_SceneList)
{
if (m_SceneList.Count == 0)
{
IMessageTransferModule trans = scene.RequestModuleInterface<IMessageTransferModule>();
if (trans == null)
{
enabled = false;
return;
}
trans.OnUndeliveredMessage += UndeliveredMessage;
}
if (!m_SceneList.Contains(scene))
m_SceneList.Add(scene);
@ -76,6 +64,28 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
public void PostInitialise()
{
if (m_SceneList.Count == 0)
return;
IMessageTransferModule trans = m_SceneList[0].RequestModuleInterface<IMessageTransferModule>();
if (trans == null)
{
enabled = false;
lock (m_SceneList)
{
foreach (Scene s in m_SceneList)
s.EventManager.OnNewClient -= OnNewClient;
m_SceneList.Clear();
}
return;
}
trans.OnUndeliveredMessage += UndeliveredMessage;
m_log.Debug("[OFFLINE MESSAGING] Offline messages enabled");
}
public string Name
@ -115,16 +125,24 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
private void UndeliveredMessage(GridInstantMessage im)
{
IClientAPI client = FindClient(new UUID(im.toAgentID));
if (client == null)
return;
if (im.offline != 0)
{
// TODO: Actually save it
client.SendInstantMessage(new UUID(im.toAgentID),
"User is not logged in. "+
"Message saved.",
new UUID(im.fromAgentID), "System",
(byte)InstantMessageDialog.BusyAutoResponse,
(uint)Util.UnixTimeSinceEpoch());
if(im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
{
IClientAPI client = FindClient(new UUID(im.fromAgentID));
if (client == null)
return;
client.SendInstantMessage(new UUID(im.fromAgentID),
"User is not logged in. "+
"Message saved.",
new UUID(im.toAgentID), "System",
(byte)InstantMessageDialog.BusyAutoResponse,
(uint)Util.UnixTimeSinceEpoch());
}
}
}
}
}