move UploadObjectAsset to simpleh..
parent
88a81a9ca4
commit
52f50d2035
|
@ -27,7 +27,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
|
@ -54,13 +54,12 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UploadObjectAssetModule")]
|
||||
public class UploadObjectAssetModule : INonSharedRegionModule
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private Scene m_scene;
|
||||
|
||||
#region Region Module interfaceBase Members
|
||||
|
||||
|
||||
public Type ReplaceableInterface
|
||||
{
|
||||
get { return null; }
|
||||
|
@ -68,7 +67,6 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
|
||||
public void Initialise(IConfigSource source)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void AddRegion(Scene pScene)
|
||||
|
@ -78,14 +76,12 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
|
||||
m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
|
||||
m_scene = null;
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
|
||||
m_scene.EventManager.OnRegisterCaps += RegisterCaps;
|
||||
}
|
||||
|
||||
|
@ -94,8 +90,6 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
|
||||
#region Region Module interface
|
||||
|
||||
|
||||
|
||||
public void Close() { }
|
||||
|
||||
public string Name { get { return "UploadObjectAssetModuleModule"; } }
|
||||
|
@ -103,29 +97,12 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
|
||||
public void RegisterCaps(UUID agentID, Caps caps)
|
||||
{
|
||||
string capUrl = "/CAPS/" + UUID.Random() + "/";
|
||||
|
||||
// m_log.Debug("[UPLOAD OBJECT ASSET MODULE]: /CAPS/" + capID);
|
||||
caps.RegisterHandler(
|
||||
"UploadObjectAsset",
|
||||
new RestHTTPHandler(
|
||||
"POST",
|
||||
capUrl,
|
||||
httpMethod => ProcessAdd(httpMethod, agentID, caps),
|
||||
"UploadObjectAsset",
|
||||
agentID.ToString()));
|
||||
|
||||
/*
|
||||
caps.RegisterHandler("NewFileAgentInventoryVariablePrice",
|
||||
|
||||
new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDNewFileAngentInventoryVariablePriceReplyResponse>("POST",
|
||||
"/CAPS/" + capID.ToString(),
|
||||
delegate(LLSDAssetUploadRequest req)
|
||||
caps.RegisterSimpleHandler("UploadObjectAsset",
|
||||
new SimpleOSDMapHandler("POST","/" + UUID.Random(), delegate (IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, OSDMap map)
|
||||
{
|
||||
return NewAgentInventoryRequest(req,agentID);
|
||||
ProcessAdd(httpRequest, httpResponse, map, agentID, caps);
|
||||
}));
|
||||
*/
|
||||
|
||||
// m_log.Debug("[UPLOAD OBJECT ASSET MODULE]: /CAPS/" + capID);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -135,26 +112,23 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
/// Parses add request
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="AgentId"></param>
|
||||
/// <param name="agentID"></param>
|
||||
/// <param name="cap"></param>
|
||||
/// <returns></returns>
|
||||
public Hashtable ProcessAdd(Hashtable request, UUID AgentId, Caps cap)
|
||||
public void ProcessAdd(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, OSDMap map, UUID agentID, Caps cap)
|
||||
{
|
||||
Hashtable responsedata = new Hashtable();
|
||||
responsedata["int_response_code"] = 400; //501; //410; //404;
|
||||
responsedata["content_type"] = "text/plain";
|
||||
responsedata["keepalive"] = false;
|
||||
responsedata["str_response_string"] = "Request wasn't what was expected";
|
||||
ScenePresence avatar;
|
||||
httpResponse.KeepAlive = false;
|
||||
|
||||
if (!m_scene.TryGetScenePresence(AgentId, out avatar))
|
||||
return responsedata;
|
||||
if (!m_scene.TryGetScenePresence(agentID, out ScenePresence avatar))
|
||||
{
|
||||
httpResponse.StatusCode = (int)HttpStatusCode.Gone;
|
||||
return;
|
||||
}
|
||||
|
||||
OSDMap r = (OSDMap)OSDParser.Deserialize((string)request["requestbody"]);
|
||||
UploadObjectAssetMessage message = new UploadObjectAssetMessage();
|
||||
try
|
||||
{
|
||||
message.Deserialize(r);
|
||||
message.Deserialize(map);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -165,19 +139,15 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
|
||||
if (message == null)
|
||||
{
|
||||
responsedata["int_response_code"] = 400; //501; //410; //404;
|
||||
responsedata["content_type"] = "text/plain";
|
||||
responsedata["keepalive"] = false;
|
||||
responsedata["str_response_string"] =
|
||||
"<llsd><map><key>error</key><string>Error parsing Object</string></map></llsd>";
|
||||
|
||||
return responsedata;
|
||||
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Vector3 pos = avatar.AbsolutePosition + (Vector3.UnitX * avatar.Rotation);
|
||||
Quaternion rot = Quaternion.Identity;
|
||||
Vector3 rootpos = Vector3.Zero;
|
||||
// Quaternion rootrot = Quaternion.Identity;
|
||||
|
||||
SceneObjectGroup rootGroup = null;
|
||||
SceneObjectGroup[] allparts = new SceneObjectGroup[message.Objects.Length];
|
||||
|
@ -187,31 +157,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
rootpos = obj.Position;
|
||||
// rootrot = obj.Rotation;
|
||||
}
|
||||
|
||||
// Combine the extraparams data into it's ugly blob again....
|
||||
//int bytelength = 0;
|
||||
//for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++)
|
||||
//{
|
||||
// bytelength += obj.ExtraParams[extparams].ExtraParamData.Length;
|
||||
//}
|
||||
//byte[] extraparams = new byte[bytelength];
|
||||
//int position = 0;
|
||||
|
||||
|
||||
|
||||
//for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++)
|
||||
//{
|
||||
// Buffer.BlockCopy(obj.ExtraParams[extparams].ExtraParamData, 0, extraparams, position,
|
||||
// obj.ExtraParams[extparams].ExtraParamData.Length);
|
||||
//
|
||||
// position += obj.ExtraParams[extparams].ExtraParamData.Length;
|
||||
// }
|
||||
|
||||
//pbs.ExtraParams = extraparams;
|
||||
for (int extparams = 0; extparams < obj.ExtraParams.Length; extparams++)
|
||||
{
|
||||
UploadObjectAssetMessage.Object.ExtraParam extraParam = obj.ExtraParams[extparams];
|
||||
|
@ -280,11 +227,11 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
pbs.LastAttachPoint = (byte) 0;
|
||||
SceneObjectPart prim = new SceneObjectPart();
|
||||
prim.UUID = UUID.Random();
|
||||
prim.CreatorID = AgentId;
|
||||
prim.OwnerID = AgentId;
|
||||
prim.CreatorID = agentID;
|
||||
prim.OwnerID = agentID;
|
||||
prim.GroupID = obj.GroupID;
|
||||
prim.LastOwnerID = prim.OwnerID;
|
||||
prim.RezzerID = AgentId;
|
||||
prim.RezzerID = agentID;
|
||||
prim.CreationDate = Util.UnixTimeSinceEpoch();
|
||||
prim.Name = obj.Name;
|
||||
prim.Description = "";
|
||||
|
@ -300,7 +247,6 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
for (int j = 0; j < obj.Faces.Length; j++)
|
||||
{
|
||||
UploadObjectAssetMessage.Object.Face face = obj.Faces[j];
|
||||
|
||||
Primitive.TextureEntryFace primFace = tmp.CreateFace((uint) j);
|
||||
|
||||
primFace.Bump = face.Bump;
|
||||
|
@ -327,15 +273,13 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
grp.SetRootPart(prim);
|
||||
prim.ParentID = 0;
|
||||
if (i == 0)
|
||||
{
|
||||
|
||||
rootGroup = grp;
|
||||
|
||||
}
|
||||
grp.AttachToScene(m_scene);
|
||||
grp.AbsolutePosition = obj.Position;
|
||||
prim.RotationOffset = obj.Rotation;
|
||||
|
||||
|
||||
// Required for linking
|
||||
grp.RootPart.ClearUpdateSchedule();
|
||||
|
||||
|
@ -357,16 +301,13 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
}
|
||||
|
||||
rootGroup.ScheduleGroupForFullAnimUpdate();
|
||||
pos
|
||||
= m_scene.GetNewRezLocation(
|
||||
Vector3.Zero, rootpos, UUID.Zero, rot, (byte)1, 1, true, allparts[0].GroupScale, false);
|
||||
|
||||
responsedata["int_response_code"] = 200; //501; //410; //404;
|
||||
responsedata["content_type"] = "text/plain";
|
||||
responsedata["keepalive"] = false;
|
||||
responsedata["str_response_string"] = String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>", ConvertUintToBytes(allparts[0].LocalId));
|
||||
httpResponse.StatusCode = (int)HttpStatusCode.OK;
|
||||
httpResponse.RawBuffer = Util.UTF8NBGetbytes(String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>", ConvertUintToBytes(allparts[0].LocalId)));
|
||||
}
|
||||
catch{ }
|
||||
|
||||
return responsedata;
|
||||
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||
}
|
||||
|
||||
private string ConvertUintToBytes(uint val)
|
||||
|
|
Loading…
Reference in New Issue