diff options
author | Melanie | 2010-10-21 07:33:01 +0100 |
---|---|---|
committer | Melanie | 2010-10-21 07:33:01 +0100 |
commit | fc33d569cd760b0ecf2d487b8d91d4ac3c53d08e (patch) | |
tree | ffe3d70e95b159dc4c7b3bf9613bca865d4067d3 /OpenSim/Region/CoreModules/Avatar | |
parent | COmmented the wrong line instead, now I commented them all to be on the safe ... (diff) | |
parent | Skip empty strings in ParseString* functions (diff) | |
download | opensim-SC-fc33d569cd760b0ecf2d487b8d91d4ac3c53d08e.zip opensim-SC-fc33d569cd760b0ecf2d487b8d91d4ac3c53d08e.tar.gz opensim-SC-fc33d569cd760b0ecf2d487b8d91d4ac3c53d08e.tar.bz2 opensim-SC-fc33d569cd760b0ecf2d487b8d91d4ac3c53d08e.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
3 files changed, 384 insertions, 5 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index d8e0f96..80adc46 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | |||
@@ -598,7 +598,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
598 | try | 598 | try |
599 | { | 599 | { |
600 | 600 | ||
601 | XmlRpcResponse GridResp = GridReq.Send("http://" + reginfo.ExternalHostName + ":" + reginfo.HttpPort, 3000); | 601 | XmlRpcResponse GridResp = GridReq.Send(reginfo.ServerURI, 3000); |
602 | 602 | ||
603 | Hashtable responseData = (Hashtable)GridResp.Value; | 603 | Hashtable responseData = (Hashtable)GridResp.Value; |
604 | 604 | ||
@@ -620,8 +620,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
620 | } | 620 | } |
621 | catch (WebException e) | 621 | catch (WebException e) |
622 | { | 622 | { |
623 | m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to http://{0}:{1} the host didn't respond ({2})", | 623 | m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to {0}} the host didn't respond ({2})", |
624 | reginfo.ExternalHostName, reginfo.HttpPort, e.Message); | 624 | reginfo.ServerURI, e.Message); |
625 | } | 625 | } |
626 | 626 | ||
627 | return false; | 627 | return false; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index a08a628..6badc74 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -159,8 +159,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
159 | 159 | ||
160 | private void OnInstantMessage(IClientAPI client, GridInstantMessage im) | 160 | private void OnInstantMessage(IClientAPI client, GridInstantMessage im) |
161 | { | 161 | { |
162 | //m_log.InfoFormat("[INVENTORY TRANSFER]: OnInstantMessage {0}", im.dialog); | 162 | // m_log.DebugFormat( |
163 | 163 | // "[INVENTORY TRANSFER]: {0} IM type received from {1}", | |
164 | // (InstantMessageDialog)im.dialog, client.Name); | ||
165 | |||
164 | Scene scene = FindClientScene(client.AgentId); | 166 | Scene scene = FindClientScene(client.AgentId); |
165 | 167 | ||
166 | if (scene == null) // Something seriously wrong here. | 168 | if (scene == null) // Something seriously wrong here. |
diff --git a/OpenSim/Region/CoreModules/Avatar/ObjectCaps/UploadObjectAssetModule.cs b/OpenSim/Region/CoreModules/Avatar/ObjectCaps/UploadObjectAssetModule.cs new file mode 100644 index 0000000..09b9719 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/ObjectCaps/UploadObjectAssetModule.cs | |||
@@ -0,0 +1,377 @@ | |||
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 OpenMetaverse.Messages.Linden; | ||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Framework.Servers; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | ||
43 | using OpenSim.Region.Framework.Interfaces; | ||
44 | using OpenSim.Region.Framework.Scenes; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
47 | using OSD = OpenMetaverse.StructuredData.OSD; | ||
48 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | ||
49 | using OpenSim.Framework.Capabilities; | ||
50 | using ExtraParamType = OpenMetaverse.ExtraParamType; | ||
51 | |||
52 | namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps | ||
53 | { | ||
54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
55 | public class UploadObjectAssetModule : INonSharedRegionModule | ||
56 | { | ||
57 | private static readonly ILog m_log = | ||
58 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
59 | private Scene m_scene; | ||
60 | |||
61 | #region IRegionModuleBase Members | ||
62 | |||
63 | |||
64 | public Type ReplaceableInterface | ||
65 | { | ||
66 | get { return null; } | ||
67 | } | ||
68 | |||
69 | public void Initialise(IConfigSource source) | ||
70 | { | ||
71 | |||
72 | } | ||
73 | |||
74 | public void AddRegion(Scene pScene) | ||
75 | { | ||
76 | m_scene = pScene; | ||
77 | } | ||
78 | |||
79 | public void RemoveRegion(Scene scene) | ||
80 | { | ||
81 | |||
82 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | ||
83 | m_scene = null; | ||
84 | } | ||
85 | |||
86 | public void RegionLoaded(Scene scene) | ||
87 | { | ||
88 | |||
89 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | ||
90 | } | ||
91 | |||
92 | #endregion | ||
93 | |||
94 | |||
95 | #region IRegionModule Members | ||
96 | |||
97 | |||
98 | |||
99 | public void Close() { } | ||
100 | |||
101 | public string Name { get { return "UploadObjectAssetModuleModule"; } } | ||
102 | |||
103 | |||
104 | public void RegisterCaps(UUID agentID, Caps caps) | ||
105 | { | ||
106 | UUID capID = UUID.Random(); | ||
107 | |||
108 | m_log.Info("[UploadObjectAssetModule]: /CAPS/" + capID); | ||
109 | caps.RegisterHandler("UploadObjectAsset", | ||
110 | new RestHTTPHandler("POST", "/CAPS/OA/" + capID + "/", | ||
111 | delegate(Hashtable m_dhttpMethod) | ||
112 | { | ||
113 | return ProcessAdd(m_dhttpMethod, agentID, caps); | ||
114 | })); | ||
115 | /* | ||
116 | caps.RegisterHandler("NewFileAgentInventoryVariablePrice", | ||
117 | |||
118 | new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDNewFileAngentInventoryVariablePriceReplyResponse>("POST", | ||
119 | "/CAPS/" + capID.ToString(), | ||
120 | delegate(LLSDAssetUploadRequest req) | ||
121 | { | ||
122 | return NewAgentInventoryRequest(req,agentID); | ||
123 | })); | ||
124 | */ | ||
125 | |||
126 | } | ||
127 | |||
128 | #endregion | ||
129 | |||
130 | |||
131 | /// <summary> | ||
132 | /// Parses ad request | ||
133 | /// </summary> | ||
134 | /// <param name="request"></param> | ||
135 | /// <param name="AgentId"></param> | ||
136 | /// <param name="cap"></param> | ||
137 | /// <returns></returns> | ||
138 | public Hashtable ProcessAdd(Hashtable request, UUID AgentId, Caps cap) | ||
139 | { | ||
140 | Hashtable responsedata = new Hashtable(); | ||
141 | responsedata["int_response_code"] = 400; //501; //410; //404; | ||
142 | responsedata["content_type"] = "text/plain"; | ||
143 | responsedata["keepalive"] = false; | ||
144 | responsedata["str_response_string"] = "Request wasn't what was expected"; | ||
145 | ScenePresence avatar; | ||
146 | |||
147 | if (!m_scene.TryGetScenePresence(AgentId, out avatar)) | ||
148 | return responsedata; | ||
149 | |||
150 | OSDMap r = (OSDMap)OSDParser.Deserialize((string)request["requestbody"]); | ||
151 | UploadObjectAssetMessage message = new UploadObjectAssetMessage(); | ||
152 | try | ||
153 | { | ||
154 | message.Deserialize(r); | ||
155 | |||
156 | } | ||
157 | catch (Exception ex) | ||
158 | { | ||
159 | m_log.Error("[UploadObjectAssetModule]: Error deserializing message " + ex.ToString()); | ||
160 | message = null; | ||
161 | } | ||
162 | |||
163 | if (message == null) | ||
164 | { | ||
165 | responsedata["int_response_code"] = 400; //501; //410; //404; | ||
166 | responsedata["content_type"] = "text/plain"; | ||
167 | responsedata["keepalive"] = false; | ||
168 | responsedata["str_response_string"] = | ||
169 | "<llsd><map><key>error</key><string>Error parsing Object</string></map></llsd>"; | ||
170 | |||
171 | return responsedata; | ||
172 | } | ||
173 | |||
174 | Vector3 pos = avatar.AbsolutePosition + (Vector3.UnitX * avatar.Rotation); | ||
175 | Quaternion rot = Quaternion.Identity; | ||
176 | Vector3 rootpos = Vector3.Zero; | ||
177 | Quaternion rootrot = Quaternion.Identity; | ||
178 | |||
179 | SceneObjectGroup rootGroup = null; | ||
180 | SceneObjectGroup[] allparts = new SceneObjectGroup[message.Objects.Length]; | ||
181 | for (int i = 0; i < message.Objects.Length; i++) | ||
182 | { | ||
183 | UploadObjectAssetMessage.Object obj = message.Objects[i]; | ||
184 | PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); | ||
185 | |||
186 | if (i == 0) | ||
187 | { | ||
188 | rootpos = obj.Position; | ||
189 | rootrot = obj.Rotation; | ||
190 | |||
191 | } | ||
192 | |||
193 | |||
194 | // Combine the extraparams data into it's ugly blob again.... | ||
195 | //int bytelength = 0; | ||
196 | //for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++) | ||
197 | //{ | ||
198 | // bytelength += obj.ExtraParams[extparams].ExtraParamData.Length; | ||
199 | //} | ||
200 | //byte[] extraparams = new byte[bytelength]; | ||
201 | //int position = 0; | ||
202 | |||
203 | |||
204 | |||
205 | //for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++) | ||
206 | //{ | ||
207 | // Buffer.BlockCopy(obj.ExtraParams[extparams].ExtraParamData, 0, extraparams, position, | ||
208 | // obj.ExtraParams[extparams].ExtraParamData.Length); | ||
209 | // | ||
210 | // position += obj.ExtraParams[extparams].ExtraParamData.Length; | ||
211 | // } | ||
212 | |||
213 | //pbs.ExtraParams = extraparams; | ||
214 | for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++) | ||
215 | { | ||
216 | UploadObjectAssetMessage.Object.ExtraParam extraParam = obj.ExtraParams[extparams]; | ||
217 | switch ((ushort)extraParam.Type) | ||
218 | { | ||
219 | case (ushort)ExtraParamType.Sculpt: | ||
220 | Primitive.SculptData sculpt = new Primitive.SculptData(extraParam.ExtraParamData, 0); | ||
221 | |||
222 | pbs.SculptEntry = true; | ||
223 | |||
224 | pbs.SculptTexture = obj.SculptID; | ||
225 | pbs.SculptType = (byte)sculpt.Type; | ||
226 | |||
227 | break; | ||
228 | case (ushort)ExtraParamType.Flexible: | ||
229 | Primitive.FlexibleData flex = new Primitive.FlexibleData(extraParam.ExtraParamData, 0); | ||
230 | pbs.FlexiEntry = true; | ||
231 | pbs.FlexiDrag = flex.Drag; | ||
232 | pbs.FlexiForceX = flex.Force.X; | ||
233 | pbs.FlexiForceY = flex.Force.Y; | ||
234 | pbs.FlexiForceZ = flex.Force.Z; | ||
235 | pbs.FlexiGravity = flex.Gravity; | ||
236 | pbs.FlexiSoftness = flex.Softness; | ||
237 | pbs.FlexiTension = flex.Tension; | ||
238 | pbs.FlexiWind = flex.Wind; | ||
239 | break; | ||
240 | case (ushort)ExtraParamType.Light: | ||
241 | Primitive.LightData light = new Primitive.LightData(extraParam.ExtraParamData, 0); | ||
242 | pbs.LightColorA = light.Color.A; | ||
243 | pbs.LightColorB = light.Color.B; | ||
244 | pbs.LightColorG = light.Color.G; | ||
245 | pbs.LightColorR = light.Color.R; | ||
246 | pbs.LightCutoff = light.Cutoff; | ||
247 | pbs.LightEntry = true; | ||
248 | pbs.LightFalloff = light.Falloff; | ||
249 | pbs.LightIntensity = light.Intensity; | ||
250 | pbs.LightRadius = light.Radius; | ||
251 | break; | ||
252 | case 0x40: | ||
253 | pbs.ReadProjectionData(extraParam.ExtraParamData, 0); | ||
254 | break; | ||
255 | |||
256 | } | ||
257 | |||
258 | |||
259 | } | ||
260 | pbs.PathBegin = (ushort) obj.PathBegin; | ||
261 | pbs.PathCurve = (byte) obj.PathCurve; | ||
262 | pbs.PathEnd = (ushort) obj.PathEnd; | ||
263 | pbs.PathRadiusOffset = (sbyte) obj.RadiusOffset; | ||
264 | pbs.PathRevolutions = (byte) obj.Revolutions; | ||
265 | pbs.PathScaleX = (byte) obj.ScaleX; | ||
266 | pbs.PathScaleY = (byte) obj.ScaleY; | ||
267 | pbs.PathShearX = (byte) obj.ShearX; | ||
268 | pbs.PathShearY = (byte) obj.ShearY; | ||
269 | pbs.PathSkew = (sbyte) obj.Skew; | ||
270 | pbs.PathTaperX = (sbyte) obj.TaperX; | ||
271 | pbs.PathTaperY = (sbyte) obj.TaperY; | ||
272 | pbs.PathTwist = (sbyte) obj.Twist; | ||
273 | pbs.PathTwistBegin = (sbyte) obj.TwistBegin; | ||
274 | pbs.HollowShape = (HollowShape) obj.ProfileHollow; | ||
275 | pbs.PCode = (byte) PCode.Prim; | ||
276 | pbs.ProfileBegin = (ushort) obj.ProfileBegin; | ||
277 | pbs.ProfileCurve = (byte) obj.ProfileCurve; | ||
278 | pbs.ProfileEnd = (ushort) obj.ProfileEnd; | ||
279 | pbs.Scale = obj.Scale; | ||
280 | pbs.State = (byte) 0; | ||
281 | SceneObjectPart prim = new SceneObjectPart(); | ||
282 | prim.UUID = UUID.Random(); | ||
283 | prim.CreatorID = AgentId; | ||
284 | prim.OwnerID = AgentId; | ||
285 | prim.GroupID = obj.GroupID; | ||
286 | prim.LastOwnerID = prim.OwnerID; | ||
287 | prim.CreationDate = Util.UnixTimeSinceEpoch(); | ||
288 | prim.Name = obj.Name; | ||
289 | prim.Description = ""; | ||
290 | |||
291 | prim.PayPrice[0] = -2; | ||
292 | prim.PayPrice[1] = -2; | ||
293 | prim.PayPrice[2] = -2; | ||
294 | prim.PayPrice[3] = -2; | ||
295 | prim.PayPrice[4] = -2; | ||
296 | Primitive.TextureEntry tmp = | ||
297 | new Primitive.TextureEntry(UUID.Parse("89556747-24cb-43ed-920b-47caed15465f")); | ||
298 | |||
299 | for (int j = 0; j < obj.Faces.Length; j++) | ||
300 | { | ||
301 | UploadObjectAssetMessage.Object.Face face = obj.Faces[j]; | ||
302 | |||
303 | Primitive.TextureEntryFace primFace = tmp.CreateFace((uint) j); | ||
304 | |||
305 | primFace.Bump = face.Bump; | ||
306 | primFace.RGBA = face.Color; | ||
307 | primFace.Fullbright = face.Fullbright; | ||
308 | primFace.Glow = face.Glow; | ||
309 | primFace.TextureID = face.ImageID; | ||
310 | primFace.Rotation = face.ImageRot; | ||
311 | primFace.MediaFlags = ((face.MediaFlags & 1) != 0); | ||
312 | |||
313 | primFace.OffsetU = face.OffsetS; | ||
314 | primFace.OffsetV = face.OffsetT; | ||
315 | primFace.RepeatU = face.ScaleS; | ||
316 | primFace.RepeatV = face.ScaleT; | ||
317 | primFace.TexMapType = (MappingType) (face.MediaFlags & 6); | ||
318 | } | ||
319 | pbs.TextureEntry = tmp.GetBytes(); | ||
320 | prim.Shape = pbs; | ||
321 | prim.Scale = obj.Scale; | ||
322 | |||
323 | |||
324 | SceneObjectGroup grp = new SceneObjectGroup(); | ||
325 | |||
326 | grp.SetRootPart(prim); | ||
327 | prim.ParentID = 0; | ||
328 | if (i == 0) | ||
329 | { | ||
330 | rootGroup = grp; | ||
331 | |||
332 | } | ||
333 | grp.AttachToScene(m_scene); | ||
334 | grp.AbsolutePosition = obj.Position; | ||
335 | prim.RotationOffset = obj.Rotation; | ||
336 | |||
337 | grp.RootPart.IsAttachment = false; | ||
338 | // Required for linking | ||
339 | grp.RootPart.UpdateFlag = 0; | ||
340 | |||
341 | if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos)) | ||
342 | { | ||
343 | m_scene.AddSceneObject(grp); | ||
344 | grp.AbsolutePosition = obj.Position; | ||
345 | } | ||
346 | allparts[i] = grp; | ||
347 | |||
348 | } | ||
349 | |||
350 | for (int j = 1; j < allparts.Length; j++) | ||
351 | { | ||
352 | rootGroup.RootPart.UpdateFlag = 0; | ||
353 | allparts[j].RootPart.UpdateFlag = 0; | ||
354 | rootGroup.LinkToGroup(allparts[j]); | ||
355 | } | ||
356 | |||
357 | rootGroup.ScheduleGroupForFullUpdate(); | ||
358 | pos = m_scene.GetNewRezLocation(Vector3.Zero, rootpos, UUID.Zero, rot, (byte)1, 1, true, allparts[0].GroupScale(), false); | ||
359 | |||
360 | responsedata["int_response_code"] = 200; //501; //410; //404; | ||
361 | responsedata["content_type"] = "text/plain"; | ||
362 | responsedata["keepalive"] = false; | ||
363 | responsedata["str_response_string"] = String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>", ConvertUintToBytes(allparts[0].LocalId)); | ||
364 | |||
365 | return responsedata; | ||
366 | |||
367 | |||
368 | } | ||
369 | private string ConvertUintToBytes(uint val) | ||
370 | { | ||
371 | byte[] resultbytes = Utils.UIntToBytes(val); | ||
372 | if (BitConverter.IsLittleEndian) | ||
373 | Array.Reverse(resultbytes); | ||
374 | return String.Format("<binary encoding=\"base64\">{0}</binary>", Convert.ToBase64String(resultbytes)); | ||
375 | } | ||
376 | } | ||
377 | } | ||