diff options
author | Melanie Thielker | 2014-04-06 23:22:37 +0200 |
---|---|---|
committer | Melanie Thielker | 2014-04-06 23:22:37 +0200 |
commit | bb841ea9cefb937c548646d366f689ef3bb80c61 (patch) | |
tree | 05e340d246962368a91fba0ac514d0a4dd804fc5 /OpenSim/Region/CoreModules/Avatar/InstantMessage | |
parent | Guard against Scene being null in attachments it the wearing avatar is in the... (diff) | |
download | opensim-SC-bb841ea9cefb937c548646d366f689ef3bb80c61.zip opensim-SC-bb841ea9cefb937c548646d366f689ef3bb80c61.tar.gz opensim-SC-bb841ea9cefb937c548646d366f689ef3bb80c61.tar.bz2 opensim-SC-bb841ea9cefb937c548646d366f689ef3bb80c61.tar.xz |
Change OfflineMessageModule to support more differentiated return values and allow support for mobile devices and other non-viewer logins
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/InstantMessage')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index 2d46276..41958b3 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | |||
@@ -40,6 +40,13 @@ using OpenSim.Region.Framework.Scenes; | |||
40 | 40 | ||
41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
42 | { | 42 | { |
43 | public struct SendReply | ||
44 | { | ||
45 | public bool Success; | ||
46 | public string Message; | ||
47 | public int Disposition; | ||
48 | } | ||
49 | |||
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "OfflineMessageModule")] | 50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "OfflineMessageModule")] |
44 | public class OfflineMessageModule : ISharedRegionModule | 51 | public class OfflineMessageModule : ISharedRegionModule |
45 | { | 52 | { |
@@ -50,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
50 | private string m_RestURL = String.Empty; | 57 | private string m_RestURL = String.Empty; |
51 | IMessageTransferModule m_TransferModule = null; | 58 | IMessageTransferModule m_TransferModule = null; |
52 | private bool m_ForwardOfflineGroupMessages = true; | 59 | private bool m_ForwardOfflineGroupMessages = true; |
60 | private Dictionary<IClientAPI, List<UUID>> m_repliesSent= new Dictionary<IClientAPI, List<UUID>>(); | ||
53 | 61 | ||
54 | public void Initialise(IConfigSource config) | 62 | public void Initialise(IConfigSource config) |
55 | { | 63 | { |
@@ -169,6 +177,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
169 | private void OnNewClient(IClientAPI client) | 177 | private void OnNewClient(IClientAPI client) |
170 | { | 178 | { |
171 | client.OnRetrieveInstantMessages += RetrieveInstantMessages; | 179 | client.OnRetrieveInstantMessages += RetrieveInstantMessages; |
180 | client.OnLogout += OnClientLoggedOut; | ||
181 | } | ||
182 | |||
183 | public void OnClientLoggedOut(IClientAPI client) | ||
184 | { | ||
185 | m_repliesSent.Remove(client); | ||
172 | } | 186 | } |
173 | 187 | ||
174 | private void RetrieveInstantMessages(IClientAPI client) | 188 | private void RetrieveInstantMessages(IClientAPI client) |
@@ -228,7 +242,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
228 | if (scene == null) | 242 | if (scene == null) |
229 | scene = m_SceneList[0]; | 243 | scene = m_SceneList[0]; |
230 | 244 | ||
231 | bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( | 245 | SendReply reply = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, SendReply>( |
232 | "POST", m_RestURL+"/SaveMessage/?scope=" + | 246 | "POST", m_RestURL+"/SaveMessage/?scope=" + |
233 | scene.RegionInfo.ScopeID.ToString(), im); | 247 | scene.RegionInfo.ScopeID.ToString(), im); |
234 | 248 | ||
@@ -238,13 +252,38 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
238 | if (client == null) | 252 | if (client == null) |
239 | return; | 253 | return; |
240 | 254 | ||
241 | client.SendInstantMessage(new GridInstantMessage( | 255 | if (reply.Message == String.Empty) |
242 | null, new UUID(im.toAgentID), | 256 | reply.Message = "User is not logged in. " + (reply.Success ? "Message saved." : "Message not saved"); |
243 | "System", new UUID(im.fromAgentID), | 257 | |
244 | (byte)InstantMessageDialog.MessageFromAgent, | 258 | bool sendReply = true; |
245 | "User is not logged in. "+ | 259 | |
246 | (success ? "Message saved." : "Message not saved"), | 260 | switch (reply.Disposition) |
247 | false, new Vector3())); | 261 | { |
262 | case 0: // Normal | ||
263 | break; | ||
264 | case 1: // Only once per user | ||
265 | if (m_repliesSent.ContainsKey(client) && m_repliesSent[client].Contains(new UUID(im.toAgentID))) | ||
266 | { | ||
267 | sendReply = false; | ||
268 | } | ||
269 | else | ||
270 | { | ||
271 | if (!m_repliesSent.ContainsKey(client)) | ||
272 | m_repliesSent[client] = new List<UUID>(); | ||
273 | m_repliesSent[client].Add(new UUID(im.toAgentID)); | ||
274 | } | ||
275 | break; | ||
276 | } | ||
277 | |||
278 | if (sendReply) | ||
279 | { | ||
280 | client.SendInstantMessage(new GridInstantMessage( | ||
281 | null, new UUID(im.toAgentID), | ||
282 | "System", new UUID(im.fromAgentID), | ||
283 | (byte)InstantMessageDialog.MessageFromAgent, | ||
284 | reply.Message, | ||
285 | false, new Vector3())); | ||
286 | } | ||
248 | } | 287 | } |
249 | } | 288 | } |
250 | } | 289 | } |