aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2012-09-24 20:14:00 +0100
committerMelanie2012-09-24 20:14:00 +0100
commitbbaf2c5a80441fdbd2f55e02ec9f46c3b66869c6 (patch)
tree2ac67907f6333bbbc9e4d821c6607b53d0e22acb /OpenSim
parentMerge branch 'master' into careminster (diff)
parentHG Rez object: warn the user if the item or asset cannot be found. (diff)
downloadopensim-SC_OLD-bbaf2c5a80441fdbd2f55e02ec9f46c3b66869c6.zip
opensim-SC_OLD-bbaf2c5a80441fdbd2f55e02ec9f46c3b66869c6.tar.gz
opensim-SC_OLD-bbaf2c5a80441fdbd2f55e02ec9f46c3b66869c6.tar.bz2
opensim-SC_OLD-bbaf2c5a80441fdbd2f55e02ec9f46c3b66869c6.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/Framework/Scenes/Scene.cs
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs74
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs30
-rw-r--r--OpenSim/ApplicationPlugins/Rest/RestPlugin.cs14
-rw-r--r--OpenSim/Framework/AssetPermissions.cs84
-rw-r--r--OpenSim/Framework/RegionInfo.cs8
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs230
-rw-r--r--OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs22
-rw-r--r--OpenSim/Framework/Servers/MainServer.cs107
-rw-r--r--OpenSim/Framework/WebUtil.cs81
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs4
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs28
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs79
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs9
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs57
-rw-r--r--OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs (renamed from OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs)0
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs23
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs172
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs136
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs24
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs134
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs62
-rw-r--r--OpenSim/Services/HypergridService/HGAssetService.cs26
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs103
28 files changed, 1098 insertions, 439 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 202d199..4473ee0 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -852,7 +852,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
852 responseData["success"] = true; 852 responseData["success"] = true;
853 responseData["region_name"] = region.RegionName; 853 responseData["region_name"] = region.RegionName;
854 responseData["region_id"] = region.RegionID.ToString(); 854 responseData["region_id"] = region.RegionID.ToString();
855 responseData["region_uuid"] = region.RegionID.ToString(); //Deprecate July 2012
856 855
857 m_log.Info("[RADMIN]: CreateRegion: request complete"); 856 m_log.Info("[RADMIN]: CreateRegion: request complete");
858 } 857 }
@@ -2015,29 +2014,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2015 { 2014 {
2016 return; 2015 return;
2017 } 2016 }
2018 #region Deprecate July 2012
2019 //region_ID, regionid, region_uuid will be deprecated in July 2012!!!!!!
2020 else if (requestData.ContainsKey("regionid") &&
2021 !String.IsNullOrEmpty((string)requestData["regionid"]))
2022 {
2023 m_log.WarnFormat("[RADMIN]: Use of parameter regionid will be deprecated as of July 2012. Use region_id instead");
2024 }
2025 else if (requestData.ContainsKey("region_ID") &&
2026 !String.IsNullOrEmpty((string)requestData["region_ID"]))
2027 {
2028 m_log.WarnFormat("[RADMIN]: Use of parameter region_ID will be deprecated as of July 2012. Use region_id instead");
2029 }
2030 else if (requestData.ContainsKey("regionID") &&
2031 !String.IsNullOrEmpty((string)requestData["regionID"]))
2032 {
2033 m_log.WarnFormat("[RADMIN]: Use of parameter regionID will be deprecated as of July 2012. Use region_id instead");
2034 }
2035 else if (requestData.ContainsKey("region_uuid") &&
2036 !String.IsNullOrEmpty((string)requestData["region_uuid"]))
2037 {
2038 m_log.WarnFormat("[RADMIN]: Use of parameter region_uuid will be deprecated as of July 2012. Use region_id instead");
2039 }
2040 #endregion
2041 else 2017 else
2042 { 2018 {
2043 responseData["accepted"] = false; 2019 responseData["accepted"] = false;
@@ -2059,56 +2035,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2059 throw new Exception(String.Format("Region ID {0} not found", regionID)); 2035 throw new Exception(String.Format("Region ID {0} not found", regionID));
2060 } 2036 }
2061 } 2037 }
2062 #region Deprecate July 2012
2063 else if (requestData.ContainsKey("regionid") &&
2064 !String.IsNullOrEmpty((string)requestData["regionid"]))
2065 {
2066 m_log.WarnFormat("[RADMIN]: Use of parameter regionid will be deprecated as of July 2012. Use region_id instead");
2067
2068 UUID regionID = (UUID)(string)requestData["regionid"];
2069 if (!m_application.SceneManager.TryGetScene(regionID, out scene))
2070 {
2071 responseData["error"] = String.Format("Region ID {0} not found", regionID);
2072 throw new Exception(String.Format("Region ID {0} not found", regionID));
2073 }
2074 }
2075 else if (requestData.ContainsKey("region_ID") &&
2076 !String.IsNullOrEmpty((string)requestData["region_ID"]))
2077 {
2078 m_log.WarnFormat("[RADMIN]: Use of parameter region_ID will be deprecated as of July 2012. Use region_id instead");
2079
2080 UUID regionID = (UUID)(string)requestData["region_ID"];
2081 if (!m_application.SceneManager.TryGetScene(regionID, out scene))
2082 {
2083 responseData["error"] = String.Format("Region ID {0} not found", regionID);
2084 throw new Exception(String.Format("Region ID {0} not found", regionID));
2085 }
2086 }
2087 else if (requestData.ContainsKey("regionID") &&
2088 !String.IsNullOrEmpty((string)requestData["regionID"]))
2089 {
2090 m_log.WarnFormat("[RADMIN]: Use of parameter regionID will be deprecated as of July 2012. Use region_id instead");
2091
2092 UUID regionID = (UUID)(string)requestData["regionID"];
2093 if (!m_application.SceneManager.TryGetScene(regionID, out scene))
2094 {
2095 responseData["error"] = String.Format("Region ID {0} not found", regionID);
2096 throw new Exception(String.Format("Region ID {0} not found", regionID));
2097 }
2098 }
2099 else if (requestData.ContainsKey("region_uuid") &&
2100 !String.IsNullOrEmpty((string)requestData["region_uuid"]))
2101 {
2102 m_log.WarnFormat("[RADMIN]: Use of parameter region_uuid will be deprecated as of July 2012. Use region_id instead");
2103
2104 UUID regionID = (UUID)(string)requestData["region_uuid"];
2105 if (!m_application.SceneManager.TryGetScene(regionID, out scene))
2106 {
2107 responseData["error"] = String.Format("Region ID {0} not found", regionID);
2108 throw new Exception(String.Format("Region ID {0} not found", regionID));
2109 }
2110 }
2111 #endregion
2112 else if (requestData.ContainsKey("region_name") && 2038 else if (requestData.ContainsKey("region_name") &&
2113 !String.IsNullOrEmpty((string)requestData["region_name"])) 2039 !String.IsNullOrEmpty((string)requestData["region_name"]))
2114 { 2040 {
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs
index cb88695..072bd6f 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs
@@ -312,14 +312,16 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
312 // Now that everything is setup we can proceed to 312 // Now that everything is setup we can proceed to
313 // add THIS agent to the HTTP server's handler list 313 // add THIS agent to the HTTP server's handler list
314 314
315 if (!AddAgentHandler(Rest.Name,this)) 315 // FIXME: If this code is ever to be re-enabled (most of it is disabled already) then this will
316 { 316 // have to be handled through the AddHttpHandler interface.
317 Rest.Log.ErrorFormat("{0} Unable to activate handler interface", MsgId); 317// if (!AddAgentHandler(Rest.Name,this))
318 foreach (IRest handler in handlers) 318// {
319 { 319// Rest.Log.ErrorFormat("{0} Unable to activate handler interface", MsgId);
320 handler.Close(); 320// foreach (IRest handler in handlers)
321 } 321// {
322 } 322// handler.Close();
323// }
324// }
323 325
324 } 326 }
325 catch (Exception e) 327 catch (Exception e)
@@ -342,11 +344,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
342 { 344 {
343 Rest.Log.InfoFormat("{0} Plugin is terminating", MsgId); 345 Rest.Log.InfoFormat("{0} Plugin is terminating", MsgId);
344 346
345 try 347 // FIXME: If this code is ever to be re-enabled (most of it is disabled already) then this will
346 { 348 // have to be handled through the AddHttpHandler interface.
347 RemoveAgentHandler(Rest.Name, this); 349// try
348 } 350// {
349 catch (KeyNotFoundException){} 351// RemoveAgentHandler(Rest.Name, this);
352// }
353// catch (KeyNotFoundException){}
350 354
351 foreach (IRest handler in handlers) 355 foreach (IRest handler in handlers)
352 { 356 {
diff --git a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs
index eb16750..a2425b5 100644
--- a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs
+++ b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs
@@ -297,7 +297,9 @@ namespace OpenSim.ApplicationPlugins.Rest
297 { 297 {
298 if (!IsEnabled) return false; 298 if (!IsEnabled) return false;
299 _agents.Add(agentName, handler); 299 _agents.Add(agentName, handler);
300 return _httpd.AddAgentHandler(agentName, handler); 300// return _httpd.AddAgentHandler(agentName, handler);
301
302 return false;
301 } 303 }
302 304
303 /// <summary> 305 /// <summary>
@@ -316,7 +318,7 @@ namespace OpenSim.ApplicationPlugins.Rest
316 if (_agents[agentName] == handler) 318 if (_agents[agentName] == handler)
317 { 319 {
318 _agents.Remove(agentName); 320 _agents.Remove(agentName);
319 return _httpd.RemoveAgentHandler(agentName, handler); 321// return _httpd.RemoveAgentHandler(agentName, handler);
320 } 322 }
321 return false; 323 return false;
322 } 324 }
@@ -358,10 +360,10 @@ namespace OpenSim.ApplicationPlugins.Rest
358 _httpd.RemoveStreamHandler(h.HttpMethod, h.Path); 360 _httpd.RemoveStreamHandler(h.HttpMethod, h.Path);
359 } 361 }
360 _handlers = null; 362 _handlers = null;
361 foreach (KeyValuePair<string, IHttpAgentHandler> h in _agents) 363// foreach (KeyValuePair<string, IHttpAgentHandler> h in _agents)
362 { 364// {
363 _httpd.RemoveAgentHandler(h.Key, h.Value); 365// _httpd.RemoveAgentHandler(h.Key, h.Value);
364 } 366// }
365 _agents = null; 367 _agents = null;
366 } 368 }
367 369
diff --git a/OpenSim/Framework/AssetPermissions.cs b/OpenSim/Framework/AssetPermissions.cs
new file mode 100644
index 0000000..4a905c2
--- /dev/null
+++ b/OpenSim/Framework/AssetPermissions.cs
@@ -0,0 +1,84 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4
5using Nini.Config;
6using log4net;
7
8using OpenMetaverse;
9
10namespace OpenSim.Framework
11{
12 public class AssetPermissions
13 {
14 private static readonly ILog m_log =
15 LogManager.GetLogger(
16 MethodBase.GetCurrentMethod().DeclaringType);
17
18 private bool[] m_DisallowExport, m_DisallowImport;
19 private string[] m_AssetTypeNames;
20
21 public AssetPermissions(IConfig config)
22 {
23 Type enumType = typeof(AssetType);
24 m_AssetTypeNames = Enum.GetNames(enumType);
25 for (int i = 0; i < m_AssetTypeNames.Length; i++)
26 m_AssetTypeNames[i] = m_AssetTypeNames[i].ToLower();
27 int n = Enum.GetValues(enumType).Length;
28 m_DisallowExport = new bool[n];
29 m_DisallowImport = new bool[n];
30
31 LoadPermsFromConfig(config, "DisallowExport", m_DisallowExport);
32 LoadPermsFromConfig(config, "DisallowImport", m_DisallowImport);
33
34 }
35
36 private void LoadPermsFromConfig(IConfig assetConfig, string variable, bool[] bitArray)
37 {
38 if (assetConfig == null)
39 return;
40
41 string perms = assetConfig.GetString(variable, String.Empty);
42 string[] parts = perms.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
43 foreach (string s in parts)
44 {
45 int index = Array.IndexOf(m_AssetTypeNames, s.Trim().ToLower());
46 if (index >= 0)
47 bitArray[index] = true;
48 else
49 m_log.WarnFormat("[Asset Permissions]: Invalid AssetType {0}", s);
50 }
51
52 }
53
54 public bool AllowedExport(sbyte type)
55 {
56 string assetTypeName = ((AssetType)type).ToString();
57
58 int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower());
59 if (index >= 0 && m_DisallowExport[index])
60 {
61 m_log.DebugFormat("[Asset Permissions]: Export denied: configuration does not allow export of AssetType {0}", assetTypeName);
62 return false;
63 }
64
65 return true;
66 }
67
68 public bool AllowedImport(sbyte type)
69 {
70 string assetTypeName = ((AssetType)type).ToString();
71
72 int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower());
73 if (index >= 0 && m_DisallowImport[index])
74 {
75 m_log.DebugFormat("[Asset Permissions]: Import denied: configuration does not allow import of AssetType {0}", assetTypeName);
76 return false;
77 }
78
79 return true;
80 }
81
82
83 }
84}
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index fc64ff9..e7bed6a 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -645,11 +645,11 @@ namespace OpenSim.Framework
645 645
646 #region Prim stuff 646 #region Prim stuff
647 647
648 m_nonphysPrimMin = config.GetFloat("NonphysicalPrimMin", 0); 648 m_nonphysPrimMin = config.GetFloat("NonPhysicalPrimMin", 0);
649 allKeys.Remove("NonphysicalPrimMin"); 649 allKeys.Remove("NonPhysicalPrimMin");
650 650
651 m_nonphysPrimMax = config.GetInt("NonphysicalPrimMax", 0); 651 m_nonphysPrimMax = config.GetInt("NonPhysicalPrimMax", 0);
652 allKeys.Remove("NonphysicalPrimMax"); 652 allKeys.Remove("NonPhysicalPrimMax");
653 653
654 m_physPrimMin = config.GetFloat("PhysicalPrimMin", 0); 654 m_physPrimMin = config.GetFloat("PhysicalPrimMin", 0);
655 allKeys.Remove("PhysicalPrimMin"); 655 allKeys.Remove("PhysicalPrimMin");
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 691b45a..29593e5 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -54,8 +54,23 @@ namespace OpenSim.Framework.Servers.HttpServer
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); 55 private HttpServerLogWriter httpserverlog = new HttpServerLogWriter();
56 56
57 /// <summary>
58 /// Gets or sets the debug level.
59 /// </summary>
60 /// <value>
61 /// See MainServer.DebugLevel.
62 /// </value>
57 public int DebugLevel { get; set; } 63 public int DebugLevel { get; set; }
58 64
65 /// <summary>
66 /// Request number for diagnostic purposes.
67 /// </summary>
68 /// <remarks>
69 /// This is an internal number. In some debug situations an external number may also be supplied in the
70 /// opensim-request-id header but we are not currently logging this.
71 /// </remarks>
72 public int RequestNumber { get; private set; }
73
59 private volatile int NotSocketErrors = 0; 74 private volatile int NotSocketErrors = 0;
60 public volatile bool HTTPDRunning = false; 75 public volatile bool HTTPDRunning = false;
61 76
@@ -67,7 +82,7 @@ namespace OpenSim.Framework.Servers.HttpServer
67 protected Dictionary<string, LLSDMethod> m_llsdHandlers = new Dictionary<string, LLSDMethod>(); 82 protected Dictionary<string, LLSDMethod> m_llsdHandlers = new Dictionary<string, LLSDMethod>();
68 protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>(); 83 protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>();
69 protected Dictionary<string, GenericHTTPMethod> m_HTTPHandlers = new Dictionary<string, GenericHTTPMethod>(); 84 protected Dictionary<string, GenericHTTPMethod> m_HTTPHandlers = new Dictionary<string, GenericHTTPMethod>();
70 protected Dictionary<string, IHttpAgentHandler> m_agentHandlers = new Dictionary<string, IHttpAgentHandler>(); 85// protected Dictionary<string, IHttpAgentHandler> m_agentHandlers = new Dictionary<string, IHttpAgentHandler>();
71 protected Dictionary<string, PollServiceEventArgs> m_pollHandlers = 86 protected Dictionary<string, PollServiceEventArgs> m_pollHandlers =
72 new Dictionary<string, PollServiceEventArgs>(); 87 new Dictionary<string, PollServiceEventArgs>();
73 88
@@ -245,29 +260,29 @@ namespace OpenSim.Framework.Servers.HttpServer
245 return new List<string>(m_pollHandlers.Keys); 260 return new List<string>(m_pollHandlers.Keys);
246 } 261 }
247 262
248 // Note that the agent string is provided simply to differentiate 263// // Note that the agent string is provided simply to differentiate
249 // the handlers - it is NOT required to be an actual agent header 264// // the handlers - it is NOT required to be an actual agent header
250 // value. 265// // value.
251 public bool AddAgentHandler(string agent, IHttpAgentHandler handler) 266// public bool AddAgentHandler(string agent, IHttpAgentHandler handler)
252 { 267// {
253 lock (m_agentHandlers) 268// lock (m_agentHandlers)
254 { 269// {
255 if (!m_agentHandlers.ContainsKey(agent)) 270// if (!m_agentHandlers.ContainsKey(agent))
256 { 271// {
257 m_agentHandlers.Add(agent, handler); 272// m_agentHandlers.Add(agent, handler);
258 return true; 273// return true;
259 } 274// }
260 } 275// }
261 276//
262 //must already have a handler for that path so return false 277// //must already have a handler for that path so return false
263 return false; 278// return false;
264 } 279// }
265 280//
266 public List<string> GetAgentHandlerKeys() 281// public List<string> GetAgentHandlerKeys()
267 { 282// {
268 lock (m_agentHandlers) 283// lock (m_agentHandlers)
269 return new List<string>(m_agentHandlers.Keys); 284// return new List<string>(m_agentHandlers.Keys);
270 } 285// }
271 286
272 public bool AddLLSDHandler(string path, LLSDMethod handler) 287 public bool AddLLSDHandler(string path, LLSDMethod handler)
273 { 288 {
@@ -296,6 +311,8 @@ namespace OpenSim.Framework.Servers.HttpServer
296 311
297 private void OnRequest(object source, RequestEventArgs args) 312 private void OnRequest(object source, RequestEventArgs args)
298 { 313 {
314 RequestNumber++;
315
299 try 316 try
300 { 317 {
301 IHttpClientContext context = (IHttpClientContext)source; 318 IHttpClientContext context = (IHttpClientContext)source;
@@ -405,7 +422,6 @@ namespace OpenSim.Framework.Servers.HttpServer
405 string requestMethod = request.HttpMethod; 422 string requestMethod = request.HttpMethod;
406 string uriString = request.RawUrl; 423 string uriString = request.RawUrl;
407 424
408// string reqnum = "unknown";
409 int requestStartTick = Environment.TickCount; 425 int requestStartTick = Environment.TickCount;
410 426
411 // Will be adjusted later on. 427 // Will be adjusted later on.
@@ -422,22 +438,22 @@ namespace OpenSim.Framework.Servers.HttpServer
422 438
423 Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", true); 439 Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", true);
424 440
425 // This is the REST agent interface. We require an agent to properly identify 441// // This is the REST agent interface. We require an agent to properly identify
426 // itself. If the REST handler recognizes the prefix it will attempt to 442// // itself. If the REST handler recognizes the prefix it will attempt to
427 // satisfy the request. If it is not recognizable, and no damage has occurred 443// // satisfy the request. If it is not recognizable, and no damage has occurred
428 // the request can be passed through to the other handlers. This is a low 444// // the request can be passed through to the other handlers. This is a low
429 // probability event; if a request is matched it is normally expected to be 445// // probability event; if a request is matched it is normally expected to be
430 // handled 446// // handled
431 IHttpAgentHandler agentHandler; 447// IHttpAgentHandler agentHandler;
432 448//
433 if (TryGetAgentHandler(request, response, out agentHandler)) 449// if (TryGetAgentHandler(request, response, out agentHandler))
434 { 450// {
435 if (HandleAgentRequest(agentHandler, request, response)) 451// if (HandleAgentRequest(agentHandler, request, response))
436 { 452// {
437 requestEndTick = Environment.TickCount; 453// requestEndTick = Environment.TickCount;
438 return; 454// return;
439 } 455// }
440 } 456// }
441 457
442 //response.KeepAlive = true; 458 //response.KeepAlive = true;
443 response.SendChunked = false; 459 response.SendChunked = false;
@@ -529,8 +545,8 @@ namespace OpenSim.Framework.Servers.HttpServer
529 545
530 if (DebugLevel >= 3) 546 if (DebugLevel >= 3)
531 m_log.DebugFormat( 547 m_log.DebugFormat(
532 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", 548 "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}",
533 request.ContentType, request.HttpMethod, request.Url.PathAndQuery); 549 RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint);
534 550
535 buffer = HandleHTTPRequest(request, response); 551 buffer = HandleHTTPRequest(request, response);
536 break; 552 break;
@@ -541,8 +557,8 @@ namespace OpenSim.Framework.Servers.HttpServer
541 557
542 if (DebugLevel >= 3) 558 if (DebugLevel >= 3)
543 m_log.DebugFormat( 559 m_log.DebugFormat(
544 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", 560 "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}",
545 request.ContentType, request.HttpMethod, request.Url.PathAndQuery); 561 RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint);
546 562
547 buffer = HandleLLSDRequests(request, response); 563 buffer = HandleLLSDRequests(request, response);
548 break; 564 break;
@@ -620,11 +636,11 @@ namespace OpenSim.Framework.Servers.HttpServer
620 } 636 }
621 catch (IOException e) 637 catch (IOException e)
622 { 638 {
623 m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.Message), e); 639 m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.StackTrace), e);
624 } 640 }
625 catch (Exception e) 641 catch (Exception e)
626 { 642 {
627 m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.Message), e); 643 m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.StackTrace), e);
628 SendHTML500(response); 644 SendHTML500(response);
629 } 645 }
630 finally 646 finally
@@ -635,12 +651,21 @@ namespace OpenSim.Framework.Servers.HttpServer
635 if (tickdiff > 3000 && requestHandler.Name != "GetTexture") 651 if (tickdiff > 3000 && requestHandler.Name != "GetTexture")
636 { 652 {
637 m_log.InfoFormat( 653 m_log.InfoFormat(
638 "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} from {4} took {5}ms", 654 "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms",
655 RequestNumber,
639 requestMethod, 656 requestMethod,
640 uriString, 657 uriString,
641 requestHandler != null ? requestHandler.Name : "", 658 requestHandler != null ? requestHandler.Name : "",
642 requestHandler != null ? requestHandler.Description : "", 659 requestHandler != null ? requestHandler.Description : "",
643 request.RemoteIPEndPoint.ToString(), 660 request.RemoteIPEndPoint,
661 tickdiff);
662 }
663 else if (DebugLevel >= 4)
664 {
665 m_log.DebugFormat(
666 "[BASE HTTP SERVER]: HTTP IN {0} :{1} took {2}ms",
667 RequestNumber,
668 Port,
644 tickdiff); 669 tickdiff);
645 } 670 }
646 } 671 }
@@ -649,30 +674,45 @@ namespace OpenSim.Framework.Servers.HttpServer
649 private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler) 674 private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler)
650 { 675 {
651 m_log.DebugFormat( 676 m_log.DebugFormat(
652 "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}", 677 "[BASE HTTP SERVER]: HTTP IN {0} :{1} stream handler {2} {3} {4} {5} from {6}",
653 request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description); 678 RequestNumber,
654 679 Port,
655 if (DebugLevel >= 4) 680 request.HttpMethod,
681 request.Url.PathAndQuery,
682 requestHandler.Name,
683 requestHandler.Description,
684 request.RemoteIPEndPoint);
685
686 if (DebugLevel >= 5)
656 LogIncomingInDetail(request); 687 LogIncomingInDetail(request);
657 } 688 }
658 689
659 private void LogIncomingToContentTypeHandler(OSHttpRequest request) 690 private void LogIncomingToContentTypeHandler(OSHttpRequest request)
660 { 691 {
661 m_log.DebugFormat( 692 m_log.DebugFormat(
662 "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", 693 "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}",
663 request.ContentType, request.HttpMethod, request.Url.PathAndQuery); 694 RequestNumber,
664 695 Port,
665 if (DebugLevel >= 4) 696 request.ContentType,
697 request.HttpMethod,
698 request.Url.PathAndQuery,
699 request.RemoteIPEndPoint);
700
701 if (DebugLevel >= 5)
666 LogIncomingInDetail(request); 702 LogIncomingInDetail(request);
667 } 703 }
668 704
669 private void LogIncomingToXmlRpcHandler(OSHttpRequest request) 705 private void LogIncomingToXmlRpcHandler(OSHttpRequest request)
670 { 706 {
671 m_log.DebugFormat( 707 m_log.DebugFormat(
672 "[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}", 708 "[BASE HTTP SERVER]: HTTP IN {0} :{1} assumed generic XMLRPC request {2} {3} from {4}",
673 request.HttpMethod, request.Url.PathAndQuery); 709 RequestNumber,
674 710 Port,
675 if (DebugLevel >= 4) 711 request.HttpMethod,
712 request.Url.PathAndQuery,
713 request.RemoteIPEndPoint);
714
715 if (DebugLevel >= 5)
676 LogIncomingInDetail(request); 716 LogIncomingInDetail(request);
677 } 717 }
678 718
@@ -682,7 +722,7 @@ namespace OpenSim.Framework.Servers.HttpServer
682 { 722 {
683 string output; 723 string output;
684 724
685 if (DebugLevel == 4) 725 if (DebugLevel == 5)
686 { 726 {
687 const int sampleLength = 80; 727 const int sampleLength = 80;
688 char[] sampleChars = new char[sampleLength]; 728 char[] sampleChars = new char[sampleLength];
@@ -790,24 +830,24 @@ namespace OpenSim.Framework.Servers.HttpServer
790 } 830 }
791 } 831 }
792 832
793 private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) 833// private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler)
794 { 834// {
795 agentHandler = null; 835// agentHandler = null;
796 836//
797 lock (m_agentHandlers) 837// lock (m_agentHandlers)
798 { 838// {
799 foreach (IHttpAgentHandler handler in m_agentHandlers.Values) 839// foreach (IHttpAgentHandler handler in m_agentHandlers.Values)
800 { 840// {
801 if (handler.Match(request, response)) 841// if (handler.Match(request, response))
802 { 842// {
803 agentHandler = handler; 843// agentHandler = handler;
804 return true; 844// return true;
805 } 845// }
806 } 846// }
807 } 847// }
808 848//
809 return false; 849// return false;
810 } 850// }
811 851
812 /// <summary> 852 /// <summary>
813 /// Try all the registered xmlrpc handlers when an xmlrpc request is received. 853 /// Try all the registered xmlrpc handlers when an xmlrpc request is received.
@@ -1778,21 +1818,21 @@ namespace OpenSim.Framework.Servers.HttpServer
1778 m_pollHandlers.Remove(path); 1818 m_pollHandlers.Remove(path);
1779 } 1819 }
1780 1820
1781 public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) 1821// public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler)
1782 { 1822// {
1783 lock (m_agentHandlers) 1823// lock (m_agentHandlers)
1784 { 1824// {
1785 IHttpAgentHandler foundHandler; 1825// IHttpAgentHandler foundHandler;
1786 1826//
1787 if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler) 1827// if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler)
1788 { 1828// {
1789 m_agentHandlers.Remove(agent); 1829// m_agentHandlers.Remove(agent);
1790 return true; 1830// return true;
1791 } 1831// }
1792 } 1832// }
1793 1833//
1794 return false; 1834// return false;
1795 } 1835// }
1796 1836
1797 public void RemoveXmlRPCHandler(string method) 1837 public void RemoveXmlRPCHandler(string method)
1798 { 1838 {
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs
index db58f6f..0bd3aae 100644
--- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs
@@ -41,10 +41,10 @@ namespace OpenSim.Framework.Servers.HttpServer
41 uint Port { get; } 41 uint Port { get; }
42 bool UseSSL { get; } 42 bool UseSSL { get; }
43 43
44 // Note that the agent string is provided simply to differentiate 44// // Note that the agent string is provided simply to differentiate
45 // the handlers - it is NOT required to be an actual agent header 45// // the handlers - it is NOT required to be an actual agent header
46 // value. 46// // value.
47 bool AddAgentHandler(string agent, IHttpAgentHandler handler); 47// bool AddAgentHandler(string agent, IHttpAgentHandler handler);
48 48
49 /// <summary> 49 /// <summary>
50 /// Add a handler for an HTTP request. 50 /// Add a handler for an HTTP request.
@@ -106,13 +106,13 @@ namespace OpenSim.Framework.Servers.HttpServer
106 106
107 bool SetDefaultLLSDHandler(DefaultLLSDMethod handler); 107 bool SetDefaultLLSDHandler(DefaultLLSDMethod handler);
108 108
109 /// <summary> 109// /// <summary>
110 /// Remove the agent if it is registered. 110// /// Remove the agent if it is registered.
111 /// </summary> 111// /// </summary>
112 /// <param name="agent"></param> 112// /// <param name="agent"></param>
113 /// <param name="handler"></param> 113// /// <param name="handler"></param>
114 /// <returns></returns> 114// /// <returns></returns>
115 bool RemoveAgentHandler(string agent, IHttpAgentHandler handler); 115// bool RemoveAgentHandler(string agent, IHttpAgentHandler handler);
116 116
117 /// <summary> 117 /// <summary>
118 /// Remove an HTTP handler 118 /// Remove an HTTP handler
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs
index 7402c73..4b61b18 100644
--- a/OpenSim/Framework/Servers/MainServer.cs
+++ b/OpenSim/Framework/Servers/MainServer.cs
@@ -48,9 +48,12 @@ namespace OpenSim.Framework.Servers
48 /// Control the printing of certain debug messages. 48 /// Control the printing of certain debug messages.
49 /// </summary> 49 /// </summary>
50 /// <remarks> 50 /// <remarks>
51 /// If DebugLevel >= 1, then short warnings are logged when receiving bad input data. 51 /// If DebugLevel >= 1 then short warnings are logged when receiving bad input data.
52 /// If DebugLevel >= 2, then long warnings are logged when receiving bad input data. 52 /// If DebugLevel >= 2 then long warnings are logged when receiving bad input data.
53 /// If DebugLevel >= 3, then short notices about all incoming non-poll HTTP requests are logged. 53 /// If DebugLevel >= 3 then short notices about all incoming non-poll HTTP requests are logged.
54 /// If DebugLevel >= 4 then the time taken to fulfill the request is logged.
55 /// If DebugLevel >= 5 then the start of the body of incoming non-poll HTTP requests will be logged.
56 /// If DebugLevel >= 6 then the entire body of incoming non-poll HTTP requests will be logged.
54 /// </remarks> 57 /// </remarks>
55 public static int DebugLevel 58 public static int DebugLevel
56 { 59 {
@@ -102,7 +105,6 @@ namespace OpenSim.Framework.Servers
102 get { return new Dictionary<uint, BaseHttpServer>(m_Servers); } 105 get { return new Dictionary<uint, BaseHttpServer>(m_Servers); }
103 } 106 }
104 107
105
106 public static void RegisterHttpConsoleCommands(ICommandConsole console) 108 public static void RegisterHttpConsoleCommands(ICommandConsole console)
107 { 109 {
108 console.Commands.AddCommand( 110 console.Commands.AddCommand(
@@ -111,15 +113,20 @@ namespace OpenSim.Framework.Servers
111 "Show all registered http handlers", HandleShowHttpHandlersCommand); 113 "Show all registered http handlers", HandleShowHttpHandlersCommand);
112 114
113 console.Commands.AddCommand( 115 console.Commands.AddCommand(
114 "Debug", false, "debug http", "debug http [<level>]", 116 "Debug", false, "debug http", "debug http <in|out|all> [<level>]",
115 "Turn on inbound non-poll http request debugging.", 117 "Turn on http request logging.",
116 "If level <= 0, then no extra logging is done.\n" 118 "If in or all and\n"
117 + "If level >= 1, then short warnings are logged when receiving bad input data.\n" 119 + " level <= 0 then no extra logging is done.\n"
118 + "If level >= 2, then long warnings are logged when receiving bad input data.\n" 120 + " level >= 1 then short warnings are logged when receiving bad input data.\n"
119 + "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n" 121 + " level >= 2 then long warnings are logged when receiving bad input data.\n"
120 + "If level >= 4, then a sample from the beginning of the incoming data is logged.\n" 122 + " level >= 3 then short notices about all incoming non-poll HTTP requests are logged.\n"
121 + "If level >= 5, then the entire incoming data is logged.\n" 123 + " level >= 4 then the time taken to fulfill the request is logged.\n"
122 + "If no level is specified then the current level is returned.", 124 + " level >= 5 then a sample from the beginning of the incoming data is logged.\n"
125 + " level >= 6 then the entire incoming data is logged.\n"
126 + " no level is specified then the current level is returned.\n\n"
127 + "If out or all and\n"
128 + " level >= 3 then short notices about all outgoing requests going through WebUtil are logged.\n"
129 + " level >= 4 then the time taken to fulfill the request is logged.\n",
123 HandleDebugHttpCommand); 130 HandleDebugHttpCommand);
124 } 131 }
125 132
@@ -127,24 +134,74 @@ namespace OpenSim.Framework.Servers
127 /// Turn on some debugging values for OpenSim. 134 /// Turn on some debugging values for OpenSim.
128 /// </summary> 135 /// </summary>
129 /// <param name="args"></param> 136 /// <param name="args"></param>
130 private static void HandleDebugHttpCommand(string module, string[] args) 137 private static void HandleDebugHttpCommand(string module, string[] cmdparams)
131 { 138 {
132 if (args.Length == 3) 139 if (cmdparams.Length < 3)
140 {
141 MainConsole.Instance.Output("Usage: debug http <in|out|all> 0..6");
142 return;
143 }
144
145 bool inReqs = false;
146 bool outReqs = false;
147 bool allReqs = false;
148
149 string subCommand = cmdparams[2];
150
151 if (subCommand.ToLower() == "in")
152 {
153 inReqs = true;
154 }
155 else if (subCommand.ToLower() == "out")
156 {
157 outReqs = true;
158 }
159 else if (subCommand.ToLower() == "all")
160 {
161 allReqs = true;
162 }
163 else
164 {
165 MainConsole.Instance.Output("You must specify in, out or all");
166 return;
167 }
168
169 if (cmdparams.Length >= 4)
133 { 170 {
171 string rawNewDebug = cmdparams[3];
134 int newDebug; 172 int newDebug;
135 if (int.TryParse(args[2], out newDebug)) 173
174 if (!int.TryParse(rawNewDebug, out newDebug))
175 {
176 MainConsole.Instance.OutputFormat("{0} is not a valid debug level", rawNewDebug);
177 return;
178 }
179
180 if (newDebug < 0 || newDebug > 5)
181 {
182 MainConsole.Instance.OutputFormat("{0} is outside the valid debug level range of 0..5", newDebug);
183 return;
184 }
185
186 if (allReqs || inReqs)
136 { 187 {
137 MainServer.DebugLevel = newDebug; 188 MainServer.DebugLevel = newDebug;
138 MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug); 189 MainConsole.Instance.OutputFormat("IN debug level set to {0}", newDebug);
190 }
191
192 if (allReqs || outReqs)
193 {
194 WebUtil.DebugLevel = newDebug;
195 MainConsole.Instance.OutputFormat("OUT debug level set to {0}", newDebug);
139 } 196 }
140 }
141 else if (args.Length == 2)
142 {
143 MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel);
144 } 197 }
145 else 198 else
146 { 199 {
147 MainConsole.Instance.Output("Usage: debug http 0..5"); 200 if (allReqs || inReqs)
201 MainConsole.Instance.OutputFormat("Current IN debug level is {0}", MainServer.DebugLevel);
202
203 if (allReqs || outReqs)
204 MainConsole.Instance.OutputFormat("Current OUT debug level is {0}", WebUtil.DebugLevel);
148 } 205 }
149 } 206 }
150 207
@@ -174,9 +231,9 @@ namespace OpenSim.Framework.Servers
174 foreach (String s in httpServer.GetHTTPHandlerKeys()) 231 foreach (String s in httpServer.GetHTTPHandlerKeys())
175 handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty)); 232 handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty));
176 233
177 handlers.AppendFormat("* Agent:\n"); 234// handlers.AppendFormat("* Agent:\n");
178 foreach (String s in httpServer.GetAgentHandlerKeys()) 235// foreach (String s in httpServer.GetAgentHandlerKeys())
179 handlers.AppendFormat("\t{0}\n", s); 236// handlers.AppendFormat("\t{0}\n", s);
180 237
181 handlers.AppendFormat("* LLSD:\n"); 238 handlers.AppendFormat("* LLSD:\n");
182 foreach (String s in httpServer.GetLLSDHandlerKeys()) 239 foreach (String s in httpServer.GetLLSDHandlerKeys())
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs
index 8094b6d..a03d626 100644
--- a/OpenSim/Framework/WebUtil.cs
+++ b/OpenSim/Framework/WebUtil.cs
@@ -54,9 +54,17 @@ namespace OpenSim.Framework
54 MethodBase.GetCurrentMethod().DeclaringType); 54 MethodBase.GetCurrentMethod().DeclaringType);
55 55
56 /// <summary> 56 /// <summary>
57 /// Control the printing of certain debug messages.
58 /// </summary>
59 /// <remarks>
60 /// If DebugLevel >= 3 then short notices about outgoing HTTP requests are logged.
61 /// </remarks>
62 public static int DebugLevel { get; set; }
63
64 /// <summary>
57 /// Request number for diagnostic purposes. 65 /// Request number for diagnostic purposes.
58 /// </summary> 66 /// </summary>
59 public static int RequestNumber = 0; 67 public static int RequestNumber { get; internal set; }
60 68
61 /// <summary> 69 /// <summary>
62 /// this is the header field used to communicate the local request id 70 /// this is the header field used to communicate the local request id
@@ -146,7 +154,11 @@ namespace OpenSim.Framework
146 private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) 154 private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed)
147 { 155 {
148 int reqnum = RequestNumber++; 156 int reqnum = RequestNumber++;
149 // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); 157
158 if (DebugLevel >= 3)
159 m_log.DebugFormat(
160 "[WEB UTIL]: HTTP OUT {0} ServiceOSD {1} {2} (timeout {3}, compressed {4})",
161 reqnum, method, url, timeout, compressed);
150 162
151 string errorMessage = "unknown error"; 163 string errorMessage = "unknown error";
152 int tickstart = Util.EnvironmentTickCount(); 164 int tickstart = Util.EnvironmentTickCount();
@@ -230,7 +242,7 @@ namespace OpenSim.Framework
230 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); 242 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
231 if (tickdiff > LongCallTime) 243 if (tickdiff > LongCallTime)
232 m_log.InfoFormat( 244 m_log.InfoFormat(
233 "[OSD REQUEST]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", 245 "[WEB UTIL]: Slow ServiceOSD request {0} {1} {2} took {3}ms, {4}ms writing, {5}",
234 reqnum, 246 reqnum,
235 method, 247 method,
236 url, 248 url,
@@ -239,10 +251,14 @@ namespace OpenSim.Framework
239 strBuffer != null 251 strBuffer != null
240 ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) 252 ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer)
241 : ""); 253 : "");
254 else if (DebugLevel >= 4)
255 m_log.DebugFormat(
256 "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing",
257 reqnum, tickdiff, tickdata);
242 } 258 }
243 259
244 m_log.DebugFormat( 260 m_log.DebugFormat(
245 "[WEB UTIL]: <{0}> osd request for {1}, method {2} FAILED: {3}", reqnum, url, method, errorMessage); 261 "[WEB UTIL]: ServiceOSD request {0} {1} {2} FAILED: {3}", reqnum, url, method, errorMessage);
246 262
247 return ErrorResponseMap(errorMessage); 263 return ErrorResponseMap(errorMessage);
248 } 264 }
@@ -318,7 +334,11 @@ namespace OpenSim.Framework
318 { 334 {
319 int reqnum = RequestNumber++; 335 int reqnum = RequestNumber++;
320 string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; 336 string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown";
321 // m_log.DebugFormat("[WEB UTIL]: <{0}> start form request for {1}, method {2}",reqnum,url,method); 337
338 if (DebugLevel >= 3)
339 m_log.DebugFormat(
340 "[WEB UTIL]: HTTP OUT {0} ServiceForm {1} {2} (timeout {3})",
341 reqnum, method, url, timeout);
322 342
323 string errorMessage = "unknown error"; 343 string errorMessage = "unknown error";
324 int tickstart = Util.EnvironmentTickCount(); 344 int tickstart = Util.EnvironmentTickCount();
@@ -381,7 +401,7 @@ namespace OpenSim.Framework
381 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); 401 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
382 if (tickdiff > LongCallTime) 402 if (tickdiff > LongCallTime)
383 m_log.InfoFormat( 403 m_log.InfoFormat(
384 "[SERVICE FORM]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", 404 "[WEB UTIL]: Slow ServiceForm request {0} {1} {2} took {3}ms, {4}ms writing, {5}",
385 reqnum, 405 reqnum,
386 method, 406 method,
387 url, 407 url,
@@ -390,9 +410,13 @@ namespace OpenSim.Framework
390 queryString != null 410 queryString != null
391 ? (queryString.Length > MaxRequestDiagLength) ? queryString.Remove(MaxRequestDiagLength) : queryString 411 ? (queryString.Length > MaxRequestDiagLength) ? queryString.Remove(MaxRequestDiagLength) : queryString
392 : ""); 412 : "");
413 else if (DebugLevel >= 4)
414 m_log.DebugFormat(
415 "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing",
416 reqnum, tickdiff, tickdata);
393 } 417 }
394 418
395 m_log.WarnFormat("[SERVICE FORM]: <{0}> form request to {1} failed: {2}", reqnum, url, errorMessage); 419 m_log.WarnFormat("[WEB UTIL]: ServiceForm request {0} {1} {2} failed: {2}", reqnum, method, url, errorMessage);
396 420
397 return ErrorResponseMap(errorMessage); 421 return ErrorResponseMap(errorMessage);
398 } 422 }
@@ -644,7 +668,6 @@ namespace OpenSim.Framework
644 /// <returns></returns> 668 /// <returns></returns>
645 public static string[] GetPreferredImageTypes(string accept) 669 public static string[] GetPreferredImageTypes(string accept)
646 { 670 {
647
648 if (accept == null || accept == string.Empty) 671 if (accept == null || accept == string.Empty)
649 return new string[0]; 672 return new string[0];
650 673
@@ -703,13 +726,15 @@ namespace OpenSim.Framework
703 int maxConnections) 726 int maxConnections)
704 { 727 {
705 int reqnum = WebUtil.RequestNumber++; 728 int reqnum = WebUtil.RequestNumber++;
706 // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); 729
730 if (WebUtil.DebugLevel >= 3)
731 m_log.DebugFormat(
732 "[WEB UTIL]: HTTP OUT {0} AsynchronousRequestObject {1} {2}",
733 reqnum, verb, requestUrl);
707 734
708 int tickstart = Util.EnvironmentTickCount(); 735 int tickstart = Util.EnvironmentTickCount();
709 int tickdata = 0; 736 int tickdata = 0;
710 737
711 // m_log.DebugFormat("[ASYNC REQUEST]: Starting {0} {1}", verb, requestUrl);
712
713 Type type = typeof(TRequest); 738 Type type = typeof(TRequest);
714 739
715 WebRequest request = WebRequest.Create(requestUrl); 740 WebRequest request = WebRequest.Create(requestUrl);
@@ -866,7 +891,7 @@ namespace OpenSim.Framework
866 } 891 }
867 892
868 m_log.InfoFormat( 893 m_log.InfoFormat(
869 "[ASYNC REQUEST]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", 894 "[ASYNC REQUEST]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}",
870 reqnum, 895 reqnum,
871 verb, 896 verb,
872 requestUrl, 897 requestUrl,
@@ -874,6 +899,12 @@ namespace OpenSim.Framework
874 tickdata, 899 tickdata,
875 originalRequest); 900 originalRequest);
876 } 901 }
902 else if (WebUtil.DebugLevel >= 4)
903 {
904 m_log.DebugFormat(
905 "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing",
906 reqnum, tickdiff, tickdata);
907 }
877 } 908 }
878 } 909 }
879 910
@@ -894,7 +925,11 @@ namespace OpenSim.Framework
894 public static string MakeRequest(string verb, string requestUrl, string obj) 925 public static string MakeRequest(string verb, string requestUrl, string obj)
895 { 926 {
896 int reqnum = WebUtil.RequestNumber++; 927 int reqnum = WebUtil.RequestNumber++;
897 // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); 928
929 if (WebUtil.DebugLevel >= 3)
930 m_log.DebugFormat(
931 "[WEB UTIL]: HTTP OUT {0} SynchronousRestForms {1} {2}",
932 reqnum, verb, requestUrl);
898 933
899 int tickstart = Util.EnvironmentTickCount(); 934 int tickstart = Util.EnvironmentTickCount();
900 int tickdata = 0; 935 int tickdata = 0;
@@ -979,13 +1014,17 @@ namespace OpenSim.Framework
979 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); 1014 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
980 if (tickdiff > WebUtil.LongCallTime) 1015 if (tickdiff > WebUtil.LongCallTime)
981 m_log.InfoFormat( 1016 m_log.InfoFormat(
982 "[FORMS]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", 1017 "[FORMS]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}",
983 reqnum, 1018 reqnum,
984 verb, 1019 verb,
985 requestUrl, 1020 requestUrl,
986 tickdiff, 1021 tickdiff,
987 tickdata, 1022 tickdata,
988 obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); 1023 obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj);
1024 else if (WebUtil.DebugLevel >= 4)
1025 m_log.DebugFormat(
1026 "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing",
1027 reqnum, tickdiff, tickdata);
989 1028
990 return respstring; 1029 return respstring;
991 } 1030 }
@@ -1020,7 +1059,11 @@ namespace OpenSim.Framework
1020 public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections) 1059 public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections)
1021 { 1060 {
1022 int reqnum = WebUtil.RequestNumber++; 1061 int reqnum = WebUtil.RequestNumber++;
1023 // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); 1062
1063 if (WebUtil.DebugLevel >= 3)
1064 m_log.DebugFormat(
1065 "[WEB UTIL]: HTTP OUT {0} SynchronousRestObject {1} {2}",
1066 reqnum, verb, requestUrl);
1024 1067
1025 int tickstart = Util.EnvironmentTickCount(); 1068 int tickstart = Util.EnvironmentTickCount();
1026 int tickdata = 0; 1069 int tickdata = 0;
@@ -1139,7 +1182,7 @@ namespace OpenSim.Framework
1139 } 1182 }
1140 1183
1141 m_log.InfoFormat( 1184 m_log.InfoFormat(
1142 "[SynchronousRestObjectRequester]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", 1185 "[SynchronousRestObjectRequester]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}",
1143 reqnum, 1186 reqnum,
1144 verb, 1187 verb,
1145 requestUrl, 1188 requestUrl,
@@ -1147,6 +1190,12 @@ namespace OpenSim.Framework
1147 tickdata, 1190 tickdata,
1148 originalRequest); 1191 originalRequest);
1149 } 1192 }
1193 else if (WebUtil.DebugLevel >= 4)
1194 {
1195 m_log.DebugFormat(
1196 "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing",
1197 reqnum, tickdiff, tickdata);
1198 }
1150 1199
1151 return deserial; 1200 return deserial;
1152 } 1201 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 951afd7..5d41c1c 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -933,6 +933,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
933 933
934 InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); 934 InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID);
935 item = m_scene.InventoryService.GetItem(item); 935 item = m_scene.InventoryService.GetItem(item);
936 if (item == null)
937 return;
938
936 bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); 939 bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID);
937 if (changed && m_scene.AvatarFactory != null) 940 if (changed && m_scene.AvatarFactory != null)
938 { 941 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 48f3a23..b7a1169 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -62,7 +62,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
62 public class AttachmentsModuleTests : OpenSimTestCase 62 public class AttachmentsModuleTests : OpenSimTestCase
63 { 63 {
64 private AutoResetEvent m_chatEvent = new AutoResetEvent(false); 64 private AutoResetEvent m_chatEvent = new AutoResetEvent(false);
65 private OSChatMessage m_osChatMessageReceived; 65// private OSChatMessage m_osChatMessageReceived;
66 66
67 [TestFixtureSetUp] 67 [TestFixtureSetUp]
68 public void FixtureInit() 68 public void FixtureInit()
@@ -83,7 +83,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
83 { 83 {
84// Console.WriteLine("Got chat [{0}]", oscm.Message); 84// Console.WriteLine("Got chat [{0}]", oscm.Message);
85 85
86 m_osChatMessageReceived = oscm; 86// m_osChatMessageReceived = oscm;
87 m_chatEvent.Set(); 87 m_chatEvent.Set();
88 } 88 }
89 89
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 4c786ff..a1d8d5a 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -150,6 +150,34 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
150 150
151 if (m_Enabled) 151 if (m_Enabled)
152 scene.RegisterModuleInterface<IUserAgentVerificationModule>(this); 152 scene.RegisterModuleInterface<IUserAgentVerificationModule>(this);
153
154 scene.EventManager.OnIncomingSceneObject += OnIncomingSceneObject;
155 }
156
157 void OnIncomingSceneObject(SceneObjectGroup so)
158 {
159 if (!so.IsAttachment)
160 return;
161
162 if (so.Scene.UserManagementModule.IsLocalGridUser(so.AttachedAvatar))
163 return;
164
165 // foreign user
166 AgentCircuitData aCircuit = so.Scene.AuthenticateHandler.GetAgentCircuitData(so.AttachedAvatar);
167 if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
168 {
169 if (aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
170 {
171 string url = aCircuit.ServiceURLs["AssetServerURI"].ToString();
172 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Incoming attachement {0} for HG user {1} with asset server {2}", so.Name, so.AttachedAvatar, url);
173 Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>();
174 HGUuidGatherer uuidGatherer = new HGUuidGatherer(so.Scene.AssetService, url);
175 uuidGatherer.GatherAssetUuids(so, ids);
176
177 foreach (KeyValuePair<UUID, AssetType> kvp in ids)
178 uuidGatherer.FetchAsset(kvp.Key);
179 }
180 }
153 } 181 }
154 182
155 protected override void OnNewClient(IClientAPI client) 183 protected override void OnNewClient(IClientAPI client)
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
index eaadc1b..6f62856 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
@@ -71,19 +71,19 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
71 71
72 #region Internal functions 72 #region Internal functions
73 73
74 public AssetBase FetchAsset(string url, UUID assetID) 74 public AssetMetadata FetchMetadata(string url, UUID assetID)
75 { 75 {
76 if (!url.EndsWith("/") && !url.EndsWith("=")) 76 if (!url.EndsWith("/") && !url.EndsWith("="))
77 url = url + "/"; 77 url = url + "/";
78 78
79 AssetBase asset = m_scene.AssetService.Get(url + assetID.ToString()); 79 AssetMetadata meta = m_scene.AssetService.GetMetadata(url + assetID.ToString());
80 80
81 if (asset != null) 81 if (meta != null)
82 { 82 m_log.DebugFormat("[HG ASSET MAPPER]: Fetched metadata for asset {0} of type {1} from {2} ", assetID, meta.Type, url);
83 m_log.DebugFormat("[HG ASSET MAPPER]: Copied asset {0} from {1} to local asset server. ", asset.ID, url); 83 else
84 return asset; 84 m_log.DebugFormat("[HG ASSET MAPPER]: Unable to fetched metadata for asset {0} from {1} ", assetID, url);
85 } 85
86 return null; 86 return meta;
87 } 87 }
88 88
89 public bool PostAsset(string url, AssetBase asset) 89 public bool PostAsset(string url, AssetBase asset)
@@ -93,6 +93,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
93 if (!url.EndsWith("/") && !url.EndsWith("=")) 93 if (!url.EndsWith("/") && !url.EndsWith("="))
94 url = url + "/"; 94 url = url + "/";
95 95
96 bool success = true;
96 // See long comment in AssetCache.AddAsset 97 // See long comment in AssetCache.AddAsset
97 if (!asset.Temporary || asset.Local) 98 if (!asset.Temporary || asset.Local)
98 { 99 {
@@ -103,14 +104,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
103 // not having a global naming infrastructure 104 // not having a global naming infrastructure
104 AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type, asset.Metadata.CreatorID); 105 AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type, asset.Metadata.CreatorID);
105 Copy(asset, asset1); 106 Copy(asset, asset1);
106 try 107 asset1.ID = url + asset.ID;
107 {
108 asset1.ID = url + asset.ID;
109 }
110 catch
111 {
112 m_log.Warn("[HG ASSET MAPPER]: Oops.");
113 }
114 108
115 AdjustIdentifiers(asset1.Metadata); 109 AdjustIdentifiers(asset1.Metadata);
116 if (asset1.Metadata.Type == (sbyte)AssetType.Object) 110 if (asset1.Metadata.Type == (sbyte)AssetType.Object)
@@ -118,11 +112,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
118 else 112 else
119 asset1.Data = asset.Data; 113 asset1.Data = asset.Data;
120 114
121 m_scene.AssetService.Store(asset1); 115 string id = m_scene.AssetService.Store(asset1);
122 m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url); 116 if (id == string.Empty)
117 {
118 m_log.DebugFormat("[HG ASSET MAPPER]: Asset server {0} did not accept {1}", url, asset.ID);
119 success = false;
120 }
121 else
122 m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url);
123 } 123 }
124 return true; 124 return success;
125 } 125 }
126 else 126 else
127 m_log.Warn("[HG ASSET MAPPER]: Tried to post asset to remote server, but asset not in local cache."); 127 m_log.Warn("[HG ASSET MAPPER]: Tried to post asset to remote server, but asset not in local cache.");
128 128
@@ -222,28 +222,19 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
222 222
223 public void Get(UUID assetID, UUID ownerID, string userAssetURL) 223 public void Get(UUID assetID, UUID ownerID, string userAssetURL)
224 { 224 {
225 // Get the item from the remote asset server onto the local AssetCache 225 // Get the item from the remote asset server onto the local AssetService
226 // and place an entry in m_assetMap
227 226
228 m_log.Debug("[HG ASSET MAPPER]: Fetching object " + assetID + " from asset server " + userAssetURL); 227 AssetMetadata meta = FetchMetadata(userAssetURL, assetID);
229 AssetBase asset = FetchAsset(userAssetURL, assetID); 228 if (meta == null)
229 return;
230 230
231 if (asset != null) 231 // The act of gathering UUIDs downloads the assets from the remote server
232 { 232 Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>();
233 // OK, now fetch the inside. 233 HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL);
234 Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); 234 uuidGatherer.GatherAssetUuids(assetID, (AssetType)meta.Type, ids);
235 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
236 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
237 if (ids.ContainsKey(assetID))
238 ids.Remove(assetID);
239 foreach (UUID uuid in ids.Keys)
240 FetchAsset(userAssetURL, uuid);
241 235
242 m_log.DebugFormat("[HG ASSET MAPPER]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL); 236 m_log.DebugFormat("[HG ASSET MAPPER]: Successfully fetched asset {0} from asset server {1}", assetID, userAssetURL);
243 237
244 }
245 else
246 m_log.Warn("[HG ASSET MAPPER]: Could not fetch asset from remote asset server " + userAssetURL);
247 } 238 }
248 239
249 240
@@ -257,19 +248,23 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
257 if (asset != null) 248 if (asset != null)
258 { 249 {
259 Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); 250 Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>();
260 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty); 251 HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty);
261 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); 252 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
253 bool success = false;
262 foreach (UUID uuid in ids.Keys) 254 foreach (UUID uuid in ids.Keys)
263 { 255 {
264 asset = m_scene.AssetService.Get(uuid.ToString()); 256 asset = m_scene.AssetService.Get(uuid.ToString());
265 if (asset == null) 257 if (asset == null)
266 m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid); 258 m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid);
267 else 259 else
268 PostAsset(userAssetURL, asset); 260 success = PostAsset(userAssetURL, asset);
269 } 261 }
270 262
271 // maybe all pieces got there... 263 // maybe all pieces got there...
272 m_log.DebugFormat("[HG ASSET MAPPER]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL); 264 if (!success)
265 m_log.DebugFormat("[HG ASSET MAPPER]: Problems posting item {0} to asset server {1}", assetID, userAssetURL);
266 else
267 m_log.DebugFormat("[HG ASSET MAPPER]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL);
273 268
274 } 269 }
275 else 270 else
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index a0cad40..80257bd 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -263,8 +263,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
263 //} 263 //}
264 264
265 // OK, we're done fetching. Pass it up to the default RezObject 265 // OK, we're done fetching. Pass it up to the default RezObject
266 return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, 266 SceneObjectGroup sog = base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
267 RezSelected, RemoveItem, fromTaskID, attachment); 267 RezSelected, RemoveItem, fromTaskID, attachment);
268
269 if (sog == null)
270 remoteClient.SendAgentAlertMessage("Unable to rez: problem accessing inventory or locating assets", false);
271
272 return sog;
268 273
269 } 274 }
270 275
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs
deleted file mode 100644
index fcb544f..0000000
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs
+++ /dev/null
@@ -1,57 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30
31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Services.Interfaces;
34using OpenMetaverse;
35
36namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
37{
38 public class HGUuidGatherer : UuidGatherer
39 {
40 protected string m_assetServerURL;
41 protected HGAssetMapper m_assetMapper;
42
43 public HGUuidGatherer(HGAssetMapper assMap, IAssetService assetCache, string assetServerURL) : base(assetCache)
44 {
45 m_assetMapper = assMap;
46 m_assetServerURL = assetServerURL;
47 }
48
49 protected override AssetBase GetAsset(UUID uuid)
50 {
51 if (string.Empty == m_assetServerURL)
52 return m_assetCache.Get(uuid.ToString());
53 else
54 return m_assetMapper.FetchAsset(m_assetServerURL, uuid);
55 }
56 }
57}
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index 98396ff..98396ff 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
index 008465f..1e1c7d0 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
@@ -56,6 +56,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
56 56
57 private bool m_Enabled = false; 57 private bool m_Enabled = false;
58 58
59 private AssetPermissions m_AssetPerms;
60
59 public Type ReplaceableInterface 61 public Type ReplaceableInterface
60 { 62 {
61 get { return null; } 63 get { return null; }
@@ -128,6 +130,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
128 if (m_LocalAssetServiceURI != string.Empty) 130 if (m_LocalAssetServiceURI != string.Empty)
129 m_LocalAssetServiceURI = m_LocalAssetServiceURI.Trim('/'); 131 m_LocalAssetServiceURI = m_LocalAssetServiceURI.Trim('/');
130 132
133 IConfig hgConfig = source.Configs["HGAssetService"];
134 m_AssetPerms = new AssetPermissions(hgConfig); // it's ok if arg is null
135
131 m_Enabled = true; 136 m_Enabled = true;
132 m_log.Info("[HG ASSET CONNECTOR]: HG asset broker enabled"); 137 m_log.Info("[HG ASSET CONNECTOR]: HG asset broker enabled");
133 } 138 }
@@ -206,14 +211,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
206 asset = m_HGService.Get(id); 211 asset = m_HGService.Get(id);
207 if (asset != null) 212 if (asset != null)
208 { 213 {
209 // Now store it locally 214 // Now store it locally, if allowed
210 // For now, let me just do it for textures and scripts 215 if (m_AssetPerms.AllowedImport(asset.Type))
211 if (((AssetType)asset.Type == AssetType.Texture) ||
212 ((AssetType)asset.Type == AssetType.LSLBytecode) ||
213 ((AssetType)asset.Type == AssetType.LSLText))
214 {
215 m_GridService.Store(asset); 216 m_GridService.Store(asset);
216 } 217 else
218 return null;
217 } 219 }
218 } 220 }
219 else 221 else
@@ -328,7 +330,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
328 330
329 string id = string.Empty; 331 string id = string.Empty;
330 if (IsHG(asset.ID)) 332 if (IsHG(asset.ID))
331 id = m_HGService.Store(asset); 333 {
334 if (m_AssetPerms.AllowedExport(asset.Type))
335 id = m_HGService.Store(asset);
336 else
337 return String.Empty;
338 }
332 else 339 else
333 id = m_GridService.Store(asset); 340 id = m_GridService.Store(asset);
334 341
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
index 57ae549..4338133 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
@@ -46,8 +46,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
46 public class GridConnectorsTests : OpenSimTestCase 46 public class GridConnectorsTests : OpenSimTestCase
47 { 47 {
48 LocalGridServicesConnector m_LocalConnector; 48 LocalGridServicesConnector m_LocalConnector;
49 private void SetUp() 49
50 [SetUp]
51 public override void SetUp()
50 { 52 {
53 base.SetUp();
54
51 IConfigSource config = new IniConfigSource(); 55 IConfigSource config = new IniConfigSource();
52 config.AddConfig("Modules"); 56 config.AddConfig("Modules");
53 config.AddConfig("GridService"); 57 config.AddConfig("GridService");
@@ -71,8 +75,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
71 TestHelpers.InMethod(); 75 TestHelpers.InMethod();
72// log4net.Config.XmlConfigurator.Configure(); 76// log4net.Config.XmlConfigurator.Configure();
73 77
74 SetUp();
75
76 // Create 4 regions 78 // Create 4 regions
77 GridRegion r1 = new GridRegion(); 79 GridRegion r1 = new GridRegion();
78 r1.RegionName = "Test Region 1"; 80 r1.RegionName = "Test Region 1";
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 0a30905..82f49b0 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -65,8 +65,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
65 protected TaskInventoryItem m_soundItem; 65 protected TaskInventoryItem m_soundItem;
66 66
67 [SetUp] 67 [SetUp]
68 public void SetUp() 68 public override void SetUp()
69 { 69 {
70 base.SetUp();
71
72 // FIXME: Do something about this - relying on statics in unit tests causes trouble sooner or later
70 new SceneManager(); 73 new SceneManager();
71 74
72 m_archiverModule = new ArchiverModule(); 75 m_archiverModule = new ArchiverModule();
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index e257b57..67d218b 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -188,6 +188,22 @@ namespace OpenSim.Region.Framework.Scenes
188 188
189 public delegate void OnPluginConsoleDelegate(string[] args); 189 public delegate void OnPluginConsoleDelegate(string[] args);
190 190
191 /// <summary>
192 /// Triggered after <see cref="OpenSim.IApplicationPlugin.PostInitialise"/>
193 /// has been called for all <see cref="OpenSim.IApplicationPlugin"/>
194 /// loaded via <see cref="OpenSim.OpenSimBase.LoadPlugins"/>.
195 /// Handlers for this event are typically used to parse the arguments
196 /// from <see cref="OnPluginConsoleDelegate"/> in order to process or
197 /// filter the arguments and pass them onto <see cref="OpenSim.Region.CoreModules.Framework.InterfaceCommander.Commander.ProcessConsoleCommand"/>
198 /// </summary>
199 /// <remarks>
200 /// Triggered by <see cref="TriggerOnPluginConsole"/> in
201 /// <see cref="Scene.SendCommandToPlugins"/> via
202 /// <see cref="SceneManager.SendCommandToPluginModules"/> via
203 /// <see cref="OpenSim.OpenSimBase.HandleCommanderCommand"/> via
204 /// <see cref="OpenSim.OpenSimBase.AddPluginCommands"/> via
205 /// <see cref="OpenSim.OpenSimBase.StartupSpecific"/>
206 /// </remarks>
191 public event OnPluginConsoleDelegate OnPluginConsole; 207 public event OnPluginConsoleDelegate OnPluginConsole;
192 208
193 /// <summary> 209 /// <summary>
@@ -202,6 +218,18 @@ namespace OpenSim.Region.Framework.Scenes
202 218
203 public delegate void OnSetRootAgentSceneDelegate(UUID agentID, Scene scene); 219 public delegate void OnSetRootAgentSceneDelegate(UUID agentID, Scene scene);
204 220
221 /// <summary>
222 /// Triggered before the grunt work for adding a root agent to a
223 /// scene has been performed (resuming attachment scripts, physics,
224 /// animations etc.)
225 /// </summary>
226 /// <remarks>
227 /// Triggered before <see cref="OnMakeRootAgent"/>
228 /// by <see cref="TriggerSetRootAgentScene"/>
229 /// in <see cref="ScenePresence.MakeRootAgent"/>
230 /// via <see cref="Scene.AgentCrossing"/>
231 /// and <see cref="ScenePresence.CompleteMovement"/>
232 /// </remarks>
205 public event OnSetRootAgentSceneDelegate OnSetRootAgentScene; 233 public event OnSetRootAgentSceneDelegate OnSetRootAgentScene;
206 234
207 /// <summary> 235 /// <summary>
@@ -226,13 +254,45 @@ namespace OpenSim.Region.Framework.Scenes
226 /// <summary> 254 /// <summary>
227 /// Fired when an object is touched/grabbed. 255 /// Fired when an object is touched/grabbed.
228 /// </summary> 256 /// </summary>
257 /// <remarks>
229 /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of 258 /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of
230 /// the root part. 259 /// the root part.
260 /// Triggerd in response to <see cref="OpenSim.Framework.IClientAPI.OnGrabObject"/>
261 /// via <see cref="TriggerObjectGrab"/>
262 /// in <see cref="Scene.ProcessObjectGrab"/>
263 /// </remarks>
231 public event ObjectGrabDelegate OnObjectGrab; 264 public event ObjectGrabDelegate OnObjectGrab;
232 public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs); 265 public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs);
233 266
267 /// <summary>
268 /// Triggered when an object is being touched/grabbed continuously.
269 /// </summary>
270 /// <remarks>
271 /// Triggered in response to <see cref="OpenSim.Framework.IClientAPI.OnGrabUpdate"/>
272 /// via <see cref="TriggerObjectGrabbing"/>
273 /// in <see cref="Scene.ProcessObjectGrabUpdate"/>
274 /// </remarks>
234 public event ObjectGrabDelegate OnObjectGrabbing; 275 public event ObjectGrabDelegate OnObjectGrabbing;
276
277 /// <summary>
278 /// Triggered when an object stops being touched/grabbed.
279 /// </summary>
280 /// <remarks>
281 /// Triggered in response to <see cref="OpenSim.Framework.IClientAPI.OnDeGrabObject"/>
282 /// via <see cref="TriggerObjectDeGrab"/>
283 /// in <see cref="Scene.ProcessObjectDeGrab"/>
284 /// </remarks>
235 public event ObjectDeGrabDelegate OnObjectDeGrab; 285 public event ObjectDeGrabDelegate OnObjectDeGrab;
286
287 /// <summary>
288 /// Triggered when a script resets.
289 /// </summary>
290 /// <remarks>
291 /// Triggered by <see cref="TriggerScriptReset"/>
292 /// in <see cref="Scene.ProcessScriptReset"/>
293 /// via <see cref="OpenSim.Framework.IClientAPI.OnScriptReset"/>
294 /// via <see cref="OpenSim.Region.ClientStack.LindenUDP.LLClientView.HandleScriptReset"/>
295 /// </remarks>
236 public event ScriptResetDelegate OnScriptReset; 296 public event ScriptResetDelegate OnScriptReset;
237 297
238 public event OnPermissionErrorDelegate OnPermissionError; 298 public event OnPermissionErrorDelegate OnPermissionError;
@@ -242,17 +302,50 @@ namespace OpenSim.Region.Framework.Scenes
242 /// </summary> 302 /// </summary>
243 /// <remarks> 303 /// <remarks>
244 /// Occurs after OnNewScript. 304 /// Occurs after OnNewScript.
305 /// Triggered by <see cref="TriggerRezScript"/>
306 /// in <see cref="SceneObjectPartInventory.CreateScriptInstance"/>
245 /// </remarks> 307 /// </remarks>
246 public event NewRezScript OnRezScript; 308 public event NewRezScript OnRezScript;
247 public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource); 309 public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource);
248 310
249 public delegate void RemoveScript(uint localID, UUID itemID); 311 public delegate void RemoveScript(uint localID, UUID itemID);
312
313 /// <summary>
314 /// Triggered when a script is removed from an object.
315 /// </summary>
316 /// <remarks>
317 /// Triggered by <see cref="TriggerRemoveScript"/>
318 /// in <see cref="Scene.RemoveTaskInventory"/>,
319 /// <see cref="Scene.CreateAgentInventoryItemFromTask"/>,
320 /// <see cref="SceneObjectPartInventory.RemoveScriptInstance"/>,
321 /// <see cref="SceneObjectPartInventory.RemoveInventoryItem"/>
322 /// </remarks>
250 public event RemoveScript OnRemoveScript; 323 public event RemoveScript OnRemoveScript;
251 324
252 public delegate void StartScript(uint localID, UUID itemID); 325 public delegate void StartScript(uint localID, UUID itemID);
326
327 /// <summary>
328 /// Triggered when a script starts.
329 /// </summary>
330 /// <remarks>
331 /// Triggered by <see cref="TriggerStartScript"/>
332 /// in <see cref="Scene.SetScriptRunning"/>
333 /// via <see cref="OpenSim.Framework.IClientAPI.OnSetScriptRunning"/>,
334 /// via <see cref="OpenSim.Region.ClientStack.LindenUDP.HandleSetScriptRunning"/>
335 /// </remarks>
253 public event StartScript OnStartScript; 336 public event StartScript OnStartScript;
254 337
255 public delegate void StopScript(uint localID, UUID itemID); 338 public delegate void StopScript(uint localID, UUID itemID);
339
340 /// <summary>
341 /// Triggered when a script stops.
342 /// </summary>
343 /// <remarks>
344 /// Triggered by <see cref="TriggerStopScript"/>,
345 /// in <see cref="SceneObjectPartInventory.CreateScriptInstance"/>,
346 /// <see cref="SceneObjectPartInventory.StopScriptInstance"/>,
347 /// <see cref="Scene.SetScriptRunning"/>
348 /// </remarks>
256 public event StopScript OnStopScript; 349 public event StopScript OnStopScript;
257 350
258 public delegate bool SceneGroupMoved(UUID groupID, Vector3 delta); 351 public delegate bool SceneGroupMoved(UUID groupID, Vector3 delta);
@@ -303,6 +396,9 @@ namespace OpenSim.Region.Framework.Scenes
303 /// </summary> 396 /// </summary>
304 /// <remarks> 397 /// <remarks>
305 /// Occurs before OnRezScript 398 /// Occurs before OnRezScript
399 /// Triggered by <see cref="TriggerNewScript"/>
400 /// in <see cref="Scene.RezScriptFromAgentInventory"/>,
401 /// <see cref="Scene.RezNewScript"/>
306 /// </remarks> 402 /// </remarks>
307 public event NewScript OnNewScript; 403 public event NewScript OnNewScript;
308 404
@@ -337,6 +433,12 @@ namespace OpenSim.Region.Framework.Scenes
337 /// </summary> 433 /// </summary>
338 /// <remarks> 434 /// <remarks>
339 /// Triggered after the scene receives a client's upload of an updated script and has stored it in an asset. 435 /// Triggered after the scene receives a client's upload of an updated script and has stored it in an asset.
436 /// Triggered by <see cref="TriggerUpdateScript"/>
437 /// in <see cref="Scene.CapsUpdateTaskInventoryScriptAsset"/>
438 /// via <see cref="Scene.CapsUpdateTaskInventoryScriptAsset"/>
439 /// via <see cref="OpenSim.Region.ClientStack.Linden.BunchOfCaps.TaskScriptUpdated"/>
440 /// via <see cref="OpenSim.Region.ClientStack.Linden.TaskInventoryScriptUpdater.OnUpLoad"/>
441 /// via <see cref="OpenSim.Region.ClientStack.Linden.TaskInventoryScriptUpdater.uploaderCaps"/>
340 /// </remarks> 442 /// </remarks>
341 public event UpdateScript OnUpdateScript; 443 public event UpdateScript OnUpdateScript;
342 444
@@ -395,15 +497,36 @@ namespace OpenSim.Region.Framework.Scenes
395 public event ScriptColliding OnScriptLandColliderEnd; 497 public event ScriptColliding OnScriptLandColliderEnd;
396 498
397 public delegate void OnMakeChildAgentDelegate(ScenePresence presence); 499 public delegate void OnMakeChildAgentDelegate(ScenePresence presence);
500
501 /// <summary>
502 /// Triggered when an agent has been made a child agent of a scene.
503 /// </summary>
504 /// <remarks>
505 /// Triggered by <see cref="TriggerOnMakeChildAgent"/>
506 /// in <see cref="ScenePresence.MakeChildAgent"/>
507 /// via <see cref="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule.CrossAgentToNewRegionAsync"/>,
508 /// <see cref="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule.DoTeleport"/>,
509 /// <see cref="OpenSim.Region.CoreModules.InterGrid.KillAUser.ShutdownNoLogout"/>
510 /// </remarks>
398 public event OnMakeChildAgentDelegate OnMakeChildAgent; 511 public event OnMakeChildAgentDelegate OnMakeChildAgent;
399 512
400 public delegate void OnSaveNewWindlightProfileDelegate(); 513 public delegate void OnSaveNewWindlightProfileDelegate();
401 public delegate void OnSendNewWindlightProfileTargetedDelegate(RegionLightShareData wl, UUID user); 514 public delegate void OnSendNewWindlightProfileTargetedDelegate(RegionLightShareData wl, UUID user);
402 515
403 /// <summary> 516 /// <summary>
517 /// Triggered after the grunt work for adding a root agent to a
518 /// scene has been performed (resuming attachment scripts, physics,
519 /// animations etc.)
520 /// </summary>
521 /// <remarks>
404 /// This event is on the critical path for transferring an avatar from one region to another. Try and do 522 /// This event is on the critical path for transferring an avatar from one region to another. Try and do
405 /// as little work on this event as possible, or do work asynchronously. 523 /// as little work on this event as possible, or do work asynchronously.
406 /// </summary> 524 /// Triggered after <see cref="OnSetRootAgentScene"/>
525 /// by <see cref="TriggerOnMakeRootAgent"/>
526 /// in <see cref="ScenePresence.MakeRootAgent"/>
527 /// via <see cref="Scene.AgentCrossing"/>
528 /// and <see cref="ScenePresence.CompleteMovement"/>
529 /// </remarks>
407 public event Action<ScenePresence> OnMakeRootAgent; 530 public event Action<ScenePresence> OnMakeRootAgent;
408 531
409 public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted; 532 public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted;
@@ -429,9 +552,10 @@ namespace OpenSim.Region.Framework.Scenes
429 public event AvatarKillData OnAvatarKilled; 552 public event AvatarKillData OnAvatarKilled;
430 public delegate void AvatarKillData(uint KillerLocalID, ScenePresence avatar); 553 public delegate void AvatarKillData(uint KillerLocalID, ScenePresence avatar);
431 554
432// public delegate void ScriptTimerEvent(uint localID, double timerinterval); 555 /*
433 556 public delegate void ScriptTimerEvent(uint localID, double timerinterval);
434// public event ScriptTimerEvent OnScriptTimerEvent; 557 public event ScriptTimerEvent OnScriptTimerEvent;
558 */
435 559
436 public delegate void EstateToolsSunUpdate(ulong regionHandle, bool FixedTime, bool EstateSun, float LindenHour); 560 public delegate void EstateToolsSunUpdate(ulong regionHandle, bool FixedTime, bool EstateSun, float LindenHour);
437 public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID); 561 public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID);
@@ -441,12 +565,27 @@ namespace OpenSim.Region.Framework.Scenes
441 /// <summary> 565 /// <summary>
442 /// Triggered when an object is added to the scene. 566 /// Triggered when an object is added to the scene.
443 /// </summary> 567 /// </summary>
568 /// <remarks>
569 /// Triggered by <see cref="TriggerObjectAddedToScene"/>
570 /// in <see cref="Scene.AddNewSceneObject"/>,
571 /// <see cref="Scene.DuplicateObject"/>,
572 /// <see cref="Scene.doObjectDuplicateOnRay"/>
573 /// </remarks>
444 public event Action<SceneObjectGroup> OnObjectAddedToScene; 574 public event Action<SceneObjectGroup> OnObjectAddedToScene;
445 575
446 /// <summary> 576 /// <summary>
447 /// Triggered when an object is removed from the scene. 577 /// Delegate for <see cref="OnObjectBeingRemovedFromScene"/>
448 /// </summary> 578 /// </summary>
579 /// <param name="obj">The object being removed from the scene</param>
449 public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj); 580 public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj);
581
582 /// <summary>
583 /// Triggered when an object is removed from the scene.
584 /// </summary>
585 /// <remarks>
586 /// Triggered by <see cref="TriggerObjectBeingRemovedFromScene"/>
587 /// in <see cref="Scene.DeleteSceneObject"/>
588 /// </remarks>
450 public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene; 589 public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene;
451 590
452 public delegate void NoticeNoLandDataFromStorage(); 591 public delegate void NoticeNoLandDataFromStorage();
@@ -632,9 +771,28 @@ namespace OpenSim.Region.Framework.Scenes
632 public event PrimsLoaded OnPrimsLoaded; 771 public event PrimsLoaded OnPrimsLoaded;
633 772
634 public delegate void TeleportStart(IClientAPI client, GridRegion destination, GridRegion finalDestination, uint teleportFlags, bool gridLogout); 773 public delegate void TeleportStart(IClientAPI client, GridRegion destination, GridRegion finalDestination, uint teleportFlags, bool gridLogout);
774
775 /// <summary>
776 /// Triggered when a teleport starts
777 /// </summary>
778 /// <remarks>
779 /// Triggered by <see cref="TriggerTeleportStart"/>
780 /// in <see cref="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule.CreateAgent"/>
781 /// and <see cref="OpenSim.Region.CoreModules.Framework.EntityTransfer.HGEntityTransferModule.CreateAgent"/>
782 /// via <see cref="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule.DoTeleport"/>
783 /// </remarks>
635 public event TeleportStart OnTeleportStart; 784 public event TeleportStart OnTeleportStart;
636 785
637 public delegate void TeleportFail(IClientAPI client, bool gridLogout); 786 public delegate void TeleportFail(IClientAPI client, bool gridLogout);
787
788 /// <summary>
789 /// Trigered when a teleport fails.
790 /// </summary>
791 /// <remarks>
792 /// Triggered by <see cref="TriggerTeleportFail"/>
793 /// in <see cref="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule.Fail"/>
794 /// via <see cref="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule.DoTeleport"/>
795 /// </remarks>
638 public event TeleportFail OnTeleportFail; 796 public event TeleportFail OnTeleportFail;
639 797
640 public class MoneyTransferArgs : EventArgs 798 public class MoneyTransferArgs : EventArgs
@@ -642,7 +800,9 @@ namespace OpenSim.Region.Framework.Scenes
642 public UUID sender; 800 public UUID sender;
643 public UUID receiver; 801 public UUID receiver;
644 802
645 // Always false. The SL protocol sucks. 803 /// <summary>
804 /// Always false. The SL protocol sucks.
805 /// </summary>
646 public bool authenticated = false; 806 public bool authenticated = false;
647 807
648 public int amount; 808 public int amount;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index ee5f6df..129bf09 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -106,7 +106,7 @@ namespace OpenSim.Region.Framework.Scenes
106 /// <summary> 106 /// <summary>
107 /// Minimum value of the size of a non-physical prim in each axis 107 /// Minimum value of the size of a non-physical prim in each axis
108 /// </summary> 108 /// </summary>
109 public float m_minNonphys = 0.01f; 109 public float m_minNonphys = 0.001f;
110 110
111 /// <summary> 111 /// <summary>
112 /// Maximum value of the size of a non-physical prim in each axis 112 /// Maximum value of the size of a non-physical prim in each axis
@@ -769,13 +769,13 @@ namespace OpenSim.Region.Framework.Scenes
769 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); 769 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
770 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); 770 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
771 771
772 m_minNonphys = startupConfig.GetFloat("NonphysicalPrimMin", m_minNonphys); 772 m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys);
773 if (RegionInfo.NonphysPrimMin > 0) 773 if (RegionInfo.NonphysPrimMin > 0)
774 { 774 {
775 m_minNonphys = RegionInfo.NonphysPrimMin; 775 m_minNonphys = RegionInfo.NonphysPrimMin;
776 } 776 }
777 777
778 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); 778 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
779 if (RegionInfo.NonphysPrimMax > 0) 779 if (RegionInfo.NonphysPrimMax > 0)
780 { 780 {
781 m_maxNonphys = RegionInfo.NonphysPrimMax; 781 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -895,6 +895,8 @@ namespace OpenSim.Region.Framework.Scenes
895 } 895 }
896 896
897 // FIXME: Ultimately this should be in a module. 897 // FIXME: Ultimately this should be in a module.
898 SendPeriodicAppearanceUpdates = true;
899
898 IConfig appearanceConfig = m_config.Configs["Appearance"]; 900 IConfig appearanceConfig = m_config.Configs["Appearance"];
899 if (appearanceConfig != null) 901 if (appearanceConfig != null)
900 { 902 {
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 411e421..b5ef7b0 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -52,26 +52,23 @@ namespace OpenSim.Region.Framework.Scenes
52 public class UuidGatherer 52 public class UuidGatherer
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55
56 /// <summary>
57 /// Asset cache used for gathering assets
58 /// </summary>
59 protected IAssetService m_assetCache;
60
61 /// <summary>
62 /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
63 /// asset was found by the asset service.
64 /// </summary>
65 private AssetBase m_requestedObjectAsset;
66 55
67 /// <summary> 56 protected IAssetService m_assetService;
68 /// Signal whether we are currently waiting for the asset service to deliver an asset. 57
69 /// </summary> 58// /// <summary>
70 private bool m_waitingForObjectAsset; 59// /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
60// /// asset was found by the asset service.
61// /// </summary>
62// private AssetBase m_requestedObjectAsset;
63//
64// /// <summary>
65// /// Signal whether we are currently waiting for the asset service to deliver an asset.
66// /// </summary>
67// private bool m_waitingForObjectAsset;
71 68
72 public UuidGatherer(IAssetService assetCache) 69 public UuidGatherer(IAssetService assetCache)
73 { 70 {
74 m_assetCache = assetCache; 71 m_assetService = assetCache;
75 } 72 }
76 73
77 /// <summary> 74 /// <summary>
@@ -191,18 +188,18 @@ namespace OpenSim.Region.Framework.Scenes
191 } 188 }
192 } 189 }
193 190
194 /// <summary> 191// /// <summary>
195 /// The callback made when we request the asset for an object from the asset service. 192// /// The callback made when we request the asset for an object from the asset service.
196 /// </summary> 193// /// </summary>
197 private void AssetReceived(string id, Object sender, AssetBase asset) 194// private void AssetReceived(string id, Object sender, AssetBase asset)
198 { 195// {
199 lock (this) 196// lock (this)
200 { 197// {
201 m_requestedObjectAsset = asset; 198// m_requestedObjectAsset = asset;
202 m_waitingForObjectAsset = false; 199// m_waitingForObjectAsset = false;
203 Monitor.Pulse(this); 200// Monitor.Pulse(this);
204 } 201// }
205 } 202// }
206 203
207 /// <summary> 204 /// <summary>
208 /// Get an asset synchronously, potentially using an asynchronous callback. If the 205 /// Get an asset synchronously, potentially using an asynchronous callback. If the
@@ -212,25 +209,29 @@ namespace OpenSim.Region.Framework.Scenes
212 /// <returns></returns> 209 /// <returns></returns>
213 protected virtual AssetBase GetAsset(UUID uuid) 210 protected virtual AssetBase GetAsset(UUID uuid)
214 { 211 {
215 m_waitingForObjectAsset = true; 212 return m_assetService.Get(uuid.ToString());
216 m_assetCache.Get(uuid.ToString(), this, AssetReceived);
217
218 // The asset cache callback can either
219 //
220 // 1. Complete on the same thread (if the asset is already in the cache) or
221 // 2. Come in via a different thread (if we need to go fetch it).
222 //
223 // The code below handles both these alternatives.
224 lock (this)
225 {
226 if (m_waitingForObjectAsset)
227 {
228 Monitor.Wait(this);
229 m_waitingForObjectAsset = false;
230 }
231 }
232 213
233 return m_requestedObjectAsset; 214 // XXX: Switching to do this synchronously where the call was async before but we always waited for it
215 // to complete anyway!
216// m_waitingForObjectAsset = true;
217// m_assetCache.Get(uuid.ToString(), this, AssetReceived);
218//
219// // The asset cache callback can either
220// //
221// // 1. Complete on the same thread (if the asset is already in the cache) or
222// // 2. Come in via a different thread (if we need to go fetch it).
223// //
224// // The code below handles both these alternatives.
225// lock (this)
226// {
227// if (m_waitingForObjectAsset)
228// {
229// Monitor.Wait(this);
230// m_waitingForObjectAsset = false;
231// }
232// }
233//
234// return m_requestedObjectAsset;
234 } 235 }
235 236
236 /// <summary> 237 /// <summary>
@@ -361,4 +362,47 @@ namespace OpenSim.Region.Framework.Scenes
361 } 362 }
362 } 363 }
363 } 364 }
365
366 public class HGUuidGatherer : UuidGatherer
367 {
368 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
369
370 protected string m_assetServerURL;
371
372 public HGUuidGatherer(IAssetService assetService, string assetServerURL)
373 : base(assetService)
374 {
375 m_assetServerURL = assetServerURL;
376 if (!m_assetServerURL.EndsWith("/") && !m_assetServerURL.EndsWith("="))
377 m_assetServerURL = m_assetServerURL + "/";
378 }
379
380 protected override AssetBase GetAsset(UUID uuid)
381 {
382 if (string.Empty == m_assetServerURL)
383 return base.GetAsset(uuid);
384 else
385 return FetchAsset(uuid);
386 }
387
388 public AssetBase FetchAsset(UUID assetID)
389 {
390
391 // Test if it's already here
392 AssetBase asset = m_assetService.Get(assetID.ToString());
393 if (asset == null)
394 {
395 // It's not, so fetch it from abroad
396 asset = m_assetService.Get(m_assetServerURL + assetID.ToString());
397 if (asset != null)
398 m_log.DebugFormat("[HGUUIDGatherer]: Copied asset {0} from {1} to local asset server", assetID, m_assetServerURL);
399 else
400 m_log.DebugFormat("[HGUUIDGatherer]: Failed to fetch asset {0} from {1}", assetID, m_assetServerURL);
401 }
402 //else
403 // m_log.DebugFormat("[HGUUIDGatherer]: Asset {0} from {1} was already here", assetID, m_assetServerURL);
404
405 return asset;
406 }
407 }
364} 408}
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
index ca956fb..a014798 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
@@ -231,12 +231,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
231 if (m_server == null || m_baseNick == null || m_ircChannel == null || m_user == null) 231 if (m_server == null || m_baseNick == null || m_ircChannel == null || m_user == null)
232 throw new Exception("Invalid connector configuration"); 232 throw new Exception("Invalid connector configuration");
233 233
234 // Generate an initial nickname if randomizing is enabled 234 // Generate an initial nickname
235 235
236 if (m_randomizeNick) 236 if (m_randomizeNick)
237 {
238 m_nick = m_baseNick + Util.RandomClass.Next(1, 99); 237 m_nick = m_baseNick + Util.RandomClass.Next(1, 99);
239 } 238 else
239 m_nick = m_baseNick;
240 240
241 m_log.InfoFormat("[IRC-Connector-{0}]: Initialization complete", idn); 241 m_log.InfoFormat("[IRC-Connector-{0}]: Initialization complete", idn);
242 242
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 9570669..8d06d83 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -5871,27 +5871,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5871 /// Returns the index of the first occurrence of test 5871 /// Returns the index of the first occurrence of test
5872 /// in src. 5872 /// in src.
5873 /// </summary> 5873 /// </summary>
5874 5874 /// <param name="src">Source list</param>
5875 /// <param name="test">List to search for</param>
5876 /// <returns>
5877 /// The index number of the point in src where test was found if it was found.
5878 /// Otherwise returns -1
5879 /// </returns>
5875 public LSL_Integer llListFindList(LSL_List src, LSL_List test) 5880 public LSL_Integer llListFindList(LSL_List src, LSL_List test)
5876 { 5881 {
5877
5878 int index = -1; 5882 int index = -1;
5879 int length = src.Length - test.Length + 1; 5883 int length = src.Length - test.Length + 1;
5880 5884
5881 m_host.AddScriptLPS(1); 5885 m_host.AddScriptLPS(1);
5882 5886
5883 // If either list is empty, do not match 5887 // If either list is empty, do not match
5884
5885 if (src.Length != 0 && test.Length != 0) 5888 if (src.Length != 0 && test.Length != 0)
5886 { 5889 {
5887 for (int i = 0; i < length; i++) 5890 for (int i = 0; i < length; i++)
5888 { 5891 {
5889 if (src.Data[i].Equals(test.Data[0])) 5892 // Why this piece of insanity? This is because most script constants are C# value types (e.g. int)
5893 // rather than wrapped LSL types. Such a script constant does not have int.Equal(LSL_Integer) code
5894 // and so the comparison fails even if the LSL_Integer conceptually has the same value.
5895 // Therefore, here we test Equals on both the source and destination objects.
5896 // However, a future better approach may be use LSL struct script constants (e.g. LSL_Integer(1)).
5897 if (src.Data[i].Equals(test.Data[0]) || test.Data[0].Equals(src.Data[i]))
5890 { 5898 {
5891 int j; 5899 int j;
5892 for (j = 1; j < test.Length; j++) 5900 for (j = 1; j < test.Length; j++)
5893 if (!src.Data[i+j].Equals(test.Data[j])) 5901 if (!(src.Data[i+j].Equals(test.Data[j]) || test.Data[j].Equals(src.Data[i+j])))
5894 break; 5902 break;
5903
5895 if (j == test.Length) 5904 if (j == test.Length)
5896 { 5905 {
5897 index = i; 5906 index = i;
@@ -5902,19 +5911,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5902 } 5911 }
5903 5912
5904 return index; 5913 return index;
5905
5906 } 5914 }
5907 5915
5908 public LSL_String llGetObjectName() 5916 public LSL_String llGetObjectName()
5909 { 5917 {
5910 m_host.AddScriptLPS(1); 5918 m_host.AddScriptLPS(1);
5911 return m_host.Name!=null?m_host.Name:String.Empty; 5919 return m_host.Name !=null ? m_host.Name : String.Empty;
5912 } 5920 }
5913 5921
5914 public void llSetObjectName(string name) 5922 public void llSetObjectName(string name)
5915 { 5923 {
5916 m_host.AddScriptLPS(1); 5924 m_host.AddScriptLPS(1);
5917 m_host.Name = name!=null?name:String.Empty; 5925 m_host.Name = name != null ? name : String.Empty;
5918 } 5926 }
5919 5927
5920 public LSL_String llGetDate() 5928 public LSL_String llGetDate()
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs
new file mode 100644
index 0000000..dd23be8
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs
@@ -0,0 +1,134 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using NUnit.Framework;
31using OpenSim.Framework;
32using OpenSim.Tests.Common;
33using OpenSim.Region.ScriptEngine.Shared;
34using OpenSim.Region.Framework.Scenes;
35using Nini.Config;
36using OpenSim.Region.ScriptEngine.Shared.Api;
37using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
38using OpenMetaverse;
39using OpenSim.Tests.Common.Mock;
40
41using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
42using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
43using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
44using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
45
46namespace OpenSim.Region.ScriptEngine.Shared.Tests
47{
48 [TestFixture]
49 public class LSL_ApiListTests
50 {
51 private LSL_Api m_lslApi;
52
53 [SetUp]
54 public void SetUp()
55 {
56 IConfigSource initConfigSource = new IniConfigSource();
57 IConfig config = initConfigSource.AddConfig("XEngine");
58 config.Set("Enabled", "true");
59
60 Scene scene = new SceneHelpers().SetupScene();
61 SceneObjectPart part = SceneHelpers.AddSceneObject(scene).RootPart;
62
63 XEngine.XEngine engine = new XEngine.XEngine();
64 engine.Initialise(initConfigSource);
65 engine.AddRegion(scene);
66
67 m_lslApi = new LSL_Api();
68 m_lslApi.Initialize(engine, part, null);
69 }
70
71 [Test]
72 public void TestllListFindList()
73 {
74 TestHelpers.InMethod();
75
76 LSL_List src = new LSL_List(new LSL_Integer(1), new LSL_Integer(2), new LSL_Integer(3));
77
78 {
79 // Test for a single item that should be found
80 int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(4)));
81 Assert.That(result, Is.EqualTo(-1));
82 }
83
84 {
85 // Test for a single item that should be found
86 int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(2)));
87 Assert.That(result, Is.EqualTo(1));
88 }
89
90 {
91 // Test for a constant that should be found
92 int result = m_lslApi.llListFindList(src, new LSL_List(ScriptBaseClass.AGENT));
93 Assert.That(result, Is.EqualTo(0));
94 }
95
96 {
97 // Test for a list that should be found
98 int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(2), new LSL_Integer(3)));
99 Assert.That(result, Is.EqualTo(1));
100 }
101
102 {
103 // Test for a single item not in the list
104 int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(4)));
105 Assert.That(result, Is.EqualTo(-1));
106 }
107
108 {
109 // Test for something that should not be cast
110 int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_String("4")));
111 Assert.That(result, Is.EqualTo(-1));
112 }
113
114 {
115 // Test for a list not in the list
116 int result
117 = m_lslApi.llListFindList(
118 src, new LSL_List(new LSL_Integer(2), new LSL_Integer(3), new LSL_Integer(4)));
119 Assert.That(result, Is.EqualTo(-1));
120 }
121
122 {
123 LSL_List srcWithConstants
124 = new LSL_List(new LSL_Integer(3), ScriptBaseClass.AGENT, ScriptBaseClass.OS_NPC_LAND_AT_TARGET);
125
126 // Test for constants that appears in the source list that should be found
127 int result
128 = m_lslApi.llListFindList(srcWithConstants, new LSL_List(new LSL_Integer(1), new LSL_Integer(2)));
129
130 Assert.That(result, Is.EqualTo(1));
131 }
132 }
133 }
134 } \ No newline at end of file
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 47d22b9..0f7d7c6 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -58,9 +58,11 @@ namespace OpenSim.Services.HypergridService
58 private static IUserAgentService m_UserAgentService; 58 private static IUserAgentService m_UserAgentService;
59 private static ISimulationService m_SimulationService; 59 private static ISimulationService m_SimulationService;
60 60
61 protected string m_AllowedClients = string.Empty; 61 private static string m_AllowedClients = string.Empty;
62 protected string m_DeniedClients = string.Empty; 62 private static string m_DeniedClients = string.Empty;
63 private static bool m_ForeignAgentsAllowed = true; 63 private static bool m_ForeignAgentsAllowed = true;
64 private static List<string> m_ForeignsAllowedExceptions = new List<string>();
65 private static List<string> m_ForeignsDisallowedExceptions = new List<string>();
64 66
65 private static UUID m_ScopeID; 67 private static UUID m_ScopeID;
66 private static bool m_AllowTeleportsToAnyRegion; 68 private static bool m_AllowTeleportsToAnyRegion;
@@ -113,6 +115,9 @@ namespace OpenSim.Services.HypergridService
113 m_DeniedClients = serverConfig.GetString("DeniedClients", string.Empty); 115 m_DeniedClients = serverConfig.GetString("DeniedClients", string.Empty);
114 m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true); 116 m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true);
115 117
118 LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_ForeignsAllowedExceptions);
119 LoadDomainExceptionsFromConfig(serverConfig, "DisallowExcept", m_ForeignsDisallowedExceptions);
120
116 if (m_GridService == null || m_PresenceService == null || m_SimulationService == null) 121 if (m_GridService == null || m_PresenceService == null || m_SimulationService == null)
117 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function."); 122 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function.");
118 123
@@ -125,6 +130,15 @@ namespace OpenSim.Services.HypergridService
125 { 130 {
126 } 131 }
127 132
133 protected void LoadDomainExceptionsFromConfig(IConfig config, string variable, List<string> exceptions)
134 {
135 string value = config.GetString(variable, string.Empty);
136 string[] parts = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
137
138 foreach (string s in parts)
139 exceptions.Add(s.Trim());
140 }
141
128 public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason) 142 public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason)
129 { 143 {
130 regionID = UUID.Zero; 144 regionID = UUID.Zero;
@@ -260,14 +274,25 @@ namespace OpenSim.Services.HypergridService
260 m_log.DebugFormat("[GATEKEEPER SERVICE]: User is ok"); 274 m_log.DebugFormat("[GATEKEEPER SERVICE]: User is ok");
261 275
262 // 276 //
263 // Foreign agents allowed 277 // Foreign agents allowed? Exceptions?
264 // 278 //
265 if (account == null && !m_ForeignAgentsAllowed) 279 if (account == null)
266 { 280 {
267 reason = "Unauthorized"; 281 bool allowed = m_ForeignAgentsAllowed;
268 m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agents are not permitted {0} {1}. Refusing service.", 282
269 aCircuit.firstname, aCircuit.lastname); 283 if (m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsAllowedExceptions))
270 return false; 284 allowed = false;
285
286 if (!m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsDisallowedExceptions))
287 allowed = true;
288
289 if (!allowed)
290 {
291 reason = "Destination does not allow visitors from your world";
292 m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agents are not permitted {0} {1} @ {2}. Refusing service.",
293 aCircuit.firstname, aCircuit.lastname, aCircuit.ServiceURLs["HomeURI"]);
294 return false;
295 }
271 } 296 }
272 297
273 // May want to authorize 298 // May want to authorize
@@ -393,6 +418,27 @@ namespace OpenSim.Services.HypergridService
393 418
394 #region Misc 419 #region Misc
395 420
421 private bool IsException(AgentCircuitData aCircuit, List<string> exceptions)
422 {
423 bool exception = false;
424 if (exceptions.Count > 0) // we have exceptions
425 {
426 // Retrieve the visitor's origin
427 string userURL = aCircuit.ServiceURLs["HomeURI"].ToString();
428 if (!userURL.EndsWith("/"))
429 userURL += "/";
430
431 if (exceptions.Find(delegate(string s)
432 {
433 if (!s.EndsWith("/"))
434 s += "/";
435 return s == userURL;
436 }) != null)
437 exception = true;
438 }
439
440 return exception;
441 }
396 442
397 #endregion 443 #endregion
398 } 444 }
diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs
index db98166..84dec8d 100644
--- a/OpenSim/Services/HypergridService/HGAssetService.cs
+++ b/OpenSim/Services/HypergridService/HGAssetService.cs
@@ -58,6 +58,8 @@ namespace OpenSim.Services.HypergridService
58 58
59 private UserAccountCache m_Cache; 59 private UserAccountCache m_Cache;
60 60
61 private AssetPermissions m_AssetPerms;
62
61 public HGAssetService(IConfigSource config, string configName) : base(config, configName) 63 public HGAssetService(IConfigSource config, string configName) : base(config, configName)
62 { 64 {
63 m_log.Debug("[HGAsset Service]: Starting"); 65 m_log.Debug("[HGAsset Service]: Starting");
@@ -80,6 +82,10 @@ namespace OpenSim.Services.HypergridService
80 m_HomeURL = assetConfig.GetString("HomeURI", m_HomeURL); 82 m_HomeURL = assetConfig.GetString("HomeURI", m_HomeURL);
81 83
82 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); 84 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
85
86 // Permissions
87 m_AssetPerms = new AssetPermissions(assetConfig);
88
83 } 89 }
84 90
85 #region IAssetService overrides 91 #region IAssetService overrides
@@ -90,6 +96,9 @@ namespace OpenSim.Services.HypergridService
90 if (asset == null) 96 if (asset == null)
91 return null; 97 return null;
92 98
99 if (!m_AssetPerms.AllowedExport(asset.Type))
100 return null;
101
93 if (asset.Metadata.Type == (sbyte)AssetType.Object) 102 if (asset.Metadata.Type == (sbyte)AssetType.Object)
94 asset.Data = AdjustIdentifiers(asset.Data); ; 103 asset.Data = AdjustIdentifiers(asset.Data); ;
95 104
@@ -112,16 +121,27 @@ namespace OpenSim.Services.HypergridService
112 121
113 public override byte[] GetData(string id) 122 public override byte[] GetData(string id)
114 { 123 {
115 byte[] data = base.GetData(id); 124 AssetBase asset = Get(id);
125
126 if (asset == null)
127 return null;
116 128
117 if (data == null) 129 if (!m_AssetPerms.AllowedExport(asset.Type))
118 return null; 130 return null;
119 131
120 return AdjustIdentifiers(data); 132 return asset.Data;
121 } 133 }
122 134
123 //public virtual bool Get(string id, Object sender, AssetRetrieved handler) 135 //public virtual bool Get(string id, Object sender, AssetRetrieved handler)
124 136
137 public override string Store(AssetBase asset)
138 {
139 if (!m_AssetPerms.AllowedImport(asset.Type))
140 return string.Empty;
141
142 return base.Store(asset);
143 }
144
125 public override bool Delete(string id) 145 public override bool Delete(string id)
126 { 146 {
127 // NOGO 147 // NOGO
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index a49993c..56aafe6 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -77,6 +77,10 @@ namespace OpenSim.Services.HypergridService
77 77
78 protected static bool m_BypassClientVerification; 78 protected static bool m_BypassClientVerification;
79 79
80 private static Dictionary<int, bool> m_ForeignTripsAllowed = new Dictionary<int, bool>();
81 private static Dictionary<int, List<string>> m_TripsAllowedExceptions = new Dictionary<int, List<string>>();
82 private static Dictionary<int, List<string>> m_TripsDisallowedExceptions = new Dictionary<int, List<string>>();
83
80 public UserAgentService(IConfigSource config) : this(config, null) 84 public UserAgentService(IConfigSource config) : this(config, null)
81 { 85 {
82 } 86 }
@@ -121,6 +125,12 @@ namespace OpenSim.Services.HypergridService
121 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); 125 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
122 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountService, args); 126 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountService, args);
123 127
128 m_LevelOutsideContacts = serverConfig.GetInt("LevelOutsideContacts", 0);
129
130 LoadTripPermissionsFromConfig(serverConfig, "ForeignTripsAllowed");
131 LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_TripsAllowedExceptions);
132 LoadDomainExceptionsFromConfig(serverConfig, "DisallowExcept", m_TripsDisallowedExceptions);
133
124 m_GridName = serverConfig.GetString("ExternalName", string.Empty); 134 m_GridName = serverConfig.GetString("ExternalName", string.Empty);
125 if (m_GridName == string.Empty) 135 if (m_GridName == string.Empty)
126 { 136 {
@@ -130,10 +140,43 @@ namespace OpenSim.Services.HypergridService
130 if (!m_GridName.EndsWith("/")) 140 if (!m_GridName.EndsWith("/"))
131 m_GridName = m_GridName + "/"; 141 m_GridName = m_GridName + "/";
132 142
133 m_LevelOutsideContacts = serverConfig.GetInt("LevelOutsideContacts", 0);
134 } 143 }
135 } 144 }
136 145
146 protected void LoadTripPermissionsFromConfig(IConfig config, string variable)
147 {
148 foreach (string keyName in config.GetKeys())
149 {
150 if (keyName.StartsWith(variable + "_Level_"))
151 {
152 int level = 0;
153 if (Int32.TryParse(keyName.Replace(variable + "_Level_", ""), out level))
154 m_ForeignTripsAllowed.Add(level, config.GetBoolean(keyName, true));
155 }
156 }
157 }
158
159 protected void LoadDomainExceptionsFromConfig(IConfig config, string variable, Dictionary<int, List<string>> exceptions)
160 {
161 foreach (string keyName in config.GetKeys())
162 {
163 if (keyName.StartsWith(variable + "_Level_"))
164 {
165 int level = 0;
166 if (Int32.TryParse(keyName.Replace(variable + "_Level_", ""), out level) && !exceptions.ContainsKey(level))
167 {
168 exceptions.Add(level, new List<string>());
169 string value = config.GetString(keyName, string.Empty);
170 string[] parts = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
171
172 foreach (string s in parts)
173 exceptions[level].Add(s.Trim());
174 }
175 }
176 }
177 }
178
179
137 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) 180 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
138 { 181 {
139 position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY; 182 position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY;
@@ -166,13 +209,39 @@ namespace OpenSim.Services.HypergridService
166 m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}", 209 m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}",
167 agentCircuit.firstname, agentCircuit.lastname, ((clientIP == null) ? "stored IP" : clientIP.Address.ToString()), gatekeeper.ServerURI); 210 agentCircuit.firstname, agentCircuit.lastname, ((clientIP == null) ? "stored IP" : clientIP.Address.ToString()), gatekeeper.ServerURI);
168 211
169 if (m_UserAccountService.GetUserAccount(UUID.Zero, agentCircuit.AgentID) == null) 212 string gridName = gatekeeper.ServerURI;
213
214 UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, agentCircuit.AgentID);
215 if (account == null)
170 { 216 {
171 m_log.WarnFormat("[USER AGENT SERVICE]: Someone attempted to lauch a foreign user from here {0} {1}", agentCircuit.firstname, agentCircuit.lastname); 217 m_log.WarnFormat("[USER AGENT SERVICE]: Someone attempted to lauch a foreign user from here {0} {1}", agentCircuit.firstname, agentCircuit.lastname);
172 reason = "Forbidden to launch your agents from here"; 218 reason = "Forbidden to launch your agents from here";
173 return false; 219 return false;
174 } 220 }
175 221
222 // Is this user allowed to go there?
223 if (m_GridName != gridName)
224 {
225 if (m_ForeignTripsAllowed.ContainsKey(account.UserLevel))
226 {
227 bool allowed = m_ForeignTripsAllowed[account.UserLevel];
228
229 if (m_ForeignTripsAllowed[account.UserLevel] && IsException(gridName, account.UserLevel, m_TripsAllowedExceptions))
230 allowed = false;
231
232 if (!m_ForeignTripsAllowed[account.UserLevel] && IsException(gridName, account.UserLevel, m_TripsDisallowedExceptions))
233 allowed = true;
234
235 if (!allowed)
236 {
237 reason = "Your world does not allow you to visit the destination";
238 m_log.InfoFormat("[USER AGENT SERVICE]: Agents not permitted to visit {0}. Refusing service.", gridName);
239 return false;
240 }
241 }
242 }
243
244
176 // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination 245 // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination
177 GridRegion region = new GridRegion(gatekeeper); 246 GridRegion region = new GridRegion(gatekeeper);
178 region.ServerURI = gatekeeper.ServerURI; 247 region.ServerURI = gatekeeper.ServerURI;
@@ -189,7 +258,6 @@ namespace OpenSim.Services.HypergridService
189 258
190 bool success = false; 259 bool success = false;
191 string myExternalIP = string.Empty; 260 string myExternalIP = string.Empty;
192 string gridName = gatekeeper.ServerURI;
193 261
194 m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}", m_GridName, gridName); 262 m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}", m_GridName, gridName);
195 263
@@ -586,6 +654,35 @@ namespace OpenSim.Services.HypergridService
586 else 654 else
587 return UUID.Zero; 655 return UUID.Zero;
588 } 656 }
657
658 #region Misc
659
660 private bool IsException(string dest, int level, Dictionary<int, List<string>> exceptions)
661 {
662 if (!exceptions.ContainsKey(level))
663 return false;
664
665 bool exception = false;
666 if (exceptions[level].Count > 0) // we have exceptions
667 {
668 string destination = dest;
669 if (!destination.EndsWith("/"))
670 destination += "/";
671
672 if (exceptions[level].Find(delegate(string s)
673 {
674 if (!s.EndsWith("/"))
675 s += "/";
676 return s == destination;
677 }) != null)
678 exception = true;
679 }
680
681 return exception;
682 }
683
684 #endregion
685
589 } 686 }
590 687
591 class TravelingAgentInfo 688 class TravelingAgentInfo