diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | 87 |
1 files changed, 55 insertions, 32 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index 297346a..315ce1b 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | |||
@@ -52,6 +52,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
53 | 53 | ||
54 | private bool enabled = true; | 54 | private bool enabled = true; |
55 | private bool m_UseNewAvnCode = false; | ||
55 | private List<Scene> m_SceneList = new List<Scene>(); | 56 | private List<Scene> m_SceneList = new List<Scene>(); |
56 | private string m_RestURL = String.Empty; | 57 | private string m_RestURL = String.Empty; |
57 | IMessageTransferModule m_TransferModule = null; | 58 | IMessageTransferModule m_TransferModule = null; |
@@ -82,6 +83,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
82 | } | 83 | } |
83 | 84 | ||
84 | m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages); | 85 | m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages); |
86 | m_UseNewAvnCode = cnf.GetBoolean("UseNewAvnCode", m_UseNewAvnCode); | ||
85 | } | 87 | } |
86 | 88 | ||
87 | public void AddRegion(Scene scene) | 89 | public void AddRegion(Scene scene) |
@@ -244,51 +246,72 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
244 | return; | 246 | return; |
245 | } | 247 | } |
246 | 248 | ||
247 | Scene scene = FindScene(new UUID(im.fromAgentID)); | 249 | if(m_UseNewAvnCode) |
248 | if (scene == null) | 250 | { |
249 | scene = m_SceneList[0]; | 251 | Scene scene = FindScene(new UUID(im.fromAgentID)); |
252 | if (scene == null) | ||
253 | scene = m_SceneList[0]; | ||
250 | 254 | ||
251 | SendReply reply = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, SendReply>( | 255 | UUID scopeID = scene.RegionInfo.ScopeID; |
252 | "POST", m_RestURL+"/SaveMessage/?scope=" + | 256 | SendReply reply = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, SendReply>( |
253 | scene.RegionInfo.ScopeID.ToString(), im); | 257 | "POST", m_RestURL+"/SaveMessage/?scope=" + scopeID.ToString(), im, 20000); |
254 | 258 | ||
255 | if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) | 259 | if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) |
256 | { | 260 | { |
257 | IClientAPI client = FindClient(new UUID(im.fromAgentID)); | 261 | IClientAPI client = FindClient(new UUID(im.fromAgentID)); |
258 | if (client == null) | 262 | if (client == null) |
259 | return; | 263 | return; |
260 | 264 | ||
261 | if (reply.Message == String.Empty) | 265 | if (string.IsNullOrEmpty(reply.Message)) |
262 | reply.Message = "User is not logged in. " + (reply.Success ? "Message saved." : "Message not saved"); | 266 | reply.Message = "User is not logged in. " + (reply.Success ? "Message saved." : "Message not saved"); |
263 | 267 | ||
264 | bool sendReply = true; | 268 | bool sendReply = true; |
265 | 269 | ||
266 | switch (reply.Disposition) | 270 | switch (reply.Disposition) |
267 | { | ||
268 | case 0: // Normal | ||
269 | break; | ||
270 | case 1: // Only once per user | ||
271 | if (m_repliesSent.ContainsKey(client) && m_repliesSent[client].Contains(new UUID(im.toAgentID))) | ||
272 | { | 271 | { |
273 | sendReply = false; | 272 | case 0: // Normal |
273 | break; | ||
274 | case 1: // Only once per user | ||
275 | if (m_repliesSent.ContainsKey(client) && m_repliesSent[client].Contains(new UUID(im.toAgentID))) | ||
276 | sendReply = false; | ||
277 | else | ||
278 | { | ||
279 | if (!m_repliesSent.ContainsKey(client)) | ||
280 | m_repliesSent[client] = new List<UUID>(); | ||
281 | m_repliesSent[client].Add(new UUID(im.toAgentID)); | ||
282 | } | ||
283 | break; | ||
274 | } | 284 | } |
275 | else | 285 | |
286 | if (sendReply) | ||
276 | { | 287 | { |
277 | if (!m_repliesSent.ContainsKey(client)) | 288 | client.SendInstantMessage(new GridInstantMessage( |
278 | m_repliesSent[client] = new List<UUID>(); | 289 | null, new UUID(im.toAgentID), |
279 | m_repliesSent[client].Add(new UUID(im.toAgentID)); | 290 | "System", new UUID(im.fromAgentID), |
291 | (byte)InstantMessageDialog.MessageFromAgent, | ||
292 | reply.Message, | ||
293 | false, new Vector3())); | ||
280 | } | 294 | } |
281 | break; | ||
282 | } | 295 | } |
296 | } | ||
297 | else | ||
298 | { | ||
299 | bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( | ||
300 | "POST", m_RestURL+"/SaveMessage/", im, 20000); | ||
283 | 301 | ||
284 | if (sendReply) | 302 | if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) |
285 | { | 303 | { |
304 | IClientAPI client = FindClient(new UUID(im.fromAgentID)); | ||
305 | if (client == null) | ||
306 | return; | ||
307 | |||
286 | client.SendInstantMessage(new GridInstantMessage( | 308 | client.SendInstantMessage(new GridInstantMessage( |
287 | null, new UUID(im.toAgentID), | 309 | null, new UUID(im.toAgentID), |
288 | "System", new UUID(im.fromAgentID), | 310 | "System", new UUID(im.fromAgentID), |
289 | (byte)InstantMessageDialog.MessageFromAgent, | 311 | (byte)InstantMessageDialog.MessageFromAgent, |
290 | reply.Message, | 312 | "User is not logged in. "+ |
291 | false, new Vector3())); | 313 | (success ? "Message saved." : "Message not saved"), |
314 | false, new Vector3())); | ||
292 | } | 315 | } |
293 | } | 316 | } |
294 | } | 317 | } |