aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar
diff options
context:
space:
mode:
authorUbitUmarov2015-09-01 14:54:35 +0100
committerUbitUmarov2015-09-01 14:54:35 +0100
commit371c9dd2af01a2e7422ec901ee1f80757284a78c (patch)
tree058d2a513cacb12efcce0c0df0ae14ad135dbfe2 /OpenSim/Region/CoreModules/Avatar
parentremove lixo (diff)
parentdont change camera on crossings (diff)
downloadopensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.zip
opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.gz
opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.bz2
opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.xz
bad merge?
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs178
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs14
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs389
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs11
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs216
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs5
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs260
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs67
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs113
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs112
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs175
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs30
-rw-r--r--OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs187
16 files changed, 1238 insertions, 532 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 2f67c4e..b24dc0c 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -41,6 +41,7 @@ using OpenSim.Region.Framework;
41using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Serialization; 43using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Services.Interfaces;
44 45
45namespace OpenSim.Region.CoreModules.Avatar.Attachments 46namespace OpenSim.Region.CoreModules.Avatar.Attachments
46{ 47{
@@ -303,6 +304,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
303 if (DebugLevel > 0) 304 if (DebugLevel > 0)
304 m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0} from simulator-side", sp.Name); 305 m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0} from simulator-side", sp.Name);
305 306
307 XmlDocument doc = new XmlDocument();
308 string stateData = String.Empty;
309
310 IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>();
311 if (attServ != null)
312 {
313 m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service");
314 stateData = attServ.Get(sp.UUID.ToString());
315 if (stateData != String.Empty)
316 {
317 try
318 {
319 doc.LoadXml(stateData);
320 }
321 catch { }
322 }
323 }
324
325 Dictionary<UUID, string> itemData = new Dictionary<UUID, string>();
326
327 XmlNodeList nodes = doc.GetElementsByTagName("Attachment");
328 if (nodes.Count > 0)
329 {
330 foreach (XmlNode n in nodes)
331 {
332 XmlElement elem = (XmlElement)n;
333 string itemID = elem.GetAttribute("ItemID");
334 string xml = elem.InnerXml;
335
336 itemData[new UUID(itemID)] = xml;
337 }
338 }
339
340
306 List<AvatarAttachment> attachments = sp.Appearance.GetAttachments(); 341 List<AvatarAttachment> attachments = sp.Appearance.GetAttachments();
307 342
308 // Let's get all items at once, so they get cached 343 // Let's get all items at once, so they get cached
@@ -330,10 +365,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
330 365
331 try 366 try
332 { 367 {
368 string xmlData;
369 XmlDocument d = null;
370 UUID asset;
371 if (itemData.TryGetValue(attach.ItemID, out xmlData))
372 {
373 d = new XmlDocument();
374 d.LoadXml(xmlData);
375 m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", attach.ItemID);
376 }
377
333 // If we're an NPC then skip all the item checks and manipulations since we don't have an 378 // If we're an NPC then skip all the item checks and manipulations since we don't have an
334 // inventory right now. 379 // inventory right now.
335 RezSingleAttachmentFromInventoryInternal( 380 RezSingleAttachmentFromInventoryInternal(
336 sp, sp.PresenceType == PresenceType.Npc ? UUID.Zero : attach.ItemID, attach.AssetID, attachmentPt, true); 381 sp, sp.PresenceType == PresenceType.Npc ? UUID.Zero : attach.ItemID, attach.AssetID, attachmentPt, true, d);
337 } 382 }
338 catch (Exception e) 383 catch (Exception e)
339 { 384 {
@@ -361,6 +406,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
361 406
362 Dictionary<SceneObjectGroup, string> scriptStates = new Dictionary<SceneObjectGroup, string>(); 407 Dictionary<SceneObjectGroup, string> scriptStates = new Dictionary<SceneObjectGroup, string>();
363 408
409<<<<<<< HEAD
364 foreach (SceneObjectGroup so in attachments) 410 foreach (SceneObjectGroup so in attachments)
365 { 411 {
366 // Scripts MUST be snapshotted before the object is 412 // Scripts MUST be snapshotted before the object is
@@ -376,12 +422,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
376 } 422 }
377 423
378 lock (sp.AttachmentsSyncLock) 424 lock (sp.AttachmentsSyncLock)
425=======
426 if (sp.PresenceType != PresenceType.Npc)
427>>>>>>> avn/ubitvar
379 { 428 {
380 foreach (SceneObjectGroup so in attachments) 429 foreach (SceneObjectGroup so in attachments)
381 UpdateDetachedObject(sp, so, scriptStates[so]); 430 {
382 431 // Scripts MUST be snapshotted before the object is
383 sp.ClearAttachments(); 432 // removed from the scene because doing otherwise will
433 // clobber the run flag
434 // This must be done outside the sp.AttachmentSyncLock so that there is no risk of a deadlock from
435 // scripts performing attachment operations at the same time. Getting object states stops the scripts.
436 scriptStates[so] = PrepareScriptInstanceForSave(so, false);
437 }
438
439 lock (sp.AttachmentsSyncLock)
440 {
441 foreach (SceneObjectGroup so in attachments)
442 UpdateDetachedObject(sp, so, scriptStates[so]);
443 sp.ClearAttachments();
444 }
384 } 445 }
446 else
447 {
448 lock (sp.AttachmentsSyncLock)
449 {
450 foreach (SceneObjectGroup so in attachments)
451 UpdateDetachedObject(sp, so, String.Empty);
452 sp.ClearAttachments();
453 }
454 }
385 } 455 }
386 456
387 public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent) 457 public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent)
@@ -402,12 +472,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
402 sp.ClearAttachments(); 472 sp.ClearAttachments();
403 } 473 }
404 474
405 public bool AttachObject( 475 public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool addToInventory, bool append)
406 IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool addToInventory, bool append)
407 { 476 {
408 if (!Enabled) 477 if (!Enabled)
409 return false; 478 return false;
410 479
480<<<<<<< HEAD
411 group.DetachFromBackup(); 481 group.DetachFromBackup();
412 482
413 bool success = AttachObjectInternal(sp, group, attachmentPt, silent, addToInventory, false, append); 483 bool success = AttachObjectInternal(sp, group, attachmentPt, silent, addToInventory, false, append);
@@ -416,6 +486,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
416 group.AttachToBackup(); 486 group.AttachToBackup();
417 487
418 return success; 488 return success;
489=======
490 return AttachObjectInternal(sp, group, attachmentPt, silent, useAttachData, addToInventory, false, append);
491>>>>>>> avn/ubitvar
419 } 492 }
420 493
421 /// <summary> 494 /// <summary>
@@ -428,10 +501,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
428 /// <param name='silent'></param> 501 /// <param name='silent'></param>
429 /// <param name='addToInventory'>If true then add object to user inventory.</param> 502 /// <param name='addToInventory'>If true then add object to user inventory.</param>
430 /// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param> 503 /// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param>
431 /// <param name='append'>Append to attachment point rather than replace.</param> 504 private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool addToInventory, bool resumeScripts, bool append)
432 private bool AttachObjectInternal(
433 IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool addToInventory, bool resumeScripts, bool append)
434 { 505 {
506// m_log.DebugFormat(
507// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
508// group.Name, group.LocalId, sp.Name, attachmentPt, silent);
509
510 if (sp.GetAttachments().Contains(group))
511 {
512// m_log.WarnFormat(
513// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
514// group.Name, group.LocalId, sp.Name, AttachmentPt);
515
516 return false;
517 }
518
435 if (group.GetSittingAvatarsCount() != 0) 519 if (group.GetSittingAvatarsCount() != 0)
436 { 520 {
437 if (DebugLevel > 0) 521 if (DebugLevel > 0)
@@ -443,6 +527,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
443 } 527 }
444 528
445 Vector3 attachPos = group.AbsolutePosition; 529 Vector3 attachPos = group.AbsolutePosition;
530
531 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
532 // be removed when that functionality is implemented in opensim
533 attachmentPt &= 0x7f;
534
446 // If the attachment point isn't the same as the one previously used 535 // If the attachment point isn't the same as the one previously used
447 // set it's offset position = 0 so that it appears on the attachment point 536 // set it's offset position = 0 so that it appears on the attachment point
448 // and not in a weird location somewhere unknown. 537 // and not in a weird location somewhere unknown.
@@ -481,9 +570,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
481 attachPos = Vector3.Zero; 570 attachPos = Vector3.Zero;
482 } 571 }
483 572
484 group.AttachmentPoint = attachmentPt;
485 group.AbsolutePosition = attachPos;
486
487 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); 573 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
488 574
489 if (attachments.Contains(group)) 575 if (attachments.Contains(group))
@@ -516,6 +602,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
516 602
517 lock (sp.AttachmentsSyncLock) 603 lock (sp.AttachmentsSyncLock)
518 { 604 {
605 group.AttachmentPoint = attachmentPt;
606 group.AbsolutePosition = attachPos;
607
519 if (addToInventory && sp.PresenceType != PresenceType.Npc) 608 if (addToInventory && sp.PresenceType != PresenceType.Npc)
520 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append); 609 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append);
521 610
@@ -546,7 +635,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
546 ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group, append); 635 ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group, append);
547 } 636 }
548 637
549 public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) 638 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
639 {
640 return RezSingleAttachmentFromInventory(sp, itemID, AttachmentPt, null);
641 }
642
643 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt, XmlDocument doc)
550 { 644 {
551 if (!Enabled) 645 if (!Enabled)
552 return null; 646 return null;
@@ -584,7 +678,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
584 bool append = (AttachmentPt & 0x80) != 0; 678 bool append = (AttachmentPt & 0x80) != 0;
585 AttachmentPt &= 0x7f; 679 AttachmentPt &= 0x7f;
586 680
587 return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, append); 681 return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, append, doc);
588 } 682 }
589 683
590 public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist) 684 public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist)
@@ -649,26 +743,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
649 if (changed && m_scene.AvatarFactory != null) 743 if (changed && m_scene.AvatarFactory != null)
650 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); 744 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
651 745
746 so.RootPart.Shape.LastAttachPoint = (byte)so.AttachmentPoint;
747
652 sp.RemoveAttachment(so); 748 sp.RemoveAttachment(so);
653 so.FromItemID = UUID.Zero; 749 so.FromItemID = UUID.Zero;
654 750
751 so.AttachedAvatar = UUID.Zero;
752 so.ClearPartAttachmentData();
753
655 SceneObjectPart rootPart = so.RootPart; 754 SceneObjectPart rootPart = so.RootPart;
755
756 rootPart.SetParentLocalId(0);
656 so.AbsolutePosition = absolutePos; 757 so.AbsolutePosition = absolutePos;
657 if (absoluteRot != Quaternion.Identity) 758 if (absoluteRot != Quaternion.Identity)
658 { 759 {
659 so.UpdateGroupRotationR(absoluteRot); 760 so.UpdateGroupRotationR(absoluteRot);
660 } 761 }
661 so.AttachedAvatar = UUID.Zero; 762
662 rootPart.SetParentLocalId(0); 763 rootPart.RemFlag(PrimFlags.TemporaryOnRez);
663 so.ClearPartAttachmentData(); 764
664 rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive); 765 // not physical, not temporary, phaton, not volume detector
766// so.UpdatePrimFlags(rootPart.LocalId,false,false,true,rootPart.VolumeDetectActive);
767
768 // restore full physical state instead
769 so.ApplyPhysics();
770
665 so.HasGroupChanged = true; 771 so.HasGroupChanged = true;
666 so.RootPart.Shape.LastAttachPoint = (byte)so.AttachmentPoint;
667 rootPart.Rezzed = DateTime.Now; 772 rootPart.Rezzed = DateTime.Now;
668 rootPart.RemFlag(PrimFlags.TemporaryOnRez);
669 so.AttachToBackup(); 773 so.AttachToBackup();
670 m_scene.EventManager.TriggerParcelPrimCountTainted(); 774 m_scene.EventManager.TriggerParcelPrimCountTainted();
671 rootPart.ScheduleFullUpdate(); 775
672 rootPart.ClearUndoState(); 776 rootPart.ClearUndoState();
673 777
674 List<UUID> uuids = new List<UUID>(); 778 List<UUID> uuids = new List<UUID>();
@@ -678,6 +782,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
678 } 782 }
679 783
680 m_scene.EventManager.TriggerOnAttach(so.LocalId, so.UUID, UUID.Zero); 784 m_scene.EventManager.TriggerOnAttach(so.LocalId, so.UUID, UUID.Zero);
785
786 // Attach (NULL) stops scripts. We don't want that. Resume them.
787 so.ResumeScripts();
788 so.ScheduleGroupForTerseUpdate();
789 so.RootPart.ScheduleFullUpdate();
681 } 790 }
682 791
683 public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so) 792 public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so)
@@ -848,8 +957,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
848 957
849 so.AttachedAvatar = sp.UUID; 958 so.AttachedAvatar = sp.UUID;
850 959
851 if (so.RootPart.PhysActor != null) 960 foreach (SceneObjectPart part in so.Parts)
852 so.RootPart.RemoveFromPhysics(); 961 {
962// if (part.KeyframeMotion != null)
963// part.KeyframeMotion.Suspend();
964
965 if (part.PhysActor != null)
966 {
967 part.RemoveFromPhysics();
968 }
969 }
853 970
854 so.AbsolutePosition = attachOffset; 971 so.AbsolutePosition = attachOffset;
855 so.RootPart.AttachedPos = attachOffset; 972 so.RootPart.AttachedPos = attachOffset;
@@ -971,6 +1088,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
971 // Remove the object from the scene so no more updates 1088 // Remove the object from the scene so no more updates
972 // are sent. Doing this before the below changes will ensure 1089 // are sent. Doing this before the below changes will ensure
973 // updates can't cause "HUD artefacts" 1090 // updates can't cause "HUD artefacts"
1091
974 m_scene.DeleteSceneObject(so, false, false); 1092 m_scene.DeleteSceneObject(so, false, false);
975 1093
976 // Prepare sog for storage 1094 // Prepare sog for storage
@@ -992,7 +1110,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
992 } 1110 }
993 1111
994 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( 1112 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
995 IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, bool append) 1113 IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, bool append, XmlDocument doc)
996 { 1114 {
997 if (m_invAccessModule == null) 1115 if (m_invAccessModule == null)
998 return null; 1116 return null;
@@ -1043,7 +1161,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1043 // This will throw if the attachment fails 1161 // This will throw if the attachment fails
1044 try 1162 try
1045 { 1163 {
1046 AttachObjectInternal(sp, objatt, attachmentPt, false, true, true, append); 1164 if (doc != null)
1165 {
1166 objatt.LoadScriptState(doc);
1167 objatt.ResetOwnerChangeFlag();
1168 }
1169
1170 AttachObjectInternal(sp, objatt, attachmentPt, false, true, true, true, append);
1047 } 1171 }
1048 catch (Exception e) 1172 catch (Exception e)
1049 { 1173 {
@@ -1197,7 +1321,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1197 AttachmentPt &= 0x7f; 1321 AttachmentPt &= 0x7f;
1198 1322
1199 // Calls attach with a Zero position 1323 // Calls attach with a Zero position
1200 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, append)) 1324 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, false, true, append))
1201 { 1325 {
1202 if (DebugLevel > 0) 1326 if (DebugLevel > 0)
1203 m_log.Debug( 1327 m_log.Debug(
@@ -1205,7 +1329,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1205 + ", AttachmentPoint: " + AttachmentPt); 1329 + ", AttachmentPoint: " + AttachmentPt);
1206 1330
1207 // Save avatar attachment information 1331 // Save avatar attachment information
1208 m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId); 1332 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
1209 } 1333 }
1210 } 1334 }
1211 catch (Exception e) 1335 catch (Exception e)
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index f1b002b..b632774 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -201,7 +201,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
201 Assert.That(so.Backup, Is.True); 201 Assert.That(so.Backup, Is.True);
202 202
203 m_numberOfAttachEventsFired = 0; 203 m_numberOfAttachEventsFired = 0;
204 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false); 204 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false, false);
205 205
206 // Check status on scene presence 206 // Check status on scene presence
207 Assert.That(sp.HasAttachments(), Is.True); 207 Assert.That(sp.HasAttachments(), Is.True);
@@ -249,7 +249,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
249 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID); 249 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID);
250 250
251 m_numberOfAttachEventsFired = 0; 251 m_numberOfAttachEventsFired = 0;
252 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, true, false); 252 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, true, false, false);
253 253
254 // Check status on scene presence 254 // Check status on scene presence
255 Assert.That(sp.HasAttachments(), Is.True); 255 Assert.That(sp.HasAttachments(), Is.True);
@@ -282,7 +282,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
282 282
283 // Test wearing a different attachment from the ground. 283 // Test wearing a different attachment from the ground.
284 { 284 {
285 scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false); 285 scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false, false);
286 286
287 // Check status on scene presence 287 // Check status on scene presence
288 Assert.That(sp.HasAttachments(), Is.True); 288 Assert.That(sp.HasAttachments(), Is.True);
@@ -315,7 +315,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
315 315
316 // Test rewearing an already worn attachment from ground. Nothing should happen. 316 // Test rewearing an already worn attachment from ground. Nothing should happen.
317 { 317 {
318 scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false); 318 scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false, false);
319 319
320 // Check status on scene presence 320 // Check status on scene presence
321 Assert.That(sp.HasAttachments(), Is.True); 321 Assert.That(sp.HasAttachments(), Is.True);
@@ -373,7 +373,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
373 sp2.AbsolutePosition = new Vector3(0, 0, 0); 373 sp2.AbsolutePosition = new Vector3(0, 0, 0);
374 sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); 374 sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero);
375 375
376 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false); 376 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false, false);
377 377
378 Assert.That(sp.HasAttachments(), Is.False); 378 Assert.That(sp.HasAttachments(), Is.False);
379 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); 379 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
@@ -671,7 +671,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
671 scene.EventManager.OnChatFromWorld += OnChatFromWorld; 671 scene.EventManager.OnChatFromWorld += OnChatFromWorld;
672 672
673 SceneObjectGroup rezzedSo 673 SceneObjectGroup rezzedSo
674 = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); 674 = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest));
675 675
676 // Wait for chat to signal rezzed script has been started. 676 // Wait for chat to signal rezzed script has been started.
677 m_chatEvent.WaitOne(60000); 677 m_chatEvent.WaitOne(60000);
@@ -690,7 +690,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
690 Assert.That(scriptStateNodes.Count, Is.EqualTo(1)); 690 Assert.That(scriptStateNodes.Count, Is.EqualTo(1));
691 691
692 // Re-rez the attachment to check script running state 692 // Re-rez the attachment to check script running state
693 SceneObjectGroup reRezzedSo = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); 693 SceneObjectGroup reRezzedSo = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest));
694 694
695 // Wait for chat to signal rezzed script has been started. 695 // Wait for chat to signal rezzed script has been started.
696 m_chatEvent.WaitOne(60000); 696 m_chatEvent.WaitOne(60000);
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index cfb082b..1e9cfba 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -188,27 +188,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
188 // Process the visual params, this may change height as well 188 // Process the visual params, this may change height as well
189 if (visualParams != null) 189 if (visualParams != null)
190 { 190 {
191 // string[] visualParamsStrings = new string[visualParams.Length];
192 // for (int i = 0; i < visualParams.Length; i++)
193 // visualParamsStrings[i] = visualParams[i].ToString();
194 // m_log.DebugFormat(
195 // "[AVFACTORY]: Setting visual params for {0} to {1}",
196 // client.Name, string.Join(", ", visualParamsStrings));
197/*
198 float oldHeight = sp.Appearance.AvatarHeight;
199 changed = sp.Appearance.SetVisualParams(visualParams);
200
201 if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0)
202 ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight);
203 */
204// float oldoff = sp.Appearance.AvatarFeetOffset;
205// Vector3 oldbox = sp.Appearance.AvatarBoxSize;
206 changed = sp.Appearance.SetVisualParams(visualParams); 191 changed = sp.Appearance.SetVisualParams(visualParams);
207// float off = sp.Appearance.AvatarFeetOffset;
208// Vector3 box = sp.Appearance.AvatarBoxSize;
209// if(oldoff != off || oldbox != box)
210// ((ScenePresence)sp).SetSize(box,off);
211
212 } 192 }
213 193
214 // Process the baked texture array 194 // Process the baked texture array
@@ -222,9 +202,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
222 202
223// WriteBakedTexturesReport(sp, m_log.DebugFormat); 203// WriteBakedTexturesReport(sp, m_log.DebugFormat);
224 204
225 // If bake textures are missing and this is not an NPC, request a rebake from client 205 UpdateBakedTextureCache(sp, cacheItems);
226 if (!ValidateBakedTextureCache(sp) && (((ScenePresence)sp).PresenceType != PresenceType.Npc))
227 RequestRebake(sp, true);
228 206
229 // This appears to be set only in the final stage of the appearance 207 // This appears to be set only in the final stage of the appearance
230 // update transaction. In theory, we should be able to do an immediate 208 // update transaction. In theory, we should be able to do an immediate
@@ -377,114 +355,335 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
377 } 355 }
378 } 356 }
379 357
380 public bool ValidateBakedTextureCache(IScenePresence sp) 358 // called on textures update
359 public bool UpdateBakedTextureCache(IScenePresence sp, WearableCacheItem[] cacheItems)
381 { 360 {
382 bool defonly = true; // are we only using default textures 361 // npcs dont have baked cache
383 IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); 362 if (((ScenePresence)sp).isNPC)
384 IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); 363 return true;
385 WearableCacheItem[] wearableCache = null; 364
386 365 // uploaded baked textures will be in assets local cache
387 // Cache wearable data for teleport. 366 IAssetService cache = m_scene.AssetService;
388 // Only makes sense if there's a bake module and a cache module 367 IBakedTextureModule m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
389 if (bakedModule != null && cache != null) 368
369 int validDirtyBakes = 0;
370 int hits = 0;
371
372 // our main cacheIDs mapper is p.Appearance.WearableCacheItems
373 WearableCacheItem[] wearableCache = sp.Appearance.WearableCacheItems;
374
375 if (wearableCache == null)
390 { 376 {
391 try 377 wearableCache = WearableCacheItem.GetDefaultCacheItem();
392 { 378 }
393 wearableCache = bakedModule.Get(sp.UUID); 379
394 } 380 List<UUID> missing = new List<UUID>();
395 catch (Exception) 381
396 { 382 // Process received baked textures
383 for (int i = 0; i < cacheItems.Length; i++)
384 {
385 int idx = (int)cacheItems[i].TextureIndex;
386 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
397 387
388 // No face
389 if (face == null)
390 {
391 // for some reason viewer is cleaning this
392 sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint) idx);
393 sp.Appearance.Texture.FaceTextures[idx].TextureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE;
394 wearableCache[idx].CacheId = UUID.Zero;
395 wearableCache[idx].TextureID = UUID.Zero;
396 wearableCache[idx].TextureAsset = null;
397 continue;
398 } 398 }
399 if (wearableCache != null) 399 else
400 { 400 {
401 for (int i = 0; i < wearableCache.Length; i++) 401 if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
402 { 402 {
403 cache.Cache(wearableCache[i].TextureAsset); 403 wearableCache[idx].CacheId = UUID.Zero;
404 wearableCache[idx].TextureID = UUID.Zero;
405 wearableCache[idx].TextureAsset = null;
406 continue;
404 } 407 }
405 } 408
406 } 409/*
407 /* 410 if (face.TextureID == wearableCache[idx].TextureID && m_BakedTextureModule != null)
408 IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
409 if (invService.GetRootFolder(userID) != null)
410 {
411 WearableCacheItem[] wearableCache = null;
412 if (bakedModule != null)
413 {
414 try
415 { 411 {
416 wearableCache = bakedModule.Get(userID); 412 if (wearableCache[idx].CacheId != cacheItems[i].CacheId)
417 appearance.WearableCacheItems = wearableCache;
418 appearance.WearableCacheItemsDirty = false;
419 foreach (WearableCacheItem item in wearableCache)
420 { 413 {
421 appearance.Texture.FaceTextures[item.TextureIndex].TextureID = item.TextureID; 414 wearableCache[idx].CacheId = cacheItems[i].CacheId;
415 validDirtyBakes++;
416
417 //assuming this can only happen if asset is in cache
422 } 418 }
419 hits++;
420 continue;
421 }
422*/
423 wearableCache[idx].TextureAsset = null;
424 if (cache != null)
425 wearableCache[idx].TextureAsset = cache.GetCached(face.TextureID.ToString());
426
427 if (wearableCache[idx].TextureAsset != null)
428 {
429 if ( wearableCache[idx].TextureID != face.TextureID ||
430 wearableCache[idx].CacheId != cacheItems[i].CacheId)
431 validDirtyBakes++;
432
433 wearableCache[idx].TextureID = face.TextureID;
434 wearableCache[idx].CacheId = cacheItems[i].CacheId;
435 hits++;
423 } 436 }
424 catch (Exception) 437 else
425 { 438 {
426 439 wearableCache[idx].CacheId = UUID.Zero;
440 wearableCache[idx].TextureID = UUID.Zero;
441 wearableCache[idx].TextureAsset = null;
442 missing.Add(face.TextureID);
443 continue;
427 } 444 }
428 } 445 }
429 */ 446 }
430 447
431 // Process the texture entry 448 sp.Appearance.WearableCacheItems = wearableCache;
432 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) 449
450 if (missing.Count > 0)
433 { 451 {
434 int idx = AvatarAppearance.BAKE_INDICES[i]; 452 foreach (UUID id in missing)
435 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; 453 sp.ControllingClient.SendRebakeAvatarTextures(id);
454 }
436 455
437 // No face, so lets check our baked service cache, teleport or login. 456 if (validDirtyBakes > 0 && hits == cacheItems.Length)
438 if (face == null) 457 {
458 // if we got a full set of baked textures save all in BakedTextureModule
459 if (m_BakedTextureModule != null)
439 { 460 {
440 if (wearableCache != null) 461 m_log.Debug("[UpdateBakedCache] uploading to bakedModule cache");
462
463 m_BakedTextureModule.Store(sp.UUID);
464 }
465 }
466
467
468 // debug
469 m_log.Debug("[UpdateBakedCache] cache hits: " + hits.ToString() + " changed entries: " + validDirtyBakes.ToString() + " rebakes " + missing.Count);
470/*
471 for (int iter = 0; iter < AvatarAppearance.BAKE_INDICES.Length; iter++)
472 {
473 int j = AvatarAppearance.BAKE_INDICES[iter];
474 m_log.Debug("[UpdateBCache] {" + iter + "/" +
475 sp.Appearance.WearableCacheItems[j].TextureIndex + "}: c-" +
476 sp.Appearance.WearableCacheItems[j].CacheId + ", t-" +
477 sp.Appearance.WearableCacheItems[j].TextureID);
478 }
479*/
480 return (hits == cacheItems.Length);
481 }
482
483 // called when we get a new root avatar
484 public bool ValidateBakedTextureCache(IScenePresence sp)
485 {
486 int hits = 0;
487
488 if (((ScenePresence)sp).isNPC)
489 return true;
490
491 lock (m_setAppearanceLock)
492 {
493 IAssetService cache = m_scene.AssetService;
494 IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
495 WearableCacheItem[] bakedModuleCache = null;
496
497 if (cache == null)
498 return false;
499
500 WearableCacheItem[] wearableCache = sp.Appearance.WearableCacheItems;
501
502 // big debug
503 m_log.DebugFormat("[AVFACTORY]: ValidateBakedTextureCache start for {0} {1}", sp.Name, sp.UUID);
504/*
505 for (int iter = 0; iter < AvatarAppearance.BAKE_INDICES.Length; iter++)
506 {
507 int j = AvatarAppearance.BAKE_INDICES[iter];
508 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[j];
509 if (wearableCache == null)
441 { 510 {
442 // If we find the an appearance item, set it as the textureentry and the face 511 if (face != null)
443 WearableCacheItem searchitem = WearableCacheItem.SearchTextureIndex((uint) idx, wearableCache); 512 m_log.Debug("[ValidateBakedCache] {" + iter + "/" + j + " t- " + face.TextureID);
444 if (searchitem != null)
445 {
446 sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint) idx);
447 sp.Appearance.Texture.FaceTextures[idx].TextureID = searchitem.TextureID;
448 face = sp.Appearance.Texture.FaceTextures[idx];
449 }
450 else 513 else
451 { 514 m_log.Debug("[ValidateBakedCache] {" + iter + "/" + j + " t- No texture");
452 // if there is no texture entry and no baked cache, skip it
453 continue;
454 }
455 } 515 }
456 else 516 else
457 { 517 {
458 //No texture entry face and no cache. Skip this face. 518 if (face != null)
459 continue; 519 m_log.Debug("[ValidateBakedCache] {" + iter + "/" + j + " ft- " + face.TextureID +
520 "}: cc-" +
521 wearableCache[j].CacheId + ", ct-" +
522 wearableCache[j].TextureID
523 );
524 else
525 m_log.Debug("[ValidateBakedCache] {" + iter + "/" + j + " t - No texture" +
526 "}: cc-" +
527 wearableCache[j].CacheId + ", ct-" +
528 wearableCache[j].TextureID
529 );
460 } 530 }
461 } 531 }
532<<<<<<< HEAD
462 533
463// m_log.DebugFormat( 534// m_log.DebugFormat(
464// "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", 535// "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}",
465// face.TextureID, idx, client.Name, client.AgentId); 536// face.TextureID, idx, client.Name, client.AgentId);
537=======
538*/
539 bool wearableCacheValid = false;
540 if (wearableCache == null)
541 {
542 wearableCache = WearableCacheItem.GetDefaultCacheItem();
543 }
544 else
545 {
546 // we may have received a full cache
547 // check same coerence and store
548 wearableCacheValid = true;
549 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
550 {
551 int idx = AvatarAppearance.BAKE_INDICES[i];
552 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
553 if (face != null)
554 {
555 if (face.TextureID == wearableCache[idx].TextureID &&
556 face.TextureID != UUID.Zero)
557 {
558 if (wearableCache[idx].TextureAsset != null)
559 {
560 hits++;
561 wearableCache[idx].TextureAsset.Temporary = true;
562 wearableCache[idx].TextureAsset.Local = true;
563 cache.Store(wearableCache[idx].TextureAsset);
564 continue;
565 }
566 if (cache.GetCached((wearableCache[idx].TextureID).ToString()) != null)
567 {
568 hits++;
569 continue;
570 }
571 }
572 wearableCacheValid = false;
573 }
574 }
575
576 wearableCacheValid = (wearableCacheValid && (hits >= AvatarAppearance.BAKE_INDICES.Length - 1));
577 if (wearableCacheValid)
578 m_log.Debug("[ValidateBakedCache] have valid local cache");
579 }
580>>>>>>> avn/ubitvar
466 581
467 // if the texture is one of the "defaults" then skip it 582 bool checkExternal = false;
468 // this should probably be more intelligent (skirt texture doesnt matter
469 // if the avatar isnt wearing a skirt) but if any of the main baked
470 // textures is default then the rest should be as well
471 if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
472 continue;
473
474 defonly = false; // found a non-default texture reference
475 583
584<<<<<<< HEAD
476 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) 585 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null)
477 return false; 586 return false;
478 } 587 }
588=======
589 if (!wearableCacheValid)
590 {
591 // only use external bake module on login condition check
592// ScenePresence ssp = null;
593// if (sp is ScenePresence)
594 {
595// ssp = (ScenePresence)sp;
596// checkExternal = (((uint)ssp.TeleportFlags & (uint)TeleportFlags.ViaLogin) != 0) &&
597// bakedModule != null;
598
599 // or do it anytime we dont have the cache
600 checkExternal = bakedModule != null;
601 }
602 }
479 603
480// m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); 604 if (checkExternal)
605 {
606 hits = 0;
607 bool gotbacked = false;
481 608
482 // If we only found default textures, then the appearance is not cached 609 m_log.Debug("[ValidateBakedCache] local cache invalid, checking bakedModule");
483 return (defonly ? false : true); 610 try
611 {
612 bakedModuleCache = bakedModule.Get(sp.UUID);
613 }
614 catch (Exception e)
615 {
616 m_log.ErrorFormat(e.ToString());
617 bakedModuleCache = null;
618 }
619
620 if (bakedModuleCache != null)
621 {
622 m_log.Debug("[ValidateBakedCache] got bakedModule " + bakedModuleCache.Length + " cached textures");
623
624 for (int i = 0; i < bakedModuleCache.Length; i++)
625 {
626 int j = (int)bakedModuleCache[i].TextureIndex;
627
628 if (bakedModuleCache[i].TextureAsset != null)
629 {
630 wearableCache[j].TextureID = bakedModuleCache[i].TextureID;
631 wearableCache[j].CacheId = bakedModuleCache[i].CacheId;
632 wearableCache[j].TextureAsset = bakedModuleCache[i].TextureAsset;
633 bakedModuleCache[i].TextureAsset.Temporary = true;
634 bakedModuleCache[i].TextureAsset.Local = true;
635 cache.Store(bakedModuleCache[i].TextureAsset);
636 }
637 }
638 gotbacked = true;
639 }
640
641 if (gotbacked)
642 {
643 // force the ones we got
644 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
645 {
646 int idx = AvatarAppearance.BAKE_INDICES[i];
647 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
648
649 if (sp.Appearance.Texture.FaceTextures[idx] == null)
650 sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint)idx);
651 sp.Appearance.Texture.FaceTextures[idx].TextureID = wearableCache[idx].TextureID;
652 face = sp.Appearance.Texture.FaceTextures[idx];
653
654 // this should be removed
655 if (face.TextureID != UUID.Zero && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
656 hits++;
657 continue;
658 }
659 }
660 }
661>>>>>>> avn/ubitvar
662
663 sp.Appearance.WearableCacheItems = wearableCache;
664
665 }
666
667 // debug
668 m_log.DebugFormat("[ValidateBakedCache]: Completed texture check for {0} {1} with {2} hits", sp.Name, sp.UUID, hits);
669/*
670 for (int iter = 0; iter < AvatarAppearance.BAKE_INDICES.Length; iter++)
671 {
672 int j = AvatarAppearance.BAKE_INDICES[iter];
673 m_log.Debug("[ValidateBakedCache] {" + iter + "/" +
674 sp.Appearance.WearableCacheItems[j].TextureIndex + "}: c-" +
675 sp.Appearance.WearableCacheItems[j].CacheId + ", t-" +
676 sp.Appearance.WearableCacheItems[j].TextureID);
677 }
678*/
679 return (hits >= AvatarAppearance.BAKE_INDICES.Length - 1); // skirt is optional
484 } 680 }
485 681
486 public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) 682 public int RequestRebake(IScenePresence sp, bool missingTexturesOnly)
487 { 683 {
684 if (((ScenePresence)sp).isNPC)
685 return 0;
686
488 int texturesRebaked = 0; 687 int texturesRebaked = 0;
489// IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); 688// IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>();
490 689
@@ -497,14 +696,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
497 if (face == null) 696 if (face == null)
498 continue; 697 continue;
499 698
500// m_log.DebugFormat(
501// "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}",
502// face.TextureID, idx, client.Name, client.AgentId);
503
504 // if the texture is one of the "defaults" then skip it
505 // this should probably be more intelligent (skirt texture doesnt matter
506 // if the avatar isnt wearing a skirt) but if any of the main baked
507 // textures is default then the rest should be as well
508 if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE) 699 if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
509 continue; 700 continue;
510 701
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs
index 9513408..b7ff4e0 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs
@@ -132,6 +132,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
132 for (byte i = 0; i < visualParams.Length; i++) 132 for (byte i = 0; i < visualParams.Length; i++)
133 visualParams[i] = i; 133 visualParams[i] = i;
134 134
135<<<<<<< HEAD
135 Primitive.TextureEntry bakedTextureEntry = new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)); 136 Primitive.TextureEntry bakedTextureEntry = new Primitive.TextureEntry(TestHelpers.ParseTail(0x10));
136 uint eyesFaceIndex = (uint)AppearanceManager.BakeTypeToAgentTextureIndex(BakeType.Eyes); 137 uint eyesFaceIndex = (uint)AppearanceManager.BakeTypeToAgentTextureIndex(BakeType.Eyes);
137 Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex); 138 Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex);
@@ -144,6 +145,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
144 afm.SetAppearance(sp, bakedTextureEntry, visualParams, null); 145 afm.SetAppearance(sp, bakedTextureEntry, visualParams, null);
145 146
146 Assert.That(rebakeRequestsReceived, Is.EqualTo(0)); 147 Assert.That(rebakeRequestsReceived, Is.EqualTo(0));
148=======
149 afm.SetAppearance(sp, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams, new WearableCacheItem[0]);
150
151 // TODO: Check baked texture
152 Assert.AreEqual(visualParams, sp.Appearance.VisualParams);
153>>>>>>> avn/ubitvar
147 } 154 }
148 155
149 [Test] 156 [Test]
@@ -181,7 +188,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
181 Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex); 188 Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex);
182 eyesFace.TextureID = eyesTextureId; 189 eyesFace.TextureID = eyesTextureId;
183 190
191<<<<<<< HEAD
184 afm.SetAppearance(sp, bakedTextureEntry, visualParams, null); 192 afm.SetAppearance(sp, bakedTextureEntry, visualParams, null);
193=======
194 afm.SetAppearance(sp, bakedTextureEntry, visualParams, new WearableCacheItem[0]);
195>>>>>>> avn/ubitvar
185 afm.SaveBakedTextures(userId); 196 afm.SaveBakedTextures(userId);
186// Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId); 197// Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId);
187 198
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index a9d2de0..2801ef0 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -51,7 +51,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
51 private int m_saydistance = 20; 51 private int m_saydistance = 20;
52 private int m_shoutdistance = 100; 52 private int m_shoutdistance = 100;
53 private int m_whisperdistance = 10; 53 private int m_whisperdistance = 10;
54 54 private List<Scene> m_scenes = new List<Scene>();
55 private List<string> FreezeCache = new List<string>();
56 private string m_adminPrefix = "";
55 internal object m_syncy = new object(); 57 internal object m_syncy = new object();
56 58
57 internal IConfig m_config; 59 internal IConfig m_config;
@@ -78,16 +80,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
78 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); 80 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance);
79 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); 81 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance);
80 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); 82 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance);
83 m_adminPrefix = config.Configs["Chat"].GetString("admin_prefix", "");
81 } 84 }
82 85
83 public virtual void AddRegion(Scene scene) 86 public virtual void AddRegion(Scene scene)
84 { 87 {
85 if (!m_enabled) 88 if (!m_enabled) return;
86 return;
87 89
88 scene.EventManager.OnNewClient += OnNewClient; 90 lock (m_syncy)
89 scene.EventManager.OnChatFromWorld += OnChatFromWorld; 91 {
90 scene.EventManager.OnChatBroadcast += OnChatBroadcast; 92 if (!m_scenes.Contains(scene))
93 {
94 m_scenes.Add(scene);
95 scene.EventManager.OnNewClient += OnNewClient;
96 scene.EventManager.OnChatFromWorld += OnChatFromWorld;
97 scene.EventManager.OnChatBroadcast += OnChatBroadcast;
98 }
99 }
91 100
92 m_log.InfoFormat("[CHAT]: Initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName, 101 m_log.InfoFormat("[CHAT]: Initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName,
93 m_whisperdistance, m_saydistance, m_shoutdistance); 102 m_whisperdistance, m_saydistance, m_shoutdistance);
@@ -107,12 +116,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
107 116
108 public virtual void RemoveRegion(Scene scene) 117 public virtual void RemoveRegion(Scene scene)
109 { 118 {
110 if (!m_enabled) 119 if (!m_enabled) return;
111 return;
112 120
113 scene.EventManager.OnNewClient -= OnNewClient; 121 lock (m_syncy)
114 scene.EventManager.OnChatFromWorld -= OnChatFromWorld; 122 {
115 scene.EventManager.OnChatBroadcast -= OnChatBroadcast; 123 if (m_scenes.Contains(scene))
124 {
125 scene.EventManager.OnNewClient -= OnNewClient;
126 scene.EventManager.OnChatFromWorld -= OnChatFromWorld;
127 scene.EventManager.OnChatBroadcast -= OnChatBroadcast;
128 m_scenes.Remove(scene);
129 }
130 }
116 } 131 }
117 132
118 public virtual void Close() 133 public virtual void Close()
@@ -169,7 +184,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
169 return; 184 return;
170 } 185 }
171 186
172 DeliverChatToAvatars(ChatSourceType.Agent, c); 187 if (FreezeCache.Contains(c.Sender.AgentId.ToString()))
188 {
189 if (c.Type != ChatTypeEnum.StartTyping || c.Type != ChatTypeEnum.StopTyping)
190 c.Sender.SendAgentAlertMessage("You may not talk as you are frozen.", false);
191 }
192 else
193 {
194 DeliverChatToAvatars(ChatSourceType.Agent, c);
195 }
173 } 196 }
174 197
175 public virtual void OnChatFromWorld(Object sender, OSChatMessage c) 198 public virtual void OnChatFromWorld(Object sender, OSChatMessage c)
@@ -183,33 +206,64 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
183 protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) 206 protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
184 { 207 {
185 string fromName = c.From; 208 string fromName = c.From;
209 string fromNamePrefix = "";
186 UUID fromID = UUID.Zero; 210 UUID fromID = UUID.Zero;
187 UUID ownerID = UUID.Zero; 211 UUID ownerID = UUID.Zero;
188 UUID targetID = c.TargetUUID;
189 string message = c.Message; 212 string message = c.Message;
190 Scene scene = (Scene)c.Scene; 213 IScene scene = c.Scene;
214 UUID destination = c.Destination;
191 Vector3 fromPos = c.Position; 215 Vector3 fromPos = c.Position;
192 Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0); 216 Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0);
217<<<<<<< HEAD
218=======
219
220 bool checkParcelHide = false;
221 UUID sourceParcelID = UUID.Zero;
222 Vector3 hidePos = fromPos;
223>>>>>>> avn/ubitvar
193 224
194 if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel; 225 if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel;
195 226
196 switch (sourceType) 227 switch (sourceType)
197 { 228 {
198 case ChatSourceType.Agent: 229 case ChatSourceType.Agent:
199 ScenePresence avatar = scene.GetScenePresence(c.Sender.AgentId); 230 if (!(scene is Scene))
231 {
232 m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}",
233 scene.RegionInfo.RegionName, c.Sender.AgentId);
234 return;
235 }
236 ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
200 fromPos = avatar.AbsolutePosition; 237 fromPos = avatar.AbsolutePosition;
201 fromName = avatar.Name; 238 fromName = avatar.Name;
202 fromID = c.Sender.AgentId; 239 fromID = c.Sender.AgentId;
240 if (avatar.GodLevel >= 200)
241 { // let gods speak to outside or things may get confusing
242 fromNamePrefix = m_adminPrefix;
243 checkParcelHide = false;
244 }
245 else
246 {
247 checkParcelHide = true;
248 }
249 destination = UUID.Zero; // Avatars cant "SayTo"
203 ownerID = c.Sender.AgentId; 250 ownerID = c.Sender.AgentId;
204 251
252 hidePos = fromPos;
205 break; 253 break;
206 254
207 case ChatSourceType.Object: 255 case ChatSourceType.Object:
208 fromID = c.SenderUUID; 256 fromID = c.SenderUUID;
209 257
210 if (c.SenderObject != null && c.SenderObject is SceneObjectPart) 258 if (c.SenderObject != null && c.SenderObject is SceneObjectPart)
259 {
211 ownerID = ((SceneObjectPart)c.SenderObject).OwnerID; 260 ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
212 261 if (((SceneObjectPart)c.SenderObject).ParentGroup.IsAttachment)
262 {
263 checkParcelHide = true;
264 hidePos = ((SceneObjectPart)c.SenderObject).ParentGroup.AbsolutePosition;
265 }
266 }
213 break; 267 break;
214 } 268 }
215 269
@@ -218,38 +272,68 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
218 message = message.Substring(0, 1000); 272 message = message.Substring(0, 1000);
219 273
220// m_log.DebugFormat( 274// m_log.DebugFormat(
221// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}", 275// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}",
222// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID); 276// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType);
223 277
224 HashSet<UUID> receiverIDs = new HashSet<UUID>(); 278 HashSet<UUID> receiverIDs = new HashSet<UUID>();
225 279
226 if (targetID == UUID.Zero) 280 if (checkParcelHide)
281 {
282 checkParcelHide = false;
283 if (c.Type < ChatTypeEnum.DebugChannel && destination == UUID.Zero)
284 {
285 ILandObject srcland = (scene as Scene).LandChannel.GetLandObject(hidePos.X, hidePos.Y);
286 if (srcland != null && !srcland.LandData.SeeAVs)
287 {
288 sourceParcelID = srcland.LandData.GlobalID;
289 checkParcelHide = true;
290 }
291 }
292 }
293
294 foreach (Scene s in m_scenes)
227 { 295 {
228 // This should use ForEachClient, but clients don't have a position. 296 // This should use ForEachClient, but clients don't have a position.
229 // If camera is moved into client, then camera position can be used 297 // If camera is moved into client, then camera position can be used
230 scene.ForEachScenePresence( 298 // MT: No, it can't, as chat is heard from the avatar position, not
299 // the camera position.
300
301 s.ForEachScenePresence(
231 delegate(ScenePresence presence) 302 delegate(ScenePresence presence)
232 { 303 {
233 if (TrySendChatMessage( 304 if (destination != UUID.Zero && presence.UUID != destination)
234 presence, fromPos, regionPos, fromID, ownerID, fromName, c.Type, message, sourceType, false)) 305 return;
235 receiverIDs.Add(presence.UUID); 306 ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
307 if (Presencecheck != null)
308 {
309 // This will pass all chat from objects. Not
310 // perfect, but it will do. For now. Better
311 // than the prior behavior of muting all
312 // objects on a parcel with access restrictions
313 if (checkParcelHide)
314 {
315 if (sourceParcelID != Presencecheck.LandData.GlobalID && presence.GodLevel < 200)
316 return;
317 }
318 if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
319 {
320 if (destination != UUID.Zero)
321 {
322 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, ownerID, fromNamePrefix + fromName, c.Type, message, sourceType, true))
323 receiverIDs.Add(presence.UUID);
324 }
325 else
326 {
327 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, ownerID, fromNamePrefix + fromName, c.Type, message, sourceType, false))
328 receiverIDs.Add(presence.UUID);
329 }
330 }
331 }
236 } 332 }
237 ); 333 );
238 } 334 }
239 else 335
240 { 336 (scene as Scene).EventManager.TriggerOnChatToClients(
241 // This is a send to a specific client eg from llRegionSayTo
242 // no need to check distance etc, jand send is as say
243 ScenePresence presence = scene.GetScenePresence(targetID);
244 if (presence != null && !presence.IsChildAgent)
245 {
246 if (TrySendChatMessage(
247 presence, fromPos, regionPos, fromID, ownerID, fromName, ChatTypeEnum.Say, message, sourceType, true))
248 receiverIDs.Add(presence.UUID);
249 }
250 }
251
252 scene.EventManager.TriggerOnChatToClients(
253 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); 337 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
254 } 338 }
255 339
@@ -291,9 +375,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
291 } 375 }
292 376
293 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); 377 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);
294
295 HashSet<UUID> receiverIDs = new HashSet<UUID>(); 378 HashSet<UUID> receiverIDs = new HashSet<UUID>();
296 379
380<<<<<<< HEAD
297 ((Scene)c.Scene).ForEachRootClient( 381 ((Scene)c.Scene).ForEachRootClient(
298 delegate(IClientAPI client) 382 delegate(IClientAPI client)
299 { 383 {
@@ -313,6 +397,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
313 397
314 (c.Scene as Scene).EventManager.TriggerOnChatToClients( 398 (c.Scene as Scene).EventManager.TriggerOnChatToClients(
315 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); 399 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully);
400=======
401 if (c.Scene != null)
402 {
403 ((Scene)c.Scene).ForEachRootClient
404 (
405 delegate(IClientAPI client)
406 {
407 // don't forward SayOwner chat from objects to
408 // non-owner agents
409 if ((c.Type == ChatTypeEnum.Owner) &&
410 (null != c.SenderObject) &&
411 (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
412 return;
413
414 client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, fromID,
415 (byte)sourceType, (byte)ChatAudibleLevel.Fully);
416 receiverIDs.Add(client.AgentId);
417 }
418 );
419 (c.Scene as Scene).EventManager.TriggerOnChatToClients(
420 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully);
421 }
422>>>>>>> avn/ubitvar
316 } 423 }
317 424
318 /// <summary> 425 /// <summary>
@@ -364,6 +471,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
364 return true; 471 return true;
365 } 472 }
366 473
474 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
475 public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
476 {
477 System.Threading.Timer Timer;
478 if (flags == 0)
479 {
480 FreezeCache.Add(target.ToString());
481 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
482 Timer = new System.Threading.Timer(timeCB, target, 30000, 0);
483 Timers.Add(target, Timer);
484 }
485 else
486 {
487 FreezeCache.Remove(target.ToString());
488 Timers.TryGetValue(target, out Timer);
489 Timers.Remove(target);
490 Timer.Dispose();
491 }
492 }
493
494 private void OnEndParcelFrozen(object avatar)
495 {
496 UUID target = (UUID)avatar;
497 FreezeCache.Remove(target.ToString());
498 System.Threading.Timer Timer;
499 Timers.TryGetValue(target, out Timer);
500 Timers.Remove(target);
501 Timer.Dispose();
502 }
367 #region SimulatorFeaturesRequest 503 #region SimulatorFeaturesRequest
368 504
369 static OSDInteger m_SayRange, m_WhisperRange, m_ShoutRange; 505 static OSDInteger m_SayRange, m_WhisperRange, m_ShoutRange;
@@ -392,4 +528,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
392 528
393 #endregion 529 #endregion
394 } 530 }
395} \ No newline at end of file 531}
diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
index fc23b72..b0b7054 100644
--- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
@@ -183,10 +183,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
183 try 183 try
184 { 184 {
185 ILandObject obj = avatar.Scene.LandChannel.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 185 ILandObject obj = avatar.Scene.LandChannel.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
186<<<<<<< HEAD
186 187
187 if (obj == null) 188 if (obj == null)
188 return; 189 return;
189 190
191=======
192 if (obj == null)
193 return;
194>>>>>>> avn/ubitvar
190 if ((obj.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0 195 if ((obj.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0
191 || avatar.Scene.RegionInfo.RegionSettings.AllowDamage) 196 || avatar.Scene.RegionInfo.RegionSettings.AllowDamage)
192 { 197 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index a896897..56819fa 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -203,8 +203,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
203 { 203 {
204 m_scene.ForEachRootClient(delegate(IClientAPI client) 204 m_scene.ForEachRootClient(delegate(IClientAPI client)
205 { 205 {
206 client.SendBlueBoxMessage(fromAvatarID, fromAvatarName, 206 client.SendAgentAlertMessage(
207 message); 207 message, false);
208 }); 208 });
209 } 209 }
210 210
@@ -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 3b6d970..adb838c 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
@@ -49,6 +49,8 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
49using OSDArray = OpenMetaverse.StructuredData.OSDArray; 49using OSDArray = OpenMetaverse.StructuredData.OSDArray;
50using OSDMap = OpenMetaverse.StructuredData.OSDMap; 50using OSDMap = OpenMetaverse.StructuredData.OSDMap;
51 51
52using Mono.Addins;
53
52namespace OpenSim.Region.CoreModules.Avatar.Gods 54namespace OpenSim.Region.CoreModules.Avatar.Gods
53{ 55{
54 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GodsModule")] 56 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GodsModule")]
@@ -62,6 +64,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
62 64
63 protected Scene m_scene; 65 protected Scene m_scene;
64 protected IDialogModule m_dialogModule; 66 protected IDialogModule m_dialogModule;
67
65 protected IDialogModule DialogModule 68 protected IDialogModule DialogModule
66 { 69 {
67 get 70 get
@@ -146,6 +149,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
146 UUID godSessionID = userData["GodSessionID"].AsUUID(); 149 UUID godSessionID = userData["GodSessionID"].AsUUID();
147 uint kickFlags = userData["KickFlags"].AsUInteger(); 150 uint kickFlags = userData["KickFlags"].AsUInteger();
148 string reason = userData["Reason"].AsString(); 151 string reason = userData["Reason"].AsString();
152
149 ScenePresence god = m_scene.GetScenePresence(godID); 153 ScenePresence god = m_scene.GetScenePresence(godID);
150 if (god == null || god.ControllingClient.SessionId != godSessionID) 154 if (god == null || god.ControllingClient.SessionId != godSessionID)
151 return String.Empty; 155 return String.Empty;
diff --git a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs
deleted file mode 100644
index b735c61..0000000
--- a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs
+++ /dev/null
@@ -1,260 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using log4net;
32using Nini.Config;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37
38using Mono.Addins;
39
40namespace OpenSim.Region.CoreModules.Avatar.Groups
41{
42 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GroupsModule")]
43 public class GroupsModule : ISharedRegionModule
44 {
45 private static readonly ILog m_log =
46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 private Dictionary<UUID, GroupMembershipData> m_GroupMap =
49 new Dictionary<UUID, GroupMembershipData>();
50
51 private Dictionary<UUID, IClientAPI> m_ClientMap =
52 new Dictionary<UUID, IClientAPI>();
53
54 private UUID opensimulatorGroupID =
55 new UUID("00000000-68f9-1111-024e-222222111123");
56
57 private List<Scene> m_SceneList = new List<Scene>();
58
59 private static GroupMembershipData osGroup =
60 new GroupMembershipData();
61
62 private bool m_Enabled = false;
63
64 #region ISharedRegionModule Members
65
66 public void Initialise(IConfigSource config)
67 {
68 IConfig groupsConfig = config.Configs["Groups"];
69
70 if (groupsConfig == null)
71 {
72 m_log.Info("[GROUPS]: No configuration found. Using defaults");
73 }
74 else
75 {
76 m_Enabled = groupsConfig.GetBoolean("Enabled", false);
77 if (!m_Enabled)
78 {
79 m_log.Info("[GROUPS]: Groups disabled in configuration");
80 return;
81 }
82
83 if (groupsConfig.GetString("Module", "Default") != "Default")
84 {
85 m_Enabled = false;
86 return;
87 }
88 }
89
90 }
91
92 public void AddRegion(Scene scene)
93 {
94 if (!m_Enabled)
95 return;
96
97 lock (m_SceneList)
98 {
99 if (!m_SceneList.Contains(scene))
100 {
101 if (m_SceneList.Count == 0)
102 {
103 osGroup.GroupID = opensimulatorGroupID;
104 osGroup.GroupName = "OpenSimulator Testing";
105 osGroup.GroupPowers =
106 (uint)(GroupPowers.AllowLandmark |
107 GroupPowers.AllowSetHome);
108 m_GroupMap[opensimulatorGroupID] = osGroup;
109 }
110 m_SceneList.Add(scene);
111 }
112 }
113
114 scene.EventManager.OnNewClient += OnNewClient;
115 scene.EventManager.OnClientClosed += OnClientClosed;
116 // scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
117 }
118
119 public void RemoveRegion(Scene scene)
120 {
121 if (!m_Enabled)
122 return;
123
124 lock (m_SceneList)
125 {
126 if (m_SceneList.Contains(scene))
127 m_SceneList.Remove(scene);
128 }
129
130 scene.EventManager.OnNewClient -= OnNewClient;
131 scene.EventManager.OnClientClosed -= OnClientClosed;
132 }
133
134 public void RegionLoaded(Scene scene)
135 {
136 }
137
138 public void PostInitialise()
139 {
140 }
141
142 public void Close()
143 {
144 if (!m_Enabled)
145 return;
146
147// m_log.Debug("[GROUPS]: Shutting down group module.");
148
149 lock (m_ClientMap)
150 {
151 m_ClientMap.Clear();
152 }
153
154 lock (m_GroupMap)
155 {
156 m_GroupMap.Clear();
157 }
158 }
159
160 public string Name
161 {
162 get { return "GroupsModule"; }
163 }
164
165 public Type ReplaceableInterface
166 {
167 get { return null; }
168 }
169
170 #endregion
171
172 private void OnNewClient(IClientAPI client)
173 {
174 // Subscribe to instant messages
175// client.OnInstantMessage += OnInstantMessage;
176 client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest;
177 client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest;
178 lock (m_ClientMap)
179 {
180 if (!m_ClientMap.ContainsKey(client.AgentId))
181 {
182 m_ClientMap.Add(client.AgentId, client);
183 }
184 }
185
186 GroupMembershipData[] updateGroups = new GroupMembershipData[1];
187 updateGroups[0] = osGroup;
188
189 client.SendGroupMembership(updateGroups);
190 }
191
192 private void OnAgentDataUpdateRequest(IClientAPI remoteClient,
193 UUID AgentID, UUID SessionID)
194 {
195 UUID ActiveGroupID;
196 string ActiveGroupName;
197 ulong ActiveGroupPowers;
198
199 string firstname = remoteClient.FirstName;
200 string lastname = remoteClient.LastName;
201
202 string ActiveGroupTitle = "I IZ N0T";
203
204 ActiveGroupID = osGroup.GroupID;
205 ActiveGroupName = osGroup.GroupName;
206 ActiveGroupPowers = osGroup.GroupPowers;
207
208 remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname,
209 lastname, ActiveGroupPowers, ActiveGroupName,
210 ActiveGroupTitle);
211 }
212
213// private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
214// {
215// }
216
217// private void OnGridInstantMessage(GridInstantMessage msg)
218// {
219// // Trigger the above event handler
220// OnInstantMessage(null, msg);
221// }
222
223 private void HandleUUIDGroupNameRequest(UUID id,IClientAPI remote_client)
224 {
225 string groupnamereply = "Unknown";
226 UUID groupUUID = UUID.Zero;
227
228 lock (m_GroupMap)
229 {
230 if (m_GroupMap.ContainsKey(id))
231 {
232 GroupMembershipData grp = m_GroupMap[id];
233 groupnamereply = grp.GroupName;
234 groupUUID = grp.GroupID;
235 }
236 }
237 remote_client.SendGroupNameReply(groupUUID, groupnamereply);
238 }
239
240 private void OnClientClosed(UUID agentID, Scene scene)
241 {
242 lock (m_ClientMap)
243 {
244 if (m_ClientMap.ContainsKey(agentID))
245 {
246// IClientAPI cli = m_ClientMap[agentID];
247// if (cli != null)
248// {
249// //m_log.Info("[GROUPS]: Removing all reference to groups for " + cli.Name);
250// }
251// else
252// {
253// //m_log.Info("[GROUPS]: Removing all reference to groups for " + agentID.ToString());
254// }
255 m_ClientMap.Remove(agentID);
256 }
257 }
258 }
259 }
260}
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
index c33a296..55e30a0 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 Mono.Addins; 32using Mono.Addins;
32using Nini.Config; 33using Nini.Config;
@@ -44,6 +45,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
44 private static readonly ILog m_log = LogManager.GetLogger( 45 private static readonly ILog m_log = LogManager.GetLogger(
45 MethodBase.GetCurrentMethod().DeclaringType); 46 MethodBase.GetCurrentMethod().DeclaringType);
46 47
48 private Timer m_logTimer = new Timer(10000);
49 private List<GridInstantMessage> m_logData = new List<GridInstantMessage>();
50 private string m_restUrl;
51
47 /// <value> 52 /// <value>
48 /// Is this module enabled? 53 /// Is this module enabled?
49 /// </value> 54 /// </value>
@@ -63,9 +68,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
63 "InstantMessageModule", "InstantMessageModule") != 68 "InstantMessageModule", "InstantMessageModule") !=
64 "InstantMessageModule") 69 "InstantMessageModule")
65 return; 70 return;
71 m_restUrl = config.Configs["Messaging"].GetString("LogURL", String.Empty);
66 } 72 }
67 73
68 m_enabled = true; 74 m_enabled = true;
75 m_logTimer.AutoReset = false;
76 m_logTimer.Elapsed += LogTimerElapsed;
69 } 77 }
70 78
71 public void AddRegion(Scene scene) 79 public void AddRegion(Scene scene)
@@ -150,6 +158,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
150 { 158 {
151 byte dialog = im.dialog; 159 byte dialog = im.dialog;
152 160
161 if (client != null && dialog == (byte)InstantMessageDialog.MessageFromAgent)
162 LogInstantMesssage(im);
163
153 if (dialog != (byte)InstantMessageDialog.MessageFromAgent 164 if (dialog != (byte)InstantMessageDialog.MessageFromAgent
154 && dialog != (byte)InstantMessageDialog.StartTyping 165 && dialog != (byte)InstantMessageDialog.StartTyping
155 && dialog != (byte)InstantMessageDialog.StopTyping 166 && dialog != (byte)InstantMessageDialog.StopTyping
@@ -159,6 +170,32 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
159 return; 170 return;
160 } 171 }
161 172
173 //DateTime dt = DateTime.UtcNow;
174
175 // Ticks from UtcNow, but make it look like local. Evil, huh?
176 //dt = DateTime.SpecifyKind(dt, DateTimeKind.Local);
177
178 //try
179 //{
180 // // Convert that to the PST timezone
181 // TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
182 // dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo);
183 //}
184 //catch
185 //{
186 // //m_log.Info("[OFFLINE MESSAGING]: No PST timezone found on this machine. Saving with local timestamp.");
187 //}
188
189 //// And make it look local again to fool the unix time util
190 //dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);
191
192 // If client is null, this message comes from storage and IS offline
193 if (client != null)
194 im.offline = 0;
195
196 if (im.offline == 0)
197 im.timestamp = (uint)Util.UnixTimeSinceEpoch();
198
162 if (m_TransferModule != null) 199 if (m_TransferModule != null)
163 { 200 {
164 if (client != null) 201 if (client != null)
@@ -202,5 +239,35 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
202 // 239 //
203 OnInstantMessage(null, msg); 240 OnInstantMessage(null, msg);
204 } 241 }
242
243 private void LogInstantMesssage(GridInstantMessage im)
244 {
245 if (m_logData.Count < 20)
246 {
247 // Restart the log write timer
248 m_logTimer.Stop();
249 }
250 if (!m_logTimer.Enabled)
251 m_logTimer.Start();
252
253 lock (m_logData)
254 {
255 m_logData.Add(im);
256 }
257 }
258
259 private void LogTimerElapsed(object source, ElapsedEventArgs e)
260 {
261 lock (m_logData)
262 {
263 if (m_restUrl != String.Empty && m_logData.Count > 0)
264 {
265 bool success = SynchronousRestObjectRequester.MakeRequest<List<GridInstantMessage>, bool>("POST", m_restUrl + "/LogMessages/", m_logData);
266 if (!success)
267 m_log.ErrorFormat("[INSTANT MESSAGE]: Failed to save log data");
268 }
269 m_logData.Clear();
270 }
271 }
205 } 272 }
206} 273}
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 2462ff8..5573c94 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -50,6 +50,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 51
52 private bool m_Enabled = false; 52 private bool m_Enabled = false;
53 protected string m_MessageKey = String.Empty;
53 protected List<Scene> m_Scenes = new List<Scene>(); 54 protected List<Scene> m_Scenes = new List<Scene>();
54 protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>(); 55 protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>();
55 56
@@ -69,14 +70,17 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
69 public virtual void Initialise(IConfigSource config) 70 public virtual void Initialise(IConfigSource config)
70 { 71 {
71 IConfig cnf = config.Configs["Messaging"]; 72 IConfig cnf = config.Configs["Messaging"];
72 if (cnf != null && cnf.GetString( 73 if (cnf != null)
73 "MessageTransferModule", "MessageTransferModule") !=
74 "MessageTransferModule")
75 { 74 {
76 m_log.Debug("[MESSAGE TRANSFER]: Disabled by configuration"); 75 if (cnf.GetString("MessageTransferModule",
77 return; 76 "MessageTransferModule") != "MessageTransferModule")
78 } 77 {
78 return;
79 }
79 80
81 m_MessageKey = cnf.GetString("MessageKey", String.Empty);
82 }
83 m_log.Debug("[MESSAGE TRANSFER]: Module enabled");
80 m_Enabled = true; 84 m_Enabled = true;
81 } 85 }
82 86
@@ -135,6 +139,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
135 { 139 {
136 UUID toAgentID = new UUID(im.toAgentID); 140 UUID toAgentID = new UUID(im.toAgentID);
137 141
142 if (toAgentID == UUID.Zero)
143 return;
144
138 // Try root avatar only first 145 // Try root avatar only first
139 foreach (Scene scene in m_Scenes) 146 foreach (Scene scene in m_Scenes)
140 { 147 {
@@ -249,6 +256,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
249 && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") 256 && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id")
250 && requestData.ContainsKey("binary_bucket")) 257 && requestData.ContainsKey("binary_bucket"))
251 { 258 {
259 if (m_MessageKey != String.Empty)
260 {
261 XmlRpcResponse error_resp = new XmlRpcResponse();
262 Hashtable error_respdata = new Hashtable();
263 error_respdata["success"] = "FALSE";
264 error_resp.Value = error_respdata;
265
266 if (!requestData.Contains("message_key"))
267 return error_resp;
268 if (m_MessageKey != (string)requestData["message_key"])
269 return error_resp;
270 }
271
252 // Do the easy way of validating the UUIDs 272 // Do the easy way of validating the UUIDs
253 UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); 273 UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID);
254 UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); 274 UUID.TryParse((string)requestData["to_agent_id"], out toAgentID);
@@ -425,34 +445,89 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
425 return resp; 445 return resp;
426 } 446 }
427 447
448<<<<<<< HEAD
428 /// <summary> 449 /// <summary>
429 /// delegate for sending a grid instant message asynchronously 450 /// delegate for sending a grid instant message asynchronously
430 /// </summary> 451 /// </summary>
431 public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result); 452 public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result);
453=======
454 private delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result);
455>>>>>>> avn/ubitvar
432 456
433 protected virtual void GridInstantMessageCompleted(IAsyncResult iar) 457 private class GIM {
434 { 458 public GridInstantMessage im;
435 GridInstantMessageDelegate icon = 459 public MessageResultNotification result;
436 (GridInstantMessageDelegate)iar.AsyncState; 460 };
437 icon.EndInvoke(iar);
438 }
439 461
462 private Queue<GIM> pendingInstantMessages = new Queue<GIM>();
463 private int numInstantMessageThreads = 0;
440 464
441 protected virtual void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result) 465 private void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result)
442 { 466 {
443 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; 467 lock (pendingInstantMessages) {
468 if (numInstantMessageThreads >= 4) {
469 GIM gim = new GIM();
470 gim.im = im;
471 gim.result = result;
472 pendingInstantMessages.Enqueue(gim);
473 } else {
474 ++ numInstantMessageThreads;
475 //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: ++numInstantMessageThreads={0}", numInstantMessageThreads);
476 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsyncMain;
477 d.BeginInvoke(im, result, GridInstantMessageCompleted, d);
478 }
479 }
480 }
444 481
482<<<<<<< HEAD
445 d.BeginInvoke(im, result, GridInstantMessageCompleted, d); 483 d.BeginInvoke(im, result, GridInstantMessageCompleted, d);
484=======
485 private void GridInstantMessageCompleted(IAsyncResult iar)
486 {
487 GridInstantMessageDelegate d = (GridInstantMessageDelegate)iar.AsyncState;
488 d.EndInvoke(iar);
489>>>>>>> avn/ubitvar
446 } 490 }
447 491
448 /// <summary> 492 /// <summary>
449 /// Internal SendGridInstantMessage over XMLRPC method. 493 /// Internal SendGridInstantMessage over XMLRPC method.
450 /// </summary> 494 /// </summary>
495<<<<<<< HEAD
451 /// <remarks> 496 /// <remarks>
452 /// This is called from within a dedicated thread. 497 /// This is called from within a dedicated thread.
453 /// </remarks> 498 /// </remarks>
454 private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result) 499 private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result)
500=======
501 /// <param name="prevRegionHandle">
502 /// Pass in 0 the first time this method is called. It will be called recursively with the last
503 /// regionhandle tried
504 /// </param>
505 private void SendGridInstantMessageViaXMLRPCAsyncMain(GridInstantMessage im, MessageResultNotification result)
506>>>>>>> avn/ubitvar
455 { 507 {
508 GIM gim;
509 do {
510 try {
511 SendGridInstantMessageViaXMLRPCAsync(im, result, UUID.Zero);
512 } catch (Exception e) {
513 m_log.Error("[SendGridInstantMessageViaXMLRPC]: exception " + e.Message);
514 }
515 lock (pendingInstantMessages) {
516 if (pendingInstantMessages.Count > 0) {
517 gim = pendingInstantMessages.Dequeue();
518 im = gim.im;
519 result = gim.result;
520 } else {
521 gim = null;
522 -- numInstantMessageThreads;
523 //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: --numInstantMessageThreads={0}", numInstantMessageThreads);
524 }
525 }
526 } while (gim != null);
527 }
528 private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID)
529 {
530
456 UUID toAgentID = new UUID(im.toAgentID); 531 UUID toAgentID = new UUID(im.toAgentID);
457 UUID regionID; 532 UUID regionID;
458 bool needToLookupAgent; 533 bool needToLookupAgent;
@@ -494,6 +569,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
494 break; 569 break;
495 } 570 }
496 571
572<<<<<<< HEAD
497 // Try to send the message to the agent via the retrieved region. 573 // Try to send the message to the agent via the retrieved region.
498 Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); 574 Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im);
499 msgdata["region_handle"] = 0; 575 msgdata["region_handle"] = 0;
@@ -501,6 +577,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
501 577
502 // If the message delivery was successful, then cache the entry. 578 // If the message delivery was successful, then cache the entry.
503 if (imresult) 579 if (imresult)
580=======
581 if (upd != null)
582 {
583 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(UUID.Zero,
584 upd.RegionID);
585 if (reginfo != null)
586>>>>>>> avn/ubitvar
504 { 587 {
505 lock (m_UserRegionMap) 588 lock (m_UserRegionMap)
506 { 589 {
@@ -622,6 +705,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
622 gim["position_z"] = msg.Position.Z.ToString(); 705 gim["position_z"] = msg.Position.Z.ToString();
623 gim["region_id"] = new UUID(msg.RegionID).ToString(); 706 gim["region_id"] = new UUID(msg.RegionID).ToString();
624 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None); 707 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None);
708 if (m_MessageKey != String.Empty)
709 gim["message_key"] = m_MessageKey;
625 return gim; 710 return gim;
626 } 711 }
627 712
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index c75920d..76023bd 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
41namespace OpenSim.Region.CoreModules.Avatar.InstantMessage 41namespace 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,11 +177,21 @@ 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)
175 { 189 {
176 if (m_RestURL != "") 190 if (m_RestURL == String.Empty)
191 {
192 return;
193 }
194 else
177 { 195 {
178 m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId); 196 m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId);
179 197
@@ -181,28 +199,28 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
181 = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>( 199 = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>(
182 "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); 200 "POST", m_RestURL + "/RetrieveMessages/", client.AgentId);
183 201
184 if (msglist == null) 202 if (msglist != null)
185 { 203 {
186 m_log.WarnFormat("[OFFLINE MESSAGING]: WARNING null message list."); 204 foreach (GridInstantMessage im in msglist)
187 return;
188 }
189
190 foreach (GridInstantMessage im in msglist)
191 {
192 if (im.dialog == (byte)InstantMessageDialog.InventoryOffered)
193 // send it directly or else the item will be given twice
194 client.SendInstantMessage(im);
195 else
196 { 205 {
197 // Send through scene event manager so all modules get a chance 206 if (im.dialog == (byte)InstantMessageDialog.InventoryOffered)
198 // to look at this message before it gets delivered. 207 // send it directly or else the item will be given twice
199 // 208 client.SendInstantMessage(im);
200 // Needed for proper state management for stored group 209 else
201 // invitations 210 {
202 // 211 // Send through scene event manager so all modules get a chance
203 Scene s = FindScene(client.AgentId); 212 // to look at this message before it gets delivered.
204 if (s != null) 213 //
205 s.EventManager.TriggerIncomingInstantMessage(im); 214 // Needed for proper state management for stored group
215 // invitations
216 //
217
218 im.offline = 1;
219
220 Scene s = FindScene(client.AgentId);
221 if (s != null)
222 s.EventManager.TriggerIncomingInstantMessage(im);
223 }
206 } 224 }
207 } 225 }
208 } 226 }
@@ -214,11 +232,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
214 im.dialog != (byte)InstantMessageDialog.MessageFromAgent && 232 im.dialog != (byte)InstantMessageDialog.MessageFromAgent &&
215 im.dialog != (byte)InstantMessageDialog.GroupNotice && 233 im.dialog != (byte)InstantMessageDialog.GroupNotice &&
216 im.dialog != (byte)InstantMessageDialog.GroupInvitation && 234 im.dialog != (byte)InstantMessageDialog.GroupInvitation &&
217 im.dialog != (byte)InstantMessageDialog.InventoryOffered) 235 im.dialog != (byte)InstantMessageDialog.InventoryOffered &&
236 im.dialog != (byte)InstantMessageDialog.TaskInventoryOffered)
218 { 237 {
219 return; 238 return;
220 } 239 }
221 240
241<<<<<<< HEAD
222 if (!m_ForwardOfflineGroupMessages) 242 if (!m_ForwardOfflineGroupMessages)
223 { 243 {
224 if (im.dialog == (byte)InstantMessageDialog.GroupNotice || 244 if (im.dialog == (byte)InstantMessageDialog.GroupNotice ||
@@ -228,6 +248,15 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
228 248
229 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( 249 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>(
230 "POST", m_RestURL+"/SaveMessage/", im, 10000); 250 "POST", m_RestURL+"/SaveMessage/", im, 10000);
251=======
252 Scene scene = FindScene(new UUID(im.fromAgentID));
253 if (scene == null)
254 scene = m_SceneList[0];
255
256 SendReply reply = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, SendReply>(
257 "POST", m_RestURL+"/SaveMessage/?scope=" +
258 scene.RegionInfo.ScopeID.ToString(), im);
259>>>>>>> avn/ubitvar
231 260
232 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) 261 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
233 { 262 {
@@ -235,13 +264,38 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
235 if (client == null) 264 if (client == null)
236 return; 265 return;
237 266
238 client.SendInstantMessage(new GridInstantMessage( 267 if (reply.Message == String.Empty)
239 null, new UUID(im.toAgentID), 268 reply.Message = "User is not logged in. " + (reply.Success ? "Message saved." : "Message not saved");
240 "System", new UUID(im.fromAgentID), 269
241 (byte)InstantMessageDialog.MessageFromAgent, 270 bool sendReply = true;
242 "User is not logged in. "+ 271
243 (success ? "Message saved." : "Message not saved"), 272 switch (reply.Disposition)
244 false, new Vector3())); 273 {
274 case 0: // Normal
275 break;
276 case 1: // Only once per user
277 if (m_repliesSent.ContainsKey(client) && m_repliesSent[client].Contains(new UUID(im.toAgentID)))
278 {
279 sendReply = false;
280 }
281 else
282 {
283 if (!m_repliesSent.ContainsKey(client))
284 m_repliesSent[client] = new List<UUID>();
285 m_repliesSent[client].Add(new UUID(im.toAgentID));
286 }
287 break;
288 }
289
290 if (sendReply)
291 {
292 client.SendInstantMessage(new GridInstantMessage(
293 null, new UUID(im.toAgentID),
294 "System", new UUID(im.fromAgentID),
295 (byte)InstantMessageDialog.MessageFromAgent,
296 reply.Message,
297 false, new Vector3()));
298 }
245 } 299 }
246 } 300 }
247 } 301 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 420520e..5295ba3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -566,6 +566,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
566 return null; 566 return null;
567 } 567 }
568 568
569 return account;
570 /*
569 try 571 try
570 { 572 {
571 string encpass = Util.Md5Hash(pass); 573 string encpass = Util.Md5Hash(pass);
@@ -586,6 +588,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
586 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e); 588 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e);
587 return null; 589 return null;
588 } 590 }
591 */
589 } 592 }
590 593
591 /// <summary> 594 /// <summary>
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index bba48cc..18e18a9 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -165,8 +165,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
165 if (im.binaryBucket.Length < 17) // Invalid 165 if (im.binaryBucket.Length < 17) // Invalid
166 return; 166 return;
167 167
168 UUID receipientID = new UUID(im.toAgentID); 168 UUID recipientID = new UUID(im.toAgentID);
169 ScenePresence user = scene.GetScenePresence(receipientID); 169 ScenePresence user = scene.GetScenePresence(recipientID);
170 UUID copyID; 170 UUID copyID;
171 171
172 // First byte is the asset type 172 // First byte is the asset type
@@ -180,8 +180,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
180 "[INVENTORY TRANSFER]: Inserting original folder {0} into agent {1}'s inventory", 180 "[INVENTORY TRANSFER]: Inserting original folder {0} into agent {1}'s inventory",
181 folderID, new UUID(im.toAgentID)); 181 folderID, new UUID(im.toAgentID));
182 182
183<<<<<<< HEAD
183 InventoryFolderBase folderCopy 184 InventoryFolderBase folderCopy
184 = scene.GiveInventoryFolder(client, receipientID, client.AgentId, folderID, UUID.Zero); 185 = scene.GiveInventoryFolder(client, receipientID, client.AgentId, folderID, UUID.Zero);
186=======
187 InventoryFolderBase folderCopy
188 = scene.GiveInventoryFolder(recipientID, client.AgentId, folderID, UUID.Zero);
189>>>>>>> avn/ubitvar
185 190
186 if (folderCopy == null) 191 if (folderCopy == null)
187 { 192 {
@@ -239,6 +244,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
239 im.imSessionID = copyID.Guid; 244 im.imSessionID = copyID.Guid;
240 } 245 }
241 246
247 im.offline = 0;
248
242 // Send the IM to the recipient. The item is already 249 // Send the IM to the recipient. The item is already
243 // in their inventory, so it will not be lost if 250 // in their inventory, so it will not be lost if
244 // they are offline. 251 // they are offline.
@@ -258,8 +265,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
258 }); 265 });
259 } 266 }
260 } 267 }
261 else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) 268 else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted ||
269 im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted)
262 { 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
263 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); 304 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
264 305
265 if (user != null) // Local 306 if (user != null) // Local
@@ -269,27 +310,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
269 else 310 else
270 { 311 {
271 if (m_TransferModule != null) 312 if (m_TransferModule != null)
272 m_TransferModule.SendInstantMessage(im, delegate(bool success) { 313 m_TransferModule.SendInstantMessage(im, delegate(bool success) {});
273
274 // justincc - FIXME: Comment out for now. This code was added in commit db91044 Mon Aug 22 2011
275 // and is apparently supposed to fix bulk inventory updates after accepting items. But
276 // instead it appears to cause two copies of an accepted folder for the receiving user in
277 // at least some cases. Folder/item update is already done when the offer is made (see code above)
278
279// // Send BulkUpdateInventory
280// IInventoryService invService = scene.InventoryService;
281// UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip
282//
283// InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId);
284// folder = invService.GetFolder(folder);
285//
286// ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID));
287//
288// // If the user has left the scene by the time the message comes back then we can't send
289// // them the update.
290// if (fromUser != null)
291// fromUser.ControllingClient.SendBulkUpdateInventory(folder);
292 });
293 } 314 }
294 } 315 }
295 316
@@ -402,6 +423,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
402 previousParentFolderID = folder.ParentID; 423 previousParentFolderID = folder.ParentID;
403 folder.ParentID = trashFolder.ID; 424 folder.ParentID = trashFolder.ID;
404 invService.MoveFolder(folder); 425 invService.MoveFolder(folder);
426 client.SendBulkUpdateInventory(folder);
405 } 427 }
406 } 428 }
407 429
@@ -453,6 +475,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
453 /// <param name="im"></param> 475 /// <param name="im"></param>
454 private void OnGridInstantMessage(GridInstantMessage im) 476 private void OnGridInstantMessage(GridInstantMessage im)
455 { 477 {
478<<<<<<< HEAD
456 // Check if it's a type of message that we should handle 479 // Check if it's a type of message that we should handle
457 if (!((im.dialog == (byte) InstantMessageDialog.InventoryOffered) 480 if (!((im.dialog == (byte) InstantMessageDialog.InventoryOffered)
458 || (im.dialog == (byte) InstantMessageDialog.TaskInventoryOffered) 481 || (im.dialog == (byte) InstantMessageDialog.TaskInventoryOffered)
@@ -465,6 +488,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
465 "[INVENTORY TRANSFER]: {0} IM type received from grid. From={1} ({2}), To={3}", 488 "[INVENTORY TRANSFER]: {0} IM type received from grid. From={1} ({2}), To={3}",
466 (InstantMessageDialog)im.dialog, im.fromAgentID, im.fromAgentName, im.toAgentID); 489 (InstantMessageDialog)im.dialog, im.fromAgentID, im.fromAgentName, im.toAgentID);
467 490
491=======
492>>>>>>> avn/ubitvar
468 // Check if this is ours to handle 493 // Check if this is ours to handle
469 // 494 //
470 Scene scene = FindClientScene(new UUID(im.toAgentID)); 495 Scene scene = FindClientScene(new UUID(im.toAgentID));
@@ -475,32 +500,100 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
475 // Find agent to deliver to 500 // Find agent to deliver to
476 // 501 //
477 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); 502 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
503 if (user == null)
504 return;
478 505
479 if (user != null) 506 // This requires a little bit of processing because we have to make the
507 // new item visible in the recipient's inventory here
508 //
509 if (im.dialog == (byte) InstantMessageDialog.InventoryOffered)
480 { 510 {
481 user.ControllingClient.SendInstantMessage(im); 511 if (im.binaryBucket.Length < 17) // Invalid
512 return;
513
514 UUID recipientID = new UUID(im.toAgentID);
482 515
483 if (im.dialog == (byte)InstantMessageDialog.InventoryOffered) 516 // First byte is the asset type
484 { 517 AssetType assetType = (AssetType)im.binaryBucket[0];
485 AssetType assetType = (AssetType)im.binaryBucket[0];
486 UUID inventoryID = new UUID(im.binaryBucket, 1);
487 518
488 IInventoryService invService = scene.InventoryService; 519 if (AssetType.Folder == assetType)
489 InventoryNodeBase node = null; 520 {
490 if (AssetType.Folder == assetType) 521 UUID folderID = new UUID(im.binaryBucket, 1);
522
523 InventoryFolderBase given =
524 new InventoryFolderBase(folderID, recipientID);
525 InventoryFolderBase folder =
526 scene.InventoryService.GetFolder(given);
527
528 if (folder != null)
529 user.ControllingClient.SendBulkUpdateInventory(folder);
530 }
531 else
532 {
533 UUID itemID = new UUID(im.binaryBucket, 1);
534
535 InventoryItemBase given =
536 new InventoryItemBase(itemID, recipientID);
537 InventoryItemBase item =
538 scene.InventoryService.GetItem(given);
539
540 if (item != null)
491 { 541 {
492 InventoryFolderBase folder = new InventoryFolderBase(inventoryID, new UUID(im.toAgentID)); 542 user.ControllingClient.SendBulkUpdateInventory(item);
493 node = invService.GetFolder(folder);
494 } 543 }
495 else 544 }
545 user.ControllingClient.SendInstantMessage(im);
546 }
547 if (im.dialog == (byte) InstantMessageDialog.TaskInventoryOffered)
548 {
549 if (im.binaryBucket.Length < 1) // Invalid
550 return;
551
552 UUID recipientID = new UUID(im.toAgentID);
553
554 // Bucket is the asset type
555 AssetType assetType = (AssetType)im.binaryBucket[0];
556
557 if (AssetType.Folder == assetType)
558 {
559 UUID folderID = new UUID(im.imSessionID);
560
561 InventoryFolderBase given =
562 new InventoryFolderBase(folderID, recipientID);
563 InventoryFolderBase folder =
564 scene.InventoryService.GetFolder(given);
565
566 if (folder != null)
567 user.ControllingClient.SendBulkUpdateInventory(folder);
568 }
569 else
570 {
571 UUID itemID = new UUID(im.imSessionID);
572
573 InventoryItemBase given =
574 new InventoryItemBase(itemID, recipientID);
575 InventoryItemBase item =
576 scene.InventoryService.GetItem(given);
577
578 if (item != null)
496 { 579 {
497 InventoryItemBase item = new InventoryItemBase(inventoryID, new UUID(im.toAgentID)); 580 user.ControllingClient.SendBulkUpdateInventory(item);
498 node = invService.GetItem(item);
499 } 581 }
500
501 if (node != null)
502 user.ControllingClient.SendBulkUpdateInventory(node);
503 } 582 }
583
584 // Fix up binary bucket since this may be 17 chars long here
585 Byte[] bucket = new Byte[1];
586 bucket[0] = im.binaryBucket[0];
587 im.binaryBucket = bucket;
588
589 user.ControllingClient.SendInstantMessage(im);
590 }
591 else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted ||
592 im.dialog == (byte) InstantMessageDialog.InventoryDeclined ||
593 im.dialog == (byte) InstantMessageDialog.TaskInventoryDeclined ||
594 im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted)
595 {
596 user.ControllingClient.SendInstantMessage(im);
504 } 597 }
505 } 598 }
506 } 599 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
index 465ffbc..c517a30 100644
--- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
@@ -163,16 +163,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
163 scene.RegionInfo.RegionHandle, 163 scene.RegionInfo.RegionHandle,
164 (uint)presence.AbsolutePosition.X, 164 (uint)presence.AbsolutePosition.X,
165 (uint)presence.AbsolutePosition.Y, 165 (uint)presence.AbsolutePosition.Y,
166 (uint)Math.Ceiling(presence.AbsolutePosition.Z)); 166 (uint)presence.AbsolutePosition.Z + 2);
167 167
168 m_log.DebugFormat("[LURE MODULE]: TP invite with message {0}, type {1}", message, lureType); 168 m_log.DebugFormat("[LURE MODULE]: TP invite with message {0}, type {1}", message, lureType);
169 169
170 GridInstantMessage m = new GridInstantMessage(scene, client.AgentId, 170 GridInstantMessage m;
171 client.FirstName+" "+client.LastName, targetid, 171
172 (byte)InstantMessageDialog.RequestTeleport, false, 172 if (scene.Permissions.IsAdministrator(client.AgentId) && presence.GodLevel >= 200 && (!scene.Permissions.IsAdministrator(targetid)))
173 message, dest, false, presence.AbsolutePosition, 173 {
174 new Byte[0], true); 174 m = new GridInstantMessage(scene, client.AgentId,
175 175 client.FirstName+" "+client.LastName, targetid,
176 (byte)InstantMessageDialog.GodLikeRequestTeleport, false,
177 message, dest, false, presence.AbsolutePosition,
178 new Byte[0], true);
179 }
180 else
181 {
182 m = new GridInstantMessage(scene, client.AgentId,
183 client.FirstName+" "+client.LastName, targetid,
184 (byte)InstantMessageDialog.RequestTeleport, false,
185 message, dest, false, presence.AbsolutePosition,
186 new Byte[0], true);
187 }
188
176 if (m_TransferModule != null) 189 if (m_TransferModule != null)
177 { 190 {
178 m_TransferModule.SendInstantMessage(m, 191 m_TransferModule.SendInstantMessage(m,
@@ -207,7 +220,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
207 { 220 {
208 // Forward remote teleport requests 221 // Forward remote teleport requests
209 // 222 //
210 if (msg.dialog != 22) 223 if (msg.dialog != (byte)InstantMessageDialog.RequestTeleport &&
224 msg.dialog != (byte)InstantMessageDialog.GodLikeRequestTeleport)
211 return; 225 return;
212 226
213 if (m_TransferModule != null) 227 if (m_TransferModule != null)
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
index c20369c..bea2834 100644
--- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
@@ -288,10 +288,6 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
288 // Notes 288 // Notes
289 client.AddGenericPacketHandler("avatarnotesrequest", NotesRequest); 289 client.AddGenericPacketHandler("avatarnotesrequest", NotesRequest);
290 client.OnAvatarNotesUpdate += NotesUpdate; 290 client.OnAvatarNotesUpdate += NotesUpdate;
291
292 // Preferences
293 client.OnUserInfoRequest += UserPreferencesRequest;
294 client.OnUpdateUserInfo += UpdateUserPreferences;
295 } 291 }
296 #endregion Region Event Handlers 292 #endregion Region Event Handlers
297 293
@@ -873,6 +869,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
873 } 869 }
874 #endregion Notes 870 #endregion Notes
875 871
872<<<<<<< HEAD
876 #region User Preferences 873 #region User Preferences
877 /// <summary> 874 /// <summary>
878 /// Updates the user preferences. 875 /// Updates the user preferences.
@@ -936,6 +933,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
936 } 933 }
937 #endregion User Preferences 934 #endregion User Preferences
938 935
936=======
937>>>>>>> avn/ubitvar
939 #region Avatar Properties 938 #region Avatar Properties
940 /// <summary> 939 /// <summary>
941 /// Update the avatars interests . 940 /// Update the avatars interests .
@@ -1402,5 +1401,185 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
1402 return null; 1401 return null;
1403 } 1402 }
1404 #endregion Util 1403 #endregion Util
1404<<<<<<< HEAD
1405=======
1406
1407 #region Web Util
1408 /// <summary>
1409 /// Sends json-rpc request with a serializable type.
1410 /// </summary>
1411 /// <returns>
1412 /// OSD Map.
1413 /// </returns>
1414 /// <param name='parameters'>
1415 /// Serializable type .
1416 /// </param>
1417 /// <param name='method'>
1418 /// Json-rpc method to call.
1419 /// </param>
1420 /// <param name='uri'>
1421 /// URI of json-rpc service.
1422 /// </param>
1423 /// <param name='jsonId'>
1424 /// Id for our call.
1425 /// </param>
1426 bool JsonRpcRequest(ref object parameters, string method, string uri, string jsonId)
1427 {
1428 if (jsonId == null)
1429 throw new ArgumentNullException ("jsonId");
1430 if (uri == null)
1431 throw new ArgumentNullException ("uri");
1432 if (method == null)
1433 throw new ArgumentNullException ("method");
1434 if (parameters == null)
1435 throw new ArgumentNullException ("parameters");
1436
1437 // Prep our payload
1438 OSDMap json = new OSDMap();
1439
1440 json.Add("jsonrpc", OSD.FromString("2.0"));
1441 json.Add("id", OSD.FromString(jsonId));
1442 json.Add("method", OSD.FromString(method));
1443
1444 json.Add("params", OSD.SerializeMembers(parameters));
1445
1446 string jsonRequestData = OSDParser.SerializeJsonString(json);
1447 byte[] content = Encoding.UTF8.GetBytes(jsonRequestData);
1448
1449 HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri);
1450
1451 webRequest.ContentType = "application/json-rpc";
1452 webRequest.Method = "POST";
1453
1454 Stream dataStream = webRequest.GetRequestStream();
1455 dataStream.Write(content, 0, content.Length);
1456 dataStream.Close();
1457
1458 WebResponse webResponse = null;
1459 try
1460 {
1461 webResponse = webRequest.GetResponse();
1462 }
1463 catch (WebException e)
1464 {
1465 Console.WriteLine("Web Error" + e.Message);
1466 Console.WriteLine ("Please check input");
1467 return false;
1468 }
1469
1470 OSDMap mret = new OSDMap();
1471
1472 using (Stream rstream = webResponse.GetResponseStream())
1473 {
1474 try
1475 {
1476 mret = (OSDMap)OSDParser.DeserializeJson(rstream);
1477 }
1478 catch (Exception e)
1479 {
1480 m_log.DebugFormat("[PROFILES]: JsonRpcRequest Error {0} - remote user with legacy profiles?", e.Message);
1481 if (webResponse != null)
1482 webResponse.Close();
1483 return false;
1484 }
1485 }
1486
1487 if (webResponse != null)
1488 webResponse.Close();
1489
1490 if (mret.ContainsKey("error"))
1491 return false;
1492
1493 // get params...
1494 OSD.DeserializeMembers(ref parameters, (OSDMap) mret["result"]);
1495 return true;
1496 }
1497
1498 /// <summary>
1499 /// Sends json-rpc request with OSD parameter.
1500 /// </summary>
1501 /// <returns>
1502 /// The rpc request.
1503 /// </returns>
1504 /// <param name='data'>
1505 /// data - incoming as parameters, outgong as result/error
1506 /// </param>
1507 /// <param name='method'>
1508 /// Json-rpc method to call.
1509 /// </param>
1510 /// <param name='uri'>
1511 /// URI of json-rpc service.
1512 /// </param>
1513 /// <param name='jsonId'>
1514 /// If set to <c>true</c> json identifier.
1515 /// </param>
1516 bool JsonRpcRequest(ref OSD data, string method, string uri, string jsonId)
1517 {
1518 OSDMap map = new OSDMap();
1519
1520 map["jsonrpc"] = "2.0";
1521 if(string.IsNullOrEmpty(jsonId))
1522 map["id"] = UUID.Random().ToString();
1523 else
1524 map["id"] = jsonId;
1525
1526 map["method"] = method;
1527 map["params"] = data;
1528
1529 string jsonRequestData = OSDParser.SerializeJsonString(map);
1530 byte[] content = Encoding.UTF8.GetBytes(jsonRequestData);
1531
1532 HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri);
1533 webRequest.ContentType = "application/json-rpc";
1534 webRequest.Method = "POST";
1535
1536 Stream dataStream = webRequest.GetRequestStream();
1537 dataStream.Write(content, 0, content.Length);
1538 dataStream.Close();
1539
1540 WebResponse webResponse = null;
1541 try
1542 {
1543 webResponse = webRequest.GetResponse();
1544 }
1545 catch (WebException e)
1546 {
1547 Console.WriteLine("Web Error" + e.Message);
1548 Console.WriteLine ("Please check input");
1549 return false;
1550 }
1551
1552 OSDMap response = new OSDMap();
1553
1554 using (Stream rstream = webResponse.GetResponseStream())
1555 {
1556 try
1557 {
1558 response = (OSDMap)OSDParser.DeserializeJson(rstream);
1559 }
1560 catch (Exception e)
1561 {
1562 m_log.DebugFormat("[PROFILES]: JsonRpcRequest Error {0} - remote user with legacy profiles?", e.Message);
1563 if (webResponse != null)
1564 webResponse.Close();
1565 return false;
1566 }
1567 }
1568
1569 if (webResponse != null)
1570 webResponse.Close();
1571
1572 if(response.ContainsKey("error"))
1573 {
1574 data = response["error"];
1575 return false;
1576 }
1577
1578 data = response;
1579
1580 return true;
1581 }
1582 #endregion Web Util
1583>>>>>>> avn/ubitvar
1405 } 1584 }
1406} 1585}