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 { } osUTF8 lsl = LLSDxmlEncode2.Start(4096); LLSDxmlEncode2.AddMap(lsl); LLSDxmlEncode2.AddElem("agent_id", m_agentID, lsl); if (items == null || items.Length == 0) { LLSDxmlEncode2.AddEmptyArray("items", lsl); } else { LLSDxmlEncode2.AddArray("items", lsl); foreach (InventoryItemBase item in items) { if (item != null) { item.ToLLSDxml(lsl, 0xff); } } LLSDxmlEncode2.AddEndArray(lsl); } LLSDxmlEncode2.AddEndMap(lsl); httpResponse.RawBuffer = LLSDxmlEncode2.EndToBytes(lsl); httpResponse.StatusCode = (int)HttpStatusCode.OK; }
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) { response.StatusCode = (int)HttpStatusCode.ServiceUnavailable; response.AddHeader("Retry-After", "5"); return; } if (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(); } byte[] envBytes = VEnv.ToCapWLBytes(UUID.Zero, regionID); 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); response.RawBuffer = LLSDxmlEncode2.EndToBytes(sb); } else { response.RawBuffer = envBytes; } response.StatusCode = (int)HttpStatusCode.OK; }
public byte[] toLLSDxml(osUTF8 sb = null) { const float scale = 10000f; bool fullLLSD = false; if (sb == null) { sb = LLSDxmlEncode2.Start(1024, false); fullLLSD = true; } LLSDxmlEncode2.AddMap(sb); LLSDxmlEncode2.AddElem("NormMap", NormalMapID, sb); LLSDxmlEncode2.AddElem("NormOffsetX", (int)(scale * NormalOffsetX + 0.5f), sb); LLSDxmlEncode2.AddElem("NormOffsetY", (int)(scale * NormalOffsetY + 0.5f), sb); LLSDxmlEncode2.AddElem("NormRepeatX", (int)(scale * NormalRepeatX + 0.5f), sb); LLSDxmlEncode2.AddElem("NormRepeatY", (int)(scale * NormalRepeatY + 0.5f), sb); LLSDxmlEncode2.AddElem("NormRotation", (int)(scale * NormalRotation + 0.5f), sb); LLSDxmlEncode2.AddElem("SpecMap", SpecularMapID, sb); LLSDxmlEncode2.AddElem("SpecOffsetX", (int)(scale * SpecularOffsetX + 0.5f), sb); LLSDxmlEncode2.AddElem("SpecOffsetY", (int)(scale * SpecularOffsetY + 0.5f), sb); LLSDxmlEncode2.AddElem("SpecRepeatX", (int)(scale * SpecularRepeatX + 0.5f), sb); LLSDxmlEncode2.AddElem("SpecRepeatY", (int)(scale * SpecularRepeatY + 0.5f), sb); LLSDxmlEncode2.AddElem("SpecRotation", (int)(scale * SpecularRotation + 0.5f), sb); LLSDxmlEncode2.AddArray("SpecColor", sb); LLSDxmlEncode2.AddElem(SpecularLightColorR, sb); LLSDxmlEncode2.AddElem(SpecularLightColorG, sb); LLSDxmlEncode2.AddElem(SpecularLightColorB, sb); LLSDxmlEncode2.AddElem(255, sb); LLSDxmlEncode2.AddEndArray(sb); LLSDxmlEncode2.AddElem("SpecExp", SpecularLightExponent, sb); LLSDxmlEncode2.AddElem("EnvIntensity", EnvironmentIntensity, sb); LLSDxmlEncode2.AddElem("DiffuseAlphaMode", DiffuseAlphaMode, sb); LLSDxmlEncode2.AddElem("AlphaMaskCutoff", AlphaMaskCutoff, sb); LLSDxmlEncode2.AddEndMap(sb); if (fullLLSD) { return(LLSDxmlEncode2.EndToBytes(sb)); } else { return(Utils.EmptyBytes); // ignored if appending } }
public void GroupMembershipData(UUID AgentID, GroupMembershipData[] data) { osUTF8 sb = StartEvent("AgentGroupDataUpdate"); LLSDxmlEncode2.AddArrayAndMap("AgentData", sb); LLSDxmlEncode2.AddElem("AgentID", AgentID, sb); LLSDxmlEncode2.AddEndMapAndArray(sb); if (data.Length == 0) { LLSDxmlEncode2.AddEmptyArray("GroupData", sb); LLSDxmlEncode2.AddEmptyArray("NewGroupData", sb); } else { List <bool> lstInProfiles = new List <bool>(data.Length); LLSDxmlEncode2.AddArray("GroupData", sb); foreach (GroupMembershipData m in data) { LLSDxmlEncode2.AddMap(sb); LLSDxmlEncode2.AddElem("GroupID", m.GroupID, sb); LLSDxmlEncode2.AddElem("GroupPowers", m.GroupPowers, sb); LLSDxmlEncode2.AddElem("AcceptNotices", m.AcceptNotices, sb); LLSDxmlEncode2.AddElem("GroupInsigniaID", m.GroupPicture, sb); LLSDxmlEncode2.AddElem("Contribution", m.Contribution, sb); LLSDxmlEncode2.AddElem("GroupName", m.GroupName, sb); LLSDxmlEncode2.AddEndMap(sb); lstInProfiles.Add(m.ListInProfile); } LLSDxmlEncode2.AddEndArray(sb); LLSDxmlEncode2.AddArray("NewGroupData", sb); foreach (bool b in lstInProfiles) { LLSDxmlEncode2.AddMap(sb); LLSDxmlEncode2.AddElem("ListInProfile", b, sb); LLSDxmlEncode2.AddEndMap(sb); } LLSDxmlEncode2.AddEndArray(sb); } Enqueue(EndEventToBytes(sb), AgentID); }
public void PlacesQueryReply(UUID avatarID, UUID queryID, UUID transactionID, PlacesReplyData[] replyDataArray) { osUTF8 sb = new osUTF8(256); LLSDxmlEncode2.AddMap(sb); LLSDxmlEncode2.AddElem("message", "PlacesReplyMessage", sb); LLSDxmlEncode2.AddMap("QueryData[]", sb); LLSDxmlEncode2.AddArray(sb); LLSDxmlEncode2.AddArray("AgentData", sb); LLSDxmlEncode2.AddMap(sb); LLSDxmlEncode2.AddElem("AgentID", avatarID, sb); LLSDxmlEncode2.AddElem("QueryID", queryID, sb); LLSDxmlEncode2.AddElem("TransactionID", transactionID, sb); LLSDxmlEncode2.AddEndMap(sb); LLSDxmlEncode2.AddEndArray(sb); LLSDxmlEncode2.AddArray("QueryData", sb); for (int i = 0; i < replyDataArray.Length; ++i) { PlacesReplyData data = replyDataArray[i]; LLSDxmlEncode2.AddMap(sb); LLSDxmlEncode2.AddElem("ActualArea", data.ActualArea, sb); LLSDxmlEncode2.AddElem("BillableArea", data.BillableArea, sb); LLSDxmlEncode2.AddElem("Description", data.Desc, sb); LLSDxmlEncode2.AddElem("Dwell", data.Dwell, sb); LLSDxmlEncode2.AddElem("Flags", data.Flags, sb); LLSDxmlEncode2.AddElem("GlobalX", data.GlobalX, sb); LLSDxmlEncode2.AddElem("GlobalY", data.GlobalY, sb); LLSDxmlEncode2.AddElem("GlobalZ", data.GlobalZ, sb); LLSDxmlEncode2.AddElem("Name", data.Name, sb); LLSDxmlEncode2.AddElem("OwnerID", data.OwnerID, sb); LLSDxmlEncode2.AddElem("SimName", data.SimName, sb); LLSDxmlEncode2.AddElem("SnapShotID", data.SnapshotID, sb); LLSDxmlEncode2.AddElem("ProductSku", (int)0, sb); LLSDxmlEncode2.AddElem("Price", data.Price, sb); LLSDxmlEncode2.AddEndMap(sb); } LLSDxmlEncode2.AddEndArray(sb); Enqueue(EndEventToBytes(sb), avatarID); }
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; osUTF8 sb = LLSDxmlEncode2.Start(); LLSDxmlEncode2.AddMap(sb); if (allowed != null && allowed.Length > 0) { LLSDxmlEncode2.AddArray("AllowedAgents", sb); for (int i = 0; i < allowed.Length; ++i) { UUID id = allowed[i]; if (id == UUID.Zero) { continue; } LLSDxmlEncode2.AddMap(sb); LLSDxmlEncode2.AddElem("id", id, sb); LLSDxmlEncode2.AddEndMap(sb); } LLSDxmlEncode2.AddEndArray(sb); } else { LLSDxmlEncode2.AddEmptyArray("AllowedAgents", sb); } if (groups != null && groups.Length > 0) { LLSDxmlEncode2.AddArray("AllowedGroups", sb); for (int i = 0; i < groups.Length; ++i) { UUID id = groups[i]; if (id == UUID.Zero) { continue; } LLSDxmlEncode2.AddMap(sb); LLSDxmlEncode2.AddElem("id", id, sb); LLSDxmlEncode2.AddEndMap(sb); } LLSDxmlEncode2.AddEndArray(sb); } else { LLSDxmlEncode2.AddEmptyArray("AllowedGroups", sb); } if (EstateBans != null && EstateBans.Length > 0) { LLSDxmlEncode2.AddArray("BannedAgents", sb); for (int i = 0; i < EstateBans.Length; ++i) { EstateBan ban = EstateBans[i]; UUID id = ban.BannedUserID; if (id == UUID.Zero) { continue; } LLSDxmlEncode2.AddMap(sb); LLSDxmlEncode2.AddElem("id", id, sb); LLSDxmlEncode2.AddElem("banning_id", ban.BanningUserID, sb); LLSDxmlEncode2.AddElem("last_login_date", "na", sb); // We will not have this. This information is far at grid if (ban.BanTime == 0) { LLSDxmlEncode2.AddElem("ban_date", "0000-00-00 00:00", sb); } else { LLSDxmlEncode2.AddElem("ban_date", (Util.ToDateTime(ban.BanTime)).ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture), sb); } LLSDxmlEncode2.AddEndMap(sb); } LLSDxmlEncode2.AddEndArray(sb); } else { LLSDxmlEncode2.AddEmptyArray("BannedAgents", sb); } if (managers != null && managers.Length > 0) { LLSDxmlEncode2.AddArray("Managers", sb); for (int i = 0; i < managers.Length; ++i) { LLSDxmlEncode2.AddMap(sb); LLSDxmlEncode2.AddElem("agent_id", managers[i], sb); LLSDxmlEncode2.AddEndMap(sb); } LLSDxmlEncode2.AddEndArray(sb); } else { LLSDxmlEncode2.AddEmptyArray("Managers", sb); } LLSDxmlEncode2.AddEndMap(sb); response.RawBuffer = LLSDxmlEncode2.EndToBytes(sb); response.StatusCode = (int)HttpStatusCode.OK; }
public void FetchInventoryDescendentsRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, ExpiringKey <UUID> BadRequests) { //m_log.DebugFormat("[XXX]: FetchInventoryDescendentsRequest in {0}, {1}", (m_Scene == null) ? "none" : m_Scene.Name, request); List <LLSDFetchInventoryDescendents> folders = null; List <UUID> bad_folders = new List <UUID>(); try { OSDArray foldersrequested = null; OSD tmp = OSDParser.DeserializeLLSDXml(httpRequest.InputStream); httpRequest.InputStream.Dispose(); OSDMap map = (OSDMap)tmp; if (map.TryGetValue("folders", out tmp) && tmp is OSDArray) { foldersrequested = tmp as OSDArray; } if (foldersrequested == null || foldersrequested.Count == 0) { httpResponse.RawBuffer = EmptyResponse; return; } folders = new List <LLSDFetchInventoryDescendents>(foldersrequested.Count); for (int i = 0; i < foldersrequested.Count; i++) { OSDMap mfolder = foldersrequested[i] as OSDMap; UUID id = mfolder["folder_id"].AsUUID(); if (BadRequests.ContainsKey(id)) { bad_folders.Add(id); } else { LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents(); try { llsdRequest.folder_id = id; llsdRequest.owner_id = mfolder["owner_id"].AsUUID(); llsdRequest.sort_order = mfolder["sort_order"].AsInteger(); llsdRequest.fetch_folders = mfolder["fetch_folders"].AsBoolean(); llsdRequest.fetch_items = mfolder["fetch_items"].AsBoolean(); } catch (Exception e) { m_log.Debug("[WEB FETCH INV DESC HANDLER]: caught exception doing OSD deserialize" + e.Message); continue; } folders.Add(llsdRequest); } } foldersrequested = null; map.Clear(); map = null; } catch (Exception e) { m_log.ErrorFormat("[FETCH INV DESC]: fail parsing request: {0}", e.Message); httpResponse.RawBuffer = EmptyResponse; return; } if (folders == null || folders.Count == 0) { if (bad_folders.Count == 0) { httpResponse.RawBuffer = EmptyResponse; return; } osUTF8 osu = OSUTF8Cached.Acquire(); osu.AppendASCII("[WEB FETCH INV DESC HANDLER]: Unable to fetch folders owned by Unknown user:"******" ..."); } m_log.Warn(osu.ToString()); } osu.Clear(); osu.AppendASCII("<llsd><map><key>folders</key><array /></map><map><key>bad_folders</key><array>"); foreach (UUID bad in bad_folders) { osu.AppendASCII("<map><key>folder_id</key><uuid>"); osu.AppendASCII(bad.ToString()); osu.AppendASCII("</uuid><key>error</key><string>Unknown</string></map>"); } osu.AppendASCII("</array></map></llsd>"); httpResponse.RawBuffer = OSUTF8Cached.GetArrayAndRelease(osu); return; } int total_folders = 0; int total_items = 0; UUID requester = folders[0].owner_id; List <InventoryCollection> invcollSet = Fetch(folders, bad_folders, ref total_folders, ref total_items); //m_log.DebugFormat("[XXX]: Got {0} folders from a request of {1}", invcollSet.Count, folders.Count); int invcollSetCount = 0; if (invcollSet != null) { invcollSetCount = invcollSet.Count; } int mem = 8192 + ((256 * invcollSetCount + 384 * total_folders + 1024 * total_items + 128 * bad_folders.Count) & 0x7ffff000); osUTF8 lastresponse = LLSDxmlEncode2.Start(mem); if (invcollSetCount > 0) { lastresponse.AppendASCII("<map><key>folders</key><array>"); int i = 0; InventoryCollection thiscoll; for (i = 0; i < invcollSetCount; i++) { thiscoll = invcollSet[i]; invcollSet[i] = null; LLSDxmlEncode2.AddMap(lastresponse); LLSDxmlEncode2.AddElem_agent_id(thiscoll.OwnerID, lastresponse); LLSDxmlEncode2.AddElem("descendents", thiscoll.Descendents, lastresponse); LLSDxmlEncode2.AddElem_folder_id(thiscoll.FolderID, lastresponse); if (thiscoll.Folders == null || thiscoll.Folders.Count == 0) { LLSDxmlEncode2.AddEmptyArray("categories", lastresponse); } else { LLSDxmlEncode2.AddArray("categories", lastresponse); foreach (InventoryFolderBase invFolder in thiscoll.Folders) { LLSDxmlEncode2.AddMap(lastresponse); LLSDxmlEncode2.AddElem_folder_id(invFolder.ID, lastresponse); LLSDxmlEncode2.AddElem_parent_id(invFolder.ParentID, lastresponse); LLSDxmlEncode2.AddElem_name(invFolder.Name, lastresponse); LLSDxmlEncode2.AddElem("type", invFolder.Type, lastresponse); LLSDxmlEncode2.AddElem("preferred_type", (int)-1, lastresponse); LLSDxmlEncode2.AddElem("version", invFolder.Version, lastresponse); LLSDxmlEncode2.AddEndMap(lastresponse); } LLSDxmlEncode2.AddEndArray(lastresponse); } if (thiscoll.Items == null || thiscoll.Items.Count == 0) { LLSDxmlEncode2.AddEmptyArray("items", lastresponse); } else { LLSDxmlEncode2.AddArray("items", lastresponse); foreach (InventoryItemBase invItem in thiscoll.Items) { invItem.ToLLSDxml(lastresponse); } LLSDxmlEncode2.AddEndArray(lastresponse); } LLSDxmlEncode2.AddElem_owner_id(thiscoll.OwnerID, lastresponse); LLSDxmlEncode2.AddElem("version", thiscoll.Version, lastresponse); LLSDxmlEncode2.AddEndMap(lastresponse); invcollSet[i] = null; } LLSDxmlEncode2.AddEndArrayAndMap(lastresponse); thiscoll = null; } else { lastresponse.AppendASCII("<map><key>folders</key><array /></map>"); } if (bad_folders.Count > 0) { lastresponse.AppendASCII("<map><key>bad_folders</key><array>"); foreach (UUID bad in bad_folders) { BadRequests.Add(bad); lastresponse.AppendASCII("<map><key>folder_id</key><uuid>"); lastresponse.AppendASCII(bad.ToString()); lastresponse.AppendASCII("</uuid><key>error</key><string>Unknown</string></map>"); } lastresponse.AppendASCII("</array></map>"); StringBuilder sb = osStringBuilderCache.Acquire(); sb.Append("[WEB FETCH INV DESC HANDLER]: Unable to fetch folders owned by "); sb.Append(requester.ToString()); sb.Append(" :"); int limit = 9; foreach (UUID bad in bad_folders) { sb.Append(" "); sb.Append(bad.ToString()); if (--limit < 0) { break; } } if (limit < 0) { sb.Append(" ..."); } m_log.Warn(osStringBuilderCache.GetStringAndRelease(sb)); } httpResponse.RawBuffer = LLSDxmlEncode2.EndToBytes(lastresponse); }
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); } } osUTF8 lsl = LLSDxmlEncode2.Start(4096); LLSDxmlEncode2.AddMap(lsl); if (m_agentID == UUID.Zero && items.Length > 0) { LLSDxmlEncode2.AddElem("agent_id", items[0].Owner, lsl); } else { LLSDxmlEncode2.AddElem("agent_id", m_agentID, lsl); } if (items == null || items.Length == 0) { LLSDxmlEncode2.AddEmptyArray("items", lsl); } else { LLSDxmlEncode2.AddArray("items", lsl); foreach (InventoryItemBase item in items) { if (item != null) { item.ToLLSDxml(lsl, 0xff); } } LLSDxmlEncode2.AddEndArray(lsl); } LLSDxmlEncode2.AddEndMap(lsl); return(LLSDxmlEncode2.End(lsl)); }
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; }