diff options
author | BlueWall | 2012-01-17 22:10:47 -0500 |
---|---|---|
committer | BlueWall | 2012-01-17 22:10:47 -0500 |
commit | 717656c453843a77dfef6d183565ab55e94e68fc (patch) | |
tree | 20faf85730869b675b5e688ee333a89806b67fb8 | |
parent | Change linux, windows and mac ODE libraries to use the GIMPACT collider rathe... (diff) | |
parent | Update osGetGrid**** functions (diff) | |
download | opensim-SC_OLD-717656c453843a77dfef6d183565ab55e94e68fc.zip opensim-SC_OLD-717656c453843a77dfef6d183565ab55e94e68fc.tar.gz opensim-SC_OLD-717656c453843a77dfef6d183565ab55e94e68fc.tar.bz2 opensim-SC_OLD-717656c453843a77dfef6d183565ab55e94e68fc.tar.xz |
Merge branch 'master' of /home/opensim/src/opensim
4 files changed, 92 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 | ||
diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs index 645a77f..bfcddca 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | |||
@@ -37,6 +37,7 @@ using Nini.Config; | |||
37 | using Nwc.XmlRpc; | 37 | using Nwc.XmlRpc; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Servers.HttpServer; | 39 | using OpenSim.Framework.Servers.HttpServer; |
40 | using OpenMetaverse.StructuredData; | ||
40 | 41 | ||
41 | namespace OpenSim.Server.Handlers.Grid | 42 | namespace OpenSim.Server.Handlers.Grid |
42 | { | 43 | { |
@@ -142,5 +143,19 @@ namespace OpenSim.Server.Handlers.Grid | |||
142 | 143 | ||
143 | return sb.ToString(); | 144 | return sb.ToString(); |
144 | } | 145 | } |
146 | |||
147 | public string JsonGetGridInfoMethod(string request, string path, string param, | ||
148 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
149 | { | ||
150 | |||
151 | OSDMap map = new OSDMap(); | ||
152 | |||
153 | foreach (string k in _info.Keys) | ||
154 | { | ||
155 | map[k] = OSD.FromString(_info[k].ToString()); | ||
156 | } | ||
157 | |||
158 | return OSDParser.SerializeJsonString(map).ToString(); | ||
159 | } | ||
145 | } | 160 | } |
146 | } | 161 | } |
diff --git a/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs b/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs index 8472d34..f9b5915 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoServerInConnector.cs | |||
@@ -48,6 +48,8 @@ namespace OpenSim.Server.Handlers.Grid | |||
48 | 48 | ||
49 | server.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", | 49 | server.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", |
50 | handlers.RestGetGridInfoMethod)); | 50 | handlers.RestGetGridInfoMethod)); |
51 | server.AddStreamHandler(new RestStreamHandler("GET", "/json_grid_info", | ||
52 | handlers.JsonGetGridInfoMethod)); | ||
51 | server.AddXmlRPCHandler("get_grid_info", handlers.XmlRpcGridInfoMethod); | 53 | server.AddXmlRPCHandler("get_grid_info", handlers.XmlRpcGridInfoMethod); |
52 | } | 54 | } |
53 | 55 | ||
diff --git a/bin/config-include/GridCommon.ini.example b/bin/config-include/GridCommon.ini.example index 815e08c..d70c8e4 100644 --- a/bin/config-include/GridCommon.ini.example +++ b/bin/config-include/GridCommon.ini.example | |||
@@ -58,6 +58,12 @@ | |||
58 | ; | 58 | ; |
59 | InventoryServerURI = "http://mygridserver.com:8003" | 59 | InventoryServerURI = "http://mygridserver.com:8003" |
60 | 60 | ||
61 | [GridInfo] | ||
62 | ; | ||
63 | ; Change this to your grid info service | ||
64 | ; | ||
65 | GridInfoURI = "http://mygridserver.com:8002" | ||
66 | |||
61 | [GridService] | 67 | [GridService] |
62 | ; | 68 | ; |
63 | ; Change this to your grid-wide grid server | 69 | ; Change this to your grid-wide grid server |