public bool Charge(UUID agentID, int amount, string text, int daysUntilNextCharge) { IMoneyModule moneyModule = m_registry.RequestModuleInterface<IMoneyModule>(); if (moneyModule != null) { bool success = moneyModule.Charge(agentID, amount, text); if (!success) return false; IScheduleService scheduler = m_registry.RequestModuleInterface<IScheduleService>(); if (scheduler != null) { OSDMap itemInfo = new OSDMap(); itemInfo.Add("AgentID", agentID); itemInfo.Add("Amount", amount); itemInfo.Add("Text", text); SchedulerItem item = new SchedulerItem("ScheduledPayment", OSDParser.SerializeJsonString(itemInfo), false, DateTime.Now.AddDays(daysUntilNextCharge) - DateTime.Now); itemInfo.Add("SchedulerID", item.id); scheduler.Save(item); } } return true; }
public bool Charge(UUID agentID, int amount, string text, int daysUntilNextCharge, TransactionType type, string identifer, bool chargeImmediately) { IMoneyModule moneyModule = m_registry.RequestModuleInterface<IMoneyModule>(); if (moneyModule != null) { if (chargeImmediately) { bool success = moneyModule.Charge(agentID, amount, text, type); if (!success) return false; } IScheduleService scheduler = m_registry.RequestModuleInterface<IScheduleService>(); if (scheduler != null) { OSDMap itemInfo = new OSDMap(); itemInfo.Add("AgentID", agentID); itemInfo.Add("Amount", amount); itemInfo.Add("Text", text); itemInfo.Add("Type", (int)type); SchedulerItem item = new SchedulerItem("ScheduledPayment " + identifer, OSDParser.SerializeJsonString(itemInfo), false, DateTime.UtcNow, daysUntilNextCharge, RepeatType.days, agentID); itemInfo.Add("SchedulerID", item.id); scheduler.Save(item); } } return true; }
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(); } }
protected override void UnpackData(OSDMap args, AgentDestinationData d, Hashtable request) { base.UnpackData(args, d, request); ExtendedAgentDestinationData data = (ExtendedAgentDestinationData)d; try { if (args.ContainsKey("gatekeeper_host") && args["gatekeeper_host"] != null) data.host = args["gatekeeper_host"].AsString(); if (args.ContainsKey("gatekeeper_port") && args["gatekeeper_port"] != null) Int32.TryParse(args["gatekeeper_port"].AsString(), out data.port); if (args.ContainsKey("gatekeeper_serveruri") && args["gatekeeper_serveruri"] != null) data.gatekeeperServerURI = args["gatekeeper_serveruri"]; if (args.ContainsKey("destination_serveruri") && args["destination_serveruri"] != null) data.destinationServerURI = args["destination_serveruri"]; } catch (InvalidCastException) { m_log.ErrorFormat("[HOME AGENT HANDLER]: Bad cast in UnpackData"); } string callerIP = GetCallerIP(request); // Verify if this call came from the login server if (callerIP == m_LoginServerIP) data.fromLogin = true; }
public override void FromOSD(OSDMap map) { AgentInfo = new IAgentInfo(); AgentInfo.FromOSD((OSDMap) (map["AgentInfo"])); UserAccount = new UserAccount(); UserAccount.FromOSD((OSDMap)(map["UserAccount"])); if (!map.ContainsKey("ActiveGroup")) ActiveGroup = null; else { ActiveGroup = new GroupMembershipData(); ActiveGroup.FromOSD((OSDMap)(map["ActiveGroup"])); } GroupMemberships = ((OSDArray) map["GroupMemberships"]).ConvertAll<GroupMembershipData>((o) => { GroupMembershipData group = new GroupMembershipData (); group .FromOSD ((OSDMap ) o); return group; }); OfflineMessages = ((OSDArray) map["OfflineMessages"]).ConvertAll<GridInstantMessage>((o) => { GridInstantMessage group = new GridInstantMessage (); group.FromOSD( (OSDMap) o); return group; }); MuteList = ((OSDArray) map["MuteList"]).ConvertAll<MuteList>((o) => { MuteList group = new MuteList(); group.FromOSD((OSDMap) o); return group; }); if (map.ContainsKey("Appearance")) { Appearance = new AvatarAppearance(); Appearance.FromOSD((OSDMap)map["Appearance"]); } if (map.ContainsKey("FriendOnlineStatuses")) FriendOnlineStatuses = ((OSDArray)map["FriendOnlineStatuses"]).ConvertAll<UUID>((o) => { return o; }); if (map.ContainsKey("Friends")) Friends = ((OSDArray)map["Friends"]).ConvertAll<FriendInfo>((o) => { FriendInfo f = new FriendInfo(); f.FromOSD((OSDMap)o); return f; }); }
/// <summary> /// Check to see if the client has baked textures that belong to banned clients /// </summary> /// <param name="client"></param> /// <param name="textureEntry"></param> public void CheckForBannedViewer(IClientAPI client, Primitive.TextureEntry textureEntry) { try { //Read the website once! if (m_map == null) m_map = (OSDMap)OSDParser.Deserialize(Utilities.ReadExternalWebsite("http://auroraserver.ath.cx:8080/client_tags.xml")); //This is the givaway texture! for (int i = 0; i < textureEntry.FaceTextures.Length; i++) { if (textureEntry.FaceTextures[i] != null) { if (m_map.ContainsKey(textureEntry.FaceTextures[i].TextureID.ToString())) { OSDMap viewerMap = (OSDMap)m_map[textureEntry.FaceTextures[i].TextureID.ToString()]; //Check the names if (BannedViewers.Contains(viewerMap["name"].ToString())) { client.Kick("You cannot use " + viewerMap["name"] + " in this sim."); ((Scene)client.Scene).IncomingCloseAgent(client.AgentId); } else if (m_banEvilViewersByDefault && viewerMap.ContainsKey("evil") && (viewerMap["evil"].AsBoolean() == true)) { client.Kick("You cannot use " + viewerMap["name"] + " in this sim."); ((Scene)client.Scene).IncomingCloseAgent(client.AgentId); } } } } } catch { } }
public void PostInternal(bool remote, string url, OSDMap request) { if (remote) DoRemoteCallPost(true, url + "/syncmessage/", false, url + "/syncmessage/", request); else m_registry.RequestModuleInterface<ISyncMessageRecievedService>().FireMessageReceived(request); }
public OSDMap GetExternalCaps(UUID agentID, GridRegion region) { if (m_registry == null) return new OSDMap(); OSDMap resp = new OSDMap(); if (m_registry.RequestModuleInterface<IGridServerInfoService>() != null) { m_servers = m_registry.RequestModuleInterface<IGridServerInfoService>().GetGridURIs("SyncMessageServerURI"); OSDMap req = new OSDMap(); req["AgentID"] = agentID; req["Region"] = region.ToOSD(); req["Method"] = "GetCaps"; List<ManualResetEvent> events = new List<ManualResetEvent>(); foreach (string uri in m_servers) { ManualResetEvent even = new ManualResetEvent(false); m_syncPoster.Get(uri, req, (r) => { if (r == null) return; foreach (KeyValuePair<string, OSD> kvp in r) resp.Add(kvp.Key, kvp.Value); even.Set(); }); events.Add(even); } ManualResetEvent.WaitAll(events.ToArray()); } foreach (var h in GetHandlers(agentID, region.RegionID)) { if (m_allowedCapsModules.Contains(h.Name)) h.IncomingCapsRequest(agentID, region, m_registry.RequestModuleInterface<ISimulationBase>(), ref resp); } return resp; }
byte [] SimulatorFeaturesCAP (string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { OSDMap data = new OSDMap (); // AvatarHoverHeight enabled data ["AvatarHoverHeightEnabled"] = true; // MaxMaterialsPerTransaction enabled data ["MaxMaterialsPerTransaction"] = 50; data ["MeshRezEnabled"] = true; data ["MeshUploadEnabled"] = true; data ["MeshXferEnabled"] = true; data ["PhysicsMaterialsEnabled"] = true; OSDMap typesMap = new OSDMap (); typesMap ["convex"] = true; typesMap ["none"] = true; typesMap ["prim"] = true; data ["PhysicsShapeTypes"] = typesMap; // some additional features data ["god_names"] = GodNames (httpRequest); //Send back data return OSDParser.SerializeLLSDXmlBytes (data); }
private byte[] SimulatorFeaturesCAP(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { OSDMap data = new OSDMap(); data["MeshRezEnabled"] = true; data["MeshUploadEnabled"] = true; data["MeshXferEnabled"] = true; data["PhysicsMaterialsEnabled"] = true; OSDMap typesMap = new OSDMap(); typesMap["convex"] = true; typesMap["none"] = true; typesMap["prim"] = true; data["PhysicsShapeTypes"] = typesMap; //Data URLS need sent as well //Not yet... //data["DataUrls"] = m_service.Registry.RequestModuleInterface<IGridRegistrationService> ().GetUrlForRegisteringClient (m_service.AgentID + "|" + m_service.RegionHandle); //Send back data return OSDParser.SerializeLLSDXmlBytes(data); }
public OSDMap Pack() { OSDMap args = new OSDMap(); args["message_type"] = OSD.FromString("AgentPosition"); args["region_handle"] = OSD.FromString(RegionHandle.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()); args["far"] = OSD.FromReal(Far); args["changed_grid"] = OSD.FromBoolean(ChangedGrid); if ((Throttles != null) && (Throttles.Length > 0)) args["throttles"] = OSD.FromBinary(Throttles); return args; }
public OSDMap GetInternal(bool remote, string url, OSDMap request) { try { LogMessage(remote, url, request); if (remote) { if (url != "") { url = (url.EndsWith("/syncmessage/", StringComparison.Ordinal) ? url : (url + "/syncmessage/")); return DoRemoteCallGet(true, url, false, url, request) as OSDMap; } else return DoRemoteCallGet(true, "SyncMessageServerURI", false, url, request) as OSDMap; } return m_registry.RequestModuleInterface<ISyncMessageRecievedService>().FireMessageReceived(request); } catch (Exception ex) { MainConsole.Instance.WarnFormat("[Sync Message Poster Service]: Caught exception when attempting to post to {0}: {1}", url, ex.ToString()); } return null; }
public List<Email> GetEmails(UUID objectID) { OSDMap map = new OSDMap(); map["ObjectID"] = objectID; map["Method"] = "getemails"; List<Email> Messages = new List<Email>(); try { List<string> urls = m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf("RemoteServerURI"); foreach (string url in urls) { OSDMap result = WebUtils.PostToService(url + "osd", map, true, false); OSDArray array = (OSDArray) OSDParser.DeserializeJson(result["_RawResult"]); foreach (OSD o in array) { Email message = new Email(); message.FromOSD((OSDMap) o); Messages.Add(message); } } return Messages; } catch (Exception e) { MainConsole.Instance.DebugFormat("[AuroraRemoteEmailConnector]: Exception when contacting server: {0}", e); } return Messages; }
public byte[] AgentExperiences (string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { MainConsole.Instance.DebugFormat("[AgentExperiences] Call = {0}", httpRequest); var agentExp = new OSDMap(); return OSDParser.SerializeLLSDXmlBytes (agentExp); }
public VoiceConsole(RadegastInstance instance) { InitializeComponent(); Disposed += new EventHandler(VoiceConsole_Disposed); this.instance = instance; // Callbacks netcom.ClientLoginStatus += new EventHandler<LoginProgressEventArgs>(netcom_ClientLoginStatus); this.instance.MainForm.Load += new EventHandler(MainForm_Load); config = instance.GlobalSettings["voice"] as OSDMap; if (config == null) { config = new OSDMap(); config["enabled"] = new OSDBoolean(false); instance.GlobalSettings["voice"] = config; instance.GlobalSettings.Save(); } chkVoiceEnable.Checked = config["enabled"].AsBoolean(); if (chkVoiceEnable.Checked) Start(); }
public override OSDMap ToOSD() { OSDMap retVal = new OSDMap(); retVal["URLS"] = URLS; retVal["SessionID"] = SessionID; return retVal; }
public virtual void AddNewUrls(string key, OSDMap urls) { m_autoConfig.Remove("ServerURI"); foreach (KeyValuePair<string, OSD> kvp in urls) { if (kvp.Value == "" && kvp.Value.Type != OSDType.Array) continue; if (!m_autoConfig.ContainsKey(kvp.Key)) { if (kvp.Value.Type == OSDType.String) m_autoConfig[kvp.Key] = kvp.Value; else if (kvp.Value.Type != OSDType.Boolean) // "Success" coming from IWC m_autoConfig[kvp.Key] = string.Join(",", ((OSDArray)kvp.Value).ConvertAll<string>((osd) => osd).ToArray()); } else { List<string> keys = kvp.Value.Type == OSDType.Array ? ((OSDArray)kvp.Value).ConvertAll<string>((osd) => osd) : new List<string>(new string[1] { kvp.Value.AsString() }); foreach (string url in keys) { //Check to see whether the base URLs are the same (removes the UUID at the end) if (url.Length < 36) continue; //Not a URL string u = url.Remove(url.Length - 36, 36); if (!m_autoConfig[kvp.Key].AsString().Contains(u)) m_autoConfig[kvp.Key] = m_autoConfig[kvp.Key] + "," + kvp.Value; } } } m_allConfigs[key] = urls; }
public IUserProfileInfo GetUserProfile (UUID PrincipalID) { try { List<string> serverURIs = m_registry.RequestModuleInterface<IConfigurationService> ().FindValueOf (PrincipalID.ToString (), "RemoteServerURI"); foreach (string url in serverURIs) { OSDMap map = new OSDMap(); map["Method"] = "getprofile"; map["PrincipalID"] = PrincipalID; OSDMap response = WebUtils.PostToService (url + "osd", map, true, true); if (response["_Result"].Type == OSDType.Map) { OSDMap responsemap = (OSDMap)response["_Result"]; if (responsemap.Count == 0) continue; IUserProfileInfo info = new IUserProfileInfo (); info.FromOSD (responsemap); return info; } } } catch (Exception e) { m_log.DebugFormat ("[AuroraRemoteProfileConnector]: Exception when contacting server: {0}", e.ToString ()); } return null; }
/// <summary> /// POST URL-encoded form data to a web service that returns LLSD or /// JSON data /// </summary> public static string PostToService (string url, OSDMap data) { byte [] buffer = data != null ? Encoding.UTF8.GetBytes (OSDParser.SerializeJsonString (data, true)) : null; Task<byte []> t = ServiceOSDRequest (url, buffer, "POST", m_defaultTimeout); t.Wait (); return t.Result == null ? null : Encoding.UTF8.GetString (t.Result); }
public override OSDMap ToOSD () { OSDMap map = new OSDMap (); map ["eventID"] = eventID; map ["creator"] = creator; map ["name"] = name; map ["category"] = category; map ["description"] = description; map ["date"] = date; map ["dateUTC"] = dateUTC; map ["duration"] = duration; map ["cover"] = cover; map ["amount"] = amount; map ["simName"] = simName; //map["globalPos"] = globalPos; map ["GPosX"] = OSD.FromReal (globalPos.X).ToString (); map ["GPosY"] = OSD.FromReal (globalPos.Y).ToString (); map ["GPosZ"] = OSD.FromReal (globalPos.Z).ToString (); //map["regionPos"] = regionPos; map ["RPosX"] = OSD.FromReal (regionPos.X).ToString (); map ["RPosY"] = OSD.FromReal (regionPos.Y).ToString (); map ["RPosZ"] = OSD.FromReal (regionPos.Z).ToString (); map ["eventFlags"] = eventFlags; map ["maturity"] = maturity; map ["regionId"] = regionId; map ["parcelId"] = parcelId; return map; }
private Hashtable SimulatorFeaturesCAP(Hashtable mDhttpMethod) { OSDMap data = new OSDMap(); data["MeshRezEnabled"] = true; data["MeshUploadEnabled"] = true; data["MeshXferEnabled"] = true; data["PhysicsMaterialsEnabled"] = true; OSDMap typesMap = new OSDMap(); typesMap["convex"] = true; typesMap["none"] = true; typesMap["prim"] = true; data["PhysicsShapeTypes"] = typesMap; //Data URLS need sent as well //Not yet... //data["DataUrls"] = m_service.Registry.RequestModuleInterface<IGridRegistrationService> ().GetUrlForRegisteringClient (m_service.AgentID + "|" + m_service.RegionHandle); //Send back data Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 200; //501; //410; //404; responsedata["content_type"] = "text/plain"; responsedata["keepalive"] = false; responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(data); return responsedata; }
public UserInfo GetUserInfo(string userID) { List<string> urls = m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf(userID, "AgentInfoServerURI"); foreach (string url in urls) { try { OSDMap request = new OSDMap(); request["userID"] = userID; request["Method"] = "GetUserInfo"; OSDMap result = WebUtils.PostToService(url, request, true, false); OSD r = OSDParser.DeserializeJson(result["_RawResult"]); if (r is OSDMap) { OSDMap innerresult = (OSDMap) r; UserInfo info = new UserInfo(); if (innerresult["Result"].AsString() == "null") return null; info.FromOSD((OSDMap) innerresult["Result"]); return info; } } catch (Exception) { } } return null; }
public static bool AddGeneric(UUID ownerID, string type, string key, OSDMap map, string m_ServerURI) { string value = OSDParser.SerializeJsonString(map); NameValueCollection RequestArgs = new NameValueCollection { { "RequestMethod", "AddGeneric" }, { "OwnerID", ownerID.ToString() }, { "Type", type }, { "Key", key }, { "Value", value} }; OSDMap Response = CachedPostRequest(RequestArgs, m_ServerURI); if (Response["Success"].AsBoolean()) { return true; } else { //m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error {0}, {1}, {2}, {3}", ownerID, type, key, Response["Message"]); return false; } }
public void Unpack(OSDMap args) { if (args["point"] != null) AttachPoint = args["point"].AsInteger(); ItemID = (args["item"] != null) ? args["item"].AsUUID() : UUID.Zero; AssetID = (args["asset"] != null) ? args["asset"].AsUUID() : UUID.Zero; }
public OSDMap FireMessageReceived(string SessionID, OSDMap message) { OSDMap result = null; ulong reg; if (ulong.TryParse(SessionID, out reg)) //Local region { if (OnMessageReceived != null) { MessageReceived eventCopy = OnMessageReceived; foreach (OSDMap r in from MessageReceived messagedelegate in eventCopy.GetInvocationList() select messagedelegate(message) into r where r != null select r) { result = r; } } } else //IWC { /*string[] session = SessionID.Split('|'); ISyncMessagePosterService smps = m_registry.RequestModuleInterface<ISyncMessagePosterService>(); //Forward it on result = smps.Get(message, UUID.Parse(session[0]), ulong.Parse(session[1]));*/ } return result; }
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); 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()); args["client_version"] = OSD.FromString(ClientVersion); if (GroupPowers != null) { using (var ostream = new MemoryStream()) { Serializer.Serialize(ostream, GroupPowers); args["group_powers"] = OSD.FromBinary(ostream.ToArray()); } } return args; }
/// <summary> /// Post a new message to the given region by region handle /// </summary> /// <param name="RegionHandle"></param> /// <param name="request"></param> public void Post(ulong RegionHandle, OSDMap request) { if (!m_regionMessages.ContainsKey(RegionHandle)) m_regionMessages.Add(RegionHandle, new List<OSDMap>()); m_regionMessages[RegionHandle].Add(request); }
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; }
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; }
public AvatarAppearance(UUID avatarID, OSDMap map) { // MainConsole.Instance.WarnFormat("[AVATAR APPEARANCE]: create appearance for {0} from OSDMap",avatarID); m_owner = avatarID; Unpack(map); }
public byte[] RenderMaterialsPostCap(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { MainConsole.Instance.Debug("[MaterialsDemoModule]: POST cap handler"); 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); AssetBase materialAsset = null; if (m_knownMaterials.ContainsKey(id)) { MainConsole.Instance.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString()); OSDMap matMap = new OSDMap(); matMap["ID"] = elem.AsBinary(); matMap["Material"] = m_knownMaterials[id]; respArr.Add(matMap); } else if ((materialAsset = m_scene.AssetService.Get(id.ToString())) != null) { MainConsole.Instance.Info("[MaterialsDemoModule]: request for stored material ID: " + id.ToString()); OSDMap matMap = new OSDMap(); matMap["ID"] = elem.AsBinary(); matMap["Material"] = (OSDMap)OSDParser.DeserializeJson( Encoding.UTF8.GetString(materialAsset.Data)); respArr.Add(matMap); } else { MainConsole.Instance.Info("[MaterialsDemoModule]: request for UNKNOWN material ID: " + id.ToString()); } } catch (Exception) { // report something here? 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) { MainConsole.Instance.Debug("[MaterialsDemoModule]: processing matsMap: " + OSDParser.SerializeJsonString(matsMap)); uint matLocalID = 0; try { matLocalID = matsMap["ID"].AsUInteger(); } catch (Exception e) { MainConsole.Instance.Warn("[MaterialsDemoModule]: cannot decode \"ID\" from matsMap: " + e.Message); } MainConsole.Instance.Debug("[MaterialsDemoModule]: matLocalId: " + matLocalID.ToString()); OSDMap mat = null; try { mat = matsMap["Material"] as OSDMap; } catch (Exception e) { MainConsole.Instance.Warn("[MaterialsDemoModule]: cannot decode \"Material\" from matsMap: " + e.Message); } MainConsole.Instance.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat)); UUID id = HashOsd(mat); m_knownMaterials[id] = mat; var sop = m_scene.GetSceneObjectPart(matLocalID); if (sop == null) { MainConsole.Instance.Debug("[MaterialsDemoModule]: null SOP for localId: " + matLocalID.ToString()); } else { //var te = sop.Shape.Textures; var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); if (te == null) { MainConsole.Instance.Debug("[MaterialsDemoModule]: null TextureEntry for localId: " + matLocalID.ToString()); } else { int face = -1; if (matsMap.ContainsKey("Face")) { face = matsMap["Face"].AsInteger(); if (te.FaceTextures == null) // && face == 0) { if (te.DefaultTexture == null) { MainConsole.Instance.Debug("[MaterialsDemoModule]: te.DefaultTexture is null"); } else { if (te.DefaultTexture.MaterialID == null) { MainConsole.Instance.Debug("[MaterialsDemoModule]: te.DefaultTexture.MaterialID is null"); } else { te.DefaultTexture.MaterialID = id; } } } else { if (te.FaceTextures.Length >= face - 1) { if (te.FaceTextures[face] == null) { te.DefaultTexture.MaterialID = id; } else { te.FaceTextures[face].MaterialID = id; } } } } else { if (te.DefaultTexture != null) { te.DefaultTexture.MaterialID = id; } } MainConsole.Instance.Debug("[MaterialsDemoModule]: setting material ID for face " + face.ToString() + " to " + id.ToString()); //we cant use sop.UpdateTextureEntry(te); because it filters so do it manually if (sop.ParentEntity != null) { sop.Shape.TextureEntry = te.GetBytes(); sop.TriggerScriptChangedEvent(Changed.TEXTURE); sop.ParentEntity.HasGroupChanged = true; sop.ScheduleUpdate(PrimUpdateFlags.FullUpdate); AssetBase asset = new AssetBase(id, "RenderMaterial", AssetType.Texture, sop.OwnerID) { Data = Encoding.UTF8.GetBytes( OSDParser.SerializeJsonString(mat)) }; m_scene.AssetService.Store(asset); StoreMaterialsForPart(sop); } } } } } catch (Exception e) { MainConsole.Instance.Warn("[MaterialsDemoModule]: exception processing received material: " + e.ToString()); } } } } } } catch (Exception e) { MainConsole.Instance.Warn("[MaterialsDemoModule]: exception decoding zipped CAP payload: " + e.ToString()); //return ""; } MainConsole.Instance.Debug("[MaterialsDemoModule]: knownMaterials.Count: " + m_knownMaterials.Count.ToString()); } resp["Zipped"] = ZCompressOSD(respArr, false); string response = OSDParser.SerializeLLSDXmlString(resp); //MainConsole.Instance.Debug("[MaterialsDemoModule]: cap request: " + request); MainConsole.Instance.Debug("[MaterialsDemoModule]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary())); MainConsole.Instance.Debug("[MaterialsDemoModule]: cap response: " + response); return(OSDParser.SerializeLLSDBinary(resp)); }
/// <summary> /// Get the user's display name, currently not used? /// </summary> /// <param name="path"></param> /// <param name="request"></param> /// <param name="httpRequest"></param> /// <param name="httpResponse"></param> /// <returns></returns> private byte[] ProcessGetDisplayName(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { //I've never seen this come in, so for now... do nothing NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); string[] ids = query.GetValues("ids"); string username = query.GetOne("username"); OSDMap map = new OSDMap(); OSDArray agents = new OSDArray(); OSDArray bad_ids = new OSDArray(); OSDArray bad_usernames = new OSDArray(); if (ids != null) { foreach (string id in ids) { UserAccount account = m_userService.GetUserAccount(m_service.ClientCaps.AccountInfo.AllScopeIDs, UUID.Parse(id)); if (account != null) { IUserProfileInfo info = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>() .GetUserProfile(account.PrincipalID); if (info != null) { PackUserInfo(info, account, ref agents); } else { PackUserInfo(info, account, ref agents); } //else //Technically is right, but needs to be packed no matter what for OS based grids // bad_ids.Add (id); } } } else if (username != null) { UserAccount account = m_userService.GetUserAccount(m_service.ClientCaps.AccountInfo.AllScopeIDs, username.Replace('.', ' ')); if (account != null) { IUserProfileInfo info = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>() .GetUserProfile(account.PrincipalID); if (info != null) { PackUserInfo(info, account, ref agents); } else { bad_usernames.Add(username); } } } map["agents"] = agents; map["bad_ids"] = bad_ids; map["bad_usernames"] = bad_usernames; return(OSDParser.SerializeLLSDXmlBytes(map)); }
public void UnpackRegionInfoData(OSDMap args) { if (args.ContainsKey("region_id")) { RegionID = args["region_id"].AsUUID(); } if (args.ContainsKey("region_name")) { RegionName = args["region_name"].AsString(); } if (args.ContainsKey("external_host_name")) { ExternalHostName = args["external_host_name"].AsString(); } if (args.ContainsKey("http_port")) { UInt32.TryParse(args["http_port"].AsString(), out m_httpPort); } if (args.ContainsKey("region_xloc")) { uint locx; UInt32.TryParse(args["region_xloc"].AsString(), out locx); RegionLocX = locx; } if (args.ContainsKey("region_yloc")) { uint locy; UInt32.TryParse(args["region_yloc"].AsString(), out locy); RegionLocY = locy; } IPAddress ip_addr = null; if (args.ContainsKey("internal_ep_address")) { IPAddress.TryParse(args["internal_ep_address"].AsString(), out ip_addr); } int port = 0; if (args.ContainsKey("internal_ep_port")) { Int32.TryParse(args["internal_ep_port"].AsString(), out port); } InternalEndPoint = new IPEndPoint(ip_addr, port); if (args.ContainsKey("remoting_address")) { RemotingAddress = args["remoting_address"].AsString(); } if (args.ContainsKey("remoting_port")) { UInt32.TryParse(args["remoting_port"].AsString(), out m_remotingPort); } if (args.ContainsKey("allow_alt_ports")) { m_allow_alternate_ports = args["allow_alt_ports"].AsBoolean(); } if (args.ContainsKey("proxy_url")) { proxyUrl = args["proxy_url"].AsString(); } if (args.ContainsKey("outside_ip")) { OutsideIP = args["outside_ip"].AsString(); } }
public override void Unpack(OSDMap map) { base.Unpack(map); }
public override void FromOSD(OSDMap map) { this.ambient = new Vector4((float)map["ambientX"].AsReal(), (float)map["ambientY"].AsReal(), (float)map["ambientZ"].AsReal(), (float)map["ambientW"].AsReal()); this.bigWaveDirection = new Vector2((float)map["bigWaveDirectionX"].AsReal(), (float)map["bigWaveDirectionY"].AsReal()); this.blueDensity = new Vector4((float)map["blueDensityX"].AsReal(), (float)map["blueDensityY"].AsReal(), (float)map["blueDensityZ"].AsReal(), (float)map["blueDensityW"].AsReal()); this.blurMultiplier = (float)map["blurMultiplier"].AsReal(); this.cloudColor = new Vector4((float)map["cloudColorX"].AsReal(), (float)map["cloudColorY"].AsReal(), (float)map["cloudColorZ"].AsReal(), (float)map["cloudColorW"].AsReal()); this.cloudCoverage = (float)map["cloudCoverage"].AsReal(); this.cloudDetailXYDensity = new Vector3((float)map["cloudDetailXYDensityX"].AsReal(), (float)map["cloudDetailXYDensityY"].AsReal(), (float)map["cloudDetailXYDensityZ"].AsReal()); this.cloudScale = (float)map["cloudScale"].AsReal(); this.cloudScrollX = (float)map["cloudScrollX"].AsReal(); this.cloudScrollXLock = map["cloudScrollXLock"].AsBoolean(); this.cloudScrollY = (float)map["cloudScrollY"].AsReal(); this.cloudScrollYLock = map["cloudScrollYLock"].AsBoolean(); this.cloudXYDensity = new Vector3((float)map["cloudXYDensityX"].AsReal(), (float)map["cloudXYDensityY"].AsReal(), (float)map["cloudXYDensityZ"].AsReal()); this.densityMultiplier = (float)map["densityMultiplier"].AsReal(); this.distanceMultiplier = (float)map["distanceMultiplier"].AsReal(); this.drawClassicClouds = map["drawClassicClouds"].AsBoolean(); this.classicCloudHeight = (float)map["classicCloudHeight"].AsReal(); this.classicCloudRange = (float)map["classicCloudRange"].AsReal(); this.eastAngle = (float)map["eastAngle"].AsReal(); this.fresnelOffset = (float)map["fresnelOffset"].AsReal(); this.fresnelScale = (float)map["fresnelScale"].AsReal(); this.hazeDensity = (float)map["hazeDensity"].AsReal(); this.hazeHorizon = (float)map["hazeHorizon"].AsReal(); this.horizon = new Vector4((float)map["horizonX"].AsReal(), (float)map["horizonY"].AsReal(), (float)map["horizonZ"].AsReal(), (float)map["horizonW"].AsReal()); this.littleWaveDirection = new Vector2((float)map["littleWaveDirectionX"].AsReal(), (float)map["littleWaveDirectionY"].AsReal()); this.maxAltitude = (ushort)map["maxAltitude"].AsReal(); this.normalMapTexture = map["normalMapTexture"].AsUUID(); this.reflectionWaveletScale = new Vector3((float)map["reflectionWaveletScaleX"].AsReal(), (float)map["reflectionWaveletScaleY"].AsReal(), (float)map["reflectionWaveletScaleZ"].AsReal()); this.refractScaleAbove = (float)map["refractScaleAbove"].AsReal(); this.refractScaleBelow = (float)map["refractScaleBelow"].AsReal(); this.sceneGamma = (float)map["sceneGamma"].AsReal(); this.starBrightness = (float)map["starBrightness"].AsReal(); this.sunGlowFocus = (float)map["sunGlowFocus"].AsReal(); this.sunGlowSize = (float)map["sunGlowSize"].AsReal(); this.sunMoonColor = new Vector4((float)map["sunMoonColorX"].AsReal(), (float)map["sunMoonColorY"].AsReal(), (float)map["sunMoonColorZ"].AsReal(), (float)map["sunMoonColorW"].AsReal()); this.sunMoonPosition = (float)map["sunMoonPosition"].AsReal(); this.underwaterFogModifier = (float)map["underwaterFogModifier"].AsReal(); this.waterColor = new Vector4((float)map["waterColorX"].AsReal(), (float)map["waterColorY"].AsReal(), (float)map["waterColorZ"].AsReal(), (float)map["waterColorW"].AsReal()); this.waterFogDensityExponent = (float)map["waterFogDensityExponent"].AsReal(); this.fade = (float)map["fade"].AsReal(); if (map.ContainsKey("overrideParcels")) { this.overrideParcels = map["overrideParcels"].AsBoolean(); } if (map.ContainsKey("maxEffectiveAltitude")) { this.maxEffectiveAltitude = (float)map["maxEffectiveAltitude"].AsReal(); } if (map.ContainsKey("minEffectiveAltitude")) { this.minEffectiveAltitude = (float)map["minEffectiveAltitude"].AsReal(); } this.type = map["type"].AsInteger(); this.regionID = map["regionID"].AsUUID(); this.UUID = map["UUID"].AsUUID(); }
public void UnpackRegionInfoData(OSDMap args) { if (args.ContainsKey("region_id")) { RegionID = args["region_id"].AsUUID(); } if (args.ContainsKey("region_name")) { RegionName = args["region_name"].AsString(); } if (args.ContainsKey("http_port")) { UInt32.TryParse(args["http_port"].AsString(), out m_httpPort); } if (args.ContainsKey("region_xloc")) { int locx; Int32.TryParse(args["region_xloc"].AsString(), out locx); RegionLocX = locx; } if (args.ContainsKey("region_yloc")) { int locy; Int32.TryParse(args["region_yloc"].AsString(), out locy); RegionLocY = locy; } IPAddress ip_addr = null; if (args.ContainsKey("internal_ep_address")) { IPAddress.TryParse(args["internal_ep_address"].AsString(), out ip_addr); } int port = 0; if (args.ContainsKey("internal_ep_port")) { Int32.TryParse(args["internal_ep_port"].AsString(), out port); } InternalEndPoint = new IPEndPoint(ip_addr, port); if (args.ContainsKey("region_type")) { m_regionType = args["region_type"].AsString(); } if (args.ContainsKey("password")) { Password = args["password"].AsUUID(); } if (args.ContainsKey("disabled")) { Disabled = args["disabled"].AsBoolean(); } if (args.ContainsKey("scope_id")) { ScopeID = args["scope_id"].AsUUID(); } if (args.ContainsKey("region_size_x")) { RegionSizeX = args["region_size_x"].AsInteger(); } if (args.ContainsKey("region_size_y")) { RegionSizeY = args["region_size_y"].AsInteger(); } if (args.ContainsKey("region_size_z")) { RegionSizeZ = args["region_size_z"].AsInteger(); } if (args.ContainsKey("object_capacity")) { m_objectCapacity = args["object_capacity"].AsInteger(); } if (args.ContainsKey("region_type")) { RegionType = args["region_type"].AsString(); } if (args.ContainsKey("see_into_this_sim_from_neighbor")) { SeeIntoThisSimFromNeighbor = args["see_into_this_sim_from_neighbor"].AsBoolean(); } if (args.ContainsKey("trust_binaries_from_foreign_sims")) { TrustBinariesFromForeignSims = args["trust_binaries_from_foreign_sims"].AsBoolean(); } if (args.ContainsKey("allow_script_crossing")) { AllowScriptCrossing = args["allow_script_crossing"].AsBoolean(); } if (args.ContainsKey("allow_physical_prims")) { AllowPhysicalPrims = args["allow_physical_prims"].AsBoolean(); } if (args.ContainsKey("number_startup")) { NumberStartup = args["number_startup"].AsInteger(); } if (args.ContainsKey("startupType")) { Startup = (StartupType)args["startupType"].AsInteger(); } if (args.ContainsKey("InfiniteRegion")) { InfiniteRegion = args["InfiniteRegion"].AsBoolean(); } if (args.ContainsKey("RegionSettings")) { RegionSettings = new RegionSettings(); RegionSettings.FromOSD((OSDMap)args["RegionSettings"]); } if (args.ContainsKey("UDPPorts")) { OSDArray ports = (OSDArray)args["UDPPorts"]; foreach (OSD p in ports) { m_UDPPorts.Add(p.AsInteger()); } } if (!m_UDPPorts.Contains(InternalEndPoint.Port)) { m_UDPPorts.Add(InternalEndPoint.Port); } }
public byte[] ProcessQueue(OSHttpResponse response, 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 (MainConsole.Instance.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() + " "; // } // MainConsole.Instance.DebugFormat(debug + " ]", agentID, m_scene.RegionInfo.RegionName, System.Threading.Thread.CurrentThread.Name); // } //MainConsole.Instance.Warn("Got EQM get at " + m_handler.CapsURL); OSD element = null; lock (queue) { if (queue.Count != 0) { element = queue.Dequeue(); } } if (element == null) { //MainConsole.Instance.ErrorFormat("[EVENTQUEUE]: Nothing to process in " + m_scene.RegionInfo.RegionName); return(NoEvents(response)); } OSDArray array = new OSDArray { element }; lock (queue) { while (queue.Count > 0) { OSD item = queue.Dequeue(); if (item != null) { OSDMap map = (OSDMap)item; if (map.ContainsKey("message") && map["message"] == "DisableSimulator") { continue; } 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") { //Disabled above //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", array }, { "id", new OSDInteger(m_ids) } }; m_ids++; response.ContentType = "application/xml"; return(OSDParser.SerializeLLSDXmlBytes(events)); }
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(); } 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) { { "body", new OSDMap() }, { "message", new OSDString("FAKEEVENT") } }; element = keepAliveEvent; array.Add(keepAliveEvent); //MainConsole.Instance.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++; } } int removeAt = -1; //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") { MainConsole.Instance.Debug("[EQService]: Sim Request to Disable Simulator " + m_service.RegionHandle); removeAt = array.IndexOf(ev); //This will be the last bunch of EQMs that go through, so we can safely die now //Except that we can't do this, the client will freak if we do this //m_service.ClientCaps.RemoveCAPS(m_service.RegionHandle); } } } catch { } } if (removeAt != -1) { array.RemoveAt(removeAt); } events.Add("events", array); events.Add("id", new OSDInteger(m_ids)); m_ids++; } catch (Exception ex) { MainConsole.Instance.Warn("[EQS]: Exception! " + ex); } 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); //MainConsole.Instance.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", pAgentId, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); return(responsedata); }
private void InitializeConfig() { // Initilize grid dropdown int gridIx = -1; cbxGrid.Items.Clear(); for (int i = 0; i < instance.GridManger.Count; i++) { cbxGrid.Items.Add(instance.GridManger[i]); if (MainProgram.CommandLine.Grid == instance.GridManger[i].ID) { gridIx = i; } } cbxGrid.Items.Add("Custom"); if (gridIx != -1) { cbxGrid.SelectedIndex = gridIx; } Settings s = instance.GlobalSettings; cbRemember.Checked = s["remember_login"]; // Setup login name string savedUsername; if (string.IsNullOrEmpty(MainProgram.CommandLine.Username)) { savedUsername = s["username"]; } else { savedUsername = MainProgram.CommandLine.Username; } cbxUsername.Items.Add(savedUsername); try { if (s["saved_logins"] is OSDMap) { OSDMap savedLogins = (OSDMap)s["saved_logins"]; foreach (string loginKey in savedLogins.Keys) { SavedLogin sl = SavedLogin.FromOSD(savedLogins[loginKey]); cbxUsername.Items.Add(sl); } } } catch { cbxUsername.Items.Clear(); cbxUsername.Text = string.Empty; } cbxUsername.SelectedIndex = 0; // Fill in saved password or use one specified on the command line if (string.IsNullOrEmpty(MainProgram.CommandLine.Password)) { txtPassword.Text = s["password"].AsString(); } else { txtPassword.Text = MainProgram.CommandLine.Password; } // Setup login location either from the last used or // override from the command line if (string.IsNullOrEmpty(MainProgram.CommandLine.Location)) { // Use last location as default if (s["login_location_type"].Type == OSDType.Unknown) { cbxLocation.SelectedIndex = 1; s["login_location_type"] = OSD.FromInteger(1); } else { cbxLocation.SelectedIndex = s["login_location_type"].AsInteger(); cbxLocation.Text = s["login_location"].AsString(); } } else { switch (MainProgram.CommandLine.Location) { case "home": cbxLocation.SelectedIndex = 0; break; case "last": cbxLocation.SelectedIndex = 1; break; default: cbxLocation.SelectedIndex = -1; cbxLocation.Text = MainProgram.CommandLine.Location; break; } } // Set grid dropdown to last used, or override from command line if (string.IsNullOrEmpty(MainProgram.CommandLine.Grid)) { cbxGrid.SelectedIndex = s["login_grid"].AsInteger(); } else if (gridIx == -1) // --grid specified but not found { MessageBox.Show(string.Format("Grid specified with --grid {0} not found", MainProgram.CommandLine.Grid), "Grid not found", MessageBoxButtons.OK, MessageBoxIcon.Warning ); } // Restore login uri from settings, or command line if (string.IsNullOrEmpty(MainProgram.CommandLine.LoginUri)) { txtCustomLoginUri.Text = s["login_uri"].AsString(); } else { txtCustomLoginUri.Text = MainProgram.CommandLine.LoginUri; cbxGrid.SelectedIndex = cbxGrid.Items.Count - 1; } // Start logging in if autologin enabled from command line if (MainProgram.CommandLine.AutoLogin) { BeginLogin(); } }
public void LoadAvatarArchive(string FileName, string Name) { UserAccount account = UserAccountService.GetUserAccount(UUID.Zero, Name); m_log.Info("[AvatarArchive] Loading archive from " + FileName); if (account == null) { m_log.Error("[AvatarArchive] User not found!"); return; } StreamReader reader = new StreamReader(FileName); string file = reader.ReadToEnd(); reader.Close(); reader.Dispose(); IScenePresence SP; m_scene.TryGetScenePresence(account.PrincipalID, out SP); if (SP == null) { return; //Bad people! } SP.ControllingClient.SendAlertMessage("Appearance loading in progress..."); string FolderNameToLoadInto = ""; OSDMap map = ((OSDMap)OSDParser.DeserializeLLSDXml(file)); OSDMap assetsMap = ((OSDMap)map["Assets"]); OSDMap itemsMap = ((OSDMap)map["Items"]); OSDMap bodyMap = ((OSDMap)map["Body"]); AvatarAppearance appearance = ConvertXMLToAvatarAppearance(bodyMap, out FolderNameToLoadInto); appearance.Owner = account.PrincipalID; List <InventoryItemBase> items = new List <InventoryItemBase>(); InventoryFolderBase AppearanceFolder = InventoryService.GetFolderForType(account.PrincipalID, AssetType.Clothing); InventoryFolderBase folderForAppearance = new InventoryFolderBase( UUID.Random(), FolderNameToLoadInto, account.PrincipalID, -1, AppearanceFolder.ID, 1); InventoryService.AddFolder(folderForAppearance); folderForAppearance = InventoryService.GetFolder(folderForAppearance); try { LoadAssets(assetsMap); LoadItems(itemsMap, account.PrincipalID, folderForAppearance, out items); } catch (Exception ex) { m_log.Warn("[AvatarArchiver]: Error loading assets and items, " + ex.ToString()); } //Now update the client about the new items SP.ControllingClient.SendBulkUpdateInventory(folderForAppearance); foreach (InventoryItemBase itemCopy in items) { if (itemCopy == null) { SP.ControllingClient.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); continue; } if (!SP.IsChildAgent) { SP.ControllingClient.SendBulkUpdateInventory(itemCopy); } } m_log.Info("[AvatarArchive] Loaded archive from " + FileName); }
protected void HandleSaveAvatarArchive(string module, string[] cmdparams) { if (cmdparams.Length != 7) { m_log.Info("[AvatarArchive] Not enough parameters!"); } UserAccount account = UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3] + " " + cmdparams[4]); if (account == null) { m_log.Error("[AvatarArchive] User not found!"); return; } IScenePresence SP; m_scene.TryGetScenePresence(account.PrincipalID, out SP); if (SP == null) { return; //Bad people! } SP.ControllingClient.SendAlertMessage("Appearance saving in progress..."); AvatarAppearance appearance = AvatarService.GetAppearance(SP.UUID); if (appearance == null) { IAvatarAppearanceModule appearancemod = SP.RequestModuleInterface <IAvatarAppearanceModule> (); appearance = appearancemod.Appearance; } StreamWriter writer = new StreamWriter(cmdparams[5], false); OSDMap map = new OSDMap(); OSDMap body = new OSDMap(); OSDMap assets = new OSDMap(); OSDMap items = new OSDMap(); body = appearance.Pack(); body.Add("FolderName", OSD.FromString(cmdparams[6])); foreach (AvatarWearable wear in appearance.Wearables) { for (int i = 0; i < wear.Count; i++) { WearableItem w = wear[i]; if (w.AssetID != UUID.Zero) { SaveItem(w.ItemID, items, assets); SaveAsset(w.AssetID, assets); } } } List <AvatarAttachment> attachments = appearance.GetAttachments(); foreach (AvatarAttachment a in attachments) { if (a.AssetID != UUID.Zero) { SaveItem(a.ItemID, items, assets); SaveAsset(a.AssetID, assets); } } map.Add("Body", body); map.Add("Assets", assets); map.Add("Items", items); //Write the map writer.Write(OSDParser.SerializeLLSDXmlString(map)); writer.Close(); writer.Dispose(); m_log.Info("[AvatarArchive] Saved archive to " + cmdparams[5]); }
public bool DoHelloNeighbourCall(GridRegion region, RegionInfo thisRegion) { string uri = region.ServerURI + "region/" + thisRegion.RegionID + "/"; // m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); WebRequest helloNeighbourRequest; try { helloNeighbourRequest = WebRequest.Create(uri); } catch (Exception e) { m_log.Warn(string.Format( "[NEIGHBOUR SERVICES CONNECTOR]: Unable to parse uri {0} to send HelloNeighbour from {1} to {2}. Exception {3} ", uri, thisRegion.RegionName, region.RegionName, e.Message), e); return(false); } helloNeighbourRequest.Method = "POST"; helloNeighbourRequest.ContentType = "application/json"; helloNeighbourRequest.Timeout = 10000; // Fill it in OSDMap args = null; try { args = thisRegion.PackRegionInfoData(); } catch (Exception e) { m_log.Warn(string.Format( "[NEIGHBOUR SERVICES CONNECTOR]: PackRegionInfoData failed for HelloNeighbour from {0} to {1}. Exception {2} ", thisRegion.RegionName, region.RegionName, e.Message), e); return(false); } // Add the regionhandle of the destination region args["destination_handle"] = OSD.FromString(region.RegionHandle.ToString()); string strBuffer = ""; byte[] buffer = new byte[1]; try { strBuffer = OSDParser.SerializeJsonString(args); buffer = Util.UTF8NoBomEncoding.GetBytes(strBuffer); } catch (Exception e) { m_log.Warn(string.Format( "[NEIGHBOUR SERVICES CONNECTOR]: Exception thrown on serialization of HelloNeighbour from {0} to {1}. Exception {2} ", thisRegion.RegionName, region.RegionName, e.Message), e); return(false); } Stream os = null; try { // send the Post helloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send os = helloNeighbourRequest.GetRequestStream(); os.Write(buffer, 0, strBuffer.Length); //Send it //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); } catch (Exception e) { m_log.Warn(string.Format( "[NEIGHBOUR SERVICES CONNECTOR]: Unable to send HelloNeighbour from {0} to {1} (uri {2}). Exception {3} ", thisRegion.RegionName, region.RegionName, uri, e.Message), e); return(false); } finally { if (os != null) { os.Dispose(); } } // Let's wait for the response //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); try { using (WebResponse webResponse = helloNeighbourRequest.GetResponse()) { if (webResponse == null) { m_log.DebugFormat( "[NEIGHBOUR SERVICES CONNECTOR]: Null reply on DoHelloNeighbourCall post from {0} to {1}", thisRegion.RegionName, region.RegionName); } using (Stream s = webResponse.GetResponseStream()) { using (StreamReader sr = new StreamReader(s)) { //reply = sr.ReadToEnd().Trim(); sr.ReadToEnd().Trim(); //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); } } } } catch (Exception e) { m_log.Warn(string.Format( "[NEIGHBOUR SERVICES CONNECTOR]: Exception on reply of DoHelloNeighbourCall from {0} back to {1}. Exception {2} ", region.RegionName, thisRegion.RegionName, e.Message), e); return(false); } return(true); }
public override OSDMap ToOSD() { OSDMap map = new OSDMap { { "waterColorX", OSD.FromReal(this.waterColor.X) }, { "waterColorY", OSD.FromReal(this.waterColor.Y) }, { "waterColorZ", OSD.FromReal(this.waterColor.Z) }, { "waterColorW", OSD.FromReal(this.waterColor.W) }, { "waterFogDensityExponent", OSD.FromReal(this.waterFogDensityExponent) }, { "underwaterFogModifier", OSD.FromReal(this.underwaterFogModifier) }, { "reflectionWaveletScaleX", OSD.FromReal(this.reflectionWaveletScale.X) }, { "reflectionWaveletScaleY", OSD.FromReal(this.reflectionWaveletScale.Y) }, { "reflectionWaveletScaleZ", OSD.FromReal(this.reflectionWaveletScale.Z) }, { "fresnelScale", OSD.FromReal(this.fresnelScale) }, { "fresnelOffset", OSD.FromReal(this.fresnelOffset) }, { "refractScaleAbove", OSD.FromReal(this.refractScaleAbove) }, { "refractScaleBelow", OSD.FromReal(this.refractScaleBelow) }, { "blurMultiplier", OSD.FromReal(this.blurMultiplier) }, { "bigWaveDirectionX", OSD.FromReal(this.bigWaveDirection.X) }, { "bigWaveDirectionY", OSD.FromReal(this.bigWaveDirection.Y) }, { "littleWaveDirectionX", OSD.FromReal(this.littleWaveDirection.X) }, { "littleWaveDirectionY", OSD.FromReal(this.littleWaveDirection.Y) }, { "normalMapTexture", OSD.FromUUID(this.normalMapTexture) }, { "sunMoonColorX", OSD.FromReal(this.sunMoonColor.X) }, { "sunMoonColorY", OSD.FromReal(this.sunMoonColor.Y) }, { "sunMoonColorZ", OSD.FromReal(this.sunMoonColor.Z) }, { "sunMoonColorW", OSD.FromReal(this.sunMoonColor.W) }, { "ambientX", OSD.FromReal(this.ambient.X) }, { "ambientY", OSD.FromReal(this.ambient.Y) }, { "ambientZ", OSD.FromReal(this.ambient.Z) }, { "ambientW", OSD.FromReal(this.ambient.W) }, { "horizonX", OSD.FromReal(this.horizon.X) }, { "horizonY", OSD.FromReal(this.horizon.Y) }, { "horizonZ", OSD.FromReal(this.horizon.Z) }, { "horizonW", OSD.FromReal(this.horizon.W) }, { "blueDensityX", OSD.FromReal(this.blueDensity.X) }, { "blueDensityY", OSD.FromReal(this.blueDensity.Y) }, { "blueDensityZ", OSD.FromReal(this.blueDensity.Z) }, { "hazeHorizon", OSD.FromReal(this.hazeHorizon) }, { "hazeDensity", OSD.FromReal(this.hazeDensity) }, { "cloudCoverage", OSD.FromReal(this.cloudCoverage) }, { "densityMultiplier", OSD.FromReal(this.densityMultiplier) }, { "distanceMultiplier", OSD.FromReal(this.distanceMultiplier) }, { "maxAltitude", OSD.FromReal(this.maxAltitude) }, { "cloudColorX", OSD.FromReal(this.cloudColor.X) }, { "cloudColorY", OSD.FromReal(this.cloudColor.Y) }, { "cloudColorZ", OSD.FromReal(this.cloudColor.Z) }, { "cloudColorW", OSD.FromReal(this.cloudColor.W) }, { "cloudXYDensityX", OSD.FromReal(this.cloudXYDensity.X) }, { "cloudXYDensityY", OSD.FromReal(this.cloudXYDensity.Y) }, { "cloudXYDensityZ", OSD.FromReal(this.cloudXYDensity.Z) }, { "cloudDetailXYDensityX", OSD.FromReal(this.cloudDetailXYDensity.X) }, { "cloudDetailXYDensityY", OSD.FromReal(this.cloudDetailXYDensity.Y) }, { "cloudDetailXYDensityZ", OSD.FromReal(this.cloudDetailXYDensity.Z) }, { "starBrightness", OSD.FromReal(this.starBrightness) }, { "eastAngle", OSD.FromReal(this.eastAngle) }, { "sunMoonPosition", OSD.FromReal(this.sunMoonPosition) }, { "sunGlowFocus", OSD.FromReal(this.sunGlowFocus) }, { "sunGlowSize", OSD.FromReal(this.sunGlowSize) }, { "cloudScale", OSD.FromReal(this.cloudScale) }, { "sceneGamma", OSD.FromReal(this.sceneGamma) }, { "cloudScrollX", OSD.FromReal(this.cloudScrollX) }, { "cloudScrollY", OSD.FromReal(this.cloudScrollY) }, { "cloudScrollXLock", OSD.FromBoolean(this.cloudScrollXLock) }, { "cloudScrollYLock", OSD.FromBoolean(this.cloudScrollYLock) }, { "drawClassicClouds", OSD.FromBoolean(this.drawClassicClouds) }, { "classicCloudHeight", OSD.FromReal(this.classicCloudHeight) }, { "classicCloudRange", OSD.FromReal(this.classicCloudRange) }, { "fade", OSD.FromReal(this.fade) }, { "type", OSD.FromReal(this.type) }, { "overrideParcels", OSD.FromBoolean(this.overrideParcels) }, { "maxEffectiveAltitude", OSD.FromReal(this.maxEffectiveAltitude) }, { "minEffectiveAltitude", OSD.FromReal(this.minEffectiveAltitude) }, { "regionID", OSD.FromUUID(this.regionID) } }; if (this.UUID == UUID.Zero) { this.UUID = UUID.Random(); } map.Add("UUID", OSD.FromUUID(this.UUID)); return(map); }
public virtual OSDMap Pack() { 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()); args["changed_grid"] = OSD.FromBoolean(ChangedGrid); 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 ((Anims != null) && (Anims.Length > 0)) { OSDArray anims = new OSDArray(Anims.Length); foreach (Animation aanim in Anims) { anims.Add(aanim.PackUpdateMessage()); } args["animations"] = anims; } if ((AgentTextures != null) && (AgentTextures.Length > 0)) { args["texture_entry"] = OSD.FromBinary(AgentTextures); } if ((VisualParams != null) && (VisualParams.Length > 0)) { args["visual_params"] = OSD.FromBinary(VisualParams); } // We might not pass this in all cases... if ((Wearables != null) && (Wearables.Length > 0)) { OSDArray wears = new OSDArray(Wearables.Length); foreach (UUID uuid in Wearables) { wears.Add(OSD.FromUUID(uuid)); } args["wearables"] = wears; } if ((Attachments != null) && (Attachments.Length > 0)) { OSDArray attachs = new OSDArray(Attachments.Length); foreach (AttachmentData att in Attachments) { attachs.Add(att.PackUpdateMessage()); } args["attachments"] = attachs; } 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); } return(args); }
public AttachmentData(OSDMap args) { UnpackUpdateMessage(args); }
/// <summary> /// Deserialization of agent data. /// Avoiding reflection makes it painful to write, but that's the price! /// </summary> /// <param name="hash"></param> public virtual void Unpack(OSDMap args) { if (args.ContainsKey("region_id")) { UUID.TryParse(args["region_id"].AsString(), out RegionID); } if (args["circuit_code"] != null) { UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode); } if (args["agent_uuid"] != null) { AgentID = args["agent_uuid"].AsUUID(); } if (args["session_uuid"] != null) { SessionID = args["session_uuid"].AsUUID(); } if (args["position"] != null) { Vector3.TryParse(args["position"].AsString(), out Position); } if (args["velocity"] != null) { Vector3.TryParse(args["velocity"].AsString(), out Velocity); } if (args["center"] != null) { Vector3.TryParse(args["center"].AsString(), out Center); } if (args["size"] != null) { Vector3.TryParse(args["size"].AsString(), out Size); } if (args["at_axis"] != null) { Vector3.TryParse(args["at_axis"].AsString(), out AtAxis); } if (args["left_axis"] != null) { Vector3.TryParse(args["left_axis"].AsString(), out AtAxis); } if (args["up_axis"] != null) { Vector3.TryParse(args["up_axis"].AsString(), out AtAxis); } if (args["changed_grid"] != null) { ChangedGrid = args["changed_grid"].AsBoolean(); } if (args["far"] != null) { Far = (float)(args["far"].AsReal()); } if (args["aspect"] != null) { Aspect = (float)args["aspect"].AsReal(); } if (args["throttles"] != null) { Throttles = args["throttles"].AsBinary(); } if (args["locomotion_state"] != null) { UInt32.TryParse(args["locomotion_state"].AsString(), out LocomotionState); } if (args["head_rotation"] != null) { Quaternion.TryParse(args["head_rotation"].AsString(), out HeadRotation); } if (args["body_rotation"] != null) { Quaternion.TryParse(args["body_rotation"].AsString(), out BodyRotation); } if (args["control_flags"] != null) { UInt32.TryParse(args["control_flags"].AsString(), out ControlFlags); } if (args["energy_level"] != null) { EnergyLevel = (float)(args["energy_level"].AsReal()); } if (args["god_level"] != null) { Byte.TryParse(args["god_level"].AsString(), out GodLevel); } if (args["always_run"] != null) { AlwaysRun = args["always_run"].AsBoolean(); } if (args["prey_agent"] != null) { PreyAgent = args["prey_agent"].AsUUID(); } if (args["agent_access"] != null) { Byte.TryParse(args["agent_access"].AsString(), out AgentAccess); } if (args["active_group_id"] != null) { ActiveGroupID = args["active_group_id"].AsUUID(); } if ((args["groups"] != null) && (args["groups"]).Type == OSDType.Array) { OSDArray groups = (OSDArray)(args["groups"]); Groups = new AgentGroupData[groups.Count]; int i = 0; foreach (OSD o in groups) { if (o.Type == OSDType.Map) { Groups[i++] = new AgentGroupData((OSDMap)o); } } } if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array) { OSDArray anims = (OSDArray)(args["animations"]); Anims = new Animation[anims.Count]; int i = 0; foreach (OSD o in anims) { if (o.Type == OSDType.Map) { Anims[i++] = new Animation((OSDMap)o); } } } if (args["texture_entry"] != null) { AgentTextures = args["texture_entry"].AsBinary(); } if (args["visual_params"] != null) { VisualParams = args["visual_params"].AsBinary(); } if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array) { OSDArray wears = (OSDArray)(args["wearables"]); Wearables = new UUID[wears.Count]; int i = 0; foreach (OSD o in wears) { Wearables[i++] = o.AsUUID(); } } if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) { OSDArray attachs = (OSDArray)(args["attachments"]); Attachments = new AttachmentData[attachs.Count]; int i = 0; foreach (OSD o in attachs) { if (o.Type == OSDType.Map) { Attachments[i++] = new AttachmentData((OSDMap)o); } } } if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) { OSDArray controls = (OSDArray)(args["controllers"]); Controllers = new ControllerData[controls.Count]; int i = 0; foreach (OSD o in controls) { if (o.Type == OSDType.Map) { Controllers[i++] = new ControllerData((OSDMap)o); } } } if (args["callback_uri"] != null) { CallbackURI = args["callback_uri"].AsString(); } }
public void Unpack(OSDMap args) { if (args.ContainsKey("region_handle")) { UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); } if (args["circuit_code"] != null) { UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode); } if (args["agent_uuid"] != null) { AgentID = args["agent_uuid"].AsUUID(); } if (args["session_uuid"] != null) { SessionID = args["session_uuid"].AsUUID(); } if (args["position"] != null) { Vector3.TryParse(args["position"].AsString(), out Position); } if (args["velocity"] != null) { Vector3.TryParse(args["velocity"].AsString(), out Velocity); } if (args["center"] != null) { Vector3.TryParse(args["center"].AsString(), out Center); } if (args["size"] != null) { Vector3.TryParse(args["size"].AsString(), out Size); } if (args["at_axis"] != null) { Vector3.TryParse(args["at_axis"].AsString(), out AtAxis); } if (args["left_axis"] != null) { Vector3.TryParse(args["left_axis"].AsString(), out LeftAxis); } if (args["up_axis"] != null) { Vector3.TryParse(args["up_axis"].AsString(), out UpAxis); } if (args["changed_grid"] != null) { ChangedGrid = args["changed_grid"].AsBoolean(); } if (args["far"] != null) { Far = (float)(args["far"].AsReal()); } if (args["throttles"] != null) { Throttles = args["throttles"].AsBinary(); } }
public ControllerData(OSDMap args) { UnpackUpdateMessage(args); }
/// <summary> /// Animation from OSDMap from LLSD XML or LLSD json /// </summary> /// <param name="args"></param> public Animation(OSDMap args) { FromOSD(args); }
public AgentGroupData(OSDMap args) { UnpackUpdateMessage(args); }
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)); } 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"].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.ContainsKey("negotiated_inbound_version") && data["negotiated_inbound_version"] != null) { ctx.InboundVersion = (float)data["negotiated_inbound_version"].AsReal(); ctx.OutboundVersion = (float)data["negotiated_outbound_version"].AsReal(); } else if (data["version"] != null && data["version"].AsString() != string.Empty) { string versionString = data["version"].AsString(); String[] parts = versionString.Split(new char[] { '/' }); if (parts.Length > 1) { ctx.InboundVersion = float.Parse(parts[1]); ctx.OutboundVersion = float.Parse(parts[1]); } } 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 (!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())); } } // 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); }
/// <summary> /// Return a decoded capabilities message as a strongly typed object /// </summary> /// <param name="eventName">A string containing the name of the capabilities message key</param> /// <param name="map">An <see cref="OSDMap"/> to decode</param> /// <returns>A strongly typed object containing the decoded information from the capabilities message, or null /// if no existing Message object exists for the specified event</returns> public static IMessage DecodeEvent(string eventName, OSDMap map) { IMessage message = null; switch (eventName) { case "AgentGroupDataUpdate": message = new AgentGroupDataUpdateMessage(); break; case "AvatarGroupsReply": message = new AgentGroupDataUpdateMessage(); break; // OpenSim sends the above with the wrong? key case "ParcelProperties": message = new ParcelPropertiesMessage(); break; case "ParcelObjectOwnersReply": message = new ParcelObjectOwnersReplyMessage(); break; case "TeleportFinish": message = new TeleportFinishMessage(); break; case "EnableSimulator": message = new EnableSimulatorMessage(); break; case "ParcelPropertiesUpdate": message = new ParcelPropertiesUpdateMessage(); break; case "EstablishAgentCommunication": message = new EstablishAgentCommunicationMessage(); break; case "ChatterBoxInvitation": message = new ChatterBoxInvitationMessage(); break; case "ChatterBoxSessionEventReply": message = new ChatterboxSessionEventReplyMessage(); break; case "ChatterBoxSessionStartReply": message = new ChatterBoxSessionStartReplyMessage(); break; case "ChatterBoxSessionAgentListUpdates": message = new ChatterBoxSessionAgentListUpdatesMessage(); break; case "RequiredVoiceVersion": message = new RequiredVoiceVersionMessage(); break; case "MapLayer": message = new MapLayerMessage(); break; case "ChatSessionRequest": message = new ChatSessionRequestMessage(); break; case "CopyInventoryFromNotecard": message = new CopyInventoryFromNotecardMessage(); break; case "ProvisionVoiceAccountRequest": message = new ProvisionVoiceAccountRequestMessage(); break; case "Viewerstats": message = new ViewerStatsMessage(); break; case "UpdateAgentLanguage": message = new UpdateAgentLanguageMessage(); break; case "RemoteParcelRequest": message = new RemoteParcelRequestMessage(); break; case "UpdateScriptTask": message = new UpdateScriptTaskMessage(); break; case "UpdateScriptAgent": message = new UpdateScriptAgentMessage(); break; case "SendPostcard": message = new SendPostcardMessage(); break; case "UpdateGestureAgentInventory": message = new UpdateGestureAgentInventoryMessage(); break; case "UpdateNotecardAgentInventory": message = new UpdateNotecardAgentInventoryMessage(); break; case "LandStatReply": message = new LandStatReplyMessage(); break; case "ParcelVoiceInfoRequest": message = new ParcelVoiceInfoRequestMessage(); break; case "ViewerStats": message = new ViewerStatsMessage(); break; case "EventQueueGet": message = new EventQueueGetMessage(); break; case "CrossedRegion": message = new CrossedRegionMessage(); break; case "TeleportFailed": message = new TeleportFailedMessage(); break; case "PlacesReply": message = new PlacesReplyMessage(); break; case "UpdateAgentInformation": message = new UpdateAgentInformationMessage(); break; case "DirLandReply": message = new DirLandReplyMessage(); break; case "ScriptRunningReply": message = new ScriptRunningReplyMessage(); break; case "SearchStatRequest": message = new SearchStatRequestMessage(); break; case "AgentDropGroup": message = new AgentDropGroupMessage(); break; case "AgentStateUpdate": message = new AgentStateUpdateMessage(); break; case "ForceCloseChatterBoxSession": message = new ForceCloseChatterBoxSessionMessage(); break; case "UploadBakedTexture": message = new UploadBakedTextureMessage(); break; case "RegionInfo": message = new RegionInfoMessage(); break; case "ObjectMediaNavigate": message = new ObjectMediaNavigateMessage(); break; case "ObjectMedia": message = new ObjectMediaMessage(); break; case "AttachmentResources": message = AttachmentResourcesMessage.GetMessageHandler(map); break; case "LandResources": message = LandResourcesMessage.GetMessageHandler(map); break; case "GetDisplayNames": message = new GetDisplayNamesMessage(); break; case "SetDisplayName": message = new SetDisplayNameMessage(); break; case "SetDisplayNameReply": message = new SetDisplayNameReplyMessage(); break; case "DisplayNameUpdate": message = new DisplayNameUpdateMessage(); break; //case "ProductInfoRequest": message = new ProductInfoRequestMessage(); break; case "ObjectPhysicsProperties": message = new ObjectPhysicsPropertiesMessage(); break; case "BulkUpdateInventory": message = new BulkUpdateInventoryMessage(); break; case "RenderMaterials": message = new RenderMaterialsMessage(); break; // Capabilities TODO: // DispatchRegionInfo // EstateChangeInfo // EventQueueGet // FetchInventoryDescendents // GroupProposalBallot // MapLayerGod // NewFileAgentInventory // RequestTextureDownload // SearchStatRequest // SearchStatTracking // SendUserReport // SendUserReportWithScreenshot // ServerReleaseNotes // StartGroupProposal // UpdateGestureTaskInventory // UpdateNotecardTaskInventory // ViewerStartAuction // UntrustedSimulatorMessage } if (message != null) { try { message.Deserialize(map); return(message); } catch (Exception e) { Logger.Log("Exception while trying to Deserialize " + eventName + ":" + e.Message + ": " + e.StackTrace, Helpers.LogLevel.Error); } return(null); } else { return(null); } }
public void TestSerializeXml2() { TestHelpers.InMethod(); //log4net.Config.XmlConfigurator.Configure(); string rpName = "My Little Pony"; UUID rpUuid = UUID.Parse("00000000-0000-0000-0000-000000000064"); UUID rpCreatorId = UUID.Parse("00000000-0000-0000-0000-000000000015"); PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); // Vector3 groupPosition = new Vector3(10, 20, 30); // Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); // Vector3 offsetPosition = new Vector3(5, 10, 15); SceneObjectPart rp = new SceneObjectPart(); rp.UUID = rpUuid; rp.Name = rpName; rp.CreatorID = rpCreatorId; rp.Shape = shape; string daNamespace = "MyNamespace"; string daStoreName = "MyStore"; string daKey = "foo"; string daValue = "bar"; OSDMap myStore = new OSDMap(); myStore.Add(daKey, daValue); rp.DynAttrs = new DAMap(); rp.DynAttrs.SetStore(daNamespace, daStoreName, myStore); SceneObjectGroup so = new SceneObjectGroup(rp); // Need to add the object to the scene so that the request to get script state succeeds m_scene.AddSceneObject(so); Dictionary <string, object> options = new Dictionary <string, object>(); options["old-guids"] = true; string xml2 = m_serialiserModule.SerializeGroupToXml2(so, options); XmlTextReader xtr = new XmlTextReader(new StringReader(xml2)); xtr.ReadStartElement("SceneObjectGroup"); xtr.ReadStartElement("SceneObjectPart"); UUID uuid = UUID.Zero; string name = null; UUID creatorId = UUID.Zero; DAMap daMap = null; while (xtr.Read() && xtr.Name != "SceneObjectPart") { if (xtr.NodeType != XmlNodeType.Element) { continue; } switch (xtr.Name) { case "UUID": xtr.ReadStartElement("UUID"); uuid = UUID.Parse(xtr.ReadElementString("Guid")); xtr.ReadEndElement(); break; case "Name": name = xtr.ReadElementContentAsString(); break; case "CreatorID": xtr.ReadStartElement("CreatorID"); creatorId = UUID.Parse(xtr.ReadElementString("Guid")); xtr.ReadEndElement(); break; case "DynAttrs": daMap = new DAMap(); daMap.ReadXml(xtr); break; } } xtr.ReadEndElement(); xtr.ReadStartElement("OtherParts"); xtr.ReadEndElement(); xtr.Close(); // TODO: More checks Assert.That(uuid, Is.EqualTo(rpUuid)); Assert.That(name, Is.EqualTo(rpName)); Assert.That(creatorId, Is.EqualTo(rpCreatorId)); Assert.NotNull(daMap); Assert.AreEqual(daValue, daMap.GetStore(daNamespace, daStoreName)[daKey].AsString()); }
/// <summary> /// </summary> public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, 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() + id + "/" + destination.RegionID.ToString() + "/"; OSDMap request = new OSDMap(); request.Add("position", OSD.FromString(position.ToString())); try { OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 10000); bool success = result["success"].AsBoolean(); if (result.ContainsKey("_Result")) { OSDMap data = (OSDMap)result["_Result"]; 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} version {2} ({3})", uri, success, version, data["version"].AsString()); } if (!success) { 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); } return(success); } catch (Exception e) { m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] QueryAcess failed with exception; {0}", e.ToString()); } return(false); }
protected OSDMap OnMessageReceived(OSDMap message) { ISyncMessagePosterService asyncPost = m_registry.RequestModuleInterface <ISyncMessagePosterService>(); //We need to check and see if this is an AgentStatusChange if (message.ContainsKey("Method") && message["Method"] == "AgentStatusChange") { OSDMap innerMessage = (OSDMap)message["Message"]; //We got a message, now pass it on to the clients that need it UUID AgentID = innerMessage["AgentID"].AsUUID(); UUID FriendToInformID = innerMessage["FriendToInformID"].AsUUID(); bool NewStatus = innerMessage["NewStatus"].AsBoolean(); //Do this since IFriendsModule is a scene module, not a ISimulationBase module (not interchangable) ISceneManager manager = m_registry.RequestModuleInterface <ISceneManager>(); if (manager != null) { foreach (IScene scene in manager.Scenes) { if (scene.GetScenePresence(FriendToInformID) != null && !scene.GetScenePresence(FriendToInformID).IsChildAgent) { IFriendsModule friendsModule = scene.RequestModuleInterface <IFriendsModule>(); if (friendsModule != null) { //Send the message friendsModule.SendFriendsStatusMessage(FriendToInformID, new[] { AgentID }, NewStatus); } } } } } else if (message.ContainsKey("Method") && message["Method"] == "AgentStatusChanges") { OSDMap innerMessage = (OSDMap)message["Message"]; //We got a message, now pass it on to the clients that need it List <UUID> AgentIDs = ((OSDArray)innerMessage["AgentIDs"]).ConvertAll <UUID>((o) => o); UUID FriendToInformID = innerMessage["FriendToInformID"].AsUUID(); bool NewStatus = innerMessage["NewStatus"].AsBoolean(); //Do this since IFriendsModule is a scene module, not a ISimulationBase module (not interchangable) ISceneManager manager = m_registry.RequestModuleInterface <ISceneManager>(); if (manager != null) { foreach (IScene scene in manager.Scenes) { if (scene.GetScenePresence(FriendToInformID) != null && !scene.GetScenePresence(FriendToInformID).IsChildAgent) { IFriendsModule friendsModule = scene.RequestModuleInterface <IFriendsModule>(); if (friendsModule != null) { //Send the message friendsModule.SendFriendsStatusMessage(FriendToInformID, AgentIDs.ToArray(), NewStatus); } } } } } else if (message.ContainsKey("Method") && message["Method"] == "FriendGrantRights") { OSDMap body = (OSDMap)message["Message"]; UUID targetID = body["Target"].AsUUID(); IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService>(); UserInfo info; if (agentInfoService != null && (info = agentInfoService.GetUserInfo(targetID.ToString())) != null && info.IsOnline) { //Forward the message asyncPost.Post(info.CurrentRegionURI, message); } } else if (message.ContainsKey("Method") && message["Method"] == "FriendshipOffered") { OSDMap body = (OSDMap)message["Message"]; UUID targetID = body["Friend"].AsUUID(); IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService>(); UserInfo info; if (agentInfoService != null && (info = agentInfoService.GetUserInfo(targetID.ToString())) != null && info.IsOnline) { //Forward the message asyncPost.Post(info.CurrentRegionURI, message); } } else if (message.ContainsKey("Method") && message["Method"] == "FriendTerminated") { OSDMap body = (OSDMap)message["Message"]; UUID targetID = body["ExFriend"].AsUUID(); IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService>(); UserInfo info; if (agentInfoService != null && (info = agentInfoService.GetUserInfo(targetID.ToString())) != null && info.IsOnline) { //Forward the message asyncPost.Post(info.CurrentRegionURI, message); } } else if (message.ContainsKey("Method") && message["Method"] == "FriendshipDenied") { OSDMap body = (OSDMap)message["Message"]; UUID targetID = body["FriendID"].AsUUID(); IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService>(); UserInfo info; if (agentInfoService != null && (info = agentInfoService.GetUserInfo(targetID.ToString())) != null && info.IsOnline) { //Forward the message asyncPost.Post(info.CurrentRegionURI, message); } } else if (message.ContainsKey("Method") && message["Method"] == "FriendshipApproved") { OSDMap body = (OSDMap)message["Message"]; UUID targetID = body["FriendID"].AsUUID(); IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService>(); UserInfo info; if (agentInfoService != null && (info = agentInfoService.GetUserInfo(targetID.ToString())) != null && info.IsOnline) { //Forward the message asyncPost.Post(info.CurrentRegionURI, message); } } return(null); }
public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, EntityTransferContext ctx, out string myipaddress, out string reason) { reason = String.Empty; myipaddress = String.Empty; if (destination == null) { reason = "Destination not found"; m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Create agent destination is null"); return(false); } m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI); string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/"; try { OSDMap args = aCircuit.PackAgentCircuitData(ctx); args["context"] = ctx.Pack(); PackData(args, source, aCircuit, destination, flags); OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000); bool success = result["success"].AsBoolean(); if (success && result.ContainsKey("_Result")) { OSDMap data = (OSDMap)result["_Result"]; reason = data["reason"].AsString(); success = data["success"].AsBoolean(); myipaddress = data["your_ip"].AsString(); return(success); } // Try the old version, uncompressed result = WebUtil.PostToService(uri, args, 30000, false); if (result["Success"].AsBoolean()) { if (result.ContainsKey("_Result")) { OSDMap data = (OSDMap)result["_Result"]; reason = data["reason"].AsString(); success = data["success"].AsBoolean(); myipaddress = data["your_ip"].AsString(); m_log.WarnFormat( "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName); return(success); } } m_log.WarnFormat( "[REMOTE SIMULATION CONNECTOR]: Failed to create agent {0} {1} at remote simulator {2}", aCircuit.firstname, aCircuit.lastname, destination.RegionName); reason = result["Message"] != null ? result["Message"].AsString() : "error"; return(false); } catch (Exception e) { m_log.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e.ToString()); reason = e.Message; } return(false); }
/// <summary> /// Creates a new asset /// </summary> /// Returns a random ID if none is passed into it /// <param name="asset"></param> /// <returns></returns> public string Store(AssetBase asset) { if (String.IsNullOrEmpty(m_serverUrl)) { m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured"); throw new InvalidOperationException(); } bool storedInCache = false; string errorMessage = null; // AssetID handling if (String.IsNullOrEmpty(asset.ID) || asset.ID == ZeroID) { asset.FullID = UUID.Random(); asset.ID = asset.FullID.ToString(); } // Cache handling if (m_cache != null) { m_cache.Cache(asset); storedInCache = true; } // Local asset handling if (asset.Local) { if (!storedInCache) { m_log.Error("Cannot store local " + asset.Metadata.ContentType + " asset without an asset cache"); asset.ID = null; asset.FullID = UUID.Zero; } return(asset.ID); } // Distinguish public and private assets bool isPublic = true; switch ((AssetType)asset.Type) { case AssetType.CallingCard: case AssetType.Gesture: case AssetType.LSLBytecode: case AssetType.LSLText: isPublic = false; break; } // Make sure ContentType is set if (String.IsNullOrEmpty(asset.Metadata.ContentType)) { asset.Metadata.ContentType = SLUtil.SLAssetTypeToContentType(asset.Type); } // Build the remote storage request List <MultipartForm.Element> postParameters = new List <MultipartForm.Element>() { new MultipartForm.Parameter("AssetID", asset.FullID.ToString()), new MultipartForm.Parameter("CreatorID", asset.Metadata.CreatorID), new MultipartForm.Parameter("Temporary", asset.Temporary ? "1" : "0"), new MultipartForm.Parameter("Public", isPublic ? "1" : "0"), new MultipartForm.File("Asset", asset.Name, asset.Metadata.ContentType, asset.Data) }; // Make the remote storage request try { HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl); HttpWebResponse response = MultipartForm.Post(request, postParameters); using (Stream responseStream = response.GetResponseStream()) { string responseStr = null; try { responseStr = responseStream.GetStreamString(); OSD responseOSD = OSDParser.Deserialize(responseStr); if (responseOSD.Type == OSDType.Map) { OSDMap responseMap = (OSDMap)responseOSD; if (responseMap["Success"].AsBoolean()) { return(asset.ID); } else { errorMessage = "Upload failed: " + responseMap["Message"].AsString(); } } else { errorMessage = "Response format was invalid:\n" + responseStr; } } catch (Exception ex) { if (!String.IsNullOrEmpty(responseStr)) { errorMessage = "Failed to parse the response:\n" + responseStr; } else { errorMessage = "Failed to retrieve the response: " + ex.Message; } } } } catch (WebException ex) { errorMessage = ex.Message; } m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}", asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage); return(null); }
public override OSDMap ToOSDMap() { OSDMap ret = new OSDMap(); return(ret); }
private void SaveConfig() { Settings s = instance.GlobalSettings; SavedLogin sl = new SavedLogin(); string username = cbxUsername.Text; if (cbxUsername.SelectedIndex > 0 && cbxUsername.SelectedItem is SavedLogin) { username = ((SavedLogin)cbxUsername.SelectedItem).Username; } if (cbxGrid.SelectedIndex == cbxGrid.Items.Count - 1) // custom login uri { sl.GridID = "custom_login_uri"; sl.CustomURI = txtCustomLoginUri.Text; } else { sl.GridID = (cbxGrid.SelectedItem as Grid).ID; sl.CustomURI = string.Empty; } string savedLoginsKey = string.Format("{0}%{1}", username, sl.GridID); if (!(s["saved_logins"] is OSDMap)) { s["saved_logins"] = new OSDMap(); } if (cbRemember.Checked) { sl.Username = s["username"] = username; if (LoginOptions.IsPasswordMD5(txtPassword.Text)) { sl.Password = txtPassword.Text; s["password"] = txtPassword.Text; } else { sl.Password = Utils.MD5(txtPassword.Text); s["password"] = Utils.MD5(txtPassword.Text); } if (cbxLocation.SelectedIndex == -1) { sl.CustomStartLocation = cbxLocation.Text; } else { sl.CustomStartLocation = string.Empty; } sl.StartLocationType = cbxLocation.SelectedIndex; ((OSDMap)s["saved_logins"])[savedLoginsKey] = sl.ToOSD(); } else if (((OSDMap)s["saved_logins"]).ContainsKey(savedLoginsKey)) { ((OSDMap)s["saved_logins"]).Remove(savedLoginsKey); } s["login_location_type"] = OSD.FromInteger(cbxLocation.SelectedIndex); s["login_location"] = OSD.FromString(cbxLocation.Text); s["login_grid"] = OSD.FromInteger(cbxGrid.SelectedIndex); s["login_uri"] = OSD.FromString(txtCustomLoginUri.Text); s["remember_login"] = cbRemember.Checked; }
private byte[] CopyInventoryFromNotecard(Stream request, UUID agentID) { OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request)); UUID FolderID = rm["folder-id"].AsUUID(); UUID ItemID = rm["item-id"].AsUUID(); UUID NotecardID = rm["notecard-id"].AsUUID(); UUID ObjectID = rm["object-id"].AsUUID(); UUID notecardAssetID = UUID.Zero; if (ObjectID != UUID.Zero) { ISceneChildEntity part = m_scene.GetSceneObjectPart(ObjectID); if (part != null) { TaskInventoryItem item = part.Inventory.GetInventoryItem(NotecardID); if (m_scene.Permissions.CanCopyObjectInventory(NotecardID, ObjectID, agentID)) { notecardAssetID = item.AssetID; } } } else { notecardAssetID = m_scene.InventoryService.GetItemAssetID(agentID, NotecardID); } if (notecardAssetID != UUID.Zero) { byte[] asset = m_scene.AssetService.GetData(notecardAssetID.ToString()); if (asset != null) { AssetNotecard noteCardAsset = new AssetNotecard(UUID.Zero, asset); noteCardAsset.Decode(); bool found = false; UUID lastOwnerID = UUID.Zero; foreach ( InventoryItem notecardObjectItem in noteCardAsset.EmbeddedItems.Where(notecardObjectItem => notecardObjectItem.UUID == ItemID)) { //Make sure that it exists found = true; lastOwnerID = notecardObjectItem.OwnerID; break; } if (found) { m_scene.InventoryService.GiveInventoryItemAsync(agentID, lastOwnerID, ItemID, FolderID, false, (item) => { IClientAPI client; m_scene.ClientManager.TryGetValue( agentID, out client); if (item != null) { client.SendBulkUpdateInventory(item); } else { client.SendAlertMessage( "Failed to retrieve item"); } }); } } } return(new byte[0]); }