Merge branch 'master' of /home/opensim/src/opensim

iar_mods
BlueWall 2012-01-17 22:10:47 -05:00
commit 717656c453
4 changed files with 92 additions and 3 deletions

View File

@ -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;
}
/// <summary>
/// Get the nickname of this grid, as set in the [GridInfo] config section.
/// </summary>
@ -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;
}

View File

@ -37,6 +37,7 @@ using Nini.Config;
using Nwc.XmlRpc;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenMetaverse.StructuredData;
namespace OpenSim.Server.Handlers.Grid
{
@ -142,5 +143,19 @@ namespace OpenSim.Server.Handlers.Grid
return sb.ToString();
}
public string JsonGetGridInfoMethod(string request, string path, string param,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
OSDMap map = new OSDMap();
foreach (string k in _info.Keys)
{
map[k] = OSD.FromString(_info[k].ToString());
}
return OSDParser.SerializeJsonString(map).ToString();
}
}
}

View File

@ -48,6 +48,8 @@ namespace OpenSim.Server.Handlers.Grid
server.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info",
handlers.RestGetGridInfoMethod));
server.AddStreamHandler(new RestStreamHandler("GET", "/json_grid_info",
handlers.JsonGetGridInfoMethod));
server.AddXmlRPCHandler("get_grid_info", handlers.XmlRpcGridInfoMethod);
}

View File

@ -58,6 +58,12 @@
;
InventoryServerURI = "http://mygridserver.com:8003"
[GridInfo]
;
; Change this to your grid info service
;
GridInfoURI = "http://mygridserver.com:8002"
[GridService]
;
; Change this to your grid-wide grid server