diff options
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 141 |
1 files changed, 78 insertions, 63 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 1f88950..e891aeb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Collections.Concurrent; | ||
31 | using System.IO; | 32 | using System.IO; |
32 | using System.Reflection; | 33 | using System.Reflection; |
33 | using System.Runtime.Remoting.Lifetime; | 34 | using System.Runtime.Remoting.Lifetime; |
@@ -142,99 +143,113 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
142 | [Serializable] | 143 | [Serializable] |
143 | public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi | 144 | public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi |
144 | { | 145 | { |
146 | public const string GridInfoServiceConfigSectionName = "GridInfoService"; | ||
147 | |||
148 | // shared things | ||
145 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 149 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
146 | 150 | ||
147 | public const string GridInfoServiceConfigSectionName = "GridInfoService"; | 151 | private static object m_OSSLLock = new object(); |
152 | private static bool m_doneSharedInit = false; | ||
153 | internal static bool m_OSFunctionsEnabled = false; | ||
154 | internal static TimeZoneInfo PSTTimeZone = null; | ||
155 | internal static bool m_PermissionErrortoOwner = false; | ||
156 | internal static ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; | ||
157 | internal static float m_ScriptDelayFactor = 1.0f; | ||
158 | internal static float m_ScriptDistanceFactor = 1.0f; | ||
159 | internal static IConfig m_osslconfig; | ||
160 | |||
161 | internal static ConcurrentDictionary<string, FunctionPerms> m_FunctionPerms = new ConcurrentDictionary<string, FunctionPerms>(); | ||
148 | 162 | ||
149 | internal IScriptEngine m_ScriptEngine; | 163 | internal IScriptEngine m_ScriptEngine; |
150 | internal LSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there | 164 | internal LSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there |
151 | internal SceneObjectPart m_host; | 165 | internal SceneObjectPart m_host; |
152 | internal TaskInventoryItem m_item; | 166 | internal TaskInventoryItem m_item; |
153 | internal bool m_OSFunctionsEnabled = false; | ||
154 | internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; | ||
155 | internal float m_ScriptDelayFactor = 1.0f; | ||
156 | internal float m_ScriptDistanceFactor = 1.0f; | ||
157 | internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); | ||
158 | protected IUrlModule m_UrlModule = null; | 167 | protected IUrlModule m_UrlModule = null; |
159 | protected ISoundModule m_SoundModule = null; | 168 | protected ISoundModule m_SoundModule = null; |
160 | internal IConfig m_osslconfig; | ||
161 | internal TimeZoneInfo PSTTimeZone = null; | ||
162 | internal bool m_PermissionErrortoOwner = false; | ||
163 | 169 | ||
164 | public void Initialize( | 170 | public void Initialize(IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item) |
165 | IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item) | ||
166 | { | 171 | { |
172 | //private init | ||
167 | m_ScriptEngine = scriptEngine; | 173 | m_ScriptEngine = scriptEngine; |
168 | m_host = host; | 174 | m_host = host; |
169 | m_item = item; | 175 | m_item = item; |
170 | 176 | ||
171 | m_osslconfig = m_ScriptEngine.ConfigSource.Configs["OSSL"]; | ||
172 | if(m_osslconfig == null) | ||
173 | m_osslconfig = m_ScriptEngine.Config; | ||
174 | |||
175 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); | 177 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); |
176 | m_SoundModule = m_ScriptEngine.World.RequestModuleInterface<ISoundModule>(); | 178 | m_SoundModule = m_ScriptEngine.World.RequestModuleInterface<ISoundModule>(); |
177 | 179 | ||
178 | if (m_osslconfig.GetBoolean("AllowOSFunctions", false)) | 180 | //private init |
181 | lock (m_OSSLLock) | ||
179 | { | 182 | { |
183 | if(m_doneSharedInit) | ||
184 | return; | ||
185 | |||
186 | m_osslconfig = m_ScriptEngine.ConfigSource.Configs["OSSL"]; | ||
187 | if(m_osslconfig == null) | ||
188 | m_osslconfig = m_ScriptEngine.Config; | ||
189 | |||
190 | if (m_osslconfig.GetBoolean("AllowOSFunctions", false)) | ||
191 | { | ||
180 | m_OSFunctionsEnabled = true; | 192 | m_OSFunctionsEnabled = true; |
181 | // m_log.Warn("[OSSL] OSSL FUNCTIONS ENABLED"); | 193 | // m_log.Warn("[OSSL] OSSL FUNCTIONS ENABLED"); |
182 | } | 194 | } |
183 | 195 | ||
184 | m_PermissionErrortoOwner = m_osslconfig.GetBoolean("PermissionErrorToOwner", m_PermissionErrortoOwner); | 196 | m_PermissionErrortoOwner = m_osslconfig.GetBoolean("PermissionErrorToOwner", m_PermissionErrortoOwner); |
185 | 197 | ||
186 | m_ScriptDelayFactor = m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); | 198 | m_ScriptDelayFactor = m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); |
187 | m_ScriptDistanceFactor = m_ScriptEngine.Config.GetFloat("ScriptDistanceLimitFactor", 1.0f); | 199 | m_ScriptDistanceFactor = m_ScriptEngine.Config.GetFloat("ScriptDistanceLimitFactor", 1.0f); |
188 | 200 | ||
189 | string risk = m_osslconfig.GetString("OSFunctionThreatLevel", "VeryLow"); | 201 | string risk = m_osslconfig.GetString("OSFunctionThreatLevel", "VeryLow"); |
190 | switch (risk) | 202 | switch (risk) |
191 | { | 203 | { |
192 | case "NoAccess": | 204 | case "NoAccess": |
193 | m_MaxThreatLevel = ThreatLevel.NoAccess; | 205 | m_MaxThreatLevel = ThreatLevel.NoAccess; |
194 | break; | 206 | break; |
195 | case "None": | 207 | case "None": |
196 | m_MaxThreatLevel = ThreatLevel.None; | 208 | m_MaxThreatLevel = ThreatLevel.None; |
197 | break; | 209 | break; |
198 | case "VeryLow": | 210 | case "VeryLow": |
199 | m_MaxThreatLevel = ThreatLevel.VeryLow; | 211 | m_MaxThreatLevel = ThreatLevel.VeryLow; |
200 | break; | 212 | break; |
201 | case "Low": | 213 | case "Low": |
202 | m_MaxThreatLevel = ThreatLevel.Low; | 214 | m_MaxThreatLevel = ThreatLevel.Low; |
203 | break; | 215 | break; |
204 | case "Moderate": | 216 | case "Moderate": |
205 | m_MaxThreatLevel = ThreatLevel.Moderate; | 217 | m_MaxThreatLevel = ThreatLevel.Moderate; |
206 | break; | 218 | break; |
207 | case "High": | 219 | case "High": |
208 | m_MaxThreatLevel = ThreatLevel.High; | 220 | m_MaxThreatLevel = ThreatLevel.High; |
209 | break; | 221 | break; |
210 | case "VeryHigh": | 222 | case "VeryHigh": |
211 | m_MaxThreatLevel = ThreatLevel.VeryHigh; | 223 | m_MaxThreatLevel = ThreatLevel.VeryHigh; |
212 | break; | 224 | break; |
213 | case "Severe": | 225 | case "Severe": |
214 | m_MaxThreatLevel = ThreatLevel.Severe; | 226 | m_MaxThreatLevel = ThreatLevel.Severe; |
215 | break; | 227 | break; |
216 | default: | 228 | default: |
217 | break; | 229 | break; |
218 | } | 230 | } |
219 | 231 | ||
220 | try | ||
221 | { | ||
222 | PSTTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"); | ||
223 | } | ||
224 | catch | ||
225 | { | ||
226 | PSTTimeZone = null; | ||
227 | } | ||
228 | if(PSTTimeZone == null) | ||
229 | { | ||
230 | try | 232 | try |
231 | { | 233 | { |
232 | PSTTimeZone = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles"); | 234 | PSTTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"); |
233 | } | 235 | } |
234 | catch | 236 | catch |
235 | { | 237 | { |
236 | PSTTimeZone = null; | 238 | PSTTimeZone = null; |
237 | } | 239 | } |
240 | if(PSTTimeZone == null) | ||
241 | { | ||
242 | try | ||
243 | { | ||
244 | PSTTimeZone = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles"); | ||
245 | } | ||
246 | catch | ||
247 | { | ||
248 | PSTTimeZone = null; | ||
249 | } | ||
250 | } | ||
251 | |||
252 | m_doneSharedInit = true; | ||
238 | } | 253 | } |
239 | } | 254 | } |
240 | 255 | ||