diff options
author | Sean McNamara | 2011-04-23 18:33:08 -0400 |
---|---|---|
committer | Sean McNamara | 2011-04-23 18:33:08 -0400 |
commit | d287e0ac683acb0cab51bf0dbbc9d1fd08bd6bc9 (patch) | |
tree | 30a24bf66050c66ebe74b68745c4f1764fe09181 /OpenSim/Region/CoreModules | |
parent | AutoBackup: Removed unneeded imports. (diff) | |
parent | Added MaxAgents configuration option to RegionConfig.ini allowing region host... (diff) | |
download | opensim-SC_OLD-d287e0ac683acb0cab51bf0dbbc9d1fd08bd6bc9.zip opensim-SC_OLD-d287e0ac683acb0cab51bf0dbbc9d1fd08bd6bc9.tar.gz opensim-SC_OLD-d287e0ac683acb0cab51bf0dbbc9d1fd08bd6bc9.tar.bz2 opensim-SC_OLD-d287e0ac683acb0cab51bf0dbbc9d1fd08bd6bc9.tar.xz |
Merge git://opensimulator.org/git/opensim
Diffstat (limited to 'OpenSim/Region/CoreModules')
35 files changed, 898 insertions, 440 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs index 878242a..fc1ddef 100644 --- a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs | |||
@@ -54,6 +54,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets | |||
54 | 54 | ||
55 | private Scene m_scene; | 55 | private Scene m_scene; |
56 | private IAssetService m_assetService; | 56 | private IAssetService m_assetService; |
57 | private bool m_enabled = true; | ||
57 | 58 | ||
58 | #region IRegionModuleBase Members | 59 | #region IRegionModuleBase Members |
59 | 60 | ||
@@ -65,7 +66,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets | |||
65 | 66 | ||
66 | public void Initialise(IConfigSource source) | 67 | public void Initialise(IConfigSource source) |
67 | { | 68 | { |
68 | 69 | IConfig meshConfig = source.Configs["Mesh"]; | |
70 | if (meshConfig == null) | ||
71 | return; | ||
72 | |||
73 | m_enabled = meshConfig.GetBoolean("AllowMeshUpload", true); | ||
69 | } | 74 | } |
70 | 75 | ||
71 | public void AddRegion(Scene pScene) | 76 | public void AddRegion(Scene pScene) |
@@ -101,16 +106,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets | |||
101 | 106 | ||
102 | public void RegisterCaps(UUID agentID, Caps caps) | 107 | public void RegisterCaps(UUID agentID, Caps caps) |
103 | { | 108 | { |
109 | if(!m_enabled) | ||
110 | return; | ||
111 | |||
104 | UUID capID = UUID.Random(); | 112 | UUID capID = UUID.Random(); |
105 | 113 | ||
106 | // m_log.Info("[GETMESH]: /CAPS/" + capID); | 114 | // m_log.Info("[GETMESH]: /CAPS/" + capID); |
115 | |||
107 | caps.RegisterHandler("GetMesh", | 116 | caps.RegisterHandler("GetMesh", |
108 | new RestHTTPHandler("GET", "/CAPS/" + capID, | 117 | new RestHTTPHandler("GET", "/CAPS/" + capID, |
109 | delegate(Hashtable m_dhttpMethod) | 118 | delegate(Hashtable m_dhttpMethod) |
110 | { | 119 | { |
111 | return ProcessGetMesh(m_dhttpMethod, agentID, caps); | 120 | return ProcessGetMesh(m_dhttpMethod, agentID, caps); |
112 | })); | 121 | })); |
113 | |||
114 | } | 122 | } |
115 | 123 | ||
116 | #endregion | 124 | #endregion |
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs index 4a42c93..3d4c7b7 100644 --- a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs | |||
@@ -56,6 +56,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets | |||
56 | private Scene m_scene; | 56 | private Scene m_scene; |
57 | // private IAssetService m_assetService; | 57 | // private IAssetService m_assetService; |
58 | private bool m_dumpAssetsToFile = false; | 58 | private bool m_dumpAssetsToFile = false; |
59 | private bool m_enabled = true; | ||
59 | 60 | ||
60 | #region IRegionModuleBase Members | 61 | #region IRegionModuleBase Members |
61 | 62 | ||
@@ -67,7 +68,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets | |||
67 | 68 | ||
68 | public void Initialise(IConfigSource source) | 69 | public void Initialise(IConfigSource source) |
69 | { | 70 | { |
70 | 71 | IConfig meshConfig = source.Configs["Mesh"]; | |
72 | if (meshConfig == null) | ||
73 | return; | ||
74 | |||
75 | m_enabled = meshConfig.GetBoolean("AllowMeshUpload", true); | ||
71 | } | 76 | } |
72 | 77 | ||
73 | public void AddRegion(Scene pScene) | 78 | public void AddRegion(Scene pScene) |
@@ -103,6 +108,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets | |||
103 | 108 | ||
104 | public void RegisterCaps(UUID agentID, Caps caps) | 109 | public void RegisterCaps(UUID agentID, Caps caps) |
105 | { | 110 | { |
111 | if(!m_enabled) | ||
112 | return; | ||
113 | |||
106 | UUID capID = UUID.Random(); | 114 | UUID capID = UUID.Random(); |
107 | 115 | ||
108 | // m_log.Debug("[NEW FILE AGENT INVENTORY VARIABLE PRICE]: /CAPS/" + capID); | 116 | // m_log.Debug("[NEW FILE AGENT INVENTORY VARIABLE PRICE]: /CAPS/" + capID); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 4d74b2a..5baf078 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -34,13 +34,13 @@ using Nini.Config; | |||
34 | using Nwc.XmlRpc; | 34 | using Nwc.XmlRpc; |
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
38 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
40 | using OpenSim.Services.Interfaces; | 41 | using OpenSim.Services.Interfaces; |
41 | using OpenSim.Services.Connectors.Friends; | 42 | using OpenSim.Services.Connectors.Friends; |
42 | using OpenSim.Server.Base; | 43 | using OpenSim.Server.Base; |
43 | using OpenSim.Framework.Servers.HttpServer; | ||
44 | using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; | 44 | using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; |
45 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | 45 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; |
46 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 46 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index fdfcd10..919ea33 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | |||
@@ -33,7 +33,6 @@ using OpenMetaverse; | |||
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using OpenSim.Framework.Client; | 36 | using OpenSim.Framework.Client; |
38 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 01170aa..6b24718 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -78,11 +78,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
78 | private Stream m_loadStream; | 78 | private Stream m_loadStream; |
79 | 79 | ||
80 | /// <summary> | 80 | /// <summary> |
81 | /// FIXME: Do not perform this check since older versions of OpenSim do save the control file after other things | 81 | /// Has the control file been loaded for this archive? |
82 | /// (I thought they weren't). We will need to bump the version number and perform this check on all | ||
83 | /// subsequent IAR versions only | ||
84 | /// </summary> | 82 | /// </summary> |
85 | protected bool m_controlFileLoaded = true; | 83 | public bool ControlFileLoaded { get; private set; } |
84 | |||
85 | /// <summary> | ||
86 | /// Do we want to enforce the check. IAR versions before 0.2 and 1.1 do not guarantee this order, so we can't | ||
87 | /// enforce. | ||
88 | /// </summary> | ||
89 | public bool EnforceControlFileCheck { get; private set; } | ||
90 | |||
86 | protected bool m_assetsLoaded; | 91 | protected bool m_assetsLoaded; |
87 | protected bool m_inventoryNodesLoaded; | 92 | protected bool m_inventoryNodesLoaded; |
88 | 93 | ||
@@ -131,6 +136,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
131 | m_userInfo = userInfo; | 136 | m_userInfo = userInfo; |
132 | m_invPath = invPath; | 137 | m_invPath = invPath; |
133 | m_loadStream = loadStream; | 138 | m_loadStream = loadStream; |
139 | |||
140 | // FIXME: Do not perform this check since older versions of OpenSim do save the control file after other things | ||
141 | // (I thought they weren't). We will need to bump the version number and perform this check on all | ||
142 | // subsequent IAR versions only | ||
143 | ControlFileLoaded = true; | ||
134 | } | 144 | } |
135 | 145 | ||
136 | /// <summary> | 146 | /// <summary> |
@@ -471,16 +481,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
471 | if (m_creatorIdForAssetId.ContainsKey(assetId)) | 481 | if (m_creatorIdForAssetId.ContainsKey(assetId)) |
472 | { | 482 | { |
473 | string xmlData = Utils.BytesToString(data); | 483 | string xmlData = Utils.BytesToString(data); |
474 | SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | 484 | List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); |
475 | foreach (SceneObjectPart sop in sog.Parts) | 485 | |
486 | CoalescedSceneObjects coa = null; | ||
487 | if (CoalescedSceneObjectsSerializer.TryFromXml(xmlData, out coa)) | ||
488 | { | ||
489 | // m_log.DebugFormat( | ||
490 | // "[INVENTORY ARCHIVER]: Loaded coalescence {0} has {1} objects", assetId, coa.Count); | ||
491 | |||
492 | sceneObjects.AddRange(coa.Objects); | ||
493 | } | ||
494 | else | ||
476 | { | 495 | { |
477 | if (sop.CreatorData == null || sop.CreatorData == "") | 496 | sceneObjects.Add(SceneObjectSerializer.FromOriginalXmlFormat(xmlData)); |
478 | { | ||
479 | sop.CreatorID = m_creatorIdForAssetId[assetId]; | ||
480 | } | ||
481 | } | 497 | } |
482 | 498 | ||
483 | data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)); | 499 | foreach (SceneObjectGroup sog in sceneObjects) |
500 | foreach (SceneObjectPart sop in sog.Parts) | ||
501 | if (sop.CreatorData == null || sop.CreatorData == "") | ||
502 | sop.CreatorID = m_creatorIdForAssetId[assetId]; | ||
503 | |||
504 | if (coa != null) | ||
505 | data = Utils.StringToBytes(CoalescedSceneObjectsSerializer.ToXml(coa)); | ||
506 | else | ||
507 | data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sceneObjects[0])); | ||
484 | } | 508 | } |
485 | } | 509 | } |
486 | 510 | ||
@@ -508,7 +532,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
508 | /// </summary> | 532 | /// </summary> |
509 | /// <param name="path"></param> | 533 | /// <param name="path"></param> |
510 | /// <param name="data"></param> | 534 | /// <param name="data"></param> |
511 | protected void LoadControlFile(string path, byte[] data) | 535 | public void LoadControlFile(string path, byte[] data) |
512 | { | 536 | { |
513 | XDocument doc = XDocument.Parse(Encoding.ASCII.GetString(data)); | 537 | XDocument doc = XDocument.Parse(Encoding.ASCII.GetString(data)); |
514 | XElement archiveElement = doc.Element("archive"); | 538 | XElement archiveElement = doc.Element("archive"); |
@@ -524,7 +548,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
524 | majorVersion, MAX_MAJOR_VERSION)); | 548 | majorVersion, MAX_MAJOR_VERSION)); |
525 | } | 549 | } |
526 | 550 | ||
527 | m_controlFileLoaded = true; | 551 | ControlFileLoaded = true; |
528 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); | 552 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); |
529 | } | 553 | } |
530 | 554 | ||
@@ -536,7 +560,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
536 | /// <param name="data"></param> | 560 | /// <param name="data"></param> |
537 | protected void LoadInventoryFile(string path, TarArchiveReader.TarEntryType entryType, byte[] data) | 561 | protected void LoadInventoryFile(string path, TarArchiveReader.TarEntryType entryType, byte[] data) |
538 | { | 562 | { |
539 | if (!m_controlFileLoaded) | 563 | if (!ControlFileLoaded) |
540 | throw new Exception( | 564 | throw new Exception( |
541 | string.Format( | 565 | string.Format( |
542 | "The IAR you are trying to load does not list {0} before {1}. Aborting load", | 566 | "The IAR you are trying to load does not list {0} before {1}. Aborting load", |
@@ -583,7 +607,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
583 | /// <param name="data"></param> | 607 | /// <param name="data"></param> |
584 | protected void LoadAssetFile(string path, byte[] data) | 608 | protected void LoadAssetFile(string path, byte[] data) |
585 | { | 609 | { |
586 | if (!m_controlFileLoaded) | 610 | if (!ControlFileLoaded) |
587 | throw new Exception( | 611 | throw new Exception( |
588 | string.Format( | 612 | string.Format( |
589 | "The IAR you are trying to load does not list {0} before {1}. Aborting load", | 613 | "The IAR you are trying to load does not list {0} before {1}. Aborting load", |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index dc4900f..c039b5a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -394,12 +394,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
394 | if (options.ContainsKey("profile")) | 394 | if (options.ContainsKey("profile")) |
395 | { | 395 | { |
396 | majorVersion = 1; | 396 | majorVersion = 1; |
397 | minorVersion = 0; | 397 | minorVersion = 1; |
398 | } | 398 | } |
399 | else | 399 | else |
400 | { | 400 | { |
401 | majorVersion = 0; | 401 | majorVersion = 0; |
402 | minorVersion = 1; | 402 | minorVersion = 2; |
403 | } | 403 | } |
404 | 404 | ||
405 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Creating version {0}.{1} IAR", majorVersion, minorVersion); | 405 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Creating version {0}.{1} IAR", majorVersion, minorVersion); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs index e5127a0..5ba08ee 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs | |||
@@ -68,17 +68,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
68 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"), | 68 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"), |
69 | FirstName = "Mr", | 69 | FirstName = "Mr", |
70 | LastName = "Tiddles" }; | 70 | LastName = "Tiddles" }; |
71 | |||
71 | protected UserAccount m_uaLL1 | 72 | protected UserAccount m_uaLL1 |
72 | = new UserAccount { | 73 | = new UserAccount { |
73 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"), | 74 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"), |
74 | FirstName = "Lord", | 75 | FirstName = "Lord", |
75 | LastName = "Lucan" }; | 76 | LastName = "Lucan" }; |
77 | |||
76 | protected UserAccount m_uaLL2 | 78 | protected UserAccount m_uaLL2 |
77 | = new UserAccount { | 79 | = new UserAccount { |
78 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000777"), | 80 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000777"), |
79 | FirstName = "Lord", | 81 | FirstName = "Lord", |
80 | LastName = "Lucan" }; | 82 | LastName = "Lucan" }; |
83 | |||
81 | protected string m_item1Name = "Ray Gun Item"; | 84 | protected string m_item1Name = "Ray Gun Item"; |
85 | protected string m_coaItemName = "Coalesced Item"; | ||
82 | 86 | ||
83 | [SetUp] | 87 | [SetUp] |
84 | public virtual void SetUp() | 88 | public virtual void SetUp() |
@@ -97,38 +101,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
97 | // log4net.Config.XmlConfigurator.Configure(); | 101 | // log4net.Config.XmlConfigurator.Configure(); |
98 | 102 | ||
99 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 103 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
100 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | 104 | Scene scene = SceneSetupHelpers.SetupScene(); |
101 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | 105 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); |
102 | 106 | ||
103 | UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); | 107 | UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); |
104 | 108 | ||
105 | MemoryStream archiveWriteStream = new MemoryStream(); | 109 | MemoryStream archiveWriteStream = new MemoryStream(); |
106 | 110 | ||
107 | // Create asset | 111 | // Create scene object asset |
108 | SceneObjectGroup object1; | 112 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); |
109 | SceneObjectPart part1; | 113 | SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "Ray Gun Object", 0x50); |
110 | { | ||
111 | string partName = "Ray Gun Object"; | ||
112 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
113 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
114 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
115 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
116 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
117 | |||
118 | part1 | ||
119 | = new SceneObjectPart( | ||
120 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
121 | part1.Name = partName; | ||
122 | |||
123 | object1 = new SceneObjectGroup(part1); | ||
124 | scene.AddNewSceneObject(object1, false); | ||
125 | } | ||
126 | 114 | ||
127 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | 115 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
128 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | 116 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); |
129 | scene.AssetService.Store(asset1); | 117 | scene.AssetService.Store(asset1); |
130 | 118 | ||
131 | // Create item | 119 | // Create scene object item |
132 | InventoryItemBase item1 = new InventoryItemBase(); | 120 | InventoryItemBase item1 = new InventoryItemBase(); |
133 | item1.Name = m_item1Name; | 121 | item1.Name = m_item1Name; |
134 | item1.ID = UUID.Parse("00000000-0000-0000-0000-000000000020"); | 122 | item1.ID = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
@@ -139,8 +127,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
139 | item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID; | 127 | item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID; |
140 | scene.AddInventoryItem(item1); | 128 | scene.AddInventoryItem(item1); |
141 | 129 | ||
130 | // Create coalesced objects asset | ||
131 | SceneObjectGroup cobj1 = SceneSetupHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object1", 0x120); | ||
132 | cobj1.AbsolutePosition = new Vector3(15, 30, 45); | ||
133 | |||
134 | SceneObjectGroup cobj2 = SceneSetupHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object2", 0x140); | ||
135 | cobj2.AbsolutePosition = new Vector3(25, 50, 75); | ||
136 | |||
137 | CoalescedSceneObjects coa = new CoalescedSceneObjects(m_uaLL1.PrincipalID, cobj1, cobj2); | ||
138 | |||
139 | AssetBase coaAsset = AssetHelpers.CreateAsset(0x160, coa); | ||
140 | scene.AssetService.Store(coaAsset); | ||
141 | |||
142 | // Create coalesced objects inventory item | ||
143 | InventoryItemBase coaItem = new InventoryItemBase(); | ||
144 | coaItem.Name = m_coaItemName; | ||
145 | coaItem.ID = UUID.Parse("00000000-0000-0000-0000-000000000180"); | ||
146 | coaItem.AssetID = coaAsset.FullID; | ||
147 | coaItem.GroupID = UUID.Random(); | ||
148 | coaItem.CreatorIdAsUuid = m_uaLL1.PrincipalID; | ||
149 | coaItem.Owner = m_uaLL1.PrincipalID; | ||
150 | coaItem.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID; | ||
151 | scene.AddInventoryItem(coaItem); | ||
152 | |||
142 | archiverModule.ArchiveInventory( | 153 | archiverModule.ArchiveInventory( |
143 | Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, m_item1Name, "hampshire", archiveWriteStream); | 154 | Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, "/*", "hampshire", archiveWriteStream); |
144 | 155 | ||
145 | m_iarStreamBytes = archiveWriteStream.ToArray(); | 156 | m_iarStreamBytes = archiveWriteStream.ToArray(); |
146 | } | 157 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 7f156f8..52232a0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -62,9 +62,66 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
62 | SerialiserModule serialiserModule = new SerialiserModule(); | 62 | SerialiserModule serialiserModule = new SerialiserModule(); |
63 | m_archiverModule = new InventoryArchiverModule(); | 63 | m_archiverModule = new InventoryArchiverModule(); |
64 | 64 | ||
65 | m_scene = SceneSetupHelpers.SetupScene("Inventory"); | 65 | m_scene = SceneSetupHelpers.SetupScene(); |
66 | SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); | 66 | SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); |
67 | } | 67 | } |
68 | |||
69 | [Test] | ||
70 | public void TestLoadCoalesecedItem() | ||
71 | { | ||
72 | TestHelper.InMethod(); | ||
73 | // log4net.Config.XmlConfigurator.Configure(); | ||
74 | |||
75 | UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL1, "password"); | ||
76 | m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "password", m_iarStream); | ||
77 | |||
78 | InventoryItemBase coaItem | ||
79 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_coaItemName); | ||
80 | |||
81 | Assert.That(coaItem, Is.Not.Null, "Didn't find loaded item 1"); | ||
82 | |||
83 | string assetXml = AssetHelpers.ReadAssetAsString(m_scene.AssetService, coaItem.AssetID); | ||
84 | |||
85 | CoalescedSceneObjects coa; | ||
86 | bool readResult = CoalescedSceneObjectsSerializer.TryFromXml(assetXml, out coa); | ||
87 | |||
88 | Assert.That(readResult, Is.True); | ||
89 | Assert.That(coa.Count, Is.EqualTo(2)); | ||
90 | |||
91 | List<SceneObjectGroup> coaObjects = coa.Objects; | ||
92 | Assert.That(coaObjects[0].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000120"))); | ||
93 | Assert.That(coaObjects[0].AbsolutePosition, Is.EqualTo(new Vector3(15, 30, 45))); | ||
94 | |||
95 | Assert.That(coaObjects[1].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000140"))); | ||
96 | Assert.That(coaObjects[1].AbsolutePosition, Is.EqualTo(new Vector3(25, 50, 75))); | ||
97 | } | ||
98 | |||
99 | /// <summary> | ||
100 | /// Test that the IAR has the required files in the right order. | ||
101 | /// </summary> | ||
102 | /// <remarks> | ||
103 | /// At the moment, the only thing that matters is that the control file is the very first one. | ||
104 | /// </remarks> | ||
105 | [Test] | ||
106 | public void TestOrder() | ||
107 | { | ||
108 | TestHelper.InMethod(); | ||
109 | // log4net.Config.XmlConfigurator.Configure(); | ||
110 | |||
111 | MemoryStream archiveReadStream = new MemoryStream(m_iarStreamBytes); | ||
112 | TarArchiveReader tar = new TarArchiveReader(archiveReadStream); | ||
113 | string filePath; | ||
114 | TarArchiveReader.TarEntryType tarEntryType; | ||
115 | |||
116 | byte[] data = tar.ReadEntry(out filePath, out tarEntryType); | ||
117 | Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); | ||
118 | |||
119 | InventoryArchiveReadRequest iarr | ||
120 | = new InventoryArchiveReadRequest(null, null, null, (Stream)null, false); | ||
121 | iarr.LoadControlFile(filePath, data); | ||
122 | |||
123 | Assert.That(iarr.ControlFileLoaded, Is.True); | ||
124 | } | ||
68 | 125 | ||
69 | /// <summary> | 126 | /// <summary> |
70 | /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive | 127 | /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive |
@@ -84,24 +141,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
84 | UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword); | 141 | UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword); |
85 | 142 | ||
86 | // Create asset | 143 | // Create asset |
87 | SceneObjectGroup object1; | 144 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); |
88 | SceneObjectPart part1; | 145 | SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50); |
89 | { | ||
90 | string partName = "My Little Dog Object"; | ||
91 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
92 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
93 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
94 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
95 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
96 | |||
97 | part1 | ||
98 | = new SceneObjectPart( | ||
99 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
100 | part1.Name = partName; | ||
101 | |||
102 | object1 = new SceneObjectGroup(part1); | ||
103 | m_scene.AddNewSceneObject(object1, false); | ||
104 | } | ||
105 | 146 | ||
106 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | 147 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
107 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | 148 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs index 0e8f647..c7dae52 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs | |||
@@ -63,7 +63,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
63 | 63 | ||
64 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 64 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
65 | 65 | ||
66 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | 66 | Scene scene = SceneSetupHelpers.SetupScene(); |
67 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | 67 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); |
68 | 68 | ||
69 | // Create user | 69 | // Create user |
@@ -180,7 +180,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
180 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 180 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
181 | 181 | ||
182 | // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene | 182 | // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene |
183 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | 183 | Scene scene = SceneSetupHelpers.SetupScene(); |
184 | 184 | ||
185 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | 185 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); |
186 | 186 | ||
@@ -223,7 +223,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
223 | 223 | ||
224 | SerialiserModule serialiserModule = new SerialiserModule(); | 224 | SerialiserModule serialiserModule = new SerialiserModule(); |
225 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 225 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
226 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | 226 | Scene scene = SceneSetupHelpers.SetupScene(); |
227 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | 227 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); |
228 | 228 | ||
229 | UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "password"); | 229 | UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "password"); |
@@ -248,7 +248,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
248 | 248 | ||
249 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 249 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
250 | 250 | ||
251 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | 251 | Scene scene = SceneSetupHelpers.SetupScene(); |
252 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | 252 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); |
253 | 253 | ||
254 | // Create user | 254 | // Create user |
@@ -327,7 +327,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
327 | TestHelper.InMethod(); | 327 | TestHelper.InMethod(); |
328 | // log4net.Config.XmlConfigurator.Configure(); | 328 | // log4net.Config.XmlConfigurator.Configure(); |
329 | 329 | ||
330 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | 330 | Scene scene = SceneSetupHelpers.SetupScene(); |
331 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); | 331 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); |
332 | 332 | ||
333 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); | 333 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); |
@@ -394,7 +394,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
394 | TestHelper.InMethod(); | 394 | TestHelper.InMethod(); |
395 | //log4net.Config.XmlConfigurator.Configure(); | 395 | //log4net.Config.XmlConfigurator.Configure(); |
396 | 396 | ||
397 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | 397 | Scene scene = SceneSetupHelpers.SetupScene(); |
398 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); | 398 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); |
399 | 399 | ||
400 | string folder1ExistingName = "a"; | 400 | string folder1ExistingName = "a"; |
@@ -445,7 +445,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
445 | TestHelper.InMethod(); | 445 | TestHelper.InMethod(); |
446 | // log4net.Config.XmlConfigurator.Configure(); | 446 | // log4net.Config.XmlConfigurator.Configure(); |
447 | 447 | ||
448 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | 448 | Scene scene = SceneSetupHelpers.SetupScene(); |
449 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); | 449 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); |
450 | 450 | ||
451 | string folder1ExistingName = "a"; | 451 | string folder1ExistingName = "a"; |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index 4565d10..52791cb 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | |||
@@ -75,6 +75,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
75 | if (name == Name) | 75 | if (name == Name) |
76 | { | 76 | { |
77 | m_Enabled = true; | 77 | m_Enabled = true; |
78 | |||
79 | InitialiseCommon(source); | ||
80 | |||
78 | m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name); | 81 | m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name); |
79 | 82 | ||
80 | IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"]; | 83 | IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"]; |
@@ -129,35 +132,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
129 | } | 132 | } |
130 | 133 | ||
131 | /// | 134 | /// |
132 | /// DeleteToInventory | 135 | /// Used in DeleteToInventory |
133 | /// | 136 | /// |
134 | public override UUID DeleteToInventory(DeRezAction action, UUID folderID, List<SceneObjectGroup> objectGroups, IClientAPI remoteClient) | 137 | protected override void ExportAsset(UUID agentID, UUID assetID) |
135 | { | 138 | { |
136 | UUID ret = UUID.Zero; | ||
137 | |||
138 | // HACK: Only works for lists of length one. | ||
139 | // Intermediate version, just to make things compile | ||
140 | foreach (SceneObjectGroup g in objectGroups) | ||
141 | ret = DeleteToInventory(action, folderID, g, remoteClient); | ||
142 | |||
143 | return ret; | ||
144 | } | ||
145 | |||
146 | // DO NOT OVERRIDE THE BASE METHOD | ||
147 | public new virtual UUID DeleteToInventory(DeRezAction action, UUID folderID, | ||
148 | SceneObjectGroup objectGroup, IClientAPI remoteClient) | ||
149 | { | ||
150 | UUID assetID = base.DeleteToInventory(action, folderID, new List<SceneObjectGroup>() {objectGroup}, remoteClient); | ||
151 | |||
152 | if (!assetID.Equals(UUID.Zero)) | 139 | if (!assetID.Equals(UUID.Zero)) |
153 | { | 140 | UploadInventoryItem(agentID, assetID, "", 0); |
154 | if (remoteClient != null) | ||
155 | UploadInventoryItem(remoteClient.AgentId, assetID, "", 0); | ||
156 | } | ||
157 | else | 141 | else |
158 | m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); | 142 | m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); |
159 | |||
160 | return assetID; | ||
161 | } | 143 | } |
162 | 144 | ||
163 | /// | 145 | /// |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 9fbfc34..6b3df9d 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -64,7 +64,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
64 | return m_UserManagement; | 64 | return m_UserManagement; |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | public bool CoalesceMultipleObjectsToInventory { get; set; } | ||
68 | 69 | ||
69 | #region INonSharedRegionModule | 70 | #region INonSharedRegionModule |
70 | 71 | ||
@@ -87,10 +88,28 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
87 | if (name == Name) | 88 | if (name == Name) |
88 | { | 89 | { |
89 | m_Enabled = true; | 90 | m_Enabled = true; |
90 | m_log.InfoFormat("[INVENTORY ACCESS MODULE]: {0} enabled.", Name); | 91 | |
92 | InitialiseCommon(source); | ||
93 | |||
94 | m_log.InfoFormat("[INVENTORY ACCESS MODULE]: {0} enabled.", Name); | ||
91 | } | 95 | } |
92 | } | 96 | } |
93 | } | 97 | } |
98 | |||
99 | /// <summary> | ||
100 | /// Common module config for both this and descendant classes. | ||
101 | /// </summary> | ||
102 | /// <param name="source"></param> | ||
103 | protected virtual void InitialiseCommon(IConfigSource source) | ||
104 | { | ||
105 | IConfig inventoryConfig = source.Configs["Inventory"]; | ||
106 | |||
107 | if (inventoryConfig != null) | ||
108 | CoalesceMultipleObjectsToInventory | ||
109 | = inventoryConfig.GetBoolean("CoalesceMultipleObjectsToInventory", true); | ||
110 | else | ||
111 | CoalesceMultipleObjectsToInventory = true; | ||
112 | } | ||
94 | 113 | ||
95 | public virtual void PostInitialise() | 114 | public virtual void PostInitialise() |
96 | { | 115 | { |
@@ -194,366 +213,386 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
194 | 213 | ||
195 | return UUID.Zero; | 214 | return UUID.Zero; |
196 | } | 215 | } |
197 | 216 | ||
198 | /// <summary> | 217 | public virtual UUID CopyToInventory(DeRezAction action, UUID folderID, |
199 | /// Delete a scene object from a scene and place in the given avatar's inventory. | ||
200 | /// Returns the UUID of the newly created asset. | ||
201 | /// </summary> | ||
202 | /// <param name="action"></param> | ||
203 | /// <param name="folderID"></param> | ||
204 | /// <param name="objectGroup"></param> | ||
205 | /// <param name="remoteClient"> </param> | ||
206 | public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID, | ||
207 | List<SceneObjectGroup> objectGroups, IClientAPI remoteClient) | 218 | List<SceneObjectGroup> objectGroups, IClientAPI remoteClient) |
208 | { | 219 | { |
209 | UUID ret = UUID.Zero; | 220 | Dictionary<UUID, List<SceneObjectGroup>> bundlesToCopy = new Dictionary<UUID, List<SceneObjectGroup>>(); |
210 | 221 | ||
211 | // The following code groups the SOG's by owner. No objects | 222 | if (CoalesceMultipleObjectsToInventory) |
212 | // belonging to different people can be coalesced, for obvious | ||
213 | // reasons. | ||
214 | Dictionary<UUID, List<SceneObjectGroup>> deletes = | ||
215 | new Dictionary<UUID, List<SceneObjectGroup>>(); | ||
216 | |||
217 | foreach (SceneObjectGroup g in objectGroups) | ||
218 | { | 223 | { |
219 | if (!deletes.ContainsKey(g.OwnerID)) | 224 | // The following code groups the SOG's by owner. No objects |
220 | deletes[g.OwnerID] = new List<SceneObjectGroup>(); | 225 | // belonging to different people can be coalesced, for obvious |
221 | 226 | // reasons. | |
222 | deletes[g.OwnerID].Add(g); | 227 | foreach (SceneObjectGroup g in objectGroups) |
228 | { | ||
229 | if (!bundlesToCopy.ContainsKey(g.OwnerID)) | ||
230 | bundlesToCopy[g.OwnerID] = new List<SceneObjectGroup>(); | ||
231 | |||
232 | bundlesToCopy[g.OwnerID].Add(g); | ||
233 | } | ||
234 | } | ||
235 | else | ||
236 | { | ||
237 | // If we don't want to coalesce then put every object in its own bundle. | ||
238 | foreach (SceneObjectGroup g in objectGroups) | ||
239 | { | ||
240 | List<SceneObjectGroup> bundle = new List<SceneObjectGroup>(); | ||
241 | bundle.Add(g); | ||
242 | bundlesToCopy[g.UUID] = bundle; | ||
243 | } | ||
223 | } | 244 | } |
224 | 245 | ||
225 | // This is pethod scoped and will be returned. It will be the | 246 | // This is method scoped and will be returned. It will be the |
226 | // last created asset id | 247 | // last created asset id |
227 | UUID assetID = UUID.Zero; | 248 | UUID assetID = UUID.Zero; |
228 | 249 | ||
229 | // Each iteration is really a separate asset being created, | 250 | // Each iteration is really a separate asset being created, |
230 | // with distinct destinations as well. | 251 | // with distinct destinations as well. |
231 | foreach (List<SceneObjectGroup> objlist in deletes.Values) | 252 | foreach (List<SceneObjectGroup> bundle in bundlesToCopy.Values) |
232 | { | 253 | assetID = CopyBundleToInventory(action, folderID, bundle, remoteClient); |
233 | Dictionary<UUID, string> xmlStrings = | 254 | |
234 | new Dictionary<UUID, string>(); | 255 | return assetID; |
235 | 256 | } | |
236 | foreach (SceneObjectGroup objectGroup in objlist) | 257 | |
237 | { | 258 | /// <summary> |
238 | Vector3 inventoryStoredPosition = new Vector3 | 259 | /// Copy a bundle of objects to inventory. If there is only one object, then this will create an object |
239 | (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) | 260 | /// item. If there are multiple objects then these will be saved as a single coalesced item. |
240 | ? 250 | 261 | /// </summary> |
241 | : objectGroup.AbsolutePosition.X) | 262 | /// <param name="action"></param> |
242 | , | 263 | /// <param name="folderID"></param> |
243 | (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) | 264 | /// <param name="objlist"></param> |
244 | ? 250 | 265 | /// <param name="remoteClient"></param> |
245 | : objectGroup.AbsolutePosition.X, | 266 | /// <returns></returns> |
246 | objectGroup.AbsolutePosition.Z); | 267 | protected UUID CopyBundleToInventory( |
247 | 268 | DeRezAction action, UUID folderID, List<SceneObjectGroup> objlist, IClientAPI remoteClient) | |
248 | Vector3 originalPosition = objectGroup.AbsolutePosition; | 269 | { |
249 | 270 | UUID assetID = UUID.Zero; | |
250 | objectGroup.AbsolutePosition = inventoryStoredPosition; | 271 | |
251 | 272 | CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero); | |
252 | // Make sure all bits but the ones we want are clear | 273 | Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>(); |
253 | // on take. | ||
254 | // This will be applied to the current perms, so | ||
255 | // it will do what we want. | ||
256 | objectGroup.RootPart.NextOwnerMask &= | ||
257 | ((uint)PermissionMask.Copy | | ||
258 | (uint)PermissionMask.Transfer | | ||
259 | (uint)PermissionMask.Modify); | ||
260 | objectGroup.RootPart.NextOwnerMask |= | ||
261 | (uint)PermissionMask.Move; | ||
262 | |||
263 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); | ||
264 | |||
265 | objectGroup.AbsolutePosition = originalPosition; | ||
266 | |||
267 | xmlStrings[objectGroup.UUID] = sceneObjectXml; | ||
268 | } | ||
269 | 274 | ||
270 | string itemXml; | 275 | foreach (SceneObjectGroup objectGroup in objlist) |
276 | { | ||
277 | Vector3 inventoryStoredPosition = new Vector3 | ||
278 | (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) | ||
279 | ? 250 | ||
280 | : objectGroup.AbsolutePosition.X) | ||
281 | , | ||
282 | (objectGroup.AbsolutePosition.Y > (int)Constants.RegionSize) | ||
283 | ? 250 | ||
284 | : objectGroup.AbsolutePosition.Y, | ||
285 | objectGroup.AbsolutePosition.Z); | ||
286 | |||
287 | originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition; | ||
288 | |||
289 | objectGroup.AbsolutePosition = inventoryStoredPosition; | ||
290 | |||
291 | // Make sure all bits but the ones we want are clear | ||
292 | // on take. | ||
293 | // This will be applied to the current perms, so | ||
294 | // it will do what we want. | ||
295 | objectGroup.RootPart.NextOwnerMask &= | ||
296 | ((uint)PermissionMask.Copy | | ||
297 | (uint)PermissionMask.Transfer | | ||
298 | (uint)PermissionMask.Modify); | ||
299 | objectGroup.RootPart.NextOwnerMask |= | ||
300 | (uint)PermissionMask.Move; | ||
301 | |||
302 | coa.Add(objectGroup); | ||
303 | } | ||
271 | 304 | ||
272 | if (objlist.Count > 1) | 305 | string itemXml; |
273 | { | ||
274 | float minX, minY, minZ; | ||
275 | float maxX, maxY, maxZ; | ||
276 | 306 | ||
277 | Vector3[] offsets = m_Scene.GetCombinedBoundingBox(objlist, | 307 | if (objlist.Count > 1) |
278 | out minX, out maxX, out minY, out maxY, | 308 | itemXml = CoalescedSceneObjectsSerializer.ToXml(coa); |
279 | out minZ, out maxZ); | 309 | else |
310 | itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0]); | ||
311 | |||
312 | // Restore the position of each group now that it has been stored to inventory. | ||
313 | foreach (SceneObjectGroup objectGroup in objlist) | ||
314 | objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID]; | ||
280 | 315 | ||
281 | // CreateWrapper | 316 | InventoryItemBase item = CreateItemForObject(action, remoteClient, objlist[0], folderID); |
282 | XmlDocument itemDoc = new XmlDocument(); | 317 | if (item == null) |
283 | XmlElement root = itemDoc.CreateElement("", "CoalescedObject", ""); | 318 | return UUID.Zero; |
284 | itemDoc.AppendChild(root); | 319 | |
320 | // Can't know creator is the same, so null it in inventory | ||
321 | if (objlist.Count > 1) | ||
322 | { | ||
323 | item.CreatorId = UUID.Zero.ToString(); | ||
324 | item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems; | ||
325 | } | ||
326 | else | ||
327 | { | ||
328 | item.CreatorId = objlist[0].RootPart.CreatorID.ToString(); | ||
329 | item.SaleType = objlist[0].RootPart.ObjectSaleType; | ||
330 | item.SalePrice = objlist[0].RootPart.SalePrice; | ||
331 | } | ||
332 | |||
333 | AssetBase asset = CreateAsset( | ||
334 | objlist[0].GetPartName(objlist[0].RootPart.LocalId), | ||
335 | objlist[0].GetPartDescription(objlist[0].RootPart.LocalId), | ||
336 | (sbyte)AssetType.Object, | ||
337 | Utils.StringToBytes(itemXml), | ||
338 | objlist[0].OwnerID.ToString()); | ||
339 | m_Scene.AssetService.Store(asset); | ||
340 | |||
341 | item.AssetID = asset.FullID; | ||
342 | assetID = asset.FullID; | ||
285 | 343 | ||
286 | // Embed the offsets into the group XML | 344 | if (DeRezAction.SaveToExistingUserInventoryItem == action) |
287 | for ( int i = 0 ; i < objlist.Count ; i++ ) | 345 | { |
288 | { | 346 | m_Scene.InventoryService.UpdateItem(item); |
289 | XmlDocument doc = new XmlDocument(); | 347 | } |
290 | SceneObjectGroup g = objlist[i]; | 348 | else |
291 | doc.LoadXml(xmlStrings[g.UUID]); | 349 | { |
292 | XmlElement e = (XmlElement)doc.SelectSingleNode("/SceneObjectGroup"); | 350 | AddPermissions(item, objlist[0], objlist, remoteClient); |
293 | e.SetAttribute("offsetx", offsets[i].X.ToString()); | ||
294 | e.SetAttribute("offsety", offsets[i].Y.ToString()); | ||
295 | e.SetAttribute("offsetz", offsets[i].Z.ToString()); | ||
296 | |||
297 | XmlNode objectNode = itemDoc.ImportNode(e, true); | ||
298 | root.AppendChild(objectNode); | ||
299 | } | ||
300 | 351 | ||
301 | float sizeX = maxX - minX; | 352 | item.CreationDate = Util.UnixTimeSinceEpoch(); |
302 | float sizeY = maxY - minY; | 353 | item.Description = asset.Description; |
303 | float sizeZ = maxZ - minZ; | 354 | item.Name = asset.Name; |
355 | item.AssetType = asset.Type; | ||
304 | 356 | ||
305 | root.SetAttribute("x", sizeX.ToString()); | 357 | m_Scene.AddInventoryItem(item); |
306 | root.SetAttribute("y", sizeY.ToString()); | ||
307 | root.SetAttribute("z", sizeZ.ToString()); | ||
308 | 358 | ||
309 | itemXml = itemDoc.InnerXml; | 359 | if (remoteClient != null && item.Owner == remoteClient.AgentId) |
360 | { | ||
361 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
310 | } | 362 | } |
311 | else | 363 | else |
312 | { | 364 | { |
313 | itemXml = xmlStrings[objlist[0].UUID]; | 365 | ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner); |
366 | if (notifyUser != null) | ||
367 | { | ||
368 | notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); | ||
369 | } | ||
314 | } | 370 | } |
371 | } | ||
315 | 372 | ||
316 | // Get the user info of the item destination | 373 | // This is a hook to do some per-asset post-processing for subclasses that need that |
317 | // | 374 | ExportAsset(remoteClient.AgentId, assetID); |
318 | UUID userID = UUID.Zero; | 375 | |
376 | return assetID; | ||
377 | } | ||
319 | 378 | ||
320 | if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || | 379 | protected virtual void ExportAsset(UUID agentID, UUID assetID) |
321 | action == DeRezAction.SaveToExistingUserInventoryItem) | 380 | { |
322 | { | 381 | // nothing to do here |
323 | // Take or take copy require a taker | 382 | } |
324 | // Saving changes requires a local user | ||
325 | // | ||
326 | if (remoteClient == null) | ||
327 | return UUID.Zero; | ||
328 | 383 | ||
329 | userID = remoteClient.AgentId; | 384 | /// <summary> |
330 | } | 385 | /// Add relevant permissions for an object to the item. |
331 | else | 386 | /// </summary> |
332 | { | 387 | /// <param name="item"></param> |
333 | // All returns / deletes go to the object owner | 388 | /// <param name="so"></param> |
334 | // | 389 | /// <param name="objsForEffectivePermissions"></param> |
390 | /// <param name="remoteClient"></param> | ||
391 | /// <returns></returns> | ||
392 | protected InventoryItemBase AddPermissions( | ||
393 | InventoryItemBase item, SceneObjectGroup so, List<SceneObjectGroup> objsForEffectivePermissions, | ||
394 | IClientAPI remoteClient) | ||
395 | { | ||
396 | uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7; | ||
397 | foreach (SceneObjectGroup grp in objsForEffectivePermissions) | ||
398 | effectivePerms &= grp.GetEffectivePermissions(); | ||
399 | effectivePerms |= (uint)PermissionMask.Move; | ||
335 | 400 | ||
336 | userID = objlist[0].RootPart.OwnerID; | 401 | if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) |
337 | } | 402 | { |
403 | uint perms = effectivePerms; | ||
404 | uint nextPerms = (perms & 7) << 13; | ||
405 | if ((nextPerms & (uint)PermissionMask.Copy) == 0) | ||
406 | perms &= ~(uint)PermissionMask.Copy; | ||
407 | if ((nextPerms & (uint)PermissionMask.Transfer) == 0) | ||
408 | perms &= ~(uint)PermissionMask.Transfer; | ||
409 | if ((nextPerms & (uint)PermissionMask.Modify) == 0) | ||
410 | perms &= ~(uint)PermissionMask.Modify; | ||
411 | |||
412 | item.BasePermissions = perms & so.RootPart.NextOwnerMask; | ||
413 | item.CurrentPermissions = item.BasePermissions; | ||
414 | item.NextPermissions = perms & so.RootPart.NextOwnerMask; | ||
415 | item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask; | ||
416 | item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask; | ||
417 | |||
418 | // Magic number badness. Maybe this deserves an enum. | ||
419 | // bit 4 (16) is the "Slam" bit, it means treat as passed | ||
420 | // and apply next owner perms on rez | ||
421 | item.CurrentPermissions |= 16; // Slam! | ||
422 | } | ||
423 | else | ||
424 | { | ||
425 | item.BasePermissions = effectivePerms; | ||
426 | item.CurrentPermissions = effectivePerms; | ||
427 | item.NextPermissions = so.RootPart.NextOwnerMask & effectivePerms; | ||
428 | item.EveryOnePermissions = so.RootPart.EveryoneMask & effectivePerms; | ||
429 | item.GroupPermissions = so.RootPart.GroupMask & effectivePerms; | ||
430 | |||
431 | item.CurrentPermissions &= | ||
432 | ((uint)PermissionMask.Copy | | ||
433 | (uint)PermissionMask.Transfer | | ||
434 | (uint)PermissionMask.Modify | | ||
435 | (uint)PermissionMask.Move | | ||
436 | 7); // Preserve folded permissions | ||
437 | } | ||
438 | |||
439 | return item; | ||
440 | } | ||
441 | |||
442 | /// <summary> | ||
443 | /// Create an item using details for the given scene object. | ||
444 | /// </summary> | ||
445 | /// <param name="action"></param> | ||
446 | /// <param name="remoteClient"></param> | ||
447 | /// <param name="so"></param> | ||
448 | /// <param name="folderID"></param> | ||
449 | /// <returns></returns> | ||
450 | protected InventoryItemBase CreateItemForObject( | ||
451 | DeRezAction action, IClientAPI remoteClient, SceneObjectGroup so, UUID folderID) | ||
452 | { | ||
453 | // Get the user info of the item destination | ||
454 | // | ||
455 | UUID userID = UUID.Zero; | ||
338 | 456 | ||
339 | if (userID == UUID.Zero) // Can't proceed | 457 | if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || |
340 | { | 458 | action == DeRezAction.SaveToExistingUserInventoryItem) |
341 | return UUID.Zero; | 459 | { |
342 | } | 460 | // Take or take copy require a taker |
461 | // Saving changes requires a local user | ||
462 | // | ||
463 | if (remoteClient == null) | ||
464 | return null; | ||
343 | 465 | ||
344 | // If we're returning someone's item, it goes back to the | 466 | userID = remoteClient.AgentId; |
345 | // owner's Lost And Found folder. | 467 | } |
346 | // Delete is treated like return in this case | 468 | else |
347 | // Deleting your own items makes them go to trash | 469 | { |
470 | // All returns / deletes go to the object owner | ||
348 | // | 471 | // |
472 | userID = so.RootPart.OwnerID; | ||
473 | } | ||
349 | 474 | ||
350 | InventoryFolderBase folder = null; | 475 | if (userID == UUID.Zero) // Can't proceed |
351 | InventoryItemBase item = null; | 476 | { |
477 | return null; | ||
478 | } | ||
352 | 479 | ||
353 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | 480 | // If we're returning someone's item, it goes back to the |
354 | { | 481 | // owner's Lost And Found folder. |
355 | item = new InventoryItemBase(objlist[0].RootPart.FromUserInventoryItemID, userID); | 482 | // Delete is treated like return in this case |
356 | item = m_Scene.InventoryService.GetItem(item); | 483 | // Deleting your own items makes them go to trash |
484 | // | ||
485 | |||
486 | InventoryFolderBase folder = null; | ||
487 | InventoryItemBase item = null; | ||
357 | 488 | ||
358 | //item = userInfo.RootFolder.FindItem( | 489 | if (DeRezAction.SaveToExistingUserInventoryItem == action) |
359 | // objectGroup.RootPart.FromUserInventoryItemID); | 490 | { |
491 | item = new InventoryItemBase(so.RootPart.FromUserInventoryItemID, userID); | ||
492 | item = m_Scene.InventoryService.GetItem(item); | ||
360 | 493 | ||
361 | if (null == item) | 494 | //item = userInfo.RootFolder.FindItem( |
362 | { | 495 | // objectGroup.RootPart.FromUserInventoryItemID); |
363 | m_log.DebugFormat( | 496 | |
364 | "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", | 497 | if (null == item) |
365 | objlist[0].Name, objlist[0].UUID); | 498 | { |
366 | return UUID.Zero; | 499 | m_log.DebugFormat( |
367 | } | 500 | "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", |
501 | so.Name, so.UUID); | ||
502 | |||
503 | return null; | ||
368 | } | 504 | } |
369 | else | 505 | } |
506 | else | ||
507 | { | ||
508 | // Folder magic | ||
509 | // | ||
510 | if (action == DeRezAction.Delete) | ||
370 | { | 511 | { |
371 | // Folder magic | 512 | // Deleting someone else's item |
372 | // | 513 | // |
373 | if (action == DeRezAction.Delete) | 514 | if (remoteClient == null || |
515 | so.OwnerID != remoteClient.AgentId) | ||
374 | { | 516 | { |
375 | // Deleting someone else's item | 517 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); |
376 | // | ||
377 | if (remoteClient == null || | ||
378 | objlist[0].OwnerID != remoteClient.AgentId) | ||
379 | { | ||
380 | |||
381 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
382 | } | ||
383 | else | ||
384 | { | ||
385 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); | ||
386 | } | ||
387 | } | 518 | } |
388 | else if (action == DeRezAction.Return) | 519 | else |
389 | { | 520 | { |
521 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); | ||
522 | } | ||
523 | } | ||
524 | else if (action == DeRezAction.Return) | ||
525 | { | ||
526 | // Dump to lost + found unconditionally | ||
527 | // | ||
528 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
529 | } | ||
390 | 530 | ||
391 | // Dump to lost + found unconditionally | 531 | if (folderID == UUID.Zero && folder == null) |
532 | { | ||
533 | if (action == DeRezAction.Delete) | ||
534 | { | ||
535 | // Deletes go to trash by default | ||
392 | // | 536 | // |
393 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | 537 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); |
394 | } | 538 | } |
395 | 539 | else | |
396 | if (folderID == UUID.Zero && folder == null) | ||
397 | { | 540 | { |
398 | if (action == DeRezAction.Delete) | 541 | if (remoteClient == null || so.OwnerID != remoteClient.AgentId) |
399 | { | 542 | { |
400 | // Deletes go to trash by default | 543 | // Taking copy of another person's item. Take to |
401 | // | 544 | // Objects folder. |
402 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); | 545 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object); |
403 | } | 546 | } |
404 | else | 547 | else |
405 | { | 548 | { |
406 | if (remoteClient == null || | 549 | // Catch all. Use lost & found |
407 | objlist[0].OwnerID != remoteClient.AgentId) | 550 | // |
408 | { | ||
409 | // Taking copy of another person's item. Take to | ||
410 | // Objects folder. | ||
411 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.Object); | ||
412 | } | ||
413 | else | ||
414 | { | ||
415 | // Catch all. Use lost & found | ||
416 | // | ||
417 | |||
418 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
419 | } | ||
420 | } | ||
421 | } | ||
422 | |||
423 | // Override and put into where it came from, if it came | ||
424 | // from anywhere in inventory | ||
425 | // | ||
426 | if (action == DeRezAction.Take || action == DeRezAction.TakeCopy) | ||
427 | { | ||
428 | if (objlist[0].RootPart.FromFolderID != UUID.Zero) | ||
429 | { | ||
430 | InventoryFolderBase f = new InventoryFolderBase(objlist[0].RootPart.FromFolderID, userID); | ||
431 | folder = m_Scene.InventoryService.GetFolder(f); | ||
432 | } | ||
433 | } | ||
434 | |||
435 | if (folder == null) // None of the above | ||
436 | { | ||
437 | folder = new InventoryFolderBase(folderID); | ||
438 | 551 | ||
439 | if (folder == null) // Nowhere to put it | 552 | folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); |
440 | { | ||
441 | return UUID.Zero; | ||
442 | } | 553 | } |
443 | } | 554 | } |
444 | |||
445 | item = new InventoryItemBase(); | ||
446 | // Can't know creator is the same, so null it in inventory | ||
447 | if (objlist.Count > 1) | ||
448 | item.CreatorId = UUID.Zero.ToString(); | ||
449 | else | ||
450 | item.CreatorId = objlist[0].RootPart.CreatorID.ToString(); | ||
451 | item.ID = UUID.Random(); | ||
452 | item.InvType = (int)InventoryType.Object; | ||
453 | item.Folder = folder.ID; | ||
454 | item.Owner = userID; | ||
455 | if (objlist.Count > 1) | ||
456 | { | ||
457 | item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems; | ||
458 | } | ||
459 | else | ||
460 | { | ||
461 | item.SaleType = objlist[0].RootPart.ObjectSaleType; | ||
462 | item.SalePrice = objlist[0].RootPart.SalePrice; | ||
463 | } | ||
464 | } | 555 | } |
465 | 556 | ||
466 | AssetBase asset = CreateAsset( | 557 | // Override and put into where it came from, if it came |
467 | objlist[0].GetPartName(objlist[0].RootPart.LocalId), | 558 | // from anywhere in inventory |
468 | objlist[0].GetPartDescription(objlist[0].RootPart.LocalId), | 559 | // |
469 | (sbyte)AssetType.Object, | 560 | if (action == DeRezAction.Take || action == DeRezAction.TakeCopy) |
470 | Utils.StringToBytes(itemXml), | ||
471 | objlist[0].OwnerID.ToString()); | ||
472 | m_Scene.AssetService.Store(asset); | ||
473 | assetID = asset.FullID; | ||
474 | |||
475 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | ||
476 | { | ||
477 | item.AssetID = asset.FullID; | ||
478 | m_Scene.InventoryService.UpdateItem(item); | ||
479 | } | ||
480 | else | ||
481 | { | 561 | { |
482 | item.AssetID = asset.FullID; | 562 | if (so.RootPart.FromFolderID != UUID.Zero) |
483 | |||
484 | uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7; | ||
485 | foreach (SceneObjectGroup grp in objlist) | ||
486 | effectivePerms &= grp.GetEffectivePermissions(); | ||
487 | effectivePerms |= (uint)PermissionMask.Move; | ||
488 | |||
489 | if (remoteClient != null && (remoteClient.AgentId != objlist[0].RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) | ||
490 | { | 563 | { |
491 | uint perms = effectivePerms; | 564 | InventoryFolderBase f = new InventoryFolderBase(so.RootPart.FromFolderID, userID); |
492 | uint nextPerms = (perms & 7) << 13; | 565 | folder = m_Scene.InventoryService.GetFolder(f); |
493 | if ((nextPerms & (uint)PermissionMask.Copy) == 0) | ||
494 | perms &= ~(uint)PermissionMask.Copy; | ||
495 | if ((nextPerms & (uint)PermissionMask.Transfer) == 0) | ||
496 | perms &= ~(uint)PermissionMask.Transfer; | ||
497 | if ((nextPerms & (uint)PermissionMask.Modify) == 0) | ||
498 | perms &= ~(uint)PermissionMask.Modify; | ||
499 | |||
500 | item.BasePermissions = perms & objlist[0].RootPart.NextOwnerMask; | ||
501 | item.CurrentPermissions = item.BasePermissions; | ||
502 | item.NextPermissions = perms & objlist[0].RootPart.NextOwnerMask; | ||
503 | item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & objlist[0].RootPart.NextOwnerMask; | ||
504 | item.GroupPermissions = objlist[0].RootPart.GroupMask & objlist[0].RootPart.NextOwnerMask; | ||
505 | |||
506 | // Magic number badness. Maybe this deserves an enum. | ||
507 | // bit 4 (16) is the "Slam" bit, it means treat as passed | ||
508 | // and apply next owner perms on rez | ||
509 | item.CurrentPermissions |= 16; // Slam! | ||
510 | } | 566 | } |
511 | else | 567 | } |
512 | { | ||
513 | item.BasePermissions = effectivePerms; | ||
514 | item.CurrentPermissions = effectivePerms; | ||
515 | item.NextPermissions = objlist[0].RootPart.NextOwnerMask & effectivePerms; | ||
516 | item.EveryOnePermissions = objlist[0].RootPart.EveryoneMask & effectivePerms; | ||
517 | item.GroupPermissions = objlist[0].RootPart.GroupMask & effectivePerms; | ||
518 | |||
519 | item.CurrentPermissions &= | ||
520 | ((uint)PermissionMask.Copy | | ||
521 | (uint)PermissionMask.Transfer | | ||
522 | (uint)PermissionMask.Modify | | ||
523 | (uint)PermissionMask.Move | | ||
524 | 7); // Preserve folded permissions | ||
525 | } | ||
526 | |||
527 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
528 | item.Description = asset.Description; | ||
529 | item.Name = asset.Name; | ||
530 | item.AssetType = asset.Type; | ||
531 | 568 | ||
532 | m_Scene.AddInventoryItem(item); | 569 | if (folder == null) // None of the above |
570 | { | ||
571 | folder = new InventoryFolderBase(folderID); | ||
533 | 572 | ||
534 | if (remoteClient != null && item.Owner == remoteClient.AgentId) | 573 | if (folder == null) // Nowhere to put it |
535 | { | ||
536 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
537 | } | ||
538 | else | ||
539 | { | 574 | { |
540 | ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner); | 575 | return null; |
541 | if (notifyUser != null) | ||
542 | { | ||
543 | notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); | ||
544 | } | ||
545 | } | 576 | } |
546 | } | 577 | } |
547 | } | ||
548 | return assetID; | ||
549 | } | ||
550 | 578 | ||
579 | item = new InventoryItemBase(); | ||
580 | item.ID = UUID.Random(); | ||
581 | item.InvType = (int)InventoryType.Object; | ||
582 | item.Folder = folder.ID; | ||
583 | item.Owner = userID; | ||
584 | } | ||
585 | |||
586 | return item; | ||
587 | } | ||
551 | 588 | ||
552 | /// <summary> | 589 | /// <summary> |
553 | /// Rez an object into the scene from the user's inventory | 590 | /// Rez an object into the scene from the user's inventory |
554 | /// </summary> | 591 | /// </summary> |
592 | /// <remarks> | ||
555 | /// FIXME: It would be really nice if inventory access modules didn't also actually do the work of rezzing | 593 | /// FIXME: It would be really nice if inventory access modules didn't also actually do the work of rezzing |
556 | /// things to the scene. The caller should be doing that, I think. | 594 | /// things to the scene. The caller should be doing that, I think. |
595 | /// </remarks> | ||
557 | /// <param name="remoteClient"></param> | 596 | /// <param name="remoteClient"></param> |
558 | /// <param name="itemID"></param> | 597 | /// <param name="itemID"></param> |
559 | /// <param name="RayEnd"></param> | 598 | /// <param name="RayEnd"></param> |
@@ -570,21 +609,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
570 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | 609 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, |
571 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | 610 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) |
572 | { | 611 | { |
573 | // Work out position details | 612 | // m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID); |
574 | byte bRayEndIsIntersection = (byte)0; | 613 | |
575 | 614 | byte bRayEndIsIntersection = (byte)(RayEndIsIntersection ? 1 : 0); | |
576 | if (RayEndIsIntersection) | ||
577 | { | ||
578 | bRayEndIsIntersection = (byte)1; | ||
579 | } | ||
580 | else | ||
581 | { | ||
582 | bRayEndIsIntersection = (byte)0; | ||
583 | } | ||
584 | |||
585 | Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f); | 615 | Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f); |
586 | |||
587 | |||
588 | Vector3 pos = m_Scene.GetNewRezLocation( | 616 | Vector3 pos = m_Scene.GetNewRezLocation( |
589 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, | 617 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, |
590 | BypassRayCast, bRayEndIsIntersection, true, scale, false); | 618 | BypassRayCast, bRayEndIsIntersection, true, scale, false); |
@@ -668,9 +696,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
668 | itemId, n.OuterXml); | 696 | itemId, n.OuterXml); |
669 | objlist.Add(g); | 697 | objlist.Add(g); |
670 | XmlElement el = (XmlElement)n; | 698 | XmlElement el = (XmlElement)n; |
671 | float x = Convert.ToSingle(el.GetAttribute("offsetx")); | 699 | |
672 | float y = Convert.ToSingle(el.GetAttribute("offsety")); | 700 | string rawX = el.GetAttribute("offsetx"); |
673 | float z = Convert.ToSingle(el.GetAttribute("offsetz")); | 701 | string rawY = el.GetAttribute("offsety"); |
702 | string rawZ = el.GetAttribute("offsetz"); | ||
703 | // | ||
704 | // m_log.DebugFormat( | ||
705 | // "[INVENTORY ACCESS MODULE]: Converting coalesced object {0} offset <{1}, {2}, {3}>", | ||
706 | // g.Name, rawX, rawY, rawZ); | ||
707 | |||
708 | float x = Convert.ToSingle(rawX); | ||
709 | float y = Convert.ToSingle(rawY); | ||
710 | float z = Convert.ToSingle(rawZ); | ||
674 | veclist.Add(new Vector3(x, y, z)); | 711 | veclist.Add(new Vector3(x, y, z)); |
675 | } | 712 | } |
676 | } | 713 | } |
@@ -762,10 +799,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
762 | // affect the name stored in the serialization, transfer | 799 | // affect the name stored in the serialization, transfer |
763 | // the correct name from the inventory to the | 800 | // the correct name from the inventory to the |
764 | // object itself before we rez. | 801 | // object itself before we rez. |
765 | rootPart.Name = item.Name; | 802 | // |
766 | rootPart.Description = item.Description; | 803 | // Only do these for the first object if we are rezzing a coalescence. |
767 | rootPart.ObjectSaleType = item.SaleType; | 804 | if (i == 0) |
768 | rootPart.SalePrice = item.SalePrice; | 805 | { |
806 | rootPart.Name = item.Name; | ||
807 | rootPart.Description = item.Description; | ||
808 | rootPart.ObjectSaleType = item.SaleType; | ||
809 | rootPart.SalePrice = item.SalePrice; | ||
810 | } | ||
769 | 811 | ||
770 | group.SetGroup(remoteClient.ActiveGroupId, remoteClient); | 812 | group.SetGroup(remoteClient.ActiveGroupId, remoteClient); |
771 | if ((rootPart.OwnerID != item.Owner) || | 813 | if ((rootPart.OwnerID != item.Owner) || |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs new file mode 100644 index 0000000..8d53cf1 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs | |||
@@ -0,0 +1,174 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using Nini.Config; | ||
34 | using NUnit.Framework; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Data; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Serialization; | ||
39 | using OpenSim.Framework.Serialization.External; | ||
40 | using OpenSim.Framework.Communications; | ||
41 | using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; | ||
42 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; | ||
43 | using OpenSim.Region.Framework.Scenes; | ||
44 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | using OpenSim.Tests.Common; | ||
47 | using OpenSim.Tests.Common.Mock; | ||
48 | using OpenSim.Tests.Common.Setup; | ||
49 | |||
50 | namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | ||
51 | { | ||
52 | [TestFixture] | ||
53 | public class InventoryAccessModuleTests | ||
54 | { | ||
55 | protected TestScene m_scene; | ||
56 | protected BasicInventoryAccessModule m_iam; | ||
57 | protected UUID m_userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
58 | protected TestClient m_tc; | ||
59 | |||
60 | [SetUp] | ||
61 | public void SetUp() | ||
62 | { | ||
63 | m_iam = new BasicInventoryAccessModule(); | ||
64 | |||
65 | IConfigSource config = new IniConfigSource(); | ||
66 | config.AddConfig("Modules"); | ||
67 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
68 | |||
69 | m_scene = SceneSetupHelpers.SetupScene(); | ||
70 | SceneSetupHelpers.SetupSceneModules(m_scene, config, m_iam); | ||
71 | |||
72 | // Create user | ||
73 | string userFirstName = "Jock"; | ||
74 | string userLastName = "Stirrup"; | ||
75 | string userPassword = "troll"; | ||
76 | UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, m_userId, userPassword); | ||
77 | |||
78 | AgentCircuitData acd = new AgentCircuitData(); | ||
79 | acd.AgentID = m_userId; | ||
80 | m_tc = new TestClient(acd, m_scene); | ||
81 | } | ||
82 | |||
83 | [Test] | ||
84 | public void TestRezCoalescedObject() | ||
85 | { | ||
86 | TestHelper.InMethod(); | ||
87 | // log4net.Config.XmlConfigurator.Configure(); | ||
88 | |||
89 | // Create asset | ||
90 | SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "Object1", 0x20); | ||
91 | object1.AbsolutePosition = new Vector3(15, 30, 45); | ||
92 | |||
93 | SceneObjectGroup object2 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "Object2", 0x40); | ||
94 | object2.AbsolutePosition = new Vector3(25, 50, 75); | ||
95 | |||
96 | CoalescedSceneObjects coa = new CoalescedSceneObjects(m_userId, object1, object2); | ||
97 | |||
98 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
99 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, coa); | ||
100 | m_scene.AssetService.Store(asset1); | ||
101 | |||
102 | // Create item | ||
103 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
104 | string item1Name = "My Little Dog"; | ||
105 | InventoryItemBase item1 = new InventoryItemBase(); | ||
106 | item1.Name = item1Name; | ||
107 | item1.AssetID = asset1.FullID; | ||
108 | item1.ID = item1Id; | ||
109 | InventoryFolderBase objsFolder | ||
110 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, m_userId, "Objects")[0]; | ||
111 | item1.Folder = objsFolder.ID; | ||
112 | m_scene.AddInventoryItem(item1); | ||
113 | |||
114 | SceneObjectGroup so | ||
115 | = m_iam.RezObject( | ||
116 | m_tc, item1Id, new Vector3(100, 100, 100), Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false); | ||
117 | |||
118 | Assert.That(so, Is.Not.Null); | ||
119 | |||
120 | Assert.That(m_scene.SceneGraph.GetTotalObjectsCount(), Is.EqualTo(2)); | ||
121 | |||
122 | SceneObjectPart retrievedObj1Part = m_scene.GetSceneObjectPart(object1.Name); | ||
123 | Assert.That(retrievedObj1Part, Is.Null); | ||
124 | |||
125 | retrievedObj1Part = m_scene.GetSceneObjectPart(item1.Name); | ||
126 | Assert.That(retrievedObj1Part, Is.Not.Null); | ||
127 | Assert.That(retrievedObj1Part.Name, Is.EqualTo(item1.Name)); | ||
128 | |||
129 | // Bottom of coalescence is placed on ground, hence we end up with 100.5 rather than 85 since the bottom | ||
130 | // object is unit square. | ||
131 | Assert.That(retrievedObj1Part.AbsolutePosition, Is.EqualTo(new Vector3(95, 90, 100.5f))); | ||
132 | |||
133 | SceneObjectPart retrievedObj2Part = m_scene.GetSceneObjectPart(object2.Name); | ||
134 | Assert.That(retrievedObj2Part, Is.Not.Null); | ||
135 | Assert.That(retrievedObj2Part.Name, Is.EqualTo(object2.Name)); | ||
136 | Assert.That(retrievedObj2Part.AbsolutePosition, Is.EqualTo(new Vector3(105, 110, 130.5f))); | ||
137 | } | ||
138 | |||
139 | [Test] | ||
140 | public void TestRezObject() | ||
141 | { | ||
142 | TestHelper.InMethod(); | ||
143 | // log4net.Config.XmlConfigurator.Configure(); | ||
144 | |||
145 | // Create asset | ||
146 | SceneObjectGroup object1 = SceneSetupHelpers.CreateSceneObject(1, m_userId, "My Little Dog Object", 0x40); | ||
147 | |||
148 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
149 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | ||
150 | m_scene.AssetService.Store(asset1); | ||
151 | |||
152 | // Create item | ||
153 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
154 | string item1Name = "My Little Dog"; | ||
155 | InventoryItemBase item1 = new InventoryItemBase(); | ||
156 | item1.Name = item1Name; | ||
157 | item1.AssetID = asset1.FullID; | ||
158 | item1.ID = item1Id; | ||
159 | InventoryFolderBase objsFolder | ||
160 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, m_userId, "Objects")[0]; | ||
161 | item1.Folder = objsFolder.ID; | ||
162 | m_scene.AddInventoryItem(item1); | ||
163 | |||
164 | SceneObjectGroup so | ||
165 | = m_iam.RezObject( | ||
166 | m_tc, item1Id, Vector3.Zero, Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false); | ||
167 | |||
168 | Assert.That(so, Is.Not.Null); | ||
169 | |||
170 | SceneObjectPart retrievedPart = m_scene.GetSceneObjectPart(so.UUID); | ||
171 | Assert.That(retrievedPart, Is.Not.Null); | ||
172 | } | ||
173 | } | ||
174 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index d78931a..4c8424d 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | |||
@@ -29,8 +29,10 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Net; | 31 | using System.Net; |
32 | using System.Net.Security; | ||
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Threading; | 34 | using System.Threading; |
35 | using System.Security.Cryptography.X509Certificates; | ||
34 | using Nini.Config; | 36 | using Nini.Config; |
35 | using OpenMetaverse; | 37 | using OpenMetaverse; |
36 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
@@ -100,8 +102,24 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
100 | 102 | ||
101 | public HttpRequestModule() | 103 | public HttpRequestModule() |
102 | { | 104 | { |
105 | ServicePointManager.ServerCertificateValidationCallback +=ValidateServerCertificate; | ||
103 | } | 106 | } |
104 | 107 | ||
108 | public static bool ValidateServerCertificate( | ||
109 | object sender, | ||
110 | X509Certificate certificate, | ||
111 | X509Chain chain, | ||
112 | SslPolicyErrors sslPolicyErrors) | ||
113 | { | ||
114 | HttpWebRequest Request = (HttpWebRequest)sender; | ||
115 | |||
116 | if (Request.Headers.Get("NoVerifyCert") != null) | ||
117 | { | ||
118 | return true; | ||
119 | } | ||
120 | |||
121 | return chain.Build(new X509Certificate2(certificate)); | ||
122 | } | ||
105 | #region IHttpRequestModule Members | 123 | #region IHttpRequestModule Members |
106 | 124 | ||
107 | public UUID MakeHttpRequest(string url, string parameters, string body) | 125 | public UUID MakeHttpRequest(string url, string parameters, string body) |
@@ -141,8 +159,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
141 | break; | 159 | break; |
142 | 160 | ||
143 | case (int)HttpRequestConstants.HTTP_VERIFY_CERT: | 161 | case (int)HttpRequestConstants.HTTP_VERIFY_CERT: |
144 | 162 | htc.HttpVerifyCert = (int.Parse(parms[i + 1]) != 0); | |
145 | // TODO implement me | ||
146 | break; | 163 | break; |
147 | } | 164 | } |
148 | } | 165 | } |
@@ -189,7 +206,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
189 | * Not sure how important ordering is is here - the next first | 206 | * Not sure how important ordering is is here - the next first |
190 | * one completed in the list is returned, based soley on its list | 207 | * one completed in the list is returned, based soley on its list |
191 | * position, not the order in which the request was started or | 208 | * position, not the order in which the request was started or |
192 | * finsihed. I thought about setting up a queue for this, but | 209 | * finished. I thought about setting up a queue for this, but |
193 | * it will need some refactoring and this works 'enough' right now | 210 | * it will need some refactoring and this works 'enough' right now |
194 | */ | 211 | */ |
195 | 212 | ||
@@ -237,8 +254,8 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
237 | 254 | ||
238 | m_scene.RegisterModuleInterface<IHttpRequestModule>(this); | 255 | m_scene.RegisterModuleInterface<IHttpRequestModule>(this); |
239 | 256 | ||
240 | m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); | 257 | m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); |
241 | m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); | 258 | m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); |
242 | 259 | ||
243 | m_pendingRequests = new Dictionary<UUID, HttpRequestClass>(); | 260 | m_pendingRequests = new Dictionary<UUID, HttpRequestClass>(); |
244 | } | 261 | } |
@@ -282,7 +299,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
282 | public string HttpMethod = "GET"; | 299 | public string HttpMethod = "GET"; |
283 | public string HttpMIMEType = "text/plain;charset=utf-8"; | 300 | public string HttpMIMEType = "text/plain;charset=utf-8"; |
284 | public int HttpTimeout; | 301 | public int HttpTimeout; |
285 | // public bool HttpVerifyCert = true; // not implemented | 302 | public bool HttpVerifyCert = true; |
286 | private Thread httpThread; | 303 | private Thread httpThread; |
287 | 304 | ||
288 | // Request info | 305 | // Request info |
@@ -344,6 +361,17 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
344 | Request.Method = HttpMethod; | 361 | Request.Method = HttpMethod; |
345 | Request.ContentType = HttpMIMEType; | 362 | Request.ContentType = HttpMIMEType; |
346 | 363 | ||
364 | if(!HttpVerifyCert) | ||
365 | { | ||
366 | // We could hijack Connection Group Name to identify | ||
367 | // a desired security exception. But at the moment we'll use a dummy header instead. | ||
368 | // Request.ConnectionGroupName = "NoVerify"; | ||
369 | Request.Headers.Add("NoVerifyCert", "true"); | ||
370 | } | ||
371 | // else | ||
372 | // { | ||
373 | // Request.ConnectionGroupName="Verify"; | ||
374 | // } | ||
347 | if (proxyurl != null && proxyurl.Length > 0) | 375 | if (proxyurl != null && proxyurl.Length > 0) |
348 | { | 376 | { |
349 | if (proxyexcepts != null && proxyexcepts.Length > 0) | 377 | if (proxyexcepts != null && proxyexcepts.Length > 0) |
@@ -436,4 +464,4 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
436 | } | 464 | } |
437 | } | 465 | } |
438 | } | 466 | } |
439 | } | 467 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs index e25700d..422f394 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs | |||
@@ -31,7 +31,6 @@ using System.Collections.Generic; | |||
31 | using log4net; | 31 | using log4net; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers.HttpServer; | ||
35 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Server.Base; | 36 | using OpenSim.Server.Base; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs index 02acddc..2b5beba 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs | |||
@@ -31,7 +31,6 @@ using System.Collections.Generic; | |||
31 | using log4net; | 31 | using log4net; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers.HttpServer; | ||
35 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Server.Base; | 36 | using OpenSim.Server.Base; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs index 6d975af..f29c074 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs | |||
@@ -31,7 +31,6 @@ using System.Collections.Generic; | |||
31 | using log4net; | 31 | using log4net; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers.HttpServer; | ||
35 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Server.Base; | 36 | using OpenSim.Server.Base; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs index 2f96bcb..d2343c9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs | |||
@@ -31,7 +31,6 @@ using System.Collections.Generic; | |||
31 | using log4net; | 31 | using log4net; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers.HttpServer; | ||
35 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Server.Base; | 36 | using OpenSim.Server.Base; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs index 209cf0d..53a8ace 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs | |||
@@ -31,9 +31,8 @@ using System.Collections.Generic; | |||
31 | using log4net; | 31 | using log4net; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers.HttpServer; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
35 | using OpenSim.Region.Framework.Scenes; | ||
37 | using OpenSim.Server.Base; | 36 | using OpenSim.Server.Base; |
38 | using OpenSim.Server.Handlers.Base; | 37 | using OpenSim.Server.Handlers.Base; |
39 | 38 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs index fcc69e9..fc64203 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs | |||
@@ -31,7 +31,6 @@ using System.Collections.Generic; | |||
31 | using log4net; | 31 | using log4net; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers.HttpServer; | ||
35 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Server.Base; | 36 | using OpenSim.Server.Base; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs index 2a9366c..f759470 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs | |||
@@ -31,7 +31,6 @@ using System.Collections.Generic; | |||
31 | using log4net; | 31 | using log4net; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers.HttpServer; | ||
35 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Server.Base; | 36 | using OpenSim.Server.Base; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs index 35518d5..5c32632 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs | |||
@@ -31,7 +31,6 @@ using System.Collections.Generic; | |||
31 | using log4net; | 31 | using log4net; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers.HttpServer; | ||
35 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Server.Base; | 36 | using OpenSim.Server.Base; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs index 5ee1c97..86b4926 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs | |||
@@ -31,7 +31,6 @@ using System.Collections.Generic; | |||
31 | using log4net; | 31 | using log4net; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers.HttpServer; | ||
35 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Server.Base; | 36 | using OpenSim.Server.Base; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs index 1b3419d..51d1d59 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs | |||
@@ -195,6 +195,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
195 | 195 | ||
196 | public byte[] GetData(string id) | 196 | public byte[] GetData(string id) |
197 | { | 197 | { |
198 | // m_log.DebugFormat("[LOCAL ASSET SERVICES CONNECTOR]: Requesting data for asset {0}", id); | ||
199 | |||
198 | AssetBase asset = m_Cache.Get(id); | 200 | AssetBase asset = m_Cache.Get(id); |
199 | 201 | ||
200 | if (asset != null) | 202 | if (asset != null) |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index fd8f546..82bef48 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -57,6 +57,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
57 | /// bumps here should be compatible. | 57 | /// bumps here should be compatible. |
58 | /// </summary> | 58 | /// </summary> |
59 | public static int MAX_MAJOR_VERSION = 1; | 59 | public static int MAX_MAJOR_VERSION = 1; |
60 | |||
61 | /// <summary> | ||
62 | /// Has the control file been loaded for this archive? | ||
63 | /// </summary> | ||
64 | public bool ControlFileLoaded { get; private set; } | ||
60 | 65 | ||
61 | protected Scene m_scene; | 66 | protected Scene m_scene; |
62 | protected Stream m_loadStream; | 67 | protected Stream m_loadStream; |
@@ -527,7 +532,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
527 | /// </summary> | 532 | /// </summary> |
528 | /// <param name="path"></param> | 533 | /// <param name="path"></param> |
529 | /// <param name="data"></param> | 534 | /// <param name="data"></param> |
530 | protected void LoadControlFile(string path, byte[] data) | 535 | public void LoadControlFile(string path, byte[] data) |
531 | { | 536 | { |
532 | XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable()); | 537 | XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable()); |
533 | XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); | 538 | XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); |
@@ -573,6 +578,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
573 | } | 578 | } |
574 | 579 | ||
575 | currentRegionSettings.Save(); | 580 | currentRegionSettings.Save(); |
581 | |||
582 | ControlFileLoaded = true; | ||
576 | } | 583 | } |
577 | } | 584 | } |
578 | } \ No newline at end of file | 585 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index f2d487e..597b780 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs | |||
@@ -206,7 +206,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
206 | /// <returns></returns> | 206 | /// <returns></returns> |
207 | public static string CreateControlFile(Dictionary<string, object> options) | 207 | public static string CreateControlFile(Dictionary<string, object> options) |
208 | { | 208 | { |
209 | int majorVersion = MAX_MAJOR_VERSION, minorVersion = 5; | 209 | int majorVersion = MAX_MAJOR_VERSION, minorVersion = 6; |
210 | // | 210 | // |
211 | // if (options.ContainsKey("version")) | 211 | // if (options.ContainsKey("version")) |
212 | // { | 212 | // { |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index e2760a2..2307c8e 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | |||
@@ -171,7 +171,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
171 | MemoryStream archiveReadStream = new MemoryStream(archive); | 171 | MemoryStream archiveReadStream = new MemoryStream(archive); |
172 | TarArchiveReader tar = new TarArchiveReader(archiveReadStream); | 172 | TarArchiveReader tar = new TarArchiveReader(archiveReadStream); |
173 | 173 | ||
174 | bool gotControlFile = false; | ||
175 | bool gotNcAssetFile = false; | 174 | bool gotNcAssetFile = false; |
176 | 175 | ||
177 | string expectedNcAssetFileName = string.Format("{0}_{1}", ncAssetUuid, "notecard.txt"); | 176 | string expectedNcAssetFileName = string.Format("{0}_{1}", ncAssetUuid, "notecard.txt"); |
@@ -182,15 +181,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
182 | expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog2)); | 181 | expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog2)); |
183 | 182 | ||
184 | string filePath; | 183 | string filePath; |
185 | TarArchiveReader.TarEntryType tarEntryType; | 184 | TarArchiveReader.TarEntryType tarEntryType; |
186 | 185 | ||
186 | byte[] data = tar.ReadEntry(out filePath, out tarEntryType); | ||
187 | Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); | ||
188 | |||
189 | ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty); | ||
190 | arr.LoadControlFile(filePath, data); | ||
191 | |||
192 | Assert.That(arr.ControlFileLoaded, Is.True); | ||
193 | |||
187 | while (tar.ReadEntry(out filePath, out tarEntryType) != null) | 194 | while (tar.ReadEntry(out filePath, out tarEntryType) != null) |
188 | { | 195 | { |
189 | if (ArchiveConstants.CONTROL_FILE_PATH == filePath) | 196 | if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) |
190 | { | ||
191 | gotControlFile = true; | ||
192 | } | ||
193 | else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) | ||
194 | { | 197 | { |
195 | string fileName = filePath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); | 198 | string fileName = filePath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); |
196 | 199 | ||
@@ -203,7 +206,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
203 | } | 206 | } |
204 | } | 207 | } |
205 | 208 | ||
206 | Assert.That(gotControlFile, Is.True, "No control file in archive"); | ||
207 | Assert.That(gotNcAssetFile, Is.True, "No notecard asset file in archive"); | 209 | Assert.That(gotNcAssetFile, Is.True, "No notecard asset file in archive"); |
208 | Assert.That(foundPaths, Is.EquivalentTo(expectedPaths)); | 210 | Assert.That(foundPaths, Is.EquivalentTo(expectedPaths)); |
209 | 211 | ||
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index b6d64ac..3aed6ba 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -125,7 +125,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
125 | else | 125 | else |
126 | Scene.RegionInfo.RegionSettings.AllowLandResell = true; | 126 | Scene.RegionInfo.RegionSettings.AllowLandResell = true; |
127 | 127 | ||
128 | Scene.RegionInfo.RegionSettings.AgentLimit = (byte) maxAgents; | 128 | if((byte)maxAgents <= Scene.RegionInfo.AgentCapacity) |
129 | Scene.RegionInfo.RegionSettings.AgentLimit = (byte) maxAgents; | ||
130 | else | ||
131 | Scene.RegionInfo.RegionSettings.AgentLimit = Scene.RegionInfo.AgentCapacity; | ||
129 | 132 | ||
130 | Scene.RegionInfo.RegionSettings.ObjectBonus = objectBonusFactor; | 133 | Scene.RegionInfo.RegionSettings.ObjectBonus = objectBonusFactor; |
131 | 134 | ||
@@ -259,6 +262,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
259 | 262 | ||
260 | private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID) | 263 | private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID) |
261 | { | 264 | { |
265 | // m_log.DebugFormat( | ||
266 | // "[ESTATE MANAGEMENT MODULE]: Handling request from {0} to change estate covenant to {1}", | ||
267 | // remoteClient.Name, estateCovenantID); | ||
268 | |||
262 | Scene.RegionInfo.RegionSettings.Covenant = estateCovenantID; | 269 | Scene.RegionInfo.RegionSettings.Covenant = estateCovenantID; |
263 | Scene.RegionInfo.RegionSettings.Save(); | 270 | Scene.RegionInfo.RegionSettings.Save(); |
264 | TriggerRegionInfoChange(); | 271 | TriggerRegionInfoChange(); |
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index dafaa0c..a866fd9 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs | |||
@@ -237,7 +237,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | |||
237 | public void Init() | 237 | public void Init() |
238 | { | 238 | { |
239 | m_serialiserModule = new SerialiserModule(); | 239 | m_serialiserModule = new SerialiserModule(); |
240 | m_scene = SceneSetupHelpers.SetupScene(""); | 240 | m_scene = SceneSetupHelpers.SetupScene(); |
241 | SceneSetupHelpers.SetupSceneModules(m_scene, m_serialiserModule); | 241 | SceneSetupHelpers.SetupSceneModules(m_scene, m_serialiserModule); |
242 | } | 242 | } |
243 | 243 | ||
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index d6fa093..21a9999 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs | |||
@@ -124,6 +124,52 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
124 | colours.Save(stream, ImageFormat.Png); | 124 | colours.Save(stream, ImageFormat.Png); |
125 | } | 125 | } |
126 | 126 | ||
127 | public virtual void SaveFile(ITerrainChannel m_channel, string filename, | ||
128 | int offsetX, int offsetY, | ||
129 | int fileWidth, int fileHeight, | ||
130 | int regionSizeX, int regionSizeY) | ||
131 | |||
132 | { | ||
133 | // We need to do this because: | ||
134 | // "Saving the image to the same file it was constructed from is not allowed and throws an exception." | ||
135 | string tempName = offsetX + "_ " + offsetY + "_" + filename; | ||
136 | |||
137 | Bitmap entireBitmap = null; | ||
138 | Bitmap thisBitmap = null; | ||
139 | if (File.Exists(filename)) | ||
140 | { | ||
141 | File.Copy(filename, tempName); | ||
142 | entireBitmap = new Bitmap(tempName); | ||
143 | if (entireBitmap.Width != fileWidth * regionSizeX || entireBitmap.Height != fileHeight * regionSizeY) | ||
144 | { | ||
145 | // old file, let's overwrite it | ||
146 | entireBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); | ||
147 | } | ||
148 | } | ||
149 | else | ||
150 | { | ||
151 | entireBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); | ||
152 | } | ||
153 | |||
154 | thisBitmap = CreateGrayscaleBitmapFromMap(m_channel); | ||
155 | Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY); | ||
156 | for (int x = 0; x < regionSizeX; x++) | ||
157 | for (int y = 0; y < regionSizeY; y++) | ||
158 | entireBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y)); | ||
159 | |||
160 | Save(entireBitmap, filename); | ||
161 | thisBitmap.Dispose(); | ||
162 | entireBitmap.Dispose(); | ||
163 | |||
164 | if (File.Exists(tempName)) | ||
165 | File.Delete(tempName); | ||
166 | } | ||
167 | |||
168 | protected virtual void Save(Bitmap bmp, string filename) | ||
169 | { | ||
170 | bmp.Save(filename, ImageFormat.Png); | ||
171 | } | ||
172 | |||
127 | #endregion | 173 | #endregion |
128 | 174 | ||
129 | public override string ToString() | 175 | public override string ToString() |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs index 8667607..1a0d8ec 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs | |||
@@ -76,6 +76,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
76 | colours.Save(stream, ImageFormat.Jpeg); | 76 | colours.Save(stream, ImageFormat.Jpeg); |
77 | } | 77 | } |
78 | 78 | ||
79 | public virtual void SaveFile(ITerrainChannel m_channel, string filename, | ||
80 | int offsetX, int offsetY, | ||
81 | int fileWidth, int fileHeight, | ||
82 | int regionSizeX, int regionSizeY) | ||
83 | { | ||
84 | throw new System.Exception("Not Implemented"); | ||
85 | } | ||
86 | |||
79 | #endregion | 87 | #endregion |
80 | 88 | ||
81 | public override string ToString() | 89 | public override string ToString() |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs index a70ef13..fad7641 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs | |||
@@ -240,6 +240,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
240 | get { return ".raw"; } | 240 | get { return ".raw"; } |
241 | } | 241 | } |
242 | 242 | ||
243 | public virtual void SaveFile(ITerrainChannel m_channel, string filename, | ||
244 | int offsetX, int offsetY, | ||
245 | int fileWidth, int fileHeight, | ||
246 | int regionSizeX, int regionSizeY) | ||
247 | { | ||
248 | throw new System.Exception("Not Implemented"); | ||
249 | } | ||
250 | |||
243 | #endregion | 251 | #endregion |
244 | 252 | ||
245 | public override string ToString() | 253 | public override string ToString() |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs index 3c76665..ba073ca 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs | |||
@@ -160,6 +160,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
160 | bs.Close(); | 160 | bs.Close(); |
161 | } | 161 | } |
162 | 162 | ||
163 | public virtual void SaveFile(ITerrainChannel m_channel, string filename, | ||
164 | int offsetX, int offsetY, | ||
165 | int fileWidth, int fileHeight, | ||
166 | int regionSizeX, int regionSizeY) | ||
167 | { | ||
168 | throw new System.Exception("Not Implemented"); | ||
169 | } | ||
163 | #endregion | 170 | #endregion |
164 | 171 | ||
165 | public override string ToString() | 172 | public override string ToString() |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs index 2919897..2f37d9d 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs | |||
@@ -308,6 +308,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
308 | get { return ".ter"; } | 308 | get { return ".ter"; } |
309 | } | 309 | } |
310 | 310 | ||
311 | public virtual void SaveFile(ITerrainChannel m_channel, string filename, | ||
312 | int offsetX, int offsetY, | ||
313 | int fileWidth, int fileHeight, | ||
314 | int regionSizeX, int regionSizeY) | ||
315 | { | ||
316 | throw new System.Exception("Not Implemented"); | ||
317 | } | ||
318 | |||
311 | #endregion | 319 | #endregion |
312 | 320 | ||
313 | public override string ToString() | 321 | public override string ToString() |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs b/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs index 7403281..7237f90 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs | |||
@@ -38,5 +38,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
38 | ITerrainChannel LoadStream(Stream stream); | 38 | ITerrainChannel LoadStream(Stream stream); |
39 | void SaveFile(string filename, ITerrainChannel map); | 39 | void SaveFile(string filename, ITerrainChannel map); |
40 | void SaveStream(Stream stream, ITerrainChannel map); | 40 | void SaveStream(Stream stream, ITerrainChannel map); |
41 | void SaveFile(ITerrainChannel map, string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int regionSizeX, int regionSizeY); | ||
41 | } | 42 | } |
42 | } \ No newline at end of file | 43 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index 8a79d78..9c7b2fa 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -541,6 +541,39 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
541 | } | 541 | } |
542 | 542 | ||
543 | /// <summary> | 543 | /// <summary> |
544 | /// Saves the terrain to a larger terrain file. | ||
545 | /// </summary> | ||
546 | /// <param name="filename">The terrain file to save</param> | ||
547 | /// <param name="fileWidth">The width of the file in units</param> | ||
548 | /// <param name="fileHeight">The height of the file in units</param> | ||
549 | /// <param name="fileStartX">Where to begin our slice</param> | ||
550 | /// <param name="fileStartY">Where to begin our slice</param> | ||
551 | public void SaveToFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) | ||
552 | { | ||
553 | int offsetX = (int)m_scene.RegionInfo.RegionLocX - fileStartX; | ||
554 | int offsetY = (int)m_scene.RegionInfo.RegionLocY - fileStartY; | ||
555 | |||
556 | if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight) | ||
557 | { | ||
558 | // this region is included in the tile request | ||
559 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) | ||
560 | { | ||
561 | if (filename.EndsWith(loader.Key)) | ||
562 | { | ||
563 | lock (m_scene) | ||
564 | { | ||
565 | loader.Value.SaveFile(m_channel, filename, offsetX, offsetY, | ||
566 | fileWidth, fileHeight, | ||
567 | (int)Constants.RegionSize, | ||
568 | (int)Constants.RegionSize); | ||
569 | } | ||
570 | return; | ||
571 | } | ||
572 | } | ||
573 | } | ||
574 | } | ||
575 | |||
576 | /// <summary> | ||
544 | /// Performs updates to the region periodically, synchronising physics and other heightmap aware sections | 577 | /// Performs updates to the region periodically, synchronising physics and other heightmap aware sections |
545 | /// </summary> | 578 | /// </summary> |
546 | private void EventManager_OnTerrainTick() | 579 | private void EventManager_OnTerrainTick() |
@@ -860,6 +893,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
860 | SaveToFile((string) args[0]); | 893 | SaveToFile((string) args[0]); |
861 | } | 894 | } |
862 | 895 | ||
896 | private void InterfaceSaveTileFile(Object[] args) | ||
897 | { | ||
898 | SaveToFile((string)args[0], | ||
899 | (int)args[1], | ||
900 | (int)args[2], | ||
901 | (int)args[3], | ||
902 | (int)args[4]); | ||
903 | } | ||
904 | |||
863 | private void InterfaceBakeTerrain(Object[] args) | 905 | private void InterfaceBakeTerrain(Object[] args) |
864 | { | 906 | { |
865 | UpdateRevertMap(); | 907 | UpdateRevertMap(); |
@@ -1115,6 +1157,17 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1115 | loadFromTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", | 1157 | loadFromTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", |
1116 | "Integer"); | 1158 | "Integer"); |
1117 | 1159 | ||
1160 | Command saveToTileCommand = | ||
1161 | new Command("save-tile", CommandIntentions.COMMAND_HAZARDOUS, InterfaceSaveTileFile, "Saves the current heightmap to the larger file."); | ||
1162 | saveToTileCommand.AddArgument("filename", | ||
1163 | "The file you wish to save to, the file extension determines the loader to be used. Supported extensions include: " + | ||
1164 | supportedFileExtensions, "String"); | ||
1165 | saveToTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer"); | ||
1166 | saveToTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer"); | ||
1167 | saveToTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file", | ||
1168 | "Integer"); | ||
1169 | saveToTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", | ||
1170 | "Integer"); | ||
1118 | // Terrain adjustments | 1171 | // Terrain adjustments |
1119 | Command fillRegionCommand = | 1172 | Command fillRegionCommand = |
1120 | new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value."); | 1173 | new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value."); |
@@ -1166,6 +1219,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1166 | m_commander.RegisterCommand("load", loadFromFileCommand); | 1219 | m_commander.RegisterCommand("load", loadFromFileCommand); |
1167 | m_commander.RegisterCommand("load-tile", loadFromTileCommand); | 1220 | m_commander.RegisterCommand("load-tile", loadFromTileCommand); |
1168 | m_commander.RegisterCommand("save", saveToFileCommand); | 1221 | m_commander.RegisterCommand("save", saveToFileCommand); |
1222 | m_commander.RegisterCommand("save-tile", saveToTileCommand); | ||
1169 | m_commander.RegisterCommand("fill", fillRegionCommand); | 1223 | m_commander.RegisterCommand("fill", fillRegionCommand); |
1170 | m_commander.RegisterCommand("elevate", elevateCommand); | 1224 | m_commander.RegisterCommand("elevate", elevateCommand); |
1171 | m_commander.RegisterCommand("lower", lowerCommand); | 1225 | m_commander.RegisterCommand("lower", lowerCommand); |