internal LinSynth(PluginControl pc, string[] beeps) { BeepNames = beeps; ToASCII = new System.Text.ASCIIEncoding(); OSDMap speech = pc.config["synthesizer"] as OSDMap; if (speech == null) { speech = new OSDMap(); speech["server"] = new OSDString("localhost:1314"); speech["speed"] = new OSDInteger(0); pc.config["synthesizer"] = speech; pc.SaveSpeechSettings(); } string server = speech["server"].AsString() ?? "localhost:1314"; string[] parts = server.Split(':'); serverhost = parts[0]; if (parts.Length > 1) { serverport = parts[1]; } else { serverport = "1314"; } rateBias = speech["speed"].AsInteger(); // Build the festival command line args ActualArgs = Regex.Replace(SynthArgs, @"%S", serverhost); ActualArgs = Regex.Replace(ActualArgs, @"%P", serverport); voiceProperties = pc.config["properties"] as OSDMap; }
// ----------------------------------------------------------------- /// <summary> /// /// </summary> // ----------------------------------------------------------------- public bool SetValue(string expr, string value, bool useJson) { OSD ovalue; // One note of caution... if you use an empty string in the // structure it will be assumed to be a default value and will // not be seialized in the json if (useJson) { // There doesn't appear to be a good way to determine if the // value is valid Json other than to let the parser crash try { ovalue = OSDParser.DeserializeJson(value); } catch (Exception) { if (value.StartsWith("'") && value.EndsWith("'")) { ovalue = new OSDString(value.Substring(1, value.Length - 2)); } else { return(false); } } } else { ovalue = new OSDString(value); } return(SetValueFromExpression(expr, ovalue)); }
/// <summary> /// Save or update a permanent voice assignment. /// </summary> /// <param name="name"></param> /// <param name="v"></param> private void SaveAssignment(string name, AssignedVoice v) { // Definition is the voice name in single quotes followed // by optional modifiers. string definition = "'" + v.root.Name + "'"; switch (v.pitchModification) { case 0: break; case -1: definition += " low"; break; case +1: definition += " high"; break; } switch (v.rateModification) { case 0: break; case -1: definition += " slow"; break; case +1: definition += " fast"; break; } // Update the configuration file. configVoices[name] = new OSDString(definition); control.SaveSpeechSettings(); }
internal LinSynth( PluginControl pc, string[] beeps) { BeepNames = beeps; ToASCII = new System.Text.ASCIIEncoding(); OSDMap speech = pc.config["synthesizer"] as OSDMap; if (speech == null) { speech = new OSDMap(); speech["server"] = new OSDString("localhost:1314"); speech["speed"] = new OSDInteger(0); pc.config["synthesizer"] = speech; pc.SaveSpeechSettings(); } string server = speech["server"].AsString(); if (server==null) server = "localhost:1314"; string[] parts = server.Split(':'); serverhost = parts[0]; if (parts.Length>1) serverport = parts[1]; else serverport = "1314"; rateBias = speech["speed"].AsInteger(); // Build the festival command line args ActualArgs = Regex.Replace( SynthArgs, @"%S", serverhost ); ActualArgs = Regex.Replace( ActualArgs, @"%P", serverport ); voiceProperties = pc.config["properties"] as OSDMap; }
public void DeserializeNestedComposite() { OSD llsdNested = OSDParser.DeserializeLLSDBinary(binaryNested); Assert.AreEqual(OSDType.Array, llsdNested.Type); OSDArray llsdArray = (OSDArray)llsdNested; Assert.AreEqual(3, llsdArray.Count); OSDMap llsdMap = (OSDMap)llsdArray[0]; Assert.AreEqual(OSDType.Map, llsdMap.Type); Assert.AreEqual(2, llsdMap.Count); OSDArray llsdNestedArray = (OSDArray)llsdMap["t0st"]; Assert.AreEqual(OSDType.Array, llsdNestedArray.Type); OSDInteger llsdNestedIntOne = (OSDInteger)llsdNestedArray[0]; Assert.AreEqual(OSDType.Integer, llsdNestedIntOne.Type); Assert.AreEqual(1, llsdNestedIntOne.AsInteger()); OSDInteger llsdNestedIntTwo = (OSDInteger)llsdNestedArray[1]; Assert.AreEqual(OSDType.Integer, llsdNestedIntTwo.Type); Assert.AreEqual(2, llsdNestedIntTwo.AsInteger()); OSDString llsdString = (OSDString)llsdMap["test"]; Assert.AreEqual(OSDType.String, llsdString.Type); Assert.AreEqual("what", llsdString.AsString()); OSDInteger llsdIntOne = (OSDInteger)llsdArray[1]; Assert.AreEqual(OSDType.Integer, llsdIntOne.Type); Assert.AreEqual(124, llsdIntOne.AsInteger()); OSDInteger llsdIntTwo = (OSDInteger)llsdArray[2]; Assert.AreEqual(OSDType.Integer, llsdIntTwo.Type); Assert.AreEqual(987, llsdIntTwo.AsInteger()); }
bool GetImageAssets(UUID avatarId) { string profileServerURI = string.Empty; string assetServerURI = string.Empty; bool foreign = GetUserProfileServerURI(avatarId, out profileServerURI); if (!foreign) { return(true); } assetServerURI = UserManagementModule.GetUserServerURL(avatarId, "AssetServerURI"); if (string.IsNullOrEmpty(profileServerURI) || string.IsNullOrEmpty(assetServerURI)) { return(false); } OSDMap parameters = new OSDMap(); parameters.Add("avatarId", OSD.FromUUID(avatarId)); OSD Params = (OSD)parameters; try { if (!rpc.JsonRpcRequest(ref Params, "image_assets_request", profileServerURI, UUID.Random().ToString())) { return(false); } parameters = (OSDMap)Params; if (parameters.ContainsKey("result")) { OSDArray list = (OSDArray)parameters["result"]; foreach (OSD asset in list) { OSDString assetId = (OSDString)asset; Scene.AssetService.Get(string.Format("{0}/{1}", assetServerURI, assetId.AsString())); } return(true); } else { return(false); } } catch { return(false); } }
private OSDString mapTextureURL(string[] parts) { OSDString resp = (OSDString)OSD.FromString(string.Empty); if (parts.Length < 1 || parts[0] != "mapTextureURL") { return(resp); } return((OSDString)OSD.FromString(m_textureServer.ServerURI + "/index.php?method=MapAPI_MapTexture&x=_%x%_&y=_%y%_&zoom=_%zoom%_")); }
public OSDArray ArrayListToOSDArray(ArrayList arrlst) { OSDArray llsdBack = new OSDArray(); foreach (Hashtable ht in arrlst) { OSDMap mp = new OSDMap(); foreach (DictionaryEntry deHt in ht) { mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value)); } llsdBack.Add(mp); } return(llsdBack); }
public void DeserializeStrings() { OSD theSD = null; OSDArray array = null; OSDString tempStr = null; String testSD = @"<?xml version='1.0' encoding='UTF-8'?> <llsd> <array> <string>Kissling</string> <string>Attack ships on fire off the shoulder of Orion</string> <string>< > & ' "</string> <string/> </array> </llsd>"; //Deserialize the string byte[] bytes = Encoding.UTF8.GetBytes(testSD); theSD = OSDParser.DeserializeLLSDXml(bytes); Assert.IsTrue(theSD is OSDArray); array = (OSDArray)theSD; Assert.AreEqual(OSDType.String, array[0].Type); tempStr = (OSDString)array[0]; Assert.AreEqual("Kissling", tempStr.AsString()); Assert.AreEqual(OSDType.String, array[1].Type); tempStr = (OSDString)array[1]; Assert.AreEqual("Attack ships on fire off the shoulder of Orion", tempStr.AsString()); Assert.AreEqual(OSDType.String, array[2].Type); tempStr = (OSDString)array[2]; Assert.AreEqual("< > & \' \"", tempStr.AsString()); Assert.AreEqual(OSDType.String, array[3].Type); tempStr = (OSDString)array[3]; Assert.AreEqual("", tempStr.AsString()); }
private OSDMap GetAbuseReport(OSDMap map) { OSDMap resp = new OSDMap(); IAbuseReports ar_service = m_registry.RequestModuleInterface<IAbuseReports>(); if (ar_service == null) { resp["Failed"] = new OSDString("Failed to find IAbuseReports service."); } else if (!map.ContainsKey("AbuseReport")) { resp["Failed"] = new OSDString("Abuse Report ID not specified."); } else { AbuseReport ar = ar_service.GetAbuseReport(map["AbuseReport"].AsInteger()); if (ar == null) { resp["Failed"] = new OSDString("Failed to find Abuse Report with specified ID."); } else { resp["AbuseReport"] = ar.ToOSD(); } } return resp; }
public RelayConsole(RadegastInstance instance) : base(instance) { InitializeComponent(); Disposed += RelayConsole_Disposed; textPrinter = new RichTextBoxPrinter(rtbChatText); // Get configuration settings, and initialize if not found. config = instance.GlobalSettings["plugin.irc"] as OSDMap; if (config == null) { config = new OSDMap(); config["server"] = new OSDString("irc.freenode.net"); config["port"] = new OSDInteger(6667); config["nick"] = new OSDString(string.Empty); config["channel"] = new OSDString("#"); config["send_delay"] = new OSDInteger(200); config["auto_reconnect"] = new OSDBoolean(true); config["ctcp_version"] = new OSDString("Radegast IRC"); instance.GlobalSettings["plugin.irc"] = config; } if (!config.ContainsKey("server")) config["server"] = new OSDString("irc.freenode.net"); if (!config.ContainsKey("port")) config["port"] = new OSDInteger(6667); if (!config.ContainsKey("nick")) config["nick"] = new OSDString(instance.Client.Self.Name); if (!config.ContainsKey("channel")) config["channel"] = new OSDString("#"); if (!config.ContainsKey("send_delay")) config["send_delay"] = new OSDInteger(200); if (!config.ContainsKey("auto_reconnect")) config["auto_reconnect"] = new OSDBoolean(true); if (!config.ContainsKey("ctcp_version")) config["ctcp_version"] = new OSDString("Radegast IRC"); txtChan.Text = config["channel"].AsString(); txtNick.Text = config["nick"].AsString(); txtPort.Text = config["port"].AsString(); txtServer.Text = config["server"].AsString(); irc = new IrcClient(); irc.SendDelay = config["send_delay"].AsInteger(); irc.AutoReconnect = config["auto_reconnect"].AsBoolean(); irc.CtcpVersion = config["ctcp_version"].AsString(); irc.Encoding = Encoding.UTF8; TC.OnTabAdded += TC_OnTabAdded; TC.OnTabRemoved += TC_OnTabRemoved; irc.OnError += irc_OnError; irc.OnRawMessage += irc_OnRawMessage; irc.OnChannelMessage += irc_OnChannelMessage; irc.OnConnected += irc_OnConnected; irc.OnDisconnected += irc_OnDisconnected; client.Self.IM += Self_IM; client.Self.ChatFromSimulator += Self_ChatFromSimulator; UpdateGui(); RefreshGroups(); }
private OSDMap FindUsers(OSDMap map) { OSDMap resp = new OSDMap(); IUserAccountService accountService = m_registry.RequestModuleInterface<IUserAccountService>(); IAgentConnector agentConnector = Aurora.DataManager.DataManager.RequestPlugin<IAgentConnector>(); if (accountService == null) { resp["Failed"] = new OSDString("Could not find IUserAccountService"); } else if (agentConnector == null) { resp["Failed"] = new OSDString("Could not find IAgentConnector"); } else { UUID scopeID = map.ContainsKey("ScopeID") ? map["ScopeID"].AsUUID() : UUID.Zero; uint start = map.ContainsKey("Start") ? map["Start"].AsUInteger() : 0; uint count = map.ContainsKey("Count") ? map["Count"].AsUInteger() : 10; string Query = map["Query"].AsString(); List<UserAccount> accounts = accountService.GetUserAccounts(scopeID, Query, start, count); OSDArray users = new OSDArray(); MainConsole.Instance.TraceFormat("{0} accounts found", accounts.Count); foreach (UserAccount acc in accounts) { OSDMap userInfo = new OSDMap(); userInfo["PrincipalID"] = acc.PrincipalID; userInfo["UserName"] = acc.Name; userInfo["Created"] = acc.Created; userInfo["UserFlags"] = acc.UserFlags; userInfo["UserLevel"] = acc.UserLevel; IAgentInfo agent = agentConnector.GetAgent(acc.PrincipalID); if (agent == null) { MainConsole.Instance.ErrorFormat("Could not get IAgentInfo for {0} ({1})", acc.Name, acc.PrincipalID); } userInfo["Flags"] = (agent == null) ? 0 : (int)agent.Flags; users.Add(userInfo); } resp["Users"] = users; resp["Start"] = OSD.FromInteger(start); resp["Count"] = OSD.FromInteger(count); resp["Query"] = OSD.FromString(Query); resp["Total"] = OSD.FromInteger((int)accountService.NumberOfUserAccounts(scopeID, Query)); } return resp; }
public RelayConsole(RadegastInstance instance) : base(instance) { InitializeComponent(); Disposed += RelayConsole_Disposed; textPrinter = new RichTextBoxPrinter(rtbChatText); // Get configuration settings, and initialize if not found. config = instance.GlobalSettings["plugin.irc"] as OSDMap; if (config == null) { config = new OSDMap(); config["server"] = new OSDString("irc.freenode.net"); config["port"] = new OSDInteger(6667); config["nick"] = new OSDString(string.Empty); config["channel"] = new OSDString("#"); config["send_delay"] = new OSDInteger(200); config["auto_reconnect"] = new OSDBoolean(true); config["ctcp_version"] = new OSDString("Radegast IRC"); instance.GlobalSettings["plugin.irc"] = config; } if (!config.ContainsKey("server")) { config["server"] = new OSDString("irc.freenode.net"); } if (!config.ContainsKey("port")) { config["port"] = new OSDInteger(6667); } if (!config.ContainsKey("nick")) { config["nick"] = new OSDString(instance.Client.Self.Name); } if (!config.ContainsKey("channel")) { config["channel"] = new OSDString("#"); } if (!config.ContainsKey("send_delay")) { config["send_delay"] = new OSDInteger(200); } if (!config.ContainsKey("auto_reconnect")) { config["auto_reconnect"] = new OSDBoolean(true); } if (!config.ContainsKey("ctcp_version")) { config["ctcp_version"] = new OSDString("Radegast IRC"); } txtChan.Text = config["channel"].AsString(); txtNick.Text = config["nick"].AsString(); txtPort.Text = config["port"].AsString(); txtServer.Text = config["server"].AsString(); irc = new IrcClient(); irc.SendDelay = config["send_delay"].AsInteger(); irc.AutoReconnect = config["auto_reconnect"].AsBoolean(); irc.CtcpVersion = config["ctcp_version"].AsString(); irc.Encoding = Encoding.UTF8; TC.OnTabAdded += TC_OnTabAdded; TC.OnTabRemoved += TC_OnTabRemoved; irc.OnError += irc_OnError; irc.OnRawMessage += irc_OnRawMessage; irc.OnChannelMessage += irc_OnChannelMessage; irc.OnConnected += irc_OnConnected; irc.OnDisconnected += irc_OnDisconnected; client.Self.IM += Self_IM; client.Self.ChatFromSimulator += Self_ChatFromSimulator; UpdateGui(); RefreshGroups(); }
private void txtChan_Validated(object sender, EventArgs e) { config["channel"] = new OSDString(txtChan.Text); }
private OSDMap RecentlyOnlineUsers(OSDMap map) { OSDMap resp = new OSDMap(); uint secondsAgo = map.ContainsKey("secondsAgo") ? uint.Parse(map["secondsAgo"]) : 0; bool stillOnline = map.ContainsKey("stillOnline") ? uint.Parse(map["stillOnline"]) == 1 : false; uint start = map.ContainsKey("Start") ? map["Start"].AsUInteger() : 0; uint count = map.ContainsKey("Count") ? map["Count"].AsUInteger() : 10; IAgentInfoConnector userInfoService = DataManager.DataManager.RequestPlugin<IAgentInfoConnector>(); if (userInfoService == null) { resp["Failed"] = new OSDString("Could not get IAgentInfoConnector"); } else { resp["Start"] = OSD.FromInteger((int)start); resp["Count"] = OSD.FromInteger((int)count); resp["Total"] = OSD.FromInteger((int)userInfoService.RecentlyOnline(secondsAgo, stillOnline)); OSDArray Users = new OSDArray(); Dictionary<string, bool> sort = new Dictionary<string, bool>(1); sort["LastSeen"] = true; List<UserInfo> users = userInfoService.RecentlyOnline(secondsAgo, stillOnline, sort, start, count); foreach (UserInfo userinfo in users) { Users.Add(UserInfo2InfoWebOSD(userinfo)); } resp["Users"] = Users; } return resp; }
private OSDMap ResetAvatar(OSDMap map) { OSDMap resp = new OSDMap(); UUID user = UUID.Zero; if (!map.ContainsKey("User")) { resp["Failed"] = new OSDString("User not specified."); } else if (!UUID.TryParse(map["User"].AsString(), out user)) { resp["Failed"] = new OSDString("User specified but was not valid UUID."); } else { IAvatarService avatarService = m_registry.RequestModuleInterface<IAvatarService>(); if (avatarService == null) { resp["Failed"] = new OSDString("Avatar service could not be fetched."); } else { resp["Success"] = new OSDBoolean(avatarService.ResetAvatar(user)); } } return resp; }
private OSDMap GetNewsSources(OSDMap map, UUID requestingAgentID) { OSDMap resp = new OSDMap(); uint start = map.ContainsKey("Start") ? map["Start"].AsUInteger() : 0; uint count = map.ContainsKey("Count") ? map["Count"].AsUInteger() : 10; IGenericsConnector generics = Aurora.DataManager.DataManager.RequestPlugin<IGenericsConnector>(); IGroupsServiceConnector groups = Aurora.DataManager.DataManager.RequestPlugin<IGroupsServiceConnector>(); if (generics == null) { resp["Failed"] = new OSDString("Could not find IGenericsConnector"); } else if (groups == null) { resp["Failed"] = new OSDString("Could not find IGroupsServiceConnector"); } else { OSDMap useValue = new OSDMap(); useValue["Use"] = OSD.FromBoolean(true); List<UUID> GroupIDs = generics.GetOwnersByGeneric("Group", "WebUI_newsSource", useValue); resp["Total"] = GroupIDs.Count; resp["Start"] = (int)start; resp["Count"] = (int)count; OSDArray Groups = new OSDArray(); if (start < GroupIDs.Count) { int end = (int)count; if (start + count > GroupIDs.Count) { end = GroupIDs.Count - (int)start; } List<UUID> page = GroupIDs.GetRange((int)start, end); if (page.Count > 0) { List<GroupRecord> reply = groups.GetGroupRecords(requestingAgentID, page); if (reply.Count > 0) { foreach (GroupRecord groupReply in reply) { Groups.Add(GroupRecord2OSDMap(groupReply)); } } } } resp["Groups"] = Groups; } return resp; }
private OSDMap GetRegionsByXY(OSDMap map) { OSDMap resp = new OSDMap(); if (!map.ContainsKey("X") || !map.ContainsKey("Y")) { resp["Failed"] = new OSDString("X and Y coordinates not specified"); } else { int x = map["X"].AsInteger(); int y = map["Y"].AsInteger(); UUID scope = map.ContainsKey("ScopeID") ? UUID.Parse(map["ScopeID"].AsString()) : UUID.Zero; RegionFlags include = map.Keys.Contains("RegionFlags") ? (RegionFlags)map["RegionFlags"].AsInteger() : RegionFlags.RegionOnline; RegionFlags? exclude = null; if (map.Keys.Contains("ExcludeRegionFlags")) { exclude = (RegionFlags)map["ExcludeRegionFlags"].AsInteger(); } IRegionData regiondata = Aurora.DataManager.DataManager.RequestPlugin<IRegionData>(); if (regiondata == null) { resp["Failed"] = new OSDString("Could not get IRegionData plugin"); } else { List<GridRegion> regions = regiondata.Get(x, y, scope); OSDArray Regions = new OSDArray(); foreach (GridRegion region in regions) { if (((int)region.Flags & (int)include) == (int)include && (!exclude.HasValue || ((int)region.Flags & (int)exclude.Value) != (int)exclude)) { Regions.Add(GridRegion2WebOSD(region)); } } resp["Total"] = Regions.Count; resp["Regions"] = Regions; } } return resp; }
// ----------------------------------------------------------------- /// <summary> /// /// </summary> // ----------------------------------------------------------------- public bool SetValue(string expr, string value, bool useJson) { OSD ovalue; // One note of caution... if you use an empty string in the // structure it will be assumed to be a default value and will // not be seialized in the json if (useJson) { // There doesn't appear to be a good way to determine if the // value is valid Json other than to let the parser crash try { ovalue = OSDParser.DeserializeJson(value); } catch (Exception) { if (value.StartsWith("'") && value.EndsWith("'")) { ovalue = new OSDString(value.Substring(1,value.Length - 2)); } else { return false; } } } else { ovalue = new OSDString(value); } return SetValueFromExpression(expr,ovalue); }
private void txtNick_Validated(object sender, EventArgs e) { config["nick"] = new OSDString(txtNick.Text); }
private void txtServer_Validated(object sender, EventArgs e) { config["server"] = new OSDString(txtServer.Text); }
public static OSD ChatterBoxSessionAgentListUpdates(UUID sessionID, UUID agentID, bool canVoiceChat, bool isModerator, bool textMute, byte dialog) { OSDMap mutes = new OSDMap(1); mutes.Add("text", OSD.FromBoolean(textMute)); OSDMap infoDetail = new OSDMap(3); infoDetail.Add("can_voice_chat", OSD.FromBoolean(canVoiceChat)); infoDetail.Add("is_moderator", OSD.FromBoolean(isModerator)); infoDetail.Add("mutes", mutes); OSD transition; switch (dialog) { case (byte)InstantMessageDialog.SessionGroupStart: transition = new OSDString("ENTER"); break; case (byte)InstantMessageDialog.SessionDrop: transition = new OSDString("LEAVE"); break; default: transition = null; break; } OSDMap agentInfo = new OSDMap(); agentInfo.Add("info", infoDetail); if (transition != null) { agentInfo.Add("transition", transition); } OSDMap agentDetail = new OSDMap(1); agentDetail.Add(agentID.ToString(), agentInfo); OSDMap updatesDetail = new OSDMap(1); if (transition == null) { updatesDetail.Add(agentID.ToString(), new OSD()); } else { updatesDetail.Add(agentID.ToString(), transition); } OSDMap body = new OSDMap(3); body.Add("agent_updates", agentDetail); body.Add("session_id", OSD.FromUUID(sessionID)); body.Add("updates", updatesDetail); OSDMap chatterBoxSessionAgentListUpdates = new OSDMap(); chatterBoxSessionAgentListUpdates.Add("message", OSD.FromString("ChatterBoxSessionAgentListUpdates")); chatterBoxSessionAgentListUpdates.Add("body", body); return(chatterBoxSessionAgentListUpdates); }
private OSDMap GetProfile(OSDMap map) { OSDMap resp = new OSDMap(); string Name = map["Name"].AsString(); UUID userID = map["UUID"].AsUUID(); IUserAccountService accountService = m_registry.RequestModuleInterface<IUserAccountService>(); if (accountService == null) { resp["Failed"] = new OSDString("Could not find IUserAccountService"); return resp; } UserAccount account = Name != "" ? accountService.GetUserAccount(UUID.Zero, Name) : accountService.GetUserAccount(UUID.Zero, userID); if (account != null) { OSDMap accountMap = new OSDMap(); accountMap["Created"] = account.Created; accountMap["Name"] = account.Name; accountMap["PrincipalID"] = account.PrincipalID; accountMap["Email"] = account.Email; accountMap["UserLevel"] = account.UserLevel; accountMap["UserFlags"] = account.UserFlags; TimeSpan diff = DateTime.Now - Util.ToDateTime(account.Created); int years = (int)diff.TotalDays / 356; int days = years > 0 ? (int)diff.TotalDays / years : (int)diff.TotalDays; accountMap["TimeSinceCreated"] = years + " years, " + days + " days"; // if we're sending account.Created do we really need to send this string ? IProfileConnector profileConnector = Aurora.DataManager.DataManager.RequestPlugin<IProfileConnector>(); IUserProfileInfo profile = profileConnector.GetUserProfile(account.PrincipalID); if (profile != null) { resp["profile"] = profile.ToOSD(false);//not trusted, use false if (account.UserFlags == 0) { account.UserFlags = 2; //Set them to no info given } string flags = ((IUserProfileInfo.ProfileFlags)account.UserFlags).ToString(); IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile.ToString(); accountMap["AccountInfo"] = (profile.CustomType != "" ? profile.CustomType : account.UserFlags == 0 ? "Resident" : "Admin") + "\n" + flags; UserAccount partnerAccount = m_registry.RequestModuleInterface<IUserAccountService>().GetUserAccount(UUID.Zero, profile.Partner); if (partnerAccount != null) { accountMap["Partner"] = partnerAccount.Name; accountMap["PartnerUUID"] = partnerAccount.PrincipalID; } else { accountMap["Partner"] = ""; accountMap["PartnerUUID"] = UUID.Zero; } } IAgentConnector agentConnector = Aurora.DataManager.DataManager.RequestPlugin<IAgentConnector>(); IAgentInfo agent = agentConnector.GetAgent(account.PrincipalID); if (agent != null) { OSDMap agentMap = new OSDMap(); agentMap["Flags"] = (int)agent.Flags; agentMap["RLName"] = agent.OtherAgentInformation["RLName"].AsString(); agentMap["RLAddress"] = agent.OtherAgentInformation["RLAddress"].AsString(); agentMap["RLZip"] = agent.OtherAgentInformation["RLZip"].AsString(); agentMap["RLCity"] = agent.OtherAgentInformation["RLCity"].AsString(); agentMap["RLCountry"] = agent.OtherAgentInformation["RLCountry"].AsString(); resp["agent"] = agentMap; } resp["account"] = accountMap; } return resp; }
public void DeserializeLLSDSample() { OSD theSD = null; OSDMap map = null; OSD tempSD = null; OSDUUID tempUUID = null; OSDString tempStr = null; OSDReal tempReal = null; String testSD = @"<?xml version='1.0' encoding='UTF-8'?> <llsd> <map> <key>region_id</key> <uuid>67153d5b-3659-afb4-8510-adda2c034649</uuid> <key>scale</key> <string>one minute</string> <key>simulator statistics</key> <map> <key>time dilation</key> <real>0.9878624</real> <key>sim fps</key> <real>44.38898</real> <key>agent updates per second</key> <real>nan</real> <key>total task count</key> <real>4</real> <key>active task count</key> <real>0</real> <key>pending uploads</key> <real>0.0001096525</real> </map> </map> </llsd>"; //Deserialize the string byte[] bytes = Encoding.UTF8.GetBytes(testSD); theSD = OSDParser.DeserializeLLSDXml(bytes); //Confirm the contents Assert.IsNotNull(theSD); Assert.IsTrue(theSD is OSDMap); Assert.IsTrue(theSD.Type == OSDType.Map); map = (OSDMap)theSD; tempSD = map["region_id"]; Assert.IsNotNull(tempSD); Assert.IsTrue(tempSD is OSDUUID); Assert.IsTrue(tempSD.Type == OSDType.UUID); tempUUID = (OSDUUID)tempSD; Assert.AreEqual(new UUID("67153d5b-3659-afb4-8510-adda2c034649"), tempUUID.AsUUID()); tempSD = map["scale"]; Assert.IsNotNull(tempSD); Assert.IsTrue(tempSD is OSDString); Assert.IsTrue(tempSD.Type == OSDType.String); tempStr = (OSDString)tempSD; Assert.AreEqual("one minute", tempStr.AsString()); tempSD = map["simulator statistics"]; Assert.IsNotNull(tempSD); Assert.IsTrue(tempSD is OSDMap); Assert.IsTrue(tempSD.Type == OSDType.Map); map = (OSDMap)tempSD; tempSD = map["time dilation"]; Assert.IsNotNull(tempSD); Assert.IsTrue(tempSD is OSDReal); Assert.IsTrue(tempSD.Type == OSDType.Real); tempReal = (OSDReal)tempSD; Assert.AreEqual(0.9878624d, tempReal.AsReal()); //TODO - figure out any relevant rounding variability for 64 bit reals tempSD = map["sim fps"]; Assert.IsNotNull(tempSD); Assert.IsTrue(tempSD is OSDReal); Assert.IsTrue(tempSD.Type == OSDType.Real); tempReal = (OSDReal)tempSD; Assert.AreEqual(44.38898d, tempReal.AsReal()); tempSD = map["agent updates per second"]; Assert.IsNotNull(tempSD); Assert.IsTrue(tempSD is OSDReal); Assert.IsTrue(tempSD.Type == OSDType.Real); tempReal = (OSDReal)tempSD; Assert.AreEqual(Double.NaN, tempSD.AsReal()); tempSD = map["total task count"]; Assert.IsNotNull(tempSD); Assert.IsTrue(tempSD is OSDReal); Assert.IsTrue(tempSD.Type == OSDType.Real); tempReal = (OSDReal)tempSD; Assert.AreEqual(4.0d, tempReal.AsReal()); tempSD = map["active task count"]; Assert.IsNotNull(tempSD); Assert.IsTrue(tempSD is OSDReal); Assert.IsTrue(tempSD.Type == OSDType.Real); tempReal = (OSDReal)tempSD; Assert.AreEqual(0.0d, tempReal.AsReal()); tempSD = map["pending uploads"]; Assert.IsNotNull(tempSD); Assert.IsTrue(tempSD is OSDReal); Assert.IsTrue(tempSD.Type == OSDType.Real); tempReal = (OSDReal)tempSD; Assert.AreEqual(0.0001096525d, tempReal.AsReal()); }
private OSDMap GetRegionsInArea(OSDMap map) { OSDMap resp = new OSDMap(); if (!map.ContainsKey("StartX") || !map.ContainsKey("StartY") || !map.ContainsKey("EndX") || !map.ContainsKey("EndY")) { resp["Failed"] = new OSDString("Start and End x/y coordinates must be specified"); } else { int StartX = map["StartX"].AsInteger(); int StartY = map["StartY"].AsInteger(); int EndX = map["EndX"].AsInteger(); int EndY = map["EndY"].AsInteger(); UUID scope = UUID.Zero; if (map.ContainsKey("ScopeID") && !UUID.TryParse(map["ScopeID"].AsString(), out scope)) { resp["Failed"] = new OSDString("ScopeID was specified but was not valid."); return resp; } IRegionData regiondata = Aurora.DataManager.DataManager.RequestPlugin<IRegionData>(); if (regiondata == null) { resp["Failed"] = new OSDString("Could not get IRegionData plugin"); } else { List<GridRegion> regions = regiondata.Get(StartX, StartY, EndX, EndY, scope); OSDArray Regions = new OSDArray(); foreach (GridRegion region in regions) { Regions.Add(GridRegion2WebOSD(region)); } resp["Total"] = Regions.Count; resp["Regions"] = Regions; } } return resp; }
private OSDMap RemoveGroupNotice(OSDMap map, UUID requestingAgentID) { OSDMap resp = new OSDMap(); if (!map.ContainsKey("GroupID") || !map.ContainsKey("NoticeID")) { resp["Failed"] = new OSDString("Missing required arguments one or more of GroupID, NoticeID"); } else { UUID GroupID = UUID.Zero; UUID.TryParse(map["GroupID"].ToString(), out GroupID); UUID noticeID = UUID.Zero; UUID.TryParse(map["NoticeID"].ToString(), out noticeID); IGroupsServiceConnector groups = Aurora.DataManager.DataManager.RequestPlugin<IGroupsServiceConnector>(); if (GroupID == UUID.Zero) { resp["Failed"] = new OSDString("GroupID was UUID.Zero"); } else if (noticeID == UUID.Zero) { resp["Failed"] = new OSDString("NoticeID was UUID.Zero"); } else if (groups == null) { resp["Failed"] = new OSDString("Could not findIGroupsServiceConnector"); } else { try { resp["Success"] = groups.RemoveGroupNotice(requestingAgentID, GroupID, noticeID); } catch { resp["Failed"] = new OSDString("An exception was thrown."); } } } return resp; }
public static OSD ChatterBoxSessionAgentListUpdates(UUID sessionID, UUID agentID, bool canVoiceChat, bool isModerator, bool textMute, byte dialog) { OSDMap mutes = new OSDMap(1); mutes.Add("text", OSD.FromBoolean(textMute)); OSDMap infoDetail = new OSDMap(3); infoDetail.Add("can_voice_chat", OSD.FromBoolean(canVoiceChat)); infoDetail.Add("is_moderator", OSD.FromBoolean(isModerator)); infoDetail.Add("mutes", mutes); OSD transition; switch (dialog) { case (byte)InstantMessageDialog.SessionGroupStart: transition = new OSDString("ENTER"); break; case (byte)InstantMessageDialog.SessionDrop: transition = new OSDString("LEAVE"); break; default: transition = null; break; } OSDMap agentInfo = new OSDMap(); agentInfo.Add("info", infoDetail); if (transition != null) agentInfo.Add("transition", transition); OSDMap agentDetail = new OSDMap(1); agentDetail.Add(agentID.ToString(), agentInfo); OSDMap updatesDetail = new OSDMap(1); if (transition == null) updatesDetail.Add(agentID.ToString(), new OSD()); else updatesDetail.Add(agentID.ToString(), transition); OSDMap body = new OSDMap(3); body.Add("agent_updates", agentDetail); body.Add("session_id", OSD.FromUUID(sessionID)); body.Add("updates", updatesDetail); OSDMap chatterBoxSessionAgentListUpdates = new OSDMap(); chatterBoxSessionAgentListUpdates.Add("message", OSD.FromString("ChatterBoxSessionAgentListUpdates")); chatterBoxSessionAgentListUpdates.Add("body", body); return chatterBoxSessionAgentListUpdates; }
private OSDMap SetHomeLocation(OSDMap map) { OSDMap resp = new OSDMap(); IAgentInfoService agentService = m_registry.RequestModuleInterface<IAgentInfoService>(); IGridService gridService = m_registry.RequestModuleInterface<IGridService>(); UserInfo userinfo = (map.ContainsKey("User") && agentService != null) ? agentService.GetUserInfo(map["User"].AsString()) : null; if (!map.ContainsKey("User")) { resp["Failed"] = new OSDString("No user specified"); } else if (!map.ContainsKey("RegionID") && !map.ContainsKey("Position") && !map.ContainsKey("LookAt")) { resp["Failed"] = new OSDString("No position info specified"); } else if (agentService == null) { resp["Failed"] = new OSDString("Could not get IAgentInfoService"); } else if (gridService == null) { resp["Failed"] = new OSDString("Could not get IGridService"); } else if (userinfo == null) { resp["Failed"] = new OSDString("Could not find user"); } else { UUID scopeID = UUID.Zero; UUID regionID = UUID.Zero; Vector3 position = Vector3.Zero; Vector3 lookAt = Vector3.Zero; List<string> fail = new List<string>(); if (map.ContainsKey("ScopeID") && !UUID.TryParse(map["ScopeID"].AsString(), out scopeID)) { fail.Add("ScopeID was specified but was not a valid UUID"); } if (map.ContainsKey("RegionID") && !UUID.TryParse(map["RegionID"].AsString(), out regionID)) { fail.Add("RegionID was specified but was not valid UUID"); } if (map.ContainsKey("Position") && !Vector3.TryParse(map["Position"].AsString(), out position)) { fail.Add("Position was specified but was not valid Vector3"); } if (map.ContainsKey("LookAt") && !Vector3.TryParse(map["LookAt"].AsString(), out lookAt)) { fail.Add("LookAt was specified but was not valid Vector3"); } if (regionID == UUID.Zero) { regionID = userinfo.HomeRegionID; } if (gridService.GetRegionByUUID(UUID.Zero, regionID) == null) { fail.Add("region does not exist"); } if (regionID == UUID.Zero && (map.ContainsKey("Position") || map.ContainsKey("LookAt"))) { fail.Add("Cannot change home location without specifying a region"); } if (fail.Count > 0) { resp["Failed"] = new OSDString(string.Join(". ", fail.ToArray())); return resp; } userinfo.HomeRegionID = regionID; if (map.ContainsKey("Position")) { userinfo.HomePosition = position; } if (map.ContainsKey("LookAt")) { userinfo.HomeLookAt = lookAt; } resp["Success"] = new OSDBoolean(agentService.SetHomePosition(userinfo.UserID, userinfo.HomeRegionID, userinfo.HomePosition, userinfo.HomeLookAt)); } return resp; }
private OSDMap AddGroupNotice(OSDMap map) { OSDMap resp = new OSDMap(); if (!map.ContainsKey("GroupID") || !map.ContainsKey("AuthorID") || !map.ContainsKey("Subject") || !map.ContainsKey("Message")) { resp["Failed"] = new OSDString("Missing required arguments one or more of GroupID, AuthorID, Subject, Message"); } else { UUID GroupID = UUID.Zero; UUID.TryParse(map["GroupID"].ToString(), out GroupID); UUID AuthorID = UUID.Zero; UUID.TryParse(map["AuthorID"].ToString(), out AuthorID); string subject = map["Subject"].ToString().Trim(); string message = map["Message"].ToString().Trim(); IGroupsServiceConnector groups = Aurora.DataManager.DataManager.RequestPlugin<IGroupsServiceConnector>(); IUserAccountService users = m_registry.RequestModuleInterface<IUserAccountService>(); UserAccount Author = AuthorID != UUID.Zero && users != null ? users.GetUserAccount(UUID.Zero, AuthorID) : null; if (GroupID == UUID.Zero) { resp["Failed"] = new OSDString("GroupID was UUID.Zero"); } else if (AuthorID == UUID.Zero) { resp["Failed"] = new OSDString("AuthorID was UUID.Zero"); } else if (subject == string.Empty) { resp["Failed"] = new OSDString("Subject was empty"); } else if (message == string.Empty) { resp["Failed"] = new OSDString("Message was empty"); } else if (groups == null) { resp["Failed"] = new OSDString("Could not findIGroupsServiceConnector"); } else if (users == null) { resp["Failed"] = new OSDString("Could not find IUserAccountService"); } else if (Author == null) { resp["Failed"] = new OSDString(string.Format("Could not find author with ID {0}", AuthorID)); } else { UUID noticeID = UUID.Random(); try { groups.AddGroupNotice(AuthorID, GroupID, noticeID, Author.Name, subject, message, UUID.Zero, 0, ""); resp["NoticeID"] = noticeID; } catch { resp["Failed"] = new OSDString("An exception was thrown."); } } } return resp; }
private OSDMap EditGroupNotice(OSDMap map, UUID requestingAgentID) { OSDMap resp = new OSDMap(); UUID noticeID = map.ContainsKey("NoticeID") ? UUID.Parse(map["NoticeID"]) : UUID.Zero; IGroupsServiceConnector groups = Aurora.DataManager.DataManager.RequestPlugin<IGroupsServiceConnector>(); GroupNoticeData GND = noticeID != UUID.Zero && groups != null ? groups.GetGroupNoticeData(requestingAgentID, noticeID) : null; GroupNoticeInfo notice = GND != null ? groups.GetGroupNotice(requestingAgentID, GND.NoticeID) : null; if (noticeID == UUID.Zero) { resp["Failed"] = new OSDString("No notice ID was specified"); } else if (groups == null) { resp["Failed"] = new OSDString("Could not find IGroupsServiceConnector"); } else if (GND == null || notice == null) { resp["Failed"] = new OSDString("Could not find group notice with specified ID"); } else if (!map.ContainsKey("Subject") && !map.ContainsKey("Message")) { resp["Success"] = new OSDBoolean(false); resp["Note"] = new OSDString("No changes were made to the group notice"); } else { resp["Success"] = groups.EditGroupNotice(requestingAgentID, notice.GroupID, GND.NoticeID, map.ContainsKey("Subject") ? map["Subject"].ToString() : GND.Subject, map.ContainsKey("Message") ? map["Message"].ToString() : notice.Message); } return resp; }