public void Startup(ConfigurationLoader loader) { IConfig config = loader.Config.Configs[GetType().FullName]; m_ExperienceServiceName = config.GetString("ExperienceService", "ExperienceService"); m_ExperienceService = loader.GetService <ExperienceServiceInterface>(m_ExperienceServiceName); m_UEI = new UEI(m_ExperienceID, "Name", new Uri("http://example.com/")); }
private void HandleExperiencePreferencesPut(ViewerAgent agent, AgentCircuit circuit, HttpRequest httpreq) { Map reqdata; using (Stream input = httpreq.Body) { reqdata = LlsdXml.Deserialize(input) as Map; } if (reqdata == null) { httpreq.ErrorResponse(HttpStatusCode.BadRequest, "Bad request"); return; } SceneInterface scene = circuit.Scene; if (scene == null) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } ExperienceServiceInterface experienceService = scene.ExperienceService; if (experienceService == null) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } foreach (KeyValuePair <string, IValue> kvp in reqdata) { Map entry = kvp.Value as Map; IValue iv; UUID experienceid; UEI uei; if (!UUID.TryParse(kvp.Key, out experienceid) || entry == null || !entry.TryGetValue("permission", out iv) || !experienceService.TryGetValue(experienceid, out uei)) { continue; } switch (iv.ToString()) { case "Allow": experienceService.Permissions[uei, agent.Owner] = true; break; case "Block": experienceService.Permissions[uei, agent.Owner] = false; break; } } }
private bool TryGetExperienceService(UGUI principal, out ExperienceServiceInterface experienceService) { experienceService = null; IAgent agent; UUID regionID; if (m_Scenes.TryFindRootAgent(principal.ID, out agent, out regionID)) { experienceService = agent.ExperienceService; } return(experienceService != null); }
public void HandleIsExperienceAdminCapability(ViewerAgent agent, AgentCircuit circuit, HttpRequest httpreq) { if (httpreq.CallerIP != circuit.RemoteIP) { httpreq.ErrorResponse(HttpStatusCode.Forbidden, "Forbidden"); return; } if (httpreq.Method != "GET") { httpreq.ErrorResponse(HttpStatusCode.MethodNotAllowed, "Method not allowed"); return; } Dictionary <string, object> reqdata = REST.ParseRESTFromRawUrl(httpreq.RawUrl); UUID experienceid = UUID.Parse((string)reqdata["experience_id"]); SceneInterface scene = circuit.Scene; if (scene == null) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } ExperienceServiceInterface experienceService = scene.ExperienceService; if (experienceService == null) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } ExperienceInfo info; bool isadmin = false; if (experienceService.TryGetValue(experienceid, out info)) { isadmin = info.Owner.EqualsGrid(agent.Owner) || experienceService.Admins[info.ID, agent.Owner]; } Map resdata = new Map { { "status", isadmin } }; using (HttpResponse res = httpreq.BeginResponse("application/llsd+xml")) { using (Stream o = res.GetOutputStream()) { LlsdXml.Serialize(resdata, o); } } }
private bool TryGetExperienceService(UEI uei, out ExperienceServiceInterface experienceService) { experienceService = default(ExperienceServiceInterface); Dictionary <string, string> cachedheaders; ExperienceBrokerEntry entry; if (uei.HomeURI == null) { return(false); } if (uei.AuthorizationToken == null) { /* if unset, try fetching the authorization token */ UEI uei2; if (m_ExperienceNameService.TryGetValue(uei.ID, out uei2)) { uei = uei2; if (uei.HomeURI == null) { return(false); } } } string experienceServerURI = uei.HomeURI.ToString(); if (m_ExperienceService != null && m_ExperienceHomeURI == experienceServerURI) { entry = new ExperienceBrokerEntry(m_ExperienceService, m_ClockSource.TickCount); m_NameCache[uei.ID] = entry; experienceService = entry; return(true); } cachedheaders = ServicePluginHelo.HeloRequest(experienceServerURI); foreach (IExperienceServicePlugin plugin in m_ExperienceServicePlugins) { if (plugin.IsProtocolSupported(experienceServerURI, cachedheaders)) { ExperienceServiceInterface service = plugin.Instantiate(uei); entry = new ExperienceBrokerEntry(service, m_ClockSource.TickCount); m_NameCache[uei.ID] = entry; experienceService = entry; return(true); } } return(false); }
public void HandleGroupExperiencesCapability(ViewerAgent agent, AgentCircuit circuit, HttpRequest httpreq) { if (httpreq.CallerIP != circuit.RemoteIP) { httpreq.ErrorResponse(HttpStatusCode.Forbidden, "Forbidden"); return; } if (httpreq.Method != "GET") { httpreq.ErrorResponse(HttpStatusCode.MethodNotAllowed, "Method not allowed"); return; } SceneInterface scene = circuit.Scene; if (scene == null) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } ExperienceServiceInterface experienceService = scene.ExperienceService; if (experienceService == null) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } List <UEI> experienceids = experienceService.GetGroupExperiences(agent.Group); var ids = new AnArray(); foreach (UEI id in experienceids) { ids.Add(id.ID); } var resdata = new Map { ["experience_ids"] = ids }; using (HttpResponse res = httpreq.BeginResponse("application/llsd+xml")) { using (Stream o = res.GetOutputStream()) { LlsdXml.Serialize(resdata, o); } } }
private bool TryGetExperienceService(UUID experienceID, out ExperienceServiceInterface experienceService) { UEI experience; ExperienceBrokerEntry entry; if (m_NameCache.TryGetValue(experienceID, out entry) && m_ClockSource.TicksElapsed(m_ClockSource.TickCount, entry.ExpiryTickCount) < m_ClockSource.SecsToTicks(120)) { experienceService = entry; return(true); } if (!m_ExperienceNameService.TryGetValue(experienceID, out experience)) { experienceService = default(ExperienceServiceInterface); return(false); } return(TryGetExperienceService(experience, out experienceService)); }
public ViewerAgent( SceneList scenes, UUID agentID, string firstName, string lastName, Uri homeURI, UUID sessionID, UUID secureSessionID, ClientInfo clientInfo, UserAccount untrustedAccountInfo, AgentServiceList serviceList) : base(agentID, homeURI) { m_Scenes = scenes; m_TeleportServices = serviceList.GetAll <IAgentTeleportServiceInterface>(); foreach (IAgentTeleportServiceInterface service in m_TeleportServices) { service.Agent = this; } CollisionPlane = Vector4.UnitW; SessionID = sessionID; m_UntrustedAccountInfo = untrustedAccountInfo; m_SecureSessionID = secureSessionID; Client = clientInfo; m_AssetService = serviceList.Get <AssetServiceInterface>(); m_InventoryService = serviceList.Get <InventoryServiceInterface>(); m_GroupsService = serviceList.Get <GroupsServiceInterface>(); m_ExperienceService = serviceList.Get <ExperienceServiceInterface>(); m_ProfileService = serviceList.Get <ProfileServiceInterface>(); m_FriendsService = serviceList.Get <FriendsServiceInterface>(); m_UserAgentService = serviceList.Get <UserAgentServiceInterface>(); m_PresenceService = serviceList.Get <IPresenceServiceInterface>(); EconomyService = serviceList.Get <EconomyServiceInterface>(); OfflineIMService = serviceList.Get <OfflineIMServiceInterface>(); MuteListService = serviceList.Get <MuteListServiceInterface>(); FirstName = firstName; LastName = lastName; OnPositionChange += ChildUpdateOnPositionChange; OnAppearanceUpdate += HandleAppearanceUpdate; }
private void HandleExperiencePreferencesDelete(ViewerAgent agent, AgentCircuit circuit, HttpRequest httpreq) { string[] parts = httpreq.RawUrl.Split('?'); UUID id; if (parts.Length < 2 || !UUID.TryParse(parts[1], out id)) { httpreq.ErrorResponse(HttpStatusCode.BadRequest, "Bad request"); return; } SceneInterface scene = circuit.Scene; if (scene == null) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } ExperienceServiceInterface experienceService = scene.ExperienceService; if (experienceService == null) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } UEI uei; if (!experienceService.TryGetValue(id, out uei)) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } experienceService.Permissions.Remove(uei, agent.Owner); }
public ExperienceBrokerEntry(ExperienceServiceInterface innerExperienceService, long expiryTickCount) { InnerExperienceService = innerExperienceService; ExpiryTickCount = expiryTickCount; }
public void HandleGetExperienceInfoCapability(ViewerAgent agent, AgentCircuit circuit, HttpRequest httpreq) { if (httpreq.CallerIP != circuit.RemoteIP) { httpreq.ErrorResponse(HttpStatusCode.Forbidden, "Forbidden"); return; } if (httpreq.Method != "GET") { httpreq.ErrorResponse(HttpStatusCode.MethodNotAllowed, "Method not allowed"); return; } var parts = httpreq.RawUrl.Split('?'); if (parts.Length < 2) { m_Log.WarnFormat("Invalid GetExperienceInfo request: {0}", httpreq.RawUrl); httpreq.ErrorResponse(HttpStatusCode.BadRequest, "Bad Request"); return; } var reqs = parts[1].Split('&'); var uuids = new List <UUID>(); Map resdata = new Map(); AnArray infos = new AnArray(); var baduuids = new AnArray(); resdata.Add("error_ids", baduuids); resdata.Add("experience_keys", infos); foreach (var req in reqs) { var p = req.Split('='); if (p.Length == 2) { if (p[0] == "public_id") { try { UUID uuid = p[1]; if (!uuids.Contains(uuid)) { uuids.Add(uuid); } } catch { baduuids.Add(p[1]); } } } } SceneInterface scene = circuit.Scene; if (scene == null) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } ExperienceServiceInterface experienceService = scene.ExperienceService; if (experienceService == null) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } foreach (UUID id in uuids) { ExperienceInfo info; try { info = experienceService[id]; } catch { baduuids.Add(id); continue; } infos.Add(info.ToMap()); } using (var res = httpreq.BeginResponse("application/llsd+xml")) { using (Stream s = res.GetOutputStream()) { LlsdXml.Serialize(resdata, s); } } }
public void HandleFindExperienceByNameCapability(ViewerAgent agent, AgentCircuit circuit, HttpRequest httpreq) { if (httpreq.CallerIP != circuit.RemoteIP) { httpreq.ErrorResponse(HttpStatusCode.Forbidden, "Forbidden"); return; } if (httpreq.Method != "GET") { httpreq.ErrorResponse(HttpStatusCode.MethodNotAllowed, "Method not allowed"); return; } Dictionary <string, object> reqdata = REST.ParseRESTFromRawUrl(httpreq.RawUrl); int currentpage; int pagesize; object o; if (!reqdata.TryGetValue("page", out o) || int.TryParse(o.ToString(), out currentpage)) { currentpage = 1; } if (!reqdata.TryGetValue("page_size", out o) || int.TryParse(o.ToString(), out pagesize)) { pagesize = 30; } if (!reqdata.TryGetValue("query", out o)) { httpreq.ErrorResponse(HttpStatusCode.BadRequest, "Bad request"); return; } string query = o.ToString(); SceneInterface scene = circuit.Scene; if (scene == null) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } ExperienceServiceInterface experienceService = scene.ExperienceService; if (experienceService == null) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } List <ExperienceInfo> experienceinfos = experienceService.FindExperienceInfoByName(query); Map resdata = new Map(); AnArray result = new AnArray(); resdata.Add("experience_keys", result); foreach (ExperienceInfo info in experienceinfos) { result.Add(info.ToMap()); } using (var res = httpreq.BeginResponse("application/llsd+xml")) { using (Stream s = res.GetOutputStream()) { LlsdXml.Serialize(resdata, s); } } }
public void HandleAgentExperiencesCapability(ViewerAgent agent, AgentCircuit circuit, HttpRequest httpreq) { if (httpreq.CallerIP != circuit.RemoteIP) { httpreq.ErrorResponse(HttpStatusCode.Forbidden, "Forbidden"); return; } if (httpreq.Method != "GET" && httpreq.Method != "POST") { httpreq.ErrorResponse(HttpStatusCode.MethodNotAllowed, "Method not allowed"); return; } SceneInterface scene = circuit.Scene; if (scene == null) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } ExperienceServiceInterface experienceService = scene.ExperienceService; if (experienceService == null) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } if (httpreq.Method == "POST") { ExperienceInfo info = new ExperienceInfo { /* ID's HomeURI is setup by ExperienceService */ ID = new UEI(UUID.Random) { ExperienceName = "New Experience" }, Owner = agent.Owner, Creator = agent.Owner, }; experienceService.Add(info); } List <UEI> experienceids = experienceService.GetOwnerExperiences(agent.Owner); var ids = new AnArray(); foreach (UEI id in experienceids) { ids.Add(id.ID); } var resdata = new Map { ["experience_ids"] = ids, ["purchase"] = new ABoolean(true) }; using (HttpResponse res = httpreq.BeginResponse("application/llsd+xml")) { using (Stream o = res.GetOutputStream()) { LlsdXml.Serialize(resdata, o); } } }
private bool TryAddAdditionalObject(SceneInterface scene, string sectionName) { IConfig config = m_Loader.Config.Configs[sectionName]; Vector3 position = Vector3.Parse(config.GetString("Position", m_Position.ToString())); Quaternion rotation = Quaternion.Parse(config.GetString("Rotation", m_Rotation.ToString())); UUID objectid = UUID.Parse(config.GetString("ID", UUID.Random.ToString())); int scriptPin = config.GetInt("ScriptAccessPin", 0); string objectName = config.GetString("ObjectName", sectionName); string scriptName = config.GetString("ScriptName", "Script"); string experienceName = config.GetString("ExperienceName", "My Experience"); UUID itemID = UUID.Parse(config.GetString("ScriptItemID", UUID.Zero.ToString())); UUID rezzingObjID = UUID.Parse(config.GetString("RezzingObjectID", UUID.Zero.ToString())); UEI experienceID; UUID expID; UUID.TryParse(config.GetString("ExperienceID", m_ExperienceID.ToString()), out expID); experienceID = new UEI(expID, experienceName, null); string objectDescription = config.GetString("ObjectDescription", ""); string scriptDescription = config.GetString("ScriptDescription", ""); var objectOwner = new UGUIWithName(config.GetString("ObjectOwner", m_ObjectOwner.ToString())) { IsAuthoritative = true }; m_AvatarNameService.Store(objectOwner); try { m_UserAccountService.Add(new UserAccount { Principal = objectOwner, IsLocalToGrid = true, }); } catch { /* intentionally ignored */ } var objectCreator = new UGUIWithName(config.GetString("ObjectCreator", m_ObjectCreator.ToString())) { IsAuthoritative = true }; m_AvatarNameService.Store(objectCreator); try { m_UserAccountService.Add(new UserAccount { Principal = objectCreator, IsLocalToGrid = true, }); } catch { /* intentionally ignored */ } var objectLastOwner = new UGUIWithName(config.GetString("ObjectLastOwner", m_ObjectLastOwner.ToString())) { IsAuthoritative = true }; m_AvatarNameService.Store(objectLastOwner); try { m_UserAccountService.Add(new UserAccount { Principal = objectLastOwner, IsLocalToGrid = true, }); } catch { /* intentionally ignored */ } var scriptOwner = new UGUIWithName(config.GetString("ScriptOwner", m_ScriptOwner.ToString())) { IsAuthoritative = true }; m_AvatarNameService.Store(scriptOwner); try { m_UserAccountService.Add(new UserAccount { Principal = scriptOwner, IsLocalToGrid = true, }); } catch { /* intentionally ignored */ } var scriptCreator = new UGUIWithName(config.GetString("ScriptCreator", m_ScriptCreator.ToString())) { IsAuthoritative = true }; m_AvatarNameService.Store(scriptCreator); try { m_UserAccountService.Add(new UserAccount { Principal = scriptCreator, IsLocalToGrid = true, }); } catch { /* intentionally ignored */ } var scriptLastOwner = new UGUIWithName(config.GetString("ScriptLastOwner", m_ScriptLastOwner.ToString())) { IsAuthoritative = true }; m_AvatarNameService.Store(scriptLastOwner); try { m_UserAccountService.Add(new UserAccount { Principal = scriptLastOwner, IsLocalToGrid = true, }); } catch { /* intentionally ignored */ } int startParameter = config.GetInt("StartParameter", m_StartParameter); InventoryPermissionsMask objectPermissionsBase = GetPermissions(config, "ObjectPermisionsBase", m_ObjectPermissionsBase); InventoryPermissionsMask objectPermissionsOwner = GetPermissions(config, "ObjectPermisionsOwner", m_ObjectPermissionsOwner); InventoryPermissionsMask objectPermissionsGroup = GetPermissions(config, "ObjectPermisionsGroup", m_ObjectPermissionsGroup); InventoryPermissionsMask objectPermissionsNext = GetPermissions(config, "ObjectPermisionsNext", m_ObjectPermissionsNext); InventoryPermissionsMask objectPermissionsEveryone = GetPermissions(config, "ObjectPermisionsEveryone", m_ObjectPermissionsEveryone); InventoryPermissionsMask scriptPermissionsBase = GetPermissions(config, "ScriptPermisionsBase", m_ScriptPermissionsBase); InventoryPermissionsMask scriptPermissionsOwner = GetPermissions(config, "ScriptPermisionsOwner", m_ScriptPermissionsOwner); InventoryPermissionsMask scriptPermissionsGroup = GetPermissions(config, "ScriptPermisionsGroup", m_ScriptPermissionsGroup); InventoryPermissionsMask scriptPermissionsNext = GetPermissions(config, "ScriptPermisionsNext", m_ScriptPermissionsNext); InventoryPermissionsMask scriptPermissionsEveryone = GetPermissions(config, "ScriptPermisionsEveryone", m_ScriptPermissionsEveryone); UUID assetID = UUID.Zero; string scriptFile = string.Empty; /* we use same asset id keying here so to make them compatible with the other scripts */ foreach (string key in config.GetKeys()) { if (UUID.TryParse(key, out assetID)) { scriptFile = config.GetString(key); break; } } IScriptAssembly scriptAssembly = null; if (!string.IsNullOrEmpty(scriptFile)) { if (itemID == UUID.Zero) { itemID = UUID.Random; } try { using (var reader = new StreamReader(scriptFile, new UTF8Encoding(false))) { scriptAssembly = CompilerRegistry.ScriptCompilers.Compile(AppDomain.CurrentDomain, UGUI.Unknown, m_AssetID, reader); } m_Log.InfoFormat("Compilation of {1} ({0}) successful", m_AssetID, scriptFile); } catch (CompilerException e) { m_Log.ErrorFormat("Compilation of {1} ({0}) failed: {2}", m_AssetID, scriptFile, e.Message); m_Log.WarnFormat("Stack Trace:\n{0}", e.StackTrace.ToString()); return(false); } catch (Exception e) { m_Log.ErrorFormat("Compilation of {1} ({0}) failed: {2}", m_AssetID, scriptFile, e.Message); m_Log.WarnFormat("Stack Trace:\n{0}", e.StackTrace.ToString()); return(false); } } try { ExperienceServiceInterface experienceService = scene.ExperienceService; if (null != experienceService) { ExperienceInfo test; if (!experienceService.TryGetValue(experienceID, out test)) { experienceService.Add(new ExperienceInfo { ID = experienceID, Creator = scriptOwner, Owner = scriptOwner, Properties = ExperiencePropertyFlags.Grid /* make this grid-wide since otherwise we have to configure a lot more */ }); } } else { experienceID = UEI.Unknown; } } catch (Exception e) { m_Log.Error("Creating experience failed", e); return(false); } string[] additionalInventoryConfigs = config.GetString("AdditionalInventories", string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (additionalInventoryConfigs.Length == 1 && additionalInventoryConfigs[0] == string.Empty) { additionalInventoryConfigs = new string[0]; } try { var grp = new ObjectGroup { RezzingObjectID = rezzingObjID }; var part = new ObjectPart(objectid); grp.Add(1, part.ID, part); part.ObjectGroup = grp; grp.Owner = objectOwner; grp.LastOwner = objectLastOwner; part.Creator = objectCreator; part.Name = objectName; part.Description = objectDescription; part.GlobalPosition = position; part.GlobalRotation = rotation; part.BaseMask = objectPermissionsBase; part.OwnerMask = objectPermissionsOwner; part.NextOwnerMask = objectPermissionsNext; part.EveryoneMask = objectPermissionsEveryone; part.GroupMask = objectPermissionsGroup; part.ScriptAccessPin = scriptPin; var item = new ObjectPartInventoryItem(itemID) { AssetType = AssetType.LSLText, AssetID = assetID, InventoryType = InventoryType.LSL, LastOwner = scriptLastOwner, Creator = scriptCreator, Owner = scriptOwner, Name = scriptName, Description = scriptDescription }; item.Permissions.Base = scriptPermissionsBase; item.Permissions.Current = scriptPermissionsOwner; item.Permissions.EveryOne = scriptPermissionsEveryone; item.Permissions.Group = scriptPermissionsGroup; item.Permissions.NextOwner = scriptPermissionsNext; item.ExperienceID = experienceID; scene.Add(grp); foreach (string invconfig in additionalInventoryConfigs) { AddAdditionalInventory(part, invconfig); } if (scriptAssembly != null) { byte[] serializedState; m_ScriptStates.TryGetValue(item.ID, out serializedState); ScriptInstance scriptInstance = scriptAssembly.Instantiate(part, item, serializedState); part.Inventory.Add(item); item.ScriptInstance = scriptInstance; item.ScriptInstance.Start(startParameter); } } catch (Exception e) { m_Log.Error("Adding object failed", e); return(false); } return(true); }
public void HandleUpdateExperienceCapability(ViewerAgent agent, AgentCircuit circuit, HttpRequest httpreq) { if (httpreq.CallerIP != circuit.RemoteIP) { httpreq.ErrorResponse(HttpStatusCode.Forbidden, "Forbidden"); return; } if (httpreq.Method != "POST") { httpreq.ErrorResponse(HttpStatusCode.MethodNotAllowed, "Method not allowed"); return; } Map reqmap; using (Stream s = httpreq.Body) { reqmap = LlsdXml.Deserialize(s) as Map; } if (reqmap == null) { httpreq.ErrorResponse(HttpStatusCode.BadRequest, "Bad request"); return; } SceneInterface scene = circuit.Scene; if (scene == null) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } ExperienceServiceInterface experienceService = scene.ExperienceService; if (experienceService == null) { httpreq.ErrorResponse(HttpStatusCode.NotFound, "Not Found"); return; } UUID experienceid = reqmap["public_id"].AsUUID; ExperienceInfo info; Map resmap = new Map(); if (experienceService.TryGetValue(experienceid, out info)) { IValue iv; if (reqmap.TryGetValue("group_id", out iv)) { UUID id = iv.AsUUID; UGI ugi; if (id == UUID.Zero) { info.Group = UGI.Unknown; } else if (scene.GroupsNameService != null && scene.GroupsNameService.TryGetValue(id, out ugi)) { info.Group = ugi; } } if (reqmap.TryGetValue("name", out iv)) { info.ID.ExperienceName = iv.ToString(); } if (reqmap.TryGetValue("description", out iv)) { info.Description = iv.ToString(); } if (reqmap.TryGetValue("properties", out iv)) { info.Properties = (ExperiencePropertyFlags)iv.AsInt; } if (reqmap.TryGetValue("maturity", out iv)) { info.Maturity = (RegionAccess)iv.AsInt; } if (reqmap.TryGetValue("extended_metadata", out iv)) { info.ExtendedMetadata = iv.ToString(); } if (reqmap.TryGetValue("slurl", out iv)) { info.SlUrl = iv.ToString(); } try { experienceService.Update(agent.Owner, info); } catch (Exception e) { #if DEBUG m_Log.Debug("UpdateExperience capability", e); #endif resmap.Add("removed", new AnArray { new Map { { "error-tag", "Failed to update" } } }); } if (!resmap.ContainsKey("removed")) { var ids = new AnArray(); ids.Add(info.ToMap()); resmap.Add("experience_keys", ids); } } else { resmap.Add("removed", new AnArray { new Map { { "error-tag", "Not found" } } }); } using (HttpResponse res = httpreq.BeginResponse("application/llsd+xml")) { using (Stream o = res.GetOutputStream()) { LlsdXml.Serialize(resmap, o); } } }
public bool Run() { m_Log.InfoFormat("Testing Execution of {1} ({0})", m_AssetID, m_ScriptFile); IScriptAssembly scriptAssembly = null; try { using (var reader = new StreamReader(m_ScriptFile, new UTF8Encoding(false))) { scriptAssembly = CompilerRegistry.ScriptCompilers.Compile(AppDomain.CurrentDomain, UGUI.Unknown, m_AssetID, reader, includeOpen: OpenFile); } m_Log.InfoFormat("Compilation of {1} ({0}) successful", m_AssetID, m_ScriptFile); } catch (CompilerException e) { m_Log.ErrorFormat("Compilation of {1} ({0}) failed: {2}", m_AssetID, m_ScriptFile, e.Message); m_Log.WarnFormat("Stack Trace:\n{0}", e.StackTrace); return(false); } catch (Exception e) { m_Log.ErrorFormat("Compilation of {1} ({0}) failed: {2}", m_AssetID, m_ScriptFile, e.Message); m_Log.WarnFormat("Stack Trace:\n{0}", e.StackTrace); return(false); } RegionInfo rInfo; try { var estate = new EstateInfo { ParentEstateID = 1, ID = m_EstateID, Owner = m_EstateOwner, Name = m_EstateName }; m_EstateService.Add(estate); m_EstateService.RegionMap[m_RegionID] = m_EstateID; rInfo = new RegionInfo { Name = m_RegionName, ID = m_RegionID, Location = m_RegionLocation, Size = m_RegionSize, ProductName = m_ProductName, ServerPort = (uint)m_RegionPort, Owner = m_RegionOwner, Flags = RegionFlags.RegionOnline, Access = m_RegionAccess, GridURI = m_GatekeeperURI }; m_RegionStorage.RegisterRegion(rInfo); } catch (Exception e) { m_Log.Error("Registration of region failed", e); return(false); } SceneInterface scene; try { scene = m_SceneFactory.Instantiate(rInfo); } catch (Exception e) { m_Log.ErrorFormat("Running of {1} ({0}) failed: Failed to start region ID {2}: {3}: {4}\n{5}", m_AssetID, m_ScriptFile, m_RegionID, e.GetType().FullName, e.Message, e.StackTrace); return(false); } try { m_Scenes.Add(scene); scene.LoadSceneSync(); } catch (Exception e) { m_Log.Error("Starting region failed", e); return(false); } try { ExperienceServiceInterface experienceService = scene.ExperienceService; if (experienceService != null) { experienceService.Add(new ExperienceInfo { ID = m_ExperienceID, Creator = m_ScriptOwner, Owner = m_ScriptOwner, Properties = ExperiencePropertyFlags.Grid /* make this grid-wide since otherwise we have to configure a lot more */ }); } else { m_ExperienceID = UEI.Unknown; } } catch (Exception e) { m_Log.Error("Creating experience failed", e); return(false); } if (!string.IsNullOrEmpty(m_AssetSourcesConfig)) { AddAssets(scene.AssetService); } if (!string.IsNullOrEmpty(m_ScriptStatesConfig)) { AddScriptStates(); } if (!string.IsNullOrEmpty(m_LoadOarFileName)) { try { using (var s = new FileStream(m_LoadOarFileName, FileMode.Open)) { OAR.Load(m_Scenes, scene, OAR.LoadOptions.PersistUuids, s); } } catch (Exception e) { m_Log.Error("Loading oar failed", e); return(false); } } m_Runner.OtherThreadResult = false; foreach (string additionalObject in m_AdditionalObjectConfigs) { m_Log.InfoFormat("Adding object from section {0}", additionalObject); if (!TryAddAdditionalObject(scene, additionalObject)) { m_Log.Info("Failed to add object"); return(false); } } try { var grp = new ObjectGroup { RezzingObjectID = m_RezzingObjID }; var part = new ObjectPart(m_ObjectID); grp.Add(1, part.ID, part); part.ObjectGroup = grp; grp.Owner = m_ObjectOwner; grp.LastOwner = m_ObjectLastOwner; part.Creator = m_ObjectCreator; part.Name = m_ObjectName; part.Description = m_ObjectDescription; part.GlobalPosition = m_Position; part.GlobalRotation = m_Rotation; part.BaseMask = m_ObjectPermissionsBase; part.OwnerMask = m_ObjectPermissionsOwner; part.NextOwnerMask = m_ObjectPermissionsNext; part.EveryoneMask = m_ObjectPermissionsEveryone; part.GroupMask = m_ObjectPermissionsGroup; var item = new ObjectPartInventoryItem(m_ItemID) { AssetType = AssetType.LSLText, AssetID = m_AssetID, InventoryType = InventoryType.LSL, LastOwner = m_ScriptLastOwner, Creator = m_ScriptCreator, Owner = m_ScriptOwner, Name = m_ScriptName, Description = m_ScriptDescription }; item.Permissions.Base = m_ScriptPermissionsBase; item.Permissions.Current = m_ScriptPermissionsOwner; item.Permissions.EveryOne = m_ScriptPermissionsEveryone; item.Permissions.Group = m_ScriptPermissionsGroup; item.Permissions.NextOwner = m_ScriptPermissionsNext; item.ExperienceID = m_ExperienceID; scene.Add(grp); foreach (string invconfig in m_AdditionalInventoryConfigs) { AddAdditionalInventory(part, invconfig); } ChatServiceInterface chatService = scene.GetService <ChatServiceInterface>(); if (chatService != null) { chatService.AddRegionListener(PUBLIC_CHANNEL, string.Empty, UUID.Zero, "", GetUUID, null, PublicChannelLog); chatService.AddRegionListener(DEBUG_CHANNEL, string.Empty, UUID.Zero, "", GetUUID, null, DebugChannelLog); } byte[] serializedState; m_ScriptStates.TryGetValue(item.ID, out serializedState); ScriptInstance scriptInstance = scriptAssembly.Instantiate(part, item, serializedState); part.Inventory.Add(item); item.ScriptInstance = scriptInstance; item.ScriptInstance.Start(m_StartParameter); m_Log.Info("Script started"); if (Debugger.IsAttached) { m_RunTimeoutEvent.WaitOne(); } else { m_KillTimer = new Timer(KillTimerCbk, null, m_TimeoutMs + 5000, Timeout.Infinite); m_RunTimeoutEvent.WaitOne(m_TimeoutMs); } return(m_Runner.OtherThreadResult); } catch (Exception e) { m_Log.Error("Starting script failed", e); return(false); } }
internal void HandleScriptAnswerYes(Message m) { var req = (ScriptAnswerYes)m; if (req.CircuitAgentID != req.AgentID || req.CircuitSessionID != req.SessionID) { return; } Script.ScriptInstance instance; ObjectPart part; ObjectPartInventoryItem item; IAgent agent; if (!Primitives.TryGetValue(req.TaskID, out part) || !part.Inventory.TryGetValue(req.ItemID, out item) || !Agents.TryGetValue(req.AgentID, out agent)) { return; } instance = item.ScriptInstance; if (instance == null) { return; } if (item.ExperienceID != UEI.Unknown) { ExperienceServiceInterface experienceService = ExperienceService; if (req.Questions == ScriptPermissions.ExperienceGrantedPermissions) { /* allow response */ if (agent.WaitsForExperienceResponse(part, item.ID)) { try { experienceService.Permissions[item.ExperienceID, agent.Owner] = true; } catch (Exception ex) { m_Log.WarnFormat("Could not store experience accept: {0}", ex.Message); } instance.PostEvent(new ExperiencePermissionsEvent { PermissionsKey = agent.Owner }); } } else if (req.Questions == ScriptPermissions.None) { /* deny response */ if (agent.WaitsForExperienceResponse(part, item.ID)) { try { experienceService.Permissions[item.ExperienceID, agent.Owner] = false; } catch (Exception ex) { m_Log.WarnFormat("Could not store experience denial: {0}", ex.Message); } instance.PostEvent(new ExperiencePermissionsDeniedEvent { AgentId = agent.Owner, Reason = 4 }); } } } var e = new RuntimePermissionsEvent { PermissionsKey = req.CircuitAgentOwner, Permissions = req.Questions }; instance.PostEvent(e); }