diff options
author | Jonathan Freedman | 2010-10-17 18:45:25 -0400 |
---|---|---|
committer | Jonathan Freedman | 2010-10-17 18:45:25 -0400 |
commit | 4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65 (patch) | |
tree | 79142f2364b658f52b63e3ae688a5521290e2a4f /OpenSim/Region/CoreModules | |
parent | * more url / hg cleanup (diff) | |
parent | Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65.zip opensim-SC_OLD-4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65.tar.gz opensim-SC_OLD-4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65.tar.bz2 opensim-SC_OLD-4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65.tar.xz |
Merge branch 'master' of git://opensimulator.org/git/opensim
Diffstat (limited to 'OpenSim/Region/CoreModules')
10 files changed, 609 insertions, 60 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs new file mode 100644 index 0000000..36aaab3 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs | |||
@@ -0,0 +1,202 @@ | |||
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; | ||
30 | using System.Collections.Specialized; | ||
31 | using System.Reflection; | ||
32 | using System.IO; | ||
33 | using System.Web; | ||
34 | using Mono.Addins; | ||
35 | using log4net; | ||
36 | using Nini.Config; | ||
37 | using OpenMetaverse; | ||
38 | using OpenMetaverse.StructuredData; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.Servers; | ||
41 | using OpenSim.Framework.Servers.HttpServer; | ||
42 | using OpenSim.Region.Framework.Interfaces; | ||
43 | using OpenSim.Region.Framework.Scenes; | ||
44 | using OpenSim.Services.Interfaces; | ||
45 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
46 | |||
47 | namespace OpenSim.Region.CoreModules.Avatar.Assets | ||
48 | { | ||
49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
50 | public class GetMeshModule : INonSharedRegionModule | ||
51 | { | ||
52 | private static readonly ILog m_log = | ||
53 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
54 | private Scene m_scene; | ||
55 | private IAssetService m_assetService; | ||
56 | |||
57 | #region IRegionModuleBase Members | ||
58 | |||
59 | |||
60 | public Type ReplaceableInterface | ||
61 | { | ||
62 | get { return null; } | ||
63 | } | ||
64 | |||
65 | public void Initialise(IConfigSource source) | ||
66 | { | ||
67 | |||
68 | } | ||
69 | |||
70 | public void AddRegion(Scene pScene) | ||
71 | { | ||
72 | m_scene = pScene; | ||
73 | } | ||
74 | |||
75 | public void RemoveRegion(Scene scene) | ||
76 | { | ||
77 | |||
78 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | ||
79 | m_scene = null; | ||
80 | } | ||
81 | |||
82 | public void RegionLoaded(Scene scene) | ||
83 | { | ||
84 | |||
85 | m_assetService = m_scene.RequestModuleInterface<IAssetService>(); | ||
86 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | ||
87 | } | ||
88 | |||
89 | #endregion | ||
90 | |||
91 | |||
92 | #region IRegionModule Members | ||
93 | |||
94 | |||
95 | |||
96 | public void Close() { } | ||
97 | |||
98 | public string Name { get { return "GetMeshModule"; } } | ||
99 | |||
100 | |||
101 | public void RegisterCaps(UUID agentID, Caps caps) | ||
102 | { | ||
103 | UUID capID = UUID.Random(); | ||
104 | |||
105 | m_log.Info("[GETMESH]: /CAPS/" + capID); | ||
106 | caps.RegisterHandler("GetMesh", | ||
107 | new RestHTTPHandler("GET", "/CAPS/" + capID, | ||
108 | delegate(Hashtable m_dhttpMethod) | ||
109 | { | ||
110 | return ProcessGetMesh(m_dhttpMethod, agentID, caps); | ||
111 | })); | ||
112 | |||
113 | } | ||
114 | |||
115 | #endregion | ||
116 | |||
117 | public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap) | ||
118 | { | ||
119 | |||
120 | Hashtable responsedata = new Hashtable(); | ||
121 | responsedata["int_response_code"] = 400; //501; //410; //404; | ||
122 | responsedata["content_type"] = "text/plain"; | ||
123 | responsedata["keepalive"] = false; | ||
124 | responsedata["str_response_string"] = "Request wasn't what was expected"; | ||
125 | |||
126 | string meshStr = string.Empty; | ||
127 | |||
128 | if (request.ContainsKey("mesh_id")) | ||
129 | meshStr = request["mesh_id"].ToString(); | ||
130 | |||
131 | |||
132 | UUID meshID = UUID.Zero; | ||
133 | if (!String.IsNullOrEmpty(meshStr) && UUID.TryParse(meshStr, out meshID)) | ||
134 | { | ||
135 | if (m_assetService == null) | ||
136 | { | ||
137 | responsedata["int_response_code"] = 404; //501; //410; //404; | ||
138 | responsedata["content_type"] = "text/plain"; | ||
139 | responsedata["keepalive"] = false; | ||
140 | responsedata["str_response_string"] = "The asset service is unavailable. So is your mesh."; | ||
141 | return responsedata; | ||
142 | } | ||
143 | |||
144 | AssetBase mesh; | ||
145 | // Only try to fetch locally cached textures. Misses are redirected | ||
146 | mesh = m_assetService.GetCached(meshID.ToString()); | ||
147 | if (mesh != null) | ||
148 | { | ||
149 | if (mesh.Type == (SByte)AssetType.Mesh) | ||
150 | { | ||
151 | responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); | ||
152 | responsedata["content_type"] = "application/vnd.ll.mesh"; | ||
153 | responsedata["int_response_code"] = 200; | ||
154 | } | ||
155 | // Optionally add additional mesh types here | ||
156 | else | ||
157 | { | ||
158 | responsedata["int_response_code"] = 404; //501; //410; //404; | ||
159 | responsedata["content_type"] = "text/plain"; | ||
160 | responsedata["keepalive"] = false; | ||
161 | responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh."; | ||
162 | return responsedata; | ||
163 | } | ||
164 | } | ||
165 | else | ||
166 | { | ||
167 | mesh = m_assetService.Get(meshID.ToString()); | ||
168 | if (mesh != null) | ||
169 | { | ||
170 | if (mesh.Type == (SByte)AssetType.Mesh) | ||
171 | { | ||
172 | responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); | ||
173 | responsedata["content_type"] = "application/vnd.ll.mesh"; | ||
174 | responsedata["int_response_code"] = 200; | ||
175 | } | ||
176 | // Optionally add additional mesh types here | ||
177 | else | ||
178 | { | ||
179 | responsedata["int_response_code"] = 404; //501; //410; //404; | ||
180 | responsedata["content_type"] = "text/plain"; | ||
181 | responsedata["keepalive"] = false; | ||
182 | responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh."; | ||
183 | return responsedata; | ||
184 | } | ||
185 | } | ||
186 | |||
187 | else | ||
188 | { | ||
189 | responsedata["int_response_code"] = 404; //501; //410; //404; | ||
190 | responsedata["content_type"] = "text/plain"; | ||
191 | responsedata["keepalive"] = false; | ||
192 | responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!"; | ||
193 | return responsedata; | ||
194 | } | ||
195 | } | ||
196 | |||
197 | } | ||
198 | |||
199 | return responsedata; | ||
200 | } | ||
201 | } | ||
202 | } | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs new file mode 100644 index 0000000..af26b2b --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs | |||
@@ -0,0 +1,266 @@ | |||
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; | ||
30 | using System.Collections.Specialized; | ||
31 | using System.Reflection; | ||
32 | using System.IO; | ||
33 | using System.Web; | ||
34 | using Mono.Addins; | ||
35 | using log4net; | ||
36 | using Nini.Config; | ||
37 | using OpenMetaverse; | ||
38 | using OpenMetaverse.StructuredData; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.Servers; | ||
41 | using OpenSim.Framework.Servers.HttpServer; | ||
42 | using OpenSim.Region.Framework.Interfaces; | ||
43 | using OpenSim.Region.Framework.Scenes; | ||
44 | using OpenSim.Services.Interfaces; | ||
45 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
46 | using OpenSim.Framework.Capabilities; | ||
47 | |||
48 | namespace OpenSim.Region.CoreModules.Avatar.Assets | ||
49 | { | ||
50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
51 | public class NewFileAgentInventoryVariablePriceModule : INonSharedRegionModule | ||
52 | { | ||
53 | private static readonly ILog m_log = | ||
54 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
55 | private Scene m_scene; | ||
56 | private IAssetService m_assetService; | ||
57 | private bool m_dumpAssetsToFile = false; | ||
58 | |||
59 | #region IRegionModuleBase Members | ||
60 | |||
61 | |||
62 | public Type ReplaceableInterface | ||
63 | { | ||
64 | get { return null; } | ||
65 | } | ||
66 | |||
67 | public void Initialise(IConfigSource source) | ||
68 | { | ||
69 | |||
70 | } | ||
71 | |||
72 | public void AddRegion(Scene pScene) | ||
73 | { | ||
74 | m_scene = pScene; | ||
75 | } | ||
76 | |||
77 | public void RemoveRegion(Scene scene) | ||
78 | { | ||
79 | |||
80 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | ||
81 | m_scene = null; | ||
82 | } | ||
83 | |||
84 | public void RegionLoaded(Scene scene) | ||
85 | { | ||
86 | |||
87 | m_assetService = m_scene.RequestModuleInterface<IAssetService>(); | ||
88 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | ||
89 | } | ||
90 | |||
91 | #endregion | ||
92 | |||
93 | |||
94 | #region IRegionModule Members | ||
95 | |||
96 | |||
97 | |||
98 | public void Close() { } | ||
99 | |||
100 | public string Name { get { return "NewFileAgentInventoryVariablePriceModule"; } } | ||
101 | |||
102 | |||
103 | public void RegisterCaps(UUID agentID, Caps caps) | ||
104 | { | ||
105 | UUID capID = UUID.Random(); | ||
106 | |||
107 | m_log.Info("[GETMESH]: /CAPS/" + capID); | ||
108 | caps.RegisterHandler("NewFileAgentInventoryVariablePrice", | ||
109 | |||
110 | new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDNewFileAngentInventoryVariablePriceReplyResponse>("POST", | ||
111 | "/CAPS/" + capID.ToString(), | ||
112 | delegate(LLSDAssetUploadRequest req) | ||
113 | { | ||
114 | return NewAgentInventoryRequest(req,agentID); | ||
115 | })); | ||
116 | |||
117 | } | ||
118 | |||
119 | #endregion | ||
120 | |||
121 | public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID) | ||
122 | { | ||
123 | |||
124 | //TODO: The Mesh uploader uploads many types of content. If you're going to implement a Money based limit | ||
125 | // You need to be aware of this and | ||
126 | |||
127 | |||
128 | //if (llsdRequest.asset_type == "texture" || | ||
129 | // llsdRequest.asset_type == "animation" || | ||
130 | // llsdRequest.asset_type == "sound") | ||
131 | // { | ||
132 | IClientAPI client = null; | ||
133 | |||
134 | |||
135 | IMoneyModule mm = m_scene.RequestModuleInterface<IMoneyModule>(); | ||
136 | |||
137 | if (mm != null) | ||
138 | { | ||
139 | if (m_scene.TryGetClient(agentID, out client)) | ||
140 | { | ||
141 | if (!mm.UploadCovered(client, mm.UploadCharge)) | ||
142 | { | ||
143 | if (client != null) | ||
144 | client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); | ||
145 | |||
146 | LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); | ||
147 | errorResponse.rsvp = ""; | ||
148 | errorResponse.state = "error"; | ||
149 | return errorResponse; | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | // } | ||
154 | |||
155 | |||
156 | |||
157 | string assetName = llsdRequest.name; | ||
158 | string assetDes = llsdRequest.description; | ||
159 | string capsBase = "/CAPS/NewFileAgentInventoryVariablePrice/"; | ||
160 | UUID newAsset = UUID.Random(); | ||
161 | UUID newInvItem = UUID.Random(); | ||
162 | UUID parentFolder = llsdRequest.folder_id; | ||
163 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/"; | ||
164 | |||
165 | Caps.AssetUploader uploader = | ||
166 | new Caps.AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, | ||
167 | llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile); | ||
168 | MainServer.Instance.AddStreamHandler( | ||
169 | new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); | ||
170 | |||
171 | string protocol = "http://"; | ||
172 | |||
173 | if (MainServer.Instance.UseSSL) | ||
174 | protocol = "https://"; | ||
175 | |||
176 | string uploaderURL = protocol + m_scene.RegionInfo.ExternalHostName + ":" + MainServer.Instance.Port.ToString() + capsBase + | ||
177 | uploaderPath; | ||
178 | |||
179 | |||
180 | LLSDNewFileAngentInventoryVariablePriceReplyResponse uploadResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); | ||
181 | |||
182 | |||
183 | uploadResponse.rsvp = uploaderURL; | ||
184 | uploadResponse.state = "upload"; | ||
185 | uploadResponse.resource_cost = 0; | ||
186 | uploadResponse.upload_price = 0; | ||
187 | |||
188 | uploader.OnUpLoad += //UploadCompleteHandler; | ||
189 | |||
190 | delegate( | ||
191 | string passetName, string passetDescription, UUID passetID, | ||
192 | UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType, | ||
193 | string passetType) | ||
194 | { | ||
195 | UploadCompleteHandler(passetName, passetDescription, passetID, | ||
196 | pinventoryItem, pparentFolder, pdata, pinventoryType, | ||
197 | passetType,agentID); | ||
198 | }; | ||
199 | return uploadResponse; | ||
200 | } | ||
201 | |||
202 | |||
203 | public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, | ||
204 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, | ||
205 | string assetType,UUID AgentID) | ||
206 | { | ||
207 | |||
208 | sbyte assType = 0; | ||
209 | sbyte inType = 0; | ||
210 | |||
211 | if (inventoryType == "sound") | ||
212 | { | ||
213 | inType = 1; | ||
214 | assType = 1; | ||
215 | } | ||
216 | else if (inventoryType == "animation") | ||
217 | { | ||
218 | inType = 19; | ||
219 | assType = 20; | ||
220 | } | ||
221 | else if (inventoryType == "wearable") | ||
222 | { | ||
223 | inType = 18; | ||
224 | switch (assetType) | ||
225 | { | ||
226 | case "bodypart": | ||
227 | assType = 13; | ||
228 | break; | ||
229 | case "clothing": | ||
230 | assType = 5; | ||
231 | break; | ||
232 | } | ||
233 | } | ||
234 | else if (inventoryType == "mesh") | ||
235 | { | ||
236 | inType = (sbyte)InventoryType.Mesh; | ||
237 | assType = (sbyte)AssetType.Mesh; | ||
238 | } | ||
239 | |||
240 | AssetBase asset; | ||
241 | asset = new AssetBase(assetID, assetName, assType, AgentID.ToString()); | ||
242 | asset.Data = data; | ||
243 | |||
244 | if (m_scene.AssetService != null) | ||
245 | m_scene.AssetService.Store(asset); | ||
246 | |||
247 | InventoryItemBase item = new InventoryItemBase(); | ||
248 | item.Owner = AgentID; | ||
249 | item.CreatorId = AgentID.ToString(); | ||
250 | item.ID = inventoryItem; | ||
251 | item.AssetID = asset.FullID; | ||
252 | item.Description = assetDescription; | ||
253 | item.Name = assetName; | ||
254 | item.AssetType = assType; | ||
255 | item.InvType = inType; | ||
256 | item.Folder = parentFolder; | ||
257 | item.CurrentPermissions = (uint)PermissionMask.All; | ||
258 | item.BasePermissions = (uint)PermissionMask.All; | ||
259 | item.EveryOnePermissions = 0; | ||
260 | item.NextPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); | ||
261 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
262 | m_scene.AddInventoryItem(item); | ||
263 | |||
264 | } | ||
265 | } | ||
266 | } | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 457e0bb..2a0c0b1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -113,6 +113,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
113 | if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) | 113 | if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) |
114 | return; | 114 | return; |
115 | 115 | ||
116 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should | ||
117 | // be removed when that functionality is implemented in opensim | ||
118 | AttachmentPt &= 0x7f; | ||
119 | |||
116 | // Calls attach with a Zero position | 120 | // Calls attach with a Zero position |
117 | if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false)) | 121 | if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false)) |
118 | { | 122 | { |
@@ -142,6 +146,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
142 | 146 | ||
143 | if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) | 147 | if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) |
144 | { | 148 | { |
149 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should | ||
150 | // be removed when that functionality is implemented in opensim | ||
151 | AttachmentPt &= 0x7f; | ||
152 | |||
145 | // If the attachment point isn't the same as the one previously used | 153 | // If the attachment point isn't the same as the one previously used |
146 | // set it's offset position = 0 so that it appears on the attachment point | 154 | // set it's offset position = 0 so that it appears on the attachment point |
147 | // and not in a weird location somewhere unknown. | 155 | // and not in a weird location somewhere unknown. |
@@ -228,6 +236,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
228 | "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", | 236 | "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", |
229 | (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); | 237 | (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); |
230 | 238 | ||
239 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should | ||
240 | // be removed when that functionality is implemented in opensim | ||
241 | AttachmentPt &= 0x7f; | ||
242 | |||
231 | SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt); | 243 | SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt); |
232 | 244 | ||
233 | if (updateInventoryStatus) | 245 | if (updateInventoryStatus) |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 6b538f6..f1f5258 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -51,6 +51,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
51 | public class ArchiveReadRequest | 51 | public class ArchiveReadRequest |
52 | { | 52 | { |
53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
54 | |||
55 | /// <summary> | ||
56 | /// The maximum major version of OAR that we can read. Minor versions shouldn't need a number since version | ||
57 | /// bumps here should be compatible. | ||
58 | /// </summary> | ||
59 | public static int MAX_MAJOR_VERSION = 0; | ||
54 | 60 | ||
55 | protected Scene m_scene; | 61 | protected Scene m_scene; |
56 | protected Stream m_loadStream; | 62 | protected Stream m_loadStream; |
@@ -497,6 +503,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
497 | { | 503 | { |
498 | if (xtr.NodeType == XmlNodeType.Element) | 504 | if (xtr.NodeType == XmlNodeType.Element) |
499 | { | 505 | { |
506 | if (xtr.Name.ToString() == "archive") | ||
507 | { | ||
508 | int majorVersion = int.Parse(xtr["major_version"]); | ||
509 | int minorVersion = int.Parse(xtr["minor_version"]); | ||
510 | string version = string.Format("{0}.{1}", majorVersion, minorVersion); | ||
511 | |||
512 | if (majorVersion > MAX_MAJOR_VERSION) | ||
513 | { | ||
514 | throw new Exception( | ||
515 | string.Format( | ||
516 | "The OAR you are trying to load has major version number of {0} but this version of OpenSim can only load OARs with major version number {1} and below", | ||
517 | majorVersion, MAX_MAJOR_VERSION)); | ||
518 | } | ||
519 | |||
520 | m_log.InfoFormat("[ARCHIVER]: Loading OAR with version {0}", version); | ||
521 | } | ||
500 | if (xtr.Name.ToString() == "datetime") | 522 | if (xtr.Name.ToString() == "datetime") |
501 | { | 523 | { |
502 | int value; | 524 | int value; |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs index 586d98e..c062833 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs | |||
@@ -60,6 +60,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
60 | protected Scene m_scene; | 60 | protected Scene m_scene; |
61 | protected TarArchiveWriter m_archiveWriter; | 61 | protected TarArchiveWriter m_archiveWriter; |
62 | protected Guid m_requestId; | 62 | protected Guid m_requestId; |
63 | protected Dictionary<string, object> m_options; | ||
63 | 64 | ||
64 | public ArchiveWriteRequestExecution( | 65 | public ArchiveWriteRequestExecution( |
65 | List<SceneObjectGroup> sceneObjects, | 66 | List<SceneObjectGroup> sceneObjects, |
@@ -67,7 +68,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
67 | IRegionSerialiserModule serialiser, | 68 | IRegionSerialiserModule serialiser, |
68 | Scene scene, | 69 | Scene scene, |
69 | TarArchiveWriter archiveWriter, | 70 | TarArchiveWriter archiveWriter, |
70 | Guid requestId) | 71 | Guid requestId, |
72 | Dictionary<string, object> options) | ||
71 | { | 73 | { |
72 | m_sceneObjects = sceneObjects; | 74 | m_sceneObjects = sceneObjects; |
73 | m_terrainModule = terrainModule; | 75 | m_terrainModule = terrainModule; |
@@ -75,6 +77,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
75 | m_scene = scene; | 77 | m_scene = scene; |
76 | m_archiveWriter = archiveWriter; | 78 | m_archiveWriter = archiveWriter; |
77 | m_requestId = requestId; | 79 | m_requestId = requestId; |
80 | m_options = options; | ||
78 | } | 81 | } |
79 | 82 | ||
80 | protected internal void ReceivedAllAssets( | 83 | protected internal void ReceivedAllAssets( |
@@ -105,12 +108,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
105 | // "[ARCHIVER]: Received {0} of {1} assets requested", | 108 | // "[ARCHIVER]: Received {0} of {1} assets requested", |
106 | // assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count); | 109 | // assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count); |
107 | 110 | ||
108 | m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time."); | ||
109 | |||
110 | // Write out control file | ||
111 | m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile()); | ||
112 | m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); | ||
113 | |||
114 | // Write out region settings | 111 | // Write out region settings |
115 | string settingsPath | 112 | string settingsPath |
116 | = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName); | 113 | = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName); |
@@ -140,47 +137,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
140 | 137 | ||
141 | m_log.InfoFormat("[ARCHIVER]: Added terrain information to archive."); | 138 | m_log.InfoFormat("[ARCHIVER]: Added terrain information to archive."); |
142 | 139 | ||
140 | Dictionary<string, object> serializationOptions = new Dictionary<string, object>(); | ||
141 | // if (m_options.ContainsKey("version") && (string)m_options["version"] == "0") | ||
142 | // serializationOptions["old-guids"] = true; | ||
143 | |||
143 | // Write out scene object metadata | 144 | // Write out scene object metadata |
144 | foreach (SceneObjectGroup sceneObject in m_sceneObjects) | 145 | foreach (SceneObjectGroup sceneObject in m_sceneObjects) |
145 | { | 146 | { |
146 | //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); | 147 | //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); |
147 | 148 | ||
148 | string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject); | 149 | string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject, serializationOptions); |
149 | m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject); | 150 | m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject); |
150 | } | 151 | } |
151 | 152 | ||
152 | m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive."); | 153 | m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive."); |
153 | } | 154 | } |
154 | 155 | ||
155 | /// <summary> | 156 | |
156 | /// Create the control file for a 0.2 version archive | ||
157 | /// </summary> | ||
158 | /// <returns></returns> | ||
159 | public static string Create0p2ControlFile() | ||
160 | { | ||
161 | StringWriter sw = new StringWriter(); | ||
162 | XmlTextWriter xtw = new XmlTextWriter(sw); | ||
163 | xtw.Formatting = Formatting.Indented; | ||
164 | xtw.WriteStartDocument(); | ||
165 | xtw.WriteStartElement("archive"); | ||
166 | xtw.WriteAttributeString("major_version", "0"); | ||
167 | xtw.WriteAttributeString("minor_version", "3"); | ||
168 | |||
169 | xtw.WriteStartElement("creation_info"); | ||
170 | DateTime now = DateTime.UtcNow; | ||
171 | TimeSpan t = now - new DateTime(1970, 1, 1); | ||
172 | xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString()); | ||
173 | xtw.WriteElementString("id", UUID.Random().ToString()); | ||
174 | xtw.WriteEndElement(); | ||
175 | xtw.WriteEndElement(); | ||
176 | |||
177 | xtw.Flush(); | ||
178 | xtw.Close(); | ||
179 | |||
180 | String s = sw.ToString(); | ||
181 | sw.Close(); | ||
182 | |||
183 | return s; | ||
184 | } | ||
185 | } | 157 | } |
186 | } | 158 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index 283b33b..43789af 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs | |||
@@ -32,6 +32,7 @@ using System.IO.Compression; | |||
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Text.RegularExpressions; | 33 | using System.Text.RegularExpressions; |
34 | using System.Threading; | 34 | using System.Threading; |
35 | using System.Xml; | ||
35 | using log4net; | 36 | using log4net; |
36 | using OpenMetaverse; | 37 | using OpenMetaverse; |
37 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
@@ -98,7 +99,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
98 | /// Archive the region requested. | 99 | /// Archive the region requested. |
99 | /// </summary> | 100 | /// </summary> |
100 | /// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception> | 101 | /// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception> |
101 | public void ArchiveRegion() | 102 | public void ArchiveRegion(Dictionary<string, object> options) |
102 | { | 103 | { |
103 | Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>(); | 104 | Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>(); |
104 | 105 | ||
@@ -165,11 +166,71 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
165 | m_scene.RequestModuleInterface<IRegionSerialiserModule>(), | 166 | m_scene.RequestModuleInterface<IRegionSerialiserModule>(), |
166 | m_scene, | 167 | m_scene, |
167 | archiveWriter, | 168 | archiveWriter, |
168 | m_requestId); | 169 | m_requestId, |
170 | options); | ||
171 | |||
172 | m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time."); | ||
173 | |||
174 | // Write out control file | ||
175 | archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile(options)); | ||
176 | m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); | ||
169 | 177 | ||
170 | new AssetsRequest( | 178 | new AssetsRequest( |
171 | new AssetsArchiver(archiveWriter), assetUuids, | 179 | new AssetsArchiver(archiveWriter), assetUuids, |
172 | m_scene.AssetService, awre.ReceivedAllAssets).Execute(); | 180 | m_scene.AssetService, awre.ReceivedAllAssets).Execute(); |
173 | } | 181 | } |
182 | |||
183 | /// <summary> | ||
184 | /// Create the control file for the most up to date archive | ||
185 | /// </summary> | ||
186 | /// <returns></returns> | ||
187 | public static string Create0p2ControlFile(Dictionary<string, object> options) | ||
188 | { | ||
189 | int majorVersion = 0, minorVersion = 4; | ||
190 | |||
191 | /* | ||
192 | if (options.ContainsKey("version") && (string)options["version"] == "0") | ||
193 | { | ||
194 | majorVersion = 0; | ||
195 | minorVersion = 3; | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | majorVersion = 1; | ||
200 | minorVersion = 0; | ||
201 | } | ||
202 | */ | ||
203 | |||
204 | m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion); | ||
205 | // if (majorVersion == 1) | ||
206 | // { | ||
207 | // m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR"); | ||
208 | // } | ||
209 | |||
210 | |||
211 | StringWriter sw = new StringWriter(); | ||
212 | XmlTextWriter xtw = new XmlTextWriter(sw); | ||
213 | xtw.Formatting = Formatting.Indented; | ||
214 | xtw.WriteStartDocument(); | ||
215 | xtw.WriteStartElement("archive"); | ||
216 | xtw.WriteAttributeString("major_version", majorVersion.ToString()); | ||
217 | xtw.WriteAttributeString("minor_version", minorVersion.ToString()); | ||
218 | |||
219 | xtw.WriteStartElement("creation_info"); | ||
220 | DateTime now = DateTime.UtcNow; | ||
221 | TimeSpan t = now - new DateTime(1970, 1, 1); | ||
222 | xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString()); | ||
223 | xtw.WriteElementString("id", UUID.Random().ToString()); | ||
224 | xtw.WriteEndElement(); | ||
225 | xtw.WriteEndElement(); | ||
226 | |||
227 | xtw.Flush(); | ||
228 | xtw.Close(); | ||
229 | |||
230 | String s = sw.ToString(); | ||
231 | sw.Close(); | ||
232 | |||
233 | return s; | ||
234 | } | ||
174 | } | 235 | } |
175 | } | 236 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index 82ede01..e0ad71e 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs | |||
@@ -122,37 +122,44 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
122 | /// <param name="cmdparams"></param> | 122 | /// <param name="cmdparams"></param> |
123 | public void HandleSaveOarConsoleCommand(string module, string[] cmdparams) | 123 | public void HandleSaveOarConsoleCommand(string module, string[] cmdparams) |
124 | { | 124 | { |
125 | Dictionary<string, object> options = new Dictionary<string, object>(); | ||
126 | |||
127 | OptionSet ops = new OptionSet(); | ||
128 | ops.Add("v|version=", delegate(string v) { options["version"] = v; }); | ||
129 | |||
130 | List<string> mainParams = ops.Parse(cmdparams); | ||
131 | |||
125 | if (cmdparams.Length > 2) | 132 | if (cmdparams.Length > 2) |
126 | { | 133 | { |
127 | ArchiveRegion(cmdparams[2]); | 134 | ArchiveRegion(mainParams[2], options); |
128 | } | 135 | } |
129 | else | 136 | else |
130 | { | 137 | { |
131 | ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME); | 138 | ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, options); |
132 | } | 139 | } |
133 | } | 140 | } |
134 | 141 | ||
135 | public void ArchiveRegion(string savePath) | 142 | public void ArchiveRegion(string savePath, Dictionary<string, object> options) |
136 | { | 143 | { |
137 | ArchiveRegion(savePath, Guid.Empty); | 144 | ArchiveRegion(savePath, Guid.Empty, options); |
138 | } | 145 | } |
139 | 146 | ||
140 | public void ArchiveRegion(string savePath, Guid requestId) | 147 | public void ArchiveRegion(string savePath, Guid requestId, Dictionary<string, object> options) |
141 | { | 148 | { |
142 | m_log.InfoFormat( | 149 | m_log.InfoFormat( |
143 | "[ARCHIVER]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath); | 150 | "[ARCHIVER]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath); |
144 | 151 | ||
145 | new ArchiveWriteRequestPreparation(m_scene, savePath, requestId).ArchiveRegion(); | 152 | new ArchiveWriteRequestPreparation(m_scene, savePath, requestId).ArchiveRegion(options); |
146 | } | 153 | } |
147 | 154 | ||
148 | public void ArchiveRegion(Stream saveStream) | 155 | public void ArchiveRegion(Stream saveStream) |
149 | { | 156 | { |
150 | ArchiveRegion(saveStream, Guid.Empty); | 157 | ArchiveRegion(saveStream, Guid.Empty); |
151 | } | 158 | } |
152 | 159 | ||
153 | public void ArchiveRegion(Stream saveStream, Guid requestId) | 160 | public void ArchiveRegion(Stream saveStream, Guid requestId) |
154 | { | 161 | { |
155 | new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion(); | 162 | new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion(new Dictionary<string, object>()); |
156 | } | 163 | } |
157 | 164 | ||
158 | public void DearchiveRegion(string loadPath) | 165 | public void DearchiveRegion(string loadPath) |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 3342164..04bdc4f 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | |||
@@ -230,7 +230,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
230 | // upset load | 230 | // upset load |
231 | tar.WriteDir(ArchiveConstants.TERRAINS_PATH); | 231 | tar.WriteDir(ArchiveConstants.TERRAINS_PATH); |
232 | 232 | ||
233 | tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile()); | 233 | tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile(new Dictionary<string, Object>())); |
234 | 234 | ||
235 | SceneObjectPart part1 = CreateSceneObjectPart1(); | 235 | SceneObjectPart part1 = CreateSceneObjectPart1(); |
236 | SceneObjectGroup object1 = new SceneObjectGroup(part1); | 236 | SceneObjectGroup object1 = new SceneObjectGroup(part1); |
@@ -329,7 +329,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
329 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); | 329 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); |
330 | 330 | ||
331 | tar.WriteDir(ArchiveConstants.TERRAINS_PATH); | 331 | tar.WriteDir(ArchiveConstants.TERRAINS_PATH); |
332 | tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile()); | 332 | tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile(new Dictionary<string, Object>())); |
333 | 333 | ||
334 | RegionSettings rs = new RegionSettings(); | 334 | RegionSettings rs = new RegionSettings(); |
335 | rs.AgentLimit = 17; | 335 | rs.AgentLimit = 17; |
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs index 04062b0..ec97acd 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs | |||
@@ -160,9 +160,9 @@ namespace OpenSim.Region.CoreModules.World.Serialiser | |||
160 | return SceneXmlLoader.DeserializeGroupFromXml2(xmlString); | 160 | return SceneXmlLoader.DeserializeGroupFromXml2(xmlString); |
161 | } | 161 | } |
162 | 162 | ||
163 | public string SerializeGroupToXml2(SceneObjectGroup grp) | 163 | public string SerializeGroupToXml2(SceneObjectGroup grp, Dictionary<string, object> options) |
164 | { | 164 | { |
165 | return SceneXmlLoader.SaveGroupToXml2(grp); | 165 | return SceneXmlLoader.SaveGroupToXml2(grp, options); |
166 | } | 166 | } |
167 | 167 | ||
168 | public void SavePrimListToXml2(EntityBase[] entityList, string fileName) | 168 | public void SavePrimListToXml2(EntityBase[] entityList, string fileName) |
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index 799a448..f10e848 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs | |||
@@ -25,6 +25,9 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | ||
29 | using System.IO; | ||
30 | using System.Xml; | ||
28 | using log4net.Config; | 31 | using log4net.Config; |
29 | using NUnit.Framework; | 32 | using NUnit.Framework; |
30 | using NUnit.Framework.SyntaxHelpers; | 33 | using NUnit.Framework.SyntaxHelpers; |
@@ -34,8 +37,6 @@ using OpenSim.Region.Framework.Scenes; | |||
34 | using OpenSim.Region.Framework.Scenes.Serialization; | 37 | using OpenSim.Region.Framework.Scenes.Serialization; |
35 | using OpenSim.Tests.Common; | 38 | using OpenSim.Tests.Common; |
36 | using OpenSim.Tests.Common.Setup; | 39 | using OpenSim.Tests.Common.Setup; |
37 | using System.IO; | ||
38 | using System.Xml; | ||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | 41 | namespace OpenSim.Region.CoreModules.World.Serialiser.Tests |
41 | { | 42 | { |
@@ -302,15 +303,19 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | |||
302 | { | 303 | { |
303 | case "UUID": | 304 | case "UUID": |
304 | xtr.ReadStartElement("UUID"); | 305 | xtr.ReadStartElement("UUID"); |
305 | uuid = UUID.Parse(xtr.ReadElementString("Guid")); | 306 | try |
306 | xtr.ReadEndElement(); | 307 | { |
308 | uuid = UUID.Parse(xtr.ReadElementString("UUID")); | ||
309 | xtr.ReadEndElement(); | ||
310 | } | ||
311 | catch { } // ignore everything but <UUID><UUID>...</UUID></UUID> | ||
307 | break; | 312 | break; |
308 | case "Name": | 313 | case "Name": |
309 | name = xtr.ReadElementContentAsString(); | 314 | name = xtr.ReadElementContentAsString(); |
310 | break; | 315 | break; |
311 | case "CreatorID": | 316 | case "CreatorID": |
312 | xtr.ReadStartElement("CreatorID"); | 317 | xtr.ReadStartElement("CreatorID"); |
313 | creatorId = UUID.Parse(xtr.ReadElementString("Guid")); | 318 | creatorId = UUID.Parse(xtr.ReadElementString("UUID")); |
314 | xtr.ReadEndElement(); | 319 | xtr.ReadEndElement(); |
315 | break; | 320 | break; |
316 | } | 321 | } |
@@ -369,7 +374,9 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | |||
369 | // Need to add the object to the scene so that the request to get script state succeeds | 374 | // Need to add the object to the scene so that the request to get script state succeeds |
370 | m_scene.AddSceneObject(so); | 375 | m_scene.AddSceneObject(so); |
371 | 376 | ||
372 | string xml2 = m_serialiserModule.SerializeGroupToXml2(so); | 377 | Dictionary<string, object> options = new Dictionary<string, object>(); |
378 | options["old-guids"] = true; | ||
379 | string xml2 = m_serialiserModule.SerializeGroupToXml2(so, options); | ||
373 | 380 | ||
374 | XmlTextReader xtr = new XmlTextReader(new StringReader(xml2)); | 381 | XmlTextReader xtr = new XmlTextReader(new StringReader(xml2)); |
375 | xtr.ReadStartElement("SceneObjectGroup"); | 382 | xtr.ReadStartElement("SceneObjectGroup"); |