From 9ed9720861ef3b63b1fca75c843a509ee3239b17 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Tue, 17 Jan 2012 22:07:40 -0500 Subject: Update osGetGrid**** functions The osGetGrid**** functions will now get the grid settings from the GridInfoService. Set the GridInfoURI in your ./bin/config-include/GridCommon.ini [GridInfo] section. --- .../Shared/Api/Implementation/OSSL_Api.cs | 72 +++++++++++++++++++++- 1 file changed, 69 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index fc478ab..c7a62b3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1944,6 +1944,54 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + private enum InfoType + { + Nick, + Name, + Login + }; + + private string GridUserInfo(InfoType type) + { + string retval = String.Empty; + IConfigSource config = m_ScriptEngine.ConfigSource; + string url = config.Configs["GridInfo"].GetString("GridInfoURI", String.Empty); + + if (String.IsNullOrEmpty(url)) + return "Configuration Error!"; + + string verb ="/json_grid_info"; + OSDMap json = new OSDMap(); + + OSDMap info = WebUtil.GetFromService(String.Format("{0}{1}",url,verb), 3000); + + if (info["Success"] != true) + return "Get GridInfo Failed!"; + + json = (OSDMap)OSDParser.DeserializeJson(info["_RawResult"].AsString()); + + switch (type) + { + case InfoType.Nick: + retval = json["gridnick"]; + break; + + case InfoType.Name: + retval = json["gridname"]; + break; + + case InfoType.Login: + retval = json["login"]; + break; + + default: + retval = "error"; + break; + } + + return retval; + } + /// /// Get the nickname of this grid, as set in the [GridInfo] config section. /// @@ -1957,10 +2005,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); m_host.AddScriptLPS(1); - string nick = "hippogrid"; + + string nick = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; + if (config.Configs["GridInfo"] != null) nick = config.Configs["GridInfo"].GetString("gridnick", nick); + + if (String.IsNullOrEmpty(nick)) + nick = GridUserInfo(InfoType.Nick); + return nick; } @@ -1968,10 +2022,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.Moderate, "osGetGridName"); m_host.AddScriptLPS(1); - string name = "the lost continent of hippo"; + + string name = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; + if (config.Configs["GridInfo"] != null) name = config.Configs["GridInfo"].GetString("gridname", name); + + if (String.IsNullOrEmpty(name)) + name = GridUserInfo(InfoType.Name); + return name; } @@ -1979,10 +2039,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.Moderate, "osGetGridLoginURI"); m_host.AddScriptLPS(1); - string loginURI = "http://127.0.0.1:9000/"; + + string loginURI = String.Empty; IConfigSource config = m_ScriptEngine.ConfigSource; + if (config.Configs["GridInfo"] != null) loginURI = config.Configs["GridInfo"].GetString("login", loginURI); + + if (String.IsNullOrEmpty(loginURI)) + loginURI = GridUserInfo(InfoType.Login); + return loginURI; } -- cgit v1.1