change cap CreateInventoryCategory
parent
e48d2f2c1f
commit
288dffcda1
|
@ -236,7 +236,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
|
|
||||||
public string GetNewCapPath()
|
public string GetNewCapPath()
|
||||||
{
|
{
|
||||||
return "/CAPS/" + UUID.Random();
|
return "/" + UUID.Random();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -319,18 +319,15 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req);
|
m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req);
|
||||||
m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req);
|
m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req);
|
||||||
|
|
||||||
IRequestHandler UpdateAgentInformationHandler = new RestStreamHandler(
|
m_HostCapsObj.RegisterSimpleHandler("UpdateAgentInformation",
|
||||||
"POST", GetNewCapPath(), UpdateAgentInformation, "UpdateAgentInformation", null);
|
new SimpleStreamHandler(GetNewCapPath(), UpdateAgentInformation));
|
||||||
m_HostCapsObj.RegisterHandler("UpdateAgentInformation", UpdateAgentInformationHandler);
|
|
||||||
|
|
||||||
IRequestHandler CopyInventoryFromNotecardHandler = new RestStreamHandler(
|
IRequestHandler CopyInventoryFromNotecardHandler = new RestStreamHandler(
|
||||||
"POST", GetNewCapPath(), CopyInventoryFromNotecard, "CopyInventoryFromNotecard", null);
|
"POST", GetNewCapPath(), CopyInventoryFromNotecard, "CopyInventoryFromNotecard", null);
|
||||||
m_HostCapsObj.RegisterHandler("CopyInventoryFromNotecard", CopyInventoryFromNotecardHandler);
|
m_HostCapsObj.RegisterHandler("CopyInventoryFromNotecard", CopyInventoryFromNotecardHandler);
|
||||||
|
|
||||||
IRequestHandler CreateInventoryCategoryHandler = new RestStreamHandler(
|
m_HostCapsObj.RegisterSimpleHandler("CreateInventoryCategory",
|
||||||
"POST", GetNewCapPath(), CreateInventoryCategory, "CreateInventoryCategory", null);
|
new SimpleStreamHandler(GetNewCapPath(), CreateInventoryCategory));
|
||||||
m_HostCapsObj.RegisterHandler("CreateInventoryCategory", CreateInventoryCategoryHandler);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1270,85 +1267,67 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
m_FileAgentInventoryState = FileAgentInventoryState.idle;
|
m_FileAgentInventoryState = FileAgentInventoryState.idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public void CreateInventoryCategory(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="mapReq"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq)
|
|
||||||
{
|
{
|
||||||
m_log.Debug("[CAPS]: MapLayer Request in region: " + m_regionName);
|
if(httpRequest.HttpMethod != "POST")
|
||||||
LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
|
{
|
||||||
mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse());
|
httpResponse.StatusCode = (int)HttpStatusCode.NotFound;
|
||||||
return mapResponse;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
protected static OSDMapLayer GetOSDMapLayerResponse()
|
|
||||||
{
|
|
||||||
OSDMapLayer mapLayer = new OSDMapLayer();
|
|
||||||
mapLayer.Right = 5000;
|
|
||||||
mapLayer.Top = 5000;
|
|
||||||
mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006");
|
|
||||||
|
|
||||||
return mapLayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request"></param>
|
|
||||||
/// <param name="path"></param>
|
|
||||||
/// <param name="param"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public string RequestTexture(string request, string path, string param)
|
|
||||||
{
|
|
||||||
m_log.Debug("texture request " + request);
|
|
||||||
// Needs implementing (added to remove compiler warning)
|
|
||||||
return String.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string CreateInventoryCategory(string request, string path, string param,
|
|
||||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
|
||||||
{
|
|
||||||
if (m_Scene.InventoryService == null)
|
if (m_Scene.InventoryService == null)
|
||||||
{
|
{
|
||||||
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.ServiceUnavailable;
|
httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented;
|
||||||
httpResponse.StatusDescription = "Service not avaiable";
|
return;
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScenePresence sp = m_Scene.GetScenePresence(m_AgentID);
|
ScenePresence sp = m_Scene.GetScenePresence(m_AgentID);
|
||||||
if (sp == null || sp.IsDeleted)
|
if (sp == null || sp.IsDeleted)
|
||||||
{
|
{
|
||||||
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.ServiceUnavailable;
|
httpResponse.StatusCode = (int)HttpStatusCode.ServiceUnavailable;
|
||||||
httpResponse.StatusDescription = "Retry later";
|
httpResponse.AddHeader("Retry-After", "60");
|
||||||
httpResponse.AddHeader("Retry-After", "30");
|
return;
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
|
OSDMap req;
|
||||||
|
OSD tmp;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
req = (OSDMap)OSDParser.DeserializeLLSDXml(httpRequest.InputStream);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (true) // kinda goto
|
while (true) // kinda goto
|
||||||
{
|
{
|
||||||
if (!hash.Contains("folder_id") || !(hash["folder_id"] is UUID))
|
if (!req.TryGetValue("folder_id", out tmp) || !(tmp is OSDUUID))
|
||||||
break;
|
break;
|
||||||
UUID folderID = (UUID)hash["folder_id"];
|
UUID folderID = tmp.AsUUID();
|
||||||
|
|
||||||
if (!hash.Contains("parent_id") || !(hash["parent_id"] is UUID))
|
if(folderID == UUID.Zero)
|
||||||
break;
|
break;
|
||||||
UUID parentID = (UUID)hash["parent_id"];
|
|
||||||
|
|
||||||
if (!hash.Contains("name") || !(hash["name"] is string))
|
if (!req.TryGetValue("parent_id", out tmp) || !(tmp is OSDUUID))
|
||||||
break;
|
break;
|
||||||
string folderName = (string)hash["name"];
|
UUID parentID = tmp.AsUUID();
|
||||||
|
|
||||||
if (!hash.Contains("type") || !(hash["type"] is int))
|
if (!req.TryGetValue("name", out tmp) || !(tmp is OSDString))
|
||||||
break;
|
break;
|
||||||
int folderType = (int)hash["type"];
|
string folderName = tmp.AsString();
|
||||||
|
|
||||||
|
if(string.IsNullOrEmpty(folderName))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if(folderName.Length > 63)
|
||||||
|
folderName = folderName.Substring(0, 63);
|
||||||
|
|
||||||
|
if (!req.TryGetValue("type", out tmp) || !(tmp is OSDInteger))
|
||||||
|
break;
|
||||||
|
int folderType = tmp.AsInteger();
|
||||||
|
|
||||||
InventoryFolderBase folder = new InventoryFolderBase(folderID, folderName, m_AgentID, (short)folderType, parentID, 1);
|
InventoryFolderBase folder = new InventoryFolderBase(folderID, folderName, m_AgentID, (short)folderType, parentID, 1);
|
||||||
if (!m_Scene.InventoryService.AddFolder(folder))
|
if (!m_Scene.InventoryService.AddFolder(folder))
|
||||||
|
@ -1366,13 +1345,16 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
LLSDxmlEncode.AddElem("parent_id", folder.ParentID, sb);
|
LLSDxmlEncode.AddElem("parent_id", folder.ParentID, sb);
|
||||||
LLSDxmlEncode.AddElem("type", folder.Type, sb);
|
LLSDxmlEncode.AddElem("type", folder.Type, sb);
|
||||||
LLSDxmlEncode.AddEndMap(sb);
|
LLSDxmlEncode.AddEndMap(sb);
|
||||||
string resp = LLSDxmlEncode.End(sb);
|
|
||||||
|
|
||||||
return resp;
|
httpResponse.RawBuffer = Encoding.UTF8.GetBytes(LLSDxmlEncode.End(sb));
|
||||||
|
httpResponse.StatusCode = (int)HttpStatusCode.OK;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
|
m_log.Debug("[CAPS]: CreateInventoryCategory failed to process request");
|
||||||
return "";
|
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1829,10 +1811,17 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
httpResponse.StatusCode = (int)HttpStatusCode.OK;
|
httpResponse.StatusCode = (int)HttpStatusCode.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string UpdateAgentInformation(string request, string path,
|
public void UpdateAgentInformation(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||||
string param, IOSHttpRequest httpRequest,
|
|
||||||
IOSHttpResponse httpResponse)
|
|
||||||
{
|
{
|
||||||
|
if (httpRequest.HttpMethod != "POST")
|
||||||
|
{
|
||||||
|
httpResponse.StatusCode = (int)HttpStatusCode.NotFound;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is wrong now ignores request and sends same result for all
|
||||||
|
// we don't store and worse don't use that to filter contents
|
||||||
|
|
||||||
// OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
|
// OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
|
||||||
OSDMap resp = new OSDMap();
|
OSDMap resp = new OSDMap();
|
||||||
|
|
||||||
|
@ -1841,8 +1830,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
|
|
||||||
resp["access_prefs"] = accessPrefs;
|
resp["access_prefs"] = accessPrefs;
|
||||||
|
|
||||||
string response = OSDParser.SerializeLLSDXmlString(resp);
|
httpResponse.RawBuffer = OSDParser.SerializeLLSDXmlBytes(resp);
|
||||||
return response;
|
httpResponse.StatusCode = (int)HttpStatusCode.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool OSDMapTOVector3(OSDMap map, out Vector3 v)
|
public bool OSDMapTOVector3(OSDMap map, out Vector3 v)
|
||||||
|
@ -2013,8 +2002,6 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
|
|
||||||
OSDMap resp = new OSDMap();
|
OSDMap resp = new OSDMap();
|
||||||
|
|
||||||
string response;
|
|
||||||
|
|
||||||
bool fail = true;
|
bool fail = true;
|
||||||
IClientAPI client = null;
|
IClientAPI client = null;
|
||||||
ScenePresence sp;
|
ScenePresence sp;
|
||||||
|
@ -2367,16 +2354,6 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
httpListener.RemoveStreamHandler("POST", uploaderPath);
|
httpListener.RemoveStreamHandler("POST", uploaderPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
///Left this in and commented in case there are unforseen issues
|
|
||||||
//private void SaveAssetToFile(string filename, byte[] data)
|
|
||||||
//{
|
|
||||||
// FileStream fs = File.Create(filename);
|
|
||||||
// BinaryWriter bw = new BinaryWriter(fs);
|
|
||||||
// bw.Write(data);
|
|
||||||
// bw.Close();
|
|
||||||
// fs.Close();
|
|
||||||
//}
|
|
||||||
|
|
||||||
private static void SaveAssetToFile(string filename, byte[] data)
|
private static void SaveAssetToFile(string filename, byte[] data)
|
||||||
{
|
{
|
||||||
string assetPath = "UserAssets";
|
string assetPath = "UserAssets";
|
||||||
|
|
Loading…
Reference in New Issue