private void GetExtEnvironmentSettings(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID agentID) { int parcelid = -1; if (httpRequest.Query.Count > 0) { if (httpRequest.Query.ContainsKey("parcelid")) { Int32.TryParse((string)httpRequest.Query["parcelid"], out parcelid); } } ViewerEnvironment VEnv = null; ScenePresence sp = m_scene.GetScenePresence(agentID); if (sp != null && sp.Environment != null) { if (parcelid == -1) { VEnv = sp.Environment; } else { OSD def = ViewerEnvironment.DefaultToOSD(regionID, parcelid); httpResponse.RawBuffer = OSDParser.SerializeLLSDXmlToBytes(def); httpResponse.StatusCode = (int)HttpStatusCode.OK; return; } } else if (parcelid == -1) { VEnv = GetRegionEnvironment(); } else { if (m_scene.RegionInfo.EstateSettings.AllowEnvironmentOverride) { ILandObject land = m_scene.LandChannel.GetLandObject(parcelid); if (land != null && land.LandData != null && land.LandData.Environment != null) { VEnv = land.LandData.Environment; } } if (VEnv == null) { OSD def = ViewerEnvironment.DefaultToOSD(regionID, parcelid); httpResponse.RawBuffer = OSDParser.SerializeLLSDXmlToBytes(def); httpResponse.StatusCode = (int)HttpStatusCode.OK; return; } } OSDMap map = new OSDMap(); OSDMap cenv = (OSDMap)VEnv.ToOSD(); cenv["parcel_id"] = parcelid; cenv["region_id"] = regionID; map["environment"] = cenv; map["parcel_id"] = parcelid; map["success"] = true; string env = OSDParser.SerializeLLSDXmlString(map); if (String.IsNullOrEmpty(env)) { StringBuilder sb = LLSDxmlEncode.Start(); LLSDxmlEncode.AddArray(sb); LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("messageID", UUID.Zero, sb); LLSDxmlEncode.AddElem("regionID", regionID, sb); LLSDxmlEncode.AddEndMap(sb); LLSDxmlEncode.AddEndArray(sb); env = LLSDxmlEncode.End(sb); } httpResponse.RawBuffer = Util.UTF8NBGetbytes(env); httpResponse.StatusCode = (int)HttpStatusCode.OK; }
private void GetExtEnvironmentSettings(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID agentID) { int parcelid = -1; if (httpRequest.Query.Count > 0) { if (httpRequest.Query.ContainsKey("parcelid")) { Int32.TryParse((string)httpRequest.Query["parcelid"], out parcelid); } } ScenePresence sp = m_scene.GetScenePresence(agentID); if (sp == null) { httpResponse.StatusCode = (int)HttpStatusCode.ServiceUnavailable; httpResponse.AddHeader("Retry-After", "5"); return; } ViewerEnvironment VEnv = null; if (sp.Environment != null) { VEnv = sp.Environment; } else if (parcelid == -1) { VEnv = GetRegionEnvironment(); } else { if (m_scene.RegionInfo.EstateSettings.AllowEnvironmentOverride) { ILandObject land = m_scene.LandChannel.GetLandObject(parcelid); if (land != null && land.LandData != null && land.LandData.Environment != null) { VEnv = land.LandData.Environment; } } if (VEnv == null) { OSD def = ViewerEnvironment.DefaultToOSD(regionID, parcelid); httpResponse.RawBuffer = OSDParser.SerializeLLSDXmlToBytes(def); httpResponse.StatusCode = (int)HttpStatusCode.OK; return; } } byte[] envBytes = VEnv.ToCapBytes(regionID, parcelid); if (envBytes == null) { osUTF8 sb = LLSDxmlEncode2.Start(); LLSDxmlEncode2.AddArray(sb); LLSDxmlEncode2.AddMap(sb); LLSDxmlEncode2.AddElem("messageID", UUID.Zero, sb); LLSDxmlEncode2.AddElem("regionID", regionID, sb); LLSDxmlEncode2.AddEndMap(sb); LLSDxmlEncode2.AddEndArray(sb); httpResponse.RawBuffer = LLSDxmlEncode2.EndToBytes(sb); } else { httpResponse.RawBuffer = envBytes; } httpResponse.StatusCode = (int)HttpStatusCode.OK; }