private string GetEnvironmentSettings(string request, string path, string param, UUID agentID, Caps caps) { // m_log.DebugFormat("[{0}]: Environment GET handle for agentID {1} in region {2}", // Name, agentID, caps.RegionName); string env = String.Empty; try { env = m_scene.SimulationDataService.LoadRegionEnvironmentSettings(regionID); } catch (Exception e) { m_log.ErrorFormat("[{0}]: Unable to load environment settings for region {1}, Exception: {2} - {3}", Name, caps.RegionName, e.Message, e.StackTrace); } 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); } return(env); }
public void FetchInventorySimpleRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, OSDMap requestmap, ExpiringKey <UUID> BadRequests) { //m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capability request {0}", request); if (BadRequests == null) { httpResponse.StatusCode = (int)HttpStatusCode.NotFound; return; } OSDArray itemsRequested = (OSDArray)requestmap["items"]; UUID[] itemIDs = new UUID[itemsRequested.Count]; int i = 0; foreach (OSDMap osdItemId in itemsRequested) { UUID id = osdItemId["item_id"].AsUUID(); if (!BadRequests.ContainsKey(id)) { itemIDs[i++] = id; } } InventoryItemBase[] items = null; try { // badrequests still not filled items = m_inventoryService.GetMultipleItems(m_agentID, itemIDs); } catch { } StringBuilder lsl = LLSDxmlEncode.Start(4096); LLSDxmlEncode.AddMap(lsl); LLSDxmlEncode.AddElem("agent_id", m_agentID, lsl); if (items == null || items.Length == 0) { LLSDxmlEncode.AddEmptyArray("items", lsl); } else { LLSDxmlEncode.AddArray("items", lsl); foreach (InventoryItemBase item in items) { if (item != null) { item.ToLLSDxml(lsl, 0xff); } } LLSDxmlEncode.AddEndArray(lsl); } LLSDxmlEncode.AddEndMap(lsl); httpResponse.RawBuffer = Util.UTF8.GetBytes(LLSDxmlEncode.End(lsl)); httpResponse.StatusCode = (int)HttpStatusCode.OK; }
public string toLLSDxml(StringBuilder sb = null) { const float scale = 10000f; bool fullLLSD = false; if (sb == null) { sb = LLSDxmlEncode.Start(1024, false); fullLLSD = true; } LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("NormMap", NormalMapID, sb); LLSDxmlEncode.AddElem("NormOffsetX", (int)(scale * NormalOffsetX + 0.5f), sb); LLSDxmlEncode.AddElem("NormOffsetY", (int)(scale * NormalOffsetY + 0.5f), sb); LLSDxmlEncode.AddElem("NormRepeatX", (int)(scale * NormalRepeatX + 0.5f), sb); LLSDxmlEncode.AddElem("NormRepeatY", (int)(scale * NormalRepeatY + 0.5f), sb); LLSDxmlEncode.AddElem("NormRotation", (int)(scale * NormalRotation + 0.5f), sb); LLSDxmlEncode.AddElem("SpecMap", SpecularMapID, sb); LLSDxmlEncode.AddElem("SpecOffsetX", (int)(scale * SpecularOffsetX + 0.5f), sb); LLSDxmlEncode.AddElem("SpecOffsetY", (int)(scale * SpecularOffsetY + 0.5f), sb); LLSDxmlEncode.AddElem("SpecRepeatX", (int)(scale * SpecularRepeatX + 0.5f), sb); LLSDxmlEncode.AddElem("SpecRepeatY", (int)(scale * SpecularRepeatY + 0.5f), sb); LLSDxmlEncode.AddElem("SpecRotation", (int)(scale * SpecularRotation + 0.5f), sb); LLSDxmlEncode.AddArray("SpecColor", sb); LLSDxmlEncode.AddElem(SpecularLightColorR, sb); LLSDxmlEncode.AddElem(SpecularLightColorG, sb); LLSDxmlEncode.AddElem(SpecularLightColorB, sb); LLSDxmlEncode.AddElem(255, sb); LLSDxmlEncode.AddEndArray(sb); LLSDxmlEncode.AddElem("SpecExp", SpecularLightExponent, sb); LLSDxmlEncode.AddElem("EnvIntensity", EnvironmentIntensity, sb); LLSDxmlEncode.AddElem("DiffuseAlphaMode", DiffuseAlphaMode, sb); LLSDxmlEncode.AddElem("AlphaMaskCutoff", AlphaMaskCutoff, sb); LLSDxmlEncode.AddEndMap(sb); if (fullLLSD) { return(LLSDxmlEncode.End(sb)); } else { return(String.Empty); // ignored if appending } }
private string SetEnvironmentSettings(string request, string path, string param, UUID agentID, Caps caps) { // m_log.DebugFormat("[{0}]: Environment SET handle from agentID {1} in region {2}", // Name, agentID, caps.RegionName); bool success = false; string fail_reason = ""; if (!m_scene.Permissions.CanIssueEstateCommand(agentID, false)) { fail_reason = "Insufficient estate permissions, settings has not been saved."; } else { try { m_scene.SimulationDataService.StoreRegionEnvironmentSettings(regionID, request); success = true; m_log.InfoFormat("[{0}]: New Environment settings has been saved from agentID {1} in region {2}", Name, agentID, caps.RegionName); } catch (Exception e) { m_log.ErrorFormat("[{0}]: Environment settings has not been saved for region {1}, Exception: {2} - {3}", Name, caps.RegionName, e.Message, e.StackTrace); success = false; fail_reason = String.Format("Environment Set for region {0} has failed, settings not saved.", caps.RegionName); } } StringBuilder sb = LLSDxmlEncode.Start(); LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("messageID", UUID.Zero, sb); LLSDxmlEncode.AddElem("regionID", regionID, sb); LLSDxmlEncode.AddElem("success", success, sb); if (!success) { LLSDxmlEncode.AddElem("fail_reason", fail_reason, sb); } LLSDxmlEncode.AddEndMap(sb); return(LLSDxmlEncode.End(sb)); }
private void GetEnvironmentSettings(IOSHttpResponse response, UUID agentID) { // m_log.DebugFormat("[{0}]: Environment GET handle for agentID {1} in region {2}", // Name, agentID, caps.RegionName); ViewerEnvironment VEnv = null; ScenePresence sp = m_scene.GetScenePresence(agentID); if (sp != null && sp.Environment != null) { VEnv = sp.Environment; } else { if (m_scene.RegionInfo.EstateSettings.AllowEnvironmentOverride) { ILandObject land = m_scene.LandChannel.GetLandObject(sp.AbsolutePosition.X, sp.AbsolutePosition.Y); if (land != null && land.LandData != null && land.LandData.Environment != null) { VEnv = land.LandData.Environment; } } if (VEnv == null) { VEnv = GetRegionEnvironment(); } } OSD d = VEnv.ToWLOSD(UUID.Zero, regionID); string env = OSDParser.SerializeLLSDXmlString(d); 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); } response.RawBuffer = Util.UTF8NBGetbytes(env); response.StatusCode = (int)HttpStatusCode.OK; }
private void DeleteExtEnvironmentSettings(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID agentID) { int parcel = -1; if (httpRequest.Query.Count > 0) { if (httpRequest.Query.ContainsKey("parcelid")) { Int32.TryParse((string)httpRequest.Query["parcelid"], out parcel); } } if (parcel == -1) { StoreOnRegion(null); WindlightRefresh(0); } else { ILandObject land = m_scene.LandChannel.GetLandObject(parcel); if (land != null && land.LandData != null) { land.StoreEnvironment(null); WindlightRefresh(0, false); } } StringBuilder sb = LLSDxmlEncode.Start(); LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("messageID", UUID.Zero, sb); LLSDxmlEncode.AddElem("regionID", regionID, sb); LLSDxmlEncode.AddElem("success", true, sb); LLSDxmlEncode.AddEndMap(sb); httpResponse.RawBuffer = Util.UTF8.GetBytes(LLSDxmlEncode.End(sb)); httpResponse.StatusCode = (int)HttpStatusCode.OK; }
public Hashtable ProcessRequest(Hashtable request, UUID AgentId, Caps cap) { Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 200; //501; //410; //404; responsedata["content_type"] = "text/plain"; ScenePresence avatar; if (!m_scene.TryGetScenePresence(AgentId, out avatar)) { responsedata["str_response_string"] = "<llsd><array /></llsd>";; responsedata["keepalive"] = false; return(responsedata); } if (m_scene.RegionInfo == null || m_scene.RegionInfo.EstateSettings == null || !m_scene.Permissions.CanIssueEstateCommand(AgentId, false)) { responsedata["str_response_string"] = "<llsd><array /></llsd>";; return(responsedata); } EstateSettings regionSettings = m_scene.RegionInfo.EstateSettings; UUID[] managers = regionSettings.EstateManagers; UUID[] allowed = regionSettings.EstateAccess; UUID[] groups = regionSettings.EstateGroups; EstateBan[] EstateBans = regionSettings.EstateBans; StringBuilder sb = LLSDxmlEncode.Start(); LLSDxmlEncode.AddArray(sb); if (allowed != null && allowed.Length > 0) { LLSDxmlEncode.AddMap("AllowedAgents", sb); for (int i = 0; i < allowed.Length; ++i) { UUID id = allowed[i]; if (id == UUID.Zero) { continue; } LLSDxmlEncode.AddElem("id", id, sb); } LLSDxmlEncode.AddEndMap(sb); } if (groups != null && groups.Length > 0) { LLSDxmlEncode.AddMap("AllowedGroups", sb); for (int i = 0; i < groups.Length; ++i) { UUID id = groups[i]; if (id == UUID.Zero) { continue; } LLSDxmlEncode.AddElem("id", id, sb); } LLSDxmlEncode.AddEndMap(sb); } if (EstateBans != null && EstateBans.Length > 0) { LLSDxmlEncode.AddMap("BannedAgents", sb); for (int i = 0; i < EstateBans.Length; ++i) { UUID id = EstateBans[i].BannedUserID; if (id == UUID.Zero) { continue; } LLSDxmlEncode.AddElem("id", id, sb); } LLSDxmlEncode.AddEndMap(sb); } if (managers != null && managers.Length > 0) { LLSDxmlEncode.AddMap("Managers", sb); for (int i = 0; i < managers.Length; ++i) { LLSDxmlEncode.AddElem("id", managers[i], sb); } LLSDxmlEncode.AddEndMap(sb); } LLSDxmlEncode.AddEndArray(sb); responsedata["str_response_string"] = LLSDxmlEncode.End(sb); return(responsedata); }
public void ProcessRequest(IOSHttpRequest request, IOSHttpResponse response, UUID AgentId) { if (request.HttpMethod != "GET") { response.StatusCode = (int)HttpStatusCode.NotFound; return; } ScenePresence avatar; if (!m_scene.TryGetScenePresence(AgentId, out avatar) || m_scene.RegionInfo == null || m_scene.RegionInfo.EstateSettings == null) { response.StatusCode = (int)HttpStatusCode.Gone; return; } if (!m_scene.Permissions.CanIssueEstateCommand(AgentId, false)) { response.StatusCode = (int)HttpStatusCode.Unauthorized; return; } EstateSettings regionSettings = m_scene.RegionInfo.EstateSettings; UUID[] managers = regionSettings.EstateManagers; UUID[] allowed = regionSettings.EstateAccess; UUID[] groups = regionSettings.EstateGroups; EstateBan[] EstateBans = regionSettings.EstateBans; StringBuilder sb = LLSDxmlEncode.Start(); LLSDxmlEncode.AddMap(sb); if (allowed != null && allowed.Length > 0) { LLSDxmlEncode.AddArray("AllowedAgents", sb); for (int i = 0; i < allowed.Length; ++i) { UUID id = allowed[i]; if (id == UUID.Zero) { continue; } LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("id", id, sb); LLSDxmlEncode.AddEndMap(sb); } LLSDxmlEncode.AddEndArray(sb); } else { LLSDxmlEncode.AddEmptyArray("AllowedAgents", sb); } if (groups != null && groups.Length > 0) { LLSDxmlEncode.AddArray("AllowedGroups", sb); for (int i = 0; i < groups.Length; ++i) { UUID id = groups[i]; if (id == UUID.Zero) { continue; } LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("id", id, sb); LLSDxmlEncode.AddEndMap(sb); } LLSDxmlEncode.AddEndArray(sb); } else { LLSDxmlEncode.AddEmptyArray("AllowedGroups", sb); } if (EstateBans != null && EstateBans.Length > 0) { LLSDxmlEncode.AddArray("BannedAgents", sb); for (int i = 0; i < EstateBans.Length; ++i) { EstateBan ban = EstateBans[i]; UUID id = ban.BannedUserID; if (id == UUID.Zero) { continue; } LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("id", id, sb); LLSDxmlEncode.AddElem("banning_id", ban.BanningUserID, sb); LLSDxmlEncode.AddElem("last_login_date", "na", sb); // We will not have this. This information is far at grid if (ban.BanTime == 0) { LLSDxmlEncode.AddElem("ban_date", "0000-00-00 00:00", sb); } else { LLSDxmlEncode.AddElem("ban_date", (Util.ToDateTime(ban.BanTime)).ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture), sb); } LLSDxmlEncode.AddEndMap(sb); } LLSDxmlEncode.AddEndArray(sb); } else { LLSDxmlEncode.AddEmptyArray("BannedAgents", sb); } if (managers != null && managers.Length > 0) { LLSDxmlEncode.AddArray("Managers", sb); for (int i = 0; i < managers.Length; ++i) { LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("agent_id", managers[i], sb); LLSDxmlEncode.AddEndMap(sb); } LLSDxmlEncode.AddEndArray(sb); } else { LLSDxmlEncode.AddEmptyArray("Managers", sb); } LLSDxmlEncode.AddEndMap(sb); response.RawBuffer = Util.UTF8.GetBytes(LLSDxmlEncode.End(sb)); response.StatusCode = (int)HttpStatusCode.OK; }
public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { //m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capability request {0}", request); OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request)); OSDArray itemsRequested = (OSDArray)requestmap["items"]; UUID[] itemIDs = new UUID[itemsRequested.Count]; int i = 0; foreach (OSDMap osdItemId in itemsRequested) { itemIDs[i++] = osdItemId["item_id"].AsUUID(); } InventoryItemBase[] items = null; if (m_agentID != UUID.Zero) { items = m_inventoryService.GetMultipleItems(m_agentID, itemIDs); } else { items = new InventoryItemBase[itemsRequested.Count]; foreach (UUID id in itemIDs) { items[i++] = m_inventoryService.GetItem(UUID.Zero, id); } } StringBuilder lsl = LLSDxmlEncode.Start(4096); LLSDxmlEncode.AddMap(lsl); if (m_agentID == UUID.Zero && items.Length > 0) { LLSDxmlEncode.AddElem("agent_id", items[0].Owner, lsl); } else { LLSDxmlEncode.AddElem("agent_id", m_agentID, lsl); } if (items == null || items.Length == 0) { LLSDxmlEncode.AddEmptyArray("items", lsl); } else { LLSDxmlEncode.AddArray("items", lsl); foreach (InventoryItemBase item in items) { if (item != null) { item.ToLLSDxml(lsl, 0xff); } } LLSDxmlEncode.AddEndArray(lsl); } LLSDxmlEncode.AddEndMap(lsl); return(LLSDxmlEncode.End(lsl));; }
public Hashtable ProcessRequest(Hashtable request, UUID AgentId, Caps cap) { Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 200; //501; //410; //404; responsedata["content_type"] = "text/plain"; ScenePresence avatar; if (!m_scene.TryGetScenePresence(AgentId, out avatar)) { responsedata["str_response_string"] = "<llsd><array /></llsd>";; responsedata["keepalive"] = false; return(responsedata); } if (m_scene.RegionInfo == null || m_scene.RegionInfo.EstateSettings == null || !m_scene.Permissions.CanIssueEstateCommand(AgentId, false)) { responsedata["str_response_string"] = "<llsd><array /></llsd>";; return(responsedata); } EstateSettings regionSettings = m_scene.RegionInfo.EstateSettings; UUID[] managers = regionSettings.EstateManagers; UUID[] allowed = regionSettings.EstateAccess; UUID[] groups = regionSettings.EstateGroups; EstateBan[] EstateBans = regionSettings.EstateBans; StringBuilder sb = LLSDxmlEncode.Start(); LLSDxmlEncode.AddMap(sb); if (allowed != null && allowed.Length > 0) { LLSDxmlEncode.AddArray("AllowedAgents", sb); for (int i = 0; i < allowed.Length; ++i) { UUID id = allowed[i]; if (id == UUID.Zero) { continue; } LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("id", id, sb); LLSDxmlEncode.AddEndMap(sb); } LLSDxmlEncode.AddEndArray(sb); } if (groups != null && groups.Length > 0) { LLSDxmlEncode.AddArray("AllowedGroups", sb); for (int i = 0; i < groups.Length; ++i) { UUID id = groups[i]; if (id == UUID.Zero) { continue; } LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("id", id, sb); LLSDxmlEncode.AddEndMap(sb); } LLSDxmlEncode.AddEndArray(sb); } if (EstateBans != null && EstateBans.Length > 0) { LLSDxmlEncode.AddArray("BannedAgents", sb); for (int i = 0; i < EstateBans.Length; ++i) { EstateBan ban = EstateBans[i]; UUID id = ban.BannedUserID; if (id == UUID.Zero) { continue; } LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("id", id, sb); LLSDxmlEncode.AddElem("banning_id", ban.BanningUserID, sb); LLSDxmlEncode.AddElem("last_login_date", "na", sb); // We will not have this. This information is far at grid if (ban.BanTime == 0) { LLSDxmlEncode.AddElem("ban_date", "0000-00-00 00:00", sb); } else { LLSDxmlEncode.AddElem("ban_date", (Util.ToDateTime(ban.BanTime)).ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture), sb); } LLSDxmlEncode.AddEndMap(sb); } LLSDxmlEncode.AddEndArray(sb); } if (managers != null && managers.Length > 0) { LLSDxmlEncode.AddArray("Managers", sb); for (int i = 0; i < managers.Length; ++i) { LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("agent_id", managers[i], sb); LLSDxmlEncode.AddEndMap(sb); } LLSDxmlEncode.AddEndArray(sb); } LLSDxmlEncode.AddEndMap(sb); responsedata["str_response_string"] = LLSDxmlEncode.End(sb); return(responsedata); }
private void SetEnvironmentSettings(IOSHttpRequest request, IOSHttpResponse response, UUID agentID) { // m_log.DebugFormat("[{0}]: Environment SET handle from agentID {1} in region {2}", // Name, agentID, caps.RegionName); bool success = false; string fail_reason = ""; if (!m_scene.Permissions.CanIssueEstateCommand(agentID, false)) { fail_reason = "Insufficient estate permissions, settings has not been saved."; goto Error; } ScenePresence sp = m_scene.GetScenePresence(agentID); if (sp == null || sp.IsChildAgent || sp.IsNPC) { response.StatusCode = (int)HttpStatusCode.NotFound; return; } if (sp.Environment != null) { fail_reason = "The environment you see is a forced one. Disable if on control object or tp out and back to region"; goto Error; } ILandObject land = m_scene.LandChannel.GetLandObject(sp.AbsolutePosition.X, sp.AbsolutePosition.Y); if (land != null && land.LandData != null && land.LandData.Environment != null) { fail_reason = "The parcel where you are has own environment set. You need a updated viewer to change environment"; goto Error; } try { ViewerEnvironment VEnv = new ViewerEnvironment(); OSD env = OSDParser.Deserialize(request.InputStream); VEnv.FromWLOSD(env); StoreOnRegion(VEnv); WindlightRefresh(0); m_log.InfoFormat("[{0}]: New Environment settings has been saved from agentID {1} in region {2}", Name, agentID, m_scene.Name); success = true; } catch (Exception e) { m_log.ErrorFormat("[{0}]: Environment settings has not been saved for region {1}, Exception: {2} - {3}", Name, m_scene.Name, e.Message, e.StackTrace); success = false; fail_reason = String.Format("Environment Set for region {0} has failed, settings not saved.", m_scene.Name); } Error: StringBuilder sb = LLSDxmlEncode.Start(); LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("messageID", UUID.Zero, sb); LLSDxmlEncode.AddElem("regionID", regionID, sb); LLSDxmlEncode.AddElem("success", success, sb); if (!success) { LLSDxmlEncode.AddElem("fail_reason", fail_reason, sb); } LLSDxmlEncode.AddEndMap(sb); response.RawBuffer = Util.UTF8NBGetbytes(LLSDxmlEncode.End(sb)); response.StatusCode = (int)HttpStatusCode.OK; }
private void SetExtEnvironmentSettings(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID agentID, Caps caps) { bool success = false; string message = "Could not process request"; int parcel = -1; int track = -1; StringBuilder sb = LLSDxmlEncode.Start(); ScenePresence sp = m_scene.GetScenePresence(agentID); if (sp == null || sp.IsChildAgent || sp.IsNPC) { message = "Could not locate your avatar"; goto Error; } if (httpRequest.Query.Count > 0) { if (httpRequest.Query.ContainsKey("parcelid")) { if (!Int32.TryParse((string)httpRequest.Query["parcelid"], out parcel)) { message = "Failed to decode request"; goto Error; } } if (httpRequest.Query.ContainsKey("trackno")) { if (!Int32.TryParse((string)httpRequest.Query["trackno"], out track)) { message = "Failed to decode request"; goto Error; } } if (track != -1) { message = "Environment Track not supported"; goto Error; } } ViewerEnvironment VEnv = m_scene.RegionEnvironment; ILandObject lchannel; if (parcel == -1) { if (!m_scene.Permissions.CanIssueEstateCommand(agentID, false)) { message = "Insufficient estate permissions, settings has not been saved."; goto Error; } VEnv = m_scene.RegionEnvironment; lchannel = null; } else { lchannel = m_landChannel.GetLandObject(parcel); if (lchannel == null || lchannel.LandData == null) { message = "Could not locate requested parcel"; goto Error; } if (!m_scene.Permissions.CanEditParcelProperties(agentID, lchannel, (GroupPowers.AllowEnvironment | GroupPowers.LandEdit), true)) // wrong { message = "No permission to change parcel environment"; goto Error; } VEnv = lchannel.LandData.Environment; } try { OSD req = OSDParser.Deserialize(httpRequest.InputStream); if (req is OpenMetaverse.StructuredData.OSDMap) { OSDMap map = req as OpenMetaverse.StructuredData.OSDMap; if (map.TryGetValue("environment", out OSD env)) { if (VEnv == null) { // need a proper clone VEnv = m_DefaultEnv.Clone(); } OSDMap evmap = (OSDMap)env; if (evmap.TryGetValue("day_asset", out OSD tmp) && !evmap.ContainsKey("day_cycle")) { string id = tmp.AsString(); AssetBase asset = m_assetService.Get(id); if (asset == null || asset.Data == null || asset.Data.Length == 0) { httpResponse.StatusCode = (int)HttpStatusCode.NotFound; return; } try { OSD oenv = OSDParser.Deserialize(asset.Data); VEnv.CycleFromOSD(oenv); } catch { httpResponse.StatusCode = (int)HttpStatusCode.NotFound; return; } } VEnv.FromOSD(env); if (lchannel == null) { StoreOnRegion(VEnv); m_log.InfoFormat("[{0}]: ExtEnvironment region {1} settings from agentID {2} saved", Name, caps.RegionName, agentID); } else { lchannel.StoreEnvironment(VEnv); m_log.InfoFormat("[{0}]: ExtEnvironment parcel {1} of region {2} settings from agentID {3} saved", Name, parcel, caps.RegionName, agentID); } WindlightRefresh(0, lchannel == null); success = true; } } else if (req is OSDArray) { VEnv = new ViewerEnvironment(); VEnv.FromWLOSD(req); StoreOnRegion(VEnv); success = true; WindlightRefresh(0); m_log.InfoFormat("[{0}]: ExtEnvironment region {1} settings from agentID {2} saved", Name, caps.RegionName, agentID); LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("messageID", UUID.Zero, sb); LLSDxmlEncode.AddElem("regionID", regionID, sb); LLSDxmlEncode.AddElem("success", success, sb); LLSDxmlEncode.AddEndMap(sb); httpResponse.RawBuffer = Util.UTF8NBGetbytes(LLSDxmlEncode.End(sb)); httpResponse.StatusCode = (int)HttpStatusCode.OK; return; } } catch (Exception e) { m_log.ErrorFormat("[{0}]: ExtEnvironment settings not saved for region {1}, Exception: {2} - {3}", Name, caps.RegionName, e.Message, e.StackTrace); success = false; message = String.Format("ExtEnvironment Set for region {0} has failed, settings not saved.", caps.RegionName); } Error: string response; LLSDxmlEncode.AddMap(sb); LLSDxmlEncode.AddElem("success", success, sb); if (!success) { LLSDxmlEncode.AddElem("message", message, sb); } LLSDxmlEncode.AddEndMap(sb); response = LLSDxmlEncode.End(sb); httpResponse.RawBuffer = Util.UTF8NBGetbytes(response); 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); } } 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; }
/// <summary> /// Callback for a client request for ParcelVoiceInfo /// </summary> /// <param name="scene">current scene object of the client</param> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public void ParcelVoiceInfoRequest(IOSHttpRequest request, IOSHttpResponse response, UUID agentID, Scene scene) { if (request.HttpMethod != "POST") { response.StatusCode = (int)HttpStatusCode.NotFound; return; } response.StatusCode = (int)HttpStatusCode.OK; m_log.DebugFormat( "[FreeSwitchVoice][PARCELVOICE]: ParcelVoiceInfoRequest() on {0} for {1}", scene.RegionInfo.RegionName, agentID); ScenePresence avatar = scene.GetScenePresence(agentID); if (avatar == null) { response.RawBuffer = Util.UTF8.GetBytes("<llsd>undef</llsd>"); return; } string avatarName = avatar.Name; // - check whether we have a region channel in our cache // - if not: // create it and cache it // - send it to the client // - send channel_uri: as "sip:regionID@m_sipDomain" try { string channelUri; if (null == scene.LandChannel) { m_log.ErrorFormat("region \"{0}\": avatar \"{1}\": land data not yet available", scene.RegionInfo.RegionName, avatarName); response.RawBuffer = Util.UTF8.GetBytes("<llsd>undef</llsd>"); return; } // get channel_uri: check first whether estate // settings allow voice, then whether parcel allows // voice, if all do retrieve or obtain the parcel // voice channel LandData land = scene.GetLandData(avatar.AbsolutePosition); //m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", // scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); // TODO: EstateSettings don't seem to get propagated... if (!scene.RegionInfo.EstateSettings.AllowVoice) { m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": voice not enabled in estate settings", scene.RegionInfo.RegionName); channelUri = String.Empty; } else if (!scene.RegionInfo.EstateSettings.TaxFree && (land.Flags & (uint)ParcelFlags.AllowVoiceChat) == 0) { // m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel", // scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName); channelUri = String.Empty; } else { channelUri = ChannelUri(scene, land); } // fast foward encode StringBuilder lsl = LLSDxmlEncode.Start(512); LLSDxmlEncode.AddMap(lsl); LLSDxmlEncode.AddElem("parcel_local_id", land.LocalID, lsl); LLSDxmlEncode.AddElem("region_name", scene.Name, lsl); LLSDxmlEncode.AddMap("voice_credentials", lsl); LLSDxmlEncode.AddElem("channel_uri", channelUri, lsl); //LLSDxmlEncode.AddElem("channel_credentials", channel_credentials, lsl); LLSDxmlEncode.AddEndMap(lsl); LLSDxmlEncode.AddEndMap(lsl); response.RawBuffer = Util.UTF8.GetBytes(LLSDxmlEncode.End(lsl)); } catch (Exception e) { m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later", scene.RegionInfo.RegionName, avatarName, e.Message); m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed", scene.RegionInfo.RegionName, avatarName, e.ToString()); response.RawBuffer = Util.UTF8.GetBytes("<llsd>undef</llsd>"); } }
/// <summary> /// Callback for a client request for Voice Account Details /// </summary> /// <param name="scene">current scene object of the client</param> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public void ProvisionVoiceAccountRequest(IOSHttpRequest request, IOSHttpResponse response, UUID agentID, Scene scene) { if (request.HttpMethod != "POST") { response.StatusCode = (int)HttpStatusCode.NotFound; return; } m_log.DebugFormat( "[FreeSwitchVoice][PROVISIONVOICE]: ProvisionVoiceAccountRequest() request for {0}", agentID.ToString()); response.StatusCode = (int)HttpStatusCode.OK; ScenePresence avatar = scene.GetScenePresence(agentID); if (avatar == null) { System.Threading.Thread.Sleep(2000); avatar = scene.GetScenePresence(agentID); if (avatar == null) { response.RawBuffer = Util.UTF8.GetBytes("<llsd>undef</llsd>"); return; } } string avatarName = avatar.Name; try { //XmlElement resp; string agentname = "x" + Convert.ToBase64String(agentID.GetBytes()); string password = "******";//temp hack//new UUID(Guid.NewGuid()).ToString().Replace('-','Z').Substring(0,16); // XXX: we need to cache the voice credentials, as // FreeSwitch is later going to come and ask us for // those agentname = agentname.Replace('+', '-').Replace('/', '_'); lock (m_UUIDName) { if (m_UUIDName.ContainsKey(agentname)) { m_UUIDName[agentname] = avatarName; } else { m_UUIDName.Add(agentname, avatarName); } } string accounturl = String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress, m_freeSwitchServicePort, m_freeSwitchAPIPrefix); // fast foward encode StringBuilder lsl = LLSDxmlEncode.Start(512); LLSDxmlEncode.AddMap(lsl); LLSDxmlEncode.AddElem("username", agentname, lsl); LLSDxmlEncode.AddElem("password", password, lsl); LLSDxmlEncode.AddElem("voice_sip_uri_hostname", m_freeSwitchRealm, lsl); LLSDxmlEncode.AddElem("voice_account_server_name", accounturl, lsl); LLSDxmlEncode.AddEndMap(lsl); response.RawBuffer = Util.UTF8.GetBytes(LLSDxmlEncode.End(lsl)); } catch (Exception e) { m_log.ErrorFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1}, retry later", avatarName, e.Message); m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1} failed", avatarName, e.ToString()); response.RawBuffer = Util.UTF8.GetBytes("<llsd>undef</llsd>"); } }