aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs112
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs10
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs17
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs169
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs211
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs67
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs104
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs52
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs168
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs32
13 files changed, 713 insertions, 236 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 24170fc..acd156e 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -40,6 +40,7 @@ using OpenSim.Region.Framework;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Scenes.Serialization; 42using OpenSim.Region.Framework.Scenes.Serialization;
43using OpenSim.Services.Interfaces;
43 44
44namespace OpenSim.Region.CoreModules.Avatar.Attachments 45namespace OpenSim.Region.CoreModules.Avatar.Attachments
45{ 46{
@@ -169,6 +170,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
169 170
170// m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0}", sp.Name); 171// m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0}", sp.Name);
171 172
173 XmlDocument doc = new XmlDocument();
174 string stateData = String.Empty;
175
176 IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>();
177 if (attServ != null)
178 {
179 m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service");
180 stateData = attServ.Get(sp.UUID.ToString());
181 if (stateData != String.Empty)
182 {
183 try
184 {
185 doc.LoadXml(stateData);
186 }
187 catch { }
188 }
189 }
190
191 Dictionary<UUID, string> itemData = new Dictionary<UUID, string>();
192
193 XmlNodeList nodes = doc.GetElementsByTagName("Attachment");
194 if (nodes.Count > 0)
195 {
196 foreach (XmlNode n in nodes)
197 {
198 XmlElement elem = (XmlElement)n;
199 string itemID = elem.GetAttribute("ItemID");
200 string xml = elem.InnerXml;
201
202 itemData[new UUID(itemID)] = xml;
203 }
204 }
205
206
172 List<AvatarAttachment> attachments = sp.Appearance.GetAttachments(); 207 List<AvatarAttachment> attachments = sp.Appearance.GetAttachments();
173 foreach (AvatarAttachment attach in attachments) 208 foreach (AvatarAttachment attach in attachments)
174 { 209 {
@@ -188,12 +223,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
188 223
189 try 224 try
190 { 225 {
226 string xmlData;
227 XmlDocument d = null;
228 UUID asset;
229 if (itemData.TryGetValue(attach.ItemID, out xmlData))
230 {
231 d = new XmlDocument();
232 d.LoadXml(xmlData);
233 m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", attach.ItemID);
234 }
235
191 // If we're an NPC then skip all the item checks and manipulations since we don't have an 236 // If we're an NPC then skip all the item checks and manipulations since we don't have an
192 // inventory right now. 237 // inventory right now.
193 if (sp.PresenceType == PresenceType.Npc) 238 if (sp.PresenceType == PresenceType.Npc)
194 RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p); 239 RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p, null);
195 else 240 else
196 RezSingleAttachmentFromInventory(sp, attach.ItemID, p); 241 RezSingleAttachmentFromInventory(sp, attach.ItemID, p, d);
197 } 242 }
198 catch (Exception e) 243 catch (Exception e)
199 { 244 {
@@ -238,13 +283,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
238 283
239 sp.ClearAttachments(); 284 sp.ClearAttachments();
240 } 285 }
241 286
242 public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp) 287 public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp)
243 { 288 {
244 if (!Enabled) 289 if (!Enabled)
245 return false; 290 return false;
246 291
247 if (AttachObjectInternal(sp, group, attachmentPt, silent, temp)) 292 if (AttachObjectInternal(sp, group, attachmentPt, silent, useAttachData, temp))
248 { 293 {
249 m_scene.EventManager.TriggerOnAttach(group.LocalId, group.FromItemID, sp.UUID); 294 m_scene.EventManager.TriggerOnAttach(group.LocalId, group.FromItemID, sp.UUID);
250 return true; 295 return true;
@@ -253,7 +298,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
253 return false; 298 return false;
254 } 299 }
255 300
256 private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp) 301 private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp)
257 { 302 {
258 lock (sp.AttachmentsSyncLock) 303 lock (sp.AttachmentsSyncLock)
259 { 304 {
@@ -308,6 +353,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
308 attachPos = Vector3.Zero; 353 attachPos = Vector3.Zero;
309 } 354 }
310 355
356 if (useAttachData)
357 {
358 group.RootPart.RotationOffset = group.RootPart.AttachRotation;
359 attachPos = group.RootPart.AttachOffset;
360 if (attachmentPt == 0)
361 {
362 attachmentPt = group.RootPart.AttachPoint;
363 if (attachmentPt == 0)
364 {
365 attachmentPt = (uint)AttachmentPoint.LeftHand;
366 attachPos = Vector3.Zero;
367 }
368 }
369 else if (group.RootPart.AttachPoint != attachmentPt)
370 {
371 attachPos = Vector3.Zero;
372 }
373 }
311 group.AttachmentPoint = attachmentPt; 374 group.AttachmentPoint = attachmentPt;
312 group.AbsolutePosition = attachPos; 375 group.AbsolutePosition = attachPos;
313 376
@@ -348,7 +411,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
348 } 411 }
349 } 412 }
350 413
351 public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) 414 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
415 {
416 return RezSingleAttachmentFromInventory(sp, itemID, AttachmentPt, null);
417 }
418
419 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt, XmlDocument doc)
352 { 420 {
353 if (!Enabled) 421 if (!Enabled)
354 return null; 422 return null;
@@ -387,7 +455,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
387 return null; 455 return null;
388 } 456 }
389 457
390 return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt); 458 return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, doc);
391 } 459 }
392 460
393 public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist) 461 public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist)
@@ -461,7 +529,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
461 so.AttachedAvatar = UUID.Zero; 529 so.AttachedAvatar = UUID.Zero;
462 rootPart.SetParentLocalId(0); 530 rootPart.SetParentLocalId(0);
463 so.ClearPartAttachmentData(); 531 so.ClearPartAttachmentData();
464 rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive); 532 rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive,false);
465 so.HasGroupChanged = true; 533 so.HasGroupChanged = true;
466 rootPart.Rezzed = DateTime.Now; 534 rootPart.Rezzed = DateTime.Now;
467 rootPart.RemFlag(PrimFlags.TemporaryOnRez); 535 rootPart.RemFlag(PrimFlags.TemporaryOnRez);
@@ -778,8 +846,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
778 UpdateDetachedObject(sp, so); 846 UpdateDetachedObject(sp, so);
779 } 847 }
780 848
781 private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( 849 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
782 IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt) 850 IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, XmlDocument doc)
783 { 851 {
784 if (m_invAccessModule == null) 852 if (m_invAccessModule == null)
785 return null; 853 return null;
@@ -817,7 +885,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
817 // This will throw if the attachment fails 885 // This will throw if the attachment fails
818 try 886 try
819 { 887 {
820 AttachObjectInternal(sp, objatt, attachmentPt, false, false); 888 AttachObjectInternal(sp, objatt, attachmentPt, false, false, false);
821 } 889 }
822 catch (Exception e) 890 catch (Exception e)
823 { 891 {
@@ -830,10 +898,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
830 m_scene.DeleteSceneObject(objatt, false); 898 m_scene.DeleteSceneObject(objatt, false);
831 return null; 899 return null;
832 } 900 }
833 901
834 if (tainted) 902 if (tainted)
835 objatt.HasGroupChanged = true; 903 objatt.HasGroupChanged = true;
836 904
905 if (doc != null)
906 {
907 objatt.LoadScriptState(doc);
908 objatt.ResetOwnerChangeFlag();
909 }
910
837 // Fire after attach, so we don't get messy perms dialogs 911 // Fire after attach, so we don't get messy perms dialogs
838 // 4 == AttachedRez 912 // 4 == AttachedRez
839 objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4); 913 objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4);
@@ -851,7 +925,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
851 itemID, sp.Name, attachmentPt); 925 itemID, sp.Name, attachmentPt);
852 } 926 }
853 } 927 }
854 928
855 return null; 929 return null;
856 } 930 }
857 931
@@ -974,7 +1048,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
974 AttachmentPt &= 0x7f; 1048 AttachmentPt &= 0x7f;
975 1049
976 // Calls attach with a Zero position 1050 // Calls attach with a Zero position
977 AttachObject(sp, part.ParentGroup, AttachmentPt, false, false); 1051 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, false))
1052 {
1053// m_log.Debug(
1054// "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
1055// + ", AttachmentPoint: " + AttachmentPt);
1056
1057 // Save avatar attachment information
1058 m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId);
1059 }
978 } 1060 }
979 catch (Exception e) 1061 catch (Exception e)
980 { 1062 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 0ee01c7..4e9d3f9 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -197,7 +197,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
197 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); 197 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);
198 198
199 m_numberOfAttachEventsFired = 0; 199 m_numberOfAttachEventsFired = 0;
200 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false); 200 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false);
201 201
202 // Check status on scene presence 202 // Check status on scene presence
203 Assert.That(sp.HasAttachments(), Is.True); 203 Assert.That(sp.HasAttachments(), Is.True);
@@ -254,7 +254,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
254 sp2.AbsolutePosition = new Vector3(0, 0, 0); 254 sp2.AbsolutePosition = new Vector3(0, 0, 0);
255 sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); 255 sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero);
256 256
257 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false); 257 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false);
258 258
259 Assert.That(sp.HasAttachments(), Is.False); 259 Assert.That(sp.HasAttachments(), Is.False);
260 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); 260 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
@@ -438,7 +438,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
438 scene.EventManager.OnChatFromWorld += OnChatFromWorld; 438 scene.EventManager.OnChatFromWorld += OnChatFromWorld;
439 439
440 SceneObjectGroup rezzedSo 440 SceneObjectGroup rezzedSo
441 = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); 441 = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest));
442 442
443 // Wait for chat to signal rezzed script has been started. 443 // Wait for chat to signal rezzed script has been started.
444 m_chatEvent.WaitOne(60000); 444 m_chatEvent.WaitOne(60000);
@@ -457,7 +457,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
457 Assert.That(scriptStateNodes.Count, Is.EqualTo(1)); 457 Assert.That(scriptStateNodes.Count, Is.EqualTo(1));
458 458
459 // Re-rez the attachment to check script running state 459 // Re-rez the attachment to check script running state
460 SceneObjectGroup reRezzedSo = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); 460 SceneObjectGroup reRezzedSo = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest));
461 461
462 // Wait for chat to signal rezzed script has been started. 462 // Wait for chat to signal rezzed script has been started.
463 m_chatEvent.WaitOne(60000); 463 m_chatEvent.WaitOne(60000);
@@ -663,4 +663,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
663 Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); 663 Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0));
664 } 664 }
665 } 665 }
666} \ No newline at end of file 666}
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index aaeeb24..7f083a9 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -592,12 +592,17 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
592 /// <param name="client"></param> 592 /// <param name="client"></param>
593 private void Client_OnRequestWearables(IClientAPI client) 593 private void Client_OnRequestWearables(IClientAPI client)
594 { 594 {
595 // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId); 595 Util.FireAndForget(delegate(object x)
596 ScenePresence sp = m_scene.GetScenePresence(client.AgentId); 596 {
597 if (sp != null) 597 Thread.Sleep(4000);
598 client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++); 598
599 else 599 // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId);
600 m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId); 600 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
601 if (sp != null)
602 client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++);
603 else
604 m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId);
605 });
601 } 606 }
602 607
603 /// <summary> 608 /// <summary>
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index ddf92c3..4407e40 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -49,7 +49,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
49 private int m_shoutdistance = 100; 49 private int m_shoutdistance = 100;
50 private int m_whisperdistance = 10; 50 private int m_whisperdistance = 10;
51 private List<Scene> m_scenes = new List<Scene>(); 51 private List<Scene> m_scenes = new List<Scene>();
52 52 private List<string> FreezeCache = new List<string>();
53 private string m_adminPrefix = "";
53 internal object m_syncy = new object(); 54 internal object m_syncy = new object();
54 55
55 internal IConfig m_config; 56 internal IConfig m_config;
@@ -76,6 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
76 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); 77 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance);
77 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); 78 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance);
78 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); 79 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance);
80 m_adminPrefix = config.Configs["Chat"].GetString("admin_prefix", "");
79 } 81 }
80 82
81 public virtual void AddRegion(Scene scene) 83 public virtual void AddRegion(Scene scene)
@@ -171,7 +173,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
171 return; 173 return;
172 } 174 }
173 175
174 DeliverChatToAvatars(ChatSourceType.Agent, c); 176 if (FreezeCache.Contains(c.Sender.AgentId.ToString()))
177 {
178 if (c.Type != ChatTypeEnum.StartTyping || c.Type != ChatTypeEnum.StopTyping)
179 c.Sender.SendAgentAlertMessage("You may not talk as you are frozen.", false);
180 }
181 else
182 {
183 DeliverChatToAvatars(ChatSourceType.Agent, c);
184 }
175 } 185 }
176 186
177 public virtual void OnChatFromWorld(Object sender, OSChatMessage c) 187 public virtual void OnChatFromWorld(Object sender, OSChatMessage c)
@@ -185,11 +195,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
185 protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) 195 protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
186 { 196 {
187 string fromName = c.From; 197 string fromName = c.From;
198 string fromNamePrefix = "";
188 UUID fromID = UUID.Zero; 199 UUID fromID = UUID.Zero;
189 UUID ownerID = UUID.Zero; 200 UUID ownerID = UUID.Zero;
190 UUID targetID = c.TargetUUID;
191 string message = c.Message; 201 string message = c.Message;
192 IScene scene = c.Scene; 202 IScene scene = c.Scene;
203 UUID destination = c.Destination;
193 Vector3 fromPos = c.Position; 204 Vector3 fromPos = c.Position;
194 Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, 205 Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize,
195 scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); 206 scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
@@ -209,6 +220,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
209 fromPos = avatar.AbsolutePosition; 220 fromPos = avatar.AbsolutePosition;
210 fromName = avatar.Name; 221 fromName = avatar.Name;
211 fromID = c.Sender.AgentId; 222 fromID = c.Sender.AgentId;
223 if (avatar.GodLevel >= 200)
224 {
225 fromNamePrefix = m_adminPrefix;
226 }
227 destination = UUID.Zero; // Avatars cant "SayTo"
212 ownerID = c.Sender.AgentId; 228 ownerID = c.Sender.AgentId;
213 229
214 break; 230 break;
@@ -227,40 +243,47 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
227 message = message.Substring(0, 1000); 243 message = message.Substring(0, 1000);
228 244
229// m_log.DebugFormat( 245// m_log.DebugFormat(
230// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}", 246// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}",
231// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID); 247// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType);
232 248
233 HashSet<UUID> receiverIDs = new HashSet<UUID>(); 249 HashSet<UUID> receiverIDs = new HashSet<UUID>();
234 250
235 foreach (Scene s in m_scenes) 251 foreach (Scene s in m_scenes)
236 { 252 {
237 if (targetID == UUID.Zero) 253 // This should use ForEachClient, but clients don't have a position.
238 { 254 // If camera is moved into client, then camera position can be used
239 // This should use ForEachClient, but clients don't have a position. 255 // MT: No, it can't, as chat is heard from the avatar position, not
240 // If camera is moved into client, then camera position can be used 256 // the camera position.
241 s.ForEachRootScenePresence( 257 s.ForEachRootScenePresence(
242 delegate(ScenePresence presence) 258 delegate(ScenePresence presence)
259 {
260 if (destination != UUID.Zero && presence.UUID != destination)
261 return;
262 ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
263 if (Presencecheck != null)
243 { 264 {
244 if (TrySendChatMessage( 265 // This will pass all chat from objects. Not
245 presence, fromPos, regionPos, fromID, ownerID, fromName, c.Type, message, sourceType, false)) 266 // perfect, but it will do. For now. Better
246 receiverIDs.Add(presence.UUID); 267 // than the prior behavior of muting all
268 // objects on a parcel with access restrictions
269 if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
270 {
271 if (destination != UUID.Zero)
272 {
273 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, ownerID, fromNamePrefix + fromName, c.Type, message, sourceType, true))
274 receiverIDs.Add(presence.UUID);
275 }
276 else
277 {
278 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, ownerID, fromNamePrefix + fromName, c.Type, message, sourceType, false))
279 receiverIDs.Add(presence.UUID);
280 }
281 }
247 } 282 }
248 );
249 }
250 else
251 {
252 // This is a send to a specific client eg from llRegionSayTo
253 // no need to check distance etc, jand send is as say
254 ScenePresence presence = s.GetScenePresence(targetID);
255 if (presence != null && !presence.IsChildAgent)
256 {
257 if (TrySendChatMessage(
258 presence, fromPos, regionPos, fromID, ownerID, fromName, ChatTypeEnum.Say, message, sourceType, true))
259 receiverIDs.Add(presence.UUID);
260 } 283 }
261 } 284 );
262 } 285 }
263 286
264 (scene as Scene).EventManager.TriggerOnChatToClients( 287 (scene as Scene).EventManager.TriggerOnChatToClients(
265 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); 288 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
266 } 289 }
@@ -300,28 +323,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
300 } 323 }
301 324
302 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); 325 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);
303
304 HashSet<UUID> receiverIDs = new HashSet<UUID>(); 326 HashSet<UUID> receiverIDs = new HashSet<UUID>();
305 327
306 ((Scene)c.Scene).ForEachRootClient( 328 if (c.Scene != null)
307 delegate(IClientAPI client) 329 {
308 { 330 ((Scene)c.Scene).ForEachRootClient
309 // don't forward SayOwner chat from objects to 331 (
310 // non-owner agents 332 delegate(IClientAPI client)
311 if ((c.Type == ChatTypeEnum.Owner) && 333 {
312 (null != c.SenderObject) && 334 // don't forward SayOwner chat from objects to
313 (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) 335 // non-owner agents
314 return; 336 if ((c.Type == ChatTypeEnum.Owner) &&
315 337 (null != c.SenderObject) &&
316 client.SendChatMessage( 338 (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
317 c.Message, (byte)cType, CenterOfRegion, fromName, fromID, fromID, 339 return;
318 (byte)sourceType, (byte)ChatAudibleLevel.Fully); 340
319 341 client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, fromID,
320 receiverIDs.Add(client.AgentId); 342 (byte)sourceType, (byte)ChatAudibleLevel.Fully);
321 }); 343 receiverIDs.Add(client.AgentId);
322 344 }
323 (c.Scene as Scene).EventManager.TriggerOnChatToClients( 345 );
324 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); 346 (c.Scene as Scene).EventManager.TriggerOnChatToClients(
347 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully);
348 }
325 } 349 }
326 350
327 /// <summary> 351 /// <summary>
@@ -346,7 +370,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
346 UUID fromAgentID, UUID ownerID, string fromName, ChatTypeEnum type, 370 UUID fromAgentID, UUID ownerID, string fromName, ChatTypeEnum type,
347 string message, ChatSourceType src, bool ignoreDistance) 371 string message, ChatSourceType src, bool ignoreDistance)
348 { 372 {
349 // don't send stuff to child agents 373 // don't send chat to child agents
350 if (presence.IsChildAgent) return false; 374 if (presence.IsChildAgent) return false;
351 375
352 Vector3 fromRegionPos = fromPos + regionPos; 376 Vector3 fromRegionPos = fromPos + regionPos;
@@ -355,15 +379,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
355 presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); 379 presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
356 380
357 int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); 381 int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);
358 382
359 if (!ignoreDistance) 383 if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
384 type == ChatTypeEnum.Say && dis > m_saydistance ||
385 type == ChatTypeEnum.Shout && dis > m_shoutdistance)
360 { 386 {
361 if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || 387 return false;
362 type == ChatTypeEnum.Say && dis > m_saydistance ||
363 type == ChatTypeEnum.Shout && dis > m_shoutdistance)
364 {
365 return false;
366 }
367 } 388 }
368 389
369 // TODO: should change so the message is sent through the avatar rather than direct to the ClientView 390 // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
@@ -373,5 +394,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
373 394
374 return true; 395 return true;
375 } 396 }
397
398 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
399 public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
400 {
401 System.Threading.Timer Timer;
402 if (flags == 0)
403 {
404 FreezeCache.Add(target.ToString());
405 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
406 Timer = new System.Threading.Timer(timeCB, target, 30000, 0);
407 Timers.Add(target, Timer);
408 }
409 else
410 {
411 FreezeCache.Remove(target.ToString());
412 Timers.TryGetValue(target, out Timer);
413 Timers.Remove(target);
414 Timer.Dispose();
415 }
416 }
417
418 private void OnEndParcelFrozen(object avatar)
419 {
420 UUID target = (UUID)avatar;
421 FreezeCache.Remove(target.ToString());
422 System.Threading.Timer Timer;
423 Timers.TryGetValue(target, out Timer);
424 Timers.Remove(target);
425 Timer.Dispose();
426 }
376 } 427 }
377} \ No newline at end of file 428}
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index d85a6e3..db5a788 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -260,4 +260,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
260 return result; 260 return result;
261 } 261 }
262 } 262 }
263} \ No newline at end of file 263}
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
index 2d3585a..e7a9f53 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
@@ -32,6 +32,24 @@ using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
34using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
35using System;
36using System.Reflection;
37using System.Collections;
38using System.Collections.Specialized;
39using System.Reflection;
40using System.IO;
41using System.Web;
42using System.Xml;
43using log4net;
44using Mono.Addins;
45using OpenMetaverse.Messages.Linden;
46using OpenMetaverse.StructuredData;
47using OpenSim.Framework.Capabilities;
48using OpenSim.Framework.Servers;
49using OpenSim.Framework.Servers.HttpServer;
50using Caps = OpenSim.Framework.Capabilities.Caps;
51using OSDArray = OpenMetaverse.StructuredData.OSDArray;
52using OSDMap = OpenMetaverse.StructuredData.OSDMap;
35 53
36using Mono.Addins; 54using Mono.Addins;
37 55
@@ -40,11 +58,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
40 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 58 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
41 public class GodsModule : INonSharedRegionModule, IGodsModule 59 public class GodsModule : INonSharedRegionModule, IGodsModule
42 { 60 {
61 private static readonly ILog m_log =
62 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
63
43 /// <summary>Special UUID for actions that apply to all agents</summary> 64 /// <summary>Special UUID for actions that apply to all agents</summary>
44 private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb"); 65 private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb");
45 66
46 protected Scene m_scene; 67 protected Scene m_scene;
47 protected IDialogModule m_dialogModule; 68 protected IDialogModule m_dialogModule;
69
70 protected Dictionary<UUID, string> m_capsDict =
71 new Dictionary<UUID, string>();
72
48 protected IDialogModule DialogModule 73 protected IDialogModule DialogModule
49 { 74 {
50 get 75 get
@@ -65,6 +90,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
65 m_scene = scene; 90 m_scene = scene;
66 m_scene.RegisterModuleInterface<IGodsModule>(this); 91 m_scene.RegisterModuleInterface<IGodsModule>(this);
67 m_scene.EventManager.OnNewClient += SubscribeToClientEvents; 92 m_scene.EventManager.OnNewClient += SubscribeToClientEvents;
93 m_scene.EventManager.OnRegisterCaps += OnRegisterCaps;
94 m_scene.EventManager.OnClientClosed += OnClientClosed;
95 scene.EventManager.OnIncomingInstantMessage +=
96 OnIncomingInstantMessage;
68 } 97 }
69 98
70 public void RemoveRegion(Scene scene) 99 public void RemoveRegion(Scene scene)
@@ -98,6 +127,54 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
98 client.OnRequestGodlikePowers -= RequestGodlikePowers; 127 client.OnRequestGodlikePowers -= RequestGodlikePowers;
99 } 128 }
100 129
130 private void OnClientClosed(UUID agentID, Scene scene)
131 {
132 m_capsDict.Remove(agentID);
133 }
134
135 private void OnRegisterCaps(UUID agentID, Caps caps)
136 {
137 string uri = "/CAPS/" + UUID.Random();
138 m_capsDict[agentID] = uri;
139
140 caps.RegisterHandler("UntrustedSimulatorMessage",
141 new RestStreamHandler("POST", uri,
142 HandleUntrustedSimulatorMessage));
143 }
144
145 private string HandleUntrustedSimulatorMessage(string request,
146 string path, string param, IOSHttpRequest httpRequest,
147 IOSHttpResponse httpResponse)
148 {
149 OSDMap osd = (OSDMap)OSDParser.DeserializeLLSDXml(request);
150
151 string message = osd["message"].AsString();
152
153 if (message == "GodKickUser")
154 {
155 OSDMap body = (OSDMap)osd["body"];
156 OSDArray userInfo = (OSDArray)body["UserInfo"];
157 OSDMap userData = (OSDMap)userInfo[0];
158
159 UUID agentID = userData["AgentID"].AsUUID();
160 UUID godID = userData["GodID"].AsUUID();
161 UUID godSessionID = userData["GodSessionID"].AsUUID();
162 uint kickFlags = userData["KickFlags"].AsUInteger();
163 string reason = userData["Reason"].AsString();
164
165 ScenePresence god = m_scene.GetScenePresence(godID);
166 if (god == null || god.ControllingClient.SessionId != godSessionID)
167 return String.Empty;
168
169 KickUser(godID, godSessionID, agentID, kickFlags, Util.StringToBytes1024(reason));
170 }
171 else
172 {
173 m_log.ErrorFormat("[GOD]: Unhandled UntrustedSimulatorMessage: {0}", message);
174 }
175 return String.Empty;
176 }
177
101 public void RequestGodlikePowers( 178 public void RequestGodlikePowers(
102 UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient) 179 UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient)
103 { 180 {
@@ -146,76 +223,86 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
146 /// <param name="reason">The message to send to the user after it's been turned into a field</param> 223 /// <param name="reason">The message to send to the user after it's been turned into a field</param>
147 public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason) 224 public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason)
148 { 225 {
149 UUID kickUserID = ALL_AGENTS; 226 if (!m_scene.Permissions.IsGod(godID))
150 227 return;
228
151 ScenePresence sp = m_scene.GetScenePresence(agentID); 229 ScenePresence sp = m_scene.GetScenePresence(agentID);
152 230
153 if (sp != null || agentID == kickUserID) 231 if (sp == null && agentID != ALL_AGENTS)
154 { 232 {
155 if (m_scene.Permissions.IsGod(godID)) 233 IMessageTransferModule transferModule =
234 m_scene.RequestModuleInterface<IMessageTransferModule>();
235 if (transferModule != null)
156 { 236 {
157 if (kickflags == 0) 237 m_log.DebugFormat("[GODS]: Sending nonlocal kill for agent {0}", agentID);
158 { 238 transferModule.SendInstantMessage(new GridInstantMessage(
159 if (agentID == kickUserID) 239 m_scene, godID, "God", agentID, (byte)250, false,
160 { 240 Utils.BytesToString(reason), UUID.Zero, true,
161 string reasonStr = Utils.BytesToString(reason); 241 new Vector3(), new byte[] {(byte)kickflags}, true),
162 242 delegate(bool success) {} );
163 m_scene.ForEachClient( 243 }
164 delegate(IClientAPI controller) 244 return;
165 { 245 }
166 if (controller.AgentId != godID)
167 controller.Kick(reasonStr);
168 }
169 );
170
171 // This is a bit crude. It seems the client will be null before it actually stops the thread
172 // The thread will kill itself eventually :/
173 // Is there another way to make sure *all* clients get this 'inter region' message?
174 m_scene.ForEachRootClient(
175 delegate(IClientAPI client)
176 {
177 if (client.AgentId != godID)
178 {
179 client.Close();
180 }
181 }
182 );
183 }
184 else
185 {
186 m_scene.SceneGraph.removeUserCount(!sp.IsChildAgent);
187 246
188 sp.ControllingClient.Kick(Utils.BytesToString(reason)); 247 switch (kickflags)
189 sp.ControllingClient.Close(); 248 {
190 } 249 case 0:
191 } 250 if (sp != null)
192 251 {
193 if (kickflags == 1) 252 KickPresence(sp, Utils.BytesToString(reason));
194 {
195 sp.AllowMovement = false;
196 if (DialogModule != null)
197 {
198 DialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
199 DialogModule.SendAlertToUser(godID, "User Frozen");
200 }
201 }
202
203 if (kickflags == 2)
204 {
205 sp.AllowMovement = true;
206 if (DialogModule != null)
207 {
208 DialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
209 DialogModule.SendAlertToUser(godID, "User Unfrozen");
210 }
211 }
212 } 253 }
213 else 254 else if (agentID == ALL_AGENTS)
214 { 255 {
215 if (DialogModule != null) 256 m_scene.ForEachRootScenePresence(
216 DialogModule.SendAlertToUser(godID, "Kick request denied"); 257 delegate(ScenePresence p)
258 {
259 if (p.UUID != godID && (!m_scene.Permissions.IsGod(p.UUID)))
260 KickPresence(p, Utils.BytesToString(reason));
261 }
262 );
263 }
264 break;
265 case 1:
266 if (sp != null)
267 {
268 sp.AllowMovement = false;
269 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
270 m_dialogModule.SendAlertToUser(godID, "User Frozen");
217 } 271 }
272 break;
273 case 2:
274 if (sp != null)
275 {
276 sp.AllowMovement = true;
277 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
278 m_dialogModule.SendAlertToUser(godID, "User Unfrozen");
279 }
280 break;
281 default:
282 break;
283 }
284 }
285
286 private void KickPresence(ScenePresence sp, string reason)
287 {
288 if (sp.IsChildAgent)
289 return;
290 sp.ControllingClient.Kick(reason);
291 sp.MakeChildAgent();
292 sp.ControllingClient.Close();
293 }
294
295 private void OnIncomingInstantMessage(GridInstantMessage msg)
296 {
297 if (msg.dialog == (uint)250) // Nonlocal kick
298 {
299 UUID agentID = new UUID(msg.toAgentID);
300 string reason = msg.message;
301 UUID godID = new UUID(msg.fromAgentID);
302 uint kickMode = (uint)msg.binaryBucket[0];
303
304 KickUser(godID, UUID.Zero, agentID, kickMode, Util.StringToBytes1024(reason));
218 } 305 }
219 } 306 }
220 } 307 }
221} \ No newline at end of file 308}
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
index 569ef26..a48b700 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
@@ -27,6 +27,7 @@
27using System; 27using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Reflection; 29using System.Reflection;
30using System.Timers;
30using log4net; 31using log4net;
31using Nini.Config; 32using Nini.Config;
32using OpenMetaverse; 33using OpenMetaverse;
@@ -42,6 +43,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
42 private static readonly ILog m_log = LogManager.GetLogger( 43 private static readonly ILog m_log = LogManager.GetLogger(
43 MethodBase.GetCurrentMethod().DeclaringType); 44 MethodBase.GetCurrentMethod().DeclaringType);
44 45
46 private Timer m_logTimer = new Timer(10000);
47 private List<GridInstantMessage> m_logData = new List<GridInstantMessage>();
48 private string m_restUrl;
49
45 /// <value> 50 /// <value>
46 /// Is this module enabled? 51 /// Is this module enabled?
47 /// </value> 52 /// </value>
@@ -61,9 +66,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
61 "InstantMessageModule", "InstantMessageModule") != 66 "InstantMessageModule", "InstantMessageModule") !=
62 "InstantMessageModule") 67 "InstantMessageModule")
63 return; 68 return;
69 m_restUrl = config.Configs["Messaging"].GetString("LogURL", String.Empty);
64 } 70 }
65 71
66 m_enabled = true; 72 m_enabled = true;
73 m_logTimer.AutoReset = false;
74 m_logTimer.Elapsed += LogTimerElapsed;
67 } 75 }
68 76
69 public void AddRegion(Scene scene) 77 public void AddRegion(Scene scene)
@@ -148,6 +156,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
148 { 156 {
149 byte dialog = im.dialog; 157 byte dialog = im.dialog;
150 158
159 if (client != null && dialog == (byte)InstantMessageDialog.MessageFromAgent)
160 LogInstantMesssage(im);
161
151 if (dialog != (byte)InstantMessageDialog.MessageFromAgent 162 if (dialog != (byte)InstantMessageDialog.MessageFromAgent
152 && dialog != (byte)InstantMessageDialog.StartTyping 163 && dialog != (byte)InstantMessageDialog.StartTyping
153 && dialog != (byte)InstantMessageDialog.StopTyping 164 && dialog != (byte)InstantMessageDialog.StopTyping
@@ -157,6 +168,32 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
157 return; 168 return;
158 } 169 }
159 170
171 //DateTime dt = DateTime.UtcNow;
172
173 // Ticks from UtcNow, but make it look like local. Evil, huh?
174 //dt = DateTime.SpecifyKind(dt, DateTimeKind.Local);
175
176 //try
177 //{
178 // // Convert that to the PST timezone
179 // TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
180 // dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo);
181 //}
182 //catch
183 //{
184 // //m_log.Info("[OFFLINE MESSAGING]: No PST timezone found on this machine. Saving with local timestamp.");
185 //}
186
187 //// And make it look local again to fool the unix time util
188 //dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);
189
190 // If client is null, this message comes from storage and IS offline
191 if (client != null)
192 im.offline = 0;
193
194 if (im.offline == 0)
195 im.timestamp = (uint)Util.UnixTimeSinceEpoch();
196
160 if (m_TransferModule != null) 197 if (m_TransferModule != null)
161 { 198 {
162 if (client != null) 199 if (client != null)
@@ -200,5 +237,35 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
200 // 237 //
201 OnInstantMessage(null, msg); 238 OnInstantMessage(null, msg);
202 } 239 }
240
241 private void LogInstantMesssage(GridInstantMessage im)
242 {
243 if (m_logData.Count < 20)
244 {
245 // Restart the log write timer
246 m_logTimer.Stop();
247 }
248 if (!m_logTimer.Enabled)
249 m_logTimer.Start();
250
251 lock (m_logData)
252 {
253 m_logData.Add(im);
254 }
255 }
256
257 private void LogTimerElapsed(object source, ElapsedEventArgs e)
258 {
259 lock (m_logData)
260 {
261 if (m_restUrl != String.Empty && m_logData.Count > 0)
262 {
263 bool success = SynchronousRestObjectRequester.MakeRequest<List<GridInstantMessage>, bool>("POST", m_restUrl + "/LogMessages/", m_logData);
264 if (!success)
265 m_log.ErrorFormat("[INSTANT MESSAGE]: Failed to save log data");
266 }
267 m_logData.Clear();
268 }
269 }
203 } 270 }
204} 271}
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 596174b..edd9707 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -48,6 +48,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 private bool m_Enabled = false; 50 private bool m_Enabled = false;
51 protected string m_MessageKey = String.Empty;
51 protected List<Scene> m_Scenes = new List<Scene>(); 52 protected List<Scene> m_Scenes = new List<Scene>();
52 protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>(); 53 protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>();
53 54
@@ -67,14 +68,17 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
67 public virtual void Initialise(IConfigSource config) 68 public virtual void Initialise(IConfigSource config)
68 { 69 {
69 IConfig cnf = config.Configs["Messaging"]; 70 IConfig cnf = config.Configs["Messaging"];
70 if (cnf != null && cnf.GetString( 71 if (cnf != null)
71 "MessageTransferModule", "MessageTransferModule") !=
72 "MessageTransferModule")
73 { 72 {
74 m_log.Debug("[MESSAGE TRANSFER]: Disabled by configuration"); 73 if (cnf.GetString("MessageTransferModule",
75 return; 74 "MessageTransferModule") != "MessageTransferModule")
76 } 75 {
76 return;
77 }
77 78
79 m_MessageKey = cnf.GetString("MessageKey", String.Empty);
80 }
81 m_log.Debug("[MESSAGE TRANSFER]: Module enabled");
78 m_Enabled = true; 82 m_Enabled = true;
79 } 83 }
80 84
@@ -133,6 +137,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
133 { 137 {
134 UUID toAgentID = new UUID(im.toAgentID); 138 UUID toAgentID = new UUID(im.toAgentID);
135 139
140 if (toAgentID == UUID.Zero)
141 return;
142
136 // Try root avatar only first 143 // Try root avatar only first
137 foreach (Scene scene in m_Scenes) 144 foreach (Scene scene in m_Scenes)
138 { 145 {
@@ -157,8 +164,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
157 // try child avatar second 164 // try child avatar second
158 foreach (Scene scene in m_Scenes) 165 foreach (Scene scene in m_Scenes)
159 { 166 {
160 m_log.DebugFormat( 167 //m_log.DebugFormat(
161 "[INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName); 168 // "[INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName);
162 169
163 ScenePresence sp = scene.GetScenePresence(toAgentID); 170 ScenePresence sp = scene.GetScenePresence(toAgentID);
164 if (sp != null) 171 if (sp != null)
@@ -247,6 +254,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
247 && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") 254 && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id")
248 && requestData.ContainsKey("binary_bucket")) 255 && requestData.ContainsKey("binary_bucket"))
249 { 256 {
257 if (m_MessageKey != String.Empty)
258 {
259 XmlRpcResponse error_resp = new XmlRpcResponse();
260 Hashtable error_respdata = new Hashtable();
261 error_respdata["success"] = "FALSE";
262 error_resp.Value = error_respdata;
263
264 if (!requestData.Contains("message_key"))
265 return error_resp;
266 if (m_MessageKey != (string)requestData["message_key"])
267 return error_resp;
268 }
269
250 // Do the easy way of validating the UUIDs 270 // Do the easy way of validating the UUIDs
251 UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); 271 UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID);
252 UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); 272 UUID.TryParse((string)requestData["to_agent_id"], out toAgentID);
@@ -423,24 +443,37 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
423 return resp; 443 return resp;
424 } 444 }
425 445
426 /// <summary> 446 private delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result);
427 /// delegate for sending a grid instant message asynchronously
428 /// </summary>
429 public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID);
430 447
431 protected virtual void GridInstantMessageCompleted(IAsyncResult iar) 448 private class GIM {
432 { 449 public GridInstantMessage im;
433 GridInstantMessageDelegate icon = 450 public MessageResultNotification result;
434 (GridInstantMessageDelegate)iar.AsyncState; 451 };
435 icon.EndInvoke(iar);
436 }
437 452
453 private Queue<GIM> pendingInstantMessages = new Queue<GIM>();
454 private int numInstantMessageThreads = 0;
438 455
439 protected virtual void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result) 456 private void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result)
440 { 457 {
441 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; 458 lock (pendingInstantMessages) {
459 if (numInstantMessageThreads >= 4) {
460 GIM gim = new GIM();
461 gim.im = im;
462 gim.result = result;
463 pendingInstantMessages.Enqueue(gim);
464 } else {
465 ++ numInstantMessageThreads;
466 //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: ++numInstantMessageThreads={0}", numInstantMessageThreads);
467 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsyncMain;
468 d.BeginInvoke(im, result, GridInstantMessageCompleted, d);
469 }
470 }
471 }
442 472
443 d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); 473 private void GridInstantMessageCompleted(IAsyncResult iar)
474 {
475 GridInstantMessageDelegate d = (GridInstantMessageDelegate)iar.AsyncState;
476 d.EndInvoke(iar);
444 } 477 }
445 478
446 /// <summary> 479 /// <summary>
@@ -455,8 +488,31 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
455 /// Pass in 0 the first time this method is called. It will be called recursively with the last 488 /// Pass in 0 the first time this method is called. It will be called recursively with the last
456 /// regionhandle tried 489 /// regionhandle tried
457 /// </param> 490 /// </param>
458 protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) 491 private void SendGridInstantMessageViaXMLRPCAsyncMain(GridInstantMessage im, MessageResultNotification result)
459 { 492 {
493 GIM gim;
494 do {
495 try {
496 SendGridInstantMessageViaXMLRPCAsync(im, result, UUID.Zero);
497 } catch (Exception e) {
498 m_log.Error("[SendGridInstantMessageViaXMLRPC]: exception " + e.Message);
499 }
500 lock (pendingInstantMessages) {
501 if (pendingInstantMessages.Count > 0) {
502 gim = pendingInstantMessages.Dequeue();
503 im = gim.im;
504 result = gim.result;
505 } else {
506 gim = null;
507 -- numInstantMessageThreads;
508 //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: --numInstantMessageThreads={0}", numInstantMessageThreads);
509 }
510 }
511 } while (gim != null);
512 }
513 private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID)
514 {
515
460 UUID toAgentID = new UUID(im.toAgentID); 516 UUID toAgentID = new UUID(im.toAgentID);
461 517
462 PresenceInfo upd = null; 518 PresenceInfo upd = null;
@@ -523,7 +579,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
523 579
524 if (upd != null) 580 if (upd != null)
525 { 581 {
526 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, 582 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(UUID.Zero,
527 upd.RegionID); 583 upd.RegionID);
528 if (reginfo != null) 584 if (reginfo != null)
529 { 585 {
@@ -672,6 +728,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
672 gim["position_z"] = msg.Position.Z.ToString(); 728 gim["position_z"] = msg.Position.Z.ToString();
673 gim["region_id"] = msg.RegionID.ToString(); 729 gim["region_id"] = msg.RegionID.ToString();
674 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None); 730 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None);
731 if (m_MessageKey != String.Empty)
732 gim["message_key"] = m_MessageKey;
675 return gim; 733 return gim;
676 } 734 }
677 735
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index de25048..b27b07d 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -171,7 +171,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
171 171
172 private void RetrieveInstantMessages(IClientAPI client) 172 private void RetrieveInstantMessages(IClientAPI client)
173 { 173 {
174 if (m_RestURL != "") 174 if (m_RestURL == String.Empty)
175 {
176 return;
177 }
178 else
175 { 179 {
176 m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId); 180 m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId);
177 181
@@ -179,22 +183,25 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
179 = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>( 183 = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>(
180 "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); 184 "POST", m_RestURL + "/RetrieveMessages/", client.AgentId);
181 185
182 if (msglist == null) 186 if (msglist != null)
183 m_log.WarnFormat("[OFFLINE MESSAGING]: WARNING null message list.");
184
185 foreach (GridInstantMessage im in msglist)
186 { 187 {
187 // client.SendInstantMessage(im); 188 foreach (GridInstantMessage im in msglist)
188 189 {
189 // Send through scene event manager so all modules get a chance 190 // client.SendInstantMessage(im);
190 // to look at this message before it gets delivered. 191
191 // 192 // Send through scene event manager so all modules get a chance
192 // Needed for proper state management for stored group 193 // to look at this message before it gets delivered.
193 // invitations 194 //
194 // 195 // Needed for proper state management for stored group
195 Scene s = FindScene(client.AgentId); 196 // invitations
196 if (s != null) 197 //
197 s.EventManager.TriggerIncomingInstantMessage(im); 198
199 im.offline = 1;
200
201 Scene s = FindScene(client.AgentId);
202 if (s != null)
203 s.EventManager.TriggerIncomingInstantMessage(im);
204 }
198 } 205 }
199 } 206 }
200 } 207 }
@@ -205,24 +212,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
205 im.dialog != (byte)InstantMessageDialog.MessageFromAgent && 212 im.dialog != (byte)InstantMessageDialog.MessageFromAgent &&
206 im.dialog != (byte)InstantMessageDialog.GroupNotice && 213 im.dialog != (byte)InstantMessageDialog.GroupNotice &&
207 im.dialog != (byte)InstantMessageDialog.GroupInvitation && 214 im.dialog != (byte)InstantMessageDialog.GroupInvitation &&
208 im.dialog != (byte)InstantMessageDialog.InventoryOffered) 215 im.dialog != (byte)InstantMessageDialog.InventoryOffered &&
216 im.dialog != (byte)InstantMessageDialog.TaskInventoryOffered)
209 { 217 {
210 return; 218 return;
211 } 219 }
212 220
213 if (!m_ForwardOfflineGroupMessages)
214 {
215 if (im.dialog == (byte)InstantMessageDialog.GroupNotice ||
216 im.dialog != (byte)InstantMessageDialog.GroupInvitation)
217 return;
218 }
219
220 Scene scene = FindScene(new UUID(im.fromAgentID)); 221 Scene scene = FindScene(new UUID(im.fromAgentID));
221 if (scene == null) 222 if (scene == null)
222 scene = m_SceneList[0]; 223 scene = m_SceneList[0];
223 224
224 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( 225 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>(
225 "POST", m_RestURL+"/SaveMessage/", im); 226 "POST", m_RestURL+"/SaveMessage/?scope=" +
227 scene.RegionInfo.ScopeID.ToString(), im);
226 228
227 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) 229 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
228 { 230 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index ee10d04..0833154 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -635,4 +635,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
635 m_assetsLoaded = true; 635 m_assetsLoaded = true;
636 } 636 }
637 } 637 }
638} \ No newline at end of file 638}
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index f5a146d..50c51d3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -519,6 +519,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
519 return null; 519 return null;
520 } 520 }
521 521
522 return account;
523 /*
522 try 524 try
523 { 525 {
524 string encpass = Util.Md5Hash(pass); 526 string encpass = Util.Md5Hash(pass);
@@ -539,6 +541,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
539 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e.Message); 541 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e.Message);
540 return null; 542 return null;
541 } 543 }
544 */
542 } 545 }
543 546
544 /// <summary> 547 /// <summary>
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index 24208df..5d20524 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -175,8 +175,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
175 if (im.binaryBucket.Length < 17) // Invalid 175 if (im.binaryBucket.Length < 17) // Invalid
176 return; 176 return;
177 177
178 UUID receipientID = new UUID(im.toAgentID); 178 UUID recipientID = new UUID(im.toAgentID);
179 ScenePresence user = scene.GetScenePresence(receipientID); 179 ScenePresence user = scene.GetScenePresence(recipientID);
180 UUID copyID; 180 UUID copyID;
181 181
182 // First byte is the asset type 182 // First byte is the asset type
@@ -191,7 +191,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
191 folderID, new UUID(im.toAgentID)); 191 folderID, new UUID(im.toAgentID));
192 192
193 InventoryFolderBase folderCopy 193 InventoryFolderBase folderCopy
194 = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero); 194 = scene.GiveInventoryFolder(recipientID, client.AgentId, folderID, UUID.Zero);
195 195
196 if (folderCopy == null) 196 if (folderCopy == null)
197 { 197 {
@@ -244,6 +244,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
244 im.imSessionID = itemID.Guid; 244 im.imSessionID = itemID.Guid;
245 } 245 }
246 246
247 im.offline = 0;
248
247 // Send the IM to the recipient. The item is already 249 // Send the IM to the recipient. The item is already
248 // in their inventory, so it will not be lost if 250 // in their inventory, so it will not be lost if
249 // they are offline. 251 // they are offline.
@@ -263,8 +265,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
263 }); 265 });
264 } 266 }
265 } 267 }
266 else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) 268 else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted ||
269 im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted)
267 { 270 {
271 UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip
272 IInventoryService invService = scene.InventoryService;
273
274 // Special case: folder redirect.
275 // RLV uses this
276 if (im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted)
277 {
278 InventoryFolderBase folder = new InventoryFolderBase(inventoryID, client.AgentId);
279 folder = invService.GetFolder(folder);
280
281 if (folder != null)
282 {
283 if (im.binaryBucket.Length >= 16)
284 {
285 UUID destFolderID = new UUID(im.binaryBucket, 0);
286 if (destFolderID != UUID.Zero)
287 {
288 InventoryFolderBase destFolder = new InventoryFolderBase(destFolderID, client.AgentId);
289 destFolder = invService.GetFolder(destFolder);
290 if (destFolder != null)
291 {
292 if (folder.ParentID != destFolder.ID)
293 {
294 folder.ParentID = destFolder.ID;
295 invService.MoveFolder(folder);
296 client.SendBulkUpdateInventory(folder);
297 }
298 }
299 }
300 }
301 }
302 }
303
268 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); 304 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
269 305
270 if (user != null) // Local 306 if (user != null) // Local
@@ -274,27 +310,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
274 else 310 else
275 { 311 {
276 if (m_TransferModule != null) 312 if (m_TransferModule != null)
277 m_TransferModule.SendInstantMessage(im, delegate(bool success) { 313 m_TransferModule.SendInstantMessage(im, delegate(bool success) {});
278
279 // justincc - FIXME: Comment out for now. This code was added in commit db91044 Mon Aug 22 2011
280 // and is apparently supposed to fix bulk inventory updates after accepting items. But
281 // instead it appears to cause two copies of an accepted folder for the receiving user in
282 // at least some cases. Folder/item update is already done when the offer is made (see code above)
283
284// // Send BulkUpdateInventory
285// IInventoryService invService = scene.InventoryService;
286// UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip
287//
288// InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId);
289// folder = invService.GetFolder(folder);
290//
291// ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID));
292//
293// // If the user has left the scene by the time the message comes back then we can't send
294// // them the update.
295// if (fromUser != null)
296// fromUser.ControllingClient.SendBulkUpdateInventory(folder);
297 });
298 } 314 }
299 } 315 }
300 316
@@ -406,6 +422,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
406 previousParentFolderID = folder.ParentID; 422 previousParentFolderID = folder.ParentID;
407 folder.ParentID = trashFolder.ID; 423 folder.ParentID = trashFolder.ID;
408 invService.MoveFolder(folder); 424 invService.MoveFolder(folder);
425 client.SendBulkUpdateInventory(folder);
409 } 426 }
410 } 427 }
411 428
@@ -519,22 +536,113 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
519 /// 536 ///
520 /// </summary> 537 /// </summary>
521 /// <param name="msg"></param> 538 /// <param name="msg"></param>
522 private void OnGridInstantMessage(GridInstantMessage msg) 539 private void OnGridInstantMessage(GridInstantMessage im)
523 { 540 {
524 // Check if this is ours to handle 541 // Check if this is ours to handle
525 // 542 //
526 Scene scene = FindClientScene(new UUID(msg.toAgentID)); 543 Scene scene = FindClientScene(new UUID(im.toAgentID));
527 544
528 if (scene == null) 545 if (scene == null)
529 return; 546 return;
530 547
531 // Find agent to deliver to 548 // Find agent to deliver to
532 // 549 //
533 ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID)); 550 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
551 if (user == null)
552 return;
553
554 // This requires a little bit of processing because we have to make the
555 // new item visible in the recipient's inventory here
556 //
557 if (im.dialog == (byte) InstantMessageDialog.InventoryOffered)
558 {
559 if (im.binaryBucket.Length < 17) // Invalid
560 return;
561
562 UUID recipientID = new UUID(im.toAgentID);
563
564 // First byte is the asset type
565 AssetType assetType = (AssetType)im.binaryBucket[0];
566
567 if (AssetType.Folder == assetType)
568 {
569 UUID folderID = new UUID(im.binaryBucket, 1);
534 570
535 // Just forward to local handling 571 InventoryFolderBase given =
536 OnInstantMessage(user.ControllingClient, msg); 572 new InventoryFolderBase(folderID, recipientID);
573 InventoryFolderBase folder =
574 scene.InventoryService.GetFolder(given);
537 575
576 if (folder != null)
577 user.ControllingClient.SendBulkUpdateInventory(folder);
578 }
579 else
580 {
581 UUID itemID = new UUID(im.binaryBucket, 1);
582
583 InventoryItemBase given =
584 new InventoryItemBase(itemID, recipientID);
585 InventoryItemBase item =
586 scene.InventoryService.GetItem(given);
587
588 if (item != null)
589 {
590 user.ControllingClient.SendBulkUpdateInventory(item);
591 }
592 }
593 user.ControllingClient.SendInstantMessage(im);
594 }
595 if (im.dialog == (byte) InstantMessageDialog.TaskInventoryOffered)
596 {
597 if (im.binaryBucket.Length < 1) // Invalid
598 return;
599
600 UUID recipientID = new UUID(im.toAgentID);
601
602 // Bucket is the asset type
603 AssetType assetType = (AssetType)im.binaryBucket[0];
604
605 if (AssetType.Folder == assetType)
606 {
607 UUID folderID = new UUID(im.imSessionID);
608
609 InventoryFolderBase given =
610 new InventoryFolderBase(folderID, recipientID);
611 InventoryFolderBase folder =
612 scene.InventoryService.GetFolder(given);
613
614 if (folder != null)
615 user.ControllingClient.SendBulkUpdateInventory(folder);
616 }
617 else
618 {
619 UUID itemID = new UUID(im.imSessionID);
620
621 InventoryItemBase given =
622 new InventoryItemBase(itemID, recipientID);
623 InventoryItemBase item =
624 scene.InventoryService.GetItem(given);
625
626 if (item != null)
627 {
628 user.ControllingClient.SendBulkUpdateInventory(item);
629 }
630 }
631
632 // Fix up binary bucket since this may be 17 chars long here
633 Byte[] bucket = new Byte[1];
634 bucket[0] = im.binaryBucket[0];
635 im.binaryBucket = bucket;
636
637 user.ControllingClient.SendInstantMessage(im);
638 }
639 else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted ||
640 im.dialog == (byte) InstantMessageDialog.InventoryDeclined ||
641 im.dialog == (byte) InstantMessageDialog.TaskInventoryDeclined ||
642 im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted)
643 {
644 user.ControllingClient.SendInstantMessage(im);
645 }
538 } 646 }
539 } 647 }
540} 648}
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
index 6ce9556..1949459 100644
--- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
@@ -161,16 +161,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
161 scene.RegionInfo.RegionHandle, 161 scene.RegionInfo.RegionHandle,
162 (uint)presence.AbsolutePosition.X, 162 (uint)presence.AbsolutePosition.X,
163 (uint)presence.AbsolutePosition.Y, 163 (uint)presence.AbsolutePosition.Y,
164 (uint)Math.Ceiling(presence.AbsolutePosition.Z)); 164 (uint)presence.AbsolutePosition.Z + 2);
165 165
166 m_log.DebugFormat("TP invite with message {0}", message); 166 m_log.DebugFormat("[LURE]: TP invite with message {0}", message);
167
168 GridInstantMessage m;
169
170 if (scene.Permissions.IsAdministrator(client.AgentId) && presence.GodLevel >= 200 && (!scene.Permissions.IsAdministrator(targetid)))
171 {
172 m = new GridInstantMessage(scene, client.AgentId,
173 client.FirstName+" "+client.LastName, targetid,
174 (byte)InstantMessageDialog.GodLikeRequestTeleport, false,
175 message, dest, false, presence.AbsolutePosition,
176 new Byte[0], true);
177 }
178 else
179 {
180 m = new GridInstantMessage(scene, client.AgentId,
181 client.FirstName+" "+client.LastName, targetid,
182 (byte)InstantMessageDialog.RequestTeleport, false,
183 message, dest, false, presence.AbsolutePosition,
184 new Byte[0], true);
185 }
167 186
168 GridInstantMessage m = new GridInstantMessage(scene, client.AgentId,
169 client.FirstName+" "+client.LastName, targetid,
170 (byte)InstantMessageDialog.RequestTeleport, false,
171 message, dest, false, presence.AbsolutePosition,
172 new Byte[0], true);
173
174 if (m_TransferModule != null) 187 if (m_TransferModule != null)
175 { 188 {
176 m_TransferModule.SendInstantMessage(m, 189 m_TransferModule.SendInstantMessage(m,
@@ -205,7 +218,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
205 { 218 {
206 // Forward remote teleport requests 219 // Forward remote teleport requests
207 // 220 //
208 if (msg.dialog != 22) 221 if (msg.dialog != (byte)InstantMessageDialog.RequestTeleport &&
222 msg.dialog != (byte)InstantMessageDialog.GodLikeRequestTeleport)
209 return; 223 return;
210 224
211 if (m_TransferModule != null) 225 if (m_TransferModule != null)