public static OSD DeserializeJson(JsonData json) { switch (json.GetJsonType()) { case JsonType.Boolean: return OSD.FromBoolean((bool)json); case JsonType.Int: return OSD.FromInteger((int)json); case JsonType.Long: return OSD.FromLong((long)json); case JsonType.Double: return OSD.FromReal((double)json); case JsonType.String: string str = (string)json; if (String.IsNullOrEmpty(str)) return new OSD(); else return OSD.FromString(str); case JsonType.Array: OSDArray array = new OSDArray(json.Count); for (int i = 0; i < json.Count; i++) array.Add(DeserializeJson(json[i])); return array; case JsonType.Object: OSDMap map = new OSDMap(json.Count); foreach (KeyValuePair<string, JsonData> kvp in json) map.Add(kvp.Key, DeserializeJson(kvp.Value)); return map; case JsonType.None: default: return new OSD(); } }
byte[] ProductInfoRequestCAP(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { //OSDMap data = m_service.GetCAPS (); var data = new OSDArray(); var mf = new OSDMap (); mf ["name"] = "mainland_full"; mf ["description"] = "Mainland / Full Region"; mf ["sku"] = "001"; data.Add(mf); var mh = new OSDMap (); mh ["name"] = "mainland_homestead"; mh ["description"] = "Mainland / Homestead"; mh ["sku"] = "011"; data.Add(mh); var mo = new OSDMap (); mo ["name"] = "mainland_openspace"; mo ["description"] = "Mainland / Openspace"; mo ["sku"] = "021"; data.Add(mo); var ef = new OSDMap (); ef ["name"] = "estate_full"; ef ["description"] = "Estate / Full Region"; ef ["sku"] = "002"; data.Add(ef); var eh = new OSDMap (); eh ["name"] = "estate_homestead"; eh ["description"] = "Estate / Homestead"; eh ["sku"] = "012"; data.Add(eh); var eo = new OSDMap (); eo ["name"] = "estate_openspace"; eo ["description"] = "Estate / Openspace"; eo ["sku"] = "022"; data.Add(eo); var wh = new OSDMap (); wh ["name"] = "universe_homes"; wh ["description"] = "Universe Homes / Full Region"; wh ["sku"] = "101"; data.Add(wh); return OSDParser.SerializeLLSDXmlBytes (data); }
public static OSD DeserializeJson(JsonData json) { switch (json.GetJsonType()) { case JsonType.Boolean: return OSD.FromBoolean((bool)json); case JsonType.Int: return OSD.FromInteger((int)json); case JsonType.Long: return OSD.FromLong((long)json); case JsonType.Double: return OSD.FromReal((double)json); case JsonType.String: string str = (string)json; if (String.IsNullOrEmpty(str)) return new OSD(); else return OSD.FromString(str); case JsonType.Array: OSDArray array = new OSDArray(json.Count); for (int i = 0; i < json.Count; i++) array.Add(DeserializeJson(json[i])); return array; case JsonType.Object: OSDMap map = new OSDMap(json.Count); IDictionaryEnumerator e = ((IOrderedDictionary)json).GetEnumerator(); while (e.MoveNext()) map.Add((string)e.Key, DeserializeJson((JsonData)e.Value)); return map; case JsonType.None: default: return new OSD(); } }
OSDMap GetParcelsByRegion (OSDMap map) { var resp = new OSDMap (); resp ["Parcels"] = new OSDArray (); resp ["Total"] = OSD.FromInteger (0); var directory = DataPlugins.RequestPlugin<IDirectoryServiceConnector> (); if (directory != null && map.ContainsKey ("Region") == true) { UUID regionID = UUID.Parse (map ["Region"]); UUID scopeID = map.ContainsKey ("ScopeID") ? UUID.Parse (map ["ScopeID"].ToString ()) : UUID.Zero; UUID owner = map.ContainsKey ("Owner") ? UUID.Parse (map ["Owner"].ToString ()) : UUID.Zero; uint start = map.ContainsKey ("Start") ? uint.Parse (map ["Start"].ToString ()) : 0; uint count = map.ContainsKey ("Count") ? uint.Parse (map ["Count"].ToString ()) : 10; ParcelFlags flags = map.ContainsKey ("Flags") ? (ParcelFlags)int.Parse (map ["Flags"].ToString ()) : ParcelFlags.None; ParcelCategory category = map.ContainsKey ("Category") ? (ParcelCategory)uint.Parse (map ["Flags"].ToString ()) : ParcelCategory.Any; uint total = directory.GetNumberOfParcelsByRegion (regionID, owner, flags, category); if (total > 0) { resp ["Total"] = OSD.FromInteger ((int)total); if (count == 0) { return resp; } List<LandData> regionParcels = directory.GetParcelsByRegion (start, count, regionID, owner, flags, category); OSDArray parcels = new OSDArray (regionParcels.Count); regionParcels.ForEach (delegate (LandData parcel) { parcels.Add (LandData2WebOSD (parcel)); }); resp ["Parcels"] = parcels; } } return resp; }
public OSDMap PackAgentCircuitData() { OSDMap args = new OSDMap(); args["agent_id"] = OSD.FromUUID(AgentID); args["base_folder"] = OSD.FromUUID(BaseFolder); args["caps_path"] = OSD.FromString(CapsPath); OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count); foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds) { OSDMap pair = new OSDMap(); pair["handle"] = OSD.FromString(kvp.Key.ToString()); pair["seed"] = OSD.FromString(kvp.Value); childrenSeeds.Add(pair); } if (ChildrenCapSeeds.Count > 0) args["children_seeds"] = childrenSeeds; args["child"] = OSD.FromBoolean(child); args["circuit_code"] = OSD.FromString(circuitcode.ToString()); args["first_name"] = OSD.FromString(firstname); args["last_name"] = OSD.FromString(lastname); args["inventory_folder"] = OSD.FromUUID(InventoryFolder); args["secure_session_id"] = OSD.FromUUID(SecureSessionID); args["session_id"] = OSD.FromUUID(SessionID); args["start_pos"] = OSD.FromString(startpos.ToString()); return args; }
protected OSDMap OnMessageReceived(OSDMap message) { //If it is an async message request, make sure that the request is valid and check it if (message["Method"] == "AsyncMessageRequest") { try { OSDMap response = new OSDMap(); OSDArray array = new OSDArray(); if (m_regionMessages.ContainsKey(message["RegionHandle"].AsULong())) { foreach (OSDMap asyncMess in m_regionMessages[message["RegionHandle"].AsULong()]) { array.Add(asyncMess); } m_regionMessages.Remove(message["RegionHandle"].AsULong()); } response["Messages"] = array; return response; } catch { } } return null; }
OSDMap GetAbuseReports (OSDMap map) { var resp = new OSDMap (); var areports = m_registry.RequestModuleInterface<IAbuseReports> (); int start = map ["Start"].AsInteger (); int count = map ["Count"].AsInteger (); bool active = map ["Active"].AsBoolean (); List<AbuseReport> arList = areports.GetAbuseReports (start, count, active); var AbuseReports = new OSDArray (); if (arList != null) { foreach (AbuseReport rpt in arList) { AbuseReports.Add (rpt.ToOSD ()); } } resp ["AbuseReports"] = AbuseReports; resp ["Start"] = OSD.FromInteger (start); resp ["Count"] = OSD.FromInteger (count); resp ["Active"] = OSD.FromBoolean (active); return resp; }
public OSDMap ToOSD() { OSDMap map = new OSDMap(); map["AuctionStart"] = AuctionStart; map["AuctionLength"] = AuctionLength; map["Description"] = Description; OSDArray array = new OSDArray(); foreach (AuctionBid bid in AuctionBids) array.Add(bid.ToOSD()); map["AuctionBids"] = array; return map; }
/// <summary> /// This adds the entire region into the search database /// </summary> /// <param name="args"></param> public void AddRegion(List<LandData> parcels) { OSDMap mess = new OSDMap(); OSDArray requests = new OSDArray(); foreach (LandData data in parcels) requests.Add(data.ToOSD()); mess["Requests"] = requests; mess["Method"] = "addregion"; List<string> m_ServerURIs = m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf("RemoteServerURI"); foreach (string m_ServerURI in m_ServerURIs) { WebUtils.PostToService (m_ServerURI + "osd", mess, false, false); } }
public override OSDMap ToOSD() { OSDMap result = new OSDMap(); foreach (KeyValuePair<ulong, List<mapItemReply>> kvp in items) { OSDArray array = new OSDArray(); foreach (mapItemReply item in kvp.Value) { array.Add(item.ToOSD()); } result[kvp.Key.ToString()] = array; } return result; }
public OSDArray ToOSD(ref OSDArray array) { OSDMap settings = new OSDMap(); OSDArray cycle = new OSDArray(); foreach (KeyValuePair<string, SkyData> kvp in DataSettings) { cycle.Add(new OSDArray {kvp.Key, kvp.Value.preset_name}); settings[kvp.Value.preset_name] = kvp.Value.ToOSD(); } array[1] = cycle; array[2] = settings; return array; }
public static OSDMap EnableSimulator(ulong regionHandle, IPAddress ip, int port) { OSDMap llsdSimInfo = new OSDMap(3); llsdSimInfo.Add("Handle", OSD.FromULong(regionHandle)); llsdSimInfo.Add("IP", OSD.FromBinary(ip.GetAddressBytes())); llsdSimInfo.Add("Port", OSD.FromInteger(port)); OSDArray arr = new OSDArray(1); arr.Add(llsdSimInfo); OSDMap llsdBody = new OSDMap(1); llsdBody.Add("SimulatorInfo", arr); return llsdBody; }
public static OSD EnableSimulator(ulong handle, IPEndPoint endPoint) { OSDMap llsdSimInfo = new OSDMap(3); llsdSimInfo.Add("Handle", new OSDBinary(ulongToByteArray(handle))); llsdSimInfo.Add("IP", new OSDBinary(endPoint.Address.GetAddressBytes())); llsdSimInfo.Add("Port", new OSDInteger(endPoint.Port)); OSDArray arr = new OSDArray(1); arr.Add(llsdSimInfo); OSDMap llsdBody = new OSDMap(1); llsdBody.Add("SimulatorInfo", arr); return BuildEvent("EnableSimulator", llsdBody); }
public static OSD EnableSimulator(ulong handle, byte[] IPAddress, int Port) { OSDMap llsdSimInfo = new OSDMap(3); llsdSimInfo.Add("Handle", new OSDBinary(ulongToByteArray(handle))); llsdSimInfo.Add("IP", new OSDBinary(IPAddress)); llsdSimInfo.Add("Port", new OSDInteger(Port)); OSDArray arr = new OSDArray(1); arr.Add(llsdSimInfo); OSDMap llsdBody = new OSDMap(1); llsdBody.Add("SimulatorInfo", arr); return buildEvent("EnableSimulator", llsdBody); }
OSDMap GetRegions (OSDMap map) { OSDMap resp = new OSDMap (); RegionFlags type = map.Keys.Contains ("RegionFlags") ? (RegionFlags)map ["RegionFlags"].AsInteger () : RegionFlags.RegionOnline; int start = map.Keys.Contains ("Start") ? map ["Start"].AsInteger () : 0; if (start < 0) { start = 0; } int count = map.Keys.Contains ("Count") ? map ["Count"].AsInteger () : 10; if (count < 0) { count = 1; } var regiondata = DataPlugins.RequestPlugin<IRegionData> (); Dictionary<string, bool> sort = new Dictionary<string, bool> (); string [] supportedSort = { "SortRegionName", "SortLocX", "SortLocY" }; foreach (string sortable in supportedSort) { if (map.ContainsKey (sortable)) { sort [sortable.Substring (4)] = map [sortable].AsBoolean (); } } List<GridRegion> regions = regiondata.Get (type, sort); OSDArray Regions = new OSDArray (); if (start < regions.Count) { int i = 0; int j = regions.Count <= (start + count) ? regions.Count : (start + count); for (i = start; i < j; ++i) { Regions.Add (regions [i].ToOSD ()); } } resp ["Start"] = OSD.FromInteger (start); resp ["Count"] = OSD.FromInteger (count); resp ["Total"] = OSD.FromInteger (regions.Count); resp ["Regions"] = Regions; return resp; }
OSDMap GetAvatarArchives (OSDMap map) { var resp = new OSDMap (); var temp = m_registry.RequestModuleInterface<IAvatarAppearanceArchiver> ().GetAvatarArchives (); var names = new OSDArray (); var snapshot = new OSDArray (); MainConsole.Instance.DebugFormat ("[API] {0} avatar archives found", temp.Count); foreach (AvatarArchive a in temp) { names.Add (OSD.FromString (a.FolderName)); //names.Add(OSD.FromString(a.FileName)); snapshot.Add (OSD.FromUUID (a.Snapshot)); } resp ["names"] = names; resp ["snapshot"] = snapshot; return resp; }
OSDMap GetClassifieds (OSDMap map) { var classifiedListVars = new List<Dictionary<string, object>> (); var resp = new OSDMap (); var directory = DataPlugins.RequestPlugin<IDirectoryServiceConnector> (); if (directory != null) { var classifieds = new List<Classified> (); int category = map.Keys.Contains ("category") ? map ["category"].AsInteger () : (int)DirectoryManager.ClassifiedCategories.Any; int maturity = map.Keys.Contains ("maturity") ? map ["maturity"].AsInteger () : (int)DirectoryManager.ClassifiedFlags.None; classifieds = directory.GetAllClassifieds (category, (uint)maturity); if (classifieds.Count > 0) { // build a list of classifieds var clarry = new OSDArray (); foreach (var classified in classifieds) clarry.Add (classified.ToOSD ()); resp ["classifieds"] = clarry; resp ["count"] = clarry.Count.ToString (); return resp; } } // no classifieds resp ["classifieds"] = new OSDArray (); resp ["count"] = "0"; return resp; }
public static OSDMap TeleportFinish(UUID agentID, int locationID, ulong regionHandle, Uri seedCap, SimAccess simAccess, IPAddress simIP, int simPort, TeleportFlags teleportFlags) { OSDMap info = new OSDMap(8); info.Add("AgentID", OSD.FromUUID(agentID)); info.Add("LocationID", OSD.FromInteger(locationID)); // Unused by the client info.Add("RegionHandle", OSD.FromULong(regionHandle)); info.Add("SeedCapability", OSD.FromUri(seedCap)); info.Add("SimAccess", OSD.FromInteger((byte)simAccess)); info.Add("SimIP", OSD.FromBinary(simIP.GetAddressBytes())); info.Add("SimPort", OSD.FromInteger(simPort)); info.Add("TeleportFlags", OSD.FromUInteger((uint)teleportFlags)); OSDArray infoArray = new OSDArray(1); infoArray.Add(info); OSDMap teleport = new OSDMap(1); teleport.Add("Info", infoArray); return teleport; }
OSDMap GetEvents(OSDMap map) { var resp = new OSDMap (); var directory = DataPlugins.RequestPlugin<IDirectoryServiceConnector> (); if (directory != null) { var events = new List<EventData> (); var timeframe = map.Keys.Contains ("timeframe") ? map ["timeframe"].AsInteger () : 24; var category = map.Keys.Contains ("category") ? map ["category"].AsInteger () :(int)DirectoryManager.EventCategories.All; int eventMaturity = map.Keys.Contains ("maturity") ? map ["maturity"].AsInteger () : Util.ConvertEventMaturityToDBMaturity (DirectoryManager.EventFlags.PG); events = directory.GetAllEvents(timeframe, category , eventMaturity); if (events.Count > 0) { // build a list of classifieds var evarry = new OSDArray (); foreach (var evnt in events) evarry.Add (evnt.ToOSD ()); resp ["events"] = evarry; resp ["count"] = evarry.Count.ToString (); return resp; } } // no eventss resp ["events"] = new OSDArray (); resp ["count"] = "0"; return resp; }
public OSDMap Serialize() { OSDMap map = new OSDMap(); if (MessageSessions.Count > 0) { OSDArray messageArray = new OSDArray(MessageSessions.Count); foreach (KeyValuePair<string, FilterEntryOptions> kvp in MessageSessions) { OSDMap sessionMap = new OSDMap(4); sessionMap["Name"] = OSD.FromString(kvp.Key); sessionMap["Type"] = OSD.FromString(kvp.Value.Type); sessionMap["Capture"] = OSD.FromBoolean(kvp.Value.Checked); sessionMap["Group"] = OSD.FromString(kvp.Value.Group); messageArray.Add(sessionMap); } map.Add("message_sessions", messageArray); } if (PacketSessions.Count > 0) { OSDArray packetArray = new OSDArray(PacketSessions.Count); foreach (KeyValuePair<string, FilterEntryOptions> kvp in PacketSessions) { OSDMap sessionMap = new OSDMap(4); sessionMap["Name"] = OSD.FromString(kvp.Key); sessionMap["Type"] = OSD.FromString(kvp.Value.Type); sessionMap["Capture"] = OSD.FromBoolean(kvp.Value.Checked); sessionMap["Group"] = OSD.FromString(kvp.Value.Group); packetArray.Add(sessionMap); } map.Add("packet_sessions", packetArray); } map.Add("CaptureStatistics", OSD.FromBoolean(StatisticsEnabled)); map.Add("SaveProfileOnExit", OSD.FromBoolean(SaveSessionOnExit)); map.Add("AutoCheckNewCaps", OSD.FromBoolean(AutoCheckNewCaps)); map.Add("FileVersion", OSD.FromInteger(FileVersion)); return map; }
public static OSD TeleportFinishEvent( ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL, UUID agentID, int regionSizeX, int regionSizeY) { // not sure why flags get overwritten here if ((flags & (uint)TeleportFlags.IsFlying) != 0) { flags = (uint)TeleportFlags.ViaLocation | (uint)TeleportFlags.IsFlying; } else { flags = (uint)TeleportFlags.ViaLocation; } OSDMap info = new OSDMap(); info.Add("AgentID", OSD.FromUUID(agentID)); info.Add("LocationID", OSD.FromInteger(4)); // TODO what is this? info.Add("RegionHandle", OSD.FromBinary(ulongToByteArray(regionHandle))); info.Add("SeedCapability", OSD.FromString(capsURL)); info.Add("SimAccess", OSD.FromInteger(simAccess)); info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes())); info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port)); // info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation info.Add("TeleportFlags", OSD.FromUInteger(flags)); info.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX)); info.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY)); OSDArray infoArr = new OSDArray(); infoArr.Add(info); OSDMap body = new OSDMap(); body.Add("Info", infoArr); return(BuildEvent("TeleportFinish", body)); }
public static OSD partPhysicsProperties(uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod) { OSDMap physinfo = new OSDMap(6); physinfo["LocalID"] = localID; physinfo["Density"] = density; physinfo["Friction"] = friction; physinfo["GravityMultiplier"] = gravmod; physinfo["Restitution"] = bounce; physinfo["PhysicsShapeType"] = (int)physhapetype; OSDArray array = new OSDArray(1); array.Add(physinfo); OSDMap llsdBody = new OSDMap(1); llsdBody.Add("ObjectData", array); return(BuildEvent("ObjectPhysicsProperties", llsdBody)); }
/// <summary> /// Serialize the object /// </summary> /// <returns>An <see cref="OSDMap"/> containing the objects data</returns> public OSDMap Serialize() { OSDMap map = new OSDMap(1); OSDArray infoArray = new OSDArray(1); OSDMap info = new OSDMap(8); info.Add("AgentID", OSD.FromUUID(AgentID)); info.Add("LocationID", OSD.FromInteger(LocationID)); // Unused by the client info.Add("RegionHandle", OSD.FromULong(RegionHandle)); info.Add("SeedCapability", OSD.FromUri(SeedCapability)); info.Add("SimAccess", OSD.FromInteger((byte)SimAccess)); info.Add("SimIP", MessageUtils.FromIP(IP)); info.Add("SimPort", OSD.FromInteger(Port)); info.Add("TeleportFlags", OSD.FromUInteger((uint)Flags)); infoArray.Add(info); map.Add("Info", infoArray); return map; }
public byte[] HandleFetchLib(Stream request, UUID AgentID) { try { //MainConsole.Instance.DebugFormat("[InventoryCAPS]: Received FetchLib request for {0}", AgentID); OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request)); OSDArray foldersrequested = (OSDArray)requestmap["items"]; OSDMap map = new OSDMap { { "agent_id", OSD.FromUUID(AgentID) } }; OSDArray items = new OSDArray(); foreach ( OSDArray item in foldersrequested.Cast <OSDMap>() .Select(requestedFolders => requestedFolders["item_id"].AsUUID()) .Select(item_id => m_inventoryService.GetOSDItem(UUID.Zero, item_id)) .Where(item => item != null && item.Count > 0)) { items.Add(item[0]); } map.Add("items", items); byte[] response = OSDParser.SerializeLLSDXmlBytes(map); map.Clear(); return(response); } catch (Exception ex) { MainConsole.Instance.Warn("[InventoryCaps]: SERIOUS ISSUE! " + ex); } OSDMap rmap = new OSDMap(); rmap["items"] = new OSDArray(); return(OSDParser.SerializeLLSDXmlBytes(rmap)); }
byte[] ProcessAvatarPickerSearch(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); string amt = query.GetOne("page-size"); if (amt == null) { amt = query.GetOne("page_size"); } string name = query.GetOne("names"); List <UserAccount> accounts = m_service.Registry.RequestModuleInterface <IUserAccountService> () .GetUserAccounts(m_service.ClientCaps.AccountInfo.AllScopeIDs, name, 0, uint.Parse(amt)) ?? new List <UserAccount> (0); OSDMap body = new OSDMap(); OSDArray array = new OSDArray(); foreach (UserAccount account in accounts) { OSDMap map = new OSDMap(); map ["agent_id"] = account.PrincipalID; IUserProfileInfo profileInfo = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector> () .GetUserProfile(account.PrincipalID); map ["display_name"] = (profileInfo == null || profileInfo.DisplayName == "") ? account.Name : profileInfo.DisplayName; map ["username"] = account.Name; map ["id"] = account.PrincipalID; map ["born_on"] = Util.ToDateTime(account.Created).ToShortDateString(); map ["profile"] = "stuff"; array.Add(map); } body ["agents"] = array; return(OSDParser.SerializeLLSDXmlBytes(body)); }
OSDMap GetParcelsByRegion(OSDMap map) { var resp = new OSDMap(); resp ["Parcels"] = new OSDArray(); resp ["Total"] = OSD.FromInteger(0); var directory = DataPlugins.RequestPlugin <IDirectoryServiceConnector> (); if (directory != null && map.ContainsKey("Region") == true) { UUID regionID = UUID.Parse(map ["Region"]); // not used? // UUID scopeID = map.ContainsKey ("ScopeID") ? UUID.Parse (map ["ScopeID"].ToString ()) : UUID.Zero; UUID owner = map.ContainsKey("Owner") ? UUID.Parse(map ["Owner"].ToString()) : UUID.Zero; uint start = map.ContainsKey("Start") ? uint.Parse(map ["Start"].ToString()) : 0; uint count = map.ContainsKey("Count") ? uint.Parse(map ["Count"].ToString()) : 10; ParcelFlags flags = map.ContainsKey("Flags") ? (ParcelFlags)int.Parse(map ["Flags"].ToString()) : ParcelFlags.None; ParcelCategory category = map.ContainsKey("Category") ? (ParcelCategory)uint.Parse(map ["Flags"].ToString()) : ParcelCategory.Any; uint total = directory.GetNumberOfParcelsByRegion(regionID, owner, flags, category); if (total > 0) { resp ["Total"] = OSD.FromInteger((int)total); if (count == 0) { return(resp); } List <LandData> regionParcels = directory.GetParcelsByRegion(start, count, regionID, owner, flags, category); OSDArray parcels = new OSDArray(regionParcels.Count); regionParcels.ForEach(delegate(LandData parcel) { parcels.Add(LandData2WebOSD(parcel)); }); resp ["Parcels"] = parcels; } } return(resp); }
private byte[] NewRegister(OSDMap request) { GridRegion rinfo = new GridRegion(); rinfo.FromOSD((OSDMap)request["Region"]); UUID SecureSessionID = request["SecureSessionID"].AsUUID(); string result = ""; List <GridRegion> neighbors = new List <GridRegion>(); if (rinfo != null) { result = m_GridService.RegisterRegion(rinfo, SecureSessionID, out SecureSessionID, out neighbors); } OSDMap resultMap = new OSDMap(); resultMap["SecureSessionID"] = SecureSessionID; resultMap["Result"] = result; if (result == "") { object[] o = new object[3] { resultMap, SecureSessionID, rinfo }; m_registry.RequestModuleInterface <ISimulationBase>().EventManager.FireGenericEventHandler( "GridRegionSuccessfullyRegistered", o); //Send the neighbors as well OSDArray array = new OSDArray(); foreach (GridRegion r in neighbors) { array.Add(r.ToOSD()); } resultMap["Neighbors"] = array; } return(Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(resultMap))); }
public byte[] HandleFetchInventory(Stream request, UUID AgentID) { try { //MainConsole.Instance.DebugFormat("[InventoryCAPS]: Received FetchInventory request for {0}", AgentID); OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(request); if (requestmap["items"].Type == OSDType.Unknown) { return(MainServer.BadRequest); } OSDArray foldersrequested = (OSDArray)requestmap["items"]; OSDMap map = new OSDMap { { "agent_id", OSD.FromUUID(AgentID) } }; //We have to send the agent_id in the main map as well as all the items OSDArray items = new OSDArray(); foreach (OSDArray item in foldersrequested.Cast <OSDMap>().Select(requestedFolders => requestedFolders["item_id"].AsUUID()).Select(item_id => m_inventoryService.GetItem(m_service.AgentID, item_id)).Where(item => item != null && item.Count > 0)) { items.Add(item[0]); } map.Add("items", items); byte[] response = OSDParser.SerializeLLSDXmlBytes(map); map.Clear(); return(response); } catch (Exception ex) { MainConsole.Instance.Warn("[InventoryCaps]: SERIOUS ISSUE! " + ex); } OSDMap rmap = new OSDMap(); rmap["items"] = new OSDArray(); return(OSDParser.SerializeLLSDXmlBytes(rmap)); }
public override byte[] Serialize() { OSDMap map = new OSDMap(7); map["Name"] = OSD.FromString(this.Name); map["Host"] = OSD.FromString(this.Host); map["ResponseBytes"] = OSD.FromBinary(this.ResponseBytes); map["Direction"] = OSD.FromInteger((int)this.Direction); map["ContentType"] = OSD.FromString(this.ContentType); map["Protocol"] = OSD.FromString(this.Protocol); OSDArray responseHeadersArray = new OSDArray(); foreach (String key in this.ResponseHeaders.Keys) { OSDMap rMap = new OSDMap(1); rMap[key] = OSD.FromString(this.ResponseHeaders[key]); responseHeadersArray.Add(rMap); } map["ResponseHeaders"] = responseHeadersArray; return(Utils.StringToBytes(map.ToString())); }
public string RenderMaterialsGetCap(string request) { OSDMap resp = new OSDMap(); int matsCount = 0; OSDArray allOsd = new OSDArray(); lock (m_regionMaterials) { foreach (KeyValuePair <UUID, OSDMap> kvp in m_regionMaterials) { OSDMap matMap = new OSDMap(); matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes()); matMap["Material"] = kvp.Value; allOsd.Add(matMap); matsCount++; } } resp["Zipped"] = ZCompressOSD(allOsd, false); return(OSDParser.SerializeLLSDXmlString(resp)); }
OSDMap GetFriends(OSDMap map) { OSDMap resp = new OSDMap(); if (map.ContainsKey("UserID") == false) { resp ["Failed"] = OSD.FromString("User ID not specified."); return(resp); } IFriendsService friendService = m_registry.RequestModuleInterface <IFriendsService> (); if (friendService == null) { resp ["Failed"] = OSD.FromString("No friend service found."); return(resp); } List <FriendInfo> friendsList = friendService.GetFriends(map ["UserID"].AsUUID()); OSDArray friends = new OSDArray(friendsList.Count); foreach (FriendInfo friendInfo in friendsList) { UserAccount userAcct = m_registry.RequestModuleInterface <IUserAccountService> ().GetUserAccount(null, UUID.Parse(friendInfo.Friend)); OSDMap friend = new OSDMap(4); friend ["PrincipalID"] = friendInfo.Friend; friend ["Name"] = userAcct.Name; friend ["MyFlags"] = friendInfo.MyFlags; friend ["TheirFlags"] = friendInfo.TheirFlags; friends.Add(friend); } resp ["Friends"] = friends; friendsList.Clear(); return(resp); }
public OSDArray GetClassifiedRecords(UUID creatorId) { OSDArray data = new OSDArray(); string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = :Id"; IDataReader reader = null; using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) { cmd.CommandText = query; cmd.Parameters.AddWithValue(":Id", creatorId); reader = cmd.ExecuteReader(); } while (reader.Read()) { OSDMap n = new OSDMap(); UUID Id = UUID.Zero; string Name = null; try { UUID.TryParse(Convert.ToString(reader["classifieduuid"]), out Id); Name = Convert.ToString(reader["name"]); } catch (Exception e) { m_log.DebugFormat("[PROFILES_DATA]" + ": UserAccount exception {0}", e.Message); } n.Add("classifieduuid", OSD.FromUUID(Id)); n.Add("name", OSD.FromString(Name)); data.Add(n); } reader.Close(); return(data); }
void SaveSession() { OSDMap s = new OSDMap(); OSDArray array = new OSDArray(); foreach (object[] row in messages.Messages) { array.Add(((Session)row[0]).Serialize()); } s["Version"] = "1.0"; s["Description"] = "Grid Proxy Session Archive"; s["Messages"] = array; System.Threading.ThreadPool.QueueUserWorkItem((sync) => { try { using (var file = File.Open(SessionFileName, FileMode.Create)) { using (var compressed = new GZipStream(file, CompressionMode.Compress)) { using (var writer = new System.Xml.XmlTextWriter(compressed, new UTF8Encoding(false))) { writer.Formatting = System.Xml.Formatting.Indented; writer.WriteStartDocument(); writer.WriteStartElement(String.Empty, "llsd", String.Empty); OSDParser.SerializeLLSDXmlElement(writer, s); writer.WriteEndElement(); } } } } catch { } }); }
public OSDArray GetAvatarPicks(UUID avatarId) { IDataReader reader = null; string query = string.Empty; query += "SELECT `pickuuid`,`name` FROM userpicks WHERE "; query += "creatoruuid = :Id"; OSDArray data = new OSDArray(); try { using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) { cmd.CommandText = query; cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); using (reader = cmd.ExecuteReader()) { while (reader.Read()) { OSDMap record = new OSDMap(); record.Add("pickuuid", OSD.FromString((string)reader["pickuuid"])); record.Add("name", OSD.FromString((string)reader["name"])); data.Add(record); } } } } catch (Exception e) { m_log.DebugFormat("[PROFILES_DATA]" + ": GetAvatarPicks exception {0}", e.Message); } return(data); }
private byte[] GetUserInfos(OSDMap request) { OSDArray userIDs = (OSDArray)request["userIDs"]; string[] users = new string[userIDs.Count]; for (int i = 0; i < userIDs.Count; i++) { users[i] = userIDs[i]; } UserInfo[] result = m_AgentInfoService.GetUserInfos(users); OSDArray resultArray = new OSDArray(); foreach (UserInfo info in result) { resultArray.Add(info != null ? info.ToOSD() : new OSD()); } OSDMap resultMap = new OSDMap(); resultMap["Result"] = resultArray; return(Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(resultMap))); }
public static OSD GetLLSD(Packet packet) { OSDMap body = new OSDMap(); Type type = packet.GetType(); foreach (FieldInfo field in type.GetFields()) { if (field.IsPublic) { Type blockType = field.FieldType; if (blockType.IsArray) { object blockArray = field.GetValue(packet); Array array = (Array)blockArray; OSDArray blockList = new OSDArray(array.Length); IEnumerator ie = array.GetEnumerator(); while (ie.MoveNext()) { object block = ie.Current; blockList.Add(BuildLLSDBlock(block)); } body[field.Name] = blockList; } else { object block = field.GetValue(packet); body[field.Name] = BuildLLSDBlock(block); } } } return body; }
public static OSD GetLLSD(Packet packet) { OSDMap body = new OSDMap(); Type type = packet.GetType(); foreach (FieldInfo field in type.GetFields()) { if (field.IsPublic) { Type blockType = field.FieldType; if (blockType.IsArray) { object blockArray = field.GetValue(packet); Array array = (Array)blockArray; OSDArray blockList = new OSDArray(array.Length); IEnumerator ie = array.GetEnumerator(); while (ie.MoveNext()) { object block = ie.Current; blockList.Add(BuildLLSDBlock(block)); } body[field.Name] = blockList; } else { object block = field.GetValue(packet); body[field.Name] = BuildLLSDBlock(block); } } } return(body); }
public static OSD GroupMembershipData(UUID receiverAgent, GroupMembershipData[] data) { OSDArray AgentData = new OSDArray(1); OSDMap AgentDataMap = new OSDMap(1); AgentDataMap.Add("AgentID", OSD.FromUUID(receiverAgent)); AgentData.Add(AgentDataMap); OSDArray GroupData = new OSDArray(data.Length); OSDArray NewGroupData = new OSDArray(data.Length); foreach (GroupMembershipData membership in data) { OSDMap GroupDataMap = new OSDMap(6); OSDMap NewGroupDataMap = new OSDMap(1); GroupDataMap.Add("GroupID", OSD.FromUUID(membership.GroupID)); GroupDataMap.Add("GroupPowers", OSD.FromULong(membership.GroupPowers)); GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(membership.AcceptNotices)); GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(membership.GroupPicture)); GroupDataMap.Add("Contribution", OSD.FromInteger(membership.Contribution)); GroupDataMap.Add("GroupName", OSD.FromString(membership.GroupName)); NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(membership.ListInProfile)); GroupData.Add(GroupDataMap); NewGroupData.Add(NewGroupDataMap); } OSDMap llDataStruct = new OSDMap(3); llDataStruct.Add("AgentData", AgentData); llDataStruct.Add("GroupData", GroupData); llDataStruct.Add("NewGroupData", NewGroupData); return(BuildEvent("AgentGroupDataUpdate", llDataStruct)); }
public static OSD GroupMembership(AgentGroupDataUpdatePacket groupUpdatePacket) { OSDMap groupUpdate = new OSDMap { { "message", OSD.FromString("AgentGroupDataUpdate") } }; OSDMap body = new OSDMap(); OSDArray agentData = new OSDArray(); OSDMap agentDataMap = new OSDMap { { "AgentID", OSD.FromUUID(groupUpdatePacket.AgentData.AgentID) } }; agentData.Add(agentDataMap); body.Add("AgentData", agentData); OSDArray groupData = new OSDArray(); foreach (OSDMap groupDataMap in groupUpdatePacket.GroupData.Select(groupDataBlock => new OSDMap { { "ListInProfile", OSD.FromBoolean(false) }, { "GroupID", OSD.FromUUID(groupDataBlock.GroupID) }, { "GroupInsigniaID", OSD.FromUUID(groupDataBlock.GroupInsigniaID) }, { "Contribution", OSD.FromInteger(groupDataBlock.Contribution) }, { "GroupPowers", OSD.FromBinary(ulongToByteArray(groupDataBlock.GroupPowers)) }, { "GroupName", OSD.FromString(Utils.BytesToString(groupDataBlock.GroupName)) }, { "AcceptNotices", OSD.FromBoolean(groupDataBlock.AcceptNotices) } })) { groupData.Add(groupDataMap); } body.Add("GroupData", groupData); groupUpdate.Add("body", body); return(groupUpdate); }
/// <summary> /// Pack AgentCircuitData into an OSDMap for transmission over LLSD XML or LLSD json /// </summary> /// <returns>map of the agent circuit data</returns> public OSDMap PackAgentCircuitData() { OSDMap args = new OSDMap(); args["agent_id"] = OSD.FromUUID(AgentID); args["base_folder"] = OSD.FromUUID(BaseFolder); args["caps_path"] = OSD.FromString(CapsPath); if (ChildrenCapSeeds != null) { OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count); foreach (KeyValuePair <ulong, string> kvp in ChildrenCapSeeds) { OSDMap pair = new OSDMap(); pair["handle"] = OSD.FromString(kvp.Key.ToString()); pair["seed"] = OSD.FromString(kvp.Value); childrenSeeds.Add(pair); } if (ChildrenCapSeeds.Count > 0) { args["children_seeds"] = childrenSeeds; } } args["child"] = OSD.FromBoolean(child); args["circuit_code"] = OSD.FromString(circuitcode.ToString()); args["first_name"] = OSD.FromString(firstname); args["last_name"] = OSD.FromString(lastname); args["inventory_folder"] = OSD.FromUUID(InventoryFolder); args["secure_session_id"] = OSD.FromUUID(SecureSessionID); args["session_id"] = OSD.FromUUID(SessionID); args["service_session_id"] = OSD.FromString(ServiceSessionID); args["start_pos"] = OSD.FromString(startpos.ToString()); args["client_ip"] = OSD.FromString(IPAddress); args["viewer"] = OSD.FromString(Viewer); args["channel"] = OSD.FromString(Channel); args["mac"] = OSD.FromString(Mac); args["id0"] = OSD.FromString(Id0); if (Appearance != null) { args["appearance_serial"] = OSD.FromInteger(Appearance.Serial); OSDMap appmap = Appearance.Pack(); args["packed_appearance"] = appmap; } // Old, bad way. Keeping it fow now for backwards compatibility // OBSOLETE -- soon to be deleted if (ServiceURLs != null && ServiceURLs.Count > 0) { OSDArray urls = new OSDArray(ServiceURLs.Count * 2); foreach (KeyValuePair <string, object> kvp in ServiceURLs) { //System.Console.WriteLine("XXX " + kvp.Key + "=" + kvp.Value); urls.Add(OSD.FromString(kvp.Key)); urls.Add(OSD.FromString((kvp.Value == null) ? string.Empty : kvp.Value.ToString())); } args["service_urls"] = urls; } // again, this time the right way if (ServiceURLs != null && ServiceURLs.Count > 0) { OSDMap urls = new OSDMap(); foreach (KeyValuePair <string, object> kvp in ServiceURLs) { //System.Console.WriteLine("XXX " + kvp.Key + "=" + kvp.Value); urls[kvp.Key] = OSD.FromString((kvp.Value == null) ? string.Empty : kvp.Value.ToString()); } args["serviceurls"] = urls; } return(args); }
private void saveSessionArchiveToolStripMenuItem_Click(object sender, EventArgs e) { if (saveFileDialog1.ShowDialog() == DialogResult.OK) { OSDMap map = new OSDMap(1); OSDArray sessionArray = new OSDArray(); foreach (Session item in m_SessionViewItems) { OSDMap session = new OSDMap(); session["type"] = OSD.FromString(item.GetType().Name); session["tag"] = OSD.FromBinary(item.Serialize()); sessionArray.Add(session); } map["sessions"] = sessionArray; try { File.WriteAllText(saveFileDialog1.FileName, map.ToString()); } catch (Exception ex) { MessageBox.Show("Exception occurred trying to save session archive: " + ex); } } }
public static OSD GroupMembership(AgentGroupDataUpdatePacket groupUpdatePacket) { OSDMap groupUpdate = new OSDMap {{"message", OSD.FromString("AgentGroupDataUpdate")}}; OSDMap body = new OSDMap(); OSDArray agentData = new OSDArray(); OSDMap agentDataMap = new OSDMap {{"AgentID", OSD.FromUUID(groupUpdatePacket.AgentData.AgentID)}}; agentData.Add(agentDataMap); body.Add("AgentData", agentData); OSDArray groupData = new OSDArray(); #if(!ISWIN) foreach (AgentGroupDataUpdatePacket.GroupDataBlock groupDataBlock in groupUpdatePacket.GroupData) { OSDMap groupDataMap = new OSDMap(); groupDataMap.Add("ListInProfile", OSD.FromBoolean(false)); groupDataMap.Add("GroupID", OSD.FromUUID(groupDataBlock.GroupID)); groupDataMap.Add("GroupInsigniaID", OSD.FromUUID(groupDataBlock.GroupInsigniaID)); groupDataMap.Add("Contribution", OSD.FromInteger(groupDataBlock.Contribution)); groupDataMap.Add("GroupPowers", OSD.FromBinary(ulongToByteArray(groupDataBlock.GroupPowers))); groupDataMap.Add("GroupName", OSD.FromString(Utils.BytesToString(groupDataBlock.GroupName))); groupDataMap.Add("AcceptNotices", OSD.FromBoolean(groupDataBlock.AcceptNotices)); groupData.Add(groupDataMap); } #else foreach (OSDMap groupDataMap in groupUpdatePacket.GroupData.Select(groupDataBlock => new OSDMap { {"ListInProfile", OSD.FromBoolean(false)}, {"GroupID", OSD.FromUUID(groupDataBlock.GroupID)}, {"GroupInsigniaID", OSD.FromUUID(groupDataBlock.GroupInsigniaID)}, {"Contribution", OSD.FromInteger(groupDataBlock.Contribution)}, {"GroupPowers", OSD.FromBinary(ulongToByteArray(groupDataBlock.GroupPowers))}, {"GroupName", OSD.FromString(Utils.BytesToString(groupDataBlock.GroupName))}, {"AcceptNotices", OSD.FromBoolean(groupDataBlock.AcceptNotices)} })) { groupData.Add(groupDataMap); } #endif body.Add("GroupData", groupData); groupUpdate.Add("body", body); return groupUpdate; }
public static OSD PlacesQuery(PlacesReplyPacket PlacesReply, string[] regionType) { OSDMap placesReply = new OSDMap {{"message", OSD.FromString("PlacesReplyMessage")}}; OSDMap body = new OSDMap(); OSDArray agentData = new OSDArray(); OSDMap agentDataMap = new OSDMap { {"AgentID", OSD.FromUUID(PlacesReply.AgentData.AgentID)}, {"QueryID", OSD.FromUUID(PlacesReply.AgentData.QueryID)}, {"TransactionID", OSD.FromUUID(PlacesReply.TransactionData.TransactionID)} }; agentData.Add(agentDataMap); body.Add("AgentData", agentData); OSDArray QueryData = new OSDArray(); #if(!ISWIN) int i = 0; foreach (PlacesReplyPacket.QueryDataBlock groupDataBlock in PlacesReply.QueryData) { OSDMap QueryDataMap = new OSDMap(); QueryDataMap.Add("ActualArea", OSD.FromInteger(groupDataBlock.ActualArea)); QueryDataMap.Add("BillableArea", OSD.FromInteger(groupDataBlock.BillableArea)); QueryDataMap.Add("Description", OSD.FromBinary(groupDataBlock.Desc)); QueryDataMap.Add("Dwell", OSD.FromInteger((int)groupDataBlock.Dwell)); QueryDataMap.Add("Flags", OSD.FromString(Convert.ToString(groupDataBlock.Flags))); QueryDataMap.Add("GlobalX", OSD.FromInteger((int)groupDataBlock.GlobalX)); QueryDataMap.Add("GlobalY", OSD.FromInteger((int)groupDataBlock.GlobalY)); QueryDataMap.Add("GlobalZ", OSD.FromInteger((int)groupDataBlock.GlobalZ)); QueryDataMap.Add("Name", OSD.FromBinary(groupDataBlock.Name)); QueryDataMap.Add("OwnerID", OSD.FromUUID(groupDataBlock.OwnerID)); QueryDataMap.Add("SimName", OSD.FromBinary(groupDataBlock.SimName)); QueryDataMap.Add("SnapShotID", OSD.FromUUID(groupDataBlock.SnapshotID)); QueryDataMap.Add("ProductSku", OSD.FromString(regionType[i])); QueryDataMap.Add("Price", OSD.FromInteger(groupDataBlock.Price)); QueryData.Add(QueryDataMap); i++; } #else int[] i = {0}; foreach (OSDMap QueryDataMap in PlacesReply.QueryData.Select(groupDataBlock => new OSDMap { {"ActualArea", OSD.FromInteger(groupDataBlock.ActualArea)}, {"BillableArea", OSD.FromInteger(groupDataBlock.BillableArea)}, {"Description", OSD.FromBinary(groupDataBlock.Desc)}, {"Dwell", OSD.FromInteger((int) groupDataBlock.Dwell)}, {"Flags", OSD.FromString(Convert.ToString(groupDataBlock.Flags))}, {"GlobalX", OSD.FromInteger((int) groupDataBlock.GlobalX)}, {"GlobalY", OSD.FromInteger((int) groupDataBlock.GlobalY)}, {"GlobalZ", OSD.FromInteger((int) groupDataBlock.GlobalZ)}, {"Name", OSD.FromBinary(groupDataBlock.Name)}, {"OwnerID", OSD.FromUUID(groupDataBlock.OwnerID)}, {"SimName", OSD.FromBinary(groupDataBlock.SimName)}, {"SnapShotID", OSD.FromUUID(groupDataBlock.SnapshotID)}, {"ProductSku", OSD.FromString(regionType[i[0]])}, {"Price", OSD.FromInteger(groupDataBlock.Price)} })) { QueryData.Add(QueryDataMap); i[0]++; } #endif body.Add("QueryData", QueryData); placesReply.Add("QueryData[]", body); placesReply.Add("body", body); return placesReply; }
public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List <UUID> featuresAvailable, EntityTransferContext ctx, out string reason) { Culture.SetCurrentCulture(); reason = "Failed to contact destination"; // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position); // Eventually, we want to use a caps url instead of the agentID string uri = destination.ServerURI + AgentPath() + agentID + "/" + destination.RegionID.ToString() + "/"; OSDMap request = new OSDMap(); request.Add("viaTeleport", OSD.FromBoolean(viaTeleport)); request.Add("position", OSD.FromString(position.ToString())); // To those who still understad this field, we're telling them // the lowest version just to be safe request.Add("my_version", OSD.FromString(String.Format("SIMULATION/{0}", VersionInfo.SimulationServiceVersionSupportedMin))); // New simulation service negotiation request.Add("simulation_service_supported_min", OSD.FromReal(VersionInfo.SimulationServiceVersionSupportedMin)); request.Add("simulation_service_supported_max", OSD.FromReal(VersionInfo.SimulationServiceVersionSupportedMax)); request.Add("simulation_service_accepted_min", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMin)); request.Add("simulation_service_accepted_max", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMax)); request.Add("context", ctx.Pack()); OSDArray features = new OSDArray(); foreach (UUID feature in featuresAvailable) { features.Add(OSD.FromString(feature.ToString())); } request.Add("features", features); if (agentHomeURI != null) { request.Add("agent_home_uri", OSD.FromString(agentHomeURI)); } OSD tmpOSD; try { OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false, false, true); bool success = result["success"].AsBoolean(); bool has_Result = false; if (result.TryGetValue("_Result", out tmpOSD)) { has_Result = true; OSDMap data = (OSDMap)tmpOSD; // FIXME: If there is a _Result map then it's the success key here that indicates the true success // or failure, not the sibling result node. //nte4.8 crap success = data["success"].AsBoolean(); reason = data["reason"].AsString(); // We will need to plumb this and start sing the outbound version as well // TODO: lay the pipe for version plumbing if (data.TryGetValue("negotiated_inbound_version", out tmpOSD) && tmpOSD != null) { ctx.InboundVersion = (float)tmpOSD.AsReal(); ctx.OutboundVersion = (float)data["negotiated_outbound_version"].AsReal(); } else if (data.TryGetValue("version", out tmpOSD) && tmpOSD != null) { string versionString = tmpOSD.AsString(); if (versionString != string.Empty) { String[] parts = versionString.Split(new char[] { '/' }); if (parts.Length > 1) { ctx.InboundVersion = float.Parse(parts[1], Culture.FormatProvider); ctx.OutboundVersion = float.Parse(parts[1], Culture.FormatProvider); } } } m_log.DebugFormat( "[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}, reason {2}, version {3}/{4}", uri, success, reason, ctx.InboundVersion, ctx.OutboundVersion); } if (!success || ctx.InboundVersion == 0f || ctx.OutboundVersion == 0f) { // If we don't check this then OpenSimulator 0.7.3.1 and some period before will never see the // actual failure message if (!has_Result) { if (result.TryGetValue("Message", out tmpOSD)) { string message = tmpOSD.AsString(); if (message == "Service request failed: [MethodNotAllowed] MethodNotAllowed") // Old style region { m_log.Info("[REMOTE SIMULATION CONNECTOR]: The above web util error was caused by a TP to a sim that doesn't support QUERYACCESS and can be ignored"); return(true); } reason = result["Message"]; } else { reason = "Communications failure"; } } return(false); } featuresAvailable.Clear(); if (result.TryGetValue("features", out tmpOSD) && tmpOSD is OSDArray) { OSDArray array = (OSDArray)tmpOSD; foreach (OSD o in array) { featuresAvailable.Add(new UUID(o.AsString())); } } // Version stuff if (ctx.OutboundVersion < 0.5) { ctx.WearablesCount = AvatarWearable.LEGACY_VERSION_MAX_WEARABLES; } else if (ctx.OutboundVersion < 0.6) { ctx.WearablesCount = AvatarWearable.LEGACY_VERSION_MAX_WEARABLES + 1; } else { ctx.WearablesCount = -1; // send all (just in case..) } return(success); } catch (Exception e) { m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] QueryAcesss failed with exception; {0}", e.ToString()); } return(false); }
public virtual OSDMap Pack(EntityTransferContext ctx) { int wearablesCount = -1; // m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data"); OSDMap args = new OSDMap(); args["message_type"] = OSD.FromString("AgentData"); args["region_id"] = OSD.FromString(RegionID.ToString()); args["circuit_code"] = OSD.FromString(CircuitCode.ToString()); args["agent_uuid"] = OSD.FromUUID(AgentID); args["session_uuid"] = OSD.FromUUID(SessionID); args["position"] = OSD.FromString(Position.ToString()); args["velocity"] = OSD.FromString(Velocity.ToString()); args["center"] = OSD.FromString(Center.ToString()); args["size"] = OSD.FromString(Size.ToString()); args["at_axis"] = OSD.FromString(AtAxis.ToString()); args["left_axis"] = OSD.FromString(LeftAxis.ToString()); args["up_axis"] = OSD.FromString(UpAxis.ToString()); //backwards compatibility args["changed_grid"] = OSD.FromBoolean(SenderWantsToWaitForRoot); args["wait_for_root"] = OSD.FromBoolean(SenderWantsToWaitForRoot); args["far"] = OSD.FromReal(Far); args["aspect"] = OSD.FromReal(Aspect); if ((Throttles != null) && (Throttles.Length > 0)) { args["throttles"] = OSD.FromBinary(Throttles); } args["locomotion_state"] = OSD.FromString(LocomotionState.ToString()); args["head_rotation"] = OSD.FromString(HeadRotation.ToString()); args["body_rotation"] = OSD.FromString(BodyRotation.ToString()); args["control_flags"] = OSD.FromString(ControlFlags.ToString()); args["energy_level"] = OSD.FromReal(EnergyLevel); args["god_level"] = OSD.FromString(GodLevel.ToString()); args["always_run"] = OSD.FromBoolean(AlwaysRun); args["prey_agent"] = OSD.FromUUID(PreyAgent); args["agent_access"] = OSD.FromString(AgentAccess.ToString()); args["active_group_id"] = OSD.FromUUID(ActiveGroupID); if ((Groups != null) && (Groups.Length > 0)) { OSDArray groups = new OSDArray(Groups.Length); foreach (AgentGroupData agd in Groups) { groups.Add(agd.PackUpdateMessage()); } args["groups"] = groups; } if (ChildrenCapSeeds != null && ChildrenCapSeeds.Count > 0) { OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count); foreach (KeyValuePair <ulong, string> kvp in ChildrenCapSeeds) { OSDMap pair = new OSDMap(); pair["handle"] = OSD.FromString(kvp.Key.ToString()); pair["seed"] = OSD.FromString(kvp.Value); childrenSeeds.Add(pair); } args["children_seeds"] = childrenSeeds; } if ((Anims != null) && (Anims.Length > 0)) { OSDArray anims = new OSDArray(Anims.Length); foreach (Animation aanim in Anims) { anims.Add(aanim.PackUpdateMessage()); } args["animations"] = anims; } if (DefaultAnim != null) { args["default_animation"] = DefaultAnim.PackUpdateMessage(); } if (AnimState != null) { args["animation_state"] = AnimState.PackUpdateMessage(); } if (MovementAnimationOverRides.Count > 0) { OSDArray AOs = new OSDArray(MovementAnimationOverRides.Count); { foreach (KeyValuePair <string, UUID> kvp in MovementAnimationOverRides) { OSDMap ao = new OSDMap(2); ao["state"] = OSD.FromString(kvp.Key); ao["uuid"] = OSD.FromUUID(kvp.Value); AOs.Add(ao); } } args["movementAO"] = AOs; } if (MotionState != 0) { args["motion_state"] = OSD.FromInteger(MotionState); } if (Appearance != null) { args["packed_appearance"] = Appearance.Pack(ctx); } //if ((AgentTextures != null) && (AgentTextures.Length > 0)) //{ // OSDArray textures = new OSDArray(AgentTextures.Length); // foreach (UUID uuid in AgentTextures) // textures.Add(OSD.FromUUID(uuid)); // args["agent_textures"] = textures; //} // The code to pack textures, visuals, wearables and attachments // should be removed; packed appearance contains the full appearance // This is retained for backward compatibility only /* then lets remove * if (Appearance.Texture != null) * { * byte[] rawtextures = Appearance.Texture.GetBytes(); * args["texture_entry"] = OSD.FromBinary(rawtextures); * } * * if ((Appearance.VisualParams != null) && (Appearance.VisualParams.Length > 0)) * args["visual_params"] = OSD.FromBinary(Appearance.VisualParams); * * // We might not pass this in all cases... * if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0)) * { * OSDArray wears = new OSDArray(Appearance.Wearables.Length); * foreach (AvatarWearable awear in Appearance.Wearables) * wears.Add(awear.Pack()); * * args["wearables"] = wears; * } * * List<AvatarAttachment> attachments = Appearance.GetAttachments(); * if ((attachments != null) && (attachments.Count > 0)) * { * OSDArray attachs = new OSDArray(attachments.Count); * foreach (AvatarAttachment att in attachments) * attachs.Add(att.Pack()); * args["attachments"] = attachs; * } * // End of code to remove */ if ((Controllers != null) && (Controllers.Length > 0)) { OSDArray controls = new OSDArray(Controllers.Length); foreach (ControllerData ctl in Controllers) { controls.Add(ctl.PackUpdateMessage()); } args["controllers"] = controls; } if ((CallbackURI != null) && (!CallbackURI.Equals(""))) { args["callback_uri"] = OSD.FromString(CallbackURI); } // Attachment objects for fatpack messages if (AttachmentObjects != null) { int i = 0; OSDArray attObjs = new OSDArray(AttachmentObjects.Count); foreach (ISceneObject so in AttachmentObjects) { OSDMap info = new OSDMap(4); info["sog"] = OSD.FromString(so.ToXml2()); info["extra"] = OSD.FromString(so.ExtraToXmlString()); info["modified"] = OSD.FromBoolean(so.HasGroupChanged); try { info["state"] = OSD.FromString(AttachmentObjectStates[i++]); } catch (IndexOutOfRangeException) { m_log.WarnFormat("[CHILD AGENT DATA]: scripts list is shorter than object list."); } attObjs.Add(info); } args["attach_objects"] = attObjs; } args["parent_part"] = OSD.FromUUID(ParentPart); args["sit_offset"] = OSD.FromString(SitOffset.ToString()); return(args); }
public string RenderMaterialsPostCap(string request, UUID agentID) { OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); OSDMap resp = new OSDMap(); OSDMap materialsFromViewer = null; OSDArray respArr = new OSDArray(); if (req.ContainsKey("Zipped")) { OSD osd = null; byte[] inBytes = req["Zipped"].AsBinary(); try { osd = ZDecompressBytesToOsd(inBytes); if (osd != null) { if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries { foreach (OSD elem in (OSDArray)osd) { try { UUID id = new UUID(elem.AsBinary(), 0); lock (m_regionMaterials) { if (m_regionMaterials.ContainsKey(id)) { OSDMap matMap = new OSDMap(); matMap["ID"] = OSD.FromBinary(id.GetBytes()); matMap["Material"] = m_regionMaterials[id]; respArr.Add(matMap); } else { m_log.Warn("[Materials]: request for unknown material ID: " + id.ToString()); // Theoretically we could try to load the material from the assets service, // but that shouldn't be necessary because the viewer should only request // materials that exist in a prim on the region, and all of these materials // are already stored in m_regionMaterials. } } } catch (Exception e) { m_log.Error("Error getting materials in response to viewer request", e); continue; } } } else if (osd is OSDMap) // request to assign a material { materialsFromViewer = osd as OSDMap; if (materialsFromViewer.ContainsKey("FullMaterialsPerFace")) { OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"]; if (matsOsd is OSDArray) { OSDArray matsArr = matsOsd as OSDArray; try { foreach (OSDMap matsMap in matsArr) { uint primLocalID = 0; try { primLocalID = matsMap["ID"].AsUInteger(); } catch (Exception e) { m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message); continue; } OSDMap mat = null; try { mat = matsMap["Material"] as OSDMap; } catch (Exception e) { m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message); continue; } SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID); if (sop == null) { m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString()); continue; } if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID)) { m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID); continue; } Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); if (te == null) { m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID); continue; } UUID id; if (mat == null) { // This happens then the user removes a material from a prim id = UUID.Zero; } else { id = StoreMaterialAsAsset(agentID, mat, sop); } int face = -1; if (matsMap.ContainsKey("Face")) { face = matsMap["Face"].AsInteger(); Primitive.TextureEntryFace faceEntry = te.CreateFace((uint)face); faceEntry.MaterialID = id; } else { if (te.DefaultTexture == null) { m_log.WarnFormat("[Materials]: TextureEntry.DefaultTexture is null in {0} {1}", sop.Name, sop.UUID); } else { te.DefaultTexture.MaterialID = id; } } //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id); // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually sop.Shape.TextureEntry = te.GetBytes(); if (sop.ParentGroup != null) { sop.TriggerScriptChangedEvent(Changed.TEXTURE); sop.UpdateFlag = UpdateRequired.FULL; sop.ParentGroup.HasGroupChanged = true; sop.ScheduleFullUpdate(); } } } catch (Exception e) { m_log.Warn("[Materials]: exception processing received material ", e); } } } } } } catch (Exception e) { m_log.Warn("[Materials]: exception decoding zipped CAP payload ", e); //return ""; } } resp["Zipped"] = ZCompressOSD(respArr, false); string response = OSDParser.SerializeLLSDXmlString(resp); //m_log.Debug("[Materials]: cap request: " + request); //m_log.Debug("[Materials]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary())); //m_log.Debug("[Materials]: cap response: " + response); return(response); }
public override string Execute(string[] args, UUID fromAgentID) { // load known texture table OSD knownTexturesOsd = null; if (File.Exists(mKnownTexturesCacheFile)) { knownTexturesOsd = OSDParser.DeserializeJson( File.ReadAllText(mKnownTexturesCacheFile)); if (knownTexturesOsd is OSDArray) { foreach (OSD osd in (OSDArray)knownTexturesOsd) { TextureInfo ti = new TextureInfo(osd); mKnownTextures[ti.Id] = ti; } } knownTexturesOsd = null; } string fileName = "sim.pov"; if (args.Length > 0) fileName = args[args.Length - 1]; if (!fileName.EndsWith(".pov")) fileName += ".pov"; Logger.Log("dpovray: fileName:" + fileName, Helpers.LogLevel.Debug); ulong regionHandle = Client.Network.CurrentSim.Handle; bool success = ProcessScene(regionHandle, fileName); // load known textures again in case another bot wrote some while we were busy // load known texture table if (File.Exists(mKnownTexturesCacheFile)) { knownTexturesOsd = OSDParser.DeserializeJson( File.ReadAllText(mKnownTexturesCacheFile)); if (knownTexturesOsd is OSDArray) { foreach (OSD osd in (OSDArray)knownTexturesOsd) { TextureInfo ti = new TextureInfo(osd); mKnownTextures[ti.Id] = ti; } } } // now save our known textuer cache OSDArray knownTexturesArr = new OSDArray(); foreach (KeyValuePair<UUID, TextureInfo> kvp in mKnownTextures) { if (kvp.Value != null) knownTexturesArr.Add(kvp.Value.GetOsd()); } File.WriteAllText(mKnownTexturesCacheFile, OSDParser.SerializeJsonString(knownTexturesArr)); if (success) return "exported sim to file: " + fileName; return "error exporting sim to file: " + fileName; }
private void MakeSeedRequest() { if (Simulator == null || !Simulator.Client.Network.Connected) { return; } // Create a request list OSDArray req = new OSDArray(); // This list can be updated by using the following command to obtain a current list of capabilities the official linden viewer supports: // wget -q -O - https://bitbucket.org/lindenlab/viewer-release/raw/default/indra/newview/llviewerregion.cpp | grep 'capabilityNames.append' | sed 's/^[ \t]*//;s/capabilityNames.append("/req.Add("/' req.Add("AgentPreferences"); req.Add("AgentState"); req.Add("AttachmentResources"); req.Add("AvatarPickerSearch"); req.Add("AvatarRenderInfo"); req.Add("CharacterProperties"); req.Add("ChatSessionRequest"); req.Add("CopyInventoryFromNotecard"); req.Add("CreateInventoryCategory"); req.Add("DispatchRegionInfo"); req.Add("DirectDelivery"); req.Add("EnvironmentSettings"); req.Add("EstateChangeInfo"); req.Add("EventQueueGet"); req.Add("FacebookConnect"); req.Add("FlickrConnect"); req.Add("TwitterConnect"); req.Add("FetchLib2"); req.Add("FetchLibDescendents2"); req.Add("FetchInventory2"); req.Add("FetchInventoryDescendents2"); req.Add("IncrementCOFVersion"); req.Add("GetDisplayNames"); req.Add("GetExperiences"); req.Add("AgentExperiences"); req.Add("FindExperienceByName"); req.Add("GetExperienceInfo"); req.Add("GetAdminExperiences"); req.Add("GetCreatorExperiences"); req.Add("ExperiencePreferences"); req.Add("GroupExperiences"); req.Add("UpdateExperience"); req.Add("IsExperienceAdmin"); req.Add("IsExperienceContributor"); req.Add("RegionExperiences"); req.Add("GetMesh"); req.Add("GetMesh2"); req.Add("GetMetadata"); req.Add("GetObjectCost"); req.Add("GetObjectPhysicsData"); req.Add("GetTexture"); req.Add("GroupAPIv1"); req.Add("GroupMemberData"); req.Add("GroupProposalBallot"); req.Add("HomeLocation"); req.Add("LandResources"); req.Add("LSLSyntax"); req.Add("MapLayer"); req.Add("MapLayerGod"); req.Add("MeshUploadFlag"); req.Add("NavMeshGenerationStatus"); req.Add("NewFileAgentInventory"); req.Add("ObjectMedia"); req.Add("ObjectMediaNavigate"); req.Add("ObjectNavMeshProperties"); req.Add("ParcelPropertiesUpdate"); req.Add("ParcelVoiceInfoRequest"); req.Add("ProductInfoRequest"); req.Add("ProvisionVoiceAccountRequest"); req.Add("RemoteParcelRequest"); req.Add("RenderMaterials"); req.Add("RequestTextureDownload"); req.Add("ResourceCostSelected"); req.Add("RetrieveNavMeshSrc"); req.Add("SearchStatRequest"); req.Add("SearchStatTracking"); req.Add("SendPostcard"); req.Add("SendUserReport"); req.Add("SendUserReportWithScreenshot"); req.Add("ServerReleaseNotes"); req.Add("SetDisplayName"); req.Add("SimConsoleAsync"); req.Add("SimulatorFeatures"); req.Add("StartGroupProposal"); req.Add("TerrainNavMeshProperties"); req.Add("TextureStats"); req.Add("UntrustedSimulatorMessage"); req.Add("UpdateAgentInformation"); req.Add("UpdateAgentLanguage"); req.Add("UpdateAvatarAppearance"); req.Add("UpdateGestureAgentInventory"); req.Add("UpdateGestureTaskInventory"); req.Add("UpdateNotecardAgentInventory"); req.Add("UpdateNotecardTaskInventory"); req.Add("UpdateScriptAgent"); req.Add("UpdateScriptTask"); req.Add("UploadBakedTexture"); req.Add("ViewerMetrics"); req.Add("ViewerStartAuction"); req.Add("ViewerStats"); // AIS3 req.Add("InventoryAPIv3"); req.Add("LibraryAPIv3"); _SeedRequest = new CapsClient(new Uri(_SeedCapsURI)); _SeedRequest.OnComplete += new CapsClient.CompleteCallback(SeedRequestCompleteHandler); _SeedRequest.BeginGetResponse(req, OSDFormat.Xml, Simulator.Client.Settings.CAPS_TIMEOUT); }
public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, string myversion, List <UUID> featuresAvailable, out string version, out string reason) { reason = "Failed to contact destination"; version = "Unknown"; // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position); IPEndPoint ext = destination.ExternalEndPoint; if (ext == null) { return(false); } // Eventually, we want to use a caps url instead of the agentID string uri = destination.ServerURI + AgentPath() + agentID + "/" + destination.RegionID.ToString() + "/"; OSDMap request = new OSDMap(); request.Add("viaTeleport", OSD.FromBoolean(viaTeleport)); request.Add("position", OSD.FromString(position.ToString())); request.Add("my_version", OSD.FromString(myversion)); OSDArray features = new OSDArray(); foreach (UUID feature in featuresAvailable) { features.Add(OSD.FromString(feature.ToString())); } request.Add("features", features); if (agentHomeURI != null) { request.Add("agent_home_uri", OSD.FromString(agentHomeURI)); } try { OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false, false); bool success = result["success"].AsBoolean(); if (result.ContainsKey("_Result")) { OSDMap data = (OSDMap)result["_Result"]; // FIXME: If there is a _Result map then it's the success key here that indicates the true success // or failure, not the sibling result node. success = data["success"]; reason = data["reason"].AsString(); if (data["version"] != null && data["version"].AsString() != string.Empty) { version = data["version"].AsString(); } m_log.DebugFormat( "[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}, reason {2}, version {3} ({4})", uri, success, reason, version, data["version"].AsString()); } if (!success) { // If we don't check this then OpenSimulator 0.7.3.1 and some period before will never see the // actual failure message if (!result.ContainsKey("_Result")) { if (result.ContainsKey("Message")) { string message = result["Message"].AsString(); if (message == "Service request failed: [MethodNotAllowed] MethodNotAllowed") // Old style region { m_log.Info("[REMOTE SIMULATION CONNECTOR]: The above web util error was caused by a TP to a sim that doesn't support QUERYACCESS and can be ignored"); return(true); } reason = result["Message"]; } else { reason = "Communications failure"; } } return(false); } featuresAvailable.Clear(); if (result.ContainsKey("features")) { OSDArray array = (OSDArray)result["features"]; foreach (OSD o in array) { featuresAvailable.Add(new UUID(o.AsString())); } } return(success); } catch (Exception e) { m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] QueryAcesss failed with exception; {0}", e.ToString()); } return(false); }
public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request) { // m_log.DebugFormat("[EVENT QUEUE GET MODULE]: Invoked GetEvents() for {0}", pAgentId); Queue <OSD> queue = TryGetQueue(pAgentId); OSD element; lock (queue) { if (queue.Count == 0) { return(NoEvents(requestID, pAgentId)); } element = queue.Dequeue(); // 15s timeout } int thisID = 0; lock (m_ids) thisID = m_ids[pAgentId]; OSDArray array = new OSDArray(); if (element == null) // didn't have an event in 15s { // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say! array.Add(EventQueueHelper.KeepAliveEvent()); //m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", pAgentId, m_scene.RegionInfo.RegionName); } else { if (DebugLevel > 0 && element is OSDMap) { OSDMap ev = (OSDMap)element; m_log.DebugFormat( "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", ev["message"], m_scene.GetScenePresence(pAgentId).Name); } array.Add(element); lock (queue) { while (queue.Count > 0) { element = queue.Dequeue(); if (DebugLevel > 0 && element is OSDMap) { OSDMap ev = (OSDMap)element; m_log.DebugFormat( "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", ev["message"], m_scene.GetScenePresence(pAgentId).Name); } array.Add(element); thisID++; } } } OSDMap events = new OSDMap(); events.Add("events", array); events.Add("id", new OSDInteger(thisID)); lock (m_ids) { m_ids[pAgentId] = thisID + 1; } Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 200; responsedata["content_type"] = "application/xml"; responsedata["keepalive"] = false; responsedata["reusecontext"] = false; responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events); //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", pAgentId, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); return(responsedata); }
public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request) { OSDMap events = new OSDMap(); try { OSD element; lock (queue) { if (queue.Count == 0) { return(NoEvents(requestID, pAgentId)); } element = queue.Dequeue(); // 15s timeout } OSDArray array = new OSDArray(); if (element == null) // didn't have an event in 15s { //return NoEvents(requestID, pAgentId); // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say! OSDMap keepAliveEvent = new OSDMap(2); keepAliveEvent.Add("body", new OSDMap()); keepAliveEvent.Add("message", new OSDString("FAKEEVENT")); element = keepAliveEvent; array.Add(keepAliveEvent); //m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", pAgentId, m_scene.RegionInfo.RegionName); } array.Add(element); lock (queue) { while (queue.Count > 0) { array.Add(queue.Dequeue()); m_ids++; } } //Look for disable Simulator EQMs so that we can disable ourselves safely foreach (OSD ev in array) { try { if (ev.Type == OSDType.Map) { OSDMap map = (OSDMap)ev; if (map.ContainsKey("message") && map["message"] == "DisableSimulator") { //This will be the last bunch of EQMs that go through, so we can safely die now m_service.ClientCaps.RemoveCAPS(m_service.RegionHandle); m_log.Warn("[EQService]: Disabling Simulator " + m_service.RegionHandle); } } } catch { } } events.Add("events", array); events.Add("id", new OSDInteger(m_ids)); m_ids++; } catch { } Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 200; responsedata["content_type"] = "application/xml"; responsedata["keepalive"] = false; responsedata["reusecontext"] = false; responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events); //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", pAgentId, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); return(responsedata); }
public Hashtable ProcessQueue(Hashtable request, UUID agentID) { // TODO: this has to be redone to not busy-wait (and block the thread), // TODO: as soon as we have a non-blocking way to handle HTTP-requests. // if (m_log.IsDebugEnabled) // { // String debug = "[EVENTQUEUE]: Got request for agent {0} in region {1} from thread {2}: [ "; // foreach (object key in request.Keys) // { // debug += key.ToString() + "=" + request[key].ToString() + " "; // } // m_log.DebugFormat(debug + " ]", agentID, m_scene.RegionInfo.RegionName, System.Threading.Thread.CurrentThread.Name); // } //m_log.Warn("Got EQM get at " + m_handler.CapsURL); OSD element = null; lock (queue) { if (queue.Count != 0) { element = queue.Dequeue(); // 15s timeout } } Hashtable responsedata = new Hashtable(); if (element == null) { //m_log.ErrorFormat("[EVENTQUEUE]: Nothing to process in " + m_scene.RegionInfo.RegionName); return(NoEvents(UUID.Zero, agentID)); } OSDArray array = new OSDArray(); array.Add(element); lock (queue) { while (queue.Count > 0) { OSD item = queue.Dequeue(); if (item != null) { array.Add(item); m_ids++; } } } //Look for disable Simulator EQMs so that we can disable ourselves safely foreach (OSD ev in array) { try { OSDMap map = (OSDMap)ev; if (map.ContainsKey("message") && map["message"] == "DisableSimulator") { //This will be the last bunch of EQMs that go through, so we can safely die now m_service.ClientCaps.RemoveCAPS(m_service.RegionHandle); } } catch { } } OSDMap events = new OSDMap(); events.Add("events", array); events.Add("id", new OSDInteger(m_ids)); m_ids++; responsedata["int_response_code"] = 200; responsedata["content_type"] = "application/xml"; responsedata["keepalive"] = false; responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events); //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); return(responsedata); }
/// <summary> /// /// </summary> /// <returns></returns> public OSD GetOSD() { OSDArray array = new OSDArray(); // If DefaultTexture is null, assume the whole TextureEntry is empty if (DefaultTexture == null) return array; // Otherwise, always add default texture array.Add(DefaultTexture.GetOSD(-1)); for (int i = 0; i < MAX_FACES; i++) { if (FaceTextures[i] != null) array.Add(FaceTextures[i].GetOSD(i)); } return array; }
public OSDArray GetUserImageAssets(UUID avatarId) { IDataReader reader = null; OSDArray data = new OSDArray(); string query = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = :Id"; // Get classified image assets try { using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) { cmd.CommandText = query; cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { while (reader.Read()) { data.Add(new OSDString((string)reader["snapshotuuid"].ToString())); } } } using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) { cmd.CommandText = query; cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (reader.Read()) { data.Add(new OSDString((string)reader["snapshotuuid"].ToString())); } } } query = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = :Id"; using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) { cmd.CommandText = query; cmd.Parameters.AddWithValue(":Id", avatarId.ToString()); using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (reader.Read()) { data.Add(new OSDString((string)reader["profileImage"].ToString())); data.Add(new OSDString((string)reader["profileFirstImage"].ToString())); } } } } catch (Exception e) { m_log.DebugFormat("[PROFILES_DATA]" + ": GetAvatarNotes exception {0}", e.Message); } return(data); }
private void BeginLogin() { LoginParams loginParams = CurrentContext.Value; // Generate a random ID to identify this login attempt loginParams.LoginID = UUID.Random(); CurrentContext = loginParams; #region Sanity Check loginParams if (loginParams.Options == null) loginParams.Options = new List<string>().ToArray(); // Convert the password to MD5 if it isn't already if (loginParams.Password.Length != 35 && !loginParams.Password.StartsWith("$1$")) loginParams.Password = Utils.MD5(loginParams.Password); if (loginParams.ViewerDigest == null) loginParams.ViewerDigest = String.Empty; if (loginParams.Version == null) loginParams.Version = String.Empty; if (loginParams.UserAgent == null) loginParams.UserAgent = String.Empty; if (loginParams.Platform == null) loginParams.Platform = String.Empty; if (loginParams.MAC == null) loginParams.MAC = String.Empty; if (loginParams.Channel == null) loginParams.Channel = String.Empty; if (loginParams.Author == null) loginParams.Author = String.Empty; #endregion // TODO: Allow a user callback to be defined for handling the cert ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy(); // Even though this will compile on Mono 2.4, it throws a runtime exception //ServicePointManager.ServerCertificateValidationCallback = TrustAllCertificatePolicy.TrustAllCertificateHandler; if (Client.Settings.USE_LLSD_LOGIN) { #region LLSD Based Login // Create the CAPS login structure OSDMap loginLLSD = new OSDMap(); loginLLSD["first"] = OSD.FromString(loginParams.FirstName); loginLLSD["last"] = OSD.FromString(loginParams.LastName); loginLLSD["passwd"] = OSD.FromString(loginParams.Password); loginLLSD["start"] = OSD.FromString(loginParams.Start); loginLLSD["channel"] = OSD.FromString(loginParams.Channel); loginLLSD["version"] = OSD.FromString(loginParams.Version); loginLLSD["platform"] = OSD.FromString(loginParams.Platform); loginLLSD["mac"] = OSD.FromString(loginParams.MAC); loginLLSD["agree_to_tos"] = OSD.FromBoolean(loginParams.AgreeToTos); loginLLSD["read_critical"] = OSD.FromBoolean(loginParams.ReadCritical); loginLLSD["viewer_digest"] = OSD.FromString(loginParams.ViewerDigest); loginLLSD["id0"] = OSD.FromString(loginParams.ID0); // Create the options LLSD array OSDArray optionsOSD = new OSDArray(); for (int i = 0; i < loginParams.Options.Length; i++) optionsOSD.Add(OSD.FromString(loginParams.Options[i])); foreach (string[] callbackOpts in CallbackOptions.Values) { if (callbackOpts != null) { for (int i = 0; i < callbackOpts.Length; i++) { if (!optionsOSD.Contains(callbackOpts[i])) optionsOSD.Add(callbackOpts[i]); } } } loginLLSD["options"] = optionsOSD; // Make the CAPS POST for login Uri loginUri; try { loginUri = new Uri(loginParams.URI); } catch (Exception ex) { Logger.Log(String.Format("Failed to parse login URI {0}, {1}", loginParams.URI, ex.Message), Helpers.LogLevel.Error, Client); return; } CapsClient loginRequest = new CapsClient(loginUri); loginRequest.OnComplete += new CapsClient.CompleteCallback(LoginReplyLLSDHandler); loginRequest.UserData = CurrentContext; UpdateLoginStatus(LoginStatus.ConnectingToLogin, String.Format("Logging in as {0} {1}...", loginParams.FirstName, loginParams.LastName)); loginRequest.BeginGetResponse(loginLLSD, OSDFormat.Xml, Client.Settings.CAPS_TIMEOUT); #endregion } else { #region XML-RPC Based Login Code // Create the Hashtable for XmlRpcCs Hashtable loginXmlRpc = new Hashtable(); loginXmlRpc["first"] = loginParams.FirstName; loginXmlRpc["last"] = loginParams.LastName; loginXmlRpc["passwd"] = loginParams.Password; loginXmlRpc["start"] = loginParams.Start; loginXmlRpc["channel"] = loginParams.Channel; loginXmlRpc["version"] = loginParams.Version; loginXmlRpc["platform"] = loginParams.Platform; loginXmlRpc["mac"] = loginParams.MAC; if (loginParams.AgreeToTos) loginXmlRpc["agree_to_tos"] = "true"; if (loginParams.ReadCritical) loginXmlRpc["read_critical"] = "true"; loginXmlRpc["id0"] = loginParams.ID0; loginXmlRpc["last_exec_event"] = 0; // Create the options array ArrayList options = new ArrayList(); for (int i = 0; i < loginParams.Options.Length; i++) options.Add(loginParams.Options[i]); foreach (string[] callbackOpts in CallbackOptions.Values) { if (callbackOpts != null) { for (int i = 0; i < callbackOpts.Length; i++) { if (!options.Contains(callbackOpts[i])) options.Add(callbackOpts[i]); } } } loginXmlRpc["options"] = options; try { ArrayList loginArray = new ArrayList(1); loginArray.Add(loginXmlRpc); XmlRpcRequest request = new XmlRpcRequest(CurrentContext.Value.MethodName, loginArray); // Start the request Thread requestThread = new Thread( delegate() { try { LoginReplyXmlRpcHandler( request.Send(CurrentContext.Value.URI, CurrentContext.Value.Timeout), loginParams); } catch (WebException e) { UpdateLoginStatus(LoginStatus.Failed, "Error opening the login server connection: " + e.Message); } }); requestThread.Name = "XML-RPC Login"; requestThread.Start(); } catch (Exception e) { UpdateLoginStatus(LoginStatus.Failed, "Error opening the login server connection: " + e); } #endregion } }
public OSDArray GetUserImageAssets(UUID avatarId) { OSDArray data = new OSDArray(); string query = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id"; // Get classified image assets try { using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) { dbcon.Open(); using (MySqlCommand cmd = new MySqlCommand(string.Format(query, "`classifieds`"), dbcon)) { cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (reader.HasRows) { while (reader.Read()) { data.Add(new OSDString((string)reader["snapshotuuid"].ToString())); } } } } dbcon.Close(); dbcon.Open(); using (MySqlCommand cmd = new MySqlCommand(string.Format(query, "`userpicks`"), dbcon)) { cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (reader.HasRows) { while (reader.Read()) { data.Add(new OSDString((string)reader["snapshotuuid"].ToString())); } } } } dbcon.Close(); dbcon.Open(); query = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id"; using (MySqlCommand cmd = new MySqlCommand(string.Format(query, "`userpicks`"), dbcon)) { cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (reader.HasRows) { while (reader.Read()) { data.Add(new OSDString((string)reader["profileImage"].ToString())); data.Add(new OSDString((string)reader["profileFirstImage"].ToString())); } } } } } } catch (Exception e) { m_log.DebugFormat("[PROFILES_DATA]" + ": GetAvatarNotes exception {0}", e.Message); } return(data); }
public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { IGroupsModule groupService = m_scene.RequestModuleInterface <IGroupsModule>(); ScenePresence SP = m_scene.GetScenePresence(this.m_agentID); IClientAPI client = (SP == null) ? null : SP.ControllingClient; if ((groupService == null) || (client == null)) { return(new byte[0]); } try { // Get *this* user's friends list (should be fast). List <FriendListItem> friends = m_scene.CommsManager.UserService.GetUserFriendList(this.m_agentID); OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml(request); UUID groupID = rm["group_id"].AsUUID(); OSDMap defaults = new OSDMap(); defaults["default_powers"] = (ulong)Constants.DefaultEveryonePowers; OSDMap members = new OSDMap(); List <string> titleList = new List <string>(); int count = 0; foreach (GroupMembersData gmd in groupService.GroupMembersRequest(null, m_scene, m_agentID, groupID)) { OSDMap member = new OSDMap(); member["donated_square_meters"] = gmd.Contribution; member["last_login"] = FilterOnlineStatus(gmd.AgentID, gmd.OnlineStatus, gmd.LastLogout, friends); member["powers"] = gmd.AgentPowers; if (gmd.IsOwner) { member["owner"] = "Y"; // mere presence of this means IsOwner to the viewer. } int titleIndex; if (titleList.Contains(gmd.Title)) { titleIndex = titleList.IndexOf(gmd.Title); } else { titleIndex = titleList.Count; // before adding, 0-based titleList.Add(gmd.Title); } member["title"] = titleIndex.ToString(); count++; members[gmd.AgentID.ToString()] = member; } // Convert optimized list to OSDArray. OSDArray titles = new OSDArray(); foreach (string title in titleList) { titles.Add(title); } OSDMap map = new OSDMap(); map["member_count"] = count; map["group_id"] = groupID; map["defaults"] = defaults; map["titles"] = titles; map["members"] = members; return(OSDParser.SerializeLLSDXmlBytes(map)); } catch (Exception e) { MainConsole.Instance.Error("[CAPS]: " + e); } return(new byte[0]); }
private void UpdateGesture(UUID userID, UUID itemID, bool enabled) { OSDArray gestures = FetchGestures(userID); OSDArray newGestures = new OSDArray(); for (int i = 0; i < gestures.Count; i++) { UUID gesture = gestures[i].AsUUID(); if (gesture != itemID) newGestures.Add(OSD.FromUUID(gesture)); } if (enabled) newGestures.Add(OSD.FromUUID(itemID)); SaveGestures(userID, newGestures); }
/// <summary> /// Create an OSDMap from the appearance data /// </summary> public OSDMap Pack() { OSDMap data = new OSDMap(); data["serial"] = OSD.FromInteger(m_serial); data["height"] = OSD.FromReal(m_avatarHeight); // Wearables OSDArray wears = new OSDArray(AvatarWearable.MAX_WEARABLES); for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) wears.Add(m_wearables[i].Pack()); data["wearables"] = wears; // Avatar Textures OSDArray textures = new OSDArray(AvatarAppearance.TEXTURE_COUNT); for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++) { if (m_texture.FaceTextures[i] != null) textures.Add(OSD.FromUUID(m_texture.FaceTextures[i].TextureID)); else textures.Add(OSD.FromUUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE)); } data["textures"] = textures; // Visual Parameters OSDBinary visualparams = new OSDBinary(m_visualparams); data["visualparams"] = visualparams; // Attachments OSDArray attachs = new OSDArray(m_attachments.Count); foreach (AvatarAttachment attach in GetAttachments()) attachs.Add(attach.Pack()); data["attachments"] = attachs; return data; }
OSD AssetResources(bool upload) { OSDArray instanceList = new OSDArray(); List <byte[]> meshes = new List <byte[]>(); List <byte[]> textures = new List <byte[]>(); foreach (var prim in Prims) { OSDMap primMap = new OSDMap(); OSDArray faceList = new OSDArray(); foreach (var face in prim.Faces) { OSDMap faceMap = new OSDMap(); faceMap["diffuse_color"] = face.Material.DiffuseColor; faceMap["fullbright"] = false; if (face.Material.TextureData != null) { int index; if (ImgIndex.ContainsKey(face.Material.Texture)) { index = ImgIndex[face.Material.Texture]; } else { index = Images.Count; ImgIndex[face.Material.Texture] = index; Images.Add(face.Material.TextureData); } faceMap["image"] = index; faceMap["scales"] = 1.0f; faceMap["scalet"] = 1.0f; faceMap["offsets"] = 0.0f; faceMap["offsett"] = 0.0f; faceMap["imagerot"] = 0.0f; } else { faceMap["image"] = 10000; // Out of range value to get rid of default "0" which erroneously textures all non-textured faces if there is at least one texture. } faceList.Add(faceMap); } primMap["face_list"] = faceList; primMap["position"] = prim.Position; primMap["rotation"] = prim.Rotation; primMap["scale"] = prim.Scale; primMap["material"] = 3; // always sent as "wood" material primMap["physics_shape_type"] = 2; // always sent as "convex hull"; primMap["mesh"] = meshes.Count; meshes.Add(prim.Asset); instanceList.Add(primMap); } OSDMap resources = new OSDMap(); resources["instance_list"] = instanceList; OSDArray meshList = new OSDArray(); foreach (var mesh in meshes) { meshList.Add(OSD.FromBinary(mesh)); } resources["mesh_list"] = meshList; OSDArray textureList = new OSDArray(); for (int i = 0; i < Images.Count; i++) { if (upload) { textureList.Add(new OSDBinary(Images[i])); } else { textureList.Add(new OSDBinary(Utils.EmptyBytes)); } } resources["texture_list"] = textureList; resources["metric"] = "MUT_Unspecified"; return(resources); }