aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorBlueWall2012-01-17 22:07:40 -0500
committerBlueWall2012-01-17 22:07:40 -0500
commit9ed9720861ef3b63b1fca75c843a509ee3239b17 (patch)
tree65a20496d05bdc4f3be958033c0b07c646463022 /OpenSim/Region
parentMerge branch 'master' of /home/opensim/lib/osgrid/opensim (diff)
downloadopensim-SC_OLD-9ed9720861ef3b63b1fca75c843a509ee3239b17.zip
opensim-SC_OLD-9ed9720861ef3b63b1fca75c843a509ee3239b17.tar.gz
opensim-SC_OLD-9ed9720861ef3b63b1fca75c843a509ee3239b17.tar.bz2
opensim-SC_OLD-9ed9720861ef3b63b1fca75c843a509ee3239b17.tar.xz
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.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs72
1 files changed, 69 insertions, 3 deletions
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
1944 } 1944 }
1945 } 1945 }
1946 1946
1947 private enum InfoType
1948 {
1949 Nick,
1950 Name,
1951 Login
1952 };
1953
1954 private string GridUserInfo(InfoType type)
1955 {
1956 string retval = String.Empty;
1957 IConfigSource config = m_ScriptEngine.ConfigSource;
1958 string url = config.Configs["GridInfo"].GetString("GridInfoURI", String.Empty);
1959
1960 if (String.IsNullOrEmpty(url))
1961 return "Configuration Error!";
1962
1963 string verb ="/json_grid_info";
1964 OSDMap json = new OSDMap();
1965
1966 OSDMap info = WebUtil.GetFromService(String.Format("{0}{1}",url,verb), 3000);
1967
1968 if (info["Success"] != true)
1969 return "Get GridInfo Failed!";
1970
1971 json = (OSDMap)OSDParser.DeserializeJson(info["_RawResult"].AsString());
1972
1973 switch (type)
1974 {
1975 case InfoType.Nick:
1976 retval = json["gridnick"];
1977 break;
1978
1979 case InfoType.Name:
1980 retval = json["gridname"];
1981 break;
1982
1983 case InfoType.Login:
1984 retval = json["login"];
1985 break;
1986
1987 default:
1988 retval = "error";
1989 break;
1990 }
1991
1992 return retval;
1993 }
1994
1947 /// <summary> 1995 /// <summary>
1948 /// Get the nickname of this grid, as set in the [GridInfo] config section. 1996 /// Get the nickname of this grid, as set in the [GridInfo] config section.
1949 /// </summary> 1997 /// </summary>
@@ -1957,10 +2005,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1957 { 2005 {
1958 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); 2006 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick");
1959 m_host.AddScriptLPS(1); 2007 m_host.AddScriptLPS(1);
1960 string nick = "hippogrid"; 2008
2009 string nick = String.Empty;
1961 IConfigSource config = m_ScriptEngine.ConfigSource; 2010 IConfigSource config = m_ScriptEngine.ConfigSource;
2011
1962 if (config.Configs["GridInfo"] != null) 2012 if (config.Configs["GridInfo"] != null)
1963 nick = config.Configs["GridInfo"].GetString("gridnick", nick); 2013 nick = config.Configs["GridInfo"].GetString("gridnick", nick);
2014
2015 if (String.IsNullOrEmpty(nick))
2016 nick = GridUserInfo(InfoType.Nick);
2017
1964 return nick; 2018 return nick;
1965 } 2019 }
1966 2020
@@ -1968,10 +2022,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1968 { 2022 {
1969 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridName"); 2023 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridName");
1970 m_host.AddScriptLPS(1); 2024 m_host.AddScriptLPS(1);
1971 string name = "the lost continent of hippo"; 2025
2026 string name = String.Empty;
1972 IConfigSource config = m_ScriptEngine.ConfigSource; 2027 IConfigSource config = m_ScriptEngine.ConfigSource;
2028
1973 if (config.Configs["GridInfo"] != null) 2029 if (config.Configs["GridInfo"] != null)
1974 name = config.Configs["GridInfo"].GetString("gridname", name); 2030 name = config.Configs["GridInfo"].GetString("gridname", name);
2031
2032 if (String.IsNullOrEmpty(name))
2033 name = GridUserInfo(InfoType.Name);
2034
1975 return name; 2035 return name;
1976 } 2036 }
1977 2037
@@ -1979,10 +2039,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1979 { 2039 {
1980 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridLoginURI"); 2040 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridLoginURI");
1981 m_host.AddScriptLPS(1); 2041 m_host.AddScriptLPS(1);
1982 string loginURI = "http://127.0.0.1:9000/"; 2042
2043 string loginURI = String.Empty;
1983 IConfigSource config = m_ScriptEngine.ConfigSource; 2044 IConfigSource config = m_ScriptEngine.ConfigSource;
2045
1984 if (config.Configs["GridInfo"] != null) 2046 if (config.Configs["GridInfo"] != null)
1985 loginURI = config.Configs["GridInfo"].GetString("login", loginURI); 2047 loginURI = config.Configs["GridInfo"].GetString("login", loginURI);
2048
2049 if (String.IsNullOrEmpty(loginURI))
2050 loginURI = GridUserInfo(InfoType.Login);
2051
1986 return loginURI; 2052 return loginURI;
1987 } 2053 }
1988 2054