aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTORS.txt2
-rw-r--r--OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs2
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs6
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs10
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs10
-rw-r--r--OpenSim/Data/MySQL/MySQLAuthenticationData.cs8
-rw-r--r--OpenSim/Data/MySQL/MySQLEstateData.cs8
-rw-r--r--OpenSim/Data/MySQL/MySQLGenericTableHandler.cs7
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs9
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs8
-rw-r--r--OpenSim/Data/MySQL/MySQLUserAccountData.cs2
-rw-r--r--OpenSim/Data/Null/NullRegionData.cs48
-rw-r--r--OpenSim/Data/Null/NullUserAccountData.cs65
-rw-r--r--OpenSim/Data/SQLite/SQLiteSimulationData.cs6
-rw-r--r--OpenSim/Data/Tests/AssetTests.cs25
-rw-r--r--OpenSim/Data/Tests/EstateTests.cs32
-rw-r--r--OpenSim/Data/Tests/InventoryTests.cs41
-rw-r--r--OpenSim/Data/Tests/PropertyCompareConstraint.cs1
-rw-r--r--OpenSim/Data/Tests/PropertyScrambler.cs2
-rw-r--r--OpenSim/Data/Tests/RegionTests.cs99
-rw-r--r--OpenSim/Framework/AgentCircuitData.cs30
-rw-r--r--OpenSim/Framework/Capabilities/Caps.cs1
-rw-r--r--OpenSim/Framework/Capabilities/CapsHandlers.cs2
-rw-r--r--OpenSim/Framework/EstateSettings.cs33
-rw-r--r--OpenSim/Framework/IMoneyModule.cs1
-rw-r--r--OpenSim/Framework/PrimitiveBaseShape.cs2
-rw-r--r--OpenSim/Framework/Serialization/External/OspResolver.cs19
-rw-r--r--OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs2
-rw-r--r--OpenSim/Framework/Servers/BaseOpenSimServer.cs27
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs74
-rw-r--r--OpenSim/Framework/Servers/HttpServer/OSHttpHandler.cs2
-rw-r--r--OpenSim/Framework/Servers/Tests/OSHttpTests.cs1
-rw-r--r--OpenSim/Framework/Tests/AnimationTests.cs1
-rw-r--r--OpenSim/Framework/Tests/PrimeNumberHelperTests.cs3
-rw-r--r--OpenSim/Framework/Tests/UtilTest.cs1
-rw-r--r--OpenSim/Framework/Util.cs23
-rw-r--r--OpenSim/Framework/WebUtil.cs20
-rw-r--r--OpenSim/Region/Application/OpenSim.cs77
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs12
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs16
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs171
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs26
-rw-r--r--OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs27
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs21
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs7
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs60
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs64
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs215
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs18
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs155
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs680
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs478
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs63
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/LightShare/LightShareModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml1
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs2
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs8
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs5
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs362
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs19
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs29
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs224
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs636
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs82
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs60
-rw-r--r--OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs102
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs9
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEstateModule.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISceneViewer.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs360
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs43
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs53
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneViewer.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs173
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs137
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs70
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs1
-rw-r--r--OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs58
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs14
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs19
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs66
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs1
-rw-r--r--OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs118
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs45
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs36
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs46
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs71
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs4
-rw-r--r--OpenSim/Server/Handlers/Simulation/AgentHandlers.cs16
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs2
-rw-r--r--OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs335
-rw-r--r--OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs140
-rw-r--r--OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs582
-rw-r--r--OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs196
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs262
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs84
-rw-r--r--OpenSim/Services/GridService/GridService.cs12
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs46
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs2
-rw-r--r--OpenSim/Services/Interfaces/ISimulationService.cs9
-rw-r--r--OpenSim/Tests/Common/DoubleToleranceConstraint.cs1
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs7
-rw-r--r--OpenSim/Tests/Common/Setup/AssetHelpers.cs2
-rw-r--r--OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs213
-rw-r--r--OpenSim/Tests/Common/TestHelper.cs3
-rw-r--r--OpenSim/Tests/Common/VectorToleranceConstraint.cs1
-rw-r--r--TESTING.txt81
-rw-r--r--bin/HttpServer_OpenSim.dllbin115712 -> 115712 bytes
-rw-r--r--bin/HttpServer_OpenSim.pdbbin409088 -> 409088 bytes
-rw-r--r--bin/MySql.Data.dllbin360448 -> 353792 bytes
-rw-r--r--bin/OpenSim.ini.example3
-rw-r--r--bin/OpenSimDefaults.ini7
-rw-r--r--bin/Robust.HG.ini.example2
-rw-r--r--bin/assets/TexturesAssetSet/TexturesAssetSet.xml9
-rw-r--r--bin/config-include/GridCommon.ini.example6
-rw-r--r--bin/config-include/HyperSimianGrid.ini11
-rw-r--r--bin/config-include/StandaloneCommon.ini.example6
-rwxr-xr-xbin/libsqlite3.so.0bin0 -> 871398 bytes
-rw-r--r--bin/libsqlite3.txt1
-rw-r--r--bin/nunit.framework.dllbin77824 -> 135168 bytes
-rw-r--r--bin/sqlite-3.6.21.sobin392316 -> 0 bytes
-rwxr-xr-xbin/sqlite3.dllbin505771 -> 559244 bytes
-rw-r--r--prebuild.xml1
150 files changed, 3933 insertions, 3784 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index 38343a4..a0af1ca 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -28,7 +28,7 @@ people that make the day to day of OpenSim happen.
28* Diva (Crista Lopes, University of California, Irvine) 28* Diva (Crista Lopes, University of California, Irvine)
29* nlin (3Di) 29* nlin (3Di)
30* Arthur Rodrigo S Valadares (IBM) 30* Arthur Rodrigo S Valadares (IBM)
31 31* BlueWall (James Hughes)
32 32
33= Past Open Sim Developers = 33= Past Open Sim Developers =
34These folks are alumns of the OpenSim core group, but are now 34These folks are alumns of the OpenSim core group, but are now
diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
index 7ef0f5f..f37c399 100644
--- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
+++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
@@ -122,9 +122,11 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
122 m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + 122 m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " +
123 Thread.CurrentThread.ManagedThreadId.ToString() + 123 Thread.CurrentThread.ManagedThreadId.ToString() +
124 ")"); 124 ")");
125
125 m_openSim.PopulateRegionEstateInfo(regionsToLoad[i]); 126 m_openSim.PopulateRegionEstateInfo(regionsToLoad[i]);
126 m_openSim.CreateRegion(regionsToLoad[i], true, out scene); 127 m_openSim.CreateRegion(regionsToLoad[i], true, out scene);
127 regionsToLoad[i].EstateSettings.Save(); 128 regionsToLoad[i].EstateSettings.Save();
129
128 if (scene != null) 130 if (scene != null)
129 { 131 {
130 m_newRegionCreatedHandler = OnNewRegionCreated; 132 m_newRegionCreatedHandler = OnNewRegionCreated;
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs
index 019ca73..0188eb7 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs
@@ -44,7 +44,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
44 44
45 // private static readonly int PARM_PATH = 1; 45 // private static readonly int PARM_PATH = 1;
46 46
47 private bool enabled = false; 47// private bool enabled = false;
48 private string qPrefix = "appearance"; 48 private string qPrefix = "appearance";
49 49
50 /// <summary> 50 /// <summary>
@@ -74,7 +74,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
74 74
75 // Activate if everything went OK 75 // Activate if everything went OK
76 76
77 enabled = true; 77// enabled = true;
78 78
79 Rest.Log.InfoFormat("{0} User appearance services initialization complete", MsgId); 79 Rest.Log.InfoFormat("{0} User appearance services initialization complete", MsgId);
80 } 80 }
@@ -95,7 +95,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
95 95
96 public void Close() 96 public void Close()
97 { 97 {
98 enabled = false; 98// enabled = false;
99 Rest.Log.InfoFormat("{0} User appearance services closing down", MsgId); 99 Rest.Log.InfoFormat("{0} User appearance services closing down", MsgId);
100 } 100 }
101 101
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
index c3cf08c..536f167 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
@@ -46,12 +46,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
46 public class RestInventoryServices : IRest 46 public class RestInventoryServices : IRest
47 { 47 {
48// private static readonly int PARM_USERID = 0; 48// private static readonly int PARM_USERID = 0;
49 private static readonly int PARM_PATH = 1; 49// private static readonly int PARM_PATH = 1;
50 50
51// private bool enabled = false; 51// private bool enabled = false;
52 private string qPrefix = "inventory"; 52 private string qPrefix = "inventory";
53 53
54 private static readonly string PRIVATE_ROOT_NAME = "My Inventory"; 54// private static readonly string PRIVATE_ROOT_NAME = "My Inventory";
55 55
56 /// <summary> 56 /// <summary>
57 /// The constructor makes sure that the service prefix is absolute 57 /// The constructor makes sure that the service prefix is absolute
@@ -2129,17 +2129,17 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
2129 } 2129 }
2130 catch (DllNotFoundException) 2130 catch (DllNotFoundException)
2131 { 2131 {
2132 Rest.Log.ErrorFormat("OpenJpeg is not installed correctly on this system. Asset Data is emtpy for {0}", ic.Item.Name); 2132 Rest.Log.ErrorFormat("OpenJpeg is not installed correctly on this system. Asset Data is empty for {0}", ic.Item.Name);
2133 ic.Asset.Data = new Byte[0]; 2133 ic.Asset.Data = new Byte[0];
2134 } 2134 }
2135 catch (IndexOutOfRangeException) 2135 catch (IndexOutOfRangeException)
2136 { 2136 {
2137 Rest.Log.ErrorFormat("OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", ic.Item.Name); 2137 Rest.Log.ErrorFormat("OpenJpeg was unable to encode this. Asset Data is empty for {0}", ic.Item.Name);
2138 ic.Asset.Data = new Byte[0]; 2138 ic.Asset.Data = new Byte[0];
2139 } 2139 }
2140 catch (Exception) 2140 catch (Exception)
2141 { 2141 {
2142 Rest.Log.ErrorFormat("OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", ic.Item.Name); 2142 Rest.Log.ErrorFormat("OpenJpeg was unable to encode this. Asset Data is empty for {0}", ic.Item.Name);
2143 ic.Asset.Data = new Byte[0]; 2143 ic.Asset.Data = new Byte[0];
2144 } 2144 }
2145 } 2145 }
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 0b0a638..94e2da4 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -47,6 +47,11 @@ namespace OpenSim.Data.MySQL
47 private string m_connectionString; 47 private string m_connectionString;
48 private object m_dbLock = new object(); 48 private object m_dbLock = new object();
49 49
50 protected virtual Assembly Assembly
51 {
52 get { return GetType().Assembly; }
53 }
54
50 #region IPlugin Members 55 #region IPlugin Members
51 56
52 public override string Version { get { return "1.0.0.0"; } } 57 public override string Version { get { return "1.0.0.0"; } }
@@ -66,13 +71,10 @@ namespace OpenSim.Data.MySQL
66 { 71 {
67 m_connectionString = connect; 72 m_connectionString = connect;
68 73
69 // This actually does the roll forward assembly stuff
70 Assembly assem = GetType().Assembly;
71
72 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 74 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
73 { 75 {
74 dbcon.Open(); 76 dbcon.Open();
75 Migration m = new Migration(dbcon, assem, "AssetStore"); 77 Migration m = new Migration(dbcon, Assembly, "AssetStore");
76 m.Update(); 78 m.Update();
77 } 79 }
78 } 80 }
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
index 5056aee..8d82f61 100644
--- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
+++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection;
31using System.Data; 32using System.Data;
32using OpenMetaverse; 33using OpenMetaverse;
33using OpenSim.Framework; 34using OpenSim.Framework;
@@ -42,6 +43,11 @@ namespace OpenSim.Data.MySQL
42 private int m_LastExpire; 43 private int m_LastExpire;
43 // private string m_connectionString; 44 // private string m_connectionString;
44 45
46 protected virtual Assembly Assembly
47 {
48 get { return GetType().Assembly; }
49 }
50
45 public MySqlAuthenticationData(string connectionString, string realm) 51 public MySqlAuthenticationData(string connectionString, string realm)
46 : base(connectionString) 52 : base(connectionString)
47 { 53 {
@@ -51,7 +57,7 @@ namespace OpenSim.Data.MySQL
51 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 57 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
52 { 58 {
53 dbcon.Open(); 59 dbcon.Open();
54 Migration m = new Migration(dbcon, GetType().Assembly, "AuthStore"); 60 Migration m = new Migration(dbcon, Assembly, "AuthStore");
55 m.Update(); 61 m.Update();
56 } 62 }
57 } 63 }
diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs
index c42c687..de72a6a 100644
--- a/OpenSim/Data/MySQL/MySQLEstateData.cs
+++ b/OpenSim/Data/MySQL/MySQLEstateData.cs
@@ -54,6 +54,11 @@ namespace OpenSim.Data.MySQL
54 private Dictionary<string, FieldInfo> m_FieldMap = 54 private Dictionary<string, FieldInfo> m_FieldMap =
55 new Dictionary<string, FieldInfo>(); 55 new Dictionary<string, FieldInfo>();
56 56
57 protected virtual Assembly Assembly
58 {
59 get { return GetType().Assembly; }
60 }
61
57 public MySQLEstateStore() 62 public MySQLEstateStore()
58 { 63 {
59 } 64 }
@@ -82,8 +87,7 @@ namespace OpenSim.Data.MySQL
82 { 87 {
83 dbcon.Open(); 88 dbcon.Open();
84 89
85 Assembly assem = GetType().Assembly; 90 Migration m = new Migration(dbcon, Assembly, "EstateStore");
86 Migration m = new Migration(dbcon, assem, "EstateStore");
87 m.Update(); 91 m.Update();
88 92
89 Type t = typeof(EstateSettings); 93 Type t = typeof(EstateSettings);
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
index 7c23a47..8efe4e9 100644
--- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
+++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
@@ -46,6 +46,11 @@ namespace OpenSim.Data.MySQL
46 protected string m_Realm; 46 protected string m_Realm;
47 protected FieldInfo m_DataField = null; 47 protected FieldInfo m_DataField = null;
48 48
49 protected virtual Assembly Assembly
50 {
51 get { return GetType().Assembly; }
52 }
53
49 public MySQLGenericTableHandler(string connectionString, 54 public MySQLGenericTableHandler(string connectionString,
50 string realm, string storeName) : base(connectionString) 55 string realm, string storeName) : base(connectionString)
51 { 56 {
@@ -57,7 +62,7 @@ namespace OpenSim.Data.MySQL
57 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 62 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
58 { 63 {
59 dbcon.Open(); 64 dbcon.Open();
60 Migration m = new Migration(dbcon, GetType().Assembly, storeName); 65 Migration m = new Migration(dbcon, Assembly, storeName);
61 m.Update(); 66 m.Update();
62 } 67 }
63 } 68 }
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index d04e3dc..c20c392 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -29,6 +29,8 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Data; 31using System.Data;
32using System.Reflection;
33
32using OpenMetaverse; 34using OpenMetaverse;
33using OpenSim.Framework; 35using OpenSim.Framework;
34using OpenSim.Data; 36using OpenSim.Data;
@@ -42,6 +44,11 @@ namespace OpenSim.Data.MySQL
42 private List<string> m_ColumnNames; 44 private List<string> m_ColumnNames;
43 //private string m_connectionString; 45 //private string m_connectionString;
44 46
47 protected virtual Assembly Assembly
48 {
49 get { return GetType().Assembly; }
50 }
51
45 public MySqlRegionData(string connectionString, string realm) 52 public MySqlRegionData(string connectionString, string realm)
46 : base(connectionString) 53 : base(connectionString)
47 { 54 {
@@ -51,7 +58,7 @@ namespace OpenSim.Data.MySQL
51 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 58 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
52 { 59 {
53 dbcon.Open(); 60 dbcon.Open();
54 Migration m = new Migration(dbcon, GetType().Assembly, "GridStore"); 61 Migration m = new Migration(dbcon, Assembly, "GridStore");
55 m.Update(); 62 m.Update();
56 } 63 }
57 } 64 }
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index 02997b3..e14d775 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -52,6 +52,11 @@ namespace OpenSim.Data.MySQL
52 private string m_connectionString; 52 private string m_connectionString;
53 private object m_dbLock = new object(); 53 private object m_dbLock = new object();
54 54
55 protected virtual Assembly Assembly
56 {
57 get { return GetType().Assembly; }
58 }
59
55 public MySQLSimulationData() 60 public MySQLSimulationData()
56 { 61 {
57 } 62 }
@@ -71,8 +76,7 @@ namespace OpenSim.Data.MySQL
71 76
72 // Apply new Migrations 77 // Apply new Migrations
73 // 78 //
74 Assembly assem = GetType().Assembly; 79 Migration m = new Migration(dbcon, Assembly, "RegionStore");
75 Migration m = new Migration(dbcon, assem, "RegionStore");
76 m.Update(); 80 m.Update();
77 81
78 // Clean dropped attachments 82 // Clean dropped attachments
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
index 3b35222..92afa75 100644
--- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Data.MySQL
72 } 72 }
73 else 73 else
74 { 74 {
75 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst or LastName like ?searchLast)", m_Realm); 75 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst and LastName like ?searchLast)", m_Realm);
76 cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%"); 76 cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%");
77 cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%"); 77 cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%");
78 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); 78 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs
index 2065355..53e5207 100644
--- a/OpenSim/Data/Null/NullRegionData.cs
+++ b/OpenSim/Data/Null/NullRegionData.cs
@@ -51,28 +51,56 @@ namespace OpenSim.Data.Null
51 //Console.WriteLine("[XXX] NullRegionData constructor"); 51 //Console.WriteLine("[XXX] NullRegionData constructor");
52 } 52 }
53 53
54 private delegate bool Matcher(string value);
55
54 public List<RegionData> Get(string regionName, UUID scopeID) 56 public List<RegionData> Get(string regionName, UUID scopeID)
55 { 57 {
56 if (Instance != this) 58 if (Instance != this)
57 return Instance.Get(regionName, scopeID); 59 return Instance.Get(regionName, scopeID);
58 60
59 List<RegionData> ret = new List<RegionData>(); 61 string cleanName = regionName.ToLower();
60 62
61 foreach (RegionData r in m_regionData.Values) 63 // Handle SQL wildcards
64 const string wildcard = "%";
65 bool wildcardPrefix = false;
66 bool wildcardSuffix = false;
67 if (cleanName.Equals(wildcard))
62 { 68 {
63 if (regionName.Contains("%")) 69 wildcardPrefix = wildcardSuffix = true;
70 cleanName = string.Empty;
71 }
72 else
73 {
74 if (cleanName.StartsWith(wildcard))
64 { 75 {
65 string cleanname = regionName.Replace("%", ""); 76 wildcardPrefix = true;
66 m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanname.ToLower(), r.RegionName.ToLower()); 77 cleanName = cleanName.Substring(1);
67 if (r.RegionName.ToLower().Contains(cleanname.ToLower()))
68 ret.Add(r);
69 } 78 }
70 else 79 if (regionName.EndsWith(wildcard))
71 { 80 {
72 if (r.RegionName.ToLower() == regionName.ToLower()) 81 wildcardSuffix = true;
73 ret.Add(r); 82 cleanName = cleanName.Remove(cleanName.Length - 1);
74 } 83 }
75 } 84 }
85 Matcher queryMatch;
86 if (wildcardPrefix && wildcardSuffix)
87 queryMatch = delegate(string s) { return s.Contains(cleanName); };
88 else if (wildcardSuffix)
89 queryMatch = delegate(string s) { return s.StartsWith(cleanName); };
90 else if (wildcardPrefix)
91 queryMatch = delegate(string s) { return s.EndsWith(cleanName); };
92 else
93 queryMatch = delegate(string s) { return s.Equals(cleanName); };
94
95 // Find region data
96 List<RegionData> ret = new List<RegionData>();
97
98 foreach (RegionData r in m_regionData.Values)
99 {
100 m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanName, r.RegionName.ToLower());
101 if (queryMatch(r.RegionName.ToLower()))
102 ret.Add(r);
103 }
76 104
77 if (ret.Count > 0) 105 if (ret.Count > 0)
78 return ret; 106 return ret;
diff --git a/OpenSim/Data/Null/NullUserAccountData.cs b/OpenSim/Data/Null/NullUserAccountData.cs
index 772d821..241616b 100644
--- a/OpenSim/Data/Null/NullUserAccountData.cs
+++ b/OpenSim/Data/Null/NullUserAccountData.cs
@@ -28,6 +28,9 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection;
32using System.Text;
33using log4net;
31using OpenMetaverse; 34using OpenMetaverse;
32using OpenSim.Framework; 35using OpenSim.Framework;
33using OpenSim.Data; 36using OpenSim.Data;
@@ -36,12 +39,17 @@ namespace OpenSim.Data.Null
36{ 39{
37 public class NullUserAccountData : IUserAccountData 40 public class NullUserAccountData : IUserAccountData
38 { 41 {
39 private static Dictionary<UUID, UserAccountData> m_DataByUUID = new Dictionary<UUID, UserAccountData>(); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40 private static Dictionary<string, UserAccountData> m_DataByName = new Dictionary<string, UserAccountData>(); 43
41 private static Dictionary<string, UserAccountData> m_DataByEmail = new Dictionary<string, UserAccountData>(); 44 private Dictionary<UUID, UserAccountData> m_DataByUUID = new Dictionary<UUID, UserAccountData>();
45 private Dictionary<string, UserAccountData> m_DataByName = new Dictionary<string, UserAccountData>();
46 private Dictionary<string, UserAccountData> m_DataByEmail = new Dictionary<string, UserAccountData>();
42 47
43 public NullUserAccountData(string connectionString, string realm) 48 public NullUserAccountData(string connectionString, string realm)
44 { 49 {
50// m_log.DebugFormat(
51// "[NULL USER ACCOUNT DATA]: Initializing new NullUserAccountData with connectionString [{0}], realm [{1}]",
52// connectionString, realm);
45 } 53 }
46 54
47 /// <summary> 55 /// <summary>
@@ -54,6 +62,15 @@ namespace OpenSim.Data.Null
54 /// <returns></returns> 62 /// <returns></returns>
55 public UserAccountData[] Get(string[] fields, string[] values) 63 public UserAccountData[] Get(string[] fields, string[] values)
56 { 64 {
65// if (m_log.IsDebugEnabled)
66// {
67// m_log.DebugFormat(
68// "[NULL USER ACCOUNT DATA]: Called Get with fields [{0}], values [{1}]",
69// string.Join(", ", fields), string.Join(", ", values));
70// }
71
72 UserAccountData[] userAccounts = new UserAccountData[0];
73
57 List<string> fieldsLst = new List<string>(fields); 74 List<string> fieldsLst = new List<string>(fields);
58 if (fieldsLst.Contains("PrincipalID")) 75 if (fieldsLst.Contains("PrincipalID"))
59 { 76 {
@@ -61,41 +78,61 @@ namespace OpenSim.Data.Null
61 UUID id = UUID.Zero; 78 UUID id = UUID.Zero;
62 if (UUID.TryParse(values[i], out id)) 79 if (UUID.TryParse(values[i], out id))
63 if (m_DataByUUID.ContainsKey(id)) 80 if (m_DataByUUID.ContainsKey(id))
64 return new UserAccountData[] { m_DataByUUID[id] }; 81 userAccounts = new UserAccountData[] { m_DataByUUID[id] };
65 } 82 }
66 if (fieldsLst.Contains("FirstName") && fieldsLst.Contains("LastName")) 83 else if (fieldsLst.Contains("FirstName") && fieldsLst.Contains("LastName"))
67 { 84 {
68 int findex = fieldsLst.IndexOf("FirstName"); 85 int findex = fieldsLst.IndexOf("FirstName");
69 int lindex = fieldsLst.IndexOf("LastName"); 86 int lindex = fieldsLst.IndexOf("LastName");
70 if (m_DataByName.ContainsKey(values[findex] + " " + values[lindex])) 87 if (m_DataByName.ContainsKey(values[findex] + " " + values[lindex]))
71 return new UserAccountData[] { m_DataByName[values[findex] + " " + values[lindex]] }; 88 {
72 } 89 userAccounts = new UserAccountData[] { m_DataByName[values[findex] + " " + values[lindex]] };
73 if (fieldsLst.Contains("Email")) 90 }
91 }
92 else if (fieldsLst.Contains("Email"))
74 { 93 {
75 int i = fieldsLst.IndexOf("Email"); 94 int i = fieldsLst.IndexOf("Email");
76 if (m_DataByEmail.ContainsKey(values[i])) 95 if (m_DataByEmail.ContainsKey(values[i]))
77 return new UserAccountData[] { m_DataByEmail[values[i]] }; 96 userAccounts = new UserAccountData[] { m_DataByEmail[values[i]] };
78 } 97 }
79 98
80 // Fail 99// if (m_log.IsDebugEnabled)
81 return new UserAccountData[0]; 100// {
101// StringBuilder sb = new StringBuilder();
102// foreach (UserAccountData uad in userAccounts)
103// sb.AppendFormat("({0} {1} {2}) ", uad.FirstName, uad.LastName, uad.PrincipalID);
104//
105// m_log.DebugFormat(
106// "[NULL USER ACCOUNT DATA]: Returning {0} user accounts out of {1}: [{2}]", userAccounts.Length, m_DataByName.Count, sb);
107// }
108
109 return userAccounts;
82 } 110 }
83 111
84 public bool Store(UserAccountData data) 112 public bool Store(UserAccountData data)
85 { 113 {
86 if (data == null) 114 if (data == null)
87 return false; 115 return false;
88 116
117 m_log.DebugFormat(
118 "[NULL USER ACCOUNT DATA]: Storing user account {0} {1} {2} {3}",
119 data.FirstName, data.LastName, data.PrincipalID, this.GetHashCode());
120
89 m_DataByUUID[data.PrincipalID] = data; 121 m_DataByUUID[data.PrincipalID] = data;
90 m_DataByName[data.FirstName + " " + data.LastName] = data; 122 m_DataByName[data.FirstName + " " + data.LastName] = data;
91 if (data.Data.ContainsKey("Email") && data.Data["Email"] != null && data.Data["Email"] != string.Empty) 123 if (data.Data.ContainsKey("Email") && data.Data["Email"] != null && data.Data["Email"] != string.Empty)
92 m_DataByEmail[data.Data["Email"]] = data; 124 m_DataByEmail[data.Data["Email"]] = data;
125
126// m_log.DebugFormat("m_DataByUUID count is {0}, m_DataByName count is {1}", m_DataByUUID.Count, m_DataByName.Count);
93 127
94 return true; 128 return true;
95 } 129 }
96 130
97 public UserAccountData[] GetUsers(UUID scopeID, string query) 131 public UserAccountData[] GetUsers(UUID scopeID, string query)
98 { 132 {
133// m_log.DebugFormat(
134// "[NULL USER ACCOUNT DATA]: Called GetUsers with scope [{0}], query [{1}]", scopeID, query);
135
99 string[] words = query.Split(new char[] { ' ' }); 136 string[] words = query.Split(new char[] { ' ' });
100 137
101 for (int i = 0; i < words.Length; i++) 138 for (int i = 0; i < words.Length; i++)
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
index 8d93354..377c680 100644
--- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs
+++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
@@ -669,10 +669,6 @@ namespace OpenSim.Data.SQLite
669 } 669 }
670 } 670 }
671 671
672 /// <summary>
673 ///
674 /// </summary>
675 /// <param name="globalID"></param>
676 public void RemoveLandObject(UUID globalID) 672 public void RemoveLandObject(UUID globalID)
677 { 673 {
678 lock (ds) 674 lock (ds)
@@ -698,7 +694,6 @@ namespace OpenSim.Data.SQLite
698 if (landRow != null) 694 if (landRow != null)
699 { 695 {
700 landRow.Delete(); 696 landRow.Delete();
701 land.Rows.Remove(landRow);
702 } 697 }
703 List<DataRow> rowsToDelete = new List<DataRow>(); 698 List<DataRow> rowsToDelete = new List<DataRow>();
704 foreach (DataRow rowToCheck in landaccesslist.Rows) 699 foreach (DataRow rowToCheck in landaccesslist.Rows)
@@ -709,7 +704,6 @@ namespace OpenSim.Data.SQLite
709 for (int iter = 0; iter < rowsToDelete.Count; iter++) 704 for (int iter = 0; iter < rowsToDelete.Count; iter++)
710 { 705 {
711 rowsToDelete[iter].Delete(); 706 rowsToDelete[iter].Delete();
712 landaccesslist.Rows.Remove(rowsToDelete[iter]);
713 } 707 }
714 } 708 }
715 Commit(); 709 Commit();
diff --git a/OpenSim/Data/Tests/AssetTests.cs b/OpenSim/Data/Tests/AssetTests.cs
index 800b9bf..b5ae244 100644
--- a/OpenSim/Data/Tests/AssetTests.cs
+++ b/OpenSim/Data/Tests/AssetTests.cs
@@ -32,13 +32,10 @@ using NUnit.Framework;
32using NUnit.Framework.Constraints; 32using NUnit.Framework.Constraints;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Tests.Common;
35using System.Data.Common; 36using System.Data.Common;
36using log4net; 37using log4net;
37 38
38#if !NUNIT25
39using NUnit.Framework.SyntaxHelpers;
40#endif
41
42// DBMS-specific: 39// DBMS-specific:
43using MySql.Data.MySqlClient; 40using MySql.Data.MySqlClient;
44using OpenSim.Data.MySQL; 41using OpenSim.Data.MySQL;
@@ -51,15 +48,6 @@ using OpenSim.Data.SQLite;
51 48
52namespace OpenSim.Data.Tests 49namespace OpenSim.Data.Tests
53{ 50{
54
55#if NUNIT25
56
57 [TestFixture(typeof(MySqlConnection), typeof(MySQLAssetData), Description="Basic Asset store tests (MySQL)")]
58 [TestFixture(typeof(SqlConnection), typeof(MSSQLAssetData), Description = "Basic Asset store tests (MS SQL Server)")]
59 [TestFixture(typeof(SqliteConnection), typeof(SQLiteAssetData), Description = "Basic Asset store tests (SQLite)")]
60
61#else
62
63 [TestFixture(Description = "Asset store tests (SQLite)")] 51 [TestFixture(Description = "Asset store tests (SQLite)")]
64 public class SQLiteAssetTests : AssetTests<SqliteConnection, SQLiteAssetData> 52 public class SQLiteAssetTests : AssetTests<SqliteConnection, SQLiteAssetData>
65 { 53 {
@@ -75,9 +63,6 @@ namespace OpenSim.Data.Tests
75 { 63 {
76 } 64 }
77 65
78#endif
79
80
81 public class AssetTests<TConn, TAssetData> : BasicDataServiceTest<TConn, TAssetData> 66 public class AssetTests<TConn, TAssetData> : BasicDataServiceTest<TConn, TAssetData>
82 where TConn : DbConnection, new() 67 where TConn : DbConnection, new()
83 where TAssetData : AssetDataBase, new() 68 where TAssetData : AssetDataBase, new()
@@ -121,6 +106,8 @@ namespace OpenSim.Data.Tests
121 [Test] 106 [Test]
122 public void T001_LoadEmpty() 107 public void T001_LoadEmpty()
123 { 108 {
109 TestHelper.InMethod();
110
124 Assert.That(m_db.ExistsAsset(uuid1), Is.False); 111 Assert.That(m_db.ExistsAsset(uuid1), Is.False);
125 Assert.That(m_db.ExistsAsset(uuid2), Is.False); 112 Assert.That(m_db.ExistsAsset(uuid2), Is.False);
126 Assert.That(m_db.ExistsAsset(uuid3), Is.False); 113 Assert.That(m_db.ExistsAsset(uuid3), Is.False);
@@ -129,6 +116,8 @@ namespace OpenSim.Data.Tests
129 [Test] 116 [Test]
130 public void T010_StoreReadVerifyAssets() 117 public void T010_StoreReadVerifyAssets()
131 { 118 {
119 TestHelper.InMethod();
120
132 AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1.ToString()); 121 AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1.ToString());
133 AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, critter2.ToString()); 122 AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, critter2.ToString());
134 AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, critter3.ToString()); 123 AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, critter3.ToString());
@@ -194,6 +183,8 @@ namespace OpenSim.Data.Tests
194 [Test] 183 [Test]
195 public void T020_CheckForWeirdCreatorID() 184 public void T020_CheckForWeirdCreatorID()
196 { 185 {
186 TestHelper.InMethod();
187
197 // It is expected that eventually the CreatorID might be an arbitrary string (an URI) 188 // It is expected that eventually the CreatorID might be an arbitrary string (an URI)
198 // rather than a valid UUID (?). This test is to make sure that the database layer does not 189 // rather than a valid UUID (?). This test is to make sure that the database layer does not
199 // attempt to convert CreatorID to GUID, but just passes it both ways as a string. 190 // attempt to convert CreatorID to GUID, but just passes it both ways as a string.
@@ -218,4 +209,4 @@ namespace OpenSim.Data.Tests
218 Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); 209 Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
219 } 210 }
220 } 211 }
221} 212} \ No newline at end of file
diff --git a/OpenSim/Data/Tests/EstateTests.cs b/OpenSim/Data/Tests/EstateTests.cs
index fbf8ba6..8d332da 100644
--- a/OpenSim/Data/Tests/EstateTests.cs
+++ b/OpenSim/Data/Tests/EstateTests.cs
@@ -28,10 +28,10 @@
28using System; 28using System;
29using log4net.Config; 29using log4net.Config;
30using NUnit.Framework; 30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 31using OpenMetaverse;
33using OpenSim.Framework; 32using OpenSim.Framework;
34using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Tests.Common;
35using System.Text; 35using System.Text;
36using log4net; 36using log4net;
37using System.Reflection; 37using System.Reflection;
@@ -49,15 +49,6 @@ using OpenSim.Data.SQLite;
49 49
50namespace OpenSim.Data.Tests 50namespace OpenSim.Data.Tests
51{ 51{
52
53#if NUNIT25
54
55 [TestFixture(typeof(MySqlConnection), typeof(MySQLEstateStore), Description = "Estate store tests (MySQL)")]
56 [TestFixture(typeof(SqlConnection), typeof(MSSQLEstateStore), Description = "Estate store tests (MS SQL Server)")]
57 [TestFixture(typeof(SqliteConnection), typeof(SQLiteEstateStore), Description = "Estate store tests (SQLite)")]
58
59#else
60
61 [TestFixture(Description = "Estate store tests (SQLite)")] 52 [TestFixture(Description = "Estate store tests (SQLite)")]
62 public class SQLiteEstateTests : EstateTests<SqliteConnection, SQLiteEstateStore> 53 public class SQLiteEstateTests : EstateTests<SqliteConnection, SQLiteEstateStore>
63 { 54 {
@@ -73,8 +64,6 @@ namespace OpenSim.Data.Tests
73 { 64 {
74 } 65 }
75 66
76#endif
77
78 public class EstateTests<TConn, TEstateStore> : BasicDataServiceTest<TConn, TEstateStore> 67 public class EstateTests<TConn, TEstateStore> : BasicDataServiceTest<TConn, TEstateStore>
79 where TConn : DbConnection, new() 68 where TConn : DbConnection, new()
80 where TEstateStore : class, IEstateDataStore, new() 69 where TEstateStore : class, IEstateDataStore, new()
@@ -118,6 +107,8 @@ namespace OpenSim.Data.Tests
118 [Test] 107 [Test]
119 public void T010_EstateSettingsSimpleStorage_MinimumParameterSet() 108 public void T010_EstateSettingsSimpleStorage_MinimumParameterSet()
120 { 109 {
110 TestHelper.InMethod();
111
121 EstateSettingsSimpleStorage( 112 EstateSettingsSimpleStorage(
122 REGION_ID, 113 REGION_ID,
123 DataTestUtil.STRING_MIN, 114 DataTestUtil.STRING_MIN,
@@ -149,6 +140,8 @@ namespace OpenSim.Data.Tests
149 [Test] 140 [Test]
150 public void T011_EstateSettingsSimpleStorage_MaximumParameterSet() 141 public void T011_EstateSettingsSimpleStorage_MaximumParameterSet()
151 { 142 {
143 TestHelper.InMethod();
144
152 EstateSettingsSimpleStorage( 145 EstateSettingsSimpleStorage(
153 REGION_ID, 146 REGION_ID,
154 DataTestUtil.STRING_MAX(64), 147 DataTestUtil.STRING_MAX(64),
@@ -180,6 +173,8 @@ namespace OpenSim.Data.Tests
180 [Test] 173 [Test]
181 public void T012_EstateSettingsSimpleStorage_AccurateParameterSet() 174 public void T012_EstateSettingsSimpleStorage_AccurateParameterSet()
182 { 175 {
176 TestHelper.InMethod();
177
183 EstateSettingsSimpleStorage( 178 EstateSettingsSimpleStorage(
184 REGION_ID, 179 REGION_ID,
185 DataTestUtil.STRING_MAX(1), 180 DataTestUtil.STRING_MAX(1),
@@ -211,6 +206,8 @@ namespace OpenSim.Data.Tests
211 [Test] 206 [Test]
212 public void T012_EstateSettingsRandomStorage() 207 public void T012_EstateSettingsRandomStorage()
213 { 208 {
209 TestHelper.InMethod();
210
214 // Letting estate store generate rows to database for us 211 // Letting estate store generate rows to database for us
215 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); 212 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
216 new PropertyScrambler<EstateSettings>() 213 new PropertyScrambler<EstateSettings>()
@@ -230,6 +227,8 @@ namespace OpenSim.Data.Tests
230 [Test] 227 [Test]
231 public void T020_EstateSettingsManagerList() 228 public void T020_EstateSettingsManagerList()
232 { 229 {
230 TestHelper.InMethod();
231
233 // Letting estate store generate rows to database for us 232 // Letting estate store generate rows to database for us
234 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); 233 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
235 234
@@ -249,6 +248,8 @@ namespace OpenSim.Data.Tests
249 [Test] 248 [Test]
250 public void T021_EstateSettingsUserList() 249 public void T021_EstateSettingsUserList()
251 { 250 {
251 TestHelper.InMethod();
252
252 // Letting estate store generate rows to database for us 253 // Letting estate store generate rows to database for us
253 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); 254 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
254 255
@@ -268,6 +269,8 @@ namespace OpenSim.Data.Tests
268 [Test] 269 [Test]
269 public void T022_EstateSettingsGroupList() 270 public void T022_EstateSettingsGroupList()
270 { 271 {
272 TestHelper.InMethod();
273
271 // Letting estate store generate rows to database for us 274 // Letting estate store generate rows to database for us
272 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); 275 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
273 276
@@ -287,6 +290,8 @@ namespace OpenSim.Data.Tests
287 [Test] 290 [Test]
288 public void T022_EstateSettingsBanList() 291 public void T022_EstateSettingsBanList()
289 { 292 {
293 TestHelper.InMethod();
294
290 // Letting estate store generate rows to database for us 295 // Letting estate store generate rows to database for us
291 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true); 296 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
292 297
@@ -520,6 +525,5 @@ namespace OpenSim.Data.Tests
520 } 525 }
521 526
522 #endregion 527 #endregion
523
524 } 528 }
525} 529} \ No newline at end of file
diff --git a/OpenSim/Data/Tests/InventoryTests.cs b/OpenSim/Data/Tests/InventoryTests.cs
index 9c2a2d6..cf3bac1 100644
--- a/OpenSim/Data/Tests/InventoryTests.cs
+++ b/OpenSim/Data/Tests/InventoryTests.cs
@@ -25,14 +25,12 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28// #define NUNIT25
29
30using System; 28using System;
31using log4net.Config; 29using log4net.Config;
32using NUnit.Framework; 30using NUnit.Framework;
33using NUnit.Framework.SyntaxHelpers;
34using OpenMetaverse; 31using OpenMetaverse;
35using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Tests.Common;
36using log4net; 34using log4net;
37using System.Reflection; 35using System.Reflection;
38using System.Data.Common; 36using System.Data.Common;
@@ -49,14 +47,6 @@ using OpenSim.Data.SQLite;
49 47
50namespace OpenSim.Data.Tests 48namespace OpenSim.Data.Tests
51{ 49{
52#if NUNIT25
53
54 [TestFixture(typeof(SqliteConnection), typeof(SQLiteInventoryStore), Description = "Inventory store tests (SQLite)")]
55 [TestFixture(typeof(MySqlConnection), typeof(MySQLInventoryData), Description = "Inventory store tests (MySQL)")]
56 [TestFixture(typeof(SqlConnection), typeof(MSSQLInventoryData), Description = "Inventory store tests (MS SQL Server)")]
57
58#else
59
60 [TestFixture(Description = "Inventory store tests (SQLite)")] 50 [TestFixture(Description = "Inventory store tests (SQLite)")]
61 public class SQLiteInventoryTests : InventoryTests<SqliteConnection, SQLiteInventoryStore> 51 public class SQLiteInventoryTests : InventoryTests<SqliteConnection, SQLiteInventoryStore>
62 { 52 {
@@ -71,7 +61,6 @@ namespace OpenSim.Data.Tests
71 public class MSSQLInventoryTests : InventoryTests<SqlConnection, MSSQLInventoryData> 61 public class MSSQLInventoryTests : InventoryTests<SqlConnection, MSSQLInventoryData>
72 { 62 {
73 } 63 }
74#endif
75 64
76 public class InventoryTests<TConn, TInvStore> : BasicDataServiceTest<TConn, TInvStore> 65 public class InventoryTests<TConn, TInvStore> : BasicDataServiceTest<TConn, TInvStore>
77 where TConn : DbConnection, new() 66 where TConn : DbConnection, new()
@@ -125,6 +114,8 @@ namespace OpenSim.Data.Tests
125 [Test] 114 [Test]
126 public void T001_LoadEmpty() 115 public void T001_LoadEmpty()
127 { 116 {
117 TestHelper.InMethod();
118
128 Assert.That(db.getInventoryFolder(zero), Is.Null); 119 Assert.That(db.getInventoryFolder(zero), Is.Null);
129 Assert.That(db.getInventoryFolder(folder1), Is.Null); 120 Assert.That(db.getInventoryFolder(folder1), Is.Null);
130 Assert.That(db.getInventoryFolder(folder2), Is.Null); 121 Assert.That(db.getInventoryFolder(folder2), Is.Null);
@@ -143,6 +134,8 @@ namespace OpenSim.Data.Tests
143 [Test] 134 [Test]
144 public void T010_FolderNonParent() 135 public void T010_FolderNonParent()
145 { 136 {
137 TestHelper.InMethod();
138
146 InventoryFolderBase f1 = NewFolder(folder2, folder1, owner1, name2); 139 InventoryFolderBase f1 = NewFolder(folder2, folder1, owner1, name2);
147 // the folder will go in 140 // the folder will go in
148 db.addInventoryFolder(f1); 141 db.addInventoryFolder(f1);
@@ -153,6 +146,8 @@ namespace OpenSim.Data.Tests
153 [Test] 146 [Test]
154 public void T011_FolderCreate() 147 public void T011_FolderCreate()
155 { 148 {
149 TestHelper.InMethod();
150
156 InventoryFolderBase f1 = NewFolder(folder1, zero, owner1, name1); 151 InventoryFolderBase f1 = NewFolder(folder1, zero, owner1, name1);
157 // TODO: this is probably wrong behavior, but is what we have 152 // TODO: this is probably wrong behavior, but is what we have
158 // db.updateInventoryFolder(f1); 153 // db.updateInventoryFolder(f1);
@@ -165,7 +160,7 @@ namespace OpenSim.Data.Tests
165 db.addInventoryFolder(f1); 160 db.addInventoryFolder(f1);
166 InventoryFolderBase f1a = db.getUserRootFolder(owner1); 161 InventoryFolderBase f1a = db.getUserRootFolder(owner1);
167 Assert.That(folder1, Is.EqualTo(f1a.ID), "Assert.That(folder1, Is.EqualTo(f1a.ID))"); 162 Assert.That(folder1, Is.EqualTo(f1a.ID), "Assert.That(folder1, Is.EqualTo(f1a.ID))");
168 Assert.That(name1, Text.Matches(f1a.Name), "Assert.That(name1, Text.Matches(f1a.Name))"); 163 Assert.That(name1, Is.StringMatching(f1a.Name), "Assert.That(name1, Text.Matches(f1a.Name))");
169 } 164 }
170 165
171 // we now have the following tree 166 // we now have the following tree
@@ -176,6 +171,8 @@ namespace OpenSim.Data.Tests
176 [Test] 171 [Test]
177 public void T012_FolderList() 172 public void T012_FolderList()
178 { 173 {
174 TestHelper.InMethod();
175
179 InventoryFolderBase f2 = NewFolder(folder3, folder1, owner1, name3); 176 InventoryFolderBase f2 = NewFolder(folder3, folder1, owner1, name3);
180 db.addInventoryFolder(f2); 177 db.addInventoryFolder(f2);
181 178
@@ -190,6 +187,8 @@ namespace OpenSim.Data.Tests
190 [Test] 187 [Test]
191 public void T013_FolderHierarchy() 188 public void T013_FolderHierarchy()
192 { 189 {
190 TestHelper.InMethod();
191
193 int n = db.getFolderHierarchy(zero).Count; // (for dbg - easier to see what's returned) 192 int n = db.getFolderHierarchy(zero).Count; // (for dbg - easier to see what's returned)
194 Assert.That(n, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))"); 193 Assert.That(n, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))");
195 n = db.getFolderHierarchy(folder1).Count; 194 n = db.getFolderHierarchy(folder1).Count;
@@ -203,6 +202,8 @@ namespace OpenSim.Data.Tests
203 [Test] 202 [Test]
204 public void T014_MoveFolder() 203 public void T014_MoveFolder()
205 { 204 {
205 TestHelper.InMethod();
206
206 InventoryFolderBase f2 = db.getInventoryFolder(folder2); 207 InventoryFolderBase f2 = db.getInventoryFolder(folder2);
207 f2.ParentID = folder3; 208 f2.ParentID = folder3;
208 db.moveInventoryFolder(f2); 209 db.moveInventoryFolder(f2);
@@ -217,6 +218,8 @@ namespace OpenSim.Data.Tests
217 [Test] 218 [Test]
218 public void T015_FolderHierarchy() 219 public void T015_FolderHierarchy()
219 { 220 {
221 TestHelper.InMethod();
222
220 Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))"); 223 Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(zero).Count, Is.EqualTo(0))");
221 Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2), "Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2))"); 224 Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2), "Assert.That(db.getFolderHierarchy(folder1).Count, Is.EqualTo(2))");
222 Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0))"); 225 Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0), "Assert.That(db.getFolderHierarchy(folder2).Count, Is.EqualTo(0))");
@@ -228,6 +231,8 @@ namespace OpenSim.Data.Tests
228 [Test] 231 [Test]
229 public void T100_NoItems() 232 public void T100_NoItems()
230 { 233 {
234 TestHelper.InMethod();
235
231 Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))"); 236 Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))");
232 Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0))"); 237 Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder1).Count, Is.EqualTo(0))");
233 Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0))"); 238 Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(folder2).Count, Is.EqualTo(0))");
@@ -240,6 +245,8 @@ namespace OpenSim.Data.Tests
240 [Test] 245 [Test]
241 public void T101_CreatItems() 246 public void T101_CreatItems()
242 { 247 {
248 TestHelper.InMethod();
249
243 db.addInventoryItem(NewItem(item1, folder3, owner1, iname1, asset1)); 250 db.addInventoryItem(NewItem(item1, folder3, owner1, iname1, asset1));
244 db.addInventoryItem(NewItem(item2, folder3, owner1, iname2, asset2)); 251 db.addInventoryItem(NewItem(item2, folder3, owner1, iname2, asset2));
245 db.addInventoryItem(NewItem(item3, folder3, owner1, iname3, asset3)); 252 db.addInventoryItem(NewItem(item3, folder3, owner1, iname3, asset3));
@@ -249,6 +256,8 @@ namespace OpenSim.Data.Tests
249 [Test] 256 [Test]
250 public void T102_CompareItems() 257 public void T102_CompareItems()
251 { 258 {
259 TestHelper.InMethod();
260
252 InventoryItemBase i1 = db.getInventoryItem(item1); 261 InventoryItemBase i1 = db.getInventoryItem(item1);
253 InventoryItemBase i2 = db.getInventoryItem(item2); 262 InventoryItemBase i2 = db.getInventoryItem(item2);
254 InventoryItemBase i3 = db.getInventoryItem(item3); 263 InventoryItemBase i3 = db.getInventoryItem(item3);
@@ -266,6 +275,8 @@ namespace OpenSim.Data.Tests
266 [Test] 275 [Test]
267 public void T103_UpdateItem() 276 public void T103_UpdateItem()
268 { 277 {
278 TestHelper.InMethod();
279
269 // TODO: probably shouldn't have the ability to have an 280 // TODO: probably shouldn't have the ability to have an
270 // owner of an item in a folder not owned by the user 281 // owner of an item in a folder not owned by the user
271 282
@@ -284,6 +295,8 @@ namespace OpenSim.Data.Tests
284 [Test] 295 [Test]
285 public void T104_RandomUpdateItem() 296 public void T104_RandomUpdateItem()
286 { 297 {
298 TestHelper.InMethod();
299
287 PropertyScrambler<InventoryFolderBase> folderScrambler = 300 PropertyScrambler<InventoryFolderBase> folderScrambler =
288 new PropertyScrambler<InventoryFolderBase>() 301 new PropertyScrambler<InventoryFolderBase>()
289 .DontScramble(x => x.Owner) 302 .DontScramble(x => x.Owner)
@@ -341,6 +354,8 @@ namespace OpenSim.Data.Tests
341 [Test] 354 [Test]
342 public void T999_StillNull() 355 public void T999_StillNull()
343 { 356 {
357 TestHelper.InMethod();
358
344 // After all tests are run, these should still return no results 359 // After all tests are run, these should still return no results
345 Assert.That(db.getInventoryFolder(zero), Is.Null); 360 Assert.That(db.getInventoryFolder(zero), Is.Null);
346 Assert.That(db.getInventoryItem(zero), Is.Null); 361 Assert.That(db.getInventoryItem(zero), Is.Null);
diff --git a/OpenSim/Data/Tests/PropertyCompareConstraint.cs b/OpenSim/Data/Tests/PropertyCompareConstraint.cs
index f3d41df..6c79bda 100644
--- a/OpenSim/Data/Tests/PropertyCompareConstraint.cs
+++ b/OpenSim/Data/Tests/PropertyCompareConstraint.cs
@@ -34,7 +34,6 @@ using System.Linq.Expressions;
34using System.Reflection; 34using System.Reflection;
35using NUnit.Framework; 35using NUnit.Framework;
36using NUnit.Framework.Constraints; 36using NUnit.Framework.Constraints;
37using NUnit.Framework.SyntaxHelpers;
38using OpenMetaverse; 37using OpenMetaverse;
39using OpenSim.Framework; 38using OpenSim.Framework;
40 39
diff --git a/OpenSim/Data/Tests/PropertyScrambler.cs b/OpenSim/Data/Tests/PropertyScrambler.cs
index 132294a..c5d40c2 100644
--- a/OpenSim/Data/Tests/PropertyScrambler.cs
+++ b/OpenSim/Data/Tests/PropertyScrambler.cs
@@ -32,13 +32,11 @@ using System.Linq.Expressions;
32using System.Reflection; 32using System.Reflection;
33using System.Text; 33using System.Text;
34using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenSim.Framework; 36using OpenSim.Framework;
38 37
39namespace OpenSim.Data.Tests 38namespace OpenSim.Data.Tests
40{ 39{
41
42 //This is generic so that the lambda expressions will work right in IDEs. 40 //This is generic so that the lambda expressions will work right in IDEs.
43 public class PropertyScrambler<T> 41 public class PropertyScrambler<T>
44 { 42 {
diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs
index 23d498d..44cf1ab 100644
--- a/OpenSim/Data/Tests/RegionTests.cs
+++ b/OpenSim/Data/Tests/RegionTests.cs
@@ -31,11 +31,11 @@ using System.Drawing;
31using System.Text; 31using System.Text;
32using log4net.Config; 32using log4net.Config;
33using NUnit.Framework; 33using NUnit.Framework;
34using NUnit.Framework.SyntaxHelpers;
35using OpenMetaverse; 34using OpenMetaverse;
36using OpenSim.Framework; 35using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common;
39using log4net; 39using log4net;
40using System.Reflection; 40using System.Reflection;
41using System.Data.Common; 41using System.Data.Common;
@@ -52,14 +52,6 @@ using OpenSim.Data.SQLite;
52 52
53namespace OpenSim.Data.Tests 53namespace OpenSim.Data.Tests
54{ 54{
55#if NUNIT25
56
57 [TestFixture(typeof(SqliteConnection), typeof(SQLiteRegionData), Description = "Region store tests (SQLite)")]
58 [TestFixture(typeof(MySqlConnection), typeof(MySqlRegionData), Description = "Region store tests (MySQL)")]
59 [TestFixture(typeof(SqlConnection), typeof(MSSQLRegionData), Description = "Region store tests (MS SQL Server)")]
60
61#else
62
63 [TestFixture(Description = "Region store tests (SQLite)")] 55 [TestFixture(Description = "Region store tests (SQLite)")]
64 public class SQLiteRegionTests : RegionTests<SqliteConnection, SQLiteSimulationData> 56 public class SQLiteRegionTests : RegionTests<SqliteConnection, SQLiteSimulationData>
65 { 57 {
@@ -75,8 +67,6 @@ namespace OpenSim.Data.Tests
75 { 67 {
76 } 68 }
77 69
78#endif
79
80 public class RegionTests<TConn, TRegStore> : BasicDataServiceTest<TConn, TRegStore> 70 public class RegionTests<TConn, TRegStore> : BasicDataServiceTest<TConn, TRegStore>
81 where TConn : DbConnection, new() 71 where TConn : DbConnection, new()
82 where TRegStore : class, ISimulationDataStore, new() 72 where TRegStore : class, ISimulationDataStore, new()
@@ -131,15 +121,18 @@ namespace OpenSim.Data.Tests
131 string[] reg_tables = new string[] { 121 string[] reg_tables = new string[] {
132 "prims", "primshapes", "primitems", "terrain", "land", "landaccesslist", "regionban", "regionsettings" 122 "prims", "primshapes", "primitems", "terrain", "land", "landaccesslist", "regionban", "regionsettings"
133 }; 123 };
124
134 if (m_rebuildDB) 125 if (m_rebuildDB)
135 { 126 {
136 DropTables(reg_tables); 127 DropTables(reg_tables);
137 ResetMigrations("RegionStore"); 128 ResetMigrations("RegionStore");
138 }else 129 }
130 else
131 {
139 ClearTables(reg_tables); 132 ClearTables(reg_tables);
133 }
140 } 134 }
141 135
142
143 // Test Plan 136 // Test Plan
144 // Prims 137 // Prims
145 // - empty test - 001 138 // - empty test - 001
@@ -158,6 +151,8 @@ namespace OpenSim.Data.Tests
158 [Test] 151 [Test]
159 public void T001_LoadEmpty() 152 public void T001_LoadEmpty()
160 { 153 {
154 TestHelper.InMethod();
155
161 List<SceneObjectGroup> objs = db.LoadObjects(region1); 156 List<SceneObjectGroup> objs = db.LoadObjects(region1);
162 List<SceneObjectGroup> objs3 = db.LoadObjects(region3); 157 List<SceneObjectGroup> objs3 = db.LoadObjects(region3);
163 List<LandData> land = db.LoadLandObjects(region1); 158 List<LandData> land = db.LoadLandObjects(region1);
@@ -174,6 +169,8 @@ namespace OpenSim.Data.Tests
174 [Test] 169 [Test]
175 public void T010_StoreSimpleObject() 170 public void T010_StoreSimpleObject()
176 { 171 {
172 TestHelper.InMethod();
173
177 SceneObjectGroup sog = NewSOG("object1", prim1, region1); 174 SceneObjectGroup sog = NewSOG("object1", prim1, region1);
178 SceneObjectGroup sog2 = NewSOG("object2", prim2, region1); 175 SceneObjectGroup sog2 = NewSOG("object2", prim2, region1);
179 176
@@ -207,6 +204,8 @@ namespace OpenSim.Data.Tests
207 [Test] 204 [Test]
208 public void T011_ObjectNames() 205 public void T011_ObjectNames()
209 { 206 {
207 TestHelper.InMethod();
208
210 List<SceneObjectGroup> objs = db.LoadObjects(region1); 209 List<SceneObjectGroup> objs = db.LoadObjects(region1);
211 foreach (SceneObjectGroup sog in objs) 210 foreach (SceneObjectGroup sog in objs)
212 { 211 {
@@ -219,6 +218,8 @@ namespace OpenSim.Data.Tests
219 [Test] 218 [Test]
220 public void T012_SceneParts() 219 public void T012_SceneParts()
221 { 220 {
221 TestHelper.InMethod();
222
222 UUID tmp0 = UUID.Random(); 223 UUID tmp0 = UUID.Random();
223 UUID tmp1 = UUID.Random(); 224 UUID tmp1 = UUID.Random();
224 UUID tmp2 = UUID.Random(); 225 UUID tmp2 = UUID.Random();
@@ -252,6 +253,8 @@ namespace OpenSim.Data.Tests
252 [Test] 253 [Test]
253 public void T013_DatabasePersistency() 254 public void T013_DatabasePersistency()
254 { 255 {
256 TestHelper.InMethod();
257
255 // Sets all ScenePart parameters, stores and retrieves them, then check for consistency with initial data 258 // Sets all ScenePart parameters, stores and retrieves them, then check for consistency with initial data
256 // The commented Asserts are the ones that are unchangeable (when storing on the database, their "Set" values are ignored 259 // The commented Asserts are the ones that are unchangeable (when storing on the database, their "Set" values are ignored
257 // The ObjectFlags is an exception, if it is entered incorrectly, the object IS REJECTED on the database silently. 260 // The ObjectFlags is an exception, if it is entered incorrectly, the object IS REJECTED on the database silently.
@@ -427,6 +430,8 @@ namespace OpenSim.Data.Tests
427 [Test] 430 [Test]
428 public void T014_UpdateObject() 431 public void T014_UpdateObject()
429 { 432 {
433 TestHelper.InMethod();
434
430 string text1 = "object1 text"; 435 string text1 = "object1 text";
431 SceneObjectGroup sog = FindSOG("object1", region1); 436 SceneObjectGroup sog = FindSOG("object1", region1);
432 sog.RootPart.Text = text1; 437 sog.RootPart.Text = text1;
@@ -528,15 +533,20 @@ namespace OpenSim.Data.Tests
528 Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))"); 533 Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))");
529 Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))"); 534 Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))");
530 } 535 }
531 536
537 /// <summary>
538 /// Test storage and retrieval of a scene object with a large number of parts.
539 /// </summary>
532 [Test] 540 [Test]
533 public void T015_LargeSceneObjects() 541 public void T015_LargeSceneObjects()
534 { 542 {
543 TestHelper.InMethod();
544
535 UUID id = UUID.Random(); 545 UUID id = UUID.Random();
536 Dictionary<UUID, SceneObjectPart> mydic = new Dictionary<UUID, SceneObjectPart>(); 546 Dictionary<UUID, SceneObjectPart> mydic = new Dictionary<UUID, SceneObjectPart>();
537 SceneObjectGroup sog = NewSOG("Test SOG", id, region4); 547 SceneObjectGroup sog = NewSOG("Test SOG", id, region4);
538 mydic.Add(sog.RootPart.UUID,sog.RootPart); 548 mydic.Add(sog.RootPart.UUID,sog.RootPart);
539 for (int i=0;i<30;i++) 549 for (int i = 0; i < 30; i++)
540 { 550 {
541 UUID tmp = UUID.Random(); 551 UUID tmp = UUID.Random();
542 SceneObjectPart sop = NewSOP(("Test SOP " + i.ToString()),tmp); 552 SceneObjectPart sop = NewSOP(("Test SOP " + i.ToString()),tmp);
@@ -555,13 +565,14 @@ namespace OpenSim.Data.Tests
555 sop.Acceleration = accel; 565 sop.Acceleration = accel;
556 566
557 mydic.Add(tmp,sop); 567 mydic.Add(tmp,sop);
558 sog.AddPart(sop); 568 sog.AddPart(sop);
559 db.StoreObject(sog, region4);
560 } 569 }
561 570
571 db.StoreObject(sog, region4);
572
562 SceneObjectGroup retsog = FindSOG("Test SOG", region4); 573 SceneObjectGroup retsog = FindSOG("Test SOG", region4);
563 SceneObjectPart[] parts = retsog.Parts; 574 SceneObjectPart[] parts = retsog.Parts;
564 for (int i=0;i<30;i++) 575 for (int i = 0; i < 30; i++)
565 { 576 {
566 SceneObjectPart cursop = mydic[parts[i].UUID]; 577 SceneObjectPart cursop = mydic[parts[i].UUID];
567 Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition), "Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition))"); 578 Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition), "Assert.That(cursop.GroupPosition,Is.EqualTo(parts[i].GroupPosition))");
@@ -576,6 +587,8 @@ namespace OpenSim.Data.Tests
576 //[Test] 587 //[Test]
577 public void T016_RandomSogWithSceneParts() 588 public void T016_RandomSogWithSceneParts()
578 { 589 {
590 TestHelper.InMethod();
591
579 PropertyScrambler<SceneObjectPart> scrambler = 592 PropertyScrambler<SceneObjectPart> scrambler =
580 new PropertyScrambler<SceneObjectPart>() 593 new PropertyScrambler<SceneObjectPart>()
581 .DontScramble(x => x.UUID); 594 .DontScramble(x => x.UUID);
@@ -642,15 +655,16 @@ namespace OpenSim.Data.Tests
642 return sog; 655 return sog;
643 } 656 }
644 657
645
646 // NOTE: it is a bad practice to rely on some of the previous tests having been run before. 658 // NOTE: it is a bad practice to rely on some of the previous tests having been run before.
647 // If the tests are run manually, one at a time, each starts with full class init (DB cleared). 659 // If the tests are run manually, one at a time, each starts with full class init (DB cleared).
648 // Even when all tests are run, NUnit 2.5+ no longer guarantee a specific test order. 660 // Even when all tests are run, NUnit 2.5+ no longer guarantee a specific test order.
649 // We shouldn't expect to find anything in the DB if we haven't put it there *in the same test*! 661 // We shouldn't expect to find anything in the DB if we haven't put it there *in the same test*!
650 662
651 [Test] 663 [Test]
652 public void T020_PrimInventoryEmpty() 664 public void T020_PrimInventoryEmpty()
653 { 665 {
666 TestHelper.InMethod();
667
654 SceneObjectGroup sog = GetMySOG("object1"); 668 SceneObjectGroup sog = GetMySOG("object1");
655 TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); 669 TaskInventoryItem t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
656 Assert.That(t, Is.Null); 670 Assert.That(t, Is.Null);
@@ -670,10 +684,11 @@ namespace OpenSim.Data.Tests
670 db.StorePrimInventory(sog.RootPart.UUID, list); 684 db.StorePrimInventory(sog.RootPart.UUID, list);
671 } 685 }
672 686
673
674 [Test] 687 [Test]
675 public void T021_PrimInventoryBasic() 688 public void T021_PrimInventoryBasic()
676 { 689 {
690 TestHelper.InMethod();
691
677 SceneObjectGroup sog = GetMySOG("object1"); 692 SceneObjectGroup sog = GetMySOG("object1");
678 InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero); 693 InventoryItemBase i = NewItem(item1, zero, zero, itemname1, zero);
679 694
@@ -701,20 +716,19 @@ namespace OpenSim.Data.Tests
701 Assert.That(t2.Name, Is.EqualTo("My New Name"), "Assert.That(t.Name, Is.EqualTo(\"My New Name\"))"); 716 Assert.That(t2.Name, Is.EqualTo("My New Name"), "Assert.That(t.Name, Is.EqualTo(\"My New Name\"))");
702 717
703 // Removing inventory 718 // Removing inventory
704
705 List<TaskInventoryItem> list = new List<TaskInventoryItem>(); 719 List<TaskInventoryItem> list = new List<TaskInventoryItem>();
706 db.StorePrimInventory(prim1, list); 720 db.StorePrimInventory(prim1, list);
707 721
708 sog = FindSOG("object1", region1); 722 sog = FindSOG("object1", region1);
709 t = sog.GetInventoryItem(sog.RootPart.LocalId, item1); 723 t = sog.GetInventoryItem(sog.RootPart.LocalId, item1);
710 Assert.That(t, Is.Null); 724 Assert.That(t, Is.Null);
711
712 } 725 }
713
714 726
715 [Test] 727 [Test]
716 public void T025_PrimInventoryPersistency() 728 public void T025_PrimInventoryPersistency()
717 { 729 {
730 TestHelper.InMethod();
731
718 InventoryItemBase i = new InventoryItemBase(); 732 InventoryItemBase i = new InventoryItemBase();
719 UUID id = UUID.Random(); 733 UUID id = UUID.Random();
720 i.ID = id; 734 i.ID = id;
@@ -786,6 +800,8 @@ namespace OpenSim.Data.Tests
786 [ExpectedException(typeof(ArgumentException))] 800 [ExpectedException(typeof(ArgumentException))]
787 public void T026_PrimInventoryMany() 801 public void T026_PrimInventoryMany()
788 { 802 {
803 TestHelper.InMethod();
804
789 UUID i1,i2,i3,i4; 805 UUID i1,i2,i3,i4;
790 i1 = UUID.Random(); 806 i1 = UUID.Random();
791 i2 = UUID.Random(); 807 i2 = UUID.Random();
@@ -816,15 +832,18 @@ namespace OpenSim.Data.Tests
816 [Test] 832 [Test]
817 public void T052_RemoveObject() 833 public void T052_RemoveObject()
818 { 834 {
835 TestHelper.InMethod();
836
819 db.RemoveObject(prim1, region1); 837 db.RemoveObject(prim1, region1);
820 SceneObjectGroup sog = FindSOG("object1", region1); 838 SceneObjectGroup sog = FindSOG("object1", region1);
821 Assert.That(sog, Is.Null); 839 Assert.That(sog, Is.Null);
822 } 840 }
823 841
824
825 [Test] 842 [Test]
826 public void T100_DefaultRegionInfo() 843 public void T100_DefaultRegionInfo()
827 { 844 {
845 TestHelper.InMethod();
846
828 RegionSettings r1 = db.LoadRegionSettings(region1); 847 RegionSettings r1 = db.LoadRegionSettings(region1);
829 Assert.That(r1.RegionUUID, Is.EqualTo(region1), "Assert.That(r1.RegionUUID, Is.EqualTo(region1))"); 848 Assert.That(r1.RegionUUID, Is.EqualTo(region1), "Assert.That(r1.RegionUUID, Is.EqualTo(region1))");
830 849
@@ -835,6 +854,8 @@ namespace OpenSim.Data.Tests
835 [Test] 854 [Test]
836 public void T101_UpdateRegionInfo() 855 public void T101_UpdateRegionInfo()
837 { 856 {
857 TestHelper.InMethod();
858
838 int agentlimit = random.Next(); 859 int agentlimit = random.Next();
839 double objectbonus = random.Next(); 860 double objectbonus = random.Next();
840 int maturity = random.Next(); 861 int maturity = random.Next();
@@ -933,13 +954,14 @@ namespace OpenSim.Data.Tests
933 //Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid), "Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid))"); 954 //Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid), "Assert.That(r1a.TerrainImageID,Is.EqualTo(terimgid))");
934 Assert.That(r1a.FixedSun,Is.True); 955 Assert.That(r1a.FixedSun,Is.True);
935 Assert.That(r1a.SunPosition, Is.EqualTo(sunpos), "Assert.That(r1a.SunPosition, Is.EqualTo(sunpos))"); 956 Assert.That(r1a.SunPosition, Is.EqualTo(sunpos), "Assert.That(r1a.SunPosition, Is.EqualTo(sunpos))");
936 Assert.That(r1a.Covenant, Is.EqualTo(cov), "Assert.That(r1a.Covenant, Is.EqualTo(cov))"); 957 Assert.That(r1a.Covenant, Is.EqualTo(cov), "Assert.That(r1a.Covenant, Is.EqualTo(cov))");
937
938 } 958 }
939 959
940 [Test] 960 [Test]
941 public void T300_NoTerrain() 961 public void T300_NoTerrain()
942 { 962 {
963 TestHelper.InMethod();
964
943 Assert.That(db.LoadTerrain(zero), Is.Null); 965 Assert.That(db.LoadTerrain(zero), Is.Null);
944 Assert.That(db.LoadTerrain(region1), Is.Null); 966 Assert.That(db.LoadTerrain(region1), Is.Null);
945 Assert.That(db.LoadTerrain(region2), Is.Null); 967 Assert.That(db.LoadTerrain(region2), Is.Null);
@@ -949,6 +971,8 @@ namespace OpenSim.Data.Tests
949 [Test] 971 [Test]
950 public void T301_CreateTerrain() 972 public void T301_CreateTerrain()
951 { 973 {
974 TestHelper.InMethod();
975
952 double[,] t1 = GenTerrain(height1); 976 double[,] t1 = GenTerrain(height1);
953 db.StoreTerrain(t1, region1); 977 db.StoreTerrain(t1, region1);
954 978
@@ -961,6 +985,8 @@ namespace OpenSim.Data.Tests
961 [Test] 985 [Test]
962 public void T302_FetchTerrain() 986 public void T302_FetchTerrain()
963 { 987 {
988 TestHelper.InMethod();
989
964 double[,] baseterrain1 = GenTerrain(height1); 990 double[,] baseterrain1 = GenTerrain(height1);
965 double[,] baseterrain2 = GenTerrain(height2); 991 double[,] baseterrain2 = GenTerrain(height2);
966 double[,] t1 = db.LoadTerrain(region1); 992 double[,] t1 = db.LoadTerrain(region1);
@@ -971,6 +997,8 @@ namespace OpenSim.Data.Tests
971 [Test] 997 [Test]
972 public void T303_UpdateTerrain() 998 public void T303_UpdateTerrain()
973 { 999 {
1000 TestHelper.InMethod();
1001
974 double[,] baseterrain1 = GenTerrain(height1); 1002 double[,] baseterrain1 = GenTerrain(height1);
975 double[,] baseterrain2 = GenTerrain(height2); 1003 double[,] baseterrain2 = GenTerrain(height2);
976 db.StoreTerrain(baseterrain2, region1); 1004 db.StoreTerrain(baseterrain2, region1);
@@ -983,6 +1011,8 @@ namespace OpenSim.Data.Tests
983 [Test] 1011 [Test]
984 public void T400_EmptyLand() 1012 public void T400_EmptyLand()
985 { 1013 {
1014 TestHelper.InMethod();
1015
986 Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0))"); 1016 Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(zero).Count, Is.EqualTo(0))");
987 Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0))"); 1017 Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region1).Count, Is.EqualTo(0))");
988 Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0))"); 1018 Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0), "Assert.That(db.LoadLandObjects(region2).Count, Is.EqualTo(0))");
@@ -1018,25 +1048,12 @@ namespace OpenSim.Data.Tests
1018 return true; 1048 return true;
1019 } 1049 }
1020 1050
1021
1022 private SceneObjectGroup FindSOG(string name, UUID r) 1051 private SceneObjectGroup FindSOG(string name, UUID r)
1023 { 1052 {
1024 List<SceneObjectGroup> objs = db.LoadObjects(r); 1053 List<SceneObjectGroup> objs = db.LoadObjects(r);
1025 foreach (SceneObjectGroup sog in objs) 1054 foreach (SceneObjectGroup sog in objs)
1026 { 1055 if (sog.Name == name)
1027 SceneObjectPart p = sog.RootPart;
1028 if (p.Name == name) {
1029 RegionInfo regionInfo = new RegionInfo();
1030 regionInfo.RegionID = r;
1031 regionInfo.RegionLocX = 0;
1032 regionInfo.RegionLocY = 0;
1033
1034 Scene scene = new Scene(regionInfo);
1035 sog.SetScene(scene);
1036
1037 return sog; 1056 return sog;
1038 }
1039 }
1040 1057
1041 return null; 1058 return null;
1042 } 1059 }
diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs
index 1600bdc..3dbc215 100644
--- a/OpenSim/Framework/AgentCircuitData.cs
+++ b/OpenSim/Framework/AgentCircuitData.cs
@@ -220,6 +220,8 @@ namespace OpenSim.Framework
220 args["packed_appearance"] = appmap; 220 args["packed_appearance"] = appmap;
221 } 221 }
222 222
223 // Old, bad way. Keeping it fow now for backwards compatibility
224 // OBSOLETE -- soon to be deleted
223 if (ServiceURLs != null && ServiceURLs.Count > 0) 225 if (ServiceURLs != null && ServiceURLs.Count > 0)
224 { 226 {
225 OSDArray urls = new OSDArray(ServiceURLs.Count * 2); 227 OSDArray urls = new OSDArray(ServiceURLs.Count * 2);
@@ -232,6 +234,19 @@ namespace OpenSim.Framework
232 args["service_urls"] = urls; 234 args["service_urls"] = urls;
233 } 235 }
234 236
237 // again, this time the right way
238 if (ServiceURLs != null && ServiceURLs.Count > 0)
239 {
240 OSDMap urls = new OSDMap();
241 foreach (KeyValuePair<string, object> kvp in ServiceURLs)
242 {
243 //System.Console.WriteLine("XXX " + kvp.Key + "=" + kvp.Value);
244 urls[kvp.Key] = OSD.FromString((kvp.Value == null) ? string.Empty : kvp.Value.ToString());
245 }
246 args["serviceurls"] = urls;
247 }
248
249
235 return args; 250 return args;
236 } 251 }
237 252
@@ -327,7 +342,20 @@ namespace OpenSim.Framework
327 } 342 }
328 343
329 ServiceURLs = new Dictionary<string, object>(); 344 ServiceURLs = new Dictionary<string, object>();
330 if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array) 345 // Try parse the new way, OSDMap
346 if (args.ContainsKey("serviceurls") && args["serviceurls"] != null && (args["serviceurls"]).Type == OSDType.Map)
347 {
348 OSDMap urls = (OSDMap)(args["serviceurls"]);
349 foreach (KeyValuePair<String, OSD> kvp in urls)
350 {
351 ServiceURLs[kvp.Key] = kvp.Value.AsString();
352 //System.Console.WriteLine("XXX " + kvp.Key + "=" + ServiceURLs[kvp.Key]);
353
354 }
355 }
356 // else try the old way, OSDArray
357 // OBSOLETE -- soon to be deleted
358 else if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array)
331 { 359 {
332 OSDArray urls = (OSDArray)(args["service_urls"]); 360 OSDArray urls = (OSDArray)(args["service_urls"]);
333 for (int i = 0; i < urls.Count / 2; i++) 361 for (int i = 0; i < urls.Count / 2; i++)
diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs
index c2f9c3a..3be97b5 100644
--- a/OpenSim/Framework/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Capabilities/Caps.cs
@@ -181,7 +181,6 @@ namespace OpenSim.Framework.Capabilities
181 181
182 RegisterRegionServiceHandlers(capsBase); 182 RegisterRegionServiceHandlers(capsBase);
183 RegisterInventoryServiceHandlers(capsBase); 183 RegisterInventoryServiceHandlers(capsBase);
184
185 } 184 }
186 185
187 public void RegisterRegionServiceHandlers(string capsBase) 186 public void RegisterRegionServiceHandlers(string capsBase)
diff --git a/OpenSim/Framework/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Capabilities/CapsHandlers.cs
index 864e6dd..e1c800e 100644
--- a/OpenSim/Framework/Capabilities/CapsHandlers.cs
+++ b/OpenSim/Framework/Capabilities/CapsHandlers.cs
@@ -88,8 +88,8 @@ namespace OpenSim.Framework.Capabilities
88 /// handler to be removed</param> 88 /// handler to be removed</param>
89 public void Remove(string capsName) 89 public void Remove(string capsName)
90 { 90 {
91 // This line must be here, or caps will break!
92 m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path); 91 m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path);
92 m_httpListener.RemoveStreamHandler("GET", m_capsHandlers[capsName].Path);
93 m_capsHandlers.Remove(capsName); 93 m_capsHandlers.Remove(capsName);
94 } 94 }
95 95
diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs
index f9c13f3..afbdd49 100644
--- a/OpenSim/Framework/EstateSettings.cs
+++ b/OpenSim/Framework/EstateSettings.cs
@@ -58,6 +58,30 @@ namespace OpenSim.Framework
58 set { m_EstateName = value; } 58 set { m_EstateName = value; }
59 } 59 }
60 60
61 private bool m_AllowLandmark = true;
62
63 public bool AllowLandmark
64 {
65 get { return m_AllowLandmark; }
66 set { m_AllowLandmark = value; }
67 }
68
69 private bool m_AllowParcelChanges = true;
70
71 public bool AllowParcelChanges
72 {
73 get { return m_AllowParcelChanges; }
74 set { m_AllowParcelChanges = value; }
75 }
76
77 private bool m_AllowSetHome = true;
78
79 public bool AllowSetHome
80 {
81 get { return m_AllowSetHome; }
82 set { m_AllowSetHome = value; }
83 }
84
61 private uint m_ParentEstateID = 1; 85 private uint m_ParentEstateID = 1;
62 86
63 public uint ParentEstateID 87 public uint ParentEstateID
@@ -392,5 +416,14 @@ namespace OpenSim.Framework
392 416
393 return l_EstateAccess.Contains(user); 417 return l_EstateAccess.Contains(user);
394 } 418 }
419
420 public void SetFromFlags(ulong regionFlags)
421 {
422 ResetHomeOnTeleport = ((regionFlags & (ulong)RegionFlags.ResetHomeOnTeleport) == (ulong)RegionFlags.ResetHomeOnTeleport);
423 BlockDwell = ((regionFlags & (ulong)RegionFlags.BlockDwell) == (ulong)RegionFlags.BlockDwell);
424 AllowLandmark = ((regionFlags & (ulong)RegionFlags.AllowLandmark) == (ulong)RegionFlags.AllowLandmark);
425 AllowParcelChanges = ((regionFlags & (ulong)RegionFlags.AllowParcelChanges) == (ulong)RegionFlags.AllowParcelChanges);
426 AllowSetHome = ((regionFlags & (ulong)RegionFlags.AllowSetHome) == (ulong)RegionFlags.AllowSetHome);
427 }
395 } 428 }
396} 429}
diff --git a/OpenSim/Framework/IMoneyModule.cs b/OpenSim/Framework/IMoneyModule.cs
index 3d4873d..ea6ed4b 100644
--- a/OpenSim/Framework/IMoneyModule.cs
+++ b/OpenSim/Framework/IMoneyModule.cs
@@ -40,6 +40,7 @@ namespace OpenSim.Framework
40 bool AmountCovered(IClientAPI client, int amount); 40 bool AmountCovered(IClientAPI client, int amount);
41 void ApplyCharge(UUID agentID, int amount, string text); 41 void ApplyCharge(UUID agentID, int amount, string text);
42 void ApplyUploadCharge(UUID agentID, int amount, string text); 42 void ApplyUploadCharge(UUID agentID, int amount, string text);
43 void MoveMoney(UUID fromUser, UUID toUser, int amount, string text);
43 44
44 int UploadCharge { get; } 45 int UploadCharge { get; }
45 int GroupCreationCharge { get; } 46 int GroupCreationCharge { get; }
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index 9a38f23..44f484e 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -250,7 +250,7 @@ namespace OpenSim.Framework
250 { 250 {
251 get 251 get
252 { 252 {
253 //m_log.DebugFormat("[SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length); 253// m_log.DebugFormat("[SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length);
254 try { return new Primitive.TextureEntry(m_textureEntry, 0, m_textureEntry.Length); } 254 try { return new Primitive.TextureEntry(m_textureEntry, 0, m_textureEntry.Length); }
255 catch { } 255 catch { }
256 256
diff --git a/OpenSim/Framework/Serialization/External/OspResolver.cs b/OpenSim/Framework/Serialization/External/OspResolver.cs
index 7e3dd1b..d31d27c 100644
--- a/OpenSim/Framework/Serialization/External/OspResolver.cs
+++ b/OpenSim/Framework/Serialization/External/OspResolver.cs
@@ -66,6 +66,8 @@ namespace OpenSim.Framework.Serialization
66 UserAccount account = userService.GetUserAccount(UUID.Zero, userId); 66 UserAccount account = userService.GetUserAccount(UUID.Zero, userId);
67 if (account != null) 67 if (account != null)
68 return MakeOspa(account.FirstName, account.LastName); 68 return MakeOspa(account.FirstName, account.LastName);
69// else
70// m_log.WarnFormat("[OSP RESOLVER]: No user account for {0}", userId);
69 71
70 return null; 72 return null;
71 } 73 }
@@ -77,6 +79,8 @@ namespace OpenSim.Framework.Serialization
77 /// <returns></returns> 79 /// <returns></returns>
78 public static string MakeOspa(string firstName, string lastName) 80 public static string MakeOspa(string firstName, string lastName)
79 { 81 {
82// m_log.DebugFormat("[OSP RESOLVER]: Making OSPA for {0} {1}", firstName, lastName);
83
80 return 84 return
81 OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; 85 OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName;
82 } 86 }
@@ -97,7 +101,10 @@ namespace OpenSim.Framework.Serialization
97 public static UUID ResolveOspa(string ospa, IUserAccountService userService) 101 public static UUID ResolveOspa(string ospa, IUserAccountService userService)
98 { 102 {
99 if (!ospa.StartsWith(OSPA_PREFIX)) 103 if (!ospa.StartsWith(OSPA_PREFIX))
100 return UUID.Zero; 104 {
105// m_log.DebugFormat("[OSP RESOLVER]: ResolveOspa() got unrecognized format [{0}]", ospa);
106 return UUID.Zero;
107 }
101 108
102// m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); 109// m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa);
103 110
@@ -161,7 +168,17 @@ namespace OpenSim.Framework.Serialization
161 168
162 UserAccount account = userService.GetUserAccount(UUID.Zero, firstName, lastName); 169 UserAccount account = userService.GetUserAccount(UUID.Zero, firstName, lastName);
163 if (account != null) 170 if (account != null)
171 {
172// m_log.DebugFormat(
173// "[OSP RESOLVER]: Found user account with uuid {0} for {1} {2}",
174// account.PrincipalID, firstName, lastName);
175
164 return account.PrincipalID; 176 return account.PrincipalID;
177 }
178// else
179// {
180// m_log.DebugFormat("[OSP RESOLVER]: No resolved OSPA user account for {0}", name);
181// }
165 182
166 // XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc 183 // XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc
167 /* 184 /*
diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
index d5e84c7..f138437 100644
--- a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
@@ -303,7 +303,7 @@ namespace OpenSim.Framework.Serialization.External
303 writer.WriteStartElement("GroupOwned"); 303 writer.WriteStartElement("GroupOwned");
304 writer.WriteString(inventoryItem.GroupOwned.ToString()); 304 writer.WriteString(inventoryItem.GroupOwned.ToString());
305 writer.WriteEndElement(); 305 writer.WriteEndElement();
306 if (inventoryItem.CreatorData != null && inventoryItem.CreatorData != string.Empty) 306 if (options.ContainsKey("creators") && inventoryItem.CreatorData != null && inventoryItem.CreatorData != string.Empty)
307 writer.WriteElementString("CreatorData", inventoryItem.CreatorData); 307 writer.WriteElementString("CreatorData", inventoryItem.CreatorData);
308 else if (options.ContainsKey("profile")) 308 else if (options.ContainsKey("profile"))
309 { 309 {
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index ebf7ded..5c3cad4 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -319,18 +319,21 @@ namespace OpenSim.Framework.Servers
319 return; 319 return;
320 } 320 }
321 321
322 string rawLevel = cmd[3]; 322 if (cmd.Length > 3)
323 323 {
324 ILoggerRepository repository = LogManager.GetRepository(); 324 string rawLevel = cmd[3];
325 Level consoleLevel = repository.LevelMap[rawLevel]; 325
326 326 ILoggerRepository repository = LogManager.GetRepository();
327 if (consoleLevel != null) 327 Level consoleLevel = repository.LevelMap[rawLevel];
328 m_consoleAppender.Threshold = consoleLevel; 328
329 else 329 if (consoleLevel != null)
330 Notice( 330 m_consoleAppender.Threshold = consoleLevel;
331 String.Format( 331 else
332 "{0} is not a valid logging level. Valid logging levels are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF", 332 Notice(
333 rawLevel)); 333 String.Format(
334 "{0} is not a valid logging level. Valid logging levels are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF",
335 rawLevel));
336 }
334 337
335 Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); 338 Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold));
336 } 339 }
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index d4ee7ba..ccec9b7 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -143,6 +143,11 @@ namespace OpenSim.Framework.Servers.HttpServer
143 } 143 }
144 } 144 }
145 145
146 public List<string> GetStreamHandlerKeys()
147 {
148 return new List<string>(m_streamHandlers.Keys);
149 }
150
146 private static string GetHandlerKey(string httpMethod, string path) 151 private static string GetHandlerKey(string httpMethod, string path)
147 { 152 {
148 return httpMethod + ":" + path; 153 return httpMethod + ":" + path;
@@ -179,6 +184,11 @@ namespace OpenSim.Framework.Servers.HttpServer
179 } 184 }
180 } 185 }
181 186
187 public List<string> GetXmlRpcHandlerKeys()
188 {
189 return new List<string>(m_rpcHandlers.Keys);
190 }
191
182 public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler) 192 public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler)
183 { 193 {
184 //m_log.DebugFormat("[BASE HTTP SERVER]: Registering {0}", methodName); 194 //m_log.DebugFormat("[BASE HTTP SERVER]: Registering {0}", methodName);
@@ -196,6 +206,12 @@ namespace OpenSim.Framework.Servers.HttpServer
196 return false; 206 return false;
197 } 207 }
198 208
209 public List<string> GetHTTPHandlerKeys()
210 {
211 return new List<string>(m_HTTPHandlers.Keys);
212 }
213
214
199 public bool AddPollServiceHTTPHandler(string methodName, GenericHTTPMethod handler, PollServiceEventArgs args) 215 public bool AddPollServiceHTTPHandler(string methodName, GenericHTTPMethod handler, PollServiceEventArgs args)
200 { 216 {
201 bool pollHandlerResult = false; 217 bool pollHandlerResult = false;
@@ -214,6 +230,12 @@ namespace OpenSim.Framework.Servers.HttpServer
214 return false; 230 return false;
215 } 231 }
216 232
233 public List<string> GetPollServiceHandlerKeys()
234 {
235 return new List<string>(m_pollHandlers.Keys);
236 }
237
238
217 // Note that the agent string is provided simply to differentiate 239 // Note that the agent string is provided simply to differentiate
218 // the handlers - it is NOT required to be an actual agent header 240 // the handlers - it is NOT required to be an actual agent header
219 // value. 241 // value.
@@ -232,6 +254,11 @@ namespace OpenSim.Framework.Servers.HttpServer
232 return false; 254 return false;
233 } 255 }
234 256
257 public List<string> GetAgentHandlerKeys()
258 {
259 return new List<string>(m_agentHandlers.Keys);
260 }
261
235 public bool AddLLSDHandler(string path, LLSDMethod handler) 262 public bool AddLLSDHandler(string path, LLSDMethod handler)
236 { 263 {
237 lock (m_llsdHandlers) 264 lock (m_llsdHandlers)
@@ -245,6 +272,11 @@ namespace OpenSim.Framework.Servers.HttpServer
245 return false; 272 return false;
246 } 273 }
247 274
275 public List<string> GetLLSDHandlerKeys()
276 {
277 return new List<string>(m_llsdHandlers.Keys);
278 }
279
248 public bool SetDefaultLLSDHandler(DefaultLLSDMethod handler) 280 public bool SetDefaultLLSDHandler(DefaultLLSDMethod handler)
249 { 281 {
250 m_defaultLlsdHandler = handler; 282 m_defaultLlsdHandler = handler;
@@ -346,6 +378,22 @@ namespace OpenSim.Framework.Servers.HttpServer
346 /// <param name="response"></param> 378 /// <param name="response"></param>
347 public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response) 379 public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response)
348 { 380 {
381 if (request.HttpMethod == String.Empty) // Can't handle empty requests, not wasting a thread
382 {
383 try
384 {
385 SendHTML500(response);
386 }
387 catch
388 {
389 }
390
391 return;
392 }
393
394 string requestMethod = request.HttpMethod;
395 string uriString = request.RawUrl;
396
349 string reqnum = "unknown"; 397 string reqnum = "unknown";
350 int tickstart = Environment.TickCount; 398 int tickstart = Environment.TickCount;
351 399
@@ -463,7 +511,7 @@ namespace OpenSim.Framework.Servers.HttpServer
463 511
464 request.InputStream.Close(); 512 request.InputStream.Close();
465 513
466 // HTTP IN support. The script engine taes it from here 514 // HTTP IN support. The script engine takes it from here
467 // Nothing to worry about for us. 515 // Nothing to worry about for us.
468 // 516 //
469 if (buffer == null) 517 if (buffer == null)
@@ -577,19 +625,19 @@ namespace OpenSim.Framework.Servers.HttpServer
577 { 625 {
578 m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw ", e); 626 m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw ", e);
579 } 627 }
580 catch (InvalidOperationException e) 628 catch (Exception e)
581 { 629 {
582 m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}", e); 630 m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw " + e.ToString());
583 SendHTML500(response); 631 SendHTML500(response);
584 } 632 }
585 finally 633 finally
586 { 634 {
587 // Every month or so this will wrap and give bad numbers, not really a problem 635 // Every month or so this will wrap and give bad numbers, not really a problem
588 // since its just for reporting, 200ms limit can be adjusted 636 // since its just for reporting, tickdiff limit can be adjusted
589 int tickdiff = Environment.TickCount - tickstart; 637 int tickdiff = Environment.TickCount - tickstart;
590 if (tickdiff > 500) 638 if (tickdiff > 3000)
591 m_log.InfoFormat( 639 m_log.InfoFormat(
592 "[BASE HTTP SERVER]: slow request <{0}> for {1} took {2} ms", reqnum, request.RawUrl, tickdiff); 640 "[BASE HTTP SERVER]: slow {0} request for {1} from {2} took {3} ms", requestMethod, uriString, request.RemoteIPEndPoint.ToString(), tickdiff);
593 } 641 }
594 } 642 }
595 643
@@ -753,7 +801,19 @@ namespace OpenSim.Framework.Servers.HttpServer
753 if (methodWasFound) 801 if (methodWasFound)
754 { 802 {
755 xmlRprcRequest.Params.Add(request.Url); // Param[2] 803 xmlRprcRequest.Params.Add(request.Url); // Param[2]
756 xmlRprcRequest.Params.Add(request.Headers.Get("X-Forwarded-For")); // Param[3] 804
805 string xff = "X-Forwarded-For";
806 string xfflower = xff.ToLower();
807 foreach (string s in request.Headers.AllKeys)
808 {
809 if (s != null && s.Equals(xfflower))
810 {
811 xff = xfflower;
812 break;
813 }
814 }
815 xmlRprcRequest.Params.Add(request.Headers.Get(xff)); // Param[3]
816
757 817
758 try 818 try
759 { 819 {
diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpHandler.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpHandler.cs
index 129a544..2c2b47d 100644
--- a/OpenSim/Framework/Servers/HttpServer/OSHttpHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/OSHttpHandler.cs
@@ -83,7 +83,7 @@ namespace OpenSim.Framework.Servers.HttpServer
83 /// <summary> 83 /// <summary>
84 /// Regular expression used to match against path of the 84 /// Regular expression used to match against path of the
85 /// incoming HTTP request. If you want to match any string 85 /// incoming HTTP request. If you want to match any string
86 /// either use '.*' or null. To match on the emtpy string use 86 /// either use '.*' or null. To match on the empty string use
87 /// '^$'. 87 /// '^$'.
88 /// </summary> 88 /// </summary>
89 public virtual Regex Path 89 public virtual Regex Path
diff --git a/OpenSim/Framework/Servers/Tests/OSHttpTests.cs b/OpenSim/Framework/Servers/Tests/OSHttpTests.cs
index e62407a..dc4eb8f 100644
--- a/OpenSim/Framework/Servers/Tests/OSHttpTests.cs
+++ b/OpenSim/Framework/Servers/Tests/OSHttpTests.cs
@@ -34,7 +34,6 @@ using System.Text;
34using HttpServer; 34using HttpServer;
35using HttpServer.FormDecoders; 35using HttpServer.FormDecoders;
36using NUnit.Framework; 36using NUnit.Framework;
37using NUnit.Framework.SyntaxHelpers;
38using OpenSim.Framework.Servers.HttpServer; 37using OpenSim.Framework.Servers.HttpServer;
39 38
40namespace OpenSim.Framework.Servers.Tests 39namespace OpenSim.Framework.Servers.Tests
diff --git a/OpenSim/Framework/Tests/AnimationTests.cs b/OpenSim/Framework/Tests/AnimationTests.cs
index 719ddce..9aa95af 100644
--- a/OpenSim/Framework/Tests/AnimationTests.cs
+++ b/OpenSim/Framework/Tests/AnimationTests.cs
@@ -28,7 +28,6 @@
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using NUnit.Framework; 30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 31using OpenMetaverse;
33using OpenMetaverse.StructuredData; 32using OpenMetaverse.StructuredData;
34using OpenSim.Framework; 33using OpenSim.Framework;
diff --git a/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs b/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs
index d741f91..36bc6e7 100644
--- a/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs
+++ b/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs
@@ -28,7 +28,6 @@
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using NUnit.Framework; 30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 31using OpenMetaverse;
33using OpenMetaverse.StructuredData; 32using OpenMetaverse.StructuredData;
34using OpenSim.Framework; 33using OpenSim.Framework;
@@ -38,8 +37,6 @@ namespace OpenSim.Framework.Tests
38 [TestFixture] 37 [TestFixture]
39 public class PrimeNumberHelperTests 38 public class PrimeNumberHelperTests
40 { 39 {
41
42
43 [Test] 40 [Test]
44 public void TestGetPrime() 41 public void TestGetPrime()
45 { 42 {
diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs
index 89f5c0c..5eac411 100644
--- a/OpenSim/Framework/Tests/UtilTest.cs
+++ b/OpenSim/Framework/Tests/UtilTest.cs
@@ -27,7 +27,6 @@
27 27
28using System; 28using System;
29using NUnit.Framework; 29using NUnit.Framework;
30using NUnit.Framework.SyntaxHelpers;
31using OpenMetaverse; 30using OpenMetaverse;
32using OpenSim.Tests.Common; 31using OpenSim.Tests.Common;
33 32
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 96292ff..3f676f9 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -471,10 +471,17 @@ namespace OpenSim.Framework
471 /// <param name="oldy">Old region y-coord</param> 471 /// <param name="oldy">Old region y-coord</param>
472 /// <param name="newy">New region y-coord</param> 472 /// <param name="newy">New region y-coord</param>
473 /// <returns></returns> 473 /// <returns></returns>
474 public static bool IsOutsideView(uint oldx, uint newx, uint oldy, uint newy) 474 public static bool IsOutsideView(float drawdist, uint oldx, uint newx, uint oldy, uint newy)
475 { 475 {
476 // Eventually this will be a function of the draw distance / camera position too. 476 int dd = (int)((drawdist + Constants.RegionSize - 1) / Constants.RegionSize);
477 return (((int)Math.Abs((int)(oldx - newx)) > 1) || ((int)Math.Abs((int)(oldy - newy)) > 1)); 477
478 int startX = (int)oldx - dd;
479 int startY = (int)oldy - dd;
480
481 int endX = (int)oldx + dd;
482 int endY = (int)oldy + dd;
483
484 return (newx < startX || endX < newx || newy < startY || endY < newy);
478 } 485 }
479 486
480 public static string FieldToString(byte[] bytes) 487 public static string FieldToString(byte[] bytes)
@@ -1346,6 +1353,11 @@ namespace OpenSim.Framework
1346 return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri; 1353 return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri;
1347 } 1354 }
1348 1355
1356 public static byte[] StringToBytes256(string str, params object[] args)
1357 {
1358 return StringToBytes256(string.Format(str, args));
1359 }
1360
1349 public static byte[] StringToBytes256(string str) 1361 public static byte[] StringToBytes256(string str)
1350 { 1362 {
1351 if (String.IsNullOrEmpty(str)) { return Utils.EmptyBytes; } 1363 if (String.IsNullOrEmpty(str)) { return Utils.EmptyBytes; }
@@ -1364,6 +1376,11 @@ namespace OpenSim.Framework
1364 return data; 1376 return data;
1365 } 1377 }
1366 1378
1379 public static byte[] StringToBytes1024(string str, params object[] args)
1380 {
1381 return StringToBytes1024(string.Format(str, args));
1382 }
1383
1367 public static byte[] StringToBytes1024(string str) 1384 public static byte[] StringToBytes1024(string str)
1368 { 1385 {
1369 if (String.IsNullOrEmpty(str)) { return Utils.EmptyBytes; } 1386 if (String.IsNullOrEmpty(str)) { return Utils.EmptyBytes; }
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs
index 0593341..4f5add9 100644
--- a/OpenSim/Framework/WebUtil.cs
+++ b/OpenSim/Framework/WebUtil.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Collections.Specialized; 31using System.Collections.Specialized;
32using System.Globalization;
32using System.IO; 33using System.IO;
33using System.Net; 34using System.Net;
34using System.Net.Security; 35using System.Net.Security;
@@ -557,34 +558,27 @@ namespace OpenSim.Framework
557 { 558 {
558 float qx = GetQ(x); 559 float qx = GetQ(x);
559 float qy = GetQ(y); 560 float qy = GetQ(y);
560 if (qx < qy) 561 return qy.CompareTo(qx); // descending order
561 return -1;
562 if (qx == qy)
563 return 0;
564 return 1;
565 } 562 }
566 563
567 private float GetQ(Object o) 564 private float GetQ(Object o)
568 { 565 {
569 // Example: image/png;q=0.9 566 // Example: image/png;q=0.9
570 567
568 float qvalue = 1F;
571 if (o is String) 569 if (o is String)
572 { 570 {
573 string mime = (string)o; 571 string mime = (string)o;
574 string[] parts = mime.Split(new char[] { ';' }); 572 string[] parts = mime.Split(';');
575 if (parts.Length > 1) 573 if (parts.Length > 1)
576 { 574 {
577 string[] kvp = parts[1].Split(new char[] { '=' }); 575 string[] kvp = parts[1].Split('=');
578 if (kvp.Length == 2 && kvp[0] == "q") 576 if (kvp.Length == 2 && kvp[0] == "q")
579 { 577 float.TryParse(kvp[1], NumberStyles.Number, CultureInfo.InvariantCulture, out qvalue);
580 float qvalue = 1F;
581 float.TryParse(kvp[1], out qvalue);
582 return qvalue;
583 }
584 } 578 }
585 } 579 }
586 580
587 return 1F; 581 return qvalue;
588 } 582 }
589 } 583 }
590 584
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 1c84e3f..313cdca 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -294,6 +294,18 @@ namespace OpenSim
294 "show connections", 294 "show connections",
295 "Show connection data", HandleShow); 295 "Show connection data", HandleShow);
296 296
297 m_console.Commands.AddCommand("region", false, "show circuits",
298 "show circuits",
299 "Show agent circuit data", HandleShow);
300
301 m_console.Commands.AddCommand("region", false, "show http-handlers",
302 "show http-handlers",
303 "Show all registered http handlers", HandleShow);
304
305 m_console.Commands.AddCommand("region", false, "show pending-objects",
306 "show pending-objects",
307 "Show # of objects on the pending queues of all scene viewers", HandleShow);
308
297 m_console.Commands.AddCommand("region", false, "show modules", 309 m_console.Commands.AddCommand("region", false, "show modules",
298 "show modules", 310 "show modules",
299 "Show module data", HandleShow); 311 "Show module data", HandleShow);
@@ -943,6 +955,66 @@ namespace OpenSim
943 MainConsole.Instance.Output(connections.ToString()); 955 MainConsole.Instance.Output(connections.ToString());
944 break; 956 break;
945 957
958 case "circuits":
959 System.Text.StringBuilder acd = new System.Text.StringBuilder("Agent Circuits:\n");
960 m_sceneManager.ForEachScene(
961 delegate(Scene scene)
962 {
963 //this.HttpServer.
964 acd.AppendFormat("{0}:\n", scene.RegionInfo.RegionName);
965 foreach (AgentCircuitData aCircuit in scene.AuthenticateHandler.AgentCircuits.Values)
966 acd.AppendFormat("\t{0} {1} ({2})\n", aCircuit.firstname, aCircuit.lastname, (aCircuit.child ? "Child" : "Root"));
967 }
968 );
969
970 MainConsole.Instance.Output(acd.ToString());
971 break;
972
973 case "http-handlers":
974 System.Text.StringBuilder handlers = new System.Text.StringBuilder("Registered HTTP Handlers:\n");
975
976 handlers.AppendFormat("* XMLRPC:\n");
977 foreach (String s in HttpServer.GetXmlRpcHandlerKeys())
978 handlers.AppendFormat("\t{0}\n", s);
979
980 handlers.AppendFormat("* HTTP:\n");
981 List<String> poll = HttpServer.GetPollServiceHandlerKeys();
982 foreach (String s in HttpServer.GetHTTPHandlerKeys())
983 handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty));
984
985 handlers.AppendFormat("* Agent:\n");
986 foreach (String s in HttpServer.GetAgentHandlerKeys())
987 handlers.AppendFormat("\t{0}\n", s);
988
989 handlers.AppendFormat("* LLSD:\n");
990 foreach (String s in HttpServer.GetLLSDHandlerKeys())
991 handlers.AppendFormat("\t{0}\n", s);
992
993 handlers.AppendFormat("* StreamHandlers ({0}):\n", HttpServer.GetStreamHandlerKeys().Count);
994 foreach (String s in HttpServer.GetStreamHandlerKeys())
995 handlers.AppendFormat("\t{0}\n", s);
996
997 MainConsole.Instance.Output(handlers.ToString());
998 break;
999
1000 case "pending-objects":
1001 System.Text.StringBuilder pending = new System.Text.StringBuilder("Pending objects:\n");
1002 m_sceneManager.ForEachScene(
1003 delegate(Scene scene)
1004 {
1005 scene.ForEachScenePresence(
1006 delegate(ScenePresence sp)
1007 {
1008 pending.AppendFormat("{0}: {1} {2} pending\n",
1009 scene.RegionInfo.RegionName, sp.Name, sp.SceneViewer.GetPendingObjectsCount());
1010 }
1011 );
1012 }
1013 );
1014
1015 MainConsole.Instance.Output(pending.ToString());
1016 break;
1017
946 case "modules": 1018 case "modules":
947 MainConsole.Instance.Output("The currently loaded shared modules are:"); 1019 MainConsole.Instance.Output("The currently loaded shared modules are:");
948 foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules) 1020 foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules)
@@ -958,11 +1030,12 @@ namespace OpenSim
958 delegate(Scene scene) 1030 delegate(Scene scene)
959 { 1031 {
960 MainConsole.Instance.Output(String.Format( 1032 MainConsole.Instance.Output(String.Format(
961 "Region Name: {0}, Region XLoc: {1}, Region YLoc: {2}, Region Port: {3}", 1033 "Region Name: {0}, Region XLoc: {1}, Region YLoc: {2}, Region Port: {3}, Estate Name: {4}",
962 scene.RegionInfo.RegionName, 1034 scene.RegionInfo.RegionName,
963 scene.RegionInfo.RegionLocX, 1035 scene.RegionInfo.RegionLocX,
964 scene.RegionInfo.RegionLocY, 1036 scene.RegionInfo.RegionLocY,
965 scene.RegionInfo.InternalEndPoint.Port)); 1037 scene.RegionInfo.InternalEndPoint.Port,
1038 scene.RegionInfo.EstateSettings.EstateName));
966 }); 1039 });
967 break; 1040 break;
968 1041
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index b74a392..9960a54 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -877,9 +877,7 @@ namespace OpenSim
877 /// <summary> 877 /// <summary>
878 /// Load the estate information for the provided RegionInfo object. 878 /// Load the estate information for the provided RegionInfo object.
879 /// </summary> 879 /// </summary>
880 /// <param name="regInfo"> 880 /// <param name="regInfo"></param>
881 /// A <see cref="RegionInfo"/>
882 /// </param>
883 public void PopulateRegionEstateInfo(RegionInfo regInfo) 881 public void PopulateRegionEstateInfo(RegionInfo regInfo)
884 { 882 {
885 IEstateDataService estateDataService = EstateDataService; 883 IEstateDataService estateDataService = EstateDataService;
@@ -901,7 +899,13 @@ namespace OpenSim
901 regInfo.EstateSettings = estateDataService.LoadEstateSettings(regInfo.RegionID, true); 899 regInfo.EstateSettings = estateDataService.LoadEstateSettings(regInfo.RegionID, true);
902 900
903 regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName); 901 regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName);
904 //regInfo.EstateSettings.Save(); 902
903 // FIXME: Later on, the scene constructor will reload the estate settings no matter what.
904 // Therefore, we need to do an initial save here otherwise the new estate name will be reset
905 // back to the default. The reloading of estate settings by scene could be eliminated if it
906 // knows that the passed in settings in RegionInfo are already valid. Also, it might be
907 // possible to eliminate some additional later saves made by callers of this method.
908 regInfo.EstateSettings.Save();
905 break; 909 break;
906 } 910 }
907 else 911 else
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
index f1fdbc5..d6159cd 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
@@ -122,6 +122,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
122 public int PacketsReceived; 122 public int PacketsReceived;
123 /// <summary>Number of packets sent to this client</summary> 123 /// <summary>Number of packets sent to this client</summary>
124 public int PacketsSent; 124 public int PacketsSent;
125 /// <summary>Number of packets resent to this client</summary>
126 public int PacketsResent;
125 /// <summary>Total byte count of unacked packets sent to this client</summary> 127 /// <summary>Total byte count of unacked packets sent to this client</summary>
126 public int UnackedBytes; 128 public int UnackedBytes;
127 129
@@ -257,9 +259,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
257 public string GetStats() 259 public string GetStats()
258 { 260 {
259 return string.Format( 261 return string.Format(
260 "{0,7} {1,7} {2,9} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7} {10,7}", 262 "{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7}",
263 PacketsReceived,
261 PacketsSent, 264 PacketsSent,
262 PacketsReceived, 265 PacketsResent,
263 UnackedBytes, 266 UnackedBytes,
264 m_packetOutboxes[(int)ThrottleOutPacketType.Resend].Count, 267 m_packetOutboxes[(int)ThrottleOutPacketType.Resend].Count,
265 m_packetOutboxes[(int)ThrottleOutPacketType.Land].Count, 268 m_packetOutboxes[(int)ThrottleOutPacketType.Land].Count,
@@ -449,13 +452,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
449 /// an outgoing packet from each, obeying the throttling bucket limits 452 /// an outgoing packet from each, obeying the throttling bucket limits
450 /// </summary> 453 /// </summary>
451 /// 454 ///
455 /// <remarks>
452 /// Packet queues are inspected in ascending numerical order starting from 0. Therefore, queues with a lower 456 /// Packet queues are inspected in ascending numerical order starting from 0. Therefore, queues with a lower
453 /// ThrottleOutPacketType number will see their packet get sent first (e.g. if both Land and Wind queues have 457 /// ThrottleOutPacketType number will see their packet get sent first (e.g. if both Land and Wind queues have
454 /// packets, then the packet at the front of the Land queue will be sent before the packet at the front of the 458 /// packets, then the packet at the front of the Land queue will be sent before the packet at the front of the
455 /// wind queue). 459 /// wind queue).
456 /// 460 ///
457 /// <remarks>This function is only called from a synchronous loop in the 461 /// This function is only called from a synchronous loop in the
458 /// UDPServer so we don't need to bother making this thread safe</remarks> 462 /// UDPServer so we don't need to bother making this thread safe
463 /// </remarks>
464 ///
459 /// <returns>True if any packets were sent, otherwise false</returns> 465 /// <returns>True if any packets were sent, otherwise false</returns>
460 public bool DequeueOutgoing() 466 public bool DequeueOutgoing()
461 { 467 {
@@ -486,7 +492,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
486 m_udpServer.SendPacketFinal(nextPacket); 492 m_udpServer.SendPacketFinal(nextPacket);
487 m_nextPackets[i] = null; 493 m_nextPackets[i] = null;
488 packetSent = true; 494 packetSent = true;
489 this.PacketsSent++;
490 } 495 }
491 } 496 }
492 else 497 else
@@ -503,7 +508,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
503 // Send the packet 508 // Send the packet
504 m_udpServer.SendPacketFinal(packet); 509 m_udpServer.SendPacketFinal(packet);
505 packetSent = true; 510 packetSent = true;
506 this.PacketsSent++;
507 } 511 }
508 else 512 else
509 { 513 {
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 703176c..c865c0f 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics;
30using System.IO; 31using System.IO;
31using System.Net; 32using System.Net;
32using System.Net.Sockets; 33using System.Net.Sockets;
@@ -506,7 +507,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
506 507
507 // Bump up the resend count on this packet 508 // Bump up the resend count on this packet
508 Interlocked.Increment(ref outgoingPacket.ResendCount); 509 Interlocked.Increment(ref outgoingPacket.ResendCount);
509 //Interlocked.Increment(ref Stats.ResentPackets);
510 510
511 // Requeue or resend the packet 511 // Requeue or resend the packet
512 if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, false)) 512 if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, false))
@@ -582,6 +582,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
582 udpClient.NeedAcks.Add(outgoingPacket); 582 udpClient.NeedAcks.Add(outgoingPacket);
583 } 583 }
584 } 584 }
585 else
586 {
587 Interlocked.Increment(ref udpClient.PacketsResent);
588 }
585 589
586 #endregion Sequence Number Assignment 590 #endregion Sequence Number Assignment
587 591
@@ -636,10 +640,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
636 { 640 {
637 object[] array = new object[] { buffer, packet }; 641 object[] array = new object[] { buffer, packet };
638 642
639 if (m_asyncPacketHandling) 643 Util.FireAndForget(HandleUseCircuitCode, array);
640 Util.FireAndForget(HandleUseCircuitCode, array);
641 else
642 HandleUseCircuitCode(array);
643 644
644 return; 645 return;
645 } 646 }
@@ -844,7 +845,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
844 845
845 private void HandleUseCircuitCode(object o) 846 private void HandleUseCircuitCode(object o)
846 { 847 {
847 DateTime startTime = DateTime.Now; 848// DateTime startTime = DateTime.Now;
848 object[] array = (object[])o; 849 object[] array = (object[])o;
849 UDPPacketBuffer buffer = (UDPPacketBuffer)array[0]; 850 UDPPacketBuffer buffer = (UDPPacketBuffer)array[0];
850 UseCircuitCodePacket packet = (UseCircuitCodePacket)array[1]; 851 UseCircuitCodePacket packet = (UseCircuitCodePacket)array[1];
@@ -856,10 +857,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
856 // Begin the process of adding the client to the simulator 857 // Begin the process of adding the client to the simulator
857 AddNewClient((UseCircuitCodePacket)packet, remoteEndPoint); 858 AddNewClient((UseCircuitCodePacket)packet, remoteEndPoint);
858 859
859 // Acknowledge the UseCircuitCode packet 860 // Send ack
860 SendAckImmediate(remoteEndPoint, packet.Header.Sequence); 861 SendAckImmediate(remoteEndPoint, packet.Header.Sequence);
861 862
862// m_log.DebugFormat( 863 // m_log.DebugFormat(
863// "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms", 864// "[LLUDPSERVER]: Handling UseCircuitCode request from {0} took {1}ms",
864// buffer.RemoteEndPoint, (DateTime.Now - startTime).Milliseconds); 865// buffer.RemoteEndPoint, (DateTime.Now - startTime).Milliseconds);
865 } 866 }
@@ -923,25 +924,32 @@ namespace OpenSim.Region.ClientStack.LindenUDP
923 924
924 protected virtual void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo) 925 protected virtual void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo)
925 { 926 {
926 // Create the LLUDPClient 927 // In priciple there shouldn't be more than one thread here, ever.
927 LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO); 928 // But in case that happens, we need to synchronize this piece of code
928 IClientAPI existingClient; 929 // because it's too important
929 930 lock (this)
930 if (!m_scene.TryGetClient(agentID, out existingClient))
931 { 931 {
932 // Create the LLClientView 932 IClientAPI existingClient;
933 LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
934 client.OnLogout += LogoutHandler;
935 933
936 client.DisableFacelights = m_disableFacelights; 934 if (!m_scene.TryGetClient(agentID, out existingClient))
935 {
936 // Create the LLUDPClient
937 LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO);
938 // Create the LLClientView
939 LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
940 client.OnLogout += LogoutHandler;
937 941
938 // Start the IClientAPI 942 client.DisableFacelights = m_disableFacelights;
939 client.Start(); 943
940 } 944 // Start the IClientAPI
941 else 945 client.Start();
942 { 946
943 m_log.WarnFormat("[LLUDPSERVER]: Ignoring a repeated UseCircuitCode from {0} at {1} for circuit {2}", 947 }
944 udpClient.AgentID, remoteEndPoint, circuitCode); 948 else
949 {
950 m_log.WarnFormat("[LLUDPSERVER]: Ignoring a repeated UseCircuitCode from {0} at {1} for circuit {2}",
951 existingClient.AgentId, remoteEndPoint, circuitCode);
952 }
945 } 953 }
946 } 954 }
947 955
@@ -1052,6 +1060,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1052 1060
1053 #endregion Update Timers 1061 #endregion Update Timers
1054 1062
1063 // Use this for emergency monitoring -- bug hunting
1064 //if (m_scene.EmergencyMonitoring)
1065 // clientPacketHandler = MonitoredClientOutgoingPacketHandler;
1066 //else
1067 // clientPacketHandler = ClientOutgoingPacketHandler;
1068
1055 // Handle outgoing packets, resends, acknowledgements, and pings for each 1069 // Handle outgoing packets, resends, acknowledgements, and pings for each
1056 // client. m_packetSent will be set to true if a packet is sent 1070 // client. m_packetSent will be set to true if a packet is sent
1057 m_scene.ForEachClient(clientPacketHandler); 1071 m_scene.ForEachClient(clientPacketHandler);
@@ -1067,6 +1081,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1067 { 1081 {
1068 m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler loop threw an exception: " + ex.Message, ex); 1082 m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler loop threw an exception: " + ex.Message, ex);
1069 } 1083 }
1084
1070 } 1085 }
1071 1086
1072 Watchdog.RemoveThread(); 1087 Watchdog.RemoveThread();
@@ -1104,6 +1119,112 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1104 } 1119 }
1105 } 1120 }
1106 1121
1122 #region Emergency Monitoring
1123 // Alternative packet handler fuull of instrumentation
1124 // Handy for hunting bugs
1125 private Stopwatch watch1 = new Stopwatch();
1126 private Stopwatch watch2 = new Stopwatch();
1127
1128 private float avgProcessingTicks = 0;
1129 private float avgResendUnackedTicks = 0;
1130 private float avgSendAcksTicks = 0;
1131 private float avgSendPingTicks = 0;
1132 private float avgDequeueTicks = 0;
1133 private long nticks = 0;
1134 private long nticksUnack = 0;
1135 private long nticksAck = 0;
1136 private long nticksPing = 0;
1137 private int npacksSent = 0;
1138 private int npackNotSent = 0;
1139
1140 private void MonitoredClientOutgoingPacketHandler(IClientAPI client)
1141 {
1142 nticks++;
1143 watch1.Start();
1144 try
1145 {
1146 if (client is LLClientView)
1147 {
1148 LLUDPClient udpClient = ((LLClientView)client).UDPClient;
1149
1150 if (udpClient.IsConnected)
1151 {
1152 if (m_resendUnacked)
1153 {
1154 nticksUnack++;
1155 watch2.Start();
1156
1157 ResendUnacked(udpClient);
1158
1159 watch2.Stop();
1160 avgResendUnackedTicks = (nticksUnack - 1)/(float)nticksUnack * avgResendUnackedTicks + (watch2.ElapsedTicks / (float)nticksUnack);
1161 watch2.Reset();
1162 }
1163
1164 if (m_sendAcks)
1165 {
1166 nticksAck++;
1167 watch2.Start();
1168
1169 SendAcks(udpClient);
1170
1171 watch2.Stop();
1172 avgSendAcksTicks = (nticksAck - 1) / (float)nticksAck * avgSendAcksTicks + (watch2.ElapsedTicks / (float)nticksAck);
1173 watch2.Reset();
1174 }
1175
1176 if (m_sendPing)
1177 {
1178 nticksPing++;
1179 watch2.Start();
1180
1181 SendPing(udpClient);
1182
1183 watch2.Stop();
1184 avgSendPingTicks = (nticksPing - 1) / (float)nticksPing * avgSendPingTicks + (watch2.ElapsedTicks / (float)nticksPing);
1185 watch2.Reset();
1186 }
1187
1188 watch2.Start();
1189 // Dequeue any outgoing packets that are within the throttle limits
1190 if (udpClient.DequeueOutgoing())
1191 {
1192 m_packetSent = true;
1193 npacksSent++;
1194 }
1195 else
1196 npackNotSent++;
1197
1198 watch2.Stop();
1199 avgDequeueTicks = (nticks - 1) / (float)nticks * avgDequeueTicks + (watch2.ElapsedTicks / (float)nticks);
1200 watch2.Reset();
1201
1202 }
1203 else
1204 m_log.WarnFormat("[LLUDPSERVER]: Client is not connected");
1205 }
1206 }
1207 catch (Exception ex)
1208 {
1209 m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler iteration for " + client.Name +
1210 " threw an exception: " + ex.Message, ex);
1211 }
1212 watch1.Stop();
1213 avgProcessingTicks = (nticks - 1) / (float)nticks * avgProcessingTicks + (watch1.ElapsedTicks / (float)nticks);
1214 watch1.Reset();
1215
1216 // reuse this -- it's every ~100ms
1217 if (m_scene.EmergencyMonitoring && nticks % 100 == 0)
1218 {
1219 m_log.InfoFormat("[LLUDPSERVER]: avg processing ticks: {0} avg unacked: {1} avg acks: {2} avg ping: {3} avg dequeue: {4} (TickCountRes: {5} sent: {6} notsent: {7})",
1220 avgProcessingTicks, avgResendUnackedTicks, avgSendAcksTicks, avgSendPingTicks, avgDequeueTicks, TickCountResolution, npacksSent, npackNotSent);
1221 npackNotSent = npacksSent = 0;
1222 }
1223
1224 }
1225
1226 #endregion
1227
1107 private void ProcessInPacket(object state) 1228 private void ProcessInPacket(object state)
1108 { 1229 {
1109 IncomingPacket incomingPacket = (IncomingPacket)state; 1230 IncomingPacket incomingPacket = (IncomingPacket)state;
diff --git a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
index 9d40688..d195110 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
@@ -143,7 +143,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
143 // Process all the pending adds 143 // Process all the pending adds
144 OutgoingPacket pendingAdd; 144 OutgoingPacket pendingAdd;
145 while (m_pendingAdds.TryDequeue(out pendingAdd)) 145 while (m_pendingAdds.TryDequeue(out pendingAdd))
146 m_packets[pendingAdd.SequenceNumber] = pendingAdd; 146 if (pendingAdd != null)
147 m_packets[pendingAdd.SequenceNumber] = pendingAdd;
147 148
148 // Process all the pending removes, including updating statistics and round-trip times 149 // Process all the pending removes, including updating statistics and round-trip times
149 PendingAck pendingRemove; 150 PendingAck pendingRemove;
@@ -152,17 +153,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
152 { 153 {
153 if (m_packets.TryGetValue(pendingRemove.SequenceNumber, out ackedPacket)) 154 if (m_packets.TryGetValue(pendingRemove.SequenceNumber, out ackedPacket))
154 { 155 {
155 m_packets.Remove(pendingRemove.SequenceNumber); 156 if (ackedPacket != null)
156
157 // Update stats
158 Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength);
159
160 if (!pendingRemove.FromResend)
161 { 157 {
162 // Calculate the round-trip time for this packet and its ACK 158 m_packets.Remove(pendingRemove.SequenceNumber);
163 int rtt = pendingRemove.RemoveTime - ackedPacket.TickCount; 159
164 if (rtt > 0) 160 // Update stats
165 ackedPacket.Client.UpdateRoundTrip(rtt); 161 Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength);
162
163 if (!pendingRemove.FromResend)
164 {
165 // Calculate the round-trip time for this packet and its ACK
166 int rtt = pendingRemove.RemoveTime - ackedPacket.TickCount;
167 if (rtt > 0)
168 ackedPacket.Client.UpdateRoundTrip(rtt);
169 }
166 } 170 }
167 } 171 }
168 } 172 }
diff --git a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
index 5c5cb70..7526bd2 100644
--- a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
@@ -26,12 +26,14 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.Reflection; 31using System.Reflection;
31using log4net; 32using log4net;
32using Nini.Config; 33using Nini.Config;
33using OpenMetaverse; 34using OpenMetaverse;
34using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Console;
35using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
37using Caps=OpenSim.Framework.Capabilities.Caps; 39using Caps=OpenSim.Framework.Capabilities.Caps;
@@ -61,6 +63,9 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
61 { 63 {
62 m_scene = scene; 64 m_scene = scene;
63 m_scene.RegisterModuleInterface<ICapabilitiesModule>(this); 65 m_scene.RegisterModuleInterface<ICapabilitiesModule>(this);
66 MainConsole.Instance.Commands.AddCommand("Capabilities", false, "show caps",
67 "show capabilities",
68 "Shows all registered capabilities", CapabilitiesCommand);
64 } 69 }
65 70
66 public void RegionLoaded(Scene scene) 71 public void RegionLoaded(Scene scene)
@@ -72,7 +77,9 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
72 m_scene.UnregisterModuleInterface<ICapabilitiesModule>(this); 77 m_scene.UnregisterModuleInterface<ICapabilitiesModule>(this);
73 } 78 }
74 79
75 public void PostInitialise() {} 80 public void PostInitialise()
81 {
82 }
76 83
77 public void Close() {} 84 public void Close() {}
78 85
@@ -227,5 +234,23 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
227 m_log.Info(" >> "+x+", "+y+": "+kvp.Value); 234 m_log.Info(" >> "+x+", "+y+": "+kvp.Value);
228 } 235 }
229 } 236 }
237
238 private void CapabilitiesCommand(string module, string[] cmdparams)
239 {
240 System.Text.StringBuilder caps = new System.Text.StringBuilder();
241 caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName);
242
243 foreach (KeyValuePair<UUID, Caps> kvp in m_capsHandlers)
244 {
245 caps.AppendFormat("** User {0}:\n", kvp.Key);
246 for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.CapsDetails.GetEnumerator(); kvp2.MoveNext(); )
247 {
248 Uri uri = new Uri(kvp2.Value.ToString());
249 caps.AppendFormat(" {0} = {1}\n", kvp2.Key, uri.PathAndQuery);
250 }
251 }
252
253 MainConsole.Instance.Output(caps.ToString());
254 }
230 } 255 }
231} 256}
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index e542d7d..7cba702 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -92,9 +92,9 @@ namespace Flotsam.RegionModules.AssetCache
92 // Expiration is expressed in hours. 92 // Expiration is expressed in hours.
93 private const double m_DefaultMemoryExpiration = 1.0; 93 private const double m_DefaultMemoryExpiration = 1.0;
94 private const double m_DefaultFileExpiration = 48; 94 private const double m_DefaultFileExpiration = 48;
95 private TimeSpan m_MemoryExpiration = TimeSpan.Zero; 95 private TimeSpan m_MemoryExpiration = TimeSpan.FromHours(m_DefaultMemoryExpiration);
96 private TimeSpan m_FileExpiration = TimeSpan.Zero; 96 private TimeSpan m_FileExpiration = TimeSpan.FromHours(m_DefaultFileExpiration);
97 private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.Zero; 97 private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.FromHours(m_DefaultFileExpiration);
98 98
99 private static int m_CacheDirectoryTiers = 1; 99 private static int m_CacheDirectoryTiers = 1;
100 private static int m_CacheDirectoryTierLen = 3; 100 private static int m_CacheDirectoryTierLen = 3;
@@ -147,7 +147,7 @@ namespace Flotsam.RegionModules.AssetCache
147 } 147 }
148 148
149 m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory); 149 m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory);
150 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_DefaultCacheDirectory); 150 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_CacheDirectory);
151 151
152 m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false); 152 m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false);
153 m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration)); 153 m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration));
@@ -245,16 +245,7 @@ namespace Flotsam.RegionModules.AssetCache
245 private void UpdateMemoryCache(string key, AssetBase asset) 245 private void UpdateMemoryCache(string key, AssetBase asset)
246 { 246 {
247 if (m_MemoryCacheEnabled) 247 if (m_MemoryCacheEnabled)
248 { 248 m_MemoryCache.AddOrUpdate(key, asset, m_MemoryExpiration);
249 if (m_MemoryExpiration > TimeSpan.Zero)
250 {
251 m_MemoryCache.AddOrUpdate(key, asset, m_MemoryExpiration);
252 }
253 else
254 {
255 m_MemoryCache.AddOrUpdate(key, asset, Double.MaxValue);
256 }
257 }
258 } 249 }
259 250
260 public void Cache(AssetBase asset) 251 public void Cache(AssetBase asset)
@@ -459,7 +450,7 @@ namespace Flotsam.RegionModules.AssetCache
459 private void CleanupExpiredFiles(object source, ElapsedEventArgs e) 450 private void CleanupExpiredFiles(object source, ElapsedEventArgs e)
460 { 451 {
461 if (m_LogLevel >= 2) 452 if (m_LogLevel >= 2)
462 m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Checking for expired files older then {0}.", m_FileExpiration.ToString()); 453 m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Checking for expired files older then {0}.", m_FileExpiration);
463 454
464 // Purge all files last accessed prior to this point 455 // Purge all files last accessed prior to this point
465 DateTime purgeLine = DateTime.Now - m_FileExpiration; 456 DateTime purgeLine = DateTime.Now - m_FileExpiration;
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
index 6fb8b46..df4d561 100644
--- a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
@@ -245,14 +245,12 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
245 WriteTextureData(httpRequest, httpResponse, texture, format); 245 WriteTextureData(httpRequest, httpResponse, texture, format);
246 return true; 246 return true;
247 } 247 }
248
249 } 248 }
250 249
251 // not found 250 // not found
252 m_log.Warn("[GETTEXTURE]: Texture " + textureID + " not found"); 251// m_log.Warn("[GETTEXTURE]: Texture " + textureID + " not found");
253 httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound; 252 httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
254 return true; 253 return true;
255
256 } 254 }
257 255
258 private void WriteTextureData(OSHttpRequest request, OSHttpResponse response, AssetBase texture, string format) 256 private void WriteTextureData(OSHttpRequest request, OSHttpResponse response, AssetBase texture, string format)
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 8c92588..dc33dbb 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -119,6 +119,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
119 return; 119 return;
120 } 120 }
121 121
122 if (part.OwnerID != remoteClient.AgentId) // Not ours
123 {
124 remoteClient.SendAgentAlertMessage(
125 "You don't have sufficient permissions to attach this object", false);
126 return;
127 }
128
122 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should 129 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
123 // be removed when that functionality is implemented in opensim 130 // be removed when that functionality is implemented in opensim
124 AttachmentPt &= 0x7f; 131 AttachmentPt &= 0x7f;
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index f8ce444..08ac624 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -167,7 +167,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
167 } 167 }
168 } 168 }
169 169
170 m_log.InfoFormat("[AVFACTORY]: complete texture check for {0}", client.AgentId); 170 m_log.DebugFormat("[AVFACTORY]: complete texture check for {0}", client.AgentId);
171 171
172 // If we only found default textures, then the appearance is not cached 172 // If we only found default textures, then the appearance is not cached
173 return (defonly ? false : true); 173 return (defonly ? false : true);
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index a514a83..ded8743 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -49,16 +49,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
49 { 49 {
50 m_scene = scene; 50 m_scene = scene;
51 m_scene.RegisterModuleInterface<IDialogModule>(this); 51 m_scene.RegisterModuleInterface<IDialogModule>(this);
52 52
53 m_scene.AddCommand( 53 m_scene.AddCommand(
54 this, "alert", "alert <first> <last> <message>", 54 this, "alert", "alert <message>",
55 "Send an alert to a user", 55 "Send an alert to everyone",
56 HandleAlertConsoleCommand); 56 HandleAlertConsoleCommand);
57 57
58 m_scene.AddCommand( 58 m_scene.AddCommand(
59 this, "alert general", "alert [general] <message>", 59 this, "alert-user", "alert-user <first> <last> <message>",
60 "Send an alert to everyone", 60 "Send an alert to a user",
61 "If keyword 'general' is omitted, then <message> must be surrounded by quotation marks.",
62 HandleAlertConsoleCommand); 61 HandleAlertConsoleCommand);
63 } 62 }
64 63
@@ -177,55 +176,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
177 { 176 {
178 if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) 177 if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene)
179 return; 178 return;
180 179
181 bool isGeneral = false;
182 string firstName = string.Empty;
183 string lastName = string.Empty;
184 string message = string.Empty; 180 string message = string.Empty;
185 181
186 if (cmdparams.Length > 1) 182 if (cmdparams[0].ToLower().Equals("alert"))
187 {
188 firstName = cmdparams[1];
189 isGeneral = firstName.ToLower().Equals("general");
190 }
191 if (cmdparams.Length == 2 && !isGeneral)
192 { 183 {
193 // alert "message" 184 message = CombineParams(cmdparams, 1);
194 message = cmdparams[1]; 185 m_log.InfoFormat("[DIALOG]: Sending general alert in region {0} with message {1}",
195 isGeneral = true; 186 m_scene.RegionInfo.RegionName, message);
196 } 187 SendGeneralAlert(message);
197 else if (cmdparams.Length > 2 && isGeneral)
198 {
199 // alert general <message>
200 message = CombineParams(cmdparams, 2);
201 } 188 }
202 else if (cmdparams.Length > 3) 189 else if (cmdparams.Length > 3)
203 { 190 {
204 // alert <first> <last> <message> 191 string firstName = cmdparams[1];
205 lastName = cmdparams[2]; 192 string lastName = cmdparams[2];
206 message = CombineParams(cmdparams, 3); 193 message = CombineParams(cmdparams, 3);
194 m_log.InfoFormat(
195 "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}",
196 m_scene.RegionInfo.RegionName, firstName, lastName, message);
197 SendAlertToUser(firstName, lastName, message, false);
207 } 198 }
208 else 199 else
209 { 200 {
210 OpenSim.Framework.Console.MainConsole.Instance.Output( 201 OpenSim.Framework.Console.MainConsole.Instance.Output(
211 "Usage: alert \"message\" | alert general <message> | alert <first> <last> <message>"); 202 "Usage: alert <message> | alert-user <first> <last> <message>");
212 return; 203 return;
213 } 204 }
214
215 if (isGeneral)
216 {
217 m_log.InfoFormat(
218 "[DIALOG]: Sending general alert in region {0} with message {1}",
219 m_scene.RegionInfo.RegionName, message);
220 SendGeneralAlert(message);
221 }
222 else
223 {
224 m_log.InfoFormat(
225 "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}",
226 m_scene.RegionInfo.RegionName, firstName, lastName, message);
227 SendAlertToUser(firstName, lastName, message, false);
228 }
229 } 205 }
230 206
231 private string CombineParams(string[] commandParams, int pos) 207 private string CombineParams(string[] commandParams, int pos)
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index dd9819a..a81ec7c 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -449,24 +449,37 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
449 return resp; 449 return resp;
450 } 450 }
451 451
452 /// <summary> 452 private delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result);
453 /// delegate for sending a grid instant message asynchronously
454 /// </summary>
455 public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID);
456 453
457 protected virtual void GridInstantMessageCompleted(IAsyncResult iar) 454 private class GIM {
458 { 455 public GridInstantMessage im;
459 GridInstantMessageDelegate icon = 456 public MessageResultNotification result;
460 (GridInstantMessageDelegate)iar.AsyncState; 457 };
461 icon.EndInvoke(iar);
462 }
463 458
459 private Queue<GIM> pendingInstantMessages = new Queue<GIM>();
460 private int numInstantMessageThreads = 0;
464 461
465 protected virtual void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result) 462 private void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result)
466 { 463 {
467 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; 464 lock (pendingInstantMessages) {
465 if (numInstantMessageThreads >= 4) {
466 GIM gim = new GIM();
467 gim.im = im;
468 gim.result = result;
469 pendingInstantMessages.Enqueue(gim);
470 } else {
471 ++ numInstantMessageThreads;
472 m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: ++numInstantMessageThreads={0}", numInstantMessageThreads);
473 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsyncMain;
474 d.BeginInvoke(im, result, GridInstantMessageCompleted, d);
475 }
476 }
477 }
468 478
469 d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); 479 private void GridInstantMessageCompleted(IAsyncResult iar)
480 {
481 GridInstantMessageDelegate d = (GridInstantMessageDelegate)iar.AsyncState;
482 d.EndInvoke(iar);
470 } 483 }
471 484
472 /// <summary> 485 /// <summary>
@@ -481,8 +494,31 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
481 /// Pass in 0 the first time this method is called. It will be called recursively with the last 494 /// Pass in 0 the first time this method is called. It will be called recursively with the last
482 /// regionhandle tried 495 /// regionhandle tried
483 /// </param> 496 /// </param>
484 protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) 497 private void SendGridInstantMessageViaXMLRPCAsyncMain(GridInstantMessage im, MessageResultNotification result)
485 { 498 {
499 GIM gim;
500 do {
501 try {
502 SendGridInstantMessageViaXMLRPCAsync(im, result, UUID.Zero);
503 } catch (Exception e) {
504 m_log.Error("[SendGridInstantMessageViaXMLRPC]: exception " + e.Message);
505 }
506 lock (pendingInstantMessages) {
507 if (pendingInstantMessages.Count > 0) {
508 gim = pendingInstantMessages.Dequeue();
509 im = gim.im;
510 result = gim.result;
511 } else {
512 gim = null;
513 -- numInstantMessageThreads;
514 m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: --numInstantMessageThreads={0}", numInstantMessageThreads);
515 }
516 }
517 } while (gim != null);
518 }
519 private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID)
520 {
521
486 UUID toAgentID = new UUID(im.toAgentID); 522 UUID toAgentID = new UUID(im.toAgentID);
487 523
488 PresenceInfo upd = null; 524 PresenceInfo upd = null;
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 6030706..9b98de3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -41,6 +41,7 @@ using OpenSim.Framework.Serialization;
41using OpenSim.Framework.Serialization.External; 41using OpenSim.Framework.Serialization.External;
42using OpenSim.Region.CoreModules.World.Archiver; 42using OpenSim.Region.CoreModules.World.Archiver;
43using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Region.Framework.Interfaces; 45using OpenSim.Region.Framework.Interfaces;
45using OpenSim.Services.Interfaces; 46using OpenSim.Services.Interfaces;
46 47
@@ -75,6 +76,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
75 /// The stream from which the inventory archive will be loaded. 76 /// The stream from which the inventory archive will be loaded.
76 /// </value> 77 /// </value>
77 private Stream m_loadStream; 78 private Stream m_loadStream;
79
80 protected bool m_controlFileLoaded;
81 protected bool m_assetsLoaded;
82 protected bool m_inventoryNodesLoaded;
83
84 protected int m_successfulAssetRestores;
85 protected int m_failedAssetRestores;
86 protected int m_successfulItemRestores;
87
88 /// <summary>
89 /// Root destination folder for the IAR load.
90 /// </summary>
91 protected InventoryFolderBase m_rootDestinationFolder;
92
93 /// <summary>
94 /// Inventory nodes loaded from the iar.
95 /// </summary>
96 protected HashSet<InventoryNodeBase> m_loadedNodes = new HashSet<InventoryNodeBase>();
97
98 /// <summary>
99 /// In order to load identically named folders, we need to keep track of the folders that we have already
100 /// resolved.
101 /// </summary>
102 Dictionary <string, InventoryFolderBase> m_resolvedFolders = new Dictionary<string, InventoryFolderBase>();
103
104 /// <summary>
105 /// Record the creator id that should be associated with an asset. This is used to adjust asset creator ids
106 /// after OSP resolution (since OSP creators are only stored in the item
107 /// </summary>
108 protected Dictionary<UUID, UUID> m_creatorIdForAssetId = new Dictionary<UUID, UUID>();
78 109
79 public InventoryArchiveReadRequest( 110 public InventoryArchiveReadRequest(
80 Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge) 111 Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge)
@@ -100,20 +131,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
100 /// <summary> 131 /// <summary>
101 /// Execute the request 132 /// Execute the request
102 /// </summary> 133 /// </summary>
134 /// <remarks>
135 /// Only call this once. To load another IAR, construct another request object.
136 /// </remarks>
103 /// <returns> 137 /// <returns>
104 /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are 138 /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are
105 /// returned 139 /// returned
106 /// </returns> 140 /// </returns>
141 /// <exception cref="System.Exception">Thrown if load fails.</exception>
107 public HashSet<InventoryNodeBase> Execute() 142 public HashSet<InventoryNodeBase> Execute()
108 { 143 {
109 try 144 try
110 { 145 {
111 string filePath = "ERROR"; 146 string filePath = "ERROR";
112 int successfulAssetRestores = 0;
113 int failedAssetRestores = 0;
114 int successfulItemRestores = 0;
115
116 HashSet<InventoryNodeBase> loadedNodes = new HashSet<InventoryNodeBase>();
117 147
118 List<InventoryFolderBase> folderCandidates 148 List<InventoryFolderBase> folderCandidates
119 = InventoryArchiveUtils.FindFolderByPath( 149 = InventoryArchiveUtils.FindFolderByPath(
@@ -124,16 +154,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
124 // Possibly provide an option later on to automatically create this folder if it does not exist 154 // Possibly provide an option later on to automatically create this folder if it does not exist
125 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath); 155 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath);
126 156
127 return loadedNodes; 157 return m_loadedNodes;
128 } 158 }
129 159
130 InventoryFolderBase rootDestinationFolder = folderCandidates[0]; 160 m_rootDestinationFolder = folderCandidates[0];
131 archive = new TarArchiveReader(m_loadStream); 161 archive = new TarArchiveReader(m_loadStream);
132
133 // In order to load identically named folders, we need to keep track of the folders that we have already
134 // resolved
135 Dictionary <string, InventoryFolderBase> resolvedFolders = new Dictionary<string, InventoryFolderBase>();
136
137 byte[] data; 162 byte[] data;
138 TarArchiveReader.TarEntryType entryType; 163 TarArchiveReader.TarEntryType entryType;
139 164
@@ -142,45 +167,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
142 if (filePath == ArchiveConstants.CONTROL_FILE_PATH) 167 if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
143 { 168 {
144 LoadControlFile(filePath, data); 169 LoadControlFile(filePath, data);
145 } 170 }
146 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) 171 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
147 { 172 {
148 if (LoadAsset(filePath, data)) 173 LoadAssetFile(filePath, data);
149 successfulAssetRestores++;
150 else
151 failedAssetRestores++;
152
153 if ((successfulAssetRestores) % 50 == 0)
154 m_log.DebugFormat(
155 "[INVENTORY ARCHIVER]: Loaded {0} assets...",
156 successfulAssetRestores);
157 } 174 }
158 else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) 175 else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH))
159 { 176 {
160 filePath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length); 177 LoadInventoryFile(filePath, entryType, data);
161
162 // Trim off the file portion if we aren't already dealing with a directory path
163 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
164 filePath = filePath.Remove(filePath.LastIndexOf("/") + 1);
165
166 InventoryFolderBase foundFolder
167 = ReplicateArchivePathToUserInventory(
168 filePath, rootDestinationFolder, resolvedFolders, loadedNodes);
169
170 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
171 {
172 InventoryItemBase item = LoadItem(data, foundFolder);
173
174 if (item != null)
175 {
176 successfulItemRestores++;
177
178 // If we aren't loading the folder containing the item then well need to update the
179 // viewer separately for that item.
180 if (!loadedNodes.Contains(foundFolder))
181 loadedNodes.Add(item);
182 }
183 }
184 } 178 }
185 } 179 }
186 180
@@ -188,10 +182,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
188 182
189 m_log.DebugFormat( 183 m_log.DebugFormat(
190 "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures", 184 "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures",
191 successfulAssetRestores, failedAssetRestores); 185 m_successfulAssetRestores, m_failedAssetRestores);
192 m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", successfulItemRestores); 186 m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", m_successfulItemRestores);
193 187
194 return loadedNodes; 188 return m_loadedNodes;
195 } 189 }
196 finally 190 finally
197 { 191 {
@@ -400,9 +394,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
400 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService); 394 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService);
401 if (UUID.Zero != ospResolvedId) // The user exists in this grid 395 if (UUID.Zero != ospResolvedId) // The user exists in this grid
402 { 396 {
397// m_log.DebugFormat("[INVENTORY ARCHIVER]: Found creator {0} via OSPA resolution", ospResolvedId);
398
403 item.CreatorIdAsUuid = ospResolvedId; 399 item.CreatorIdAsUuid = ospResolvedId;
404 400
405 // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the 401 // Don't preserve the OSPA in the creator id (which actually gets persisted to the
406 // database). Instead, replace with the UUID that we found. 402 // database). Instead, replace with the UUID that we found.
407 item.CreatorId = ospResolvedId.ToString(); 403 item.CreatorId = ospResolvedId.ToString();
408 404
@@ -410,7 +406,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
410 } 406 }
411 else if (item.CreatorData == null || item.CreatorData == String.Empty) 407 else if (item.CreatorData == null || item.CreatorData == String.Empty)
412 { 408 {
413 item.CreatorIdAsUuid = m_userInfo.PrincipalID; 409 item.CreatorId = m_userInfo.PrincipalID.ToString();
410 item.CreatorIdAsUuid = new UUID(item.CreatorId);
414 } 411 }
415 412
416 item.Owner = m_userInfo.PrincipalID; 413 item.Owner = m_userInfo.PrincipalID;
@@ -418,6 +415,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
418 // Reset folder ID to the one in which we want to load it 415 // Reset folder ID to the one in which we want to load it
419 item.Folder = loadFolder.ID; 416 item.Folder = loadFolder.ID;
420 417
418 // Record the creator id for the item's asset so that we can use it later, if necessary, when the asset
419 // is loaded.
420 // FIXME: This relies on the items coming before the assets in the TAR file. Need to create stronger
421 // checks for this, and maybe even an external tool for creating OARs which enforces this, rather than
422 // relying on native tar tools.
423 m_creatorIdForAssetId[item.AssetID] = item.CreatorIdAsUuid;
424
421 m_scene.AddInventoryItem(item); 425 m_scene.AddInventoryItem(item);
422 426
423 return item; 427 return item;
@@ -446,18 +450,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
446 } 450 }
447 451
448 string extension = filename.Substring(i); 452 string extension = filename.Substring(i);
449 string uuid = filename.Remove(filename.Length - extension.Length); 453 string rawUuid = filename.Remove(filename.Length - extension.Length);
454 UUID assetId = new UUID(rawUuid);
450 455
451 if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) 456 if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
452 { 457 {
453 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; 458 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
454 459
455 if (assetType == (sbyte)AssetType.Unknown) 460 if (assetType == (sbyte)AssetType.Unknown)
456 m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); 461 {
462 m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, assetId);
463 }
464 else if (assetType == (sbyte)AssetType.Object)
465 {
466 if (m_creatorIdForAssetId.ContainsKey(assetId))
467 {
468 string xmlData = Utils.BytesToString(data);
469 SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
470 foreach (SceneObjectPart sop in sog.Parts)
471 {
472 if (sop.CreatorData == null || sop.CreatorData == "")
473 {
474 sop.CreatorID = m_creatorIdForAssetId[assetId];
475 }
476 }
477
478 data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog));
479 }
480 }
457 481
458 //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); 482 //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
459 483
460 AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType, UUID.Zero.ToString()); 484 AssetBase asset = new AssetBase(assetId, "From IAR", assetType, UUID.Zero.ToString());
461 asset.Data = data; 485 asset.Data = data;
462 486
463 m_scene.AssetService.Store(asset); 487 m_scene.AssetService.Store(asset);
@@ -495,7 +519,88 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
495 majorVersion, MAX_MAJOR_VERSION)); 519 majorVersion, MAX_MAJOR_VERSION));
496 } 520 }
497 521
498 m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); 522 m_controlFileLoaded = true;
523 m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version);
499 } 524 }
525
526 /// <summary>
527 /// Load inventory file
528 /// </summary>
529 /// <param name="path"></param>
530 /// <param name="entryType"></param>
531 /// <param name="data"></param>
532 protected void LoadInventoryFile(string path, TarArchiveReader.TarEntryType entryType, byte[] data)
533 {
534 if (!m_controlFileLoaded)
535 throw new Exception(
536 string.Format(
537 "The IAR you are trying to load does not list {0} before {1}. Aborting load",
538 ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.INVENTORY_PATH));
539
540 if (m_assetsLoaded)
541 throw new Exception(
542 string.Format(
543 "The IAR you are trying to load does not list all {0} before {1}. Aborting load",
544 ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH));
545
546 path = path.Substring(ArchiveConstants.INVENTORY_PATH.Length);
547
548 // Trim off the file portion if we aren't already dealing with a directory path
549 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
550 path = path.Remove(path.LastIndexOf("/") + 1);
551
552 InventoryFolderBase foundFolder
553 = ReplicateArchivePathToUserInventory(
554 path, m_rootDestinationFolder, m_resolvedFolders, m_loadedNodes);
555
556 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
557 {
558 InventoryItemBase item = LoadItem(data, foundFolder);
559
560 if (item != null)
561 {
562 m_successfulItemRestores++;
563
564 // If we aren't loading the folder containing the item then well need to update the
565 // viewer separately for that item.
566 if (!m_loadedNodes.Contains(foundFolder))
567 m_loadedNodes.Add(item);
568 }
569 }
570
571 m_inventoryNodesLoaded = true;
572 }
573
574 /// <summary>
575 /// Load asset file
576 /// </summary>
577 /// <param name="path"></param>
578 /// <param name="data"></param>
579 protected void LoadAssetFile(string path, byte[] data)
580 {
581 if (!m_controlFileLoaded)
582 throw new Exception(
583 string.Format(
584 "The IAR you are trying to load does not list {0} before {1}. Aborting load",
585 ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.ASSETS_PATH));
586
587 if (!m_inventoryNodesLoaded)
588 throw new Exception(
589 string.Format(
590 "The IAR you are trying to load does not list all {0} before {1}. Aborting load",
591 ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH));
592
593 if (LoadAsset(path, data))
594 m_successfulAssetRestores++;
595 else
596 m_failedAssetRestores++;
597
598 if ((m_successfulAssetRestores) % 50 == 0)
599 m_log.DebugFormat(
600 "[INVENTORY ARCHIVER]: Loaded {0} assets...",
601 m_successfulAssetRestores);
602
603 m_assetsLoaded = true;
604 }
500 } 605 }
501} \ No newline at end of file 606} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index b1c2a3c..613f0ed 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -109,9 +109,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
109 109
110 scene.AddCommand( 110 scene.AddCommand(
111 this, "load iar", 111 this, "load iar",
112 "load iar [--merge] <first> <last> <inventory path> <password> [<IAR path>]", 112 "load iar [-m|--merge] <first> <last> <inventory path> <password> [<IAR path>]",
113 "Load user inventory archive (IAR).", 113 "Load user inventory archive (IAR).",
114 "--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones" 114 "-m|--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones"
115 + "<first> is user's first name." + Environment.NewLine 115 + "<first> is user's first name." + Environment.NewLine
116 + "<last> is user's last name." + Environment.NewLine 116 + "<last> is user's last name." + Environment.NewLine
117 + "<inventory path> is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine 117 + "<inventory path> is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine
@@ -128,6 +128,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
128 + "<last> is the user's last name." + Environment.NewLine 128 + "<last> is the user's last name." + Environment.NewLine
129 + "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine 129 + "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine
130 + "-p|--profile=<url> adds the url of the profile service to the saved user information." + Environment.NewLine 130 + "-p|--profile=<url> adds the url of the profile service to the saved user information." + Environment.NewLine
131 + "-c|--creators preserves information about foreign creators." + Environment.NewLine
132 + "-v|--verbose extra debug messages." + Environment.NewLine
131 + "<IAR path> is the filesystem path at which to save the IAR." 133 + "<IAR path> is the filesystem path at which to save the IAR."
132 + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), 134 + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME),
133 HandleSaveInvConsoleCommand); 135 HandleSaveInvConsoleCommand);
@@ -179,7 +181,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
179 catch (EntryPointNotFoundException e) 181 catch (EntryPointNotFoundException e)
180 { 182 {
181 m_log.ErrorFormat( 183 m_log.ErrorFormat(
182 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." 184 "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
183 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 185 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
184 m_log.Error(e); 186 m_log.Error(e);
185 187
@@ -219,7 +221,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
219 catch (EntryPointNotFoundException e) 221 catch (EntryPointNotFoundException e)
220 { 222 {
221 m_log.ErrorFormat( 223 m_log.ErrorFormat(
222 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." 224 "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
223 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 225 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
224 m_log.Error(e); 226 m_log.Error(e);
225 227
@@ -267,7 +269,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
267 catch (EntryPointNotFoundException e) 269 catch (EntryPointNotFoundException e)
268 { 270 {
269 m_log.ErrorFormat( 271 m_log.ErrorFormat(
270 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." 272 "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
271 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 273 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
272 m_log.Error(e); 274 m_log.Error(e);
273 275
@@ -315,7 +317,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
315 catch (EntryPointNotFoundException e) 317 catch (EntryPointNotFoundException e)
316 { 318 {
317 m_log.ErrorFormat( 319 m_log.ErrorFormat(
318 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." 320 "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
319 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 321 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
320 m_log.Error(e); 322 m_log.Error(e);
321 323
@@ -356,7 +358,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
356 if (mainParams.Count < 6) 358 if (mainParams.Count < 6)
357 { 359 {
358 m_log.Error( 360 m_log.Error(
359 "[INVENTORY ARCHIVER]: usage is load iar [--merge] <first name> <last name> <inventory path> <user password> [<load file path>]"); 361 "[INVENTORY ARCHIVER]: usage is load iar [-m|--merge] <first name> <last name> <inventory path> <user password> [<load file path>]");
360 return; 362 return;
361 } 363 }
362 364
@@ -394,6 +396,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
394 OptionSet ops = new OptionSet(); 396 OptionSet ops = new OptionSet();
395 //ops.Add("v|version=", delegate(string v) { options["version"] = v; }); 397 //ops.Add("v|version=", delegate(string v) { options["version"] = v; });
396 ops.Add("p|profile=", delegate(string v) { options["profile"] = v; }); 398 ops.Add("p|profile=", delegate(string v) { options["profile"] = v; });
399 ops.Add("v|verbose", delegate(string v) { options["verbose"] = v; });
400 ops.Add("c|creators", delegate(string v) { options["creators"] = v; });
397 401
398 List<string> mainParams = ops.Parse(cmdparams); 402 List<string> mainParams = ops.Parse(cmdparams);
399 403
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
new file mode 100644
index 0000000..e5127a0
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
@@ -0,0 +1,155 @@
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 System.IO;
31using System.Reflection;
32using System.Threading;
33using NUnit.Framework;
34using OpenMetaverse;
35using OpenSim.Data;
36using OpenSim.Framework;
37using OpenSim.Framework.Serialization;
38using OpenSim.Framework.Serialization.External;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
41using OpenSim.Region.CoreModules.World.Serialiser;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Services.Interfaces;
45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock;
47using OpenSim.Tests.Common.Setup;
48
49namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
50{
51 [TestFixture]
52 public class InventoryArchiveTestCase
53 {
54 protected ManualResetEvent mre = new ManualResetEvent(false);
55
56 /// <summary>
57 /// A raw array of bytes that we'll use to create an IAR memory stream suitable for isolated use in each test.
58 /// </summary>
59 protected byte[] m_iarStreamBytes;
60
61 /// <summary>
62 /// Stream of data representing a common IAR for load tests.
63 /// </summary>
64 protected MemoryStream m_iarStream;
65
66 protected UserAccount m_uaMT
67 = new UserAccount {
68 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"),
69 FirstName = "Mr",
70 LastName = "Tiddles" };
71 protected UserAccount m_uaLL1
72 = new UserAccount {
73 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"),
74 FirstName = "Lord",
75 LastName = "Lucan" };
76 protected UserAccount m_uaLL2
77 = new UserAccount {
78 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000777"),
79 FirstName = "Lord",
80 LastName = "Lucan" };
81 protected string m_item1Name = "Ray Gun Item";
82
83 [SetUp]
84 public virtual void SetUp()
85 {
86 m_iarStream = new MemoryStream(m_iarStreamBytes);
87 }
88
89 [TestFixtureSetUp]
90 public void FixtureSetup()
91 {
92 ConstructDefaultIarBytesForTestLoad();
93 }
94
95 protected void ConstructDefaultIarBytesForTestLoad()
96 {
97// log4net.Config.XmlConfigurator.Configure();
98
99 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
100 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
101 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
102
103 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire");
104
105 MemoryStream archiveWriteStream = new MemoryStream();
106
107 // Create asset
108 SceneObjectGroup object1;
109 SceneObjectPart part1;
110 {
111 string partName = "Ray Gun Object";
112 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
113 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
114 Vector3 groupPosition = new Vector3(10, 20, 30);
115 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
116 Vector3 offsetPosition = new Vector3(5, 10, 15);
117
118 part1
119 = new SceneObjectPart(
120 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
121 part1.Name = partName;
122
123 object1 = new SceneObjectGroup(part1);
124 scene.AddNewSceneObject(object1, false);
125 }
126
127 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
128 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
129 scene.AssetService.Store(asset1);
130
131 // Create item
132 InventoryItemBase item1 = new InventoryItemBase();
133 item1.Name = m_item1Name;
134 item1.ID = UUID.Parse("00000000-0000-0000-0000-000000000020");
135 item1.AssetID = asset1.FullID;
136 item1.GroupID = UUID.Random();
137 item1.CreatorIdAsUuid = m_uaLL1.PrincipalID;
138 item1.Owner = m_uaLL1.PrincipalID;
139 item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID;
140 scene.AddInventoryItem(item1);
141
142 archiverModule.ArchiveInventory(
143 Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, m_item1Name, "hampshire", archiveWriteStream);
144
145 m_iarStreamBytes = archiveWriteStream.ToArray();
146 }
147
148 protected void SaveCompleted(
149 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
150 Exception reportedException)
151 {
152 mre.Set();
153 }
154 }
155} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 76d0b85..7f156f8 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -31,7 +31,6 @@ using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Threading; 32using System.Threading;
33using NUnit.Framework; 33using NUnit.Framework;
34using NUnit.Framework.SyntaxHelpers;
35using OpenMetaverse; 34using OpenMetaverse;
36using OpenSim.Data; 35using OpenSim.Data;
37using OpenSim.Framework; 36using OpenSim.Framework;
@@ -50,182 +49,21 @@ using OpenSim.Tests.Common.Setup;
50namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests 49namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
51{ 50{
52 [TestFixture] 51 [TestFixture]
53 public class InventoryArchiverTests 52 public class InventoryArchiverTests : InventoryArchiveTestCase
54 { 53 {
55 protected ManualResetEvent mre = new ManualResetEvent(false); 54 protected TestScene m_scene;
56 55 protected InventoryArchiverModule m_archiverModule;
57 /// <summary> 56
58 /// Stream of data representing a common IAR that can be reused in load tests.
59 /// </summary>
60 protected MemoryStream m_iarStream;
61
62 protected UserAccount m_ua1
63 = new UserAccount {
64 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"),
65 FirstName = "Mr",
66 LastName = "Tiddles" };
67 protected UserAccount m_ua2
68 = new UserAccount {
69 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"),
70 FirstName = "Lord",
71 LastName = "Lucan" };
72 string m_item1Name = "b.lsl";
73
74 private void SaveCompleted(
75 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
76 Exception reportedException)
77 {
78 mre.Set();
79 }
80
81 [SetUp] 57 [SetUp]
82 public void Init() 58 public override void SetUp()
83 {
84 ConstructDefaultIarForTestLoad();
85 }
86
87 protected void ConstructDefaultIarForTestLoad()
88 {
89 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(m_item1Name, UUID.Random());
90
91 MemoryStream archiveWriteStream = new MemoryStream();
92 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
93
94 InventoryItemBase item1 = new InventoryItemBase();
95 item1.Name = m_item1Name;
96 item1.AssetID = UUID.Random();
97 item1.GroupID = UUID.Random();
98 //item1.CreatorId = OspResolver.MakeOspa(m_ua2.FirstName, m_ua2.LastName);
99 //item1.CreatorId = userUuid.ToString();
100 item1.CreatorId = m_ua2.PrincipalID.ToString();
101 item1.Owner = UUID.Zero;
102
103 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
104 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire");
105
106 string item1FileName
107 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
108 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string, object>(), scene.UserAccountService));
109 tar.Close();
110 m_iarStream = new MemoryStream(archiveWriteStream.ToArray());
111 }
112
113 /// <summary>
114 /// Test saving an inventory path to a V0.1 OpenSim Inventory Archive
115 /// (subject to change since there is no fixed format yet).
116 /// </summary>
117 [Test]
118 public void TestSavePathToIarV0_1()
119 { 59 {
120 TestHelper.InMethod(); 60 base.SetUp();
121// log4net.Config.XmlConfigurator.Configure();
122
123 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
124
125 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
126 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
127
128 // Create user
129 string userFirstName = "Jock";
130 string userLastName = "Stirrup";
131 string userPassword = "troll";
132 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
133 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword);
134 61
135 // Create asset 62 SerialiserModule serialiserModule = new SerialiserModule();
136 SceneObjectGroup object1; 63 m_archiverModule = new InventoryArchiverModule();
137 SceneObjectPart part1;
138 {
139 string partName = "My Little Dog Object";
140 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
141 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
142 Vector3 groupPosition = new Vector3(10, 20, 30);
143 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
144 Vector3 offsetPosition = new Vector3(5, 10, 15);
145
146 part1
147 = new SceneObjectPart(
148 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
149 part1.Name = partName;
150
151 object1 = new SceneObjectGroup(part1);
152 scene.AddNewSceneObject(object1, false);
153 }
154
155 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
156 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
157 scene.AssetService.Store(asset1);
158
159 // Create item
160 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
161 InventoryItemBase item1 = new InventoryItemBase();
162 item1.Name = "My Little Dog";
163 item1.AssetID = asset1.FullID;
164 item1.ID = item1Id;
165 InventoryFolderBase objsFolder
166 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
167 item1.Folder = objsFolder.ID;
168 scene.AddInventoryItem(item1);
169
170 MemoryStream archiveWriteStream = new MemoryStream();
171 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
172
173 // Test saving a particular path
174 mre.Reset();
175 archiverModule.ArchiveInventory(
176 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
177 mre.WaitOne(60000, false);
178
179 byte[] archive = archiveWriteStream.ToArray();
180 MemoryStream archiveReadStream = new MemoryStream(archive);
181 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
182
183 //bool gotControlFile = false;
184 bool gotObject1File = false;
185 //bool gotObject2File = false;
186 string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
187 string expectedObject1FilePath = string.Format(
188 "{0}{1}{2}",
189 ArchiveConstants.INVENTORY_PATH,
190 InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder),
191 expectedObject1FileName);
192
193 string filePath;
194 TarArchiveReader.TarEntryType tarEntryType;
195
196// Console.WriteLine("Reading archive");
197
198 while (tar.ReadEntry(out filePath, out tarEntryType) != null)
199 {
200// Console.WriteLine("Got {0}", filePath);
201
202// if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
203// {
204// gotControlFile = true;
205// }
206
207 if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
208 {
209// string fileName = filePath.Remove(0, "Objects/".Length);
210//
211// if (fileName.StartsWith(part1.Name))
212// {
213 Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
214 gotObject1File = true;
215// }
216// else if (fileName.StartsWith(part2.Name))
217// {
218// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
219// gotObject2File = true;
220// }
221 }
222 }
223
224// Assert.That(gotControlFile, Is.True, "No control file in archive");
225 Assert.That(gotObject1File, Is.True, "No item1 file in archive");
226// Assert.That(gotObject2File, Is.True, "No object2 file in archive");
227 64
228 // TODO: Test presence of more files and contents of files. 65 m_scene = SceneSetupHelpers.SetupScene("Inventory");
66 SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule);
229 } 67 }
230 68
231 /// <summary> 69 /// <summary>
@@ -238,17 +76,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
238 TestHelper.InMethod(); 76 TestHelper.InMethod();
239// log4net.Config.XmlConfigurator.Configure(); 77// log4net.Config.XmlConfigurator.Configure();
240 78
241 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
242
243 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
244 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
245
246 // Create user 79 // Create user
247 string userFirstName = "Jock"; 80 string userFirstName = "Jock";
248 string userLastName = "Stirrup"; 81 string userLastName = "Stirrup";
249 string userPassword = "troll"; 82 string userPassword = "troll";
250 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); 83 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
251 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); 84 UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword);
252 85
253 // Create asset 86 // Create asset
254 SceneObjectGroup object1; 87 SceneObjectGroup object1;
@@ -267,12 +100,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
267 part1.Name = partName; 100 part1.Name = partName;
268 101
269 object1 = new SceneObjectGroup(part1); 102 object1 = new SceneObjectGroup(part1);
270 scene.AddNewSceneObject(object1, false); 103 m_scene.AddNewSceneObject(object1, false);
271 } 104 }
272 105
273 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); 106 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
274 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); 107 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
275 scene.AssetService.Store(asset1); 108 m_scene.AssetService.Store(asset1);
276 109
277 // Create item 110 // Create item
278 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); 111 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
@@ -282,15 +115,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
282 item1.AssetID = asset1.FullID; 115 item1.AssetID = asset1.FullID;
283 item1.ID = item1Id; 116 item1.ID = item1Id;
284 InventoryFolderBase objsFolder 117 InventoryFolderBase objsFolder
285 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; 118 = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, userId, "Objects")[0];
286 item1.Folder = objsFolder.ID; 119 item1.Folder = objsFolder.ID;
287 scene.AddInventoryItem(item1); 120 m_scene.AddInventoryItem(item1);
288 121
289 MemoryStream archiveWriteStream = new MemoryStream(); 122 MemoryStream archiveWriteStream = new MemoryStream();
290 archiverModule.OnInventoryArchiveSaved += SaveCompleted; 123 m_archiverModule.OnInventoryArchiveSaved += SaveCompleted;
291 124
292 mre.Reset(); 125 mre.Reset();
293 archiverModule.ArchiveInventory( 126 m_archiverModule.ArchiveInventory(
294 Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream); 127 Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream);
295 mre.WaitOne(60000, false); 128 mre.WaitOne(60000, false);
296 129
@@ -346,474 +179,99 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
346 } 179 }
347 180
348 /// <summary> 181 /// <summary>
349 /// Test that things work when the load path specified starts with a slash 182 /// Test case where a creator account exists for the creator UUID embedded in item metadata and serialized
350 /// </summary> 183 /// objects.
184 /// </summary>
351 [Test] 185 [Test]
352 public void TestLoadIarPathStartsWithSlash() 186 public void TestLoadIarCreatorAccountPresent()
353 { 187 {
354 TestHelper.InMethod(); 188 TestHelper.InMethod();
355// log4net.Config.XmlConfigurator.Configure(); 189// log4net.Config.XmlConfigurator.Configure();
356
357 SerialiserModule serialiserModule = new SerialiserModule();
358 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
359 Scene scene = SceneSetupHelpers.SetupScene("inventory");
360 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
361
362 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "password");
363 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/Objects", "password", m_iarStream);
364 190
191 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood");
192
193 m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "meowfood", m_iarStream);
365 InventoryItemBase foundItem1 194 InventoryItemBase foundItem1
366 = InventoryArchiveUtils.FindItemByPath( 195 = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_item1Name);
367 scene.InventoryService, m_ua1.PrincipalID, "/Objects/" + m_item1Name); 196
197 Assert.That(
198 foundItem1.CreatorId, Is.EqualTo(m_uaLL1.PrincipalID.ToString()),
199 "Loaded item non-uuid creator doesn't match original");
200 Assert.That(
201 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL1.PrincipalID),
202 "Loaded item uuid creator doesn't match original");
203 Assert.That(foundItem1.Owner, Is.EqualTo(m_uaLL1.PrincipalID),
204 "Loaded item owner doesn't match inventory reciever");
368 205
369 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()"); 206 AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
207 string xmlData = Utils.BytesToString(asset1.Data);
208 SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
209
210 Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL1.PrincipalID));
370 } 211 }
371 212
372 /// <summary> 213 /// <summary>
373 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where 214 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
374 /// an account exists with the creator name. 215 /// an account exists with the same name as the creator, though not the same id.
375 /// </summary> 216 /// </summary>
376 ///
377 /// This test also does some deeper probing of loading into nested inventory structures
378 [Test] 217 [Test]
379 public void TestLoadIarV0_1ExistingUsers() 218 public void TestLoadIarV0_1SameNameCreator()
380 { 219 {
381 TestHelper.InMethod(); 220 TestHelper.InMethod();
382 //log4net.Config.XmlConfigurator.Configure(); 221// log4net.Config.XmlConfigurator.Configure();
383
384 SerialiserModule serialiserModule = new SerialiserModule();
385 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
386
387 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
388 Scene scene = SceneSetupHelpers.SetupScene("inventory");
389
390 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
391 222
392 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood"); 223 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaMT, "meowfood");
393 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); 224 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire");
394 225
395 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "meowfood", m_iarStream); 226 m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream);
396
397 InventoryItemBase foundItem1 227 InventoryItemBase foundItem1
398 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name); 228 = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
399
400 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
401 229
402// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the
403// UUID, not the OSPA itself.
404// Assert.That(
405// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
406// "Loaded item non-uuid creator doesn't match original");
407 Assert.That( 230 Assert.That(
408 foundItem1.CreatorId, Is.EqualTo(m_ua2.PrincipalID.ToString()), 231 foundItem1.CreatorId, Is.EqualTo(m_uaLL2.PrincipalID.ToString()),
409 "Loaded item non-uuid creator doesn't match original"); 232 "Loaded item non-uuid creator doesn't match original");
410
411 Assert.That( 233 Assert.That(
412 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua2.PrincipalID), 234 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL2.PrincipalID),
413 "Loaded item uuid creator doesn't match original"); 235 "Loaded item uuid creator doesn't match original");
414 Assert.That(foundItem1.Owner, Is.EqualTo(m_ua1.PrincipalID), 236 Assert.That(foundItem1.Owner, Is.EqualTo(m_uaMT.PrincipalID),
415 "Loaded item owner doesn't match inventory reciever"); 237 "Loaded item owner doesn't match inventory reciever");
416
417 // Now try loading to a root child folder
418 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xA");
419 MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray());
420 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xA", "meowfood", archiveReadStream);
421
422 InventoryItemBase foundItem2
423 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xA/" + m_item1Name);
424 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
425
426 // Now try loading to a more deeply nested folder
427 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xB/xC");
428 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
429 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xB/xC", "meowfood", archiveReadStream);
430
431 InventoryItemBase foundItem3
432 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xB/xC/" + m_item1Name);
433 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
434 }
435
436 [Test]
437 public void TestIarV0_1WithEscapedChars()
438 {
439 TestHelper.InMethod();
440// log4net.Config.XmlConfigurator.Configure();
441
442 string itemName = "You & you are a mean/man/";
443 string humanEscapedItemName = @"You & you are a mean\/man\/";
444 string userPassword = "meowfood";
445
446 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
447
448 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
449 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
450
451 // Create user
452 string userFirstName = "Jock";
453 string userLastName = "Stirrup";
454 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
455 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood");
456
457 // Create asset
458 SceneObjectGroup object1;
459 SceneObjectPart part1;
460 {
461 string partName = "part name";
462 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
463 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
464 Vector3 groupPosition = new Vector3(10, 20, 30);
465 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
466 Vector3 offsetPosition = new Vector3(5, 10, 15);
467
468 part1
469 = new SceneObjectPart(
470 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
471 part1.Name = partName;
472
473 object1 = new SceneObjectGroup(part1);
474 scene.AddNewSceneObject(object1, false);
475 }
476
477 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
478 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
479 scene.AssetService.Store(asset1);
480
481 // Create item
482 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
483 InventoryItemBase item1 = new InventoryItemBase();
484 item1.Name = itemName;
485 item1.AssetID = asset1.FullID;
486 item1.ID = item1Id;
487 InventoryFolderBase objsFolder
488 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
489 item1.Folder = objsFolder.ID;
490 scene.AddInventoryItem(item1);
491
492 MemoryStream archiveWriteStream = new MemoryStream();
493 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
494
495 mre.Reset();
496 archiverModule.ArchiveInventory(
497 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
498 mre.WaitOne(60000, false);
499
500 // LOAD ITEM
501 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
502 238
503 archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); 239 AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
504 240 string xmlData = Utils.BytesToString(asset1.Data);
505 InventoryItemBase foundItem1 241 SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
506 = InventoryArchiveUtils.FindItemByPath(
507 scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName);
508 242
509 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); 243 Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL2.PrincipalID));
510// Assert.That(
511// foundItem1.CreatorId, Is.EqualTo(userUuid),
512// "Loaded item non-uuid creator doesn't match that of the loading user");
513 Assert.That(
514 foundItem1.Name, Is.EqualTo(itemName),
515 "Loaded item name doesn't match saved name");
516 } 244 }
517 245
518 /// <summary> 246 /// <summary>
519 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where 247 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
520 /// embedded creators do not exist in the system 248 /// the creator or an account with the creator's name does not exist within the system.
521 /// </summary> 249 /// </summary>
522 ///
523 /// This may possibly one day get overtaken by the as yet incomplete temporary profiles feature
524 /// (as tested in the a later commented out test)
525 /// This test is currently disabled
526 [Test] 250 [Test]
527 public void TestLoadIarV0_1AbsentUsers() 251 public void TestLoadIarV0_1AbsentCreator()
528 { 252 {
529 TestHelper.InMethod(); 253 TestHelper.InMethod();
530 //log4net.Config.XmlConfigurator.Configure(); 254// log4net.Config.XmlConfigurator.Configure();
531
532 string userFirstName = "Charlie";
533 string userLastName = "Chan";
534 UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000999");
535 string userItemCreatorFirstName = "Bat";
536 string userItemCreatorLastName = "Man";
537 //UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000008888");
538
539 string itemName = "b.lsl";
540 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
541
542 MemoryStream archiveWriteStream = new MemoryStream();
543 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
544
545 InventoryItemBase item1 = new InventoryItemBase();
546 item1.Name = itemName;
547 item1.AssetID = UUID.Random();
548 item1.GroupID = UUID.Random();
549 item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
550 //item1.CreatorId = userUuid.ToString();
551 //item1.CreatorId = "00000000-0000-0000-0000-000000000444";
552 item1.Owner = UUID.Zero;
553
554 string item1FileName
555 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
556 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string,object>(), null));
557 tar.Close();
558
559 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
560 SerialiserModule serialiserModule = new SerialiserModule();
561 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
562
563 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
564 Scene scene = SceneSetupHelpers.SetupScene("inventory");
565
566 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
567 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userUuid, "meowfood");
568 255
569 archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream); 256 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaMT, "password");
257 m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "password", m_iarStream);
570 258
571 InventoryItemBase foundItem1 259 InventoryItemBase foundItem1
572 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, itemName); 260 = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
573 261
574 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); 262 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
575// Assert.That(
576// foundItem1.CreatorId, Is.EqualTo(userUuid),
577// "Loaded item non-uuid creator doesn't match that of the loading user");
578 Assert.That( 263 Assert.That(
579 foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid), 264 foundItem1.CreatorId, Is.EqualTo(m_uaMT.PrincipalID.ToString()),
265 "Loaded item non-uuid creator doesn't match that of the loading user");
266 Assert.That(
267 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaMT.PrincipalID),
580 "Loaded item uuid creator doesn't match that of the loading user"); 268 "Loaded item uuid creator doesn't match that of the loading user");
581 }
582
583 /// <summary>
584 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
585 /// no account exists with the creator name
586 /// </summary>
587 /// Disabled since temporary profiles have not yet been implemented.
588 ///
589 //[Test]
590 //public void TestLoadIarV0_1TempProfiles()
591 //{
592 // TestHelper.InMethod();
593
594 // //log4net.Config.XmlConfigurator.Configure();
595 269
596 // string userFirstName = "Dennis"; 270 AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
597 // string userLastName = "Menace"; 271 string xmlData = Utils.BytesToString(asset1.Data);
598 // UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000aaa"); 272 SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
599 // string user2FirstName = "Walter";
600 // string user2LastName = "Mitty";
601 273
602 // string itemName = "b.lsl"; 274 Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaMT.PrincipalID));
603 // string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
604
605 // MemoryStream archiveWriteStream = new MemoryStream();
606 // TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
607
608 // InventoryItemBase item1 = new InventoryItemBase();
609 // item1.Name = itemName;
610 // item1.AssetID = UUID.Random();
611 // item1.GroupID = UUID.Random();
612 // item1.CreatorId = OspResolver.MakeOspa(user2FirstName, user2LastName);
613 // item1.Owner = UUID.Zero;
614
615 // string item1FileName
616 // = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
617 // tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
618 // tar.Close();
619
620 // MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
621 // SerialiserModule serialiserModule = new SerialiserModule();
622 // InventoryArchiverModule archiverModule = new InventoryArchiverModule();
623
624 // // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
625 // Scene scene = SceneSetupHelpers.SetupScene();
626 // IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
627
628 // SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
629 // userAdminService.AddUser(
630 // userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid);
631
632 // archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream);
633
634 // // Check that a suitable temporary user profile has been created.
635 // UserProfileData user2Profile
636 // = scene.CommsManager.UserService.GetUserProfile(
637 // OspResolver.HashName(user2FirstName + " " + user2LastName));
638 // Assert.That(user2Profile, Is.Not.Null);
639 // Assert.That(user2Profile.FirstName == user2FirstName);
640 // Assert.That(user2Profile.SurName == user2LastName);
641
642 // CachedUserInfo userInfo
643 // = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
644 // userInfo.OnInventoryReceived += InventoryReceived;
645
646 // lock (this)
647 // {
648 // userInfo.FetchInventory();
649 // Monitor.Wait(this, 60000);
650 // }
651
652 // InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName);
653
654 // Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId));
655 // Assert.That(
656 // foundItem.CreatorIdAsUuid, Is.EqualTo(OspResolver.HashName(user2FirstName + " " + user2LastName)));
657 // Assert.That(foundItem.Owner, Is.EqualTo(userUuid));
658
659 // Console.WriteLine("### Successfully completed {0} ###", MethodBase.GetCurrentMethod());
660 //}
661
662 /// <summary>
663 /// Test replication of an archive path to the user's inventory.
664 /// </summary>
665 [Test]
666 public void TestNewIarPath()
667 {
668 TestHelper.InMethod();
669// log4net.Config.XmlConfigurator.Configure();
670
671 Scene scene = SceneSetupHelpers.SetupScene("inventory");
672 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
673
674 Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
675 HashSet<InventoryNodeBase> nodesLoaded = new HashSet<InventoryNodeBase>();
676
677 string folder1Name = "1";
678 string folder2aName = "2a";
679 string folder2bName = "2b";
680
681 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
682 string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random());
683 string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random());
684
685 string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName });
686 string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName });
687
688 {
689 // Test replication of path1
690 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
691 .ReplicateArchivePathToUserInventory(
692 iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
693 foldersCreated, nodesLoaded);
694
695 List<InventoryFolderBase> folder1Candidates
696 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
697 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
698
699 InventoryFolderBase folder1 = folder1Candidates[0];
700 List<InventoryFolderBase> folder2aCandidates
701 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
702 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
703 }
704
705 {
706 // Test replication of path2
707 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
708 .ReplicateArchivePathToUserInventory(
709 iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
710 foldersCreated, nodesLoaded);
711
712 List<InventoryFolderBase> folder1Candidates
713 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
714 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
715
716 InventoryFolderBase folder1 = folder1Candidates[0];
717
718 List<InventoryFolderBase> folder2aCandidates
719 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
720 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
721
722 List<InventoryFolderBase> folder2bCandidates
723 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2bName);
724 Assert.That(folder2bCandidates.Count, Is.EqualTo(1));
725 }
726 }
727
728 /// <summary>
729 /// Test replication of a partly existing archive path to the user's inventory. This should create
730 /// a duplicate path without the merge option.
731 /// </summary>
732 [Test]
733 public void TestPartExistingIarPath()
734 {
735 TestHelper.InMethod();
736 //log4net.Config.XmlConfigurator.Configure();
737
738 Scene scene = SceneSetupHelpers.SetupScene("inventory");
739 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
740
741 string folder1ExistingName = "a";
742 string folder2Name = "b";
743
744 InventoryFolderBase folder1
745 = UserInventoryTestUtils.CreateInventoryFolder(
746 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
747
748 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
749 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
750
751 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
752
753 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
754 .ReplicateArchivePathToUserInventory(
755 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
756 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
757
758 List<InventoryFolderBase> folder1PostCandidates
759 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
760 Assert.That(folder1PostCandidates.Count, Is.EqualTo(2));
761
762 // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder.
763 InventoryFolderBase folder1Post = null;
764 foreach (InventoryFolderBase folder in folder1PostCandidates)
765 {
766 if (folder.ID != folder1.ID)
767 {
768 folder1Post = folder;
769 break;
770 }
771 }
772// Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));
773
774 List<InventoryFolderBase> folder2PostCandidates
775 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b");
776 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
777 }
778
779 /// <summary>
780 /// Test replication of a partly existing archive path to the user's inventory. This should create
781 /// a merged path.
782 /// </summary>
783 [Test]
784 public void TestMergeIarPath()
785 {
786 TestHelper.InMethod();
787// log4net.Config.XmlConfigurator.Configure();
788
789 Scene scene = SceneSetupHelpers.SetupScene("inventory");
790 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
791
792 string folder1ExistingName = "a";
793 string folder2Name = "b";
794
795 InventoryFolderBase folder1
796 = UserInventoryTestUtils.CreateInventoryFolder(
797 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
798
799 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
800 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
801
802 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
803
804 new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true)
805 .ReplicateArchivePathToUserInventory(
806 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
807 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
808
809 List<InventoryFolderBase> folder1PostCandidates
810 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
811 Assert.That(folder1PostCandidates.Count, Is.EqualTo(1));
812 Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID));
813
814 List<InventoryFolderBase> folder2PostCandidates
815 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1PostCandidates[0], "b");
816 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
817 } 275 }
818 } 276 }
819} \ No newline at end of file 277} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs
new file mode 100644
index 0000000..0e8f647
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs
@@ -0,0 +1,478 @@
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 System.IO;
31using System.Reflection;
32using System.Threading;
33using NUnit.Framework;
34using OpenMetaverse;
35using OpenSim.Data;
36using OpenSim.Framework;
37using OpenSim.Framework.Serialization;
38using OpenSim.Framework.Serialization.External;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
41using OpenSim.Region.CoreModules.World.Serialiser;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Services.Interfaces;
45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock;
47using OpenSim.Tests.Common.Setup;
48
49namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
50{
51 [TestFixture]
52 public class PathTests : InventoryArchiveTestCase
53 {
54 /// <summary>
55 /// Test saving an inventory path to a V0.1 OpenSim Inventory Archive
56 /// (subject to change since there is no fixed format yet).
57 /// </summary>
58 [Test]
59 public void TestSavePathToIarV0_1()
60 {
61 TestHelper.InMethod();
62// log4net.Config.XmlConfigurator.Configure();
63
64 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
65
66 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
67 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
68
69 // Create user
70 string userFirstName = "Jock";
71 string userLastName = "Stirrup";
72 string userPassword = "troll";
73 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
74 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword);
75
76 // Create asset
77 SceneObjectGroup object1;
78 SceneObjectPart part1;
79 {
80 string partName = "My Little Dog Object";
81 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
82 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
83 Vector3 groupPosition = new Vector3(10, 20, 30);
84 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
85 Vector3 offsetPosition = new Vector3(5, 10, 15);
86
87 part1 = new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition);
88 part1.Name = partName;
89
90 object1 = new SceneObjectGroup(part1);
91 scene.AddNewSceneObject(object1, false);
92 }
93
94 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
95 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
96 scene.AssetService.Store(asset1);
97
98 // Create item
99 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
100 InventoryItemBase item1 = new InventoryItemBase();
101 item1.Name = "My Little Dog";
102 item1.AssetID = asset1.FullID;
103 item1.ID = item1Id;
104 InventoryFolderBase objsFolder
105 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
106 item1.Folder = objsFolder.ID;
107 scene.AddInventoryItem(item1);
108
109 MemoryStream archiveWriteStream = new MemoryStream();
110 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
111
112 // Test saving a particular path
113 mre.Reset();
114 archiverModule.ArchiveInventory(
115 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
116 mre.WaitOne(60000, false);
117
118 byte[] archive = archiveWriteStream.ToArray();
119 MemoryStream archiveReadStream = new MemoryStream(archive);
120 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
121
122 //bool gotControlFile = false;
123 bool gotObject1File = false;
124 //bool gotObject2File = false;
125 string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
126 string expectedObject1FilePath = string.Format(
127 "{0}{1}{2}",
128 ArchiveConstants.INVENTORY_PATH,
129 InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder),
130 expectedObject1FileName);
131
132 string filePath;
133 TarArchiveReader.TarEntryType tarEntryType;
134
135// Console.WriteLine("Reading archive");
136
137 while (tar.ReadEntry(out filePath, out tarEntryType) != null)
138 {
139// Console.WriteLine("Got {0}", filePath);
140
141// if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
142// {
143// gotControlFile = true;
144// }
145
146 if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
147 {
148// string fileName = filePath.Remove(0, "Objects/".Length);
149//
150// if (fileName.StartsWith(part1.Name))
151// {
152 Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
153 gotObject1File = true;
154// }
155// else if (fileName.StartsWith(part2.Name))
156// {
157// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
158// gotObject2File = true;
159// }
160 }
161 }
162
163// Assert.That(gotControlFile, Is.True, "No control file in archive");
164 Assert.That(gotObject1File, Is.True, "No item1 file in archive");
165// Assert.That(gotObject2File, Is.True, "No object2 file in archive");
166
167 // TODO: Test presence of more files and contents of files.
168 }
169
170 /// <summary>
171 /// Test loading an IAR to various different inventory paths.
172 /// </summary>
173 [Test]
174 public void TestLoadIarToInventoryPaths()
175 {
176 TestHelper.InMethod();
177// log4net.Config.XmlConfigurator.Configure();
178
179 SerialiserModule serialiserModule = new SerialiserModule();
180 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
181
182 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
183 Scene scene = SceneSetupHelpers.SetupScene("inventory");
184
185 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
186
187 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "meowfood");
188 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire");
189
190 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream);
191 InventoryItemBase foundItem1
192 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
193
194 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
195
196 // Now try loading to a root child folder
197 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xA");
198 MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray());
199 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xA", "meowfood", archiveReadStream);
200
201 InventoryItemBase foundItem2
202 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xA/" + m_item1Name);
203 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
204
205 // Now try loading to a more deeply nested folder
206 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC");
207 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
208 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xB/xC", "meowfood", archiveReadStream);
209
210 InventoryItemBase foundItem3
211 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC/" + m_item1Name);
212 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
213 }
214
215 /// <summary>
216 /// Test that things work when the load path specified starts with a slash
217 /// </summary>
218 [Test]
219 public void TestLoadIarPathStartsWithSlash()
220 {
221 TestHelper.InMethod();
222// log4net.Config.XmlConfigurator.Configure();
223
224 SerialiserModule serialiserModule = new SerialiserModule();
225 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
226 Scene scene = SceneSetupHelpers.SetupScene("inventory");
227 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
228
229 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "password");
230 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/Objects", "password", m_iarStream);
231
232 InventoryItemBase foundItem1
233 = InventoryArchiveUtils.FindItemByPath(
234 scene.InventoryService, m_uaMT.PrincipalID, "/Objects/" + m_item1Name);
235
236 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()");
237 }
238
239 [Test]
240 public void TestLoadIarPathWithEscapedChars()
241 {
242 TestHelper.InMethod();
243// log4net.Config.XmlConfigurator.Configure();
244
245 string itemName = "You & you are a mean/man/";
246 string humanEscapedItemName = @"You & you are a mean\/man\/";
247 string userPassword = "meowfood";
248
249 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
250
251 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
252 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
253
254 // Create user
255 string userFirstName = "Jock";
256 string userLastName = "Stirrup";
257 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
258 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood");
259
260 // Create asset
261 SceneObjectGroup object1;
262 SceneObjectPart part1;
263 {
264 string partName = "part name";
265 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
266 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
267 Vector3 groupPosition = new Vector3(10, 20, 30);
268 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
269 Vector3 offsetPosition = new Vector3(5, 10, 15);
270
271 part1
272 = new SceneObjectPart(
273 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
274 part1.Name = partName;
275
276 object1 = new SceneObjectGroup(part1);
277 scene.AddNewSceneObject(object1, false);
278 }
279
280 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
281 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
282 scene.AssetService.Store(asset1);
283
284 // Create item
285 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
286 InventoryItemBase item1 = new InventoryItemBase();
287 item1.Name = itemName;
288 item1.AssetID = asset1.FullID;
289 item1.ID = item1Id;
290 InventoryFolderBase objsFolder
291 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
292 item1.Folder = objsFolder.ID;
293 scene.AddInventoryItem(item1);
294
295 MemoryStream archiveWriteStream = new MemoryStream();
296 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
297
298 mre.Reset();
299 archiverModule.ArchiveInventory(
300 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
301 mre.WaitOne(60000, false);
302
303 // LOAD ITEM
304 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
305
306 archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream);
307
308 InventoryItemBase foundItem1
309 = InventoryArchiveUtils.FindItemByPath(
310 scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName);
311
312 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
313// Assert.That(
314// foundItem1.CreatorId, Is.EqualTo(userUuid),
315// "Loaded item non-uuid creator doesn't match that of the loading user");
316 Assert.That(
317 foundItem1.Name, Is.EqualTo(itemName),
318 "Loaded item name doesn't match saved name");
319 }
320
321 /// <summary>
322 /// Test replication of an archive path to the user's inventory.
323 /// </summary>
324 [Test]
325 public void TestNewIarPath()
326 {
327 TestHelper.InMethod();
328// log4net.Config.XmlConfigurator.Configure();
329
330 Scene scene = SceneSetupHelpers.SetupScene("inventory");
331 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
332
333 Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
334 HashSet<InventoryNodeBase> nodesLoaded = new HashSet<InventoryNodeBase>();
335
336 string folder1Name = "1";
337 string folder2aName = "2a";
338 string folder2bName = "2b";
339
340 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
341 string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random());
342 string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random());
343
344 string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName });
345 string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName });
346
347 {
348 // Test replication of path1
349 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
350 .ReplicateArchivePathToUserInventory(
351 iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
352 foldersCreated, nodesLoaded);
353
354 List<InventoryFolderBase> folder1Candidates
355 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
356 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
357
358 InventoryFolderBase folder1 = folder1Candidates[0];
359 List<InventoryFolderBase> folder2aCandidates
360 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
361 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
362 }
363
364 {
365 // Test replication of path2
366 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
367 .ReplicateArchivePathToUserInventory(
368 iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
369 foldersCreated, nodesLoaded);
370
371 List<InventoryFolderBase> folder1Candidates
372 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
373 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
374
375 InventoryFolderBase folder1 = folder1Candidates[0];
376
377 List<InventoryFolderBase> folder2aCandidates
378 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
379 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
380
381 List<InventoryFolderBase> folder2bCandidates
382 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2bName);
383 Assert.That(folder2bCandidates.Count, Is.EqualTo(1));
384 }
385 }
386
387 /// <summary>
388 /// Test replication of a partly existing archive path to the user's inventory. This should create
389 /// a duplicate path without the merge option.
390 /// </summary>
391 [Test]
392 public void TestPartExistingIarPath()
393 {
394 TestHelper.InMethod();
395 //log4net.Config.XmlConfigurator.Configure();
396
397 Scene scene = SceneSetupHelpers.SetupScene("inventory");
398 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
399
400 string folder1ExistingName = "a";
401 string folder2Name = "b";
402
403 InventoryFolderBase folder1
404 = UserInventoryTestUtils.CreateInventoryFolder(
405 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
406
407 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
408 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
409
410 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
411
412 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
413 .ReplicateArchivePathToUserInventory(
414 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
415 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
416
417 List<InventoryFolderBase> folder1PostCandidates
418 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
419 Assert.That(folder1PostCandidates.Count, Is.EqualTo(2));
420
421 // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder.
422 InventoryFolderBase folder1Post = null;
423 foreach (InventoryFolderBase folder in folder1PostCandidates)
424 {
425 if (folder.ID != folder1.ID)
426 {
427 folder1Post = folder;
428 break;
429 }
430 }
431// Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));
432
433 List<InventoryFolderBase> folder2PostCandidates
434 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b");
435 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
436 }
437
438 /// <summary>
439 /// Test replication of a partly existing archive path to the user's inventory. This should create
440 /// a merged path.
441 /// </summary>
442 [Test]
443 public void TestMergeIarPath()
444 {
445 TestHelper.InMethod();
446// log4net.Config.XmlConfigurator.Configure();
447
448 Scene scene = SceneSetupHelpers.SetupScene("inventory");
449 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
450
451 string folder1ExistingName = "a";
452 string folder2Name = "b";
453
454 InventoryFolderBase folder1
455 = UserInventoryTestUtils.CreateInventoryFolder(
456 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
457
458 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
459 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
460
461 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
462
463 new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true)
464 .ReplicateArchivePathToUserInventory(
465 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
466 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
467
468 List<InventoryFolderBase> folder1PostCandidates
469 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
470 Assert.That(folder1PostCandidates.Count, Is.EqualTo(1));
471 Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID));
472
473 List<InventoryFolderBase> folder2PostCandidates
474 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1PostCandidates[0], "b");
475 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
476 }
477 }
478} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 9e1d414..138556f 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -244,7 +244,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
244 } 244 }
245 catch (Exception e) 245 catch (Exception e)
246 { 246 {
247 m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0}\n{1}", e.Message, e.StackTrace); 247 m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0} {1}", e.Message, e.StackTrace);
248 sp.ControllingClient.SendTeleportFailed("Internal error"); 248 sp.ControllingClient.SendTeleportFailed("Internal error");
249 } 249 }
250 } 250 }
@@ -285,9 +285,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
285 return; 285 return;
286 } 286 }
287 287
288 if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero)) 288 string reason;
289 if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero, out reason))
289 { 290 {
290 sp.ControllingClient.SendTeleportFailed("The destination region has refused access"); 291 sp.ControllingClient.SendTeleportFailed("Teleport failed: " + reason);
291 return; 292 return;
292 } 293 }
293 294
@@ -318,14 +319,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
318 agentCircuit.Id0 = currentAgentCircuit.Id0; 319 agentCircuit.Id0 = currentAgentCircuit.Id0;
319 } 320 }
320 321
321 if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) 322 if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY))
322 { 323 {
323 // brand new agent, let's create a new caps seed 324 // brand new agent, let's create a new caps seed
324 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); 325 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
325 } 326 }
326 327
327 string reason = String.Empty;
328
329 // Let's create an agent there if one doesn't exist yet. 328 // Let's create an agent there if one doesn't exist yet.
330 bool logout = false; 329 bool logout = false;
331 if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) 330 if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout))
@@ -338,7 +337,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
338 // OK, it got this agent. Let's close some child agents 337 // OK, it got this agent. Let's close some child agents
339 sp.CloseChildAgents(newRegionX, newRegionY); 338 sp.CloseChildAgents(newRegionX, newRegionY);
340 IClientIPEndpoint ipepClient; 339 IClientIPEndpoint ipepClient;
341 if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) 340 if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY))
342 { 341 {
343 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); 342 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
344 #region IP Translation for NAT 343 #region IP Translation for NAT
@@ -401,6 +400,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
401 if (!UpdateAgent(reg, finalDestination, agent)) 400 if (!UpdateAgent(reg, finalDestination, agent))
402 { 401 {
403 // Region doesn't take it 402 // Region doesn't take it
403 m_log.WarnFormat(
404 "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1}. Returning avatar to source region.",
405 sp.Name, finalDestination.RegionName);
406
404 Fail(sp, finalDestination); 407 Fail(sp, finalDestination);
405 return; 408 return;
406 } 409 }
@@ -427,16 +430,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
427 // that the client contacted the destination before we send the attachments and close things here. 430 // that the client contacted the destination before we send the attachments and close things here.
428 if (!WaitForCallback(sp.UUID)) 431 if (!WaitForCallback(sp.UUID))
429 { 432 {
430 Fail(sp, finalDestination); 433 m_log.WarnFormat(
434 "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} failed due to no callback from destination region. Returning avatar to source region.",
435 sp.Name, finalDestination.RegionName);
436
437 Fail(sp, finalDestination);
431 return; 438 return;
432 } 439 }
433 440
434
435 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it 441 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
436 CrossAttachmentsIntoNewRegion(finalDestination, sp, true); 442 CrossAttachmentsIntoNewRegion(finalDestination, sp, true);
437 443
438 // Well, this is it. The agent is over there. 444 // Well, this is it. The agent is over there.
439
440 KillEntity(sp.Scene, sp.LocalId); 445 KillEntity(sp.Scene, sp.LocalId);
441 446
442 // May need to logout or other cleanup 447 // May need to logout or other cleanup
@@ -449,7 +454,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
449 454
450 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone 455 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
451 456
452 if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) 457 if (NeedsClosing(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
453 { 458 {
454 Thread.Sleep(5000); 459 Thread.Sleep(5000);
455 sp.Close(); 460 sp.Close();
@@ -523,14 +528,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
523 return region; 528 return region;
524 } 529 }
525 530
526 protected virtual bool NeedsNewAgent(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY) 531 protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY)
527 { 532 {
528 return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY); 533 return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY);
529 } 534 }
530 535
531 protected virtual bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) 536 protected virtual bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg)
532 { 537 {
533 return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY); 538 return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY);
534 } 539 }
535 540
536 protected virtual bool IsOutsideRegion(Scene s, Vector3 pos) 541 protected virtual bool IsOutsideRegion(Scene s, Vector3 pos)
@@ -797,7 +802,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
797 802
798 GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); 803 GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y);
799 804
800 if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos)) 805 string reason;
806 if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos, out reason))
801 { 807 {
802 agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel"); 808 agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel");
803 if (r == null) 809 if (r == null)
@@ -1006,7 +1012,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1006 /// </summary> 1012 /// </summary>
1007 public void EnableChildAgent(ScenePresence sp, GridRegion region) 1013 public void EnableChildAgent(ScenePresence sp, GridRegion region)
1008 { 1014 {
1009 m_log.DebugFormat("[ENTITY TRANSFER]: Enabling child agent in new neighour {0}", region.RegionName); 1015 m_log.DebugFormat("[ENTITY TRANSFER]: Enabling child agent in new neighbour {0}", region.RegionName);
1010 1016
1011 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); 1017 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
1012 AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); 1018 AgentCircuitData agent = sp.ControllingClient.RequestClientInfo();
@@ -1072,7 +1078,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1072 1078
1073 if (m_regionInfo != null) 1079 if (m_regionInfo != null)
1074 { 1080 {
1075 neighbours = RequestNeighbours(sp.Scene, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 1081 neighbours = RequestNeighbours(sp, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
1076 } 1082 }
1077 else 1083 else
1078 { 1084 {
@@ -1298,8 +1304,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1298 /// <param name="pRegionLocX"></param> 1304 /// <param name="pRegionLocX"></param>
1299 /// <param name="pRegionLocY"></param> 1305 /// <param name="pRegionLocY"></param>
1300 /// <returns></returns> 1306 /// <returns></returns>
1301 protected List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY) 1307 protected List<GridRegion> RequestNeighbours(ScenePresence avatar, uint pRegionLocX, uint pRegionLocY)
1302 { 1308 {
1309 Scene pScene = avatar.Scene;
1303 RegionInfo m_regionInfo = pScene.RegionInfo; 1310 RegionInfo m_regionInfo = pScene.RegionInfo;
1304 1311
1305 Border[] northBorders = pScene.NorthBorders.ToArray(); 1312 Border[] northBorders = pScene.NorthBorders.ToArray();
@@ -1307,10 +1314,24 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1307 Border[] eastBorders = pScene.EastBorders.ToArray(); 1314 Border[] eastBorders = pScene.EastBorders.ToArray();
1308 Border[] westBorders = pScene.WestBorders.ToArray(); 1315 Border[] westBorders = pScene.WestBorders.ToArray();
1309 1316
1310 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. 1317 // Leaving this as a "megaregions" computation vs "non-megaregions" computation; it isn't
1318 // clear what should be done with a "far view" given that megaregions already extended the
1319 // view to include everything in the megaregion
1311 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) 1320 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
1312 { 1321 {
1313 return pScene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID); 1322 int dd = avatar.DrawDistance < Constants.RegionSize ? (int)Constants.RegionSize : (int)avatar.DrawDistance;
1323
1324 int startX = (int)pRegionLocX * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2);
1325 int startY = (int)pRegionLocY * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2);
1326
1327 int endX = (int)pRegionLocX * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2);
1328 int endY = (int)pRegionLocY * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2);
1329
1330 List<GridRegion> neighbours =
1331 avatar.Scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
1332
1333 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
1334 return neighbours;
1314 } 1335 }
1315 else 1336 else
1316 { 1337 {
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index c75bc0a..5a80100 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -130,9 +130,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
130 return region; 130 return region;
131 } 131 }
132 132
133 protected override bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) 133 protected override bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg)
134 { 134 {
135 if (base.NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) 135 if (base.NeedsClosing(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
136 return true; 136 return true;
137 137
138 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); 138 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID);
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index 34b8114..4565d10 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -55,6 +55,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
55 } 55 }
56 56
57 private string m_ProfileServerURI; 57 private string m_ProfileServerURI;
58 private bool m_OutboundPermission;
58 59
59// private bool m_Initialized = false; 60// private bool m_Initialized = false;
60 61
@@ -78,7 +79,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
78 79
79 IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"]; 80 IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"];
80 if (thisModuleConfig != null) 81 if (thisModuleConfig != null)
82 {
81 m_ProfileServerURI = thisModuleConfig.GetString("ProfileServerURI", string.Empty); 83 m_ProfileServerURI = thisModuleConfig.GetString("ProfileServerURI", string.Empty);
84 m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true);
85 }
82 else 86 else
83 m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); 87 m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!");
84 } 88 }
@@ -103,7 +107,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
103 public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) 107 public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel)
104 { 108 {
105 string userAssetServer = string.Empty; 109 string userAssetServer = string.Empty;
106 if (IsForeignUser(avatarID, out userAssetServer)) 110 if (IsForeignUser(avatarID, out userAssetServer) && m_OutboundPermission)
107 { 111 {
108 Util.FireAndForget(delegate { m_assMapper.Post(assetID, avatarID, userAssetServer); }); 112 Util.FireAndForget(delegate { m_assMapper.Post(assetID, avatarID, userAssetServer); });
109 } 113 }
@@ -197,7 +201,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
197 if (IsForeignUser(sender, out userAssetServer)) 201 if (IsForeignUser(sender, out userAssetServer))
198 m_assMapper.Get(item.AssetID, sender, userAssetServer); 202 m_assMapper.Get(item.AssetID, sender, userAssetServer);
199 203
200 if (IsForeignUser(receiver, out userAssetServer)) 204 if (IsForeignUser(receiver, out userAssetServer) && m_OutboundPermission)
201 m_assMapper.Post(item.AssetID, receiver, userAssetServer); 205 m_assMapper.Post(item.AssetID, receiver, userAssetServer);
202 } 206 }
203 207
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 0163060..108c9a0 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -149,6 +149,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
149 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 149 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
150 item = m_Scene.InventoryService.GetItem(item); 150 item = m_Scene.InventoryService.GetItem(item);
151 151
152 if (item.Owner != remoteClient.AgentId)
153 return UUID.Zero;
154
152 if (item != null) 155 if (item != null)
153 { 156 {
154 if ((InventoryType)item.InvType == InventoryType.Notecard) 157 if ((InventoryType)item.InvType == InventoryType.Notecard)
@@ -604,6 +607,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
604 { 607 {
605 m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 1"); 608 m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 1");
606 } 609 }
610 item.Owner = remoteClient.AgentId;
607 611
608 AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); 612 AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString());
609 613
diff --git a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
index 88f392d..2de8d7a 100644
--- a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
+++ b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
@@ -75,7 +75,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
75 m_scene = scene; 75 m_scene = scene;
76 m_scene.RegisterModuleInterface<IRegionModule>(this); 76 m_scene.RegisterModuleInterface<IRegionModule>(this);
77 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; 77 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
78 78
79 // ini file settings 79 // ini file settings
80 try 80 try
81 { 81 {
@@ -148,7 +148,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
148 public void SendProfileToClient(ScenePresence presence) 148 public void SendProfileToClient(ScenePresence presence)
149 { 149 {
150 IClientAPI client = presence.ControllingClient; 150 IClientAPI client = presence.ControllingClient;
151 if (m_enableWindlight) 151 if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid)
152 { 152 {
153 if (presence.IsChildAgent == false) 153 if (presence.IsChildAgent == false)
154 { 154 {
@@ -165,7 +165,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
165 public void SendProfileToClient(ScenePresence presence, RegionLightShareData wl) 165 public void SendProfileToClient(ScenePresence presence, RegionLightShareData wl)
166 { 166 {
167 IClientAPI client = presence.ControllingClient; 167 IClientAPI client = presence.ControllingClient;
168 if (m_enableWindlight) 168 if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid)
169 { 169 {
170 if (presence.IsChildAgent == false) 170 if (presence.IsChildAgent == false)
171 { 171 {
@@ -229,7 +229,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare
229 { 229 {
230 Command wlload = new Command("load", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleLoad, "Load windlight profile from the database and broadcast"); 230 Command wlload = new Command("load", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleLoad, "Load windlight profile from the database and broadcast");
231 Command wlenable = new Command("enable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleEnable, "Enable the windlight plugin"); 231 Command wlenable = new Command("enable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleEnable, "Enable the windlight plugin");
232 Command wldisable = new Command("disable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleDisable, "Enable the windlight plugin"); 232 Command wldisable = new Command("disable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleDisable, "Disable the windlight plugin");
233 233
234 m_commander.RegisterCommand("load", wlload); 234 m_commander.RegisterCommand("load", wlload);
235 m_commander.RegisterCommand("enable", wlenable); 235 m_commander.RegisterCommand("enable", wlenable);
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index 43de2ab..a9d247a 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -47,7 +47,6 @@
47 <RegionModule id="RemoteAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.RemoteAuthorizationServicesConnector" /> 47 <RegionModule id="RemoteAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.RemoteAuthorizationServicesConnector" />
48 <RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.HGAssetBroker" /> 48 <RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.HGAssetBroker" />
49 <RegionModule id="LocalInventoryServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.LocalInventoryServicesConnector" /> 49 <RegionModule id="LocalInventoryServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.LocalInventoryServicesConnector" />
50 <RegionModule id="RemoteInventoryServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.RemoteInventoryServicesConnector" />
51 <RegionModule id="RemoteXInventoryServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.RemoteXInventoryServicesConnector" /> 50 <RegionModule id="RemoteXInventoryServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.RemoteXInventoryServicesConnector" />
52 <RegionModule id="HGInventoryBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.HGInventoryBroker" /> 51 <RegionModule id="HGInventoryBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.HGInventoryBroker" />
53 <RegionModule id="LocalNeighbourServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour.LocalNeighbourServicesConnector" /> 52 <RegionModule id="LocalNeighbourServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour.LocalNeighbourServicesConnector" />
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 66eb747..bdbd0c2 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -77,7 +77,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
77 new Dictionary<string, UrlData>(); 77 new Dictionary<string, UrlData>();
78 78
79 79
80 private int m_TotalUrls = 1000; 80 private int m_TotalUrls = 5000;
81 81
82 private IHttpServer m_HttpServer = null; 82 private IHttpServer m_HttpServer = null;
83 83
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
index 01a2615..66994fa 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs
@@ -139,7 +139,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
139 139
140 if (scene != null) 140 if (scene != null)
141 { 141 {
142 UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, userID); 142 UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, new UUID(userID));
143 isAuthorized = IsAuthorizedForRegion(userID, account.FirstName, account.LastName, 143 isAuthorized = IsAuthorizedForRegion(userID, account.FirstName, account.LastName,
144 account.Email, scene.RegionInfo.RegionName, regionID, out message); 144 account.Email, scene.RegionInfo.RegionName, regionID, out message);
145 } 145 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
index 023a44c..3c36799 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
@@ -247,13 +247,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
247 247
248 public void NeighboursCommand(string module, string[] cmdparams) 248 public void NeighboursCommand(string module, string[] cmdparams)
249 { 249 {
250 System.Text.StringBuilder caps = new System.Text.StringBuilder();
251
250 foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache) 252 foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache)
251 { 253 {
252 m_log.InfoFormat("*** Neighbours of {0} {1} ***", kvp.Key, kvp.Value.RegionName); 254 caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key);
253 List<GridRegion> regions = kvp.Value.GetNeighbours(); 255 List<GridRegion> regions = kvp.Value.GetNeighbours();
254 foreach (GridRegion r in regions) 256 foreach (GridRegion r in regions)
255 m_log.InfoFormat(" {0} @ {1}={2}", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); 257 caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize);
256 } 258 }
259
260 MainConsole.Instance.Output(caps.ToString());
257 } 261 }
258 262
259 } 263 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
index ebfba2b..7128d2b 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
@@ -32,7 +32,6 @@ using System.Reflection;
32using System.Threading; 32using System.Threading;
33using log4net.Config; 33using log4net.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenSim.Framework; 36using OpenSim.Framework;
38using Nini.Config; 37using Nini.Config;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index 39410b5..3f63db3 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -200,6 +200,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
200 return; 200 return;
201 } 201 }
202 } 202 }
203 else
204 {
205 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: User {0} does not have InventoryServerURI. OH NOES!", userID);
206 return;
207 }
203 } 208 }
204 } 209 }
205 } 210 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
deleted file mode 100644
index 9213132..0000000
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
+++ /dev/null
@@ -1,362 +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 log4net;
29using System;
30using System.Collections.Generic;
31using System.Reflection;
32using Nini.Config;
33using OpenSim.Framework;
34using OpenSim.Framework.Statistics;
35using OpenSim.Services.Connectors;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Services.Interfaces;
39using OpenMetaverse;
40
41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
42{
43 public class RemoteInventoryServicesConnector : BaseInventoryConnector, ISharedRegionModule, IInventoryService
44 {
45 private static readonly ILog m_log =
46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 private bool m_Enabled = false;
49 private bool m_Initialized = false;
50 private Scene m_Scene;
51 private InventoryServicesConnector m_RemoteConnector;
52
53 private IUserManagement m_UserManager;
54 private IUserManagement UserManager
55 {
56 get
57 {
58 if (m_UserManager == null)
59 {
60 m_UserManager = m_Scene.RequestModuleInterface<IUserManagement>();
61 }
62 return m_UserManager;
63 }
64 }
65
66
67 public Type ReplaceableInterface
68 {
69 get { return null; }
70 }
71
72 public string Name
73 {
74 get { return "RemoteInventoryServicesConnector"; }
75 }
76
77 public RemoteInventoryServicesConnector()
78 {
79 }
80
81 public RemoteInventoryServicesConnector(IConfigSource source)
82 {
83 Init(source);
84 }
85
86 protected override void Init(IConfigSource source)
87 {
88 m_RemoteConnector = new InventoryServicesConnector(source);
89 base.Init(source);
90 }
91
92 #region ISharedRegionModule
93
94 public void Initialise(IConfigSource source)
95 {
96 IConfig moduleConfig = source.Configs["Modules"];
97 if (moduleConfig != null)
98 {
99 string name = moduleConfig.GetString("InventoryServices", "");
100 if (name == Name)
101 {
102 Init(source);
103 m_Enabled = true;
104
105 m_log.Info("[INVENTORY CONNECTOR]: Remote inventory enabled");
106 }
107 }
108 }
109
110 public void PostInitialise()
111 {
112 }
113
114 public void Close()
115 {
116 }
117
118 public void AddRegion(Scene scene)
119 {
120// m_Scene = scene;
121 //m_log.Debug("[XXXX] Adding scene " + m_Scene.RegionInfo.RegionName);
122
123 if (!m_Enabled)
124 return;
125
126 if (!m_Initialized)
127 {
128 m_Initialized = true;
129 }
130
131 scene.RegisterModuleInterface<IInventoryService>(this);
132 m_cache.AddRegion(scene);
133
134 if (m_Scene == null)
135 m_Scene = scene;
136 }
137
138 public void RemoveRegion(Scene scene)
139 {
140 if (!m_Enabled)
141 return;
142
143 m_cache.RemoveRegion(scene);
144 }
145
146 public void RegionLoaded(Scene scene)
147 {
148 if (!m_Enabled)
149 return;
150
151 m_log.InfoFormat("[INVENTORY CONNECTOR]: Enabled remote inventory for region {0}", scene.RegionInfo.RegionName);
152
153 }
154
155 #endregion ISharedRegionModule
156
157 #region IInventoryService
158
159 public override bool CreateUserInventory(UUID user)
160 {
161 return false;
162 }
163
164 public override List<InventoryFolderBase> GetInventorySkeleton(UUID userId)
165 {
166 return new List<InventoryFolderBase>();
167 }
168
169 public override InventoryCollection GetUserInventory(UUID userID)
170 {
171 return null;
172 }
173
174 public override void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
175 {
176 UUID sessionID = GetSessionID(userID);
177 try
178 {
179 m_RemoteConnector.GetUserInventory(userID.ToString(), sessionID, callback);
180 }
181 catch (Exception e)
182 {
183 if (StatsManager.SimExtraStats != null)
184 StatsManager.SimExtraStats.AddInventoryServiceRetrievalFailure();
185
186 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Request inventory operation failed, {0} {1}",
187 e.Source, e.Message);
188 }
189
190 }
191
192 // inherited. See base class
193 // public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
194
195 public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
196 {
197 UUID sessionID = GetSessionID(userID);
198 return m_RemoteConnector.GetSystemFolders(userID.ToString(), sessionID);
199 }
200
201 public override InventoryCollection GetFolderContent(UUID userID, UUID folderID)
202 {
203 UUID sessionID = GetSessionID(userID);
204 try
205 {
206 InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID.ToString(), folderID, sessionID);
207 foreach (InventoryItemBase item in invCol.Items)
208 UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
209 return invCol;
210 }
211 catch (Exception e)
212 {
213 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation failed, {0} {1}",
214 e.Source, e.Message);
215 }
216 InventoryCollection nullCollection = new InventoryCollection();
217 nullCollection.Folders = new List<InventoryFolderBase>();
218 nullCollection.Items = new List<InventoryItemBase>();
219 nullCollection.UserID = userID;
220 return nullCollection;
221 }
222
223 public override List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
224 {
225 UUID sessionID = GetSessionID(userID);
226 return m_RemoteConnector.GetFolderItems(userID.ToString(), folderID, sessionID);
227 }
228
229 public override bool AddFolder(InventoryFolderBase folder)
230 {
231 if (folder == null)
232 return false;
233
234 UUID sessionID = GetSessionID(folder.Owner);
235 return m_RemoteConnector.AddFolder(folder.Owner.ToString(), folder, sessionID);
236 }
237
238 public override bool UpdateFolder(InventoryFolderBase folder)
239 {
240 if (folder == null)
241 return false;
242
243 UUID sessionID = GetSessionID(folder.Owner);
244 return m_RemoteConnector.UpdateFolder(folder.Owner.ToString(), folder, sessionID);
245 }
246
247 public override bool MoveFolder(InventoryFolderBase folder)
248 {
249 if (folder == null)
250 return false;
251
252 UUID sessionID = GetSessionID(folder.Owner);
253 return m_RemoteConnector.MoveFolder(folder.Owner.ToString(), folder, sessionID);
254 }
255
256 public override bool DeleteFolders(UUID ownerID, List<UUID> folderIDs)
257 {
258 if (folderIDs == null)
259 return false;
260 if (folderIDs.Count == 0)
261 return false;
262
263 UUID sessionID = GetSessionID(ownerID);
264 return m_RemoteConnector.DeleteFolders(ownerID.ToString(), folderIDs, sessionID);
265 }
266
267
268 public override bool PurgeFolder(InventoryFolderBase folder)
269 {
270 if (folder == null)
271 return false;
272
273 UUID sessionID = GetSessionID(folder.Owner);
274 return m_RemoteConnector.PurgeFolder(folder.Owner.ToString(), folder, sessionID);
275 }
276
277 // public bool AddItem(InventoryItemBase item) inherited
278 // Uses AddItemPlain
279
280 protected override bool AddItemPlain(InventoryItemBase item)
281 {
282 if (item == null)
283 return false;
284
285 UUID sessionID = GetSessionID(item.Owner);
286 return m_RemoteConnector.AddItem(item.Owner.ToString(), item, sessionID);
287 }
288
289 public override bool UpdateItem(InventoryItemBase item)
290 {
291 if (item == null)
292 return false;
293
294 UUID sessionID = GetSessionID(item.Owner);
295 return m_RemoteConnector.UpdateItem(item.Owner.ToString(), item, sessionID);
296 }
297
298 public override bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
299 {
300 if (items == null)
301 return false;
302
303 UUID sessionID = GetSessionID(ownerID);
304 return m_RemoteConnector.MoveItems(ownerID.ToString(), items, sessionID);
305 }
306
307
308 public override bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
309 {
310 if (itemIDs == null)
311 return false;
312 if (itemIDs.Count == 0)
313 return true;
314
315 UUID sessionID = GetSessionID(ownerID);
316 return m_RemoteConnector.DeleteItems(ownerID.ToString(), itemIDs, sessionID);
317 }
318
319 public override InventoryItemBase GetItem(InventoryItemBase item)
320 {
321 if (item == null)
322 return null;
323
324 UUID sessionID = GetSessionID(item.Owner);
325 return m_RemoteConnector.QueryItem(item.Owner.ToString(), item, sessionID);
326 }
327
328 public override InventoryFolderBase GetFolder(InventoryFolderBase folder)
329 {
330 if (folder == null)
331 return null;
332
333 UUID sessionID = GetSessionID(folder.Owner);
334 return m_RemoteConnector.QueryFolder(folder.Owner.ToString(), folder, sessionID);
335 }
336
337 public override bool HasInventoryForUser(UUID userID)
338 {
339 return false;
340 }
341
342 public override List<InventoryItemBase> GetActiveGestures(UUID userId)
343 {
344 return new List<InventoryItemBase>();
345 }
346
347 public override int GetAssetPermissions(UUID userID, UUID assetID)
348 {
349 UUID sessionID = GetSessionID(userID);
350 return m_RemoteConnector.GetAssetPermissions(userID.ToString(), assetID, sessionID);
351 }
352
353
354 #endregion
355
356 private UUID GetSessionID(UUID userID)
357 {
358 return UUID.Zero;
359 }
360
361 }
362}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
index ef910f4..e471f75 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
@@ -32,7 +32,6 @@ using System.Reflection;
32using System.Threading; 32using System.Threading;
33using log4net.Config; 33using log4net.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenSim.Framework; 36using OpenSim.Framework;
38using Nini.Config; 37using Nini.Config;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index 971a56f..41dbffb 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -225,17 +225,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
225 if (destination == null) 225 if (destination == null)
226 return false; 226 return false;
227 227
228 // We limit the number of messages sent for a position change to just one per
229 // simulator so when we receive the update we need to hand it to each of the
230 // scenes; scenes each check to see if the is a scene presence for the avatar
231 // note that we really don't need the GridRegion for this call
228 foreach (Scene s in m_sceneList) 232 foreach (Scene s in m_sceneList)
229 { 233 {
230 if (s.RegionInfo.RegionHandle == destination.RegionHandle) 234 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
231 { 235 s.IncomingChildAgentDataUpdate(cAgentData);
232 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
233 s.IncomingChildAgentDataUpdate(cAgentData);
234 return true;
235 }
236 } 236 }
237 //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); 237 //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate");
238 return false; 238 return true;
239 } 239 }
240 240
241 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) 241 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
@@ -257,15 +257,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
257 return false; 257 return false;
258 } 258 }
259 259
260 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position) 260 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string reason)
261 { 261 {
262 reason = "Communications failure";
262 if (destination == null) 263 if (destination == null)
263 return false; 264 return false;
264 265
265 foreach (Scene s in m_sceneList) 266 foreach (Scene s in m_sceneList)
266 { 267 {
267 if (s.RegionInfo.RegionID == destination.RegionID) 268 if (s.RegionInfo.RegionID == destination.RegionID)
268 return s.QueryAccess(id, position); 269 return s.QueryAccess(id, position, out reason);
269 } 270 }
270 return false; 271 return false;
271 } 272 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
index e8a6629..97833f3 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -192,15 +192,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
192 return false; 192 return false;
193 193
194 // Try local first 194 // Try local first
195 if (m_localBackend.UpdateAgent(destination, cAgentData)) 195 if (m_localBackend.IsLocalRegion(destination.RegionHandle))
196 return true; 196 return m_localBackend.UpdateAgent(destination, cAgentData);
197
198 // else do the remote thing
199 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
200 return m_remoteConnector.UpdateAgent(destination, cAgentData);
201
202 return false;
203 197
198 return m_remoteConnector.UpdateAgent(destination, cAgentData);
204 } 199 }
205 200
206 public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) 201 public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData)
@@ -209,15 +204,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
209 return false; 204 return false;
210 205
211 // Try local first 206 // Try local first
212 if (m_localBackend.UpdateAgent(destination, cAgentData)) 207 if (m_localBackend.IsLocalRegion(destination.RegionHandle))
213 return true; 208 return m_localBackend.UpdateAgent(destination, cAgentData);
214
215 // else do the remote thing
216 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
217 return m_remoteConnector.UpdateAgent(destination, cAgentData);
218
219 return false;
220 209
210 return m_remoteConnector.UpdateAgent(destination, cAgentData);
221 } 211 }
222 212
223 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) 213 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
@@ -239,18 +229,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
239 229
240 } 230 }
241 231
242 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position) 232 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string reason)
243 { 233 {
234 reason = "Communications failure";
244 if (destination == null) 235 if (destination == null)
245 return false; 236 return false;
246 237
247 // Try local first 238 // Try local first
248 if (m_localBackend.QueryAccess(destination, id, position)) 239 if (m_localBackend.QueryAccess(destination, id, position, out reason))
249 return true; 240 return true;
250 241
251 // else do the remote thing 242 // else do the remote thing
252 if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) 243 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
253 return m_remoteConnector.QueryAccess(destination, id, position); 244 return m_remoteConnector.QueryAccess(destination, id, position, out reason);
254 245
255 return false; 246 return false;
256 247
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 04b6e3d..e2760a2 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -32,7 +32,6 @@ using System.Reflection;
32using System.Threading; 32using System.Threading;
33using log4net.Config; 33using log4net.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenMetaverse.Assets; 36using OpenMetaverse.Assets;
38using OpenSim.Framework; 37using OpenSim.Framework;
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs
new file mode 100644
index 0000000..f6d1a82
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs
@@ -0,0 +1,224 @@
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 System.IO;
31using System.Reflection;
32using System.Security;
33using System.Text;
34using log4net;
35using Nini.Config;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Console;
39using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes;
42
43namespace OpenSim.Region.CoreModules.World.Estate
44{
45 /// <summary>
46 /// Estate management console commands.
47 /// </summary>
48 public class EstateManagementCommands
49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51
52 protected EstateManagementModule m_module;
53
54 protected Commander m_commander = new Commander("estate");
55
56 public EstateManagementCommands(EstateManagementModule module)
57 {
58 m_module = module;
59 }
60
61 public void Initialise()
62 {
63 m_log.DebugFormat("[ESTATE MODULE]: Setting up estate commands for region {0}", m_module.Scene.RegionInfo.RegionName);
64
65 m_module.Scene.AddCommand(m_module, "set terrain texture",
66 "set terrain texture <number> <uuid> [<x>] [<y>]",
67 "Sets the terrain <number> to <uuid>, if <x> or <y> are specified, it will only " +
68 "set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
69 " that coordinate.",
70 consoleSetTerrainTexture);
71
72 m_module.Scene.AddCommand(m_module, "set terrain heights",
73 "set terrain heights <corner> <min> <max> [<x>] [<y>]",
74 "Sets the terrain texture heights on corner #<corner> to <min>/<max>, if <x> or <y> are specified, it will only " +
75 "set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
76 " that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3.",
77 consoleSetTerrainHeights);
78
79 Command showCommand
80 = new Command("show", CommandIntentions.COMMAND_STATISTICAL, ShowEstatesCommand, "Shows all estates on the simulator.");
81
82 m_commander.RegisterCommand("show", showCommand);
83
84 m_module.Scene.RegisterModuleCommander(m_commander);
85
86 m_module.Scene.EventManager.OnPluginConsole += EventManagerOnPluginConsole;
87 }
88
89 public void Close()
90 {
91 m_module.Scene.EventManager.OnPluginConsole -= EventManagerOnPluginConsole;
92 m_module.Scene.UnregisterModuleCommander(m_commander.Name);
93 }
94
95 /// <summary>
96 /// Processes commandline input. Do not call directly.
97 /// </summary>
98 /// <param name="args">Commandline arguments</param>
99 protected void EventManagerOnPluginConsole(string[] args)
100 {
101 if (args[0] == "estate")
102 {
103 if (args.Length == 1)
104 {
105 m_commander.ProcessConsoleCommand("help", new string[0]);
106 return;
107 }
108
109 string[] tmpArgs = new string[args.Length - 2];
110 int i;
111 for (i = 2; i < args.Length; i++)
112 tmpArgs[i - 2] = args[i];
113
114 m_commander.ProcessConsoleCommand(args[1], tmpArgs);
115 }
116 }
117
118 protected void consoleSetTerrainTexture(string module, string[] args)
119 {
120 string num = args[3];
121 string uuid = args[4];
122 int x = (args.Length > 5 ? int.Parse(args[5]) : -1);
123 int y = (args.Length > 6 ? int.Parse(args[6]) : -1);
124
125 if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x)
126 {
127 if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y)
128 {
129 int corner = int.Parse(num);
130 UUID texture = UUID.Parse(uuid);
131
132 m_log.Debug("[ESTATEMODULE]: Setting terrain textures for " + m_module.Scene.RegionInfo.RegionName +
133 string.Format(" (C#{0} = {1})", corner, texture));
134
135 switch (corner)
136 {
137 case 0:
138 m_module.Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
139 break;
140 case 1:
141 m_module.Scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
142 break;
143 case 2:
144 m_module.Scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
145 break;
146 case 3:
147 m_module.Scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
148 break;
149 }
150
151 m_module.Scene.RegionInfo.RegionSettings.Save();
152 m_module.TriggerRegionInfoChange();
153 m_module.sendRegionInfoPacketToAll();
154 }
155 }
156 }
157
158 protected void consoleSetTerrainHeights(string module, string[] args)
159 {
160 string num = args[3];
161 string min = args[4];
162 string max = args[5];
163 int x = (args.Length > 6 ? int.Parse(args[6]) : -1);
164 int y = (args.Length > 7 ? int.Parse(args[7]) : -1);
165
166 if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x)
167 {
168 if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y)
169 {
170 int corner = int.Parse(num);
171 float lowValue = float.Parse(min, Culture.NumberFormatInfo);
172 float highValue = float.Parse(max, Culture.NumberFormatInfo);
173
174 m_log.Debug("[ESTATEMODULE]: Setting terrain heights " + m_module.Scene.RegionInfo.RegionName +
175 string.Format(" (C{0}, {1}-{2}", corner, lowValue, highValue));
176
177 switch (corner)
178 {
179 case 0:
180 m_module.Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
181 m_module.Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
182 break;
183 case 1:
184 m_module.Scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
185 m_module.Scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
186 break;
187 case 2:
188 m_module.Scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
189 m_module.Scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
190 break;
191 case 3:
192 m_module.Scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
193 m_module.Scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
194 break;
195 }
196
197 m_module.Scene.RegionInfo.RegionSettings.Save();
198 m_module.TriggerRegionInfoChange();
199 m_module.sendRegionHandshakeToAll();
200 }
201 }
202 }
203
204 protected void ShowEstatesCommand(Object[] args)
205 {
206 StringBuilder report = new StringBuilder();
207 RegionInfo ri = m_module.Scene.RegionInfo;
208 EstateSettings es = ri.EstateSettings;
209
210 report.AppendFormat("Estate information for region {0}\n", ri.RegionName);
211 report.AppendFormat(
212 "{0,-20} {1,-7} {2,-20}\n",
213 "Estate Name",
214 "ID",
215 "Owner");
216
217 report.AppendFormat(
218 "{0,-20} {1,-7} {2,-20}\n",
219 es.EstateName, es.EstateID, m_module.UserManager.GetUserName(es.EstateOwner));
220
221 MainConsole.Instance.Output(report.ToString());
222 }
223 }
224} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 3653842..c146b72 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -24,6 +24,7 @@
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27
27using System; 28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using System.IO; 30using System.IO;
@@ -31,6 +32,7 @@ using System.Reflection;
31using System.Security; 32using System.Security;
32using System.Timers; 33using System.Timers;
33using log4net; 34using log4net;
35using Mono.Addins;
34using Nini.Config; 36using Nini.Config;
35using OpenMetaverse; 37using OpenMetaverse;
36using OpenSim.Framework; 38using OpenSim.Framework;
@@ -39,14 +41,18 @@ using OpenSim.Region.Framework.Scenes;
39 41
40namespace OpenSim.Region.CoreModules.World.Estate 42namespace OpenSim.Region.CoreModules.World.Estate
41{ 43{
42 public class EstateManagementModule : IEstateModule 44 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EstateManagementModule")]
45 public class EstateManagementModule : IEstateModule, INonSharedRegionModule
43 { 46 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 48
46 private delegate void LookupUUIDS(List<UUID> uuidLst); 49 private delegate void LookupUUIDS(List<UUID> uuidLst);
47 50
48 private Scene m_scene;
49 private Timer m_regionChangeTimer = new Timer(); 51 private Timer m_regionChangeTimer = new Timer();
52 public Scene Scene { get; private set; }
53 public IUserManagement UserManager { get; private set; }
54
55 protected EstateManagementCommands m_commands;
50 56
51 private EstateTerrainXferHandler TerrainUploader; 57 private EstateTerrainXferHandler TerrainUploader;
52 58
@@ -60,89 +66,89 @@ namespace OpenSim.Region.CoreModules.World.Estate
60 { 66 {
61 uint sun = 0; 67 uint sun = 0;
62 68
63 if (!m_scene.RegionInfo.EstateSettings.UseGlobalTime) 69 if (!Scene.RegionInfo.EstateSettings.UseGlobalTime)
64 sun=(uint)(m_scene.RegionInfo.EstateSettings.SunPosition*1024.0) + 0x1800; 70 sun = (uint)(Scene.RegionInfo.EstateSettings.SunPosition * 1024.0) + 0x1800;
65 UUID estateOwner; 71 UUID estateOwner;
66 estateOwner = m_scene.RegionInfo.EstateSettings.EstateOwner; 72 estateOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
67 73
68 if (m_scene.Permissions.IsGod(remote_client.AgentId)) 74 if (Scene.Permissions.IsGod(remote_client.AgentId))
69 estateOwner = remote_client.AgentId; 75 estateOwner = remote_client.AgentId;
70 76
71 remote_client.SendDetailedEstateData(invoice, 77 remote_client.SendDetailedEstateData(invoice,
72 m_scene.RegionInfo.EstateSettings.EstateName, 78 Scene.RegionInfo.EstateSettings.EstateName,
73 m_scene.RegionInfo.EstateSettings.EstateID, 79 Scene.RegionInfo.EstateSettings.EstateID,
74 m_scene.RegionInfo.EstateSettings.ParentEstateID, 80 Scene.RegionInfo.EstateSettings.ParentEstateID,
75 GetEstateFlags(), 81 GetEstateFlags(),
76 sun, 82 sun,
77 m_scene.RegionInfo.RegionSettings.Covenant, 83 Scene.RegionInfo.RegionSettings.Covenant,
78 m_scene.RegionInfo.EstateSettings.AbuseEmail, 84 Scene.RegionInfo.EstateSettings.AbuseEmail,
79 estateOwner); 85 estateOwner);
80 86
81 remote_client.SendEstateList(invoice, 87 remote_client.SendEstateList(invoice,
82 (int)Constants.EstateAccessCodex.EstateManagers, 88 (int)Constants.EstateAccessCodex.EstateManagers,
83 m_scene.RegionInfo.EstateSettings.EstateManagers, 89 Scene.RegionInfo.EstateSettings.EstateManagers,
84 m_scene.RegionInfo.EstateSettings.EstateID); 90 Scene.RegionInfo.EstateSettings.EstateID);
85 91
86 remote_client.SendEstateList(invoice, 92 remote_client.SendEstateList(invoice,
87 (int)Constants.EstateAccessCodex.AccessOptions, 93 (int)Constants.EstateAccessCodex.AccessOptions,
88 m_scene.RegionInfo.EstateSettings.EstateAccess, 94 Scene.RegionInfo.EstateSettings.EstateAccess,
89 m_scene.RegionInfo.EstateSettings.EstateID); 95 Scene.RegionInfo.EstateSettings.EstateID);
90 96
91 remote_client.SendEstateList(invoice, 97 remote_client.SendEstateList(invoice,
92 (int)Constants.EstateAccessCodex.AllowedGroups, 98 (int)Constants.EstateAccessCodex.AllowedGroups,
93 m_scene.RegionInfo.EstateSettings.EstateGroups, 99 Scene.RegionInfo.EstateSettings.EstateGroups,
94 m_scene.RegionInfo.EstateSettings.EstateID); 100 Scene.RegionInfo.EstateSettings.EstateID);
95 101
96 remote_client.SendBannedUserList(invoice, 102 remote_client.SendBannedUserList(invoice,
97 m_scene.RegionInfo.EstateSettings.EstateBans, 103 Scene.RegionInfo.EstateSettings.EstateBans,
98 m_scene.RegionInfo.EstateSettings.EstateID); 104 Scene.RegionInfo.EstateSettings.EstateID);
99 } 105 }
100 106
101 private void estateSetRegionInfoHandler(bool blockTerraform, bool noFly, bool allowDamage, bool blockLandResell, int maxAgents, float objectBonusFactor, 107 private void estateSetRegionInfoHandler(bool blockTerraform, bool noFly, bool allowDamage, bool blockLandResell, int maxAgents, float objectBonusFactor,
102 int matureLevel, bool restrictPushObject, bool allowParcelChanges) 108 int matureLevel, bool restrictPushObject, bool allowParcelChanges)
103 { 109 {
104 if (blockTerraform) 110 if (blockTerraform)
105 m_scene.RegionInfo.RegionSettings.BlockTerraform = true; 111 Scene.RegionInfo.RegionSettings.BlockTerraform = true;
106 else 112 else
107 m_scene.RegionInfo.RegionSettings.BlockTerraform = false; 113 Scene.RegionInfo.RegionSettings.BlockTerraform = false;
108 114
109 if (noFly) 115 if (noFly)
110 m_scene.RegionInfo.RegionSettings.BlockFly = true; 116 Scene.RegionInfo.RegionSettings.BlockFly = true;
111 else 117 else
112 m_scene.RegionInfo.RegionSettings.BlockFly = false; 118 Scene.RegionInfo.RegionSettings.BlockFly = false;
113 119
114 if (allowDamage) 120 if (allowDamage)
115 m_scene.RegionInfo.RegionSettings.AllowDamage = true; 121 Scene.RegionInfo.RegionSettings.AllowDamage = true;
116 else 122 else
117 m_scene.RegionInfo.RegionSettings.AllowDamage = false; 123 Scene.RegionInfo.RegionSettings.AllowDamage = false;
118 124
119 if (blockLandResell) 125 if (blockLandResell)
120 m_scene.RegionInfo.RegionSettings.AllowLandResell = false; 126 Scene.RegionInfo.RegionSettings.AllowLandResell = false;
121 else 127 else
122 m_scene.RegionInfo.RegionSettings.AllowLandResell = true; 128 Scene.RegionInfo.RegionSettings.AllowLandResell = true;
123 129
124 m_scene.RegionInfo.RegionSettings.AgentLimit = (byte) maxAgents; 130 Scene.RegionInfo.RegionSettings.AgentLimit = (byte) maxAgents;
125 131
126 m_scene.RegionInfo.RegionSettings.ObjectBonus = objectBonusFactor; 132 Scene.RegionInfo.RegionSettings.ObjectBonus = objectBonusFactor;
127 133
128 if (matureLevel <= 13) 134 if (matureLevel <= 13)
129 m_scene.RegionInfo.RegionSettings.Maturity = 0; 135 Scene.RegionInfo.RegionSettings.Maturity = 0;
130 else if (matureLevel <= 21) 136 else if (matureLevel <= 21)
131 m_scene.RegionInfo.RegionSettings.Maturity = 1; 137 Scene.RegionInfo.RegionSettings.Maturity = 1;
132 else 138 else
133 m_scene.RegionInfo.RegionSettings.Maturity = 2; 139 Scene.RegionInfo.RegionSettings.Maturity = 2;
134 140
135 if (restrictPushObject) 141 if (restrictPushObject)
136 m_scene.RegionInfo.RegionSettings.RestrictPushing = true; 142 Scene.RegionInfo.RegionSettings.RestrictPushing = true;
137 else 143 else
138 m_scene.RegionInfo.RegionSettings.RestrictPushing = false; 144 Scene.RegionInfo.RegionSettings.RestrictPushing = false;
139 145
140 if (allowParcelChanges) 146 if (allowParcelChanges)
141 m_scene.RegionInfo.RegionSettings.AllowLandJoinDivide = true; 147 Scene.RegionInfo.RegionSettings.AllowLandJoinDivide = true;
142 else 148 else
143 m_scene.RegionInfo.RegionSettings.AllowLandJoinDivide = false; 149 Scene.RegionInfo.RegionSettings.AllowLandJoinDivide = false;
144 150
145 m_scene.RegionInfo.RegionSettings.Save(); 151 Scene.RegionInfo.RegionSettings.Save();
146 TriggerRegionInfoChange(); 152 TriggerRegionInfoChange();
147 153
148 sendRegionInfoPacketToAll(); 154 sendRegionInfoPacketToAll();
@@ -156,19 +162,19 @@ namespace OpenSim.Region.CoreModules.World.Estate
156 switch (corner) 162 switch (corner)
157 { 163 {
158 case 0: 164 case 0:
159 m_scene.RegionInfo.RegionSettings.TerrainTexture1 = texture; 165 Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
160 break; 166 break;
161 case 1: 167 case 1:
162 m_scene.RegionInfo.RegionSettings.TerrainTexture2 = texture; 168 Scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
163 break; 169 break;
164 case 2: 170 case 2:
165 m_scene.RegionInfo.RegionSettings.TerrainTexture3 = texture; 171 Scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
166 break; 172 break;
167 case 3: 173 case 3:
168 m_scene.RegionInfo.RegionSettings.TerrainTexture4 = texture; 174 Scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
169 break; 175 break;
170 } 176 }
171 m_scene.RegionInfo.RegionSettings.Save(); 177 Scene.RegionInfo.RegionSettings.Save();
172 TriggerRegionInfoChange(); 178 TriggerRegionInfoChange();
173 sendRegionInfoPacketToAll(); 179 sendRegionInfoPacketToAll();
174 } 180 }
@@ -178,23 +184,23 @@ namespace OpenSim.Region.CoreModules.World.Estate
178 switch (corner) 184 switch (corner)
179 { 185 {
180 case 0: 186 case 0:
181 m_scene.RegionInfo.RegionSettings.Elevation1SW = lowValue; 187 Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
182 m_scene.RegionInfo.RegionSettings.Elevation2SW = highValue; 188 Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
183 break; 189 break;
184 case 1: 190 case 1:
185 m_scene.RegionInfo.RegionSettings.Elevation1NW = lowValue; 191 Scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
186 m_scene.RegionInfo.RegionSettings.Elevation2NW = highValue; 192 Scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
187 break; 193 break;
188 case 2: 194 case 2:
189 m_scene.RegionInfo.RegionSettings.Elevation1SE = lowValue; 195 Scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
190 m_scene.RegionInfo.RegionSettings.Elevation2SE = highValue; 196 Scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
191 break; 197 break;
192 case 3: 198 case 3:
193 m_scene.RegionInfo.RegionSettings.Elevation1NE = lowValue; 199 Scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
194 m_scene.RegionInfo.RegionSettings.Elevation2NE = highValue; 200 Scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
195 break; 201 break;
196 } 202 }
197 m_scene.RegionInfo.RegionSettings.Save(); 203 Scene.RegionInfo.RegionSettings.Save();
198 TriggerRegionInfoChange(); 204 TriggerRegionInfoChange();
199 sendRegionInfoPacketToAll(); 205 sendRegionInfoPacketToAll();
200 } 206 }
@@ -210,30 +216,30 @@ namespace OpenSim.Region.CoreModules.World.Estate
210 bool UseGlobal, bool EstateFixedSun, float EstateSunHour) 216 bool UseGlobal, bool EstateFixedSun, float EstateSunHour)
211 { 217 {
212 // Water Height 218 // Water Height
213 m_scene.RegionInfo.RegionSettings.WaterHeight = WaterHeight; 219 Scene.RegionInfo.RegionSettings.WaterHeight = WaterHeight;
214 220
215 // Terraforming limits 221 // Terraforming limits
216 m_scene.RegionInfo.RegionSettings.TerrainRaiseLimit = TerrainRaiseLimit; 222 Scene.RegionInfo.RegionSettings.TerrainRaiseLimit = TerrainRaiseLimit;
217 m_scene.RegionInfo.RegionSettings.TerrainLowerLimit = TerrainLowerLimit; 223 Scene.RegionInfo.RegionSettings.TerrainLowerLimit = TerrainLowerLimit;
218 224
219 // Time of day / fixed sun 225 // Time of day / fixed sun
220 m_scene.RegionInfo.RegionSettings.UseEstateSun = UseEstateSun; 226 Scene.RegionInfo.RegionSettings.UseEstateSun = UseEstateSun;
221 m_scene.RegionInfo.RegionSettings.FixedSun = UseFixedSun; 227 Scene.RegionInfo.RegionSettings.FixedSun = UseFixedSun;
222 m_scene.RegionInfo.RegionSettings.SunPosition = SunHour; 228 Scene.RegionInfo.RegionSettings.SunPosition = SunHour;
223 229
224 m_scene.TriggerEstateSunUpdate(); 230 Scene.TriggerEstateSunUpdate();
225 231
226 //m_log.Debug("[ESTATE]: UFS: " + UseFixedSun.ToString()); 232 //m_log.Debug("[ESTATE]: UFS: " + UseFixedSun.ToString());
227 //m_log.Debug("[ESTATE]: SunHour: " + SunHour.ToString()); 233 //m_log.Debug("[ESTATE]: SunHour: " + SunHour.ToString());
228 234
229 sendRegionInfoPacketToAll(); 235 sendRegionInfoPacketToAll();
230 m_scene.RegionInfo.RegionSettings.Save(); 236 Scene.RegionInfo.RegionSettings.Save();
231 TriggerRegionInfoChange(); 237 TriggerRegionInfoChange();
232 } 238 }
233 239
234 private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds) 240 private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds)
235 { 241 {
236 IRestartModule restartModule = m_scene.RequestModuleInterface<IRestartModule>(); 242 IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>();
237 if (restartModule != null) 243 if (restartModule != null)
238 { 244 {
239 List<int> times = new List<int>(); 245 List<int> times = new List<int>();
@@ -254,8 +260,8 @@ namespace OpenSim.Region.CoreModules.World.Estate
254 260
255 private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID) 261 private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID)
256 { 262 {
257 m_scene.RegionInfo.RegionSettings.Covenant = estateCovenantID; 263 Scene.RegionInfo.RegionSettings.Covenant = estateCovenantID;
258 m_scene.RegionInfo.RegionSettings.Save(); 264 Scene.RegionInfo.RegionSettings.Save();
259 TriggerRegionInfoChange(); 265 TriggerRegionInfoChange();
260 } 266 }
261 267
@@ -263,17 +269,17 @@ namespace OpenSim.Region.CoreModules.World.Estate
263 { 269 {
264 // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc. 270 // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc.
265 271
266 if (user == m_scene.RegionInfo.EstateSettings.EstateOwner) 272 if (user == Scene.RegionInfo.EstateSettings.EstateOwner)
267 return; // never process EO 273 return; // never process EO
268 274
269 if ((estateAccessType & 4) != 0) // User add 275 if ((estateAccessType & 4) != 0) // User add
270 { 276 {
271 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions()) 277 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
272 { 278 {
273 m_scene.RegionInfo.EstateSettings.AddEstateUser(user); 279 Scene.RegionInfo.EstateSettings.AddEstateUser(user);
274 m_scene.RegionInfo.EstateSettings.Save(); 280 Scene.RegionInfo.EstateSettings.Save();
275 TriggerEstateInfoChange(); 281 TriggerEstateInfoChange();
276 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, m_scene.RegionInfo.EstateSettings.EstateAccess, m_scene.RegionInfo.EstateSettings.EstateID); 282 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
277 } 283 }
278 else 284 else
279 { 285 {
@@ -283,13 +289,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
283 } 289 }
284 if ((estateAccessType & 8) != 0) // User remove 290 if ((estateAccessType & 8) != 0) // User remove
285 { 291 {
286 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions()) 292 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
287 { 293 {
288 m_scene.RegionInfo.EstateSettings.RemoveEstateUser(user); 294 Scene.RegionInfo.EstateSettings.RemoveEstateUser(user);
289 m_scene.RegionInfo.EstateSettings.Save(); 295 Scene.RegionInfo.EstateSettings.Save();
290 TriggerEstateInfoChange(); 296 TriggerEstateInfoChange();
291 297
292 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, m_scene.RegionInfo.EstateSettings.EstateAccess, m_scene.RegionInfo.EstateSettings.EstateID); 298 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
293 } 299 }
294 else 300 else
295 { 301 {
@@ -298,12 +304,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
298 } 304 }
299 if ((estateAccessType & 16) != 0) // Group add 305 if ((estateAccessType & 16) != 0) // Group add
300 { 306 {
301 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions()) 307 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
302 { 308 {
303 m_scene.RegionInfo.EstateSettings.AddEstateGroup(user); 309 Scene.RegionInfo.EstateSettings.AddEstateGroup(user);
304 m_scene.RegionInfo.EstateSettings.Save(); 310 Scene.RegionInfo.EstateSettings.Save();
305 TriggerEstateInfoChange(); 311 TriggerEstateInfoChange();
306 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, m_scene.RegionInfo.EstateSettings.EstateGroups, m_scene.RegionInfo.EstateSettings.EstateID); 312 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
307 } 313 }
308 else 314 else
309 { 315 {
@@ -312,13 +318,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
312 } 318 }
313 if ((estateAccessType & 32) != 0) // Group remove 319 if ((estateAccessType & 32) != 0) // Group remove
314 { 320 {
315 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions()) 321 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
316 { 322 {
317 m_scene.RegionInfo.EstateSettings.RemoveEstateGroup(user); 323 Scene.RegionInfo.EstateSettings.RemoveEstateGroup(user);
318 m_scene.RegionInfo.EstateSettings.Save(); 324 Scene.RegionInfo.EstateSettings.Save();
319 TriggerEstateInfoChange(); 325 TriggerEstateInfoChange();
320 326
321 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, m_scene.RegionInfo.EstateSettings.EstateGroups, m_scene.RegionInfo.EstateSettings.EstateID); 327 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
322 } 328 }
323 else 329 else
324 { 330 {
@@ -327,9 +333,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
327 } 333 }
328 if ((estateAccessType & 64) != 0) // Ban add 334 if ((estateAccessType & 64) != 0) // Ban add
329 { 335 {
330 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions()) 336 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || Scene.Permissions.BypassPermissions())
331 { 337 {
332 EstateBan[] banlistcheck = m_scene.RegionInfo.EstateSettings.EstateBans; 338 EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
333 339
334 bool alreadyInList = false; 340 bool alreadyInList = false;
335 341
@@ -348,20 +354,20 @@ namespace OpenSim.Region.CoreModules.World.Estate
348 EstateBan item = new EstateBan(); 354 EstateBan item = new EstateBan();
349 355
350 item.BannedUserID = user; 356 item.BannedUserID = user;
351 item.EstateID = m_scene.RegionInfo.EstateSettings.EstateID; 357 item.EstateID = Scene.RegionInfo.EstateSettings.EstateID;
352 item.BannedHostAddress = "0.0.0.0"; 358 item.BannedHostAddress = "0.0.0.0";
353 item.BannedHostIPMask = "0.0.0.0"; 359 item.BannedHostIPMask = "0.0.0.0";
354 360
355 m_scene.RegionInfo.EstateSettings.AddBan(item); 361 Scene.RegionInfo.EstateSettings.AddBan(item);
356 m_scene.RegionInfo.EstateSettings.Save(); 362 Scene.RegionInfo.EstateSettings.Save();
357 TriggerEstateInfoChange(); 363 TriggerEstateInfoChange();
358 364
359 ScenePresence s = m_scene.GetScenePresence(user); 365 ScenePresence s = Scene.GetScenePresence(user);
360 if (s != null) 366 if (s != null)
361 { 367 {
362 if (!s.IsChildAgent) 368 if (!s.IsChildAgent)
363 { 369 {
364 if (!m_scene.TeleportClientHome(user, s.ControllingClient)) 370 if (!Scene.TeleportClientHome(user, s.ControllingClient))
365 { 371 {
366 s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out."); 372 s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out.");
367 s.ControllingClient.Close(); 373 s.ControllingClient.Close();
@@ -374,8 +380,8 @@ namespace OpenSim.Region.CoreModules.World.Estate
374 { 380 {
375 remote_client.SendAlertMessage("User is already on the region ban list"); 381 remote_client.SendAlertMessage("User is already on the region ban list");
376 } 382 }
377 //m_scene.RegionInfo.regionBanlist.Add(Manager(user); 383 //Scene.RegionInfo.regionBanlist.Add(Manager(user);
378 remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.EstateSettings.EstateBans, m_scene.RegionInfo.EstateSettings.EstateID); 384 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
379 } 385 }
380 else 386 else
381 { 387 {
@@ -384,9 +390,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
384 } 390 }
385 if ((estateAccessType & 128) != 0) // Ban remove 391 if ((estateAccessType & 128) != 0) // Ban remove
386 { 392 {
387 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions()) 393 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || Scene.Permissions.BypassPermissions())
388 { 394 {
389 EstateBan[] banlistcheck = m_scene.RegionInfo.EstateSettings.EstateBans; 395 EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
390 396
391 bool alreadyInList = false; 397 bool alreadyInList = false;
392 EstateBan listitem = null; 398 EstateBan listitem = null;
@@ -399,20 +405,21 @@ namespace OpenSim.Region.CoreModules.World.Estate
399 listitem = banlistcheck[i]; 405 listitem = banlistcheck[i];
400 break; 406 break;
401 } 407 }
402
403 } 408 }
409
404 if (alreadyInList && listitem != null) 410 if (alreadyInList && listitem != null)
405 { 411 {
406 m_scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID); 412 Scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID);
407 m_scene.RegionInfo.EstateSettings.Save(); 413 Scene.RegionInfo.EstateSettings.Save();
408 TriggerEstateInfoChange(); 414 TriggerEstateInfoChange();
409 } 415 }
410 else 416 else
411 { 417 {
412 remote_client.SendAlertMessage("User is not on the region ban list"); 418 remote_client.SendAlertMessage("User is not on the region ban list");
413 } 419 }
414 //m_scene.RegionInfo.regionBanlist.Add(Manager(user); 420
415 remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.EstateSettings.EstateBans, m_scene.RegionInfo.EstateSettings.EstateID); 421 //Scene.RegionInfo.regionBanlist.Add(Manager(user);
422 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
416 } 423 }
417 else 424 else
418 { 425 {
@@ -421,12 +428,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
421 } 428 }
422 if ((estateAccessType & 256) != 0) // Manager add 429 if ((estateAccessType & 256) != 0) // Manager add
423 { 430 {
424 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions()) 431 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
425 { 432 {
426 m_scene.RegionInfo.EstateSettings.AddEstateManager(user); 433 Scene.RegionInfo.EstateSettings.AddEstateManager(user);
427 m_scene.RegionInfo.EstateSettings.Save(); 434 Scene.RegionInfo.EstateSettings.Save();
428 TriggerEstateInfoChange(); 435 TriggerEstateInfoChange();
429 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateID); 436 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
430 } 437 }
431 else 438 else
432 { 439 {
@@ -435,13 +442,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
435 } 442 }
436 if ((estateAccessType & 512) != 0) // Manager remove 443 if ((estateAccessType & 512) != 0) // Manager remove
437 { 444 {
438 if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions()) 445 if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
439 { 446 {
440 m_scene.RegionInfo.EstateSettings.RemoveEstateManager(user); 447 Scene.RegionInfo.EstateSettings.RemoveEstateManager(user);
441 m_scene.RegionInfo.EstateSettings.Save(); 448 Scene.RegionInfo.EstateSettings.Save();
442 TriggerEstateInfoChange(); 449 TriggerEstateInfoChange();
443 450
444 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateID); 451 remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
445 } 452 }
446 else 453 else
447 { 454 {
@@ -453,7 +460,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
453 private void SendSimulatorBlueBoxMessage( 460 private void SendSimulatorBlueBoxMessage(
454 IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message) 461 IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
455 { 462 {
456 IDialogModule dm = m_scene.RequestModuleInterface<IDialogModule>(); 463 IDialogModule dm = Scene.RequestModuleInterface<IDialogModule>();
457 464
458 if (dm != null) 465 if (dm != null)
459 dm.SendNotificationToUsersInRegion(senderID, senderName, message); 466 dm.SendNotificationToUsersInRegion(senderID, senderName, message);
@@ -468,38 +475,38 @@ namespace OpenSim.Region.CoreModules.World.Estate
468 private void handleEstateDebugRegionRequest(IClientAPI remote_client, UUID invoice, UUID senderID, bool scripted, bool collisionEvents, bool physics) 475 private void handleEstateDebugRegionRequest(IClientAPI remote_client, UUID invoice, UUID senderID, bool scripted, bool collisionEvents, bool physics)
469 { 476 {
470 if (physics) 477 if (physics)
471 m_scene.RegionInfo.RegionSettings.DisablePhysics = true; 478 Scene.RegionInfo.RegionSettings.DisablePhysics = true;
472 else 479 else
473 m_scene.RegionInfo.RegionSettings.DisablePhysics = false; 480 Scene.RegionInfo.RegionSettings.DisablePhysics = false;
474 481
475 if (scripted) 482 if (scripted)
476 m_scene.RegionInfo.RegionSettings.DisableScripts = true; 483 Scene.RegionInfo.RegionSettings.DisableScripts = true;
477 else 484 else
478 m_scene.RegionInfo.RegionSettings.DisableScripts = false; 485 Scene.RegionInfo.RegionSettings.DisableScripts = false;
479 486
480 if (collisionEvents) 487 if (collisionEvents)
481 m_scene.RegionInfo.RegionSettings.DisableCollisions = true; 488 Scene.RegionInfo.RegionSettings.DisableCollisions = true;
482 else 489 else
483 m_scene.RegionInfo.RegionSettings.DisableCollisions = false; 490 Scene.RegionInfo.RegionSettings.DisableCollisions = false;
484 491
485 492
486 m_scene.RegionInfo.RegionSettings.Save(); 493 Scene.RegionInfo.RegionSettings.Save();
487 TriggerRegionInfoChange(); 494 TriggerRegionInfoChange();
488 495
489 m_scene.SetSceneCoreDebug(scripted, collisionEvents, physics); 496 Scene.SetSceneCoreDebug(scripted, collisionEvents, physics);
490 } 497 }
491 498
492 private void handleEstateTeleportOneUserHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID, UUID prey) 499 private void handleEstateTeleportOneUserHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID, UUID prey)
493 { 500 {
494 if (!m_scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false)) 501 if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
495 return; 502 return;
496 503
497 if (prey != UUID.Zero) 504 if (prey != UUID.Zero)
498 { 505 {
499 ScenePresence s = m_scene.GetScenePresence(prey); 506 ScenePresence s = Scene.GetScenePresence(prey);
500 if (s != null) 507 if (s != null)
501 { 508 {
502 if (!m_scene.TeleportClientHome(prey, s.ControllingClient)) 509 if (!Scene.TeleportClientHome(prey, s.ControllingClient))
503 { 510 {
504 s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out."); 511 s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
505 s.ControllingClient.Close(); 512 s.ControllingClient.Close();
@@ -510,19 +517,19 @@ namespace OpenSim.Region.CoreModules.World.Estate
510 517
511 private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID) 518 private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID)
512 { 519 {
513 if (!m_scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false)) 520 if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
514 return; 521 return;
515 522
516 m_scene.ForEachScenePresence(delegate(ScenePresence sp) 523 Scene.ForEachScenePresence(delegate(ScenePresence sp)
517 { 524 {
518 if (sp.UUID != senderID) 525 if (sp.UUID != senderID)
519 { 526 {
520 ScenePresence p = m_scene.GetScenePresence(sp.UUID); 527 ScenePresence p = Scene.GetScenePresence(sp.UUID);
521 // make sure they are still there, we could be working down a long list 528 // make sure they are still there, we could be working down a long list
522 // Also make sure they are actually in the region 529 // Also make sure they are actually in the region
523 if (p != null && !p.IsChildAgent) 530 if (p != null && !p.IsChildAgent)
524 { 531 {
525 if (!m_scene.TeleportClientHome(p.UUID, p.ControllingClient)) 532 if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient))
526 { 533 {
527 p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out."); 534 p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
528 p.ControllingClient.Close(); 535 p.ControllingClient.Close();
@@ -531,6 +538,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
531 } 538 }
532 }); 539 });
533 } 540 }
541
534 private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID) 542 private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID)
535 { 543 {
536 if (TerrainUploader != null) 544 if (TerrainUploader != null)
@@ -561,11 +569,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
561 TerrainUploader = null; 569 TerrainUploader = null;
562 } 570 }
563 remoteClient.SendAlertMessage("Terrain Upload Complete. Loading...."); 571 remoteClient.SendAlertMessage("Terrain Upload Complete. Loading....");
564 ITerrainModule terr = m_scene.RequestModuleInterface<ITerrainModule>(); 572 ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
565 573
566 if (terr != null) 574 if (terr != null)
567 { 575 {
568 m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + m_scene.RegionInfo.RegionName); 576 m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName);
569 577
570 try 578 try
571 { 579 {
@@ -611,7 +619,6 @@ namespace OpenSim.Region.CoreModules.World.Estate
611 619
612 private void handleUploadTerrain(IClientAPI remote_client, string clientFileName) 620 private void handleUploadTerrain(IClientAPI remote_client, string clientFileName)
613 { 621 {
614
615 if (TerrainUploader == null) 622 if (TerrainUploader == null)
616 { 623 {
617 624
@@ -629,16 +636,16 @@ namespace OpenSim.Region.CoreModules.World.Estate
629 { 636 {
630 remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!"); 637 remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!");
631 } 638 }
632
633 } 639 }
640
634 private void handleTerrainRequest(IClientAPI remote_client, string clientFileName) 641 private void handleTerrainRequest(IClientAPI remote_client, string clientFileName)
635 { 642 {
636 // Save terrain here 643 // Save terrain here
637 ITerrainModule terr = m_scene.RequestModuleInterface<ITerrainModule>(); 644 ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
638 645
639 if (terr != null) 646 if (terr != null)
640 { 647 {
641 m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + m_scene.RegionInfo.RegionName); 648 m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName);
642 if (File.Exists(Util.dataDir() + "/terrain.raw")) 649 if (File.Exists(Util.dataDir() + "/terrain.raw"))
643 { 650 {
644 File.Delete(Util.dataDir() + "/terrain.raw"); 651 File.Delete(Util.dataDir() + "/terrain.raw");
@@ -649,7 +656,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
649 byte[] bdata = new byte[input.Length]; 656 byte[] bdata = new byte[input.Length];
650 input.Read(bdata, 0, (int)input.Length); 657 input.Read(bdata, 0, (int)input.Length);
651 remote_client.SendAlertMessage("Terrain file written, starting download..."); 658 remote_client.SendAlertMessage("Terrain file written, starting download...");
652 m_scene.XferManager.AddNewFile("terrain.raw", bdata); 659 Scene.XferManager.AddNewFile("terrain.raw", bdata);
653 // Tell client about it 660 // Tell client about it
654 m_log.Warn("[CLIENT]: Sending Terrain to " + remote_client.Name); 661 m_log.Warn("[CLIENT]: Sending Terrain to " + remote_client.Name);
655 remote_client.SendInitiateDownload("terrain.raw", clientFileName); 662 remote_client.SendInitiateDownload("terrain.raw", clientFileName);
@@ -659,35 +666,35 @@ namespace OpenSim.Region.CoreModules.World.Estate
659 private void HandleRegionInfoRequest(IClientAPI remote_client) 666 private void HandleRegionInfoRequest(IClientAPI remote_client)
660 { 667 {
661 RegionInfoForEstateMenuArgs args = new RegionInfoForEstateMenuArgs(); 668 RegionInfoForEstateMenuArgs args = new RegionInfoForEstateMenuArgs();
662 args.billableFactor = m_scene.RegionInfo.EstateSettings.BillableFactor; 669 args.billableFactor = Scene.RegionInfo.EstateSettings.BillableFactor;
663 args.estateID = m_scene.RegionInfo.EstateSettings.EstateID; 670 args.estateID = Scene.RegionInfo.EstateSettings.EstateID;
664 args.maxAgents = (byte)m_scene.RegionInfo.RegionSettings.AgentLimit; 671 args.maxAgents = (byte)Scene.RegionInfo.RegionSettings.AgentLimit;
665 args.objectBonusFactor = (float)m_scene.RegionInfo.RegionSettings.ObjectBonus; 672 args.objectBonusFactor = (float)Scene.RegionInfo.RegionSettings.ObjectBonus;
666 args.parentEstateID = m_scene.RegionInfo.EstateSettings.ParentEstateID; 673 args.parentEstateID = Scene.RegionInfo.EstateSettings.ParentEstateID;
667 args.pricePerMeter = m_scene.RegionInfo.EstateSettings.PricePerMeter; 674 args.pricePerMeter = Scene.RegionInfo.EstateSettings.PricePerMeter;
668 args.redirectGridX = m_scene.RegionInfo.EstateSettings.RedirectGridX; 675 args.redirectGridX = Scene.RegionInfo.EstateSettings.RedirectGridX;
669 args.redirectGridY = m_scene.RegionInfo.EstateSettings.RedirectGridY; 676 args.redirectGridY = Scene.RegionInfo.EstateSettings.RedirectGridY;
670 args.regionFlags = GetRegionFlags(); 677 args.regionFlags = GetRegionFlags();
671 args.simAccess = m_scene.RegionInfo.AccessLevel; 678 args.simAccess = Scene.RegionInfo.AccessLevel;
672 args.sunHour = (float)m_scene.RegionInfo.RegionSettings.SunPosition; 679 args.sunHour = (float)Scene.RegionInfo.RegionSettings.SunPosition;
673 args.terrainLowerLimit = (float)m_scene.RegionInfo.RegionSettings.TerrainLowerLimit; 680 args.terrainLowerLimit = (float)Scene.RegionInfo.RegionSettings.TerrainLowerLimit;
674 args.terrainRaiseLimit = (float)m_scene.RegionInfo.RegionSettings.TerrainRaiseLimit; 681 args.terrainRaiseLimit = (float)Scene.RegionInfo.RegionSettings.TerrainRaiseLimit;
675 args.useEstateSun = m_scene.RegionInfo.RegionSettings.UseEstateSun; 682 args.useEstateSun = Scene.RegionInfo.RegionSettings.UseEstateSun;
676 args.waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight; 683 args.waterHeight = (float)Scene.RegionInfo.RegionSettings.WaterHeight;
677 args.simName = m_scene.RegionInfo.RegionName; 684 args.simName = Scene.RegionInfo.RegionName;
678 args.regionType = m_scene.RegionInfo.RegionType; 685 args.regionType = Scene.RegionInfo.RegionType;
679 686
680 remote_client.SendRegionInfoToEstateMenu(args); 687 remote_client.SendRegionInfoToEstateMenu(args);
681 } 688 }
682 689
683 private void HandleEstateCovenantRequest(IClientAPI remote_client) 690 private void HandleEstateCovenantRequest(IClientAPI remote_client)
684 { 691 {
685 remote_client.SendEstateCovenantInformation(m_scene.RegionInfo.RegionSettings.Covenant); 692 remote_client.SendEstateCovenantInformation(Scene.RegionInfo.RegionSettings.Covenant);
686 } 693 }
687 694
688 private void HandleLandStatRequest(int parcelID, uint reportType, uint requestFlags, string filter, IClientAPI remoteClient) 695 private void HandleLandStatRequest(int parcelID, uint reportType, uint requestFlags, string filter, IClientAPI remoteClient)
689 { 696 {
690 if (!m_scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false)) 697 if (!Scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false))
691 return; 698 return;
692 699
693 Dictionary<uint, float> SceneData = new Dictionary<uint,float>(); 700 Dictionary<uint, float> SceneData = new Dictionary<uint,float>();
@@ -695,11 +702,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
695 702
696 if (reportType == 1) 703 if (reportType == 1)
697 { 704 {
698 SceneData = m_scene.PhysicsScene.GetTopColliders(); 705 SceneData = Scene.PhysicsScene.GetTopColliders();
699 } 706 }
700 else if (reportType == 0) 707 else if (reportType == 0)
701 { 708 {
702 SceneData = m_scene.SceneGraph.GetTopScripts(); 709 SceneData = Scene.SceneGraph.GetTopScripts();
703 } 710 }
704 711
705 List<LandStatReportItem> SceneReport = new List<LandStatReportItem>(); 712 List<LandStatReportItem> SceneReport = new List<LandStatReportItem>();
@@ -707,7 +714,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
707 { 714 {
708 foreach (uint obj in SceneData.Keys) 715 foreach (uint obj in SceneData.Keys)
709 { 716 {
710 SceneObjectPart prt = m_scene.GetSceneObjectPart(obj); 717 SceneObjectPart prt = Scene.GetSceneObjectPart(obj);
711 if (prt != null) 718 if (prt != null)
712 { 719 {
713 if (prt.ParentGroup != null) 720 if (prt.ParentGroup != null)
@@ -777,9 +784,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
777 784
778 for (int i = 0; i < uuidarr.Length; i++) 785 for (int i = 0; i < uuidarr.Length; i++)
779 { 786 {
780 // string lookupname = m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]); 787 // string lookupname = Scene.CommsManager.UUIDNameRequestString(uuidarr[i]);
781 788
782 IUserManagement userManager = m_scene.RequestModuleInterface<IUserManagement>(); 789 IUserManagement userManager = Scene.RequestModuleInterface<IUserManagement>();
783 if (userManager != null) 790 if (userManager != null)
784 userManager.GetUserName(uuidarr[i]); 791 userManager.GetUserName(uuidarr[i]);
785 792
@@ -794,7 +801,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
794 801
795 public void sendRegionInfoPacketToAll() 802 public void sendRegionInfoPacketToAll()
796 { 803 {
797 m_scene.ForEachScenePresence(delegate(ScenePresence sp) 804 Scene.ForEachScenePresence(delegate(ScenePresence sp)
798 { 805 {
799 if (!sp.IsChildAgent) 806 if (!sp.IsChildAgent)
800 HandleRegionInfoRequest(sp.ControllingClient); 807 HandleRegionInfoRequest(sp.ControllingClient);
@@ -805,99 +812,99 @@ namespace OpenSim.Region.CoreModules.World.Estate
805 { 812 {
806 RegionHandshakeArgs args = new RegionHandshakeArgs(); 813 RegionHandshakeArgs args = new RegionHandshakeArgs();
807 814
808 args.isEstateManager = m_scene.RegionInfo.EstateSettings.IsEstateManager(remoteClient.AgentId); 815 args.isEstateManager = Scene.RegionInfo.EstateSettings.IsEstateManager(remoteClient.AgentId);
809 if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero && m_scene.RegionInfo.EstateSettings.EstateOwner == remoteClient.AgentId) 816 if (Scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero && Scene.RegionInfo.EstateSettings.EstateOwner == remoteClient.AgentId)
810 args.isEstateManager = true; 817 args.isEstateManager = true;
811 818
812 args.billableFactor = m_scene.RegionInfo.EstateSettings.BillableFactor; 819 args.billableFactor = Scene.RegionInfo.EstateSettings.BillableFactor;
813 args.terrainStartHeight0 = (float)m_scene.RegionInfo.RegionSettings.Elevation1SW; 820 args.terrainStartHeight0 = (float)Scene.RegionInfo.RegionSettings.Elevation1SW;
814 args.terrainHeightRange0 = (float)m_scene.RegionInfo.RegionSettings.Elevation2SW; 821 args.terrainHeightRange0 = (float)Scene.RegionInfo.RegionSettings.Elevation2SW;
815 args.terrainStartHeight1 = (float)m_scene.RegionInfo.RegionSettings.Elevation1NW; 822 args.terrainStartHeight1 = (float)Scene.RegionInfo.RegionSettings.Elevation1NW;
816 args.terrainHeightRange1 = (float)m_scene.RegionInfo.RegionSettings.Elevation2NW; 823 args.terrainHeightRange1 = (float)Scene.RegionInfo.RegionSettings.Elevation2NW;
817 args.terrainStartHeight2 = (float)m_scene.RegionInfo.RegionSettings.Elevation1SE; 824 args.terrainStartHeight2 = (float)Scene.RegionInfo.RegionSettings.Elevation1SE;
818 args.terrainHeightRange2 = (float)m_scene.RegionInfo.RegionSettings.Elevation2SE; 825 args.terrainHeightRange2 = (float)Scene.RegionInfo.RegionSettings.Elevation2SE;
819 args.terrainStartHeight3 = (float)m_scene.RegionInfo.RegionSettings.Elevation1NE; 826 args.terrainStartHeight3 = (float)Scene.RegionInfo.RegionSettings.Elevation1NE;
820 args.terrainHeightRange3 = (float)m_scene.RegionInfo.RegionSettings.Elevation2NE; 827 args.terrainHeightRange3 = (float)Scene.RegionInfo.RegionSettings.Elevation2NE;
821 args.simAccess = m_scene.RegionInfo.AccessLevel; 828 args.simAccess = Scene.RegionInfo.AccessLevel;
822 args.waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight; 829 args.waterHeight = (float)Scene.RegionInfo.RegionSettings.WaterHeight;
823 args.regionFlags = GetRegionFlags(); 830 args.regionFlags = GetRegionFlags();
824 args.regionName = m_scene.RegionInfo.RegionName; 831 args.regionName = Scene.RegionInfo.RegionName;
825 args.SimOwner = m_scene.RegionInfo.EstateSettings.EstateOwner; 832 args.SimOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
826 833
827 args.terrainBase0 = UUID.Zero; 834 args.terrainBase0 = UUID.Zero;
828 args.terrainBase1 = UUID.Zero; 835 args.terrainBase1 = UUID.Zero;
829 args.terrainBase2 = UUID.Zero; 836 args.terrainBase2 = UUID.Zero;
830 args.terrainBase3 = UUID.Zero; 837 args.terrainBase3 = UUID.Zero;
831 args.terrainDetail0 = m_scene.RegionInfo.RegionSettings.TerrainTexture1; 838 args.terrainDetail0 = Scene.RegionInfo.RegionSettings.TerrainTexture1;
832 args.terrainDetail1 = m_scene.RegionInfo.RegionSettings.TerrainTexture2; 839 args.terrainDetail1 = Scene.RegionInfo.RegionSettings.TerrainTexture2;
833 args.terrainDetail2 = m_scene.RegionInfo.RegionSettings.TerrainTexture3; 840 args.terrainDetail2 = Scene.RegionInfo.RegionSettings.TerrainTexture3;
834 args.terrainDetail3 = m_scene.RegionInfo.RegionSettings.TerrainTexture4; 841 args.terrainDetail3 = Scene.RegionInfo.RegionSettings.TerrainTexture4;
835 842
836 remoteClient.SendRegionHandshake(m_scene.RegionInfo,args); 843 remoteClient.SendRegionHandshake(Scene.RegionInfo,args);
837 } 844 }
838 845
839 public void sendRegionHandshakeToAll() 846 public void sendRegionHandshakeToAll()
840 { 847 {
841 m_scene.ForEachClient(sendRegionHandshake); 848 Scene.ForEachClient(sendRegionHandshake);
842 } 849 }
843 850
844 public void handleEstateChangeInfo(IClientAPI remoteClient, UUID invoice, UUID senderID, UInt32 parms1, UInt32 parms2) 851 public void handleEstateChangeInfo(IClientAPI remoteClient, UUID invoice, UUID senderID, UInt32 parms1, UInt32 parms2)
845 { 852 {
846 if (parms2 == 0) 853 if (parms2 == 0)
847 { 854 {
848 m_scene.RegionInfo.EstateSettings.UseGlobalTime = true; 855 Scene.RegionInfo.EstateSettings.UseGlobalTime = true;
849 m_scene.RegionInfo.EstateSettings.SunPosition = 0.0; 856 Scene.RegionInfo.EstateSettings.SunPosition = 0.0;
850 } 857 }
851 else 858 else
852 { 859 {
853 m_scene.RegionInfo.EstateSettings.UseGlobalTime = false; 860 Scene.RegionInfo.EstateSettings.UseGlobalTime = false;
854 m_scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0; 861 Scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0;
855 } 862 }
856 863
857 if ((parms1 & 0x00000010) != 0) 864 if ((parms1 & 0x00000010) != 0)
858 m_scene.RegionInfo.EstateSettings.FixedSun = true; 865 Scene.RegionInfo.EstateSettings.FixedSun = true;
859 else 866 else
860 m_scene.RegionInfo.EstateSettings.FixedSun = false; 867 Scene.RegionInfo.EstateSettings.FixedSun = false;
861 868
862 if ((parms1 & 0x00008000) != 0) 869 if ((parms1 & 0x00008000) != 0)
863 m_scene.RegionInfo.EstateSettings.PublicAccess = true; 870 Scene.RegionInfo.EstateSettings.PublicAccess = true;
864 else 871 else
865 m_scene.RegionInfo.EstateSettings.PublicAccess = false; 872 Scene.RegionInfo.EstateSettings.PublicAccess = false;
866 873
867 if ((parms1 & 0x10000000) != 0) 874 if ((parms1 & 0x10000000) != 0)
868 m_scene.RegionInfo.EstateSettings.AllowVoice = true; 875 Scene.RegionInfo.EstateSettings.AllowVoice = true;
869 else 876 else
870 m_scene.RegionInfo.EstateSettings.AllowVoice = false; 877 Scene.RegionInfo.EstateSettings.AllowVoice = false;
871 878
872 if ((parms1 & 0x00100000) != 0) 879 if ((parms1 & 0x00100000) != 0)
873 m_scene.RegionInfo.EstateSettings.AllowDirectTeleport = true; 880 Scene.RegionInfo.EstateSettings.AllowDirectTeleport = true;
874 else 881 else
875 m_scene.RegionInfo.EstateSettings.AllowDirectTeleport = false; 882 Scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
876 883
877 if ((parms1 & 0x00800000) != 0) 884 if ((parms1 & 0x00800000) != 0)
878 m_scene.RegionInfo.EstateSettings.DenyAnonymous = true; 885 Scene.RegionInfo.EstateSettings.DenyAnonymous = true;
879 else 886 else
880 m_scene.RegionInfo.EstateSettings.DenyAnonymous = false; 887 Scene.RegionInfo.EstateSettings.DenyAnonymous = false;
881 888
882 if ((parms1 & 0x01000000) != 0) 889 if ((parms1 & 0x01000000) != 0)
883 m_scene.RegionInfo.EstateSettings.DenyIdentified = true; 890 Scene.RegionInfo.EstateSettings.DenyIdentified = true;
884 else 891 else
885 m_scene.RegionInfo.EstateSettings.DenyIdentified = false; 892 Scene.RegionInfo.EstateSettings.DenyIdentified = false;
886 893
887 if ((parms1 & 0x02000000) != 0) 894 if ((parms1 & 0x02000000) != 0)
888 m_scene.RegionInfo.EstateSettings.DenyTransacted = true; 895 Scene.RegionInfo.EstateSettings.DenyTransacted = true;
889 else 896 else
890 m_scene.RegionInfo.EstateSettings.DenyTransacted = false; 897 Scene.RegionInfo.EstateSettings.DenyTransacted = false;
891 898
892 if ((parms1 & 0x40000000) != 0) 899 if ((parms1 & 0x40000000) != 0)
893 m_scene.RegionInfo.EstateSettings.DenyMinors = true; 900 Scene.RegionInfo.EstateSettings.DenyMinors = true;
894 else 901 else
895 m_scene.RegionInfo.EstateSettings.DenyMinors = false; 902 Scene.RegionInfo.EstateSettings.DenyMinors = false;
896 903
897 m_scene.RegionInfo.EstateSettings.Save(); 904 Scene.RegionInfo.EstateSettings.Save();
898 TriggerEstateInfoChange(); 905 TriggerEstateInfoChange();
899 906
900 m_scene.TriggerEstateSunUpdate(); 907 Scene.TriggerEstateSunUpdate();
901 908
902 sendDetailedEstateData(remoteClient, invoice); 909 sendDetailedEstateData(remoteClient, invoice);
903 } 910 }
@@ -905,140 +912,42 @@ namespace OpenSim.Region.CoreModules.World.Estate
905 #endregion 912 #endregion
906 913
907 #region IRegionModule Members 914 #region IRegionModule Members
915
916 public string Name { get { return "EstateManagementModule"; } }
917
918 public Type ReplaceableInterface { get { return null; } }
908 919
909 public void Initialise(Scene scene, IConfigSource source) 920 public void Initialise(IConfigSource source) {}
921
922 public void AddRegion(Scene scene)
910 { 923 {
911 m_scene = scene;
912 m_scene.RegisterModuleInterface<IEstateModule>(this);
913 m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
914 m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
915 m_regionChangeTimer.AutoReset = false; 924 m_regionChangeTimer.AutoReset = false;
916 m_regionChangeTimer.Interval = 2000; 925 m_regionChangeTimer.Interval = 2000;
917 m_regionChangeTimer.Elapsed += RaiseRegionInfoChange; 926 m_regionChangeTimer.Elapsed += RaiseRegionInfoChange;
918 927
919 m_scene.AddCommand(this, "set terrain texture", 928 Scene = scene;
920 "set terrain texture <number> <uuid> [<x>] [<y>]", 929 Scene.RegisterModuleInterface<IEstateModule>(this);
921 "Sets the terrain <number> to <uuid>, if <x> or <y> are specified, it will only " + 930 Scene.EventManager.OnNewClient += EventManager_OnNewClient;
922 "set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" + 931 Scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
923 " that coordinate.", 932
924 consoleSetTerrainTexture); 933 m_commands = new EstateManagementCommands(this);
925 934 m_commands.Initialise();
926 m_scene.AddCommand(this, "set terrain heights",
927 "set terrain heights <corner> <min> <max> [<x>] [<y>]",
928 "Sets the terrain texture heights on corner #<corner> to <min>/<max>, if <x> or <y> are specified, it will only " +
929 "set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
930 " that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3.",
931 consoleSetTerrainHeights);
932 }
933
934 #region Console Commands
935
936 public void consoleSetTerrainTexture(string module, string[] args)
937 {
938 string num = args[3];
939 string uuid = args[4];
940 int x = (args.Length > 5 ? int.Parse(args[5]) : -1);
941 int y = (args.Length > 6 ? int.Parse(args[6]) : -1);
942
943 if (x == -1 || m_scene.RegionInfo.RegionLocX == x)
944 {
945 if (y == -1 || m_scene.RegionInfo.RegionLocY == y)
946 {
947 int corner = int.Parse(num);
948 UUID texture = UUID.Parse(uuid);
949
950 m_log.Debug("[ESTATEMODULE] Setting terrain textures for " + m_scene.RegionInfo.RegionName +
951 string.Format(" (C#{0} = {1})", corner, texture));
952
953 switch (corner)
954 {
955 case 0:
956 m_scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
957 break;
958 case 1:
959 m_scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
960 break;
961 case 2:
962 m_scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
963 break;
964 case 3:
965 m_scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
966 break;
967 }
968 m_scene.RegionInfo.RegionSettings.Save();
969 TriggerRegionInfoChange();
970 sendRegionInfoPacketToAll();
971
972 }
973 }
974 }
975
976 public void consoleSetTerrainHeights(string module, string[] args)
977 {
978 string num = args[3];
979 string min = args[4];
980 string max = args[5];
981 int x = (args.Length > 6 ? int.Parse(args[6]) : -1);
982 int y = (args.Length > 7 ? int.Parse(args[7]) : -1);
983
984 if (x == -1 || m_scene.RegionInfo.RegionLocX == x)
985 {
986 if (y == -1 || m_scene.RegionInfo.RegionLocY == y)
987 {
988 int corner = int.Parse(num);
989 float lowValue = float.Parse(min, Culture.NumberFormatInfo);
990 float highValue = float.Parse(max, Culture.NumberFormatInfo);
991
992 m_log.Debug("[ESTATEMODULE] Setting terrain heights " + m_scene.RegionInfo.RegionName +
993 string.Format(" (C{0}, {1}-{2}", corner, lowValue, highValue));
994
995 switch (corner)
996 {
997 case 0:
998 m_scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
999 m_scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
1000 break;
1001 case 1:
1002 m_scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
1003 m_scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
1004 break;
1005 case 2:
1006 m_scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
1007 m_scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
1008 break;
1009 case 3:
1010 m_scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
1011 m_scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
1012 break;
1013 }
1014 m_scene.RegionInfo.RegionSettings.Save();
1015 TriggerRegionInfoChange();
1016 sendRegionHandshakeToAll();
1017 }
1018 }
1019 } 935 }
1020 936
1021 #endregion 937 public void RemoveRegion(Scene scene) {}
1022 938
1023 public void PostInitialise() 939 public void RegionLoaded(Scene scene)
1024 { 940 {
1025 // Sets up the sun module based no the saved Estate and Region Settings 941 // Sets up the sun module based no the saved Estate and Region Settings
1026 // DO NOT REMOVE or the sun will stop working 942 // DO NOT REMOVE or the sun will stop working
1027 m_scene.TriggerEstateSunUpdate(); 943 scene.TriggerEstateSunUpdate();
1028 } 944
1029 945 UserManager = scene.RequestModuleInterface<IUserManagement>();
1030 public void Close()
1031 {
1032 }
1033
1034 public string Name
1035 {
1036 get { return "EstateManagementModule"; }
1037 } 946 }
1038 947
1039 public bool IsSharedModule 948 public void Close()
1040 { 949 {
1041 get { return false; } 950 m_commands.Close();
1042 } 951 }
1043 952
1044 #endregion 953 #endregion
@@ -1048,14 +957,14 @@ namespace OpenSim.Region.CoreModules.World.Estate
1048 public void changeWaterHeight(float height) 957 public void changeWaterHeight(float height)
1049 { 958 {
1050 setRegionTerrainSettings(height, 959 setRegionTerrainSettings(height,
1051 (float)m_scene.RegionInfo.RegionSettings.TerrainRaiseLimit, 960 (float)Scene.RegionInfo.RegionSettings.TerrainRaiseLimit,
1052 (float)m_scene.RegionInfo.RegionSettings.TerrainLowerLimit, 961 (float)Scene.RegionInfo.RegionSettings.TerrainLowerLimit,
1053 m_scene.RegionInfo.RegionSettings.UseEstateSun, 962 Scene.RegionInfo.RegionSettings.UseEstateSun,
1054 m_scene.RegionInfo.RegionSettings.FixedSun, 963 Scene.RegionInfo.RegionSettings.FixedSun,
1055 (float)m_scene.RegionInfo.RegionSettings.SunPosition, 964 (float)Scene.RegionInfo.RegionSettings.SunPosition,
1056 m_scene.RegionInfo.EstateSettings.UseGlobalTime, 965 Scene.RegionInfo.EstateSettings.UseGlobalTime,
1057 m_scene.RegionInfo.EstateSettings.FixedSun, 966 Scene.RegionInfo.EstateSettings.FixedSun,
1058 (float)m_scene.RegionInfo.EstateSettings.SunPosition); 967 (float)Scene.RegionInfo.EstateSettings.SunPosition);
1059 968
1060 sendRegionInfoPacketToAll(); 969 sendRegionInfoPacketToAll();
1061 } 970 }
@@ -1095,33 +1004,42 @@ namespace OpenSim.Region.CoreModules.World.Estate
1095 1004
1096 // Fully implemented 1005 // Fully implemented
1097 // 1006 //
1098 if (m_scene.RegionInfo.RegionSettings.AllowDamage) 1007 if (Scene.RegionInfo.RegionSettings.AllowDamage)
1099 flags |= RegionFlags.AllowDamage; 1008 flags |= RegionFlags.AllowDamage;
1100 if (m_scene.RegionInfo.RegionSettings.BlockTerraform) 1009 if (Scene.RegionInfo.RegionSettings.BlockTerraform)
1101 flags |= RegionFlags.BlockTerraform; 1010 flags |= RegionFlags.BlockTerraform;
1102 if (!m_scene.RegionInfo.RegionSettings.AllowLandResell) 1011 if (!Scene.RegionInfo.RegionSettings.AllowLandResell)
1103 flags |= RegionFlags.BlockLandResell; 1012 flags |= RegionFlags.BlockLandResell;
1104 if (m_scene.RegionInfo.RegionSettings.DisableCollisions) 1013 if (Scene.RegionInfo.RegionSettings.DisableCollisions)
1105 flags |= RegionFlags.SkipCollisions; 1014 flags |= RegionFlags.SkipCollisions;
1106 if (m_scene.RegionInfo.RegionSettings.DisableScripts) 1015 if (Scene.RegionInfo.RegionSettings.DisableScripts)
1107 flags |= RegionFlags.SkipScripts; 1016 flags |= RegionFlags.SkipScripts;
1108 if (m_scene.RegionInfo.RegionSettings.DisablePhysics) 1017 if (Scene.RegionInfo.RegionSettings.DisablePhysics)
1109 flags |= RegionFlags.SkipPhysics; 1018 flags |= RegionFlags.SkipPhysics;
1110 if (m_scene.RegionInfo.RegionSettings.BlockFly) 1019 if (Scene.RegionInfo.RegionSettings.BlockFly)
1111 flags |= RegionFlags.NoFly; 1020 flags |= RegionFlags.NoFly;
1112 if (m_scene.RegionInfo.RegionSettings.RestrictPushing) 1021 if (Scene.RegionInfo.RegionSettings.RestrictPushing)
1113 flags |= RegionFlags.RestrictPushObject; 1022 flags |= RegionFlags.RestrictPushObject;
1114 if (m_scene.RegionInfo.RegionSettings.AllowLandJoinDivide) 1023 if (Scene.RegionInfo.RegionSettings.AllowLandJoinDivide)
1115 flags |= RegionFlags.AllowParcelChanges; 1024 flags |= RegionFlags.AllowParcelChanges;
1116 if (m_scene.RegionInfo.RegionSettings.BlockShowInSearch) 1025 if (Scene.RegionInfo.RegionSettings.BlockShowInSearch)
1117 flags |= RegionFlags.BlockParcelSearch; 1026 flags |= RegionFlags.BlockParcelSearch;
1118 1027
1119 if (m_scene.RegionInfo.RegionSettings.FixedSun) 1028 if (Scene.RegionInfo.RegionSettings.FixedSun)
1120 flags |= RegionFlags.SunFixed; 1029 flags |= RegionFlags.SunFixed;
1121 if (m_scene.RegionInfo.RegionSettings.Sandbox) 1030 if (Scene.RegionInfo.RegionSettings.Sandbox)
1122 flags |= RegionFlags.Sandbox; 1031 flags |= RegionFlags.Sandbox;
1123 if (m_scene.RegionInfo.EstateSettings.AllowVoice) 1032 if (Scene.RegionInfo.EstateSettings.AllowVoice)
1124 flags |= RegionFlags.AllowVoice; 1033 flags |= RegionFlags.AllowVoice;
1034 if (Scene.RegionInfo.EstateSettings.AllowLandmark)
1035 flags |= RegionFlags.AllowLandmark;
1036 if (Scene.RegionInfo.EstateSettings.AllowSetHome)
1037 flags |= RegionFlags.AllowSetHome;
1038 if (Scene.RegionInfo.EstateSettings.BlockDwell)
1039 flags |= RegionFlags.BlockDwell;
1040 if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport)
1041 flags |= RegionFlags.ResetHomeOnTeleport;
1042
1125 1043
1126 // Fudge these to always on, so the menu options activate 1044 // Fudge these to always on, so the menu options activate
1127 // 1045 //
@@ -1142,32 +1060,38 @@ namespace OpenSim.Region.CoreModules.World.Estate
1142 { 1060 {
1143 RegionFlags flags = RegionFlags.None; 1061 RegionFlags flags = RegionFlags.None;
1144 1062
1145 if (m_scene.RegionInfo.EstateSettings.FixedSun) 1063 if (Scene.RegionInfo.EstateSettings.FixedSun)
1146 flags |= RegionFlags.SunFixed; 1064 flags |= RegionFlags.SunFixed;
1147 if (m_scene.RegionInfo.EstateSettings.PublicAccess) 1065 if (Scene.RegionInfo.EstateSettings.PublicAccess)
1148 flags |= (RegionFlags.PublicAllowed | 1066 flags |= (RegionFlags.PublicAllowed |
1149 RegionFlags.ExternallyVisible); 1067 RegionFlags.ExternallyVisible);
1150 if (m_scene.RegionInfo.EstateSettings.AllowVoice) 1068 if (Scene.RegionInfo.EstateSettings.AllowVoice)
1151 flags |= RegionFlags.AllowVoice; 1069 flags |= RegionFlags.AllowVoice;
1152 if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport) 1070 if (Scene.RegionInfo.EstateSettings.AllowDirectTeleport)
1153 flags |= RegionFlags.AllowDirectTeleport; 1071 flags |= RegionFlags.AllowDirectTeleport;
1154 if (m_scene.RegionInfo.EstateSettings.DenyAnonymous) 1072 if (Scene.RegionInfo.EstateSettings.DenyAnonymous)
1155 flags |= RegionFlags.DenyAnonymous; 1073 flags |= RegionFlags.DenyAnonymous;
1156 if (m_scene.RegionInfo.EstateSettings.DenyIdentified) 1074 if (Scene.RegionInfo.EstateSettings.DenyIdentified)
1157 flags |= RegionFlags.DenyIdentified; 1075 flags |= RegionFlags.DenyIdentified;
1158 if (m_scene.RegionInfo.EstateSettings.DenyTransacted) 1076 if (Scene.RegionInfo.EstateSettings.DenyTransacted)
1159 flags |= RegionFlags.DenyTransacted; 1077 flags |= RegionFlags.DenyTransacted;
1160 if (m_scene.RegionInfo.EstateSettings.AbuseEmailToEstateOwner) 1078 if (Scene.RegionInfo.EstateSettings.AbuseEmailToEstateOwner)
1161 flags |= RegionFlags.AbuseEmailToEstateOwner; 1079 flags |= RegionFlags.AbuseEmailToEstateOwner;
1162 if (m_scene.RegionInfo.EstateSettings.BlockDwell) 1080 if (Scene.RegionInfo.EstateSettings.BlockDwell)
1163 flags |= RegionFlags.BlockDwell; 1081 flags |= RegionFlags.BlockDwell;
1164 if (m_scene.RegionInfo.EstateSettings.EstateSkipScripts) 1082 if (Scene.RegionInfo.EstateSettings.EstateSkipScripts)
1165 flags |= RegionFlags.EstateSkipScripts; 1083 flags |= RegionFlags.EstateSkipScripts;
1166 if (m_scene.RegionInfo.EstateSettings.ResetHomeOnTeleport) 1084 if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport)
1167 flags |= RegionFlags.ResetHomeOnTeleport; 1085 flags |= RegionFlags.ResetHomeOnTeleport;
1168 if (m_scene.RegionInfo.EstateSettings.TaxFree) 1086 if (Scene.RegionInfo.EstateSettings.TaxFree)
1169 flags |= RegionFlags.TaxFree; 1087 flags |= RegionFlags.TaxFree;
1170 if (m_scene.RegionInfo.EstateSettings.DenyMinors) 1088 if (Scene.RegionInfo.EstateSettings.AllowLandmark)
1089 flags |= RegionFlags.AllowLandmark;
1090 if (Scene.RegionInfo.EstateSettings.AllowParcelChanges)
1091 flags |= RegionFlags.AllowParcelChanges;
1092 if (Scene.RegionInfo.EstateSettings.AllowSetHome)
1093 flags |= RegionFlags.AllowSetHome;
1094 if (Scene.RegionInfo.EstateSettings.DenyMinors)
1171 flags |= (RegionFlags)(1 << 30); 1095 flags |= (RegionFlags)(1 << 30);
1172 1096
1173 return (uint)flags; 1097 return (uint)flags;
@@ -1175,17 +1099,17 @@ namespace OpenSim.Region.CoreModules.World.Estate
1175 1099
1176 public bool IsManager(UUID avatarID) 1100 public bool IsManager(UUID avatarID)
1177 { 1101 {
1178 if (avatarID == m_scene.RegionInfo.EstateSettings.EstateOwner) 1102 if (avatarID == Scene.RegionInfo.EstateSettings.EstateOwner)
1179 return true; 1103 return true;
1180 1104
1181 List<UUID> ems = new List<UUID>(m_scene.RegionInfo.EstateSettings.EstateManagers); 1105 List<UUID> ems = new List<UUID>(Scene.RegionInfo.EstateSettings.EstateManagers);
1182 if (ems.Contains(avatarID)) 1106 if (ems.Contains(avatarID))
1183 return true; 1107 return true;
1184 1108
1185 return false; 1109 return false;
1186 } 1110 }
1187 1111
1188 protected void TriggerRegionInfoChange() 1112 public void TriggerRegionInfoChange()
1189 { 1113 {
1190 m_regionChangeTimer.Stop(); 1114 m_regionChangeTimer.Stop();
1191 m_regionChangeTimer.Start(); 1115 m_regionChangeTimer.Start();
@@ -1196,23 +1120,23 @@ namespace OpenSim.Region.CoreModules.World.Estate
1196 ChangeDelegate change = OnRegionInfoChange; 1120 ChangeDelegate change = OnRegionInfoChange;
1197 1121
1198 if (change != null) 1122 if (change != null)
1199 change(m_scene.RegionInfo.RegionID); 1123 change(Scene.RegionInfo.RegionID);
1200 } 1124 }
1201 1125
1202 protected void TriggerEstateInfoChange() 1126 public void TriggerEstateInfoChange()
1203 { 1127 {
1204 ChangeDelegate change = OnEstateInfoChange; 1128 ChangeDelegate change = OnEstateInfoChange;
1205 1129
1206 if (change != null) 1130 if (change != null)
1207 change(m_scene.RegionInfo.RegionID); 1131 change(Scene.RegionInfo.RegionID);
1208 } 1132 }
1209 1133
1210 protected void TriggerEstateMessage(UUID fromID, string fromName, string message) 1134 public void TriggerEstateMessage(UUID fromID, string fromName, string message)
1211 { 1135 {
1212 MessageDelegate onmessage = OnEstateMessage; 1136 MessageDelegate onmessage = OnEstateMessage;
1213 1137
1214 if (onmessage != null) 1138 if (onmessage != null)
1215 onmessage(m_scene.RegionInfo.RegionID, fromID, fromName, message); 1139 onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message);
1216 } 1140 }
1217 } 1141 }
1218} 1142}
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index b671aec..ad75ea5 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -163,13 +163,6 @@ namespace OpenSim.Region.CoreModules.World.Land
163 m_scene.UnregisterModuleCommander(m_commander.Name); 163 m_scene.UnregisterModuleCommander(m_commander.Name);
164 } 164 }
165 165
166// private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason)
167// {
168// ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y);
169// reason = "You are not allowed to enter this sim.";
170// return nearestParcel != null;
171// }
172
173 /// <summary> 166 /// <summary>
174 /// Processes commandline input. Do not call directly. 167 /// Processes commandline input. Do not call directly.
175 /// </summary> 168 /// </summary>
@@ -364,31 +357,7 @@ namespace OpenSim.Region.CoreModules.World.Land
364 } 357 }
365 358
366 if (parcelAvatarIsEntering != null) 359 if (parcelAvatarIsEntering != null)
367 { 360 EnforceBans(parcelAvatarIsEntering, avatar);
368 if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
369 {
370 if (parcelAvatarIsEntering.IsEitherBannedOrRestricted(avatar.UUID))
371 {
372 SendYouAreBannedNotice(avatar);
373 ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
374 //ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
375 }
376 else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID))
377 {
378 SendYouAreRestrictedNotice(avatar);
379 ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
380 //ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
381 }
382 else
383 {
384 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
385 }
386 }
387 else
388 {
389 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
390 }
391 }
392 } 361 }
393 } 362 }
394 363
@@ -460,32 +429,7 @@ namespace OpenSim.Region.CoreModules.World.Land
460 SendOutNearestBanLine(remote_client); 429 SendOutNearestBanLine(remote_client);
461 ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); 430 ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y);
462 if (parcel != null) 431 if (parcel != null)
463 { 432 EnforceBans(parcel, clientAvatar);
464 if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
465 clientAvatar.sentMessageAboutRestrictedParcelFlyingDown)
466 {
467 EventManagerOnAvatarEnteringNewParcel(clientAvatar, parcel.LandData.LocalID,
468 m_scene.RegionInfo.RegionID);
469 //They are going under the safety line!
470 if (!parcel.IsBannedFromLand(clientAvatar.UUID))
471 {
472 clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false;
473 }
474 }
475 else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
476 parcel.IsBannedFromLand(clientAvatar.UUID))
477 {
478 // SendYouAreBannedNotice(clientAvatar);
479 //ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
480 ForceAvatarToPosition(clientAvatar, clientAvatar.lastKnownAllowedPosition);
481 }
482 else if (parcel.IsRestrictedFromLand(clientAvatar.UUID))
483 {
484 // SendYouAreRestrictedNotice(clientAvatar);
485 //ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
486 ForceAvatarToPosition(clientAvatar, clientAvatar.lastKnownAllowedPosition);
487 }
488 }
489 } 433 }
490 } 434 }
491 435
@@ -2005,5 +1949,27 @@ namespace OpenSim.Region.CoreModules.World.Land
2005 1949
2006 MainConsole.Instance.Output(report.ToString()); 1950 MainConsole.Instance.Output(report.ToString());
2007 } 1951 }
1952
1953 public void EnforceBans(ILandObject land, ScenePresence avatar)
1954 {
1955 if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HIEGHT)
1956 return;
1957
1958 if (land.IsEitherBannedOrRestricted(avatar.UUID))
1959 {
1960 if (land.ContainsPoint(Convert.ToInt32(avatar.lastKnownAllowedPosition.X), Convert.ToInt32(avatar.lastKnownAllowedPosition.Y)))
1961 {
1962 Vector3? pos = m_scene.GetNearestAllowedPosition(avatar);
1963 if (pos == null)
1964 m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient);
1965 else
1966 ForceAvatarToPosition(avatar, (Vector3)pos);
1967 }
1968 else
1969 {
1970 ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
1971 }
1972 }
1973 }
2008 } 1974 }
2009} 1975}
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
index 071314a..aa14054 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
@@ -188,17 +188,17 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
188 } 188 }
189 catch (DllNotFoundException) 189 catch (DllNotFoundException)
190 { 190 {
191 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is emtpy for {0}", id); 191 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is empty for {0}", id);
192 192
193 } 193 }
194 catch (IndexOutOfRangeException) 194 catch (IndexOutOfRangeException)
195 { 195 {
196 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", id); 196 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id);
197 197
198 } 198 }
199 catch (Exception) 199 catch (Exception)
200 { 200 {
201 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", id); 201 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id);
202 202
203 } 203 }
204 return null; 204 return null;
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
index 7c5d044..898ca4a 100644
--- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
@@ -50,7 +50,7 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
50using OSDArray = OpenMetaverse.StructuredData.OSDArray; 50using OSDArray = OpenMetaverse.StructuredData.OSDArray;
51using OSDMap = OpenMetaverse.StructuredData.OSDMap; 51using OSDMap = OpenMetaverse.StructuredData.OSDMap;
52 52
53namespace OpenSim.Region.CoreModules.Media.Moap 53namespace OpenSim.Region.CoreModules.World.Media.Moap
54{ 54{
55 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MoapModule")] 55 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MoapModule")]
56 public class MoapModule : INonSharedRegionModule, IMoapModule 56 public class MoapModule : INonSharedRegionModule, IMoapModule
@@ -225,24 +225,62 @@ namespace OpenSim.Region.CoreModules.Media.Moap
225 return me; 225 return me;
226 } 226 }
227 227
228 /// <summary>
229 /// Set the media entry on the face of the given part.
230 /// </summary>
231 /// <param name="part">/param>
232 /// <param name="face"></param>
233 /// <param name="me">If null, then the media entry is cleared.</param>
228 public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) 234 public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me)
229 { 235 {
236// m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face);
237
230 CheckFaceParam(part, face); 238 CheckFaceParam(part, face);
231 239
232 if (null == part.Shape.Media) 240 if (null == part.Shape.Media)
233 part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); 241 {
234 242 if (me == null)
243 return;
244 else
245 part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]);
246 }
247
235 lock (part.Shape.Media) 248 lock (part.Shape.Media)
236 part.Shape.Media[face] = me; 249 part.Shape.Media[face] = me;
237 250
238 UpdateMediaUrl(part, UUID.Zero); 251 UpdateMediaUrl(part, UUID.Zero);
252
253 SetPartMediaFlags(part, face, me != null);
254
239 part.ScheduleFullUpdate(); 255 part.ScheduleFullUpdate();
240 part.TriggerScriptChangedEvent(Changed.MEDIA); 256 part.TriggerScriptChangedEvent(Changed.MEDIA);
241 } 257 }
242 258
259 /// <summary>
260 /// Clear the media entry from the face of the given part.
261 /// </summary>
262 /// <param name="part"></param>
263 /// <param name="face"></param>
243 public void ClearMediaEntry(SceneObjectPart part, int face) 264 public void ClearMediaEntry(SceneObjectPart part, int face)
244 { 265 {
245 SetMediaEntry(part, face, null); 266 SetMediaEntry(part, face, null);
267 }
268
269 /// <summary>
270 /// Set the media flags on the texture face of the given part.
271 /// </summary>
272 /// <remarks>
273 /// The fact that we need a separate function to do what should be a simple one line operation is BUTT UGLY.
274 /// </remarks>
275 /// <param name="part"></param>
276 /// <param name="face"></param>
277 /// <param name="flag"></param>
278 protected void SetPartMediaFlags(SceneObjectPart part, int face, bool flag)
279 {
280 Primitive.TextureEntry te = part.Shape.Textures;
281 Primitive.TextureEntryFace teFace = te.CreateFace((uint)face);
282 teFace.MediaFlags = flag;
283 part.Shape.Textures = te;
246 } 284 }
247 285
248 /// <summary> 286 /// <summary>
@@ -333,7 +371,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
333 } 371 }
334 372
335// m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", omu.FaceMedia.Length, primId); 373// m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", omu.FaceMedia.Length, primId);
336 374//
337// for (int i = 0; i < omu.FaceMedia.Length; i++) 375// for (int i = 0; i < omu.FaceMedia.Length; i++)
338// { 376// {
339// MediaEntry me = omu.FaceMedia[i]; 377// MediaEntry me = omu.FaceMedia[i];
@@ -368,10 +406,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
368 // FIXME: Race condition here since some other texture entry manipulator may overwrite/get 406 // FIXME: Race condition here since some other texture entry manipulator may overwrite/get
369 // overwritten. Unfortunately, PrimitiveBaseShape does not allow us to change texture entry 407 // overwritten. Unfortunately, PrimitiveBaseShape does not allow us to change texture entry
370 // directly. 408 // directly.
371 Primitive.TextureEntry te = part.Shape.Textures; 409 SetPartMediaFlags(part, i, true);
372 Primitive.TextureEntryFace face = te.CreateFace((uint)i);
373 face.MediaFlags = true;
374 part.Shape.Textures = te;
375// m_log.DebugFormat( 410// m_log.DebugFormat(
376// "[MOAP]: Media flags for face {0} is {1}", 411// "[MOAP]: Media flags for face {0} is {1}",
377// i, part.Shape.Textures.FaceTextures[i].MediaFlags); 412// i, part.Shape.Textures.FaceTextures[i].MediaFlags);
@@ -380,6 +415,8 @@ namespace OpenSim.Region.CoreModules.Media.Moap
380 } 415 }
381 else 416 else
382 { 417 {
418// m_log.DebugFormat("[MOAP]: Setting existing media list for {0}", part.Name);
419
383 // We need to go through the media textures one at a time to make sure that we have permission 420 // We need to go through the media textures one at a time to make sure that we have permission
384 // to change them 421 // to change them
385 422
@@ -401,8 +438,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
401 if (null == media[i]) 438 if (null == media[i])
402 continue; 439 continue;
403 440
404 Primitive.TextureEntryFace face = te.CreateFace((uint)i); 441 SetPartMediaFlags(part, i, true);
405 face.MediaFlags = true;
406 442
407 // m_log.DebugFormat( 443 // m_log.DebugFormat(
408 // "[MOAP]: Media flags for face {0} is {1}", 444 // "[MOAP]: Media flags for face {0} is {1}",
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
new file mode 100644
index 0000000..5b85830
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
@@ -0,0 +1,102 @@
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 System.IO;
31using System.Reflection;
32using System.Threading;
33using log4net.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenMetaverse.Assets;
37using OpenSim.Framework;
38using OpenSim.Region.CoreModules.World.Media.Moap;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Region.Framework.Scenes.Serialization;
41using OpenSim.Tests.Common;
42using OpenSim.Tests.Common.Mock;
43using OpenSim.Tests.Common.Setup;
44
45namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests
46{
47 [TestFixture]
48 public class MoapTests
49 {
50 protected TestScene m_scene;
51 protected MoapModule m_module;
52
53 [SetUp]
54 public void SetUp()
55 {
56 m_module = new MoapModule();
57 m_scene = SceneSetupHelpers.SetupScene();
58 SceneSetupHelpers.SetupSceneModules(m_scene, m_module);
59 }
60
61 [Test]
62 public void TestClearMediaUrl()
63 {
64 TestHelper.InMethod();
65// log4net.Config.XmlConfigurator.Configure();
66
67 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene);
68 MediaEntry me = new MediaEntry();
69
70 m_module.SetMediaEntry(part, 1, me);
71 m_module.ClearMediaEntry(part, 1);
72
73 Assert.That(part.Shape.Media[1], Is.EqualTo(null));
74
75 // Although we've cleared one face, other faces may still be present. So we need to check for an
76 // update media url version
77 Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000001/" + UUID.Zero));
78
79 // By changing media flag to false, the face texture once again becomes identical to the DefaultTexture.
80 // Therefore, when libOMV reserializes it, it disappears and we are left with no face texture in this slot.
81 // Not at all confusing, eh?
82 Assert.That(part.Shape.Textures.FaceTextures[1], Is.Null);
83 }
84
85 [Test]
86 public void TestSetMediaUrl()
87 {
88 TestHelper.InMethod();
89
90 string homeUrl = "opensimulator.org";
91
92 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene);
93 MediaEntry me = new MediaEntry() { HomeURL = homeUrl };
94
95 m_module.SetMediaEntry(part, 1, me);
96
97 Assert.That(part.Shape.Media[1].HomeURL, Is.EqualTo(homeUrl));
98 Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000000/" + UUID.Zero));
99 Assert.That(part.Shape.Textures.FaceTextures[1].MediaFlags, Is.True);
100 }
101 }
102} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index f9b2384..a098ff6 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -642,7 +642,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
642 /// implemented by callers. 642 /// implemented by callers.
643 /// </summary> 643 /// </summary>
644 /// <param name="currentUser"></param> 644 /// <param name="currentUser"></param>
645 /// <param name="objId"></param> 645 /// <param name="objId">This is a scene object group UUID</param>
646 /// <param name="denyOnLocked"></param> 646 /// <param name="denyOnLocked"></param>
647 /// <returns></returns> 647 /// <returns></returns>
648 protected bool GenericObjectPermission(UUID currentUser, UUID objId, bool denyOnLocked) 648 protected bool GenericObjectPermission(UUID currentUser, UUID objId, bool denyOnLocked)
@@ -1896,7 +1896,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1896// "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}", 1896// "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}",
1897// agentID, primID, face, me.ControlPermissions); 1897// agentID, primID, face, me.ControlPermissions);
1898 1898
1899 return GenericPrimMediaPermission(part, agentID, me.ControlPermissions); 1899 return GenericObjectPermission(agentID, part.ParentGroup.UUID, true);
1900 } 1900 }
1901 1901
1902 private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face) 1902 private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face)
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
index f10e848..dafaa0c 100644
--- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
+++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
@@ -30,7 +30,6 @@ using System.IO;
30using System.Xml; 30using System.Xml;
31using log4net.Config; 31using log4net.Config;
32using NUnit.Framework; 32using NUnit.Framework;
33using NUnit.Framework.SyntaxHelpers;
34using OpenMetaverse; 33using OpenMetaverse;
35using OpenSim.Framework; 34using OpenSim.Framework;
36using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index 334dcb0..282e4f1 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -113,7 +113,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
113 data = new MapBlockData(); 113 data = new MapBlockData();
114 data.Agents = 0; 114 data.Agents = 0;
115 data.Access = info.Access; 115 data.Access = info.Access;
116 data.MapImageId = info.TerrainImage; 116 data.MapImageId = UUID.Zero; // could use info.TerrainImage but it seems to break viewer2
117 data.Name = info.RegionName; 117 data.Name = info.RegionName;
118 data.RegionFlags = 0; // TODO not used? 118 data.RegionFlags = 0; // TODO not used?
119 data.WaterHeight = 0; // not used 119 data.WaterHeight = 0; // not used
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index e0f36a2..b05aef8 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -764,10 +764,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
764 764
765 if (!responseMap.ContainsKey(itemtype.ToString())) // remote sim doesnt have the stated region handle 765 if (!responseMap.ContainsKey(itemtype.ToString())) // remote sim doesnt have the stated region handle
766 { 766 {
767 if (!m_blacklistedregions.ContainsKey(regionhandle)) 767 m_log.DebugFormat("[WORLD MAP]: Remote sim does not have the stated region. Blacklisting.");
768 lock (m_blacklistedregions)
768 { 769 {
769 m_log.DebugFormat("[WORLD MAP]: Remote sim does not have the stated region. Blacklisting."); 770 if (!m_blacklistedregions.ContainsKey(regionhandle))
770 m_blacklistedregions.Add(regionhandle, Environment.TickCount); 771 m_blacklistedregions.Add(regionhandle, Environment.TickCount);
771 } 772 }
772 } 773 }
773 774
@@ -1055,7 +1056,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1055 } 1056 }
1056 else 1057 else
1057 { 1058 {
1058 OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount()); 1059 OSDArray responsearr = new OSDArray(); // Don't preallocate. MT (m_scene.GetRootAgentCount());
1059 m_scene.ForEachScenePresence(delegate(ScenePresence sp) 1060 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
1060 { 1061 {
1061 OSDMap responsemapdata = new OSDMap(); 1062 OSDMap responsemapdata = new OSDMap();
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs
index c850f7f..72e79ed 100644
--- a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs
@@ -32,7 +32,7 @@ namespace OpenSim.Region.Framework.Interfaces
32 public delegate void ChangeDelegate(UUID regionID); 32 public delegate void ChangeDelegate(UUID regionID);
33 public delegate void MessageDelegate(UUID regionID, UUID fromID, string fromName, string message); 33 public delegate void MessageDelegate(UUID regionID, UUID fromID, string fromName, string message);
34 34
35 public interface IEstateModule : IRegionModule 35 public interface IEstateModule
36 { 36 {
37 event ChangeDelegate OnRegionInfoChange; 37 event ChangeDelegate OnRegionInfoChange;
38 event ChangeDelegate OnEstateInfoChange; 38 event ChangeDelegate OnEstateInfoChange;
@@ -45,5 +45,7 @@ namespace OpenSim.Region.Framework.Interfaces
45 /// Tell all clients about the current state of the region (terrain textures, water height, etc.). 45 /// Tell all clients about the current state of the region (terrain textures, water height, etc.).
46 /// </summary> 46 /// </summary>
47 void sendRegionHandshakeToAll(); 47 void sendRegionHandshakeToAll();
48 void TriggerEstateInfoChange();
49 void TriggerRegionInfoChange();
48 } 50 }
49} 51}
diff --git a/OpenSim/Region/Framework/Interfaces/ISceneViewer.cs b/OpenSim/Region/Framework/Interfaces/ISceneViewer.cs
index 7251d57..2397f22 100644
--- a/OpenSim/Region/Framework/Interfaces/ISceneViewer.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISceneViewer.cs
@@ -36,5 +36,6 @@ namespace OpenSim.Region.Framework.Interfaces
36 void Close(); 36 void Close();
37 void QueuePartForUpdate(SceneObjectPart part); 37 void QueuePartForUpdate(SceneObjectPart part);
38 void SendPrimUpdates(); 38 void SendPrimUpdates();
39 int GetPendingObjectsCount();
39 } 40 }
40} 41}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 9a93a26..bc892e0 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -303,6 +303,8 @@ namespace OpenSim.Region.Framework.Scenes
303 // Passing something to another avatar or a an object will already 303 // Passing something to another avatar or a an object will already
304 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 304 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
305 item = InventoryService.GetItem(item); 305 item = InventoryService.GetItem(item);
306 if (item.Owner != remoteClient.AgentId)
307 return;
306 308
307 if (item != null) 309 if (item != null)
308 { 310 {
@@ -1227,6 +1229,10 @@ namespace OpenSim.Region.Framework.Scenes
1227 if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) 1229 if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0))
1228 return; 1230 return;
1229 1231
1232 bool overrideNoMod = false;
1233 if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0)
1234 overrideNoMod = true;
1235
1230 if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) 1236 if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
1231 { 1237 {
1232 // object cannot copy items to an object owned by a different owner 1238 // object cannot copy items to an object owned by a different owner
@@ -1236,7 +1242,7 @@ namespace OpenSim.Region.Framework.Scenes
1236 } 1242 }
1237 1243
1238 // must have both move and modify permission to put an item in an object 1244 // must have both move and modify permission to put an item in an object
1239 if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) 1245 if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod))
1240 { 1246 {
1241 return; 1247 return;
1242 } 1248 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 2424194..e5c0f38 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -64,6 +64,8 @@ namespace OpenSim.Region.Framework.Scenes
64 64
65 #region Fields 65 #region Fields
66 66
67 public bool EmergencyMonitoring = false;
68
67 public SynchronizeSceneHandler SynchronizeScene; 69 public SynchronizeSceneHandler SynchronizeScene;
68 public SimStatsReporter StatsReporter; 70 public SimStatsReporter StatsReporter;
69 public List<Border> NorthBorders = new List<Border>(); 71 public List<Border> NorthBorders = new List<Border>();
@@ -81,6 +83,13 @@ namespace OpenSim.Region.Framework.Scenes
81 public bool m_useFlySlow; 83 public bool m_useFlySlow;
82 public bool m_usePreJump; 84 public bool m_usePreJump;
83 public bool m_seeIntoRegionFromNeighbor; 85 public bool m_seeIntoRegionFromNeighbor;
86
87 protected float m_defaultDrawDistance = 255.0f;
88 public float DefaultDrawDistance
89 {
90 get { return m_defaultDrawDistance; }
91 }
92
84 // TODO: need to figure out how allow client agents but deny 93 // TODO: need to figure out how allow client agents but deny
85 // root agents when ACL denies access to root agent 94 // root agents when ACL denies access to root agent
86 public bool m_strictAccessControl = true; 95 public bool m_strictAccessControl = true;
@@ -129,7 +138,16 @@ namespace OpenSim.Region.Framework.Scenes
129 protected ICapabilitiesModule m_capsModule; 138 protected ICapabilitiesModule m_capsModule;
130 // Central Update Loop 139 // Central Update Loop
131 protected int m_fps = 10; 140 protected int m_fps = 10;
132 protected uint m_frame; 141
142 /// <summary>
143 /// Current scene frame number
144 /// </summary>
145 public uint Frame
146 {
147 get;
148 protected set;
149 }
150
133 protected float m_timespan = 0.089f; 151 protected float m_timespan = 0.089f;
134 protected DateTime m_lastupdate = DateTime.UtcNow; 152 protected DateTime m_lastupdate = DateTime.UtcNow;
135 153
@@ -638,6 +656,8 @@ namespace OpenSim.Region.Framework.Scenes
638 // 656 //
639 IConfig startupConfig = m_config.Configs["Startup"]; 657 IConfig startupConfig = m_config.Configs["Startup"];
640 658
659 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
660
641 //Animation states 661 //Animation states
642 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 662 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
643 // TODO: Change default to true once the feature is supported 663 // TODO: Change default to true once the feature is supported
@@ -1209,7 +1229,8 @@ namespace OpenSim.Region.Framework.Scenes
1209 1229
1210 try 1230 try
1211 { 1231 {
1212 Update(); 1232 while (!shuttingdown)
1233 Update();
1213 } 1234 }
1214 catch (ThreadAbortException) 1235 catch (ThreadAbortException)
1215 { 1236 {
@@ -1223,190 +1244,180 @@ namespace OpenSim.Region.Framework.Scenes
1223 Watchdog.RemoveThread(); 1244 Watchdog.RemoveThread();
1224 } 1245 }
1225 1246
1226 /// <summary>
1227 /// Performs per-frame updates on the scene, this should be the central scene loop
1228 /// </summary>
1229 public override void Update() 1247 public override void Update()
1230 { 1248 {
1231 float physicsFPS; 1249 TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate;
1232 int maintc; 1250 float physicsFPS = 0f;
1233 1251
1234 while (!shuttingdown) 1252 int maintc = Util.EnvironmentTickCount();
1253 int tmpFrameMS = maintc;
1254 tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
1255
1256 // Increment the frame counter
1257 ++Frame;
1258
1259 try
1235 { 1260 {
1236 TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; 1261 // Check if any objects have reached their targets
1237 physicsFPS = 0f; 1262 CheckAtTargets();
1238 1263
1239 maintc = Util.EnvironmentTickCount(); 1264 // Update SceneObjectGroups that have scheduled themselves for updates
1240 int tmpFrameMS = maintc; 1265 // Objects queue their updates onto all scene presences
1241 tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; 1266 if (Frame % m_update_objects == 0)
1267 m_sceneGraph.UpdateObjectGroups();
1242 1268
1243 // Increment the frame counter 1269 // Run through all ScenePresences looking for updates
1244 ++m_frame; 1270 // Presence updates and queued object updates for each presence are sent to clients
1271 if (Frame % m_update_presences == 0)
1272 m_sceneGraph.UpdatePresences();
1245 1273
1246 try 1274 // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client)
1275 if (Frame % m_update_coarse_locations == 0)
1247 { 1276 {
1248 // Check if any objects have reached their targets 1277 List<Vector3> coarseLocations;
1249 CheckAtTargets(); 1278 List<UUID> avatarUUIDs;
1250 1279 SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60);
1251 // Update SceneObjectGroups that have scheduled themselves for updates 1280 // Send coarse locations to clients
1252 // Objects queue their updates onto all scene presences 1281 ForEachScenePresence(delegate(ScenePresence presence)
1253 if (m_frame % m_update_objects == 0) 1282 {
1254 m_sceneGraph.UpdateObjectGroups(); 1283 presence.SendCoarseLocations(coarseLocations, avatarUUIDs);
1284 });
1285 }
1255 1286
1256 // Run through all ScenePresences looking for updates 1287 int tmpPhysicsMS2 = Util.EnvironmentTickCount();
1257 // Presence updates and queued object updates for each presence are sent to clients 1288 if ((Frame % m_update_physics == 0) && m_physics_enabled)
1258 if (m_frame % m_update_presences == 0) 1289 m_sceneGraph.UpdatePreparePhysics();
1259 m_sceneGraph.UpdatePresences(); 1290 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2);
1260 1291
1261 // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client) 1292 // Apply any pending avatar force input to the avatar's velocity
1262 if (m_frame % m_update_coarse_locations == 0) 1293 if (Frame % m_update_entitymovement == 0)
1263 { 1294 m_sceneGraph.UpdateScenePresenceMovement();
1264 List<Vector3> coarseLocations;
1265 List<UUID> avatarUUIDs;
1266 SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60);
1267 // Send coarse locations to clients
1268 ForEachScenePresence(delegate(ScenePresence presence)
1269 {
1270 presence.SendCoarseLocations(coarseLocations, avatarUUIDs);
1271 });
1272 }
1273 1295
1274 int tmpPhysicsMS2 = Util.EnvironmentTickCount(); 1296 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their
1275 if ((m_frame % m_update_physics == 0) && m_physics_enabled) 1297 // velocity
1276 m_sceneGraph.UpdatePreparePhysics(); 1298 int tmpPhysicsMS = Util.EnvironmentTickCount();
1277 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); 1299 if (Frame % m_update_physics == 0)
1300 {
1301 if (m_physics_enabled)
1302 physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan));
1303 if (SynchronizeScene != null)
1304 SynchronizeScene(this);
1305 }
1306 physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS);
1278 1307
1279 // Apply any pending avatar force input to the avatar's velocity 1308 // Delete temp-on-rez stuff
1280 if (m_frame % m_update_entitymovement == 0) 1309 if (Frame % 1000 == 0 && !m_cleaningTemps)
1281 m_sceneGraph.UpdateScenePresenceMovement(); 1310 {
1311 int tmpTempOnRezMS = Util.EnvironmentTickCount();
1312 m_cleaningTemps = true;
1313 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; });
1314 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS);
1315 }
1282 1316
1283 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their 1317 if (RegionStatus != RegionStatus.SlaveScene)
1284 // velocity 1318 {
1285 int tmpPhysicsMS = Util.EnvironmentTickCount(); 1319 if (Frame % m_update_events == 0)
1286 if (m_frame % m_update_physics == 0)
1287 { 1320 {
1288 if (m_physics_enabled) 1321 int evMS = Util.EnvironmentTickCount();
1289 physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan)); 1322 UpdateEvents();
1290 if (SynchronizeScene != null) 1323 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1291 SynchronizeScene(this);
1292 } 1324 }
1293 physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS);
1294 1325
1295 // Delete temp-on-rez stuff 1326 if (Frame % m_update_backup == 0)
1296 if (m_frame % 1000 == 0 && !m_cleaningTemps)
1297 { 1327 {
1298 int tmpTempOnRezMS = Util.EnvironmentTickCount(); 1328 int backMS = Util.EnvironmentTickCount();
1299 m_cleaningTemps = true; 1329 UpdateStorageBackup();
1300 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); 1330 backupMS = Util.EnvironmentTickCountSubtract(backMS);
1301 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS);
1302 } 1331 }
1303 1332
1304 if (RegionStatus != RegionStatus.SlaveScene) 1333 if (Frame % m_update_terrain == 0)
1305 { 1334 {
1306 if (m_frame % m_update_events == 0) 1335 int terMS = Util.EnvironmentTickCount();
1307 { 1336 UpdateTerrain();
1308 int evMS = Util.EnvironmentTickCount(); 1337 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1309 UpdateEvents();
1310 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1311 }
1312
1313 if (m_frame % m_update_backup == 0)
1314 {
1315 int backMS = Util.EnvironmentTickCount();
1316 UpdateStorageBackup();
1317 backupMS = Util.EnvironmentTickCountSubtract(backMS);
1318 }
1319
1320 if (m_frame % m_update_terrain == 0)
1321 {
1322 int terMS = Util.EnvironmentTickCount();
1323 UpdateTerrain();
1324 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1325 }
1326
1327 if (m_frame % m_update_land == 0)
1328 {
1329 int ldMS = Util.EnvironmentTickCount();
1330 UpdateLand();
1331 landMS = Util.EnvironmentTickCountSubtract(ldMS);
1332 }
1333
1334 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
1335 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1336 lastCompletedFrame = Util.EnvironmentTickCount();
1337
1338 // if (m_frame%m_update_avatars == 0)
1339 // UpdateInWorldTime();
1340 StatsReporter.AddPhysicsFPS(physicsFPS);
1341 StatsReporter.AddTimeDilation(TimeDilation);
1342 StatsReporter.AddFPS(1);
1343 StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
1344 StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
1345 StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
1346 StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
1347 StatsReporter.addFrameMS(frameMS);
1348 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1349 StatsReporter.addOtherMS(otherMS);
1350 StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
1351 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1352 } 1338 }
1353 1339
1354 if (LoginsDisabled && m_frame == 20) 1340 if (Frame % m_update_land == 0)
1355 { 1341 {
1356 // In 99.9% of cases it is a bad idea to manually force garbage collection. However, 1342 int ldMS = Util.EnvironmentTickCount();
1357 // this is a rare case where we know we have just went through a long cycle of heap 1343 UpdateLand();
1358 // allocations, and there is no more work to be done until someone logs in 1344 landMS = Util.EnvironmentTickCountSubtract(ldMS);
1359 GC.Collect(); 1345 }
1360 1346
1361 IConfig startupConfig = m_config.Configs["Startup"]; 1347 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
1362 if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false)) 1348 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1363 { 1349 lastCompletedFrame = Util.EnvironmentTickCount();
1364 m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); 1350
1365 LoginsDisabled = false; 1351 // if (Frame%m_update_avatars == 0)
1366 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); 1352 // UpdateInWorldTime();
1367 } 1353 StatsReporter.AddPhysicsFPS(physicsFPS);
1354 StatsReporter.AddTimeDilation(TimeDilation);
1355 StatsReporter.AddFPS(1);
1356 StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
1357 StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
1358 StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
1359 StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
1360 StatsReporter.addFrameMS(frameMS);
1361 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1362 StatsReporter.addOtherMS(otherMS);
1363 StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
1364 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1365 }
1366
1367 if (LoginsDisabled && Frame == 20)
1368 {
1369 // In 99.9% of cases it is a bad idea to manually force garbage collection. However,
1370 // this is a rare case where we know we have just went through a long cycle of heap
1371 // allocations, and there is no more work to be done until someone logs in
1372 GC.Collect();
1373
1374 IConfig startupConfig = m_config.Configs["Startup"];
1375 if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false))
1376 {
1377 m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
1378 LoginsDisabled = false;
1379 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
1368 } 1380 }
1369 } 1381 }
1370 catch (NotImplementedException) 1382 }
1371 { 1383 catch (NotImplementedException)
1372 throw; 1384 {
1373 } 1385 throw;
1374 catch (AccessViolationException e) 1386 }
1375 { 1387 catch (AccessViolationException e)
1376 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 1388 {
1377 } 1389 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
1378 //catch (NullReferenceException e) 1390 }
1379 //{ 1391 //catch (NullReferenceException e)
1380 // m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 1392 //{
1381 //} 1393 // m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
1382 catch (InvalidOperationException e) 1394 //}
1383 { 1395 catch (InvalidOperationException e)
1384 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 1396 {
1385 } 1397 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
1386 catch (Exception e) 1398 }
1387 { 1399 catch (Exception e)
1388 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 1400 {
1389 } 1401 m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
1390 finally 1402 }
1391 { 1403 finally
1392 m_lastupdate = DateTime.UtcNow; 1404 {
1393 } 1405 m_lastupdate = DateTime.UtcNow;
1406 }
1394 1407
1395 maintc = Util.EnvironmentTickCountSubtract(maintc); 1408 maintc = Util.EnvironmentTickCountSubtract(maintc);
1396 maintc = (int)(m_timespan * 1000) - maintc; 1409 maintc = (int)(m_timespan * 1000) - maintc;
1397 1410
1398 if (maintc > 0)
1399 Thread.Sleep(maintc);
1400 1411
1401 // Tell the watchdog that this thread is still alive 1412 m_lastUpdate = Util.EnvironmentTickCount();
1402 Watchdog.UpdateThread(); 1413 m_firstHeartbeat = false;
1403 1414
1404 m_lastUpdate = Util.EnvironmentTickCount(); 1415 if (maintc > 0)
1405 m_firstHeartbeat = false; 1416 Thread.Sleep(maintc);
1406 }
1407 }
1408 1417
1409 1418 // Tell the watchdog that this thread is still alive
1419 Watchdog.UpdateThread();
1420 }
1410 1421
1411 public void AddGroupTarget(SceneObjectGroup grp) 1422 public void AddGroupTarget(SceneObjectGroup grp)
1412 { 1423 {
@@ -3125,7 +3136,9 @@ namespace OpenSim.Region.Framework.Scenes
3125 (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); 3136 (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName);
3126 3137
3127 m_sceneGraph.removeUserCount(!childagentYN); 3138 m_sceneGraph.removeUserCount(!childagentYN);
3128 CapsModule.RemoveCapsHandler(agentID); 3139
3140 if (CapsModule != null)
3141 CapsModule.RemoveCapsHandler(agentID);
3129 3142
3130 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever 3143 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
3131 // this method is doing is HORRIBLE!!! 3144 // this method is doing is HORRIBLE!!!
@@ -3329,7 +3342,7 @@ namespace OpenSim.Region.Framework.Scenes
3329 // TeleportFlags.ViaLandmark | TeleportFlags.ViaLocation | TeleportFlags.ViaLandmark | TeleportFlags.Default - Regular Teleport 3342 // TeleportFlags.ViaLandmark | TeleportFlags.ViaLocation | TeleportFlags.ViaLandmark | TeleportFlags.Default - Regular Teleport
3330 3343
3331 // Don't disable this log message - it's too helpful 3344 // Don't disable this log message - it's too helpful
3332 m_log.InfoFormat( 3345 m_log.DebugFormat(
3333 "[CONNECTION BEGIN]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, teleportflags {6})", 3346 "[CONNECTION BEGIN]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, teleportflags {6})",
3334 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, 3347 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
3335 agent.AgentID, agent.circuitcode, teleportFlags); 3348 agent.AgentID, agent.circuitcode, teleportFlags);
@@ -3403,8 +3416,11 @@ namespace OpenSim.Region.Framework.Scenes
3403 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, 3416 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
3404 agent.AgentID, agent.circuitcode); 3417 agent.AgentID, agent.circuitcode);
3405 3418
3406 CapsModule.NewUserConnection(agent); 3419 if (CapsModule != null)
3407 CapsModule.AddCapsHandler(agent.AgentID); 3420 {
3421 CapsModule.NewUserConnection(agent);
3422 CapsModule.AddCapsHandler(agent.AgentID);
3423 }
3408 } 3424 }
3409 else 3425 else
3410 { 3426 {
@@ -3419,7 +3435,9 @@ namespace OpenSim.Region.Framework.Scenes
3419 agent.AgentID, RegionInfo.RegionName); 3435 agent.AgentID, RegionInfo.RegionName);
3420 3436
3421 sp.AdjustKnownSeeds(); 3437 sp.AdjustKnownSeeds();
3422 CapsModule.NewUserConnection(agent); 3438
3439 if (CapsModule != null)
3440 CapsModule.NewUserConnection(agent);
3423 } 3441 }
3424 } 3442 }
3425 3443
@@ -3506,6 +3524,8 @@ namespace OpenSim.Region.Framework.Scenes
3506 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) 3524 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3507 { 3525 {
3508 reason = String.Empty; 3526 reason = String.Empty;
3527 if (Permissions.IsGod(agentID))
3528 return true;
3509 3529
3510 ILandObject land = LandChannel.GetLandObject(posX, posY); 3530 ILandObject land = LandChannel.GetLandObject(posX, posY);
3511 if (land == null) 3531 if (land == null)
@@ -3931,15 +3951,15 @@ namespace OpenSim.Region.Framework.Scenes
3931 public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, 3951 public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position,
3932 Vector3 lookat, uint teleportFlags) 3952 Vector3 lookat, uint teleportFlags)
3933 { 3953 {
3934 GridRegion regionInfo = GridService.GetRegionByName(UUID.Zero, regionName); 3954 List<GridRegion> regions = GridService.GetRegionsByName(RegionInfo.ScopeID, regionName, 1);
3935 if (regionInfo == null) 3955 if (regions == null || regions.Count == 0)
3936 { 3956 {
3937 // can't find the region: Tell viewer and abort 3957 // can't find the region: Tell viewer and abort
3938 remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found."); 3958 remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found.");
3939 return; 3959 return;
3940 } 3960 }
3941 3961
3942 RequestTeleportLocation(remoteClient, regionInfo.RegionHandle, position, lookat, teleportFlags); 3962 RequestTeleportLocation(remoteClient, regions[0].RegionHandle, position, lookat, teleportFlags);
3943 } 3963 }
3944 3964
3945 /// <summary> 3965 /// <summary>
@@ -5143,9 +5163,15 @@ namespace OpenSim.Region.Framework.Scenes
5143 // from logging into the region, teleporting into the region 5163 // from logging into the region, teleporting into the region
5144 // or corssing the broder walking, but will NOT prevent 5164 // or corssing the broder walking, but will NOT prevent
5145 // child agent creation, thereby emulating the SL behavior. 5165 // child agent creation, thereby emulating the SL behavior.
5146 public bool QueryAccess(UUID agentID, Vector3 position) 5166 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5147 { 5167 {
5148 string reason; 5168 reason = "You are banned from the region";
5169
5170 if (Permissions.IsGod(agentID))
5171 {
5172 reason = String.Empty;
5173 return true;
5174 }
5149 5175
5150 if (!AuthorizeUser(agentID, out reason)) 5176 if (!AuthorizeUser(agentID, out reason))
5151 { 5177 {
@@ -5176,6 +5202,8 @@ namespace OpenSim.Region.Framework.Scenes
5176 if (banned || restricted) 5202 if (banned || restricted)
5177 return false; 5203 return false;
5178 } 5204 }
5205
5206 reason = String.Empty;
5179 return true; 5207 return true;
5180 } 5208 }
5181 } 5209 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index c8af4c3..19cb0c1 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -189,7 +189,8 @@ namespace OpenSim.Region.Framework.Scenes
189 } 189 }
190 } 190 }
191 191
192 public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, UUID scopeID, ulong regionHandle); 192 public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, UUID scopeID, GridRegion dest);
193
193 194
194 /// <summary> 195 /// <summary>
195 /// This informs all neighboring regions about the settings of it's child agent. 196 /// This informs all neighboring regions about the settings of it's child agent.
@@ -198,31 +199,17 @@ namespace OpenSim.Region.Framework.Scenes
198 /// This contains information, such as, Draw Distance, Camera location, Current Position, Current throttle settings, etc. 199 /// This contains information, such as, Draw Distance, Camera location, Current Position, Current throttle settings, etc.
199 /// 200 ///
200 /// </summary> 201 /// </summary>
201 private void SendChildAgentDataUpdateAsync(AgentPosition cAgentData, UUID scopeID, ulong regionHandle) 202 private void SendChildAgentDataUpdateAsync(AgentPosition cAgentData, UUID scopeID, GridRegion dest)
202 { 203 {
203 //m_log.Info("[INTERGRID]: Informing neighbors about my agent in " + m_regionInfo.RegionName); 204 //m_log.Info("[INTERGRID]: Informing neighbors about my agent in " + m_regionInfo.RegionName);
204 try 205 try
205 { 206 {
206 //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData); 207 m_scene.SimulationService.UpdateAgent(dest, cAgentData);
207 uint x = 0, y = 0;
208 Utils.LongToUInts(regionHandle, out x, out y);
209 GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
210 m_scene.SimulationService.UpdateAgent(destination, cAgentData);
211 } 208 }
212 catch 209 catch
213 { 210 {
214 // Ignore; we did our best 211 // Ignore; we did our best
215 } 212 }
216
217 //if (regionAccepted)
218 //{
219 // //m_log.Info("[INTERGRID]: Completed sending a neighbor an update about my agent");
220 //}
221 //else
222 //{
223 // //m_log.Info("[INTERGRID]: Failed sending a neighbor an update about my agent");
224 //}
225
226 } 213 }
227 214
228 private void SendChildAgentDataUpdateCompleted(IAsyncResult iar) 215 private void SendChildAgentDataUpdateCompleted(IAsyncResult iar)
@@ -236,14 +223,28 @@ namespace OpenSim.Region.Framework.Scenes
236 // This assumes that we know what our neighbors are. 223 // This assumes that we know what our neighbors are.
237 try 224 try
238 { 225 {
226 uint x = 0, y = 0;
227 List<string> simulatorList = new List<string>();
239 foreach (ulong regionHandle in presence.KnownChildRegionHandles) 228 foreach (ulong regionHandle in presence.KnownChildRegionHandles)
240 { 229 {
241 if (regionHandle != m_regionInfo.RegionHandle) 230 if (regionHandle != m_regionInfo.RegionHandle)
242 { 231 {
243 SendChildAgentDataUpdateDelegate d = SendChildAgentDataUpdateAsync; 232 // we only want to send one update to each simulator; the simulator will
244 d.BeginInvoke(cAgentData, m_regionInfo.ScopeID, regionHandle, 233 // hand it off to the regions where a child agent exists, this does assume
245 SendChildAgentDataUpdateCompleted, 234 // that the region position is cached or performance will degrade
246 d); 235 Utils.LongToUInts(regionHandle, out x, out y);
236 GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
237 if (! simulatorList.Contains(dest.ServerURI))
238 {
239 // we havent seen this simulator before, add it to the list
240 // and send it an update
241 simulatorList.Add(dest.ServerURI);
242
243 SendChildAgentDataUpdateDelegate d = SendChildAgentDataUpdateAsync;
244 d.BeginInvoke(cAgentData, m_regionInfo.ScopeID, dest,
245 SendChildAgentDataUpdateCompleted,
246 d);
247 }
247 } 248 }
248 } 249 }
249 } 250 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 92fe2ab..e8cf4f4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -218,9 +218,10 @@ namespace OpenSim.Region.Framework.Scenes
218 for (int i = 0; i < Math.Min(presences.Count, maxLocations); ++i) 218 for (int i = 0; i < Math.Min(presences.Count, maxLocations); ++i)
219 { 219 {
220 ScenePresence sp = presences[i]; 220 ScenePresence sp = presences[i];
221
221 // If this presence is a child agent, we don't want its coarse locations 222 // If this presence is a child agent, we don't want its coarse locations
222 if (sp.IsChildAgent) 223 if (sp.IsChildAgent)
223 return; 224 continue;
224 225
225 if (sp.ParentID != 0) 226 if (sp.ParentID != 0)
226 { 227 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 6496a25..9b9f280 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2093,8 +2093,9 @@ namespace OpenSim.Region.Framework.Scenes
2093 2093
2094 public void GetProperties(IClientAPI client) 2094 public void GetProperties(IClientAPI client)
2095 { 2095 {
2096 //Viewer wants date in microseconds so multiply it by 1,000,000.
2096 client.SendObjectPropertiesReply( 2097 client.SendObjectPropertiesReply(
2097 m_fromUserInventoryItemID, (ulong)_creationDate, _creatorID, UUID.Zero, UUID.Zero, 2098 m_fromUserInventoryItemID, (ulong)_creationDate*(ulong)1e6, _creatorID, UUID.Zero, UUID.Zero,
2098 _groupID, (short)InventorySerial, _lastOwnerID, UUID, _ownerID, 2099 _groupID, (short)InventorySerial, _lastOwnerID, UUID, _ownerID,
2099 ParentGroup.RootPart.TouchName, new byte[0], ParentGroup.RootPart.SitName, Name, Description, 2100 ParentGroup.RootPart.TouchName, new byte[0], ParentGroup.RootPart.SitName, Name, Description,
2100 ParentGroup.RootPart._ownerMask, ParentGroup.RootPart._nextOwnerMask, ParentGroup.RootPart._groupMask, ParentGroup.RootPart._everyoneMask, 2101 ParentGroup.RootPart._ownerMask, ParentGroup.RootPart._nextOwnerMask, ParentGroup.RootPart._groupMask, ParentGroup.RootPart._everyoneMask,
@@ -2141,7 +2142,7 @@ namespace OpenSim.Region.Framework.Scenes
2141 { 2142 {
2142 Quaternion newRot; 2143 Quaternion newRot;
2143 2144
2144 if (this.LinkNum < 2) //KF Single or root prim 2145 if (this.LinkNum == 0 || this.LinkNum == 1)
2145 { 2146 {
2146 newRot = RotationOffset; 2147 newRot = RotationOffset;
2147 } 2148 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 7e59b10..854f1dc 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -1287,9 +1287,13 @@ namespace OpenSim.Region.Framework.Scenes
1287 1287
1288 public Dictionary<UUID, string> GetScriptStates(bool oldIDs) 1288 public Dictionary<UUID, string> GetScriptStates(bool oldIDs)
1289 { 1289 {
1290 Dictionary<UUID, string> ret = new Dictionary<UUID, string>();
1291
1292 if (m_part.ParentGroup.Scene == null) // Group not in a scene
1293 return ret;
1294
1290 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); 1295 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
1291 1296
1292 Dictionary<UUID, string> ret = new Dictionary<UUID, string>();
1293 if (engines == null) // No engine at all 1297 if (engines == null) // No engine at all
1294 return ret; 1298 return ret;
1295 1299
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index b87275c..3a5b05d 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -123,7 +123,6 @@ namespace OpenSim.Region.Framework.Scenes
123 private SceneObjectGroup proxyObjectGroup; 123 private SceneObjectGroup proxyObjectGroup;
124 //private SceneObjectPart proxyObjectPart = null; 124 //private SceneObjectPart proxyObjectPart = null;
125 public Vector3 lastKnownAllowedPosition; 125 public Vector3 lastKnownAllowedPosition;
126 public bool sentMessageAboutRestrictedParcelFlyingDown;
127 public Vector4 CollisionPlane = Vector4.UnitW; 126 public Vector4 CollisionPlane = Vector4.UnitW;
128 127
129 private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation 128 private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation
@@ -691,7 +690,7 @@ namespace OpenSim.Region.Framework.Scenes
691 Utils.LongToUInts(handle, out x, out y); 690 Utils.LongToUInts(handle, out x, out y);
692 x = x / Constants.RegionSize; 691 x = x / Constants.RegionSize;
693 y = y / Constants.RegionSize; 692 y = y / Constants.RegionSize;
694 if (Util.IsOutsideView(x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) 693 if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY))
695 { 694 {
696 old.Add(handle); 695 old.Add(handle);
697 } 696 }
@@ -765,6 +764,7 @@ namespace OpenSim.Region.Framework.Scenes
765 764
766 private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() 765 private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this()
767 { 766 {
767 m_DrawDistance = world.DefaultDrawDistance;
768 m_rootRegionHandle = reginfo.RegionHandle; 768 m_rootRegionHandle = reginfo.RegionHandle;
769 m_controllingClient = client; 769 m_controllingClient = client;
770 m_firstname = m_controllingClient.FirstName; 770 m_firstname = m_controllingClient.FirstName;
@@ -1311,7 +1311,9 @@ namespace OpenSim.Region.Framework.Scenes
1311 if (m_agentTransfer != null) 1311 if (m_agentTransfer != null)
1312 m_agentTransfer.EnableChildAgents(this); 1312 m_agentTransfer.EnableChildAgents(this);
1313 else 1313 else
1314 m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active"); 1314 m_log.DebugFormat(
1315 "[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active for region {0}",
1316 m_scene.RegionInfo.RegionName);
1315 1317
1316 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); 1318 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
1317 if (friendsModule != null) 1319 if (friendsModule != null)
@@ -1428,7 +1430,11 @@ namespace OpenSim.Region.Framework.Scenes
1428 m_CameraUpAxis = agentData.CameraUpAxis; 1430 m_CameraUpAxis = agentData.CameraUpAxis;
1429 1431
1430 // The Agent's Draw distance setting 1432 // The Agent's Draw distance setting
1431 m_DrawDistance = agentData.Far; 1433 // When we get to the point of re-computing neighbors everytime this
1434 // changes, then start using the agent's drawdistance rather than the
1435 // region's draw distance.
1436 // m_DrawDistance = agentData.Far;
1437 m_DrawDistance = Scene.DefaultDrawDistance;
1432 1438
1433 // Check if Client has camera in 'follow cam' or 'build' mode. 1439 // Check if Client has camera in 'follow cam' or 'build' mode.
1434 Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); 1440 Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation);
@@ -2853,7 +2859,7 @@ namespace OpenSim.Region.Framework.Scenes
2853 // If we are using the the cached appearance then send it out to everyone 2859 // If we are using the the cached appearance then send it out to everyone
2854 if (cachedappearance) 2860 if (cachedappearance)
2855 { 2861 {
2856 m_log.InfoFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); 2862 m_log.DebugFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name);
2857 2863
2858 // If the avatars baked textures are all in the cache, then we have a 2864 // If the avatars baked textures are all in the cache, then we have a
2859 // complete appearance... send it out, if not, then we'll send it when 2865 // complete appearance... send it out, if not, then we'll send it when
@@ -3070,8 +3076,11 @@ namespace OpenSim.Region.Framework.Scenes
3070 #region Border Crossing Methods 3076 #region Border Crossing Methods
3071 3077
3072 /// <summary> 3078 /// <summary>
3073 /// Checks to see if the avatar is in range of a border and calls CrossToNewRegion 3079 /// Starts the process of moving an avatar into another region if they are crossing the border.
3074 /// </summary> 3080 /// </summary>
3081 /// <remarks>
3082 /// Also removes the avatar from the physical scene if transit has started.
3083 /// </remarks>
3075 protected void CheckForBorderCrossing() 3084 protected void CheckForBorderCrossing()
3076 { 3085 {
3077 if (IsChildAgent) 3086 if (IsChildAgent)
@@ -3139,7 +3148,6 @@ namespace OpenSim.Region.Framework.Scenes
3139 neighbor = HaveNeighbor(Cardinals.N, ref fix); 3148 neighbor = HaveNeighbor(Cardinals.N, ref fix);
3140 } 3149 }
3141 3150
3142
3143 // Makes sure avatar does not end up outside region 3151 // Makes sure avatar does not end up outside region
3144 if (neighbor <= 0) 3152 if (neighbor <= 0)
3145 { 3153 {
@@ -3194,6 +3202,13 @@ namespace OpenSim.Region.Framework.Scenes
3194 } 3202 }
3195 else 3203 else
3196 { 3204 {
3205 // We must remove the agent from the physical scene if it has been placed in transit. If we don't,
3206 // then this method continues to be called from ScenePresence.Update() until the handover of the client between
3207 // regions is completed. Since this handover can take more than 1000ms (due to the 1000ms
3208 // event queue polling response from the server), this results in the avatar pausing on the border
3209 // for the handover period.
3210 RemoveFromPhysicalScene();
3211
3197 // This constant has been inferred from experimentation 3212 // This constant has been inferred from experimentation
3198 // I'm not sure what this value should be, so I tried a few values. 3213 // I'm not sure what this value should be, so I tried a few values.
3199 timeStep = 0.04f; 3214 timeStep = 0.04f;
@@ -3205,6 +3220,15 @@ namespace OpenSim.Region.Framework.Scenes
3205 } 3220 }
3206 } 3221 }
3207 3222
3223 /// <summary>
3224 /// Checks whether this region has a neighbour in the given direction.
3225 /// </summary>
3226 /// <param name="car"></param>
3227 /// <param name="fix"></param>
3228 /// <returns>
3229 /// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8.
3230 /// Returns a positive integer if there is a region in that direction, a negative integer if not.
3231 /// </returns>
3208 protected int HaveNeighbor(Cardinals car, ref int[] fix) 3232 protected int HaveNeighbor(Cardinals car, ref int[] fix)
3209 { 3233 {
3210 uint neighbourx = m_regionInfo.RegionLocX; 3234 uint neighbourx = m_regionInfo.RegionLocX;
@@ -3311,7 +3335,7 @@ namespace OpenSim.Region.Framework.Scenes
3311 3335
3312 //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); 3336 //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
3313 //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); 3337 //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
3314 if (Util.IsOutsideView(x, newRegionX, y, newRegionY)) 3338 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY))
3315 { 3339 {
3316 byebyeRegions.Add(handle); 3340 byebyeRegions.Add(handle);
3317 } 3341 }
@@ -3387,7 +3411,12 @@ namespace OpenSim.Region.Framework.Scenes
3387 3411
3388 Vector3 offset = new Vector3(shiftx, shifty, 0f); 3412 Vector3 offset = new Vector3(shiftx, shifty, 0f);
3389 3413
3390 m_DrawDistance = cAgentData.Far; 3414 // When we get to the point of re-computing neighbors everytime this
3415 // changes, then start using the agent's drawdistance rather than the
3416 // region's draw distance.
3417 // m_DrawDistance = cAgentData.Far;
3418 m_DrawDistance = Scene.DefaultDrawDistance;
3419
3391 if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! 3420 if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!!
3392 m_pos = cAgentData.Position + offset; 3421 m_pos = cAgentData.Position + offset;
3393 3422
@@ -3538,7 +3567,11 @@ namespace OpenSim.Region.Framework.Scenes
3538 m_CameraLeftAxis = cAgent.LeftAxis; 3567 m_CameraLeftAxis = cAgent.LeftAxis;
3539 m_CameraUpAxis = cAgent.UpAxis; 3568 m_CameraUpAxis = cAgent.UpAxis;
3540 3569
3541 m_DrawDistance = cAgent.Far; 3570 // When we get to the point of re-computing neighbors everytime this
3571 // changes, then start using the agent's drawdistance rather than the
3572 // region's draw distance.
3573 // m_DrawDistance = cAgent.Far;
3574 m_DrawDistance = Scene.DefaultDrawDistance;
3542 3575
3543 if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) 3576 if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0)
3544 ControllingClient.SetChildAgentThrottle(cAgent.Throttles); 3577 ControllingClient.SetChildAgentThrottle(cAgent.Throttles);
diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
index 40a73a9..1f4ec96 100644
--- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
@@ -205,6 +205,14 @@ namespace OpenSim.Region.Framework.Scenes
205 Reset(); 205 Reset();
206 } 206 }
207 207
208 public int GetPendingObjectsCount()
209 {
210 if (m_pendingObjects != null)
211 return m_pendingObjects.Count;
212
213 return 0;
214 }
215
208 public class ScenePartUpdate 216 public class ScenePartUpdate
209 { 217 {
210 public UUID FullID; 218 public UUID FullID;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs
new file mode 100644
index 0000000..855b589
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs
@@ -0,0 +1,173 @@
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 System.Reflection;
31using System.Text;
32using System.Threading;
33using System.Timers;
34using Timer=System.Timers.Timer;
35using Nini.Config;
36using NUnit.Framework;
37using OpenMetaverse;
38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.CoreModules.World.Serialiser;
43using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
44using OpenSim.Tests.Common;
45using OpenSim.Tests.Common.Mock;
46using OpenSim.Tests.Common.Setup;
47
48namespace OpenSim.Region.Framework.Scenes.Tests
49{
50 /// <summary>
51 /// Attachment tests
52 /// </summary>
53 [TestFixture]
54 public class AttachmentTests
55 {
56 public Scene scene, scene2;
57 public UUID agent1;
58 public static Random random;
59 public ulong region1, region2;
60 public AgentCircuitData acd1;
61 public SceneObjectGroup sog1, sog2, sog3;
62
63 [TestFixtureSetUp]
64 public void Init()
65 {
66 TestHelper.InMethod();
67
68 scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
69 scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000);
70
71 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
72 interregionComms.Initialise(new IniConfigSource());
73 interregionComms.PostInitialise();
74 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
75 SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms);
76
77 agent1 = UUID.Random();
78 random = new Random();
79 sog1 = NewSOG(UUID.Random(), scene, agent1);
80 sog2 = NewSOG(UUID.Random(), scene, agent1);
81 sog3 = NewSOG(UUID.Random(), scene, agent1);
82
83 //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
84 region1 = scene.RegionInfo.RegionHandle;
85 region2 = scene2.RegionInfo.RegionHandle;
86
87 SceneSetupHelpers.AddRootAgent(scene, agent1);
88 }
89
90 [Test]
91 public void T030_TestAddAttachments()
92 {
93 TestHelper.InMethod();
94
95 ScenePresence presence = scene.GetScenePresence(agent1);
96
97 presence.AddAttachment(sog1);
98 presence.AddAttachment(sog2);
99 presence.AddAttachment(sog3);
100
101 Assert.That(presence.HasAttachments(), Is.True);
102 Assert.That(presence.ValidateAttachments(), Is.True);
103 }
104
105 [Test]
106 public void T031_RemoveAttachments()
107 {
108 TestHelper.InMethod();
109
110 ScenePresence presence = scene.GetScenePresence(agent1);
111 presence.RemoveAttachment(sog1);
112 presence.RemoveAttachment(sog2);
113 presence.RemoveAttachment(sog3);
114 Assert.That(presence.HasAttachments(), Is.False);
115 }
116
117 // I'm commenting this test because scene setup NEEDS InventoryService to
118 // be non-null
119 //[Test]
120 public void T032_CrossAttachments()
121 {
122 TestHelper.InMethod();
123
124 ScenePresence presence = scene.GetScenePresence(agent1);
125 ScenePresence presence2 = scene2.GetScenePresence(agent1);
126 presence2.AddAttachment(sog1);
127 presence2.AddAttachment(sog2);
128
129 ISharedRegionModule serialiser = new SerialiserModule();
130 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser);
131 SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser);
132
133 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
134
135 //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful");
136 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted");
137 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
138 }
139
140 private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent)
141 {
142 SceneObjectPart sop = new SceneObjectPart();
143 sop.Name = RandomName();
144 sop.Description = RandomName();
145 sop.Text = RandomName();
146 sop.SitName = RandomName();
147 sop.TouchName = RandomName();
148 sop.UUID = uuid;
149 sop.Shape = PrimitiveBaseShape.Default;
150 sop.Shape.State = 1;
151 sop.OwnerID = agent;
152
153 SceneObjectGroup sog = new SceneObjectGroup(sop);
154 sog.SetScene(scene);
155
156 return sog;
157 }
158
159 private static string RandomName()
160 {
161 StringBuilder name = new StringBuilder();
162 int size = random.Next(5,12);
163 char ch;
164 for (int i = 0; i < size; i++)
165 {
166 ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
167 name.Append(ch);
168 }
169
170 return name.ToString();
171 }
172 }
173} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
index b3c3e22..667b74e 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
@@ -32,7 +32,6 @@ using System.Text;
32using System.Collections.Generic; 32using System.Collections.Generic;
33using Nini.Config; 33using Nini.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenSim.Framework; 36using OpenSim.Framework;
38using OpenSim.Framework.Communications; 37using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
index 9244bc3..ca635d7 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
@@ -28,7 +28,6 @@
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using NUnit.Framework; 30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 31using OpenMetaverse;
33using OpenSim.Framework; 32using OpenSim.Framework;
34using OpenSim.Framework.Communications; 33using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 4969b09..a6a95ef 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -28,7 +28,6 @@
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using NUnit.Framework; 30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 31using OpenMetaverse;
33using OpenSim.Framework; 32using OpenSim.Framework;
34using OpenSim.Framework.Communications; 33using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
index 39116b6..0d26026 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
@@ -30,7 +30,6 @@ using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using Nini.Config; 31using Nini.Config;
32using NUnit.Framework; 32using NUnit.Framework;
33using NUnit.Framework.SyntaxHelpers;
34using OpenMetaverse; 33using OpenMetaverse;
35using OpenSim.Framework; 34using OpenSim.Framework;
36using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
index b84298f..bdfcd1d 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
@@ -29,7 +29,6 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using NUnit.Framework; 31using NUnit.Framework;
32using NUnit.Framework.SyntaxHelpers;
33using OpenMetaverse; 32using OpenMetaverse;
34using OpenSim.Framework; 33using OpenSim.Framework;
35using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
index c78038f..8876a43 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
@@ -30,7 +30,6 @@ using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using Nini.Config; 31using Nini.Config;
32using NUnit.Framework; 32using NUnit.Framework;
33using NUnit.Framework.SyntaxHelpers;
34using OpenMetaverse; 33using OpenMetaverse;
35using OpenSim.Framework; 34using OpenSim.Framework;
36using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
index ef52363..efb757f 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -34,12 +34,12 @@ using System.Timers;
34using Timer=System.Timers.Timer; 34using Timer=System.Timers.Timer;
35using Nini.Config; 35using Nini.Config;
36using NUnit.Framework; 36using NUnit.Framework;
37using NUnit.Framework.SyntaxHelpers;
38using OpenMetaverse; 37using OpenMetaverse;
39using OpenSim.Framework; 38using OpenSim.Framework;
40using OpenSim.Framework.Communications; 39using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.CoreModules.Framework.EntityTransfer;
43using OpenSim.Region.CoreModules.World.Serialiser; 43using OpenSim.Region.CoreModules.World.Serialiser;
44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
45using OpenSim.Tests.Common; 45using OpenSim.Tests.Common;
@@ -116,9 +116,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
116 agent.ChildrenCapSeeds = new Dictionary<ulong, string>(); 116 agent.ChildrenCapSeeds = new Dictionary<ulong, string>();
117 agent.child = true; 117 agent.child = true;
118 118
119 if (scene.PresenceService == null)
120 Console.WriteLine("Presence Service is null");
121
122 scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID); 119 scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID);
123 120
124 string reason; 121 string reason;
@@ -175,25 +172,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
175 172
176 Assert.That(neighbours.Count, Is.EqualTo(2)); 173 Assert.That(neighbours.Count, Is.EqualTo(2));
177 } 174 }
178
179 public void fixNullPresence()
180 {
181 string firstName = "testfirstname";
182
183 AgentCircuitData agent = new AgentCircuitData();
184 agent.AgentID = agent1;
185 agent.firstname = firstName;
186 agent.lastname = "testlastname";
187 agent.SessionID = UUID.Zero;
188 agent.SecureSessionID = UUID.Zero;
189 agent.circuitcode = 123;
190 agent.BaseFolder = UUID.Zero;
191 agent.InventoryFolder = UUID.Zero;
192 agent.startpos = Vector3.Zero;
193 agent.CapsPath = GetRandomCapsObjectPath();
194
195 acd1 = agent;
196 }
197 175
198 [Test] 176 [Test]
199 public void T013_TestRemoveNeighbourRegion() 177 public void T013_TestRemoveNeighbourRegion()
@@ -211,24 +189,36 @@ namespace OpenSim.Region.Framework.Scenes.Tests
211 CompleteAvatarMovement 189 CompleteAvatarMovement
212 */ 190 */
213 } 191 }
214 192
215 // I'm commenting this test, because this is not supposed to happen here 193 /// <summary>
216 //[Test] 194 /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region
217 public void T020_TestMakeRootAgent() 195 /// </summary>
196 /// <remarks>
197 /// Please note that unlike the other tests here, this doesn't rely on structures
198 /// </remarks>
199 [Test]
200 public void TestChildAgentEstablished()
218 { 201 {
219 TestHelper.InMethod(); 202 TestHelper.InMethod();
220 203// log4net.Config.XmlConfigurator.Configure();
221 ScenePresence presence = scene.GetScenePresence(agent1); 204
222 Assert.That(presence.IsChildAgent, Is.False, "Starts out as a root agent"); 205 UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001");
223 206
224 presence.MakeChildAgent(); 207 TestScene myScene1 = SceneSetupHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000);
225 Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent"); 208 TestScene myScene2 = SceneSetupHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000);
226 209
227 // Accepts 0 but rejects Constants.RegionSize 210 IConfigSource configSource = new IniConfigSource();
228 Vector3 pos = new Vector3(0,unchecked(Constants.RegionSize-1),0); 211 configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule");
229 presence.MakeRootAgent(pos,true); 212 EntityTransferModule etm = new EntityTransferModule();
230 Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent"); 213
231 Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); 214 SceneSetupHelpers.SetupSceneModules(myScene1, configSource, etm);
215
216 SceneSetupHelpers.AddRootAgent(myScene1, agent1Id);
217 ScenePresence childPresence = myScene2.GetScenePresence(agent1);
218
219 // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents
220// Assert.That(childPresence, Is.Not.Null);
221// Assert.That(childPresence.IsChildAgent, Is.True);
232 } 222 }
233 223
234 // I'm commenting this test because it does not represent 224 // I'm commenting this test because it does not represent
@@ -333,63 +323,26 @@ namespace OpenSim.Region.Framework.Scenes.Tests
333 Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); 323 Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected.");
334 Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); 324 Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again.");
335 } 325 }
336 326
337 [Test] 327 public void fixNullPresence()
338 public void T030_TestAddAttachments()
339 {
340 TestHelper.InMethod();
341
342 ScenePresence presence = scene.GetScenePresence(agent1);
343
344 presence.AddAttachment(sog1);
345 presence.AddAttachment(sog2);
346 presence.AddAttachment(sog3);
347
348 Assert.That(presence.HasAttachments(), Is.True);
349 Assert.That(presence.ValidateAttachments(), Is.True);
350 }
351
352 [Test]
353 public void T031_RemoveAttachments()
354 {
355 TestHelper.InMethod();
356
357 ScenePresence presence = scene.GetScenePresence(agent1);
358 presence.RemoveAttachment(sog1);
359 presence.RemoveAttachment(sog2);
360 presence.RemoveAttachment(sog3);
361 Assert.That(presence.HasAttachments(), Is.False);
362 }
363
364 // I'm commenting this test because scene setup NEEDS InventoryService to
365 // be non-null
366 //[Test]
367 public void T032_CrossAttachments()
368 { 328 {
369 TestHelper.InMethod(); 329 string firstName = "testfirstname";
370
371 ScenePresence presence = scene.GetScenePresence(agent1);
372 ScenePresence presence2 = scene2.GetScenePresence(agent1);
373 presence2.AddAttachment(sog1);
374 presence2.AddAttachment(sog2);
375
376 ISharedRegionModule serialiser = new SerialiserModule();
377 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser);
378 SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser);
379
380 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
381 330
382 //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); 331 AgentCircuitData agent = new AgentCircuitData();
383 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); 332 agent.AgentID = agent1;
384 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); 333 agent.firstname = firstName;
385 } 334 agent.lastname = "testlastname";
335 agent.SessionID = UUID.Zero;
336 agent.SecureSessionID = UUID.Zero;
337 agent.circuitcode = 123;
338 agent.BaseFolder = UUID.Zero;
339 agent.InventoryFolder = UUID.Zero;
340 agent.startpos = Vector3.Zero;
341 agent.CapsPath = GetRandomCapsObjectPath();
386 342
387 [TearDown] 343 acd1 = agent;
388 public void TearDown()
389 {
390 if (MainServer.Instance != null) MainServer.Instance.Stop();
391 } 344 }
392 345
393 public static string GetRandomCapsObjectPath() 346 public static string GetRandomCapsObjectPath()
394 { 347 {
395 UUID caps = UUID.Random(); 348 UUID caps = UUID.Random();
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
new file mode 100644
index 0000000..abcce66
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -0,0 +1,70 @@
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 System.Reflection;
31using System.Text;
32using System.Threading;
33using System.Timers;
34using Timer=System.Timers.Timer;
35using Nini.Config;
36using NUnit.Framework;
37using OpenMetaverse;
38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.CoreModules.World.Serialiser;
43using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
44using OpenSim.Tests.Common;
45using OpenSim.Tests.Common.Mock;
46using OpenSim.Tests.Common.Setup;
47
48namespace OpenSim.Region.Framework.Scenes.Tests
49{
50 /// <summary>
51 /// Scene presence tests
52 /// </summary>
53 [TestFixture]
54 public class SceneTests
55 {
56 /// <summary>
57 /// Very basic scene update test. Should become more elaborate with time.
58 /// </summary>
59 [Test]
60 public void TestUpdateScene()
61 {
62 TestHelper.InMethod();
63
64 Scene scene = SceneSetupHelpers.SetupScene();
65 scene.Update();
66
67 Assert.That(scene.Frame, Is.EqualTo(1));
68 }
69 }
70} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
index cafe48a..8588f7f 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
@@ -29,7 +29,6 @@ using System;
29using System.Reflection; 29using System.Reflection;
30using Nini.Config; 30using Nini.Config;
31using NUnit.Framework; 31using NUnit.Framework;
32using NUnit.Framework.SyntaxHelpers;
33using OpenMetaverse; 32using OpenMetaverse;
34using OpenSim.Framework; 33using OpenSim.Framework;
35using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
index fe59d4f..8138bcc 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
@@ -34,7 +34,6 @@ using System.Timers;
34using Timer=System.Timers.Timer; 34using Timer=System.Timers.Timer;
35using Nini.Config; 35using Nini.Config;
36using NUnit.Framework; 36using NUnit.Framework;
37using NUnit.Framework.SyntaxHelpers;
38using OpenMetaverse; 37using OpenMetaverse;
39using OpenMetaverse.Assets; 38using OpenMetaverse.Assets;
40using OpenSim.Framework; 39using OpenSim.Framework;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
index 5e6124b..6b70865 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
@@ -28,7 +28,6 @@
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Text; 29using System.Text;
30using NUnit.Framework; 30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 31using OpenMetaverse;
33using OpenSim.Framework; 32using OpenSim.Framework;
34using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
index 87d067c..6a24cc1 100644
--- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
51 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LindenUDPInfoModule")] 51 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LindenUDPInfoModule")]
52 public class LindenUDPInfoModule : ISharedRegionModule 52 public class LindenUDPInfoModule : ISharedRegionModule
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 55
56 protected Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); 56 protected Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
57 57
@@ -95,7 +95,15 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
95 "Show throttle settings for each client and for the server overall", 95 "Show throttle settings for each client and for the server overall",
96 "Without the 'full' option, only root agents are shown." 96 "Without the 'full' option, only root agents are shown."
97 + " With the 'full' option child agents are also shown.", 97 + " With the 'full' option child agents are also shown.",
98 ShowThrottlesReport); 98 ShowThrottlesReport);
99
100 scene.AddCommand(
101 this, "emergency-monitoring",
102 "Go on/off emergency monitoring mode",
103 "Go on/off emergency monitoring mode",
104 "Go on/off emergency monitoring mode",
105 EmergencyMonitoring);
106
99 } 107 }
100 108
101 public void RemoveRegion(Scene scene) 109 public void RemoveRegion(Scene scene)
@@ -120,7 +128,25 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
120 { 128 {
121 MainConsole.Instance.Output(GetThrottlesReport(cmd)); 129 MainConsole.Instance.Output(GetThrottlesReport(cmd));
122 } 130 }
123 131
132 protected void EmergencyMonitoring(string module, string[] cmd)
133 {
134 bool mode = true;
135 if (cmd.Length == 1 || (cmd.Length > 1 && cmd[1] == "on"))
136 {
137 mode = true;
138 MainConsole.Instance.Output("Emergency Monitoring ON");
139 }
140 else
141 {
142 mode = false;
143 MainConsole.Instance.Output("Emergency Monitoring OFF");
144 }
145
146 foreach (Scene s in m_scenes.Values)
147 s.EmergencyMonitoring = mode;
148 }
149
124 protected string GetColumnEntry(string entry, int maxLength, int columnPadding) 150 protected string GetColumnEntry(string entry, int maxLength, int columnPadding)
125 { 151 {
126 return string.Format( 152 return string.Format(
@@ -154,24 +180,26 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
154 report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding)); 180 report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding));
155 181
156 report.AppendFormat( 182 report.AppendFormat(
157 "{0,7} {1,7} {2,9} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7} {10,7}\n", 183 "{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7}\n",
158 "Pkts", 184 "Pkts",
159 "Pkts", 185 "Pkts",
186 "Pkts",
160 "Bytes", 187 "Bytes",
161 "Pkts", 188 "Q Pkts",
162 "Pkts", 189 "Q Pkts",
163 "Pkts", 190 "Q Pkts",
164 "Pkts", 191 "Q Pkts",
165 "Pkts", 192 "Q Pkts",
166 "Pkts", 193 "Q Pkts",
167 "Pkts", 194 "Q Pkts",
168 "Pkts"); 195 "Q Pkts");
169 196
170 report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", ""); 197 report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", "");
171 report.AppendFormat( 198 report.AppendFormat(
172 "{0,7} {1,7} {2,9} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7} {10,7}\n", 199 "{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7}\n",
173 "Out",
174 "In", 200 "In",
201 "Out",
202 "Resent",
175 "Unacked", 203 "Unacked",
176 "Resend", 204 "Resend",
177 "Land", 205 "Land",
@@ -333,7 +361,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
333 ThrottleRates throttleRates = udpServer.ThrottleRates; 361 ThrottleRates throttleRates = udpServer.ThrottleRates;
334 report.AppendFormat( 362 report.AppendFormat(
335 "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}", 363 "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}",
336 "n/a", 364 (throttleRates.Total * 8) / 1000,
337 (throttleRates.ResendLimit * 8) / 1000, 365 (throttleRates.ResendLimit * 8) / 1000,
338 (throttleRates.LandLimit * 8) / 1000, 366 (throttleRates.LandLimit * 8) / 1000,
339 (throttleRates.WindLimit * 8) / 1000, 367 (throttleRates.WindLimit * 8) / 1000,
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
index d75e25d..7deb32f 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
@@ -92,7 +92,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
92 private static string m_freeSwitchUrlResetPassword; 92 private static string m_freeSwitchUrlResetPassword;
93 private uint m_freeSwitchServicePort; 93 private uint m_freeSwitchServicePort;
94 private string m_openSimWellKnownHTTPAddress; 94 private string m_openSimWellKnownHTTPAddress;
95 private string m_freeSwitchContext; 95// private string m_freeSwitchContext;
96 96
97 private readonly Dictionary<string, string> m_UUIDName = new Dictionary<string, string>(); 97 private readonly Dictionary<string, string> m_UUIDName = new Dictionary<string, string>();
98 private Dictionary<string, string> m_ParcelAddress = new Dictionary<string, string>(); 98 private Dictionary<string, string> m_ParcelAddress = new Dictionary<string, string>();
@@ -144,7 +144,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
144 m_freeSwitchDefaultWellKnownIP = map["DefaultWellKnownIP"].AsString(); 144 m_freeSwitchDefaultWellKnownIP = map["DefaultWellKnownIP"].AsString();
145 m_freeSwitchDefaultTimeout = map["DefaultTimeout"].AsInteger(); 145 m_freeSwitchDefaultTimeout = map["DefaultTimeout"].AsInteger();
146 m_freeSwitchUrlResetPassword = String.Empty; 146 m_freeSwitchUrlResetPassword = String.Empty;
147 m_freeSwitchContext = map["Context"].AsString(); 147// m_freeSwitchContext = map["Context"].AsString();
148 148
149 if (String.IsNullOrEmpty(m_freeSwitchRealm) || 149 if (String.IsNullOrEmpty(m_freeSwitchRealm) ||
150 String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) 150 String.IsNullOrEmpty(m_freeSwitchAPIPrefix))
@@ -662,7 +662,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
662 resp.Append("</buddies><groups></groups></body></level0></response>"); 662 resp.Append("</buddies><groups></groups></body></level0></response>");
663 663
664 response["str_response_string"] = resp.ToString(); 664 response["str_response_string"] = resp.ToString();
665 Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); 665// Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline);
666 666
667 //m_log.DebugFormat("[FREESWITCH]: {0}", normalizeEndLines.Replace((string)response["str_response_string"],"")); 667 //m_log.DebugFormat("[FREESWITCH]: {0}", normalizeEndLines.Replace((string)response["str_response_string"],""));
668 return response; 668 return response;
@@ -670,10 +670,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
670 670
671 public Hashtable FreeSwitchSLVoiceSigninHTTPHandler(Hashtable request) 671 public Hashtable FreeSwitchSLVoiceSigninHTTPHandler(Hashtable request)
672 { 672 {
673// m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceSigninHTTPHandler called"); 673 //m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceSigninHTTPHandler called");
674 string requestbody = (string)request["body"]; 674// string requestbody = (string)request["body"];
675 string uri = (string)request["uri"]; 675// string uri = (string)request["uri"];
676 string contenttype = (string)request["content-type"]; 676// string contenttype = (string)request["content-type"];
677 677
678 Hashtable requestBody = ParseRequestBody((string)request["body"]); 678 Hashtable requestBody = ParseRequestBody((string)request["body"]);
679 679
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
index 5c779de..6d26075 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
@@ -63,7 +63,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
63 void SetAgentActiveGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID); 63 void SetAgentActiveGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID);
64 void SetAgentGroupInfo(UUID RequestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile); 64 void SetAgentGroupInfo(UUID RequestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile);
65 65
66 /// <summary>
67 /// Get information about a specific group to which the user belongs.
68 /// </summary>
69 /// <param name="RequestingAgentID">The agent requesting the information.</param>
70 /// <param name="AgentID">The agent requested.</param>
71 /// <param name="GroupID">The group requested.</param>
72 /// <returns>
73 /// If the user is a member of the group then the data structure is returned. If not, then null is returned.
74 /// </returns>
66 GroupMembershipData GetAgentGroupMembership(UUID RequestingAgentID, UUID AgentID, UUID GroupID); 75 GroupMembershipData GetAgentGroupMembership(UUID RequestingAgentID, UUID AgentID, UUID GroupID);
76
77 /// <summary>
78 /// Get information about the groups to which a user belongs.
79 /// </summary>
80 /// <param name="RequestingAgentID">The agent requesting the information.</param>
81 /// <param name="AgentID">The agent requested.</param>
82 /// <returns>
83 /// Information about the groups to which the user belongs. If the user belongs to no groups then an empty
84 /// list is returned.
85 /// </returns>
67 List<GroupMembershipData> GetAgentGroupMemberships(UUID RequestingAgentID, UUID AgentID); 86 List<GroupMembershipData> GetAgentGroupMemberships(UUID RequestingAgentID, UUID AgentID);
68 87
69 void AddGroupNotice(UUID RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket); 88 void AddGroupNotice(UUID RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket);
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
index 0d265f2..02751ea 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
@@ -704,7 +704,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
704 } 704 }
705 } 705 }
706 706
707
708 return findings; 707 return findings;
709 } 708 }
710 709
@@ -712,54 +711,55 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
712 { 711 {
713 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 712 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
714 713
715 GroupMembershipData data = new GroupMembershipData(); 714 GroupMembershipData data = null;
716 715// bool foundData = false;
717 ///////////////////////////////
718 // Agent Specific Information:
719 //
720 OSDMap UserActiveGroup;
721 if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup))
722 {
723 data.Active = UserActiveGroup["GroupID"].AsUUID().Equals(groupID);
724 }
725 716
726 OSDMap UserGroupMemberInfo; 717 OSDMap UserGroupMemberInfo;
727 if (SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out UserGroupMemberInfo)) 718 if (SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out UserGroupMemberInfo))
728 { 719 {
720 data = new GroupMembershipData();
729 data.AcceptNotices = UserGroupMemberInfo["AcceptNotices"].AsBoolean(); 721 data.AcceptNotices = UserGroupMemberInfo["AcceptNotices"].AsBoolean();
730 data.Contribution = UserGroupMemberInfo["Contribution"].AsInteger(); 722 data.Contribution = UserGroupMemberInfo["Contribution"].AsInteger();
731 data.ListInProfile = UserGroupMemberInfo["ListInProfile"].AsBoolean(); 723 data.ListInProfile = UserGroupMemberInfo["ListInProfile"].AsBoolean();
732 data.ActiveRole = UserGroupMemberInfo["SelectedRoleID"].AsUUID(); 724 data.ActiveRole = UserGroupMemberInfo["SelectedRoleID"].AsUUID();
725
726 ///////////////////////////////
727 // Agent Specific Information:
728 //
729 OSDMap UserActiveGroup;
730 if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup))
731 {
732 data.Active = UserActiveGroup["GroupID"].AsUUID().Equals(groupID);
733 }
733 734
734 /////////////////////////////// 735 ///////////////////////////////
735 // Role Specific Information: 736 // Role Specific Information:
736 // 737 //
737
738 OSDMap GroupRoleInfo; 738 OSDMap GroupRoleInfo;
739 if (SimianGetGenericEntry(groupID, "GroupRole", data.ActiveRole.ToString(), out GroupRoleInfo)) 739 if (SimianGetGenericEntry(groupID, "GroupRole", data.ActiveRole.ToString(), out GroupRoleInfo))
740 { 740 {
741 data.GroupTitle = GroupRoleInfo["Title"].AsString(); 741 data.GroupTitle = GroupRoleInfo["Title"].AsString();
742 data.GroupPowers = GroupRoleInfo["Powers"].AsULong(); 742 data.GroupPowers = GroupRoleInfo["Powers"].AsULong();
743 } 743 }
744 } 744
745 745 ///////////////////////////////
746 /////////////////////////////// 746 // Group Specific Information:
747 // Group Specific Information: 747 //
748 // 748 OSDMap GroupInfo;
749 OSDMap GroupInfo; 749 string GroupName;
750 string GroupName; 750 if (SimianGetFirstGenericEntry(groupID, "Group", out GroupName, out GroupInfo))
751 if (SimianGetFirstGenericEntry(groupID, "Group", out GroupName, out GroupInfo)) 751 {
752 { 752 data.GroupID = groupID;
753 data.GroupID = groupID; 753 data.AllowPublish = GroupInfo["AllowPublish"].AsBoolean();
754 data.AllowPublish = GroupInfo["AllowPublish"].AsBoolean(); 754 data.Charter = GroupInfo["Charter"].AsString();
755 data.Charter = GroupInfo["Charter"].AsString(); 755 data.FounderID = GroupInfo["FounderID"].AsUUID();
756 data.FounderID = GroupInfo["FounderID"].AsUUID(); 756 data.GroupName = GroupName;
757 data.GroupName = GroupName; 757 data.GroupPicture = GroupInfo["InsigniaID"].AsUUID();
758 data.GroupPicture = GroupInfo["InsigniaID"].AsUUID(); 758 data.MaturePublish = GroupInfo["MaturePublish"].AsBoolean();
759 data.MaturePublish = GroupInfo["MaturePublish"].AsBoolean(); 759 data.MembershipFee = GroupInfo["MembershipFee"].AsInteger();
760 data.MembershipFee = GroupInfo["MembershipFee"].AsInteger(); 760 data.OpenEnrollment = GroupInfo["OpenEnrollment"].AsBoolean();
761 data.OpenEnrollment = GroupInfo["OpenEnrollment"].AsBoolean(); 761 data.ShowInList = GroupInfo["ShowInList"].AsBoolean();
762 data.ShowInList = GroupInfo["ShowInList"].AsBoolean(); 762 }
763 } 763 }
764 764
765 return data; 765 return data;
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
index bc55b04..6de97b7 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
@@ -29,7 +29,6 @@ using System;
29using System.Reflection; 29using System.Reflection;
30using Nini.Config; 30using Nini.Config;
31using NUnit.Framework; 31using NUnit.Framework;
32using NUnit.Framework.SyntaxHelpers;
33using OpenMetaverse; 32using OpenMetaverse;
34using OpenSim.Framework; 33using OpenSim.Framework;
35using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
index b84a34d..d469548 100644
--- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
+++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
@@ -838,6 +838,10 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
838 if (module != null) 838 if (module != null)
839 module.BuyObject(remoteClient, categoryID, localID, saleType, salePrice); 839 module.BuyObject(remoteClient, categoryID, localID, saleType, salePrice);
840 } 840 }
841
842 public void MoveMoney(UUID fromAgentID, UUID toAgentID, int amount, string text)
843 {
844 }
841 } 845 }
842 846
843 public enum TransactionType : int 847 public enum TransactionType : int
diff --git a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs
index d4b7020..cee8851 100644
--- a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs
+++ b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs
@@ -71,6 +71,9 @@ namespace OpenSim.Region.OptionalModules.World.WorldView
71 71
72 public void RegionLoaded(Scene scene) 72 public void RegionLoaded(Scene scene)
73 { 73 {
74 if (!m_Enabled)
75 return;
76
74 m_Generator = scene.RequestModuleInterface<IMapImageGenerator>(); 77 m_Generator = scene.RequestModuleInterface<IMapImageGenerator>();
75 if (m_Generator == null) 78 if (m_Generator == null)
76 { 79 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
new file mode 100644
index 0000000..489c1c6
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
@@ -0,0 +1,118 @@
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.Reflection;
30using System.Collections;
31using System.Collections.Generic;
32using System.Runtime.Remoting.Lifetime;
33using OpenMetaverse;
34using Nini.Config;
35using OpenSim;
36using OpenSim.Framework;
37using OpenSim.Region.CoreModules.World.LightShare;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Region.ScriptEngine.Shared;
41using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
42using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
43using OpenSim.Region.ScriptEngine.Interfaces;
44using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
45using OpenSim.Services.Interfaces;
46
47using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
48using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
49using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
50using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
51using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
52using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
53using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
54
55namespace OpenSim.Region.ScriptEngine.Shared.Api
56{
57 [Serializable]
58 public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi
59 {
60 internal IScriptEngine m_ScriptEngine;
61 internal SceneObjectPart m_host;
62 internal uint m_localID;
63 internal UUID m_itemID;
64 internal bool m_CMFunctionsEnabled = false;
65
66 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
67 {
68 m_ScriptEngine = ScriptEngine;
69 m_host = host;
70 m_localID = localID;
71 m_itemID = itemID;
72
73 if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false))
74 m_CMFunctionsEnabled = true;
75 }
76
77 public override Object InitializeLifetimeService()
78 {
79 ILease lease = (ILease)base.InitializeLifetimeService();
80
81 if (lease.CurrentState == LeaseState.Initial)
82 {
83 lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
84 // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
85 // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
86 }
87 return lease;
88 }
89
90 public Scene World
91 {
92 get { return m_ScriptEngine.World; }
93 }
94
95 public string cmDetectedCountry(int number)
96 {
97 m_host.AddScriptLPS(1);
98 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number);
99 if (detectedParams == null)
100 return String.Empty;
101 return detectedParams.Country;
102 }
103
104 public string cmGetAgentCountry(LSL_Key key)
105 {
106 if (!World.Permissions.IsGod(m_host.OwnerID))
107 return String.Empty;
108
109 UUID uuid;
110
111 if (!UUID.TryParse(key, out uuid))
112 return String.Empty;
113
114 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid);
115 return account.UserCountry;
116 }
117 }
118}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 59e905e..559523b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1920,15 +1920,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1920 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) 1920 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1921 return; 1921 return;
1922 1922
1923 UUID textureID=new UUID(); 1923 UUID textureID = new UUID();
1924 1924
1925 if (!UUID.TryParse(texture, out textureID)) 1925 textureID = InventoryKey(texture, (int)AssetType.Texture);
1926 { 1926 if (textureID == UUID.Zero)
1927 textureID=InventoryKey(texture, (int)AssetType.Texture); 1927 {
1928 } 1928 if (!UUID.TryParse(texture, out textureID))
1929 1929 return;
1930 if (textureID == UUID.Zero) 1930 }
1931 return;
1932 1931
1933 Primitive.TextureEntry tex = part.Shape.Textures; 1932 Primitive.TextureEntry tex = part.Shape.Textures;
1934 1933
@@ -3346,12 +3345,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3346 msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID; 3345 msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID;
3347 msg.Position = new Vector3(m_host.AbsolutePosition); 3346 msg.Position = new Vector3(m_host.AbsolutePosition);
3348 msg.RegionID = World.RegionInfo.RegionID.Guid; 3347 msg.RegionID = World.RegionInfo.RegionID.Guid;
3349 msg.binaryBucket = Util.StringToBytes256(m_host.OwnerID.ToString()); 3348 msg.binaryBucket
3349 = Util.StringToBytes256(
3350 "{0}/{1}/{2}/{3}",
3351 World.RegionInfo.RegionName,
3352 (int)Math.Floor(m_host.AbsolutePosition.X),
3353 (int)Math.Floor(m_host.AbsolutePosition.Y),
3354 (int)Math.Floor(m_host.AbsolutePosition.Z));
3350 3355
3351 if (m_TransferModule != null) 3356 if (m_TransferModule != null)
3352 { 3357 {
3353 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); 3358 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
3354 } 3359 }
3360
3355 ScriptSleep(2000); 3361 ScriptSleep(2000);
3356 } 3362 }
3357 3363
@@ -4195,7 +4201,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4195 if (!found) 4201 if (!found)
4196 { 4202 {
4197 llSay(0, String.Format("Could not find object '{0}'", inventory)); 4203 llSay(0, String.Format("Could not find object '{0}'", inventory));
4198 throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); 4204 return;
4205// throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory));
4199 } 4206 }
4200 4207
4201 // check if destination is an object 4208 // check if destination is an object
@@ -4479,7 +4486,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4479 if (presence != null) 4486 if (presence != null)
4480 { 4487 {
4481 // agent must not be a god 4488 // agent must not be a god
4482 if (presence.GodLevel >= 200) return; 4489 if (presence.UserLevel >= 200) return;
4483 4490
4484 // agent must be over the owners land 4491 // agent must be over the owners land
4485 if (m_host.OwnerID == World.LandChannel.GetLandObject( 4492 if (m_host.OwnerID == World.LandChannel.GetLandObject(
@@ -6860,6 +6867,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6860 } 6867 }
6861 6868
6862 // copy the first script found with this inventory name 6869 // copy the first script found with this inventory name
6870 TaskInventoryItem scriptItem = null;
6863 m_host.TaskInventory.LockItemsForRead(true); 6871 m_host.TaskInventory.LockItemsForRead(true);
6864 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 6872 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
6865 { 6873 {
@@ -6870,6 +6878,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6870 { 6878 {
6871 found = true; 6879 found = true;
6872 srcId = inv.Key; 6880 srcId = inv.Key;
6881 scriptItem = inv.Value;
6873 break; 6882 break;
6874 } 6883 }
6875 } 6884 }
@@ -6882,8 +6891,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6882 return; 6891 return;
6883 } 6892 }
6884 6893
6885 // the rest of the permission checks are done in RezScript, so check the pin there as well 6894 SceneObjectPart dest = World.GetSceneObjectPart(destId);
6886 World.RezScript(srcId, m_host, destId, pin, running, start_param); 6895 if (dest != null)
6896 {
6897 if ((scriptItem.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID)
6898 {
6899 // the rest of the permission checks are done in RezScript, so check the pin there as well
6900 World.RezScript(srcId, m_host, destId, pin, running, start_param);
6901
6902 if ((scriptItem.BasePermissions & (uint)PermissionMask.Copy) == 0)
6903 m_host.Inventory.RemoveInventoryItem(srcId);
6904 }
6905 }
6887 // this will cause the delay even if the script pin or permissions were wrong - seems ok 6906 // this will cause the delay even if the script pin or permissions were wrong - seems ok
6888 ScriptSleep(3000); 6907 ScriptSleep(3000);
6889 } 6908 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index cf059b3..39e1a27 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -690,10 +690,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
690 // 690 //
691 CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); 691 CheckThreatLevel(ThreatLevel.High, "osTeleportAgent");
692 692
693 TeleportAgent(agent, regionName, position, lookat); 693 TeleportAgent(agent, regionName, position, lookat, false);
694 } 694 }
695 695
696 private void TeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) 696 private void TeleportAgent(string agent, string regionName,
697 LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions)
697 { 698 {
698 m_host.AddScriptLPS(1); 699 m_host.AddScriptLPS(1);
699 UUID agentId = new UUID(); 700 UUID agentId = new UUID();
@@ -702,21 +703,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
702 ScenePresence presence = World.GetScenePresence(agentId); 703 ScenePresence presence = World.GetScenePresence(agentId);
703 if (presence != null) 704 if (presence != null)
704 { 705 {
705 // agent must be over owners land to avoid abuse 706 // For osTeleportAgent, agent must be over owners land to avoid abuse
706 if (m_host.OwnerID 707 // For osTeleportOwner, this restriction isn't necessary
708 if (relaxRestrictions ||
709 m_host.OwnerID
707 == World.LandChannel.GetLandObject( 710 == World.LandChannel.GetLandObject(
708 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) 711 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
709 { 712 {
710 // Check for hostname, attempt to make a HG link,
711 // and convert the regionName to the target region
712 if (regionName.Contains(".") && regionName.Contains(":"))
713 {
714// List<GridRegion> regions = World.GridService.GetRegionsByName(World.RegionInfo.ScopeID, regionName, 1);
715 string[] parts = regionName.Split(new char[] { ':' });
716 if (parts.Length > 2)
717 regionName = parts[0] + ':' + parts[1] + "/ " + parts[2];
718 regionName = "http://" + regionName;
719 }
720 World.RequestTeleportLocation(presence.ControllingClient, regionName, 713 World.RequestTeleportLocation(presence.ControllingClient, regionName,
721 new Vector3((float)position.x, (float)position.y, (float)position.z), 714 new Vector3((float)position.x, (float)position.y, (float)position.z),
722 new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation); 715 new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation);
@@ -733,10 +726,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
733 // 726 //
734 CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); 727 CheckThreatLevel(ThreatLevel.High, "osTeleportAgent");
735 728
736 TeleportAgent(agent, regionX, regionY, position, lookat); 729 TeleportAgent(agent, regionX, regionY, position, lookat, false);
737 } 730 }
738 731
739 private void TeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) 732 private void TeleportAgent(string agent, int regionX, int regionY,
733 LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions)
740 { 734 {
741 ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize)); 735 ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize));
742 736
@@ -747,8 +741,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
747 ScenePresence presence = World.GetScenePresence(agentId); 741 ScenePresence presence = World.GetScenePresence(agentId);
748 if (presence != null) 742 if (presence != null)
749 { 743 {
750 // agent must be over owners land to avoid abuse 744 // For osTeleportAgent, agent must be over owners land to avoid abuse
751 if (m_host.OwnerID 745 // For osTeleportOwner, this restriction isn't necessary
746 if (relaxRestrictions ||
747 m_host.OwnerID
752 == World.LandChannel.GetLandObject( 748 == World.LandChannel.GetLandObject(
753 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) 749 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
754 { 750 {
@@ -771,7 +767,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
771 // Threat level None because this is what can already be done with the World Map in the viewer 767 // Threat level None because this is what can already be done with the World Map in the viewer
772 CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); 768 CheckThreatLevel(ThreatLevel.None, "osTeleportOwner");
773 769
774 TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat); 770 TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat, true);
775 } 771 }
776 772
777 public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) 773 public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
@@ -783,7 +779,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
783 { 779 {
784 CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); 780 CheckThreatLevel(ThreatLevel.None, "osTeleportOwner");
785 781
786 TeleportAgent(m_host.OwnerID.ToString(), regionX, regionY, position, lookat); 782 TeleportAgent(m_host.OwnerID.ToString(), regionX, regionY, position, lookat, true);
787 } 783 }
788 784
789 // Functions that get information from the agent itself. 785 // Functions that get information from the agent itself.
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
new file mode 100644
index 0000000..ab215f3
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
@@ -0,0 +1,46 @@
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.Collections;
29using OpenSim.Region.ScriptEngine.Interfaces;
30
31using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
32using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
33using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
34using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
35using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
36using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
37using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
38
39namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
40{
41 public interface ICM_Api
42 {
43 string cmDetectedCountry(int num);
44 string cmGetAgentCountry(key key);
45 }
46}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
new file mode 100644
index 0000000..4132dfa
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
@@ -0,0 +1,71 @@
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.Runtime.Remoting.Lifetime;
30using System.Threading;
31using System.Reflection;
32using System.Collections;
33using System.Collections.Generic;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.ScriptEngine.Interfaces;
37using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
38using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
39using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
40using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
41using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
42using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
43using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
44using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
45using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
46
47namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
48{
49 public partial class ScriptBaseClass : MarshalByRefObject
50 {
51 public ICM_Api m_CM_Functions;
52
53 public void ApiTypeCM(IScriptApi api)
54 {
55 if (!(api is ICM_Api))
56 return;
57
58 m_CM_Functions = (ICM_Api)api;
59 }
60
61 public string cmDetectedCountry(int num)
62 {
63 return m_CM_Functions.cmDetectedCountry(num);
64 }
65
66 public string cmGetAgentCountry(key key)
67 {
68 return m_CM_Functions.cmGetAgentCountry(key);
69 }
70 }
71}
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
index 913c6c9..edc0561 100644
--- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
@@ -115,15 +115,15 @@ namespace OpenSim.Server.Handlers.Grid
115 case "get_region_flags": 115 case "get_region_flags":
116 return GetRegionFlags(request); 116 return GetRegionFlags(request);
117 } 117 }
118
118 m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method); 119 m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method);
119 } 120 }
120 catch (Exception e) 121 catch (Exception e)
121 { 122 {
122 m_log.DebugFormat("[GRID HANDLER]: Exception {0}", e); 123 m_log.ErrorFormat("[GRID HANDLER]: Exception {0} {1}", e.Message, e.StackTrace);
123 } 124 }
124 125
125 return FailureResult(); 126 return FailureResult();
126
127 } 127 }
128 128
129 #region Method-specific handlers 129 #region Method-specific handlers
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
index b33b0d5..616aef3 100644
--- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
+++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
@@ -205,6 +205,11 @@ namespace OpenSim.Server.Handlers.Simulation
205 205
206 // We're behind a proxy 206 // We're behind a proxy
207 Hashtable headers = (Hashtable)request["headers"]; 207 Hashtable headers = (Hashtable)request["headers"];
208
209 //// DEBUG
210 //foreach (object o in headers.Keys)
211 // m_log.DebugFormat("XXX {0} = {1}", o.ToString(), (headers[o] == null? "null" : headers[o].ToString()));
212
208 string xff = "X-Forwarded-For"; 213 string xff = "X-Forwarded-For";
209 if (headers.ContainsKey(xff.ToLower())) 214 if (headers.ContainsKey(xff.ToLower()))
210 xff = xff.ToLower(); 215 xff = xff.ToLower();
@@ -341,10 +346,17 @@ namespace OpenSim.Server.Handlers.Simulation
341 GridRegion destination = new GridRegion(); 346 GridRegion destination = new GridRegion();
342 destination.RegionID = regionID; 347 destination.RegionID = regionID;
343 348
344 bool result = m_SimulationService.QueryAccess(destination, id, position); 349 string reason;
350 bool result = m_SimulationService.QueryAccess(destination, id, position, out reason);
345 351
346 responsedata["int_response_code"] = HttpStatusCode.OK; 352 responsedata["int_response_code"] = HttpStatusCode.OK;
347 responsedata["str_response_string"] = result.ToString(); 353
354 OSDMap resp = new OSDMap(2);
355
356 resp["success"] = OSD.FromBoolean(result);
357 resp["reason"] = OSD.FromString(reason);
358
359 responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
348 } 360 }
349 361
350 protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, UUID regionID) 362 protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, UUID regionID)
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index 81ef225..c29bce8 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -93,7 +93,7 @@ namespace OpenSim.Services.AssetService
93 93
94 if (!UUID.TryParse(id, out assetID)) 94 if (!UUID.TryParse(id, out assetID))
95 { 95 {
96 m_log.WarnFormat("[ASSET SERVICE]: Could not parse requested sset id {0}", id); 96 m_log.WarnFormat("[ASSET SERVICE]: Could not parse requested asset id {0}", id);
97 return null; 97 return null;
98 } 98 }
99 99
diff --git a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
deleted file mode 100644
index 9878855..0000000
--- a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
+++ /dev/null
@@ -1,335 +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 log4net;
29using Nini.Config;
30using System;
31using System.Collections.Generic;
32using System.Reflection;
33using OpenSim.Framework;
34using OpenSim.Services.Interfaces;
35using OpenMetaverse;
36
37namespace OpenSim.Services.Connectors.Inventory
38{
39 public class HGInventoryServiceConnector : ISessionAuthInventoryService
40 {
41 private static readonly ILog m_log =
42 LogManager.GetLogger(
43 MethodBase.GetCurrentMethod().DeclaringType);
44
45 private Dictionary<string, InventoryServicesConnector> m_connectors = new Dictionary<string, InventoryServicesConnector>();
46
47 public HGInventoryServiceConnector(IConfigSource source)
48 {
49 IConfig moduleConfig = source.Configs["Modules"];
50 if (moduleConfig != null)
51 {
52
53 IConfig inventoryConfig = source.Configs["InventoryService"];
54 if (inventoryConfig == null)
55 {
56 m_log.Error("[HG INVENTORY SERVICE]: InventoryService missing from OpenSim.ini");
57 return;
58 }
59
60 m_log.Info("[HG INVENTORY SERVICE]: HG inventory service enabled");
61 }
62 }
63
64 private bool StringToUrlAndUserID(string id, out string url, out string userID)
65 {
66 url = String.Empty;
67 userID = String.Empty;
68
69 Uri assetUri;
70
71 if (Uri.TryCreate(id, UriKind.Absolute, out assetUri) &&
72 assetUri.Scheme == Uri.UriSchemeHttp)
73 {
74 url = "http://" + assetUri.Authority;
75 userID = assetUri.LocalPath.Trim(new char[] { '/' });
76 return true;
77 }
78
79 return false;
80 }
81 private ISessionAuthInventoryService GetConnector(string url)
82 {
83 InventoryServicesConnector connector = null;
84 lock (m_connectors)
85 {
86 if (m_connectors.ContainsKey(url))
87 {
88 connector = m_connectors[url];
89 }
90 else
91 {
92 // We're instantiating this class explicitly, but this won't
93 // work in general, because the remote grid may be running
94 // an inventory server that has a different protocol.
95 // Eventually we will want a piece of protocol asking
96 // the remote server about its kind. Definitely cool thing to do!
97 connector = new InventoryServicesConnector(url);
98 m_connectors.Add(url, connector);
99 }
100 }
101 return connector;
102 }
103
104 public string Host
105 {
106 get { return string.Empty; }
107 }
108
109 public void GetUserInventory(string id, UUID sessionID, InventoryReceiptCallback callback)
110 {
111 m_log.Debug("[HGInventory]: GetUserInventory " + id);
112 string url = string.Empty;
113 string userID = string.Empty;
114
115 if (StringToUrlAndUserID(id, out url, out userID))
116 {
117 ISessionAuthInventoryService connector = GetConnector(url);
118 connector.GetUserInventory(userID, sessionID, callback);
119 }
120
121 }
122
123 /// <summary>
124 /// Gets the user folder for the given folder-type
125 /// </summary>
126 /// <param name="userID"></param>
127 /// <param name="type"></param>
128 /// <returns></returns>
129 public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string id, UUID sessionID)
130 {
131 m_log.Debug("[HGInventory]: GetSystemFolders " + id);
132 string url = string.Empty;
133 string userID = string.Empty;
134
135 if (StringToUrlAndUserID(id, out url, out userID))
136 {
137 ISessionAuthInventoryService connector = GetConnector(url);
138 return connector.GetSystemFolders(userID, sessionID);
139 }
140
141 return new Dictionary<AssetType, InventoryFolderBase>();
142 }
143
144 /// <summary>
145 /// Gets everything (folders and items) inside a folder
146 /// </summary>
147 /// <param name="userId"></param>
148 /// <param name="folderID"></param>
149 /// <returns></returns>
150 public InventoryCollection GetFolderContent(string id, UUID folderID, UUID sessionID)
151 {
152 m_log.Debug("[HGInventory]: GetFolderContent " + id);
153 string url = string.Empty;
154 string userID = string.Empty;
155
156 if (StringToUrlAndUserID(id, out url, out userID))
157 {
158 ISessionAuthInventoryService connector = GetConnector(url);
159 return connector.GetFolderContent(userID, folderID, sessionID);
160 }
161
162 return null;
163 }
164
165 public bool AddFolder(string id, InventoryFolderBase folder, UUID sessionID)
166 {
167 string url = string.Empty;
168 string userID = string.Empty;
169
170 if (StringToUrlAndUserID(id, out url, out userID))
171 {
172 ISessionAuthInventoryService connector = GetConnector(url);
173 return connector.AddFolder(userID, folder, sessionID);
174 }
175 return false;
176 }
177
178 public bool UpdateFolder(string id, InventoryFolderBase folder, UUID sessionID)
179 {
180 string url = string.Empty;
181 string userID = string.Empty;
182
183 if (StringToUrlAndUserID(id, out url, out userID))
184 {
185 ISessionAuthInventoryService connector = GetConnector(url);
186 return connector.UpdateFolder(userID, folder, sessionID);
187 }
188 return false;
189 }
190
191 public bool MoveFolder(string id, InventoryFolderBase folder, UUID sessionID)
192 {
193 string url = string.Empty;
194 string userID = string.Empty;
195
196 if (StringToUrlAndUserID(id, out url, out userID))
197 {
198 ISessionAuthInventoryService connector = GetConnector(url);
199 return connector.MoveFolder(userID, folder, sessionID);
200 }
201 return false;
202 }
203
204 public bool DeleteFolders(string id, List<UUID> folders, UUID sessionID)
205 {
206 string url = string.Empty;
207 string userID = string.Empty;
208
209 if (StringToUrlAndUserID(id, out url, out userID))
210 {
211 ISessionAuthInventoryService connector = GetConnector(url);
212 return connector.DeleteFolders(userID, folders, sessionID);
213 }
214 return false;
215 }
216
217 public bool PurgeFolder(string id, InventoryFolderBase folder, UUID sessionID)
218 {
219 string url = string.Empty;
220 string userID = string.Empty;
221
222 if (StringToUrlAndUserID(id, out url, out userID))
223 {
224 ISessionAuthInventoryService connector = GetConnector(url);
225 return connector.PurgeFolder(userID, folder, sessionID);
226 }
227 return false;
228 }
229
230 public List<InventoryItemBase> GetFolderItems(string id, UUID folderID, UUID sessionID)
231 {
232 string url = string.Empty;
233 string userID = string.Empty;
234
235 if (StringToUrlAndUserID(id, out url, out userID))
236 {
237 ISessionAuthInventoryService connector = GetConnector(url);
238 return connector.GetFolderItems(userID, folderID, sessionID);
239 }
240 return new List<InventoryItemBase>();
241 }
242
243 public bool AddItem(string id, InventoryItemBase item, UUID sessionID)
244 {
245 string url = string.Empty;
246 string userID = string.Empty;
247
248 if (StringToUrlAndUserID(id, out url, out userID))
249 {
250 ISessionAuthInventoryService connector = GetConnector(url);
251 return connector.AddItem(userID, item, sessionID);
252 }
253 return false;
254 }
255
256 public bool UpdateItem(string id, InventoryItemBase item, UUID sessionID)
257 {
258 string url = string.Empty;
259 string userID = string.Empty;
260
261 if (StringToUrlAndUserID(id, out url, out userID))
262 {
263 ISessionAuthInventoryService connector = GetConnector(url);
264 return connector.UpdateItem(userID, item, sessionID);
265 }
266 return false;
267 }
268
269 public bool MoveItems(string id, List<InventoryItemBase> items, UUID sessionID)
270 {
271 string url = string.Empty;
272 string userID = string.Empty;
273
274 if (StringToUrlAndUserID(id, out url, out userID))
275 {
276 ISessionAuthInventoryService connector = GetConnector(url);
277 return connector.MoveItems(userID, items, sessionID);
278 }
279 return false;
280 }
281
282 public bool DeleteItems(string id, List<UUID> itemIDs, UUID sessionID)
283 {
284 string url = string.Empty;
285 string userID = string.Empty;
286
287 if (StringToUrlAndUserID(id, out url, out userID))
288 {
289 ISessionAuthInventoryService connector = GetConnector(url);
290 return connector.DeleteItems(userID, itemIDs, sessionID);
291 }
292 return false;
293 }
294
295 public InventoryItemBase QueryItem(string id, InventoryItemBase item, UUID sessionID)
296 {
297 string url = string.Empty;
298 string userID = string.Empty;
299
300 if (StringToUrlAndUserID(id, out url, out userID))
301 {
302 //m_log.DebugFormat("[HGInventory CONNECTOR]: calling {0}", url);
303 ISessionAuthInventoryService connector = GetConnector(url);
304 return connector.QueryItem(userID, item, sessionID);
305 }
306 return null;
307 }
308
309 public InventoryFolderBase QueryFolder(string id, InventoryFolderBase folder, UUID sessionID)
310 {
311 string url = string.Empty;
312 string userID = string.Empty;
313
314 if (StringToUrlAndUserID(id, out url, out userID))
315 {
316 ISessionAuthInventoryService connector = GetConnector(url);
317 return connector.QueryFolder(userID, folder, sessionID);
318 }
319 return null;
320 }
321
322 public int GetAssetPermissions(string id, UUID assetID, UUID sessionID)
323 {
324 string url = string.Empty;
325 string userID = string.Empty;
326
327 if (StringToUrlAndUserID(id, out url, out userID))
328 {
329 ISessionAuthInventoryService connector = GetConnector(url);
330 return connector.GetAssetPermissions(userID, assetID, sessionID);
331 }
332 return 0;
333 }
334 }
335}
diff --git a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs
deleted file mode 100644
index da8c7e2..0000000
--- a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs
+++ /dev/null
@@ -1,140 +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.Collections.Generic;
29using OpenSim.Framework;
30using OpenSim.Services.Interfaces;
31using OpenMetaverse;
32
33namespace OpenSim.Services.Connectors
34{
35 /// <summary>
36 /// Defines all operations to access a remote inventory service
37 /// using session authentication as a form of security.
38 /// </summary>
39 public interface ISessionAuthInventoryService
40 {
41 string Host
42 {
43 get;
44 }
45
46 /// <summary>
47 /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the
48 /// inventory has been received
49 /// </summary>
50 /// <param name="userID"></param>
51 /// <param name="callback"></param>
52 void GetUserInventory(string userID, UUID session_id, InventoryReceiptCallback callback);
53
54 /// <summary>
55 /// Gets the user folder for the given folder-type
56 /// </summary>
57 /// <param name="userID"></param>
58 /// <param name="type"></param>
59 /// <returns></returns>
60 Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string userID, UUID session_id);
61
62 /// <summary>
63 /// Gets everything (folders and items) inside a folder
64 /// </summary>
65 /// <param name="userId"></param>
66 /// <param name="folderID"></param>
67 /// <returns></returns>
68 InventoryCollection GetFolderContent(string userID, UUID folderID, UUID session_id);
69
70 /// <summary>
71 /// Add a new folder to the user's inventory
72 /// </summary>
73 /// <param name="folder"></param>
74 /// <returns>true if the folder was successfully added</returns>
75 bool AddFolder(string userID, InventoryFolderBase folder, UUID session_id);
76
77 /// <summary>
78 /// Update a folder in the user's inventory
79 /// </summary>
80 /// <param name="folder"></param>
81 /// <returns>true if the folder was successfully updated</returns>
82 bool UpdateFolder(string userID, InventoryFolderBase folder, UUID session_id);
83
84 /// <summary>
85 /// Move an inventory folder to a new location
86 /// </summary>
87 /// <param name="folder">A folder containing the details of the new location</param>
88 /// <returns>true if the folder was successfully moved</returns>
89 bool MoveFolder(string userID, InventoryFolderBase folder, UUID session_id);
90
91 /// <summary>
92 /// Delete a list of inventory folders (from trash)
93 /// </summary>
94 bool DeleteFolders(string userID, List<UUID> folders, UUID session_id);
95
96 /// <summary>
97 /// Purge an inventory folder of all its items and subfolders.
98 /// </summary>
99 /// <param name="folder"></param>
100 /// <returns>true if the folder was successfully purged</returns>
101 bool PurgeFolder(string userID, InventoryFolderBase folder, UUID session_id);
102
103 /// <summary>
104 /// Get items from a folder.
105 /// </summary>
106 /// <param name="folder"></param>
107 /// <returns>true if the folder was successfully purged</returns>
108 List<InventoryItemBase> GetFolderItems(string userID, UUID folderID, UUID session_id);
109
110 /// <summary>
111 /// Add a new item to the user's inventory
112 /// </summary>
113 /// <param name="item"></param>
114 /// <returns>true if the item was successfully added</returns>
115 bool AddItem(string userID, InventoryItemBase item, UUID session_id);
116
117 /// <summary>
118 /// Update an item in the user's inventory
119 /// </summary>
120 /// <param name="item"></param>
121 /// <returns>true if the item was successfully updated</returns>
122 bool UpdateItem(string userID, InventoryItemBase item, UUID session_id);
123
124 bool MoveItems(string userID, List<InventoryItemBase> items, UUID session_id);
125
126 /// <summary>
127 /// Delete an item from the user's inventory
128 /// </summary>
129 /// <param name="item"></param>
130 /// <returns>true if the item was successfully deleted</returns>
131 bool DeleteItems(string userID, List<UUID> itemIDs, UUID session_id);
132
133 InventoryItemBase QueryItem(string userID, InventoryItemBase item, UUID session_id);
134
135 InventoryFolderBase QueryFolder(string userID, InventoryFolderBase item, UUID session_id);
136
137 int GetAssetPermissions(string userID, UUID assetID, UUID session_id);
138
139 }
140}
diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
deleted file mode 100644
index f86b453..0000000
--- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
+++ /dev/null
@@ -1,582 +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 log4net;
29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Servers.HttpServer;
36using OpenSim.Services.Interfaces;
37using OpenMetaverse;
38
39namespace OpenSim.Services.Connectors
40{
41 public class InventoryServicesConnector : ISessionAuthInventoryService
42 {
43 private static readonly ILog m_log =
44 LogManager.GetLogger(
45 MethodBase.GetCurrentMethod().DeclaringType);
46
47 private string m_ServerURI = String.Empty;
48
49 private Dictionary<UUID, InventoryReceiptCallback> m_RequestingInventory = new Dictionary<UUID, InventoryReceiptCallback>();
50 private Dictionary<UUID, DateTime> m_RequestTime = new Dictionary<UUID, DateTime>();
51
52 public InventoryServicesConnector()
53 {
54 }
55
56 public InventoryServicesConnector(string serverURI)
57 {
58 m_ServerURI = serverURI.TrimEnd('/');
59 }
60
61 public InventoryServicesConnector(IConfigSource source)
62 {
63 Initialise(source);
64 }
65
66 public virtual void Initialise(IConfigSource source)
67 {
68 IConfig inventoryConfig = source.Configs["InventoryService"];
69 if (inventoryConfig == null)
70 {
71 m_log.Error("[INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini");
72 throw new Exception("InventoryService missing from OpenSim.ini");
73 }
74
75 string serviceURI = inventoryConfig.GetString("InventoryServerURI",
76 String.Empty);
77
78 if (serviceURI == String.Empty)
79 {
80 m_log.Error("[INVENTORY CONNECTOR]: No Server URI named in section InventoryService");
81 throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's");
82 }
83 m_ServerURI = serviceURI.TrimEnd('/');
84 }
85
86 #region ISessionAuthInventoryService
87
88 public string Host
89 {
90 get { return m_ServerURI; }
91 }
92
93 /// <summary>
94 /// Caller must catch eventual Exceptions.
95 /// </summary>
96 /// <param name="userID"></param>
97 /// <param name="sessionID"></param>
98 /// <param name="callback"></param>
99 public void GetUserInventory(string userIDStr, UUID sessionID, InventoryReceiptCallback callback)
100 {
101 UUID userID = UUID.Zero;
102 if (UUID.TryParse(userIDStr, out userID))
103 {
104 lock (m_RequestingInventory)
105 {
106 // *HACK ALERT*
107
108 // If an inventory request times out, it blocks any further requests from the
109 // same user, even after a relog. This is bad, and makes me sad.
110
111 // Really, we should detect a timeout and report a failure to the callback,
112 // BUT in my testing i found that it's hard to detect a timeout.. sometimes,
113 // a partial response is recieved, and sometimes a null response.
114
115 // So, for now, add a timer of ten seconds (which is the request timeout).
116
117 // This should basically have the same effect.
118
119 lock (m_RequestTime)
120 {
121 if (m_RequestTime.ContainsKey(userID))
122 {
123 TimeSpan interval = DateTime.Now - m_RequestTime[userID];
124 if (interval.TotalSeconds > 10)
125 {
126 m_RequestTime.Remove(userID);
127 if (m_RequestingInventory.ContainsKey(userID))
128 {
129 m_RequestingInventory.Remove(userID);
130 }
131 }
132 }
133 if (!m_RequestingInventory.ContainsKey(userID))
134 {
135 m_RequestTime.Add(userID, DateTime.Now);
136 m_RequestingInventory.Add(userID, callback);
137 }
138 else
139 {
140 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetUserInventory - ignoring repeated request for user {0}", userID);
141 return;
142 }
143 }
144 }
145
146 m_log.InfoFormat(
147 "[INVENTORY CONNECTOR]: Requesting inventory from {0}/GetInventory/ for user {1}",
148 m_ServerURI, userID);
149
150 RestSessionObjectPosterResponse<Guid, InventoryCollection> requester
151 = new RestSessionObjectPosterResponse<Guid, InventoryCollection>();
152 requester.ResponseCallback = InventoryResponse;
153
154 requester.BeginPostObject(m_ServerURI + "/GetInventory/", userID.Guid, sessionID.ToString(), userID.ToString());
155 }
156 }
157
158 /// <summary>
159 /// Gets the user folder for the given folder-type
160 /// </summary>
161 /// <param name="userID"></param>
162 /// <param name="type"></param>
163 /// <returns></returns>
164 public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string userID, UUID sessionID)
165 {
166 List<InventoryFolderBase> folders = null;
167 Dictionary<AssetType, InventoryFolderBase> dFolders = new Dictionary<AssetType, InventoryFolderBase>();
168 try
169 {
170 folders = SynchronousRestSessionObjectPoster<Guid, List<InventoryFolderBase>>.BeginPostObject(
171 "POST", m_ServerURI + "/SystemFolders/", new Guid(userID), sessionID.ToString(), userID.ToString());
172
173 foreach (InventoryFolderBase f in folders)
174 dFolders[(AssetType)f.Type] = f;
175
176 return dFolders;
177 }
178 catch (Exception e)
179 {
180 // Maybe we're talking to an old inventory server. Try this other thing.
181 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetSystemFolders operation failed, {0} {1} (old sever?). Trying GetInventory.",
182 e.Source, e.Message);
183
184 try
185 {
186 InventoryCollection inventory = SynchronousRestSessionObjectPoster<Guid, InventoryCollection>.BeginPostObject(
187 "POST", m_ServerURI + "/GetInventory/", new Guid(userID), sessionID.ToString(), userID.ToString());
188 folders = inventory.Folders;
189 }
190 catch (Exception ex)
191 {
192 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetInventory operation also failed, {0} {1}. Giving up.",
193 e.Source, ex.Message);
194 }
195
196 if ((folders != null) && (folders.Count > 0))
197 {
198 m_log.DebugFormat("[INVENTORY CONNECTOR]: Received entire inventory ({0} folders) for user {1}",
199 folders.Count, userID);
200 foreach (InventoryFolderBase f in folders)
201 {
202 if ((f.Type != (short)AssetType.Folder) && (f.Type != (short)AssetType.Unknown))
203 dFolders[(AssetType)f.Type] = f;
204 }
205
206 UUID rootFolderID = dFolders[AssetType.Animation].ParentID;
207 InventoryFolderBase rootFolder = new InventoryFolderBase(rootFolderID, new UUID(userID));
208 rootFolder = QueryFolder(userID, rootFolder, sessionID);
209 dFolders[AssetType.Folder] = rootFolder;
210 m_log.DebugFormat("[INVENTORY CONNECTOR]: {0} system folders for user {1}", dFolders.Count, userID);
211 return dFolders;
212 }
213 }
214
215 return new Dictionary<AssetType, InventoryFolderBase>();
216 }
217
218 /// <summary>
219 /// Gets everything (folders and items) inside a folder
220 /// </summary>
221 /// <param name="userId"></param>
222 /// <param name="folderID"></param>
223 /// <returns></returns>
224 public InventoryCollection GetFolderContent(string userID, UUID folderID, UUID sessionID)
225 {
226 try
227 {
228 // normal case
229 return SynchronousRestSessionObjectPoster<Guid, InventoryCollection>.BeginPostObject(
230 "POST", m_ServerURI + "/GetFolderContent/", folderID.Guid, sessionID.ToString(), userID.ToString());
231 }
232 catch (TimeoutException e)
233 {
234 m_log.ErrorFormat(
235 "[INVENTORY CONNECTOR]: GetFolderContent operation to {0} for {1} timed out {2} {3}.",
236 m_ServerURI, folderID, e.Source, e.Message);
237 }
238 catch (Exception e)
239 {
240 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation failed for {0}, {1} {2} (old server?).",
241 folderID, e.Source, e.Message);
242 }
243
244 InventoryCollection nullCollection = new InventoryCollection();
245 nullCollection.Folders = new List<InventoryFolderBase>();
246 nullCollection.Items = new List<InventoryItemBase>();
247 nullCollection.UserID = new UUID(userID);
248 return nullCollection;
249 }
250
251 public bool AddFolder(string userID, InventoryFolderBase folder, UUID sessionID)
252 {
253 try
254 {
255 return SynchronousRestSessionObjectPoster<InventoryFolderBase, bool>.BeginPostObject(
256 "POST", m_ServerURI + "/NewFolder/", folder, sessionID.ToString(), folder.Owner.ToString());
257 }
258 catch (Exception e)
259 {
260 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Add new inventory folder operation failed for {0} {1}, {2} {3}",
261 folder.Name, folder.ID, e.Source, e.Message);
262 }
263
264 return false;
265 }
266
267 public bool UpdateFolder(string userID, InventoryFolderBase folder, UUID sessionID)
268 {
269 try
270 {
271 return SynchronousRestSessionObjectPoster<InventoryFolderBase, bool>.BeginPostObject(
272 "POST", m_ServerURI + "/UpdateFolder/", folder, sessionID.ToString(), folder.Owner.ToString());
273 }
274 catch (Exception e)
275 {
276 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Update inventory folder operation failed for {0} {1}, {2} {3}",
277 folder.Name, folder.ID, e.Source, e.Message);
278 }
279
280 return false;
281 }
282
283 public bool DeleteFolders(string userID, List<UUID> folderIDs, UUID sessionID)
284 {
285 try
286 {
287 List<Guid> guids = new List<Guid>();
288 foreach (UUID u in folderIDs)
289 guids.Add(u.Guid);
290 return SynchronousRestSessionObjectPoster<List<Guid>, bool>.BeginPostObject(
291 "POST", m_ServerURI + "/DeleteFolders/", guids, sessionID.ToString(), userID);
292 }
293 catch (Exception e)
294 {
295 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Delete inventory folders operation failed, {0} {1}",
296 e.Source, e.Message);
297 }
298
299 return false;
300 }
301
302 public bool MoveFolder(string userID, InventoryFolderBase folder, UUID sessionID)
303 {
304 try
305 {
306 return SynchronousRestSessionObjectPoster<InventoryFolderBase, bool>.BeginPostObject(
307 "POST", m_ServerURI + "/MoveFolder/", folder, sessionID.ToString(), folder.Owner.ToString());
308 }
309 catch (Exception e)
310 {
311 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Move inventory folder operation failed for {0} {1}, {2} {3}",
312 folder.Name, folder.ID, e.Source, e.Message);
313 }
314
315 return false;
316 }
317
318 public bool PurgeFolder(string userID, InventoryFolderBase folder, UUID sessionID)
319 {
320 try
321 {
322 return SynchronousRestSessionObjectPoster<InventoryFolderBase, bool>.BeginPostObject(
323 "POST", m_ServerURI + "/PurgeFolder/", folder, sessionID.ToString(), folder.Owner.ToString());
324 }
325 catch (Exception e)
326 {
327 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Purge inventory folder operation failed for {0} {1}, {2} {3}",
328 folder.Name, folder.ID, e.Source, e.Message);
329 }
330
331 return false;
332 }
333
334 public List<InventoryItemBase> GetFolderItems(string userID, UUID folderID, UUID sessionID)
335 {
336 try
337 {
338 InventoryFolderBase folder = new InventoryFolderBase(folderID, new UUID(userID));
339 return SynchronousRestSessionObjectPoster<InventoryFolderBase, List<InventoryItemBase>>.BeginPostObject(
340 "POST", m_ServerURI + "/GetItems/", folder, sessionID.ToString(), userID);
341 }
342 catch (Exception e)
343 {
344 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Get folder items operation failed for folder {0}, {1} {2}",
345 folderID, e.Source, e.Message);
346 }
347
348 return null;
349 }
350
351 public bool AddItem(string userID, InventoryItemBase item, UUID sessionID)
352 {
353 try
354 {
355 return SynchronousRestSessionObjectPoster<InventoryItemBase, bool>.BeginPostObject(
356 "POST", m_ServerURI + "/NewItem/", item, sessionID.ToString(), item.Owner.ToString());
357 }
358 catch (Exception e)
359 {
360 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Add new inventory item operation failed for {0} {1}, {2} {3}",
361 item.Name, item.ID, e.Source, e.Message);
362 }
363
364 return false;
365 }
366
367 public bool UpdateItem(string userID, InventoryItemBase item, UUID sessionID)
368 {
369 try
370 {
371 return SynchronousRestSessionObjectPoster<InventoryItemBase, bool>.BeginPostObject(
372 "POST", m_ServerURI + "/NewItem/", item, sessionID.ToString(), item.Owner.ToString());
373 }
374 catch (Exception e)
375 {
376 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Update new inventory item operation failed for {0} {1}, {2} {3}",
377 item.Name, item.ID, e.Source, e.Message);
378 }
379
380 return false;
381 }
382
383 /**
384 * MoveItems Async group
385 */
386
387 delegate void MoveItemsDelegate(string userID, List<InventoryItemBase> items, UUID sessionID);
388
389 private void MoveItemsAsync(string userID, List<InventoryItemBase> items, UUID sessionID)
390 {
391 if (items == null)
392 {
393 m_log.WarnFormat("[INVENTORY CONNECTOR]: request to move items got a null list.");
394 return;
395 }
396
397 try
398 {
399 //SynchronousRestSessionObjectPoster<List<InventoryItemBase>, bool>.BeginPostObject(
400 // "POST", m_ServerURI + "/MoveItems/", items, sessionID.ToString(), userID.ToString());
401
402 //// Success
403 //return;
404 string uri = m_ServerURI + "/inventory/" + userID;
405 if (SynchronousRestObjectRequester.
406 MakeRequest<List<InventoryItemBase>, bool>("PUT", uri, items))
407 m_log.DebugFormat("[INVENTORY CONNECTOR]: move {0} items poster succeeded {1}", items.Count, uri);
408 else
409 m_log.DebugFormat("[INVENTORY CONNECTOR]: move {0} items poster failed {1}", items.Count, uri); ;
410
411 return;
412
413 }
414 catch (Exception e)
415 {
416 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Move inventory items operation failed, {0} {1} (old server?). Trying slow way.",
417 e.Source, e.Message);
418 }
419
420 }
421
422 private void MoveItemsCompleted(IAsyncResult iar)
423 {
424 MoveItemsDelegate d = (MoveItemsDelegate)iar.AsyncState;
425 d.EndInvoke(iar);
426 }
427
428 public bool MoveItems(string userID, List<InventoryItemBase> items, UUID sessionID)
429 {
430 MoveItemsDelegate d = MoveItemsAsync;
431 d.BeginInvoke(userID, items, sessionID, MoveItemsCompleted, d);
432 return true;
433 }
434
435 public bool DeleteItems(string userID, List<UUID> items, UUID sessionID)
436 {
437 try
438 {
439 List<Guid> guids = new List<Guid>();
440 foreach (UUID u in items)
441 guids.Add(u.Guid);
442 return SynchronousRestSessionObjectPoster<List<Guid>, bool>.BeginPostObject(
443 "POST", m_ServerURI + "/DeleteItem/", guids, sessionID.ToString(), userID);
444 }
445 catch (Exception e)
446 {
447 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Delete inventory items operation failed, {0} {1}",
448 e.Source, e.Message);
449 }
450
451 return false;
452 }
453
454 public InventoryItemBase QueryItem(string userID, InventoryItemBase item, UUID sessionID)
455 {
456 try
457 {
458 return SynchronousRestSessionObjectPoster<InventoryItemBase, InventoryItemBase>.BeginPostObject(
459 "POST", m_ServerURI + "/QueryItem/", item, sessionID.ToString(), item.Owner.ToString());
460 }
461 catch (Exception e)
462 {
463 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Query inventory item operation failed, {0} {1}",
464 e.Source, e.Message);
465 }
466
467 return null;
468 }
469
470 public InventoryFolderBase QueryFolder(string userID, InventoryFolderBase folder, UUID sessionID)
471 {
472 try
473 {
474 return SynchronousRestSessionObjectPoster<InventoryFolderBase, InventoryFolderBase>.BeginPostObject(
475 "POST", m_ServerURI + "/QueryFolder/", folder, sessionID.ToString(), userID);
476 }
477 catch (Exception e)
478 {
479 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Query inventory folder operation failed, {0} {1}",
480 e.Source, e.Message);
481 }
482
483 return null;
484 }
485
486 public int GetAssetPermissions(string userID, UUID assetID, UUID sessionID)
487 {
488 try
489 {
490 InventoryItemBase item = new InventoryItemBase();
491 item.Owner = new UUID(userID);
492 item.AssetID = assetID;
493 return SynchronousRestSessionObjectPoster<InventoryItemBase, int>.BeginPostObject(
494 "POST", m_ServerURI + "/AssetPermissions/", item, sessionID.ToString(), userID);
495 }
496 catch (Exception e)
497 {
498 m_log.ErrorFormat("[INVENTORY CONNECTOR]: AssetPermissions operation failed, {0} {1}",
499 e.Source, e.Message);
500 }
501
502 return 0;
503 }
504
505 #endregion
506
507 /// <summary>
508 /// Callback used by the inventory server GetInventory request
509 /// </summary>
510 /// <param name="userID"></param>
511 private void InventoryResponse(InventoryCollection response)
512 {
513 UUID userID = response.UserID;
514 InventoryReceiptCallback callback = null;
515 lock (m_RequestingInventory)
516 {
517 if (m_RequestingInventory.ContainsKey(userID))
518 {
519 callback = m_RequestingInventory[userID];
520 m_RequestingInventory.Remove(userID);
521 lock (m_RequestTime)
522 {
523 if (m_RequestTime.ContainsKey(userID))
524 {
525 m_RequestTime.Remove(userID);
526 }
527 }
528 }
529 else
530 {
531 m_log.WarnFormat(
532 "[INVENTORY CONNECTOR]: " +
533 "Received inventory response for {0} for which we do not have a record of requesting!",
534 userID);
535 return;
536 }
537 }
538
539 m_log.InfoFormat("[INVENTORY CONNECTOR]: " +
540 "Received inventory response for user {0} containing {1} folders and {2} items",
541 userID, response.Folders.Count, response.Items.Count);
542
543 InventoryFolderImpl rootFolder = null;
544
545 ICollection<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
546 ICollection<InventoryItemBase> items = new List<InventoryItemBase>();
547
548 foreach (InventoryFolderBase folder in response.Folders)
549 {
550 if (folder.ParentID == UUID.Zero)
551 {
552 rootFolder = new InventoryFolderImpl(folder);
553 folders.Add(rootFolder);
554
555 break;
556 }
557 }
558
559 if (rootFolder != null)
560 {
561 foreach (InventoryFolderBase folder in response.Folders)
562 {
563 if (folder.ID != rootFolder.ID)
564 {
565 folders.Add(new InventoryFolderImpl(folder));
566 }
567 }
568
569 foreach (InventoryItemBase item in response.Items)
570 {
571 items.Add(item);
572 }
573 }
574 else
575 {
576 m_log.ErrorFormat("[INVENTORY CONNECTOR]: Did not get back an inventory containing a root folder for user {0}", userID);
577 }
578
579 callback(folders, items);
580 }
581 }
582}
diff --git a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs
deleted file mode 100644
index a7aa138..0000000
--- a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs
+++ /dev/null
@@ -1,196 +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 log4net;
29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Servers.HttpServer;
36using OpenSim.Services.Interfaces;
37using OpenMetaverse;
38
39namespace OpenSim.Services.Connectors
40{
41 /// <summary>
42 /// This connector is temporary. It's used by the user server, before that server is refactored.
43 /// </summary>
44 public class QuickAndDirtyInventoryServiceConnector : IInventoryService
45 {
46// private static readonly ILog m_log =
47// LogManager.GetLogger(
48// MethodBase.GetCurrentMethod().DeclaringType);
49
50 private string m_ServerURI = String.Empty;
51
52 //private Dictionary<UUID, InventoryReceiptCallback> m_RequestingInventory = new Dictionary<UUID, InventoryReceiptCallback>();
53
54 public QuickAndDirtyInventoryServiceConnector()
55 {
56 }
57
58 public QuickAndDirtyInventoryServiceConnector(string serverURI)
59 {
60 m_ServerURI = serverURI.TrimEnd('/');
61 }
62
63 /// <summary>
64 /// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/>
65 /// </summary>
66 /// <param name="userId"></param>
67 /// <returns></returns>
68 public bool CreateUserInventory(UUID userId)
69 {
70 return SynchronousRestObjectPoster.BeginPostObject<Guid, bool>(
71 "POST", m_ServerURI + "CreateInventory/", userId.Guid);
72 }
73
74 /// <summary>
75 /// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/>
76 /// </summary>
77 /// <param name="userId"></param>
78 /// <returns></returns>
79 public List<InventoryFolderBase> GetInventorySkeleton(UUID userId)
80 {
81 return SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>(
82 "POST", m_ServerURI + "RootFolders/", userId.Guid);
83 }
84
85 /// <summary>
86 /// Returns a list of all the active gestures in a user's inventory.
87 /// </summary>
88 /// <param name="userId">
89 /// The <see cref="UUID"/> of the user
90 /// </param>
91 /// <returns>
92 /// A flat list of the gesture items.
93 /// </returns>
94 public List<InventoryItemBase> GetActiveGestures(UUID userId)
95 {
96 return SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryItemBase>>(
97 "POST", m_ServerURI + "ActiveGestures/", userId.Guid);
98 }
99
100 public InventoryCollection GetUserInventory(UUID userID)
101 {
102 return null;
103 }
104
105 public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
106 {
107 }
108
109 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
110 {
111 return null;
112 }
113
114 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
115 {
116 return null;
117 }
118
119 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
120 {
121 return null;
122 }
123
124 public bool AddFolder(InventoryFolderBase folder)
125 {
126 return false;
127 }
128
129 public bool UpdateFolder(InventoryFolderBase folder)
130 {
131 return false;
132 }
133
134 public bool MoveFolder(InventoryFolderBase folder)
135 {
136 return false;
137 }
138
139 public bool DeleteFolders(UUID ownerID, List<UUID> folderIDs)
140 {
141 return false;
142 }
143
144
145 public bool PurgeFolder(InventoryFolderBase folder)
146 {
147 return false;
148 }
149
150 public bool AddItem(InventoryItemBase item)
151 {
152 return false;
153 }
154
155 public bool UpdateItem(InventoryItemBase item)
156 {
157 return false;
158 }
159
160 public bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
161 {
162 return false;
163 }
164
165 public bool DeleteItems(UUID owner, List<UUID> itemIDs)
166 {
167 return false;
168 }
169
170 public InventoryItemBase GetItem(InventoryItemBase item)
171 {
172 return null;
173 }
174
175 public InventoryFolderBase GetFolder(InventoryFolderBase folder)
176 {
177 return null;
178 }
179
180 public bool HasInventoryForUser(UUID userID)
181 {
182 return false;
183 }
184
185 public InventoryFolderBase GetRootFolder(UUID userID)
186 {
187 return null;
188 }
189
190 public int GetAssetPermissions(UUID userID, UUID assetID)
191 {
192 return 0;
193 }
194
195 }
196}
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
new file mode 100644
index 0000000..93fdae3
--- /dev/null
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
@@ -0,0 +1,262 @@
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 System.Reflection;
31using System.Net;
32using System.IO;
33using System.Timers;
34using System.Drawing;
35using System.Drawing.Imaging;
36
37using log4net;
38using Mono.Addins;
39using Nini.Config;
40using OpenSim.Framework;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes;
43using OpenMetaverse;
44using OpenMetaverse.StructuredData;
45
46namespace OpenSim.Region.OptionalModules.Simian
47{
48 /// <summary>
49 /// </summary>
50 /// <remarks>
51 /// </remarks>
52
53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianGridMaptile")]
54 public class SimianGridMaptile : ISharedRegionModule
55 {
56 private static readonly ILog m_log =
57 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58
59 private bool m_enabled = false;
60 private string m_serverUrl = String.Empty;
61 private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
62
63 private int m_refreshtime = 0;
64 private int m_lastrefresh = 0;
65 private System.Timers.Timer m_refreshTimer = new System.Timers.Timer();
66
67 #region ISharedRegionModule
68
69 public Type ReplaceableInterface { get { return null; } }
70 public string Name { get { return "SimianGridMaptile"; } }
71 public void RegionLoaded(Scene scene) { }
72 public void Close() { }
73
74 ///<summary>
75 ///
76 ///</summary>
77 public void Initialise(IConfigSource source)
78 {
79 IConfig config = source.Configs["SimianGridMaptiles"];
80 if (config == null)
81 return;
82
83 if (! config.GetBoolean("Enabled", false))
84 return;
85
86 m_serverUrl = config.GetString("MaptileURL");
87 if (String.IsNullOrEmpty(m_serverUrl))
88 return;
89
90 int refreshseconds = Convert.ToInt32(config.GetString("RefreshTime"));
91 if (refreshseconds <= 0)
92 return;
93
94 m_refreshtime = refreshseconds * 1000; // convert from seconds to ms
95 m_log.InfoFormat("[SIMIAN MAPTILE] enabled with refresh timeout {0} and URL {1}",
96 m_refreshtime,m_serverUrl);
97
98 m_enabled = true;
99 }
100
101 ///<summary>
102 ///
103 ///</summary>
104 public void PostInitialise()
105 {
106 if (m_enabled)
107 {
108 m_refreshTimer.Enabled = true;
109 m_refreshTimer.AutoReset = true;
110 m_refreshTimer.Interval = 5 * 60 * 1000; // every 5 minutes
111 m_refreshTimer.Elapsed += new ElapsedEventHandler(HandleMaptileRefresh);
112 }
113 }
114
115
116 ///<summary>
117 ///
118 ///</summary>
119 public void AddRegion(Scene scene)
120 {
121 if (! m_enabled)
122 return;
123
124 // Every shared region module has to maintain an indepedent list of
125 // currently running regions
126 lock (m_scenes)
127 m_scenes[scene.RegionInfo.RegionID] = scene;
128 }
129
130 ///<summary>
131 ///
132 ///</summary>
133 public void RemoveRegion(Scene scene)
134 {
135 if (! m_enabled)
136 return;
137
138 lock (m_scenes)
139 m_scenes.Remove(scene.RegionInfo.RegionID);
140 }
141
142 #endregion ISharedRegionModule
143
144 ///<summary>
145 ///
146 ///</summary>
147 private void HandleMaptileRefresh(object sender, EventArgs ea)
148 {
149 // this approach is a bit convoluted becase we want to wait for the
150 // first upload to happen on startup but after all the objects are
151 // loaded and initialized
152 if (m_lastrefresh > 0 && Util.EnvironmentTickCountSubtract(m_lastrefresh) < m_refreshtime)
153 return;
154
155 m_log.DebugFormat("[SIMIAN MAPTILE] map refresh fired");
156 lock (m_scenes)
157 {
158 foreach (IScene scene in m_scenes.Values)
159 {
160 try
161 {
162 UploadMapTile(scene);
163 }
164 catch (Exception ex)
165 {
166 m_log.WarnFormat("[SIMIAN MAPTILE] something bad happened {0}",ex.Message);
167 }
168 }
169 }
170
171 m_lastrefresh = Util.EnvironmentTickCount();
172 }
173
174 ///<summary>
175 ///
176 ///</summary>
177 private void UploadMapTile(IScene scene)
178 {
179 m_log.DebugFormat("[SIMIAN MAPTILE]: upload maptile for {0}",scene.RegionInfo.RegionName);
180
181 // Create a PNG map tile and upload it to the AddMapTile API
182 byte[] pngData = Utils.EmptyBytes;
183 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>();
184 if (tileGenerator == null)
185 {
186 m_log.Warn("[SIMIAN MAPTILE]: Cannot upload PNG map tile without an ImageGenerator");
187 return;
188 }
189
190 using (Image mapTile = tileGenerator.CreateMapTile())
191 {
192 using (MemoryStream stream = new MemoryStream())
193 {
194 mapTile.Save(stream, ImageFormat.Png);
195 pngData = stream.ToArray();
196 }
197 }
198
199 List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
200 {
201 new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()),
202 new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()),
203 new MultipartForm.File("Tile", "tile.png", "image/png", pngData)
204 };
205
206 string errorMessage = null;
207 int tickstart = Util.EnvironmentTickCount();
208
209 // Make the remote storage request
210 try
211 {
212 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl);
213 request.Timeout = 20000;
214 request.ReadWriteTimeout = 5000;
215
216 using (HttpWebResponse response = MultipartForm.Post(request, postParameters))
217 {
218 using (Stream responseStream = response.GetResponseStream())
219 {
220 string responseStr = responseStream.GetStreamString();
221 OSD responseOSD = OSDParser.Deserialize(responseStr);
222 if (responseOSD.Type == OSDType.Map)
223 {
224 OSDMap responseMap = (OSDMap)responseOSD;
225 if (responseMap["Success"].AsBoolean())
226 return;
227
228 errorMessage = "Upload failed: " + responseMap["Message"].AsString();
229 }
230 else
231 {
232 errorMessage = "Response format was invalid:\n" + responseStr;
233 }
234 }
235 }
236 }
237 catch (WebException we)
238 {
239 errorMessage = we.Message;
240 if (we.Status == WebExceptionStatus.ProtocolError)
241 {
242 HttpWebResponse webResponse = (HttpWebResponse)we.Response;
243 errorMessage = String.Format("[{0}] {1}",
244 webResponse.StatusCode,webResponse.StatusDescription);
245 }
246 }
247 catch (Exception ex)
248 {
249 errorMessage = ex.Message;
250 }
251 finally
252 {
253 // This just dumps a warning for any operation that takes more than 100 ms
254 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
255 m_log.DebugFormat("[SIMIAN MAPTILE]: map tile uploaded in {0}ms",tickdiff);
256 }
257
258 m_log.WarnFormat("[SIMIAN MAPTILE]: Failed to store {0} byte tile for {1}: {2}",
259 pngData.Length, scene.RegionInfo.RegionName, errorMessage);
260 }
261 }
262} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index 2c8277f..1c31402 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -48,6 +48,9 @@ namespace OpenSim.Services.Connectors.Simulation
48 { 48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 // we use this dictionary to track the pending updateagent requests, maps URI --> position update
52 private Dictionary<string,AgentPosition> m_updateAgentQueue = new Dictionary<string,AgentPosition>();
53
51 //private GridRegion m_Region; 54 //private GridRegion m_Region;
52 55
53 public SimulationServiceConnector() 56 public SimulationServiceConnector()
@@ -76,9 +79,6 @@ namespace OpenSim.Services.Connectors.Simulation
76 return "agent/"; 79 return "agent/";
77 } 80 }
78 81
79 /// <summary>
80 ///
81 /// </summary>
82 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) 82 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason)
83 { 83 {
84 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent start"); 84 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent start");
@@ -106,6 +106,9 @@ namespace OpenSim.Services.Connectors.Simulation
106 if (result["Success"].AsBoolean()) 106 if (result["Success"].AsBoolean())
107 return true; 107 return true;
108 108
109 m_log.WarnFormat(
110 "[REMOTE SIMULATION CONNECTOR]: Failed to create agent {0} {1} at remote simulator {1}",
111 aCircuit.firstname, aCircuit.lastname, destination.RegionName);
109 reason = result["Message"] != null ? result["Message"].AsString() : "error"; 112 reason = result["Message"] != null ? result["Message"].AsString() : "error";
110 return false; 113 return false;
111 } 114 }
@@ -133,10 +136,56 @@ namespace OpenSim.Services.Connectors.Simulation
133 /// </summary> 136 /// </summary>
134 public bool UpdateAgent(GridRegion destination, AgentPosition data) 137 public bool UpdateAgent(GridRegion destination, AgentPosition data)
135 { 138 {
136 // we need a better throttle for these 139 // The basic idea of this code is that the first thread that needs to
137 // return false; 140 // send an update for a specific avatar becomes the worker for any subsequent
141 // requests until there are no more outstanding requests. Further, only send the most
142 // recent update; this *should* never be needed but some requests get
143 // slowed down and once that happens the problem with service end point
144 // limits kicks in and nothing proceeds
145 string uri = destination.ServerURI + AgentPath() + data.AgentID + "/";
146 lock (m_updateAgentQueue)
147 {
148 if (m_updateAgentQueue.ContainsKey(uri))
149 {
150 // Another thread is already handling
151 // updates for this simulator, just update
152 // the position and return, overwrites are
153 // not a problem since we only care about the
154 // last update anyway
155 m_updateAgentQueue[uri] = data;
156 return true;
157 }
158
159 // Otherwise update the reference and start processing
160 m_updateAgentQueue[uri] = data;
161 }
138 162
139 return UpdateAgent(destination, (IAgentData)data); 163 AgentPosition pos = null;
164 while (true)
165 {
166 lock (m_updateAgentQueue)
167 {
168 // save the position
169 AgentPosition lastpos = pos;
170
171 pos = m_updateAgentQueue[uri];
172
173 // this is true if no one put a new
174 // update in the map since the last
175 // one we processed, if thats the
176 // case then we are done
177 if (pos == lastpos)
178 {
179 m_updateAgentQueue.Remove(uri);
180 return true;
181 }
182 }
183
184 UpdateAgent(destination,(IAgentData)pos);
185 }
186
187 // unreachable
188// return true;
140 } 189 }
141 190
142 /// <summary> 191 /// <summary>
@@ -207,8 +256,10 @@ namespace OpenSim.Services.Connectors.Simulation
207 256
208 /// <summary> 257 /// <summary>
209 /// </summary> 258 /// </summary>
210 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position) 259 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string reason)
211 { 260 {
261 reason = "Failed to contact destination";
262
212 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position); 263 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position);
213 264
214 IPEndPoint ext = destination.ExternalEndPoint; 265 IPEndPoint ext = destination.ExternalEndPoint;
@@ -223,7 +274,11 @@ namespace OpenSim.Services.Connectors.Simulation
223 try 274 try
224 { 275 {
225 OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 10000); 276 OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 10000);
226 bool success = result["Success"].AsBoolean(); 277 bool success = result["success"].AsBoolean();
278 reason = result["reason"].AsString();
279
280 //m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}", uri, success);
281
227 if (!success) 282 if (!success)
228 { 283 {
229 if (result.ContainsKey("Message")) 284 if (result.ContainsKey("Message"))
@@ -234,8 +289,21 @@ namespace OpenSim.Services.Connectors.Simulation
234 m_log.Info("[REMOTE SIMULATION CONNECTOR]: The above web util error was caused by a TP to a sim that doesn't support QUERYACCESS and can be ignored"); 289 m_log.Info("[REMOTE SIMULATION CONNECTOR]: The above web util error was caused by a TP to a sim that doesn't support QUERYACCESS and can be ignored");
235 return true; 290 return true;
236 } 291 }
292
293 reason = result["Message"];
294 }
295 else
296 {
297 reason = "Communications failure";
237 } 298 }
299
300 return false;
238 } 301 }
302
303 OSDMap resp = (OSDMap)result["_Result"];
304 success = resp["success"].AsBoolean();
305 reason = resp["reason"].AsString();
306
239 return success; 307 return success;
240 } 308 }
241 catch (Exception e) 309 catch (Exception e)
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index 125c2be..985d77b 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -271,6 +271,7 @@ namespace OpenSim.Services.GridService
271 { 271 {
272 List<GridRegion> rinfos = new List<GridRegion>(); 272 List<GridRegion> rinfos = new List<GridRegion>();
273 RegionData region = m_Database.Get(regionID, scopeID); 273 RegionData region = m_Database.Get(regionID, scopeID);
274
274 if (region != null) 275 if (region != null)
275 { 276 {
276 // Not really? Maybe? 277 // Not really? Maybe?
@@ -278,15 +279,24 @@ namespace OpenSim.Services.GridService
278 region.posX + (int)Constants.RegionSize + 1, region.posY + (int)Constants.RegionSize + 1, scopeID); 279 region.posX + (int)Constants.RegionSize + 1, region.posY + (int)Constants.RegionSize + 1, scopeID);
279 280
280 foreach (RegionData rdata in rdatas) 281 foreach (RegionData rdata in rdatas)
282 {
281 if (rdata.RegionID != regionID) 283 if (rdata.RegionID != regionID)
282 { 284 {
283 int flags = Convert.ToInt32(rdata.Data["flags"]); 285 int flags = Convert.ToInt32(rdata.Data["flags"]);
284 if ((flags & (int)Data.RegionFlags.Hyperlink) == 0) // no hyperlinks as neighbours 286 if ((flags & (int)Data.RegionFlags.Hyperlink) == 0) // no hyperlinks as neighbours
285 rinfos.Add(RegionData2RegionInfo(rdata)); 287 rinfos.Add(RegionData2RegionInfo(rdata));
286 } 288 }
289 }
287 290
291 m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighbours", region.RegionName, rinfos.Count);
288 } 292 }
289 m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighours", region.RegionName, rinfos.Count); 293 else
294 {
295 m_log.WarnFormat(
296 "[GRID SERVICE]: GetNeighbours() called for scope {0}, region {1} but no such region found",
297 scopeID, regionID);
298 }
299
290 return rinfos; 300 return rinfos;
291 } 301 }
292 302
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index c02c813..a4aa44d 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -121,7 +121,7 @@ namespace OpenSim.Services.GridService
121 121
122 m_Check4096 = gridConfig.GetBoolean("Check4096", true); 122 m_Check4096 = gridConfig.GetBoolean("Check4096", true);
123 123
124 m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", string.Empty); 124 m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", "maptiles");
125 125
126 m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); 126 m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService);
127 127
@@ -180,44 +180,18 @@ namespace OpenSim.Services.GridService
180 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason) 180 public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason)
181 { 181 {
182 reason = string.Empty; 182 reason = string.Empty;
183 string host = "127.0.0.1";
184 string portstr;
185 string regionName = "";
186 uint port = 0; 183 uint port = 0;
187 string[] parts = mapName.Split(new char[] { ':' }); 184 string[] parts = mapName.Split(new char[] {':'});
188 if (parts.Length >= 1) 185 string regionName = String.Empty;
186 if (parts.Length > 1)
189 { 187 {
190 host = parts[0]; 188 regionName = mapName.Substring(parts[0].Length + 1);
189 regionName = regionName.Trim(new char[] {'"'});
191 } 190 }
192 if (parts.Length >= 2)
193 {
194 portstr = parts[1];
195 //m_log.Debug("-- port = " + portstr);
196 if (!UInt32.TryParse(portstr, out port))
197 regionName = parts[1];
198 }
199 // always take the last one
200 if (parts.Length >= 3)
201 {
202 regionName = parts[2];
203 }
204
205 //// Sanity check.
206 //try
207 //{
208 // Util.GetHostFromDNS(host);
209 //}
210 //catch
211 //{
212 // reason = "Malformed hostname";
213 // return null;
214 //}
215
216 GridRegion regInfo; 191 GridRegion regInfo;
217 bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, ownerID, out regInfo, out reason); 192 if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, parts[0], ownerID, out regInfo, out reason))
218 if (success)
219 { 193 {
220 regInfo.RegionName = mapName; 194 regInfo.RegionName = mapName;
221 return regInfo; 195 return regInfo;
222 } 196 }
223 197
@@ -313,9 +287,9 @@ namespace OpenSim.Services.GridService
313 287
314 regInfo.RegionID = regionID; 288 regInfo.RegionID = regionID;
315 289
316 if ( externalName == string.Empty ) 290 if (externalName == string.Empty)
317 regInfo.RegionName = regInfo.ServerURI; 291 regInfo.RegionName = regInfo.ServerURI;
318 else 292 else
319 regInfo.RegionName = externalName; 293 regInfo.RegionName = externalName;
320 294
321 m_log.Debug("[HYPERGRID LINKER]: naming linked region " + regInfo.RegionName); 295 m_log.Debug("[HYPERGRID LINKER]: naming linked region " + regInfo.RegionName);
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 12dda48..09e785f 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -253,7 +253,7 @@ namespace OpenSim.Services.HypergridService
253 253
254 TravelingAgentInfo travel = m_TravelingAgents[sessionID]; 254 TravelingAgentInfo travel = m_TravelingAgents[sessionID];
255 255
256 return travel.GridExternalName == thisGridExternalName; 256 return travel.GridExternalName.ToLower() == thisGridExternalName.ToLower();
257 } 257 }
258 258
259 public bool VerifyClient(UUID sessionID, string reportedIP) 259 public bool VerifyClient(UUID sessionID, string reportedIP)
diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs
index f08e1c0..f2184fc 100644
--- a/OpenSim/Services/Interfaces/ISimulationService.cs
+++ b/OpenSim/Services/Interfaces/ISimulationService.cs
@@ -40,6 +40,13 @@ namespace OpenSim.Services.Interfaces
40 40
41 #region Agents 41 #region Agents
42 42
43 /// <summary>
44 /// Ask the simulator hosting the destination to create an agent on that region.
45 /// </summary>
46 /// <param name="destination"></param>
47 /// <param name="aCircuit"></param>
48 /// <param name="flags"></param>
49 /// <param name="reason">Reason message in the event of a failure.</param>
43 bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason); 50 bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason);
44 51
45 /// <summary> 52 /// <summary>
@@ -60,7 +67,7 @@ namespace OpenSim.Services.Interfaces
60 67
61 bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent); 68 bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent);
62 69
63 bool QueryAccess(GridRegion destination, UUID id, Vector3 position); 70 bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string reason);
64 71
65 /// <summary> 72 /// <summary>
66 /// Message from receiving region to departing region, telling it got contacted by the client. 73 /// Message from receiving region to departing region, telling it got contacted by the client.
diff --git a/OpenSim/Tests/Common/DoubleToleranceConstraint.cs b/OpenSim/Tests/Common/DoubleToleranceConstraint.cs
index c397a62..b2f2057 100644
--- a/OpenSim/Tests/Common/DoubleToleranceConstraint.cs
+++ b/OpenSim/Tests/Common/DoubleToleranceConstraint.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using NUnit.Framework; 29using NUnit.Framework;
30using NUnit.Framework.Constraints;
30 31
31namespace OpenSim.Tests.Common 32namespace OpenSim.Tests.Common
32{ 33{
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 147571b..7b7d66e 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -560,8 +560,11 @@ namespace OpenSim.Tests.Common.Mock
560 agentData.lastname = m_lastName; 560 agentData.lastname = m_lastName;
561 561
562 ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>(); 562 ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
563 agentData.CapsPath = capsModule.GetCapsPath(m_agentId); 563 if (capsModule != null)
564 agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId)); 564 {
565 agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
566 agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId));
567 }
565 568
566 return agentData; 569 return agentData;
567 } 570 }
diff --git a/OpenSim/Tests/Common/Setup/AssetHelpers.cs b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
index 8647cfe..ff4423f 100644
--- a/OpenSim/Tests/Common/Setup/AssetHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Tests.Common
68 return CreateAsset( 68 return CreateAsset(
69 assetUuid, 69 assetUuid,
70 AssetType.Object, 70 AssetType.Object,
71 Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(sog)), 71 Encoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)),
72 sog.OwnerID); 72 sog.OwnerID);
73 } 73 }
74 74
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
index 8b16496..aa4b285 100644
--- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
@@ -57,21 +57,12 @@ namespace OpenSim.Tests.Common.Setup
57 /// </summary> 57 /// </summary>
58 public class SceneSetupHelpers 58 public class SceneSetupHelpers
59 { 59 {
60 // These static variables in order to allow regions to be linked by shared modules and same
61 // CommunicationsManager.
62 private static ISharedRegionModule m_assetService = null;
63// private static ISharedRegionModule m_authenticationService = null;
64 private static ISharedRegionModule m_inventoryService = null;
65 private static ISharedRegionModule m_gridService = null;
66 private static ISharedRegionModule m_userAccountService = null;
67 private static ISharedRegionModule m_presenceService = null;
68
69 /// <summary> 60 /// <summary>
70 /// Set up a test scene 61 /// Set up a test scene
71 /// </summary> 62 /// </summary>
72 /// 63 /// <remarks>
73 /// Automatically starts service threads, as would the normal runtime. 64 /// Automatically starts service threads, as would the normal runtime.
74 /// 65 /// </remarks>
75 /// <returns></returns> 66 /// <returns></returns>
76 public static TestScene SetupScene() 67 public static TestScene SetupScene()
77 { 68 {
@@ -86,24 +77,9 @@ namespace OpenSim.Tests.Common.Setup
86 /// <returns></returns> 77 /// <returns></returns>
87 public static TestScene SetupScene(String realServices) 78 public static TestScene SetupScene(String realServices)
88 { 79 {
89 return SetupScene( 80 return SetupScene("Unit test region", UUID.Random(), 1000, 1000, realServices);
90 "Unit test region", UUID.Random(), 1000, 1000, realServices);
91 } 81 }
92 82
93 // REFACTORING PROBLEM. No idea what the difference is with the previous one
94 ///// <summary>
95 ///// Set up a test scene
96 ///// </summary>
97 /////
98 ///// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param>
99 ///// <param name="cm">This should be the same if simulating two scenes within a standalone</param>
100 ///// <returns></returns>
101 //public static TestScene SetupScene(String realServices)
102 //{
103 // return SetupScene(
104 // "Unit test region", UUID.Random(), 1000, 1000, "");
105 //}
106
107 /// <summary> 83 /// <summary>
108 /// Set up a test scene 84 /// Set up a test scene
109 /// </summary> 85 /// </summary>
@@ -115,7 +91,7 @@ namespace OpenSim.Tests.Common.Setup
115 /// <returns></returns> 91 /// <returns></returns>
116 public static TestScene SetupScene(string name, UUID id, uint x, uint y) 92 public static TestScene SetupScene(string name, UUID id, uint x, uint y)
117 { 93 {
118 return SetupScene(name, id, x, y,""); 94 return SetupScene(name, id, x, y, "");
119 } 95 }
120 96
121 /// <summary> 97 /// <summary>
@@ -132,24 +108,11 @@ namespace OpenSim.Tests.Common.Setup
132 public static TestScene SetupScene( 108 public static TestScene SetupScene(
133 string name, UUID id, uint x, uint y, String realServices) 109 string name, UUID id, uint x, uint y, String realServices)
134 { 110 {
135 bool newScene = false;
136
137 Console.WriteLine("Setting up test scene {0}", name); 111 Console.WriteLine("Setting up test scene {0}", name);
138 112
139 // REFACTORING PROBLEM!
140 //// If cm is the same as our last commsManager used, this means the tester wants to link
141 //// regions. In this case, don't use the sameshared region modules and dont initialize them again.
142 //// Also, no need to start another MainServer and MainConsole instance.
143 //if (cm == null || cm != commsManager)
144 //{
145 // System.Console.WriteLine("Starting a brand new scene");
146 // newScene = true;
147 MainConsole.Instance = new MockConsole("TEST PROMPT");
148 // MainServer.Instance = new BaseHttpServer(980);
149 // commsManager = cm;
150 //}
151
152 // We must set up a console otherwise setup of some modules may fail 113 // We must set up a console otherwise setup of some modules may fail
114 MainConsole.Instance = new MockConsole("TEST PROMPT");
115
153 RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); 116 RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1");
154 regInfo.RegionName = name; 117 regInfo.RegionName = name;
155 regInfo.RegionID = id; 118 regInfo.RegionID = id;
@@ -164,55 +127,26 @@ namespace OpenSim.Tests.Common.Setup
164 TestScene testScene = new TestScene( 127 TestScene testScene = new TestScene(
165 regInfo, acm, scs, simDataService, estateDataService, null, false, false, false, configSource, null); 128 regInfo, acm, scs, simDataService, estateDataService, null, false, false, false, configSource, null);
166 129
167 INonSharedRegionModule capsModule = new CapabilitiesModule();
168 capsModule.Initialise(new IniConfigSource());
169 testScene.AddRegionModule(capsModule.Name, capsModule);
170 capsModule.AddRegion(testScene);
171
172 IRegionModule godsModule = new GodsModule(); 130 IRegionModule godsModule = new GodsModule();
173 godsModule.Initialise(testScene, new IniConfigSource()); 131 godsModule.Initialise(testScene, new IniConfigSource());
174 testScene.AddModule(godsModule.Name, godsModule); 132 testScene.AddModule(godsModule.Name, godsModule);
175 realServices = realServices.ToLower(); 133 realServices = realServices.ToLower();
176 // IConfigSource config = new IniConfigSource();
177 134
178 // If we have a brand new scene, need to initialize shared region modules 135 LocalAssetServicesConnector assetService = StartAssetService(testScene, realServices.Contains("asset"));
179 if ((m_assetService == null && m_inventoryService == null) || newScene)
180 {
181 if (realServices.Contains("asset"))
182 StartAssetService(testScene, true);
183 else
184 StartAssetService(testScene, false);
185
186 // For now, always started a 'real' authentication service
187 StartAuthenticationService(testScene, true);
188
189 if (realServices.Contains("inventory"))
190 StartInventoryService(testScene, true);
191 else
192 StartInventoryService(testScene, false);
193
194 StartGridService(testScene, true);
195 StartUserAccountService(testScene);
196 StartPresenceService(testScene);
197 }
198 // If not, make sure the shared module gets references to this new scene
199 else
200 {
201 m_assetService.AddRegion(testScene);
202 m_assetService.RegionLoaded(testScene);
203 m_inventoryService.AddRegion(testScene);
204 m_inventoryService.RegionLoaded(testScene);
205 m_userAccountService.AddRegion(testScene);
206 m_userAccountService.RegionLoaded(testScene);
207 m_presenceService.AddRegion(testScene);
208 m_presenceService.RegionLoaded(testScene);
209 136
210 } 137 // For now, always started a 'real' authentication service
138 StartAuthenticationService(testScene, true);
139
140 LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene, realServices.Contains("inventory"));
141 StartGridService(testScene, true);
142 LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene);
143 LocalPresenceServicesConnector presenceService = StartPresenceService(testScene);
211 144
212 m_inventoryService.PostInitialise(); 145 inventoryService.PostInitialise();
213 m_assetService.PostInitialise(); 146 assetService.PostInitialise();
214 m_userAccountService.PostInitialise(); 147 userAccountService.PostInitialise();
215 m_presenceService.PostInitialise(); 148 presenceService.PostInitialise();
149
216 testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); 150 testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random();
217 testScene.SetModuleInterfaces(); 151 testScene.SetModuleInterfaces();
218 152
@@ -224,24 +158,15 @@ namespace OpenSim.Tests.Common.Setup
224 testScene.PhysicsScene 158 testScene.PhysicsScene
225 = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); 159 = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test");
226 160
227 // It's really not a good idea to use static variables as they carry over between tests, leading to
228 // problems that are extremely hard to debug. Really, these static fields need to be eliminated -
229 // tests using multiple regions that need to share modules need to find another solution.
230 m_assetService = null;
231 m_inventoryService = null;
232 m_gridService = null;
233 m_userAccountService = null;
234 m_presenceService = null;
235
236 testScene.RegionInfo.EstateSettings = new EstateSettings(); 161 testScene.RegionInfo.EstateSettings = new EstateSettings();
237 testScene.LoginsDisabled = false; 162 testScene.LoginsDisabled = false;
238 163
239 return testScene; 164 return testScene;
240 } 165 }
241 166
242 private static void StartAssetService(Scene testScene, bool real) 167 private static LocalAssetServicesConnector StartAssetService(Scene testScene, bool real)
243 { 168 {
244 ISharedRegionModule assetService = new LocalAssetServicesConnector(); 169 LocalAssetServicesConnector assetService = new LocalAssetServicesConnector();
245 IConfigSource config = new IniConfigSource(); 170 IConfigSource config = new IniConfigSource();
246 config.AddConfig("Modules"); 171 config.AddConfig("Modules");
247 config.AddConfig("AssetService"); 172 config.AddConfig("AssetService");
@@ -255,7 +180,8 @@ namespace OpenSim.Tests.Common.Setup
255 assetService.AddRegion(testScene); 180 assetService.AddRegion(testScene);
256 assetService.RegionLoaded(testScene); 181 assetService.RegionLoaded(testScene);
257 testScene.AddRegionModule(assetService.Name, assetService); 182 testScene.AddRegionModule(assetService.Name, assetService);
258 m_assetService = assetService; 183
184 return assetService;
259 } 185 }
260 186
261 private static void StartAuthenticationService(Scene testScene, bool real) 187 private static void StartAuthenticationService(Scene testScene, bool real)
@@ -279,9 +205,9 @@ namespace OpenSim.Tests.Common.Setup
279 //m_authenticationService = service; 205 //m_authenticationService = service;
280 } 206 }
281 207
282 private static void StartInventoryService(Scene testScene, bool real) 208 private static LocalInventoryServicesConnector StartInventoryService(Scene testScene, bool real)
283 { 209 {
284 ISharedRegionModule inventoryService = new LocalInventoryServicesConnector(); 210 LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector();
285 IConfigSource config = new IniConfigSource(); 211 IConfigSource config = new IniConfigSource();
286 config.AddConfig("Modules"); 212 config.AddConfig("Modules");
287 config.AddConfig("InventoryService"); 213 config.AddConfig("InventoryService");
@@ -301,10 +227,11 @@ namespace OpenSim.Tests.Common.Setup
301 inventoryService.AddRegion(testScene); 227 inventoryService.AddRegion(testScene);
302 inventoryService.RegionLoaded(testScene); 228 inventoryService.RegionLoaded(testScene);
303 testScene.AddRegionModule(inventoryService.Name, inventoryService); 229 testScene.AddRegionModule(inventoryService.Name, inventoryService);
304 m_inventoryService = inventoryService; 230
231 return inventoryService;
305 } 232 }
306 233
307 private static void StartGridService(Scene testScene, bool real) 234 private static LocalGridServicesConnector StartGridService(Scene testScene, bool real)
308 { 235 {
309 IConfigSource config = new IniConfigSource(); 236 IConfigSource config = new IniConfigSource();
310 config.AddConfig("Modules"); 237 config.AddConfig("Modules");
@@ -313,24 +240,25 @@ namespace OpenSim.Tests.Common.Setup
313 config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); 240 config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData");
314 if (real) 241 if (real)
315 config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); 242 config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
316 if (m_gridService == null) 243
317 { 244 LocalGridServicesConnector gridService = new LocalGridServicesConnector();
318 ISharedRegionModule gridService = new LocalGridServicesConnector(); 245 gridService.Initialise(config);
319 gridService.Initialise(config); 246
320 m_gridService = gridService;
321 }
322 //else 247 //else
323 // config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestGridService"); 248 // config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestGridService");
324 m_gridService.AddRegion(testScene); 249 gridService.AddRegion(testScene);
325 m_gridService.RegionLoaded(testScene); 250 gridService.RegionLoaded(testScene);
326 //testScene.AddRegionModule(m_gridService.Name, m_gridService); 251 //testScene.AddRegionModule(m_gridService.Name, m_gridService);
252
253 return gridService;
327 } 254 }
328 255
329 /// <summary> 256 /// <summary>
330 /// Start a user account service 257 /// Start a user account service
331 /// </summary> 258 /// </summary>
332 /// <param name="testScene"></param> 259 /// <param name="testScene"></param>
333 private static void StartUserAccountService(Scene testScene) 260 /// <returns></returns>
261 private static LocalUserAccountServicesConnector StartUserAccountService(Scene testScene)
334 { 262 {
335 IConfigSource config = new IniConfigSource(); 263 IConfigSource config = new IniConfigSource();
336 config.AddConfig("Modules"); 264 config.AddConfig("Modules");
@@ -340,23 +268,21 @@ namespace OpenSim.Tests.Common.Setup
340 config.Configs["UserAccountService"].Set( 268 config.Configs["UserAccountService"].Set(
341 "LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService"); 269 "LocalServiceModule", "OpenSim.Services.UserAccountService.dll:UserAccountService");
342 270
343 if (m_userAccountService == null) 271 LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector();
344 { 272 userAccountService.Initialise(config);
345 ISharedRegionModule userAccountService = new LocalUserAccountServicesConnector();
346 userAccountService.Initialise(config);
347 m_userAccountService = userAccountService;
348 }
349 273
350 m_userAccountService.AddRegion(testScene); 274 userAccountService.AddRegion(testScene);
351 m_userAccountService.RegionLoaded(testScene); 275 userAccountService.RegionLoaded(testScene);
352 testScene.AddRegionModule(m_userAccountService.Name, m_userAccountService); 276 testScene.AddRegionModule(userAccountService.Name, userAccountService);
277
278 return userAccountService;
353 } 279 }
354 280
355 /// <summary> 281 /// <summary>
356 /// Start a presence service 282 /// Start a presence service
357 /// </summary> 283 /// </summary>
358 /// <param name="testScene"></param> 284 /// <param name="testScene"></param>
359 private static void StartPresenceService(Scene testScene) 285 private static LocalPresenceServicesConnector StartPresenceService(Scene testScene)
360 { 286 {
361 IConfigSource config = new IniConfigSource(); 287 IConfigSource config = new IniConfigSource();
362 config.AddConfig("Modules"); 288 config.AddConfig("Modules");
@@ -366,16 +292,14 @@ namespace OpenSim.Tests.Common.Setup
366 config.Configs["PresenceService"].Set( 292 config.Configs["PresenceService"].Set(
367 "LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); 293 "LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService");
368 294
369 if (m_presenceService == null) 295 LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector();
370 { 296 presenceService.Initialise(config);
371 ISharedRegionModule presenceService = new LocalPresenceServicesConnector();
372 presenceService.Initialise(config);
373 m_presenceService = presenceService;
374 }
375 297
376 m_presenceService.AddRegion(testScene); 298 presenceService.AddRegion(testScene);
377 m_presenceService.RegionLoaded(testScene); 299 presenceService.RegionLoaded(testScene);
378 testScene.AddRegionModule(m_presenceService.Name, m_presenceService); 300 testScene.AddRegionModule(presenceService.Name, presenceService);
301
302 return presenceService;
379 } 303 }
380 304
381 /// <summary> 305 /// <summary>
@@ -472,7 +396,7 @@ namespace OpenSim.Tests.Common.Setup
472 /// <summary> 396 /// <summary>
473 /// Add a root agent. 397 /// Add a root agent.
474 /// </summary> 398 /// </summary>
475 /// 399 /// <remarks>
476 /// This function 400 /// This function
477 /// 401 ///
478 /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the 402 /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the
@@ -483,7 +407,7 @@ namespace OpenSim.Tests.Common.Setup
483 /// 407 ///
484 /// This function performs actions equivalent with notifying the scene that an agent is 408 /// This function performs actions equivalent with notifying the scene that an agent is
485 /// coming and then actually connecting the agent to the scene. The one step missed out is the very first 409 /// coming and then actually connecting the agent to the scene. The one step missed out is the very first
486 /// 410 /// </remarks>
487 /// <param name="scene"></param> 411 /// <param name="scene"></param>
488 /// <param name="agentData"></param> 412 /// <param name="agentData"></param>
489 /// <returns></returns> 413 /// <returns></returns>
@@ -504,12 +428,10 @@ namespace OpenSim.Tests.Common.Setup
504 TestClient client = new TestClient(agentData, scene); 428 TestClient client = new TestClient(agentData, scene);
505 scene.AddNewClient(client); 429 scene.AddNewClient(client);
506 430
507 // Stage 3: Invoke agent crossing, which converts the child agent into a root agent (with appearance, 431 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent.
508 // inventory, etc.)
509 //scene.AgentCrossing(agentData.AgentID, new Vector3(90, 90, 90), false); OBSOLETE
510
511 ScenePresence scp = scene.GetScenePresence(agentData.AgentID); 432 ScenePresence scp = scene.GetScenePresence(agentData.AgentID);
512 scp.MakeRootAgent(new Vector3(90, 90, 90), true); 433 scp.CompleteMovement(client);
434 //scp.MakeRootAgent(new Vector3(90, 90, 90), true);
513 435
514 return client; 436 return client;
515 } 437 }
@@ -543,24 +465,5 @@ namespace OpenSim.Tests.Common.Setup
543 465
544 return part; 466 return part;
545 } 467 }
546
547 /// <summary>
548 /// Delete a scene object asynchronously
549 /// </summary>
550 /// <param name="scene"></param>
551 /// <param name="part"></param>
552 /// <param name="action"></param>
553 /// <param name="destinationId"></param>
554 /// <param name="client"></param>
555 public static void DeleteSceneObjectAsync(
556 TestScene scene, SceneObjectPart part, DeRezAction action, UUID destinationId, IClientAPI client)
557 {
558 // Turn off the timer on the async sog deleter - we'll crank it by hand within a unit test
559 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
560 sogd.Enabled = false;
561
562 scene.DeRezObjects(client, new List<uint>() { part.LocalId }, UUID.Zero, action, destinationId);
563 sogd.InventoryDeQueueAndDelete();
564 }
565 } 468 }
566} 469}
diff --git a/OpenSim/Tests/Common/TestHelper.cs b/OpenSim/Tests/Common/TestHelper.cs
index 9d53063..1722e59 100644
--- a/OpenSim/Tests/Common/TestHelper.cs
+++ b/OpenSim/Tests/Common/TestHelper.cs
@@ -27,11 +27,10 @@
27 27
28using System; 28using System;
29using System.Diagnostics; 29using System.Diagnostics;
30using NUnit.Framework;
30 31
31namespace OpenSim.Tests.Common 32namespace OpenSim.Tests.Common
32{ 33{
33 public delegate void TestDelegate();
34
35 public class TestHelper 34 public class TestHelper
36 { 35 {
37 public static bool AssertThisDelegateCausesArgumentException(TestDelegate d) 36 public static bool AssertThisDelegateCausesArgumentException(TestDelegate d)
diff --git a/OpenSim/Tests/Common/VectorToleranceConstraint.cs b/OpenSim/Tests/Common/VectorToleranceConstraint.cs
index 118cc70..2fa20ed 100644
--- a/OpenSim/Tests/Common/VectorToleranceConstraint.cs
+++ b/OpenSim/Tests/Common/VectorToleranceConstraint.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using OpenMetaverse; 29using OpenMetaverse;
30using NUnit.Framework; 30using NUnit.Framework;
31using NUnit.Framework.Constraints;
31 32
32namespace OpenSim.Tests.Common 33namespace OpenSim.Tests.Common
33{ 34{
diff --git a/TESTING.txt b/TESTING.txt
index e0a7748..54fc976 100644
--- a/TESTING.txt
+++ b/TESTING.txt
@@ -2,23 +2,14 @@
2 2
3== Running Tests == 3== Running Tests ==
4 4
5On Linux: 5On Linux you will need to have NUnit installed (http://www.nunit.org).
6This is commonly available in distribution package repositories.
6 7
7 > nant test 8When this is installed, run the command
8
9This will print out to the console the test state.
10
11On Windows: Please see the TESTING ON WINDOWS section below.
12 9
10 > nant test
13 11
14Also, every checkin will run tests that are kicked off by bamboo. 12Please see the TESTING ON WINDOWS section below for Windows instructions.
15Results are posted here: http://www.opensimulator.org:8085/ as well as
16to #opensim-dev IRC channel.
17
18== Writing Tests ==
19
20Tests are written to run under NUnit. For more information on NUnit
21please see: http://www.nunit.org/index.php
22 13
23== Adding Tests == 14== Adding Tests ==
24 15
@@ -32,70 +23,15 @@ that if you are writing tests they end up in a "Tests" sub-directory
32of the directory where the code you are testing resides. 23of the directory where the code you are testing resides.
33 24
34If you have added a new test assembly that hasn't existed before you 25If you have added a new test assembly that hasn't existed before you
35must list it in both ".nant/local.include" and ".nant/bamboo.build" 26must list it in both ".nant/local.include"
36for it to be accessible to Linux users and to the continuous 27for it to be accessible to Linux users and to the continuous
37integration system. 28integration system.
38 29
39
40=== The Gory Details ===
41The following is the original document which started off this
42document. It should probably be better integrated with the new info.
43
44==UPDATE==
45
46The text immediately following is an update to the testing documentation. The
47update is written on 2008.08.30 and is copied from an email to the opensim-dev
48mailing list[1]. The information below the update, beginning with the section
49titled TESTING, is still relevant, so please read this document in its
50entirety.
51
52Mike Mazur
53
54[1] https://lists.berlios.de/pipermail/opensim-dev/2008-August/002695.html
55
56"""
57The tests are contained in certain DLLs. At the time of writing, these DLLs
58have tests in them:
59
60OpenSim.Region.ScriptEngine.Common.Tests.dll
61OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests.dll
62OpenSim.Region.ScriptEngine.Shared.Tests.dll
63OpenSim.Framework.Tests.dll OpenSim.Region.CoreModules.dll
64OpenSim.Region.Physics.OdePlugin.dll[2]
65
66The console command used to run the tests is `nunit-console` (or
67`nunit-console2` on some systems). This command takes a listing of DLLs to
68inspect for tests.
69
70Currently Bamboo's[3] build file (.nant/bamboo.build) lists only those DLLs
71for nunit-console to use. However it would be equally correct to simply pass
72in all DLLs in bin/; those without tests are just skipped.
73
74The nunit-console command generates a file TestResults.txt by default. This is
75an XML file containing a listing of all DLLs inspected, tests executed,
76successes, failures, etc. If nunit-console is passed in all DLLs in bin/, this
77file bloats with lots of entries like this:
78
79 <test-suite name="/home/mike/source/workspace/bin/OpenSim.Grid.Communications.OGS1.dll" success="True" time="0.000" asserts="0">
80 <results />
81 </test-suite>
82 <test-suite name="/home/mike/source/workspace/bin/OpenSim.Region.ClientStack.dll" success="True" time="0.000" asserts="0">
83 <results />
84 </test-suite>
85
86Therefore it makes more sense to me to specify the DLLs when running
87nunit-console.
88
89[2] Note that OpenSim.Region.Physics.OdePlugin.dll is in bin/Physics/ and
90needs to be first copied to bin/ before nunit-console is executed.
91[3] http://opensimulator.org:8085/
92"""
93
94==TESTING ON WINDOWS== 30==TESTING ON WINDOWS==
95 31
96To use nunit testing on opensim code, you have a variety of methods. The 32To use nunit testing on opensim code, you have a variety of methods. The
97easiast methods involve using IDE capabilities to test code. Using 33easiast methods involve using IDE capabilities to test code. Using
98VS2005/2008 I recommend using the testing capabilities of Resarper(commercial) 34VS2005/2008 I recommend using the testing capabilities of Resharper(commercial)
99or TestDriven.Net(free). Both will recognize nunit tests within your 35or TestDriven.Net(free). Both will recognize nunit tests within your
100application and allow you to test them individually, or all at once, etc. You 36application and allow you to test them individually, or all at once, etc. You
101will also be able to step into debug mode into a test through these add-ins 37will also be able to step into debug mode into a test through these add-ins
@@ -133,6 +69,3 @@ Example
133 69
134nunit-console2 OpenSim.Framework.Tests.dll (on linux) 70nunit-console2 OpenSim.Framework.Tests.dll (on linux)
135nunit-console OpenSim.Framework.Tests.dll (on windows) 71nunit-console OpenSim.Framework.Tests.dll (on windows)
136
137For more information on testing contact the autor of this testing readme: Daedius Moskvitch ( daedius @@@@ daedius com)
138
diff --git a/bin/HttpServer_OpenSim.dll b/bin/HttpServer_OpenSim.dll
index d7503a0..95ea5dd 100644
--- a/bin/HttpServer_OpenSim.dll
+++ b/bin/HttpServer_OpenSim.dll
Binary files differ
diff --git a/bin/HttpServer_OpenSim.pdb b/bin/HttpServer_OpenSim.pdb
index 4151588..b6b77f7 100644
--- a/bin/HttpServer_OpenSim.pdb
+++ b/bin/HttpServer_OpenSim.pdb
Binary files differ
diff --git a/bin/MySql.Data.dll b/bin/MySql.Data.dll
index c28c618..992aa56 100644
--- a/bin/MySql.Data.dll
+++ b/bin/MySql.Data.dll
Binary files differ
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index 7245bee..5bac56e 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -306,6 +306,9 @@
306[ODEPhysicsSettings] 306[ODEPhysicsSettings]
307 ;# {mesh_sculpted_prim} {[Startup]physics:OpenDynamicsEngine} {Mesh sculpties so they collide as they look?} {true false} true 307 ;# {mesh_sculpted_prim} {[Startup]physics:OpenDynamicsEngine} {Mesh sculpties so they collide as they look?} {true false} true
308 ;; Do we want to mesh sculpted prim to collide like they look? 308 ;; Do we want to mesh sculpted prim to collide like they look?
309 ;; If you are seeing sculpt texture decode problems
310 ;; (messages such as "Decoded image with unhandled number of components: 0 shortly followed by a physcs exception")
311 ;; then you might want to try setting this to false.
309 ; mesh_sculpted_prim = true 312 ; mesh_sculpted_prim = true
310 313
311 ;# {use_NINJA_physics_joints} {[Startup]physics:OpenDynamicsEngine} {Use jointed (NINJA) physics?} {true false} false 314 ;# {use_NINJA_physics_joints} {[Startup]physics:OpenDynamicsEngine} {Use jointed (NINJA) physics?} {true false} false
diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini
index c7e550b..0337c77 100644
--- a/bin/OpenSimDefaults.ini
+++ b/bin/OpenSimDefaults.ini
@@ -94,6 +94,13 @@
94 ; Warning! Don't use this with regions that have existing content!, This will likely break them 94 ; Warning! Don't use this with regions that have existing content!, This will likely break them
95 CombineContiguousRegions = false 95 CombineContiguousRegions = false
96 96
97 ; Extend the region's draw distance; 255m is the default which includes
98 ; one neighbor on each side of the current region, 767m would go three
99 ; neighbors on each side for a total of 49 regions in view. Warning, unless
100 ; all the regions have the same drawdistance, you will end up with strange
101 ; effects because the agents that get closed may be inconsistent.
102 ; DefaultDrawDistance = 255.0
103
97 ; If you have only one region in an instance, or to avoid the many bugs 104 ; If you have only one region in an instance, or to avoid the many bugs
98 ; that you can trigger in modules by restarting a region, set this to 105 ; that you can trigger in modules by restarting a region, set this to
99 ; true to make the entire instance exit instead of restarting the region. 106 ; true to make the entire instance exit instead of restarting the region.
diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example
index 9adf1ac..f12a143 100644
--- a/bin/Robust.HG.ini.example
+++ b/bin/Robust.HG.ini.example
@@ -72,7 +72,7 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
72 AssetService = "OpenSim.Services.AssetService.dll:AssetService" 72 AssetService = "OpenSim.Services.AssetService.dll:AssetService"
73 73
74 ;; Directory for map tile images of linked regions 74 ;; Directory for map tile images of linked regions
75 ; MapTileDirectory = "./" 75 ; MapTileDirectory = "./maptiles"
76 76
77 ;; Next, we can specify properties of regions, including default and fallback regions 77 ;; Next, we can specify properties of regions, including default and fallback regions
78 ;; The syntax is: Region_<RegionName> = "<flags>" 78 ;; The syntax is: Region_<RegionName> = "<flags>"
diff --git a/bin/assets/TexturesAssetSet/TexturesAssetSet.xml b/bin/assets/TexturesAssetSet/TexturesAssetSet.xml
index 5484ee2..3af9c99 100644
--- a/bin/assets/TexturesAssetSet/TexturesAssetSet.xml
+++ b/bin/assets/TexturesAssetSet/TexturesAssetSet.xml
@@ -413,6 +413,15 @@
413 <Key Name="assetType" Value="0" /> 413 <Key Name="assetType" Value="0" />
414 <Key Name="fileName" Value="default_clear.jp2" /> 414 <Key Name="fileName" Value="default_clear.jp2" />
415 </Section> 415 </Section>
416
417 <!-- 3a367d1c-bef1-6d43-7595-e88c1e3aadb3 is a UUID that viewers assume exists in the asset server -->
418 <!-- See http://opensimulator.org/mantis/bug_view_advanced_page.php?bug_id=4751 for more details -->
419 <Section Name="Default Alpha Layer Texture">
420 <Key Name="assetID" Value="3a367d1c-bef1-6d43-7595-e88c1e3aadb3"/>
421 <Key Name="name" Value="Default Alpha Layer Texture"/>
422 <Key Name="assetType" Value="0" />
423 <Key Name="fileName" Value="default_clear.jp2" />
424 </Section>
416 425
417 <Section Name="Default Avatar"> 426 <Section Name="Default Avatar">
418 <Key Name="assetID" Value="c228d1cf-4b5d-4ba8-84f4-899a0796aa97"/> 427 <Key Name="assetID" Value="c228d1cf-4b5d-4ba8-84f4-899a0796aa97"/>
diff --git a/bin/config-include/GridCommon.ini.example b/bin/config-include/GridCommon.ini.example
index 761e5eb..4dc0e53 100644
--- a/bin/config-include/GridCommon.ini.example
+++ b/bin/config-include/GridCommon.ini.example
@@ -43,7 +43,7 @@
43 ;AllowHypergridMapSearch = true 43 ;AllowHypergridMapSearch = true
44 44
45 ;; Directory for map tile images of linked regions 45 ;; Directory for map tile images of linked regions
46 ; MapTileDirectory = "./" 46 ; MapTileDirectory = "./maptiles"
47 47
48[AvatarService] 48[AvatarService]
49 ; 49 ;
@@ -88,6 +88,10 @@
88 ; accessible from other grids 88 ; accessible from other grids
89 ; 89 ;
90 ProfileServerURI = "http://mygridserver.com:8002/user" 90 ProfileServerURI = "http://mygridserver.com:8002/user"
91 ;; If you want to protect your assets from being copied by foreign visitors
92 ;; uncomment the next line. You may want to do this on sims that have licensed content.
93 ; OutboundPermission = False
94
91 95
92[Modules] 96[Modules]
93 ;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists. 97 ;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists.
diff --git a/bin/config-include/HyperSimianGrid.ini b/bin/config-include/HyperSimianGrid.ini
index 0b01116..89d6be7 100644
--- a/bin/config-include/HyperSimianGrid.ini
+++ b/bin/config-include/HyperSimianGrid.ini
@@ -82,3 +82,14 @@
82 82
83[Profiles] 83[Profiles]
84 Module = "SimianProfiles" 84 Module = "SimianProfiles"
85
86[HGInventoryAccessModule]
87 ;
88 ; === HG ONLY ===
89 ; Change this to your profile server
90 ; accessible from other grids
91 ;
92 ProfileServerURI = "http://mygridserver.com:8002/user"
93 ;; If you want to protect your assets from being copied by foreign visitors
94 ;; uncomment the next line. You may want to do this on sims that have licensed content.
95 ; OutboundPermission = False
diff --git a/bin/config-include/StandaloneCommon.ini.example b/bin/config-include/StandaloneCommon.ini.example
index 4956bc3..816e9a6 100644
--- a/bin/config-include/StandaloneCommon.ini.example
+++ b/bin/config-include/StandaloneCommon.ini.example
@@ -33,6 +33,10 @@
33 33
34[HGInventoryAccessModule] 34[HGInventoryAccessModule]
35 ProfileServerURI = "http://127.0.0.1:9000/profiles" 35 ProfileServerURI = "http://127.0.0.1:9000/profiles"
36 ;; If you want to protect your assets from being copied by foreign visitors
37 ;; uncomment the next line. You may want to do this on sims that have licensed content.
38 ; OutboundPermission = False
39
36 40
37[Modules] 41[Modules]
38 ;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists. 42 ;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists.
@@ -66,7 +70,7 @@
66 ; Check4096 = true 70 ; Check4096 = true
67 71
68 ;; Directory for map tile images of remote regions 72 ;; Directory for map tile images of remote regions
69 ; MapTileDirectory = "./" 73 ; MapTileDirectory = "./maptiles"
70 74
71 ;; Next, we can specify properties of regions, including default and fallback regions 75 ;; Next, we can specify properties of regions, including default and fallback regions
72 ;; The syntax is: Region_<RegioName> = "<flags>" 76 ;; The syntax is: Region_<RegioName> = "<flags>"
diff --git a/bin/libsqlite3.so.0 b/bin/libsqlite3.so.0
new file mode 100755
index 0000000..0512d8a
--- /dev/null
+++ b/bin/libsqlite3.so.0
Binary files differ
diff --git a/bin/libsqlite3.txt b/bin/libsqlite3.txt
new file mode 100644
index 0000000..8ef66bd
--- /dev/null
+++ b/bin/libsqlite3.txt
@@ -0,0 +1 @@
libsqlite version: 3.7.5
diff --git a/bin/nunit.framework.dll b/bin/nunit.framework.dll
index d68d9f2..875e098 100644
--- a/bin/nunit.framework.dll
+++ b/bin/nunit.framework.dll
Binary files differ
diff --git a/bin/sqlite-3.6.21.so b/bin/sqlite-3.6.21.so
deleted file mode 100644
index 2a8f38b..0000000
--- a/bin/sqlite-3.6.21.so
+++ /dev/null
Binary files differ
diff --git a/bin/sqlite3.dll b/bin/sqlite3.dll
index 558a015..f29dc62 100755
--- a/bin/sqlite3.dll
+++ b/bin/sqlite3.dll
Binary files differ
diff --git a/prebuild.xml b/prebuild.xml
index bf6c1cc..fc94e75 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -2959,6 +2959,7 @@
2959 <Match path="Avatar/Inventory/Archiver/Tests" pattern="*.cs" recurse="true"/> 2959 <Match path="Avatar/Inventory/Archiver/Tests" pattern="*.cs" recurse="true"/>
2960 <Match path="World/Archiver/Tests" pattern="*.cs" recurse="true"/> 2960 <Match path="World/Archiver/Tests" pattern="*.cs" recurse="true"/>
2961 <Match buildAction="EmbeddedResource" path="World/Archiver/Tests/Resources" pattern="*"/> 2961 <Match buildAction="EmbeddedResource" path="World/Archiver/Tests/Resources" pattern="*"/>
2962 <Match path="World/Media/Moap/Tests" pattern="*.cs" recurse="true"/>
2962 <Match path="World/Serialiser/Tests" pattern="*.cs" recurse="true"/> 2963 <Match path="World/Serialiser/Tests" pattern="*.cs" recurse="true"/>
2963 <Match path="World/Terrain/Tests" pattern="*.cs" recurse="true"/> 2964 <Match path="World/Terrain/Tests" pattern="*.cs" recurse="true"/>
2964 <Match path="ServiceConnectorsOut/Grid/Tests" pattern="*.cs" recurse="true"/> 2965 <Match path="ServiceConnectorsOut/Grid/Tests" pattern="*.cs" recurse="true"/>