Change OfflineMessageModule to support more differentiated return values and allow support for mobile devices and other non-viewer logins
parent
a30ad71651
commit
bb841ea9ce
|
@ -40,6 +40,13 @@ using OpenSim.Region.Framework.Scenes;
|
||||||
|
|
||||||
namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||||
{
|
{
|
||||||
|
public struct SendReply
|
||||||
|
{
|
||||||
|
public bool Success;
|
||||||
|
public string Message;
|
||||||
|
public int Disposition;
|
||||||
|
}
|
||||||
|
|
||||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "OfflineMessageModule")]
|
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "OfflineMessageModule")]
|
||||||
public class OfflineMessageModule : ISharedRegionModule
|
public class OfflineMessageModule : ISharedRegionModule
|
||||||
{
|
{
|
||||||
|
@ -50,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||||
private string m_RestURL = String.Empty;
|
private string m_RestURL = String.Empty;
|
||||||
IMessageTransferModule m_TransferModule = null;
|
IMessageTransferModule m_TransferModule = null;
|
||||||
private bool m_ForwardOfflineGroupMessages = true;
|
private bool m_ForwardOfflineGroupMessages = true;
|
||||||
|
private Dictionary<IClientAPI, List<UUID>> m_repliesSent= new Dictionary<IClientAPI, List<UUID>>();
|
||||||
|
|
||||||
public void Initialise(IConfigSource config)
|
public void Initialise(IConfigSource config)
|
||||||
{
|
{
|
||||||
|
@ -169,6 +177,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||||
private void OnNewClient(IClientAPI client)
|
private void OnNewClient(IClientAPI client)
|
||||||
{
|
{
|
||||||
client.OnRetrieveInstantMessages += RetrieveInstantMessages;
|
client.OnRetrieveInstantMessages += RetrieveInstantMessages;
|
||||||
|
client.OnLogout += OnClientLoggedOut;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnClientLoggedOut(IClientAPI client)
|
||||||
|
{
|
||||||
|
m_repliesSent.Remove(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RetrieveInstantMessages(IClientAPI client)
|
private void RetrieveInstantMessages(IClientAPI client)
|
||||||
|
@ -228,7 +242,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||||
if (scene == null)
|
if (scene == null)
|
||||||
scene = m_SceneList[0];
|
scene = m_SceneList[0];
|
||||||
|
|
||||||
bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>(
|
SendReply reply = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, SendReply>(
|
||||||
"POST", m_RestURL+"/SaveMessage/?scope=" +
|
"POST", m_RestURL+"/SaveMessage/?scope=" +
|
||||||
scene.RegionInfo.ScopeID.ToString(), im);
|
scene.RegionInfo.ScopeID.ToString(), im);
|
||||||
|
|
||||||
|
@ -238,13 +252,38 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||||
if (client == null)
|
if (client == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
client.SendInstantMessage(new GridInstantMessage(
|
if (reply.Message == String.Empty)
|
||||||
null, new UUID(im.toAgentID),
|
reply.Message = "User is not logged in. " + (reply.Success ? "Message saved." : "Message not saved");
|
||||||
"System", new UUID(im.fromAgentID),
|
|
||||||
(byte)InstantMessageDialog.MessageFromAgent,
|
bool sendReply = true;
|
||||||
"User is not logged in. "+
|
|
||||||
(success ? "Message saved." : "Message not saved"),
|
switch (reply.Disposition)
|
||||||
false, new Vector3()));
|
{
|
||||||
|
case 0: // Normal
|
||||||
|
break;
|
||||||
|
case 1: // Only once per user
|
||||||
|
if (m_repliesSent.ContainsKey(client) && m_repliesSent[client].Contains(new UUID(im.toAgentID)))
|
||||||
|
{
|
||||||
|
sendReply = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!m_repliesSent.ContainsKey(client))
|
||||||
|
m_repliesSent[client] = new List<UUID>();
|
||||||
|
m_repliesSent[client].Add(new UUID(im.toAgentID));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sendReply)
|
||||||
|
{
|
||||||
|
client.SendInstantMessage(new GridInstantMessage(
|
||||||
|
null, new UUID(im.toAgentID),
|
||||||
|
"System", new UUID(im.fromAgentID),
|
||||||
|
(byte)InstantMessageDialog.MessageFromAgent,
|
||||||
|
reply.Message,
|
||||||
|
false, new Vector3()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue