aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
authorMelanie2012-01-21 19:52:33 +0000
committerMelanie2012-01-21 19:52:33 +0000
commitba3b0c69f11aaa3b4305cddd57099e98325a146d (patch)
treecf70355a8cac0579354e67eeb3632a6706d41012 /OpenSim/Region/ScriptEngine/Shared
parentAdd some logging (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-ba3b0c69f11aaa3b4305cddd57099e98325a146d.zip
opensim-SC_OLD-ba3b0c69f11aaa3b4305cddd57099e98325a146d.tar.gz
opensim-SC_OLD-ba3b0c69f11aaa3b4305cddd57099e98325a146d.tar.bz2
opensim-SC_OLD-ba3b0c69f11aaa3b4305cddd57099e98325a146d.tar.xz
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs121
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs10
3 files changed, 130 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 37792ef..4831377 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1953,6 +1953,69 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1953 } 1953 }
1954 } 1954 }
1955 1955
1956 private enum InfoType
1957 {
1958 Nick,
1959 Name,
1960 Login,
1961 Home,
1962 Custom
1963 };
1964
1965 private string GridUserInfo(InfoType type)
1966 {
1967 return GridUserInfo(type, "");
1968 }
1969
1970 private string GridUserInfo(InfoType type, string key)
1971 {
1972 string retval = String.Empty;
1973 IConfigSource config = m_ScriptEngine.ConfigSource;
1974 string url = config.Configs["GridInfo"].GetString("GridInfoURI", String.Empty);
1975
1976 if (String.IsNullOrEmpty(url))
1977 return "Configuration Error!";
1978
1979 string verb ="/json_grid_info";
1980 OSDMap json = new OSDMap();
1981
1982 OSDMap info = WebUtil.GetFromService(String.Format("{0}{1}",url,verb), 3000);
1983
1984 if (info["Success"] != true)
1985 return "Get GridInfo Failed!";
1986
1987 json = (OSDMap)OSDParser.DeserializeJson(info["_RawResult"].AsString());
1988
1989 switch (type)
1990 {
1991 case InfoType.Nick:
1992 retval = json["gridnick"];
1993 break;
1994
1995 case InfoType.Name:
1996 retval = json["gridname"];
1997 break;
1998
1999 case InfoType.Login:
2000 retval = json["login"];
2001 break;
2002
2003 case InfoType.Home:
2004 retval = json["home"];
2005 break;
2006
2007 case InfoType.Custom:
2008 retval = json[key];
2009 break;
2010
2011 default:
2012 retval = "error";
2013 break;
2014 }
2015
2016 return retval;
2017 }
2018
1956 /// <summary> 2019 /// <summary>
1957 /// Get the nickname of this grid, as set in the [GridInfo] config section. 2020 /// Get the nickname of this grid, as set in the [GridInfo] config section.
1958 /// </summary> 2021 /// </summary>
@@ -1966,10 +2029,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1966 { 2029 {
1967 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); 2030 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick");
1968 m_host.AddScriptLPS(1); 2031 m_host.AddScriptLPS(1);
1969 string nick = "hippogrid"; 2032
2033 string nick = String.Empty;
1970 IConfigSource config = m_ScriptEngine.ConfigSource; 2034 IConfigSource config = m_ScriptEngine.ConfigSource;
2035
1971 if (config.Configs["GridInfo"] != null) 2036 if (config.Configs["GridInfo"] != null)
1972 nick = config.Configs["GridInfo"].GetString("gridnick", nick); 2037 nick = config.Configs["GridInfo"].GetString("gridnick", nick);
2038
2039 if (String.IsNullOrEmpty(nick))
2040 nick = GridUserInfo(InfoType.Nick);
2041
1973 return nick; 2042 return nick;
1974 } 2043 }
1975 2044
@@ -1977,10 +2046,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1977 { 2046 {
1978 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridName"); 2047 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridName");
1979 m_host.AddScriptLPS(1); 2048 m_host.AddScriptLPS(1);
1980 string name = "the lost continent of hippo"; 2049
2050 string name = String.Empty;
1981 IConfigSource config = m_ScriptEngine.ConfigSource; 2051 IConfigSource config = m_ScriptEngine.ConfigSource;
2052
1982 if (config.Configs["GridInfo"] != null) 2053 if (config.Configs["GridInfo"] != null)
1983 name = config.Configs["GridInfo"].GetString("gridname", name); 2054 name = config.Configs["GridInfo"].GetString("gridname", name);
2055
2056 if (String.IsNullOrEmpty(name))
2057 name = GridUserInfo(InfoType.Name);
2058
1984 return name; 2059 return name;
1985 } 2060 }
1986 2061
@@ -1988,13 +2063,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1988 { 2063 {
1989 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridLoginURI"); 2064 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridLoginURI");
1990 m_host.AddScriptLPS(1); 2065 m_host.AddScriptLPS(1);
1991 string loginURI = "http://127.0.0.1:9000/"; 2066
2067 string loginURI = String.Empty;
1992 IConfigSource config = m_ScriptEngine.ConfigSource; 2068 IConfigSource config = m_ScriptEngine.ConfigSource;
2069
1993 if (config.Configs["GridInfo"] != null) 2070 if (config.Configs["GridInfo"] != null)
1994 loginURI = config.Configs["GridInfo"].GetString("login", loginURI); 2071 loginURI = config.Configs["GridInfo"].GetString("login", loginURI);
2072
2073 if (String.IsNullOrEmpty(loginURI))
2074 loginURI = GridUserInfo(InfoType.Login);
2075
1995 return loginURI; 2076 return loginURI;
1996 } 2077 }
1997 2078
2079 public string osGetGridHomeURI()
2080 {
2081 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridHomeURI");
2082 m_host.AddScriptLPS(1);
2083
2084 string HomeURI = String.Empty;
2085 IConfigSource config = m_ScriptEngine.ConfigSource;
2086
2087 if (config.Configs["LoginService"] != null)
2088 HomeURI = config.Configs["LoginService"].GetString("SRV_HomeURI", HomeURI);
2089
2090 if (String.IsNullOrEmpty(HomeURI))
2091 HomeURI = GridUserInfo(InfoType.Home);
2092
2093 return HomeURI;
2094 }
2095
2096 public string osGetGridCustom(string key)
2097 {
2098 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridCustom");
2099 m_host.AddScriptLPS(1);
2100
2101 string retval = String.Empty;
2102 IConfigSource config = m_ScriptEngine.ConfigSource;
2103
2104 if (config.Configs["GridInfo"] != null)
2105 retval = config.Configs["GridInfo"].GetString(key, retval);
2106
2107 if (String.IsNullOrEmpty(retval))
2108 retval = GridUserInfo(InfoType.Custom, key);
2109
2110 return retval;
2111 }
2112
1998 public LSL_String osFormatString(string str, LSL_List strings) 2113 public LSL_String osFormatString(string str, LSL_List strings)
1999 { 2114 {
2000 CheckThreatLevel(ThreatLevel.Low, "osFormatString"); 2115 CheckThreatLevel(ThreatLevel.Low, "osFormatString");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 403e491..6388704 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -160,6 +160,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
160 string osGetGridNick(); 160 string osGetGridNick();
161 string osGetGridName(); 161 string osGetGridName();
162 string osGetGridLoginURI(); 162 string osGetGridLoginURI();
163 string osGetGridHomeURI();
164 string osGetGridCustom(string key);
163 165
164 LSL_String osFormatString(string str, LSL_List strings); 166 LSL_String osFormatString(string str, LSL_List strings);
165 LSL_List osMatchString(string src, string pattern, int start); 167 LSL_List osMatchString(string src, string pattern, int start);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 0c05ea4..02efecf 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -452,6 +452,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
452 return m_OSSL_Functions.osGetGridLoginURI(); 452 return m_OSSL_Functions.osGetGridLoginURI();
453 } 453 }
454 454
455 public string osGetGridHomeURI()
456 {
457 return m_OSSL_Functions.osGetGridHomeURI();
458 }
459
460 public string osGetGridCustom(string key)
461 {
462 return m_OSSL_Functions.osGetGridCustom(key);
463 }
464
455 public LSL_String osFormatString(string str, LSL_List strings) 465 public LSL_String osFormatString(string str, LSL_List strings)
456 { 466 {
457 return m_OSSL_Functions.osFormatString(str, strings); 467 return m_OSSL_Functions.osFormatString(str, strings);